� K�gi6��~�UdZddlmZddlZddlZddlZddlmZmZddl m Z ddl m Z m Z mZmZmZmZmZe rddlmZddlmcmZed��Z gd �Zd ed < d Z d Z edzZ edzezZ ejedz��Z edzezZ! edzezZ" eje"dz��Z# edzezZ$ dZ%ed���d���Z&d8d9d�Z'd:d;d&�Z(d<d(�Z)d8d=d*�Z*d>d+�Z+Gd,�d-e,��Z-Gd.�d/��Z.e rGd0�d1e��Z/Gd2�d3��Z0Gd4�d5e��Z1Gd6�d7e e��Z2dS)?zv This module contains various contacts, classes and functions which get referenced and used throughout the code base. �)� annotationsN)�wraps� lru_cache)�count)� TYPE_CHECKING�Generic�Iterator� NamedTuple�TypeVar� TypedDict�overload)�Markdown�_T):�address�article�aside� blockquote�details�div�dl�fieldset� figcaption�figure�footer�form�h1�h2�h3�h4�h5�h6�header�hgroup�hr�main�menu�nav�ol�p�pre�section�table�ul�canvas�colgroup�dd�body�dt�group�html�iframe�li�legend�math�map�noscript�output�object�option�progress�script�style�summary�tbody�td�textarea�tfoot�th�thead�tr�videoz list[str]�BLOCK_LEVEL_ELEMENTS��zklzzwxh:z%sz([0-9]+)�ampz wzxhzdk:%sz hzzhzkh:%s))u֐u߿)uⴰu⵿)�maxsizec�d�tjdkrddlm}nddl}|�d���S)z= Return all entry_points in the `markdown.extensions` group. )�� r��metadataNzmarkdown.extensions)r3)�sys� version_info� importlibrS�importlib_metadata� entry_pointsrRs �]/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/markdown/util.py�get_installed_extensionsrZfsK�� ��7�"�"�&�&�&�&�&�&�&�-�-�-�-� � � �'<� � =� =�=���message�str� stacklevel�intc������fd�}|S)z� Raise a [`DeprecationWarning`][] when wrapped function/method is called. Usage: ```python @deprecated("This method will be removed in version X; use Y instead.") def some_method(): pass ``` c�B���t������fd���}|S)Nc�b��tjd�j�d���t�����|i|��S)N�'z' is deprecated. )�categoryr_)�warnings�warn�__name__�DeprecationWarning)�args�kwargs�funcr]r_s ���rY�deprecated_funcz4deprecated.<locals>.wrapper.<locals>.deprecated_func~sN��� �M�=�D�M�=�=�G�=�=�+�%� � � � � �4��(��(�(� (r[)r)rlrmr]r_s` ��rY�wrapperzdeprecated.<locals>.wrapper}s?���� �t��� )� )� )� )� )� )� �� )��r[�)r]r_rns`` rY� deprecatedrpqs)���� � � � � � � �Nr[TF�value� str | None�fail_on_errors�bool� preserve_none�return� bool | Nonec��t|t��s|r|�|St|��S|r|���dkrdS|���dvrdS|���dvrdS|rt d|z���dS)aParses a string representing a boolean value. If parsing was successful, returns `True` or `False`. If `preserve_none=True`, returns `True`, `False`, or `None`. If parsing was not successful, raises `ValueError`, or, if `fail_on_errors=False`, returns `None`.N�none)�true�yes�y�on�1T)�false�no�n�off�0ryFzCannot parse bool value: %r)� isinstancer^rt�lower� ValueError)rqrsrus rY�parseBoolValuer��s��� �e�S� !� !� @� � �U�]��L��E�{�{�� �@�5�;�;�=�=�F�2�2��t� �����9� 9� 9��t� �����B� B� B��u� �@��6��>�?�?�?�@�@r[�textc��d|vr|�dd��}d|vr|�dd��}d|vr|�dd��}|S)zHTML escape a string of code.�&z&amp;�<z&lt;�>z&gt;)�replace)r�s rY� code_escaper��s[�� �d�{�{��|�|�C��)�)�� �d�{�{��|�|�C��(�(�� �d�{�{��|�|�C��(�(�� �Kr[�sizec�l�tj|��}t|��D]}|j}|s|cS�dS)z+Get current stack depth, performantly. N)rT� _getframer�f_back)r��frames rY�_get_stack_depthr��sO�� �M�$� � �E��d� � ����� ��� ��K�K�K� ��r[c�N�tj��t��z dkS)zBReturn true if current stack depth is within 100 of maximum limit.�d)rT�getrecursionlimitr�ror[rY�nearing_recursion_limitr��s"�� � � "� "�%5�%7�%7� 7�#� =�=r[c��eZdZdZdS)� AtomicStringz/A string which should not be further processed.N)rh� __module__� __qualname__�__doc__ror[rYr�r��s������9�9��Dr[r�c��eZdZdZddd�ZdS)� Processorz� The base class for all processors. Attributes: Processor.md: The `Markdown` instance passed in an initialization. Arguments: md: The `Markdown` instance this processor is a part of. N�md�Markdown | Nonec��||_dS�N)r�)�selfr�s rY�__init__zProcessor.__init__�s ������r[r�)r�r�)rhr�r�r�r�ror[rYr�r��s7��������������r[r�c�8�eZdZUded<ded<ded<ded<dS) �TagDatar^�tag�dict[str, str]�attrsr`� left_index� right_indexN�rhr�r��__annotations__ror[rYr�r��s<������������������������r[r�c�8�eZdZdZd�Zdd�Zdd �Zdd �Zdd�ZdS)� HtmlStashz{ This class is used for stashing HTML objects that we extract in the beginning and replace with place-holders. c�>�d|_g|_d|_g|_dS)z Create an `HtmlStash`. rN)� html_counter� rawHtmlBlocks� tag_counter�tag_data�r�s rYr�zHtmlStash.__init__�s%�����8:������')�� � � r[r4�str | etree.Elementrvr^c��|j�|��|�|j��}|xjdz c_|S)a  Saves an HTML segment for later reinsertion. Returns a placeholder string that needs to be inserted into the document. Keyword arguments: html: An html segment. Returns: A placeholder string. �)r��append�get_placeholderr�)r�r4� placeholders rY�storezHtmlStash.store�sK�� ��!�!�$�'�'�'��*�*�4�+<�=�=� � ���Q�����r[�Nonec�"�d|_g|_dS)z Clear the stash. rN)r�r�r�s rY�resetzHtmlStash.reset�s���������r[�keyr`c��t|zSr�)�HTML_PLACEHOLDER�r�r�s rYr�zHtmlStash.get_placeholder�s ���#�%�%r[r�r�r�r�r�c��|j�||||d���tt|j��z}|xjdz c_|S)z(Store tag data and return a placeholder.)r�r�r�r�r�)r�r��TAG_PLACEHOLDERr^r�)r�r�r�r�r�r�s rY� store_tagzHtmlStash.store_tag�sa�� � ���S�5�,6�-8�:�:� ;� ;� ;�&��D�,<�(=�(=�=� � ���A�����r[N)r4r�rvr^�rvr�)r�r`rvr^) r�r^r�r�r�r`r�r`rvr^) rhr�r�r�r�r�r�r�r�ror[rYr�r��s}�������� *�*�*�����$ � � � � &�&�&�&������r[r�c�$�eZdZUded<ded<dS)� _PriorityItemr^�name�float�priorityNr�ror[rYr�r� s"������� �I�I�I��O�O�O�O�Or[r�c��eZdZdZd�Zd#d�Zd$d �Zed%d ���Zed&d���Zd'd�Zd(d�Z d�Z d)d�Z d*d�Z d+d,d �Z d-d!�Zd"S).�Registrya� A priority sorted registry. A `Registry` instance provides two public methods to alter the data of the registry: `register` and `deregister`. Use `register` to add items and `deregister` to remove items. See each method for specifics. When registering an item, a "name" and a "priority" must be provided. All items are automatically sorted by "priority" from highest to lowest. The "name" is used to remove ("deregister") and get items. A `Registry` instance it like a list (which maintains order) when reading data. You may iterate over the items, get an item and get a count (length) of all items. You may also check that the registry contains an item. When getting an item you may use either the index of the item or the string-based "name". For example: registry = Registry() registry.register(SomeItem(), 'itemname', 20) # Get the item by index item = registry[0] # Get the item by name item = registry['itemname'] When checking that the registry contains an item, you may use either the string-based "name", or a reference to the actual item. For example: someitem = SomeItem() registry.register(someitem, 'itemname', 20) # Contains the name assert 'itemname' in registry # Contains the item instance assert someitem in registry The method `get_index_for_name` is also available to obtain the index of an item using that item's assigned "name". c�0�i|_g|_d|_dS)NF)�_data� _priority� _is_sortedr�s rYr�zRegistry.__init__8s��$&�� �.0�������r[�item�str | _Trvrtc��t|t��r||j���vS||j���vSr�)r�r^r��keys�values)r�r�s rY� __contains__zRegistry.__contains__=sD�� �d�C� � � -��4�:�?�?�,�,�,� ,��t�z�(�(�*�*�*�*r[� Iterator[_T]c�l������t�fd��jD����S)Nc�0��g|]\}}�j|��Sro)r�)�.0�kr)r�s �rY� <listcomp>z%Registry.__iter__.<locals>.<listcomp>Fs#���>�>�>�t�q�!�T�Z��]�>�>�>r[)�_sort�iterr�r�s`rY�__iter__zRegistry.__iter__Ds5��� � � � � � ��>�>�>�>�t�~�>�>�>�?�?�?r[r�� str | intrc��dSr�ror�s rY� __getitem__zRegistry.__getitem__H��� �r[�slice� Registry[_T]c��dSr�ror�s rYr�zRegistry.__getitem__Lr�r[�str | int | slice�_T | Registry[_T]c�\�|���t|t��rEt��}|j|D]'\}}|�|j|||���(|St|t��r|j|j|jS|j|Sr�) r�r�r�r�r��registerr�r`r�)r�r��datar�r)s rYr�zRegistry.__getitem__Ps��� � � � � � � �c�5� !� !� �!)���D���s�+� 3� 3���1�� � �d�j��m�Q��2�2�2�2��K� �c�3� � � 8��:�d�n�S�1�6�7� 7��z�#��r[r`c�*�t|j��Sr�)�lenr�r�s rY�__len__zRegistry.__len__[s���4�>�"�"�"r[c�\�d�|jjt|����S)Nz<{}({})>)�format� __class__rh�listr�s rY�__repr__zRegistry.__repr__^s#��� � ���!8�$�t�*�*�E�E�Er[r�r^c�����|vrE|���|j��fd�|jD��d��Std�������)z5 Return the index of the given name. c�*��g|]}|j�k� |��Sro)r�)r��xr�s �rYr�z/Registry.get_index_for_name.<locals>.<listcomp>hs ���=�=�=�q�a�f��n�n��n�n�nr[rzNo item named "{}" exists.)r�r��indexr�r�)r�r�s `rY�get_index_for_namezRegistry.get_index_for_nameasr��� �4�<�<� �J�J�L�L�L��>�'�'�=�=�=�=�D�N�=�=�=�a�@��� ��5�<�<�T�B�B�C�C�Cr[r�r�r�c��||vr|�|��d|_||j|<|j�t ||����dS)aW Add an item to the registry with the given name and priority. Arguments: item: The item being registered. name: A string used to reference the item. priority: An integer or float used to sort against all items. If an item is registered with a "name" which already exists, the existing item is replaced with the new item. Treat carefully as the old item is lost with no way to recover it. The new item will be sorted according to its priority and will **not** retain the position of the old item. FN)� deregisterr�r�r�r�r�)r�r�r�r�s rYr�zRegistry.registerlsX�� �4�<�<� �O�O�D� !� !� !������ �4�� ����m�D�(�;�;�<�<�<�<�<r[T�strictc�z� |�|��}|j|=|j|=dS#t$r|r�YdSwxYw)z� Remove an item from the registry. Set `strict=False` to fail silently. Otherwise a [`ValueError`][] is raised for an unknown `name`. N)r�r�r�r�)r�r�r�r�s rYr�zRegistry.deregister�si��  ��+�+�D�1�1�E���u�%�� �4� � � ��� � � �� �� � � � ���s �%)� :�:c�`�|js&|j�d�d���d|_dSdS)z� Sort the registry by priority from highest to lowest. This method is called internally and should never be explicitly called. c��|jSr�)r�)r�s rY�<lambda>z Registry._sort.<locals>.<lambda>�s����r[T)r��reverseN)r�r��sortr�s rYr�zRegistry._sort�sB�� �� #� �N� � �$>�$>�� � M� M� M�"�D�O�O�O� #� #r[N)r�r�rvrt)rvr�)r�r�rvr)r�r�rvr�)r�r�rvr�)rvr`)r�r^rvr`)r�rr�r^r�r�rvr�)T)r�r^r�rtrvr�r�)rhr�r�r�r�r�r�r r�r�r�r�r�r�r�ror[rYr�r�s-������%�%�N � � � +�+�+�+�@�@�@�@�� � � ��X� �� � � ��X� � � � � �#�#�#�#�F�F�F� D� D� D� D�=�=�=�=�, � � � � �#�#�#�#�#�#r[r�)r\)r]r^r_r`)TF)rqrrrsrtrurtrvrw)r�r^rvr^)r�r`rvr`)rvrt)3r�� __future__r�rerTrf� functoolsrr� itertoolsr�typingrrr r r r r �markdownr�xml.etree.ElementTree�etree� ElementTreerrJr��STX�ETX�INLINE_PLACEHOLDER_PREFIX�INLINE_PLACEHOLDER�compile�INLINE_PLACEHOLDER_RE�AMP_SUBSTITUTEr��HTML_PLACEHOLDER_REr��RTL_BIDI_RANGESrZrpr�r�r�r�r^r�r�r�r�r�r�ror[rY�<module>rsu��(��� #�"�"�"�"�"� � � � � � � � �����&�&�&�&�&�&�&�&�������]�]�]�]�]�]�]�]�]�]�]�]�]�]�]�]�]�]��*�!�!�!�!�!�!�)�)�)�)�)�)�)�)�)� �W�T�]�]��� #� #� #�� � � � ����9���7�� �N��/�.��5��;��5�"�� �#5� �#C�D�D��=��U��3���/���%��+��*� �b�j�!1�K�!?�@�@��;�� �$�s�*��&� �� ��4����>�>���>������2@�@�@�@�@�&���������>�>�>�>� � � � � �3� � � � � � � � � � � ��������)����.�.�.�.�.�.�.�.�h�����J���� H#�H#�H#�H#�H#�w�r�{�H#�H#�H#�H#�H#r[
Memory