Ë
    V¼Sfþ´  ã                   ól  — U d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlZddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* ejV                  e,d<   e-e,d<   dZ.dZ/dZ0dZ1dZ2dZ3ejh                  jj                  jl                  Z7ejp                  jr                  ejt                  ejp                  jv                  ejx                  iZ= G d„ de>«      Z?dZd„Z@dej:                  j‚                  fd „ZBde-fd!„ZCd"d#de(d$   fd%„ZD G d&„ d'«      ZEde"fd(„ZFde*deGeHeIeJej                  eKeLe-e?ef   fd)„ZMde*e-ef   fd*„ZNdeKfd+„ZO ejV                  d,«      ZP	 d[d-ede$e)e"e"f   e"df   fd.„ZQdZd/„ZRde"fd0„ZS G d1„ d2e>«      ZTde&ej<                  jª                     fd3„ZVde&ej<                  jª                     fd4„ZW G d5„ d6eT«      ZXde&ej<                  jª                     fd7„ZY G d8„ d9eT«      ZZde&ej<                  jª                     fd:„Z[dej<                  jª                  fd;„Z\ G d<„ d=e]«      Z^d\de*eLdf   fd>„Z_d?eKde&e)eKeKf      fd@„Z` G dA„ dBe>«      Za G dC„ dDea«      Zb G dE„ dFea«      Zcde-fdG„Zd	 d]dHe(e*eej                  f      de fdI„ZedJe*e ej                  f   dKe*e ej                  f   deHfdL„ZfdMe*eKeLf   dNdOddPfdQ„ZgdMe*eKeLf   de$e#ddf   fdR„ZhddSœdTe(eK   de$dU   fdV„ZidWeKde(dX   fdY„Zjy)^z<Common helpers shared across Google Cloud Firestore modules.é    N)ÚDatetimeWithNanoseconds)Úgapic_v1)Ú
struct_pb2)Ú
latlng_pb2)Ú
exceptions)Ú_datetime_to_pb_timestamp)ÚVector)ÚDocumentTransform)Ú
transforms)Útypes)Ú	FieldPath)Úparse_field_path)Úcommon)Údocument)Úwrite)Ú	Timestamp)	ÚAnyÚDictÚ	GeneratorÚIteratorÚListÚNoReturnÚOptionalÚTupleÚUnionÚ
_EmptyDictÚ_GRPC_ERROR_MAPPINGz<A path element must be a string. Received {}, which is a {}.ú/z<Transaction not in progress, cannot be used in API requests.z,Attempted read after write in a transaction.z’Reference value {!r} in unexpected format, expected to be of the form ``projects/{{project}}/databases/{{database}}/documents/{{document_path}}``.zLDocument {!r} does not correspond to the same database ({!r}) as the client.c                   óD   — e Zd ZdZdd„Zdej                  fd„Zd„ Zd„ Z	y)	ÚGeoPointz—Simple container for a geo point value.

    Args:
        latitude (float): Latitude of a point.
        longitude (float): Longitude of a point.
    ÚreturnNc                 ó    — || _         || _        y ©N©ÚlatitudeÚ	longitude)Úselfr%   r&   s      úaC:\Users\user\Documents\project_loop\venv\Lib\site-packages\google/cloud/firestore_v1/_helpers.pyÚ__init__zGeoPoint.__init__R   s   € Ø ˆŒØ"ˆ�ó    c                 óX   — t        j                  | j                  | j                  ¬«      S )zŽConvert the current object to protobuf.

        Returns:
            google.type.latlng_pb2.LatLng: The current point as a protobuf.
        r$   )r   ÚLatLngr%   r&   ©r'   s    r(   Úto_protobufzGeoPoint.to_protobufV   s   € ô × Ñ ¨$¯-©-À4Ç>Á>ÔRÐRr*   c                 ó–   — t        |t        «      st        S | j                  |j                  k(  xr | j                  |j                  k(  S )zûCompare two geo points for equality.

        Returns:
            Union[bool, NotImplemented]: :data:`True` if the points compare
            equal, else :data:`False`. (Or :data:`NotImplemented` if
            ``other`` is not a geo point.)
        )Ú
isinstancer    ÚNotImplementedr%   r&   ©r'   Úothers     r(   Ú__eq__zGeoPoint.__eq__^   s9   € ô ˜%¤Ô*Ü!Ð!à�}‰} §¡Ñ.ÒT°4·>±>ÀUÇ_Á_Ñ3TÐTr*   c                 óF   — | j                  |«      }|t        u rt        S | S )zýCompare two geo points for inequality.

        Returns:
            Union[bool, NotImplemented]: :data:`False` if the points compare
            equal, else :data:`True`. (Or :data:`NotImplemented` if
            ``other`` is not a geo point.)
        )r4   r1   )r'   r3   Úequality_vals      r(   Ú__ne__zGeoPoint.__ne__k   s)   € ð —{‘{ 5Ó)ˆØœ>Ñ)Ü!Ð!à#Ð#Ð#r*   ©r!   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r)   r   r,   r.   r4   r7   © r*   r(   r    r    J   s+   „ ñó#ðS˜Z×.Ñ.ó SòUó$r*   r    r!   c                 ó  — t        | «      }|dk(  rt        d«      ‚|r|dz  dk(  rt        d«      ‚|dz  dk(  rt        d«      ‚| D ]<  }t        |t        «      rŒt        j                  |t        |«      «      }t        |«      ‚ y)aR  Verifies that a ``path`` has the correct form.

    Checks that all of the elements in ``path`` are strings.

    Args:
        path (Tuple[str, ...]): The components in a collection or
            document path.
        is_collection (bool): Indicates if the ``path`` represents
            a document or a collection.

    Raises:
        ValueError: if

            * the ``path`` is empty
            * ``is_collection=True`` and there are an even number of elements
            * ``is_collection=False`` and there are an odd number of elements
            * an element is not a string
    r   z+Document or collection path cannot be emptyé   z5A collection must have an odd number of path elementsé   z4A document must have an even number of path elementsN)ÚlenÚ
ValueErrorr0   ÚstrÚBAD_PATH_TEMPLATEÚformatÚtype)ÚpathÚis_collectionÚnum_elementsÚelementÚmsgs        r(   Úverify_pathrL   z   s‘   € ô& �t“9€LØ�qÒÜÐFÓGÐGáØ˜!Ñ˜qÒ ÜÐTÓUÐUð ˜!Ñ˜qÒ ÜÐSÓTÐTàò "ˆÜ˜'¤3Õ'Ü#×*Ñ*¨7´D¸³MÓBˆCÜ˜S“/Ð!ñ"r*   c                 ó   — | €$t        j                  t        j                  ¬«      S t	        | t
        «      rt        j                  | ¬«      S t	        | t        «      rt        j                  | ¬«      S t	        | t        «      rt        j                  | ¬«      S t	        | t        «      r$t        j                  | j                  «       ¬«      S t	        | t        j                  «      rt        j                  t        | «      ¬«      S t	        | t        «      rt        j                  | ¬«      S t	        | t        «      rt        j                  | ¬«      S t        | d	d«      }|�t        j                  |¬
«      S t	        | t        «      r$t        j                  | j!                  «       ¬«      S t	        | t"        t$        t&        t(        f«      r>t%        d„ | D «       «      }t        j*                  |¬«      }t        j                  |¬«      S t	        | t,        «      rt/        | j1                  «       «      S t	        | t2        «      r7t5        | «      }t        j6                  |¬«      }t        j                  |¬«      S t9        d| dt;        | «      «      ‚)a  Converts a native Python value into a Firestore protobuf ``Value``.

    Args:
        value (Union[NoneType, bool, int, float, datetime.datetime,             str, bytes, dict, ~google.cloud.Firestore.GeoPoint,             ~google.cloud.firestore_v1.vector.Vector]): A native
            Python value to convert to a protobuf field.

    Returns:
        ~google.cloud.firestore_v1.types.Value: A
        value encoded as a Firestore protobuf.

    Raises:
        TypeError: If the ``value`` is not one of the accepted types.
    N)Ú
null_value)Úboolean_value)Úinteger_value)Údouble_value)Útimestamp_value)Ústring_value)Úbytes_valueÚ_document_path)Úreference_value)Úgeo_point_valuec              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr#   )Úencode_value)Ú.0rJ   s     r(   ú	<genexpr>zencode_value.<locals>.<genexpr>Ò   s   è ø€ ÒF°Wœ<¨×0ÑFùs   ‚©Úvalues)Úarray_value)Úfields)Ú	map_valuez#Cannot convert to a Firestore ValuezInvalid type)r   ÚValuer   Ú
NULL_VALUEr0   ÚboolÚintÚfloatr   Útimestamp_pbÚdatetimer   rC   ÚbytesÚgetattrr    r.   ÚlistÚtupleÚsetÚ	frozensetÚ
ArrayValuer	   rY   Úto_map_valueÚdictÚencode_dictÚMapValueÚ	TypeErrorrF   )ÚvalueÚdocument_pathÚ
value_listÚvalue_pbÚ
value_dicts        r(   rY   rY   Ÿ   sÚ  € ð  €}Ü�~‰~¬×)>Ñ)>Ô?Ð?ô �%œÔÜ�~‰~¨EÔ2Ð2ä�%œÔÜ�~‰~¨EÔ2Ð2ä�%œÔÜ�~‰~¨5Ô1Ð1ä�%Ô0Ô1Ü�~‰~¨e×.@Ñ.@Ó.BÔCÐCä�%œ×*Ñ*Ô+Ü�~‰~Ô.GÈÓ.NÔOÐOä�%œÔÜ�~‰~¨5Ô1Ð1ä�%œÔÜ�~‰~¨%Ô0Ð0ô ˜EÐ#3°TÓ:€MØÐ Ü�~‰~¨mÔ<Ð<ä�%œÔ"Ü�~‰~¨e×.?Ñ.?Ó.AÔBÐBä�%œ$¤¤s¬IÐ6Ô7ÜÑFÀÔFÓFˆ
Ü×&Ñ&¨jÔ9ˆÜ�~‰~¨(Ô3Ð3ä�%œÔ Ü˜E×.Ñ.Ó0Ó1Ð1ä�%œÔÜ  Ó'ˆ
Ü×$Ñ$¨JÔ7ˆÜ�~‰~¨Ô1Ð1ä
Ø-¨u°nÄdÈ5Ãkóð r*   c                 óh   — | j                  «       D ��ci c]  \  }}|t        |«      “Œ c}}S c c}}w )a*  Encode a dictionary into protobuf ``Value``-s.

    Args:
        values_dict (dict): The dictionary to encode as protobuf fields.

    Returns:
        Dict[str, ~google.cloud.firestore_v1.types.Value]: A
        dictionary of string keys and ``Value`` protobufs as dictionary
        values.
    )ÚitemsrY   )Úvalues_dictÚkeyrt   s      r(   rq   rq   ã   s0   € ð 8C×7HÑ7HÓ7J×K©¨¨eˆC”˜eÓ$Ñ$ÓKÐKùÓKs   ”.Úsnapshotz8google.cloud.firestore_v1.base_document.DocumentSnapshotz(google.cloud.firestore_v1.types.Documentc                 ó¶   — ddl m} | j                  sy  || j                  j                  t        | j                  «      | j                  | j                  ¬«      S )Nr   )ÚDocument)Únamer_   Úcreate_timeÚupdate_time)	Úgoogle.cloud.firestore_v1.typesr   ÚexistsÚ	referencerU   rq   Ú_datar�   r‚   )r}   r   s     r(   Údocument_snapshot_to_protobufr‡   ñ   sI   € Ý8à�?Š?ØáØ×Ñ×.Ñ.Ü˜8Ÿ>™>Ó*Ø×(Ñ(Ø×(Ñ(ô	ð r*   c                   óH   — e Zd ZdZdefd„Zedefd„«       Zedefd„«       Zy)ÚDocumentReferenceValuea  DocumentReference path container with accessors for each relevant chunk.

    Usage:
        doc_ref_val = DocumentReferenceValue(
            'projects/my-proj/databases/(default)/documents/my-col/my-doc',
        )
        assert doc_ref_val.project_name == 'my-proj'
        assert doc_ref_val.collection_name == 'my-col'
        assert doc_ref_val.document_id == 'my-doc'
        assert doc_ref_val.database_name == '(default)'

    Raises:
        ValueError: If the supplied value cannot satisfy a complete path.
    rV   c                 ó  — || _         |j                  t        «      }t        |«      dk  r t        j                  |«      }t        |«      ‚|d   | _        |d   | _        |d   | _	        dj                  |dd  «      | _        y )Né   r@   é   é   r   é   )Ú_reference_valueÚsplitÚDOCUMENT_PATH_DELIMITERrA   ÚBAD_REFERENCE_ERRORrE   rB   Úproject_nameÚcollection_nameÚdatabase_nameÚjoinÚdocument_id)r'   rV   ÚpartsrK   s       r(   r)   zDocumentReferenceValue.__init__  s}   € Ø /ˆÔð  ×%Ñ%Ô&=Ó>ˆÜˆu‹:˜Š>Ü%×,Ñ,¨_Ó=ˆCÜ˜S“/Ð!à! !™HˆÔØ$ Q™xˆÔØ" 1™XˆÔØŸ8™8 E¨!¨" IÓ.ˆÕr*   r!   c                 óP   — dj                  | j                  | j                  g«      S )zSComputed property for a DocumentReference's collection_name and
        document Idr   )r–   r”   r—   r-   s    r(   Úfull_keyzDocumentReferenceValue.full_key  s$   € ð �x‰x˜×-Ñ-¨t×/?Ñ/?Ð@ÓAÐAr*   c           	      óž   — | j                   xs@ dj                  d| j                  d| j                  d| j                  | j
                  g«      S )Nr   ÚprojectsÚ	databasesÚ	documents)r�   r–   r“   r•   r”   r—   r-   s    r(   Ú	full_pathz DocumentReferenceValue.full_path$  sR   € à×$Ñ$ò 

¨¯©àØ×!Ñ!ØØ×"Ñ"ØØ×$Ñ$Ø× Ñ ðó
)
ð 
	
r*   N)	r9   r:   r;   r<   rC   r)   Úpropertyrš   rŸ   r=   r*   r(   r‰   r‰   ÿ   sL   „ ñð/¨ó /ð ðB˜#ò Bó ðBð
 ð
˜3ò 
ó ñ
r*   r‰   c                 óÒ   — ddl m} t        | «      }|j                  |j                  «      }|j
                  | k7  r+t        j                  | |j                  «      }t        |«      ‚|S )a°  Convert a reference value string to a document.

    Args:
        reference_value (str): A document reference value.
        client (:class:`~google.cloud.firestore_v1.client.Client`):
            A client that has a document factory.

    Returns:
        :class:`~google.cloud.firestore_v1.document.DocumentReference`:
            The document corresponding to ``reference_value``.

    Raises:
        ValueError: If the ``reference_value`` is not of the expected
            format: ``projects/{project}/databases/{database}/documents/...``.
        ValueError: If the ``reference_value`` does not come from the same
            project / database combination as the ``client``.
    r   )ÚBaseDocumentReference)
Ú'google.cloud.firestore_v1.base_documentr¢   r‰   r   rš   rU   ÚWRONG_APP_REFERENCErE   Ú_database_stringrB   )rV   Úclientr¢   Údoc_ref_valuer   rK   s         r(   Úreference_value_to_documentr¨   3  s[   € õ$ Nä*¨?Ó;€Mà&,§o¡o°m×6LÑ6LÓ&M€HØ×Ñ /Ò1Ü!×(Ñ(¨¸&×:QÑ:QÓRˆÜ˜‹oÐà€Or*   c                 ó¶  — t        | d| «      }|j                  d«      }|dk(  ry|dk(  r|j                  S |dk(  r|j                  S |dk(  r|j                  S |dk(  rt        j                  |j                  «      S |d	k(  r|j                  S |d
k(  r|j                  S |dk(  rt        |j                  |«      S |dk(  r4t        |j                  j                  |j                  j                  «      S |dk(  r.|j                   j"                  D �cg c]  }t%        ||«      ‘Œ c}S |dk(  r t'        |j(                  j*                  |«      S t-        d|«      ‚c c}w )a™  Converts a Firestore protobuf ``Value`` to a native Python value.

    Args:
        value (google.cloud.firestore_v1.types.Value): A
            Firestore protobuf to be decoded / parsed / converted.
        client (:class:`~google.cloud.firestore_v1.client.Client`):
            A client that has a document factory.

    Returns:
        Union[NoneType, bool, int, float, datetime.datetime,             str, bytes, dict, ~google.cloud.Firestore.GeoPoint]: A native
        Python value converted from the ``value``.

    Raises:
        NotImplementedError: If the ``value_type`` is ``reference_value``.
        ValueError: If the ``value_type`` is unknown.
    Ú_pbÚ
value_typerN   NrO   rP   rQ   rR   rS   rT   rV   rW   r^   r`   zUnknown ``value_type``)ri   Ú
WhichOneofrO   rP   rQ   r   Úfrom_timestamp_pbrR   rS   rT   r¨   rV   r    rW   r%   r&   r^   r]   Údecode_valueÚdecode_dictr`   r_   rB   )rt   r¦   rw   r«   rJ   s        r(   r®   r®   Q  sk  € ô, �u˜e UÓ+€HØ×$Ñ$ \Ó2€Jà�\Ò!ØØ	�Ò	&Ø×%Ñ%Ð%Ø	�Ò	&Ø×%Ñ%Ð%Ø	�~Ò	%Ø×$Ñ$Ð$Ø	Ð(Ò	(Ü&×8Ñ8¸×9QÑ9QÓRÐRØ	�~Ò	%Ø×$Ñ$Ð$Ø	�}Ò	$Ø×#Ñ#Ð#Ø	Ð(Ò	(Ü*¨8×+CÑ+CÀVÓLÐLØ	Ð(Ò	(ÜØ×$Ñ$×-Ñ-¨x×/GÑ/G×/QÑ/Qó
ð 	
ð 
�}Ò	$à9A×9MÑ9M×9TÑ9Tö
Ø.5ŒL˜ &Õ)ò
ð 	
ð 
�{Ò	"Ü˜8×-Ñ-×4Ñ4°fÓ=Ð=äÐ1°:Ó>Ð>ùò
s   ÄEc           	      óÌ   — t        | d| «      }|j                  «       D ��ci c]  \  }}|t        ||«      “Œ }}}|j                  dd«      dk(  rt	        |d   «      S |S c c}}w )a   Converts a protobuf map of Firestore ``Value``-s.

    Args:
        value_fields (google.protobuf.pyext._message.MessageMapContainer): A
            protobuf map of Firestore ``Value``-s.
        client (:class:`~google.cloud.firestore_v1.client.Client`):
            A client that has a document factory.

    Returns:
        Dict[str, Union[NoneType, bool, int, float, datetime.datetime,             str, bytes, dict, ~google.cloud.Firestore.GeoPoint]]: A dictionary
        of native Python values converted from the ``value_fields``.
    rª   Ú__type__NÚ
__vector__rt   )ri   rz   r®   Úgetr	   )Úvalue_fieldsr¦   Úvalue_fields_pbr|   rt   Úress         r(   r¯   r¯   ˆ  sm   € ô ˜l¨E°<Ó@€OØ>M×>SÑ>SÓ>U×
V±
°°Uˆ3”˜U FÓ+Ñ+Ð
V€CÑ
Và
‡w�wˆz˜4Ó  LÒ0ô �c˜'‘lÓ#Ð#à€Jùó Ws   ¡A c                 ó†   — | j                   j                  t        d«      \  }}||k7  rt        d| j                   d|«      ‚|S )aâ  Parse a document ID from a document protobuf.

    Args:
        document_pb (google.cloud.proto.firestore.v1.            document.Document): A protobuf for a document that
            was created in a ``CreateDocument`` RPC.
        expected_prefix (str): The expected collection prefix for the
            fully-qualified document name.

    Returns:
        str: The document ID from the protobuf.

    Raises:
        ValueError: If the name does not begin with the prefix.
    r@   zUnexpected document namezExpected to begin with)r€   Úrsplitr‘   rB   )Údocument_pbÚexpected_prefixÚprefixr—   s       r(   Ú
get_doc_idr¼   ¡  sQ   € ð  &×*Ñ*×1Ñ1Ô2IÈ1ÓMÑ€FˆKØ�Ò ÜØ&Ø×ÑØ$Øó	
ð 	
ð Ðr*   zMarker for an empty dict valueÚprefix_pathc              #   óN  K  — | s|t         f–— yt        | j                  «       «      D ]x  \  }}|rt        j                  |«      }nt        |«      }t        |j
                  |j
                  z   Ž }t        |t        «      rt        ||«      D ]  \  }}||f–— Œ Œs||f–— Œz y­w)z7Do depth-first walk of tree, yielding field_path, valueN)	r   Úsortedrz   r   Úfrom_stringr˜   r0   rp   Úextract_fields)	Údocument_datar½   Úexpand_dotsr|   rt   Úsub_keyÚ
field_pathÚs_pathÚs_values	            r(   rÁ   rÁ   À  s§   è ø€ ñ Øœ:Ð%Ó%ä  ×!4Ñ!4Ó!6Ó7ò 	(‰JˆC�ÙÜ#×/Ñ/°Ó4‘ä# C›.�ä" [×%6Ñ%6¸¿¹Ñ%FÐHˆJä˜%¤Ô&Ü'5°e¸ZÓ'Hò *‘O�F˜GØ  '˜/Ó)ñ*ð ! %Ð'Ó'ñ	(ùs   ‚B#B%c                 óŒ   — | }|j                   dd D ]  }|j                  |i «      }Œ |t        u ri }|||j                   d   <   y)z,Set a value into a document for a field_pathNéÿÿÿÿ)r˜   Ú
setdefaultr   )rÂ   rÅ   rt   ÚcurrentrJ   s        r(   Úset_field_valuerÌ   Ö  sW   € à€GØ×#Ñ# C RÐ(ò 2ˆØ×$Ñ$ W¨bÓ1‰ð2à”
ÑØˆØ$)€GˆJ×Ñ˜RÑ Ò!r*   c                 óŠ   — |j                   st        d«      ‚| }|j                   d d D ]  }||   }Œ	 ||j                   d      S )Nz
Empty pathrÉ   )r˜   rB   )rÂ   rÅ   rË   rJ   s       r(   Úget_field_valuerÎ   à  sW   € Ø×ÒÜ˜Ó&Ð&à€GØ×#Ñ# C RÐ(ò #ˆØ˜'Ñ"‰ð#à�:×#Ñ# BÑ'Ñ(Ð(r*   c                   ó$  — e Zd ZdZdd„Zdedeeeef   edf   fd„Z	e
d„ «       Ze
d„ «       Zddd	„Z	 ddej                  j                   fd
„Zdeej                  j&                  j(                     fd„Zddej                  j                   fd„Zy)ÚDocumentExtractora  Break document data up into actual data and transforms.

    Handle special values such as ``DELETE_FIELD``, ``SERVER_TIMESTAMP``.

    Args:
        document_data (dict):
            Property names and values to use for sending a change to
            a document.
    r!   Nc                 ó@  — || _         g | _        g | _        g | _        i | _        i | _        i | _        i | _        i | _        i | _	        d| _
        t        «       }| j                  |«      }|D �]°  \  }}||k(  r|t        u rd| _
        Œ|t        j                  u r| j                  j!                  |«       ŒJ|t        j"                  u r| j                  j!                  |«       Œxt%        |t        j&                  «      r|j(                  | j                  |<   Œ¬t%        |t        j*                  «      r|j(                  | j
                  |<   Œàt%        |t        j,                  «      r|j.                  | j                  |<   �Œt%        |t        j0                  «      r|j.                  | j                  |<   �ŒJt%        |t        j2                  «      r|j.                  | j                  |<   �Œ| j                  j!                  |«       t5        | j                  ||«       �Œ³ y )NFT)rÂ   Úfield_pathsÚdeleted_fieldsÚserver_timestampsÚarray_removesÚarray_unionsÚ
incrementsÚminimumsÚmaximumsÚ
set_fieldsÚempty_documentr   Ú_get_document_iteratorr   r   ÚDELETE_FIELDÚappendÚSERVER_TIMESTAMPr0   ÚArrayRemover]   Ú
ArrayUnionÚ	Incrementrt   ÚMaximumÚMinimumrÌ   )r'   rÂ   r½   ÚiteratorrÅ   rt   s         r(   r)   zDocumentExtractor.__init__õ  s²  € Ø*ˆÔØˆÔØ ˆÔØ!#ˆÔØˆÔØˆÔØˆŒØˆŒØˆŒØˆŒØ#ˆÔä“kˆØ×.Ñ.¨{Ó;ˆà!)ó 	DÑˆJ˜Ø˜[Ò(¨U´jÑ-@Ø&*�Õ#àœ*×1Ñ1Ñ1Ø×#Ñ#×*Ñ*¨:Õ6àœ*×5Ñ5Ñ5Ø×&Ñ&×-Ñ-¨jÕ9ä˜E¤:×#9Ñ#9Ô:Ø16·±�×"Ñ" :Ò.ä˜E¤:×#8Ñ#8Ô9Ø05·±�×!Ñ! *Ò-ä˜E¤:×#7Ñ#7Ô8Ø.3¯k©k�—‘ 
Ó+ä˜E¤:×#5Ñ#5Ô6Ø,1¯K©K�—‘˜jÓ)ä˜E¤:×#5Ñ#5Ô6Ø,1¯K©K�—‘˜jÓ)ð × Ñ ×'Ñ'¨
Ô3Ü §¡°¸UÖCñ7	Dr*   r½   c                 ó.   — t        | j                  |«      S r#   ©rÁ   rÂ   ©r'   r½   s     r(   rÜ   z(DocumentExtractor._get_document_iterator"  s   € ô ˜d×0Ñ0°+Ó>Ð>r*   c                 ó¸   — t        | j                  xsD | j                  xs6 | j                  xs( | j                  xs | j
                  xs | j                  «      S r#   )rc   rÔ   rÕ   rÖ   r×   rÙ   rØ   r-   s    r(   Úhas_transformsz DocumentExtractor.has_transforms'  s^   € äØ×"Ñ"ò Ø×!Ñ!òà× Ñ òð �‰òð �}‰}ò	ð
 �}‰}ó
ð 	
r*   c                 ó  — t        | j                  t        | j                  «      z   t        | j                  «      z   t        | j
                  «      z   t        | j                  «      z   t        | j                  «      z   «      S r#   )r¿   rÔ   rj   rÕ   rÖ   r×   rÙ   rØ   r-   s    r(   Útransform_pathsz!DocumentExtractor.transform_paths2  sw   € äØ×"Ñ"Ü�4×%Ñ%Ó&ñ'ä�4×$Ñ$Ó%ñ&ô �4—?‘?Ó#ñ$ô �4—=‘=Ó!ñ	"ô
 �4—=‘=Ó!ñ"ó
ð 	
r*   c                  ó   — y r#   r=   )r'   Úallow_empty_masks     r(   Ú_get_update_maskz"DocumentExtractor._get_update_mask=  s   € Ør*   c                 óÚ   — |�t        j                  |¬«      }nd }t        j                  t	        j
                  |t        | j                  «      ¬«      | j                  |«      |¬«      }|S )N©r„   )r€   r_   )ÚupdateÚupdate_maskÚcurrent_document)	r   ÚPreconditionr   ÚWriter   r   rq   rÚ   rï   )r'   ru   r„   rî   rô   Ú	update_pbs         r(   Úget_update_pbzDocumentExtractor.get_update_pb@  sg   € ð ÐÜ%×2Ñ2¸&ÔAÑà#Ðä—K‘KÜ×$Ñ$Ø"¬;°t·±Ó+Gôð ×-Ñ-Ð.>Ó?Ø-ô
ˆ	ð Ðr*   c                 ó   — d„ }| j                   D �cg c]7  }|t        j                  j                  |j	                  «       t
        ¬«      f‘Œ9 c}| j                  j                  «       D ��cg c]<  \  }}|t        j                  j                  |j	                  «        ||«      ¬«      f‘Œ> c}}z   | j                  j                  «       D ��cg c]<  \  }}|t        j                  j                  |j	                  «        ||«      ¬«      f‘Œ> c}}z   | j                  j                  «       D ��cg c]?  \  }}|t        j                  j                  |j	                  «       t        |«      ¬«      f‘ŒA c}}z   | j                  j                  «       D ��cg c]?  \  }}|t        j                  j                  |j	                  «       t        |«      ¬«      f‘ŒA c}}z   | j                  j                  «       D ��cg c]?  \  }}|t        j                  j                  |j	                  «       t        |«      ¬«      f‘ŒA c}}z   }t        |«      D ��cg c]  \  }}|‘Œ	 c}}S c c}w c c}}w c c}}w c c}}w c c}}w c c}}w c c}}w )Nc                 óh   — | D �cg c]  }t        |«      ‘Œ }}t        j                  |¬«      S c c}w )Nr\   )rY   r   rn   )r]   rJ   rv   s      r(   Úmake_array_valuezCDocumentExtractor.get_field_transform_pbs.<locals>.make_array_valueU  s1   € Ø?EÖF°Gœ, wÕ/ÐFˆJÐFÜ×&Ñ&¨jÔ9Ð9ùò Gs   …/)rÅ   Úset_to_server_value)rÅ   Úremove_all_from_array)rÅ   Úappend_missing_elements)rÅ   Ú	increment)rÅ   Úmaximum)rÅ   Úminimum)rÔ   r   r
   ÚFieldTransformÚto_api_reprÚREQUEST_TIME_ENUMrÕ   rz   rÖ   r×   rY   rÙ   rØ   r¿   )r'   ru   rû   rG   r]   rt   Úpath_field_transformsÚ	transforms           r(   Úget_field_transform_pbsz)DocumentExtractor.get_field_transform_pbsR  sŒ  € ò	:ð !×2Ñ2ö	ð ð Ü×+Ñ+×:Ñ:Ø#'×#3Ñ#3Ó#5Ü,=ð ;ó òò	ð$ %)×$6Ñ$6×$<Ñ$<Ó$>÷	ñ !�D˜&ð Ü×+Ñ+×:Ñ:Ø#'×#3Ñ#3Ó#5Ù.>¸vÓ.Fð ;ó òó	ñð8 %)×$5Ñ$5×$;Ñ$;Ó$=÷	ñ !�D˜&ð Ü×+Ñ+×:Ñ:Ø#'×#3Ñ#3Ó#5Ù0@ÀÓ0Hð ;ó òó	ñ)ðJ $(§?¡?×#8Ñ#8Ó#:÷ñ  �D˜%ð Ü×+Ñ+×:Ñ:Ø#'×#3Ñ#3Ó#5ÄÈeÓATð ;ó òóñ=&ð\ $(§=¡=×#6Ñ#6Ó#8÷ñ  �D˜%ð Ü×+Ñ+×:Ñ:Ø#'×#3Ñ#3Ó#5¼|ÈEÓ?Rð ;ó òóñO/ðn $(§=¡=×#6Ñ#6Ó#8÷ñ  �D˜%ð Ü×+Ñ+×:Ñ:Ø#'×#3Ñ#3Ó#5¼|ÈEÓ?Rð ;ó òóña8ð 	ôv 28Ð8MÓ1N×O™o˜d I’	ÓOÐOùòu	ùó	ùó	ùóùóùóùó Ps.   ’<I'Á-AI,ÃAI2Ä3AI8ÆAI>Ç?AJÉJ
c                 ó  — | j                  |«      }t        j                  t        j                  ||¬«      ¬«      }|�C|j                  j
                  j                  t        j                  |¬«      j                  «       |S )N)r   Úfield_transforms)r  rñ   )	r  r   rö   r
   rª   rô   ÚCopyFromr   rõ   )r'   ru   r„   r	  Útransform_pbs        r(   Úget_transform_pbz"DocumentExtractor.get_transform_pb–  ss   € Ø×7Ñ7¸ÓFÐÜ—{‘{Ü×-Ñ-Ø&Ð9Iôô
ˆð
 ÐØ×Ñ×-Ñ-×6Ñ6Ü×#Ñ#¨6Ô2×6Ñ6ôð Ðr*   r8   ©F)NFr#   )r9   r:   r;   r<   r)   r   r   r   r   rÜ   r    rê   rì   rï   r   r   rö   rø   r   r
   r  r  r  r=   r*   r(   rÐ   rÐ   ê  s¾   „ ñó+DðZ?Ø$ð?à	�5˜˜c˜‘? C¨Ð-Ñ	.ó?ð
 ñ
ó ð
ð ñ
ó ð
ôð <Añà	�‰×	Ñ	óð$BPà	ˆe�k‰k×+Ñ+×:Ñ:Ñ	;óBPñH¸e¿k¹k×>OÑ>Oô r*   rÐ   c                 óâ   — t        |«      }|j                  rt        d«      ‚|j                  | d¬«      }|j                  r,|j                  | «      }|j                  j                  |«       |gS )ai  Make ``Write`` protobufs for ``create()`` methods.

    Args:
        document_path (str): A fully-qualified document path.
        document_data (dict): Property names and values to use for
            creating a document.

    Returns:
        List[google.cloud.firestore_v1.types.Write]: One or two
        ``Write`` protobuf instances for ``create()``.
    z.Cannot apply DELETE_FIELD in a create request.Frñ   ©rÐ   rÓ   rB   rø   rê   r  Úupdate_transformsÚextend)ru   rÂ   Ú	extractorÚ	create_pbÚfield_transform_pbss        r(   Úpbs_for_creater  ¥  so   € ô " -Ó0€Ià×ÒÜÐIÓJÐJà×'Ñ'¨¸eÐ'ÓD€Ià×ÒØ'×?Ñ?ÀÓNÐØ×#Ñ#×*Ñ*Ð+>Ô?àˆ;Ðr*   c                 óÞ   — t        |«      }|j                  rt        d«      ‚|j                  | «      }|j                  r,|j                  | «      }|j                  j                  |«       |gS )ad  Make ``Write`` protobufs for ``set()`` methods.

    Args:
        document_path (str): A fully-qualified document path.
        document_data (dict): Property names and values to use for
            replacing a document.

    Returns:
        List[google.cloud.firestore_v1.types.Write]: One
        or two ``Write`` protobuf instances for ``set()``.
    zdCannot apply DELETE_FIELD in a set request without specifying 'merge=True' or 'merge=[field_paths]'.r  )ru   rÂ   r  Úset_pbr  s        r(   Úpbs_for_set_no_merger  ¿  sr   € ô " -Ó0€Ià×ÒÜð@ó
ð 	
ð
 ×$Ñ$ ]Ó3€Fà×ÒØ'×?Ñ?ÀÓNÐØ× Ñ ×'Ñ'Ð(;Ô<àˆ8€Or*   c                   óž   ‡ — e Zd ZdZdˆ fd„Zdd„Zdeeedf   fd„Zde	fd„Z
dd„Zdd	„Z	 ddeej                  j                      fd
„Zˆ xZS )ÚDocumentExtractorForMergeú7Break document data up into actual data and transforms.r!   Nc                 óV   •— t         t        | �  |«       g | _        g | _        g | _        y r#   )Úsuperr  r)   Ú
data_mergeÚtransform_mergeÚmerge)r'   rÂ   Ú	__class__s     €r(   r)   z"DocumentExtractorForMerge.__init__ß  s)   ø€ ÜÔ'¨Ñ7¸ÔFØˆŒØ!ˆÔØˆ�
r*   c                 óÂ   — t        | j                  | j                  z   «      | _        | j                  | _        t        | j                  | j                  z   «      | _        y r#   )r¿   rÒ   rÓ   r  rì   r  r   r-   s    r(   Ú_apply_merge_allz*DocumentExtractorForMerge._apply_merge_allå  sH   € Ü  ×!1Ñ!1°D×4GÑ4GÑ!GÓHˆŒà#×3Ñ3ˆÔÜ˜DŸO™O¨d×.BÑ.BÑBÓCˆ�
r*   c              #   ój   K  — |D ]*  }t        |t        «      r|–— Œt        t        |«      Ž –— Œ, y ­wr#   )r0   r   r   )r'   r   Úmerge_fields      r(   Ú_construct_merge_pathsz0DocumentExtractorForMerge._construct_merge_pathsë  s8   è ø€ Ø ò 	@ˆKÜ˜+¤yÔ1Ø!Ó!äÔ!1°+Ó!>Ð?Ó?ñ		@ùs   ‚13c                 óŒ  — t        | j                  |«      «      }t        t        |«      dz
  «      D ];  }||   ||dz      }}|j	                  |«      sŒ"t        dj                  ||«      «      ‚ |D ](  }|| j                  v rŒ	 t        | j                  |«       Œ* |S # t        $ r t        dj                  |«      «      ‚w xY w)Nr@   zMerge paths overlap: {}, {}zInvalid merge path: {})r¿   r&  ÚrangerA   Úeq_or_parentrB   rE   rÓ   rÎ   rÂ   ÚKeyError)r'   r   Úmerge_pathsÚindexÚlhsÚrhsÚ
merge_paths          r(   Ú_normalize_merge_pathsz0DocumentExtractorForMerge._normalize_merge_pathsò  sã   € Ü˜T×8Ñ8¸Ó?Ó@ˆô œ3˜{Ó+¨aÑ/Ó0ò 	QˆEØ" 5Ñ)¨;°u¸q±yÑ+A�ˆCØ×Ñ Õ$Ü Ð!>×!EÑ!EÀcÈ3Ó!OÓPÐPð	Qð
 &ò 	NˆJØ˜T×0Ñ0Ñ0ØðNÜ × 2Ñ 2°JÕ?ð		Nð Ðøô ò NÜ Ð!9×!@Ñ!@ÀÓ!LÓMÐMðNús   ÂBÂ$Cc                 óÎ  — | j                   rt        d«      ‚| j                  |«      }| j                  d d …= | j                  d d …= || _        |D ]i  }|| j                  v r| j                  j                  |«       | j                  D ]/  }|j                  |«      sŒ| j                  j                  |«       Œ1 Œk i }| j                  D ]%  }t        | j                  |«      }t        |||«       Œ' || _        | j                  D �cg c]  }|| j
                  vr|‘Œ }}|rt        dj                  |«      «      ‚t!        | j                  | j                  z   «      | _        t#        «       }| j
                  D ]=  }| j                  D �	cg c]  }	|j                  |	«      r|	‘Œ }
}	|j%                  |
«       Œ? | j&                  D �cg c]	  }||v sŒ|‘Œ c}| _        | j(                  j+                  «       D ��ci c]  \  }}||v r||“Œ c}}| _        | j,                  j+                  «       D ��ci c]  \  }}||v r||“Œ c}}| _        y c c}w c c}	w c c}w c c}}w c c}}w )Nz1Cannot merge specific fields with empty document.z!Cannot delete unmerged fields: {})rÛ   rB   r0  r  r  r   rì   rÞ   rÒ   r)  rÎ   rÂ   rÌ   rÚ   rÓ   rE   r¿   rl   rò   rÔ   rÕ   rz   rÖ   )r'   r   r+  r/  rÅ   Úmerged_set_fieldsrt   Úunmerged_deleted_fieldsÚmerged_transform_pathsÚtransform_pathÚtranform_merge_pathsrG   r]   s                r(   Ú_apply_merge_pathsz,DocumentExtractorForMerge._apply_merge_paths  s‚  € Ø×ÒÜÐPÓQÐQà×1Ñ1°%Ó8ˆà�O‰OšAÐØ× Ñ ¢Ð#Ø ˆŒ
à%ò 	7ˆJØ˜T×1Ñ1Ñ1Ø×$Ñ$×+Ñ+¨JÔ7à"×.Ñ.ò 7�
Ø×*Ñ*¨:Õ6Ø—O‘O×*Ñ*¨:Õ6ñ7ð		7ð ÐØŸ/™/ò 	BˆJÜ# D×$6Ñ$6¸
ÓCˆEÜÐ-¨z¸5ÕAð	Bð ,ˆŒð #×1Ñ1ö#
àØ §¡Ñ+ò ð#
Ðð #
ñ
 #ÜØ3×:Ñ:Ð;RÓSóð ô ! §¡°4×3FÑ3FÑ!FÓGˆŒô "%£ÐØŸ*™*ò 	@ˆJð '+×&:Ñ&:ö$à"Ø×*Ñ*¨>Ô:ò ð$Ð ð $ð
 #×)Ñ)Ð*>Õ?ð	@ð "×3Ñ3ö"
Ø°tÐ?UÒ7UŠDò"
ˆÔð !%× 2Ñ 2× 8Ñ 8Ó :÷
á��fØÐ-Ñ-ð �&‰Ló
ˆÔð !%× 1Ñ 1× 7Ñ 7Ó 9÷
á��fØÐ-Ñ-ð �&‰Ló
ˆÕùò?#
ùò$ùò"
ùó
ùó
s$   ÄIÆ
IÇ	IÇIÇ:IÈ1I!c                 óP   — |du r| j                  «        y | j                  |«       y )NT)r#  r7  )r'   r   s     r(   Úapply_mergez%DocumentExtractorForMerge.apply_mergeD  s#   € Ø�D‰=Ø×!Ñ!Õ#à×#Ñ# EÕ*r*   c                 ó¢   — | j                   D �cg c]   }|| j                  vr|j                  «       ‘Œ" }}t        j                  |¬«      S c c}w ©N)rÒ   )r   r  r  r   ÚDocumentMask)r'   rî   rÅ   Ú
mask_pathss       r(   rï   z*DocumentExtractorForMerge._get_update_maskJ  sT   € ð #Ÿj™jö
àØ ×!5Ñ!5Ñ5ð ×"Ñ"Õ$ð
ˆ
ð 
ô ×"Ñ"¨zÔ:Ð:ùò
s   �%Ar8   r  )r9   r:   r;   r<   r)   r#  r   r   r&  rj   r0  r7  r9  r   r   r   r<  rï   Ú__classcell__©r!  s   @r(   r  r  Ü  sb   ø„ ÙAõóDð@¨y¸¸cÀ4¸Ñ/Hó @ð¨tó ó(<
ó|+ð  %ñ
;à	�%—,‘,×+Ñ+Ñ	,÷
;r*   r  c                 óÒ   — t        |«      }|j                  |«       |j                  | «      }|j                  r,|j	                  | «      }|j
                  j                  |«       |gS )aé  Make ``Write`` protobufs for ``set()`` methods.

    Args:
        document_path (str): A fully-qualified document path.
        document_data (dict): Property names and values to use for
            replacing a document.
        merge (Optional[bool] or Optional[List<apispec>]):
            If True, merge all fields; else, merge only the named fields.

    Returns:
        List[google.cloud.firestore_v1.types.Write]: One
        or two ``Write`` protobuf instances for ``set()``.
    )r  r9  rø   rì   r  r  r  )ru   rÂ   r   r  r  r  s         r(   Úpbs_for_set_with_mergerA  W  sb   € ô  *¨-Ó8€IØ×Ñ˜%Ô à×$Ñ$ ]Ó3€Fà× Ò Ø'×?Ñ?ÀÓNÐØ× Ñ ×'Ñ'Ð(;Ô<àˆ8€Or*   c                   ó€   ‡ — e Zd ZdZdˆ fd„Zdedeeeef   edf   fd„Z	d	de
j                  j                  fd„Zˆ xZS )
ÚDocumentExtractorForUpdater  r!   Nc                 óª  •— t         t        | �  |«       t        |D �cg c]  }t	        j
                  |«      ‘Œ c}«      | _        t        | j                  «      }| j                  D ]6  }|j                  «       D ]!  }||v sŒt        dj                  ||«      «      ‚ Œ8 | j                  D ]   }||vsŒt        dj                  |«      «      ‚ y c c}w )NzConflicting field path: {}, {}z"Cannot update with nest delete: {})r  rC  r)   r¿   r   rÀ   Útop_level_pathsrl   ÚlineagerB   rE   rÓ   )r'   rÂ   r|   ÚtopsÚtop_level_pathÚancestorrÅ   r!  s          €r(   r)   z#DocumentExtractorForUpdate.__init__v  sà   ø€ ÜÔ(¨$Ñ8¸ÔGÜ%Ø3@ÖA¨CŒY×"Ñ" 3Õ'ÒAó 
ˆÔô �4×'Ñ'Ó(ˆØ"×2Ñ2ò 	ˆNØ*×2Ñ2Ó4ò �Ø˜tÒ#Ü$Ø8×?Ñ?Ø*¨Hóóð ñð	ð ×-Ñ-ò 	ˆJØ Ò%Ü Ø8×?Ñ?À
ÓKóð ñ	ùò Bs   žCr½   c                 ó2   — t        | j                  |d¬«      S )NT)rÃ   rç   rè   s     r(   rÜ   z1DocumentExtractorForUpdate._get_document_iterator‹  s   € ô ˜d×0Ñ0°+È4ÔPÐPr*   c                 ó°   — g }| j                   D ]0  }|| j                  vsŒ|j                  |j                  «       «       Œ2 t	        j
                  |¬«      S r;  )rE  rì   rÞ   r  r   r<  )r'   rî   r=  rÅ   s       r(   rï   z+DocumentExtractorForUpdate._get_update_mask�  sT   € Øˆ
Ø×.Ñ.ò 	<ˆJØ ×!5Ñ!5Ò5Ø×!Ñ! *×"8Ñ"8Ó":Õ;ð	<ô ×"Ñ"¨zÔ:Ð:r*   r8   r  )r9   r:   r;   r<   r)   r   r   r   r   rÜ   r   r   r<  rï   r>  r?  s   @r(   rC  rC  s  sM   ø„ ÙAõð*QØ$ðQà	�5˜˜c˜‘? C¨Ð-Ñ	.óQñ
;¸%¿,¹,×:SÑ:S÷ ;r*   rC  c                 ó  — t        |«      }|j                  rt        d«      ‚|€t        d¬«      }|j	                  | «      }|j                  |«       |j                  r,|j                  | «      }|j                  j                  |«       |gS )aC  Make ``Write`` protobufs for ``update()`` methods.

    Args:
        document_path (str): A fully-qualified document path.
        field_updates (dict): Field names or paths to update and values
            to update with.
        option (optional[:class:`~google.cloud.firestore_v1.client.WriteOption`]):
            A write option to make assertions / preconditions on the server
            state of the document before applying changes.

    Returns:
        List[google.cloud.firestore_v1.types.Write]: One
        or two ``Write`` protobuf instances for ``update()``.
    z%Cannot update with an empty document.Trñ   )
rC  rÛ   rB   ÚExistsOptionrø   Úmodify_writerê   r  r  r  )ru   Úfield_updatesÚoptionr  r÷   r  s         r(   Úpbs_for_updaterQ  ™  s‡   € ô +¨=Ó9€Ià×ÒÜÐ@ÓAÐAà€~Ü TÔ*ˆà×'Ñ'¨Ó6€IØ
×Ñ˜	Ô"à×ÒØ'×?Ñ?ÀÓNÐØ×#Ñ#×*Ñ*Ð+>Ô?àˆ;Ðr*   c                 óX   — t        j                  | ¬«      }|�|j                  |«       |S )aÔ  Make a ``Write`` protobuf for ``delete()`` methods.

    Args:
        document_path (str): A fully-qualified document path.
        option (optional[:class:`~google.cloud.firestore_v1.client.WriteOption`]):
            A write option to make assertions / preconditions on the server
            state of the document before applying changes.

    Returns:
        google.cloud.firestore_v1.types.Write: A
        ``Write`` protobuf instance for the ``delete()``.
    )Údelete)r   rö   rN  )ru   rP  Úwrite_pbs      r(   Úpb_for_deleterU  º  s+   € ô �{‰{ -Ô0€HØÐØ×Ñ˜HÔ%à€Or*   c                   ó   — e Zd ZdZy)ÚReadAfterWriteErrorzhRaised when a read is attempted after a write.

    Raised by "read" methods that use transactions.
    N)r9   r:   r;   r<   r=   r*   r(   rW  rW  Î  s   „ òr*   rW  c                 ó¨   — | €y| j                   st        t        «      ‚|r't        | j                  «      dkD  rt        t        «      ‚| j                  S )a  Get the transaction ID from a ``Transaction`` object.

    Args:
        transaction (Optional[:class:`~google.cloud.firestore_v1.transaction.            Transaction`]):
            An existing transaction that this query will run in.
        read_operation (Optional[bool]): Indicates if the transaction ID
            will be used in a read operation. Defaults to :data:`True`.

    Returns:
        Optional[bytes]: The ID of the transaction, or :data:`None` if the
        ``transaction`` is :data:`None`.

    Raises:
        ValueError: If the ``transaction`` is not in progress (only if
            ``transaction`` is not :data:`None`).
        ReadAfterWriteError: If the ``transaction`` has writes stored on
            it and ``read_operation`` is :data:`True`.
    Nr   )Úin_progressrB   ÚINACTIVE_TXNrA   Ú
_write_pbsrW  ÚREAD_AFTER_WRITE_ERRORÚid)ÚtransactionÚread_operations     r(   Úget_transaction_idr`  Õ  sL   € ð( ÐØà×&Ò&Üœ\Ó*Ð*Ùœc +×"8Ñ"8Ó9¸AÒ=Ü%Ô&<Ó=Ð=Ø�~‰~Ðr*   r»   c                 ó   — d| fgS )z¸Create RPC metadata containing a prefix.

    Args:
        prefix (str): appropriate resource path.

    Returns:
        List[Tuple[str, str]]: RPC metadata with supplied prefix
    zgoogle-cloud-resource-prefixr=   )r»   Úkws     r(   Úmetadata_with_prefixrc  ó  s   € ð ,¨VÐ4Ð5Ð5r*   c                   ó   — e Zd ZdZddefd„Zy)ÚWriteOptionz7Option used to assert a condition on a write operation.Nr!   c                 ó   — t         ‚)a>  Modify a ``Write`` protobuf based on the state of this write option.

        This is a virtual method intended to be implemented by subclasses.

        Args:
            write (google.cloud.firestore_v1.types.Write): A
                ``Write`` protobuf instance to be modified with a precondition
                determined by the state of this option.
            no_create_msg (Optional[str]): A message to use to indicate that
                a create operation is not allowed.

        Raises:
            NotImplementedError: Always, this method is virtual.
        )ÚNotImplementedError)r'   r   Úno_create_msgs      r(   rN  zWriteOption.modify_write  s
   € ô "Ð!r*   r#   )r9   r:   r;   r<   r   rN  r=   r*   r(   re  re  ÿ  s   „ ÙAñ"¸ô "r*   re  c                   ó&   — e Zd ZdZdd„Zd„ Zdd„Zy)ÚLastUpdateOptiona*  Option used to assert a "last update" condition on a write operation.

    This will typically be created by
    :meth:`~google.cloud.firestore_v1.client.Client.write_option`.

    Args:
        last_update_time (google.protobuf.timestamp_pb2.Timestamp): A
            timestamp. When set, the target document must exist and have
            been last updated at that time. Protobuf ``update_time`` timestamps
            are typically returned from methods that perform write operations
            as part of a "write result" protobuf or directly.
    Nc                 ó   — || _         y r#   )Ú_last_update_time)r'   Úlast_update_times     r(   r)   zLastUpdateOption.__init__"  s
   € Ø!1ˆÕr*   c                 ól   — t        || j                  «      st        S | j                  |j                  k(  S r#   )r0   r!  r1   rl  r2   s     r(   r4   zLastUpdateOption.__eq__%  s-   € Ü˜% §¡Ô0Ü!Ð!Ø×%Ñ%¨×)@Ñ)@Ñ@Ð@r*   c                 ó¢   — t        j                  | j                  ¬«      }|j                  j                  j                  |j                  «       y)ac  Modify a ``Write`` protobuf based on the state of this write option.

        The ``last_update_time`` is added to ``write_pb`` as an "update time"
        precondition. When set, the target document must exist and have been
        last updated at that time.

        Args:
            write_pb (google.cloud.firestore_v1.types.Write): A
                ``Write`` protobuf instance to be modified with a precondition
                determined by the state of this option.
            unused_kwargs (Dict[str, Any]): Keyword arguments accepted by
                other subclasses that are unused here.
        )r‚   N)r   rõ   rl  rª   rô   r
  ©r'   r   Úunused_kwargsÚcurrent_docs       r(   rN  zLastUpdateOption.modify_write*  s6   € ô ×(Ñ(°T×5KÑ5KÔLˆØ�	‰	×"Ñ"×+Ñ+¨K¯O©OÕ<r*   r8   ©r9   r:   r;   r<   r)   r4   rN  r=   r*   r(   rj  rj    s   „ ñó2òAô
=r*   rj  c                   ó&   — e Zd ZdZdd„Zd„ Zdd„Zy)rM  a  Option used to assert existence on a write operation.

    This will typically be created by
    :meth:`~google.cloud.firestore_v1.client.Client.write_option`.

    Args:
        exists (bool): Indicates if the document being modified
            should already exist.
    Nc                 ó   — || _         y r#   )Ú_exists)r'   r„   s     r(   r)   zExistsOption.__init__G  s	   € Øˆ�r*   c                 ól   — t        || j                  «      st        S | j                  |j                  k(  S r#   )r0   r!  r1   rv  r2   s     r(   r4   zExistsOption.__eq__J  s)   € Ü˜% §¡Ô0Ü!Ð!Ø�|‰|˜uŸ}™}Ñ,Ð,r*   c                 ó¢   — t        j                  | j                  ¬«      }|j                  j                  j                  |j                  «       y)aB  Modify a ``Write`` protobuf based on the state of this write option.

        If:

        * ``exists=True``, adds a precondition that requires existence
        * ``exists=False``, adds a precondition that requires non-existence

        Args:
            write (google.cloud.firestore_v1.types.Write): A
                ``Write`` protobuf instance to be modified with a precondition
                determined by the state of this option.
            unused_kwargs (Dict[str, Any]): Keyword arguments accepted by
                other subclasses that are unused here.
        rñ   N)r   rõ   rv  rª   rô   r
  rp  s       r(   rN  zExistsOption.modify_writeO  s4   € ô ×(Ñ(°·±Ô=ˆØ�	‰	×"Ñ"×+Ñ+¨K¯O©OÕ<r*   r8   rs  r=   r*   r(   rM  rM  <  s   „ ñóò-ô
=r*   rM  c                 óZ   — i }| t         j                  j                  ur| |d<   |�||d<   |S )zCHelper fo API methods which take optional 'retry' / 'timeout' args.ÚretryÚtimeout)r   ÚmethodÚDEFAULT)rz  r{  Úkwargss      r(   Úmake_retry_timeout_kwargsr  b  s7   € à€Fà”H—O‘O×+Ñ+Ñ+Øˆˆw‰àÐØ#ˆˆyÑà€Mr*   Údtc                 óx   — t        | xs. t        j                  t        j                  j
                  ¬«      «      S )z7Returns the supplied datetime (or "now") as a Timestamp)Útz)r   r   Únowrg   ÚtimezoneÚutc)r€  s    r(   Úbuild_timestampr†  o  s1   € ô %Ø
ÒCÔ%×)Ñ)¬X×->Ñ->×-BÑ-BÔCóð r*   Úts1Úts2c                 ó  — t        | t        «      st        | «      n| } t        |t        «      st        |«      n|}| j                  | j                  dz  z   }|j                  |j                  dz  z   }||k(  ry||kD  rdS dS )Ng    eÍÍAr   r@   rÉ   )r0   r   r†  ÚnanosÚseconds)r‡  rˆ  Ú	ts1_nanosÚ	ts2_nanoss       r(   Úcompare_timestampsrŽ  x  sy   € ô '1°´iÔ&@Œ/˜#Ô
Àc€CÜ&0°´iÔ&@Œ/˜#Ô
Àc€CØ—	‘	˜CŸK™K¨#Ñ-Ñ-€IØ—	‘	˜CŸK™K¨#Ñ-Ñ-€IØ�IÒØØ˜IÒ%ˆ1Ð-¨2Ð-r*   Ú
serializedr¦   z+google.cloud.firestore_v1.client.BaseClientz-google.cloud.firestore_bundle.FirestoreBundlec                 óV  — ddl m}m} dgg d¢g d¢dgddgdœ}|d	   }d
}d
}t        | «      D ]¦  }t	        |j                  «       «      }	t        |	«      dk7  rt        d«      ‚|	d   }
|
|vrt        d|
› d|› �«      ‚	 |j                  t        j                  |«      «      }|€|
dk(  sJ ‚ |||
   d   «      }|}n|j                  |||
¬«       ||
   }Œ¨ d|vrt        d«      ‚|j                  ||d¬«       |S # t        $ r$}|j                  d   dk(  rt        d«      ‚|‚d
}~ww xY w)a¾  Inverse operation to a `FirestoreBundle` instance's `build()` method.

    Args:
        serialized (Union[str, bytes]): The result of `FirestoreBundle.build()`.
            Should be a list of dictionaries in string format.
        client (BaseClient): A connected Client instance.

    Returns:
        FirestoreBundle: A bundle equivalent to that which called `build()` and
            initially created the `serialized` value.

    Raises:
        ValueError: If any of the dictionaries in the list contain any more than
            one top-level key.
        ValueError: If any unexpected BundleElement types are encountered.
        ValueError: If the serialized bundle ends before expected.
    r   )ÚBundleElementÚFirestoreBundleÚmetadata)Ú
namedQueryÚdocumentMetadataÚ__end__r   r•  r–  )Ú__initial__r“  r”  r•  r   r—  Nr@   z8Expected serialized BundleElement with one top-level keyz"Encountered BundleElement of type z. Expected one of z%'dict' object has no attribute 'find'z[Invalid serialization of datetimes. Cannot deserialize Bundles created from the NodeJS SDK.r]  )r¦   rF   z,Unexpected end to serialized FirestoreBundle)Úgoogle.cloud.firestore_bundler‘  r’  Ú_parse_bundle_elements_datarj   ÚkeysrA   rB   Ú	from_jsonÚjsonÚdumpsÚAttributeErrorÚargsÚ_add_bundle_element)r�  r¦   r‘  r’  Úbundle_state_machineÚallowed_next_element_typesÚmetadata_bundle_elementÚbundleÚdatarš  r|   Úbundle_elementÚes                r(   Údeserialize_bundler¨  …  s   € ÷* Mð #�|ÚAÚCØ'˜LØ'¨Ð3ñÐð -AÀÑ,OÐð 8<Ðà(,€Fä+¨JÓ7ò '?ˆô ˜tŸy™y›{Ó+ˆäˆt‹9˜Š>ÜÐWÓXÐXà˜‘7ˆàÐ0Ñ0ÜØ4°S°Eð :#Ø#=Ð">ð@óð ð		Ø,9×,CÑ,CÄDÇJÁJÈtÓDTÓ,UˆNð ˆ>à˜*Ò$Ñ$Ù$ T¨#¡Y¨t¡_Ó5ˆFØ&4Ñ#ð ×&Ñ& ~¸fÈ3Ð&ÔOð &:¸#Ñ%>Ñ"ðO'?ðR Ð2Ñ2ÜÐGÓHÐHð ×ÑØØØð ô ð €Møô? ò 	à�v‰v�a‰yÐCÒCÜ ðNóð ð ˆGûð	ús   Á=$C;Ã;	D(ÄD#Ä#D(c              #   óÀ  K  — t        t        | t        «      r| n| j                  d«      «      }d}	 t	        |d«      }|€yt        |«      }|j                  «       r||z  }n{|dk(  rt        d«      ‚t        |«      }d}t        |g«      }d}||k  r%|j                  t	        |«      «       |dz  }||k  rŒ%t        j                  |j                  d«      «      –— Œ¬­w)a
  Reads through a serialized FirestoreBundle and yields JSON chunks that
    were created via `BundleElement.to_json(bundle_element)`.

    Serialized FirestoreBundle instances are length-prefixed JSON objects, and
    so are of the form "123{...}57{...}"
    To correctly and safely read a bundle, we must first detect these length
    prefixes, read that many bytes of data, and attempt to JSON-parse that.

    Raises:
        ValueError: If a chunk of JSON ever starts without following a length
            prefix.
    zutf-8Ú NzExpected length prefixr@   )Úiterr0   rh   ÚencodeÚnextÚchrÚ	isnumericrB   rd   Ú	bytearrayrÞ   rœ  ÚloadsÚdecode)r�  Ú_serializedÚlength_prefixÚbyteÚ_strÚ_length_prefixÚ_bytesÚ_counters           r(   r™  r™  å  så   è ø€ ô "&Ü  ¬UÔ3‰
¸×9JÑ9JÈ7Ó9Só"€Kð €MØ
Ü" ;°Ó5ˆàˆ<Øä˜“IˆØ�>‰>ÔØ˜TÑ!‰Mà Ò"Ü Ð!9Ó:Ð:ä  Ó/ˆNØˆMÜ ˜vÓ&ˆFØˆHØ˜^Ò+Ø—‘œd ;Ó/Ô0Ø˜A‘�ð ˜^Ó+ô —*‘*˜VŸ]™]¨7Ó3Ó4Ò4ð+ ùs   ‚B4CÂ7'C)Ú
query_namerº  )ú'google.cloud.firestore.DocumentSnapshotNNc             #   ó¨   K  — ddl m} | j                  j                  «       D ]+  }|r||j                  j
                  vrŒ|j                  –— Œ- y ­w)Nr   )Ú_BundledDocument)Ú$google.cloud.firestore_bundle.bundler½  rž   r]   r“  Úqueriesr}   )r¤  rº  r½  Úbundled_docs       r(   Ú_get_documents_from_bundlerÁ    sQ   è ø€ õ Fð ×'Ñ'×.Ñ.Ó0ò #ˆÙ˜*¨K×,@Ñ,@×,HÑ,HÑHØØ×"Ñ"Ó"ñ#ùs   ‚AAr—   r»  c                óV   — | j                   j                  |«      }|r|j                  S y r#   )rž   r³   r}   )r¤  r—   rÀ  s      r(   Ú_get_document_from_bundlerÃ    s.   € ð
 ×"Ñ"×&Ñ& {Ó3€KÙØ×#Ñ#Ð#ð r*   r8   r  )Tr#   )kr<   rg   rœ  ÚgoogleÚ google.api_core.datetime_helpersr   Úgoogle.api_corer   Úgoogle.protobufr   Úgoogle.typer   ÚgrpcÚgoogle.cloudr   Úgoogle.cloud._helpersr   Ú google.cloud.firestore_v1.vectorr	   Ú%google.cloud.firestore_v1.types.writer
   Úgoogle.cloud.firestore_v1r   r   Ú$google.cloud.firestore_v1.field_pathr   r   rƒ   r   r   r   Úgoogle.protobuf.timestamp_pb2r   Útypingr   r   r   r   r   r   r   r   r   ÚSentinelÚ__annotations__rp   rD   r‘   rZ  r\  r’   r¤   r  ÚServerValueÚREQUEST_TIMEr  Ú
StatusCodeÚALREADY_EXISTSÚConflictÚ	NOT_FOUNDÚNotFoundr   Úobjectr    rL   ra   rY   rq   r‡   r‰   r¨   rc   rd   re   rj   rC   rh   r®   r¯   r¼   r   rÁ   rÌ   rÎ   rÐ   rö   r  r  r  rA  rC  rQ  rU  Ú	ExceptionrW  r`  rc  re  rj  rM  r  r†  rŽ  r¨  r™  rÁ  rÃ  r=   r*   r(   ú<module>rÝ     s2  ðò Cã Û ã Ý DÝ $Ý &Ý "Û å #Ý ;Ý 3Ý CÝ 0Ý +Ý :Ý AÝ 2Ý 4Ý 1Ý 3÷
÷ 
õ 
ð ×ÑÓ ØÓ ð SÐ ØÐ ØM€ØGÐ ð%ð ð Vð ð &×4Ñ4×@Ñ@×MÑMÐ à‡O�O×"Ñ" J×$7Ñ$7Ø‡O�O×Ñ˜z×2Ñ2ðÐ ô-$ˆvô -$ó`""ðJA˜5Ÿ>™>×/Ñ/ó AðHL ó LðÐ,fð Ðksð  u_ñ  l`ó ÷1
ñ 1
ðh¸Có ð<4?à
Øˆ$��U˜D (×"3Ñ"3°S¸%ÀÀxÐQWÐWñó4?ðn¨¨t°V¨|Ñ)<ó ð2°ó ð8 !ˆZ× Ñ Ð!AÓB€
ð 8=ñ(Ø )ð(àˆu�S˜#�X‰  TÐ)Ñ*ó(ó,*ð)°#ó )ôx˜ô xðv°D¸¿¹×9JÑ9JÑ4Kó ð4¸$¸u¿{¹{×?PÑ?PÑ:Qó ô:x;Ð 1ô x;ðvà	ˆ%�+‰+×
Ñ
Ñóô8#;Ð!2ô #;ðL¸DÀÇÁ×ARÑARÑ<Só ðB¨E¯K©K×,=Ñ,=ó ô(˜)ô ñ¸EÀ%ÈÀ+Ñ<Nó ð<	6 ð 	6¨t°E¸#¸s¸(±OÑ/Dó 	6ô"�&ô "ô*%=�{ô %=ôP#=�;ô #=ðL
°ó 
ð GKñØ�Ð.°×0AÑ0AÐAÑBÑCðàóð
.Ø	ˆy˜(×+Ñ+Ð+Ñ	,ð
.à	ˆy˜(×+Ñ+Ð+Ñ	,ð
.ð 	ó
.ð]Ø�c˜5�jÑ!ð]à9ð]ð 5ó]ð@'5¨E°#°u°*Ñ,=ð '5À)ÈDÐRVÐX\ÐL\ÑB]ó '5ðV ,0ò	#Ø# C™=ð	#àÐDÑEó	#ð$ð ð$ð Ð7Ñ8ô	$r*   