
    Mi!i                       S r SSKJr  SSKrSSKJrJrJrJrJ	r	J
r
Jr  SSKJr  SSKJrJr  SSKJr  SSKJr  SS	KJrJrJr  SS
KJr   " S S\5      rS*S+S jjrS,S jr " S S\5      r " S S\ 5      r! " S S5      r" " S S\"5      r# " S S\"5      r$ " S S5      r% " S S\%5      r& " S S\%5      r' " S  S!\%5      r( " S" S#\%5      r) " S$ S%\%5      r* " S& S'\%5      r+ " S( S\R                  \!S)9r,g)-zPBase and meta classes enabling declarative definition of custom element classes.    )annotationsN)AnyCallableIterableProtocolSequenceTypecast)etree)ElementBase_Element)InvalidXmlError)oxml_parser)NamespacePrefixedTag_nsmapqn)lazypropertyc                  @    \ rS rSrSr\SS j5       r\SS j5       rSrg)	AttributeType   zInterface for an object that can act as an attribute type.

An attribute-type specifies how values are transformed to and from the XML "string" value of the
attribute.
c                    g)z/Transform an attribute value to a Python value.N )cls	xml_values     l/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/pptx/oxml/xmlchemy.pyfrom_xmlAttributeType.from_xml        	    c                    g)zGTransform a Python value to a str value suitable to this XML attribute.Nr   )r   values     r   to_xmlAttributeType.to_xml   r   r   r   N)r   strreturnr   )r!   r   r%   r$   )	__name__
__module____qualname____firstlineno____doc__classmethodr   r"   __static_attributes__r   r   r   r   r      s/        r   r   BaseOxmlElementc                x    [        U 5      nUb  UOUR                  n[        R                  " UR                  US9$ )zReturn a "loose" lxml element having the tag specified by `nsptag_str`.

`nsptag_str` must contain the standard namespace prefix, e.g. 'a:tbl'. The resulting element is
an instance of the custom element class for this tag name if one is defined.
)nsmap)r   r/   r   makeelement
clark_name)
nsptag_strr/   nsptags      r   OxmlElementr4   #   s7     "*-F&EFLLE""6#4#4EBBr   c                D    [         R                  " U SSS9n[        U5      $ )zS
Serialize *element* to human-readable XML suitable for tests. No XML
declaration.
unicodeT)encodingpretty_print)r   tostring	XmlString)elementxmls     r   serialize_for_readingr=   .   s     
 ..94
HCS>r   c                  n    \ rS rSrSr\R                  " S5      rSS jrSS jr	SS jr
SS jrSS jrS	rg
)r:   7   zRProvides string comparison override suitable for serialized XML; useful for tests.z(( *</?[\w:]+)(.*?)(/?>)([^<]*</[\w:]+>)?c                    [        U[        5      (       d  gU R                  5       nUR                  5       n[        U5      [        U5      :w  a  g[	        X#5       H  u  pEU R                  XE5      (       a  M    g   g)NFT)
isinstancer$   
splitlineslenzip_eq_elm_strs)selfotherlineslines_otherline
line_others         r   __eq__XmlString.__eq__B   sk    %%%!&&(u:[)) #E 7D$$T66 !8 r   c                .    U R                  U5      (       + $ N)rL   )rF   rG   s     r   __ne__XmlString.__ne__N   s    ;;u%%%r   c                X    UR                  5       nUR                  5       n[        U5      $ )z{Return a sequence of attribute strings parsed from *attrs*.

Each attribute string is stripped of whitespace on both ends.
)stripsplitsorted)rF   attrsattr_lsts      r   	_attr_seqXmlString._attr_seqQ   s%    
 ;;=hr   c                    U R                  U5      u  p4pVU R                  U5      u  pxpX7:w  a  gU R                  U5      U R                  U5      :w  a  gXY:w  a  gXj:w  a  gg)zTrue if the element in `line_2` is XML-equivalent to the element in `line`.

In particular, the order of attributes in XML is not significant.
FT)_parse_linerX   )rF   rJ   line_2frontrV   closetextfront_2attrs_2close_2text_2s              r   rE   XmlString._eq_elm_strsZ   sh    
 %)$4$4T$:!e,0,<,<V,D)'>>% DNN7$;;>r   c                    U R                   R                  U5      nUc  [        S5      e[        SS5       Vs/ s H  o2R	                  U5      PM     snu  pEpgXEXg4$ s  snf )zUReturn front, attrs, close, text 4-tuple result of parsing XML element string `line`.z0`line` does not match pattern for an XML element      )_xml_elm_line_pattmatch
ValueErrorrangegroup)rF   rJ   ri   nr]   rV   r^   r_   s           r   r[   XmlString._parse_linek   s_    ''--d3=OPP=B1a[$I[[[^[$I!eU(( %Js   Ar   N)rG   objectr%   bool)rV   r$   r%   	list[str])rJ   r$   r\   r$   r%   rp   )rJ   r$   )r&   r'   r(   r)   r*   recompilerh   rL   rP   rX   rE   r[   r,   r   r   r   r:   r:   7   s0    \ $OP
& ")r   r:   c                  "    \ rS rSrSrSS jrSrg)MetaOxmlElementt   zMetaclass for BaseOxmlElement.c                    [         [        [        [        [        [
        [        4nUR                  5        H(  u  pV[        Xd5      (       d  M  UR                  X5        M*     g rO   )
OneAndOnlyOne	OneOrMoreOptionalAttributeRequiredAttribute
ZeroOrMore	ZeroOrOneZeroOrOneChoiceitemsrA   populate_class_members)r   clsnamebasesclsdictdispatchablekeyr!   s          r   __init__MetaOxmlElement.__init__w   sK    
 "--/JC%..,,S6 *r   r   N)r   r$   r   ztuple[type, ...]r   zdict[str, Any])r&   r'   r(   r)   r*   r   r,   r   r   r   ru   ru   t   s
    (7r   ru   c                  j    \ rS rSrSrSS jrSS jrS r\S 5       r	\SS j5       r
\SS j5       rS	rg
)BaseAttribute   zQBase class for OptionalAttribute and RequiredAttribute, providing common methods.c                    Xl         X l        g rO   )
_attr_name_simple_type)rF   	attr_namesimple_types      r   r   BaseAttribute.__init__   s    #'r   c                <    Xl         X l        U R                  5         gz/
Add the appropriate methods to *element_cls*.
N)_element_cls
_prop_name_add_attr_propertyrF   element_cls	prop_names      r   r   $BaseAttribute.populate_class_members   s     (#!r   c                    [        U R                  U R                  S5      n[        U R                  U R
                  U5        g)zAdd a read/write `{prop_name}` property to the element class.

The property returns the interpreted value of this attribute on access and changes the
attribute value to its ST_* counterpart on assignment.
N)property_getter_settersetattrr   r   rF   	property_s     r   r    BaseAttribute._add_attr_property   s0     T\\4<<>	!!4??I>r   c                d    SU R                   ;   a  [        U R                   5      $ U R                   $ )N:)r   r   rF   s    r   _clark_nameBaseAttribute._clark_name   s'    $//!doo&&r   c                    [        S5      e)JCallable suitable for the "get" side of the attribute property descriptor.$must be implemented by each subclassNotImplementedErrorr   s    r   r   BaseAttribute._getter        ""HIIr   c                    [        S5      e)JCallable suitable for the "set" side of the attribute property descriptor.r   r   r   s    r   r   BaseAttribute._setter   r   r   )r   r   r   r   N)r   r$   r   type[AttributeType]r   Type[BaseOxmlElement]r   r$   r%   z Callable[[BaseOxmlElement], Any]r%   z&Callable[[BaseOxmlElement, Any], None])r&   r'   r(   r)   r*   r   r   r   r   r   r   r   r,   r   r   r   r   r      sT    [("?  
 J J J Jr   r   c                  l   ^  \ rS rSrSrSS	U 4S jjjr\S 5       r\S
S j5       r\SS j5       r	Sr
U =r$ )rz      zDefines an optional attribute on a custom element class.

An optional attribute returns a default value when not present for reading. When assigned
|None|, the attribute is removed.
c                8   > [         [        U ]  X5        X0l        g rO   )superrz   r   _default)rF   r   r   default	__class__s       r   r   OptionalAttribute.__init__   s    /	Gr   c                R    U R                   R                  < SU R                  < S3$ )[
Return the string to use as the ``__doc__`` attribute of the property
for this attribute.
 type-converted value of ``z`` attribute, or |None| (or specified default value) if not present. Assigning the default value causes the attribute to be removed from the element.r   r&   r   r   s    r   
_docstringOptionalAttribute._docstring   s#       ))4??<	
r   c                :   ^  SU 4S jjnT R                   Ul        U$ )r   c                   > U R                  TR                  5      nUc  TR                  $ TR                  R	                  U5      $ rO   )getr   r   r   r   objattr_str_valuerF   s     r   get_attr_value1OptionalAttribute._getter.<locals>.get_attr_value   s>     WWT%5%56N%}}$$$--n==r   r   r-   r%   r   r   r*   rF   r   s   ` r   r   OptionalAttribute._getter   s    	> "&r   c                   ^  SU 4S jjnU$ )r   c                   > UTR                   :X  a2  TR                  U R                  ;   a  U R                  TR                  	 g TR                  R	                  U5      nU R                  TR                  U5        g rO   )r   r   attribr   r"   setr   r!   	str_valuerF   s      r   set_attr_value1OptionalAttribute._setter.<locals>.set_attr_value   sb     %##szz1

4#3#34))007IGGD$$i0r   r   r-   r!   r   r%   Noner   rF   r   s   ` r   r   OptionalAttribute._setter   s    	1 r   )r   rO   )r   r$   r   r   r   r   r   r   )r&   r'   r(   r)   r*   r   r   r   r   r   r,   __classcell__r   s   @r   rz   rz      sN        

 

 
 
  r   rz   c                  P    \ rS rSrSr\SS j5       r\S 5       r\S	S j5       rSr	g)
r{      a  Defines a required attribute on a custom element class.

A required attribute is assumed to be present for reading, so does not have a default value;
its actual value is always used. If missing on read, an |InvalidXmlError| is raised. It also
does not remove the attribute if |None| is assigned. Assigning |None| raises |TypeError| or
|ValueError|, depending on the simple type of the attribute.
c                :   ^  SU 4S jjnT R                   Ul        U$ )r   c                   > U R                  TR                  5      nUc'  [        STR                  < SU R                  < 35      eTR
                  R                  U5      $ )Nz
required 'z#' attribute not present on element )r   r   r   r   tagr   r   r   s     r   r   1RequiredAttribute._getter.<locals>.get_attr_value   sV     WWT%5%56N%%KO??\_\c\cd  $$--n==r   r   r   r   s   ` r   r   RequiredAttribute._getter   s    	> "&r   c                R    U R                   R                  < SU R                  < S3$ )r   r   z`` attribute.r   r   s    r   r   RequiredAttribute._docstring   s$     &&OO
 	
r   c                   ^  SU 4S jjnU$ )r   c                t   > TR                   R                  U5      nU R                  TR                  U5        g rO   )r   r"   r   r   r   s      r   r   1RequiredAttribute._setter.<locals>.set_attr_value  s-    ))007IGGD$$i0r   r   r   r   s   ` r   r   RequiredAttribute._setter
  s    	1 r   r   Nr   r   )
r&   r'   r(   r)   r*   r   r   r   r   r,   r   r   r   r{   r{      sC       
 
  r   r{   c                     ^  \ rS rSrSrSSU 4S jjjrSS jrS rS rS r	S r
S	 r\S
 5       rSS jr\SS j5       r\SS j5       r\S 5       r\SS j5       r\S 5       r\S 5       rSrU =r$ )_BaseChildElementi  zBase class for the child element classes corresponding to varying cardinalities.

Subclasses include ZeroOrOne and ZeroOrMore.
c                B   > [         [        U ]  5         Xl        X l        g rO   )r   r   r   _nsptagname_successors)rF   
nsptagname
successorsr   s      r   r   _BaseChildElement.__init__  s    /1%%r   c                    Xl         X l        g)zFBaseline behavior for adding the appropriate methods to `element_cls`.N)r   r   r   s      r   r   (_BaseChildElement.populate_class_members   s    '#r   c                v   ^  SU 4S jjnST R                   -  Ul        T R                  T R                  U5        g)zGAdd an ``_add_x()`` method to the element class for this child element.c                   > [        U TR                  5      nU" 5       nUR                  5        H  u  pE[        X4U5        M     [        U TR                  5      nU" U5        U$ rO   )getattr_new_method_namer   r   _insert_method_name)r   rV   
new_methodchildr   r!   insert_methodrF   s          r   
_add_child0_BaseChildElement._add_adder.<locals>._add_child(  sW     d&;&;<JLE#kkm
E* ,#C)A)ABM% Lr   SAdd a new ``<%s>`` child element unconditionally, inserted in the correct sequence.N)r   r-   rV   r   )r   r*   _add_to_class_add_method_name)rF   r   s   ` r   
_add_adder_BaseChildElement._add_adder%  s;    	#%)%5%56 	 	400*=r   c                |    U R                   nSU R                  -  Ul        U R                  U R                  U5        g)zAdd a `_new_{prop_name}()` method to the element class.

This method creates a new, empty element of the correct type, having no attributes.
zYReturn a "loose", newly created ``<%s>`` element having no attributes, text, or children.N)_creatorr   r*   r   r   )rF   creators     r   _add_creator_BaseChildElement._add_creator7  s?    
 --(*.*:*:; 	 	400':r   c                t    [        U R                  SS5      n[        U R                  U R                  U5        g)zAdd a read-only `{prop_name}` property to the parent element class.

The property locates and returns this child element or `None` if not present.
N)r   r   r   r   r   r   s     r   _add_getter_BaseChildElement._add_getterC  s,    
 T\\46	!!4??I>r   c                v   ^  SU 4S jjnST R                   -  Ul        T R                  T R                  U5        g)zJAdd an ``_insert_x()`` method to the element class for this child element.c                B   > U R                   " U/TR                  Q76   U$ rO   )insert_element_beforer   r   r   rF   s     r   _insert_child6_BaseChildElement._add_inserter.<locals>._insert_childO  s!    %%e?d.>.>?Lr   zYReturn the passed ``<%s>`` element after inserting it as a child in the correct sequence.N)r   r-   r   r-   )r   r*   r   r   )rF   r  s   ` r   _add_inserter_BaseChildElement._add_inserterL  s;    	
)+/+;+;< 	 	433]Cr   c                |    U R                    S3n[        U R                  SS5      n[        U R                  X5        g)z|
Add a read-only ``{prop_name}_lst`` property to the element class to
retrieve a list of child elements matching this type.
_lstN)r   r   _list_getterr   r   )rF   r   r   s      r   _add_list_getter"_BaseChildElement._add_list_getterY  s9    
 't,	T..d;	!!98r   c                     SU R                   -  $ )Nz_add_%sr   r   s    r   r  "_BaseChildElement._add_method_nameb      4??**r   c                h    [        U R                  U5      (       a  g[        U R                  X5        g)zSAdd `method` to the target class as `name`, unless `name` is already defined there.N)hasattrr   r   )rF   namemethods      r   r   _BaseChildElement._add_to_classf  s(    4$$d++!!40r   c                   ^  SU 4S jjnU$ )zSCallable that creates a new, empty element of the child type, having no attributes.c                .   > [        TR                  5      $ rO   )r4   r   r   rF   s    r   new_child_element5_BaseChildElement._creator.<locals>.new_child_elementp  s    t//00r   r   r-   r   )rF   r%  s   ` r   r  _BaseChildElement._creatorl  s    	1 ! r   c                @   ^  SU 4S jjnST R                   -  Ul        U$ )zCallable suitable for the "get" side of the property descriptor.

This default getter returns the child element with matching tag name or |None| if not
present.
c                L   > U R                  [        TR                  5      5      $ rO   )findr   r   r$  s    r   get_child_element4_BaseChildElement._getter.<locals>.get_child_element}  s    88Bt//011r   z0``<%s>`` child element or |None| if not present.r   r-   r%   BaseOxmlElement | Noner   r*   rF   r,  s   ` r   r   _BaseChildElement._getteru  s(    	2 ?AQAQQ 	! ! r   c                     SU R                   -  $ )Nz
_insert_%sr  r   s    r   r   %_BaseChildElement._insert_method_name      doo--r   c                @   ^  SU 4S jjnST R                   -  Ul        U$ )zCCallable suitable for the "get" side of a list property descriptor.c                `   > [        SU R                  [        TR                  5      5      5      $ )Nlist[BaseOxmlElement])r
   findallr   r   r$  s    r   get_child_element_list>_BaseChildElement._list_getter.<locals>.get_child_element_list  s%    /R@P@P=Q1RSSr   zPA list containing each of the ``<%s>`` child elements, in the order they appear.)r   r-   r%   r8  r0  )rF   r:  s   ` r   r  _BaseChildElement._list_getter  s,    	T "&"2"23 	& &%r   c                     SU R                   -  $ Nz
_remove_%sr  r   s    r   _remove_method_name%_BaseChildElement._remove_method_name  r5  r   c                     SU R                   -  $ )Nz_new_%sr  r   s    r   r   "_BaseChildElement._new_method_name  r  r   )r   r   r   r   r   )r   r$   r   Sequence[str]r   )r  r$   r   zCallable[..., Any]r%   z,Callable[[BaseOxmlElement], BaseOxmlElement])r%   z3Callable[[BaseOxmlElement], BaseOxmlElement | None])r%   z2Callable[[BaseOxmlElement], list[BaseOxmlElement]])r&   r'   r(   r)   r*   r   r   r  r  r
  r  r  r   r  r   r   r  r   r   r  r?  r   r,   r   r   s   @r   r   r     s    
& &
$
>$
;?D9 + +1 ! ! ! ! . . 
& 
& . . + +r   r   c                  x    \ rS rSrSr\S 5       r      SS jrSS jr\S 5       r	\
S 5       r\
S 5       rS	rg
)Choicei  zVDefines a child element belonging to a group, only one of which may appear as a child.c                    U R                   $ rO   )r   r   s    r   r   Choice.nsptagname  s    r   c                    Xl         X l        X0l        U R                  5         U R	                  5         U R                  5         U R                  5         U R                  5         gz-Add the appropriate methods to `element_cls`.N)r   _group_prop_namer   r
  r  r  r  _add_get_or_change_to_method)rF   r   group_prop_namer   s       r   r   Choice.populate_class_members  sP     ( /%))+r   c                v   ^  SU 4S jjnST R                   -  Ul        T R                  T R                  U5        g)zPAdd a `get_or_change_to_x()` method to the element class for this child element.c                   > [        U TR                  5      nUb  U$ [        U TR                  5      nU" 5         [        U TR                  5      nU" 5       nU$ rO   )r   r   _remove_group_method_namer  )r   r   remove_group_method
add_methodrF   s       r   get_or_change_to_childCChoice._add_get_or_change_to_method.<locals>.get_or_change_to_child  sU    C1E ")#t/M/M"N! d&;&;<JLELr   zFReturn the ``<%s>`` child, replacing any other group element if found.Nr'  )r   r*   r   _get_or_change_to_method_name)rF   rU  s   ` r   rM  #Choice._add_get_or_change_to_method  s;    	 X*& 	4==?UVr   c                    SU R                   ;   a  U R                   R                  S5      S-   nOSnU R                   US $ )zG
Calculate property name from tag name, e.g. a:schemeClr -> schemeClr.
r   rf   r   N)r   index)rF   starts     r   r   Choice._prop_name  sE    
 $"""$$**3/!3EE''r   c                     SU R                   -  $ )Nzget_or_change_to_%sr  r   s    r   rW  $Choice._get_or_change_to_method_name  s    $t66r   c                     SU R                   -  $ r>  )rL  r   s    r   rR   Choice._remove_group_method_name  s    d3333r   )r   rL  r   N)r   r   rN  r$   r   rD  r%   r   )r&   r'   r(   r)   r*   r   r   r   rM  r   r   rW  rR  r,   r   r   r   rG  rG    sv    `   ,0,CF,Ta,W$ ( ( 7 7 4 4r   rG  c                  T   ^  \ rS rSrSrSU 4S jjrSU 4S jjr\S	S j5       rSr	U =r
$ )
rx   i  z5Defines a required child element for MetaOxmlElement.c                .   > [         [        U ]  US5        g )Nr   )r   rx   r   )rF   r   r   s     r   r   OneAndOnlyOne.__init__  s    mT+J;r   c                L   > [         [        U ]  X5        U R                  5         gr   )r   rx   r   r
  rF   r   r   r   s      r   r   $OneAndOnlyOne.populate_class_members  s      	mT9+Qr   c                @   ^  SU 4S jjnST R                   -  Ul        U$ )z@Callable suitable for the "get" side of the property descriptor.c                   > U R                  [        TR                  5      5      nUc  [        STR                  -  5      eU$ )Nz+required ``<%s>`` child element not present)r+  r   r   r   r  s     r   r,  0OneAndOnlyOne._getter.<locals>.get_child_element  sC    HHR 0 012E}%ADDTDTT  Lr   z Required ``<%s>`` child element.r   r-   r%   r-   r0  r1  s   ` r   r   OneAndOnlyOne._getter  s%    	 %GIYIY$Y!  r   r   )r   r$   r   rE  )r&   r'   r(   r)   r*   r   r   r   r   r,   r   r   s   @r   rx   rx     s$    ?< ! !r   rx   c                  J   ^  \ rS rSrSrSU 4S jjrSS jr\S 5       rSr	U =r
$ )	ry   i  zUDefines a repeating child element for MetaOxmlElement that must appear at least once.c                   > [         [        U ]  X5        U R                  5         U R	                  5         U R                  5         U R                  5         U R                  5         [        X5        g)z-Add the appropriate methods to *element_cls*.N)	r   ry   r   r  r  r  r  _add_public_adderdelattrrf  s      r   r    OneOrMore.populate_class_members  sT    i5kM 'r   c                v   ^  SU 4S jjnST R                   -  Ul        T R                  T R                  U5        g)z;Add a public `.add_x()` method to the parent element class.c                B   > [        U TR                  5      nU" 5       nU$ rO   )r   r  )r   private_add_methodr   rF   s      r   	add_child.OneOrMore._add_public_adder.<locals>.add_child  s#    !(d.C.C!D&(ELr   r   Nrk  )r   r*   r   _public_add_method_name)rF   ru  s   ` r   ro  OneOrMore._add_public_adder  s;    	#%)%5%56 	 	477Cr   c                     SU R                   -  $ )z
add_childElement() is public API for a repeating element, allowing
new elements to be added to the sequence. May be overridden to
provide a friendlier API to clients having domain appropriate
parameter names for required attributes.
zadd_%sr  r   s    r   rw  !OneOrMore._public_add_method_name  s     $//))r   r   r   ra  )r&   r'   r(   r)   r*   r   ro  r   rw  r,   r   r   s   @r   ry   ry     s%    _(D * *r   ry   c                  0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r|   i  zB
Defines an optional repeating child element for MetaOxmlElement.
c                   > [         [        U ]  X5        U R                  5         U R	                  5         U R                  5         U R                  5         [        X5        gr   )r   r|   r   r  r  r  r  rp  rf  s      r   r   !ZeroOrMore.populate_class_members"  sJ     	j$6{N'r   r   r   )r&   r'   r(   r)   r*   r   r,   r   r   s   @r   r|   r|     s    	( 	(r   r|   c                  L   ^  \ rS rSrSrSU 4S jjrS rS r\S 5       r	Sr
U =r$ )	r}   i.  z6Defines an optional child element for MetaOxmlElement.c                   > [         [        U ]  X5        U R                  5         U R	                  5         U R                  5         U R                  5         U R                  5         U R                  5         grK  )	r   r}   r   r
  r  r  r  _add_get_or_adder_add_removerrf  s      r   r    ZeroOrOne.populate_class_members1  sX    i5kM r   c                v   ^  SU 4S jjnST R                   -  Ul        T R                  T R                  U5        g)zKAdd a `.get_or_add_x()` method to the element class for this child element.c                t   > [        U TR                  5      nUc  [        U TR                  5      nU" 5       nU$ rO   )r   r   r  )r   r   rT  rF   s      r   get_or_add_child5ZeroOrOne._add_get_or_adder.<locals>.get_or_add_child>  s6    C1E}$S$*?*?@
"Lr   z>Return the ``<%s>`` child element, newly added if not present.Nrk  )r   r*   r   _get_or_add_method_name)rF   r  s   ` r   r  ZeroOrOne._add_get_or_adder;  s;    	 M$  	4779IJr   c                x   ^  SU 4S jjnST R                    S3Ul        T R                  T R                  U5        g)zHAdd a `._remove_x()` method to the element class for this child element.c                <   > U R                  TR                  5        g rO   )
remove_allr   r$  s    r   _remove_child-ZeroOrOne._add_remover.<locals>._remove_childM  s    NN4++,r   zRemove all `z` child elements.Nr   r-   r%   r   )r   r*   r   r?  )rF   r  s   ` r   r  ZeroOrOne._add_removerJ  s9    	- #/t/?/?.@@Q R433]Cr   c                     SU R                   -  $ )Nzget_or_add_%sr  r   s    r   r  !ZeroOrOne._get_or_add_method_nameS  s    00r   r   r   )r&   r'   r(   r)   r*   r   r  r  r   r  r,   r   r   s   @r   r}   r}   .  s+    @KD 1 1r   r}   c                  ~   ^  \ rS rSrSrSSS jjrSU 4S jjrS rS r\	S 5       r
\SS j5       r\S	 5       rS
rU =r$ )r~   iX  zOAn `EG_*` element group where at most one of its members may appear as a child.c                D    [        U5      U l        [        U5      U l        g rO   )tuple_choicesr   )rF   choicesr   s      r   r   ZeroOrOneChoice.__init__[  s    g ,r   c                   > [         [        U ]  X5        U R                  5         U R                   H)  nUR                  XR
                  U R                  5        M+     U R                  5         grK  )r   r~   r   _add_choice_getterr  r   r   _add_group_remover)rF   r   r   choicer   s       r   r   &ZeroOrOneChoice.populate_class_members_  sR    ot;KS!mmF))+HXHXY $!r   c                t    [        U R                  SS5      n[        U R                  U R                  U5        g)zAdd a read-only `.{prop_name}` property to the element class.

The property returns the present member of this group, or |None| if none are present.
N)r   _choice_getterr   r   r   r   s     r   r  "ZeroOrOneChoice._add_choice_getterg  s.    
 T00$=	!!4??I>r   c                \   ^  SU 4S jjnSUl         T R                  T R                  U5        g)zJAdd a `._remove_eg_x()` method to the element class for this choice group.c                N   > TR                    H  nU R                  U5        M     g rO   )_member_nsptagnamesr  )r   tagnamerF   s     r   _remove_choice_group@ZeroOrOneChoice._add_group_remover.<locals>._remove_choice_groups  s    33w' 4r   z9Remove the current choice group child element if present.Nr  )r*   r    _remove_choice_group_method_name)rF   r  s   ` r   r  "ZeroOrOneChoice._add_group_removerp  s+    	( (c$4@@BVWr   c                &   ^  SU 4S jjnSUl         U$ )zR
Return a function object suitable for the "get" side of the property
descriptor.
c                J   > [        SU R                  " TR                  6 5      $ )Nr/  )r
   first_child_found_inr  r$  s    r   get_group_member_element@ZeroOrOneChoice._choice_getter.<locals>.get_group_member_element  s&    (#*B*BDD\D\*] r   zbReturn the child element belonging to this element group, or |None| if no member child is present.r.  )r*   )rF   r  s   ` r   r  ZeroOrOneChoice._choice_getterz  s    	4 	!( ('r   c                X    U R                    Vs/ s H  oR                  PM     sn$ s  snf )zUSequence of namespace-prefixed tagnames, one for each member element of choice group.)r  r   )rF   r  s     r   r  #ZeroOrOneChoice._member_nsptagnames  s$     15>f!!>>>s   'c                     SU R                    3$ )z!Function-name for choice remover._remove_r  r   s    r   r  0ZeroOrOneChoice._remove_choice_group_method_name  s     $//*++r   )r  r   rC  )r  zIterable[Choice]r   zIterable[str]r   )r%   rq   )r&   r'   r(   r)   r*   r   r   r  r  r   r  r   r  r  r,   r   r   s   @r   r~   r~   X  sW    Y-"?X ( (" ? ? , ,r   r~   c                  |   ^  \ rS rSrSrS rSS jrSS jrSS jr\	SS j5       r
SU 4S jjr\	SS	 j5       rS
rU =r$ )r-   i  znEffective base class for all custom element classes.

Adds standardized behavior to all classes in one place.
c                `    SU R                   R                  U R                  [        U 5      4-  $ )Nz<%s '<%s>' at 0x%0x>)r   r&   _nsptagidr   s    r   __repr__BaseOxmlElement.__repr__  s/    %NN##LLtH)
 
 	
r   c                X    U H$  nU R                  [        U5      5      nUc  M"  Us  $    g)z9First child with tag in `tagnames`, or None if not found.N)r+  r   )rF   tagnamesr  r   s       r   r  $BaseOxmlElement.first_child_found_in  s.    GIIbk*E    r   c                r    U R                   " U6 nUb  UR                  U5        U$ U R                  U5        U$ rO   )r  addpreviousappend)rF   elmr  	successors       r   r  %BaseOxmlElement.insert_element_before  s@    --x8	 !!#& 
 KK
r   c                ~    U H7  nU R                  [        U5      5      nU H  nU R                  U5        M     M9     g)z>Remove child elements with tagname (e.g. "a:p") in `tagnames`.N)r9  r   remove)rF   r  r  matchingr   s        r   r  BaseOxmlElement.remove_all  s4    G||BwK0H!E" "  r   c                    [        U 5      $ )zXML string for this element, suitable for testing purposes.

Pretty printed for readability and without an XML declaration at the top.
)r=   r   s    r   r<   BaseOxmlElement.xml  s     %T**r   c                (   > [         TU ]  U[        S9$ )z}Override of `lxml` _Element.xpath() method.

Provides standard Open XML namespace mapping (`nsmap`) in centralized location.
)
namespaces)r   xpathr   )rF   	xpath_strr   s     r   r  BaseOxmlElement.xpath  s    
 w}Y6}::r   c                B    [         R                  " U R                  5      $ rO   )r   from_clark_namer   r   s    r   r  BaseOxmlElement._nsptag  s    #33DHH==r   r   )r  r$   r%   z_Element | None)r  r   r  r$   )r  r$   r%   r   )r%   r$   )r  r$   r%   r   )r&   r'   r(   r)   r*   r  r  r  r  r   r<   r  r  r,   r   r   s   @r   r-   r-     sI    

# + +; > >r   )	metaclassrO   )r2   r$   r/   zdict[str, str] | Noner%   r-   )r;   r   )-r*   
__future__r   rr   typingr   r   r   r   r   r	   r
   lxmlr   
lxml.etreer   r   pptx.excr   	pptx.oxmlr   pptx.oxml.nsr   r   r   	pptx.utilr   r   r4   r=   r$   r:   typeru   r   rz   r{   r   rG  rx   ry   r|   r}   r~   r-   r   r   r   <module>r     s    V " 	 J J J  , $ ! 9 9 "H $C:) :)z7d 7$(J (JV3 3l+ +\G+ G+T84 84v!% !:#*! #*L(" ("'1! '1T<,' <,@5>e''? 5>r   