
    Hohm                        U d dl mZ g dZd dlZd dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZ ddlmZmZ ddlmZ er$eeej0                  e   ej2                  f   Zded	<   	 d d
lmZmZ d dZ!d dZ" G d de      Z# G d de#d      Z$ G d de#d      Z% G d de#d      Z&ee	e$   e	e%   e	e&   f   Z'ee'gef   Z(d!dZ)d!dZ* G d de      Z+e)fd"dZ,ded<   edZ-ye)fd#dZ-y# e $ r 	 d dlmZmZ n# e $ r dxZZY nw xY wY w xY w)$    )annotations)

DeviceDictMatchersDataOSDictUserAgentDictload_builtins	load_data	load_json	load_lazyload_lazy_builtins	load_yamlN)TYPE_CHECKINGCallableListLiteralOptionalProtocolTupleType	TypedDictUnioncast   )lazymatchers)MatcherszOptional[Type[object]]
SafeLoader)CSafeLoaderload)r   r   c                 .    ddl m}  t        t        |       S )zLoads the pre-compiled matcher data into eager matchers.

    The matchers data is imported lazily, and cached after imports,
    further imports simply reference the existing datas.

    r   MATCHERS)ua_parser_builtins.matchersr"   r   r   r!   s    m/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/ua_parser/loaders.pyr   r   0   s     5 (##    c                 .    ddl m}  t        t        |       S )zLoads the pre-compiled matcher data into lazy matchers.

    The matchers data is imported lazily, and cached after imports,
    further imports simply reference the existing datas.

    r   r!   )ua_parser_builtins.lazyr"   r   r   r!   s    r$   r   r   >   s     1(##r%   c                      e Zd ZU ded<   y)
_RegexDictstrregexN__name__
__module____qualname____annotations__ r%   r$   r)   r)   L   s    Jr%   r)   c                  @    e Zd ZU ded<   ded<   ded<   ded<   ded<   y)r   r*   family_replacementv1_replacementv2_replacementv3_replacementv4_replacementNr,   r1   r%   r$   r   r   P   s     r%   r   F)totalc                  @    e Zd ZU ded<   ded<   ded<   ded<   ded<   y)r   r*   os_replacementos_v1_replacementos_v2_replacementos_v3_replacementos_v4_replacementNr,   r1   r%   r$   r   r   X   s     r%   r   c                  6    e Zd ZU ded<   ded<   ded<   ded<   y)r   zLiteral['i']
regex_flagr*   device_replacementbrand_replacementmodel_replacementNr,   r1   r%   r$   r   r   `   s    r%   r   c                   | d   D cg c]j  }t        j                  |d   |j                  d      |j                  d      |j                  d      |j                  d      |j                  d            l c}| d   D cg c]j  }t        j                  |d   |j                  d	      |j                  d
      |j                  d      |j                  d      |j                  d            l c}| d   D cg c]Z  }t        j                  |d   |j                  d      |j                  d      |j                  d      |j                  d            \ c}fS c c}w c c}w c c}w )z-Loads the input data set into eager matchers.r   r+   r3   r4   r5   r6   r7   r   r:   r;   r<   r=   r>      r@   rA   rB   rC   )r   UserAgentMatcherget	OSMatcherDeviceMatcherdps     r$   r	   r	   k   s`    qT
	
  %%'
*+&'&'&'&'
	
( qT
	
  '
&')*)*)*)*
	
& qT		
  ""'
l#*+)*)*		
/! !
	

	
		
   A/E A/E 8AE%c                   | d   D cg c]j  }t        j                  |d   |j                  d      |j                  d      |j                  d      |j                  d      |j                  d            l c}| d   D cg c]j  }t        j                  |d   |j                  d	      |j                  d
      |j                  d      |j                  d      |j                  d            l c}| d   D cg c]Z  }t        j                  |d   |j                  d      |j                  d      |j                  d      |j                  d            \ c}fS c c}w c c}w c c}w )z,Loads the input data set into lazy matchers.r   r+   r3   r4   r5   r6   r7   r   r:   r;   r<   r=   r>   rE   r@   rA   rB   rC   )r   rF   rG   rH   rI   rJ   s     r$   r   r      s^    qT
	
  !!'
*+&'&'&'&'
	
( qT
	
  NN'
&')*)*)*)*
	
& qT		
  '
l#*+)*)*		
/! !
	

	
		
rM   c                  "    e Zd Zef	 	 	 	 	 ddZy)
FileLoaderc                     y )Nr1   )selfpathloaders      r$   __call__zFileLoader.__call__   s    r%   NrS   
PathOrFilerT   
DataLoaderreturnr   )r-   r.   r/   r	   rU   r1   r%   r$   rP   rP      s"    5>(2	r%   rP   c                    t        | t        t        j                  f      r*t	        |       5 }t        j                  |      }ddd       nt        j                  |       } |d   |d   |d   f      S # 1 sw Y   xY w)a  Loads JSON data following the ``regexes.yaml`` structure.

    The ``loader`` parameter customises which matcher variant is
    generated, by default :func:`load_data` is used to generate eager
    matchers, :func:`load_lazy` can be used to generate lazy matchers
    instead.

    Nuser_agent_parsers
os_parsersdevice_parsers)
isinstancer*   osPathLikeopenjsonr   )frT   fpregexess       r$   r
   r
      s     !c2;;'(!W 	$iimG	$ 	$ ))A,()L!$%	
 	$ 	$s   A44A=zOptional[FileLoader]r   c                    t        | t        t        j                  f      r&t	        |       5 }t        |t              }ddd       nt        | t              }t        d   |d   |d   f      S # 1 sw Y    xY w)a-  Loads YAML data following the ``regexes.yaml`` structure.

        The ``loader`` parameter customises which matcher variant is
        generated, by default :func:`load_data` is used to generate eager
        matchers, :func:`load_lazy` cab be used to generate lazy matchers
        instead.
        )LoaderNr[   r\   r]   )r^   r*   r_   r`   ra   r   r   r	   )rS   rT   rd   re   s       r$   r   r      s     dS"++./d 6rr*56 6 4
3G,-%()
 	
6 6s   A//A8)rY   r   )rK   r   rY   r   )rc   rW   rT   rX   rY   r   rV   ).
__future__r   __all__iorb   r_   typingr   r   r   r   r   r   r   r   r   r   r    r   r   corer   r*   r`   IOBaserW   r0   yamlr   r   r   ImportErrorr   r   r)   r   r   r   r   rX   r	   r   rP   r
   r   r1   r%   r$   <module>rq      sL   " 
  	     sBKK,bii78J&&!4$	$ Je Zu 5  T-($v,Z8HHI|nh./
#L#L  3< 0   <I :C 
c  !!)) !  z!!s6   'C, ,D2C;:D;	DDDDD