Ë
    Eêñiµ  ã                  ó¦   — d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 erddl
mZmZ ddlmZ dd„Zdd	„Z	 d	 	 	 	 	 	 	 dd„Zdd„Zdd„Zdd„Zdd„Zy
)ztData marshalling utilities for ArrowTable protobufs, which are used by
CustomComponent for dataframe serialization.
é    )Úannotations)ÚTYPE_CHECKINGÚAny)Údataframe_util)Úpandas_styler_utils)Ú	DataFrameÚIndex)Ú
ArrowTablec                ó<   — t        | t        «      rt        | «      S | S )z;Convert a tuple to a list. Leave as is if it's not a tuple.)Ú
isinstanceÚtupleÚlist)Úitems    úi/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/streamlit/components/v1/component_arrow.pyÚ_maybe_tuple_to_listr       s   € ä# D¬%Ô0Œ4�‹:Ð:°dÐ:ó    c                óX   — t        j                  | t        j                  d«       ¬«      S )aZ  Convert a DataFrame to Arrow IPC bytes for custom component v1.

    Uses ``convert_pandas_df_to_arrow_bytes`` with large-type downcasting
    enabled for pandas >= 3.0, where ``StringDtype`` is backed by
    ``large_string`` in Arrow. Third-party custom components bundling
    older Arrow JS libraries cannot decode these large type codes.
    z3.0.0)Údowncast_large_types)r   Ú convert_pandas_df_to_arrow_bytesÚis_pandas_version_less_than)Údfs    r   Ú$_convert_df_to_component_arrow_bytesr   %   s+   € ô ×:Ñ:Ø
Ü!/×!KÑ!KÈGÓ!TÐTôð r   Nc                óö   — t        j                  |«      rt        j                  | ||«       t        j                  |«      }t        | |j                  «       t        | |j                  «       t        | |«       y)a:  Marshall data into an ArrowTable proto.

    Parameters
    ----------
    proto : proto.ArrowTable
        Output. The protobuf for a Streamlit ArrowTable proto.

    data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict, or None
        Something that is or can be converted to a dataframe.

    N)
r   Úis_pandas_stylerr   Úmarshall_stylerÚconvert_anything_to_pandas_dfÚ_marshall_indexÚindexÚ_marshall_columnsÚcolumnsÚ_marshall_data)ÚprotoÚdataÚdefault_uuidr   s       r   Úmarshallr%   3   sZ   € ô ×&Ñ& tÔ,Ü×+Ñ+¨E°4¸ÔFä	×	5Ñ	5°dÓ	;€BÜ�E˜2Ÿ8™8Ô$Ü�e˜RŸZ™ZÔ(Ü�5˜"Õr   c                ó”   — ddl }t        t        t        |j                  «      «      }|j                  |«      }t        |«      | _        y)aH  Marshall pandas.DataFrame index into an ArrowTable proto.

    Parameters
    ----------
    proto : proto.ArrowTable
        Output. The protobuf for a Streamlit ArrowTable proto.

    index : pd.Index
        Index to use for resulting frame.
        Will default to RangeIndex (0, 1, 2, ..., n) if no index is provided.

    r   N)Úpandasr   Úmapr   Úvaluesr   r   r   )r"   r   ÚpdÚindex_valuesÚindex_dfs        r   r   r   J   s7   € ó äœÔ0°%·,±,Ó?Ó@€LØ�|‰|˜LÓ)€HÜ6°xÓ@€E…Kr   c                ó”   — ddl }t        t        t        |j                  «      «      }|j                  |«      }t        |«      | _        y)aZ  Marshall pandas.DataFrame columns into an ArrowTable proto.

    Parameters
    ----------
    proto : proto.ArrowTable
        Output. The protobuf for a Streamlit ArrowTable proto.

    columns : Index
        Column labels to use for resulting frame.
        Will default to RangeIndex (0, 1, 2, ..., n) if no column labels are provided.

    r   N)r'   r   r(   r   r)   r   r   r    )r"   r    r*   Úcolumn_valuesÚ
columns_dfs        r   r   r   ^   s7   € ó äœÔ1°7·>±>ÓBÓC€MØ—‘˜mÓ,€JÜ8¸ÓD€E…Mr   c                ó$   — t        |«      | _        y)zõMarshall pandas.DataFrame data into an ArrowTable proto.

    Parameters
    ----------
    proto : proto.ArrowTable
        Output. The protobuf for a Streamlit ArrowTable proto.

    df : pandas.DataFrame
        A dataframe to marshall.

    N)r   r#   )r"   r   s     r   r!   r!   r   s   € ô 6°bÓ9€E…Jr   c                óà  — t        j                  d«      rt        d«      ‚ddl}t        j                  | j
                  «      }t        j                  | j                  «      }t        j                  | j                  «      }|j                  |j                  «       |j                  «       j                  j                  «       |j                  «       j                  j                  «       ¬«      S )z�Convert ArrowTable proto to pandas.DataFrame.

    Parameters
    ----------
    proto : proto.ArrowTable
        Output. pandas.DataFrame

    z14.0.1zThe installed pyarrow version is not compatible with this component. Please upgrade to 14.0.1 or higher: pip install -U pyarrowr   N)r   r    )r   Úis_pyarrow_version_less_thanÚRuntimeErrorr'   Ú convert_arrow_bytes_to_pandas_dfr#   r   r    r   Úto_numpyÚTÚtolist)r"   r*   r#   r   r    s        r   Úarrow_proto_to_dataframer8   �   s¹   € ô ×2Ñ2°8Ô<ÜðIó
ð 	
ó
 ä×:Ñ:¸5¿:¹:ÓF€DÜ×;Ñ;¸E¿K¹KÓH€EÜ×=Ñ=¸e¿m¹mÓL€Gà�<‰<Ø�‰‹Ø�n‰nÓ× Ñ ×'Ñ'Ó)Ø× Ñ Ó"×$Ñ$×+Ñ+Ó-ð ó ð r   )r   r   Úreturnr   )r   r   r9   Úbytes)N)r"   ÚArrowTableProtor#   r   r$   z
str | Noner9   ÚNone)r"   r;   r   ú
Index[Any]r9   r<   )r"   r;   r    r=   r9   r<   )r"   r;   r   r   r9   r<   )r"   r;   r9   r   )Ú__doc__Ú
__future__r   Útypingr   r   Ú	streamlitr   Ústreamlit.elements.libr   r'   r   r	   Ústreamlit.proto.Components_pb2r
   r;   r   r   r%   r   r   r!   r8   © r   r   ú<module>rE      sm   ðñõ #ç %å $Ý 6áß'åLó;ó
ð CGðØðØ"%ðØ5?ðà	óó.Aó(Eó(:ôr   