+
    #j                     ,   R t ^ RIt^ RIt^ RIt^ RIHt R R ltR R ltR R ltR	 R
 lt	R R lt
R R ltR R lt]R8X  EdN   ]! ]P                  4      ^8w  d   ]! R]P"                  R7       ]! R]P"                  R7       ]! R]P"                  R7       ]! R]P"                  R7       ]! R]P"                  R7       ]! R]P"                  R7       ]! R]P"                  R7       ]P$                  ! ^4       ]! ]P                  ^,          4      t]P                  ^,          t]P+                  4       '       g+   ]! R] R2]P"                  R7       ]P$                  ! ^4       ]! ]4      w  tt]R8X  d   ]e   ]! ]]4       R# ]! ]]4       R# R# )a-  Add a new slide to an unpacked PPTX directory.

Usage: python add_slide.py <unpacked_dir> <source>

The source can be:
  - A slide file (e.g., slide2.xml) - duplicates the slide
  - A layout file (e.g., slideLayout2.xml) - creates from layout

Examples:
    python add_slide.py unpacked/ slide2.xml
    # Duplicates slide2, creates slide5.xml

    python add_slide.py unpacked/ slideLayout2.xml
    # Creates slide5.xml from slideLayout2.xml

To see available layouts: ls unpacked/ppt/slideLayouts/

Prints the <p:sldId> element to add to presentation.xml.
N)Pathc                0    V ^8  d   QhR\         R\        /# )   
slides_dirreturnr   int)formats   "j/opt/hermes-venv/lib/python3.14/site-packages/../../../skills/productivity/powerpoint/scripts/add_slide.py__annotate__r      s     0 0d 0s 0    c                 
   V P                  R 4       Uu. uFH  p\        P                  ! RVP                  4      ;p'       g   K.  \	        VP                  ^4      4      NKJ  	  ppV'       d   \        V4      ^,           # ^# u upi )z
slide*.xmlzslide(\d+)\.xml)globrematchnamer   groupmax)r   fmexistings   &   r
   get_next_slide_numberr      so    )3)F @)FA"4aff==A=  AGGAJ)FH @ (3x=1/a/@s   +B B c                4    V ^8  d   QhR\         R\        RR/# )r   unpacked_dirlayout_filer   Nr   str)r	   s   "r
   r   r   !   s&     6a 6a4 6ac 6ad 6ar   c                 N   V R ,          R,          pVR,          pV R ,          R,          pWA,          pVP                  4       '       g6   \        RV R2\        P                  R7       \        P                  ! ^4       \        V4      pRV R2pW',          pW7 R	2,          p	R
p
VP                  V
RR7       VP                  RR7       RV R2pV	P                  VRR7       \        W4       \        W4      p\        V 4      p\        RV RV 24       \        RV RV R24       R# )pptslides_relsslideLayoutsError: 
 not foundfileslide.xml.relsa  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
  <p:cSld>
    <p:spTree>
      <p:nvGrpSpPr>
        <p:cNvPr id="1" name=""/>
        <p:cNvGrpSpPr/>
        <p:nvPr/>
      </p:nvGrpSpPr>
      <p:grpSpPr>
        <a:xfrm>
          <a:off x="0" y="0"/>
          <a:ext cx="0" cy="0"/>
          <a:chOff x="0" y="0"/>
          <a:chExt cx="0" cy="0"/>
        </a:xfrm>
      </p:grpSpPr>
    </p:spTree>
  </p:cSld>
  <p:clrMapOvr>
    <a:masterClrMapping/>
  </p:clrMapOvr>
</p:sld>utf-8encodingT)exist_oka  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
  <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/z"/>
</Relationships>Created  from 3Add to presentation.xml <p:sldIdLst>: <p:sldId id="" r:id=""/>N)existsprintsysstderrexitr   
write_textmkdir_add_to_content_types_add_to_presentation_rels_get_next_slide_id)r   r   r   rels_dirlayouts_dirlayout_pathnext_numdest
dest_slide	dest_rels	slide_xmlrels_xmlridnext_slide_ids   &&            r
   create_slide_from_layoutrG   !   s=   %0JG#H&7K+K}J/cjjA$Z0H8*D!D"JV5>)II. )g6NNDN!J KV  JW WH G4,-
#L
7C&|4M	HTF&
./	?hWZV[[^
_`r   c                4    V ^8  d   QhR\         R\        RR/# )r   r   sourcer   Nr   )r	   s   "r
   r   r   Z   s&     %a %a$ %a %a %ar   c                    V R ,          R,          pVR,          pW!,          pVP                  4       '       g6   \        RV R2\        P                  R7       \        P                  ! ^4       \        V4      pRV R2pW&,          pW1 R2,          pW6 R2,          p	\        P                  ! WG4       VP                  4       '       dT   \        P                  ! W4       V	P                  R	R
7      p
\        P                  ! RRV
4      p
V	P                  V
R	R
7       \        W4       \        W4      p\        V 4      p\        RV RV 24       \        RV RV R24       R# )r   r   r    r"   r#   r$   r&   r'   r(   r)   r*   z5\s*<Relationship[^>]*Type="[^"]*notesSlide"[^>]*/>\s*
r-   r.   r/   r0   r1   N)r2   r3   r4   r5   r6   r   shutilcopy2	read_textr   subr7   r9   r:   r;   )r   rI   r   r<   source_slider?   r@   rA   source_relsrB   rels_contentrE   rF   s   &&           r
   duplicate_sliderS   Z   sC   %0JG#H&L  ~Z0szzB$Z0H8*D!D"Jxu--KV5>)I
LL*[, **G*<vvD

 	\G<,-
#L
7C&|4M	HTF&
)*	?hWZV[[^
_`r   c                4    V ^8  d   QhR\         R\        RR/# )r   r   r@   r   Nr   )r	   s   "r
   r   r      s&     G G GC GD Gr   c                     V R ,          pVP                  RR7      pRV R2pRV 2V9  d,   VP                  RRV R24      pVP                  VRR7       R	# R	# )
z[Content_Types].xmlr)   r*   z <Override PartName="/ppt/slides/zX" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>z/ppt/slides/z</Types>  z	
</Types>N)rN   replacer7   )r   r@   content_types_pathcontent_typesnew_overrides   &&   r
   r9   r9      sx    %(==&00'0BM5dV  <T  UL	dVM1%--jB|nJ:WX%%mg%F 2r   c                <    V ^8  d   QhR\         R\        R\        /# )r   r   r@   r   r   )r	   s   "r
   r   r      s!      D   r   c                 z   V R ,          R,          R,          pVP                  RR7      p\        P                  ! RV4       Uu. uF  p\        V4      NK  	  ppV'       d   \	        V4      ^,           M^pRV 2pRV RV R	2pR
V 2V9  d*   VP                  RRV R24      pVP                  VRR7       V# u upi )r   r    zpresentation.xml.relsr)   r*   zId="rId(\d+)"rIdz<Relationship Id="zb" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/r1   zslides/z</Relationships>rV   z
</Relationships>)rN   r   findallr   r   rW   r7   )	r   r@   pres_rels_path	pres_relsr   ridsnext_ridrE   new_rels	   &&       r
   r:   r:      s    !E)G36MMN(('(:IJJ'7CDCqCFCDD $s4y1}!Hz
C"3%  (J  KO  JP  PS  TG	y(%%&8BwiGY:Z[	!!)g!>J Es   B8c                0    V ^8  d   QhR\         R\        /# )r   r   r   r   )r	   s   "r
   r   r      s     4 4T 4c 4r   c                     V R ,          R,          pVP                  RR7      p\        P                  ! RV4       Uu. uF  p\        V4      NK  	  ppV'       d   \	        V4      ^,           # R# u upi )r   zpresentation.xmlr)   r*   z<p:sldId[^>]*id="(\d+)"   )rN   r   r^   r   r   )r   	pres_pathpres_contentr   	slide_idss   &    r
   r;   r;      sg    u$'99I&&&8L!#,F!UV!UAQ!UIV!*3y>A33 Ws   A.c                `    V ^8  d   QhR\         R\        \         \         R,          3,          /# )r   rI   r   N)r   tuple)r	   s   "r
   r   r      s'       sC$J!7 r   c                 j    V P                  R 4      '       d   V P                  R4      '       d   RV 3# R# )slideLayoutr'   layout)r&   N)
startswithendswith)rI   s   &r
   parse_sourcerq      s2    ''FOOF,C,C&!!r   __main__z2Usage: python add_slide.py <unpacked_dir> <source>r$    zSource can be:z1  slide2.xml        - duplicate an existing slidez3  slideLayout2.xml  - create from a layout templatez=To see available layouts: ls <unpacked_dir>/ppt/slideLayouts/r"   r#   rn   )__doc__r   rL   r4   pathlibr   r   rG   rS   r9   r:   r;   rq   __name__lenargvr3   r5   r6   r   rI   r2   source_typer    r   r
   <module>r{      sT  ( 
  
 06ar%aPG"4 z
388}BTbszz"SZZ0A

SC#**Ubszz"MTWT^T^_$LXXa[F  ~Z0szzB+F3Kh;#: {;f-/ r   