
    <i                        d Z ddlmZ dZddlmZ ddlmZ  G d de          Z G d d	e          Z	 G d
 de          Z
dS )z
Miscellaneous transforms.
    )annotationsreStructuredText)nodes)	Transformc                      e Zd ZdZdZddZdS )CallBacka  
    Inserts a callback into a document.  The callback is called when the
    transform is applied, which is determined by its priority.

    For use with `nodes.pending` elements.  Requires a ``details['callback']``
    entry, a bound method or function which takes one parameter: the pending
    node.  Other data can be stored in the ``details`` attribute or in the
    object hosting the callback method.
    i  returnNonec                t    | j         } |j        d         |           |j                            |           d S )Ncallback)	startnodedetailsparentremove)selfpendings     /Users/kimhansen/Desktop/03 Workspace/ceo-agents/chl-effectiveness/mcp-servers/whoop/.venv/lib/python3.11/site-packages/docutils/transforms/misc.pyapplyzCallBack.apply   s<    .#
#G,,,g&&&&&    Nr	   r
   __name__
__module____qualname____doc__default_priorityr    r   r   r   r      s:          ' ' ' ' ' 'r   r   c                      e Zd ZdZdZddZdS )ClassAttributezg
    Move the "class" attribute specified in the "pending" node into the
    next visible element.
       r	   r
   c                b   | j         }|j        }|}|rt          |                    |          dz   t	          |                    D ]v}||         }t          |t          j                  st          |t          j                  r?|dxx         |j	        d         z  cc<   |j        
                    |            d S |}|j        }|| j        j                            d|j	        d         z  t          j        |j        |j                  |j                  }|                    |           d S )N   classesclassz,No suitable element following "%s" directive	directive)line)r   r   rangeindexlen
isinstancer   	Invisiblesystem_messager   r   documentreportererrorliteral_block	rawsourcer&   replace_self)r   r   r   childr(   elementr/   s          r   r   zClassAttribute.apply.   sD   . 	'v||E22Q6FDD ' ' -w88 !'5+?@@	"""gog&>>"""%%g...   	' &,,:ok*+ 173DEE	 -  
 	U#####r   Nr   r   r   r   r   r   r   %   s:         
 $ $ $ $ $ $r   r   c                  &    e Zd ZdZdZddZddZdS )	Transitionsa  
    Move transitions at the end of sections up the tree.  Complain
    on transitions after a title, subtitle, meta, or decoration element,
    at the beginning or end of the document, and after another transition.

    For example, transform this::

        <section>
            ...
            <transition>
        <section>
            ...

    into this::

        <section>
            ...
        <transition>
        <section>
            ...
    i>  r	   r
   c                ~    | j                             t          j                  D ]}|                     |           d S )N)r-   findallr   
transitionvisit_transition)r   nodes     r   r   zTransitions.applyb   sE    M))%*:;; 	( 	(D!!$''''	( 	(r   c                D   |j                             |          }|                                }d}t          |j         t          j        t          j        f          sd}na|dk    s<t          |t          j        t          j        t          j	        t          j
        f          rd}nt          |t          j                  rd}|r| j        j                            ||          }t	          j                    |j         |<   	 |j                             d           ||j         |<   |j                             |d	z   |           |d	z  }n# t          j        $ r ||j         |<   Y nw xY wt          |j         t          j        t          j        f          sd S |t%          |j                   k     sJ |t%          |j                   d	z
  k    rd S |}|t%          |j                   d	z
  k    r|j         }|j         =| j        j                            d
|          }|j                             |           d S |j                             |          }|t%          |j                   d	z
  k    |j                             |           |j                             |d	z   |           d S )N z4Transition must be child of <document> or <section>.r   z4Document or section may not begin with a transition.zZAt least one body element must separate transitions; adjacent transitions are not allowed.)	base_nodeF)	recursiver"   z'Document may not end with a transition.)r   r(   previous_siblingr*   r   r-   sectiontitlesubtitlemeta
decorationr9   r.   warning	paragraphvalidateinsertValidationErrorr)   appendr   )r   r;   r(   r@   msgrF   siblings          r   r:   zTransitions.visit_transitionf   s   !!$''0022$+'FGG 		<HCCaZZ:&69>9>9>9I9K L LZ ICC(%*:;; 	<;C 	m,44SD4IIG!&!2!2DK$$u$555 &*E"""57G444
 ( * * *%)E"""* $+'FGG 	Fs4;''''''C$$q(((Fs7>**Q...nG~% -088G(, 9 . . ""7+++N((11E s7>**Q... 	4   eai.....s   ?E E$#E$Nr   )r   r   r   r   r   r   r:   r   r   r   r6   r6   H   sN         , ( ( ( (1/ 1/ 1/ 1/ 1/ 1/r   r6   N)r   
__future__r   __docformat__docutilsr   docutils.transformsr   r   r   r6   r   r   r   <module>rR      s   
  # " " " " ""       ) ) ) ) ) )' ' ' ' 'y ' ' '( $  $  $  $  $Y  $  $  $FO/ O/ O/ O/ O/) O/ O/ O/ O/ O/r   