� J�g�����dZddlmZmZmZmZddlmZmZm Z ddl m Z ddl m Z mZmZddlmZerddlmZGd �d e��ZGd �d e��ZGd �de��Zd�ZGd�d��ZdS)u� Quoting section 8.2.2 "Document Outline" of the 2006 PDF spec 1.7: > The document outline consists of a tree-structured hierarchy of outline items (sometimes called bookmarks), > which serve as a visual table of contents to display the document’s structure to the user. The contents of this module are internal to fpdf2, and not part of the public API. They may change at any time without prior warning or any deprecation period, in non-backward-compatible ways. �)�List� NamedTuple�Optional� TYPE_CHECKING�)�Align�XPos�YPos)� TextStyle)� Destination� PDFObject� PDFString)� StructElem)�FPDFc�R�eZdZUeed<eed<eed<eed<dZee ed<dS)�OutlineSection�name�level� page_number�destN� struct_elem) �__name__� __module__� __qualname__�str�__annotations__�intr rrr���\/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/fpdf/outline.pyrrsQ������� �I�I�I� �J�J�J����� ����(,�K��*�%�,�,�,�,�,rrc�6��eZdZdZ ddededef�fd� Z�xZS)�OutlineItemDictionary) �_id�title�parent�prev�next�first�last�countrrNr$rrc����t�����t|d���|_d|_d|_d|_d|_d|_d|_ ||_ ||_ dS)NT)�encryptr) �super�__init__rr$r%r&r'r(r)r*rr)�selfr$rr� __class__s �r r.zOutlineItemDictionary.__init__,sn��� ���������u�d�3�3�3�� ��� ��� ��� ��� ��� ��� ��� �&����r)NN) rrr� __slots__rr rr.� __classcell__�r0s@r r"r"sm������� �I� !�"&� '�'��'��'� � '�'�'�'�'�'�'�'�'�'rr"c�"��eZdZdZ�fd�Z�xZS)�OutlineDictionary)r#�typer(r)r*c �r��t��jdi|��d|_d|_d|_d|_dS)Nz /Outlinesrr)r-r.r6r(r)r*)r/�kwargsr0s �r r.zOutlineDictionary.__init__As@��������"�"�6�"�"�"��� ��� ��� ��� � � r)rrrr1r.r2r3s@r r5r5>s=�������9�I���������rr5c#���K�t��}|V�g}i}|D]Պt�j�j�j���}|V��j|vr|�j}||_||_�jdz |vr|�jdz }n|}||_|j �||_ ||_ |xj dz c_ |� |��||�j<�fd�|� ��D��}��|g|zS)z� Build PDF objects constitutive of the documents outline, and yield them one by one, starting with the outline dictionary )r$rrrNc�2��i|]\}}|�jk�||��Sr)r)�.0r�oitem�sections �r � <dictcomp>z&build_outline_objs.<locals>.<dictcomp>hs6���' �' �' ���u��� �%�%� �5�%�%�%r)r5r"rrrrr'r&r%r(r)r*�append�items)�sections�outline� outline_items�last_outline_item_per_level� outline_item�last_outline_item_at_level�parent_outline_itemr=s @r �build_outline_objsrHIsb�����  �!�!�G� �M�M�M��M�"$��� � ��,��,����+� � � � � ���� �=�7� 7� 7�)D�W�]�)S� &�.:� &� +� :�L� � �=�1� � ;� ;� ;�"=�g�m�a�>O�"P� � �")� �1� �� � $� ,�(4� � %�#/�� ��!�!�Q�&�!�!����\�*�*�*�5A�#�G�M�2�' �' �' �' � ;� A� A� C� C�' �' �' �#�#� �9�}� $�$rc�r�eZdZdZ ddeefd�Zd d d efd �Zd d d efd �Z d d de efd�Z dS)�TableOfContentsa� A reference implementation of a Table of Contents (ToC) for use with `fpdf2`. This class provides a customizable Table of Contents that can be used directly or subclassed for additional functionality. To use this class, create an instance of `TableOfContents`, configure it as needed, and pass its `render_toc` method as the `render_toc_function` argument to `FPDF.insert_toc_placeholder()`. NF�@��?T� text_stylec�h�|p t��|_||_||_||_||_dS)N)r rM�use_section_title_styles� level_indent� line_spacing�ignore_pages_before_toc)r/rMrOrPrQrRs r r.zTableOfContents.__init__zs:��%�3� � � ���(@��%�(���(���'>��$�$�$r�pdfr�itemc���|jr$|j|jr|j|jSt|jjt tf��rtd|jj�����|jS)Nz2Unsupported l_margin value provided as TextStyle: ) rO�section_title_stylesr� isinstancerM�l_marginrr� ValueError)r/rSrTs r �get_text_stylezTableOfContents.get_text_style�su�� � (� 8�S�-E�d�j�-Q� 8��+�D�J�7� 7� �d�o�.��e� � =� =� ��_�T�_�E]�_�_��� ���rc �P�|�|j���}|j|j���}|�|�||����5|j|jz}|�|j |z��|� |j |z |j tjtj|t"j|j|jz���|���}|�|��}|j|z |z |jz }|dkr=|���|���}|j|z |z |jz }d} |dkr�|�| dz��|kr!| dz } |�| dz��|k�!t5| ��dkr_|� |j|z |jz | dd�tjtj|t"j|j|jz���|�|��|� |j|z |jz |tjtj|t"j|j|jz���ddd��dS#1swxYwYdS) N)�page)�w�text�new_x�new_y�link�align�hr�z �.r�����)�add_linkr�pages� get_label�use_text_stylerZrrP�set_xrX� multi_cell�epwrr �ENDr �LASTr�J� font_sizerQ�get_x�get_string_widthr]�r_margin�ln�len�L�LMARGIN�NEXT�R) r/rSrTra� page_label�indent� current_x�page_label_length�in_between_space� in_betweens r �render_toc_itemzTableOfContents.render_toc_item�s����|�|��!1�|�2�2���Y�t�/�0�:�:�<�<� �� � �� 3� 3�C�� >� >� ?� ?�0 �0 ��Z�$�"3�3�F� �I�I�c�l�V�+� ,� ,� ,� �N�N��'�F�"��Y��h��i���g��-�$�"3�3� � � � �� � � � �I� #� 4� 4�Z� @� @� �"�u�y�0�3D�D�s�|�S� ��!�#�#��������I�I�K�K� �#&�5�9�#4�7H�#H�3�<�#W� ��J��!�#�#��*�*�:��+<�=�=�@P�P�P��#�%�J��*�*�:��+<�=�=�@P�P�P��z�?�?�Q�&�&��N�N��%�)�+�c�l�:�'����_�"�h�"�i�!�#�g��-�$�*;�;�#���� �I�I�i� � � � �N�N��%�)�#�c�l�2���l��i���g��-�$�"3�3� � � � �Q0 �0 �0 �0 �0 �0 �0 �0 �0 �0 �0 �0 ����0 �0 �0 �0 �0 �0 s�)H%J�J�"JrBc�v�|D]5}|jr|j|jjkr�|�||���6dS)zTThis method can be overriden by subclasses to customize the Table of Contents style.N)rRr�toc_placeholder� start_pager�)r/rSrBr=s r � render_toczTableOfContents.render_toc�sV��� /� /�G��,� ��'�3�+>�+I�I�I�� � � ��g� .� .� .� .�  /� /r)NFrKrLT) rrr�__doc__rr r.rrZr�rr�rrr rJrJps���������+/�!&��� $� ?� ?��Y�'� ?� ?� ?� ?��&�������5�6�5��5�5�5�5�n/�f�/�t�N�/C�/�/�/�/�/�/rrJN)r��typingrrrr�enumsrr r �fontsr �syntaxr r r�structure_treer�fpdfrrr"r5rHrJrrr �<module>r�sz����=�<�<�<�<�<�<�<�<�<�<�<�$�$�$�$�$�$�$�$�$�$�������5�5�5�5�5�5�5�5�5�5�&�&�&�&�&�&���������-�-�-�-�-�Z�-�-�-�'�'�'�'�'�I�'�'�'�@����� ����$%�$%�$%�N`/�`/�`/�`/�`/�`/�`/�`/�`/�`/r
Memory