
    !<i                         U d Z ddlZddlZddlZddlZddlmZ dZg dZdej	        fdZ
ej        dk    rddlmZ dS e
Zeg ej	        f         ed	<   dS )
z
UUID v7 polyfill for Python < 3.14.

On Python 3.14+, we use the stdlib implementation. On older versions,
we use a simplified vendored implementation.

The vendored code can be removed once Python 3.13 support is dropped.
    N)Callable)uuid7)r   r   r   r   returnc                  d   t          j                    } d}t          | |          \  }}t          |dz  |          \  }}t          |dz  |          \  }}|dz  }|t          d         k    rI|t          d         k    r8|t          d         k    r't          d         d	k     rt          dxx         dz  cc<   n|||dft          d
d
<   dt          d         z  }t	          j        d          }	t                              |	d          }
|dz  |dz  z   |dz  z   |dz  z   |
z   }t          j	        |          S )a  
    Generate a UUID v7 with embedded timestamp and sequence counter.

    This implementation matches stdlib behavior by using a sequence counter
    to guarantee monotonic ordering when multiple UUIDs are generated within
    the same timestamp tick.

    The 128 bits in the UUID are allocated as follows:
    - 36 bits of whole seconds
    - 24 bits of fractional seconds, giving approx 50ns resolution
    - 14 bits of sequence counter (increments when time unchanged)
    - 48 bits of randomness
    plus, at locations defined by RFC4122, 4 bits for the
    uuid version (0b0111) and 2 bits for the uuid variant (0b10).

             0                   1                   2                   3
             0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    t1      |                 unixts (secs since epoch)                     |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    t2/t3   |unixts |  frac secs (12 bits)  |  ver  |  frac secs (12 bits)  |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    t4/rand |var|       seq (14 bits)       |          rand (16 bits)       |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    rand    |                          rand (32 bits)                       |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    l     Ys       i p  r            i?  Ni      big`   P   @   0   )int)
timetime_nsdivmod_lastosurandomr   
from_bytesuuidUUID)nssixteen_secst1rest1t2rest2t3_t4randruuid_ints               /Users/kimhansen/Desktop/03 Workspace/ceo-agents/chl-effectiveness/mcp-servers/whoop/.venv/lib/python3.11/site-packages/docket/_uuid7.py_vendored_uuid7r)      s1   : 
B "Lr<((IBu{L11IB5B;--EB'MB
 
U1X~~"a..R58^^ 8f!HHHMHHHB?aaa
U1X	B :a==D 	tU##AbR2X&"(3rRx@1DH9""""    )r      r   )__doc__r   sysr   r   typingr   __all__r   r   r)   version_infor   __annotations__ r*   r(   <module>r3      s      
			 



        
 	@# @# @# @# @#H w%4E8B	M"44444r*   