+
    =i                    <   ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	H
t
HtHtHtHtHtHtHtHtHtHt ^ RIHtHtHtHtHtHtHtHt ^ RIHt ^ RI H!t! ^ R	I"H#t# ^ R
I$H%t%H&t& ]'       d   ^ RI'H(t( ^ RI)H)t)H*t* . ROt+ ! R R4      t, ! R R4      t- ! R R]#4      t.R# )    )annotations)Path)TYPE_CHECKING)warn)BackgroundImageBorderCellControlFormattingTypeCustomFormattingCustomFormattingType
FormattingFormattingType
MergedCellStyleTextCellUnsupportedWarning)CUSTOM_FORMATTING_ALLOWED_CELLSDEFAULT_COLUMN_COUNTDEFAULT_ROW_COUNTFORMATTING_ACTION_CELLSFORMATTING_ALLOWED_CELLSMAX_COL_COUNTMAX_HEADER_COUNTMAX_ROW_COUNT)	ItemsList)_NumbersModel)	Cacheable)xl_cell_to_rowcolxl_range)Iterator)datetime	timedeltaDocumentSheetTablec                      ] tR t^+tRtRRR^^]]3R R llt]R R l4       t	]R	 R
 l4       t
]R R l4       t]R R l4       tRR R lltRR]]3R R lltR R ltR R ltRtR# )r#   au  
Create an instance of a new Numbers document.

If ``filename`` is ``None``, an empty document is created using the defaults
defined by the class constructor. You can optionally override these
defaults at object construction time.

Parameters
----------
filename: str | Path, optional
    Apple Numbers document to read.
sheet_name: *str*, *optional*, *default*: ``Sheet 1``
    Name of the first sheet in a new document
table_name: *str*, *optional*, *default*: ``Table 1``
    Name of the first table in the first sheet of a new
num_header_rows: int, optional, default: 1
    Number of header rows in the first table of a new document.
num_header_cols: int, optional, default: 1
    Number of header columns in the first table of a new document.
num_rows: int, optional, default: 12
    Number of rows in the first table of a new document.
num_cols: int, optional, default: 8
    Number of columns in the first table of a new document.

Raises
------
IndexError:
    If the sheet name already exists in the document.
IndexError:
    If the table name already exists in the first sheet.
UnsupportedError:
    If the document is encrypted.

NzSheet 1zTable 1c               8    V ^8  d   QhRRRRRRRRRRR	RR
RRR/# )   filenamezstr | Path | None
sheet_name
str | None
table_namenum_header_rows
int | Nonenum_header_colsnum_rowsnum_colsreturnNone )formats   "z/Users/tonyclaw/.openclaw/workspace/scripts/youtube-playlists/venv/lib/python3.14/site-packages/numbers_parser/document.py__annotate__Document.__annotate__O   sZ     4 4#4 4 	4
 $4 $4 4 4 
4    c                	   \        Vf   R M
\        V4      4      V n        V P                  P                  4       p\	        V P                  V\
        4      V n        Vf   W P                  ^ ,          n        V P                  ^ ,          P                  ^ ,          p	W9n        V	P                  V^,
          4       WIn        V	P                  V^,
          4       WYn        R # R # N)r   r   _model	sheet_idsr   r$   _sheetssheetsnametablesadd_rowr-   
add_columnr/   )
selfr)   r*   r,   r-   r/   r0   r1   refstables
   &&&&&&&&  r6   __init__Document.__init__O   s     $H,<D$x.Q{{$$& dE:",KKNKKN))!,E#J MM(Q,'$3!X\*$3! r9   c                   V ^8  d   QhRR/# )r(   r2   zlist[Sheet]r4   )r5   s   "r6   r7   r8   i          r9   c                    V P                   # )z7List[:class:`Sheet`]: A list of sheets in the document.)r>   rD   s   &r6   r?   Document.sheetsh        ||r9   c                   V ^8  d   QhRR/# )r(   r2   r%   r4   )r5   s   "r6   r7   r8   n   s     ( (u (r9   c                J    V P                   ^ ,          P                  ^ ,          # )zATable: return the first table of the first sheet in the document.)r?   rA   rL   s   &r6   default_tableDocument.default_tablem   s     {{1~$$Q''r9   c                   V ^8  d   QhRR/# )r(   r2   zdict[str, Style]r4   )r5   s   "r6   r7   r8   s   s     " "( "r9   c                .    V P                   P                  # )zTDict[str, :class:`Style`]: A dict mapping style names to to the corresponding style.)r<   stylesrL   s   &r6   rU   Document.stylesr   s     {{!!!r9   c                   V ^8  d   QhRR/# )r(   r2   zdict[str, CustomFormatting]r4   )r5   s   "r6   r7   r8   x   s     * * ; *r9   c                .    V P                   P                  # )zn
Dict[str, :class:`CustomFormatting`]: A dict mapping custom format names
to the corresponding custom format.
)r<   custom_formatsrL   s   &r6   rY   Document.custom_formatsw   s     {{)))r9   c               $    V ^8  d   QhRRRRRR/# )r(   r)   z
str | Pathpackageboolr2   r3   r4   )r5   s   "r6   r7   r8      s!     2 2Z 2$ 24 2r9   c                   V P                    F  pVP                   F  pV P                  P                  VP                  4      '       d>   V P                  P                  VP                  4      p\        RV R2\        ^R7       Kk  V P                  P                  VP                  VP                  4       K  	  K  	  V P                  P                  \        V4      V4       R# )a  
Save the document in the specified filename.

Parameters
----------
filename: str | Path
    The path to save the document to. If the file already exists,
    it will be overwritten.
package: bool, optional, default: False
    If ``True``, create a package format document (a folder) instead
    of a single file

Raises
------
FileFormatError:
    If attempting to write a package into a folder that is not an
    existing Numbers document.

zNot modifying pivot table ''
stacklevelN)r?   rA   r<   is_a_pivot_table	_table_idr,   r   r   recalculate_table_data_datasaver   )rD   r)   r\   sheetrF   r,   s   &&&   r6   rf   Document.save   s    ( [[E;;//@@!%!7!7!HJ5j\C*#$ KK66uT & ! 	h1r9   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	r(   r*   r+   r,   r0   r.   r1   r2   r3   r4   )r5   s   "r6   r7   r8      s<     8' 8'8' 8' 	8'
 8' 
8'r9   c                .   Ve#   WP                   9   d   RV R2p\        V4      hM&^pRV 2V P                   9   d   V^,          pK  RV 2pV P                   R,          P                  ^ ,          P                  pV P                  P                  V4      p\        V P                  V4      p	V	P                  P                  \        V P                  V P                  P                  VVV^ ^ VV4      4      4       V P                   P                  V	4       R# )az  
Add a new sheet to the current document.

If no sheet name is provided, the next available numbered sheet
will be generated in the series ``Sheet 1``, ``Sheet 2``, etc.

Parameters
----------
sheet_name: str, optional
    The name of the sheet to add to the document
table_name: *str*, *optional*, *default*: ``Table 1``
    The name of the table created in the new sheet
num_rows: int, optional, default: 12
    The number of columns in the newly created table
num_cols: int, optional, default: 8
    The number of columns in the newly created table

Raises
------
    IndexError: If the sheet name already exists in the document.

Nzsheet '' already existszsheet zSheet )
r>   
IndexError_tablesrc   r<   	add_sheetr$   appendr%   	add_table)
rD   r*   r,   r0   r1   msg	sheet_numprev_table_idnew_sheet_id	new_sheets
   &&&&&     r6   ro   Document.add_sheet   s   : !\\)
|+;< o% * I9+&$,,6Q	!)-JR(003=={{,,Z8$++|4	  %% !	
 	I&r9   c                   V ^8  d   QhRR/# )r(   r2   r   r4   )r5   s   "r6   r7   r8      s     1 1U 1r9   c                T   RV9   dF   VR,          e;   VR,          V P                   P                  9   d   RVR,           R2p\        V4      hRV9   dt   VR,          ei   \        VR,          \        4      '       g   Rp\        V4      hV P                   P                  VR,          P                  VR,          P                  4       \        R/ VB pVP                  f    V P                   P                  4       Vn
        RVn        W0P                   P                  VP                  &   V# )az  
Add a new style to the current document.

If no style name is provided, the next available numbered style
will be generated in the series ``Custom Style 1``, ``Custom Style 2``, etc.

.. code-block:: python

    red_text = doc.add_style(
        name="Red Text",
        font_name="Lucida Grande",
        font_color=RGB(230, 25, 25),
        font_size=14.0,
        bold=True,
        italic=True,
        alignment=Alignment("right", "top"),
    )
    table.write("B2", "Red", style=red_text)
    table.set_cell_style("C2", red_text)

Parameters
----------
kwargs: dict, optional
    Key-value pairs to pass to the :py:class:`~numbers_parser.Style` constructor.

Raises
------
TypeError:
    If ``font_size`` is not a ``float``, ``font_name`` is not a ``str``,
    ``bg_image`` is not a :py:class:`~numbers_parser.BackgroundImage`,
    or if any of the ``bool`` parameters are invalid.

r@   style 'rk   bg_imagez)bg_image must be a BackgroundImage objectTr4   )r<   rU   rm   
isinstancer   	TypeErrorstore_imagedatar)   r   r@   custom_style_name_update_styles)rD   kwargsrr   styles   &,  r6   	add_styleDocument.add_style   s    D Vv :vf~QUQ\Q\QcQc?cF6N++;<CS/!F:$6$BfZ0/BBAn$KK##VJ%7%<%<vj?Q?Z?Z[::668EJ#).5::&r9   c                   V ^8  d   QhRR/# )r(   r2   r   r4   )r5   s   "r6   r7   r8     s     I I-= Ir9   c                   RV9   dF   VR,          e;   VR,          V P                   P                  9   d   RVR,           R2p\        V4      hRV9   d)   VR,          P                  4       p \        V,          VR&   \        R/ VB pVP                  f    V P                   P                  4       Vn	        VP                  \        P                  8X  d   V P                   P                  V4       V# VP                  \        P                  8X  d   V P                   P                  V4       V# V P                   P!                  V4       V#   \
        \        3 d    RT R2p\        T4      Rhi ; i)	a  
Add a new custom format to the current document.

.. code-block:: python

    long_date = doc.add_custom_format(
        name="Long Date",
        type="datetime",
        date_time_format="EEEE, d MMMM yyyy"
    )
    table.set_cell_formatting("C1", "custom", format=long_date)

All custom formatting styles share a name and a type, described in the **Common**
parameters in the following table. Additional key-value pairs configure the format
depending upon the value of ``kwargs["type"]``.

:Common Args:
    * **name** (``str``) - The name of the custom format. If no name is provided,
      one is generated using the scheme ``Custom Format``, ``Custom Format 1``, ``Custom Format 2``, etc.
    * **type** (``str``, *optional*, default: ``number``) - The type of format to
      create:

      * ``"datetime"``: A date and time value with custom formatting.
      * ``"number"``: A decimal number.
      * ``"text"``: A simple text string.

:``"number"``:
    * **integer_format** (``PaddingType``, *optional*, default: ``PaddingType.NONE``) - How
      to pad integers.
    * **decimal_format** (``PaddingType``, *optional*, default: ``PaddingType.NONE``) - How
      to pad decimals.
    * **num_integers** (``int``, *optional*, default: ``0``) - Integer precision
      when integers are padded.
    * **num_decimals** (``int``, *optional*, default: ``0``) - Integer precision
      when decimals are padded.
    * **show_thousands_separator** (``bool``, *optional*, default: ``False``) - ``True``
      if the number should include a thousands separator.

:``"datetime"``:
    * **format** (``str``, *optional*, default: ``"d MMM y"``) - A POSIX strftime-like
      formatting string of `Numbers date/time directives <#datetime-formats>`_.

:``"text"``:
    * **format** (``str``, *optional*, default: ``"%s"``) - Text format.
      The cell value is inserted in place of %s. Only one substitution is allowed by
      Numbers, and multiple %s formatting references raise a TypeError exception
r@   Nformat 'rk   typeunsupported cell format type 'r_   r4   )r<   rY   rm   upperr   KeyErrorAttributeErrorr}   r   r@   custom_format_namer   NUMBER!add_custom_decimal_format_archiveDATETIME"add_custom_datetime_format_archiveadd_custom_text_format_archive)rD   r   rr   format_typecustom_formats   &,   r6   add_custom_formatDocument.add_custom_format  sR   b fv*v$++"<"<<VF^,,<=CS/!V ...0K/!5k!Bv
 )262%!%!?!?!AM!5!<!<<KK99-H
 	 #7#@#@@KK::=I  KK66}E n- /6{m1En$./s   ,E	 	$E-)r<   r>   F)__name__
__module____qualname____firstlineno____doc__r   r   rG   propertyr?   rQ   rU   rY   rf   ro   r   r   __static_attributes__r4   r9   r6   r#   r#   +   s    !J '+!*!*&'&'0342   ( ( " " * *2F "&!*038't1fI Ir9   c                      ] tR tRtR R lt]R R l4       t]R R l4       t]P                  R R	 l4       tR
R
R
]	]
^^3R R lltR R ltRtR
# )r$   iY  c                   V ^8  d   QhRR/# r(   r2   r3   r4   )r5   s   "r6   r7   Sheet.__annotate__Z  s     ; ;4 ;r9   c                	    W n         Wn        V P                  P                  V P                   4      p\        V P                  V\        4      V n        R # r;   )	_sheet_idr<   	table_idsr   r%   rn   )rD   modelsheet_idrE   s   &&& r6   rG   Sheet.__init__Z  s8    !{{$$T^^4 dE:r9   c                   V ^8  d   QhRR/# )r(   r2   zlist[Table]r4   )r5   s   "r6   r7   r   a  rJ   r9   c                    V P                   # )z4List[:class:`Table`]: A list of tables in the sheet.)rn   rL   s   &r6   rA   Sheet.tables`  rN   r9   c                   V ^8  d   QhRR/# r(   r2   strr4   )r5   s   "r6   r7   r   f       6 6c 6r9   c                L    V P                   P                  V P                  4      # )zstr: The name of the sheet.r<   r*   r   rL   s   &r6   r@   
Sheet.namee       {{%%dnn55r9   c                    V ^8  d   QhRRRR/# r(   valuer   r2   r3   r4   )r5   s   "r6   r7   r   k       6 6# 6$ 6r9   c                	R    V P                   P                  V P                  V4       R # r;   r   rD   r   s   &&r6   r@   r   j      t~~u5r9   Nc               8    V ^8  d   QhRRRRRRRRRRR	RR
RRR/# )r(   r,   r+   xzfloat | Noneyr0   r.   r1   r-   r/   r2   r%   r4   )r5   s   "r6   r7   r   n  sd     B
 B
B
 B
 	B

 B
 B
 $B
 $B
 
B
r9   c           
     l    V P                   R,          P                  pV P                  VVVVVVVV4      # )aV  
Add a new table to the current sheet.

If no table name is provided, the next available numbered table
will be generated in the series ``Table 1``, ``Table 2``, etc.

By default, new tables are positioned at a fixed offset below the last
table vertically in a sheet and on the left side of the sheet. Large
table headers and captions may result in new tables overlapping existing
ones. The ``add_table`` method takes optional coordinates for
positioning a table. A table's height and coordinates can also be
queried to help aligning new tables:

.. code:: python

    (x, y) = sheet.table[0].coordinates
    y += sheet.table[0].height + 200.0
    new_table = sheet.add_table("Offset Table", x, y)

Parameters
----------
table_name: str, optional
    The name of the new table.
x: float, optional
    The x offset for the table in points.
y: float, optional
    The y offset for the table in points.
num_rows: int, optional, default: 12
    The number of rows for the new table.
num_cols: int, optional, default: 10
    The number of columns for the new table.
num_header_rows: int, optional, default: 1
    The number of header rows for the new table.
num_header_cols: int, optional, default: 1
    The number of header columns for the new table.

Returns
-------
Table
    The newly created table.

Raises
------
    IndexError: If the table name already exists.

rl   )rn   rc   
_add_table)	rD   r,   r   r   r0   r1   r-   r/   from_table_ids	   &&&&&&&& r6   rq   Sheet.add_tablen  sB    p R(22	
 		
r9   c                   V ^8  d   QhRR/# )r(   r2   objectr4   )r5   s   "r6   r7   r     s     !  !  
! r9   c	                	x   Ve#   WP                   9   d   RV R2p	\        V	4      hM&^p
RV
 2V P                   9   d   V
^,          p
K  RV
 2pV P                  P                  V P                  VVVVVVVV4	      pV P                   P                  \        V P                  V4      4       V P                   R,          # )Nztable 'rk   ztable zTable rl   )rn   rm   r<   rq   r   rp   r%   )rD   r,   r   r   r   r0   r1   r-   r/   rr   	table_numnew_table_ids   &&&&&&&&&   r6   r   Sheet._add_table  s     !\\)
|+;< o% * I9+&$,,6Q	!)-J{{,,NN

 	E$++|<=||Br9   )r<   r   rn   )r   r   r   r   rG   r   rA   r@   setterr   r   rq   r   r   r4   r9   r6   r$   r$   Y  so    ;   6 6 
[[6 6
 "&03&'&'B
H!  ! r9   c                    a  ] tR tRtR V 3R llt]R R l4       t]P                  R R l4       t]R R	 l4       t]P                  R
 R l4       t]R R l4       t	]	P                  R R l4       t	]R R l4       t
]
P                  R R l4       t
]R R l4       t]P                  R R l4       t]R R l4       t]P                  R R l4       t]R R l4       t]R R l4       tRLR! R" lltRLR# R$ llt]R% R& l4       tRMR' R( llt]R) R* l4       tR+ R, ltRNR- R. lltRNR/ R0 lltR1 tR2R /R3 R4 lltR5 R6 ltRMR7 R8 lltROR9 R: lltROR; R< lltRPR= R> lltRPR? R@ lltRA RB ltRC RD lt RE RF lt!RG RH lt"RI RJ lt#RKt$V ;t%# )Qr%   i  c                   V ^8  d   QhRR/# r   r4   )r5   s   "r6   r7   Table.__annotate__  s     - -4 -r9   c           	     	\  < \         SV `  4        Wn        W n        V P                  P	                  V P                  4      V n        V P                  P                  V P                  4      V n        . V n        V P                  P                  W P                  4       V P                  P                  V4      p\        V P
                  4       F  pV P                  P                  . 4       \        V P                  4       F  pVP                  WE34      '       d   \        P                  ! W$WQ4      pMPV P                  P!                  W$V4      pVf   \        P"                  ! W$WQ4      pM\        P$                  ! W$WWV4      pV P                  V,          P                  V4       K  	  K  	  R # r;   )superrG   r<   rc   number_of_rowsr0   number_of_columnsr1   re   set_table_datamerge_cellsrangerp   is_merge_referencer	   _merged_cellstorage_buffer_empty_cell_from_storage)	rD   r   table_idr   rowcolcellbuffer	__class__s	   &&&     r6   rG   Table.__init__  s3   !224>>B55dnnE 
""8ZZ8kk--h7'CJJb!T]]+113*==,,XCGD![[77sKF~#//sJ#11(eT

3&&t, , (r9   c                   V ^8  d   QhRR/# r   r4   )r5   s   "r6   r7   r     r   r9   c                L    V P                   P                  V P                  4      # )zstr: The table's name.r<   r,   rc   rL   s   &r6   r@   
Table.name  r   r9   c                    V ^8  d   QhRRRR/# r   r4   )r5   s   "r6   r7   r     r   r9   c                	R    V P                   P                  V P                  V4       R # r;   r   r   s   &&r6   r@   r     r   r9   c                   V ^8  d   QhRR/# )r(   r2   r]   r4   )r5   s   "r6   r7   r     s     > >D >r9   c                L    V P                   P                  V P                  4      # )zAbool: ``True`` if the table name is visible, ``False`` otherwise.r<   table_name_enabledrc   rL   s   &r6   r   Table.table_name_enabled  s     {{--dnn==r9   c                    V ^8  d   QhRRRR/# r(   enabledr]   r2   r3   r4   )r5   s   "r6   r7   r     s     @ @$ @4 @r9   c                	R    V P                   P                  V P                  V4       R # r;   r   rD   r   s   &&r6   r   r     s    &&t~~w?r9   c                   V ^8  d   QhRR/# r(   r2   intr4   )r5   s   "r6   r7   r     s     ; ; ;r9   c                L    V P                   P                  V P                  4      # )zDbool: ``True`` if the table caption is visible, ``False`` otherwise.r<   caption_enabledrc   rL   s   &r6   r   Table.caption_enabled  s     {{**4>>::r9   c                    V ^8  d   QhRRRR/# r   r4   )r5   s   "r6   r7   r     s     = =t = =r9   c                	R    V P                   P                  V P                  V4       R # r;   r   r   s   &&r6   r   r     s    ##DNNG<r9   c                   V ^8  d   QhRR/# r   r4   )r5   s   "r6   r7   r     s     8 8 8r9   c                L    V P                   P                  V P                  4      # )zstr: The table's caption text.r<   caption_textrc   rL   s   &r6   captionTable.caption       {{''77r9   c                    V ^8  d   QhRRRR/# )r(   r   r   r2   r3   r4   )r5   s   "r6   r7   r     s     : :s :t :r9   c                	R    V P                   P                  V P                  V4       R # r;   r   )rD   r   s   &&r6   r   r     s      9r9   c                   V ^8  d   QhRR/# r   r4   )r5   s   "r6   r7   r          ; ; ;r9   c                L    V P                   P                  V P                  4      # )a?  
int: The number of header rows.

Example
-------
.. code-block:: python

    # Add an extra header row
    table.num_header_rows += 1

Raises
------
ValueError:
    If the number of headers is negative, exceeds the number of rows in the
    table, or exceeds Numbers maximum number of headers (``MAX_HEADER_COUNT``).

)r<   r-   rc   rL   s   &r6   r-   Table.num_header_rows      & {{**4>>::r9   c                   V ^8  d   QhRR/# r(   num_headersr   r4   )r5   s   "r6   r7   r   *       
H 
H3 
Hr9   c                	    V^ 8  d   Rp\        V4      hWP                  8  d   Rp\        V4      hV\        8  d   R\         R2p\        V4      hV P                  P	                  V P
                  V4      # )r   $Number of headers cannot be negativez2Number of headers cannot exceed the number of rows Number of headers cannot exceed z rows)
ValueErrorr0   r   r<   r-   rc   rD   r	  rr   s   && r6   r-   r  )  so    ?8CS/!&FCS/!))45E4FeLCS/!{{**4>>;GGr9   c                   V ^8  d   QhRR/# r   r4   )r5   s   "r6   r7   r   7  r  r9   c                L    V P                   P                  V P                  4      # )aE  
int: The number of header columns.

Example
-------
.. code-block:: python

    # Add an extra header column
    table.num_header_cols += 1

Raises
------
ValueError:
    If the number of headers is negative, exceeds the number of rows in the
    table, or exceeds Numbers maximum number of headers (``MAX_HEADER_COUNT``).

)r<   r/   rc   rL   s   &r6   r/   Table.num_header_cols6  r  r9   c                   V ^8  d   QhRR/# r  r4   )r5   s   "r6   r7   r   L  r
  r9   c                	    V^ 8  d   Rp\        V4      hWP                  8  d   Rp\        V4      hV\        8  d   R\         R2p\        V4      hV P                  P	                  V P
                  V4      # )r   r  z5Number of headers cannot exceed the number of columnsr  z columns)r  r1   r   r<   r/   rc   r  s   && r6   r/   r  K  so    ?8CS/!&ICS/!))45E4FhOCS/!{{**4>>;GGr9   c                   V ^8  d   QhRR/# r   r4   )r5   s   "r6   r7   r   Y  s     8 8 8r9   c                L    V P                   P                  V P                  4      # )z"int: The table's height in points.)r<   table_heightrc   rL   s   &r6   heightTable.heightX  r   r9   c                   V ^8  d   QhRR/# r   r4   )r5   s   "r6   r7   r   ^  s     7 7s 7r9   c                L    V P                   P                  V P                  4      # )z!int: The table's width in points.)r<   table_widthrc   rL   s   &r6   widthTable.width]  s     {{&&t~~66r9   Nc               $    V ^8  d   QhRRRRRR/# )r(   r   r   r  r.   r2   r4   )r5   s   "r6   r7   r   b  s&     C Cc C: C Cr9   c                N    V P                   P                  V P                  W4      # )ac  
The height of a table row in points.

.. code-block:: python

    # Double the row's height
    _ = table.row_height(4, table.row_height(4) * 2)

Parameters
----------
row: int
    The row number (zero indexed).
height: int
    The height of the row in points. If not ``None``, set the row height.

Returns
-------
int:
    The height of the table row.

)r<   
row_heightrc   )rD   r   r  s   &&&r6   r!  Table.row_heightb  s    , {{%%dnncBBr9   c               $    V ^8  d   QhRRRRRR/# )r(   r   r   r  r.   r2   r4   )r5   s   "r6   r7   r   z  s&     A AS A As Ar9   c                N    V P                   P                  V P                  W4      # )a  
The width of a table column in points.

Parameters
----------
col: int
    The column number (zero indexed).
width: int
    The width of the column in points. If not ``None``, set the column width.

Returns
-------
int:
    The width of the table column.

)r<   	col_widthrc   )rD   r   r  s   &&&r6   r%  Table.col_widthz  s    " {{$$T^^S@@r9   c                   V ^8  d   QhRR/# )r(   r2   ztuple[float]r4   )r5   s   "r6   r7   r     s     = =\ =r9   c                L    V P                   P                  V P                  4      # )z1Tuple[float]: The table's x, y offsets in points.)r<   table_coordinatesrc   rL   s   &r6   coordinatesTable.coordinates  s     {{,,T^^<<r9   c                    V ^8  d   QhRRRR/# )r(   values_onlyr]   r2   z"list[list[Cell]] | list[list[str]]r4   )r5   s   "r6   r7   r     s       1S r9   c                    V'       d7   V P                    UUu. uF  q" Uu. uF  q3P                  NK  	  upNK  	  upp# V P                   # u upi u uppi )a  
Return all rows of cells for the Table.

Parameters
----------
values_only:
    If ``True``, return cell values instead of :class:`Cell` objects

Returns
-------
List[List[Cell]] | List[List[str]]:
    List of rows; each row is a list of :class:`Cell` objects, or string values.

)re   r   )rD   r-  r   r   s   &&  r6   rows
Table.rows  sC     <@JJGJSC0CDZZC0JGGzz 1Gs   AAAAc                   V ^8  d   QhRR/# )r(   r2   z	list[str]r4   )r5   s   "r6   r7   r     s     # #i #r9   c                X   \        4       p\        V P                  4       F}  w  r#\        V4       Fi  w  rEVP                  '       g   K  VP                  pVP                  \        W$W&^ ,          ,           ^,
          WF^,          ,           ^,
          4      4       Kk  	  K  	  \        V4      # )a0  
List[str]: The merge ranges of cells in A1 notation.

Example
-------
.. code-block:: python

    >>> table.merge_ranges
    ['A4:A10']
    >>> table.cell("A4")
    <numbers_parser.cell.TextCell object at 0x1035f4a90>
    >>> table.cell("A5")
    <numbers_parser.cell.MergedCell object at 0x1035f5310>

)set	enumeratere   	is_mergedsizeaddr   sorted)rD   r   r   cellsr   r   r6  s   &      r6   merge_rangesTable.merge_ranges  s~    " e#DJJ/JC&u-	>>>99DOOHSs!W}q7H#UVPW-Z[J[$\] . 0
 k""r9   c                   V ^8  d   QhRR/# )r(   r2   zCell | MergedCellr4   )r5   s   "r6   r7   r     s     =$ =$. =$r9   c                x   \        V^ ,          \        4      '       d   \        V^ ,          4      w  r#M/\        V4      ^8w  d   \	        R\        V4      ,           4      hVw  r#W P
                  8  g   V^ 8  d   RV R2p\	        V4      hW0P                  8  g   V^ 8  d   RV R2p\	        V4      hV P                  P                  V P                  4       V P                  P                  V P                  ,          pVe!   V P                  WR,          ,          V,          # V P                  V,          V,          # )a  
Return a single cell in the table.

The ``cell()`` method supports two forms of notation to designate the position
of cells: **Row-column** notation and **A1** notation:

.. code-block:: python

    (0, 0)      # Row-column notation.
    ("A1")      # The same cell in A1 notation.

Parameters
----------
param1: int
    The row number (zero indexed).
param2: int
    The column number (zero indexed).

Returns
-------
Cell | MergedCell:
    A cell with the base class :class:`Cell` or, if merged, a :class:`MergedCell`.

Example
-------

.. code-block:: python

    >>> doc = Document("mydoc.numbers")
    >>> sheets = doc.sheets
    >>> tables = sheets["Sheet 1"].tables
    >>> table = tables["Table 1"]
    >>> table.cell(1,0)
    <numbers_parser.cell.TextCell object at 0x105a80a10>
    >>> table.cell(1,0).value
    'Debit'
    >>> table.cell("B2")
    <numbers_parser.cell.TextCell object at 0x105a80b90>
    >>> table.cell("B2").value
    1234.50

invalid cell reference row  out of rangecolumn )r|   r   r   lenrm   r0   r1   r<   calculate_table_categoriesrc   _table_categories_row_mapperre   )rD   argsr   r   rr   
row_mappers   &*    r6   r   
Table.cell  s    V d1gs##*473JS#Y!^6TBCCJS--37]+CS/!--37C5.CS/!..t~~>[[==dnnM
!::jo.s33zz#s##r9   c               0    V ^8  d   QhRRRRRRRRRRRR	/# )
r(   min_rowr.   max_rowmin_colmax_colr-  bool | Noner2   "Iterator[tuple[Cell] | tuple[str]]r4   )r5   s   "r6   r7   r     sN     K8 K8K8 K8 	K8
 K8 !K8 
,K8r9   c              #    "   Ve   TM^ pVe   TMV P                   ^,
          pVe   TM^ pVe   TMV P                  ^,
          pV^ 8  d   RV R2p\        V4      hW P                   8  d   RV R2p\        V4      hV^ 8  d   RV R2p\        V4      hW@P                  8  d   RV R2p\        V4      hV P                  4       pV P                  P                  V P                  4       V P                  P                  V P                  ,          pVe/   \        W^,           4       U	u. uF  qW,          ,          NK  	  pp	MWqV^,            pV Fc  p	V'       dC   \        ;QJ d    . R WV^,             4       F  NK  	  5M! R WV^,             4       4      x  KM  \        WV^,            4      x  Ke  	  R# u up	i 5i)at  
Produces cells from a table, by row.

Specify the iteration range using the indexes of the rows and columns.

Parameters
----------
min_row: int, optional
    Starting row number (zero indexed), or ``0`` if ``None``.
max_row: int, optional
    End row number (zero indexed), or all rows if ``None``.
min_col: int, optional
    Starting column number (zero indexed) or ``0`` if ``None``.
max_col: int, optional
    End column number (zero indexed), or all columns if ``None``.
values_only: bool, optional
    If ``True``, yield cell values rather than :class:`Cell` objects

Yields
------
Tuple[Cell] | Tuple[str]:
    :class:`Cell` objects or string values for the row

Raises
------
IndexError:
    If row or column values are out of range for the table

Example
-------

.. code:: python

    for row in table.iter_rows(min_row=2, max_row=7, values_only=True):
        sum += row

Nr?  r@  rA  c              3  8   "   T F  qP                   x  K  	  R # 5ir;   r   ).0r   s   & r6   	<genexpr>"Table.iter_rows.<locals>.<genexpr>F  s     N3M4JJ3Ms   
r0   r1   rm   r/  r<   rC  rc   rD  r   tuple)
rD   rI  rJ  rK  rL  r-  rr   r/  rF  r   s
   &&&&&&    r6   	iter_rowsTable.iter_rows  s    Z %0'a$0'dmma6G$0'a$0'dmma6GQ;	/CS/!]]"	/CS/!Q;G9M2CS/!]]"G9M2CS/!yy{..t~~>[[==dnnM
!5:7aK5PQ5Pc))5PDQD'A+.DCeN313MNeeN313MNNNC'A+677	 	 Rs   D)G +F;%G (AG c               0    V ^8  d   QhRRRRRRRRRRRR	/# )
r(   rK  r.   rL  rI  rJ  r-  rM  r2   rN  r4   )r5   s   "r6   r7   r   J  sN     K6 K6K6 K6 	K6
 K6 !K6 
,K6r9   c              #    a
"   Ve   TM^ pVe   TMV P                   ^,
          pVe   TM^ pVe   TMV P                  ^,
          pV^ 8  d   RV R2p\        V4      hW@P                   8  d   RV R2p\        V4      hV^ 8  d   RV R2p\        V4      hW P                  8  d   RV R2p\        V4      hV P                  4       pV P                  P                  V P                  4       V P                  P                  V P                  ,          pVe/   \        W4^,           4       U	u. uF  qW,          ,          NK  	  pp	MWsV^,            p\        W^,           4       Fu  o
V'       d7   \        ;QJ d    . V
3R lV 4       F  NK  	  5M! V
3R lV 4       4      x  KA  \        ;QJ d    . V
3R lV 4       F  NK  	  5M! V
3R lV 4       4      x  Kw  	  R# u up	i 5i)al  
Produces cells from a table, by column.

Specify the iteration range using the indexes of the rows and columns.

Parameters
----------
min_col: int, optional
    Starting column number (zero indexed) or ``0`` if ``None``.
max_col: int, optional
    End column number (zero indexed), or all columns if ``None``.
min_row: int, optional
    Starting row number (zero indexed), or ``0`` if ``None``.
max_row: int, optional
    End row number (zero indexed), or all rows if ``None``.
values_only: bool, optional
    If ``True``, yield cell values rather than :class:`Cell` objects.

Yields
------
Tuple[Cell] | Tuple[str]:
    :class:`Cell` objects or string values for the row

Raises
------
IndexError:
    If row or column values are out of range for the table

Example
=======

.. code:: python

    for col in table.iter_cols(min_row=2, max_row=7):
        sum += col.value

Nr?  r@  rA  c              3  H   <"   T F  qS,          P                   x  K  	  R # 5ir;   rQ  rR  r   r   s   & r6   rS  "Table.iter_cols.<locals>.<genexpr>  s     ;dsHNNds   "c              3  4   <"   T F  qS,          x  K  	  R # 5ir;   r4   r\  s   & r6   rS  r]    s     5HHs   rU  )rD   rK  rL  rI  rJ  r-  rr   r/  rF  row_numr   s   &&&&&&    @r6   	iter_colsTable.iter_colsJ  s    Z %0'a$0'dmma6G$0'a$0'dmma6GQ;	/CS/!]]"	/CS/!Q;G9M2CS/!]]"G9M2CS/!yy{..t~~>[[==dnnM
!=B7VWK=XY=X',--=XDYD'A+.DA+.Ce;d;ee;d;;;e55ee5555	 /	 Zs   D)G#,G5G#95G#/4G#c                	   \        V^ ,          \        4      '       d   \        V^ ,          4      w  r#VR,          pM?\        V4      ^8  d   \	        R\        V4      ,           4      hVR,          w  r#VR,          pV\
        8  d   V R\
        ^,
           2p\	        V4      hV\        8  d   V R\        ^,
           2p\	        V4      h\        V P                  V^,           4       F  pV P                  4        K  	  \        V P                  V^,           4       F  pV P                  4        K  	  W#.\        V4      O5# )r   :   NNr>  :r   r(   N:r(   NNz exceeds maximum row z exceeds maximum column )r|   r   r   rB  rm   r   r   r   r0   rB   r1   rC   rV  )rD   rE  r   r   valuesrr   _s   &*     r6   _validate_cell_coordsTable._validate_cell_coords  s   d1gs##*473JS"XFY]6TBCCcJS"XF-E.}q/@.ABCS/!-E1-!2C1DECS/!t}}cAg.ALLN / t}}cAg.AOO / )5=))r9   r   c                    V ^8  d   QhRRRR/# )r(   r   zStyle | str | Noner2   r3   r4   )r5   s   "r6   r7   r     s     =1 =1"4 =1 =1r9   c                  V P                   ! V!  w  r4p\        P                  ! W4V4      V P                  V,          V&   V P                  V,          V,          P	                  WPP                  V,          V,          4       V P
                  P                  V P                  4      pV P                  V P                  V,          V,          n        V P
                  V P                  V,          V,          n        V P                  V,          V,          P                  VP                  W434      4       W0P
                  P                  V P                  4      8  g*   W@P
                  P                  V P                  4      8  d%   V P
                  P                  P                  4        Ve   V P                  W4V4       R# R# )a  
Write a value to a cell and update the style/cell type.

The ``write()`` method supports two forms of notation to designate the position
of cells: **Row-column** notation and **A1** notation:

.. code:: python

    doc = Document("write.numbers")
    sheets = doc.sheets
    tables = sheets[0].tables
    table = tables[0]
    table.write(1, 1, "This is new text")
    table.write("B7", datetime(2020, 12, 25))
    doc.save("new-sheet.numbers")

Parameters
----------
row: int
    The row number (zero indexed)
col: int
    The column number (zero indexed)
value: str | int | float | bool | DateTime | Duration
    The value to write to the cell. The generated cell type is automatically
    created based on the type of ``value``.
style: Style | str | None
    The name of a document custom style or a :py:class:`~numbers_parser.cell.Style` object.

Warns
-----
RuntimeWarning:
    If the default value is a float that is rounded to the maximum number
    of supported digits.

Raises
------
IndexError:
    If the style name cannot be found in the document.
TypeError:
    If the style parameter is an invalid type.
ValueError:
    If the cell type cannot be determined from the type of `param3`.

N)rf  r	   _from_valuere   _update_valuer<   r   rc   
_set_mergegetr-   r/   name_ref_cache
mark_dirtyset_cell_style)rD   r   rE  r   r   r   r   s   &$*    r6   writeTable.write  s<   \ !66=5#//%@

3

3**5**S/#2FGkk--dnn=)-

3&&*kk

3#

3''
(CD,,T^^<<kkFaFaNNG
 A
 KK&&113%0 r9   c                   V ^8  d   QhRR/# r   r4   )r5   s   "r6   r7   r     s     ! !t !r9   c                	   V P                   ! V!  w  r#p\        V\        4      '       d!   W@P                  V,          V,          n        R# \        V\
        4      '       dh   W@P                  P                  9  d   R V R2p\        V4      hV P                  P                  V,          V P                  V,          V,          n        R# Rp\        V4      h)rz   ' does not existz*style must be a Style object or style nameN)
rf  r|   r   re   _styler   r<   rU   rm   r}   )rD   rE  r   r   r   rr   s   &*    r6   rp  Table.set_cell_style  s     66=5eU##*/JJsOC 's##KK...w&67 o%*.++*<*<U*CDJJsOC '>CC. r9   c                    V ^8  d   QhRRRR/# )r(   r-  r]   r2   zdict | Noner4   )r5   s   "r6   r7   r     s     5 5D 5[ 5r9   c                   a V3R loV P                   P                  V P                  4       V P                   P                  V P                  ,          pV'       d	   S! V4      # V# )a(  
Return the table's data organized into categories, if enabled or ``None``
if the table has not had categories enabled.

The data is a set of nested dictionaries and lists. Dictionary keys are
Category keys and values are either another dictionary in the case of
nested categories or a list of rows. Each row is itself a list such that
the data is the same as returned by :py:meth:`numbers_parser.Table.rows`.

Parameters
----------
values_only:
    If ``True``, return cell values instead of :class:`Cell` objects

Returns
-------
Dict[str, Dict | List]:
    Nested dictionary of lists of rows or dictionaries of the next group
    of categories down. Row data is returned as :py:class:`Cell` classes
    unless ``values_only`` is ``True``.

Example
-------
.. code:: python

    "Transport": [
        {"Airplane", "Air": 5 },
        {"Helicopter": "Air", 2 },
        {"Bus": "Road", 10 },
    ],
    "Fruit": [
        {"Apple", "Green": 7 },
        {"Banana", "Yellow", 6 },
    ],

For tables with multiple categories, the top-level dictionary is nested.

c                  < \        V \        4      '       d,   V P                  4        UUu/ uF  w  rVS! V4      bK  	  upp# \        V \        4      '       d   V  Uu. uF  pS! V4      NK  	  up# V P                  # u uppi u upi r;   )r|   dictitemslistr   )itemkvdata_to_valuess   &  r6   r  .Table.categorized_data.<locals>.data_to_values$  ss    $%%9=F>!,,FF$%%3784aq)488:: G 9s   A=B)r<   rC  rc   _table_categories_data)rD   r-  r   r  s   && @r6   categorized_dataTable.categorized_data  sL    P	 	..t~~>{{11$..A!$''r9   c               (    V ^8  d   QhRRRRRRRR/# )r(   r0   r.   	start_rowdefault0str | float | bool | datetime | timedelta | Noner2   r3   r4   )r5   s   "r6   r7   r   3  s3     >2 >2>2 >2 B	>2
 
>2r9   c                   Ve%   V^ 8  g   W P                   8  d   Rp\        V4      hVf   V P                   pV ;P                   V,          un         V P                  P                  V P                  V P                   4       . p\        W"V,           4       Fa  pTP                  \        V P                  4       Uu. uF/  p\        P                  ! V P                  WgV P                  4      NK1  	  up4       Kc  	  WPP                  W"% \        W P                   4       F[  p\        V P                  4       F?  pW`P                  V,          V,          n        WpP                  V,          V,          n        KA  	  K]  	  VeJ   \        W"V,           4       F1  p\        V P                  4       F  pV P                  WgV4       K  	  K3  	  R# R# u upi )a.  
Add or insert rows to the table.

Parameters
----------
num_rows: int, optional, default: 1
    The number of rows to add to the table.
start_row: int, optional, default: None
    The start row number (zero indexed), or ``None`` to add a row to
    the end of the table.
default: str | int | float | bool | DateTime | Duration, optional, default: None
    The default value for cells. Supported values are those supported by
    :py:meth:`numbers_parser.Table.write` which will determine the new
    cell type.

Warns
-----
RuntimeWarning:
    If the default value is a float that is rounded to the maximum number
    of supported digits.

Raises
------
IndexError:
    If the start_row is out of range for the table.
ValueError:
    If the default value is unsupported by :py:meth:`numbers_parser.Table.write`.

N!Row number not in range for table)r0   rm   r<   r   rc   r   rp   r1   r	   r   re   r   r   rq  )rD   r0   r  r  rr   r/  r   r   s   &&&&    r6   rB   Table.add_row3  se   F  i!myMM7Q5CS/!I!""4>>4==A$89CKK  %T]]33 $$T^^St{{K3 : +/

9'MM2CT]]++.

3$(+.

3$( , 3
 YH(<= /CJJs1 0 > s   ;5G
c               (    V ^8  d   QhRRRRRRRR/# )r(   r1   r.   	start_colr  r  r2   r3   r4   )r5   s   "r6   r7   r   s  s3     82 8282 82 B	82
 
82r9   c           
        Ve%   V^ 8  g   W P                   8  d   Rp\        V4      hVf   V P                   pV ;P                   V,          un         V P                  P                  V P                  V P                   4       \        V P                  4       F  p\        V4       Uu. uF6  p\        P                  ! V P                  WRV,           V P                  4      NK8  	  ppWpP                  V,          W"% \        \        V P                  V,          4      4       F!  pW`P                  V,          V,          n        K#  	  Vf   K  \        W"V,           4       F  pV P                  WVV4       K  	  K  	  R# u upi )a:  
Add or insert columns to the table.

Parameters
----------
num_cols: int, optional, default: 1
    The number of columns to add to the table.
start_col: int, optional, default: None
    The start column number (zero indexed), or ``None`` to add a column to
    the end of the table.
default: str | int | float | bool | DateTime | Duration, optional, default: None
    The default value for cells. Supported values are those supported by
    :py:meth:`numbers_parser.Table.write` which will determine the new
    cell type.

Warns
-----
RuntimeWarning:
    If the default value is a float that is rounded to the maximum number
    of supported digits.

Raises
------
IndexError:
    If the start_col is out of range for the table.
ValueError:
    If the default value is unsupported by :py:meth:`numbers_parser.Table.write`.

N$Column number not in range for table)r1   rm   r<   r   rc   r   r0   r	   r   re   rB  r   rq  )rD   r1   r  r  rr   r   r   colss   &&&&    r6   rC   Table.add_columns  s'   F  i!myMM7Q8CS/!I!%%dnndmmD'C !?*C   #ot{{S*   48JJsOI0SC12+.

3$( 3 " ,@ACJJs1 B (s   '<E:c               $    V ^8  d   QhRRRRRR/# )r(   r0   r.   r  r2   r3   r4   )r5   s   "r6   r7   r     s(     ,3 ,3,3 ,3 
	,3r9   c                0   Ve%   V^ 8  g   W P                   8  d   Rp\        V4      hVe   V P                  W"V,           1 MV P                  V) R1 V ;P                   V,          un         V P                  P	                  V P
                  V P                   4       Vew   \        W P                   4       F[  p\        V P                  4       F?  pW@P                  V,          V,          n        WPP                  V,          V,          n	        KA  	  K]  	  R# R# )a  
Delete rows from the table.

Parameters
----------
num_rows: int, optional, default: 1
    The number of rows to add to the table.
start_row: int, optional, default: None
    The start row number (zero indexed), or ``None`` to delete rows
    from the end of the table.

Warns
-----
RuntimeWarning:
    If the default value is a float that is rounded to the maximum number
    of supported digits.

Raises
------
IndexError:
    If the start_row is out of range for the table.

Nr  )
r0   rm   re   r<   r   rc   r   r1   r   r   )rD   r0   r  rr   r   r   s   &&&   r6   
delete_rowTable.delete_row  s    8  i!myMM7Q5CS/! 

98';;<

H9:&!""4>>4==A Y6 /C/2JJsOC(,/2JJsOC(, 0 7 !r9   c               $    V ^8  d   QhRRRRRR/# )r(   r1   r.   r  r2   r3   r4   )r5   s   "r6   r7   r     s-     #E #E#E #E 
	#Er9   c                $   Ve%   V^ 8  g   W P                   8  d   Rp\        V4      h\        V P                  4       F  pVe   V P                  V,          W"V,           1 MV P                  V,          V) R1 \        \        V P                  V,          4      4       F!  pWPP                  V,          V,          n        K#  	  K  	  V ;P                   V,          un         V P                  P                  V P                  V P                   4       R# )a~  
Add or delete columns columns from the table.

Parameters
----------
num_cols: int, optional, default: 1
    The number of columns to add to the table.
start_col: int, optional, default: None
    The start column number (zero indexed), or ``None`` to add delete columns
    from the end of the table.

Raises
------
IndexError:
    If the start_col is out of range for the table.

Nr  )
r1   rm   r   r0   re   rB  r   r<   r   rc   )rD   r1   r  rr   r   r   s   &&&   r6   delete_columnTable.delete_column  s    ,  i!myMM7Q8CS/!'C$JJsOIH0D$DEJJsOXIJ/SC12+.

3$( 3 ( 	!%%dnndmmDr9   c                    V ^8  d   QhRRRR/# )r(   
cell_rangezstr | list[str]r2   r3   r4   )r5   s   "r6   r7   r      s     )A )Ao )A$ )Ar9   c           
     B   \        V\        4      '       d   V F  pV P                  V4       K  	  R# VP                  R4      w  r4\	        V4      w  rV\	        V4      w  rxWu,
          ^,           p	W,
          ^,           p
V P
                  P                  V P                  4      pVP                  WVW34       \        V^,           V^,           4       Fx  p\        V^,           V^,           4       FW  p\        P                  ! V P                  WV P
                  4      V P                  V,          V&   VP                  WWVWx34       KY  	  Kz  	  \        V P                  4       F:  w  r\        V4       F&  w  rVP                  VP                  W34      4       K(  	  K<  	  R# )a  
Convert a cell range or list of cell ranges into merged cells.

Parameters
----------
cell_range: str | List[str]
    Cell range(s) to merge in A1 notation

Example
--------
.. code:: python

    >>> table.cell("B2")
    <numbers_parser.cell.TextCell object at 0x102c0d390>
    >>> table.cell("B2").is_merged
    False
    >>> table.merge_cells("B2:C2")
    >>> table.cell("B2").is_merged
    True

:N)r|   r}  r   splitr   r<   rc   
add_anchorr   r	   r   re   add_referencer4  rl  rm  )rD   r  r   start_cell_refend_cell_ref	row_start	col_startrow_endcol_endr0   r1   r   r   r   r9  r   s   &&              r6   r   Table.merge_cells   sO   , j$''  #   .8-=-=c-B*^%6~%F"Y!2<!@W*Q.H*Q.H++11$..AK""9(9MNY]GaK8 Q!<C+/+<+<T^^SW[WbWb+cDJJsOC(--cw8`a = 9
 (

3
!*5!1ICOOKOOSJ$?@ "2 4r9   c                   V ^8  d   QhRR/# r   r4   )r5   s   "r6   r7   r   +  s     cU cU cUr9   c                `   V P                   ! V!  vr#p\        V4      ^8X  d   Vw  rE^pM#\        V4      ^8X  d   Vw  rEpMRp\        V4      h\        V\        4      '       g   Rp\        V4      h\        V\
        4      '       g   Rp\        V4      h\        V\        4      '       d   V F  pV P                  W#WV4       K  	  R# V P                  V,          V,          p	V	P                  '       d?   VR8X  d   V	P                  ^,          ^8  g   VR8X  d   V	P                  ^ ,          ^8  gw   \        V	\        4      '       d~   VR8X  d   V	P                  V8  gI   VR8X  d   V	P                  V8  g1   VR8X  d   V	P                  V8  g   VR8X  d/   V	P                  V8  d   \!        V R	V R
V R2\"        ^R7       R# V P$                  P'                  V P(                  4       VR9   dB   \+        W3V,           4       F*  p
V P$                  P                  V P(                  W*WE4       K,  	  MUVR9   dB   \+        W"V,           4       F*  pV P$                  P                  V P(                  WWE4       K,  	  MRp\        V4      hV P$                  P-                  V P(                  W#WEV4       R# )a  
Set the borders for a cell.

Cell references can be row-column offsets or Excel/Numbers-style A1 notation. Borders
can be applied to multiple sides of a cell by passing a list of sides. The name(s)
of the side(s) must be one of ``"top"``, ``"right"``, ``"bottom"`` or ``"left"``.

Numbers supports different border styles for each cell within a merged cell range
for those cells that are on the outer part of the merge. ``numbers-parser`` will
ignore attempts to set these invisible cell edges and issue a ``RuntimeWarning``.

.. code-block:: python

    # Dashed line for B7's right border
    table.set_cell_border(6, 1, "right", Border(5.0, RGB(29, 177, 0), "dashes"))
    # Solid line starting at B7's left border and running for 3 rows
    table.set_cell_border("B7", "left", Border(8.0, RGB(29, 177, 0), "solid"), 3)

:Args (row-column):
    * **param1** (*int*): The row number (zero indexed).
    * **param2** (*int*): The column number (zero indexed).
    * **param3** (*str | List[str]*): Which side(s) of the cell to apply the border to.
    * **param4** (:py:class:`Border`): The border to add.
    * **param5** (*int*, *optional*, default: 1): The length of the stroke to add.

:Args (A1):
    * **param1** (*str*): A cell reference using Excel/Numbers-style A1 notation.
    * **param2** (*str | List[str]*): Which side(s) of the cell to apply the border to.
    * **param3** (:py:class:`Border`): The border to add.
    * **param4** (*int*, *optional*, default: 1): The length of the stroke to add.

Raises
------
TypeError:
    If an invalid number of arguments is passed or if the types of the arguments
    are invalid.

Warns:
-----
RuntimeWarning:
    If any of the sides to which the border is applied have been merged.

z-invalid number of arguments to border_value()z$border value must be a Border objectzborder length must be an intNrightbottomtopleftz
 edge of [,z] is merged; border not setr`   z#side must be a valid border segment)r  r  )r  r  )rf  rB  r}   r|   r   r   r}  set_cell_borderre   r5  r6  r   r  r  r  r  r   RuntimeWarningr<   extract_strokesrc   r   
add_stroke)rD   rE  r   r   sideborder_valuelengthrr   sr   border_col_numborder_row_nums   &*          r6   r  Table.set_cell_border+  s:   X !66=Dt9>#' TFY!^+/(TACC. ,//8CC. &#&&0CC. dD!!$$SqG zz#s#NNN'/diilQ&6DH<LQUQZQZ[\Q]`aQatZ((4>>C#7GOs(:H$);FNt~~'; &
3%q-HI
 ##DNN3$$"'6\":++DNNCQUd #;&&"'6\":++DNNNQUd #; 8CC. t~~sVTr9   c                    V ^8  d   QhRRRR/# )r(   rE  r   r2   r3   r4   )r5   s   "r6   r7   r     s"     nH nH nH4 nHr9   c                   V P                   ! V!  vr4p\        V4      ^8X  d   V^ ,          pM*\        V4      ^8  d   Rp\        V4      hRp\        V4      hVR8X  d   V P                  ! W43/ VB  R# V P                  ! W4V3/ VB  R# )a9  
Set the data format for a cell.

Cell references can be **row-column** offsets or Excel/Numbers-style **A1** notation.

.. code:: python

    table.set_cell_formatting(
        "C1",
        "datetime",
        date_time_format="EEEE, d MMMM yyyy"
    )
    table.set_cell_formatting(
        0,
        4,
        "number",
        decimal_places=3,
        negative_style=NegativeNumberStyle.RED
    )
    table.set_cell_formatting(
        3,
        0,
        "popup",
        popup_values=["Cat", "Dog", "Rabbit"],
        allow_none=True
    )

:Parameters:
    * **args** (*list*, *optional*) - Positional arguments for cell reference and data format type (see below)
    * **kwargs** (*dict*, *optional*) - Key-value pairs defining a formatting options for each data format (see below).

:Args (row-column):
    * **param1** (*int*): The row number (zero indexed).
    * **param2** (*int*): The column number (zero indexed).
    * **param3** (*str*): Data format type for the cell (see "data formats" below).

:Args (A1):
    * **param1** (*str*): A cell reference using Excel/Numbers-style A1 notation.
    * **param2** (*str*): Data format type for the cell (see "data formats" below).

:Raises:
    * **TypeError** -
        If a tickbox is chosen for anything other than ``bool`` values.
    * **IndexError** -
        If the current cell value does not match a list of popup items.

:Warns:
    * **RuntimeWarning** -
        If ``use_accounting_style`` is used with
        any ``negative_style`` other than ``NegativeNumberStyle.MINUS``, or
        if a rating is out of range 0 to 5 (rating is clamped to these values).

All formatting styles share a name and a type, described in the **Common**
parameters in the following table. Additional key-value pairs configure the format
depending upon the value of ``kwargs["type"]``.

:Common Args:
    * **name** (*str*) - The name of the custom format. If no name is provided,
      one is generated using the scheme ``Custom Format``, ``Custom Format 1``, ``Custom Format 2``, etc.
    * **type** (*str, optional, default: number*) - The type of format to
      create:

      * ``"base"``: A number base in the range 2-36.
      * ``"currency"``: A decimal formatted with a currency symbol.
      * ``"custom"``: A named custom cell format that is applied to multiple cells.
      * ``"datetime"``: A date and time value with custom formatting.
      * ``"fraction"``: A number formatted as the nearest fraction.
      * ``"percentage"``: A number formatted as a percentage
      * ``"number"``: A decimal number.
      * ``"scientific"``: A decimal number with scientific notation.
      * ``"tickbox"``: A checkbox (bool values only).
      * ``"rating"``: A star rating from 0 to 5.
      * ``"slider"``: A range slider.
      * ``"stepper"``: An up/down value stepper.
      * ``"popup"``: A menu of options.

:``"base"``:
    * **base_use_minus_sign** (*int, optional, default: 10*) - The integer
      base to represent the number from 2-36.
    * **base_use_minus_sign** (*bool, optional, default: True*) - If ``True``
      use a standard minus sign, otherwise format as two's compliment (only
      possible for binary, octal and hexadecimal.
    * **base_places** (*int, optional, default: 0*) - The number of
      decimal places, or ``None`` for automatic.

:``"custom"``:
    * **format** (*str | CustomFormatting*) - The name of a custom
        formatting the document or a :py:class:`~numbers_parser.CustomFormatting`
        object.

:``"currency"``:
    * **currency** (*str, optional, default: "GBP"*) - An ISO currency
      code, e.g. ``"GBP"`` or ``"USD"``.
    * **decimal_places** (*int, optional, default: 2*) - The number of
      decimal places, or ``None`` for automatic.
    * **negative_style** (*:py:class:`~numbers_parser.NegativeNumberStyle`, optional, default: NegativeNumberStyle.MINUS*) - How negative numbers are represented.
      See `Negative number formats <#negative-formats>`_.
    * **show_thousands_separator** (*bool, optional, default: False*) - ``True``
      if the number should include a thousands separator, e.g. ``,``
    * **use_accounting_style** (*bool, optional, default: False*) -  ``True``
      if the currency symbol should be formatted to the left of the cell and
      separated from the number value by a tab.

:``"datetime"``:
    * **date_time_format** (*str, optional, default: "dd MMM YYY HH:MM"*) - A POSIX
       strftime-like formatting string of `Numbers date/time
       directives <#datetime-formats>`_.

:``"fraction"``:
    * **fraction_accuracy** (*:py:class:`~numbers_parser.FractionAccuracy`, optional, default: FractionAccuracy.THREE* - The
        precision of the faction.

:``"percentage"``:
    * **decimal_places** (*float, optional, default: None*) -  number of
      decimal places, or ``None`` for automatic.
    * **negative_style** (*:py:class:`~numbers_parser.NegativeNumberStyle`, optional, default: NegativeNumberStyle.MINUS*) - How negative numbers are represented.
      See `Negative number formats <#negative-formats>`_.
    * **show_thousands_separator** (*bool, optional, default: False*) - ``True``
      if the number should include a thousands separator, e.g. ``,``

:``"scientific"``:
    * **decimal_places** (*float, optional, default: None*) - number of
      decimal places, or ``None`` for automatic.

:``"tickbox"``:
    * No additional parameters defined.

:``"rating"``:
    * No additional parameters defined.

:``"slider"``:
    * **control_format** (*ControlFormattingType, optional, default: ControlFormattingType.NUMBER*) - the format
        of the data in the slider. Valid options are ``"base"``, ``"currency"``,
        ``"datetime"``, ``"fraction"``, ``"percentage"``, ``"number"``,
        or ``"scientific". Each format allows additional parameters identical to those
        available for the formats themselves. For example, a slider using fractions
        is configured with ``fraction_accuracy``.
    * **increment** (*float, optional, default: 1*) - the slider's minimum value
    * **maximum** (*float, optional, default: 100*) - the slider's maximum value
    * **minimum** (*float, optional, default: 1*) - increment value for the slider

:`"stepper"``:
    * **control_format** (*ControlFormattingType, optional, default: ControlFormattingType.NUMBER*) - the format
        of the data in the stepper. Valid options are ``"base"``, ``"currency"``,
        ``"datetime"``, ``"fraction"``, ``"percentage"``, ``"number"``,
        or ``"scientific"``. Each format allows additional parameters identical to those
        available for the formats themselves. For example, a stepper using fractions
        is configured with ``fraction_accuracy``.
    * **increment** (*float, optional, default: 1*) - the stepper's minimum value
    * **maximum** (*float, optional, default: 100*) - the stepper's maximum value
    * **minimum** (*float, optional, default: 1*) - increment value for the stepper

:`"popup"``:
    * **popup_values** (*List[str|int|float], optional, default: None*) - values
        for the popup menu
    * **allow_none** (*bool, optional, default: True*) - If ``True``
        include a blank value in the list


z4too many positional arguments to set_cell_formattingzno type defined for cell formatcustomN)rf  rB  r}   _set_cell_custom_format_set_cell_data_format)rD   rE  r   r   r   r   rr   s   &*,    r6   set_cell_formattingTable.set_cell_formatting  s    B !66=Dt9>q'KY]HCC. 3CC. ("((<V<&&sGGr9   c               $    V ^8  d   QhRRRRRR/# )r(   r   r   r   r2   r3   r4   )r5   s   "r6   r7   r   @  s!     < <3 <S <t <r9   c                	   R V9  d   Rp\        V4      hVR ,          p\        V\        4      '       d   VR ,          pMl\        V\        4      '       dJ   WPP                  P
                  9  d   RV R2p\        V4      hV P                  P
                  V,          pMRp\        V4      hV P                  V,          V,          p\        V4      P                  pVP                  P                  P                  4       pV\        V,          9  d   RV RV 2p\        V4      hV P                  P                  V P                  V4      p	VP                  WP                  4       R# )r5   z$no format provided for custom formatr   ru  z7format must be a CustomFormatting object or format namecannot use  formatting for cells of type N)r}   r|   r   r   r<   rY   rm   re   r   r   r@   lowerr   custom_format_idrc   _set_formatting)
rD   r   r   r   rr   r   r   	type_nameformat_type_name	format_ids
   &&&,      r6   r  Table._set_cell_custom_format@  s5   6!8CC. x(m%566"8,Ms++KK$>$>> /?@ o% KK66}EMKCC. zz#s#J''	(--2288:;<LMM 011OPY{[C  KK00O	Y(:(:;r9   c               (    V ^8  d   QhRRRRRRRR/# )r(   r   r   r   r  r   r2   r3   r4   )r5   s   "r6   r7   r   ]  s/     5Z 5Z 5Z3 5Z# 5Z\` 5Zr9   c                	j    \         VP                  4       ,          p\        V,          pT P                  T,          T,          p\        T4      P                  p	T	\        T,          9  d   RT RT	 2p\        T4      h\        RRT/TB p
T\        9   d(   T P                  P                  T P                  YZ4      pMRpT\         P                  8H  pTR9   d{   RT9   d=    TR,          P                  p\         T,          pTR,          \         P                  8H  pM\         P"                  pT P                  P%                  T P                  Y4      pMTR	8X  d   TP&                  R
8X  d    T
P(                  '       g   Rp\+        T4      hTP&                  R
8w  d7   TP&                  T
P,                  9  d   RTP&                   R2p\+        T4      h\/        T\0        4      '       d   \         P2                  MRpT P                  P%                  T P                  TT
4      pM&T P                  P%                  T P                  YZ4      pTP5                  YYR7       R#   \        \        3 d    R T R2p\        T4      Rhi ; i  \        \        3 d    TR,          pRT RT 2p\        T4      Rhi ; i)r   r_   Nr  r  r   control_formatzunsupported number format 'z' for popup z none value not allowed for popupzcurrent cell value 'z!' does not match any popup valuesT)is_currencyr4   )sliderstepper)r   r   r   r   r   r}   re   r   r   r   r   r<   control_cell_archiverc   CURRENCYr@   r
   r   format_archiver   
allow_nonerm   popup_valuesr|   r   TEXTr  )rD   r   r   r  r   r   re  rr   r   r  
formatting
control_idr  r  number_format_typer  popup_format_types   &&&&,            r6   r  Table._set_cell_data_format]  s   	+()9)?)?)ABK()9:A
 zz#s#J''	45EFF 011OPY{[C   ;[;F;
6699$..+bJJ!^%<%<<446)	 %+,<%=%B%BN)7)G&"()9":>S>\>\"\K &4%:%:"224>>CUbI(zzR
(=(=(=8 o%zzRDJJj6M6M$M,TZZL8YZ   8B$7Q7Q 3 3W[224>>CTV`aI224>>;[IYZYc .) 	+23C2DAFCC.d*	+2 !.1  %+,<%=N77GvN^M_`C#  s   (I !:J $J /J2)re   r<   rc   r1   r0   r;   r   )NNNNF)rc  NN)rc  N)&r   r   r   r   rG   r   r@   r   r   r   r   r-   r/   r  r  r!  r%  r*  r/  r:  r   rW  r`  rf  rq  rp  r  rB   rC   r  r  r   r  r  r  r  r   __classcell__)r   s   @r6   r%   r%     s   - -2 6 6 
[[6 6 > > @ @ ; ; = = 8 8 ^^: : ; ;( 
H 
H ; ;( 
H 
H 8 8 7 7C0A& = =& # #0=$~K8ZK6Z*2=1t =1~!5n>2@82t,3\#EJ)AVcUJnH`<:5Z 5Zr9   N)r#   r$   r%   )/
__future__r   pathlibr   typingr   warningsr   numbers_parser.cellr   r   r	   r
   r   r   r   r   r   r   r   r   numbers_parser.constantsr   r   r   r   r   r   r   r   numbers_parser.containersr   numbers_parser.modelr   numbers_parser.numbers_cacher   numbers_parser.xrefsr   r   collections.abcr    r!   r"   __all__r#   r$   r%   r4   r9   r6   <module>r     sz    "       	 	 	 0 . 2 <(,
(k k\	z  z z|ZI |Zr9   