+
    }ig2                       a  R t!0 t ^ RIHtHt ^ RIHt ^ RIHtHtH	t	 ^ RI
Ht ^ RIHtHt ^ RIHt ^ RIHt  ^ RItR	t]! ]4      P0                  R,          t] ^ k ] ! R R4      4       t] ! R R4      4       t] ! R R4      4       t] ! R R4      4       t] ! R R4      4       t ! R R4      tR t R#   ] d
    ^ RItR
t Li ; i)    )asdict	dataclass)Path)DictListOptional)get_fingerprint_network)BayesianNetworkget_possible_values)HeaderGenerator)get_user_agentNTFdatac                   ,   a  ] tR t^t o V 3R ltRtV tR# )ScreenFingerprintc                   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[;R	&   S[ ;R
&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[;R&   # )   availHeight
availWidthavailTop	availLeft
colorDepthheight
pixelDepthwidthdevicePixelRatiopageXOffsetpageYOffsetinnerHeightouterHeight
outerWidth
innerWidthscreenXclientWidthclientHeighthasHDR)intfloatbool)format__classdict__s   "u/Users/ahmad/.openclaw/workspace/my-crawler/.venv/lib/python3.14/site-packages/browserforge/fingerprints/generator.py__annotate__ScreenFingerprint.__annotate__   s       O  M	 
 N  O  K  O  J            O   O! " L# $ % & ' ( L)      N__name__
__module____qualname____firstlineno____annotate_func____static_attributes____classdictcell__r*   s   @r+   r   r            r.   r   c                   ,   a  ] tR t^.t o V 3R ltRtV tR# )NavigatorFingerprintc                Z  < V ^8  d   Qh/ S[ ;R&   S[S[ S[ 3,          ;R&   S[S[ ,          ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R	&   S[S[ ,          ;R
&   S[ ;R&   S[S[,          ;R&   S[;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[;R&   S[S[ S[ 3,          ;R&   # )r   	userAgentuserAgentData
doNotTrackappCodeNameappName
appVersionoscpu	webdriverlanguage	languagesplatformdeviceMemoryhardwareConcurrencyproduct
productSubvendor	vendorSubmaxTouchPointsextraProperties)strr   r   r   r&   )r)   r*   s   "r+   r,   !NavigatorFingerprint.__annotate__.   s    N  S>!  	 
   L  O  J  N  M  Cy  M  3-    L   O! " K# $ N% & ' ( #s(^#) r.   r/   Nr0   r8   s   @r+   r;   r;   .   r9   r.   r;   c                   ,   a  ] tR t^Et o V 3R ltRtV tR# )	VideoCardc                2   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   # )r   rendererrL   rP   )r)   r*   s   "r+   r,   VideoCard.__annotate__E   s     M  K r.   r/   Nr0   r8   s   @r+   rS   rS   E   r9   r.   rS   c                   B   a  ] tR t^Kt o RtV 3R lR ltV 3R ltRtV tR# )Fingerprintz(Output data of the fingerprint generatorc                    < V ^8  d   QhRS[ /# r   returnrV   )r)   r*   s   "r+   r,   Fingerprint.__annotate__\   s     ( (s (r.   c                    \         '       d%   \        P                  ! V 4      P                  4       # \        P                  ! \	        V 4      4      # )z'
Dumps the dataclass as a JSON string.
)
USE_ORJSONjsondumpsdecoder   selfs   &r+   ra   Fingerprint.dumps\   s6     :::d#**,, zz&,''r.   c                x  < V ^8  d   Qh/ S[ ;R&   S[;R&   S[S[S[3,          ;R&   S[S[S[3,          ;R&   S[S[S[3,          ;R&   S[S[S[3,          ;R&   S[S[S[S[3,          ,          ;R&   S[S[,          ;R&   S[S[,          ;R	&   S[S[,          ;R
&   S[S[,          ;R&   S[S[,          ;R&   # )r   screen	navigatorheadersvideoCodecsaudioCodecspluginsDatabattery	videoCardmultimediaDevicesfonts
mockWebRTCslim)r   r;   r   rP   r   rS   r   r(   )r)   r*   s   "r+   r,   r]   K   s      	 
 $#  #s(^  c3h  c3h  c3h  d38n%%  	""  Cy   9    4. r.   r/   N)	r1   r2   r3   r4   __doc__ra   r5   r6   r7   r8   s   @r+   rY   rY   K   s     2( (#  r.   rY   c                   X   a  ] tR t^gt o RtRtRtRtRtR t	V 3R lR lt
V 3R ltRtV tR# )Screenz=Constrains the screen dimensions of the generated fingerprintNc                    R V P                   V P                  39  d   V P                   V P                  8  g9   R V P                  V P                  39  d)   V P                  V P                  8  d   \	        R4      hR # R # )NzHInvalid screen constraints: min values cannot be greater than max values)	min_width	max_width
min_height
max_height
ValueErrorrc   s   &r+   __post_init__Screen.__post_init__p   sf    88/DOOT__==$//1Z  2 >r.   c                    < V ^8  d   QhRS[ /# r[   )r(   )r)   r*   s   "r+   r,   Screen.__annotate__{   s     J J Jr.   c                    \         ;QJ d4    R V P                  P                  4        4       F  '       g   K   R# 	  R# ! R V P                  P                  4        4       4      # )z*
Returns true if any constraints were set
c              3   (   "   T F  qR Jx  K
  	  R # 5iNr/   ).0values   & r+   	<genexpr> Screen.is_set.<locals>.<genexpr>   s     I2H$2Hs   TF)any__dict__valuesrc   s   &r+   is_setScreen.is_set{   sG     sI$--2F2F2HIssIsIsI$--2F2F2HIIIr.   c                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r   rw   rx   ry   rz   )r   r&   )r)   r*   s   "r+   r,   r   g   sI      }#	 
 }#  $  $ r.   r/   )r1   r2   r3   r4   rs   rw   rx   ry   rz   r|   r   r5   r6   r7   r8   s   @r+   ru   ru   g   s4     G#I#I $J $J	J J)  r.   ru   c                      a  ] tR t^t o Rt]! ]! 4       4      tRV 3R lR lltRRRRRRRR/V 3R	 lR
 llt	V 3R lR lt
]V 3R lR l4       t]V 3R lR l4       tRtV tR# )FingerprintGeneratorz(Generates realistic browser fingerprintsNc                B   < V ^8  d   QhRS[ S[,          RS[RS[RS[/# )r   rg   strictmock_webrtcrr   )r   ru   r(   )r)   r*   s   "r+   r,   !FingerprintGenerator.__annotate__   s8         	
 r.   c                V    \        R/ VB V n        Wn        W n        W0n        W@n        R# )a+  
Initializes the FingerprintGenerator with the given options.

Parameters:
    screen (Screen, optional): Screen constraints for the generated fingerprint.
    strict (bool, optional): Whether to raise an exception if the constraints are too strict. Default is False.
    mock_webrtc (bool, optional): Whether to mock WebRTC when injecting the fingerprint. Default is False.
    slim (bool, optional): Disables performance-heavy evasions when injecting the fingerprint. Default is False.
    **header_kwargs: Header generation options for HeaderGenerator
Nr/   )r   header_generatorrg   r   r   rr   )rd   rg   r   r   rr   header_kwargss   &&&&&,r+   __init__FingerprintGenerator.__init__   s,    $ 2A1Q=1Q )/"!,	r.   rg   r   r   rr   c          
      x   < V ^8  d   QhRS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[/# )r   rg   r   r   rr   r\   )r   ru   r(   rY   )r)   r*   s   "r+   r,   r      sW     R
 R
  R
 	R

 d^R
 tnR
 
R
r.   c          	        / pVf   / p\        WP                  4      p\        W P                  4      pV P                  W!VR7      pV'       d   VR,          VR&   V P                  P
                  ! R/ VB p\        V4      p	V	f   \        R4      h V P                  P                  / VCRV	3/C4      p
V
e   MV'       d   \        R4      h/ pK?  \        V
P                  4       4       F{  pW,          R8X  d   RW&   \        W,          \        4      '       g   K2  W,          P                  R4      '       g   KQ  \        P                   ! W,          \#        R4      R 4      W&   K}  	  VP%                  R	R
4      pVP'                  R4       Uu. uF  qP'                  R^4      ^ ,          NK  	  ppWR&   V P)                  V
V\        W0P*                  4      \        W@P,                  4      4      # u upi )a  
Generates a fingerprint and a matching set of ordered headers using a combination of the default options
specified in the constructor and their possible overrides provided here.

Parameters:
    screen (Screen, optional): Screen constraints for the generated fingerprint.
    strict (bool, optional): Whether to raise an exception if the constraints are too strict.
    mock_webrtc (bool, optional): Whether to mock WebRTC when injecting the fingerprint. Default is False.
    slim (bool, optional): Disables performance-heavy evasions when injecting the fingerprint. Default is False.
    **header_kwargs: Additional header generation options for HeaderGenerator.generate
N)r   rg   filtered_valuesr=   
user_agentz/Failed to find User-Agent in generated responsez^Cannot generate headers. User-Agent may be invalid, or screen constraints are too restrictive.z*MISSING_VALUE**STRINGIFIED*zAccept-Language ,;rF   r/   )_firstrg   r   partial_cspr   generater   r{   fingerprint_generator_network(generate_consistent_sample_when_possiblelistkeys
isinstancerP   
startswithr`   loadslengetsplit_transform_fingerprintr   rr   )rd   rg   r   r   rr   r   r   r   ri   r   fingerprint	attributeaccept_language_header_valuelocaleaccepted_languagess   &$$$$,         r+   r   FingerprintGenerator.generate   s   ( +- M ,,&&/ ' 
 *5k*BM,'''00A=A#G,
NOO 22[[CCj]C 
 & t 
 !O k..01I%)::)-&+0#66;;Q;\;\< < *.K4J3K_Ka4b)c& 2 (/{{3Db'I$2N2T2TUX2Y
2YLLa ##2Y 	 
 $6K **; 0 014#	
 	

s   !G-c          	      b   < V ^8  d   QhRS[ S[,          RS[ S[,          RS[RS[ S[,          /# )r   r   rg   r   r\   )r   r(   ru   r   )r)   r*   s   "r+   r,   r      s:        tn .6v.> QU 	$ r.   c                l   V'       d   VP                  4       '       g   R# V P                  P                  R,          P                   Uu. uF  pV P	                  WB4      '       g   K  VNK   	  upVR&    \        V P                  V4      # u upi   \         d   pT'       d   ThTR  Rp?R# Rp?ii ; i)a  
Generates partial content security policy (CSP) based on the provided options and filtered values.

Parameters:
    strict (Optional[bool): Whether to raise an exception if the constraints are too strict.
    screen (Optional[Screen]): Screen for generating the partial CSP.
    filtered_values (Dict): Filtered values used for generating the partial CSP.

Returns:
    Dict: Partial CSP values.
Nrg   )r   r   nodes_by_namepossible_values_is_screen_within_constraintsr   	Exception)rd   r   rg   r   screen_stringes   &&&&  r+   r    FingerprintGenerator.partial_csp   s     6==?? "&!C!C!Q!Q"o"%
" 11-H	 M"%
!	*&t'I'I?[[%
  	*)		*s$   
B(B5B B3B..B3c                ,   < V ^8  d   QhRS[ RS[RS[/# )r   r   screen_optionsr\   )rP   ru   r(   )r)   r*   s   "r+   r,   r     s#      S & UY r.   c                    \         P                  ! V \        R4      R 4      pVP                  RR4      VP                  ;'       g    ^ 8  ;'       d    VP                  RR4      VP
                  ;'       g    ^ 8  ;'       d[    VP                  R^ 4      VP                  ;'       g    R8*  ;'       d*    VP                  R^ 4      VP                  ;'       g    R8*  #   \        \        3 d     R# i ; i)a)  
Checks if the given screen dimensions are within the specified constraints.

Parameters:
    screen_string (str): Stringified screen dimensions.
    screen_options (Screen): Screen constraint options.

Returns:
    bool: True if the screen dimensions are within the constraints, False otherwise.
r   Nr   r   g     j@F)
r`   r   r   r   rw   ry   rx   rz   r{   	TypeError)r   r   rg   s   && r+   r   2FingerprintGenerator._is_screen_within_constraints  s    	ZZc/.B.D EFF 

7B'N,D,D,I,IJ R RJJx,1J1J1O1OaPR R JJw*~/G/G/N/N3OR R JJx+0I0I0P0PSQ I& 		s<   AC  C  $C  9C  $C  *C  6$C  C   C54C5c          
      8   < V ^8  d   QhRS[ RS[ RS[RS[RS[/# )r   r   ri   r   rr   r\   )r   r(   rY   )r)   r*   s   "r+   r,   r   2  s5     :
 :
:
$(:
7;:
CG:
	:
r.   c                   R Uu/ uF  pW@V,          bK  	  ppVR,          ^ ,          VR&   V P                  R^ 4      VR&   \        \        R/ V R,          B \        R/ VB TV R,          V R,          V R,          V R,          V P                  R	4      '       d   \	        R/ V R	,          B MR
V R,          V R,          VVR7      # u upi )a  
Transforms fingerprint into a final dataclass instance.

Parameters:
    fingerprint (Dict): Fingerprint to be transformed.
    headers (Dict): Generated headers.
    mock_webrtc (bool): Whether to mock WebRTC when injecting the fingerprint.
    slim (bool): Disables performance-heavy evasions when injecting the fingerprint.

Returns:
    Fingerprint: Transformed fingerprint as a Fingerprint dataclass instance.
rF   rE   rN   rg   rj   rk   rl   rm   rn   Nro   rp   )rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   )r=   r>   r?   r@   rA   rB   rC   rD   rG   rH   rJ   rK   rL   rM   rO   rI   rF   r/   )r   rY   r   r;   rS   )r   ri   r   rr   knavigator_kwargss   &&&&  r+   r   +FingerprintGenerator._transform_fingerprint1  s    &
 1~ 	 
0 (8'DQ'G$-8__=Mq-Q)*$={8'<=*>-=>#M2#M2#M2	*9D9U9U	5K45[_)*=>g&"
 	
7
s   C)r   r   rg   rr   r   )NFFF)r1   r2   r3   r4   rs   r
   r	   r   r   r   r   staticmethodr   r   r6   r7   r8   s   @r+   r   r      s     2$34K4M$N! 4R
 $(R
 "&	R

 '+R
  $R
 R
h   D  2 :
 :
r.   r   c                 (    \        R V  4       R4      # )z>
Simple function that returns the first non-None value passed
c              3   0   "   T F  qf   K  Vx  K  	  R # 5ir   r/   )r   vs   & r+   r   _first.<locals>.<genexpr>s  s     4FqFs   
N)next)r   s   *r+   r   r   o  s     4F4d;;r.   c                @    V ^8  d   Qh/ ^ \         9   d
   \        ;R&   # )r   DATA_DIR)__conditional_annotations__r   )r)   s   "r+   r,   r,      s     ) )& 0 /$ /' *r.   )"r   dataclassesr   r   pathlibr   typingr   r   r   apify_fingerprint_datapointsr	   browserforge.bayesian_networkr
   r   browserforge.headersr   browserforge.headers.utilsr   orjsonr`   r_   ImportError__file__parentr   r   r;   rS   rY   ru   r   r   r,   )r   s   @r+   <module>r      s    ) )  ' ' @ N 0 5J h&&/ /   , $ $ $,   
 ( ( (6 J J J4j
 j
Z<A  Js   B7 7CC