Ë
    úmxik|  ã                  óÖ  — U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZ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 ddlZddlmc mZ dd	lm Z m!Z! dd
l"m#Z# ddl$m%Z%m&Z&m'Z' ejP                  dk\  rddlm)Z)m*Z*m+Z+ n
ddl,m)Z)m*Z*m+Z+ ejP                  dk\  r	ddlm-Z-m.Z. nddl,m-Z-m.Z. er ddl/Z0ddl"m1Z1 ddl2m3Z4 ddl5m6Z7  edd¬«      Z8 ede#¬«      Z9 ed«      Z: e.d«      Z; ed«      Z< e*de
de<f   e<f¬«      Z= e*de
e;e<f   e;e<f¬«      Z> e*dde:e<f¬«      Z? e*d e
e-e:e;f   e<f   e:e;e<f¬«      Z@e+ G d!„ d"e)«      «       ZAd#d$d%dd&d'œZBeBj‡                  «       D � �ci c]  \  } }|| “Œ
 c}} ZDg d(¢ZEg d)¢ZFg d*¢ZG eH ej’                   eJeB«       eJeD«      «      «      ZKd+d,j™                  d-j›                  eK«      «      d.d/d0j™                  d-j›                  eE«      «      d1j™                  d-j›                  eEeFz   «      «      d2j™                  d-j›                  eG«      «      d3œZN eOd4«      ZPd5eQd6<   	 	 	 	 dLd7„ZRdMd8„ZSdNd9„ZTdOd:„ZUdPd;„ZV	 	 	 	 dQd<„ZWdRd=„ZX	 	 	 	 	 dS	 	 	 	 	 	 	 	 	 	 	 	 	 dTd>„ZY	 	 	 	 dUd?„ZZdVd@„Z[e	 dW	 	 	 	 	 	 	 dXdA„«       Z\e	 	 	 	 	 	 	 	 dYdB„«       Z\	 dZ	 	 	 	 	 	 	 d[dC„Z\d\d]dD„Z]edE   Z^dFeQdG<   	  G dH„ dF«      Z_dI„ Z`	 	 	 	 d^dJ„Zad_dK„Zbyc c}} w )`zUtility routines.é    )ÚannotationsN)ÚCallableÚIteratorÚMappingÚMutableMapping)Údeepcopy)Úgroupby)Ú
itemgetter)ÚTYPE_CHECKINGÚAnyÚLiteralÚTypeVarÚcastÚoverload)Úis_pandas_dataframeÚis_polars_dataframe)ÚIntoDataFrame)Ú
SchemaBaseÚ
SchemaLikeÚ	Undefined)é   é   )ÚProtocolÚTypeAliasTypeÚruntime_checkable)r   é
   )ÚConcatenateÚ	ParamSpec)ÚIntoExpr)Ú	DataFrame)ÚStandardType_TÚ_PandasDataFrameTzpd.DataFrame)ÚboundÚTIntoDataFrameÚTÚPÚRÚ	WrapsFunc.)Útype_paramsÚWrappedFuncÚWrapsMethodz Callable[Concatenate[T, ...], R]ÚWrappedMethodc                  ó"   — e Zd Z	 d	 	 	 	 	 dd„Zy)ÚDataFrameLikec                 ó   — y ©N© )ÚselfÚnan_as_nullÚ
allow_copys      úH/home/htdocs/ttos/venv/lib/python3.12/site-packages/altair/utils/core.pyÚ__dataframe__zDataFrameLike.__dataframe__>   s   € àó    N)FT)r3   Úboolr4   r8   ÚreturnÚDfiDataFrame)Ú__name__Ú
__module__Ú__qualname__r6   r1   r7   r5   r.   r.   <   s%   „ ð =AðØðØ59ðà	ôr7   r.   ÚOÚNÚQÚG)ÚordinalÚnominalÚquantitativeÚtemporalÚgeojson)ÚargmaxÚargminÚaverageÚcountÚdistinctÚmaxÚmeanÚmedianÚminÚmissingÚproductÚq1Úq3Úci0Úci1ÚstderrÚstdevÚstdevpÚsumÚvalidÚvaluesÚvarianceÚ	variancepÚexponentialÚexponentialb)Ú
row_numberÚrankÚ
dense_rankÚpercent_rankÚ	cume_distÚntileÚlagÚleadÚfirst_valueÚ
last_valueÚ	nth_value)QÚyearÚquarterÚmonthÚweekÚdayÚ	dayofyearÚdateÚhoursÚminutesÚsecondsÚmillisecondsÚyearquarterÚyearquartermonthÚ	yearmonthÚyearmonthdateÚyearmonthdatehoursÚyearmonthdatehoursminutesÚ yearmonthdatehoursminutessecondsÚyearweekÚyearweekdayÚyearweekdayhoursÚyearweekdayhoursminutesÚyearweekdayhoursminutessecondsÚyeardayofyearÚquartermonthÚ	monthdateÚmonthdatehoursÚmonthdatehoursminutesÚmonthdatehoursminutessecondsÚweekdayÚweeksdayhoursÚweekdayhoursÚweekdayhoursminutesÚweekdayhoursminutessecondsÚdayhoursÚdayhoursminutesÚdayhoursminutessecondsÚhoursminutesÚhoursminutessecondsÚminutessecondsÚsecondsmillisecondsÚutcyearÚ
utcquarterÚutcmonthÚutcweekÚutcdayÚutcdayofyearÚutcdateÚutchoursÚ
utcminutesÚ
utcsecondsÚutcmillisecondsÚutcyearquarterÚutcyearquartermonthÚutcyearmonthÚutcyearmonthdateÚutcyearmonthdatehoursÚutcyearmonthdatehoursminutesÚ#utcyearmonthdatehoursminutessecondsÚutcyearweekÚutcyearweekdayÚutcyearweekdayhoursÚutcyearweekdayhoursminutesÚ!utcyearweekdayhoursminutessecondsÚutcyeardayofyearÚutcquartermonthÚutcmonthdateÚutcmonthdatehoursÚutcmonthdatehoursminutesÚutcmonthdatehoursminutessecondsÚ
utcweekdayÚutcweekdayhoursÚutcweekdayhoursminutesÚutcweekdayhoursminutessecondsÚutcdayhoursÚutcdayhoursminutesÚutcdayhoursminutessecondsÚutchoursminutesÚutchoursminutessecondsÚutcminutessecondsÚutcsecondsmillisecondsz(?P<field>.*)z(?P<type>{})ú|z(?P<aggregate>count)z(?P<op>count)z(?P<aggregate>{})z
(?P<op>{})z(?P<timeUnit>{}))ÚfieldÚtypeÚ	agg_countÚop_countÚ	aggregateÚ	window_opÚtimeUnit)r½   rÁ   r¾   rÃ   z<frozenset[Literal['field', 'aggregate', 'type', 'timeUnit']]ÚSHORTHAND_KEYSc                ó  — ddl m}  || d¬«      }|dv ry|dk(  rHt        | d«      r<| j                  j                  r&d	| j                  j
                  j                  «       fS |d
v ry|dv ryt        j                  d|› d�d¬«       y)z­
    From an array-like input, infer the correct vega typecode.

    ('ordinal', 'nominal', 'quantitative', or 'temporal').

    Parameters
    ----------
    data: Any
    r   )Úinfer_dtypeF)Úskipna>   úmixed-integerúmixed-integer-floatÚcomplexÚintegerÚfloatingrD   ÚcategoricalÚcatrB   >   ÚbytesÚmixedÚstringÚbooleanÚunicoderÍ   rC   >   rq   ÚtimeÚperiodÚdatetimeÚ	timedeltaÚ
datetime64Útimedelta64rE   z.I don't know how to infer vegalite type from 'z'.  Defaulting to nominal.é   ©Ú
stacklevel)	Úpandas.api.typesrÆ   ÚhasattrrÎ   ÚorderedÚ
categoriesÚtolistÚwarningsÚwarn)ÚdatarÆ   Útyps      r5   Úinfer_vegalite_type_for_pandasræ   à   s¤   € õ -á
�d 5Ô
)€Cà
ð ñ ð Ø	�Ò	¤'¨$°Ô"6¸4¿8¹8×;KÒ;KØ˜4Ÿ8™8×.Ñ.×5Ñ5Ó7Ð8Ð8Ø	ÐQÑ	QØØ	ð ñ 
ð ä�‰Ø<¸S¸Eð B%ð %àõ	
ð
 r7   c                óš   — dD �ci c]  }|| |   “Œ
 }}	 | d   j                  |«       | d   }|S c c}w # t        t        f$ r |}Y |S w xY w)zf
    Merge properties with geometry.

    * Overwrites 'type' and 'geometry' entries if existing.
    ©r¾   ÚgeometryÚ
properties)ÚupdateÚAttributeErrorÚKeyError)ÚfeatÚkÚgeomÚ
props_geoms       r5   Úmerge_props_geomrò     sq   € ð !5Ö5˜1ˆAˆt�A‰w‰JÐ5€DÐ5ðØˆ\Ñ×!Ñ! $Ô'Ø˜,Ñ'ˆ
ð Ðùò 6øô œHÐ%ò ð ‰
àÐðús   …0•5 µA
Á	A
c                ó¸  — t        | «      } | D ]I  }t        t        | |   «      j                  «      j	                  d«      sŒ4| |   j                  «       | |<   ŒK t        j                  t        j                  | «      «      }|d   dk(  r6|d   }t        |«      dkD  r!t        |«      D ]  \  }}t        |«      ||<   Œ |S |d   dk(  rt        |«      }|S d|dœ}|S )zÝ
    Sanitize a geo_interface to prepare it for serialization.

    * Make a copy
    * Convert type array or _Array to list
    * Convert tuples to lists (using json.loads/dumps)
    * Merge properties with geometry
    )Ú_ArrayÚarrayr¾   ÚFeatureCollectionÚfeaturesr   ÚFeaturerè   )r   Ústrr¾   r;   Ú
startswithrá   ÚjsonÚloadsÚdumpsÚlenÚ	enumeraterò   )ÚgeoÚkeyÚgeo_dctÚidxrî   s        r5   Úsanitize_geo_interfacer  "  sî   € ô �3‹-€Cð ò )ˆÜŒt�C˜‘H‹~×&Ñ&Ó'×2Ñ2Ð3FÕGØ˜3‘x—‘Ó(ˆC�ŠHð)ô
 —J‘JœtŸz™z¨#›Ó/€Gð ˆv�Ð-Ò-Ø˜*Ñ%ˆÜˆw‹<˜!ÒÜ& wÓ/ò 6‘	��TÜ/°Ó5�˜’ð6ð €Nð 
�‰˜IÒ	%Ü" 7Ó+ˆð €Nð %°'Ñ:ˆà€Nr7   c                ón   — dd l }	 t        d|j                  | |«      «      S # t        t        f$ r Y yw xY w)Nr   r8   F)Únumpyr   Ú
issubdtypeÚNotImplementedErrorÚ	TypeError)ÚdtypeÚsubtypeÚnps      r5   Únumpy_is_subtyper  C  s9   € ãðÜ�F˜BŸM™M¨%°Ó9Ó:Ð:øÜ¤Ð+ò Ùðús   †" ¢4³4c                óˆ  ‡
— ddl Š
ddl}t        d| j                  «       «      } t	        | j
                  |j                  «      r$| j
                  j                  t        «      | _        | j
                  D ]#  }t	        |t        «      rŒd|›d�}t        |«      ‚ t	        | j                  |j                  «      rd}t        |«      ‚t	        | j
                  |j                  «      rd}t        |«      ‚ˆ
fd„}| j                  j                  «       D �]«  }t        d|d   «      }|d	   }t        |«      }|d
k(  r<| |   j                  t        «      }|j                  |j!                  «       d«      | |<   Œd|dk(  r<| |   j                  t        «      }|j                  |j!                  «       d«      | |<   Œ¥|dk(  r| |   j                  t        «      | |<   ŒÆ|dk(  r=| |   j                  t        «      }|j                  |j!                  «       d«      | |<   �Œ|j#                  d«      r*| |   j%                  d„ «      j'                  dd«      | |<   �ŒC|j#                  d«      rd|› d|› d�}t        |«      ‚|j#                  d«      r�Œ{|dv r=| |   j                  t        «      }|j                  |j!                  «       d«      | |<   �Œ¼t)        |‰
j*                  «      r| |   j                  t        «      | |<   �Œït)        |‰
j,                  «      rR| |   }|j/                  «       ‰
j1                  |«      z  }	|j                  t        «      j                  |	 d«      | |<   �ŒW|t        k(  s�Œb| |   j                  t        «      j%                  |«      }|j                  |j!                  «       d«      | |<   �Œ® | S )a  
    Sanitize a DataFrame to prepare it for serialization.

    * Make a copy
    * Convert RangeIndex columns to strings
    * Raise ValueError if column names are not strings
    * Raise ValueError if it has a hierarchical index.
    * Convert categoricals to strings.
    * Convert np.bool_ dtypes to Python bool objects
    * Convert np.int dtypes to Python int objects
    * Convert floats to objects and replace NaNs/infs with None.
    * Convert DateTime dtypes into appropriate string representations
    * Convert Nullable integers to objects and replace NaN with None
    * Convert Nullable boolean to objects and replace NaN with None
    * convert dedicated string column to objects and replace NaN with None
    * Raise a ValueError for TimeDelta dtypes
    r   Nr"   z(Dataframe contains invalid column name: z. Column names must be stringsz"Hierarchical indices not supportedc                óT   •— t        | ‰j                  «      r| j                  «       S | S r0   )Ú
isinstanceÚndarrayrá   )Úvalr  s    €r5   Úto_list_if_arrayz3sanitize_pandas_dataframe.<locals>.to_list_if_arrayx  s"   ø€ Ü�c˜2Ÿ:™:Ô&Ø—:‘:“<ÐàˆJr7   rù   rÚ   ÚcategoryrÑ   r8   rÒ   )rÖ   Ú	timestampc                ó"   — | j                  «       S r0   )Ú	isoformat)Úxs    r5   ú<lambda>z+sanitize_pandas_dataframe.<locals>.<lambda>   s   € ¨Q¯[©[«]€ r7   ÚNaTÚ r×   úField "ú" has type "ú^" which is not supported by Altair. Please convert to either a timestamp or a numerical value.ré   >
   ÚInt8ÚInt16ÚInt32ÚInt64ÚUInt8ÚUInt16ÚUInt32ÚUInt64ÚFloat32ÚFloat64)r  Úpandasr   Úcopyr  ÚcolumnsÚ
RangeIndexÚastyperù   Ú
ValueErrorÚindexÚ
MultiIndexÚdtypesÚitemsÚobjectÚwhereÚnotnullrú   ÚapplyÚreplacer  rË   rÌ   ÚisnullÚisinf)ÚdfÚpdÚcol_nameÚmsgr  Ú
dtype_itemr
  Ú
dtype_nameÚcolÚ
bad_valuesr  s             @r5   Úsanitize_pandas_dataframerB  M  s_  ø€ ó( Ûä	Ð! 2§7¡7£9Ó	-€Bä�"—*‘*˜bŸm™mÔ,Ø—Z‘Z×&Ñ&¤sÓ+ˆŒ
à—J‘Jò "ˆÜ˜(¤CÕ(à:¸8¸,ð G/ð /ð ô ˜S“/Ð!ð"ô �"—(‘(˜BŸM™MÔ*Ø2ˆÜ˜‹oÐÜ�"—*‘*˜bŸm™mÔ,Ø2ˆÜ˜‹oÐôð —i‘i—o‘oÓ'ó O:ˆ
ô ˜˜z¨!™}Ó-ˆØ˜1‘ˆÜ˜“Zˆ
Ø˜Ò#ð �X‘,×%Ñ%¤fÓ-ˆCØŸ9™9 S§[¡[£]°DÓ9ˆBˆxŠLØ˜8Ò#ð �X‘,×%Ñ%¤fÓ-ˆCØŸ9™9 S§[¡[£]°DÓ9ˆBˆxŠLØ˜6Ò!à˜h™<×.Ñ.¬vÓ6ˆBˆxŠLØ˜9Ò$ð �X‘,×%Ñ%¤fÓ-ˆCØŸ9™9 S§[¡[£]°DÓ9ˆBˆx‹LØ×"Ñ"Ð#<Ô=ð �8‘×"Ñ"Ñ#:Ó;×CÑCÀEÈ2ÓNð ˆx‹Lð ×"Ñ" ;Ô/à˜(˜ <°¨wð 7ð ð ô ˜S“/Ð!Ø×"Ñ" :Ô.ñ àðñð �X‘,×%Ñ%¤fÓ-ˆCØŸ9™9 S§[¡[£]°DÓ9ˆBˆx‹LÜ˜e R§Z¡ZÔ0à˜h™<×.Ñ.¬vÓ6ˆBˆx‹LÜ˜e R§[¡[Ô1ð �X‘,ˆCØŸ™›¨¯©°«Ñ5ˆJØŸ:™:¤fÓ-×3Ñ3°Z°KÀÓFˆBˆx‹LØ”fŒ_ð �X‘,×%Ñ%¤fÓ-×3Ñ3Ð4DÓEˆCØŸ9™9 S§[¡[£]°DÓ9ˆBˆx‹Lð_O:ð` €Ir7   c                óF  — | j                   }g }d}t        | j                  «       «      }|j                  «       D �]T  \  }}|t        j
                  k(  r]|r[|j                  t	        j                  |«      j                  t        j                  «      j                  j                  |«      «       Œw|t        j
                  k(  r>|j                  t	        j                  |«      j                  j                  |«      «       ŒÈ|t        j                  k(  rB|j                  t	        j                  |«      j                  j                  |› d�«      «       �Œ|t        j                  k(  rd|› d|› d�}t        |«      ‚|j                  |«       �ŒW | j                  |«      S )z3Sanitize narwhals.DataFrame for JSON serialization.z%Y-%m-%dT%H:%M:%Sz%.fr  r  r  )Úschemar   Ú	to_nativer2  ÚnwÚDateÚappendr@  r   ÚDatetimeÚdtÚ	to_stringÚDurationr.  Úselect)rä   rD  r+  Úlocal_iso_fmt_stringÚ	is_polarsÚnamer
  r=  s           r5   Úsanitize_narwhals_dataframerQ  Ñ  sE  € ð �[‰[€FØ €Gà.ÐÜ# D§N¡NÓ$4Ó5€IØ—|‘|“~ó !‰ˆˆeØ”B—G‘GÒ¡	ð �N‰NÜ—‘�t“×!Ñ!¤"§+¡+Ó.×1Ñ1×;Ñ;Ð<PÓQõð ”b—g‘gÒØ�N‰Nœ2Ÿ6™6 $›<Ÿ?™?×4Ñ4Ð5IÓJÕKØ”b—k‘kÒ!Ø�N‰Nœ2Ÿ6™6 $›<Ÿ?™?×4Ñ4Ð8LÐ7MÈSÐ5QÓRÖSØ”b—k‘kÒ!à˜$˜˜|¨E¨7ð 3ð ð ô ˜S“/Ð!à�N‰N˜4Ö ð)!ð* �;‰;�wÓÐr7   c                ó®   — t        j                  | d¬«      }t        j                  |«      dk(  r%ddlm}  || «      }t        j                  |d¬«      }|S )zÛ
    Wrap `data` in `narwhals.DataFrame`.

    If `data` is not supported by Narwhals, but it is convertible
    to a PyArrow table, then first convert to a PyArrow Table,
    and then wrap in `narwhals.DataFrame`.
    T©Úeager_or_interchange_onlyÚinterchanger   )Úarrow_table_from_dfi_dataframe)Ú
eager_only)rF  Úfrom_nativeÚ	get_levelÚaltair.utils.datarV  )rä   Údata_nwrV  Úpa_tables       r5   Úto_eager_narwhals_dataframer]  ò  sJ   € ô �n‰n˜T¸TÔB€GÜ	‡|�|�GÓ Ò-õ 	Eá1°$Ó7ˆÜ—.‘. °dÔ;ˆØ€Nr7   c           	     ó  ‡ — ddl m} ‰ si S g }|r$|j                  dg«       |j                  dg«       |r$|j                  dg«       |j                  dg«       |r|j                  dg«       |j                  dg«       |r"t        t	        j
                  d	„ |D «       Ž «      }d
„ |D «       }t        ‰ t        «      r‰ }	nt        ˆ fd„|D «       «      }	d|	v rt        j                  |	d   |	d   «      |	d<   |	ddik(  rd|	d<   d|	v r	d|	vrd|	d<   d|	vrÛ ||«      rÓ|	d   j                  dd«      }
t        j                  |d¬«      }|j                  }|
|v r—||
   }||
   t        j                  t        j                   hv r6t#        |j%                  «       «      rt'        |j%                  «       «      |	d<   nt)        |«      |	d<   t        |	d   t*        «      r|	d   d   |	d<   |	d   d   |	d<   d|	v r’d|	d   v r‹|	d   |	d   j-                  d«      dz
     dk7  rkt/        dj1                  |	d   j3                  d«      d   «      dj1                  dj5                  t6        j9                  «       «      «      z   dz   dz   d z   «      ‚|	S )!a 
  
    General tool to parse shorthand values.

    These are of the form:

    - "col_name"
    - "col_name:O"
    - "average(col_name)"
    - "average(col_name):O"

    Optionally, a dataframe may be supplied, from which the type
    will be inferred if not specified in the shorthand.

    Parameters
    ----------
    shorthand : dict or string
        The shorthand representation to be parsed
    data : DataFrame, optional
        If specified and of type DataFrame, then use these values to infer the
        column type if not provided by the shorthand.
    parse_aggregates : boolean
        If True (default), then parse aggregate functions within the shorthand.
    parse_window_ops : boolean
        If True then parse window operations within the shorthand (default:False)
    parse_timeunits : boolean
        If True (default), then parse timeUnits from within the shorthand
    parse_types : boolean
        If True (default), then parse typecodes within the shorthand

    Returns
    -------
    attrs : dict
        a dictionary of attributes extracted from the shorthand

    Examples
    --------
    >>> import pandas as pd
    >>> data = pd.DataFrame({"foo": ["A", "B", "A", "B"], "bar": [1, 2, 3, 4]})

    >>> parse_shorthand("name") == {"field": "name"}
    True

    >>> parse_shorthand("name:Q") == {"field": "name", "type": "quantitative"}
    True

    >>> parse_shorthand("average(col)") == {"aggregate": "average", "field": "col"}
    True

    >>> parse_shorthand("foo:O") == {"field": "foo", "type": "ordinal"}
    True

    >>> parse_shorthand("min(foo):Q") == {
    ...     "aggregate": "min",
    ...     "field": "foo",
    ...     "type": "quantitative",
    ... }
    True

    >>> parse_shorthand("month(col)") == {
    ...     "field": "col",
    ...     "timeUnit": "month",
    ...     "type": "temporal",
    ... }
    True

    >>> parse_shorthand("year(col):O") == {
    ...     "field": "col",
    ...     "timeUnit": "year",
    ...     "type": "ordinal",
    ... }
    True

    >>> parse_shorthand("foo", data) == {"field": "foo", "type": "nominal"}
    True

    >>> parse_shorthand("bar", data) == {"field": "bar", "type": "quantitative"}
    True

    >>> parse_shorthand("bar:O", data) == {"field": "bar", "type": "ordinal"}
    True

    >>> parse_shorthand("sum(bar)", data) == {
    ...     "aggregate": "sum",
    ...     "field": "bar",
    ...     "type": "quantitative",
    ... }
    True

    >>> parse_shorthand("count()", data) == {
    ...     "aggregate": "count",
    ...     "type": "quantitative",
    ... }
    True
    r   )Úis_data_typez{agg_count}\(\)z{aggregate}\({field}\)z{op_count}\(\)z{window_op}\({field}\)z{timeUnit}\({field}\)z{field}c              3  ó*   K  — | ]  }|d z   |f–— Œ y­w)z:{type}Nr1   ©Ú.0Úps     r5   ú	<genexpr>z"parse_shorthand.<locals>.<genexpr>~  s   è ø€ Ò)OÀ¨1¨y©=¸!Ô*<Ñ)Oùs   ‚c           	   3  ó˜   K  — | ]B  }t        j                  d  |j                  di t        ¤Žz   dz   t         j                  «      –— ŒD y­w)z\Az\ZNr1   )ÚreÚcompileÚformatÚSHORTHAND_UNITSÚDOTALLra  s     r5   rd  z"parse_shorthand.<locals>.<genexpr>€  s?   è ø€ ò àô 	�
‰
�5˜8˜1Ÿ8™8Ñ6¤oÑ6Ñ6¸Ñ>ÄÇ	Á	×Jñùs   ‚AA
c              3  ó~   •K  — | ]4  }|j                  ‰«      �!|j                  ‰«      j                  «       –— Œ6 y ­wr0   )ÚmatchÚ	groupdict)rb  ÚexpÚ	shorthands     €r5   rd  z"parse_shorthand.<locals>.<genexpr>‰  s:   øè ø€ ò 
àØ�y‰y˜Ó#Ð/ð �I‰I�iÓ ×*Ñ*×,ñ
ùs   ƒ:=r¾   rÁ   rJ   rD   rÃ   rE   r½   ú\r  TrS  rÚ   Úsortú:z"{}" éÿÿÿÿz0is not one of the valid encoding data types: {}.z, zi
For more details, see https://altair-viz.github.io/user_guide/encodings/index.html#encoding-data-types. z>If you are trying to use a column name that contains a colon, zPprefix it with a backslash; for example "column\:name" instead of "column:name".)rZ  r_  ÚextendÚlistÚ	itertoolsÚchainr  ÚdictÚnextÚINV_TYPECODE_MAPÚgetr7  rF  rX  rD  ÚObjectÚUnknownr   rE  ræ   Ú infer_vegalite_type_for_narwhalsÚtupleÚrfindr.  rh  ÚsplitÚjoinÚTYPECODE_MAPr[   )ro  rä   Úparse_aggregatesÚparse_window_opsÚparse_timeunitsÚparse_typesr_  ÚpatternsÚregexpsÚattrsÚunescaped_fieldr[  rD  Úcolumns   `             r5   Úparse_shorthandr�    sÀ  ø€ õL /áØˆ	à€HáØ�‰Ð+Ð,Ô-Ø�‰Ð2Ð3Ô4ÙØ�‰Ð*Ð+Ô,Ø�‰Ð2Ð3Ô4ÙØ�‰Ð1Ð2Ô3à‡O�O�Z�LÔ!áÜœ	Ÿ™Ñ)OÀhÔ)OÐPÓQˆñàô€Gô �)œTÔ"Ø‰äó 
àô
ó 
ˆð ��Ü(×,Ñ,¨U°6©]¸EÀ&¹MÓJˆˆf‰ð �˜gÐ&Ò&Ø&ˆˆf‰ð �UÑ˜v¨UÑ2Ø"ˆˆf‰ð �UÑ™|¨DÔ1Ø ™.×0Ñ0°°rÓ:ˆÜ—.‘. ÀÔFˆØ—‘ˆØ˜fÑ$Ø˜_Ñ-ˆFØ�oÑ&Ü—	‘	Ü—
‘
ð+ñ ô & g×&7Ñ&7Ó&9Ô:Ü >¸v×?OÑ?OÓ?QÓ R��f’ä @ÀÓ H��f‘Ü˜% ™-¬Ô/Ø % f¡¨aÑ 0��f‘Ø % f¡¨aÑ 0��f‘ð
 	�5ÑØ�5˜‘>Ñ!Ø�'‰N˜5 ™>×/Ñ/°Ó4°qÑ8Ñ9¸TÒAäØ�N‰N˜5 ™>×/Ñ/°Ó4°RÑ8Ó9Ø@×GÑGØ—	‘	œ,×-Ñ-Ó/Ó0óñð {ñ	{ð
 OñOð bñbó
ð 	
ð €Lr7   c                óÀ  — | j                   }t        j                  | «      r<| j                  j	                  «       x}j                  «       sd|j                  «       fS |t        j                  k(  s&|t        j                  k(  s|t        j                  k(  ry|j                  «       ry|t        j                  k(  s|t        j                  k(  ryd|› �}t        |«      ‚)NrB   rC   rD   rE   zUnexpected DtypeKind: )r
  rF  Úis_ordered_categoricalrÎ   Úget_categoriesÚis_emptyÚto_listÚStringÚCategoricalÚBooleanÚ
is_numericrI  rG  r.  )rŒ  r
  rà   r=  s       r5   r~  r~  À  s³   € ð �L‰L€Eä
×!Ñ! &Ô)Ø%Ÿz™z×8Ñ8Ó:Ð:�×DÑDÔFà˜*×,Ñ,Ó.Ð.Ð.Ø”—	‘	Ò˜U¤b§n¡nÒ4¸ÄÇÁÒ8KØØ	×	Ñ	Ô	ØØ	”"—+‘+Ò	 ¬"¯'©'Ò!1ð à& u gÐ.ˆÜ˜‹oÐr7   c               óH   ‡ — t         dd„«       }t         dd„«       }dˆ fd„}|S )a_  
    Use the signature and doc of ``tp`` for the decorated callable ``cb``.

    - **Overload 1**: Decorating method
    - **Overload 2**: Decorating function

    Returns
    -------
    **Adding the annotation breaks typing**:

        Overload[Callable[[WrapsMethod[T, R]], WrappedMethod[T, P, R]], Callable[[WrapsFunc[R]], WrappedFunc[P, R]]]
    c                ó   — y r0   r1   ©Úcbs    r5   Údecoratezuse_signature.<locals>.decorateå  s   € ØFIr7   c                ó   — y r0   r1   r™  s    r5   r›  zuse_signature.<locals>.decorateè  s   € Ø<?r7   c               ó  •— t        ‰d‰«      | _        ‰j                  x}rP| j                  xs d‰j                  › d�› d�}dj	                  |g|j                  d¬«      dd	 ¢­«      | _        | S d
‰›�}t        |«      ‚)zß
        Raises when no doc was found.

        Notes
        -----
        - Reference to ``tp`` is stored in ``cb.__wrapped__``.
        - The doc for ``cb`` will have a ``.rst`` link added, referring  to ``tp``.
        Ú__init__zRefer to :class:`ú`ú
r  T)ÚkeependsrÚ   NzFound no doc for )ÚgetattrÚ__wrapped__Ú__doc__r;   r‚  Ú
splitlinesrì   )rš  Údoc_inÚline_1r=  Útps       €r5   r›  zuse_signature.<locals>.decorateë  s‘   ø€ ô !  Z°Ó4ˆŒà—Z‘ZÐˆ6ÐØŸ
™
ÒHÐ(9¸"¿+¹+¸ÀaÐ&HÐIÈÐLˆFØŸ™ &Ð!P¨6×+<Ñ+<ÀdÐ+<Ó+KÈAÈBÐ+OÑ!PÓQˆBŒJØˆIà% b VÐ,ˆCÜ  Ó%Ð%r7   )rš  zWrapsMethod[T, R]r9   zWrappedMethod[T, P, R])rš  úWrapsFunc[R]r9   zWrappedFunc[P, R])rš  r©  r9   z*WrappedMethod[T, P, R] | WrappedFunc[P, R])r   )r¨  r›  s   ` r5   Úuse_signaturerª  ×  s-   ø€ ô ÚIó ØIäÚ?ó Ø?õ&ð& €Or7   c                 ó   — y r0   r1   ©Úoriginalrë   r*  s      r5   Úupdate_nestedr®    ó   € ð
  #r7   c                 ó   — y r0   r1   r¬  s      r5   r®  r®    r¯  r7   c                óê   — |rt        | «      } |j                  «       D ]R  \  }}t        |t        «      r8| j	                  |i «      }t        |t
        «      rt        ||«      | |<   ŒH|| |<   ŒN|| |<   ŒT | S )aî  
    Update nested dictionaries.

    Parameters
    ----------
    original : MutableMapping
        the original (nested) dictionary, which will be updated in-place
    update : Mapping
        the nested dictionary of updates
    copy : bool, default False
        if True, then copy the original dictionary rather than modifying it

    Returns
    -------
    original : MutableMapping
        a reference to the (modified) original dict

    Examples
    --------
    >>> original = {"x": {"b": 2, "c": 4}}
    >>> update = {"x": {"b": 5, "d": 6}, "y": 40}
    >>> update_nested(original, update)  # doctest: +SKIP
    {'x': {'b': 5, 'c': 4, 'd': 6}, 'y': 40}
    >>> original  # doctest: +SKIP
    {'x': {'b': 5, 'c': 4, 'd': 6}, 'y': 40}
    )r   r2  r  r   r{  r   r®  )r­  rë   r*  r  r  Úorig_vals         r5   r®  r®    sw   € ñ> Ü˜HÓ%ˆØ—L‘L“Nò  ‰ˆˆSÜ�cœ7Ô#Ø—|‘| C¨Ó,ˆHÜ˜(¤NÔ3Ü -¨h¸Ó <�˜’à #�˜’àˆH�SŠMð ð €Or7   c                óœ   — t        j                  «       }| rddlm}  |«       }nd }|�|j	                  |«       y t        j                  |Ž  y )Nr   )Úget_ipython)ÚsysÚexc_infoÚIPython.core.getipythonr´  ÚshowtracebackÚ	tracebackÚprint_exception)Ú
in_ipythonr¶  r´  Úips       r5   Údisplay_tracebackr½  :  s@   € Ü�|‰|‹~€HáÝ7á‹]‰àˆà	€~Ø
×Ñ˜Õ"ä×!Ñ! 8Ò,r7   )r½   ÚdatumÚvalueÚ_ChannelCacheÚ_CHANNEL_CACHEc                  óL   — e Zd ZU ded<   ded<   ed
d„«       Zdd„Zdd„Zdd„Zy	)rÀ  údict[type[SchemaBase], str]Úchannel_to_nameú/dict[str, dict[_ChannelType, type[SchemaBase]]]Úname_to_channelc                ó¼   — 	 t         }t         S # t        $ rD | j                  | «      }t        «       |_        t        |j                  «      |_        |a Y t         S w xY wr0   )rÁ  Ú	NameErrorÚ__new__Ú_init_channel_to_namerÄ  Ú_invert_group_channelsrÆ  )ÚclsÚcacheds     r5   Ú
from_cachez_ChannelCache.from_cacheV  s\   € ð	$Ü#ˆFô Ðøô ò 	$Ø—[‘[ Ó%ˆFÜ%:Ó%<ˆFÔ"Ü%;¸F×<RÑ<RÓ%SˆFÔ"Ø#‰NÜÐð	$ús   ‚ ŽAAÁAc               ó†   — | j                   j                  |«      x}r|S dt        |«      j                  ›�}t	        |«      ‚)Nzpositional of type )rÄ  r{  r¾   r;   r  )r2   r¨  Úencodingr=  s       r5   Úget_encodingz_ChannelCache.get_encodingb  sE   € Ø×+Ñ+×/Ñ/°Ó3Ð3ˆ8Ð3ØˆOØ#¤D¨£H×$5Ñ$5Ð#8Ð9ˆÜ! #Ó&Ð&r7   c               óì  — t        |t        «      r|S t        |t        «      rd|i}nVt        |t        t        f«      r |D �cg c]  }| j                  ||«      ‘Œ c}S t        |t        «      r|j                  «       }| j                  j                  |«      x}r|d|v rdnd   }	 |j                  |d¬«      S t        j                  d|›�d¬«       |S c c}w # t        j                  $ r |cY S w xY w)	Nro  r¿  r½   F)ÚvalidatezUnrecognized encoding channel rÚ   rÛ   )r  r   rù   ru  r  Ú_wrap_in_channelr   Úto_dictrÆ  r{  Ú	from_dictÚ
jsonschemaÚValidationErrorrâ   rã   )r2   ÚobjrÐ  ÚelÚchannelr¨  s         r5   rÔ  z_ChannelCache._wrap_in_channelh  sî   € Ü�cœ:Ô&ØˆJÜ˜œSÔ!Ø Ð$‰CÜ˜œd¤E˜]Ô+ØBEÖF¸B�D×)Ñ)¨"¨hÕ7ÒFÐFÜ˜œZÔ(Ø—+‘+“-ˆCØ×*Ñ*×.Ñ.¨xÓ8Ð8ˆ7Ð8Ø G¨s¡N™¸Ñ@ˆBðð —|‘| C°%�|Ó8Ð8ô
 �M‰MÐ:¸8¸,ÐGÐTUÕVØˆJùò Gøô ×-Ñ-ò à’
ðús   ÁCÂ'C ÃC3Ã2C3c          	     ó†   — |j                  «       D ��ci c]   \  }}|t        ur|| j                  ||«      “Œ" c}}S c c}}w r0   )r2  r   rÔ  )r2   ÚkwargsrÐ  rÙ  s       r5   Úinfer_encoding_typesz"_ChannelCache.infer_encoding_types~  sH   € ð "(§¡£÷
á�˜#Øœ)Ñ#ð �d×+Ñ+¨C°Ó:Ñ:ó
ð 	
ùó 
s   ”%=N)r9   rÀ  )r¨  z	type[Any]r9   rù   )rÙ  r   rÐ  rù   )rÝ  údict[str, Any])	r;   r<   r=   Ú__annotations__ÚclassmethodrÎ  rÑ  rÔ  rÞ  r1   r7   r5   rÀ  rÀ  R  s/   … Ø0Ó0ØDÓDàò	ó ð	ó'óô,
r7   c                 ó  — ddl m}  | j                  | j                  | j                  f}| j
                  j                  «       D �ci c];  }t        |t        «      r)t        ||«      rt        |t        «      r||j                  “Œ= c}S c c}w )aÂ  
    Construct a dictionary of channel type to encoding name.

    Note
    ----
    The return type is not expressible using annotations, but is used
    internally by `mypy`/`pyright` and avoids the need for type ignores.

    Returns
    -------
        mapping: dict[type[`<subclass of FieldChannelMixin and SchemaBase>`] | type[`<subclass of ValueChannelMixin and SchemaBase>`] | type[`<subclass of DatumChannelMixin and SchemaBase>`], str]
    r   )Úchannels)Úaltair.vegalite.v6.schemarã  ÚFieldChannelMixinÚValueChannelMixinÚDatumChannelMixinÚ__dict__r[   r  r¾   Ú
issubclassr   Ú_encoding_name)ÚchÚmixinsÚcs      r5   rÊ  rÊ  †  s{   € õ 9à×!Ñ! 2×#7Ñ#7¸×9MÑ9MÐM€Fð —‘×#Ñ#Ó%öàÜ�aœÔ¤:¨a°Ô#8¼ZÈÌ:Ô=Vð 	
ˆ1×ÑÑòð ùò s   ÁA B	c               ó”   — dd„}t        | j                  «       t        d«      «      }|D ��ci c]  \  }}| ||«      “Œ c}}S c c}}w )z;Grouped inverted index for `_ChannelCache.channel_to_name`.c                ó�   — i }| D ]>  \  }}|j                   }|j                  d«      rŒ$|j                  d«      rd}nd}|||<   Œ@ |S )z†
        Returns a 1-2 item dict, per channel.

        Never includes `datum`, as it is never utilized in `wrap_in_channel`.
        ÚDatumÚValuer¿  r½   )r;   Úendswith)ÚitÚitemr¨  Ú_rP  Úsub_keys         r5   Ú_reducez'_invert_group_channels.<locals>._reduce£  sZ   € ð -/ˆØò 	‰EˆB�Ø—;‘;ˆDØ�}‰}˜WÔ%ØØ—‘˜wÔ'Ø!‘à!�ØˆD�ŠMð	ð ˆr7   rÚ   )ró  zIterator[tuple[type[Any], str]]r9   r   )r	   r2  r
   )Úmr÷  Úgrouperrï   Úchanss        r5   rË  rË  ž  s@   € ó
ô$ �a—g‘g“i¤¨A£Ó/€GØ.5×6¡( ! UˆA‰w�u‹~ÑÓ6Ð6ùÓ6s   ­Ac                ó  — t         j                  «       }| D ]c  }t        |t        t        f«      rt        t        |«      d«      n|}|j                  t        |«      «      }||vr|||<   ŒTd|›d�}t        |«      ‚ |j                  |«      S )aa  
    Infer typed keyword arguments for args and kwargs.

    Parameters
    ----------
    args : Sequence
        Sequence of function args
    kwargs : MutableMapping
        Dict of function kwargs

    Returns
    -------
    kwargs : dict
        All args and kwargs in a single dict, with keys and types
        based on the channels mapping.
    Nz	encoding z specified twice.)rÀ  rÎ  r  ru  r  ry  ÚiterrÑ  r¾   r.  rÞ  )ÚargsrÝ  ÚcacheÚargrÚ  rÐ  r=  s          r5   rÞ  rÞ  ¹  s’   € ô" ×$Ñ$Ó&€Eàò "ˆÜ&0°´t¼U°mÔ&DŒT”$�s“)˜TÔ"È#ˆØ×%Ñ%¤d¨2£hÓ/ˆØ˜6Ñ!Ø"ˆF�8Òà˜h˜\Ð):Ð;ˆCÜ˜S“/Ð!ð"ð ×%Ñ% fÓ-Ð-r7   )rä   r   r9   z=InferredVegaLiteType | tuple[InferredVegaLiteType, list[Any]])rî   rß  r9   rß  )r   úMutableMapping[Any, Any]r9   rß  )r
  r   r  r   r9   r8   )r:  r"   r9   r"   )rä   únw.DataFrame[TIntoDataFrame]r9   r  )rä   r   r9   znw.DataFrame[Any])NTFTT)ro  zdict[str, Any] | strrä   zIntoDataFrame | Noner„  r8   r…  r8   r†  r8   r‡  r8   r9   rß  )rŒ  z	nw.Seriesr9   z8InferredVegaLiteType | tuple[InferredVegaLiteType, list])r¨  zCallable[P, Any]).)r­  r   rë   úMapping[Any, Any]r*  zLiteral[False]r9   r   )r­  r  rë   r  r*  zLiteral[True]r9   r   )F)r­  r   rë   r  r*  r8   r9   r   )T)r»  r8   )rø  rÃ  r9   rÅ  )rý  ztuple[Any, ...]rÝ  rß  )cr¤  Ú
__future__r   rv  rû   rf  rµ  r¹  râ   Úcollections.abcr   r   r   r   r*  r   r	   Úoperatorr
   Útypingr   r   r   r   r   r   r×  Únarwhals.stable.v1ÚstableÚv1rF  Únarwhals.stable.v1.dependenciesr   r   Únarwhals.stable.v1.typingr   Úaltair.utils.schemapir   r   r   Úversion_infor   r   r   Útyping_extensionsr   r   r)  r;  r   Úaltair.utils._dfi_typesr    r:   Ú!altair.vegalite.v6.schema._typingr!   ÚInferredVegaLiteTyper"   r$   r%   r&   r'   r(   r*   r+   r,   r.   rƒ  r2  rz  Ú
AGGREGATESÚWINDOW_AGGREGATESÚ	TIMEUNITSru  rw  rü  ÚVALID_TYPECODESrh  r‚  ri  Ú	frozensetrÄ   rà  ræ   rò   r  r  rB  rQ  r]  r�  r~  rª  r®  r½  Ú_ChannelTyperÀ  rÊ  rË  rÞ  )rï   Úvs   00r5   ú<module>r     s
  ðÚ å "ã Û Û 	Û 
Û Û ß GÓ GÝ Ý Ý ß G× Gã ß Ð ß TÝ 3ç CÑ Cà×Ñ�wÒßAÒAçLÑLØ×Ñ�wÒß-Ð-ç8ñ ÛÝ2åAÝXáÐ 3¸>ÔJÐáÐ)°Ô?€ÙˆCƒL€ÙˆcƒN€ÙˆCƒL€á˜+ x°°Q°Ñ'7ÀaÀTÔJ€	Ù˜M¨8°A°q°D©>ÈÈ1ÀvÔN€ñ ØÐ5ÀAÀqÀ6ô€ñ Ø�X˜k¨!¨Q¨$Ñ/°Ð2Ñ3À!ÀQÈÀô€ð
 ô�Hó ó ðð ØØØØñ€ð &2×%7Ñ%7Ó%9×:™T˜Q �A�q‘DÓ:Ð ò€
ò:Ð òR€	ñh ��y—‘¡t¨LÓ'9¹4Ð@PÓ;QÓRÓS€ð Ø×!Ñ! #§(¡(¨?Ó";Ó<Ø'ØØ$×+Ñ+¨C¯H©H°ZÓ,@ÓAØ×$Ñ$ S§X¡X¨jÐ;LÑ.LÓ%MÓNØ"×)Ñ)¨#¯(©(°9Ó*=Ó>ñ€ñ Ð8Ó9ð ÐLó ð
-Ø
ð-àBó-ó`ó$óBóAðH Ø
&ð à!ó óBð* "&Ø!Ø"Ø ØðxØ#ðxà
ðxð ðxð ð	xð
 ðxð ðxð óxðvØðà=óó.'ðT 
ð ð#Ø&ð#àð#ð ð#ð ò	#ó 
ð#ð
 
ð#Øð#àð#ð ð#ð ò	#ó 
ð#ð ð*Øð*àð*ð ð*ð ó	*ôZ-ð  Ð0Ñ1€ØÓ ð÷1
ñ 1
òhð07Ø"ð7à4ó7ô6.ùó] ;s   Å0K%