@poe-platform/safe-bash 0.1.806 → 0.1.807

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (856) hide show
  1. package/README.md +4 -0
  2. package/dist/image-ast/portable.d.ts +8 -0
  3. package/dist/image-ast/portable.js +2 -0
  4. package/dist/safe-bash/chunks/{chunk-KRA6WK4Z.js → chunk-3Y54SR4R.js} +6 -6
  5. package/dist/safe-bash/chunks/{chunk-OYJI4L4J.js → chunk-PPAA3LJS.js} +1 -1
  6. package/dist/safe-bash/chunks/{chunk-SCROOJV7.js → chunk-XZ2Y4RWC.js} +2 -2
  7. package/dist/safe-bash/command-chunks/{biff-AU4VGVMD-6EQ64QPG.js → biff-YBHP7ZES-M7TU7NA5.js} +1211 -1205
  8. package/dist/safe-bash/command-chunks/chunk-2A6TBB4F.js +14 -0
  9. package/dist/safe-bash/command-chunks/chunk-2AF7J6FE.js +372 -0
  10. package/dist/safe-bash/command-chunks/{chunk-AITNVBXO.js → chunk-2ANW3FXH.js} +4 -4
  11. package/dist/safe-bash/command-chunks/chunk-2B6XWO6A.js +730 -0
  12. package/dist/safe-bash/command-chunks/chunk-2BKOSQD3.js +11 -0
  13. package/dist/safe-bash/command-chunks/chunk-2EUH5B6A.js +127 -0
  14. package/dist/safe-bash/command-chunks/chunk-2FOLUJLI.js +400 -0
  15. package/dist/safe-bash/command-chunks/{chunk-CZLX3KVF.js → chunk-2GILUQJY.js} +4 -6
  16. package/dist/safe-bash/command-chunks/chunk-2HHGDJ7J.js +280 -0
  17. package/dist/safe-bash/command-chunks/chunk-2NE2GPSF.js +546 -0
  18. package/dist/safe-bash/command-chunks/chunk-2P7BLWWI.js +272 -0
  19. package/dist/safe-bash/command-chunks/chunk-2PSVE7I5.js +101 -0
  20. package/dist/safe-bash/command-chunks/chunk-2UUFZMOH.js +503 -0
  21. package/dist/safe-bash/command-chunks/chunk-2VGAC6S6.js +393 -0
  22. package/dist/safe-bash/command-chunks/chunk-2W54TAGI.js +162 -0
  23. package/dist/safe-bash/command-chunks/chunk-326A5G42.js +328 -0
  24. package/dist/safe-bash/command-chunks/chunk-36KIT4DU.js +218 -0
  25. package/dist/safe-bash/command-chunks/chunk-3CHQG25N.js +455 -0
  26. package/dist/safe-bash/command-chunks/chunk-3JQ3RF2O.js +72 -0
  27. package/dist/safe-bash/command-chunks/chunk-3MLJWSYL.js +92 -0
  28. package/dist/safe-bash/command-chunks/{chunk-ASYR2LU7.js → chunk-3RQCLLQA.js} +5 -5
  29. package/dist/safe-bash/command-chunks/chunk-3SEQG5JH.js +521 -0
  30. package/dist/safe-bash/command-chunks/chunk-3SWT2KYH.js +78 -0
  31. package/dist/safe-bash/command-chunks/chunk-3VETFXYR.js +170 -0
  32. package/dist/safe-bash/command-chunks/chunk-3W6PTHHB.js +65 -0
  33. package/dist/safe-bash/command-chunks/chunk-457CU3IC.js +8 -0
  34. package/dist/safe-bash/command-chunks/chunk-45BW6MGM.js +250 -0
  35. package/dist/safe-bash/command-chunks/chunk-47MFDPH4.js +419 -0
  36. package/dist/safe-bash/command-chunks/chunk-4ATHODCG.js +444 -0
  37. package/dist/safe-bash/command-chunks/chunk-4DJICIFV.js +227 -0
  38. package/dist/safe-bash/command-chunks/chunk-4FNQPK7C.js +385 -0
  39. package/dist/safe-bash/command-chunks/chunk-4LXDJES2.js +65 -0
  40. package/dist/safe-bash/command-chunks/chunk-4QRXKUD2.js +662 -0
  41. package/dist/safe-bash/command-chunks/chunk-4QYNOBWZ.js +455 -0
  42. package/dist/safe-bash/command-chunks/{chunk-MWNWT6HG.js → chunk-4XFFIKA3.js} +5 -5
  43. package/dist/safe-bash/command-chunks/chunk-5AU5ENL5.js +180 -0
  44. package/dist/safe-bash/command-chunks/chunk-5DFZAJHL.js +324 -0
  45. package/dist/safe-bash/command-chunks/chunk-5GEFJROP.js +270 -0
  46. package/dist/safe-bash/command-chunks/chunk-5HWX4XYW.js +263 -0
  47. package/dist/safe-bash/command-chunks/chunk-5LKNP4IF.js +872 -0
  48. package/dist/safe-bash/command-chunks/chunk-5OEHUIVE.js +240 -0
  49. package/dist/safe-bash/command-chunks/chunk-6EHVFKM7.js +171 -0
  50. package/dist/safe-bash/command-chunks/chunk-6JTPLJ3B.js +155 -0
  51. package/dist/safe-bash/command-chunks/chunk-6KLUPQ65.js +496 -0
  52. package/dist/safe-bash/command-chunks/chunk-6NS5RXQ7.js +285 -0
  53. package/dist/safe-bash/command-chunks/chunk-6PJIQEH4.js +3472 -0
  54. package/dist/safe-bash/command-chunks/chunk-763ECQWB.js +566 -0
  55. package/dist/safe-bash/command-chunks/chunk-7DADVPKN.js +23 -0
  56. package/dist/safe-bash/command-chunks/chunk-7LEADSSA.js +164 -0
  57. package/dist/safe-bash/command-chunks/chunk-7MMSBVUP.js +732 -0
  58. package/dist/safe-bash/command-chunks/chunk-7OXNWLSL.js +35 -0
  59. package/dist/safe-bash/command-chunks/chunk-7PZASWL6.js +354 -0
  60. package/dist/safe-bash/command-chunks/{chunk-ZBR3UH4P.js → chunk-7QH3WAMQ.js} +2 -2
  61. package/dist/safe-bash/command-chunks/{chunk-CB3HTIDK.js → chunk-7SOE7XIS.js} +11 -11
  62. package/dist/safe-bash/command-chunks/chunk-7Y3ZQ6FE.js +56 -0
  63. package/dist/safe-bash/command-chunks/chunk-A2YEQYCC.js +289 -0
  64. package/dist/safe-bash/command-chunks/chunk-A3XE767Q.js +502 -0
  65. package/dist/safe-bash/command-chunks/{chunk-MWY75E3F.js → chunk-A6LCBGE6.js} +187 -187
  66. package/dist/safe-bash/command-chunks/{chunk-HFUL6E5I.js → chunk-A7CE4EIU.js} +33 -151
  67. package/dist/safe-bash/command-chunks/chunk-A7EMM3SB.js +297 -0
  68. package/dist/safe-bash/command-chunks/{chunk-G3YO3JIN.js → chunk-ABH5FMMA.js} +1 -1
  69. package/dist/safe-bash/command-chunks/chunk-AEJZEGW7.js +1376 -0
  70. package/dist/safe-bash/command-chunks/chunk-AELXRNM6.js +207 -0
  71. package/dist/safe-bash/command-chunks/chunk-AEZIPWRI.js +260 -0
  72. package/dist/safe-bash/command-chunks/{chunk-AHD3CGAY.js → chunk-AFPXADZG.js} +4 -4
  73. package/dist/safe-bash/command-chunks/chunk-AIOB34IX.js +201 -0
  74. package/dist/safe-bash/command-chunks/chunk-AJEYCC4X.js +262 -0
  75. package/dist/safe-bash/command-chunks/chunk-ALMHXDKZ.js +321 -0
  76. package/dist/safe-bash/command-chunks/chunk-AQ6RTM2M.js +309 -0
  77. package/dist/safe-bash/command-chunks/chunk-AQNFEGMZ.js +481 -0
  78. package/dist/safe-bash/command-chunks/{chunk-2AKKYY5G.js → chunk-ASZ4EMKE.js} +1 -1
  79. package/dist/safe-bash/command-chunks/chunk-AYJGINE5.js +144 -0
  80. package/dist/safe-bash/command-chunks/{chunk-MRFW2E6B.js → chunk-B4UWZCQR.js} +1 -1
  81. package/dist/safe-bash/command-chunks/chunk-BDYKJTBQ.js +43 -0
  82. package/dist/safe-bash/command-chunks/chunk-BERVTMQB.js +41 -0
  83. package/dist/safe-bash/command-chunks/chunk-BZOY2UMP.js +275 -0
  84. package/dist/safe-bash/command-chunks/{chunk-W47KIMSP.js → chunk-C2EYJT4S.js} +1 -1
  85. package/dist/safe-bash/command-chunks/chunk-CK5Q6RDE.js +342 -0
  86. package/dist/safe-bash/command-chunks/chunk-CKEODJVT.js +992 -0
  87. package/dist/safe-bash/command-chunks/{chunk-Z7UIOPHJ.js → chunk-DCMSPMMD.js} +1 -1
  88. package/dist/safe-bash/command-chunks/chunk-DE66JRWJ.js +352 -0
  89. package/dist/safe-bash/command-chunks/chunk-DKNNYPOI.js +409 -0
  90. package/dist/safe-bash/command-chunks/chunk-DV745GFU.js +294 -0
  91. package/dist/safe-bash/command-chunks/chunk-DXX2Z2QA.js +33 -0
  92. package/dist/safe-bash/command-chunks/chunk-E7AYF54A.js +473 -0
  93. package/dist/safe-bash/command-chunks/chunk-EDSFQJAU.js +159 -0
  94. package/dist/safe-bash/command-chunks/{chunk-UQ3KEUCF.js → chunk-ESD5ZD74.js} +7 -1
  95. package/dist/safe-bash/command-chunks/chunk-EUXUCRCI.js +1739 -0
  96. package/dist/safe-bash/command-chunks/chunk-F2ORFLCH.js +3669 -0
  97. package/dist/safe-bash/command-chunks/chunk-FANIWOBM.js +311 -0
  98. package/dist/safe-bash/command-chunks/chunk-FOO3AXFK.js +47 -0
  99. package/dist/safe-bash/command-chunks/chunk-FRZ5P5AB.js +131 -0
  100. package/dist/safe-bash/command-chunks/chunk-FZSQMMYV.js +276 -0
  101. package/dist/safe-bash/command-chunks/{chunk-P6NUIMMX.js → chunk-G5F2VSQ7.js} +1 -1
  102. package/dist/safe-bash/command-chunks/chunk-GGOZXIGH.js +299 -0
  103. package/dist/safe-bash/command-chunks/chunk-GIESJLR2.js +241 -0
  104. package/dist/safe-bash/command-chunks/chunk-GLPIFP7N.js +385 -0
  105. package/dist/safe-bash/command-chunks/chunk-GZ2N24A2.js +342 -0
  106. package/dist/safe-bash/command-chunks/chunk-H2NWPMNW.js +216 -0
  107. package/dist/safe-bash/command-chunks/chunk-HHLVI2CB.js +3949 -0
  108. package/dist/safe-bash/command-chunks/chunk-HJDE7ZNV.js +82 -0
  109. package/dist/safe-bash/command-chunks/chunk-HOAM3F5I.js +124 -0
  110. package/dist/safe-bash/command-chunks/chunk-HPKUFWHW.js +482 -0
  111. package/dist/safe-bash/command-chunks/chunk-HPMVMOD2.js +109 -0
  112. package/dist/safe-bash/command-chunks/chunk-HQAHDJPX.js +8 -0
  113. package/dist/safe-bash/command-chunks/chunk-HR2Y6YEP.js +12 -0
  114. package/dist/safe-bash/command-chunks/chunk-HUNXIAOL.js +62 -0
  115. package/dist/safe-bash/command-chunks/chunk-I4JWZOSP.js +244 -0
  116. package/dist/safe-bash/command-chunks/chunk-I6AMDG2T.js +85 -0
  117. package/dist/safe-bash/command-chunks/chunk-IB2Q5CL3.js +288 -0
  118. package/dist/safe-bash/command-chunks/chunk-IFNLDOJ4.js +316 -0
  119. package/dist/safe-bash/command-chunks/chunk-IKHBXETN.js +174 -0
  120. package/dist/safe-bash/command-chunks/chunk-IOSWG5JS.js +228 -0
  121. package/dist/safe-bash/command-chunks/chunk-IQFRPIXH.js +317 -0
  122. package/dist/safe-bash/command-chunks/chunk-IR6ZKAUH.js +582 -0
  123. package/dist/safe-bash/command-chunks/chunk-IW7PEB4I.js +297 -0
  124. package/dist/safe-bash/command-chunks/chunk-JGGRMERW.js +36 -0
  125. package/dist/safe-bash/command-chunks/chunk-JHAY3KYC.js +520 -0
  126. package/dist/safe-bash/command-chunks/{chunk-UO25D4WG.js → chunk-JITDS55R.js} +22 -22
  127. package/dist/safe-bash/command-chunks/chunk-JJK3CU7Z.js +6 -0
  128. package/dist/safe-bash/command-chunks/{chunk-XKZWUMH4.js → chunk-JN7GNI2C.js} +1 -1
  129. package/dist/safe-bash/command-chunks/chunk-JQ3EJKHF.js +160 -0
  130. package/dist/safe-bash/command-chunks/chunk-JQE256UO.js +292 -0
  131. package/dist/safe-bash/command-chunks/chunk-JQZ3BXWY.js +382 -0
  132. package/dist/safe-bash/command-chunks/{chunk-7DLR4HCC.js → chunk-JWSOFSGI.js} +22 -22
  133. package/dist/safe-bash/command-chunks/chunk-K3CDZMUN.js +168 -0
  134. package/dist/safe-bash/command-chunks/{chunk-SUYSZJI3.js → chunk-K5COUQAQ.js} +4 -4
  135. package/dist/safe-bash/command-chunks/chunk-K7HUXUN2.js +489 -0
  136. package/dist/safe-bash/command-chunks/chunk-KB3CY3QO.js +62 -0
  137. package/dist/safe-bash/command-chunks/chunk-KCBVOYAY.js +92 -0
  138. package/dist/safe-bash/command-chunks/chunk-KD25ICP4.js +366 -0
  139. package/dist/safe-bash/command-chunks/chunk-KDKQ5D55.js +180 -0
  140. package/dist/safe-bash/command-chunks/chunk-KNKDUEDW.js +521 -0
  141. package/dist/safe-bash/command-chunks/chunk-KR2PQ7GD.js +174 -0
  142. package/dist/safe-bash/command-chunks/chunk-KS6WUDPM.js +153 -0
  143. package/dist/safe-bash/command-chunks/{chunk-XFHUSZBM.js → chunk-KUGV3SSL.js} +5 -5
  144. package/dist/safe-bash/command-chunks/chunk-L2JAP5KO.js +249 -0
  145. package/dist/safe-bash/command-chunks/chunk-L2KEA6SN.js +271 -0
  146. package/dist/safe-bash/command-chunks/chunk-L3WY5ASN.js +526 -0
  147. package/dist/safe-bash/command-chunks/chunk-L4XEXXVQ.js +399 -0
  148. package/dist/safe-bash/command-chunks/chunk-LDTUZIJK.js +90 -0
  149. package/dist/safe-bash/command-chunks/chunk-LHDB4QO5.js +479 -0
  150. package/dist/safe-bash/command-chunks/chunk-LHL6RWGJ.js +548 -0
  151. package/dist/safe-bash/command-chunks/chunk-LHRXDH45.js +164 -0
  152. package/dist/safe-bash/command-chunks/chunk-LQOKYG3O.js +153 -0
  153. package/dist/safe-bash/command-chunks/chunk-LRDME6WV.js +12 -0
  154. package/dist/safe-bash/command-chunks/chunk-LWVDJB5S.js +305 -0
  155. package/dist/safe-bash/command-chunks/chunk-M57GLLK4.js +27 -0
  156. package/dist/safe-bash/command-chunks/chunk-MAHX3IW3.js +108 -0
  157. package/dist/safe-bash/command-chunks/{chunk-LQZSR6DT.js → chunk-MDV7W5AS.js} +2 -2
  158. package/dist/safe-bash/command-chunks/chunk-MG7AJD5E.js +168 -0
  159. package/dist/safe-bash/command-chunks/chunk-MHJ3DQUE.js +213 -0
  160. package/dist/safe-bash/command-chunks/chunk-MLGNBD7V.js +552 -0
  161. package/dist/safe-bash/command-chunks/chunk-MN2M33JK.js +237 -0
  162. package/dist/safe-bash/command-chunks/chunk-MOL3TRBT.js +32 -0
  163. package/dist/safe-bash/command-chunks/chunk-MQFXMBGD.js +75 -0
  164. package/dist/safe-bash/command-chunks/chunk-MQPWE22J.js +171 -0
  165. package/dist/safe-bash/command-chunks/chunk-MQU6Q75R.js +523 -0
  166. package/dist/safe-bash/command-chunks/chunk-MWAAMNAM.js +353 -0
  167. package/dist/safe-bash/command-chunks/chunk-MZ4BTMTI.js +240 -0
  168. package/dist/safe-bash/command-chunks/chunk-N4DY4FPA.js +679 -0
  169. package/dist/safe-bash/command-chunks/chunk-N74TJL6X.js +183 -0
  170. package/dist/safe-bash/command-chunks/chunk-NA5Q4V2H.js +304 -0
  171. package/dist/safe-bash/command-chunks/chunk-NSM366N6.js +22 -0
  172. package/dist/safe-bash/command-chunks/chunk-NY4ZPV3N.js +523 -0
  173. package/dist/safe-bash/command-chunks/chunk-NYBF2BVE.js +17 -0
  174. package/dist/safe-bash/command-chunks/chunk-OBK24KGM.js +24 -0
  175. package/dist/safe-bash/command-chunks/{chunk-GDAS4LY7.js → chunk-OEKLEUUW.js} +4 -4
  176. package/dist/safe-bash/command-chunks/chunk-OGWJD5QP.js +404 -0
  177. package/dist/safe-bash/command-chunks/chunk-OIPATOZW.js +154 -0
  178. package/dist/safe-bash/command-chunks/chunk-OP6J3OLL.js +243 -0
  179. package/dist/safe-bash/command-chunks/chunk-OTTMIB3C.js +266 -0
  180. package/dist/safe-bash/command-chunks/{chunk-OZHPB4KD.js → chunk-OU4VE5CR.js} +12 -12
  181. package/dist/safe-bash/command-chunks/chunk-P42REFYL.js +228 -0
  182. package/dist/safe-bash/command-chunks/{chunk-YJ3TFZB2.js → chunk-PQOAM5SC.js} +1 -1
  183. package/dist/safe-bash/command-chunks/chunk-PQOIOVF2.js +444 -0
  184. package/dist/safe-bash/command-chunks/chunk-PRQEVUNE.js +205 -0
  185. package/dist/safe-bash/command-chunks/{chunk-W5OR7COJ.js → chunk-PVLPWVRH.js} +21 -21
  186. package/dist/safe-bash/command-chunks/{chunk-BNG4ZMZ3.js → chunk-PXL4NBYP.js} +1 -78
  187. package/dist/safe-bash/command-chunks/chunk-Q6W5FRZG.js +41 -0
  188. package/dist/safe-bash/command-chunks/{chunk-KLCHCSIV.js → chunk-QGD64UHJ.js} +1 -1
  189. package/dist/safe-bash/command-chunks/chunk-QHS7PDG3.js +188 -0
  190. package/dist/safe-bash/command-chunks/chunk-QXCSASIE.js +151 -0
  191. package/dist/safe-bash/command-chunks/chunk-QYCBVKFT.js +255 -0
  192. package/dist/safe-bash/command-chunks/chunk-R4TYL2G6.js +1529 -0
  193. package/dist/safe-bash/command-chunks/chunk-RAXJVM4U.js +625 -0
  194. package/dist/safe-bash/command-chunks/chunk-RBFZYSZZ.js +207 -0
  195. package/dist/safe-bash/command-chunks/chunk-RJHVJZ4H.js +185 -0
  196. package/dist/safe-bash/command-chunks/chunk-RKPPUYZE.js +213 -0
  197. package/dist/safe-bash/command-chunks/chunk-RMJNV6Q7.js +23 -0
  198. package/dist/safe-bash/command-chunks/{chunk-MR2RLUPV.js → chunk-RQHQCJMV.js} +11 -9
  199. package/dist/safe-bash/command-chunks/chunk-RR6QQ25D.js +71 -0
  200. package/dist/safe-bash/command-chunks/{chunk-JW3KIZU6.js → chunk-RUXY7GN5.js} +1 -1
  201. package/dist/safe-bash/command-chunks/chunk-RZC7QHL6.js +112 -0
  202. package/dist/safe-bash/command-chunks/chunk-RZJRR4UJ.js +1677 -0
  203. package/dist/safe-bash/command-chunks/chunk-S4OBYRNI.js +639 -0
  204. package/dist/safe-bash/command-chunks/{chunk-DQNDEWCI.js → chunk-S65T5JJO.js} +12 -12
  205. package/dist/safe-bash/command-chunks/chunk-S6PPBBXX.js +77 -0
  206. package/dist/safe-bash/command-chunks/chunk-SCG4LK5U.js +265 -0
  207. package/dist/safe-bash/command-chunks/chunk-SDTC2BLK.js +143 -0
  208. package/dist/safe-bash/command-chunks/chunk-SEK43FRN.js +357 -0
  209. package/dist/safe-bash/command-chunks/chunk-SH45NZ2P.js +194 -0
  210. package/dist/safe-bash/command-chunks/chunk-SM733XRT.js +250 -0
  211. package/dist/safe-bash/command-chunks/chunk-SSRGI476.js +116 -0
  212. package/dist/safe-bash/command-chunks/chunk-SUUD352U.js +127 -0
  213. package/dist/safe-bash/command-chunks/{chunk-B5F2KQYA.js → chunk-SWUVHT7G.js} +1 -1
  214. package/dist/safe-bash/command-chunks/chunk-TBAH4XGI.js +38 -0
  215. package/dist/safe-bash/command-chunks/chunk-TBVWTZTR.js +469 -0
  216. package/dist/safe-bash/command-chunks/chunk-TGHQGJNR.js +144 -0
  217. package/dist/safe-bash/command-chunks/{chunk-Q6JLT2EY.js → chunk-TL3KDYEM.js} +8 -110
  218. package/dist/safe-bash/command-chunks/chunk-TVAEX4WQ.js +473 -0
  219. package/dist/safe-bash/command-chunks/chunk-TZ2J6LGM.js +163 -0
  220. package/dist/safe-bash/command-chunks/chunk-UICO7H6S.js +186 -0
  221. package/dist/safe-bash/command-chunks/chunk-UJTJFMIN.js +501 -0
  222. package/dist/safe-bash/command-chunks/chunk-UMWWCLBG.js +109 -0
  223. package/dist/safe-bash/command-chunks/chunk-UPXFSGQG.js +134 -0
  224. package/dist/safe-bash/command-chunks/chunk-UWUYSXYT.js +272 -0
  225. package/dist/safe-bash/command-chunks/{chunk-5FMXQUDY.js → chunk-UZOGSYJP.js} +1 -1
  226. package/dist/safe-bash/command-chunks/chunk-V3RGA5PS.js +125 -0
  227. package/dist/safe-bash/command-chunks/chunk-VEUQWV2V.js +287 -0
  228. package/dist/safe-bash/command-chunks/chunk-VGKYTZT5.js +161 -0
  229. package/dist/safe-bash/command-chunks/chunk-VQUEIEVP.js +410 -0
  230. package/dist/safe-bash/command-chunks/chunk-VU3YUC3U.js +169 -0
  231. package/dist/safe-bash/command-chunks/chunk-W32KW66B.js +27 -0
  232. package/dist/safe-bash/command-chunks/chunk-W543LSYH.js +899 -0
  233. package/dist/safe-bash/command-chunks/chunk-W5YFDYHO.js +387 -0
  234. package/dist/safe-bash/command-chunks/chunk-W6DV2CLS.js +267 -0
  235. package/dist/safe-bash/command-chunks/chunk-WAKYUXVQ.js +215 -0
  236. package/dist/safe-bash/command-chunks/chunk-WGOL3MM6.js +125 -0
  237. package/dist/safe-bash/command-chunks/{chunk-N2A7V3WY.js → chunk-WHNYT34N.js} +3 -3
  238. package/dist/safe-bash/command-chunks/chunk-WOZCIRJ5.js +169 -0
  239. package/dist/safe-bash/command-chunks/chunk-WVB6ONZS.js +232 -0
  240. package/dist/safe-bash/command-chunks/chunk-WVESNAND.js +25 -0
  241. package/dist/safe-bash/command-chunks/chunk-XDEA3TL5.js +322 -0
  242. package/dist/safe-bash/command-chunks/chunk-XFEUWSYG.js +357 -0
  243. package/dist/safe-bash/command-chunks/chunk-XFMJ4RMS.js +2849 -0
  244. package/dist/safe-bash/command-chunks/chunk-XH6DXJHX.js +196 -0
  245. package/dist/safe-bash/command-chunks/chunk-XNJ67APB.js +6 -0
  246. package/dist/safe-bash/command-chunks/chunk-XP6BHGZ6.js +227 -0
  247. package/dist/safe-bash/command-chunks/chunk-XXFHTGV2.js +142 -0
  248. package/dist/safe-bash/command-chunks/chunk-Y5GI5PVT.js +139 -0
  249. package/dist/safe-bash/command-chunks/chunk-Y6KHC3JB.js +177 -0
  250. package/dist/safe-bash/command-chunks/{chunk-2UWPMSME.js → chunk-Y72LPXST.js} +8 -8
  251. package/dist/safe-bash/command-chunks/chunk-YDRWQZNB.js +69 -0
  252. package/dist/safe-bash/command-chunks/{chunk-P4OJBL2B.js → chunk-YFZ6FPIC.js} +1 -1
  253. package/dist/safe-bash/command-chunks/chunk-YH4DC4RP.js +171 -0
  254. package/dist/safe-bash/command-chunks/chunk-YH7KKMMN.js +463 -0
  255. package/dist/safe-bash/command-chunks/{chunk-MN3BB4WW.js → chunk-YP3WWV5N.js} +4 -4
  256. package/dist/safe-bash/command-chunks/chunk-YPVBU7QF.js +2817 -0
  257. package/dist/safe-bash/command-chunks/chunk-YQYVEVUE.js +1621 -0
  258. package/dist/safe-bash/command-chunks/chunk-YRNBIU5U.js +175 -0
  259. package/dist/safe-bash/command-chunks/chunk-Z7ESJVFP.js +10 -0
  260. package/dist/safe-bash/command-chunks/chunk-ZTAFAHY3.js +653 -0
  261. package/dist/safe-bash/command-chunks/chunk-ZXKOMB24.js +85 -0
  262. package/dist/safe-bash/command-chunks/{clipboard-XCSQACOK-SHFXT53F.js → clipboard-6SDGQGC3-TVJ3CG7A.js} +4 -4
  263. package/dist/safe-bash/command-chunks/{command-engine-4TEGTXCQ.js → command-engine-KMLHVFMA.js} +356 -316
  264. package/dist/safe-bash/command-chunks/{engine-QDC5VCGO-LYAAFESF.js → engine-EOYR2WTY-KUFLFTDE.js} +2 -4
  265. package/dist/safe-bash/command-chunks/{gnumeric-OCFH63UT-YI7SG7TN.js → gnumeric-ABKSRBZJ-MPIIPXKP.js} +3 -3
  266. package/dist/safe-bash/command-chunks/inspection-command-ULEU7ZVV.js +7 -0
  267. package/dist/safe-bash/command-chunks/model-store-JUFU3RSW.js +54 -0
  268. package/dist/safe-bash/command-chunks/pdf-22JDKKAR-UDWNSWYB.js +338 -0
  269. package/dist/safe-bash/command-chunks/{pptx-XG3YSXWZ-XAG36NAB.js → pptx-YDKHIGCD-H7FU4VMJ.js} +2 -2
  270. package/dist/safe-bash/commands/bc/index.browser.js +2 -2
  271. package/dist/safe-bash/commands/diffpdf/index.d.ts +2 -0
  272. package/dist/safe-bash/commands/diffpdf/index.js +2 -0
  273. package/dist/safe-bash/commands/dot/index.d.ts +2 -0
  274. package/dist/safe-bash/commands/dot/index.js +2 -0
  275. package/dist/safe-bash/commands/llm/collections.browser.js +6 -0
  276. package/dist/safe-bash/commands/llm/collections.d.ts +2 -0
  277. package/dist/safe-bash/commands/llm/collections.js +2 -0
  278. package/dist/safe-bash/commands/pandoc/index.browser.js +1 -1
  279. package/dist/safe-bash/commands/rsvg-convert/index.d.ts +2 -0
  280. package/dist/safe-bash/commands/rsvg-convert/index.js +2 -0
  281. package/dist/safe-bash/commands/safejs/io.d.ts +1 -1
  282. package/dist/safe-bash/commands/safejs/io.js +1 -1
  283. package/dist/safe-bash/commands/safejs/options.d.ts +1 -1
  284. package/dist/safe-bash/commands/safejs/options.js +1 -1
  285. package/dist/safe-bash/commands/safejs/render.d.ts +1 -1
  286. package/dist/safe-bash/commands/safejs/render.js +1 -1
  287. package/dist/safe-bash/commands/safejs/runtime.d.ts +1 -1
  288. package/dist/safe-bash/commands/safejs/runtime.js +1 -1
  289. package/dist/safe-bash/commands/safejs/types.d.ts +1 -1
  290. package/dist/safe-bash/commands/safejs/types.js +1 -1
  291. package/dist/safe-bash/commands/wdiff/index.d.ts +2 -0
  292. package/dist/safe-bash/commands/wdiff/index.js +2 -0
  293. package/dist/safe-bash/core.d.ts +4 -0
  294. package/dist/safe-bash/core.js +4 -0
  295. package/dist/safe-bash/full-core.browser.js +59 -35
  296. package/dist/safe-bash/optional-host.browser.js +7 -7
  297. package/dist/safe-bash/plugins/index.browser.js +7 -7
  298. package/dist/safe-bash/registry-entry.browser.js +6 -6
  299. package/dist/safe-bash/search.browser.js +2 -2
  300. package/dist/safe-bash/shell-entry.browser.js +3 -3
  301. package/dist/safe-bash-checksum-engine/index.js +83 -40
  302. package/dist/safe-bash-checksum-engine/md5.d.ts +2 -0
  303. package/dist/safe-bash-checksum-engine/md5.js +7 -0
  304. package/dist/safe-bash-command-awk/awk-inspection.js +2 -2
  305. package/dist/safe-bash-command-awk/awk-runtime.js +2 -2
  306. package/dist/safe-bash-command-awk/awk.js +7 -7
  307. package/dist/safe-bash-command-awk/index.js +7 -7
  308. package/dist/safe-bash-command-chmod/command.js +1 -1
  309. package/dist/safe-bash-command-chmod/index.js +1 -1
  310. package/dist/safe-bash-command-csvkit/index.js +6 -6
  311. package/dist/safe-bash-command-diff/index.js +3 -3
  312. package/dist/safe-bash-command-diffpdf/LICENSE +21 -0
  313. package/dist/safe-bash-command-diffpdf/index.d.ts +12 -0
  314. package/dist/safe-bash-command-diffpdf/index.js +107 -0
  315. package/dist/safe-bash-command-docx/command.d.ts +36 -0
  316. package/dist/{safe-bash-docx-engine → safe-bash-command-docx}/discovery.d.ts +4 -4
  317. package/dist/safe-bash-command-docx/index.js +1 -1
  318. package/dist/{safe-bash-docx-engine → safe-bash-command-docx}/inspection-command.d.ts +6 -6
  319. package/dist/safe-bash-command-docx/sdk.d.ts +4 -0
  320. package/dist/safe-bash-command-docx/sdk.js +24 -0
  321. package/dist/safe-bash-command-dot/LICENSE +21 -0
  322. package/dist/safe-bash-command-dot/index.d.ts +14 -0
  323. package/dist/safe-bash-command-dot/index.js +1298 -0
  324. package/dist/safe-bash-command-du/arguments.d.ts +1 -1
  325. package/dist/safe-bash-command-du/arguments.js +1 -1
  326. package/dist/safe-bash-command-du/du.js +2 -2
  327. package/dist/safe-bash-command-du/index.js +2 -2
  328. package/dist/safe-bash-command-factor/command.js +2 -2
  329. package/dist/safe-bash-command-factor/index.js +2 -2
  330. package/dist/safe-bash-command-ffmpeg/index.js +16 -16
  331. package/dist/safe-bash-command-imagemagick/index.js +21 -53
  332. package/dist/safe-bash-command-llm/collections-embed.d.ts +23 -0
  333. package/dist/safe-bash-command-llm/collections.d.ts +38 -0
  334. package/dist/safe-bash-command-llm/collections.js +423 -0
  335. package/dist/safe-bash-command-llm/command.js +4 -2
  336. package/dist/safe-bash-command-llm/index.js +12 -8
  337. package/dist/safe-bash-command-llm/openai.js +4 -3
  338. package/dist/safe-bash-command-llm/providers/index.js +6 -4
  339. package/dist/safe-bash-command-llm/providers/openai.js +4 -3
  340. package/dist/safe-bash-command-node/commands/node/browser.js +9 -12
  341. package/dist/safe-bash-command-node/commands/node/buffer.js +2 -2
  342. package/dist/safe-bash-command-node/commands/node/default-runtime.js +9 -12
  343. package/dist/safe-bash-command-node/commands/node/filesystem.js +3 -3
  344. package/dist/safe-bash-command-node/commands/node/safejs.js +9 -12
  345. package/dist/safe-bash-command-node/commands/node/source-maps.js +2 -2
  346. package/dist/safe-bash-command-node/commands/node/timers.js +3 -3
  347. package/dist/safe-bash-command-node/commands/safejs/io.d.ts +1 -35
  348. package/dist/safe-bash-command-node/commands/safejs/io.js +3 -7
  349. package/dist/safe-bash-command-node/commands/safejs/options.d.ts +2 -22
  350. package/dist/safe-bash-command-node/commands/safejs/options.js +1 -1
  351. package/dist/safe-bash-command-node/commands/safejs/render.d.ts +1 -1
  352. package/dist/safe-bash-command-node/commands/safejs/render.js +3 -5
  353. package/dist/safe-bash-command-node/commands/safejs/runtime.d.ts +2 -25
  354. package/dist/safe-bash-command-node/commands/safejs/runtime.js +1 -7
  355. package/dist/safe-bash-command-node/commands/safejs/types.d.ts +2 -85
  356. package/dist/safe-bash-command-node/commands/safejs/types.js +1 -1
  357. package/dist/safe-bash-command-node/integrations/safejs/filesystem.d.ts +2 -5
  358. package/dist/safe-bash-command-node/integrations/safejs/filesystem.js +3 -3
  359. package/dist/safe-bash-command-node/integrations/safejs/shell.js +1 -1
  360. package/dist/safe-bash-command-node/integrations/safejs/values.d.ts +1 -7
  361. package/dist/safe-bash-command-node/integrations/safejs/values.js +1 -1
  362. package/dist/safe-bash-command-openssl/index.js +15452 -420
  363. package/dist/safe-bash-command-pandoc/command.js +1 -1
  364. package/dist/safe-bash-command-pandoc/index.js +1 -1
  365. package/dist/safe-bash-command-patch/index.js +5 -5
  366. package/dist/safe-bash-command-patch/patch.js +4 -4
  367. package/dist/safe-bash-command-playwright-cli/index.js +25 -25
  368. package/dist/safe-bash-command-playwright-cli/playwright/abilities.js +8 -8
  369. package/dist/safe-bash-command-playwright-cli/playwright/controller.js +16 -16
  370. package/dist/safe-bash-command-playwright-cli/playwright/index.js +25 -25
  371. package/dist/safe-bash-command-playwright-cli/playwright/standard-capabilities.js +4 -4
  372. package/dist/{safe-bash-pptx-engine → safe-bash-command-pptx}/command-engine.d.ts +5 -13
  373. package/dist/safe-bash-command-pptx/engine.d.ts +4 -0
  374. package/dist/safe-bash-command-pptx/engine.js +37 -0
  375. package/dist/safe-bash-command-pptx/index.js +1 -1
  376. package/dist/safe-bash-command-python/executor.js +15 -15
  377. package/dist/safe-bash-command-python/index.js +15 -15
  378. package/dist/safe-bash-command-python/jspi.js +4 -4
  379. package/dist/safe-bash-command-qrencode/index.js +1 -4
  380. package/dist/safe-bash-command-rsvg-convert/LICENSE +21 -0
  381. package/dist/safe-bash-command-rsvg-convert/index.d.ts +13 -0
  382. package/dist/safe-bash-command-rsvg-convert/index.js +84 -0
  383. package/dist/safe-bash-command-safejs/LICENSE +21 -0
  384. package/dist/safe-bash-command-safejs/filesystem.d.ts +5 -0
  385. package/dist/safe-bash-command-safejs/filesystem.js +7 -0
  386. package/dist/safe-bash-command-safejs/index.d.ts +4 -0
  387. package/dist/safe-bash-command-safejs/index.js +19 -0
  388. package/dist/safe-bash-command-safejs/io.d.ts +35 -0
  389. package/dist/safe-bash-command-safejs/io.js +12 -0
  390. package/dist/safe-bash-command-safejs/options.d.ts +22 -0
  391. package/dist/safe-bash-command-safejs/options.js +11 -0
  392. package/dist/safe-bash-command-safejs/render.d.ts +1 -0
  393. package/dist/safe-bash-command-safejs/render.js +9 -0
  394. package/dist/safe-bash-command-safejs/runtime.d.ts +25 -0
  395. package/dist/safe-bash-command-safejs/runtime.js +13 -0
  396. package/dist/safe-bash-command-safejs/types.d.ts +85 -0
  397. package/dist/safe-bash-command-safejs/types.js +7 -0
  398. package/dist/safe-bash-command-safejs/values.d.ts +7 -0
  399. package/dist/safe-bash-command-safejs/values.js +19 -0
  400. package/dist/safe-bash-command-sips/index.js +1 -14
  401. package/dist/safe-bash-command-ssconvert/index.js +413 -546
  402. package/dist/safe-bash-command-ssconvert/rendering/chart/axis.d.ts +1 -26
  403. package/dist/safe-bash-command-ssconvert/rendering/chart/error-bar.d.ts +1 -39
  404. package/dist/safe-bash-command-ssconvert/rendering/chart/layout.d.ts +1 -24
  405. package/dist/safe-bash-command-ssconvert/rendering/chart/line.d.ts +1 -23
  406. package/dist/safe-bash-command-ssconvert/rendering/chart/marker.d.ts +1 -35
  407. package/dist/safe-bash-command-ssconvert/rendering/chart/pie.d.ts +1 -32
  408. package/dist/safe-bash-command-ssconvert/rendering/images/index.d.ts +1 -26
  409. package/dist/safe-bash-command-ssconvert/rendering/print/header-footer.d.ts +1 -16
  410. package/dist/safe-bash-command-ssconvert/rendering/print/layout.d.ts +1 -65
  411. package/dist/safe-bash-command-ssconvert/rendering/print/pagination.d.ts +1 -34
  412. package/dist/safe-bash-command-tar/create.js +4 -4
  413. package/dist/safe-bash-command-tar/extract.js +4 -4
  414. package/dist/safe-bash-command-tar/index.js +16 -14
  415. package/dist/safe-bash-command-tar/modes.js +6 -6
  416. package/dist/safe-bash-command-tar/options.d.ts +3 -1
  417. package/dist/safe-bash-command-tar/options.js +1 -1
  418. package/dist/safe-bash-command-unzip/index.js +4 -4
  419. package/dist/safe-bash-command-wdiff/LICENSE +21 -0
  420. package/dist/safe-bash-command-wdiff/index.d.ts +12 -0
  421. package/dist/safe-bash-command-wdiff/index.js +123 -0
  422. package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
  423. package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
  424. package/dist/safe-bash-compression-engine/files.js +5 -5
  425. package/dist/safe-bash-compression-engine/index.js +4 -4
  426. package/dist/safe-bash-compression-engine/operand.js +5 -5
  427. package/dist/safe-bash-compression-engine/stream.js +4 -4
  428. package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
  429. package/dist/safe-bash-contracts/escaping.js +2 -2
  430. package/dist/safe-bash-contracts/index.js +15 -15
  431. package/dist/safe-bash-docx-engine/admission.js +31 -0
  432. package/dist/safe-bash-docx-engine/ancillary-resources.js +38 -0
  433. package/dist/safe-bash-docx-engine/archive.js +24 -0
  434. package/dist/safe-bash-docx-engine/argument-json.js +25 -0
  435. package/dist/safe-bash-docx-engine/batch-operations.d.ts +7 -0
  436. package/dist/safe-bash-docx-engine/batch-operations.js +95 -0
  437. package/dist/safe-bash-docx-engine/batch-result-schema.d.ts +2 -0
  438. package/dist/safe-bash-docx-engine/batch-result-schema.js +145 -0
  439. package/dist/safe-bash-docx-engine/batch.js +106 -0
  440. package/dist/safe-bash-docx-engine/bookmarks.js +43 -0
  441. package/dist/safe-bash-docx-engine/budget.js +18 -0
  442. package/dist/safe-bash-docx-engine/charts.js +35 -0
  443. package/dist/safe-bash-docx-engine/command-option-rules.d.ts +1 -0
  444. package/dist/safe-bash-docx-engine/command-option-rules.js +24 -0
  445. package/dist/safe-bash-docx-engine/command-properties.d.ts +1 -0
  446. package/dist/safe-bash-docx-engine/command-properties.js +18 -0
  447. package/dist/safe-bash-docx-engine/command-selection.d.ts +1 -0
  448. package/dist/safe-bash-docx-engine/command-selection.js +15 -0
  449. package/dist/safe-bash-docx-engine/comments.js +53 -0
  450. package/dist/safe-bash-docx-engine/control-bindings.js +45 -0
  451. package/dist/safe-bash-docx-engine/control-repeat.js +46 -0
  452. package/dist/safe-bash-docx-engine/controls.js +52 -0
  453. package/dist/safe-bash-docx-engine/create.js +36 -0
  454. package/dist/safe-bash-docx-engine/diagrams.js +43 -0
  455. package/dist/safe-bash-docx-engine/diff.js +33 -0
  456. package/dist/safe-bash-docx-engine/discovery-result-schema.d.ts +72 -0
  457. package/dist/safe-bash-docx-engine/discovery-result-schema.js +36 -0
  458. package/dist/safe-bash-docx-engine/document-properties.js +43 -0
  459. package/dist/safe-bash-docx-engine/equations.js +53 -0
  460. package/dist/safe-bash-docx-engine/extract.js +40 -0
  461. package/dist/safe-bash-docx-engine/fields.js +48 -0
  462. package/dist/safe-bash-docx-engine/font-inventory.js +40 -0
  463. package/dist/safe-bash-docx-engine/font-resources.js +33 -0
  464. package/dist/safe-bash-docx-engine/image-batch-operations.d.ts +4 -0
  465. package/dist/safe-bash-docx-engine/image-batch-operations.js +35 -0
  466. package/dist/safe-bash-docx-engine/image-insertion.js +46 -0
  467. package/dist/safe-bash-docx-engine/image-layout.js +43 -0
  468. package/dist/safe-bash-docx-engine/image-replacement.js +48 -0
  469. package/dist/safe-bash-docx-engine/images.js +49 -0
  470. package/dist/safe-bash-docx-engine/index.d.ts +1 -3
  471. package/dist/safe-bash-docx-engine/index.js +369 -19350
  472. package/dist/safe-bash-docx-engine/inspection.js +49 -0
  473. package/dist/safe-bash-docx-engine/invocation.d.ts +50 -0
  474. package/dist/safe-bash-docx-engine/invocation.js +66 -0
  475. package/dist/safe-bash-docx-engine/io-errors.js +11 -0
  476. package/dist/safe-bash-docx-engine/io.js +29 -0
  477. package/dist/safe-bash-docx-engine/links.js +47 -0
  478. package/dist/safe-bash-docx-engine/lists.js +46 -0
  479. package/dist/safe-bash-docx-engine/location-token.js +27 -0
  480. package/dist/safe-bash-docx-engine/locations.js +39 -0
  481. package/dist/safe-bash-docx-engine/model-context.js +15 -0
  482. package/dist/safe-bash-docx-engine/model-errors.js +13 -0
  483. package/dist/safe-bash-docx-engine/notes.js +48 -0
  484. package/dist/safe-bash-docx-engine/objects.js +49 -0
  485. package/dist/safe-bash-docx-engine/operation-json-schema.js +21 -0
  486. package/dist/safe-bash-docx-engine/operation-schema.js +29 -0
  487. package/dist/safe-bash-docx-engine/pack-uri-batch-operations.d.ts +3 -0
  488. package/dist/safe-bash-docx-engine/pack-uri-batch-operations.js +15 -0
  489. package/dist/safe-bash-docx-engine/pack.js +38 -0
  490. package/dist/safe-bash-docx-engine/package-view-batch-operations.d.ts +4 -0
  491. package/dist/safe-bash-docx-engine/package-view-batch-operations.js +47 -0
  492. package/dist/safe-bash-docx-engine/package-xml.js +25 -0
  493. package/dist/safe-bash-docx-engine/pandoc-adapter.js +55 -6
  494. package/dist/safe-bash-docx-engine/paragraph-edit.js +52 -0
  495. package/dist/safe-bash-docx-engine/part-provider.js +18 -0
  496. package/dist/safe-bash-docx-engine/property-values.js +46 -0
  497. package/dist/safe-bash-docx-engine/publication.js +40 -0
  498. package/dist/safe-bash-docx-engine/removal.js +44 -0
  499. package/dist/safe-bash-docx-engine/revision-decisions.js +46 -0
  500. package/dist/safe-bash-docx-engine/revision-edit.js +43 -0
  501. package/dist/safe-bash-docx-engine/revisions.js +42 -0
  502. package/dist/safe-bash-docx-engine/run-format.js +43 -0
  503. package/dist/safe-bash-docx-engine/sanitize.js +59 -0
  504. package/dist/safe-bash-docx-engine/sections.js +47 -0
  505. package/dist/safe-bash-docx-engine/settings.js +36 -0
  506. package/dist/safe-bash-docx-engine/shape-edit.js +47 -0
  507. package/dist/safe-bash-docx-engine/signatures.js +42 -0
  508. package/dist/safe-bash-docx-engine/simple-selection.d.ts +1 -1
  509. package/dist/safe-bash-docx-engine/stories.js +48 -0
  510. package/dist/safe-bash-docx-engine/structure-model-batch-operations.d.ts +3 -0
  511. package/dist/safe-bash-docx-engine/structure-model-batch-operations.js +64 -0
  512. package/dist/safe-bash-docx-engine/style-model-batch-operations.js +57 -0
  513. package/dist/safe-bash-docx-engine/style-model-result-schema.d.ts +4 -0
  514. package/dist/safe-bash-docx-engine/style-model-result-schema.js +76 -0
  515. package/dist/safe-bash-docx-engine/styles.js +44 -0
  516. package/dist/safe-bash-docx-engine/table-edit.js +52 -0
  517. package/dist/safe-bash-docx-engine/table-read.js +38 -0
  518. package/dist/safe-bash-docx-engine/template.js +45 -0
  519. package/dist/safe-bash-docx-engine/text-replace.js +47 -0
  520. package/dist/safe-bash-docx-engine/text-resource-read.js +42 -0
  521. package/dist/safe-bash-docx-engine/text.js +36 -0
  522. package/dist/safe-bash-docx-engine/validation.js +30 -0
  523. package/dist/safe-bash-docx-engine/xml-parts.js +48 -0
  524. package/dist/safe-bash-markdown-engine/index.js +3 -3
  525. package/dist/safe-bash-network-engine/aggregate.js +3 -3
  526. package/dist/safe-bash-network-engine/args.js +3 -3
  527. package/dist/safe-bash-network-engine/body.js +4 -4
  528. package/dist/safe-bash-network-engine/decode.js +3 -3
  529. package/dist/safe-bash-network-engine/fetch-transport.js +3 -3
  530. package/dist/safe-bash-network-engine/index.js +3 -3
  531. package/dist/safe-bash-network-engine/output.js +3 -3
  532. package/dist/safe-bash-network-engine/platform-portable.js +3 -3
  533. package/dist/safe-bash-network-engine/shared.js +2 -2
  534. package/dist/safe-bash-network-engine/transfer.js +20 -20
  535. package/dist/safe-bash-pptx-engine/bytes.d.ts +1 -4
  536. package/dist/safe-bash-pptx-engine/bytes.js +2 -11
  537. package/dist/safe-bash-pptx-engine/index.d.ts +1 -103
  538. package/dist/safe-bash-pptx-engine/index.js +1 -662
  539. package/dist/safe-bash-presentation-engine/LICENSE +21 -0
  540. package/dist/safe-bash-presentation-engine/accessibility.js +43 -0
  541. package/dist/safe-bash-presentation-engine/animation-editing.js +29 -0
  542. package/dist/safe-bash-presentation-engine/animations.js +23 -0
  543. package/dist/safe-bash-presentation-engine/backgrounds.js +26 -0
  544. package/dist/safe-bash-presentation-engine/bytes.d.ts +4 -0
  545. package/dist/safe-bash-presentation-engine/bytes.js +13 -0
  546. package/dist/safe-bash-presentation-engine/chart-editing.js +60 -0
  547. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-enums.d.ts +2 -2
  548. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-object-operations.d.ts +1 -1
  549. package/dist/safe-bash-presentation-engine/chart-object-operations.js +35 -0
  550. package/dist/safe-bash-presentation-engine/charts.js +41 -0
  551. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/color-enums.d.ts +5 -5
  552. package/dist/safe-bash-presentation-engine/command-placeholder.js +64 -0
  553. package/dist/safe-bash-presentation-engine/comments.js +32 -0
  554. package/dist/safe-bash-presentation-engine/connector-operations.js +50 -0
  555. package/dist/safe-bash-presentation-engine/connectors.js +49 -0
  556. package/dist/safe-bash-presentation-engine/content-types.js +9 -0
  557. package/dist/safe-bash-presentation-engine/contracts.js +0 -0
  558. package/dist/safe-bash-presentation-engine/creation.js +15 -0
  559. package/dist/safe-bash-presentation-engine/diff.js +40 -0
  560. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/drawing-enums.d.ts +20 -20
  561. package/dist/safe-bash-presentation-engine/drawing-format.js +44 -0
  562. package/dist/safe-bash-presentation-engine/drawing-operations.js +41 -0
  563. package/dist/safe-bash-presentation-engine/drawing-schema.d.ts +1549 -0
  564. package/dist/safe-bash-presentation-engine/drawing-schema.js +33 -0
  565. package/dist/safe-bash-presentation-engine/equations.js +30 -0
  566. package/dist/safe-bash-presentation-engine/errors.js +23 -0
  567. package/dist/safe-bash-presentation-engine/fields.js +32 -0
  568. package/dist/safe-bash-presentation-engine/font-metrics.js +12 -0
  569. package/dist/safe-bash-presentation-engine/image-extraction.js +29 -0
  570. package/dist/safe-bash-presentation-engine/image-formatting.js +43 -0
  571. package/dist/safe-bash-presentation-engine/image-insertion.js +26 -0
  572. package/dist/safe-bash-presentation-engine/image-metadata.d.ts +9 -0
  573. package/dist/safe-bash-presentation-engine/image-metadata.js +9 -0
  574. package/dist/safe-bash-presentation-engine/image-replacement.js +30 -0
  575. package/dist/safe-bash-presentation-engine/image-value.js +15 -0
  576. package/dist/safe-bash-presentation-engine/images.js +30 -0
  577. package/dist/safe-bash-presentation-engine/index.d.ts +100 -0
  578. package/dist/safe-bash-presentation-engine/index.js +791 -0
  579. package/dist/safe-bash-presentation-engine/layouts.js +31 -0
  580. package/dist/safe-bash-presentation-engine/length.js +21 -0
  581. package/dist/safe-bash-presentation-engine/links.js +33 -0
  582. package/dist/safe-bash-presentation-engine/masters.js +54 -0
  583. package/dist/safe-bash-presentation-engine/media-editing.js +35 -0
  584. package/dist/safe-bash-presentation-engine/media-extraction.js +24 -0
  585. package/dist/safe-bash-presentation-engine/media.js +23 -0
  586. package/dist/safe-bash-presentation-engine/memberships.js +24 -0
  587. package/dist/safe-bash-presentation-engine/notes.js +27 -0
  588. package/dist/safe-bash-presentation-engine/ole-enum.js +10 -0
  589. package/dist/safe-bash-presentation-engine/ole-insertion.js +29 -0
  590. package/dist/safe-bash-presentation-engine/opaque-objects.js +21 -0
  591. package/dist/safe-bash-presentation-engine/package-reader.js +13 -0
  592. package/dist/safe-bash-presentation-engine/package-tools.js +25 -0
  593. package/dist/safe-bash-presentation-engine/package-uri.d.ts +13 -0
  594. package/dist/safe-bash-presentation-engine/package-uri.js +16 -0
  595. package/dist/safe-bash-presentation-engine/package-writer.js +13 -0
  596. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/presentation-model.d.ts +1 -1
  597. package/dist/safe-bash-presentation-engine/presentation-model.js +63 -0
  598. package/dist/safe-bash-presentation-engine/presentation-settings.js +25 -0
  599. package/dist/safe-bash-presentation-engine/properties.js +37 -0
  600. package/dist/safe-bash-presentation-engine/publication.d.ts +10 -0
  601. package/dist/safe-bash-presentation-engine/publication.js +0 -0
  602. package/dist/safe-bash-presentation-engine/relationships.js +16 -0
  603. package/dist/safe-bash-presentation-engine/resource-limits.js +8 -0
  604. package/dist/safe-bash-presentation-engine/sanitize.js +24 -0
  605. package/dist/safe-bash-presentation-engine/selector-schema.js +7 -0
  606. package/dist/safe-bash-presentation-engine/selectors.js +26 -0
  607. package/dist/safe-bash-presentation-engine/shape-groups.js +47 -0
  608. package/dist/safe-bash-presentation-engine/shape-operations.js +48 -0
  609. package/dist/safe-bash-presentation-engine/shape-path-operations.js +44 -0
  610. package/dist/safe-bash-presentation-engine/shape-paths.js +31 -0
  611. package/dist/safe-bash-presentation-engine/shape-presets.js +11 -0
  612. package/dist/safe-bash-presentation-engine/shape-selection.js +43 -0
  613. package/dist/safe-bash-presentation-engine/shape-transforms.js +28 -0
  614. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-types.d.ts +1 -1
  615. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shapes.d.ts +1 -1
  616. package/dist/safe-bash-presentation-engine/shapes.js +66 -0
  617. package/dist/safe-bash-presentation-engine/slide-copy.js +24 -0
  618. package/dist/safe-bash-presentation-engine/slide-import.js +27 -0
  619. package/dist/safe-bash-presentation-engine/slide-merge-split.js +33 -0
  620. package/dist/safe-bash-presentation-engine/slide-model.js +74 -0
  621. package/dist/safe-bash-presentation-engine/slide-removal.js +25 -0
  622. package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +17 -0
  623. package/dist/safe-bash-presentation-engine/slides.js +26 -0
  624. package/dist/safe-bash-presentation-engine/table-operations.js +51 -0
  625. package/dist/safe-bash-presentation-engine/table-spans.js +42 -0
  626. package/dist/safe-bash-presentation-engine/tables.js +45 -0
  627. package/dist/safe-bash-presentation-engine/tags.js +25 -0
  628. package/dist/safe-bash-presentation-engine/template-bindings.js +44 -0
  629. package/dist/safe-bash-presentation-engine/template-repeat.js +51 -0
  630. package/dist/safe-bash-presentation-engine/text-fitting.js +39 -0
  631. package/dist/safe-bash-presentation-engine/text-frames.js +52 -0
  632. package/dist/safe-bash-presentation-engine/text-paragraphs.js +58 -0
  633. package/dist/safe-bash-presentation-engine/text-reading.js +23 -0
  634. package/dist/safe-bash-presentation-engine/text-replacement.js +24 -0
  635. package/dist/safe-bash-presentation-engine/text-runs.js +45 -0
  636. package/dist/safe-bash-presentation-engine/themes.js +31 -0
  637. package/dist/safe-bash-presentation-engine/transitions.js +27 -0
  638. package/dist/safe-bash-presentation-engine/validation.js +14 -0
  639. package/dist/safe-bash-presentation-engine/xml-parts.js +25 -0
  640. package/dist/safe-bash-presentation-engine/xml-view.js +8 -0
  641. package/dist/safe-bash-presentation-engine/xml.js +8 -0
  642. package/dist/safe-bash-sqlite-engine/sqlite-edit-snapshot.d.ts +15 -0
  643. package/dist/safe-bash-sqlite-engine/sqlite-finalization.d.ts +7 -0
  644. package/dist/safe-bash-sqlite-engine/sqlite-pages.d.ts +18 -0
  645. package/dist/safe-bash-sqlite-engine/sqlite-record-read.d.ts +8 -0
  646. package/dist/safe-bash-sqlite-engine/sqlite-record-write.d.ts +20 -0
  647. package/dist/safe-bash-sqlite-engine/storage.d.ts +2 -0
  648. package/dist/safe-bash-sqlite-engine/storage.js +236 -55
  649. package/dist/safe-bash-svg-engine/LICENSE +21 -0
  650. package/dist/safe-bash-svg-engine/index.d.ts +8 -0
  651. package/dist/safe-bash-svg-engine/index.js +477 -0
  652. package/dist/safe-bash-zip-engine/index.js +3 -3
  653. package/dist/safe-bash-zip-engine/zip/repair.js +3 -3
  654. package/dist/safe-bash-zip-engine/zip/sfx.js +3 -3
  655. package/dist/safe-bash-zip-engine/zip-format.js +3 -3
  656. package/dist/safe-playwright-cloudflare/browser-provider.generated.js +55 -18
  657. package/dist/safe-playwright-cloudflare/browser-run-code-guest.generated.js +1 -1
  658. package/dist/spreadsheet-engine/datasource.js +4 -1
  659. package/dist/spreadsheet-engine/formulas/functions/math.js +3 -1
  660. package/dist/spreadsheet-engine/rendering/chart/axis.d.ts +26 -0
  661. package/dist/spreadsheet-engine/rendering/chart/axis.js +61 -0
  662. package/dist/spreadsheet-engine/rendering/chart/error-bar.d.ts +39 -0
  663. package/dist/spreadsheet-engine/rendering/chart/error-bar.js +59 -0
  664. package/dist/spreadsheet-engine/rendering/chart/layout.d.ts +24 -0
  665. package/dist/spreadsheet-engine/rendering/chart/layout.js +54 -0
  666. package/dist/spreadsheet-engine/rendering/chart/line.d.ts +23 -0
  667. package/dist/spreadsheet-engine/rendering/chart/line.js +56 -0
  668. package/dist/spreadsheet-engine/rendering/chart/marker.d.ts +35 -0
  669. package/dist/spreadsheet-engine/rendering/chart/marker.js +52 -0
  670. package/dist/spreadsheet-engine/rendering/chart/pie.d.ts +32 -0
  671. package/dist/spreadsheet-engine/rendering/chart/pie.js +47 -0
  672. package/dist/{safe-bash-command-ssconvert → spreadsheet-engine}/rendering/images/codecs.d.ts +0 -1
  673. package/dist/spreadsheet-engine/rendering/images/codecs.js +253 -0
  674. package/dist/spreadsheet-engine/rendering/images/index.d.ts +26 -0
  675. package/dist/spreadsheet-engine/rendering/images/index.js +144 -0
  676. package/dist/spreadsheet-engine/rendering/images/profile-raster.d.ts +4 -0
  677. package/dist/spreadsheet-engine/rendering/images/profile-raster.js +72 -0
  678. package/dist/spreadsheet-engine/rendering/images/scene.d.ts +3 -0
  679. package/dist/spreadsheet-engine/rendering/images/scene.js +34 -0
  680. package/dist/spreadsheet-engine/rendering/print/cell-style.d.ts +10 -0
  681. package/dist/spreadsheet-engine/rendering/print/cell-style.js +52 -0
  682. package/dist/spreadsheet-engine/rendering/print/font-normalization-data.d.ts +43 -0
  683. package/dist/spreadsheet-engine/rendering/print/font-normalization-data.js +1558 -0
  684. package/dist/spreadsheet-engine/rendering/print/font-normalization.d.ts +3 -0
  685. package/dist/spreadsheet-engine/rendering/print/font-normalization.js +113 -0
  686. package/dist/spreadsheet-engine/rendering/print/font-shaping.d.ts +18 -0
  687. package/dist/spreadsheet-engine/rendering/print/font-shaping.js +271 -0
  688. package/dist/spreadsheet-engine/rendering/print/harfbuzz/data.d.ts +1 -0
  689. package/dist/spreadsheet-engine/rendering/print/harfbuzz/data.js +2 -0
  690. package/dist/spreadsheet-engine/rendering/print/header-footer.d.ts +16 -0
  691. package/dist/spreadsheet-engine/rendering/print/header-footer.js +92 -0
  692. package/dist/spreadsheet-engine/rendering/print/layout.d.ts +65 -0
  693. package/dist/spreadsheet-engine/rendering/print/layout.js +75 -0
  694. package/dist/spreadsheet-engine/rendering/print/pagination.d.ts +34 -0
  695. package/dist/spreadsheet-engine/rendering/print/pagination.js +126 -0
  696. package/dist/spreadsheet-engine/rendering/print/settings.d.ts +42 -0
  697. package/dist/spreadsheet-engine/rendering/print/settings.js +159 -0
  698. package/dist/spreadsheet-format-xls/biff-metadata.js +3 -3
  699. package/dist/spreadsheet-format-xls/biff-write-metadata.d.ts +1 -1
  700. package/dist/spreadsheet-format-xls/biff-write-metadata.js +20 -3
  701. package/dist/spreadsheet-format-xls/biff-write.js +1 -1
  702. package/package.json +239 -12
  703. package/third-party/spreadsheet-engine/scripts/harfbuzz/README.md +39 -0
  704. package/third-party/spreadsheet-engine/scripts/harfbuzz/allocator.cc +18 -0
  705. package/third-party/spreadsheet-engine/scripts/harfbuzz/build.mjs +94 -0
  706. package/third-party/spreadsheet-engine/scripts/harfbuzz/completion.patch +98 -0
  707. package/third-party/spreadsheet-engine/scripts/harfbuzz/config-override.h +19 -0
  708. package/third-party/spreadsheet-engine/scripts/harfbuzz/exports.json +29 -0
  709. package/third-party/spreadsheet-engine/scripts/harfbuzz/sources.json +274 -0
  710. package/third-party/spreadsheet-engine/scripts/harfbuzz/verify.d.mts +10 -0
  711. package/third-party/spreadsheet-engine/scripts/harfbuzz/verify.mjs +96 -0
  712. package/third-party/spreadsheet-engine/scripts/harfbuzz/verify.test.mjs +60 -0
  713. package/third-party/spreadsheet-engine/src/rendering/images/NOTICE.md +22 -0
  714. package/third-party/spreadsheet-engine/src/rendering/print/NOTICE.md +30 -0
  715. package/third-party/spreadsheet-engine/src/rendering/print/font-normalization-NOTICE.md +64 -0
  716. package/third-party/spreadsheet-engine/src/rendering/print/font-normalization-data.ts +1558 -0
  717. package/third-party/spreadsheet-engine/src/rendering/print/font-normalization.ts +91 -0
  718. package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/EMSCRIPTEN-LICENSE.txt +102 -0
  719. package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/HARFBUZZ-LICENSE.txt +42 -0
  720. package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/LIBCXX-LICENSE.txt +311 -0
  721. package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/LIBCXXABI-LICENSE.txt +311 -0
  722. package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/MUSL-LICENSE.txt +193 -0
  723. package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/NOTICE.md +41 -0
  724. package/third-party/spreadsheet-engine/src/rendering/print/harfbuzz/data.ts +2 -0
  725. package/dist/safe-bash/command-chunks/chunk-C5TUE2FE.js +0 -169
  726. package/dist/safe-bash/command-chunks/chunk-CVKW2YIC.js +0 -13631
  727. package/dist/safe-bash/command-chunks/chunk-JBGGUHQY.js +0 -17617
  728. package/dist/safe-bash/command-chunks/chunk-S4R2JDPL.js +0 -35
  729. package/dist/safe-bash/command-chunks/chunk-TU5IFVCX.js +0 -33708
  730. package/dist/safe-bash/command-chunks/chunk-TUWGIF22.js +0 -328
  731. package/dist/safe-bash/command-chunks/data-2FJOPYXA-PDKMLCGR.js +0 -8
  732. package/dist/safe-bash/command-chunks/index.browser-2NLML6H4.js +0 -269
  733. package/dist/safe-bash/command-chunks/model-store-EEI3QS4G.js +0 -10
  734. package/dist/safe-bash/command-chunks/pdf-M2GFAR2A-FCJMJCAP.js +0 -683
  735. package/dist/safe-bash-command-ssconvert/rendering/images/formats.d.ts +0 -2
  736. package/dist/safe-bash-docx-engine/command.d.ts +0 -65
  737. package/dist/safe-bash/chunks/{chunk-4T4RQYRI.js → chunk-5HRGBHZH.js} +10 -10
  738. package/dist/safe-bash/chunks/{chunk-QUS6X4MS.js → chunk-EOQMDRTY.js} +0 -0
  739. package/dist/safe-bash/command-chunks/{chunk-2L3JKGUH.js → chunk-4LYZBDZF.js} +4 -4
  740. package/dist/safe-bash/command-chunks/{chunk-EMMSXKEJ.js → chunk-4Q4R3VZU.js} +0 -0
  741. package/dist/safe-bash/command-chunks/{chunk-5RLK2QSY.js → chunk-7JEIWA3A.js} +5 -5
  742. package/dist/safe-bash/command-chunks/{chunk-AV6N7DDA.js → chunk-DDYPQAXN.js} +3 -3
  743. package/dist/safe-bash/command-chunks/{chunk-OOB7YCFQ.js → chunk-FMJKCVSQ.js} +3 -3
  744. package/dist/safe-bash/command-chunks/{chunk-FUL2C4EX.js → chunk-HFKS6AET.js} +3 -3
  745. package/dist/safe-bash/command-chunks/{chunk-2M3WUEDX.js → chunk-J6K5Q53O.js} +10 -10
  746. package/dist/safe-bash/command-chunks/{chunk-ATWMLV75.js → chunk-RJXZYDSN.js} +7 -7
  747. package/dist/safe-bash/command-chunks/{chunk-JD3NSHFT.js → chunk-TVGIJ56E.js} +3 -3
  748. package/dist/safe-bash/command-chunks/{chunk-3I33KPQH.js → chunk-X2HVVMTW.js} +6 -6
  749. package/dist/safe-bash/command-chunks/{odf-UKSXPNOZ-NCL5P7YL.js → odf-UKSXPNOZ-BV2LCKTB.js} +0 -0
  750. package/dist/{safe-bash/command-chunks/chunk-3SVT5VB7.js → safe-bash-docx-engine/operation-types.js} +0 -0
  751. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/accessibility.d.ts +0 -0
  752. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/animation-editing.d.ts +0 -0
  753. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/animations.d.ts +0 -0
  754. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/backgrounds.d.ts +0 -0
  755. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-data-model.d.ts +0 -0
  756. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-editing.d.ts +0 -0
  757. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-font-operations.d.ts +0 -0
  758. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-model-axes.d.ts +0 -0
  759. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-model-core.d.ts +0 -0
  760. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-model-series.d.ts +0 -0
  761. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-model.d.ts +0 -0
  762. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-objects.d.ts +0 -0
  763. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/chart-workbook.d.ts +0 -0
  764. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/charts.d.ts +0 -0
  765. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/command-placeholder.d.ts +0 -0
  766. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/comments.d.ts +0 -0
  767. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/connector-operations.d.ts +0 -0
  768. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/connectors-model.d.ts +0 -0
  769. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/connectors.d.ts +0 -0
  770. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/content-types.d.ts +0 -0
  771. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/contracts.d.ts +0 -0
  772. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/creation.d.ts +0 -0
  773. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/diagram-resources.d.ts +0 -0
  774. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/diff.d.ts +0 -0
  775. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/drawing-format.d.ts +0 -0
  776. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/drawing-operations.d.ts +0 -0
  777. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/equations.d.ts +0 -0
  778. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/errors.d.ts +0 -0
  779. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/fields.d.ts +0 -0
  780. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/font-metrics.d.ts +0 -0
  781. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/freeform-builder.d.ts +0 -0
  782. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/group-model.d.ts +0 -0
  783. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/image-extraction.d.ts +0 -0
  784. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/image-formatting.d.ts +0 -0
  785. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/image-insertion.d.ts +0 -0
  786. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/image-replacement.d.ts +0 -0
  787. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/image-value.d.ts +0 -0
  788. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/images.d.ts +0 -0
  789. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/inventory.d.ts +0 -0
  790. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/language-enum.d.ts +0 -0
  791. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/layouts.d.ts +0 -0
  792. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/length.d.ts +0 -0
  793. package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/links-model.d.ts +4 -4
  794. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/links.d.ts +0 -0
  795. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/masters.d.ts +0 -0
  796. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/media-editing.d.ts +0 -0
  797. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/media-enum.d.ts +0 -0
  798. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/media-extraction.d.ts +0 -0
  799. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/media.d.ts +0 -0
  800. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/memberships.d.ts +0 -0
  801. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/modern-comments.d.ts +0 -0
  802. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/notes.d.ts +0 -0
  803. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/ole-enum.d.ts +0 -0
  804. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/ole-insertion.d.ts +0 -0
  805. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/opaque-objects.d.ts +0 -0
  806. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/package-reader.d.ts +0 -0
  807. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/package-tools.d.ts +0 -0
  808. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/package-view.d.ts +0 -0
  809. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/package-writer.d.ts +0 -0
  810. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/paragraph-alignment.d.ts +0 -0
  811. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/presentation-settings.d.ts +0 -0
  812. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/properties.d.ts +0 -0
  813. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/relationships.d.ts +0 -0
  814. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/resource-limits.d.ts +0 -0
  815. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/sanitize.d.ts +0 -0
  816. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/selector-schema.d.ts +0 -0
  817. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/selectors.d.ts +0 -0
  818. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-adjustments.d.ts +0 -0
  819. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-groups.d.ts +0 -0
  820. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-operations.d.ts +0 -0
  821. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-path-operations.d.ts +0 -0
  822. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-paths.d.ts +0 -0
  823. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-placeholder-types.d.ts +0 -0
  824. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-presets.d.ts +0 -0
  825. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-selection.d.ts +0 -0
  826. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/shape-transforms.d.ts +0 -0
  827. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-copy.d.ts +0 -0
  828. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-import.d.ts +0 -0
  829. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-layout-model.d.ts +0 -0
  830. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-merge-split.d.ts +0 -0
  831. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-model.d.ts +0 -0
  832. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-removal.d.ts +0 -0
  833. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slide-transfer-budget.d.ts +0 -0
  834. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/slides.d.ts +0 -0
  835. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/table-operations.d.ts +0 -0
  836. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/table-spans.d.ts +0 -0
  837. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/tables-model.d.ts +0 -0
  838. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/tables.d.ts +0 -0
  839. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/tags.d.ts +0 -0
  840. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/template-bindings.d.ts +0 -0
  841. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/template-repeat.d.ts +0 -0
  842. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-fitting.d.ts +0 -0
  843. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-frame-enums.d.ts +0 -0
  844. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-frames.d.ts +0 -0
  845. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-paragraphs.d.ts +0 -0
  846. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-reading.d.ts +0 -0
  847. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-replacement.d.ts +0 -0
  848. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-run-color.d.ts +0 -0
  849. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-runs.d.ts +0 -0
  850. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/text-style-resolution.d.ts +0 -0
  851. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/themes.d.ts +0 -0
  852. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/transitions.d.ts +0 -0
  853. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/validation.d.ts +0 -0
  854. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/xml-parts.d.ts +0 -0
  855. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/xml-view.d.ts +0 -0
  856. /package/dist/{safe-bash-pptx-engine → safe-bash-presentation-engine}/xml.d.ts +0 -0
@@ -0,0 +1,3669 @@
1
+ import {
2
+ inspectChart,
3
+ readCharts
4
+ } from "./chunk-AJEYCC4X.js";
5
+ import {
6
+ XL_AXIS_CROSSES,
7
+ XL_CATEGORY_TYPE,
8
+ XL_CHART_TYPE,
9
+ XL_DATA_LABEL_POSITION,
10
+ XL_LEGEND_POSITION,
11
+ XL_MARKER_STYLE,
12
+ XL_TICK_LABEL_POSITION,
13
+ XL_TICK_MARK,
14
+ applyChartFontUpdate,
15
+ validateChartObjectUpdates
16
+ } from "./chunk-ZTAFAHY3.js";
17
+ import {
18
+ nodeFor,
19
+ validateSelection
20
+ } from "./chunk-QHS7PDG3.js";
21
+ import {
22
+ FillFormat,
23
+ LineFormat,
24
+ ShadowFormat,
25
+ TextFrame,
26
+ applyFrameFormatting,
27
+ applyShapeUpdate
28
+ } from "./chunk-HHLVI2CB.js";
29
+ import {
30
+ createXmlElementView
31
+ } from "./chunk-QXCSASIE.js";
32
+ import {
33
+ ShapeIdAllocator
34
+ } from "./chunk-RZC7QHL6.js";
35
+ import {
36
+ applyDrawingUpdate,
37
+ validateDrawingUpdate
38
+ } from "./chunk-A3XE767Q.js";
39
+ import {
40
+ attr,
41
+ child,
42
+ escape,
43
+ loadShared,
44
+ nextRel,
45
+ relPart,
46
+ required
47
+ } from "./chunk-RAXJVM4U.js";
48
+ import {
49
+ writePackageArchive
50
+ } from "./chunk-YRNBIU5U.js";
51
+ import {
52
+ SelectionError
53
+ } from "./chunk-CKEODJVT.js";
54
+ import {
55
+ readPackage
56
+ } from "./chunk-FRZ5P5AB.js";
57
+ import {
58
+ parseXmlPart
59
+ } from "./chunk-L3WY5ASN.js";
60
+ import {
61
+ parseContentTypes
62
+ } from "./chunk-N74TJL6X.js";
63
+ import {
64
+ readRelationshipGraph
65
+ } from "./chunk-5GEFJROP.js";
66
+ import {
67
+ relativePartReference
68
+ } from "./chunk-XXFHTGV2.js";
69
+ import {
70
+ IndexError,
71
+ InvalidHandleError,
72
+ OfficeError,
73
+ PropertyAccessError,
74
+ TypeError,
75
+ ValueError
76
+ } from "./chunk-RR6QQ25D.js";
77
+ import {
78
+ __export
79
+ } from "./chunk-65DS4IOB.js";
80
+
81
+ // packages/safe-bash-presentation-engine/src/chart-model-core.ts
82
+ function chartBinding(read, write) {
83
+ const handles = [];
84
+ let previous = read();
85
+ const synchronize = (next) => {
86
+ if (previous === next) return;
87
+ previous = next;
88
+ for (const handle of handles) {
89
+ if (!handle.valid) continue;
90
+ try {
91
+ handle.locate(next);
92
+ } catch {
93
+ handle.valid = false;
94
+ }
95
+ }
96
+ };
97
+ const trackedRead = () => {
98
+ const next = read();
99
+ synchronize(next);
100
+ return next;
101
+ };
102
+ const trackedWrite = (xml) => {
103
+ write(xml);
104
+ synchronize(xml);
105
+ };
106
+ const track = (locate) => {
107
+ const state2 = { locate, valid: true };
108
+ handles.push(state2);
109
+ return (xml) => {
110
+ if (!state2.valid) throw new InvalidHandleError();
111
+ return locate(xml);
112
+ };
113
+ };
114
+ return { read: trackedRead, write: trackedWrite, locate: (xml) => xml.root, track };
115
+ }
116
+ var order = {
117
+ chartSpace: [
118
+ "date1904",
119
+ "lang",
120
+ "roundedCorners",
121
+ "AlternateContent",
122
+ "style",
123
+ "clrMapOvr",
124
+ "pivotSource",
125
+ "protection",
126
+ "chart",
127
+ "spPr",
128
+ "txPr",
129
+ "externalData",
130
+ "printSettings",
131
+ "userShapes",
132
+ "extLst"
133
+ ],
134
+ chart: [
135
+ "title",
136
+ "autoTitleDeleted",
137
+ "pivotFmts",
138
+ "view3D",
139
+ "floor",
140
+ "sideWall",
141
+ "backWall",
142
+ "plotArea",
143
+ "legend",
144
+ "plotVisOnly",
145
+ "dispBlanksAs",
146
+ "showDLblsOverMax",
147
+ "extLst"
148
+ ],
149
+ title: ["tx", "layout", "overlay", "spPr", "txPr", "extLst"],
150
+ legend: ["legendPos", "legendEntry", "layout", "overlay", "spPr", "txPr", "extLst"],
151
+ catAx: [
152
+ "axId",
153
+ "scaling",
154
+ "delete",
155
+ "axPos",
156
+ "majorGridlines",
157
+ "minorGridlines",
158
+ "title",
159
+ "numFmt",
160
+ "majorTickMark",
161
+ "minorTickMark",
162
+ "tickLblPos",
163
+ "spPr",
164
+ "txPr",
165
+ "crossAx",
166
+ "crosses",
167
+ "crossesAt",
168
+ "auto",
169
+ "lblAlgn",
170
+ "lblOffset",
171
+ "tickLblSkip",
172
+ "tickMarkSkip",
173
+ "noMultiLvlLbl",
174
+ "extLst"
175
+ ],
176
+ valAx: [
177
+ "axId",
178
+ "scaling",
179
+ "delete",
180
+ "axPos",
181
+ "majorGridlines",
182
+ "minorGridlines",
183
+ "title",
184
+ "numFmt",
185
+ "majorTickMark",
186
+ "minorTickMark",
187
+ "tickLblPos",
188
+ "spPr",
189
+ "txPr",
190
+ "crossAx",
191
+ "crosses",
192
+ "crossesAt",
193
+ "crossBetween",
194
+ "majorUnit",
195
+ "minorUnit",
196
+ "dispUnits",
197
+ "extLst"
198
+ ],
199
+ dateAx: [
200
+ "axId",
201
+ "scaling",
202
+ "delete",
203
+ "axPos",
204
+ "majorGridlines",
205
+ "minorGridlines",
206
+ "title",
207
+ "numFmt",
208
+ "majorTickMark",
209
+ "minorTickMark",
210
+ "tickLblPos",
211
+ "spPr",
212
+ "txPr",
213
+ "crossAx",
214
+ "crosses",
215
+ "crossesAt",
216
+ "auto",
217
+ "lblOffset",
218
+ "baseTimeUnit",
219
+ "majorUnit",
220
+ "majorTimeUnit",
221
+ "minorUnit",
222
+ "minorTimeUnit",
223
+ "extLst"
224
+ ],
225
+ scaling: ["logBase", "orientation", "max", "min", "extLst"],
226
+ marker: ["symbol", "size", "spPr", "extLst"],
227
+ dPt: [
228
+ "idx",
229
+ "invertIfNegative",
230
+ "marker",
231
+ "bubble3D",
232
+ "explosion",
233
+ "spPr",
234
+ "pictureOptions",
235
+ "extLst"
236
+ ],
237
+ dLbl: [
238
+ "idx",
239
+ "layout",
240
+ "tx",
241
+ "numFmt",
242
+ "spPr",
243
+ "txPr",
244
+ "dLblPos",
245
+ "showLegendKey",
246
+ "showVal",
247
+ "showCatName",
248
+ "showSerName",
249
+ "showPercent",
250
+ "showBubbleSize",
251
+ "separator",
252
+ "extLst"
253
+ ],
254
+ dLbls: [
255
+ "dLbl",
256
+ "delete",
257
+ "numFmt",
258
+ "spPr",
259
+ "txPr",
260
+ "dLblPos",
261
+ "showLegendKey",
262
+ "showVal",
263
+ "showCatName",
264
+ "showSerName",
265
+ "showPercent",
266
+ "showBubbleSize",
267
+ "separator",
268
+ "showLeaderLines",
269
+ "leaderLines",
270
+ "extLst"
271
+ ],
272
+ ser: [
273
+ "idx",
274
+ "order",
275
+ "tx",
276
+ "spPr",
277
+ "invertIfNegative",
278
+ "pictureOptions",
279
+ "marker",
280
+ "dPt",
281
+ "dLbls",
282
+ "trendline",
283
+ "errBars",
284
+ "cat",
285
+ "val",
286
+ "xVal",
287
+ "yVal",
288
+ "bubbleSize",
289
+ "smooth",
290
+ "bubble3D",
291
+ "extLst"
292
+ ],
293
+ manualLayout: ["layoutTarget", "xMode", "yMode", "wMode", "hMode", "x", "y", "w", "h", "extLst"]
294
+ };
295
+ var plotOrder = [
296
+ "barDir",
297
+ "grouping",
298
+ "scatterStyle",
299
+ "radarStyle",
300
+ "varyColors",
301
+ "ser",
302
+ "dLbls",
303
+ "dropLines",
304
+ "hiLowLines",
305
+ "upDownBars",
306
+ "marker",
307
+ "smooth",
308
+ "gapWidth",
309
+ "gapDepth",
310
+ "overlap",
311
+ "serLines",
312
+ "firstSliceAng",
313
+ "holeSize",
314
+ "ofPieType",
315
+ "splitType",
316
+ "splitPos",
317
+ "custSplit",
318
+ "secondPieSize",
319
+ "bubbleScale",
320
+ "showNegBubbles",
321
+ "sizeRepresents",
322
+ "bandFmts",
323
+ "wireframe",
324
+ "axId",
325
+ "extLst"
326
+ ];
327
+ function numberValue(value, min = -Infinity, max = Infinity, integer = false) {
328
+ if (typeof value !== "number") throw new TypeError();
329
+ if (!Number.isFinite(value) || value < min || value > max || integer && !Number.isInteger(value))
330
+ throw new ValueError();
331
+ }
332
+ function booleanValue(value) {
333
+ if (typeof value !== "boolean") throw new TypeError();
334
+ }
335
+ function readBoolean(node, defaultValue) {
336
+ if (!node) return defaultValue;
337
+ const token2 = attr(node, "val");
338
+ if (token2 === void 0 || token2 === "1" || token2 === "true") return true;
339
+ if (token2 === "0" || token2 === "false") return false;
340
+ throw new ValueError("Invalid chart boolean.");
341
+ }
342
+ var chartBindings = /* @__PURE__ */ new WeakMap();
343
+ function chartNodeBinding(node) {
344
+ const binding = chartBindings.get(node);
345
+ if (!binding) throw new InvalidHandleError();
346
+ binding.locate(binding.read());
347
+ return binding;
348
+ }
349
+ function chartNode(node) {
350
+ const binding = chartNodeBinding(node);
351
+ return binding.locate(binding.read());
352
+ }
353
+ function chartDescendant(self, name, create = false) {
354
+ if (create && !child(chartNode(self), name)) chartPut(self, name, "");
355
+ const parent = chartNodeBinding(self);
356
+ return {
357
+ read: parent.read,
358
+ write: parent.write,
359
+ track: parent.track,
360
+ locate: (xml) => {
361
+ const found = child(parent.locate(xml), name);
362
+ if (!found) throw new InvalidHandleError();
363
+ return found;
364
+ }
365
+ };
366
+ }
367
+ function chartOptionalDescendant(self, name) {
368
+ const parent = chartNodeBinding(self), virtual = {
369
+ name: { namespace: chartNode(self).name.namespace, localName: name },
370
+ attributes: [],
371
+ children: []
372
+ };
373
+ let materialized = !!child(chartNode(self), name);
374
+ return {
375
+ read: parent.read,
376
+ write: parent.write,
377
+ track: parent.track,
378
+ prepare: () => {
379
+ parent.prepare?.();
380
+ if (!child(chartNode(self), name)) chartPut(self, name, "");
381
+ },
382
+ locate: (xml) => {
383
+ const found = child(parent.locate(xml), name);
384
+ if (found) {
385
+ materialized = true;
386
+ return found;
387
+ }
388
+ if (materialized) throw new InvalidHandleError();
389
+ return virtual;
390
+ }
391
+ };
392
+ }
393
+ function chartPut(self, name, content, attributes = {}) {
394
+ chartNodeBinding(self).prepare?.();
395
+ const document = chartNodeBinding(self).read(), node = chartNodeBinding(self).locate(document), existing = child(node, name);
396
+ if (content === null) {
397
+ if (existing)
398
+ chartNodeBinding(self).write(
399
+ document.spliceChildren(node, node.children.indexOf(existing), 1, [])
400
+ );
401
+ return;
402
+ }
403
+ const sequence = order[node.name.localName] ?? (node.name.localName.endsWith("Chart") ? plotOrder : [name, "extLst"]);
404
+ const rank = sequence.indexOf(name);
405
+ const next = node.children.findIndex(
406
+ (n) => n.name.namespace === node.name.namespace && sequence.indexOf(n.name.localName) > rank
407
+ );
408
+ const index = existing ? node.children.indexOf(existing) : next < 0 ? node.children.length : next;
409
+ const markup = `<c:${name} xmlns:c="${node.name.namespace}"${Object.entries(attributes).map(([key, value]) => ` ${key}="${escape(value)}"`).join("")}>${content}</c:${name}>`;
410
+ chartNodeBinding(self).write(document.spliceChildren(node, index, existing ? 1 : 0, [markup]));
411
+ }
412
+ var ChartNode = class _ChartNode {
413
+ #binding;
414
+ constructor(binding) {
415
+ this.#binding = { ...binding, locate: binding.track?.(binding.locate) ?? binding.locate };
416
+ chartBindings.set(this, this.#binding);
417
+ }
418
+ scalar(name) {
419
+ const n = child(chartNode(this), name);
420
+ return n ? attr(n, "val") ?? null : null;
421
+ }
422
+ setScalar(name, value) {
423
+ if (value === null) {
424
+ chartPut(this, name, null);
425
+ return;
426
+ }
427
+ const xml = this.#binding.read(), node = this.#binding.locate(xml), existing = child(node, name);
428
+ const encoded = typeof value === "boolean" ? value ? "1" : "0" : String(value);
429
+ if (existing)
430
+ this.#binding.write(
431
+ xml.merge(existing, { attributes: [{ namespace: "", localName: "val", value: encoded }] })
432
+ );
433
+ else chartPut(this, name, "", { val: encoded });
434
+ }
435
+ present(name, value) {
436
+ booleanValue(value);
437
+ if (value) {
438
+ if (!child(chartNode(this), name)) chartPut(this, name, "");
439
+ } else chartPut(this, name, null);
440
+ }
441
+ textFrame(name = "txPr") {
442
+ if (!child(chartNode(this), name)) {
443
+ const ans = chartNode(this).name.namespace.includes("purl.oclc.org") ? "http://purl.oclc.org/ooxml/drawingml/main" : "http://schemas.openxmlformats.org/drawingml/2006/main";
444
+ chartPut(
445
+ this,
446
+ name,
447
+ `<a:bodyPr xmlns:a="${ans}"/><a:lstStyle xmlns:a="${ans}"/><a:p xmlns:a="${ans}"/>`
448
+ );
449
+ }
450
+ const binding = chartDescendant(this, name);
451
+ let owner, cached;
452
+ const read = () => {
453
+ const xml = binding.read();
454
+ if (owner !== xml) {
455
+ cached = xml.subtree(binding.locate(xml));
456
+ owner = xml;
457
+ }
458
+ return cached;
459
+ };
460
+ return new TextFrame(read(), void 0, {
461
+ read,
462
+ write: (next) => {
463
+ const xml = binding.read(), parent = this.#binding.locate(xml), node = binding.locate(xml);
464
+ binding.write(
465
+ xml.spliceChildren(parent, parent.children.indexOf(node), 1, [
466
+ next.markup(next.root, true)
467
+ ])
468
+ );
469
+ }
470
+ });
471
+ }
472
+ get element() {
473
+ this.#binding.prepare?.();
474
+ const expected = this.#binding.read(), selected = this.#binding.locate(expected), subtree = expected.subtree(selected);
475
+ return createXmlElementView({
476
+ read: () => {
477
+ if (this.#binding.read() !== expected) throw new InvalidHandleError();
478
+ return subtree;
479
+ },
480
+ commit: (_old, next) => {
481
+ if (this.#binding.read() !== expected) throw new InvalidHandleError();
482
+ const findParent = (node) => node.children.includes(selected) ? node : node.children.map(findParent).find(Boolean);
483
+ const parent = findParent(expected.root);
484
+ if (!parent) throw new InvalidHandleError();
485
+ this.#binding.write(
486
+ expected.spliceChildren(parent, parent.children.indexOf(selected), 1, [
487
+ next.markup(next.root, true)
488
+ ])
489
+ );
490
+ }
491
+ });
492
+ }
493
+ equals(other) {
494
+ return other instanceof _ChartNode && this.#binding.read() === other.#binding.read() && chartNode(this) === chartNode(other);
495
+ }
496
+ get format() {
497
+ return new ChartFormat(chartNodeBinding(this));
498
+ }
499
+ };
500
+ var ChartFormat = class extends ChartNode {
501
+ apply(update) {
502
+ validateDrawingUpdate(update);
503
+ if (!child(chartNode(this), "spPr")) chartPut(this, "spPr", "");
504
+ const binding = chartNodeBinding(this);
505
+ const xml = binding.read();
506
+ binding.write(applyDrawingUpdate(xml, binding.locate(xml), update));
507
+ }
508
+ #drawing() {
509
+ if (!child(chartNode(this), "spPr")) chartPut(this, "spPr", "");
510
+ const binding = chartNodeBinding(this);
511
+ let owner, cached;
512
+ const read = () => {
513
+ const xml = binding.read();
514
+ if (owner !== xml) {
515
+ cached = xml.subtree(binding.locate(xml));
516
+ owner = xml;
517
+ }
518
+ return cached;
519
+ };
520
+ const edit = (transform) => {
521
+ const xml = binding.read(), selected = binding.locate(xml), local = read();
522
+ const next = transform(local, local.root);
523
+ const parentOf = (node) => {
524
+ if (node.children.includes(selected)) return node;
525
+ for (const c of node.children) {
526
+ const found = parentOf(c);
527
+ if (found) return found;
528
+ }
529
+ return void 0;
530
+ };
531
+ const parent = parentOf(xml.root);
532
+ if (!parent) throw new InvalidHandleError();
533
+ binding.write(
534
+ xml.spliceChildren(parent, parent.children.indexOf(selected), 1, [
535
+ next.markup(next.root, true)
536
+ ])
537
+ );
538
+ };
539
+ const update = (value) => edit(
540
+ (xml, node) => applyDrawingUpdate(xml, node, {
541
+ ...value.fill === void 0 ? {} : {
542
+ fill: value.fill === null ? { kind: "none" } : value.fill === "solid" ? { kind: "solid" } : { kind: "solid", color: value.fill }
543
+ },
544
+ ...value.lineColor === void 0 && value.lineWidth === void 0 ? {} : {
545
+ line: {
546
+ ...value.lineColor === void 0 ? {} : {
547
+ fill: value.lineColor === null ? { kind: "none" } : value.lineColor === "solid" ? { kind: "solid" } : { kind: "solid", color: value.lineColor }
548
+ },
549
+ ...value.lineWidth === void 0 ? {} : { width: value.lineWidth }
550
+ }
551
+ }
552
+ })
553
+ );
554
+ return { read, edit, update };
555
+ }
556
+ get fill() {
557
+ const { read, edit, update } = this.#drawing();
558
+ return new FillFormat(read, update, false, edit);
559
+ }
560
+ get line() {
561
+ const { read, edit, update } = this.#drawing();
562
+ return new LineFormat(read, update, edit);
563
+ }
564
+ get shadow() {
565
+ const { read, edit } = this.#drawing();
566
+ return new ShadowFormat(read, edit);
567
+ }
568
+ };
569
+ var sequences = /* @__PURE__ */ new WeakMap();
570
+ function state(sequence) {
571
+ return sequences.get(sequence);
572
+ }
573
+ var ChartSequence = class {
574
+ constructor(read, negative = true, equal = (a, b) => a === b || a instanceof ChartNode && a.equals(b)) {
575
+ const data = { read, negative, equal };
576
+ const numeric2 = (key) => typeof key === "string" && key !== "" && String(Number(key)) === key;
577
+ const proxy = new Proxy(this, {
578
+ get(target, key, receiver) {
579
+ if (numeric2(key)) {
580
+ if (Number(key) < 0) throw new IndexError();
581
+ return target.at(Number(key));
582
+ }
583
+ return Reflect.get(target, key, receiver);
584
+ },
585
+ set(target, key, value, receiver) {
586
+ if (numeric2(key)) throw new ValueError("Sequence entries cannot be replaced.");
587
+ return Reflect.set(target, key, value, receiver);
588
+ },
589
+ defineProperty(target, key, descriptor) {
590
+ if (numeric2(key)) throw new ValueError("Sequence entries cannot be replaced.");
591
+ return Reflect.defineProperty(target, key, descriptor);
592
+ },
593
+ deleteProperty(target, key) {
594
+ if (numeric2(key)) throw new ValueError("Sequence entries cannot be removed.");
595
+ return Reflect.deleteProperty(target, key);
596
+ }
597
+ });
598
+ sequences.set(this, data);
599
+ sequences.set(proxy, data);
600
+ return proxy;
601
+ }
602
+ get length() {
603
+ return state(this).read().length;
604
+ }
605
+ at(index) {
606
+ if (typeof index !== "number") throw new TypeError();
607
+ const data = state(this), all = data.read();
608
+ if (!Number.isInteger(index)) throw new IndexError();
609
+ const offset = index < 0 && data.negative ? all.length + index : index;
610
+ if (offset < 0 || offset >= all.length) throw new IndexError();
611
+ return all[offset];
612
+ }
613
+ *[Symbol.iterator]() {
614
+ yield* state(this).read();
615
+ }
616
+ includes(value) {
617
+ return this.count(value) > 0;
618
+ }
619
+ count(value) {
620
+ const data = state(this);
621
+ return data.read().filter((item) => data.equal(item, value)).length;
622
+ }
623
+ index(value, start = 0, stop) {
624
+ const data = state(this), all = data.read();
625
+ for (const bound of [start, stop])
626
+ if (bound !== void 0 && !Number.isSafeInteger(bound))
627
+ throw new ValueError("Invalid sequence search bound.");
628
+ const normalize = (bound) => Math.min(all.length, Math.max(0, bound < 0 ? all.length + bound : bound));
629
+ const first = normalize(start), last = stop === void 0 ? all.length : normalize(stop);
630
+ for (let index = first; index < last; index++) if (data.equal(all[index], value)) return index;
631
+ throw new ValueError();
632
+ }
633
+ *reversed() {
634
+ yield* [...state(this).read()].reverse();
635
+ }
636
+ };
637
+
638
+ // packages/safe-bash-presentation-engine/src/model-sequence.ts
639
+ function sequenceSlice(values, start, end, step = 1) {
640
+ if (!Number.isSafeInteger(step) || step === 0 || [start, end].some((value) => value !== void 0 && !Number.isSafeInteger(value)))
641
+ throw new ValueError("Invalid sequence slice bounds.");
642
+ const length = values.length;
643
+ const normalize = (value) => Math.max(
644
+ step > 0 ? 0 : -1,
645
+ Math.min(step > 0 ? length : length - 1, value < 0 ? length + value : value)
646
+ );
647
+ const first = start === void 0 ? step > 0 ? 0 : length - 1 : normalize(start);
648
+ const last = end === void 0 ? step > 0 ? length : -1 : normalize(end);
649
+ const result = [];
650
+ for (let i = first; step > 0 ? i < last : i > last; i += step) result.push(values[i]);
651
+ return Object.freeze(result);
652
+ }
653
+
654
+ // packages/safe-bash-presentation-engine/src/chart-model-axes.ts
655
+ var RichText = class extends ChartNode {
656
+ get frame() {
657
+ return this.textFrame("rich");
658
+ }
659
+ };
660
+ var ChartTitle = class extends ChartNode {
661
+ get has_text_frame() {
662
+ const tx = child(chartNode(this), "tx");
663
+ return !!(tx && child(tx, "rich"));
664
+ }
665
+ set has_text_frame(value) {
666
+ booleanValue(value);
667
+ if (value) {
668
+ void this.text_frame;
669
+ } else chartPut(this, "tx", null);
670
+ }
671
+ get text_frame() {
672
+ if (!this.has_text_frame) chartPut(this, "tx", "");
673
+ return new RichText(chartDescendant(this, "tx")).frame;
674
+ }
675
+ };
676
+ var AxisTitle = class extends ChartTitle {
677
+ };
678
+ var Legend = class extends ChartNode {
679
+ get font() {
680
+ return this.textFrame().paragraphs[0].font;
681
+ }
682
+ get position() {
683
+ const value = this.scalar("legendPos");
684
+ return value === null ? XL_LEGEND_POSITION.RIGHT : XL_LEGEND_POSITION.from_xml(value);
685
+ }
686
+ set position(value) {
687
+ this.setScalar("legendPos", XL_LEGEND_POSITION.to_xml(value));
688
+ }
689
+ get include_in_layout() {
690
+ return readBoolean(child(chartNode(this), "overlay"), true);
691
+ }
692
+ set include_in_layout(value) {
693
+ if (value !== null) booleanValue(value);
694
+ this.setScalar("overlay", value);
695
+ }
696
+ get horz_offset() {
697
+ const layout = child(chartNode(this), "layout"), manual = layout && child(layout, "manualLayout"), mode = manual && child(manual, "xMode"), x = manual && child(manual, "x");
698
+ return x && (!mode || attr(mode, "val") === "factor") ? Number(attr(x, "val") ?? 0) : 0;
699
+ }
700
+ set horz_offset(value) {
701
+ if (value !== null) numberValue(value, -1, 1);
702
+ new Layout(chartDescendant(this, "layout", true)).offset = value;
703
+ }
704
+ };
705
+ var Layout = class extends ChartNode {
706
+ set offset(value) {
707
+ new ManualLayout(chartDescendant(this, "manualLayout", true)).offset = value;
708
+ }
709
+ };
710
+ var ManualLayout = class extends ChartNode {
711
+ set offset(value) {
712
+ this.setScalar("xMode", "factor");
713
+ this.setScalar("x", value);
714
+ }
715
+ };
716
+ var TickLabels = class extends ChartNode {
717
+ get font() {
718
+ return this.textFrame().paragraphs[0].font;
719
+ }
720
+ get number_format() {
721
+ const node = child(chartNode(this), "numFmt");
722
+ return node ? attr(node, "formatCode") ?? "General" : "General";
723
+ }
724
+ set number_format(value) {
725
+ if (typeof value !== "string") throw new TypeError();
726
+ this.numberFormat(value, false);
727
+ }
728
+ get number_format_is_linked() {
729
+ const node = child(chartNode(this), "numFmt");
730
+ if (!node) return true;
731
+ const value = attr(node, "sourceLinked");
732
+ return value === void 0 || value === "1" || value === "true";
733
+ }
734
+ set number_format_is_linked(value) {
735
+ booleanValue(value);
736
+ this.numberFormat(this.number_format, value);
737
+ }
738
+ numberFormat(value, linked) {
739
+ const binding = chartNodeBinding(this), xml = binding.read(), node = binding.locate(xml), existing = child(node, "numFmt");
740
+ if (existing)
741
+ binding.write(
742
+ xml.merge(existing, {
743
+ attributes: [
744
+ { namespace: "", localName: "formatCode", value },
745
+ { namespace: "", localName: "sourceLinked", value: linked ? "1" : "0" }
746
+ ]
747
+ })
748
+ );
749
+ else chartPut(this, "numFmt", "", { formatCode: value, sourceLinked: linked ? "1" : "0" });
750
+ }
751
+ get offset() {
752
+ return Number(this.scalar("lblOffset") ?? 100);
753
+ }
754
+ set offset(value) {
755
+ numberValue(value, 0, 1e3, true);
756
+ this.setScalar("lblOffset", value);
757
+ }
758
+ };
759
+ var MajorGridlines = class extends ChartNode {
760
+ get format() {
761
+ return new ChartFormat(chartOptionalDescendant(this, "majorGridlines"));
762
+ }
763
+ };
764
+ var Scaling = class extends ChartNode {
765
+ get min() {
766
+ const value = this.scalar("min");
767
+ return value === null ? null : Number(value);
768
+ }
769
+ set min(value) {
770
+ if (value !== null) numberValue(value);
771
+ this.setScalar("min", value);
772
+ }
773
+ get max() {
774
+ const value = this.scalar("max");
775
+ return value === null ? null : Number(value);
776
+ }
777
+ set max(value) {
778
+ if (value !== null) numberValue(value);
779
+ this.setScalar("max", value);
780
+ }
781
+ get reversed() {
782
+ return this.scalar("orientation") === "maxMin";
783
+ }
784
+ set reversed(value) {
785
+ booleanValue(value);
786
+ this.setScalar("orientation", value ? "maxMin" : "minMax");
787
+ }
788
+ };
789
+ var BaseAxis = class extends ChartNode {
790
+ get axis_title() {
791
+ return new AxisTitle(chartDescendant(this, "title", true));
792
+ }
793
+ get has_title() {
794
+ return !!child(chartNode(this), "title");
795
+ }
796
+ set has_title(value) {
797
+ this.present("title", value);
798
+ }
799
+ get has_major_gridlines() {
800
+ return !!child(chartNode(this), "majorGridlines");
801
+ }
802
+ set has_major_gridlines(value) {
803
+ this.present("majorGridlines", value);
804
+ }
805
+ get has_minor_gridlines() {
806
+ return !!child(chartNode(this), "minorGridlines");
807
+ }
808
+ set has_minor_gridlines(value) {
809
+ this.present("minorGridlines", value);
810
+ }
811
+ get major_gridlines() {
812
+ return new MajorGridlines(chartNodeBinding(this));
813
+ }
814
+ get major_tick_mark() {
815
+ return XL_TICK_MARK.from_xml(this.scalar("majorTickMark") ?? "none");
816
+ }
817
+ set major_tick_mark(value) {
818
+ this.setScalar("majorTickMark", XL_TICK_MARK.to_xml(value));
819
+ }
820
+ get minor_tick_mark() {
821
+ return XL_TICK_MARK.from_xml(this.scalar("minorTickMark") ?? "none");
822
+ }
823
+ set minor_tick_mark(value) {
824
+ this.setScalar("minorTickMark", XL_TICK_MARK.to_xml(value));
825
+ }
826
+ get maximum_scale() {
827
+ const scaling = child(chartNode(this), "scaling");
828
+ return scaling ? new Scaling(chartDescendant(this, "scaling")).max : null;
829
+ }
830
+ set maximum_scale(value) {
831
+ if (value !== null) numberValue(value);
832
+ new Scaling(chartDescendant(this, "scaling", true)).max = value;
833
+ }
834
+ get minimum_scale() {
835
+ const scaling = child(chartNode(this), "scaling");
836
+ return scaling ? new Scaling(chartDescendant(this, "scaling")).min : null;
837
+ }
838
+ set minimum_scale(value) {
839
+ if (value !== null) numberValue(value);
840
+ new Scaling(chartDescendant(this, "scaling", true)).min = value;
841
+ }
842
+ get reverse_order() {
843
+ return !!child(chartNode(this), "scaling") && new Scaling(chartDescendant(this, "scaling")).reversed;
844
+ }
845
+ set reverse_order(value) {
846
+ booleanValue(value);
847
+ new Scaling(chartDescendant(this, "scaling", true)).reversed = value;
848
+ }
849
+ get tick_label_position() {
850
+ return XL_TICK_LABEL_POSITION.from_xml(this.scalar("tickLblPos") ?? "nextTo");
851
+ }
852
+ set tick_label_position(value) {
853
+ this.setScalar("tickLblPos", XL_TICK_LABEL_POSITION.to_xml(value));
854
+ }
855
+ get tick_labels() {
856
+ return new TickLabels(chartNodeBinding(this));
857
+ }
858
+ get visible() {
859
+ return !readBoolean(child(chartNode(this), "delete"), false);
860
+ }
861
+ set visible(value) {
862
+ booleanValue(value);
863
+ this.setScalar("delete", !value);
864
+ }
865
+ };
866
+ var CategoryAxis = class extends BaseAxis {
867
+ get category_type() {
868
+ return XL_CATEGORY_TYPE.CATEGORY_SCALE;
869
+ }
870
+ };
871
+ var DateAxis = class extends BaseAxis {
872
+ get category_type() {
873
+ return XL_CATEGORY_TYPE.TIME_SCALE;
874
+ }
875
+ };
876
+ var ValueAxis = class extends BaseAxis {
877
+ #crossing() {
878
+ const id = this.scalar("crossAx"), binding = chartNodeBinding(this), namespace = chartNode(this).name.namespace;
879
+ const locate = (xml) => {
880
+ const visit = (node) => {
881
+ if (node.name.namespace === namespace && ["catAx", "dateAx", "valAx"].includes(node.name.localName) && attr(child(node, "axId") ?? node, "val") === id)
882
+ return node;
883
+ for (const c of node.children) {
884
+ const found2 = visit(c);
885
+ if (found2) return found2;
886
+ }
887
+ return void 0;
888
+ };
889
+ const found = visit(xml.root);
890
+ if (!found) throw new PropertyAccessError("Crossed axis is unavailable.");
891
+ return found;
892
+ };
893
+ return new Crossing({ read: binding.read, write: binding.write, track: binding.track, locate });
894
+ }
895
+ get crosses() {
896
+ return this.#crossing().crosses;
897
+ }
898
+ set crosses(value) {
899
+ this.#crossing().crosses = value;
900
+ }
901
+ get crosses_at() {
902
+ return this.#crossing().crosses_at;
903
+ }
904
+ set crosses_at(value) {
905
+ this.#crossing().crosses_at = value;
906
+ }
907
+ get major_unit() {
908
+ const v = this.scalar("majorUnit");
909
+ return v === null ? null : Number(v);
910
+ }
911
+ set major_unit(value) {
912
+ if (value !== null) numberValue(value, Number.MIN_VALUE);
913
+ this.setScalar("majorUnit", value);
914
+ }
915
+ get minor_unit() {
916
+ const v = this.scalar("minorUnit");
917
+ return v === null ? null : Number(v);
918
+ }
919
+ set minor_unit(value) {
920
+ if (value !== null) numberValue(value, Number.MIN_VALUE);
921
+ this.setScalar("minorUnit", value);
922
+ }
923
+ };
924
+ var Crossing = class extends ChartNode {
925
+ get crosses() {
926
+ const value = this.scalar("crosses");
927
+ return value === null ? XL_AXIS_CROSSES.CUSTOM : XL_AXIS_CROSSES.from_xml(value);
928
+ }
929
+ set crosses(value) {
930
+ if (value === XL_AXIS_CROSSES.CUSTOM) {
931
+ if (this.crosses_at === null) this.crosses_at = 0;
932
+ return;
933
+ }
934
+ const token2 = XL_AXIS_CROSSES.to_xml(value);
935
+ chartPut(this, "crossesAt", null);
936
+ this.setScalar("crosses", token2);
937
+ }
938
+ get crosses_at() {
939
+ const value = this.scalar("crossesAt");
940
+ return value === null ? null : Number(value);
941
+ }
942
+ set crosses_at(value) {
943
+ if (value !== null) numberValue(value);
944
+ chartPut(this, "crosses", null);
945
+ this.setScalar("crossesAt", value);
946
+ }
947
+ };
948
+
949
+ // packages/safe-bash-presentation-engine/src/chart-model-series.ts
950
+ var DataLabels = class extends TickLabels {
951
+ get position() {
952
+ const value = this.scalar("dLblPos");
953
+ return value === null ? null : XL_DATA_LABEL_POSITION.from_xml(value);
954
+ }
955
+ set position(value) {
956
+ this.setScalar("dLblPos", value === null ? null : XL_DATA_LABEL_POSITION.to_xml(value));
957
+ }
958
+ get show_category_name() {
959
+ return readBoolean(child(chartNode(this), "showCatName"), false);
960
+ }
961
+ set show_category_name(value) {
962
+ booleanValue(value);
963
+ this.setScalar("showCatName", value);
964
+ }
965
+ get show_legend_key() {
966
+ return readBoolean(child(chartNode(this), "showLegendKey"), false);
967
+ }
968
+ set show_legend_key(value) {
969
+ booleanValue(value);
970
+ this.setScalar("showLegendKey", value);
971
+ }
972
+ get show_percentage() {
973
+ return readBoolean(child(chartNode(this), "showPercent"), false);
974
+ }
975
+ set show_percentage(value) {
976
+ booleanValue(value);
977
+ this.setScalar("showPercent", value);
978
+ }
979
+ get show_series_name() {
980
+ return readBoolean(child(chartNode(this), "showSerName"), false);
981
+ }
982
+ set show_series_name(value) {
983
+ booleanValue(value);
984
+ this.setScalar("showSerName", value);
985
+ }
986
+ get show_value() {
987
+ return readBoolean(child(chartNode(this), "showVal"), false);
988
+ }
989
+ set show_value(value) {
990
+ booleanValue(value);
991
+ this.setScalar("showVal", value);
992
+ }
993
+ };
994
+ var DataLabel = class extends ChartTitle {
995
+ get font() {
996
+ return this.textFrame().paragraphs[0].font;
997
+ }
998
+ get position() {
999
+ const value = this.scalar("dLblPos");
1000
+ return value === null ? null : XL_DATA_LABEL_POSITION.from_xml(value);
1001
+ }
1002
+ set position(value) {
1003
+ this.setScalar("dLblPos", value === null ? null : XL_DATA_LABEL_POSITION.to_xml(value));
1004
+ }
1005
+ };
1006
+ var Marker = class extends ChartNode {
1007
+ get size() {
1008
+ const marker = child(chartNode(this), "marker"), size = marker && child(marker, "size");
1009
+ return size ? Number(attr(size, "val")) : null;
1010
+ }
1011
+ set size(value) {
1012
+ if (value !== null) numberValue(value, 2, 72, true);
1013
+ new MarkerProperties(chartDescendant(this, "marker", true)).size = value;
1014
+ }
1015
+ get style() {
1016
+ const marker = child(chartNode(this), "marker"), symbol = marker && child(marker, "symbol");
1017
+ return symbol ? XL_MARKER_STYLE.from_xml(attr(symbol, "val") ?? "auto") : null;
1018
+ }
1019
+ set style(value) {
1020
+ const token2 = value === null ? null : XL_MARKER_STYLE.to_xml(value);
1021
+ new MarkerProperties(chartDescendant(this, "marker", true)).style = token2;
1022
+ }
1023
+ get format() {
1024
+ return new ChartFormat(chartDescendant(this, "marker", true));
1025
+ }
1026
+ };
1027
+ var MarkerProperties = class extends ChartNode {
1028
+ set size(value) {
1029
+ this.setScalar("size", value);
1030
+ }
1031
+ set style(value) {
1032
+ this.setScalar("symbol", value);
1033
+ }
1034
+ };
1035
+ function indexed(parent, name, index, create) {
1036
+ const locate = (xml) => parent.locate(xml).children.find(
1037
+ (node) => node.name.namespace === parent.locate(xml).name.namespace && node.name.localName === name && attr(child(node, "idx") ?? node, "val") === String(index)
1038
+ );
1039
+ if (create) parent.prepare?.();
1040
+ if (create && !locate(parent.read())) {
1041
+ const xml = parent.read(), node = parent.locate(xml), ns2 = node.name.namespace;
1042
+ const next = node.children.findIndex(
1043
+ (n) => n.name.namespace === ns2 && (n.name.localName === name && Number(attr(child(n, "idx") ?? n, "val")) > index || [
1044
+ "dLbls",
1045
+ "trendline",
1046
+ "errBars",
1047
+ "cat",
1048
+ "val",
1049
+ "xVal",
1050
+ "yVal",
1051
+ "bubbleSize",
1052
+ "smooth",
1053
+ "bubble3D",
1054
+ "extLst"
1055
+ ].includes(n.name.localName))
1056
+ );
1057
+ parent.write(
1058
+ xml.spliceChildren(node, next < 0 ? node.children.length : next, 0, [
1059
+ `<c:${name} xmlns:c="${ns2}"><c:idx val="${index}"/></c:${name}>`
1060
+ ])
1061
+ );
1062
+ }
1063
+ return {
1064
+ read: parent.read,
1065
+ write: parent.write,
1066
+ track: parent.track,
1067
+ locate: (xml) => {
1068
+ const found = locate(xml);
1069
+ if (!found) throw new InvalidHandleError();
1070
+ return found;
1071
+ }
1072
+ };
1073
+ }
1074
+ function deferredIndexed(parent, name, index) {
1075
+ const virtual = {
1076
+ name: { namespace: parent.locate(parent.read()).name.namespace, localName: name },
1077
+ attributes: [],
1078
+ children: []
1079
+ };
1080
+ let materialized = false;
1081
+ const locate = (xml) => {
1082
+ const root = parent.locate(xml), node = root.children.find(
1083
+ (n) => n.name.namespace === root.name.namespace && n.name.localName === name && attr(child(n, "idx") ?? n, "val") === String(index)
1084
+ );
1085
+ if (node) {
1086
+ materialized = true;
1087
+ return node;
1088
+ }
1089
+ if (materialized) throw new InvalidHandleError();
1090
+ return virtual;
1091
+ };
1092
+ return {
1093
+ read: parent.read,
1094
+ write: parent.write,
1095
+ track: parent.track,
1096
+ locate,
1097
+ prepare: () => {
1098
+ indexed(parent, name, index, true);
1099
+ }
1100
+ };
1101
+ }
1102
+ var Point = class _Point extends ChartNode {
1103
+ #index;
1104
+ constructor(binding, index) {
1105
+ super(binding);
1106
+ this.#index = index;
1107
+ }
1108
+ get format() {
1109
+ return new ChartFormat(indexed(chartNodeBinding(this), "dPt", this.#index, true));
1110
+ }
1111
+ get marker() {
1112
+ return new Marker(deferredIndexed(chartNodeBinding(this), "dPt", this.#index));
1113
+ }
1114
+ get data_label() {
1115
+ return new DataLabel(
1116
+ deferredIndexed(chartOptionalDescendant(this, "dLbls"), "dLbl", this.#index)
1117
+ );
1118
+ }
1119
+ equals(other) {
1120
+ return other instanceof _Point && this.#index === other.#index && super.equals(other);
1121
+ }
1122
+ };
1123
+ function cacheValues(xml, series2, channel) {
1124
+ const root = child(series2, channel);
1125
+ if (!root) return [];
1126
+ const ref = child(root, "numRef"), cache = ref ? child(ref, "numCache") : child(root, "numLit");
1127
+ if (!cache) return [];
1128
+ const count = child(cache, "ptCount");
1129
+ const points = cache.children.filter(
1130
+ (n) => n.name.namespace === cache.name.namespace && n.name.localName === "pt"
1131
+ );
1132
+ const length = count ? Number(attr(count, "val")) : Math.max(0, ...points.map((n) => Number(attr(n, "idx")) + 1));
1133
+ if (!Number.isInteger(length) || length < 0 || length > 25e4)
1134
+ throw new ValueError("Invalid chart cache size.");
1135
+ const values = Array.from({ length }, () => null);
1136
+ const indexes = /* @__PURE__ */ new Set();
1137
+ for (const point of points) {
1138
+ const idx = Number(attr(point, "idx")), v = child(point, "v"), text = v && xml.text(v);
1139
+ if (!Number.isInteger(idx) || idx < 0 || idx >= length || indexes.has(idx))
1140
+ throw new ValueError("Invalid chart point index.");
1141
+ indexes.add(idx);
1142
+ if (text !== null && text !== void 0 && text !== "") {
1143
+ const value = Number(text);
1144
+ if (!Number.isFinite(value)) throw new ValueError("Invalid chart point value.");
1145
+ values[idx] = value;
1146
+ }
1147
+ }
1148
+ return Object.freeze(values);
1149
+ }
1150
+ var BaseSeries = class extends ChartNode {
1151
+ get index() {
1152
+ return Number(this.scalar("idx") ?? 0);
1153
+ }
1154
+ get name() {
1155
+ const tx = child(chartNode(this), "tx");
1156
+ if (!tx) return "";
1157
+ const xml = chartNodeBinding(this).read();
1158
+ const direct = child(tx, "v");
1159
+ if (direct) return xml.text(direct) ?? "";
1160
+ const ref = child(tx, "strRef"), cache = ref && child(ref, "strCache"), pt = cache && child(cache, "pt"), v = pt && child(pt, "v");
1161
+ return v ? xml.text(v) ?? "" : "";
1162
+ }
1163
+ };
1164
+ var Series = class extends BaseSeries {
1165
+ get values() {
1166
+ const binding = chartNodeBinding(this), xml = binding.read(), node = binding.locate(xml);
1167
+ return cacheValues(xml, node, child(node, "yVal") ? "yVal" : "val");
1168
+ }
1169
+ get points() {
1170
+ const binding = chartNodeBinding(this);
1171
+ return new ChartSequence(() => this.values.map((_, index) => new Point(binding, index)), false);
1172
+ }
1173
+ };
1174
+ var CategorySeries = class extends Series {
1175
+ get data_labels() {
1176
+ return new DataLabels(chartDescendant(this, "dLbls", true));
1177
+ }
1178
+ };
1179
+ var AreaSeries = class extends CategorySeries {
1180
+ };
1181
+ var PieSeries = class extends CategorySeries {
1182
+ };
1183
+ var BarSeries = class extends CategorySeries {
1184
+ get invert_if_negative() {
1185
+ return readBoolean(child(chartNode(this), "invertIfNegative"), true);
1186
+ }
1187
+ set invert_if_negative(value) {
1188
+ booleanValue(value);
1189
+ this.setScalar("invertIfNegative", value);
1190
+ }
1191
+ };
1192
+ var RadarSeries = class extends CategorySeries {
1193
+ get marker() {
1194
+ return new Marker(chartNodeBinding(this));
1195
+ }
1196
+ };
1197
+ var LineSeries = class extends RadarSeries {
1198
+ get smooth() {
1199
+ return readBoolean(child(chartNode(this), "smooth"), false);
1200
+ }
1201
+ set smooth(value) {
1202
+ booleanValue(value);
1203
+ this.setScalar("smooth", value);
1204
+ }
1205
+ };
1206
+ var XySeries = class extends Series {
1207
+ get marker() {
1208
+ return new Marker(chartNodeBinding(this));
1209
+ }
1210
+ *iter_values() {
1211
+ yield* this.values;
1212
+ }
1213
+ };
1214
+ var BubbleSeries = class extends XySeries {
1215
+ };
1216
+ function seriesFor(binding, plotName) {
1217
+ const classes = {
1218
+ areaChart: AreaSeries,
1219
+ area3DChart: AreaSeries,
1220
+ barChart: BarSeries,
1221
+ bar3DChart: BarSeries,
1222
+ bubbleChart: BubbleSeries,
1223
+ doughnutChart: PieSeries,
1224
+ lineChart: LineSeries,
1225
+ line3DChart: LineSeries,
1226
+ pieChart: PieSeries,
1227
+ pie3DChart: PieSeries,
1228
+ ofPieChart: PieSeries,
1229
+ radarChart: RadarSeries,
1230
+ scatterChart: XySeries,
1231
+ stockChart: LineSeries,
1232
+ surfaceChart: Series,
1233
+ surface3DChart: Series
1234
+ };
1235
+ return new (classes[plotName] ?? Series)(binding);
1236
+ }
1237
+ var SeriesCollection = class extends ChartSequence {
1238
+ };
1239
+ var Category = class _Category {
1240
+ idx;
1241
+ label;
1242
+ constructor(idx, label2) {
1243
+ this.idx = idx;
1244
+ this.label = label2;
1245
+ Object.freeze(this);
1246
+ }
1247
+ toString() {
1248
+ return this.label;
1249
+ }
1250
+ equals(other) {
1251
+ return this.label === (other instanceof _Category ? other.label : other);
1252
+ }
1253
+ };
1254
+ var CategoryLevel = class extends ChartSequence {
1255
+ constructor(read) {
1256
+ super(read, true, (a, b) => a.equals(b));
1257
+ }
1258
+ };
1259
+ var Categories = class extends ChartSequence {
1260
+ #levels;
1261
+ constructor(levels) {
1262
+ super(
1263
+ () => [...levels()[0] ?? []],
1264
+ true,
1265
+ (a, b) => a.equals(b)
1266
+ );
1267
+ this.#levels = levels;
1268
+ }
1269
+ get depth() {
1270
+ return this.#levels().length;
1271
+ }
1272
+ get levels() {
1273
+ return this.#levels();
1274
+ }
1275
+ get flattened_labels() {
1276
+ const levels = this.#levels();
1277
+ if (!levels.length) return [];
1278
+ return Object.freeze(
1279
+ [...levels[0]].map(
1280
+ (leaf) => Object.freeze(
1281
+ [...levels].reverse().map((level) => [...level].filter((item) => item.idx <= leaf.idx).at(-1)?.label ?? "")
1282
+ )
1283
+ )
1284
+ );
1285
+ }
1286
+ };
1287
+ var BasePlot = class extends ChartNode {
1288
+ #chart;
1289
+ constructor(binding, chart) {
1290
+ super(binding);
1291
+ this.#chart = chart;
1292
+ }
1293
+ get chart() {
1294
+ void chartNode(this);
1295
+ return this.#chart;
1296
+ }
1297
+ get series() {
1298
+ const binding = chartNodeBinding(this);
1299
+ return new SeriesCollection(() => {
1300
+ const xml = binding.read(), node = binding.locate(xml);
1301
+ return node.children.filter((n) => n.name.namespace === node.name.namespace && n.name.localName === "ser").map(
1302
+ (original, index) => seriesFor(
1303
+ {
1304
+ read: binding.read,
1305
+ write: binding.write,
1306
+ track: binding.track,
1307
+ locate: (doc) => {
1308
+ const parent = binding.locate(doc), found = parent.children.filter(
1309
+ (n) => n.name.namespace === parent.name.namespace && n.name.localName === "ser"
1310
+ )[index];
1311
+ if (!found) throw new InvalidHandleError();
1312
+ const signature = (part, ser) => ["idx", "order", "cat", "val", "xVal", "yVal", "bubbleSize"].map((name) => {
1313
+ const value = child(ser, name);
1314
+ return value ? part.markup(value) : null;
1315
+ });
1316
+ if (JSON.stringify(signature(doc, found)) !== JSON.stringify(signature(xml, original)))
1317
+ throw new InvalidHandleError();
1318
+ return found;
1319
+ }
1320
+ },
1321
+ node.name.localName
1322
+ )
1323
+ );
1324
+ });
1325
+ }
1326
+ get categories() {
1327
+ const binding = chartNodeBinding(this);
1328
+ return new Categories(() => {
1329
+ const xml = binding.read(), plot = binding.locate(xml), series2 = plot.children.find(
1330
+ (n) => n.name.namespace === plot.name.namespace && n.name.localName === "ser"
1331
+ ), cat = series2 && child(series2, "cat");
1332
+ if (!cat) return [];
1333
+ const multi = child(cat, "multiLvlStrRef"), multiCache = multi && child(multi, "multiLvlStrCache");
1334
+ const ref = child(cat, "strRef") ?? child(cat, "numRef"), cache = ref ? child(ref, "strCache") ?? child(ref, "numCache") : child(cat, "strLit") ?? child(cat, "numLit");
1335
+ const levels = multiCache ? multiCache.children.filter(
1336
+ (n) => n.name.localName === "lvl" && n.name.namespace === cat.name.namespace
1337
+ ) : cache ? [cache] : [];
1338
+ return Object.freeze(
1339
+ levels.map(
1340
+ (level) => new CategoryLevel(() => {
1341
+ const indexes = /* @__PURE__ */ new Set();
1342
+ return level.children.filter((n) => n.name.localName === "pt" && n.name.namespace === cat.name.namespace).map((pt) => {
1343
+ const idx = Number(attr(pt, "idx")), value = child(pt, "v");
1344
+ if (!Number.isInteger(idx) || idx < 0 || !value || indexes.has(idx))
1345
+ throw new ValueError("Invalid category cache index.");
1346
+ indexes.add(idx);
1347
+ return new Category(idx, xml.text(value) ?? "");
1348
+ });
1349
+ })
1350
+ )
1351
+ );
1352
+ });
1353
+ }
1354
+ get has_data_labels() {
1355
+ return !!child(chartNode(this), "dLbls");
1356
+ }
1357
+ set has_data_labels(value) {
1358
+ this.present("dLbls", value);
1359
+ }
1360
+ get data_labels() {
1361
+ if (!this.has_data_labels) throw new PropertyAccessError("Plot has no data labels.");
1362
+ return new DataLabels(chartDescendant(this, "dLbls"));
1363
+ }
1364
+ get vary_by_categories() {
1365
+ return readBoolean(child(chartNode(this), "varyColors"), true);
1366
+ }
1367
+ set vary_by_categories(value) {
1368
+ booleanValue(value);
1369
+ this.setScalar("varyColors", value);
1370
+ }
1371
+ };
1372
+ var AreaPlot = class extends BasePlot {
1373
+ };
1374
+ var Area3DPlot = class extends BasePlot {
1375
+ };
1376
+ var LinePlot = class extends BasePlot {
1377
+ };
1378
+ var PiePlot = class extends BasePlot {
1379
+ };
1380
+ var DoughnutPlot = class extends BasePlot {
1381
+ };
1382
+ var RadarPlot = class extends BasePlot {
1383
+ };
1384
+ var XyPlot = class extends BasePlot {
1385
+ };
1386
+ var BarPlot = class extends BasePlot {
1387
+ get gap_width() {
1388
+ return Number(this.scalar("gapWidth") ?? 150);
1389
+ }
1390
+ set gap_width(value) {
1391
+ numberValue(value, 0, 500, true);
1392
+ this.setScalar("gapWidth", value);
1393
+ }
1394
+ get overlap() {
1395
+ return Number(this.scalar("overlap") ?? 0);
1396
+ }
1397
+ set overlap(value) {
1398
+ numberValue(value, -100, 100, true);
1399
+ this.setScalar("overlap", value === 0 ? null : value);
1400
+ }
1401
+ };
1402
+ var BubblePlot = class extends BasePlot {
1403
+ get bubble_scale() {
1404
+ return Number(this.scalar("bubbleScale") ?? 100);
1405
+ }
1406
+ set bubble_scale(value) {
1407
+ if (value !== null) numberValue(value, 0, 300, true);
1408
+ this.setScalar("bubbleScale", value);
1409
+ }
1410
+ };
1411
+ var plotNames = [
1412
+ "areaChart",
1413
+ "area3DChart",
1414
+ "barChart",
1415
+ "bar3DChart",
1416
+ "bubbleChart",
1417
+ "doughnutChart",
1418
+ "lineChart",
1419
+ "line3DChart",
1420
+ "ofPieChart",
1421
+ "pieChart",
1422
+ "pie3DChart",
1423
+ "radarChart",
1424
+ "scatterChart",
1425
+ "stockChart",
1426
+ "surfaceChart",
1427
+ "surface3DChart"
1428
+ ];
1429
+ var Plots = class extends ChartSequence {
1430
+ slice(start, end, step = 1) {
1431
+ return sequenceSlice([...this], start, end, step);
1432
+ }
1433
+ };
1434
+ function plotFor(binding, chart) {
1435
+ const classes = {
1436
+ areaChart: AreaPlot,
1437
+ area3DChart: Area3DPlot,
1438
+ barChart: BarPlot,
1439
+ bar3DChart: BarPlot,
1440
+ bubbleChart: BubblePlot,
1441
+ doughnutChart: DoughnutPlot,
1442
+ lineChart: LinePlot,
1443
+ line3DChart: LinePlot,
1444
+ pieChart: PiePlot,
1445
+ pie3DChart: PiePlot,
1446
+ ofPieChart: PiePlot,
1447
+ radarChart: RadarPlot,
1448
+ scatterChart: XyPlot
1449
+ };
1450
+ return new (classes[binding.locate(binding.read()).name.localName] ?? BasePlot)(binding, chart);
1451
+ }
1452
+
1453
+ // packages/safe-bash-presentation-engine/src/chart-data-model.ts
1454
+ var chart_data_model_exports = {};
1455
+ __export(chart_data_model_exports, {
1456
+ BubbleChartData: () => BubbleChartData,
1457
+ BubbleDataPoint: () => BubbleDataPoint,
1458
+ BubbleSeriesData: () => BubbleSeriesData,
1459
+ Categories: () => Categories2,
1460
+ Category: () => Category2,
1461
+ CategoryChartData: () => CategoryChartData,
1462
+ CategoryDataPoint: () => CategoryDataPoint,
1463
+ CategorySeriesData: () => CategorySeriesData,
1464
+ ChartData: () => CategoryChartData,
1465
+ ChartDataSequence: () => ChartDataSequence,
1466
+ XyChartData: () => XyChartData,
1467
+ XyDataPoint: () => XyDataPoint,
1468
+ XySeriesData: () => XySeriesData,
1469
+ toChartData: () => toChartData
1470
+ });
1471
+
1472
+ // packages/safe-bash-presentation-engine/src/chart-workbook.ts
1473
+ var ns = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
1474
+ var relationships = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
1475
+ var encode = (text) => new TextEncoder().encode(text);
1476
+ function unsupported() {
1477
+ throw new OfficeError(
1478
+ "unsupported-edit",
1479
+ "Chart data requires one simple owned worksheet without formulas or external dependencies.",
1480
+ "mutate"
1481
+ );
1482
+ }
1483
+ function attribute(node, name, namespace = "") {
1484
+ return node.attributes.find((a) => a.name.localName === name && a.name.namespace === namespace)?.value;
1485
+ }
1486
+ function escaped(text) {
1487
+ return text.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;").split('"').join("&quot;").split("\r").join("&#13;").split("\n").join("&#10;").split(" ").join("&#9;");
1488
+ }
1489
+ function spreadsheetString(text, attribute2 = false) {
1490
+ let result = "";
1491
+ for (let index = 0; index < text.length; index++) {
1492
+ const character = text[index];
1493
+ if (character === "_" && text[index + 1] === "x" && text[index + 6] === "_" && [...text.slice(index + 2, index + 6)].every(
1494
+ (digit) => "0123456789abcdefABCDEF".includes(digit)
1495
+ )) {
1496
+ result += "_x005F_";
1497
+ } else if (character === "\r" || attribute2 && (character === "\n" || character === " ")) {
1498
+ result += `_x${character.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}_`;
1499
+ } else result += character;
1500
+ }
1501
+ return result;
1502
+ }
1503
+ function workbookColumn(index) {
1504
+ if (!Number.isInteger(index) || index < 0 || index >= 16384)
1505
+ throw new OfficeError(
1506
+ "invalid-value",
1507
+ "Worksheet column is outside the supported grid.",
1508
+ "usage"
1509
+ );
1510
+ let result = "";
1511
+ for (let value = index + 1; value > 0; value = Math.floor((value - 1) / 26))
1512
+ result = String.fromCharCode(65 + (value - 1) % 26) + result;
1513
+ return result;
1514
+ }
1515
+ function cellReference(value) {
1516
+ let position = value[0] === "$" ? 1 : 0;
1517
+ let col = 0;
1518
+ while (position < value.length) {
1519
+ const code = value.charCodeAt(position);
1520
+ if (code < 65 || code > 90) break;
1521
+ col = col * 26 + code - 64;
1522
+ if (col > 16384) unsupported();
1523
+ position++;
1524
+ }
1525
+ if (value[position] === "$") position++;
1526
+ const digits = value.slice(position);
1527
+ if (!col || !digits || [...digits].some((char) => char < "0" || char > "9")) unsupported();
1528
+ const row = Number(digits);
1529
+ if (!Number.isSafeInteger(row) || row < 1 || row > 1048576 || String(row) !== digits)
1530
+ unsupported();
1531
+ return { column: col, row };
1532
+ }
1533
+ function chartWorkbookRange(formula, sheetName) {
1534
+ const quoted = `'${sheetName.split("'").join("''")}'!`;
1535
+ const prefix = formula.startsWith(quoted) ? quoted : `${sheetName}!`;
1536
+ if (!formula.startsWith(prefix)) unsupported();
1537
+ const parts = formula.slice(prefix.length).split(":");
1538
+ if (parts.length > 2) unsupported();
1539
+ const start = cellReference(parts[0]);
1540
+ const end = parts.length === 2 ? cellReference(parts[1]) : start;
1541
+ if (end.row < start.row || end.column < start.column) unsupported();
1542
+ return { start, end };
1543
+ }
1544
+ function validateWorkbookOwnership(info, ranges) {
1545
+ for (const cell of info.cells) {
1546
+ if (!ranges.some(
1547
+ ({ start, end }) => cell.row >= start.row && cell.row <= end.row && cell.column >= start.column && cell.column <= end.column
1548
+ ))
1549
+ unsupported();
1550
+ }
1551
+ }
1552
+ function inspectWorkbook(pkg, context) {
1553
+ const graph = readRelationshipGraph(pkg, context.relationshipLimits);
1554
+ if (graph.dangling.length) unsupported();
1555
+ for (const owner of ["/", ...graph.parts]) {
1556
+ if (graph.outgoing(owner).some((edge) => edge.external)) unsupported();
1557
+ }
1558
+ const roots = graph.outgoing("/").filter((edge) => edge.type === `${relationships}/officeDocument`);
1559
+ if (roots.length !== 1 || !roots[0].targetPart) unsupported();
1560
+ const workbookPart = roots[0].targetPart;
1561
+ const workbook = parseXmlPart(pkg.get(workbookPart), context.xmlLimits);
1562
+ if (workbook.root.name.namespace !== ns || workbook.root.name.localName !== "workbook")
1563
+ unsupported();
1564
+ const allowed = ["fileVersion", "workbookPr", "bookViews", "sheets", "calcPr"];
1565
+ if (workbook.root.children.some(
1566
+ (node) => node.name.namespace !== ns || !allowed.includes(node.name.localName)
1567
+ ))
1568
+ unsupported();
1569
+ const sheets = workbook.root.children.filter((node) => node.name.localName === "sheets");
1570
+ if (sheets.length !== 1 || sheets[0].children.length !== 1) unsupported();
1571
+ const sheet = sheets[0].children[0];
1572
+ const sheetName = attribute(sheet, "name");
1573
+ const id = attribute(sheet, "id", relationships);
1574
+ const links = graph.outgoing(workbookPart);
1575
+ if (links.some(
1576
+ (edge) => ![
1577
+ `${relationships}/worksheet`,
1578
+ `${relationships}/styles`,
1579
+ `${relationships}/sharedStrings`,
1580
+ `${relationships}/theme`
1581
+ ].includes(edge.type)
1582
+ ))
1583
+ unsupported();
1584
+ const worksheets = links.filter((edge) => edge.type === `${relationships}/worksheet`);
1585
+ if (sheet.name.localName !== "sheet" || !sheetName || worksheets.length !== 1 || worksheets[0].id !== id || !worksheets[0].targetPart)
1586
+ unsupported();
1587
+ const sheetPart = worksheets[0].targetPart;
1588
+ const types = parseContentTypes(pkg.get("/[Content_Types].xml"), {
1589
+ maxBytes: context.xmlLimits.maxBytes,
1590
+ maxEntries: context.archiveLimits.maxMembers
1591
+ });
1592
+ for (const part of graph.parts) {
1593
+ const type = types.get(part);
1594
+ if ([
1595
+ "table",
1596
+ "calcChain",
1597
+ "externalLink",
1598
+ "connections",
1599
+ "queryTable",
1600
+ "pivotTable",
1601
+ "pivotCacheDefinition",
1602
+ "pivotCacheRecords"
1603
+ ].some(
1604
+ (kind2) => type === `application/vnd.openxmlformats-officedocument.spreadsheetml.${kind2}+xml`
1605
+ ) || type === "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" && part !== sheetPart)
1606
+ unsupported();
1607
+ }
1608
+ if (graph.incoming(sheetPart).length !== 1 || graph.outgoing(sheetPart).length) unsupported();
1609
+ if (pkg.names.some(
1610
+ (name) => name.startsWith("/xl/worksheets/") && name.endsWith(".xml") && name !== sheetPart
1611
+ ))
1612
+ unsupported();
1613
+ const worksheet = parseXmlPart(pkg.get(sheetPart), context.xmlLimits);
1614
+ if (worksheet.root.name.namespace !== ns || worksheet.root.name.localName !== "worksheet")
1615
+ unsupported();
1616
+ const sheetChildren = [
1617
+ "sheetPr",
1618
+ "dimension",
1619
+ "sheetViews",
1620
+ "sheetFormatPr",
1621
+ "cols",
1622
+ "sheetData",
1623
+ "pageMargins"
1624
+ ];
1625
+ if (worksheet.root.children.some(
1626
+ (node) => node.name.namespace !== ns || !sheetChildren.includes(node.name.localName)
1627
+ ))
1628
+ unsupported();
1629
+ if (worksheet.root.children.filter((node) => node.name.localName === "sheetData").length !== 1)
1630
+ unsupported();
1631
+ const visit = (node) => {
1632
+ if (node.name.namespace !== ns || ["f", "extLst"].includes(node.name.localName)) unsupported();
1633
+ node.children.forEach(visit);
1634
+ };
1635
+ visit(worksheet.root);
1636
+ const cells = [];
1637
+ const seen = /* @__PURE__ */ new Set();
1638
+ const data = worksheet.root.children.find((node) => node.name.localName === "sheetData");
1639
+ for (const row of data.children) {
1640
+ if (row.name.localName !== "row") unsupported();
1641
+ for (const cell of row.children) {
1642
+ if (cell.name.localName !== "c") unsupported();
1643
+ const ref = attribute(cell, "r");
1644
+ if (!ref || seen.has(ref)) unsupported();
1645
+ seen.add(ref);
1646
+ const coordinate = cellReference(ref);
1647
+ if (String(coordinate.row) !== attribute(row, "r")) unsupported();
1648
+ if (cell.children.some((node) => node.name.localName === "v" || node.name.localName === "is"))
1649
+ cells.push(coordinate);
1650
+ }
1651
+ }
1652
+ const props = workbook.root.children.filter((node) => node.name.localName === "workbookPr");
1653
+ if (props.length > 1) unsupported();
1654
+ const date1904 = props[0] && attribute(props[0], "date1904");
1655
+ if (date1904 !== void 0 && !["0", "1", "false", "true"].includes(date1904)) unsupported();
1656
+ const styles = links.filter((edge) => edge.type === `${relationships}/styles`);
1657
+ if (styles.length > 1) unsupported();
1658
+ const strings = links.filter((edge) => edge.type === `${relationships}/sharedStrings`);
1659
+ if (strings.length > 1) unsupported();
1660
+ const stringsPart = strings[0]?.targetPart;
1661
+ if (stringsPart) {
1662
+ if (graph.incoming(stringsPart).length !== 1 || graph.outgoing(stringsPart).length)
1663
+ unsupported();
1664
+ const table = parseXmlPart(pkg.get(stringsPart), context.xmlLimits);
1665
+ if (table.root.name.namespace !== ns || table.root.name.localName !== "sst" || table.root.children.some((node) => node.name.namespace !== ns || node.name.localName !== "si"))
1666
+ unsupported();
1667
+ }
1668
+ return {
1669
+ workbookPart,
1670
+ ...styles[0]?.targetPart ? { stylesPart: styles[0].targetPart } : {},
1671
+ ...stringsPart ? { stringsPart, stringsId: strings[0].id } : {},
1672
+ sheetName,
1673
+ sheetPart,
1674
+ cells,
1675
+ date1904: date1904 === "1" || date1904 === "true"
1676
+ };
1677
+ }
1678
+ function workbookStyles(formats, context, source) {
1679
+ if (!source && !formats.some((format2) => format2 !== void 0 && format2 !== "General"))
1680
+ return { indices: formats.map(() => 0) };
1681
+ let xml = parseXmlPart(
1682
+ source ?? encode(
1683
+ `<styleSheet xmlns="${ns}"><numFmts count="0"/><fonts count="1"><font><sz val="11"/><name val="Calibri"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border/></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/></cellXfs></styleSheet>`
1684
+ ),
1685
+ context.xmlLimits
1686
+ );
1687
+ if (xml.root.name.namespace !== ns || xml.root.name.localName !== "styleSheet") unsupported();
1688
+ const child2 = (name) => {
1689
+ const matches = xml.root.children.filter(
1690
+ (node) => node.name.namespace === ns && node.name.localName === name
1691
+ );
1692
+ if (matches.length > 1) unsupported();
1693
+ return matches[0];
1694
+ };
1695
+ if (!child2("numFmts"))
1696
+ xml = xml.spliceChildren(xml.root, 0, 0, [`<numFmts xmlns="${ns}" count="0"/>`]);
1697
+ if (!child2("cellXfs")?.children.length) unsupported();
1698
+ const indices = formats.map((format2) => {
1699
+ let numFmts = child2("numFmts");
1700
+ const code = format2 === void 0 ? void 0 : spreadsheetString(format2, true);
1701
+ const id = numFmts.children.find((node) => attribute(node, "formatCode") === code);
1702
+ let number = format2 === void 0 || format2 === "General" ? "0" : id && attribute(id, "numFmtId");
1703
+ if (!number) {
1704
+ const used = numFmts.children.map((node) => Number(attribute(node, "numFmtId")));
1705
+ if (used.some((value) => !Number.isSafeInteger(value) || value < 0)) unsupported();
1706
+ number = String(Math.max(163, ...used) + 1);
1707
+ xml = xml.spliceChildren(numFmts, numFmts.children.length, 0, [
1708
+ `<numFmt xmlns="${ns}" numFmtId="${number}" formatCode="${escaped(code)}"/>`
1709
+ ]);
1710
+ numFmts = child2("numFmts");
1711
+ xml = xml.merge(numFmts, {
1712
+ attributes: [{ namespace: "", localName: "count", value: String(numFmts.children.length) }]
1713
+ });
1714
+ }
1715
+ let xfs = child2("cellXfs");
1716
+ const existing = xfs.children.findIndex(
1717
+ (node) => attribute(node, "numFmtId") === number && !["0", "false"].includes(attribute(node, "applyNumberFormat") ?? "") && node.attributes.every(
1718
+ (item) => item.name.namespace === "http://www.w3.org/2000/xmlns/" || item.name.namespace === "" && ["numFmtId", "fontId", "fillId", "borderId", "xfId", "applyNumberFormat"].includes(
1719
+ item.name.localName
1720
+ )
1721
+ ) && ["fontId", "fillId", "borderId", "xfId"].every((name) => attribute(node, name) === "0") && node.children.length === 0
1722
+ );
1723
+ if (existing >= 0) return existing;
1724
+ const index = xfs.children.length;
1725
+ xml = xml.spliceChildren(xfs, index, 0, [
1726
+ `<xf xmlns="${ns}" numFmtId="${number}" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>`
1727
+ ]);
1728
+ xfs = child2("cellXfs");
1729
+ xml = xml.merge(xfs, {
1730
+ attributes: [{ namespace: "", localName: "count", value: String(xfs.children.length) }]
1731
+ });
1732
+ return index;
1733
+ });
1734
+ return { indices, bytes: xml.bytes() };
1735
+ }
1736
+ async function createChartWorkbook(data, scatter, context, options = {}) {
1737
+ const source = options.source ? await readPackage(options.source, context) : void 0;
1738
+ return writePackageArchive(
1739
+ prepareChartWorkbookMembers(data, scatter, context, {
1740
+ ...options.date1904 === void 0 ? {} : { date1904: options.date1904 },
1741
+ ...source ? { source } : {}
1742
+ }),
1743
+ context,
1744
+ { compression: "store" }
1745
+ );
1746
+ }
1747
+ function prepareChartWorkbookMembers(data, scatter, context, options = {}) {
1748
+ if (context.signal?.aborted)
1749
+ throw new OfficeError("cancelled", "Workbook preparation cancelled.", "serialize");
1750
+ const source = options.source;
1751
+ const info = source ? inspectWorkbook(source, context) : void 0;
1752
+ const columns = scatter ? data.series.flatMap((series2) => [
1753
+ ["", ...series2.xValues],
1754
+ [series2.name, ...series2.values],
1755
+ ...series2.bubbleSizes ? [["Size", ...series2.bubbleSizes]] : []
1756
+ ]) : [
1757
+ ...(data.categoryLevels ?? [data.categories]).map((level) => [null, ...level]),
1758
+ ...data.series.map((series2) => [series2.name, ...series2.values])
1759
+ ];
1760
+ if (columns.length > 16384 || columns.some((values) => values.length > 1048576))
1761
+ throw new OfficeError("resource-limit", "Chart worksheet grid limit exceeded.", "serialize");
1762
+ const formats = scatter ? data.series.flatMap((series2) => [
1763
+ data.numberFormat,
1764
+ series2.numberFormat ?? data.numberFormat,
1765
+ ...series2.bubbleSizes ? [data.numberFormat] : []
1766
+ ]) : [
1767
+ ...(data.categoryLevels ?? [data.categories]).map(() => data.categoryNumberFormat),
1768
+ ...data.series.map((series2) => series2.numberFormat ?? data.numberFormat)
1769
+ ];
1770
+ const pointFormats = scatter ? data.series.flatMap((series2) => [
1771
+ void 0,
1772
+ series2.pointNumberFormats,
1773
+ ...series2.bubbleSizes ? [void 0] : []
1774
+ ]) : [
1775
+ ...(data.categoryLevels ?? [data.categories]).map(() => void 0),
1776
+ ...data.series.map((series2) => series2.pointNumberFormats)
1777
+ ];
1778
+ const extraFormats = pointFormats.flatMap(
1779
+ (column) => column?.filter((value) => value !== null) ?? []
1780
+ );
1781
+ const allFormats = [...formats, ...extraFormats];
1782
+ const styles = workbookStyles(
1783
+ allFormats,
1784
+ context,
1785
+ source && info?.stylesPart ? source.get(info.stylesPart) : void 0
1786
+ );
1787
+ let rows = "";
1788
+ const count = Math.max(...columns.map((values) => values.length));
1789
+ for (let row = 0; row < count; row++) {
1790
+ let cells = "";
1791
+ columns.forEach((values, col) => {
1792
+ const value = values[row];
1793
+ if (value === null || value === void 0) return;
1794
+ const ref = `${workbookColumn(col)}${row + 1}`;
1795
+ const pointFormat = row > 0 ? pointFormats[col]?.[row - 1] : void 0;
1796
+ const styleIndex = pointFormat == null ? styles.indices[col] : styles.indices[allFormats.indexOf(pointFormat)];
1797
+ const style = row > 0 && styleIndex ? ` s="${styleIndex}"` : "";
1798
+ cells += typeof value === "number" ? `<c r="${ref}"${style}><v>${value}</v></c>` : `<c r="${ref}"${style} t="inlineStr"><is><t xml:space="preserve">${escaped(spreadsheetString(value))}</t></is></c>`;
1799
+ });
1800
+ rows += `<row r="${row + 1}">${cells}</row>`;
1801
+ if (rows.length > context.xmlLimits.maxBytes)
1802
+ throw new OfficeError("resource-limit", "Chart worksheet XML limit exceeded.", "serialize");
1803
+ }
1804
+ const sheetData = `<sheetData>${rows}</sheetData>`;
1805
+ let worksheet = encode(`<worksheet xmlns="${ns}">${sheetData}</worksheet>`);
1806
+ parseXmlPart(worksheet, context.xmlLimits);
1807
+ if (source && info) {
1808
+ let xml = parseXmlPart(source.get(info.sheetPart), context.xmlLimits);
1809
+ const position = xml.root.children.findIndex((node) => node.name.localName === "sheetData");
1810
+ xml = xml.spliceChildren(xml.root, position, 1, [
1811
+ `<sheetData xmlns="${ns}">${rows}</sheetData>`
1812
+ ]);
1813
+ const dimension = xml.root.children.findIndex((node) => node.name.localName === "dimension");
1814
+ if (dimension !== -1) xml = xml.spliceChildren(xml.root, dimension, 1, []);
1815
+ worksheet = xml.bytes();
1816
+ const entries = new Map(source.names.map((name) => [name, source.get(name)]));
1817
+ entries.set(info.sheetPart, worksheet);
1818
+ if (info.stringsPart) {
1819
+ entries.delete(info.stringsPart);
1820
+ const split = info.workbookPart.lastIndexOf("/");
1821
+ const relsPart = `${info.workbookPart.slice(0, split)}/_rels/${info.workbookPart.slice(split + 1)}.rels`;
1822
+ const rels = parseXmlPart(source.get(relsPart), context.xmlLimits);
1823
+ entries.set(
1824
+ relsPart,
1825
+ rels.spliceChildren(
1826
+ rels.root,
1827
+ rels.root.children.findIndex((node) => attribute(node, "Id") === info.stringsId),
1828
+ 1,
1829
+ []
1830
+ ).bytes()
1831
+ );
1832
+ let types = parseXmlPart(source.get("/[Content_Types].xml"), context.xmlLimits);
1833
+ const index = types.root.children.findIndex(
1834
+ (node) => attribute(node, "PartName") === info.stringsPart
1835
+ );
1836
+ if (index >= 0) types = types.spliceChildren(types.root, index, 1, []);
1837
+ entries.set("/[Content_Types].xml", types.bytes());
1838
+ }
1839
+ if (styles.bytes) {
1840
+ const stylesPart = info.stylesPart ?? `${info.workbookPart.slice(0, info.workbookPart.lastIndexOf("/") + 1)}chart-styles.xml`;
1841
+ if (!info.stylesPart) {
1842
+ if (entries.has(stylesPart)) unsupported();
1843
+ const split = info.workbookPart.lastIndexOf("/");
1844
+ const relsPart = `${info.workbookPart.slice(0, split)}/_rels/${info.workbookPart.slice(split + 1)}.rels`;
1845
+ let rels = parseXmlPart(entries.get(relsPart), context.xmlLimits);
1846
+ let id = "chartStyles";
1847
+ while (rels.root.children.some((node) => attribute(node, "Id") === id)) id += "_";
1848
+ rels = rels.spliceChildren(rels.root, rels.root.children.length, 0, [
1849
+ `<Relationship xmlns="http://schemas.openxmlformats.org/package/2006/relationships" Id="${id}" Type="${relationships}/styles" Target="chart-styles.xml"/>`
1850
+ ]);
1851
+ entries.set(relsPart, rels.bytes());
1852
+ let types = parseXmlPart(entries.get("/[Content_Types].xml"), context.xmlLimits);
1853
+ types = types.spliceChildren(types.root, types.root.children.length, 0, [
1854
+ `<Override xmlns="http://schemas.openxmlformats.org/package/2006/content-types" PartName="${escaped(stylesPart)}" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>`
1855
+ ]);
1856
+ entries.set("/[Content_Types].xml", types.bytes());
1857
+ }
1858
+ entries.set(stylesPart, styles.bytes);
1859
+ }
1860
+ return admitPreparedWorkbook(
1861
+ [...entries].map(([name, bytes]) => ({ name: name.slice(1), bytes })),
1862
+ context
1863
+ );
1864
+ }
1865
+ return admitPreparedWorkbook(
1866
+ [
1867
+ {
1868
+ name: "[Content_Types].xml",
1869
+ bytes: encode(
1870
+ `<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>${styles.bytes ? '<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>' : ""}</Types>`
1871
+ )
1872
+ },
1873
+ {
1874
+ name: "_rels/.rels",
1875
+ bytes: encode(
1876
+ `<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${relationships}/officeDocument" Target="xl/workbook.xml"/></Relationships>`
1877
+ )
1878
+ },
1879
+ {
1880
+ name: "xl/workbook.xml",
1881
+ bytes: encode(
1882
+ `<workbook xmlns="${ns}" xmlns:r="${relationships}"><workbookPr date1904="${options.date1904 ? "1" : "0"}"/><sheets><sheet name="Sheet1" sheetId="1" r:id="rId1"/></sheets></workbook>`
1883
+ )
1884
+ },
1885
+ {
1886
+ name: "xl/_rels/workbook.xml.rels",
1887
+ bytes: encode(
1888
+ `<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${relationships}/worksheet" Target="worksheets/sheet1.xml"/>${styles.bytes ? `<Relationship Id="rId2" Type="${relationships}/styles" Target="styles.xml"/>` : ""}</Relationships>`
1889
+ )
1890
+ },
1891
+ { name: "xl/worksheets/sheet1.xml", bytes: worksheet },
1892
+ ...styles.bytes ? [{ name: "xl/styles.xml", bytes: styles.bytes }] : []
1893
+ ],
1894
+ context
1895
+ );
1896
+ }
1897
+ function admitPreparedWorkbook(members, context) {
1898
+ let bytes = 22, total = 0;
1899
+ const limits = context.archiveLimits;
1900
+ if (members.length > Math.min(limits.maxMembers, 65534))
1901
+ throw new OfficeError("resource-limit", "Chart workbook member limit exceeded.", "serialize");
1902
+ for (const member of members) {
1903
+ const pathBytes = new TextEncoder().encode(member.name).length;
1904
+ total += member.bytes.length;
1905
+ bytes += 76 + pathBytes * 2 + member.bytes.length;
1906
+ if (member.bytes.length > limits.maxEntryBytes || pathBytes > limits.maxPathBytes || member.name.split("/").length > limits.maxDepth)
1907
+ throw new OfficeError(
1908
+ "resource-limit",
1909
+ "Chart workbook member budget exceeded.",
1910
+ "serialize"
1911
+ );
1912
+ }
1913
+ if (total > limits.maxTotalBytes || bytes > Math.min(limits.maxArchiveBytes, context.limits.maxBytes, 4294967294))
1914
+ throw new OfficeError("resource-limit", "Chart workbook byte budget exceeded.", "serialize");
1915
+ return members;
1916
+ }
1917
+
1918
+ // packages/safe-bash-presentation-engine/src/chart-data-model.ts
1919
+ function format(value) {
1920
+ if (typeof value !== "string") throw new TypeError("Number format must be a string.");
1921
+ return value;
1922
+ }
1923
+ function numeric(value, nullable = true) {
1924
+ if (value === null && nullable) return null;
1925
+ if (typeof value !== "number") throw new TypeError("Expected a numeric chart value.");
1926
+ if (!Number.isFinite(value)) throw new ValueError("Chart values must be finite.");
1927
+ return value;
1928
+ }
1929
+ function label(value) {
1930
+ if (value === null) return null;
1931
+ if (value instanceof Date) {
1932
+ if (!Number.isFinite(value.getTime())) throw new ValueError("Invalid category date.");
1933
+ return new Date(value.getTime());
1934
+ }
1935
+ if (typeof value === "number") return numeric(value, false);
1936
+ if (typeof value !== "string") throw new TypeError("Invalid category label.");
1937
+ return value;
1938
+ }
1939
+ function kind(value) {
1940
+ return value instanceof Date ? "date" : value === null ? "string" : typeof value;
1941
+ }
1942
+ function bounds(value, length) {
1943
+ if (!Number.isSafeInteger(value)) throw new IndexError();
1944
+ return Math.max(0, Math.min(length, value < 0 ? length + value : value));
1945
+ }
1946
+ var sequenceStorage = /* @__PURE__ */ new WeakMap();
1947
+ var sequenceTargets = /* @__PURE__ */ new WeakMap();
1948
+ function sameOwner(left, right) {
1949
+ return (sequenceTargets.get(left) ?? left) === (sequenceTargets.get(right) ?? right);
1950
+ }
1951
+ function sequenceItems(owner) {
1952
+ return sequenceStorage.get(owner);
1953
+ }
1954
+ var ChartDataSequence = class {
1955
+ constructor() {
1956
+ const items = [];
1957
+ sequenceStorage.set(this, items);
1958
+ const proxy = new Proxy(this, {
1959
+ get(target, key, receiver) {
1960
+ if (typeof key === "string" && key !== "" && String(Number(key)) === key) {
1961
+ if (Number(key) < 0) throw new IndexError();
1962
+ return target.at(Number(key));
1963
+ }
1964
+ return Reflect.get(target, key, receiver);
1965
+ },
1966
+ set(target, key, value, receiver) {
1967
+ if (typeof key === "string" && key !== "" && String(Number(key)) === key)
1968
+ throw new ValueError("Sequence entries cannot be replaced.");
1969
+ return Reflect.set(target, key, value, receiver);
1970
+ },
1971
+ defineProperty(target, key, descriptor) {
1972
+ if (typeof key === "string" && key !== "" && String(Number(key)) === key)
1973
+ throw new ValueError("Sequence entries cannot be replaced.");
1974
+ return Reflect.defineProperty(target, key, descriptor);
1975
+ },
1976
+ deleteProperty(target, key) {
1977
+ if (typeof key === "string" && key !== "" && String(Number(key)) === key)
1978
+ throw new ValueError("Sequence entries cannot be removed.");
1979
+ return Reflect.deleteProperty(target, key);
1980
+ }
1981
+ });
1982
+ sequenceStorage.set(proxy, items);
1983
+ sequenceTargets.set(proxy, this);
1984
+ return proxy;
1985
+ }
1986
+ get length() {
1987
+ return sequenceItems(this).length;
1988
+ }
1989
+ at(index) {
1990
+ if (!Number.isSafeInteger(index) || index < -this.length || index >= this.length)
1991
+ throw new IndexError();
1992
+ return sequenceItems(this)[index < 0 ? this.length + index : index];
1993
+ }
1994
+ slice(start, end, step = 1) {
1995
+ return sequenceSlice(sequenceItems(this), start, end, step);
1996
+ }
1997
+ [Symbol.iterator]() {
1998
+ return sequenceItems(this)[Symbol.iterator]();
1999
+ }
2000
+ includes(value) {
2001
+ return sequenceItems(this).includes(value);
2002
+ }
2003
+ count(value) {
2004
+ return sequenceItems(this).filter((item) => item === value).length;
2005
+ }
2006
+ reversed() {
2007
+ return Object.freeze([...sequenceItems(this)].reverse());
2008
+ }
2009
+ };
2010
+ var Categories2 = class extends ChartDataSequence {
2011
+ #customFormat = null;
2012
+ add_category(value) {
2013
+ const normalized = label(value);
2014
+ if (this.length && kind(this.at(0).label) !== kind(normalized))
2015
+ throw new ValueError("Category labels must have the same type.");
2016
+ const category = new Category2(normalized, this);
2017
+ sequenceItems(this).push(category);
2018
+ return category;
2019
+ }
2020
+ index(category) {
2021
+ let offset = 0;
2022
+ for (const item of this) {
2023
+ if (item === category) return offset;
2024
+ offset += item.leaf_count;
2025
+ }
2026
+ throw new ValueError("Category does not belong to this hierarchy.");
2027
+ }
2028
+ get are_dates() {
2029
+ return this.depth === 1 && this.length > 0 && this.at(0).label instanceof Date;
2030
+ }
2031
+ get are_numeric() {
2032
+ return this.depth === 1 && this.length > 0 && (this.are_dates || typeof this.at(0).label === "number");
2033
+ }
2034
+ get depth() {
2035
+ if (!this.length) return 0;
2036
+ const depths = sequenceItems(this).map((item) => item.depth);
2037
+ if (depths.some((depth) => depth !== depths[0]))
2038
+ throw new ValueError("Category hierarchy must have uniform depth.");
2039
+ return depths[0];
2040
+ }
2041
+ get leaf_count() {
2042
+ return sequenceItems(this).reduce((count, item) => count + item.leaf_count, 0);
2043
+ }
2044
+ get levels() {
2045
+ const levels = Array.from({ length: this.depth }, () => []);
2046
+ const visit = (category, depth) => {
2047
+ levels[depth].push([category.idx, category.label]);
2048
+ for (const child2 of category.sub_categories) visit(child2, depth + 1);
2049
+ };
2050
+ for (const category of this) visit(category, 0);
2051
+ return Object.freeze(
2052
+ levels.reverse().map((level) => Object.freeze(level.map((pair) => Object.freeze(pair))))
2053
+ );
2054
+ }
2055
+ get number_format() {
2056
+ return this.#customFormat ?? (this.are_dates ? "yyyy\\-mm\\-dd" : "General");
2057
+ }
2058
+ set number_format(value) {
2059
+ this.#customFormat = value === null ? null : format(value);
2060
+ }
2061
+ };
2062
+ var Category2 = class _Category {
2063
+ #value;
2064
+ #children = [];
2065
+ #parent;
2066
+ constructor(value, parent) {
2067
+ this.#value = label(value);
2068
+ this.#parent = parent;
2069
+ }
2070
+ get label() {
2071
+ return this.#value instanceof Date ? new Date(this.#value.getTime()) : this.#value ?? "";
2072
+ }
2073
+ get sub_categories() {
2074
+ return Object.freeze([...this.#children]);
2075
+ }
2076
+ add_sub_category(value) {
2077
+ if (typeof this.#value !== "string" || typeof value !== "string")
2078
+ throw new ValueError("Hierarchical categories require string labels.");
2079
+ const category = new _Category(value, this);
2080
+ this.#children.push(category);
2081
+ return category;
2082
+ }
2083
+ get idx() {
2084
+ return this.#parent.index(this);
2085
+ }
2086
+ index(category) {
2087
+ let offset = this.idx;
2088
+ for (const item of this.#children) {
2089
+ if (item === category) return offset;
2090
+ offset += item.leaf_count;
2091
+ }
2092
+ throw new ValueError("Subcategory does not belong to this category.");
2093
+ }
2094
+ get depth() {
2095
+ if (!this.#children.length) return 1;
2096
+ const depths = this.#children.map((child2) => child2.depth);
2097
+ if (depths.some((depth) => depth !== depths[0]))
2098
+ throw new ValueError("Category hierarchy must have uniform depth.");
2099
+ return depths[0] + 1;
2100
+ }
2101
+ get leaf_count() {
2102
+ return this.#children.length ? this.#children.reduce((sum, child2) => sum + child2.leaf_count, 0) : 1;
2103
+ }
2104
+ numeric_str_val(date_1904 = false) {
2105
+ if (typeof date_1904 !== "boolean") throw new TypeError();
2106
+ if (this.#value instanceof Date) {
2107
+ const day = Math.floor(this.#value.getTime() / 864e5);
2108
+ const serial = date_1904 ? day - Math.floor(Date.UTC(1904, 0, 1) / 864e5) : day - Math.floor(Date.UTC(1899, 11, 31) / 864e5) + (day >= Math.floor(Date.UTC(1900, 2, 1) / 864e5) ? 1 : 0);
2109
+ return serial.toFixed(1);
2110
+ }
2111
+ return String(this.#value);
2112
+ }
2113
+ };
2114
+ var CategoryDataPoint = class {
2115
+ value;
2116
+ #owner;
2117
+ #override;
2118
+ get owner() {
2119
+ return this.#owner;
2120
+ }
2121
+ constructor(owner, value, override = null) {
2122
+ this.value = numeric(value);
2123
+ if (override !== null) format(override);
2124
+ this.#owner = owner;
2125
+ this.#override = override;
2126
+ Object.freeze(this);
2127
+ }
2128
+ get number_format() {
2129
+ return this.#override ?? this.owner.number_format;
2130
+ }
2131
+ };
2132
+ var XyDataPoint = class _XyDataPoint {
2133
+ x;
2134
+ y;
2135
+ #owner;
2136
+ #override;
2137
+ get owner() {
2138
+ return this.#owner;
2139
+ }
2140
+ constructor(owner, x, y, override = null) {
2141
+ this.x = numeric(x, false);
2142
+ this.y = numeric(y);
2143
+ if (override !== null) format(override);
2144
+ this.#owner = owner;
2145
+ this.#override = override;
2146
+ if (new.target === _XyDataPoint) Object.freeze(this);
2147
+ }
2148
+ get number_format() {
2149
+ return this.#override ?? this.owner.number_format;
2150
+ }
2151
+ };
2152
+ var BubbleDataPoint = class extends XyDataPoint {
2153
+ bubble_size;
2154
+ constructor(owner, x, y, size, number_format = null) {
2155
+ super(owner, x, y, number_format);
2156
+ this.bubble_size = numeric(size, false);
2157
+ if (size < 0) throw new ValueError("Bubble size must not be negative.");
2158
+ Object.freeze(this);
2159
+ }
2160
+ };
2161
+ var SeriesData = class extends ChartDataSequence {
2162
+ #name;
2163
+ #owner;
2164
+ #override;
2165
+ get name() {
2166
+ return this.#name;
2167
+ }
2168
+ get owner() {
2169
+ return this.#owner;
2170
+ }
2171
+ constructor(owner, name, override = null) {
2172
+ super();
2173
+ this.#name = name === null ? "" : format(name);
2174
+ this.#owner = owner;
2175
+ this.#override = override;
2176
+ if (override !== null) format(override);
2177
+ }
2178
+ get number_format() {
2179
+ return this.#override ?? this.owner.number_format;
2180
+ }
2181
+ get index() {
2182
+ return this.owner.series_index(this);
2183
+ }
2184
+ get data_point_offset() {
2185
+ return this.owner.data_point_offset(this);
2186
+ }
2187
+ get name_ref() {
2188
+ return this.owner.series_name_ref(this);
2189
+ }
2190
+ get x_values_ref() {
2191
+ return this.owner.x_values_ref(this);
2192
+ }
2193
+ get y_values_ref() {
2194
+ return this.owner.y_values_ref(this);
2195
+ }
2196
+ append(point) {
2197
+ if (!sameOwner(point.owner, this))
2198
+ throw new ValueError("Data point belongs to another series.");
2199
+ sequenceItems(this).push(point);
2200
+ }
2201
+ };
2202
+ var CategorySeriesData = class extends SeriesData {
2203
+ add_data_point(value, number_format = null) {
2204
+ const point = new CategoryDataPoint(this, value, number_format);
2205
+ sequenceItems(this).push(point);
2206
+ return point;
2207
+ }
2208
+ get values() {
2209
+ return Object.freeze(sequenceItems(this).map((point) => point.value));
2210
+ }
2211
+ get y_values() {
2212
+ if (this.length)
2213
+ throw new PropertyAccessError(
2214
+ "Category points expose value; use values for category series."
2215
+ );
2216
+ return Object.freeze([]);
2217
+ }
2218
+ get x_values() {
2219
+ if (this.length)
2220
+ throw new PropertyAccessError(
2221
+ "Category points expose labels through categories, not x coordinates."
2222
+ );
2223
+ return Object.freeze([]);
2224
+ }
2225
+ get categories() {
2226
+ return this.owner.categories;
2227
+ }
2228
+ get categories_ref() {
2229
+ return this.owner.categories_ref;
2230
+ }
2231
+ get values_ref() {
2232
+ return this.owner.values_ref(this);
2233
+ }
2234
+ };
2235
+ var XySeriesData = class extends SeriesData {
2236
+ add_data_point(x, y, number_format = null) {
2237
+ const point = new XyDataPoint(this, x, y, number_format);
2238
+ sequenceItems(this).push(point);
2239
+ return point;
2240
+ }
2241
+ get x_values() {
2242
+ return Object.freeze(sequenceItems(this).map((point) => point.x));
2243
+ }
2244
+ get y_values() {
2245
+ return Object.freeze(sequenceItems(this).map((point) => point.y));
2246
+ }
2247
+ };
2248
+ var BubbleSeriesData = class extends SeriesData {
2249
+ add_data_point(x, y, size, number_format = null) {
2250
+ const point = new BubbleDataPoint(this, x, y, size, number_format);
2251
+ sequenceItems(this).push(point);
2252
+ return point;
2253
+ }
2254
+ get x_values() {
2255
+ return Object.freeze(sequenceItems(this).map((point) => point.x));
2256
+ }
2257
+ get y_values() {
2258
+ return Object.freeze(sequenceItems(this).map((point) => point.y));
2259
+ }
2260
+ get bubble_sizes() {
2261
+ return Object.freeze(sequenceItems(this).map((point) => point.bubble_size));
2262
+ }
2263
+ get bubble_sizes_ref() {
2264
+ return this.owner.bubble_sizes_ref(this);
2265
+ }
2266
+ };
2267
+ var BaseChartData = class extends ChartDataSequence {
2268
+ #numberFormat;
2269
+ get number_format() {
2270
+ return this.#numberFormat;
2271
+ }
2272
+ constructor(number_format = "General") {
2273
+ super();
2274
+ this.#numberFormat = format(number_format);
2275
+ }
2276
+ index(series2, start = 0, stop = this.length) {
2277
+ for (let i = bounds(start, this.length); i < bounds(stop, this.length); i++)
2278
+ if (sequenceItems(this)[i] === series2) return i;
2279
+ throw new ValueError("Series is not in this chart data.");
2280
+ }
2281
+ series_index(series2) {
2282
+ const i = sequenceItems(this).findIndex((item) => sameOwner(item, series2));
2283
+ if (i < 0) throw new ValueError("Series is not in this chart data.");
2284
+ return i;
2285
+ }
2286
+ data_point_offset(series2) {
2287
+ return sequenceItems(this).slice(0, this.series_index(series2)).reduce((sum, item) => sum + item.length, 0);
2288
+ }
2289
+ append(series2) {
2290
+ if (!sameOwner(series2.owner, this))
2291
+ throw new ValueError("Series belongs to another chart data.");
2292
+ sequenceItems(this).push(series2);
2293
+ }
2294
+ column(series2) {
2295
+ return this.series_index(series2) * this.columnsPerSeries;
2296
+ }
2297
+ reference(series2, column) {
2298
+ const letter = workbookColumn(column);
2299
+ const count = sequenceItems(this)[this.series_index(series2)].length;
2300
+ return `Sheet1!$${letter}$2:$${letter}$${count + 1}`;
2301
+ }
2302
+ series_name_ref(series2) {
2303
+ return `Sheet1!$${workbookColumn(this.column(series2) + 1)}$1`;
2304
+ }
2305
+ x_values_ref(series2) {
2306
+ return this.reference(series2, this.column(series2));
2307
+ }
2308
+ y_values_ref(series2) {
2309
+ return this.reference(series2, this.column(series2) + 1);
2310
+ }
2311
+ async xlsx_blob(context, date1904 = false) {
2312
+ const data = this.to_chart_data(date1904);
2313
+ return createChartWorkbook(
2314
+ {
2315
+ ...data,
2316
+ ...this instanceof CategoryChartData && this.categories.are_dates ? {
2317
+ categories: [...this.categories].map(
2318
+ (category) => Number(category.numeric_str_val(date1904 ?? false))
2319
+ )
2320
+ } : {}
2321
+ },
2322
+ this.columnsPerSeries > 1,
2323
+ context,
2324
+ { date1904 }
2325
+ );
2326
+ }
2327
+ xml_bytes(chart_type) {
2328
+ const type = typeof chart_type === "string" ? chart_type : chartTypes.find((name) => XL_CHART_TYPE[name] === chart_type);
2329
+ if (!type || !chartTypes.includes(type)) throw new ValueError("Unsupported chart type.");
2330
+ return new TextEncoder().encode(createChartXml(type, this.to_chart_data()));
2331
+ }
2332
+ };
2333
+ var CategoryChartData = class extends BaseChartData {
2334
+ #categoryData = new Categories2();
2335
+ get columnsPerSeries() {
2336
+ return 1;
2337
+ }
2338
+ get categories() {
2339
+ return this.#categoryData;
2340
+ }
2341
+ set categories(values) {
2342
+ const next = new Categories2();
2343
+ for (const value of values) next.add_category(value);
2344
+ this.#categoryData = next;
2345
+ }
2346
+ add_category(value) {
2347
+ return this.#categoryData.add_category(value);
2348
+ }
2349
+ add_series(name, values = [], number_format = null) {
2350
+ const series2 = new CategorySeriesData(this, name, number_format);
2351
+ for (const value of values) series2.add_data_point(value);
2352
+ sequenceItems(this).push(series2);
2353
+ return series2;
2354
+ }
2355
+ get categories_ref() {
2356
+ if (!this.categories.length) throw new ValueError("Chart data contains no categories.");
2357
+ return `Sheet1!$A$2:$${workbookColumn(Math.max(1, this.categories.depth) - 1)}$${this.categories.leaf_count + 1}`;
2358
+ }
2359
+ column(series2) {
2360
+ return this.series_index(series2) + Math.max(1, this.categories.depth) - 1;
2361
+ }
2362
+ values_ref(series2) {
2363
+ return this.reference(series2, this.column(series2) + 1);
2364
+ }
2365
+ x_values_ref(_series) {
2366
+ throw new PropertyAccessError("Category chart data exposes categories_ref, not x_values_ref.");
2367
+ }
2368
+ y_values_ref(_series) {
2369
+ throw new PropertyAccessError("Category chart data exposes values_ref, not y_values_ref.");
2370
+ }
2371
+ to_chart_data(date1904) {
2372
+ const categories = this.categories;
2373
+ return {
2374
+ numberFormat: this.number_format,
2375
+ categoryNumberFormat: categories.number_format,
2376
+ ...date1904 === void 0 ? {} : { date1904 },
2377
+ ...categories.depth > 1 ? {
2378
+ categoryLevels: [...categories.levels].reverse().map((level) => {
2379
+ const values = Array(categories.leaf_count).fill(null);
2380
+ for (const [index, label2] of level) values[index] = String(label2);
2381
+ return values;
2382
+ })
2383
+ } : {
2384
+ categories: [...categories].map(
2385
+ (category) => category.label instanceof Date ? category.label.toISOString() : categories.are_numeric ? Number(category.numeric_str_val(date1904 ?? false)) : String(category.label)
2386
+ )
2387
+ },
2388
+ series: sequenceItems(this).map((series2) => ({
2389
+ name: series2.name,
2390
+ values: series2.values,
2391
+ numberFormat: series2.number_format,
2392
+ pointNumberFormats: [...series2].map(
2393
+ (point) => point.number_format === series2.number_format ? null : point.number_format
2394
+ )
2395
+ }))
2396
+ };
2397
+ }
2398
+ };
2399
+ var XyChartData = class extends BaseChartData {
2400
+ get columnsPerSeries() {
2401
+ return 2;
2402
+ }
2403
+ add_series(name, number_format = null) {
2404
+ const series2 = new XySeriesData(this, name, number_format);
2405
+ sequenceItems(this).push(series2);
2406
+ return series2;
2407
+ }
2408
+ to_chart_data() {
2409
+ return {
2410
+ numberFormat: this.number_format,
2411
+ series: sequenceItems(this).map((series2) => ({
2412
+ name: series2.name,
2413
+ values: series2.y_values,
2414
+ xValues: series2.x_values,
2415
+ numberFormat: series2.number_format,
2416
+ pointNumberFormats: [...series2].map(
2417
+ (point) => point.number_format === series2.number_format ? null : point.number_format
2418
+ )
2419
+ }))
2420
+ };
2421
+ }
2422
+ };
2423
+ var BubbleChartData = class extends BaseChartData {
2424
+ get columnsPerSeries() {
2425
+ return 3;
2426
+ }
2427
+ add_series(name, number_format = null) {
2428
+ const series2 = new BubbleSeriesData(this, name, number_format);
2429
+ sequenceItems(this).push(series2);
2430
+ return series2;
2431
+ }
2432
+ bubble_sizes_ref(series2) {
2433
+ return this.reference(series2, this.column(series2) + 2);
2434
+ }
2435
+ to_chart_data() {
2436
+ return {
2437
+ numberFormat: this.number_format,
2438
+ series: sequenceItems(this).map((series2) => ({
2439
+ name: series2.name,
2440
+ values: series2.y_values,
2441
+ xValues: series2.x_values,
2442
+ bubbleSizes: series2.bubble_sizes,
2443
+ numberFormat: series2.number_format,
2444
+ pointNumberFormats: [...series2].map(
2445
+ (point) => point.number_format === series2.number_format ? null : point.number_format
2446
+ )
2447
+ }))
2448
+ };
2449
+ }
2450
+ };
2451
+ function toChartData(input) {
2452
+ return input instanceof CategoryChartData || input instanceof XyChartData || input instanceof BubbleChartData ? input.to_chart_data() : input;
2453
+ }
2454
+
2455
+ // packages/safe-bash-presentation-engine/src/chart-type-model.ts
2456
+ var plotTags = /* @__PURE__ */ new Set([
2457
+ "areaChart",
2458
+ "area3DChart",
2459
+ "barChart",
2460
+ "bar3DChart",
2461
+ "bubbleChart",
2462
+ "doughnutChart",
2463
+ "lineChart",
2464
+ "line3DChart",
2465
+ "ofPieChart",
2466
+ "pieChart",
2467
+ "pie3DChart",
2468
+ "radarChart",
2469
+ "scatterChart",
2470
+ "stockChart",
2471
+ "surfaceChart",
2472
+ "surface3DChart"
2473
+ ]);
2474
+ function unsupported2() {
2475
+ throw new OfficeError(
2476
+ "unsupported-edit",
2477
+ "Chart type cannot be classified from the retained plot properties.",
2478
+ "validate-intent"
2479
+ );
2480
+ }
2481
+ function token(node, localName, fallback) {
2482
+ const matches = node.children.filter(
2483
+ (n) => n.name.namespace === node.name.namespace && n.name.localName === localName
2484
+ );
2485
+ if (matches.length > 1)
2486
+ throw new OfficeError("invalid-xml", "Duplicate chart type discriminator.", "index");
2487
+ return matches[0] ? attr(matches[0], "val") ?? fallback : fallback;
2488
+ }
2489
+ function flag(node, localName, fallback = false) {
2490
+ const value = token(node, localName, child(node, localName) ? "1" : void 0);
2491
+ if (value === void 0) return fallback;
2492
+ if (!["1", "0", "true", "false"].includes(value)) unsupported2();
2493
+ return value === "1" || value === "true";
2494
+ }
2495
+ function series(node) {
2496
+ return node.children.filter(
2497
+ (n) => n.name.namespace === node.name.namespace && n.name.localName === "ser"
2498
+ );
2499
+ }
2500
+ function enumType(name) {
2501
+ const value = Object.hasOwn(XL_CHART_TYPE, name) ? XL_CHART_TYPE[name] : void 0;
2502
+ if (typeof value !== "number") unsupported2();
2503
+ return value;
2504
+ }
2505
+ function readModelChartType(doc) {
2506
+ const ns2 = doc.root.name.namespace;
2507
+ if (![
2508
+ "http://schemas.openxmlformats.org/drawingml/2006/chart",
2509
+ "http://purl.oclc.org/ooxml/drawingml/chart"
2510
+ ].includes(ns2))
2511
+ unsupported2();
2512
+ const chart = child(doc.root, "chart"), area = chart && child(chart, "plotArea");
2513
+ if (!area) unsupported2();
2514
+ const plots = area.children.filter(
2515
+ (n) => n.name.namespace === ns2 && plotTags.has(n.name.localName)
2516
+ );
2517
+ const plot = plots[0];
2518
+ if (!plot) unsupported2();
2519
+ const stock = plots.find((n) => n.name.localName === "stockChart");
2520
+ if (stock && plots.length === 2 && plots.some(
2521
+ (n) => n.name.localName === "barChart" && token(n, "barDir") === "col" && series(n).length === 1
2522
+ )) {
2523
+ const count = series(stock).length;
2524
+ if (count !== 3 && count !== 4) unsupported2();
2525
+ return count === 3 ? XL_CHART_TYPE.STOCK_VHLC : XL_CHART_TYPE.STOCK_VOHLC;
2526
+ }
2527
+ const tag = plot.name.localName;
2528
+ const grouping = token(plot, "grouping", tag.startsWith("bar") ? "clustered" : "standard");
2529
+ if (!["standard", "clustered", "stacked", "percentStacked"].includes(grouping)) unsupported2();
2530
+ const suffix = grouping === "percentStacked" ? "_STACKED_100" : grouping === "stacked" ? "_STACKED" : "";
2531
+ const first = series(plot)[0];
2532
+ if (tag === "barChart" || tag === "bar3DChart") {
2533
+ const direction = token(plot, "barDir");
2534
+ if (direction !== "bar" && direction !== "col") unsupported2();
2535
+ if (tag === "barChart")
2536
+ return enumType(`${direction === "bar" ? "BAR" : "COLUMN"}${suffix || "_CLUSTERED"}`);
2537
+ const shape = (first && token(first, "shape")) ?? token(plot, "shape", "box");
2538
+ const prefixes = {
2539
+ box: `THREE_D_${direction === "bar" ? "BAR" : "COLUMN"}`,
2540
+ cone: `CONE_${direction === "bar" ? "BAR" : "COL"}`,
2541
+ coneToMax: `CONE_${direction === "bar" ? "BAR" : "COL"}`,
2542
+ cylinder: `CYLINDER_${direction === "bar" ? "BAR" : "COL"}`,
2543
+ pyramid: `PYRAMID_${direction === "bar" ? "BAR" : "COL"}`,
2544
+ pyramidToMax: `PYRAMID_${direction === "bar" ? "BAR" : "COL"}`
2545
+ };
2546
+ if (!shape || !Object.hasOwn(prefixes, shape)) unsupported2();
2547
+ return enumType(`${prefixes[shape]}${suffix || (grouping === "standard" ? "" : "_CLUSTERED")}`);
2548
+ }
2549
+ if (tag === "areaChart" || tag === "area3DChart")
2550
+ return enumType(`${tag === "area3DChart" ? "THREE_D_" : ""}AREA${suffix}`);
2551
+ if (tag === "lineChart") {
2552
+ const marker = first && child(first, "marker"), symbol = marker && token(marker, "symbol");
2553
+ const marked = symbol === void 0 ? flag(plot, "marker") : symbol !== "none";
2554
+ return enumType(`LINE${marked ? "_MARKERS" : ""}${suffix}`);
2555
+ }
2556
+ if (tag === "line3DChart") return XL_CHART_TYPE.THREE_D_LINE;
2557
+ if (["pieChart", "pie3DChart", "doughnutChart"].includes(tag)) {
2558
+ const exploded = series(plot).some((n) => Number(token(n, "explosion", "0")) > 0);
2559
+ return enumType(
2560
+ `${tag === "pie3DChart" ? "THREE_D_PIE" : tag === "pieChart" ? "PIE" : "DOUGHNUT"}${exploded ? "_EXPLODED" : ""}`
2561
+ );
2562
+ }
2563
+ if (tag === "ofPieChart") {
2564
+ const type = token(plot, "ofPieType");
2565
+ if (type !== "bar" && type !== "pie") unsupported2();
2566
+ return type === "bar" ? XL_CHART_TYPE.BAR_OF_PIE : XL_CHART_TYPE.PIE_OF_PIE;
2567
+ }
2568
+ if (tag === "bubbleChart")
2569
+ return (first && child(first, "bubble3D") ? flag(first, "bubble3D") : flag(plot, "bubble3D")) ? XL_CHART_TYPE.BUBBLE_THREE_D_EFFECT : XL_CHART_TYPE.BUBBLE;
2570
+ if (tag === "radarChart") {
2571
+ const style = token(plot, "radarStyle"), types = {
2572
+ standard: "RADAR",
2573
+ marker: "RADAR_MARKERS",
2574
+ filled: "RADAR_FILLED"
2575
+ };
2576
+ if (!style || !Object.hasOwn(types, style)) unsupported2();
2577
+ return enumType(types[style]);
2578
+ }
2579
+ if (tag === "scatterChart") {
2580
+ const style = token(plot, "scatterStyle"), types = {
2581
+ marker: "XY_SCATTER",
2582
+ lineMarker: "XY_SCATTER_LINES",
2583
+ line: "XY_SCATTER_LINES_NO_MARKERS",
2584
+ smoothMarker: "XY_SCATTER_SMOOTH",
2585
+ smooth: "XY_SCATTER_SMOOTH_NO_MARKERS"
2586
+ };
2587
+ if (!style || !Object.hasOwn(types, style)) unsupported2();
2588
+ const a = ns2 === "http://purl.oclc.org/ooxml/drawingml/chart" ? "http://purl.oclc.org/ooxml/drawingml/main" : "http://schemas.openxmlformats.org/drawingml/2006/main";
2589
+ const props = first && child(first, "spPr"), line = props && child(props, "ln", a);
2590
+ if (line && child(line, "noFill", a)) return XL_CHART_TYPE.XY_SCATTER;
2591
+ return enumType(types[style]);
2592
+ }
2593
+ if (tag === "stockChart") {
2594
+ const count = series(plot).length;
2595
+ if (count !== 3 && count !== 4) unsupported2();
2596
+ return count === 3 ? XL_CHART_TYPE.STOCK_HLC : XL_CHART_TYPE.STOCK_OHLC;
2597
+ }
2598
+ return enumType(
2599
+ `SURFACE${tag === "surfaceChart" ? "_TOP_VIEW" : ""}${flag(plot, "wireframe") ? "_WIREFRAME" : ""}`
2600
+ );
2601
+ }
2602
+
2603
+ // packages/safe-bash-presentation-engine/src/chart-model.ts
2604
+ var ChartRoot = class extends ChartNode {
2605
+ get title() {
2606
+ return new ChartTitle(chartDescendant(this, "title", true));
2607
+ }
2608
+ get hasTitle() {
2609
+ return !!child(chartNode(this), "title");
2610
+ }
2611
+ set hasTitle(value) {
2612
+ this.present("title", value);
2613
+ }
2614
+ get legend() {
2615
+ return child(chartNode(this), "legend") ? new Legend(chartDescendant(this, "legend")) : null;
2616
+ }
2617
+ };
2618
+ var ChartSpace = class extends ChartNode {
2619
+ get font() {
2620
+ return this.textFrame().paragraphs[0].font;
2621
+ }
2622
+ };
2623
+ var Chart = class {
2624
+ #owner;
2625
+ #options;
2626
+ #read;
2627
+ #write;
2628
+ constructor(read, write, options = {}) {
2629
+ this.#options = options;
2630
+ this.#owner = chartBinding(read, write);
2631
+ this.#read = this.#owner.read;
2632
+ this.#write = this.#owner.write;
2633
+ }
2634
+ get part() {
2635
+ this.#read();
2636
+ if (!this.#options.part) throw new PropertyAccessError("Chart package part is unavailable.");
2637
+ return this.#options.part();
2638
+ }
2639
+ replace_data(data) {
2640
+ this.#read();
2641
+ const input = toChartData(data);
2642
+ if (!this.#options.replaceData)
2643
+ throw new PropertyAccessError("Chart workbook ownership is unavailable.");
2644
+ this.#options.replaceData(input);
2645
+ this.#read();
2646
+ }
2647
+ #binding() {
2648
+ return this.#owner;
2649
+ }
2650
+ #chart() {
2651
+ const binding = this.#binding();
2652
+ return new ChartRoot({ ...binding, locate: (xml) => required(xml.root, "chart") });
2653
+ }
2654
+ get has_title() {
2655
+ return this.#chart().hasTitle;
2656
+ }
2657
+ set has_title(value) {
2658
+ this.#chart().hasTitle = value;
2659
+ }
2660
+ get chart_title() {
2661
+ return this.#chart().title;
2662
+ }
2663
+ get legend() {
2664
+ return this.#chart().legend;
2665
+ }
2666
+ get font() {
2667
+ return new ChartSpace(this.#binding()).font;
2668
+ }
2669
+ #axis(names, index = 0) {
2670
+ const binding = this.#binding();
2671
+ const locate = (xml) => {
2672
+ const area = required(required(xml.root, "chart"), "plotArea");
2673
+ const found = area.children.filter(
2674
+ (n) => n.name.namespace === area.name.namespace && names.includes(n.name.localName)
2675
+ )[index];
2676
+ if (!found) throw new PropertyAccessError("Chart axis is unavailable.");
2677
+ return found;
2678
+ };
2679
+ locate(this.#read());
2680
+ return { ...binding, locate };
2681
+ }
2682
+ get category_axis() {
2683
+ try {
2684
+ const binding = this.#axis(["catAx", "dateAx"]);
2685
+ return binding.locate(this.#read()).name.localName === "dateAx" ? new DateAxis(binding) : new CategoryAxis(binding);
2686
+ } catch (error) {
2687
+ if (!(error instanceof PropertyAccessError)) throw error;
2688
+ return new ValueAxis(this.#axis(["valAx"]));
2689
+ }
2690
+ }
2691
+ get value_axis() {
2692
+ const area = required(required(this.#read().root, "chart"), "plotArea");
2693
+ const hasCategories = area.children.some(
2694
+ (n) => n.name.namespace === area.name.namespace && ["catAx", "dateAx"].includes(n.name.localName)
2695
+ );
2696
+ return new ValueAxis(this.#axis(["valAx"], hasCategories ? 0 : 1));
2697
+ }
2698
+ get plots() {
2699
+ const binding = this.#binding();
2700
+ return new Plots(() => {
2701
+ const area = required(required(this.#read().root, "chart"), "plotArea");
2702
+ return area.children.filter(
2703
+ (n) => n.name.namespace === area.name.namespace && plotNames.includes(n.name.localName)
2704
+ ).map(
2705
+ (_, index) => plotFor(
2706
+ {
2707
+ ...binding,
2708
+ locate: (xml) => {
2709
+ const parent = required(required(xml.root, "chart"), "plotArea"), found = parent.children.filter(
2710
+ (n) => n.name.namespace === parent.name.namespace && plotNames.includes(n.name.localName)
2711
+ )[index];
2712
+ if (!found) throw new InvalidHandleError();
2713
+ return found;
2714
+ }
2715
+ },
2716
+ this
2717
+ )
2718
+ );
2719
+ });
2720
+ }
2721
+ get series() {
2722
+ return new SeriesCollection(() => [...this.plots].flatMap((plot) => [...plot.series]));
2723
+ }
2724
+ get chart_type() {
2725
+ return readModelChartType(this.#read());
2726
+ }
2727
+ get chart_style() {
2728
+ const node = child(this.#read().root, "style");
2729
+ if (!node) return null;
2730
+ const value = Number(attr(node, "val"));
2731
+ if (!Number.isInteger(value) || value < 1 || value > 48)
2732
+ throw new ValueError("Invalid chart style.");
2733
+ return value;
2734
+ }
2735
+ set chart_style(value) {
2736
+ if (value !== null && typeof value !== "number") throw new TypeError();
2737
+ this.#write(applyChartAppearance(this.#read(), { style: value }));
2738
+ }
2739
+ get has_legend() {
2740
+ return !!child(required(this.#read().root, "chart"), "legend");
2741
+ }
2742
+ set has_legend(value) {
2743
+ if (typeof value !== "boolean") throw new TypeError();
2744
+ this.#write(applyChartAppearance(this.#read(), { legend: value }));
2745
+ }
2746
+ get element() {
2747
+ return createXmlElementView({
2748
+ read: this.#read,
2749
+ commit: (expected, next) => {
2750
+ if (this.#read() !== expected) throw new InvalidHandleError();
2751
+ this.#write(next);
2752
+ }
2753
+ });
2754
+ }
2755
+ };
2756
+
2757
+ // packages/safe-bash-presentation-engine/src/chart-object-mutations.ts
2758
+ function applyChartObjectUpdates(document, updates) {
2759
+ validateChartObjectUpdates(updates);
2760
+ const chart = new Chart(
2761
+ () => document,
2762
+ (next) => {
2763
+ document = next;
2764
+ }
2765
+ );
2766
+ for (const edit of updates) {
2767
+ switch (edit.target) {
2768
+ case "font": {
2769
+ const { target: ignoredTarget, ...font } = edit;
2770
+ applyChartFontUpdate(chart, font);
2771
+ break;
2772
+ }
2773
+ case "format": {
2774
+ const series2 = () => chart.series.at(edit.series);
2775
+ const owner = (() => {
2776
+ switch (edit.owner) {
2777
+ case "title":
2778
+ return chart.chart_title;
2779
+ case "legend": {
2780
+ if (!chart.legend) throw new PropertyAccessError();
2781
+ return chart.legend;
2782
+ }
2783
+ case "categoryAxis":
2784
+ return chart.category_axis;
2785
+ case "valueAxis":
2786
+ return chart.value_axis;
2787
+ case "categoryAxisTitle":
2788
+ return chart.category_axis.axis_title;
2789
+ case "valueAxisTitle":
2790
+ return chart.value_axis.axis_title;
2791
+ case "categoryMajorGridlines":
2792
+ return chart.category_axis.major_gridlines;
2793
+ case "valueMajorGridlines":
2794
+ return chart.value_axis.major_gridlines;
2795
+ case "series":
2796
+ return series2();
2797
+ case "point":
2798
+ return series2().points.at(edit.point);
2799
+ case "marker": {
2800
+ const selected = series2();
2801
+ if (edit.point !== void 0) return selected.points.at(edit.point).marker;
2802
+ if (!(selected instanceof RadarSeries || selected instanceof XySeries))
2803
+ throw new PropertyAccessError();
2804
+ return selected.marker;
2805
+ }
2806
+ }
2807
+ })();
2808
+ owner.format.apply(edit.drawing);
2809
+ break;
2810
+ }
2811
+ case "chart":
2812
+ if (edit.hasTitle !== void 0) chart.has_title = edit.hasTitle;
2813
+ if (edit.hasLegend !== void 0) chart.has_legend = edit.hasLegend;
2814
+ if (edit.style !== void 0) chart.chart_style = edit.style;
2815
+ break;
2816
+ case "title": {
2817
+ const title = chart.chart_title;
2818
+ if (edit.hasTextFrame !== void 0) title.has_text_frame = edit.hasTextFrame;
2819
+ if (edit.text !== void 0) title.text_frame.text = edit.text;
2820
+ break;
2821
+ }
2822
+ case "legend": {
2823
+ const legend = chart.legend;
2824
+ if (!legend) throw new PropertyAccessError();
2825
+ if (edit.position !== void 0)
2826
+ legend.position = XL_LEGEND_POSITION[edit.position];
2827
+ if (edit.includeInLayout !== void 0)
2828
+ legend.include_in_layout = edit.includeInLayout;
2829
+ if (edit.horzOffset !== void 0) legend.horz_offset = edit.horzOffset;
2830
+ break;
2831
+ }
2832
+ case "categoryAxis":
2833
+ case "valueAxis": {
2834
+ const axis = edit.target === "categoryAxis" ? chart.category_axis : chart.value_axis;
2835
+ if (edit.hasTitle !== void 0) axis.has_title = edit.hasTitle;
2836
+ if (edit.hasMajorGridlines !== void 0)
2837
+ axis.has_major_gridlines = edit.hasMajorGridlines;
2838
+ if (edit.hasMinorGridlines !== void 0)
2839
+ axis.has_minor_gridlines = edit.hasMinorGridlines;
2840
+ if (edit.majorTickMark !== void 0)
2841
+ axis.major_tick_mark = XL_TICK_MARK[edit.majorTickMark];
2842
+ if (edit.minorTickMark !== void 0)
2843
+ axis.minor_tick_mark = XL_TICK_MARK[edit.minorTickMark];
2844
+ if (edit.maximumScale !== void 0)
2845
+ axis.maximum_scale = edit.maximumScale;
2846
+ if (edit.minimumScale !== void 0)
2847
+ axis.minimum_scale = edit.minimumScale;
2848
+ if (edit.reverseOrder !== void 0) axis.reverse_order = edit.reverseOrder;
2849
+ if (edit.tickLabelPosition !== void 0)
2850
+ axis.tick_label_position = XL_TICK_LABEL_POSITION[edit.tickLabelPosition];
2851
+ if (edit.visible !== void 0) axis.visible = edit.visible;
2852
+ if (edit.target === "valueAxis") {
2853
+ const value = chart.value_axis;
2854
+ if (edit.crosses !== void 0)
2855
+ value.crosses = XL_AXIS_CROSSES[edit.crosses];
2856
+ if (edit.crossesAt !== void 0) value.crosses_at = edit.crossesAt;
2857
+ if (edit.majorUnit !== void 0) value.major_unit = edit.majorUnit;
2858
+ if (edit.minorUnit !== void 0) value.minor_unit = edit.minorUnit;
2859
+ }
2860
+ break;
2861
+ }
2862
+ case "axisTitle": {
2863
+ const title = (edit.axis === "category" ? chart.category_axis : chart.value_axis).axis_title;
2864
+ if (edit.hasTextFrame !== void 0) title.has_text_frame = edit.hasTextFrame;
2865
+ if (edit.text !== void 0) title.text_frame.text = edit.text;
2866
+ break;
2867
+ }
2868
+ case "tickLabels": {
2869
+ const labels = (edit.axis === "category" ? chart.category_axis : chart.value_axis).tick_labels;
2870
+ if (edit.numberFormat !== void 0) labels.number_format = edit.numberFormat;
2871
+ if (edit.numberFormatIsLinked !== void 0)
2872
+ labels.number_format_is_linked = edit.numberFormatIsLinked;
2873
+ if (edit.offset !== void 0) labels.offset = edit.offset;
2874
+ break;
2875
+ }
2876
+ case "plot": {
2877
+ const plot = chart.plots.at(edit.plot);
2878
+ if (edit.hasDataLabels !== void 0) plot.has_data_labels = edit.hasDataLabels;
2879
+ if (edit.varyByCategories !== void 0)
2880
+ plot.vary_by_categories = edit.varyByCategories;
2881
+ if (edit.gapWidth !== void 0) {
2882
+ if (!(plot instanceof BarPlot)) throw new PropertyAccessError();
2883
+ plot.gap_width = edit.gapWidth;
2884
+ }
2885
+ if (edit.overlap !== void 0) {
2886
+ if (!(plot instanceof BarPlot)) throw new PropertyAccessError();
2887
+ plot.overlap = edit.overlap;
2888
+ }
2889
+ if (edit.bubbleScale !== void 0) {
2890
+ if (!(plot instanceof BubblePlot)) throw new PropertyAccessError();
2891
+ plot.bubble_scale = edit.bubbleScale;
2892
+ }
2893
+ break;
2894
+ }
2895
+ case "series": {
2896
+ const series2 = chart.series.at(edit.series);
2897
+ if (edit.invertIfNegative !== void 0) {
2898
+ if (!(series2 instanceof BarSeries)) throw new PropertyAccessError();
2899
+ series2.invert_if_negative = edit.invertIfNegative;
2900
+ }
2901
+ if (edit.smooth !== void 0) {
2902
+ if (!(series2 instanceof LineSeries)) throw new PropertyAccessError();
2903
+ series2.smooth = edit.smooth;
2904
+ }
2905
+ break;
2906
+ }
2907
+ case "marker": {
2908
+ const series2 = chart.series.at(edit.series);
2909
+ if (edit.point === void 0 && !(series2 instanceof RadarSeries || series2 instanceof XySeries))
2910
+ throw new PropertyAccessError();
2911
+ const marker = edit.point === void 0 ? series2.marker : series2.points.at(edit.point).marker;
2912
+ if (edit.style !== void 0)
2913
+ marker.style = edit.style === null ? null : XL_MARKER_STYLE[edit.style];
2914
+ if (edit.size !== void 0) marker.size = edit.size;
2915
+ break;
2916
+ }
2917
+ case "dataLabels": {
2918
+ const labels = chart.plots.at(edit.plot).data_labels;
2919
+ if (edit.position !== void 0)
2920
+ labels.position = edit.position === null ? null : XL_DATA_LABEL_POSITION[edit.position];
2921
+ if (edit.numberFormat !== void 0) labels.number_format = edit.numberFormat;
2922
+ if (edit.numberFormatIsLinked !== void 0)
2923
+ labels.number_format_is_linked = edit.numberFormatIsLinked;
2924
+ if (edit.showCategoryName !== void 0)
2925
+ labels.show_category_name = edit.showCategoryName;
2926
+ if (edit.showLegendKey !== void 0)
2927
+ labels.show_legend_key = edit.showLegendKey;
2928
+ if (edit.showPercentage !== void 0)
2929
+ labels.show_percentage = edit.showPercentage;
2930
+ if (edit.showSeriesName !== void 0)
2931
+ labels.show_series_name = edit.showSeriesName;
2932
+ if (edit.showValue !== void 0) labels.show_value = edit.showValue;
2933
+ break;
2934
+ }
2935
+ case "dataLabel": {
2936
+ const label2 = chart.series.at(edit.series).points.at(edit.point).data_label;
2937
+ if (edit.position !== void 0)
2938
+ label2.position = edit.position === null ? null : XL_DATA_LABEL_POSITION[edit.position];
2939
+ if (edit.hasTextFrame !== void 0) label2.has_text_frame = edit.hasTextFrame;
2940
+ if (edit.text !== void 0) label2.text_frame.text = edit.text;
2941
+ break;
2942
+ }
2943
+ }
2944
+ }
2945
+ return document;
2946
+ }
2947
+
2948
+ // packages/safe-bash-presentation-engine/src/chart-editing.ts
2949
+ var chartTypes = [
2950
+ "AREA",
2951
+ "AREA_STACKED",
2952
+ "AREA_STACKED_100",
2953
+ "BUBBLE",
2954
+ "BUBBLE_THREE_D_EFFECT",
2955
+ "DOUGHNUT",
2956
+ "DOUGHNUT_EXPLODED",
2957
+ "RADAR",
2958
+ "RADAR_FILLED",
2959
+ "RADAR_MARKERS",
2960
+ "BAR_CLUSTERED",
2961
+ "BAR_STACKED",
2962
+ "BAR_STACKED_100",
2963
+ "COLUMN_CLUSTERED",
2964
+ "COLUMN_STACKED",
2965
+ "COLUMN_STACKED_100",
2966
+ "LINE",
2967
+ "LINE_MARKERS",
2968
+ "LINE_MARKERS_STACKED",
2969
+ "LINE_MARKERS_STACKED_100",
2970
+ "LINE_STACKED",
2971
+ "LINE_STACKED_100",
2972
+ "PIE",
2973
+ "PIE_EXPLODED",
2974
+ "XY_SCATTER",
2975
+ "XY_SCATTER_LINES",
2976
+ "XY_SCATTER_LINES_NO_MARKERS",
2977
+ "XY_SCATTER_SMOOTH",
2978
+ "XY_SCATTER_SMOOTH_NO_MARKERS"
2979
+ ];
2980
+ function invalid(message) {
2981
+ throw new OfficeError("invalid-value", message, "usage");
2982
+ }
2983
+ function unsupported3(message) {
2984
+ throw new OfficeError("unsupported-edit", message, "validate-intent");
2985
+ }
2986
+ function object(value, keys) {
2987
+ if (!value || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value)) || Reflect.ownKeys(value).some(
2988
+ (k) => typeof k !== "string" || !keys.includes(k) || !("value" in Object.getOwnPropertyDescriptor(value, k))
2989
+ ))
2990
+ invalid("Chart options require plain data properties.");
2991
+ }
2992
+ function array(value) {
2993
+ if (!Array.isArray(value) || value.length === 0 || Reflect.ownKeys(value).some(
2994
+ (k) => k !== "length" && (typeof k !== "string" || !Number.isSafeInteger(Number(k)) || String(Number(k)) !== k || !("value" in Object.getOwnPropertyDescriptor(value, k)))
2995
+ ) || Object.keys(value).length !== value.length)
2996
+ invalid("Chart arrays require nonempty bounded dense data.");
2997
+ }
2998
+ function dateLabel(value) {
2999
+ return typeof value === "string" && value.length >= 20 && value[4] === "-" && value[7] === "-" && value[10] === "T" && value.endsWith("Z");
3000
+ }
3001
+ function dateSerial(value, date1904) {
3002
+ const stamp = Date.parse(value);
3003
+ if (!Number.isFinite(stamp) || new Date(stamp).toISOString().slice(0, 19) !== value.slice(0, 19))
3004
+ invalid("Invalid UTC category date.");
3005
+ const day = Math.floor(stamp / 864e5);
3006
+ return date1904 ? day - Math.floor(Date.UTC(1904, 0, 1) / 864e5) : day - Math.floor(Date.UTC(1899, 11, 31) / 864e5) + (day >= Math.floor(Date.UTC(1900, 2, 1) / 864e5) ? 1 : 0);
3007
+ }
3008
+ function normalizedData(data, date1904 = data.date1904 ?? false) {
3009
+ return {
3010
+ ...data,
3011
+ ...data.categories?.some(dateLabel) ? { categoryNumberFormat: data.categoryNumberFormat ?? "yyyy-mm-dd" } : {},
3012
+ ...data.categories ? {
3013
+ categories: data.categories.map(
3014
+ (value) => dateLabel(value) ? dateSerial(value, date1904) : value
3015
+ )
3016
+ } : {}
3017
+ };
3018
+ }
3019
+ function validateChartData(data, type) {
3020
+ object(data, [
3021
+ "categories",
3022
+ "categoryLevels",
3023
+ "numberFormat",
3024
+ "categoryNumberFormat",
3025
+ "date1904",
3026
+ "series"
3027
+ ]);
3028
+ for (const format2 of [data.numberFormat, data.categoryNumberFormat])
3029
+ if (format2 !== void 0 && typeof format2 !== "string")
3030
+ invalid("Number formats require strings.");
3031
+ if (data.date1904 !== void 0 && typeof data.date1904 !== "boolean")
3032
+ invalid("Date system requires a boolean.");
3033
+ if (data.categoryLevels !== void 0) {
3034
+ array(data.categoryLevels);
3035
+ for (const level of data.categoryLevels) array(level);
3036
+ if (data.categories !== void 0)
3037
+ invalid("Hierarchical categories cannot accompany flat categories.");
3038
+ for (const level of data.categoryLevels) {
3039
+ array(level);
3040
+ if (level.length !== data.categoryLevels[0].length || level.some((value) => value !== null && typeof value !== "string"))
3041
+ invalid("Category levels require equally sized string or null arrays.");
3042
+ }
3043
+ }
3044
+ array(data.series);
3045
+ if (type !== void 0 && !chartTypes.includes(type)) invalid("Unsupported chart creation type.");
3046
+ if (data.categories !== void 0) {
3047
+ array(data.categories);
3048
+ const kinds = new Set(
3049
+ data.categories.filter((v) => v !== null).map((v) => dateLabel(v) ? "date" : typeof v)
3050
+ );
3051
+ for (const value of data.categories) if (dateLabel(value)) dateSerial(value, false);
3052
+ if (kinds.size > 1 || data.categories.some(
3053
+ (v) => v !== null && typeof v !== "string" && (typeof v !== "number" || !Number.isFinite(v))
3054
+ ))
3055
+ invalid("Categories require homogeneous strings or finite numbers with optional nulls.");
3056
+ }
3057
+ for (const series2 of data.series) {
3058
+ object(series2, [
3059
+ "name",
3060
+ "values",
3061
+ "xValues",
3062
+ "bubbleSizes",
3063
+ "numberFormat",
3064
+ "pointNumberFormats"
3065
+ ]);
3066
+ if (typeof series2.name !== "string" || series2.numberFormat !== void 0 && typeof series2.numberFormat !== "string")
3067
+ invalid("Series names and number formats require strings.");
3068
+ array(series2.values);
3069
+ if (series2.pointNumberFormats !== void 0) {
3070
+ array(series2.pointNumberFormats);
3071
+ if (series2.pointNumberFormats.length !== series2.values.length || series2.pointNumberFormats.some((format2) => format2 !== null && typeof format2 !== "string"))
3072
+ invalid("Point number formats require matching string or null entries.");
3073
+ }
3074
+ if (series2.values.some((v) => v !== null && (typeof v !== "number" || !Number.isFinite(v))))
3075
+ invalid("Series values require finite numbers or nulls.");
3076
+ if (series2.xValues !== void 0) {
3077
+ array(series2.xValues);
3078
+ if (series2.xValues.length !== series2.values.length || series2.xValues.some((v) => typeof v !== "number" || !Number.isFinite(v)))
3079
+ invalid("Scatter coordinates require equal length finite x values.");
3080
+ }
3081
+ if (series2.bubbleSizes !== void 0) {
3082
+ array(series2.bubbleSizes);
3083
+ if (series2.bubbleSizes.length !== series2.values.length || series2.bubbleSizes.some(
3084
+ (value) => typeof value !== "number" || !Number.isFinite(value) || value < 0
3085
+ ))
3086
+ invalid("Bubble sizes require equal length nonnegative finite values.");
3087
+ }
3088
+ if (type !== void 0 && !type.startsWith("BUBBLE") && series2.bubbleSizes !== void 0)
3089
+ invalid("Bubble sizes are only supported by bubble charts.");
3090
+ if (type?.startsWith("BUBBLE") && series2.bubbleSizes === void 0)
3091
+ invalid("Bubble charts require sizes.");
3092
+ if (type?.startsWith("XY_") || type?.startsWith("BUBBLE")) {
3093
+ if (data.categories !== void 0 || data.categoryLevels !== void 0 || !series2.xValues)
3094
+ invalid("Scatter requires x values and forbids categories.");
3095
+ } else if (type !== void 0) {
3096
+ if (!data.categories && !data.categoryLevels || (data.categories ?? data.categoryLevels[0]).length !== series2.values.length || series2.xValues !== void 0)
3097
+ invalid("Category series lengths must match categories.");
3098
+ }
3099
+ }
3100
+ if ((type?.startsWith("PIE") || type?.startsWith("DOUGHNUT")) && data.series.length !== 1)
3101
+ invalid("Pie charts require exactly one series.");
3102
+ }
3103
+ function validateChartUpdate(update) {
3104
+ object(update, ["objects", "data", "style", "title", "legend", "left", "top", "width", "height"]);
3105
+ if (update.objects !== void 0) validateChartObjectUpdates(update.objects);
3106
+ if (update.data !== void 0) validateChartData(update.data);
3107
+ if (update.style !== void 0 && (!Number.isInteger(update.style) || update.style < 1 || update.style > 48))
3108
+ invalid("Chart style requires an integer from 1 to 48.");
3109
+ if (update.title !== void 0 && typeof update.title !== "string")
3110
+ invalid("Chart title requires text.");
3111
+ if (update.legend !== void 0 && typeof update.legend !== "boolean")
3112
+ invalid("Chart legend requires a boolean.");
3113
+ for (const k of ["left", "top", "width", "height"]) {
3114
+ const v = update[k];
3115
+ if (v !== void 0 && (!Number.isSafeInteger(v) || Math.abs(v) > 27273042316900 || (k === "width" || k === "height") && v <= 0))
3116
+ invalid("Chart geometry requires bounded integer EMUs and positive extents.");
3117
+ }
3118
+ }
3119
+ function variant(type) {
3120
+ return {
3121
+ scatter: type.startsWith("XY_") || type.startsWith("BUBBLE"),
3122
+ bubble: type.startsWith("BUBBLE"),
3123
+ area: type.startsWith("AREA"),
3124
+ radar: type.startsWith("RADAR"),
3125
+ doughnut: type.startsWith("DOUGHNUT"),
3126
+ pie: type.startsWith("PIE") || type.startsWith("DOUGHNUT"),
3127
+ bar: type.startsWith("BAR_") || type.startsWith("COLUMN_"),
3128
+ horizontal: type.startsWith("BAR_"),
3129
+ grouping: type.endsWith("_100") ? "percentStacked" : type.includes("STACKED") ? "stacked" : "clustered",
3130
+ marker: !type.endsWith("NO_MARKERS"),
3131
+ smooth: type.includes("SMOOTH")
3132
+ };
3133
+ }
3134
+ function seriesXml(type, data, index, sheetName, date1904 = false) {
3135
+ const dates = data.categories?.some(dateLabel) ?? false;
3136
+ data = normalizedData(data, date1904);
3137
+ const series2 = data.series[index], v = variant(type), xColumn = v.scatter ? index * (v.bubble ? 3 : 2) : 0, yColumn = v.scatter ? xColumn + 1 : index + (data.categoryLevels?.length ?? 1);
3138
+ const sheet = sheetName === "Sheet1" ? sheetName : `'${sheetName.split("'").join("''")}'`;
3139
+ const reference = (holder, values, numeric2, col) => `<c:${holder}><c:${numeric2 ? "num" : "str"}Ref><c:f>${escape(`${sheet}!$${workbookColumn(col)}$2:$${workbookColumn(col)}$${values.length + 1}`)}</c:f><c:${numeric2 ? "num" : "str"}Cache>${numeric2 ? `<c:formatCode>${escape(holder === "cat" ? data.categoryNumberFormat ?? (dates ? "yyyy-mm-dd" : "General") : holder === "xVal" || holder === "bubbleSize" ? data.numberFormat ?? "General" : series2.numberFormat ?? data.numberFormat ?? "General")}</c:formatCode>` : ""}<c:ptCount val="${values.length}"/>${values.map((n, i) => n === null ? "" : `<c:pt idx="${i}"${(holder === "val" || holder === "yVal") && series2.pointNumberFormats?.[i] !== void 0 && series2.pointNumberFormats[i] !== null ? ` formatCode="${escape(series2.pointNumberFormats[i])}"` : ""}><c:v>${escape(String(n))}</c:v></c:pt>`).join("")}</c:${numeric2 ? "num" : "str"}Cache></c:${numeric2 ? "num" : "str"}Ref></c:${holder}>`;
3140
+ return `<c:ser><c:idx val="${index}"/><c:order val="${index}"/><c:tx><c:strRef><c:f>${escape(`${sheet}!$${workbookColumn(yColumn)}$1`)}</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>${escape(series2.name)}</c:v></c:pt></c:strCache></c:strRef></c:tx>${type.startsWith("LINE") || v.scatter && !v.bubble || v.radar && type !== "RADAR_FILLED" ? `<c:marker><c:symbol val="${(v.scatter ? v.marker : type.includes("MARKERS")) ? "circle" : "none"}"/></c:marker>` : ""}${type === "PIE_EXPLODED" || type === "DOUGHNUT_EXPLODED" ? '<c:explosion val="25"/>' : ""}${v.scatter ? reference("xVal", series2.xValues, true, xColumn) + reference("yVal", series2.values, true, yColumn) + (v.bubble ? reference("bubbleSize", series2.bubbleSizes, true, yColumn + 1) + `<c:bubble3D val="${type === "BUBBLE_THREE_D_EFFECT" ? 1 : 0}"/>` : "") : (data.categoryLevels ? `<c:cat><c:multiLvlStrRef><c:f>${escape(`${sheet}!$A$2:$${workbookColumn(data.categoryLevels.length - 1)}$${data.categoryLevels[0].length + 1}`)}</c:f><c:multiLvlStrCache><c:ptCount val="${data.categoryLevels[0].length}"/>${[
3141
+ ...data.categoryLevels
3142
+ ].reverse().map(
3143
+ (level, reversedLevel) => `<c:lvl>${level.map((value, i) => value === null || reversedLevel > 0 && i > 0 && data.categoryLevels.slice(0, data.categoryLevels.length - reversedLevel).every((ancestor) => ancestor[i] === ancestor[i - 1]) ? "" : `<c:pt idx="${i}"><c:v>${escape(value)}</c:v></c:pt>`).join("")}</c:lvl>`
3144
+ ).join("")}</c:multiLvlStrCache></c:multiLvlStrRef></c:cat>` : reference(
3145
+ "cat",
3146
+ data.categories,
3147
+ data.categories.some((x) => typeof x === "number"),
3148
+ 0
3149
+ )) + reference("val", series2.values, true, yColumn)}${type.startsWith("LINE") || v.scatter && !v.bubble ? `<c:smooth val="${v.smooth ? 1 : 0}"/>` : ""}</c:ser>`;
3150
+ }
3151
+ function titleXml(title, a, c) {
3152
+ return `<c:title xmlns:c="${c}" xmlns:a="${a}"><c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:t>${escape(title)}</a:t></a:r></a:p></c:rich></c:tx><c:overlay val="0"/></c:title>`;
3153
+ }
3154
+ function createChartXml(type, data, properties = {}, strict = false, sheetName = "Sheet1", date1904 = data.date1904 ?? false) {
3155
+ validateChartData(data, type);
3156
+ validateChartUpdate(properties);
3157
+ const c = strict ? "http://purl.oclc.org/ooxml/drawingml/chart" : "http://schemas.openxmlformats.org/drawingml/2006/chart", a = strict ? "http://purl.oclc.org/ooxml/drawingml/main" : "http://schemas.openxmlformats.org/drawingml/2006/main", r = strict ? "http://purl.oclc.org/ooxml/officeDocument/relationships" : "http://schemas.openxmlformats.org/officeDocument/2006/relationships", v = variant(type), plot = v.bubble ? "bubbleChart" : v.scatter ? "scatterChart" : v.doughnut ? "doughnutChart" : v.pie ? "pieChart" : v.bar ? "barChart" : v.area ? "areaChart" : v.radar ? "radarChart" : "lineChart";
3158
+ const axisName = (category) => category ? data.categories?.some(dateLabel) && !v.radar ? "dateAx" : "catAx" : "valAx";
3159
+ const axis = (id, cross, pos, category) => `<c:${axisName(category)}><c:axId val="${id}"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:delete val="0"/><c:axPos val="${pos}"/><c:numFmt formatCode="${escape(category ? data.categoryNumberFormat ?? (data.categories?.some(dateLabel) ? "yyyy-mm-dd" : "General") : "General")}" sourceLinked="1"/><c:majorTickMark val="none"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crossAx val="${cross}"/><c:crosses val="autoZero"/>${category ? data.categories?.some(dateLabel) && !v.radar ? '<c:auto val="1"/><c:lblOffset val="100"/><c:baseTimeUnit val="days"/>' : '<c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/>' : `<c:crossBetween val="${v.scatter ? "midCat" : "between"}"/>`}</c:${axisName(category)}>`;
3160
+ const setup = v.bubble ? "" : v.radar ? `<c:radarStyle val="${type === "RADAR_FILLED" ? "filled" : "marker"}"/>` : v.scatter ? `<c:scatterStyle val="${type === "XY_SCATTER" ? "marker" : v.smooth ? v.marker ? "smoothMarker" : "smooth" : v.marker ? "lineMarker" : "line"}"/>` : v.bar ? `<c:barDir val="${v.horizontal ? "bar" : "col"}"/><c:grouping val="${v.grouping}"/>` : v.pie ? "" : `<c:grouping val="${v.grouping === "clustered" ? "standard" : v.grouping}"/>`;
3161
+ return `<c:chartSpace xmlns:c="${c}" xmlns:a="${a}" xmlns:r="${r}">${date1904 ? '<c:date1904 val="1"/>' : ""}${properties.style === void 0 ? "" : `<c:style val="${properties.style}"/>`}<c:chart>${properties.title === void 0 ? "" : titleXml(properties.title, a, c)}<c:autoTitleDeleted val="${properties.title === void 0 ? 1 : 0}"/><c:plotArea><c:layout/><c:${plot}>${setup}<c:varyColors val="${v.pie ? 1 : 0}"/>${data.series.map((_, i) => seriesXml(type, data, i, sheetName, date1904)).join("")}${v.bar ? `<c:gapWidth val="150"/>${v.grouping !== "clustered" ? '<c:overlap val="100"/>' : ""}` : ""}${v.bubble ? '<c:bubbleScale val="100"/><c:showNegBubbles val="0"/>' : ""}${v.doughnut ? '<c:firstSliceAng val="0"/><c:holeSize val="50"/>' : v.pie ? '<c:firstSliceAng val="0"/>' : '<c:axId val="1"/><c:axId val="2"/>'}</c:${plot}>${v.pie ? "" : axis(1, 2, v.horizontal ? "l" : "b", !v.scatter) + axis(2, 1, v.horizontal ? "b" : "l", false)}</c:plotArea>${properties.legend ? '<c:legend><c:legendPos val="r"/><c:overlay val="0"/></c:legend>' : ""}<c:plotVisOnly val="1"/><c:dispBlanksAs val="gap"/></c:chart><c:externalData r:id="rId1"><c:autoUpdate val="0"/></c:externalData></c:chartSpace>`;
3162
+ }
3163
+ function validateAddChartOptions(options) {
3164
+ object(options, [
3165
+ "slide",
3166
+ "type",
3167
+ "data",
3168
+ "style",
3169
+ "title",
3170
+ "legend",
3171
+ "left",
3172
+ "top",
3173
+ "width",
3174
+ "height"
3175
+ ]);
3176
+ const { slide, type, ...update } = options;
3177
+ validateChartUpdate(update);
3178
+ validateChartData(options.data, type);
3179
+ if (!Number.isSafeInteger(slide) || slide < 1)
3180
+ invalid("Chart creation requires a positive slide position.");
3181
+ for (const key of ["left", "top", "width", "height"])
3182
+ if (options[key] === void 0) invalid("Chart creation requires explicit geometry.");
3183
+ }
3184
+ async function addChart(input, options, context) {
3185
+ validateAddChartOptions(options);
3186
+ options = structuredClone(options);
3187
+ const state2 = await loadShared(input, context);
3188
+ const workbooks = /* @__PURE__ */ new Map();
3189
+ insertChartIntoState(state2, options, context, (part, members) => {
3190
+ workbooks.set(part, members);
3191
+ });
3192
+ for (const [part, members] of workbooks)
3193
+ state2.changes.set(part, await writePackageArchive(members, context, { compression: "store" }));
3194
+ const target = state2.index.inventory.slides.find((slide) => slide.position === options.slide);
3195
+ return (await state2.finish(target.part, [options.slide])).bytes;
3196
+ }
3197
+ function insertChartIntoState(original, options, context, registerWorkbook) {
3198
+ validateAddChartOptions(options);
3199
+ if (context.signal?.aborted)
3200
+ throw new OfficeError("cancelled", "Chart insertion cancelled.", "mutate");
3201
+ options = structuredClone(options);
3202
+ const { slide, type, ...update } = options;
3203
+ const members = prepareChartWorkbookMembers(
3204
+ normalizedData(options.data),
3205
+ variant(type).scatter,
3206
+ context,
3207
+ { date1904: options.data.date1904 ?? false }
3208
+ );
3209
+ const changes = new Map(original.changes);
3210
+ const s = {
3211
+ ...original,
3212
+ changes,
3213
+ doc: (part) => parseXmlPart(changes.get(part) ?? original.reader.get(part), context.xmlLimits),
3214
+ save: (part, xml2) => {
3215
+ changes.set(part, xml2.bytes());
3216
+ }
3217
+ };
3218
+ const target = s.index.inventory.slides.find((x) => x.position === slide);
3219
+ if (!target) throw new SelectionError("missing-selection");
3220
+ const doc = s.doc(target.part), tree = required(required(doc.root, "cSld"), "spTree");
3221
+ const id = new ShapeIdAllocator(() => doc).next();
3222
+ let n = 1;
3223
+ while ([...s.reader.names, ...s.changes.keys()].some(
3224
+ (x) => x.toLowerCase() === `/ppt/charts/chart${n}.xml` || x.toLowerCase() === `/ppt/embeddings/chart${n}.xlsx` || x.toLowerCase() === `/ppt/charts/_rels/chart${n}.xml.rels`
3225
+ ))
3226
+ n++;
3227
+ const chartPart = `/ppt/charts/chart${n}.xml`, workbookPart = `/ppt/embeddings/chart${n}.xlsx`, relns = "http://schemas.openxmlformats.org/package/2006/relationships", slideRelPart = relPart(target.part), rels = s.reader.names.includes(slideRelPart) || s.changes.has(slideRelPart) ? s.doc(slideRelPart) : parseXmlPart(
3228
+ new TextEncoder().encode(`<Relationships xmlns="${relns}"/>`),
3229
+ context.xmlLimits
3230
+ ), rid = nextRel(rels);
3231
+ s.save(
3232
+ slideRelPart,
3233
+ rels.spliceChildren(rels.root, rels.root.children.length, 0, [
3234
+ `<Relationship xmlns="${relns}" Id="${rid}" Type="${s.r}/chart" Target="${escape(relativePartReference(chartPart, target.part.slice(0, target.part.lastIndexOf("/"))))}"/>`
3235
+ ])
3236
+ );
3237
+ const chartBytes = new TextEncoder().encode(
3238
+ createChartXml(type, options.data, update, s.p.includes("purl.oclc.org"))
3239
+ );
3240
+ parseXmlPart(chartBytes, context.xmlLimits);
3241
+ s.changes.set(chartPart, chartBytes);
3242
+ s.changes.set(workbookPart, new Uint8Array());
3243
+ s.changes.set(
3244
+ relPart(chartPart),
3245
+ new TextEncoder().encode(
3246
+ `<Relationships xmlns="${relns}"><Relationship Id="rId1" Type="${s.r}/package" Target="../embeddings/chart${n}.xlsx"/></Relationships>`
3247
+ )
3248
+ );
3249
+ const types = s.doc("/[Content_Types].xml");
3250
+ s.save(
3251
+ "/[Content_Types].xml",
3252
+ types.spliceChildren(types.root, types.root.children.length, 0, [
3253
+ `<Override xmlns="${types.root.name.namespace}" PartName="${chartPart}" ContentType="application/vnd.openxmlformats-officedocument.drawingml.chart+xml"/>`,
3254
+ `<Override xmlns="${types.root.name.namespace}" PartName="${workbookPart}" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/>`
3255
+ ])
3256
+ );
3257
+ const c = s.p.includes("purl.oclc.org") ? "http://purl.oclc.org/ooxml/drawingml/chart" : "http://schemas.openxmlformats.org/drawingml/2006/chart";
3258
+ const xml = `<p:graphicFrame xmlns:p="${s.p}" xmlns:a="${s.a}" xmlns:r="${s.r}" xmlns:c="${c}"><p:nvGraphicFramePr><p:cNvPr id="${id}" name="Chart ${id}"/><p:cNvGraphicFramePr/><p:nvPr/></p:nvGraphicFramePr><p:xfrm><a:off x="${options.left}" y="${options.top}"/><a:ext cx="${options.width}" cy="${options.height}"/></p:xfrm><a:graphic><a:graphicData uri="${c}"><c:chart r:id="${rid}"/></a:graphicData></a:graphic></p:graphicFrame>`;
3259
+ const ext = child(tree, "extLst");
3260
+ s.save(
3261
+ target.part,
3262
+ doc.spliceChildren(tree, ext ? tree.children.indexOf(ext) : tree.children.length, 0, [xml])
3263
+ );
3264
+ registerWorkbook(workbookPart, members);
3265
+ for (const [part, bytes] of changes)
3266
+ if (original.changes.get(part) !== bytes) original.changes.set(part, bytes);
3267
+ return id;
3268
+ }
3269
+ function replaceChild(doc, parent, name, xml) {
3270
+ const old = child(parent, name), order2 = parent.name.localName === "chartSpace" ? [
3271
+ "date1904",
3272
+ "lang",
3273
+ "roundedCorners",
3274
+ "style",
3275
+ "clrMapOvr",
3276
+ "pivotSource",
3277
+ "protection",
3278
+ "chart",
3279
+ "spPr",
3280
+ "txPr",
3281
+ "externalData",
3282
+ "printSettings",
3283
+ "userShapes",
3284
+ "extLst"
3285
+ ] : [
3286
+ "title",
3287
+ "autoTitleDeleted",
3288
+ "pivotFmts",
3289
+ "view3D",
3290
+ "floor",
3291
+ "sideWall",
3292
+ "backWall",
3293
+ "plotArea",
3294
+ "legend",
3295
+ "plotVisOnly",
3296
+ "dispBlanksAs",
3297
+ "showDLblsOverMax",
3298
+ "extLst"
3299
+ ];
3300
+ const following = parent.children.find(
3301
+ (n) => n.name.namespace === parent.name.namespace && order2.indexOf(n.name.localName) > order2.indexOf(name)
3302
+ );
3303
+ return doc.spliceChildren(
3304
+ parent,
3305
+ old ? parent.children.indexOf(old) : following ? parent.children.indexOf(following) : parent.children.length,
3306
+ old ? 1 : 0,
3307
+ xml === void 0 ? [] : [xml]
3308
+ );
3309
+ }
3310
+ function readChartType(doc, firstPlot = false) {
3311
+ const info = inspectChart(doc);
3312
+ if (!info.plots.length || !firstPlot && info.plots.length !== 1)
3313
+ unsupported3("Combination chart data is preserve-only.");
3314
+ const plot = info.plots[0], group = plot.properties.grouping, suffix = group === "percentStacked" ? "_STACKED_100" : group === "stacked" ? "_STACKED" : "";
3315
+ if (plot.type === "barChart")
3316
+ return `${plot.properties.barDir === "bar" ? "BAR" : "COLUMN"}${suffix || "_CLUSTERED"}`;
3317
+ if (plot.type === "lineChart") {
3318
+ const marker = plot.series[0]?.marker?.children.find((n) => n.name === "symbol")?.attributes.val;
3319
+ return `LINE${marker && marker !== "none" ? "_MARKERS" : ""}${suffix}`;
3320
+ }
3321
+ if (plot.type === "pieChart" || plot.type === "doughnutChart") {
3322
+ const plotNode = required(required(required(doc.root, "chart"), "plotArea"), plot.type);
3323
+ const exploded = plotNode.children.some((series2) => {
3324
+ const explosion = series2.name.localName === "ser" && child(series2, "explosion");
3325
+ return explosion && Number(attr(explosion, "val") ?? 0) > 0;
3326
+ });
3327
+ return `${plot.type === "pieChart" ? "PIE" : "DOUGHNUT"}${exploded ? "_EXPLODED" : ""}`;
3328
+ }
3329
+ if (plot.type === "areaChart") return `AREA${suffix}`;
3330
+ if (plot.type === "radarChart") {
3331
+ if (plot.properties.radarStyle === "filled") return "RADAR_FILLED";
3332
+ const marker = plot.series[0]?.marker?.children.find((node) => node.name === "symbol")?.attributes.val;
3333
+ return marker === "none" ? "RADAR" : "RADAR_MARKERS";
3334
+ }
3335
+ if (plot.type === "bubbleChart") {
3336
+ const chart = required(required(doc.root, "chart"), "plotArea");
3337
+ const series2 = required(chart, "bubbleChart").children.find(
3338
+ (node) => node.name.namespace === doc.root.name.namespace && node.name.localName === "ser"
3339
+ );
3340
+ const effect = series2 && child(series2, "bubble3D");
3341
+ return effect && ["1", "true"].includes(attr(effect, "val") ?? "") ? "BUBBLE_THREE_D_EFFECT" : "BUBBLE";
3342
+ }
3343
+ if (plot.type === "scatterChart") {
3344
+ const types = {
3345
+ marker: "XY_SCATTER",
3346
+ lineMarker: "XY_SCATTER_LINES",
3347
+ line: "XY_SCATTER_LINES_NO_MARKERS",
3348
+ smoothMarker: "XY_SCATTER_SMOOTH",
3349
+ smooth: "XY_SCATTER_SMOOTH_NO_MARKERS"
3350
+ };
3351
+ const type = types[plot.properties.scatterStyle ?? ""];
3352
+ if (!type) unsupported3("Unsupported scatter style cannot be reconstructed.");
3353
+ return type;
3354
+ }
3355
+ return unsupported3("Chart data reconstruction is unsupported for this plot.");
3356
+ }
3357
+ function applyChartAppearance(doc, update) {
3358
+ if (update.style !== void 0 && update.style !== null && (!Number.isInteger(update.style) || update.style < 1 || update.style > 48))
3359
+ invalid("Chart style requires an integer from 1 to 48.");
3360
+ if (update.legend !== void 0 && typeof update.legend !== "boolean")
3361
+ invalid("Chart legend requires a boolean.");
3362
+ const ns2 = doc.root.name.namespace;
3363
+ if (update.style !== void 0)
3364
+ doc = replaceChild(
3365
+ doc,
3366
+ doc.root,
3367
+ "style",
3368
+ update.style === null ? void 0 : `<c:style xmlns:c="${ns2}" val="${update.style}"/>`
3369
+ );
3370
+ if (update.legend !== void 0 && (!update.legend || !child(required(doc.root, "chart"), "legend"))) {
3371
+ doc = replaceChild(
3372
+ doc,
3373
+ required(doc.root, "chart"),
3374
+ "legend",
3375
+ update.legend ? `<c:legend xmlns:c="${ns2}"><c:legendPos val="r"/><c:overlay val="0"/></c:legend>` : void 0
3376
+ );
3377
+ }
3378
+ return doc;
3379
+ }
3380
+ function replaceChartData(doc, data, context, source, metadata) {
3381
+ const ns2 = doc.root.name.namespace;
3382
+ const type = readChartType(doc);
3383
+ validateChartData(data, type);
3384
+ const inspection = inspectChart(doc);
3385
+ if (inspection.unsupported.length)
3386
+ unsupported3("Unknown chart extensions prevent data replacement.");
3387
+ if (data.date1904 !== void 0 && data.date1904 !== metadata.date1904)
3388
+ unsupported3("Chart replacement must retain the existing date system.");
3389
+ const epoch = child(doc.root, "date1904");
3390
+ const epochValue = epoch ? attr(epoch, "val") ?? "1" : "0";
3391
+ if (!["0", "1", "false", "true"].includes(epochValue) || ["1", "true"].includes(epochValue) !== metadata.date1904)
3392
+ unsupported3("Chart and workbook date systems must agree.");
3393
+ const ranges = [];
3394
+ let referenceCount = 0;
3395
+ for (const series3 of inspection.plots[0].series) {
3396
+ const v = variant(type);
3397
+ const channels = [
3398
+ series3.nameSource,
3399
+ v.scatter ? series3.xValues : series3.categories,
3400
+ v.scatter ? series3.yValues : series3.values,
3401
+ ...v.bubble ? [series3.bubbleSizes] : []
3402
+ ];
3403
+ for (const [position, source2] of channels.entries()) {
3404
+ if (!source2 || source2.authority !== "referenced" || !source2.cached || !source2.formula)
3405
+ unsupported3("Chart data must have simple owned cached references.");
3406
+ const count = Number(source2.pointCount);
3407
+ const range = chartWorkbookRange(source2.formula, metadata.sheetName);
3408
+ const width = position === 1 && !v.scatter ? series3.categories?.levels.length || 1 : 1;
3409
+ if (!Number.isSafeInteger(count) || count < 1 || position === 0 && count !== 1 || range.end.row - range.start.row + 1 !== count || range.end.column - range.start.column + 1 !== width)
3410
+ unsupported3("Chart cache cardinality must match its simple worksheet range.");
3411
+ ranges.push(range);
3412
+ referenceCount++;
3413
+ if (v.scatter && position !== 0 && range.start.row > 1)
3414
+ ranges.push({
3415
+ start: { ...range.start, row: range.start.row - 1 },
3416
+ end: { ...range.start, row: range.start.row - 1 }
3417
+ });
3418
+ }
3419
+ }
3420
+ let formulas = 0;
3421
+ const countFormulas = (node) => {
3422
+ if (node.name.namespace === ns2 && node.name.localName === "f") formulas++;
3423
+ node.children.forEach(countFormulas);
3424
+ };
3425
+ countFormulas(doc.root);
3426
+ if (formulas !== referenceCount)
3427
+ unsupported3("Dependent chart formulas prevent data replacement.");
3428
+ validateWorkbookOwnership(metadata, ranges);
3429
+ const plot = child(required(doc.root, "chart"), "plotArea").children.find(
3430
+ (x) => x.name.namespace === ns2 && x.name.localName === inspection.plots[0].type
3431
+ );
3432
+ const series2 = plot.children.filter((x) => x.name.namespace === ns2 && x.name.localName === "ser");
3433
+ const identities = ["idx", "order"].map(
3434
+ (name) => series2.map((node) => Number(attr(required(node, name), "val")))
3435
+ );
3436
+ if (identities.some(
3437
+ (values) => values.some((value) => !Number.isSafeInteger(value) || value < 0 || value > 4294967295) || new Set(values).size !== values.length
3438
+ ))
3439
+ unsupported3("Chart series identities must be unique unsigned integers.");
3440
+ const ordered = series2.map((node, index) => ({ node, order: identities[1][index] })).sort((left, right) => left.order - right.order);
3441
+ if (ordered.some((item, index) => item.node !== series2[index])) {
3442
+ let position = 0;
3443
+ doc = doc.reorderChildren(
3444
+ plot,
3445
+ plot.children.map(
3446
+ (node) => node.name.namespace === ns2 && node.name.localName === "ser" ? ordered[position++].node : node
3447
+ )
3448
+ );
3449
+ }
3450
+ const nextIdentity = identities.map((values) => Math.max(-1, ...values) + 1);
3451
+ for (let index = 0; index < data.series.length; index++) {
3452
+ let generated = parseXmlPart(
3453
+ new TextEncoder().encode(
3454
+ `<c:ser xmlns:c="${ns2}">${seriesXml(type, data, index, metadata.sheetName, metadata.date1904).slice(7, -8)}</c:ser>`
3455
+ ),
3456
+ context.xmlLimits
3457
+ );
3458
+ if (index >= series2.length) {
3459
+ for (const [position, name] of ["idx", "order"].entries()) {
3460
+ const value = nextIdentity[position]++;
3461
+ if (value > 4294967295) unsupported3("Chart series identity limit exceeded.");
3462
+ generated = generated.merge(required(generated.root, name), {
3463
+ attributes: [{ namespace: "", localName: "val", value: String(value) }]
3464
+ });
3465
+ }
3466
+ const currentPlot = required(required(doc.root, "chart"), "plotArea").children.find(
3467
+ (x) => x.name.namespace === ns2 && x.name.localName === plot.name.localName
3468
+ );
3469
+ const currentSeries = currentPlot.children.filter(
3470
+ (x) => x.name.namespace === ns2 && x.name.localName === "ser"
3471
+ );
3472
+ const insertion = currentSeries.length ? currentPlot.children.indexOf(currentSeries[currentSeries.length - 1]) + 1 : currentPlot.children.length;
3473
+ doc = doc.spliceChildren(currentPlot, insertion, 0, [generated.markup(generated.root, true)]);
3474
+ continue;
3475
+ }
3476
+ for (const name of [
3477
+ "tx",
3478
+ variant(type).scatter ? "xVal" : "cat",
3479
+ variant(type).scatter ? "yVal" : "val",
3480
+ ...variant(type).bubble ? ["bubbleSize"] : []
3481
+ ]) {
3482
+ const fresh = child(generated.root, name);
3483
+ const updatedPlot = required(required(doc.root, "chart"), "plotArea").children.find(
3484
+ (x) => x.name.namespace === ns2 && x.name.localName === plot.name.localName
3485
+ ), updated = updatedPlot.children.filter(
3486
+ (x) => x.name.namespace === ns2 && x.name.localName === "ser"
3487
+ )[index];
3488
+ const old = child(updated, name);
3489
+ if (!old) unsupported3("Missing chart data structure.");
3490
+ doc = doc.spliceChildren(updated, updated.children.indexOf(old), 1, [
3491
+ generated.markup(fresh, true)
3492
+ ]);
3493
+ }
3494
+ }
3495
+ for (let index = series2.length - 1; index >= data.series.length; index--) {
3496
+ const currentPlot = required(required(doc.root, "chart"), "plotArea").children.find(
3497
+ (x) => x.name.namespace === ns2 && x.name.localName === plot.name.localName
3498
+ );
3499
+ const current = currentPlot.children.filter(
3500
+ (x) => x.name.namespace === ns2 && x.name.localName === "ser"
3501
+ )[index];
3502
+ doc = doc.spliceChildren(currentPlot, currentPlot.children.indexOf(current), 1, []);
3503
+ }
3504
+ const members = prepareChartWorkbookMembers(
3505
+ normalizedData(data, metadata.date1904),
3506
+ variant(type).scatter,
3507
+ context,
3508
+ { ...source ? { source } : {}, date1904: metadata.date1904 }
3509
+ );
3510
+ return { doc, members };
3511
+ }
3512
+ async function setCharts(input, selection, update, context) {
3513
+ object(selection, ["scope", "slide", "shape", "select", "all", "allowEmpty"]);
3514
+ validateSelection(selection, "set");
3515
+ validateChartUpdate(update);
3516
+ if (selection.scope !== void 0 && selection.scope !== "slides")
3517
+ throw new SelectionError("invalid-selection");
3518
+ selection = { ...selection };
3519
+ update = structuredClone(update);
3520
+ const s = await loadShared(input, context), records = await readCharts(
3521
+ s.source,
3522
+ {
3523
+ ...selection.scope !== void 0 ? { scope: selection.scope } : {},
3524
+ ...selection.slide !== void 0 ? { slide: selection.slide } : {},
3525
+ ...selection.shape !== void 0 ? { shape: selection.shape } : {},
3526
+ ...selection.select !== void 0 ? { select: selection.select } : {}
3527
+ },
3528
+ context
3529
+ );
3530
+ if (!records.length && !selection.allowEmpty) throw new SelectionError("missing-selection");
3531
+ if (records.length > 1 && !selection.all) throw new SelectionError("ambiguous-selection");
3532
+ for (const record of records) {
3533
+ let doc = s.doc(record.chartPart);
3534
+ const ns2 = doc.root.name.namespace;
3535
+ if (![
3536
+ "http://schemas.openxmlformats.org/drawingml/2006/chart",
3537
+ "http://purl.oclc.org/ooxml/drawingml/chart"
3538
+ ].includes(ns2))
3539
+ unsupported3("Extended chart editing is unsupported.");
3540
+ if (update.style !== void 0 && doc.root.children.some(
3541
+ (n) => n.name.namespace === "http://schemas.openxmlformats.org/markup-compatibility/2006" && n.name.localName === "AlternateContent"
3542
+ ))
3543
+ unsupported3("Conditional chart style dependencies prevent an unambiguous style edit.");
3544
+ if (update.data !== void 0) {
3545
+ const links = record.links.filter((x) => x.role === "workbook");
3546
+ if (links.length !== 1 || links[0].external || !links[0].targetPart || !links[0].authoritative)
3547
+ unsupported3("Data replacement requires one owned embedded workbook.");
3548
+ const workbookPart = links[0].targetPart;
3549
+ if (s.index.inventory.relationships.filter((x) => x.targetPart === workbookPart).length !== 1)
3550
+ unsupported3("Shared chart workbook ownership is ambiguous.");
3551
+ const workbook = await readPackage(s.reader.get(workbookPart), context);
3552
+ const replacement = replaceChartData(
3553
+ doc,
3554
+ update.data,
3555
+ context,
3556
+ workbook,
3557
+ inspectWorkbook(workbook, context)
3558
+ );
3559
+ doc = replacement.doc;
3560
+ s.changes.set(workbookPart, await writePackageArchive(replacement.members, context, { compression: "store" }));
3561
+ }
3562
+ if (update.title !== void 0) {
3563
+ const title = child(required(doc.root, "chart"), "title");
3564
+ const replacement = parseXmlPart(
3565
+ new TextEncoder().encode(titleXml(update.title, s.a, ns2)),
3566
+ context.xmlLimits
3567
+ );
3568
+ if (title) {
3569
+ const text = child(title, "tx");
3570
+ const rich = text && child(text, "rich");
3571
+ if (rich) doc = applyFrameFormatting(doc, rich, { text: update.title });
3572
+ else
3573
+ doc = doc.spliceChildren(title, text ? title.children.indexOf(text) : 0, text ? 1 : 0, [
3574
+ replacement.markup(required(replacement.root, "tx"), true)
3575
+ ]);
3576
+ } else {
3577
+ doc = replaceChild(
3578
+ doc,
3579
+ required(doc.root, "chart"),
3580
+ "title",
3581
+ replacement.markup(replacement.root, true)
3582
+ );
3583
+ }
3584
+ doc = replaceChild(
3585
+ doc,
3586
+ required(doc.root, "chart"),
3587
+ "autoTitleDeleted",
3588
+ `<c:autoTitleDeleted xmlns:c="${ns2}" val="0"/>`
3589
+ );
3590
+ }
3591
+ doc = applyChartAppearance(doc, update);
3592
+ if (update.objects !== void 0) doc = applyChartObjectUpdates(doc, update.objects);
3593
+ s.save(record.chartPart, doc);
3594
+ const geometry = Object.fromEntries(
3595
+ Object.entries(update).filter(([k]) => ["left", "top", "width", "height"].includes(k))
3596
+ );
3597
+ if (Object.keys(geometry).length) {
3598
+ const slideDoc = s.doc(record.part);
3599
+ s.save(
3600
+ record.part,
3601
+ applyShapeUpdate(slideDoc, nodeFor(slideDoc.root, record.shapeId), geometry)
3602
+ );
3603
+ }
3604
+ }
3605
+ return (await s.finish(
3606
+ records[0]?.chartPart ?? s.main,
3607
+ s.index.inventory.slides.filter((slide) => records.some((r) => r.part === slide.part)).map((slide) => slide.position)
3608
+ )).bytes;
3609
+ }
3610
+
3611
+ export {
3612
+ ChartFormat,
3613
+ ChartSequence,
3614
+ ChartTitle,
3615
+ AxisTitle,
3616
+ Legend,
3617
+ TickLabels,
3618
+ MajorGridlines,
3619
+ BaseAxis,
3620
+ CategoryAxis,
3621
+ DateAxis,
3622
+ ValueAxis,
3623
+ DataLabels,
3624
+ DataLabel,
3625
+ Marker,
3626
+ Point,
3627
+ BaseSeries,
3628
+ Series,
3629
+ CategorySeries,
3630
+ AreaSeries,
3631
+ PieSeries,
3632
+ BarSeries,
3633
+ RadarSeries,
3634
+ LineSeries,
3635
+ XySeries,
3636
+ BubbleSeries,
3637
+ SeriesCollection,
3638
+ Category,
3639
+ CategoryLevel,
3640
+ Categories,
3641
+ BasePlot,
3642
+ AreaPlot,
3643
+ Area3DPlot,
3644
+ LinePlot,
3645
+ PiePlot,
3646
+ DoughnutPlot,
3647
+ RadarPlot,
3648
+ XyPlot,
3649
+ BarPlot,
3650
+ BubblePlot,
3651
+ Plots,
3652
+ inspectWorkbook,
3653
+ chartTypes,
3654
+ validateChartData,
3655
+ validateChartUpdate,
3656
+ createChartXml,
3657
+ addChart,
3658
+ insertChartIntoState,
3659
+ readChartType,
3660
+ applyChartAppearance,
3661
+ replaceChartData,
3662
+ setCharts,
3663
+ CategoryChartData,
3664
+ XyChartData,
3665
+ BubbleChartData,
3666
+ toChartData,
3667
+ chart_data_model_exports,
3668
+ Chart
3669
+ };