ooxml-core 1.32.1 → 1.34.0

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 (595) hide show
  1. package/dist/PptxHandler-5UDSMCBG.cjs +14 -0
  2. package/dist/PptxHandler-TTRTAQAR.mjs +5 -0
  3. package/dist/PptxHandler-XCYX5DVX.mjs +7 -0
  4. package/dist/{PresentationBuilder-5NFBUP7Y.cjs → PresentationBuilder-HA56ZY23.cjs} +6 -5
  5. package/dist/{PresentationBuilder-S6HXHKEJ.mjs → PresentationBuilder-IVLUEB4K.mjs} +4 -4
  6. package/dist/{PresentationBuilder-3CH5TR4W.mjs → PresentationBuilder-JBTNOIL7.mjs} +3 -2
  7. package/dist/automation/index.cjs +47133 -42384
  8. package/dist/automation/index.mjs +47133 -42384
  9. package/dist/chart/funnel-geometry.d.ts +1 -1
  10. package/dist/chart/funnel-geometry.d.ts.map +1 -1
  11. package/dist/chart/index.cjs +5743 -3820
  12. package/dist/chart/index.mjs +5736 -3821
  13. package/dist/chart/region-map/alias.d.ts +12 -0
  14. package/dist/chart/region-map/alias.d.ts.map +1 -0
  15. package/dist/chart/region-map/cache.d.ts +20 -0
  16. package/dist/chart/region-map/cache.d.ts.map +1 -0
  17. package/dist/chart/region-map/colors.d.ts +4 -0
  18. package/dist/chart/region-map/colors.d.ts.map +1 -0
  19. package/dist/chart/region-map/data.d.ts +45 -0
  20. package/dist/chart/region-map/data.d.ts.map +1 -0
  21. package/dist/chart/region-map/geographic-projection.d.ts +4 -0
  22. package/dist/chart/region-map/geographic-projection.d.ts.map +1 -0
  23. package/dist/chart/region-map/geometry.d.ts +10 -0
  24. package/dist/chart/region-map/geometry.d.ts.map +1 -0
  25. package/dist/chart/region-map/index.cjs +892 -0
  26. package/dist/chart/region-map/index.d.ts +12 -0
  27. package/dist/chart/region-map/index.d.ts.map +1 -0
  28. package/dist/chart/region-map/index.mjs +870 -0
  29. package/dist/chart/region-map/projection.d.ts +19 -0
  30. package/dist/chart/region-map/projection.d.ts.map +1 -0
  31. package/dist/chart/region-map/types.d.ts +39 -0
  32. package/dist/chart/region-map/types.d.ts.map +1 -0
  33. package/dist/chart/region-map/value-color-positions.d.ts +4 -0
  34. package/dist/chart/region-map/value-color-positions.d.ts.map +1 -0
  35. package/dist/chart/region-map/value-colors.d.ts +4 -0
  36. package/dist/chart/region-map/value-colors.d.ts.map +1 -0
  37. package/dist/chart/region-map/world-regions.d.ts +22 -0
  38. package/dist/chart/region-map/world-regions.d.ts.map +1 -0
  39. package/dist/chart/render/chart-3d-camera.d.ts +26 -0
  40. package/dist/chart/render/chart-3d-camera.d.ts.map +1 -0
  41. package/dist/chart/render/chart-3d-layout.d.ts +27 -0
  42. package/dist/chart/render/chart-3d-layout.d.ts.map +1 -0
  43. package/dist/chart/render/chart-3d-marks.d.ts +10 -0
  44. package/dist/chart/render/chart-3d-marks.d.ts.map +1 -0
  45. package/dist/chart/render/chart-3d-mesh.d.ts +32 -0
  46. package/dist/chart/render/chart-3d-mesh.d.ts.map +1 -0
  47. package/dist/chart/render/chart-3d-pie.d.ts +16 -0
  48. package/dist/chart/render/chart-3d-pie.d.ts.map +1 -0
  49. package/dist/chart/render/chart-3d-projection.d.ts +37 -0
  50. package/dist/chart/render/chart-3d-projection.d.ts.map +1 -0
  51. package/dist/chart/render/chart-3d-scene.d.ts +9 -0
  52. package/dist/chart/render/chart-3d-scene.d.ts.map +1 -0
  53. package/dist/chart/render/chart-3d-shading.d.ts +10 -0
  54. package/dist/chart/render/chart-3d-shading.d.ts.map +1 -0
  55. package/dist/chart/render/chart-3d-surface.d.ts +5 -0
  56. package/dist/chart/render/chart-3d-surface.d.ts.map +1 -0
  57. package/dist/chart/render/chart-3d-svg.d.ts +7 -0
  58. package/dist/chart/render/chart-3d-svg.d.ts.map +1 -0
  59. package/dist/chart/render/chart-3d-walls.d.ts +13 -0
  60. package/dist/chart/render/chart-3d-walls.d.ts.map +1 -0
  61. package/dist/chart/render/chart-svg-funnel.d.ts.map +1 -1
  62. package/dist/chart/render/chart-svg-region-map.d.ts +4 -0
  63. package/dist/chart/render/chart-svg-region-map.d.ts.map +1 -0
  64. package/dist/chart/render/chart-svg-text-metrics.d.ts +2 -0
  65. package/dist/chart/render/chart-svg-text-metrics.d.ts.map +1 -1
  66. package/dist/chart/render/chart-svg.d.ts.map +1 -1
  67. package/dist/chart/render/chart-view.d.ts +5 -1
  68. package/dist/chart/render/chart-view.d.ts.map +1 -1
  69. package/dist/chart/render/index.d.ts +5 -0
  70. package/dist/chart/render/index.d.ts.map +1 -1
  71. package/dist/chart/render/render-space.d.ts.map +1 -1
  72. package/dist/chart/render/summary-ex-formatting.d.ts +5 -0
  73. package/dist/chart/render/summary-ex-formatting.d.ts.map +1 -0
  74. package/dist/chart/render/summary-ex-series.d.ts.map +1 -1
  75. package/dist/chart/render/summary-from-chartex.d.ts.map +1 -1
  76. package/dist/chart/render/summary-from-space.d.ts.map +1 -1
  77. package/dist/chart/render/summary.d.ts +5 -1
  78. package/dist/chart/render/summary.d.ts.map +1 -1
  79. package/dist/chunk-2N7RZQLC.mjs +8 -0
  80. package/dist/{chunk-Q6NM64J2.cjs → chunk-A27O7M5X.cjs} +4938 -1083
  81. package/dist/{chunk-4R65YYAD.mjs → chunk-EGBNPVBA.mjs} +6256 -2277
  82. package/dist/{chunk-3H5UAJB3.mjs → chunk-GNGL4BO7.mjs} +935 -568
  83. package/dist/chunk-LSO5SSFX.mjs +112 -0
  84. package/dist/chunk-MB3TYNMV.mjs +28 -0
  85. package/dist/{chunk-N6424WKA.mjs → chunk-MK2IBZU6.mjs} +1 -1
  86. package/dist/{chunk-X6VNUBES.cjs → chunk-PA5ADSTX.cjs} +2124 -1791
  87. package/dist/{chunk-IOTGRLJH.mjs → chunk-RI56PFGL.mjs} +933 -600
  88. package/dist/{chunk-NAWLWKOJ.mjs → chunk-RPJHMPEL.mjs} +2 -2
  89. package/dist/{chunk-UYMSFJQZ.mjs → chunk-TJXK4D4U.mjs} +5 -5
  90. package/dist/{chunk-O7SVHLD7.mjs → chunk-UQMAPY6D.mjs} +4901 -1077
  91. package/dist/{chunk-54S5A5PZ.mjs → chunk-VDUNZTJC.mjs} +36 -1
  92. package/dist/chunk-XF6ZRA2D.cjs +120 -0
  93. package/dist/crypto/index.cjs +23 -15
  94. package/dist/crypto/index.mjs +23 -15
  95. package/dist/diagram/drawing-resolve.d.ts.map +1 -1
  96. package/dist/diagram/drawing-view.d.ts +6 -0
  97. package/dist/diagram/drawing-view.d.ts.map +1 -1
  98. package/dist/diagram/engine/engine-to-result.d.ts.map +1 -1
  99. package/dist/diagram/index.cjs +786 -145
  100. package/dist/diagram/index.d.ts +1 -0
  101. package/dist/diagram/index.d.ts.map +1 -1
  102. package/dist/diagram/index.mjs +783 -147
  103. package/dist/diagram/layout/smartart-layout-types.d.ts +7 -0
  104. package/dist/diagram/layout/smartart-layout-types.d.ts.map +1 -1
  105. package/dist/diagram/layout-preview.d.ts +4 -0
  106. package/dist/diagram/layout-preview.d.ts.map +1 -1
  107. package/dist/diagram/layout-role-style.d.ts +4 -0
  108. package/dist/diagram/layout-role-style.d.ts.map +1 -0
  109. package/dist/diagram/load.d.ts.map +1 -1
  110. package/dist/diagram/picture-layout.d.ts +23 -0
  111. package/dist/diagram/picture-layout.d.ts.map +1 -0
  112. package/dist/diagram/types.d.ts +6 -0
  113. package/dist/diagram/types.d.ts.map +1 -1
  114. package/dist/diagram/write/cache.d.ts +1 -0
  115. package/dist/diagram/write/cache.d.ts.map +1 -1
  116. package/dist/digest/crc32.d.ts +2 -0
  117. package/dist/digest/crc32.d.ts.map +1 -0
  118. package/dist/digest/index.cjs +11 -0
  119. package/dist/digest/index.d.ts +1 -0
  120. package/dist/digest/index.d.ts.map +1 -1
  121. package/dist/digest/index.mjs +11 -1
  122. package/dist/docx/block-parser.d.ts.map +1 -1
  123. package/dist/docx/diagram-cache.d.ts.map +1 -1
  124. package/dist/docx/diagram-save.d.ts.map +1 -1
  125. package/dist/docx/drawing.d.ts.map +1 -1
  126. package/dist/docx/embedded.cjs +1394 -366
  127. package/dist/docx/embedded.mjs +1394 -366
  128. package/dist/docx/find-pattern.d.ts +33 -0
  129. package/dist/docx/find-pattern.d.ts.map +1 -0
  130. package/dist/docx/find-replacement.d.ts +16 -0
  131. package/dist/docx/find-replacement.d.ts.map +1 -0
  132. package/dist/docx/find-syntax.d.ts +13 -0
  133. package/dist/docx/find-syntax.d.ts.map +1 -0
  134. package/dist/docx/find-wildcards.d.ts +8 -0
  135. package/dist/docx/find-wildcards.d.ts.map +1 -0
  136. package/dist/docx/form-field-model.d.ts +39 -0
  137. package/dist/docx/form-field-model.d.ts.map +1 -1
  138. package/dist/docx/index.cjs +6107 -1728
  139. package/dist/docx/index.d.ts +3 -1
  140. package/dist/docx/index.d.ts.map +1 -1
  141. package/dist/docx/index.mjs +6103 -1729
  142. package/dist/docx/inline-model.d.ts +4 -0
  143. package/dist/docx/inline-model.d.ts.map +1 -1
  144. package/dist/docx/layout/adapt-floats.d.ts.map +1 -1
  145. package/dist/docx/layout/adapter.d.ts.map +1 -1
  146. package/dist/docx/layout/floats.d.ts.map +1 -1
  147. package/dist/docx/layout/index.cjs +2338 -554
  148. package/dist/docx/layout/index.mjs +2338 -554
  149. package/dist/docx/layout/input.d.ts +5 -0
  150. package/dist/docx/layout/input.d.ts.map +1 -1
  151. package/dist/docx/layout/result.d.ts +3 -0
  152. package/dist/docx/layout/result.d.ts.map +1 -1
  153. package/dist/docx/load/index.cjs +7593 -1539
  154. package/dist/docx/load/index.mjs +7593 -1539
  155. package/dist/docx/load/legacy-doc/binary-save.d.ts +4 -0
  156. package/dist/docx/load/legacy-doc/binary-save.d.ts.map +1 -0
  157. package/dist/docx/load/legacy-doc/blocks.d.ts +19 -0
  158. package/dist/docx/load/legacy-doc/blocks.d.ts.map +1 -0
  159. package/dist/docx/load/legacy-doc/borders.d.ts +7 -0
  160. package/dist/docx/load/legacy-doc/borders.d.ts.map +1 -0
  161. package/dist/docx/load/legacy-doc/context.d.ts +65 -0
  162. package/dist/docx/load/legacy-doc/context.d.ts.map +1 -0
  163. package/dist/docx/load/legacy-doc/drawing.d.ts +15 -0
  164. package/dist/docx/load/legacy-doc/drawing.d.ts.map +1 -0
  165. package/dist/docx/load/legacy-doc/error.d.ts +5 -0
  166. package/dist/docx/load/legacy-doc/error.d.ts.map +1 -0
  167. package/dist/docx/load/legacy-doc/inline.d.ts +7 -0
  168. package/dist/docx/load/legacy-doc/inline.d.ts.map +1 -0
  169. package/dist/docx/load/legacy-doc/numbering-part.d.ts +3 -0
  170. package/dist/docx/load/legacy-doc/numbering-part.d.ts.map +1 -0
  171. package/dist/docx/load/legacy-doc/package.d.ts +8 -0
  172. package/dist/docx/load/legacy-doc/package.d.ts.map +1 -0
  173. package/dist/docx/load/legacy-doc/para-props.d.ts +6 -0
  174. package/dist/docx/load/legacy-doc/para-props.d.ts.map +1 -0
  175. package/dist/docx/load/legacy-doc/run-props.d.ts +8 -0
  176. package/dist/docx/load/legacy-doc/run-props.d.ts.map +1 -0
  177. package/dist/docx/load/legacy-doc/sections.d.ts +23 -0
  178. package/dist/docx/load/legacy-doc/sections.d.ts.map +1 -0
  179. package/dist/docx/load/legacy-doc/styles-part.d.ts +3 -0
  180. package/dist/docx/load/legacy-doc/styles-part.d.ts.map +1 -0
  181. package/dist/docx/load/legacy-doc/table.d.ts +6 -0
  182. package/dist/docx/load/legacy-doc/table.d.ts.map +1 -0
  183. package/dist/docx/load/legacy-doc/xml.d.ts +21 -0
  184. package/dist/docx/load/legacy-doc/xml.d.ts.map +1 -0
  185. package/dist/docx/load/legacy-doc.d.ts +5 -4
  186. package/dist/docx/load/legacy-doc.d.ts.map +1 -1
  187. package/dist/docx/model-paragraph.d.ts +5 -0
  188. package/dist/docx/model-paragraph.d.ts.map +1 -1
  189. package/dist/docx/model.d.ts +3 -0
  190. package/dist/docx/model.d.ts.map +1 -1
  191. package/dist/docx/numbering-editing.d.ts +11 -1
  192. package/dist/docx/numbering-editing.d.ts.map +1 -1
  193. package/dist/docx/numbering-format.d.ts.map +1 -1
  194. package/dist/docx/numbering-model.d.ts +17 -0
  195. package/dist/docx/numbering-model.d.ts.map +1 -1
  196. package/dist/docx/numbering-package.d.ts +2 -2
  197. package/dist/docx/numbering-package.d.ts.map +1 -1
  198. package/dist/docx/numbering-parse.d.ts +2 -1
  199. package/dist/docx/numbering-parse.d.ts.map +1 -1
  200. package/dist/docx/numbering-picture-save.d.ts +13 -0
  201. package/dist/docx/numbering-picture-save.d.ts.map +1 -0
  202. package/dist/docx/numbering-picture.d.ts +18 -0
  203. package/dist/docx/numbering-picture.d.ts.map +1 -0
  204. package/dist/docx/parse.d.ts.map +1 -1
  205. package/dist/docx/permission-markers.d.ts +19 -0
  206. package/dist/docx/permission-markers.d.ts.map +1 -0
  207. package/dist/docx/permissions.d.ts +11 -0
  208. package/dist/docx/permissions.d.ts.map +1 -0
  209. package/dist/docx/protection-legacy.d.ts +13 -0
  210. package/dist/docx/protection-legacy.d.ts.map +1 -0
  211. package/dist/docx/protection.d.ts +30 -0
  212. package/dist/docx/protection.d.ts.map +1 -0
  213. package/dist/docx/save.d.ts.map +1 -1
  214. package/dist/docx/settings.d.ts +6 -1
  215. package/dist/docx/settings.d.ts.map +1 -1
  216. package/dist/docx/ui/customization.d.ts.map +1 -1
  217. package/dist/docx/ui/edit-restriction.d.ts +53 -0
  218. package/dist/docx/ui/edit-restriction.d.ts.map +1 -0
  219. package/dist/docx/ui/index.cjs +3617 -1097
  220. package/dist/docx/ui/index.d.ts +4 -0
  221. package/dist/docx/ui/index.d.ts.map +1 -1
  222. package/dist/docx/ui/index.mjs +3597 -1098
  223. package/dist/docx/ui/inline-content-schema.d.ts.map +1 -1
  224. package/dist/docx/ui/paragraph-attributes.d.ts.map +1 -1
  225. package/dist/docx/ui/ribbon-action-ids.d.ts +1 -1
  226. package/dist/docx/ui/ribbon-action-ids.d.ts.map +1 -1
  227. package/dist/docx/ui/run-adapter.d.ts.map +1 -1
  228. package/dist/docx/write-drawing.d.ts.map +1 -1
  229. package/dist/docx/write-paragraph.d.ts.map +1 -1
  230. package/dist/drawingml/index.cjs +708 -111
  231. package/dist/drawingml/index.d.ts +7 -0
  232. package/dist/drawingml/index.d.ts.map +1 -1
  233. package/dist/drawingml/index.mjs +698 -113
  234. package/dist/drawingml/picture-artistic.d.ts +14 -0
  235. package/dist/drawingml/picture-artistic.d.ts.map +1 -0
  236. package/dist/drawingml/picture-effects.d.ts +4 -1
  237. package/dist/drawingml/picture-effects.d.ts.map +1 -1
  238. package/dist/drawingml/picture-fill.d.ts.map +1 -1
  239. package/dist/drawingml/picture-hsl-pixels.d.ts +4 -0
  240. package/dist/drawingml/picture-hsl-pixels.d.ts.map +1 -0
  241. package/dist/drawingml/picture-layout.d.ts +25 -0
  242. package/dist/drawingml/picture-layout.d.ts.map +1 -0
  243. package/dist/drawingml/picture-standard-effects.d.ts +15 -0
  244. package/dist/drawingml/picture-standard-effects.d.ts.map +1 -0
  245. package/dist/drawingml/picture-transfer.d.ts +11 -0
  246. package/dist/drawingml/picture-transfer.d.ts.map +1 -0
  247. package/dist/drawingml/raster-image.d.ts +29 -0
  248. package/dist/drawingml/raster-image.d.ts.map +1 -0
  249. package/dist/drawingml/types.d.ts +1 -0
  250. package/dist/drawingml/types.d.ts.map +1 -1
  251. package/dist/drawingml/write-pattern-picture.d.ts.map +1 -1
  252. package/dist/drawingml/write-theme.d.ts +2 -0
  253. package/dist/drawingml/write-theme.d.ts.map +1 -1
  254. package/dist/geometry/index.cjs +38 -0
  255. package/dist/geometry/index.d.ts +1 -0
  256. package/dist/geometry/index.d.ts.map +1 -1
  257. package/dist/geometry/index.mjs +36 -1
  258. package/dist/geometry/picture-tile.d.ts +29 -0
  259. package/dist/geometry/picture-tile.d.ts.map +1 -0
  260. package/dist/index.cjs +15671 -12934
  261. package/dist/index.mjs +15671 -12934
  262. package/dist/pptx/automation/index.cjs +9313 -3688
  263. package/dist/pptx/automation/index.d.ts +40 -6
  264. package/dist/pptx/automation/index.d.ts.map +1 -1
  265. package/dist/pptx/automation/index.mjs +254 -12
  266. package/dist/pptx/automation/schemas/index.cjs +26 -0
  267. package/dist/pptx/automation/schemas/index.d.ts +26 -1
  268. package/dist/pptx/automation/schemas/index.d.ts.map +1 -0
  269. package/dist/pptx/automation/schemas/index.mjs +1 -1
  270. package/dist/pptx/chunks/{elements-mSCZ84Tc.d.ts → elements-f3UbFph-.d.ts} +7 -2
  271. package/dist/pptx/chunks/elements-f3UbFph-.d.ts.map +1 -0
  272. package/dist/pptx/chunks/{index-DnWlmYCy.d.ts → index-BnH2QjYm.d.ts} +4 -4
  273. package/dist/pptx/chunks/{index-DnWlmYCy.d.ts.map → index-BnH2QjYm.d.ts.map} +1 -1
  274. package/dist/pptx/chunks/{index-D-FdgqrP.d.ts → index-Bp-1pGo1.d.ts} +4 -4
  275. package/dist/pptx/chunks/{index-D-FdgqrP.d.ts.map → index-Bp-1pGo1.d.ts.map} +1 -1
  276. package/dist/pptx/chunks/{index-DKybuHPT.d.ts → index-pLLN4OTz.d.ts} +62 -24
  277. package/dist/pptx/chunks/index-pLLN4OTz.d.ts.map +1 -0
  278. package/dist/pptx/chunks/{smart-art-DLumQo90.d.ts → smart-art-CmOrPLLQ.d.ts} +86 -2
  279. package/dist/pptx/chunks/smart-art-CmOrPLLQ.d.ts.map +1 -0
  280. package/dist/pptx/chunks/{text-operations-hyPODwIQ.d.ts → text-operations-D5sgspO6.d.ts} +2 -2
  281. package/dist/pptx/chunks/{text-operations-hyPODwIQ.d.ts.map → text-operations-D5sgspO6.d.ts.map} +1 -1
  282. package/dist/pptx/cli/index.cjs +7477 -2848
  283. package/dist/pptx/cli/index.d.ts +1 -1
  284. package/dist/pptx/cli/index.mjs +6 -6
  285. package/dist/pptx/converter/index.cjs +3895 -503
  286. package/dist/pptx/converter/index.d.ts +1 -1
  287. package/dist/pptx/converter/index.mjs +3 -3
  288. package/dist/pptx/editor/render/custom-show-operations.cjs +133 -0
  289. package/dist/pptx/editor/render/custom-show-operations.d.ts +42 -0
  290. package/dist/pptx/editor/render/custom-show-operations.d.ts.map +1 -0
  291. package/dist/pptx/editor/render/custom-show-operations.mjs +119 -0
  292. package/dist/pptx/editor/render/find-replace.cjs +15 -14
  293. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  294. package/dist/pptx/editor/render/find-replace.mjs +2 -1
  295. package/dist/pptx/editor/render/slide-operations.cjs +9 -8
  296. package/dist/pptx/editor/render/slide-operations.mjs +3 -2
  297. package/dist/pptx/editor/render/table-data-grid-ops.cjs +1 -1
  298. package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
  299. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +1 -1
  300. package/dist/pptx/editor/render/text-style-scope.d.ts +1 -1
  301. package/dist/pptx/index.cjs +8447 -3693
  302. package/dist/pptx/index.d.ts +7 -7
  303. package/dist/pptx/index.mjs +7 -7
  304. package/dist/pptx/node/index.d.ts +1 -1
  305. package/dist/pptx/smartart-layouts/index.d.ts +1 -1
  306. package/dist/pptx/smartart-layouts/index.mjs +2 -2
  307. package/dist/teams/index.cjs +2176 -751
  308. package/dist/teams/index.mjs +2176 -751
  309. package/dist/text/index.cjs +241 -0
  310. package/dist/text/index.d.ts +2 -0
  311. package/dist/text/index.d.ts.map +1 -1
  312. package/dist/text/index.mjs +240 -1
  313. package/dist/text/truetype/parse.d.ts +36 -0
  314. package/dist/text/truetype/parse.d.ts.map +1 -0
  315. package/dist/text/truetype/subset.d.ts +16 -0
  316. package/dist/text/truetype/subset.d.ts.map +1 -0
  317. package/dist/visio/cell-formula.d.ts +5 -1
  318. package/dist/visio/cell-formula.d.ts.map +1 -1
  319. package/dist/visio/collab/index.cjs +3 -1
  320. package/dist/visio/collab/index.mjs +3 -1
  321. package/dist/visio/container-relationships.d.ts +53 -0
  322. package/dist/visio/container-relationships.d.ts.map +1 -0
  323. package/dist/visio/data-connections.d.ts +32 -0
  324. package/dist/visio/data-connections.d.ts.map +1 -0
  325. package/dist/visio/data-recordsets.d.ts +7 -0
  326. package/dist/visio/data-recordsets.d.ts.map +1 -1
  327. package/dist/visio/data-refresh.d.ts +33 -0
  328. package/dist/visio/data-refresh.d.ts.map +1 -0
  329. package/dist/visio/edit-commands.d.ts +6 -1
  330. package/dist/visio/edit-commands.d.ts.map +1 -1
  331. package/dist/visio/edit-connector.d.ts.map +1 -1
  332. package/dist/visio/edit-container-fit.d.ts +32 -0
  333. package/dist/visio/edit-container-fit.d.ts.map +1 -0
  334. package/dist/visio/edit-container-members.d.ts +33 -0
  335. package/dist/visio/edit-container-members.d.ts.map +1 -0
  336. package/dist/visio/edit-container-options.d.ts +33 -0
  337. package/dist/visio/edit-container-options.d.ts.map +1 -0
  338. package/dist/visio/edit-data-commands.d.ts +5 -0
  339. package/dist/visio/edit-data-commands.d.ts.map +1 -1
  340. package/dist/visio/edit-data-parts.d.ts +2 -0
  341. package/dist/visio/edit-data-parts.d.ts.map +1 -1
  342. package/dist/visio/edit-data.d.ts.map +1 -1
  343. package/dist/visio/edit-delete.d.ts.map +1 -1
  344. package/dist/visio/edit-diagram-parts-commands.d.ts +24 -1
  345. package/dist/visio/edit-diagram-parts-commands.d.ts.map +1 -1
  346. package/dist/visio/edit-diagram-parts.d.ts +11 -2
  347. package/dist/visio/edit-diagram-parts.d.ts.map +1 -1
  348. package/dist/visio/edit-geometry.d.ts +4 -1
  349. package/dist/visio/edit-geometry.d.ts.map +1 -1
  350. package/dist/visio/edit-group-resize.d.ts.map +1 -1
  351. package/dist/visio/edit-instance-checks.d.ts.map +1 -1
  352. package/dist/visio/edit-package.d.ts.map +1 -1
  353. package/dist/visio/edit-page-theme-commands.d.ts +26 -0
  354. package/dist/visio/edit-page-theme-commands.d.ts.map +1 -1
  355. package/dist/visio/edit-page-theme-part.d.ts +6 -0
  356. package/dist/visio/edit-page-theme-part.d.ts.map +1 -0
  357. package/dist/visio/edit-page-theme.d.ts +9 -1
  358. package/dist/visio/edit-page-theme.d.ts.map +1 -1
  359. package/dist/visio/edit-picture-adjust.d.ts +32 -0
  360. package/dist/visio/edit-picture-adjust.d.ts.map +1 -0
  361. package/dist/visio/edit-recalculate-index.d.ts +13 -0
  362. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  363. package/dist/visio/edit-recalculate-values.d.ts.map +1 -1
  364. package/dist/visio/edit-recalculate.d.ts.map +1 -1
  365. package/dist/visio/edit-resize-anchor.d.ts.map +1 -1
  366. package/dist/visio/edit-swimlane-commands.d.ts +91 -0
  367. package/dist/visio/edit-swimlane-commands.d.ts.map +1 -0
  368. package/dist/visio/edit-swimlane-layout.d.ts +64 -0
  369. package/dist/visio/edit-swimlane-layout.d.ts.map +1 -0
  370. package/dist/visio/edit-swimlane-ops.d.ts +11 -0
  371. package/dist/visio/edit-swimlane-ops.d.ts.map +1 -0
  372. package/dist/visio/edit-swimlane-shapes.d.ts +42 -0
  373. package/dist/visio/edit-swimlane-shapes.d.ts.map +1 -0
  374. package/dist/visio/edit-swimlane-turn.d.ts +9 -0
  375. package/dist/visio/edit-swimlane-turn.d.ts.map +1 -0
  376. package/dist/visio/edit.d.ts.map +1 -1
  377. package/dist/visio/effects.d.ts +3 -2
  378. package/dist/visio/effects.d.ts.map +1 -1
  379. package/dist/visio/formula-analyze.d.ts +2 -0
  380. package/dist/visio/formula-analyze.d.ts.map +1 -1
  381. package/dist/visio/formula-evaluate.d.ts.map +1 -1
  382. package/dist/visio/formula-master.d.ts +1 -0
  383. package/dist/visio/formula-master.d.ts.map +1 -1
  384. package/dist/visio/geometry.d.ts +2 -1
  385. package/dist/visio/geometry.d.ts.map +1 -1
  386. package/dist/visio/index.cjs +12207 -7779
  387. package/dist/visio/index.d.ts +8 -1
  388. package/dist/visio/index.d.ts.map +1 -1
  389. package/dist/visio/index.mjs +12201 -7780
  390. package/dist/visio/infinite-line.d.ts +17 -0
  391. package/dist/visio/infinite-line.d.ts.map +1 -0
  392. package/dist/visio/media.d.ts +4 -23
  393. package/dist/visio/media.d.ts.map +1 -1
  394. package/dist/visio/model.d.ts +46 -0
  395. package/dist/visio/model.d.ts.map +1 -1
  396. package/dist/visio/package-common.d.ts +1 -1
  397. package/dist/visio/package-common.d.ts.map +1 -1
  398. package/dist/visio/package-kind.d.ts +34 -0
  399. package/dist/visio/package-kind.d.ts.map +1 -0
  400. package/dist/visio/page-theme.d.ts +7 -0
  401. package/dist/visio/page-theme.d.ts.map +1 -1
  402. package/dist/visio/parser.d.ts +2 -2
  403. package/dist/visio/parser.d.ts.map +1 -1
  404. package/dist/visio/shadow.d.ts +2 -1
  405. package/dist/visio/shadow.d.ts.map +1 -1
  406. package/dist/visio/shape-structure.d.ts +19 -3
  407. package/dist/visio/shape-structure.d.ts.map +1 -1
  408. package/dist/visio/shapes.d.ts +7 -1
  409. package/dist/visio/shapes.d.ts.map +1 -1
  410. package/dist/visio/stencil-file.d.ts +2 -2
  411. package/dist/visio/style.d.ts.map +1 -1
  412. package/dist/visio/swimlane-stack.d.ts +65 -0
  413. package/dist/visio/swimlane-stack.d.ts.map +1 -0
  414. package/dist/visio/theme-builtins.d.ts +3 -0
  415. package/dist/visio/theme-builtins.d.ts.map +1 -1
  416. package/dist/visio/theme-effects.d.ts +19 -0
  417. package/dist/visio/theme-effects.d.ts.map +1 -0
  418. package/dist/visio/theme-font.d.ts +13 -0
  419. package/dist/visio/theme-font.d.ts.map +1 -0
  420. package/dist/visio/theme-line.d.ts.map +1 -1
  421. package/dist/visio/theme-write.d.ts.map +1 -1
  422. package/dist/visio/theme.d.ts +7 -0
  423. package/dist/visio/theme.d.ts.map +1 -1
  424. package/dist/visio/ui/data-graphic-config.d.ts +45 -0
  425. package/dist/visio/ui/data-graphic-config.d.ts.map +1 -0
  426. package/dist/visio/ui/data-graphic-rules.d.ts +7 -0
  427. package/dist/visio/ui/data-graphic-rules.d.ts.map +1 -1
  428. package/dist/visio/ui/data-graphics.d.ts +9 -0
  429. package/dist/visio/ui/data-graphics.d.ts.map +1 -1
  430. package/dist/visio/ui/diagram-parts.d.ts +20 -2
  431. package/dist/visio/ui/diagram-parts.d.ts.map +1 -1
  432. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  433. package/dist/visio/ui/guides.d.ts +9 -1
  434. package/dist/visio/ui/guides.d.ts.map +1 -1
  435. package/dist/visio/ui/index.cjs +14266 -10008
  436. package/dist/visio/ui/index.d.ts +4 -0
  437. package/dist/visio/ui/index.d.ts.map +1 -1
  438. package/dist/visio/ui/index.mjs +14231 -10009
  439. package/dist/visio/ui/org-chart.d.ts +75 -0
  440. package/dist/visio/ui/org-chart.d.ts.map +1 -0
  441. package/dist/visio/ui/resize-snap.d.ts +51 -0
  442. package/dist/visio/ui/resize-snap.d.ts.map +1 -0
  443. package/dist/visio/ui/sample-drawing.d.ts +26 -0
  444. package/dist/visio/ui/sample-drawing.d.ts.map +1 -1
  445. package/dist/visio/ui/scene-validation.d.ts.map +1 -1
  446. package/dist/visio/ui/selection-resize.d.ts +2 -2
  447. package/dist/visio/ui/selection-resize.d.ts.map +1 -1
  448. package/dist/visio/ui/shape-resize.d.ts +29 -1
  449. package/dist/visio/ui/shape-resize.d.ts.map +1 -1
  450. package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
  451. package/dist/visio/ui/swimlane.d.ts +37 -0
  452. package/dist/visio/ui/swimlane.d.ts.map +1 -0
  453. package/dist/visio/ui/templates.d.ts +26 -0
  454. package/dist/visio/ui/templates.d.ts.map +1 -0
  455. package/dist/xlsx/audit/ast-text.d.ts +12 -0
  456. package/dist/xlsx/audit/ast-text.d.ts.map +1 -0
  457. package/dist/xlsx/audit/error-check.d.ts +23 -0
  458. package/dist/xlsx/audit/error-check.d.ts.map +1 -0
  459. package/dist/xlsx/audit/evaluate-steps.d.ts +48 -0
  460. package/dist/xlsx/audit/evaluate-steps.d.ts.map +1 -0
  461. package/dist/xlsx/audit/index.d.ts +6 -0
  462. package/dist/xlsx/audit/index.d.ts.map +1 -0
  463. package/dist/xlsx/audit/trace.d.ts +59 -0
  464. package/dist/xlsx/audit/trace.d.ts.map +1 -0
  465. package/dist/xlsx/audit/watch.d.ts +17 -0
  466. package/dist/xlsx/audit/watch.d.ts.map +1 -0
  467. package/dist/xlsx/edit/cell-values.d.ts.map +1 -1
  468. package/dist/xlsx/edit/chart-ex.d.ts +1 -0
  469. package/dist/xlsx/edit/chart-ex.d.ts.map +1 -1
  470. package/dist/xlsx/edit/filter.d.ts +8 -1
  471. package/dist/xlsx/edit/filter.d.ts.map +1 -1
  472. package/dist/xlsx/edit/index.d.ts +5 -1
  473. package/dist/xlsx/edit/index.d.ts.map +1 -1
  474. package/dist/xlsx/edit/session-calc.d.ts +5 -0
  475. package/dist/xlsx/edit/session-calc.d.ts.map +1 -1
  476. package/dist/xlsx/edit/session.d.ts.map +1 -1
  477. package/dist/xlsx/edit/sort-choices.d.ts +23 -0
  478. package/dist/xlsx/edit/sort-choices.d.ts.map +1 -0
  479. package/dist/xlsx/edit/sort-keys.d.ts +49 -0
  480. package/dist/xlsx/edit/sort-keys.d.ts.map +1 -0
  481. package/dist/xlsx/edit/sort-reapply.d.ts +11 -0
  482. package/dist/xlsx/edit/sort-reapply.d.ts.map +1 -0
  483. package/dist/xlsx/edit/sort.d.ts +14 -12
  484. package/dist/xlsx/edit/sort.d.ts.map +1 -1
  485. package/dist/xlsx/edit/text-columns.d.ts +21 -0
  486. package/dist/xlsx/edit/text-columns.d.ts.map +1 -0
  487. package/dist/xlsx/edit/types.d.ts +10 -5
  488. package/dist/xlsx/edit/types.d.ts.map +1 -1
  489. package/dist/xlsx/edit/view.d.ts +9 -1
  490. package/dist/xlsx/edit/view.d.ts.map +1 -1
  491. package/dist/xlsx/embedded-chart-ex-space.d.ts +18 -0
  492. package/dist/xlsx/embedded-chart-ex-space.d.ts.map +1 -0
  493. package/dist/xlsx/filter-criteria.d.ts +23 -0
  494. package/dist/xlsx/filter-criteria.d.ts.map +1 -0
  495. package/dist/xlsx/filter-dynamic.d.ts +8 -0
  496. package/dist/xlsx/filter-dynamic.d.ts.map +1 -0
  497. package/dist/xlsx/filter-menu.d.ts +49 -0
  498. package/dist/xlsx/filter-menu.d.ts.map +1 -0
  499. package/dist/xlsx/filter-rows.d.ts +4 -4
  500. package/dist/xlsx/filter-rows.d.ts.map +1 -1
  501. package/dist/xlsx/formula/engine-types.d.ts +8 -0
  502. package/dist/xlsx/formula/engine-types.d.ts.map +1 -1
  503. package/dist/xlsx/formula/engine.d.ts.map +1 -1
  504. package/dist/xlsx/index.cjs +7259 -3079
  505. package/dist/xlsx/index.d.ts +5 -0
  506. package/dist/xlsx/index.d.ts.map +1 -1
  507. package/dist/xlsx/index.mjs +7213 -3079
  508. package/dist/xlsx/layout/index.d.ts +1 -0
  509. package/dist/xlsx/layout/index.d.ts.map +1 -1
  510. package/dist/xlsx/layout/split.d.ts +55 -0
  511. package/dist/xlsx/layout/split.d.ts.map +1 -0
  512. package/dist/xlsx/layout/viewport.d.ts +2 -0
  513. package/dist/xlsx/layout/viewport.d.ts.map +1 -1
  514. package/dist/xlsx/load/index.cjs +2170 -688
  515. package/dist/xlsx/load/index.mjs +2170 -688
  516. package/dist/xlsx/model-filter.d.ts +54 -0
  517. package/dist/xlsx/model-filter.d.ts.map +1 -0
  518. package/dist/xlsx/model-sort.d.ts +27 -0
  519. package/dist/xlsx/model-sort.d.ts.map +1 -0
  520. package/dist/xlsx/model.d.ts +81 -4
  521. package/dist/xlsx/model.d.ts.map +1 -1
  522. package/dist/xlsx/read/chart.d.ts.map +1 -1
  523. package/dist/xlsx/read/drawing.d.ts.map +1 -1
  524. package/dist/xlsx/read/filter-columns.d.ts +5 -0
  525. package/dist/xlsx/read/filter-columns.d.ts.map +1 -0
  526. package/dist/xlsx/read/ignored-errors.d.ts +4 -0
  527. package/dist/xlsx/read/ignored-errors.d.ts.map +1 -0
  528. package/dist/xlsx/read/shared-strings.d.ts +5 -3
  529. package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
  530. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  531. package/dist/xlsx/read/sheet-props.d.ts +2 -2
  532. package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
  533. package/dist/xlsx/read/sort-state.d.ts +5 -0
  534. package/dist/xlsx/read/sort-state.d.ts.map +1 -0
  535. package/dist/xlsx/read/tables.d.ts +2 -2
  536. package/dist/xlsx/read/tables.d.ts.map +1 -1
  537. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  538. package/dist/xlsx/sort-lists.d.ts +6 -0
  539. package/dist/xlsx/sort-lists.d.ts.map +1 -0
  540. package/dist/xlsx/ui/audit-state.d.ts +19 -0
  541. package/dist/xlsx/ui/audit-state.d.ts.map +1 -0
  542. package/dist/xlsx/ui/commands/audit.d.ts +3 -0
  543. package/dist/xlsx/ui/commands/audit.d.ts.map +1 -0
  544. package/dist/xlsx/ui/commands/formulas.d.ts.map +1 -1
  545. package/dist/xlsx/ui/commands/i18n/audit.d.ts +3 -0
  546. package/dist/xlsx/ui/commands/i18n/audit.d.ts.map +1 -0
  547. package/dist/xlsx/ui/commands/i18n/filters.d.ts +3 -0
  548. package/dist/xlsx/ui/commands/i18n/filters.d.ts.map +1 -0
  549. package/dist/xlsx/ui/commands/i18n/index.d.ts.map +1 -1
  550. package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
  551. package/dist/xlsx/ui/commands/i18n/ribbon-tabs.d.ts.map +1 -1
  552. package/dist/xlsx/ui/commands/i18n/rules.d.ts.map +1 -1
  553. package/dist/xlsx/ui/commands/i18n/tools.d.ts.map +1 -1
  554. package/dist/xlsx/ui/commands/icons.d.ts.map +1 -1
  555. package/dist/xlsx/ui/commands/sort-filter.d.ts.map +1 -1
  556. package/dist/xlsx/ui/context.d.ts +6 -1
  557. package/dist/xlsx/ui/context.d.ts.map +1 -1
  558. package/dist/xlsx/ui/dialogs/grid-chart.d.ts.map +1 -1
  559. package/dist/xlsx/ui/grid/geometry.d.ts +29 -1
  560. package/dist/xlsx/ui/grid/geometry.d.ts.map +1 -1
  561. package/dist/xlsx/ui/index.cjs +9454 -5323
  562. package/dist/xlsx/ui/index.d.ts +1 -0
  563. package/dist/xlsx/ui/index.d.ts.map +1 -1
  564. package/dist/xlsx/ui/index.mjs +9448 -5324
  565. package/dist/xlsx/ui/ribbon/icon-paths.d.ts.map +1 -1
  566. package/dist/xlsx/ui/ribbon/tabs/review-view.d.ts.map +1 -1
  567. package/dist/xlsx/write/drawing.d.ts.map +1 -1
  568. package/dist/xlsx/write/filter-columns.d.ts +53 -0
  569. package/dist/xlsx/write/filter-columns.d.ts.map +1 -0
  570. package/dist/xlsx/write/ignored-errors.d.ts +3 -0
  571. package/dist/xlsx/write/ignored-errors.d.ts.map +1 -0
  572. package/dist/xlsx/write/shared-strings.d.ts +4 -4
  573. package/dist/xlsx/write/shared-strings.d.ts.map +1 -1
  574. package/dist/xlsx/write/sheet-parts.d.ts.map +1 -1
  575. package/dist/xlsx/write/sheet-props.d.ts +2 -1
  576. package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
  577. package/dist/xlsx/write/smart-art-cache.d.ts.map +1 -1
  578. package/dist/xlsx/write/smart-art.d.ts.map +1 -1
  579. package/dist/xlsx/write/sort-state.d.ts +55 -0
  580. package/dist/xlsx/write/sort-state.d.ts.map +1 -0
  581. package/dist/xlsx/write/table-patch.d.ts +2 -1
  582. package/dist/xlsx/write/table-patch.d.ts.map +1 -1
  583. package/dist/xlsx/write/tables.d.ts +2 -1
  584. package/dist/xlsx/write/tables.d.ts.map +1 -1
  585. package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
  586. package/dist/xlsx/write/worksheet.d.ts.map +1 -1
  587. package/package.json +7 -2
  588. package/dist/PptxHandler-QY5VL3CY.mjs +0 -7
  589. package/dist/PptxHandler-SJ5ZUIUX.mjs +0 -4
  590. package/dist/PptxHandler-TESZUH66.cjs +0 -13
  591. package/dist/chunk-3GXV5MPC.mjs +0 -41
  592. package/dist/chunk-MHNETXQB.mjs +0 -1
  593. package/dist/pptx/chunks/elements-mSCZ84Tc.d.ts.map +0 -1
  594. package/dist/pptx/chunks/index-DKybuHPT.d.ts.map +0 -1
  595. package/dist/pptx/chunks/smart-art-DLumQo90.d.ts.map +0 -1
@@ -408,8 +408,8 @@ function parseHalfPoints(value) {
408
408
  function parseSignedHalfPoints(value) {
409
409
  if (value === null || value === void 0) return void 0;
410
410
  const text = value.trim();
411
- const integer4 = parseInteger(text);
412
- if (integer4 !== void 0) return halfPoints(integer4);
411
+ const integer5 = parseInteger(text);
412
+ if (integer5 !== void 0) return halfPoints(integer5);
413
413
  const twips3 = universalMeasureToTwips(text);
414
414
  return twips3 === void 0 ? void 0 : halfPoints(Math.sign(twips3) * Math.round(Math.abs(twips3) / 10));
415
415
  }
@@ -1549,37 +1549,271 @@ function resolveDrawingColor(color, theme, options) {
1549
1549
  };
1550
1550
  }
1551
1551
 
1552
- // drawingml/picture-crop.ts
1553
- var SIDES2 = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
1554
- function parsePictureCrop(blipFill) {
1555
- const rect2 = first(blipFill, "srcRect", NS.a);
1556
- if (!rect2) return void 0;
1557
- const result = {};
1558
- for (const [attr3, key] of Object.entries(SIDES2)) {
1559
- const raw2 = rect2.getAttribute(attr3);
1560
- if (raw2 === null || !raw2.trim()) continue;
1561
- const percent = raw2.endsWith("%");
1562
- const value = Number(percent ? raw2.slice(0, -1) : raw2) / (percent ? 100 : 1e5);
1563
- if (Number.isFinite(value)) result[key] = value;
1552
+ // drawingml/picture-artistic.ts
1553
+ var ARTISTIC_PRIMARY_ATTRIBUTE = {
1554
+ artisticBlur: "radius",
1555
+ artisticCement: "crackSpacing",
1556
+ artisticChalkSketch: "pressure",
1557
+ artisticCrisscrossEtching: "pressure",
1558
+ artisticCutout: "numberOfShades",
1559
+ artisticFilmGrain: "grainSize",
1560
+ artisticGlass: "scaling",
1561
+ artisticGlowDiffused: "intensity",
1562
+ artisticGlowEdges: "smoothness",
1563
+ artisticLightScreen: "gridSize",
1564
+ artisticLineDrawing: "pencilSize",
1565
+ artisticMarker: "size",
1566
+ // Spelled "Mosiaic" in the schema; Microsoft's typo is part of the format.
1567
+ artisticMosiaicBubbles: "pressure",
1568
+ artisticPaintBrush: "brushSize",
1569
+ artisticPaintStrokes: "intensity",
1570
+ artisticPastelsSmooth: "scaling",
1571
+ artisticPencilGrayscale: "pencilSize",
1572
+ artisticPencilSketch: "pressure",
1573
+ artisticPhotocopy: "detail",
1574
+ artisticPlasticWrap: "smoothness",
1575
+ artisticTexturizer: "scaling",
1576
+ artisticWatercolorSponge: "brushSize"
1577
+ };
1578
+ function parseArtisticPictureExtension(node) {
1579
+ if (node.namespaceURI !== NS.a || node.localName !== "extLst") return void 0;
1580
+ const found = [];
1581
+ const unhandled = [];
1582
+ const pending2 = [node];
1583
+ while (pending2.length) {
1584
+ const item2 = pending2.pop();
1585
+ if (item2 !== node && !(item2.namespaceURI === NS.a && item2.localName === "ext") && !(item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && (["imgProps", "imgLayer", "imgEffect", "useLocalDpi"].includes(item2.localName) || ARTISTIC_PRIMARY_ATTRIBUTE[item2.localName])))
1586
+ unhandled.push(item2.localName);
1587
+ if (item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && item2.localName.startsWith("artistic"))
1588
+ found.push(item2);
1589
+ pending2.push(...elements(item2));
1590
+ }
1591
+ if (found.length !== 1) return void 0;
1592
+ const effect = found[0];
1593
+ const key = ARTISTIC_PRIMARY_ATTRIBUTE[effect.localName];
1594
+ if (!key) return void 0;
1595
+ const raw2 = key ? effect.getAttribute(key) : null;
1596
+ const n = raw2 === null ? 0 : Number(raw2);
1597
+ if (!Number.isFinite(n)) return void 0;
1598
+ return {
1599
+ kind: "artistic",
1600
+ name: effect.localName,
1601
+ radius: effect.localName === "artisticBlur" ? n : n / 1e3,
1602
+ baked: true,
1603
+ ...unhandled.length ? { unhandled } : {}
1604
+ };
1605
+ }
1606
+
1607
+ // drawingml/write-color.ts
1608
+ var ELEMENTS = {
1609
+ srgb: "srgbClr",
1610
+ scheme: "schemeClr",
1611
+ system: "sysClr",
1612
+ preset: "prstClr",
1613
+ scrgb: "scrgbClr",
1614
+ hsl: "hslClr"
1615
+ };
1616
+ function drawingColorXml(color) {
1617
+ const local = ELEMENTS[color.kind];
1618
+ const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
1619
+ const root = doc.documentElement;
1620
+ if (color.kind === "scrgb" || color.kind === "hsl") {
1621
+ const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
1622
+ const values = color.value.split(",");
1623
+ keys.forEach((key, i) => root.setAttribute(key, values[i] ?? "0"));
1624
+ } else root.setAttribute("val", color.value);
1625
+ if (color.fallback !== void 0 && color.kind === "system")
1626
+ root.setAttribute("lastClr", color.fallback);
1627
+ for (const transform2 of color.transforms) {
1628
+ if (!/^[A-Za-z_][\w.-]*$/.test(transform2.name))
1629
+ throw new Error(`Invalid DrawingML transform ${transform2.name}`);
1630
+ const node = doc.createElementNS(NS.a, `a:${transform2.name}`);
1631
+ if (transform2.value !== "") node.setAttribute("val", transform2.value);
1632
+ root.appendChild(node);
1564
1633
  }
1565
- return result;
1634
+ return buildXml(doc);
1566
1635
  }
1567
- function applyPictureCrop(blipFill, crop) {
1568
- let rect2 = first(blipFill, "srcRect", NS.a);
1569
- if (!rect2 && crop && Object.values(crop).some((value) => value !== void 0)) {
1570
- rect2 = blipFill.ownerDocument.createElementNS(NS.a, "a:srcRect");
1571
- const blip = first(blipFill, "blip", NS.a);
1572
- blipFill.insertBefore(rect2, blip?.nextSibling ?? blipFill.firstChild);
1636
+
1637
+ // drawingml/patch-color.ts
1638
+ function patchDrawingColorIn(container, color) {
1639
+ const old = elements(container).find((node) => parseDrawingColor(node));
1640
+ const before = parseDrawingColorIn(container);
1641
+ if (!old || !before || before.kind !== color.kind) {
1642
+ const next = container.ownerDocument.importNode(
1643
+ parseXml(drawingColorXml(color)).documentElement,
1644
+ true
1645
+ );
1646
+ if (old) container.replaceChild(next, old);
1647
+ else container.insertBefore(next, container.firstChild);
1648
+ return;
1573
1649
  }
1574
- if (!rect2) return;
1575
- for (const [attr3, key] of Object.entries(SIDES2)) {
1576
- const value = crop?.[key];
1577
- if (value === void 0) rect2.removeAttribute(attr3);
1578
- else {
1579
- if (!Number.isFinite(value)) throw new RangeError("Picture crop must be finite");
1580
- rect2.setAttribute(attr3, String(Math.round(value * 1e5)));
1650
+ if (before.value !== color.value) {
1651
+ if (color.kind === "scrgb" || color.kind === "hsl") {
1652
+ const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
1653
+ const values = color.value.split(",");
1654
+ keys.forEach((key, index) => old.setAttribute(key, values[index] ?? "0"));
1655
+ } else old.setAttribute("val", color.value);
1656
+ }
1657
+ if (before.fallback !== color.fallback && color.kind === "system") {
1658
+ if (color.fallback === void 0) old.removeAttribute("lastClr");
1659
+ else old.setAttribute("lastClr", color.fallback);
1660
+ }
1661
+ const originals = elements(old);
1662
+ color.transforms.forEach((transform2, index) => {
1663
+ const source2 = originals[index];
1664
+ if (source2?.localName === transform2.name) {
1665
+ if (before.transforms[index]?.value !== transform2.value) {
1666
+ if (transform2.value === "") source2.removeAttribute("val");
1667
+ else source2.setAttribute("val", transform2.value);
1668
+ }
1669
+ return;
1581
1670
  }
1671
+ if (!/^[A-Za-z_][\w.-]*$/u.test(transform2.name))
1672
+ throw new Error("Invalid DrawingML colour transform");
1673
+ const next = old.ownerDocument.createElementNS(NS.a, `a:${transform2.name}`);
1674
+ if (transform2.value !== "") next.setAttribute("val", transform2.value);
1675
+ if (source2) old.replaceChild(next, source2);
1676
+ else old.appendChild(next);
1677
+ });
1678
+ for (const extra of originals.slice(color.transforms.length)) old.removeChild(extra);
1679
+ }
1680
+
1681
+ // drawingml/picture-standard-effects.ts
1682
+ var attrs = {
1683
+ biLevel: { threshold: "thresh" },
1684
+ alphaRepl: { amount: "a" },
1685
+ alphaBiLevel: { threshold: "thresh" },
1686
+ hsl: { hue: "hue", saturation: "sat", luminance: "lum" },
1687
+ tint: { hue: "hue", amount: "amt" },
1688
+ blur: { radiusEmu: "rad" }
1689
+ };
1690
+ function parseStandardPictureEffect(node) {
1691
+ const name = node.localName;
1692
+ if (![
1693
+ "biLevel",
1694
+ "alphaInv",
1695
+ "alphaCeiling",
1696
+ "alphaFloor",
1697
+ "alphaRepl",
1698
+ "alphaBiLevel",
1699
+ "alphaMod",
1700
+ "duotone",
1701
+ "clrRepl",
1702
+ "clrChange",
1703
+ "hsl",
1704
+ "tint",
1705
+ "blur"
1706
+ ].includes(name))
1707
+ return void 0;
1708
+ const values = {};
1709
+ for (const [key, attribute2] of Object.entries(attrs[name] ?? {})) {
1710
+ const raw2 = node.getAttribute(attribute2);
1711
+ if (raw2 === null) continue;
1712
+ const percent = raw2.endsWith("%");
1713
+ const n = Number(percent ? raw2.slice(0, -1) : raw2) / (key === "hue" ? 6e4 : key === "radiusEmu" ? 1 : percent ? 100 : 1e5);
1714
+ if (!Number.isFinite(n) || key === "hue" && (n < 0 || n >= 360) || key === "threshold" && (n < 0 || n > 1) || key === "radiusEmu" && (!Number.isSafeInteger(n) || n < 0) || ["saturation", "luminance", "amount"].includes(key) && name !== "alphaMod" && (n < (name === "alphaRepl" ? 0 : -1) || n > 1))
1715
+ return void 0;
1716
+ values[key] = n;
1717
+ }
1718
+ if (["biLevel", "alphaBiLevel"].includes(name) && values.threshold === void 0)
1719
+ return void 0;
1720
+ if (name === "alphaRepl" && values.amount === void 0) return void 0;
1721
+ if (name === "alphaMod") {
1722
+ const cont = first(node, "cont", NS.a);
1723
+ const nested = cont ? elements(cont) : [];
1724
+ if (nested.length !== 1 || nested[0]?.localName !== "alphaModFix") return void 0;
1725
+ const raw2 = nested[0].getAttribute("amt") ?? "100000";
1726
+ const n = Number(raw2.endsWith("%") ? raw2.slice(0, -1) : raw2) / (raw2.endsWith("%") ? 100 : 1e5);
1727
+ if (!Number.isFinite(n) || n < 0) return void 0;
1728
+ values.amount = n;
1729
+ }
1730
+ let colors = [];
1731
+ if (name === "duotone") {
1732
+ const candidates = elements(node).filter(
1733
+ (item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
1734
+ );
1735
+ colors = candidates.map((item2) => parseDrawingColor(item2)).filter((item2) => Boolean(item2));
1736
+ if (colors.length !== 2) return void 0;
1582
1737
  }
1738
+ if (name === "clrRepl") {
1739
+ const color = parseDrawingColorIn(node);
1740
+ if (!color) return void 0;
1741
+ colors = [color];
1742
+ }
1743
+ if (name === "clrChange") {
1744
+ const from = parseDrawingColorIn(first(node, "clrFrom", NS.a)), to = parseDrawingColorIn(first(node, "clrTo", NS.a));
1745
+ if (!from || !to) return void 0;
1746
+ colors = [from, to];
1747
+ }
1748
+ if (name === "alphaInv") {
1749
+ const color = parseDrawingColorIn(node);
1750
+ if (color) colors = [color];
1751
+ }
1752
+ return {
1753
+ kind: "standard",
1754
+ name,
1755
+ ...Object.keys(values).length ? { values } : {},
1756
+ ...colors.length ? { colors } : {},
1757
+ ...name === "clrChange" && node.hasAttribute("useA") ? { useAlpha: !["0", "false"].includes(node.getAttribute("useA") ?? "") } : {},
1758
+ ...name === "blur" && node.hasAttribute("grow") ? { grow: !["0", "false"].includes(node.getAttribute("grow") ?? "") } : {}
1759
+ };
1760
+ }
1761
+ function applyStandardPictureEffect(node, effect) {
1762
+ const doc = node.ownerDocument, before = parseStandardPictureEffect(node);
1763
+ for (const [key, value] of Object.entries(effect.values ?? {})) {
1764
+ if (!Number.isFinite(value) || key === "hue" && (value < 0 || value >= 360) || key === "threshold" && (value < 0 || value > 1) || key === "radiusEmu" && (!Number.isSafeInteger(value) || value < 0) || key === "amount" && effect.name === "alphaMod" && value < 0 || ["saturation", "luminance", "amount"].includes(key) && effect.name !== "alphaMod" && (value < (effect.name === "alphaRepl" ? 0 : -1) || value > 1))
1765
+ throw new RangeError("Invalid picture effect values");
1766
+ }
1767
+ const count = effect.colors?.length ?? 0;
1768
+ if (["duotone", "clrChange"].includes(effect.name) && count !== 2 || effect.name === "clrRepl" && count !== 1 || effect.name === "alphaInv" && count > 1)
1769
+ throw new RangeError("Invalid picture effect colours");
1770
+ for (const [key, attribute2] of Object.entries(attrs[effect.name] ?? {})) {
1771
+ const value = effect.values?.[key];
1772
+ if (value === before?.values?.[key]) continue;
1773
+ if (value === void 0) node.removeAttribute(attribute2);
1774
+ else
1775
+ node.setAttribute(
1776
+ attribute2,
1777
+ String(Math.round(value * (key === "hue" ? 6e4 : key === "radiusEmu" ? 1 : 1e5)))
1778
+ );
1779
+ }
1780
+ if (effect.name === "alphaMod" && effect.values?.amount !== before?.values?.amount) {
1781
+ const cont = first(node, "cont", NS.a) ?? doc.createElementNS(NS.a, "a:cont");
1782
+ const fix = first(cont, "alphaModFix", NS.a) ?? doc.createElementNS(NS.a, "a:alphaModFix");
1783
+ fix.setAttribute("amt", String(Math.round((effect.values?.amount ?? 1) * 1e5)));
1784
+ if (!fix.parentNode) cont.appendChild(fix);
1785
+ if (!cont.parentNode) node.appendChild(cont);
1786
+ }
1787
+ if (effect.useAlpha !== before?.useAlpha) {
1788
+ if (effect.useAlpha === void 0) node.removeAttribute("useA");
1789
+ else node.setAttribute("useA", effect.useAlpha ? "1" : "0");
1790
+ }
1791
+ if (effect.grow !== before?.grow) {
1792
+ if (effect.grow === void 0) node.removeAttribute("grow");
1793
+ else node.setAttribute("grow", effect.grow ? "1" : "0");
1794
+ }
1795
+ if (JSON.stringify(effect.colors) !== JSON.stringify(before?.colors)) {
1796
+ if (effect.name === "duotone") {
1797
+ const old = elements(node).filter(
1798
+ (item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
1799
+ );
1800
+ for (let i = 0; i < (effect.colors?.length ?? 0); i++) {
1801
+ const holder = doc.createElementNS(NS.a, "a:holder");
1802
+ if (old[i]) holder.appendChild(doc.importNode(old[i], true));
1803
+ patchDrawingColorIn(holder, effect.colors[i]);
1804
+ const next = elements(holder)[0];
1805
+ if (old[i]) node.replaceChild(next, old[i]);
1806
+ else node.insertBefore(next, first(node, "extLst", NS.a) ?? null);
1807
+ }
1808
+ } else if (effect.name === "clrChange") {
1809
+ for (const [i, name] of ["clrFrom", "clrTo"].entries()) {
1810
+ const holder = first(node, name, NS.a) ?? doc.createElementNS(NS.a, `a:${name}`);
1811
+ if (effect.colors?.[i]) patchDrawingColorIn(holder, effect.colors[i]);
1812
+ if (!holder.parentNode) node.insertBefore(holder, first(node, "extLst", NS.a) ?? null);
1813
+ }
1814
+ } else if (effect.colors?.[0]) patchDrawingColorIn(node, effect.colors[0]);
1815
+ }
1816
+ if (!parseStandardPictureEffect(node)) throw new RangeError("Invalid picture effect values");
1583
1817
  }
1584
1818
 
1585
1819
  // drawingml/picture-effects.ts
@@ -1619,14 +1853,19 @@ function readPictureEffect(name, attribute2) {
1619
1853
  function parsePictureEffects(blip) {
1620
1854
  if (!blip) return [];
1621
1855
  return elements(blip).map((node) => ({
1622
- ...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) : void 0) ?? { kind: "unsupported", name: node.localName },
1856
+ ...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) ?? parseStandardPictureEffect(node) ?? parseArtisticPictureExtension(node) : void 0) ?? { kind: "unsupported", name: node.localName },
1623
1857
  sourceXml: buildXml(node)
1624
1858
  }));
1625
1859
  }
1626
1860
  function applyPictureEffects(blip, effects) {
1627
1861
  if (JSON.stringify(parsePictureEffects(blip)) === JSON.stringify(effects)) return;
1628
1862
  const nodes = effects.map((effect) => {
1629
- const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind;
1863
+ const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind === "artistic" ? "extLst" : effect.kind === "standard" ? effect.name : effect.kind;
1864
+ if (effect.kind === "artistic") {
1865
+ const before = effect.sourceXml ? parseArtisticPictureExtension(parseXml(effect.sourceXml).documentElement) : void 0;
1866
+ if (!effect.baked || !before || before.name !== effect.name || before.radius !== effect.radius)
1867
+ throw new Error("Artistic authoring requires a host-generated baked picture cache");
1868
+ }
1630
1869
  const source2 = effect.sourceXml ? parseXml(effect.sourceXml).documentElement : void 0;
1631
1870
  if (effect.kind === "unsupported" && !source2)
1632
1871
  throw new Error("An unsupported picture effect needs source XML");
@@ -1653,12 +1892,157 @@ function applyPictureEffects(blip, effects) {
1653
1892
  if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
1654
1893
  set2("amt", effect.amount);
1655
1894
  }
1895
+ if (effect.kind === "standard") applyStandardPictureEffect(node, effect);
1656
1896
  return node;
1657
1897
  });
1658
1898
  for (const node of elements(blip)) blip.removeChild(node);
1659
1899
  for (const node of nodes) blip.appendChild(node);
1660
1900
  }
1661
1901
 
1902
+ // drawingml/picture-layout.ts
1903
+ function parsePictureLayout(fill) {
1904
+ const out = {};
1905
+ const rot = fill.getAttribute("rotWithShape");
1906
+ if (rot !== null) out.rotWithShape = rot !== "0" && rot !== "false";
1907
+ const dpi = Number(fill.getAttribute("dpi"));
1908
+ if (fill.hasAttribute("dpi") && Number.isFinite(dpi) && dpi > 0) out.dpi = dpi;
1909
+ const tile = first(fill, "tile", NS.a);
1910
+ if (tile) {
1911
+ const value = {};
1912
+ for (const [key, attr3] of [
1913
+ ["scaleX", "sx"],
1914
+ ["scaleY", "sy"]
1915
+ ]) {
1916
+ const n = picturePercentage(tile.getAttribute(attr3));
1917
+ if (n !== void 0) value[key] = n;
1918
+ }
1919
+ for (const [key, attr3] of [
1920
+ ["offsetXEmu", "tx"],
1921
+ ["offsetYEmu", "ty"]
1922
+ ]) {
1923
+ const raw2 = tile.getAttribute(attr3);
1924
+ const n = raw2 === null ? NaN : Number(raw2);
1925
+ if (Number.isSafeInteger(n)) value[key] = n;
1926
+ }
1927
+ const alignment = tile.getAttribute("algn");
1928
+ if (alignment) value.alignment = alignment;
1929
+ const flip = tile.getAttribute("flip");
1930
+ if (flip && ["none", "x", "y", "xy"].includes(flip))
1931
+ value.flip = flip;
1932
+ out.tile = value;
1933
+ }
1934
+ const rect2 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
1935
+ if (rect2)
1936
+ out.fillRect = {
1937
+ l: picturePercentage(rect2.getAttribute("l")) ?? 0,
1938
+ t: picturePercentage(rect2.getAttribute("t")) ?? 0,
1939
+ r: picturePercentage(rect2.getAttribute("r")) ?? 0,
1940
+ b: picturePercentage(rect2.getAttribute("b")) ?? 0
1941
+ };
1942
+ return out;
1943
+ }
1944
+ function applyPictureLayout(fill, layout2) {
1945
+ const before = parsePictureLayout(fill);
1946
+ const attr3 = (node, name, value, old) => {
1947
+ if (value === old) return;
1948
+ if (value === void 0) node.removeAttribute(name);
1949
+ else node.setAttribute(name, String(value));
1950
+ };
1951
+ if (layout2.rotWithShape !== before.rotWithShape)
1952
+ attr3(
1953
+ fill,
1954
+ "rotWithShape",
1955
+ layout2.rotWithShape === void 0 ? void 0 : layout2.rotWithShape ? "1" : "0",
1956
+ void 0
1957
+ );
1958
+ if (layout2.dpi !== before.dpi) {
1959
+ if (layout2.dpi !== void 0 && (!Number.isSafeInteger(layout2.dpi) || layout2.dpi <= 0))
1960
+ throw new RangeError("Invalid picture DPI");
1961
+ attr3(fill, "dpi", layout2.dpi, void 0);
1962
+ }
1963
+ const make = (parent, name) => {
1964
+ const old = first(parent, name, NS.a);
1965
+ if (old) return old;
1966
+ const node = fill.ownerDocument.createElementNS(NS.a, `a:${name}`);
1967
+ parent.insertBefore(node, first(parent, "extLst", NS.a) ?? null);
1968
+ return node;
1969
+ };
1970
+ if (layout2.tile) {
1971
+ const stretch = first(fill, "stretch", NS.a);
1972
+ if (stretch) fill.removeChild(stretch);
1973
+ const tile = make(fill, "tile");
1974
+ for (const [key, name] of [
1975
+ ["scaleX", "sx"],
1976
+ ["scaleY", "sy"],
1977
+ ["offsetXEmu", "tx"],
1978
+ ["offsetYEmu", "ty"]
1979
+ ]) {
1980
+ const n = layout2.tile[key];
1981
+ if (n !== void 0 && (!Number.isFinite(n) || (name === "sx" || name === "sy" ? n <= 0 : !Number.isSafeInteger(n))))
1982
+ throw new RangeError("Invalid picture tile");
1983
+ if (n !== before.tile?.[key])
1984
+ attr3(
1985
+ tile,
1986
+ name,
1987
+ n === void 0 ? void 0 : Math.round(n * (name === "sx" || name === "sy" ? 1e5 : 1)),
1988
+ void 0
1989
+ );
1990
+ }
1991
+ if (layout2.tile.alignment !== before.tile?.alignment) {
1992
+ if (layout2.tile.alignment && !["tl", "t", "tr", "l", "ctr", "r", "bl", "b", "br"].includes(layout2.tile.alignment))
1993
+ throw new RangeError("Invalid picture tile alignment");
1994
+ attr3(tile, "algn", layout2.tile.alignment, void 0);
1995
+ }
1996
+ if (layout2.tile.flip !== void 0 && !["none", "x", "y", "xy"].includes(layout2.tile.flip))
1997
+ throw new RangeError("Invalid picture tile flip");
1998
+ if (layout2.tile.flip !== before.tile?.flip) attr3(tile, "flip", layout2.tile.flip, void 0);
1999
+ } else if (before.tile || layout2.fillRect) {
2000
+ const tile = first(fill, "tile", NS.a);
2001
+ if (tile) fill.removeChild(tile);
2002
+ const rect2 = make(make(fill, "stretch"), "fillRect");
2003
+ for (const key of ["l", "t", "r", "b"]) {
2004
+ const n = layout2.fillRect?.[key];
2005
+ if (n !== void 0 && !Number.isFinite(n))
2006
+ throw new RangeError("Invalid picture fill rectangle");
2007
+ if (n !== before.fillRect?.[key])
2008
+ attr3(rect2, key, n === void 0 ? void 0 : Math.round(n * 1e5), void 0);
2009
+ }
2010
+ }
2011
+ }
2012
+
2013
+ // drawingml/picture-crop.ts
2014
+ var SIDES2 = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
2015
+ function parsePictureCrop(blipFill) {
2016
+ const rect2 = first(blipFill, "srcRect", NS.a);
2017
+ if (!rect2) return void 0;
2018
+ const result = {};
2019
+ for (const [attr3, key] of Object.entries(SIDES2)) {
2020
+ const raw2 = rect2.getAttribute(attr3);
2021
+ if (raw2 === null || !raw2.trim()) continue;
2022
+ const percent = raw2.endsWith("%");
2023
+ const value = Number(percent ? raw2.slice(0, -1) : raw2) / (percent ? 100 : 1e5);
2024
+ if (Number.isFinite(value)) result[key] = value;
2025
+ }
2026
+ return result;
2027
+ }
2028
+ function applyPictureCrop(blipFill, crop) {
2029
+ let rect2 = first(blipFill, "srcRect", NS.a);
2030
+ if (!rect2 && crop && Object.values(crop).some((value) => value !== void 0)) {
2031
+ rect2 = blipFill.ownerDocument.createElementNS(NS.a, "a:srcRect");
2032
+ const blip = first(blipFill, "blip", NS.a);
2033
+ blipFill.insertBefore(rect2, blip?.nextSibling ?? blipFill.firstChild);
2034
+ }
2035
+ if (!rect2) return;
2036
+ for (const [attr3, key] of Object.entries(SIDES2)) {
2037
+ const value = crop?.[key];
2038
+ if (value === void 0) rect2.removeAttribute(attr3);
2039
+ else {
2040
+ if (!Number.isFinite(value)) throw new RangeError("Picture crop must be finite");
2041
+ rect2.setAttribute(attr3, String(Math.round(value * 1e5)));
2042
+ }
2043
+ }
2044
+ }
2045
+
1662
2046
  // drawingml/picture-fill.ts
1663
2047
  function parseDrawingPictureFill(fill) {
1664
2048
  const blip = first(fill, "blip", NS.a);
@@ -1666,13 +2050,32 @@ function parseDrawingPictureFill(fill) {
1666
2050
  const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
1667
2051
  const crop = parsePictureCrop(fill);
1668
2052
  const effects = parsePictureEffects(blip);
1669
- const tile = first(fill, "tile", NS.a);
1670
- const rect2 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
1671
- const unsupported2 = [
1672
- ...tile ? ["tile"] : [],
1673
- ...rect2 && ["l", "t", "r", "b"].some((key) => Number(rect2.getAttribute(key) ?? 0) !== 0) ? ["fillRect"] : [],
1674
- ...fill.getAttribute("rotWithShape") === "0" || fill.getAttribute("rotWithShape") === "false" ? ["rotWithShape"] : []
1675
- ];
2053
+ const layout2 = parsePictureLayout(fill);
2054
+ const unsupported2 = [];
2055
+ const tile = first(fill, "tile", NS.a), stretch = first(fill, "stretch", NS.a);
2056
+ if (tile && stretch) unsupported2.push("tile/stretch-choice");
2057
+ if (tile) {
2058
+ for (const [attr3, key] of [
2059
+ ["sx", "scaleX"],
2060
+ ["sy", "scaleY"],
2061
+ ["tx", "offsetXEmu"],
2062
+ ["ty", "offsetYEmu"]
2063
+ ])
2064
+ if (tile.hasAttribute(attr3) && (layout2.tile?.[key] === void 0 || (attr3 === "sx" || attr3 === "sy") && layout2.tile[key] <= 0))
2065
+ unsupported2.push(`tile:${attr3}`);
2066
+ if (tile.hasAttribute("algn") && !["tl", "t", "tr", "l", "ctr", "r", "bl", "b", "br"].includes(tile.getAttribute("algn") ?? ""))
2067
+ unsupported2.push("tile:algn");
2068
+ if (tile.hasAttribute("flip") && !layout2.tile?.flip) unsupported2.push("tile:flip");
2069
+ }
2070
+ const rect2 = first(stretch, "fillRect", NS.a);
2071
+ if (rect2)
2072
+ for (const key of ["l", "t", "r", "b"]) {
2073
+ const raw2 = rect2.getAttribute(key);
2074
+ if (raw2 !== null && !/^[-+]?(?:\d+\.?\d*|\.\d+)%?$/.test(raw2))
2075
+ unsupported2.push(`fillRect:${key}`);
2076
+ }
2077
+ if (fill.hasAttribute("rotWithShape") && !["0", "1", "true", "false"].includes(fill.getAttribute("rotWithShape") ?? ""))
2078
+ unsupported2.push("rotWithShape");
1676
2079
  return {
1677
2080
  kind: "picture",
1678
2081
  sourceXml: buildXml(fill),
@@ -1680,6 +2083,7 @@ function parseDrawingPictureFill(fill) {
1680
2083
  ...linkRelId ? { linkRelId } : {},
1681
2084
  ...crop ? { crop } : {},
1682
2085
  ...effects.length ? { effects } : {},
2086
+ ...Object.keys(layout2).length ? { layout: layout2 } : {},
1683
2087
  ...unsupported2.length ? { unsupportedPicture: unsupported2 } : {}
1684
2088
  };
1685
2089
  }
@@ -1811,80 +2215,6 @@ function drawingDashLength(value) {
1811
2215
  return Number.isSafeInteger(number2) && number2 <= 2147483647 ? number2 : void 0;
1812
2216
  }
1813
2217
 
1814
- // drawingml/write-color.ts
1815
- var ELEMENTS = {
1816
- srgb: "srgbClr",
1817
- scheme: "schemeClr",
1818
- system: "sysClr",
1819
- preset: "prstClr",
1820
- scrgb: "scrgbClr",
1821
- hsl: "hslClr"
1822
- };
1823
- function drawingColorXml(color) {
1824
- const local = ELEMENTS[color.kind];
1825
- const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
1826
- const root = doc.documentElement;
1827
- if (color.kind === "scrgb" || color.kind === "hsl") {
1828
- const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
1829
- const values = color.value.split(",");
1830
- keys.forEach((key, i) => root.setAttribute(key, values[i] ?? "0"));
1831
- } else root.setAttribute("val", color.value);
1832
- if (color.fallback !== void 0 && color.kind === "system")
1833
- root.setAttribute("lastClr", color.fallback);
1834
- for (const transform2 of color.transforms) {
1835
- if (!/^[A-Za-z_][\w.-]*$/.test(transform2.name))
1836
- throw new Error(`Invalid DrawingML transform ${transform2.name}`);
1837
- const node = doc.createElementNS(NS.a, `a:${transform2.name}`);
1838
- if (transform2.value !== "") node.setAttribute("val", transform2.value);
1839
- root.appendChild(node);
1840
- }
1841
- return buildXml(doc);
1842
- }
1843
-
1844
- // drawingml/patch-color.ts
1845
- function patchDrawingColorIn(container, color) {
1846
- const old = elements(container).find((node) => parseDrawingColor(node));
1847
- const before = parseDrawingColorIn(container);
1848
- if (!old || !before || before.kind !== color.kind) {
1849
- const next = container.ownerDocument.importNode(
1850
- parseXml(drawingColorXml(color)).documentElement,
1851
- true
1852
- );
1853
- if (old) container.replaceChild(next, old);
1854
- else container.insertBefore(next, container.firstChild);
1855
- return;
1856
- }
1857
- if (before.value !== color.value) {
1858
- if (color.kind === "scrgb" || color.kind === "hsl") {
1859
- const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
1860
- const values = color.value.split(",");
1861
- keys.forEach((key, index) => old.setAttribute(key, values[index] ?? "0"));
1862
- } else old.setAttribute("val", color.value);
1863
- }
1864
- if (before.fallback !== color.fallback && color.kind === "system") {
1865
- if (color.fallback === void 0) old.removeAttribute("lastClr");
1866
- else old.setAttribute("lastClr", color.fallback);
1867
- }
1868
- const originals = elements(old);
1869
- color.transforms.forEach((transform2, index) => {
1870
- const source2 = originals[index];
1871
- if (source2?.localName === transform2.name) {
1872
- if (before.transforms[index]?.value !== transform2.value) {
1873
- if (transform2.value === "") source2.removeAttribute("val");
1874
- else source2.setAttribute("val", transform2.value);
1875
- }
1876
- return;
1877
- }
1878
- if (!/^[A-Za-z_][\w.-]*$/u.test(transform2.name))
1879
- throw new Error("Invalid DrawingML colour transform");
1880
- const next = old.ownerDocument.createElementNS(NS.a, `a:${transform2.name}`);
1881
- if (transform2.value !== "") next.setAttribute("val", transform2.value);
1882
- if (source2) old.replaceChild(next, source2);
1883
- else old.appendChild(next);
1884
- });
1885
- for (const extra of originals.slice(color.transforms.length)) old.removeChild(extra);
1886
- }
1887
-
1888
2218
  // drawingml/write-pattern-picture.ts
1889
2219
  function drawingPatternPictureXml(fill) {
1890
2220
  const name = fill.kind === "pattern" ? "pattFill" : "blipFill";
@@ -1946,7 +2276,8 @@ function drawingPatternPictureXml(fill) {
1946
2276
  applyPictureCrop(root, fill.crop);
1947
2277
  if (fill.effects !== void 0 && JSON.stringify(before?.kind === "picture" ? before.effects ?? [] : []) !== JSON.stringify(fill.effects ?? []))
1948
2278
  applyPictureEffects(blip, fill.effects ?? []);
1949
- if (!fill.sourceXml) {
2279
+ if (fill.layout !== void 0) applyPictureLayout(root, fill.layout);
2280
+ if (!fill.sourceXml && !fill.layout?.tile && !first(root, "stretch", NS.a)) {
1950
2281
  const stretch = doc.createElementNS(NS.a, "a:stretch");
1951
2282
  stretch.appendChild(doc.createElementNS(NS.a, "a:fillRect"));
1952
2283
  root.appendChild(stretch);
@@ -6694,8 +7025,33 @@ function reconcileBookmarks(doc, starts, ends, names, baseNames, nextId) {
6694
7025
  return { starts: keptStarts, ends: keptEnds };
6695
7026
  }
6696
7027
 
7028
+ // docx/permission-markers.ts
7029
+ var setAttribute4 = (element4, local, value) => element4.setAttributeNS(WORD_NS, `w:${local}`, value);
7030
+ var isPermission = (element4) => named2(element4, "permStart") || named2(element4, "permEnd");
7031
+ function changedPermissionMarkers(doc, paragraph2, base, source2, length) {
7032
+ if (!base || JSON.stringify(paragraph2.permissions ?? null) === JSON.stringify(base.permissions ?? null))
7033
+ return void 0;
7034
+ const spans = (list2) => list2?.some((r) => r.fromPrevious || r.toNext);
7035
+ if (spans(paragraph2.permissions) || spans(base.permissions)) return void 0;
7036
+ const drop = new Set(source2.filter(isPermission));
7037
+ const added = [];
7038
+ for (const range of paragraph2.permissions ?? []) {
7039
+ const start = makeW(doc, "permStart");
7040
+ setAttribute4(start, "id", range.id);
7041
+ if (range.group !== void 0) setAttribute4(start, "edGrp", range.group);
7042
+ if (range.user !== void 0) setAttribute4(start, "ed", range.user);
7043
+ const end = makeW(doc, "permEnd");
7044
+ setAttribute4(end, "id", range.id);
7045
+ added.push(
7046
+ { element: start, position: Math.min(range.from, length), source: range.from, opening: true },
7047
+ { element: end, position: Math.min(range.to, length), source: range.to, opening: false }
7048
+ );
7049
+ }
7050
+ return { drop, added };
7051
+ }
7052
+
6697
7053
  // docx/numbering-write.ts
6698
- function setAttribute4(element4, local, value) {
7054
+ function setAttribute5(element4, local, value) {
6699
7055
  element4.setAttributeNS(WORD_NS, `w:${local}`, value);
6700
7056
  }
6701
7057
  function sameNumbering(a2, b) {
@@ -6707,16 +7063,16 @@ function writeNumberingProperties(doc, props, paragraph2, base) {
6707
7063
  if (!paragraph2.numbering) return;
6708
7064
  const numPr = makeW(doc, "numPr");
6709
7065
  const ilvl = makeW(doc, "ilvl");
6710
- setAttribute4(ilvl, "val", String(paragraph2.numbering.level));
7066
+ setAttribute5(ilvl, "val", String(paragraph2.numbering.level));
6711
7067
  numPr.appendChild(ilvl);
6712
7068
  const numId = makeW(doc, "numId");
6713
- setAttribute4(numId, "val", String(paragraph2.numbering.numId));
7069
+ setAttribute5(numId, "val", String(paragraph2.numbering.numId));
6714
7070
  numPr.appendChild(numId);
6715
7071
  props.appendChild(numPr);
6716
7072
  }
6717
7073
 
6718
7074
  // docx/write-run-extra.ts
6719
- function setAttribute5(element4, local, value) {
7075
+ function setAttribute6(element4, local, value) {
6720
7076
  element4.setAttributeNS(WORD_NS, `w:${local}`, value);
6721
7077
  }
6722
7078
  function removeChildren2(element4, local) {
@@ -6726,7 +7082,7 @@ function setToggle(doc, props, local, value) {
6726
7082
  removeChildren2(props, local);
6727
7083
  if (value === void 0) return;
6728
7084
  const element4 = makeW(doc, local);
6729
- if (!value) setAttribute5(element4, "val", "0");
7085
+ if (!value) setAttribute6(element4, "val", "0");
6730
7086
  props.appendChild(element4);
6731
7087
  }
6732
7088
  function setExtendedRunProperties(doc, props, run2, base) {
@@ -6736,7 +7092,7 @@ function setExtendedRunProperties(doc, props, run2, base) {
6736
7092
  removeChildren2(props, "rStyle");
6737
7093
  if (run2.style) {
6738
7094
  const style = makeW(doc, "rStyle");
6739
- setAttribute5(style, "val", run2.style);
7095
+ setAttribute6(style, "val", run2.style);
6740
7096
  props.insertBefore(style, props.firstChild);
6741
7097
  }
6742
7098
  }
@@ -6753,14 +7109,14 @@ function setExtendedRunProperties(doc, props, run2, base) {
6753
7109
  removeChildren2(props, local);
6754
7110
  if (run2[key] === void 0) continue;
6755
7111
  const element4 = makeW(doc, local);
6756
- setAttribute5(element4, "val", String(run2[key]));
7112
+ setAttribute6(element4, "val", String(run2[key]));
6757
7113
  props.appendChild(element4);
6758
7114
  }
6759
7115
  if (changed("characterSpacingTwips")) {
6760
7116
  removeChildren2(props, "spacing");
6761
7117
  if (run2.characterSpacingTwips !== void 0) {
6762
7118
  const spacing2 = makeW(doc, "spacing");
6763
- setAttribute5(spacing2, "val", String(Math.round(run2.characterSpacingTwips)));
7119
+ setAttribute6(spacing2, "val", String(Math.round(run2.characterSpacingTwips)));
6764
7120
  props.appendChild(spacing2);
6765
7121
  }
6766
7122
  }
@@ -6768,14 +7124,14 @@ function setExtendedRunProperties(doc, props, run2, base) {
6768
7124
  removeChildren2(props, "shd");
6769
7125
  if (run2.shadingFill || run2.shadingThemeFill) {
6770
7126
  const shd = makeW(doc, "shd");
6771
- setAttribute5(shd, "val", "clear");
6772
- setAttribute5(shd, "fill", run2.shadingFill ? run2.shadingFill.replace(/^#/, "") : "auto");
7127
+ setAttribute6(shd, "val", "clear");
7128
+ setAttribute6(shd, "fill", run2.shadingFill ? run2.shadingFill.replace(/^#/, "") : "auto");
6773
7129
  if (run2.shadingThemeFill) {
6774
- setAttribute5(shd, "themeFill", run2.shadingThemeFill.token);
7130
+ setAttribute6(shd, "themeFill", run2.shadingThemeFill.token);
6775
7131
  if (run2.shadingThemeFill.tint !== void 0)
6776
- setAttribute5(shd, "themeFillTint", fractionToThemeByte(run2.shadingThemeFill.tint));
7132
+ setAttribute6(shd, "themeFillTint", fractionToThemeByte(run2.shadingThemeFill.tint));
6777
7133
  if (run2.shadingThemeFill.shade !== void 0)
6778
- setAttribute5(shd, "themeFillShade", fractionToThemeByte(run2.shadingThemeFill.shade));
7134
+ setAttribute6(shd, "themeFillShade", fractionToThemeByte(run2.shadingThemeFill.shade));
6779
7135
  }
6780
7136
  props.appendChild(shd);
6781
7137
  }
@@ -7414,25 +7770,25 @@ function parseCustomGeometry(custom, width, height) {
7414
7770
  const value = (node, name) => operand(node.getAttribute(name), vars);
7415
7771
  for (const node of elements(path3)) {
7416
7772
  if (node.namespaceURI !== NS.a) return void 0;
7417
- const points = children(node, "pt", NS.a).map((point) => ({
7773
+ const points2 = children(node, "pt", NS.a).map((point) => ({
7418
7774
  x: value(point, "x"),
7419
7775
  y: value(point, "y")
7420
7776
  }));
7421
- if (points.some((point) => !Number.isFinite(point.x) || !Number.isFinite(point.y)))
7777
+ if (points2.some((point) => !Number.isFinite(point.x) || !Number.isFinite(point.y)))
7422
7778
  return void 0;
7423
- const [p0, p1, p2] = points;
7779
+ const [p0, p1, p2] = points2;
7424
7780
  switch (node.localName) {
7425
7781
  case "moveTo":
7426
7782
  case "lnTo":
7427
- if (points.length !== 1 || !p0) return void 0;
7783
+ if (points2.length !== 1 || !p0) return void 0;
7428
7784
  commands.push({ op: node.localName === "moveTo" ? "M" : "L", ...p0 });
7429
7785
  break;
7430
7786
  case "quadBezTo":
7431
- if (points.length !== 2 || !p0 || !p1) return void 0;
7787
+ if (points2.length !== 2 || !p0 || !p1) return void 0;
7432
7788
  commands.push({ op: "Q", x1: p0.x, y1: p0.y, ...p1 });
7433
7789
  break;
7434
7790
  case "cubicBezTo":
7435
- if (points.length !== 3 || !p0 || !p1 || !p2) return void 0;
7791
+ if (points2.length !== 3 || !p0 || !p1 || !p2) return void 0;
7436
7792
  commands.push({ op: "C", x1: p0.x, y1: p0.y, x2: p1.x, y2: p1.y, ...p2 });
7437
7793
  break;
7438
7794
  case "arcTo": {
@@ -7678,8 +8034,8 @@ function parseDrawingRunProperties(element4) {
7678
8034
 
7679
8035
  // drawingml/read-paragraph-properties.ts
7680
8036
  function parseDrawingTextSpacing(element4) {
7681
- const points = integerAttribute(first(element4, "spcPts", NS.a), "val");
7682
- if (points !== void 0) return { unit: "points", value: points / 100 };
8037
+ const points2 = integerAttribute(first(element4, "spcPts", NS.a), "val");
8038
+ if (points2 !== void 0) return { unit: "points", value: points2 / 100 };
7683
8039
  const percent = parseOoxmlPercent(first(element4, "spcPct", NS.a)?.getAttribute("val"));
7684
8040
  if (percent !== void 0) return { unit: "percent", value: percent };
7685
8041
  return void 0;
@@ -13621,9 +13977,9 @@ var heart = {
13621
13977
  }
13622
13978
  ]
13623
13979
  };
13624
- function buildIrregularSeal(name, points) {
13980
+ function buildIrregularSeal(name, points2) {
13625
13981
  const commands = [];
13626
- const first3 = points[0];
13982
+ const first3 = points2[0];
13627
13983
  if (!first3) {
13628
13984
  return {
13629
13985
  name,
@@ -13632,8 +13988,8 @@ function buildIrregularSeal(name, points) {
13632
13988
  };
13633
13989
  }
13634
13990
  commands.push({ kind: "moveTo", x: String(first3[0]), y: String(first3[1]) });
13635
- for (let i = 1; i < points.length; i++) {
13636
- const p = points[i];
13991
+ for (let i = 1; i < points2.length; i++) {
13992
+ const p = points2[i];
13637
13993
  commands.push({ kind: "lnTo", x: String(p[0]), y: String(p[1]) });
13638
13994
  }
13639
13995
  commands.push({ kind: "close" });
@@ -18214,7 +18570,7 @@ function isSpace(ch) {
18214
18570
  return ch === " " || ch === " " || ch === "\n" || ch === "\r";
18215
18571
  }
18216
18572
  function parseAttributes(source2) {
18217
- const attrs2 = {};
18573
+ const attrs3 = {};
18218
18574
  let i = 0;
18219
18575
  const n = source2.length;
18220
18576
  while (i < n) {
@@ -18249,9 +18605,9 @@ function parseAttributes(source2) {
18249
18605
  if (name === "xmlns" || name.startsWith("xmlns:")) {
18250
18606
  continue;
18251
18607
  }
18252
- attrs2[localName(name)] = decodeEntities(value);
18608
+ attrs3[localName(name)] = decodeEntities(value);
18253
18609
  }
18254
- return attrs2;
18610
+ return attrs3;
18255
18611
  }
18256
18612
  function tagEnd2(xml, from) {
18257
18613
  let quote = "";
@@ -18377,14 +18733,14 @@ function numOrNaN(value) {
18377
18733
  function relation(value) {
18378
18734
  return value === "ch" || value === "des" ? value : "self";
18379
18735
  }
18380
- function parseIterator(attrs2) {
18736
+ function parseIterator(attrs3) {
18381
18737
  return {
18382
- axis: list(attrs2.axis),
18383
- ptType: list(attrs2.ptType),
18384
- hideLastTrans: list(attrs2.hideLastTrans).map((v) => v === "1" || v === "true"),
18385
- st: numberList(attrs2.st),
18386
- cnt: numberList(attrs2.cnt),
18387
- step: numberList(attrs2.step)
18738
+ axis: list(attrs3.axis),
18739
+ ptType: list(attrs3.ptType),
18740
+ hideLastTrans: list(attrs3.hideLastTrans).map((v) => v === "1" || v === "true"),
18741
+ st: numberList(attrs3.st),
18742
+ cnt: numberList(attrs3.cnt),
18743
+ step: numberList(attrs3.step)
18388
18744
  };
18389
18745
  }
18390
18746
  function parseAlgorithm(element4) {
@@ -18415,41 +18771,41 @@ function parseShape2(element4) {
18415
18771
  adj
18416
18772
  };
18417
18773
  }
18418
- function parseConstraint(attrs2) {
18419
- const op = attrs2.op;
18774
+ function parseConstraint(attrs3) {
18775
+ const op = attrs3.op;
18420
18776
  return {
18421
- type: attrs2.type ?? "none",
18422
- for: relation(attrs2.for),
18423
- forName: attrs2.forName || void 0,
18424
- ptType: attrs2.ptType ?? "all",
18425
- refType: attrs2.refType ?? "none",
18426
- refFor: relation(attrs2.refFor),
18427
- refForName: attrs2.refForName || void 0,
18428
- refPtType: attrs2.refPtType ?? "all",
18777
+ type: attrs3.type ?? "none",
18778
+ for: relation(attrs3.for),
18779
+ forName: attrs3.forName || void 0,
18780
+ ptType: attrs3.ptType ?? "all",
18781
+ refType: attrs3.refType ?? "none",
18782
+ refFor: relation(attrs3.refFor),
18783
+ refForName: attrs3.refForName || void 0,
18784
+ refPtType: attrs3.refPtType ?? "all",
18429
18785
  op: op === "equ" || op === "gte" || op === "lte" ? op : "none",
18430
- val: num(attrs2.val, 0),
18431
- hasVal: attrs2.val !== void 0,
18432
- fact: num(attrs2.fact, 1)
18786
+ val: num(attrs3.val, 0),
18787
+ hasVal: attrs3.val !== void 0,
18788
+ fact: num(attrs3.fact, 1)
18433
18789
  };
18434
18790
  }
18435
- function parseRule(attrs2) {
18791
+ function parseRule(attrs3) {
18436
18792
  return {
18437
- type: attrs2.type ?? "none",
18438
- for: relation(attrs2.for),
18439
- forName: attrs2.forName || void 0,
18440
- ptType: attrs2.ptType ?? "all",
18441
- val: numOrNaN(attrs2.val),
18442
- fact: numOrNaN(attrs2.fact),
18443
- max: numOrNaN(attrs2.max)
18793
+ type: attrs3.type ?? "none",
18794
+ for: relation(attrs3.for),
18795
+ forName: attrs3.forName || void 0,
18796
+ ptType: attrs3.ptType ?? "all",
18797
+ val: numOrNaN(attrs3.val),
18798
+ fact: numOrNaN(attrs3.fact),
18799
+ max: numOrNaN(attrs3.max)
18444
18800
  };
18445
18801
  }
18446
- function parseCondition(attrs2) {
18802
+ function parseCondition(attrs3) {
18447
18803
  return {
18448
- ...parseIterator(attrs2),
18449
- func: attrs2.func ?? "cnt",
18450
- arg: attrs2.arg,
18451
- op: attrs2.op ?? "equ",
18452
- val: attrs2.val ?? ""
18804
+ ...parseIterator(attrs3),
18805
+ func: attrs3.func ?? "cnt",
18806
+ arg: attrs3.arg,
18807
+ op: attrs3.op ?? "equ",
18808
+ val: attrs3.val ?? ""
18453
18809
  };
18454
18810
  }
18455
18811
  function parseBody(element4, state) {
@@ -18655,15 +19011,15 @@ function isLastSiblingTransition(point) {
18655
19011
  }
18656
19012
  return false;
18657
19013
  }
18658
- function windowPoints(points, st = 1, cnt = 0, step = 1) {
18659
- if (points.length === 0) {
19014
+ function windowPoints(points2, st = 1, cnt = 0, step = 1) {
19015
+ if (points2.length === 0) {
18660
19016
  return [];
18661
19017
  }
18662
19018
  const stride = step === 0 ? 1 : step;
18663
- let index = st > 0 ? st - 1 : st < 0 ? points.length + st : 0;
19019
+ let index = st > 0 ? st - 1 : st < 0 ? points2.length + st : 0;
18664
19020
  const out = [];
18665
- while (index >= 0 && index < points.length) {
18666
- out.push(points[index]);
19021
+ while (index >= 0 && index < points2.length) {
19022
+ out.push(points2[index]);
18667
19023
  if (cnt > 0 && out.length >= cnt) {
18668
19024
  break;
18669
19025
  }
@@ -18675,12 +19031,12 @@ function iterateStep(point, iterator, step) {
18675
19031
  const axis = iterator.axis[step] ?? "none";
18676
19032
  const ptType = iterator.ptType[step] ?? iterator.ptType[iterator.ptType.length - 1] ?? "all";
18677
19033
  const hideLast = (iterator.hideLastTrans[step] ?? true) && SIBLING_AXES.has(axis);
18678
- let points = axisPoints(point, axis).filter((candidate) => matchesPointType(candidate, ptType));
19034
+ let points2 = axisPoints(point, axis).filter((candidate) => matchesPointType(candidate, ptType));
18679
19035
  if (hideLast) {
18680
- points = points.filter((candidate) => !isLastSiblingTransition(candidate));
19036
+ points2 = points2.filter((candidate) => !isLastSiblingTransition(candidate));
18681
19037
  }
18682
19038
  return windowPoints(
18683
- points,
19039
+ points2,
18684
19040
  iterator.st[step] ?? 1,
18685
19041
  iterator.cnt[step] ?? 0,
18686
19042
  iterator.step[step] ?? 1
@@ -22550,7 +22906,13 @@ function buildRenderedNode(node, index, nodeById, palette, style, mergedSourceId
22550
22906
  fontSize: 0,
22551
22907
  textX: x + width / 2,
22552
22908
  textY: y + height / 2,
22553
- nodeId: primary?.id,
22909
+ // Picture roles often omit presOf: they present the current point's image, not its text.
22910
+ nodeId: primary?.id ?? (node.shape?.blipPhldr ? node.point.source?.id : void 0),
22911
+ picturePlaceholder: node.shape?.blipPhldr,
22912
+ layoutRole: node.name,
22913
+ contextNodeId: node.point.source?.id,
22914
+ textAlign: ["l", "ctr", "r"].includes(node.alg.params.parTxLTRAlign ?? "") ? node.alg.params.parTxLTRAlign : void 0,
22915
+ textVerticalAnchor: ["t", "ctr", "b"].includes(node.alg.params.txAnchorVert ?? "") ? node.alg.params.txAnchorVert : void 0,
22554
22916
  rotation: transform2.rotation === 0 ? void 0 : transform2.rotation,
22555
22917
  presetOverride: node.shape?.type ?? "roundRect",
22556
22918
  foldedNodeIds: foldedNodeIds.length > 0 ? foldedNodeIds : void 0,
@@ -22681,15 +23043,15 @@ function treeDepth(t, depth = 0) {
22681
23043
  }
22682
23044
 
22683
23045
  // diagram/layout/smartart-layout-interpreter-custom.ts
22684
- function parsePoints(points) {
22685
- return points.trim().split(/\s+/u).filter((pair) => pair.length > 0).map((pair) => {
23046
+ function parsePoints(points2) {
23047
+ return points2.trim().split(/\s+/u).filter((pair) => pair.length > 0).map((pair) => {
22686
23048
  const [x, y] = pair.split(",").map(Number);
22687
23049
  return [x, y];
22688
23050
  });
22689
23051
  }
22690
- function pointsBoundingBox(points) {
22691
- const xs = points.map(([x]) => x);
22692
- const ys = points.map(([, y]) => y);
23052
+ function pointsBoundingBox(points2) {
23053
+ const xs = points2.map(([x]) => x);
23054
+ const ys = points2.map(([, y]) => y);
22693
23055
  const minX = Math.min(...xs);
22694
23056
  const minY = Math.min(...ys);
22695
23057
  const maxX = Math.max(...xs);
@@ -22742,15 +23104,15 @@ function applyToCircle(node, custom, box) {
22742
23104
  };
22743
23105
  }
22744
23106
  function applyToPolygon(node, custom, box) {
22745
- const points = parsePoints(node.points);
22746
- const bbox = pointsBoundingBox(points);
23107
+ const points2 = parsePoints(node.points);
23108
+ const bbox = pointsBoundingBox(points2);
22747
23109
  const cx = bbox.x + bbox.width / 2;
22748
23110
  const cy = bbox.y + bbox.height / 2;
22749
23111
  const { x: scaleX, y: scaleY } = scaleRatios(custom);
22750
23112
  const flipX = custom.flipHorizontal ? -1 : 1;
22751
23113
  const flipY = custom.flipVertical ? -1 : 1;
22752
23114
  const { dx, dy } = positionNudge(custom, box);
22753
- const transformed = points.map(([x, y]) => {
23115
+ const transformed = points2.map(([x, y]) => {
22754
23116
  const relX = (x - cx) * scaleX * flipX;
22755
23117
  const relY = (y - cy) * scaleY * flipY;
22756
23118
  return `${cx + dx + relX},${cy + dy + relY}`;
@@ -23851,7 +24213,7 @@ function writeFabricatedDiagramData(data, ids, options = {}) {
23851
24213
  const docGuid = createModelId();
23852
24214
  const guidByNodeId = options.guidByNodeId ?? buildDiagramNodeGuidMap(data.nodes, createModelId);
23853
24215
  const presentationGuidByNodeId = options.presentationGuidByNodeId ?? buildDiagramPresentationGuidMap(data.nodes, createModelId);
23854
- const points = [docPointXml(docGuid, ids)];
24216
+ const points2 = [docPointXml(docGuid, ids)];
23855
24217
  const connections = [];
23856
24218
  const nextSrcOrd = /* @__PURE__ */ new Map();
23857
24219
  for (const node of data.nodes) {
@@ -23865,15 +24227,15 @@ function writeFabricatedDiagramData(data, ids, options = {}) {
23865
24227
  const cxnGuid = createModelId();
23866
24228
  const parTransGuid = createModelId();
23867
24229
  const sibTransGuid = createModelId();
23868
- points.push(contentPointXml(guid, node));
23869
- points.push(transPointXml(parTransGuid, "parTrans", cxnGuid));
23870
- points.push(transPointXml(sibTransGuid, "sibTrans", cxnGuid));
24230
+ points2.push(contentPointXml(guid, node));
24231
+ points2.push(transPointXml(parTransGuid, "parTrans", cxnGuid));
24232
+ points2.push(transPointXml(sibTransGuid, "sibTrans", cxnGuid));
23871
24233
  connections.push(
23872
24234
  `<dgm:cxn modelId="${cxnGuid}" srcId="${parentGuid}" destId="${guid}" srcOrd="${srcOrd}" destOrd="0" parTransId="${parTransGuid}" sibTransId="${sibTransGuid}"/>`
23873
24235
  );
23874
24236
  const presentationGuid = node.id ? presentationGuidByNodeId.get(node.id) : void 0;
23875
24237
  if (presentationGuid) {
23876
- points.push(
24238
+ points2.push(
23877
24239
  `<dgm:pt modelId="${presentationGuid}" type="pres"><dgm:prSet presAssocID="${guid}" presName="node" presStyleLbl="node1" presStyleIdx="${srcOrd}" presStyleCnt="${data.nodes.length}"/><dgm:spPr/></dgm:pt>`
23878
24240
  );
23879
24241
  connections.push(
@@ -23882,7 +24244,7 @@ function writeFabricatedDiagramData(data, ids, options = {}) {
23882
24244
  }
23883
24245
  }
23884
24246
  return `${DIAGRAM_XML_PROLOG}\r
23885
- <dgm:dataModel ${DIAGRAM_DATA_XMLNS}><dgm:ptLst>${points.join("")}</dgm:ptLst><dgm:cxnLst>${connections.join("")}</dgm:cxnLst><dgm:bg/><dgm:whole/>${dataModelExtXml(options.drawingRelId)}</dgm:dataModel>`;
24247
+ <dgm:dataModel ${DIAGRAM_DATA_XMLNS}><dgm:ptLst>${points2.join("")}</dgm:ptLst><dgm:cxnLst>${connections.join("")}</dgm:cxnLst><dgm:bg/><dgm:whole/>${dataModelExtXml(options.drawingRelId)}</dgm:dataModel>`;
23886
24248
  }
23887
24249
  function dataModelExtXml(drawingRelId) {
23888
24250
  if (!drawingRelId) {
@@ -24005,9 +24367,9 @@ function writeEditedDiagramData(xml, nodes, options = {}) {
24005
24367
  cxnLst = element2(doc, DGM, "dgm:cxnLst");
24006
24368
  ptLst.parentNode?.insertBefore(cxnLst, ptLst.nextSibling);
24007
24369
  }
24008
- const points = elements(ptLst).filter((el5) => el5.localName === "pt");
24009
- const pointById = new Map(points.map((pt) => [pt.getAttribute("modelId") ?? "", pt]));
24010
- const docPoint = points.find((pt) => pointType(pt) === "doc");
24370
+ const points2 = elements(ptLst).filter((el5) => el5.localName === "pt");
24371
+ const pointById = new Map(points2.map((pt) => [pt.getAttribute("modelId") ?? "", pt]));
24372
+ const docPoint = points2.find((pt) => pointType(pt) === "doc");
24011
24373
  const rootId = docPoint?.getAttribute("modelId");
24012
24374
  if (!rootId) throw new Error("The diagram data part has no document point.");
24013
24375
  const connections = () => elements(cxnLst).filter((el5) => el5.localName === "cxn");
@@ -24019,7 +24381,7 @@ function writeEditedDiagramData(xml, nodes, options = {}) {
24019
24381
  }
24020
24382
  const kept = new Set(idMap.values());
24021
24383
  const removed2 = /* @__PURE__ */ new Set();
24022
- for (const pt of points) {
24384
+ for (const pt of points2) {
24023
24385
  const id = pt.getAttribute("modelId") ?? "";
24024
24386
  if (CONTENT_TYPES.has(pointType(pt)) && !kept.has(id)) removed2.add(id);
24025
24387
  }
@@ -24033,14 +24395,14 @@ function writeEditedDiagramData(xml, nodes, options = {}) {
24033
24395
  if (id) removed2.add(id);
24034
24396
  }
24035
24397
  const cxnId = cxn2.getAttribute("modelId");
24036
- for (const pt of points)
24398
+ for (const pt of points2)
24037
24399
  if (cxnId && pt.getAttribute("cxnId") === cxnId)
24038
24400
  removed2.add(pt.getAttribute("modelId") ?? "");
24039
24401
  cxnLst.removeChild(cxn2);
24040
24402
  } else if (!parOfByDest.has(dest)) parOfByDest.set(dest, cxn2);
24041
24403
  }
24042
24404
  const removedPres = /* @__PURE__ */ new Set();
24043
- for (const pt of points)
24405
+ for (const pt of points2)
24044
24406
  if (pointType(pt) === "pres" && removed2.has(child5(pt, "prSet")?.getAttribute("presAssocID") ?? ""))
24045
24407
  removedPres.add(pt.getAttribute("modelId") ?? "");
24046
24408
  for (let grew = true; grew; ) {
@@ -24058,7 +24420,7 @@ function writeEditedDiagramData(xml, nodes, options = {}) {
24058
24420
  if (type === "presOf" && (removed2.has(src) || removedPres.has(dest)) || type === "presParOf" && (removedPres.has(src) || removedPres.has(dest)))
24059
24421
  cxnLst.removeChild(cxn2);
24060
24422
  }
24061
- for (const pt of points) {
24423
+ for (const pt of points2) {
24062
24424
  const id = pt.getAttribute("modelId") ?? "";
24063
24425
  if (removed2.has(id) || removedPres.has(id)) ptLst.removeChild(pt);
24064
24426
  }
@@ -24458,9 +24820,9 @@ var DEFAULT_GENERATED_DIAGRAM_SCHEME = {
24458
24820
  // diagram/data-model.ts
24459
24821
  var TRANSITION_TYPES = /* @__PURE__ */ new Set(["parTrans", "sibTrans"]);
24460
24822
  var STRUCTURAL_TYPES = /* @__PURE__ */ new Set(["doc", "pres", "parTrans", "sibTrans"]);
24461
- function collectTransitionText(points, describe, text) {
24823
+ function collectTransitionText(points2, describe, text) {
24462
24824
  const byId = /* @__PURE__ */ new Map();
24463
- for (const point of points) {
24825
+ for (const point of points2) {
24464
24826
  const { type, modelId } = describe(point);
24465
24827
  if (!TRANSITION_TYPES.has((type ?? "").trim())) continue;
24466
24828
  const id = (modelId ?? "").trim();
@@ -24522,7 +24884,7 @@ function parseDiagramDataModel(source2, part) {
24522
24884
  const root = (typeof source2 === "string" ? parseXml(source2, { label: "DiagramML" }) : source2).documentElement;
24523
24885
  const issues = [];
24524
24886
  const report = (code, message) => issues.push({ code, message, ...part ? { part } : {} });
24525
- const points = [];
24887
+ const points2 = [];
24526
24888
  const ids = /* @__PURE__ */ new Set();
24527
24889
  for (const element4 of children(first(root, "ptLst", NS.dgm) ?? root, "pt", NS.dgm)) {
24528
24890
  const point = parsePoint(element4);
@@ -24533,10 +24895,10 @@ function parseDiagramDataModel(source2, part) {
24533
24895
  if (ids.has(point.modelId))
24534
24896
  report("POINT_ID_DUPLICATE", `Duplicate dgm:pt modelId: ${point.modelId}.`);
24535
24897
  ids.add(point.modelId);
24536
- points.push(point);
24898
+ points2.push(point);
24537
24899
  }
24538
24900
  const transitionText = collectTransitionText(
24539
- points,
24901
+ points2,
24540
24902
  (point) => ({ type: point.type, modelId: point.modelId }),
24541
24903
  (point) => point.text
24542
24904
  );
@@ -24573,13 +24935,13 @@ function parseDiagramDataModel(source2, part) {
24573
24935
  );
24574
24936
  const generatedCacheDigest = generated2?.getAttribute("drawingSha256");
24575
24937
  return {
24576
- points,
24938
+ points: points2,
24577
24939
  ...descendants(root, "generatedCache").some(
24578
24940
  (node) => node.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
24579
24941
  ) ? { generatedCache: true } : {},
24580
24942
  ...generatedCacheDigest ? { generatedCacheDigest } : {},
24581
24943
  connections,
24582
- nodes: points.filter((point) => !STRUCTURAL_TYPES.has(point.type)),
24944
+ nodes: points2.filter((point) => !STRUCTURAL_TYPES.has(point.type)),
24583
24945
  parentById,
24584
24946
  ...drawingRelId ? { drawingRelId } : {},
24585
24947
  issues
@@ -24837,6 +25199,203 @@ function approximateDiagramDrawingFromNodes(input) {
24837
25199
  });
24838
25200
  }
24839
25201
 
25202
+ // diagram/picture-layout.ts
25203
+ var DIAGRAM_PICTURE_SOURCE_NS = "urn:ooxml-core:diagram-picture-sources:1";
25204
+ function remapFill(fill, id) {
25205
+ if (!fill.sourceXml) return { ...fill, relId: id };
25206
+ const node = parseXml(fill.sourceXml).documentElement;
25207
+ const blip = first(node, "blip", NS.a);
25208
+ if (blip) {
25209
+ blip.setAttributeNS(NS.r, "r:embed", id);
25210
+ blip.removeAttributeNS(NS.r, "link");
25211
+ }
25212
+ return { ...fill, relId: id, sourceXml: buildXml(node) };
25213
+ }
25214
+ function captureDiagramPictures(model, dataXml2, dataParts, drawing) {
25215
+ const pictures = [];
25216
+ const parts = { ...dataParts };
25217
+ const add4 = (source2, owner) => {
25218
+ const part = source2.fill.relId ? owner[source2.fill.relId] : void 0;
25219
+ if (!part) return;
25220
+ let id = Object.keys(parts).find((key) => parts[key] === part);
25221
+ if (!id) {
25222
+ let index = 1;
25223
+ while (Object.hasOwn(parts, `ooxmlDiagramPicture${index}`)) index++;
25224
+ id = `ooxmlDiagramPicture${index}`;
25225
+ parts[id] = part;
25226
+ }
25227
+ const entry2 = { ...source2, fill: remapFill(source2.fill, id) };
25228
+ const existing = pictures.findIndex(
25229
+ (item2) => item2.nodeId === entry2.nodeId && (item2.role === entry2.role && item2.styleLabel === entry2.styleLabel || !item2.role && !item2.styleLabel && item2.fill.relId === entry2.fill.relId)
25230
+ );
25231
+ if (existing < 0) pictures.push(entry2);
25232
+ else pictures[existing] = entry2;
25233
+ };
25234
+ const root = parseXml(dataXml2).documentElement;
25235
+ const saved = root.getElementsByTagNameNS(DIAGRAM_PICTURE_SOURCE_NS, "picture");
25236
+ for (const element4 of saved) {
25237
+ const nodeId = element4.getAttribute("nodeId");
25238
+ const fill = first(element4, "blipFill", NS.a);
25239
+ if (nodeId && fill && model.nodes.some((node) => node.modelId === nodeId))
25240
+ add4(
25241
+ {
25242
+ nodeId,
25243
+ fill: parseDrawingPictureFill(fill),
25244
+ ...element4.getAttribute("role") ? { role: element4.getAttribute("role") } : {},
25245
+ ...element4.getAttribute("styleLabel") ? { styleLabel: element4.getAttribute("styleLabel") } : {}
25246
+ },
25247
+ dataParts
25248
+ );
25249
+ }
25250
+ for (const point of model.points) {
25251
+ if (point.fill?.kind !== "picture") continue;
25252
+ const nodeId = point.type === "pres" ? point.presAssocId : point.modelId;
25253
+ if (nodeId && model.nodes.some((node) => node.modelId === nodeId) && !pictures.some((item2) => item2.nodeId === nodeId))
25254
+ add4(
25255
+ {
25256
+ nodeId,
25257
+ fill: point.fill,
25258
+ ...point.presName ? { role: point.presName } : {},
25259
+ ...point.presStyleLabel ? { styleLabel: point.presStyleLabel } : {}
25260
+ },
25261
+ dataParts
25262
+ );
25263
+ }
25264
+ for (const shape of drawing?.shapes ?? []) {
25265
+ if (shape.fill?.kind !== "picture") continue;
25266
+ const point = model.points.find((point2) => point2.modelId === shape.modelId);
25267
+ const nodeId = shape.sourceNodeId ?? (point?.type === "pres" ? point.presAssocId : point?.modelId);
25268
+ const part = shape.fill.relId ? drawing?.pictureParts?.[shape.fill.relId] : void 0;
25269
+ if (saved.length && pictures.some(
25270
+ (item2) => item2.nodeId === nodeId && item2.fill.relId && parts[item2.fill.relId] === part && item2.role !== point?.presName && item2.styleLabel !== point?.presStyleLabel
25271
+ ))
25272
+ continue;
25273
+ if (nodeId && model.nodes.some((node) => node.modelId === nodeId))
25274
+ add4(
25275
+ {
25276
+ nodeId,
25277
+ fill: shape.fill,
25278
+ ...point?.presName ? { role: point.presName } : {},
25279
+ ...point?.presStyleLabel ? { styleLabel: point.presStyleLabel } : {}
25280
+ },
25281
+ drawing?.pictureParts ?? {}
25282
+ );
25283
+ }
25284
+ return pictures.length ? { pictures, pictureParts: parts } : {};
25285
+ }
25286
+ function applyDiagramPictureSources(drawing, nodes, source2, issues, liveNodeIds) {
25287
+ if (!source2?.pictures?.length) return;
25288
+ if (source2.pictureParts) drawing.pictureParts = { ...source2.pictureParts };
25289
+ const used = /* @__PURE__ */ new Set();
25290
+ nodes.forEach((node, index) => {
25291
+ if (!node.picturePlaceholder || !node.nodeId) return;
25292
+ const shape = drawing.shapes[index];
25293
+ if (!shape) return;
25294
+ const candidates = source2.pictures.filter((picture2) => picture2.nodeId === node.nodeId);
25295
+ const matching = candidates.filter(
25296
+ (picture2) => picture2.role === node.layoutRole || !!picture2.styleLabel && picture2.styleLabel === node.styleLabel
25297
+ );
25298
+ const picture = matching.length === 1 ? matching[0] : candidates.length === 1 ? candidates[0] : void 0;
25299
+ if (picture) {
25300
+ shape.fill = structuredClone(picture.fill);
25301
+ delete shape.text;
25302
+ delete shape.body;
25303
+ used.add(picture);
25304
+ } else if (candidates.length)
25305
+ issues.push({
25306
+ code: "DIAGRAM_PICTURE_AMBIGUOUS",
25307
+ message: `Picture role ${node.layoutRole ?? node.key} has multiple source pictures; no arbitrary assignment was made.`
25308
+ });
25309
+ });
25310
+ if (source2.pictures.some(
25311
+ (picture) => (!liveNodeIds || liveNodeIds.has(picture.nodeId)) && !used.has(picture)
25312
+ ))
25313
+ issues.push({
25314
+ code: "DIAGRAM_PICTURE_LAYOUT_UNSUPPORTED",
25315
+ message: "Some retained pictures have no matching image placeholder in this layout. Their source associations are preserved for a compatible layout."
25316
+ });
25317
+ }
25318
+ function withDiagramPictureSources(dataXml2, source2) {
25319
+ if (!source2?.pictures?.length) return dataXml2;
25320
+ const doc = parseXml(dataXml2);
25321
+ const root = doc.documentElement;
25322
+ const points2 = first(root, "ptLst", NS.dgm);
25323
+ const live = children(points2 ?? root, "pt", NS.dgm).filter(
25324
+ (point) => !["doc", "pres", "parTrans", "sibTrans"].includes(point.getAttribute("type") ?? "node")
25325
+ );
25326
+ for (const element4 of [...root.getElementsByTagNameNS(DIAGRAM_PICTURE_SOURCE_NS, "pictures")]) {
25327
+ const extension2 = element4.parentNode;
25328
+ if (extension2?.parentNode) extension2.parentNode.removeChild(extension2);
25329
+ }
25330
+ const retained = source2.pictures.filter(
25331
+ (picture) => live.some((point) => point.getAttribute("modelId") === picture.nodeId)
25332
+ );
25333
+ if (!retained.length) return buildXml(doc);
25334
+ const list2 = first(root, "extLst", NS.dgm) ?? doc.createElementNS(NS.dgm, "dgm:extLst");
25335
+ if (!list2.parentNode) root.appendChild(list2);
25336
+ const extension = doc.createElementNS(NS.a, "a:ext");
25337
+ extension.setAttribute("uri", DIAGRAM_PICTURE_SOURCE_NS);
25338
+ const payload = doc.createElementNS(DIAGRAM_PICTURE_SOURCE_NS, "op:pictures");
25339
+ extension.appendChild(payload);
25340
+ list2.appendChild(extension);
25341
+ for (const picture of retained) {
25342
+ if (!picture.fill.sourceXml)
25343
+ throw new Error("A retained SmartArt picture needs source fill XML");
25344
+ const element4 = doc.createElementNS(DIAGRAM_PICTURE_SOURCE_NS, "op:picture");
25345
+ element4.setAttribute("nodeId", picture.nodeId);
25346
+ if (picture.role) element4.setAttribute("role", picture.role);
25347
+ if (picture.styleLabel) element4.setAttribute("styleLabel", picture.styleLabel);
25348
+ const fill = parseXml(picture.fill.sourceXml).documentElement;
25349
+ element4.appendChild(doc.importNode(fill, true));
25350
+ payload.appendChild(element4);
25351
+ const presentations = children(points2 ?? root, "pt", NS.dgm).filter((point) => {
25352
+ const props = first(point, "prSet", NS.dgm);
25353
+ return point.getAttribute("type") === "pres" && props?.getAttribute("presAssocID") === picture.nodeId && (picture.role && props.getAttribute("presName") === picture.role || picture.styleLabel && props.getAttribute("presStyleLbl") === picture.styleLabel);
25354
+ });
25355
+ if (presentations.length === 1) {
25356
+ const point = presentations[0];
25357
+ const props = first(point, "spPr", NS.dgm) ?? doc.createElementNS(NS.dgm, "dgm:spPr");
25358
+ if (!props.parentNode) point.appendChild(props);
25359
+ for (const old of [...props.childNodes].filter((node) => node.nodeType === 1).filter(
25360
+ (node) => node.namespaceURI === NS.a && ["blipFill", "solidFill", "gradFill", "pattFill", "noFill", "grpFill"].includes(
25361
+ node.localName
25362
+ )
25363
+ ))
25364
+ props.removeChild(old);
25365
+ props.insertBefore(doc.importNode(fill, true), props.firstChild);
25366
+ }
25367
+ }
25368
+ return buildXml(doc);
25369
+ }
25370
+ function diagramPictureRelationships(owner, source2, existing) {
25371
+ if (!source2?.pictures?.length || !source2.pictureParts) return existing;
25372
+ const rels = parseRelationships(existing);
25373
+ for (const [id, part] of Object.entries(source2.pictureParts)) {
25374
+ const previous = rels.get(id);
25375
+ if (previous && (previous.mode === "External" || resolvePartPath(owner, previous.target) !== part))
25376
+ throw new Error(`Conflicting SmartArt picture relationship: ${id}`);
25377
+ rels.set(id, { id, type: RELATIONSHIP_TYPES.image, target: `/${part}`, mode: "Internal" });
25378
+ }
25379
+ return buildRelationshipsXml(rels);
25380
+ }
25381
+
25382
+ // diagram/layout-role-style.ts
25383
+ function applyDiagramRoleColors(shape, role, index, minorFont) {
25384
+ const at = (colors) => colors[index % colors.length];
25385
+ const fill = role && at(role.fill.colors);
25386
+ if (fill && shape.fill?.kind !== "none" && shape.fill?.kind !== "picture")
25387
+ shape.fill = { kind: "solid", color: structuredClone(fill) };
25388
+ const line2 = role && at(role.line.colors);
25389
+ if (line2 && shape.line) shape.line.fill = { kind: "solid", color: structuredClone(line2) };
25390
+ const text = role && at(role.textFill.colors);
25391
+ for (const paragraph2 of shape.text?.paragraphs ?? []) {
25392
+ for (const run2 of paragraph2.runs) {
25393
+ if (!run2.color && text) run2.color = structuredClone(text);
25394
+ if (!run2.typeface && minorFont) run2.typeface = minorFont;
25395
+ }
25396
+ }
25397
+ }
25398
+
24840
25399
  // diagram/layout-preview.ts
24841
25400
  function diagramLayoutData(input) {
24842
25401
  const original = input.source?.dataXml ? parseDiagramDataModel(input.source.dataXml) : void 0;
@@ -24982,6 +25541,8 @@ function previewDiagramLayout(input) {
24982
25541
  ];
24983
25542
  });
24984
25543
  const drawing2 = diagramDrawingFromViews(views);
25544
+ drawing2.extentEmu = { ...input.extentEmu };
25545
+ const colors = input.source?.colorsXml ? parseDiagramColors(input.source.colorsXml) : void 0;
24985
25546
  const quickStyle = input.source?.quickStyleXml ? parseDiagramQuickStyle(input.source.quickStyleXml) : void 0;
24986
25547
  const originalModel = input.source?.dataXml ? parseDiagramDataModel(input.source.dataXml) : void 0;
24987
25548
  result.nodes.forEach((node, index) => {
@@ -24992,7 +25553,9 @@ function previewDiagramLayout(input) {
24992
25553
  shape.style = label;
24993
25554
  shape.has3d = label.requires3d ?? label.hasShape3d;
24994
25555
  }
24995
- if (node.nodeId) shape.sourceNodeId = node.nodeId;
25556
+ const contextNodeId = node.nodeId ?? node.contextNodeId;
25557
+ if (contextNodeId) shape.sourceNodeId = contextNodeId;
25558
+ if (node.layoutRole) shape.sourceLayoutRole = node.layoutRole;
24996
25559
  if (node.styleLabel) shape.sourceStyleLabel = node.styleLabel;
24997
25560
  if (node.foldedNodeIds?.length) shape.foldedNodeIds = node.foldedNodeIds;
24998
25561
  const sourceNode = data.nodes.find((entry2) => entry2.id === node.nodeId);
@@ -25005,15 +25568,36 @@ function previewDiagramLayout(input) {
25005
25568
  if (fill) shape.fill = fill;
25006
25569
  }
25007
25570
  const direct = originalModel?.nodes.find((entry2) => entry2.modelId === node.nodeId);
25008
- if (direct?.fill) shape.fill = direct.fill;
25009
- if (direct?.line) shape.line = { ...shape.line, ...direct.line };
25010
25571
  const sourceIds = [node.nodeId, ...node.foldedNodeIds ?? []];
25011
25572
  const textNodes = sourceIds.flatMap((id) => {
25012
25573
  const source2 = input.nodes.find((entry2) => entry2.id === id);
25013
25574
  return source2 ? [source2] : [];
25014
25575
  });
25015
25576
  if (textNodes.length) shape.text = diagramPreviewText(textNodes, node.fontSize);
25577
+ if (shape.text) {
25578
+ if (node.textVerticalAnchor) shape.text.anchor = node.textVerticalAnchor;
25579
+ for (const paragraph2 of shape.text.paragraphs)
25580
+ if (!paragraph2.align && node.textAlign) paragraph2.align = node.textAlign;
25581
+ }
25582
+ applyDiagramRoleColors(
25583
+ shape,
25584
+ colors?.labels.find((label2) => label2.name === node.styleLabel),
25585
+ Math.max(
25586
+ 0,
25587
+ input.nodes.findIndex((entry2) => entry2.id === contextNodeId)
25588
+ ),
25589
+ input.minorFont
25590
+ );
25591
+ if (direct?.fill && direct.fill.kind !== "picture") shape.fill = direct.fill;
25592
+ if (direct?.line) shape.line = { ...shape.line, ...direct.line };
25016
25593
  });
25594
+ applyDiagramPictureSources(
25595
+ drawing2,
25596
+ result.nodes,
25597
+ input.source,
25598
+ issues,
25599
+ new Set(input.nodes.map((node) => node.id))
25600
+ );
25017
25601
  return { drawing: drawing2, mode: "interpreted", issues };
25018
25602
  }
25019
25603
  } catch (error) {
@@ -25054,9 +25638,9 @@ function resolveDiagramDrawingStyles(drawing, scheme2) {
25054
25638
 
25055
25639
  // diagram/write/cache.ts
25056
25640
  var DSP2 = "http://schemas.microsoft.com/office/drawing/2008/diagram";
25057
- function add2(parent, namespace, name, attrs2 = {}) {
25641
+ function add2(parent, namespace, name, attrs3 = {}) {
25058
25642
  const child7 = parent.ownerDocument.createElementNS(namespace, name);
25059
- for (const [key, value] of Object.entries(attrs2)) child7.setAttribute(key, value);
25643
+ for (const [key, value] of Object.entries(attrs3)) child7.setAttribute(key, value);
25060
25644
  parent.appendChild(child7);
25061
25645
  return child7;
25062
25646
  }
@@ -25074,6 +25658,7 @@ function withDiagramDrawingRelationship(xml, relationshipId) {
25074
25658
  return buildXml(doc);
25075
25659
  }
25076
25660
  function buildGeneratedDiagramCache(dataXml2, input) {
25661
+ dataXml2 = withDiagramPictureSources(dataXml2, input.source);
25077
25662
  const source2 = { ...input.source, dataXml: dataXml2 };
25078
25663
  const model = parseDiagramDataModel(dataXml2);
25079
25664
  const scheme2 = { ...DEFAULT_GENERATED_DIAGRAM_SCHEME, ...input.scheme };
@@ -25088,9 +25673,9 @@ function buildGeneratedDiagramCache(dataXml2, input) {
25088
25673
  const drawing = resolveDiagramDrawingStyles(preview.drawing, input.formatScheme);
25089
25674
  const doc = parseXml(dataXml2);
25090
25675
  const root = doc.documentElement;
25091
- const points = first(root, "ptLst", NS.dgm);
25676
+ const points2 = first(root, "ptLst", NS.dgm);
25092
25677
  const connections = first(root, "cxnLst", NS.dgm);
25093
- if (!points || !connections) return void 0;
25678
+ if (!points2 || !connections) return void 0;
25094
25679
  const colors = source2.colorsXml ? parseDiagramColors(source2.colorsXml).labels : [];
25095
25680
  const authoredColors = colors.flatMap((label) => [...label.fill.colors, ...label.line.colors]);
25096
25681
  const themed = /* @__PURE__ */ new Map();
@@ -25100,14 +25685,17 @@ function buildGeneratedDiagramCache(dataXml2, input) {
25100
25685
  }
25101
25686
  for (const shape of drawing.shapes) {
25102
25687
  if (shape.has3d || shape.foldedNodeIds?.length) return void 0;
25103
- if (shape.fill && !["none", "solid", "gradient"].includes(shape.fill.kind)) return void 0;
25688
+ if (shape.fill && !["none", "solid", "gradient", "picture"].includes(shape.fill.kind))
25689
+ return void 0;
25690
+ if (shape.fill?.kind === "picture" && (!shape.fill.relId || !drawing.pictureParts?.[shape.fill.relId]))
25691
+ return void 0;
25104
25692
  if (shape.fill?.kind === "gradient" && shape.fill.path && !["circle", "rect"].includes(shape.fill.path))
25105
25693
  return void 0;
25106
25694
  if (shape.effects?.effects.some(
25107
25695
  (effect) => effect.kind !== "outerShadow" || !resolveDrawingOuterShadow(effect, { scheme: (name) => scheme2[name] })
25108
25696
  ))
25109
25697
  return void 0;
25110
- const point = children(points, "pt", NS.dgm).find(
25698
+ const point = children(points2, "pt", NS.dgm).find(
25111
25699
  (point2) => point2.getAttribute("modelId") === shape.sourceNodeId
25112
25700
  );
25113
25701
  const direct = model.nodes.find((node) => node.modelId === shape.sourceNodeId);
@@ -25181,8 +25769,8 @@ function buildGeneratedDiagramCache(dataXml2, input) {
25181
25769
  (marker2) => descendants(marker2, "shape").map((node) => node.getAttribute("id"))
25182
25770
  )
25183
25771
  );
25184
- for (const point of children(points, "pt", NS.dgm))
25185
- if (oldIds.has(point.getAttribute("modelId"))) points.removeChild(point);
25772
+ for (const point of children(points2, "pt", NS.dgm))
25773
+ if (oldIds.has(point.getAttribute("modelId"))) points2.removeChild(point);
25186
25774
  for (const edge of children(connections, "cxn", NS.dgm))
25187
25775
  if (oldIds.has(edge.getAttribute("destId"))) connections.removeChild(edge);
25188
25776
  for (const marker2 of oldMarkers) {
@@ -25204,15 +25792,18 @@ function buildGeneratedDiagramCache(dataXml2, input) {
25204
25792
  );
25205
25793
  drawing.shapes.forEach((shape, index) => {
25206
25794
  const id = serialized.modelIds.get(shape.modelId);
25207
- const point = add2(points, NS.dgm, "dgm:pt", { modelId: id, type: "pres" });
25795
+ const point = add2(points2, NS.dgm, "dgm:pt", { modelId: id, type: "pres" });
25208
25796
  add2(point, NS.dgm, "dgm:prSet", {
25209
25797
  ...shape.sourceNodeId ? { presAssocID: shape.sourceNodeId } : {},
25210
- presName: "node",
25798
+ presName: shape.sourceLayoutRole ?? "node",
25211
25799
  presStyleLbl: shape.sourceStyleLabel ?? "node1",
25212
25800
  presStyleIdx: String(index),
25213
25801
  presStyleCnt: String(drawing.shapes.length)
25214
25802
  });
25215
- add2(point, NS.dgm, "dgm:spPr");
25803
+ const properties = add2(point, NS.dgm, "dgm:spPr");
25804
+ if (shape.fill?.kind === "picture" && shape.fill.sourceXml) {
25805
+ properties.appendChild(doc.importNode(parseXml(shape.fill.sourceXml).documentElement, true));
25806
+ }
25216
25807
  if (shape.sourceNodeId)
25217
25808
  add2(connections, NS.dgm, "dgm:cxn", {
25218
25809
  modelId: createOfficeGuid(),
@@ -25225,7 +25816,11 @@ function buildGeneratedDiagramCache(dataXml2, input) {
25225
25816
  });
25226
25817
  add2(marker, GENERATED_DIAGRAM_CACHE_NS, "oc:shape", { id });
25227
25818
  });
25228
- return { dataXml: buildXml(doc), drawingXml: serialized.xml };
25819
+ return {
25820
+ dataXml: buildXml(doc),
25821
+ drawingXml: serialized.xml,
25822
+ ...drawing.pictureParts ? { pictureParts: drawing.pictureParts } : {}
25823
+ };
25229
25824
  }
25230
25825
 
25231
25826
  // diagram/relationships.ts
@@ -25490,6 +26085,29 @@ async function loadDiagram(hostPart, relationshipIds, host) {
25490
26085
  code: "DIAGRAM_DRAWING_ABSENT",
25491
26086
  message: "The package has no cached drawing for this diagram; its layout can only be recomputed from the layout definition."
25492
26087
  });
26088
+ if (data && layoutSource.dataXml) {
26089
+ let pictureParts = {};
26090
+ if (paths.data) {
26091
+ const owner = paths.data;
26092
+ try {
26093
+ const entries = await host.readRelationshipEntries(diagramRelationshipsPart(owner));
26094
+ pictureParts = Object.fromEntries(
26095
+ (entries ?? []).filter(
26096
+ (entry2) => entry2.type.endsWith("/image") && entry2.mode !== "External" && !/^[a-z][a-z0-9+.-]*:/i.test(entry2.target)
26097
+ ).map((entry2) => [entry2.id, host.resolvePath(owner, entry2.target)])
26098
+ );
26099
+ } catch {
26100
+ issues.push({
26101
+ code: "DIAGRAM_PICTURE_RELATIONSHIPS_UNREADABLE",
26102
+ message: "Picture relationships in the diagram data could not be read."
26103
+ });
26104
+ }
26105
+ }
26106
+ Object.assign(
26107
+ layoutSource,
26108
+ captureDiagramPictures(data, layoutSource.dataXml, pictureParts, drawing)
26109
+ );
26110
+ }
25493
26111
  return {
25494
26112
  layoutSource,
25495
26113
  ...generatedCache ? { generatedCache: true } : {},
@@ -27420,14 +28038,14 @@ function formula(parent, local) {
27420
28038
  var LEVEL = /* @__PURE__ */ new Set(["pt", "extLst"]);
27421
28039
  function parseLevel(context, element4) {
27422
28040
  reportUnmodelled2(context, element4, LEVEL);
27423
- const points = cxChildren(element4, "pt").map((pt) => {
28041
+ const points2 = cxChildren(element4, "pt").map((pt) => {
27424
28042
  const point = { value: pt.textContent ?? "" };
27425
28043
  const index = indexAttribute(context, pt, "idx");
27426
28044
  if (index !== void 0) point.index = index;
27427
28045
  return point;
27428
28046
  });
27429
28047
  return assignDefined(
27430
- { points },
28048
+ { points: points2 },
27431
28049
  {
27432
28050
  pointCount: indexAttribute(context, element4, "ptCount"),
27433
28051
  formatCode: attribute(element4, "formatCode"),
@@ -27861,8 +28479,8 @@ function attributes(entries) {
27861
28479
  return ` ${name}="${text}"`;
27862
28480
  }).join("");
27863
28481
  }
27864
- var cxElement = (local, content = "", attrs2 = "") => content ? `<cx:${local}${attrs2}>${content}</cx:${local}>` : `<cx:${local}${attrs2}/>`;
27865
- var cxText = (local, text, attrs2 = "") => text === void 0 ? "" : `<cx:${local}${attrs2}>${escapeText2(text)}</cx:${local}>`;
28482
+ var cxElement = (local, content = "", attrs3 = "") => content ? `<cx:${local}${attrs3}>${content}</cx:${local}>` : `<cx:${local}${attrs3}/>`;
28483
+ var cxText = (local, text, attrs3 = "") => text === void 0 ? "" : `<cx:${local}${attrs3}>${escapeText2(text)}</cx:${local}>`;
27866
28484
  var cxVal = (local, value) => value === void 0 ? "" : `<cx:${local}${attributes([["val", value]])}/>`;
27867
28485
  var formulaXml = (local, formula2) => formula2 ? cxText(local, formula2.formula, attributes([["dir", formula2.direction]])) : "";
27868
28486
  var shapeXml = (context, shape) => shape ? cxElement("spPr", shapePropertiesInnerXml(context, shape)) : "";
@@ -27947,7 +28565,7 @@ function labelBody(context, label) {
27947
28565
  }
27948
28566
  function dataLabelsXml2(context, labels) {
27949
28567
  if (!labels) return "";
27950
- const points = labels.labels.map(
28568
+ const points2 = labels.labels.map(
27951
28569
  (label) => cxElement(
27952
28570
  "dataLabel",
27953
28571
  labelBody(context, label) + raw(context, label.extLst),
@@ -27960,7 +28578,7 @@ function dataLabelsXml2(context, labels) {
27960
28578
  const hidden = labels.hidden.map((index) => cxElement("dataLabelHidden", "", attributes([["idx", index]]))).join("");
27961
28579
  return cxElement(
27962
28580
  "dataLabels",
27963
- labelBody(context, labels) + points + hidden + raw(context, labels.extLst),
28581
+ labelBody(context, labels) + points2 + hidden + raw(context, labels.extLst),
27964
28582
  attributes([["pos", labels.position]])
27965
28583
  );
27966
28584
  }
@@ -28007,7 +28625,7 @@ function layoutXml2(context, layout2) {
28007
28625
  );
28008
28626
  }
28009
28627
  function seriesXml2(context, series) {
28010
- const points = series.dataPoints.map(
28628
+ const points2 = series.dataPoints.map(
28011
28629
  (point) => cxElement(
28012
28630
  "dataPt",
28013
28631
  shapeXml(context, point.spPr) + raw(context, point.extLst),
@@ -28016,7 +28634,7 @@ function seriesXml2(context, series) {
28016
28634
  ).join("");
28017
28635
  return cxElement(
28018
28636
  "series",
28019
- textXml(context, series.tx) + shapeXml(context, series.spPr) + textBodyXml2(context, series.txPr) + raw(context, series.valueColorsXml) + raw(context, series.valueColorPositionsXml) + points + dataLabelsXml2(context, series.dataLabels) + (series.data ? dataXml(context, series.data) : "") + cxVal("dataId", series.dataId) + layoutXml2(context, series.layoutProperties) + series.axisIds.map((id) => cxVal("axisId", id)).join("") + raw(context, series.extLst),
28637
+ textXml(context, series.tx) + shapeXml(context, series.spPr) + textBodyXml2(context, series.txPr) + raw(context, series.valueColorsXml) + raw(context, series.valueColorPositionsXml) + points2 + dataLabelsXml2(context, series.dataLabels) + (series.data ? dataXml(context, series.data) : "") + cxVal("dataId", series.dataId) + layoutXml2(context, series.layoutProperties) + series.axisIds.map((id) => cxVal("axisId", id)).join("") + raw(context, series.extLst),
28020
28638
  attributes([
28021
28639
  ["layoutId", series.layoutId],
28022
28640
  ["hidden", series.hidden],
@@ -28913,6 +29531,54 @@ async function appendChartExWorkbookData(bytes, before, after) {
28913
29531
  return { bytes: result.bytes, space: layout2.space };
28914
29532
  }
28915
29533
 
29534
+ // chart/render/chart-title-text.ts
29535
+ function chartRunStyle(run2) {
29536
+ return {
29537
+ ...run2.sizePt === void 0 ? {} : { fontSize: run2.sizePt },
29538
+ ...run2.bold === void 0 ? {} : { bold: run2.bold },
29539
+ ...run2.italic === void 0 ? {} : { italic: run2.italic },
29540
+ ...run2.underline === void 0 ? {} : { underline: run2.underline },
29541
+ ...run2.typeface === void 0 ? {} : { typeface: run2.typeface },
29542
+ ...run2.color === void 0 ? {} : { textColor: run2.color }
29543
+ };
29544
+ }
29545
+
29546
+ // chart/render/summary-ex-formatting.ts
29547
+ function textStyle(body) {
29548
+ const paragraph2 = body?.paragraphs[0];
29549
+ return {
29550
+ ...chartRunStyle(paragraph2?.defaultProperties ?? {}),
29551
+ ...chartRunStyle(paragraph2?.runs[0] ?? {})
29552
+ };
29553
+ }
29554
+ function chartExFormatting(space) {
29555
+ return {
29556
+ builtInStyle: 2,
29557
+ sourceXml: "",
29558
+ entries: {
29559
+ title: {
29560
+ fontSize: 18,
29561
+ bold: false,
29562
+ textColor: {
29563
+ kind: "scheme",
29564
+ value: "tx1",
29565
+ transforms: []
29566
+ },
29567
+ ...textStyle(space.title?.txPr),
29568
+ ...textStyle(space.title?.tx?.rich),
29569
+ ...space.title?.tx?.rich ? { textBody: space.title.tx.rich } : {},
29570
+ sourceXml: ""
29571
+ },
29572
+ legend: { fontSize: 12, ...textStyle(space.legend?.txPr), sourceXml: "" },
29573
+ categoryAxis: {
29574
+ fontSize: 10,
29575
+ ...textStyle(space.plotArea.axes.find((a2) => a2.scaling?.kind === "cat")?.txPr),
29576
+ sourceXml: ""
29577
+ }
29578
+ }
29579
+ };
29580
+ }
29581
+
28916
29582
  // chart/render/summary-ex-series.ts
28917
29583
  var level2 = (source2) => ({
28918
29584
  ...source2.visibility?.value === void 0 ? {} : { showValue: source2.visibility.value },
@@ -28925,15 +29591,16 @@ var level2 = (source2) => ({
28925
29591
  function chartExSeriesPaint(source2, series, defaultValues = false) {
28926
29592
  const fill = source2.spPr?.fill;
28927
29593
  if (fill) series.fill = fill;
28928
- const points = {};
29594
+ if (source2.spPr?.line) series.line = source2.spPr.line;
29595
+ const points2 = {};
28929
29596
  const fills = {};
28930
29597
  for (const point of source2.dataPoints) {
28931
29598
  if (point.index === void 0) continue;
28932
29599
  const fill2 = point.spPr?.fill;
28933
- if (fill2?.kind === "solid") points[point.index] = fill2.color;
29600
+ if (fill2?.kind === "solid") points2[point.index] = fill2.color;
28934
29601
  else if (fill2) fills[point.index] = fill2;
28935
29602
  }
28936
- if (Object.keys(points).length) series.pointColors = points;
29603
+ if (Object.keys(points2).length) series.pointColors = points2;
28937
29604
  if (Object.keys(fills).length) series.pointFills = fills;
28938
29605
  const labels = source2.dataLabels;
28939
29606
  if (!labels && !defaultValues) return;
@@ -28956,10 +29623,10 @@ function seriesData(space, series) {
28956
29623
  }
28957
29624
  var findDimension = (data, kind, type) => data?.dimensions.find((d) => d.kind === kind && (d.type ?? "") === type);
28958
29625
  function levelPoints(level3) {
28959
- const points = [];
28960
- for (const point of level3.points) points[point.index ?? points.length] = point.value.trim();
28961
- for (let i = 0; i < Math.max(level3.pointCount ?? 0, points.length); i++) points[i] ??= "";
28962
- return points;
29626
+ const points2 = [];
29627
+ for (const point of level3.points) points2[point.index ?? points2.length] = point.value.trim();
29628
+ for (let i = 0; i < Math.max(level3.pointCount ?? 0, points2.length); i++) points2[i] ??= "";
29629
+ return points2;
28963
29630
  }
28964
29631
  function dimension(data, kind, type) {
28965
29632
  const element4 = findDimension(data, kind, type);
@@ -29008,34 +29675,13 @@ function chartExSummary(source2) {
29008
29675
  if (!isChartExRoot(root)) return void 0;
29009
29676
  return chartExSummaryFromModel(parseChartExSpace(root).chartExSpace);
29010
29677
  }
29011
- function chartExFormatting() {
29012
- return {
29013
- builtInStyle: 2,
29014
- sourceXml: "",
29015
- entries: {
29016
- title: {
29017
- fontSize: 14,
29018
- bold: false,
29019
- textColor: {
29020
- kind: "scheme",
29021
- value: "tx1",
29022
- transforms: [
29023
- { name: "lumMod", value: "65000" },
29024
- { name: "lumOff", value: "35000" }
29025
- ]
29026
- },
29027
- sourceXml: ""
29028
- }
29029
- }
29030
- };
29031
- }
29032
29678
  function summarySeries(space, source2, chartType) {
29033
29679
  const data = seriesData(space, source2);
29034
29680
  const categories = dimension(data, "strDim", "cat");
29035
29681
  const values = dimension(
29036
29682
  data,
29037
29683
  "numDim",
29038
- chartType === "treemap" || chartType === "sunburst" ? "size" : "val"
29684
+ chartType === "treemap" || chartType === "sunburst" ? "size" : chartType === "regionMap" ? "colorVal" : "val"
29039
29685
  );
29040
29686
  const series = {
29041
29687
  categories: categories?.points ?? [],
@@ -29044,11 +29690,24 @@ function summarySeries(space, source2, chartType) {
29044
29690
  ),
29045
29691
  ...seriesFill(source2)
29046
29692
  };
29047
- if (chartType === "funnel" || chartType === "boxWhisker") {
29693
+ if (chartType === "funnel" || chartType === "boxWhisker" || chartType === "regionMap") {
29048
29694
  chartExSeriesPaint(source2, series, chartType === "funnel" && source2.dataLabels !== void 0);
29049
29695
  if (source2.hidden !== void 0) series.hidden = source2.hidden;
29050
29696
  }
29051
29697
  if (chartType === "boxWhisker") series.boxWhisker = source2.layoutProperties ?? {};
29698
+ if (chartType === "regionMap") {
29699
+ const geo = source2.layoutProperties?.geography;
29700
+ series.regionMap = {
29701
+ ...geo,
29702
+ ...geo?.geoCacheXml ? { geographyCacheXml: geo.geoCacheXml } : {},
29703
+ ...dimension(data, "strDim", "entityId") ? { entityIds: dimension(data, "strDim", "entityId").points } : {},
29704
+ ...source2.layoutProperties?.regionLabelLayout ? {
29705
+ regionLabelLayout: source2.layoutProperties.regionLabelLayout
29706
+ } : {},
29707
+ ...source2.valueColorsXml ? { valueColorsXml: source2.valueColorsXml } : {},
29708
+ ...source2.valueColorPositionsXml ? { valueColorPositionsXml: source2.valueColorPositionsXml } : {}
29709
+ };
29710
+ }
29052
29711
  const name = source2.tx?.value?.trim();
29053
29712
  if (name) series.name = name;
29054
29713
  const nameRef = source2.tx?.formula?.formula.trim();
@@ -29061,7 +29720,7 @@ function chartExSummaryFromModel(space) {
29061
29720
  const all = space.plotArea.series;
29062
29721
  const primary = all.find((s) => s.layoutId !== "paretoLine") ?? all[0];
29063
29722
  const layoutId = primary?.layoutId ?? "";
29064
- const chartType = layoutId === "waterfall" ? "waterfall" : layoutId === "clusteredColumn" ? "histogram" : layoutId === "treemap" || layoutId === "sunburst" || layoutId === "funnel" || layoutId === "boxWhisker" ? layoutId : void 0;
29723
+ const chartType = layoutId === "waterfall" ? "waterfall" : layoutId === "clusteredColumn" ? "histogram" : layoutId === "treemap" || layoutId === "sunburst" || layoutId === "funnel" || layoutId === "boxWhisker" || layoutId === "regionMap" ? layoutId : void 0;
29065
29724
  if (!primary || !chartType) return { layoutId };
29066
29725
  const series = summarySeries(space, primary, chartType);
29067
29726
  const layout2 = primary.layoutProperties;
@@ -29099,7 +29758,12 @@ function chartExSummaryFromModel(space) {
29099
29758
  ];
29100
29759
  });
29101
29760
  }
29102
- summary.formatting = chartExFormatting();
29761
+ if (chartType === "funnel") {
29762
+ const cat = space.plotArea.axes.find((axis) => axis.scaling?.kind === "cat")?.scaling;
29763
+ if (cat?.kind === "cat" && typeof cat.gapWidth === "number")
29764
+ summary.funnelGapWidth = cat.gapWidth;
29765
+ }
29766
+ summary.formatting = chartExFormatting(space);
29103
29767
  const title = titleOf(space);
29104
29768
  if (title) summary.title = title;
29105
29769
  const position2 = legend?.position;
@@ -29296,11 +29960,11 @@ function warningsFor(document) {
29296
29960
  ],
29297
29961
  [
29298
29962
  ["rPrChange"],
29299
- "Formatting-change revisions retain their prior run-properties snapshots and support acceptance and rejection; recording new formatting changes and showing prior formatting in Original display are not supported yet."
29963
+ "Formatting-change revisions retain their prior run-properties snapshots and support acceptance, rejection and Original display; supported run-formatting changes are recorded as new revisions, other formatting edits are not."
29300
29964
  ],
29301
29965
  [
29302
29966
  ["pPrChange"],
29303
- "Paragraph-formatting-change revisions retain their prior properties snapshots and support acceptance and rejection; recording new paragraph formatting changes and showing prior formatting in Original display are not supported yet."
29967
+ "Paragraph-formatting-change revisions retain their prior properties snapshots and support acceptance, rejection and Original display; pure paragraph-formatting changes are recorded as new revisions, and revised paragraph-mark merging is not shown yet."
29304
29968
  ],
29305
29969
  [
29306
29970
  ["ffData"],
@@ -29595,6 +30259,7 @@ function parseModernDrawing(node, context) {
29595
30259
  if (picture)
29596
30260
  return {
29597
30261
  ...picture,
30262
+ ...blip?.parentNode ? { pictureFill: parseDrawingPictureFill(blip.parentNode) } : {},
29598
30263
  widthPx,
29599
30264
  heightPx,
29600
30265
  ...definedProps({ altText, title, anchored }),
@@ -29698,7 +30363,7 @@ var add3 = (parent, ...items) => {
29698
30363
  };
29699
30364
  var emu3 = (px2) => String(Math.max(1, Math.round(px2 * EMU_PER_PIXEL)));
29700
30365
  var emuOffset = (px2) => String(Math.round(px2 * EMU_PER_PIXEL));
29701
- var attrs = (element4, values) => {
30366
+ var attrs2 = (element4, values) => {
29702
30367
  for (const [name, value] of Object.entries(values)) element4.setAttribute(name, value);
29703
30368
  return element4;
29704
30369
  };
@@ -29751,9 +30416,9 @@ function textParagraphs(doc, lines2, color) {
29751
30416
  }
29752
30417
  function shapeStyle(doc) {
29753
30418
  const ref = (name, idx, scheme2, shade) => {
29754
- const node = attrs(el2(doc, A_NS2, `a:${name}`), { idx });
29755
- const color = attrs(el2(doc, A_NS2, "a:schemeClr"), { val: scheme2 });
29756
- if (shade) add3(color, attrs(el2(doc, A_NS2, "a:shade"), { val: shade }));
30419
+ const node = attrs2(el2(doc, A_NS2, `a:${name}`), { idx });
30420
+ const color = attrs2(el2(doc, A_NS2, "a:schemeClr"), { val: scheme2 });
30421
+ if (shade) add3(color, attrs2(el2(doc, A_NS2, "a:shade"), { val: shade }));
29757
30422
  return add3(node, color);
29758
30423
  };
29759
30424
  return add3(
@@ -29767,17 +30432,17 @@ function shapeStyle(doc) {
29767
30432
  function wrapElement(doc, placement) {
29768
30433
  switch (placement.wrap) {
29769
30434
  case "square":
29770
- return attrs(el2(doc, WP_NS3, "wp:wrapSquare"), { wrapText: "bothSides" });
30435
+ return attrs2(el2(doc, WP_NS3, "wp:wrapSquare"), { wrapText: "bothSides" });
29771
30436
  case "tight":
29772
30437
  case "through": {
29773
- const wrap2 = attrs(
30438
+ const wrap2 = attrs2(
29774
30439
  el2(doc, WP_NS3, `wp:wrap${placement.wrap === "tight" ? "Tight" : "Through"}`),
29775
30440
  {
29776
30441
  wrapText: "bothSides"
29777
30442
  }
29778
30443
  );
29779
- const polygon = attrs(el2(doc, WP_NS3, "wp:wrapPolygon"), { edited: "0" });
29780
- const point = (name, x, y) => attrs(el2(doc, WP_NS3, `wp:${name}`), { x, y });
30444
+ const polygon = attrs2(el2(doc, WP_NS3, "wp:wrapPolygon"), { edited: "0" });
30445
+ const point = (name, x, y) => attrs2(el2(doc, WP_NS3, `wp:${name}`), { x, y });
29781
30446
  return add3(
29782
30447
  wrap2,
29783
30448
  add3(
@@ -29797,7 +30462,7 @@ function wrapElement(doc, placement) {
29797
30462
  }
29798
30463
  }
29799
30464
  function position(doc, axis, relativeFrom, align, offsetPx) {
29800
- const node = attrs(el2(doc, WP_NS3, `wp:position${axis}`), { relativeFrom });
30465
+ const node = attrs2(el2(doc, WP_NS3, `wp:position${axis}`), { relativeFrom });
29801
30466
  if (align) {
29802
30467
  const a2 = el2(doc, WP_NS3, "wp:align");
29803
30468
  a2.textContent = align;
@@ -29808,10 +30473,10 @@ function position(doc, axis, relativeFrom, align, offsetPx) {
29808
30473
  return add3(node, offset);
29809
30474
  }
29810
30475
  function geometry(doc, spec) {
29811
- const prst = attrs(el2(doc, A_NS2, "a:prstGeom"), { prst: spec.preset });
30476
+ const prst = attrs2(el2(doc, A_NS2, "a:prstGeom"), { prst: spec.preset });
29812
30477
  const avLst = el2(doc, A_NS2, "a:avLst");
29813
30478
  for (const [name, value] of Object.entries(spec.adjustments ?? {}))
29814
- add3(avLst, attrs(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
30479
+ add3(avLst, attrs2(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
29815
30480
  const nodes = spec.customGeometryXml ? importFragment(doc, spec.customGeometryXml) : [add3(prst, avLst)];
29816
30481
  if (spec.fill) {
29817
30482
  const xml = drawingFillXml(spec.fill);
@@ -29827,7 +30492,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
29827
30492
  const anchored = Boolean(image.anchored);
29828
30493
  const holder = el2(doc, WP_NS3, anchored ? "wp:anchor" : "wp:inline");
29829
30494
  if (anchored) {
29830
- attrs(holder, {
30495
+ attrs2(holder, {
29831
30496
  distT: "0",
29832
30497
  distB: "0",
29833
30498
  distL: "114300",
@@ -29841,7 +30506,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
29841
30506
  });
29842
30507
  add3(
29843
30508
  holder,
29844
- attrs(el2(doc, WP_NS3, "wp:simplePos"), { x: "0", y: "0" }),
30509
+ attrs2(el2(doc, WP_NS3, "wp:simplePos"), { x: "0", y: "0" }),
29845
30510
  position(
29846
30511
  doc,
29847
30512
  "H",
@@ -29860,24 +30525,24 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
29860
30525
  } else for (const side of ["distT", "distB", "distL", "distR"]) holder.setAttribute(side, "0");
29861
30526
  add3(
29862
30527
  holder,
29863
- attrs(el2(doc, WP_NS3, "wp:extent"), { cx: emu3(image.widthPx), cy: emu3(image.heightPx) }),
29864
- attrs(el2(doc, WP_NS3, "wp:effectExtent"), { l: "0", t: "0", r: "0", b: "0" })
30528
+ attrs2(el2(doc, WP_NS3, "wp:extent"), { cx: emu3(image.widthPx), cy: emu3(image.heightPx) }),
30529
+ attrs2(el2(doc, WP_NS3, "wp:effectExtent"), { l: "0", t: "0", r: "0", b: "0" })
29865
30530
  );
29866
30531
  if (anchored) add3(holder, wrapElement(doc, placement ?? { wrap: "none" }));
29867
- const docPr = attrs(el2(doc, WP_NS3, "wp:docPr"), {
30532
+ const docPr = attrs2(el2(doc, WP_NS3, "wp:docPr"), {
29868
30533
  id: identity.id,
29869
30534
  name: identity.name ?? `Shape ${identity.id}`
29870
30535
  });
29871
30536
  if (identity.descr) docPr.setAttribute("descr", identity.descr);
29872
30537
  if (identity.title) docPr.setAttribute("title", identity.title);
29873
- const xfrm = attrs(el2(doc, A_NS2, "a:xfrm"), {});
30538
+ const xfrm = attrs2(el2(doc, A_NS2, "a:xfrm"), {});
29874
30539
  if (spec.rotation) xfrm.setAttribute("rot", String(Math.round(spec.rotation * 6e4)));
29875
30540
  if (spec.flipH) xfrm.setAttribute("flipH", "1");
29876
30541
  if (spec.flipV) xfrm.setAttribute("flipV", "1");
29877
30542
  add3(
29878
30543
  xfrm,
29879
- attrs(el2(doc, A_NS2, "a:off"), { x: "0", y: "0" }),
29880
- attrs(el2(doc, A_NS2, "a:ext"), { cx: emu3(image.widthPx), cy: emu3(image.heightPx) })
30544
+ attrs2(el2(doc, A_NS2, "a:off"), { x: "0", y: "0" }),
30545
+ attrs2(el2(doc, A_NS2, "a:ext"), { cx: emu3(image.widthPx), cy: emu3(image.heightPx) })
29881
30546
  );
29882
30547
  const spPr = add3(el2(doc, WPS_NS2, "wps:spPr"), xfrm, ...geometry(doc, spec));
29883
30548
  const wsp = add3(
@@ -29893,7 +30558,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
29893
30558
  );
29894
30559
  add3(wsp, add3(el2(doc, WPS_NS2, "wps:txbx"), content));
29895
30560
  }
29896
- const body = attrs(el2(doc, WPS_NS2, "wps:bodyPr"), {
30561
+ const body = attrs2(el2(doc, WPS_NS2, "wps:bodyPr"), {
29897
30562
  rot: "0",
29898
30563
  vert: "horz",
29899
30564
  wrap: "square",
@@ -29905,7 +30570,7 @@ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
29905
30570
  anchorCtr: "0"
29906
30571
  });
29907
30572
  add3(wsp, add3(body, el2(doc, A_NS2, "a:noAutofit")));
29908
- const graphicData = attrs(el2(doc, A_NS2, "a:graphicData"), { uri: WPS_NS2 });
30573
+ const graphicData = attrs2(el2(doc, A_NS2, "a:graphicData"), { uri: WPS_NS2 });
29909
30574
  add3(
29910
30575
  holder,
29911
30576
  docPr,
@@ -30021,9 +30686,9 @@ function clearNonProperties(node, keep) {
30021
30686
  var A_NS5 = "http://schemas.openxmlformats.org/drawingml/2006/main";
30022
30687
  var WP_NS5 = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
30023
30688
  var C_NS = "http://schemas.openxmlformats.org/drawingml/2006/chart";
30024
- function child6(parent, ns, name, attrs2 = {}) {
30689
+ function child6(parent, ns, name, attrs3 = {}) {
30025
30690
  const node = makeNS(parent.ownerDocument, ns, name);
30026
- for (const [key, value] of Object.entries(attrs2)) node.setAttribute(key, value);
30691
+ for (const [key, value] of Object.entries(attrs3)) node.setAttribute(key, value);
30027
30692
  parent.appendChild(node);
30028
30693
  return node;
30029
30694
  }
@@ -30409,14 +31074,14 @@ async function writeNewRelationships(zip, partName, created, pendingMedia) {
30409
31074
  overrides.push(relationship2);
30410
31075
  continue;
30411
31076
  }
30412
- const pending = pendingMedia?.get(relationship2.partName);
30413
- if (!pending)
31077
+ const pending2 = pendingMedia?.get(relationship2.partName);
31078
+ if (!pending2)
30414
31079
  throw new Error(`Missing bytes for newly inserted media part: ${relationship2.partName}`);
30415
- zip.file(relationship2.partName, pending.bytes);
31080
+ zip.file(relationship2.partName, pending2.bytes);
30416
31081
  contentTypesXml = ensureContentTypeDefault(
30417
31082
  contentTypesXml,
30418
31083
  extensionOf(relationship2.partName),
30419
- pending.contentType
31084
+ pending2.contentType
30420
31085
  );
30421
31086
  }
30422
31087
  zip.file(relsPath, buildRelationshipsXml(relationships));
@@ -30507,6 +31172,19 @@ async function applyDiagramEdits(zip, blocks, baseBlocks, pendingMedia) {
30507
31172
  ...relaid && layoutId ? { layout: { uniqueId: layoutId, category: diagram.layout?.family } } : {}
30508
31173
  })
30509
31174
  );
31175
+ if (diagram.layoutSource?.pictures?.length) {
31176
+ zip.file(
31177
+ partName,
31178
+ withDiagramPictureSources(await zip.file(partName).async("string"), diagram.layoutSource)
31179
+ );
31180
+ const relsName = relationshipsPartFor2(partName);
31181
+ const rels = diagramPictureRelationships(
31182
+ partName,
31183
+ diagram.layoutSource,
31184
+ await zip.file(relsName)?.async("string")
31185
+ );
31186
+ if (rels) zip.file(relsName, rels);
31187
+ }
30510
31188
  if (drawing) await dropDrawingPart(zip, drawing.relId, drawing.partName, drawing.ownerPart);
30511
31189
  }
30512
31190
  }
@@ -30519,9 +31197,9 @@ var EMU_PER_PIXEL2 = 9525;
30519
31197
  function isSameDiagram(base, next) {
30520
31198
  return Boolean(base?.parts.data?.partName) && base?.parts.data?.partName === next.parts.data?.partName && !next.inserted;
30521
31199
  }
30522
- function el3(doc, ns, qualified, attrs2 = {}) {
31200
+ function el3(doc, ns, qualified, attrs3 = {}) {
30523
31201
  const node = makeNS(doc, ns, qualified);
30524
- for (const [name, value] of Object.entries(attrs2)) node.setAttribute(name, value);
31202
+ for (const [name, value] of Object.entries(attrs3)) node.setAttribute(name, value);
30525
31203
  return node;
30526
31204
  }
30527
31205
  function buildInsertedDiagramDrawing(doc, diagram, widthPx, heightPx, allocator) {
@@ -30671,6 +31349,9 @@ function buildInlineDrawing(doc, image, relId, docPrId, svgRelId) {
30671
31349
  stretch.appendChild(el4(doc, A_NS7, "a:fillRect"));
30672
31350
  const blipFill = el4(doc, PIC_NS, "pic:blipFill");
30673
31351
  appendAll(blipFill, blip, stretch);
31352
+ if (image.pictureFill?.crop) applyPictureCrop(blipFill, image.pictureFill.crop);
31353
+ if (image.pictureFill?.effects) applyPictureEffects(blip, image.pictureFill.effects);
31354
+ if (image.pictureFill?.layout) applyPictureLayout(blipFill, image.pictureFill.layout);
30674
31355
  const xfrm = el4(doc, A_NS7, "a:xfrm");
30675
31356
  const off = el4(doc, A_NS7, "a:off");
30676
31357
  off.setAttribute("x", "0");
@@ -30757,6 +31438,16 @@ function createImageRun(doc, image, base, old, allocator) {
30757
31438
  return node;
30758
31439
  }
30759
31440
  if (base && oldDrawing && sameUnderlyingImage(base, image)) {
31441
+ if (image.pictureFill && JSON.stringify(image.pictureFill) !== JSON.stringify(base.pictureFill)) {
31442
+ const fill = oldDrawing.getElementsByTagNameNS(PIC_NS, "blipFill")[0];
31443
+ const blip = fill?.getElementsByTagNameNS(A_NS7, "blip")[0];
31444
+ if (fill && image.pictureFill.crop !== void 0)
31445
+ applyPictureCrop(fill, image.pictureFill.crop);
31446
+ if (blip && image.pictureFill.effects !== void 0)
31447
+ applyPictureEffects(blip, image.pictureFill.effects);
31448
+ if (fill && image.pictureFill.layout !== void 0)
31449
+ applyPictureLayout(fill, image.pictureFill.layout);
31450
+ }
30760
31451
  if (image.widthPx !== base.widthPx || image.heightPx !== base.heightPx)
30761
31452
  updateExtent(oldDrawing, image.widthPx, image.heightPx);
30762
31453
  if (image.altText !== base.altText || image.title !== base.title)
@@ -31067,7 +31758,7 @@ function writeFormFieldData(doc, field, source2) {
31067
31758
  }
31068
31759
 
31069
31760
  // docx/write-run.ts
31070
- function setAttribute6(element4, local, value) {
31761
+ function setAttribute7(element4, local, value) {
31071
31762
  element4.setAttributeNS(WORD_NS, `w:${local}`, value);
31072
31763
  }
31073
31764
  function removeChildren3(element4, local) {
@@ -31077,7 +31768,7 @@ function setToggle2(doc, props, local, value) {
31077
31768
  removeChildren3(props, local);
31078
31769
  if (value === void 0) return;
31079
31770
  const element4 = makeW(doc, local);
31080
- if (!value) setAttribute6(element4, "val", "0");
31771
+ if (!value) setAttribute7(element4, "val", "0");
31081
31772
  props.appendChild(element4);
31082
31773
  }
31083
31774
  function setBooleanAttribute(doc, props, local, value) {
@@ -31090,7 +31781,7 @@ function setBooleanAttribute(doc, props, local, value) {
31090
31781
  element4 = makeW(doc, local);
31091
31782
  props.appendChild(element4);
31092
31783
  }
31093
- setAttribute6(element4, "val", value ? "1" : "0");
31784
+ setAttribute7(element4, "val", value ? "1" : "0");
31094
31785
  }
31095
31786
  function setLanguageAttribute(doc, props, attribute2, value) {
31096
31787
  let language = first2(props, "lang");
@@ -31102,7 +31793,7 @@ function setLanguageAttribute(doc, props, attribute2, value) {
31102
31793
  language = makeW(doc, "lang");
31103
31794
  props.appendChild(language);
31104
31795
  }
31105
- setAttribute6(language, attribute2, value);
31796
+ setAttribute7(language, attribute2, value);
31106
31797
  }
31107
31798
  if (language && !language.attributes.length && !language.childNodes.length)
31108
31799
  props.removeChild(language);
@@ -31133,7 +31824,7 @@ function setRunProperties(doc, runNode, run2, base) {
31133
31824
  removeChildren3(props, "szCs");
31134
31825
  if (run2.fontSizeComplexScript !== void 0) {
31135
31826
  const size = makeW(doc, "szCs");
31136
- setAttribute6(size, "val", String(Math.round(run2.fontSizeComplexScript * 2)));
31827
+ setAttribute7(size, "val", String(Math.round(run2.fontSizeComplexScript * 2)));
31137
31828
  props.appendChild(size);
31138
31829
  }
31139
31830
  }
@@ -31145,13 +31836,13 @@ function setRunProperties(doc, runNode, run2, base) {
31145
31836
  removeChildren3(props, "u");
31146
31837
  if (run2.underline === false) {
31147
31838
  const none = makeW(doc, "u");
31148
- setAttribute6(none, "val", "none");
31839
+ setAttribute7(none, "val", "none");
31149
31840
  props.appendChild(none);
31150
31841
  } else if (run2.underline) {
31151
31842
  const underline = makeW(doc, "u");
31152
- setAttribute6(underline, "val", run2.underlineStyle ?? "single");
31843
+ setAttribute7(underline, "val", run2.underlineStyle ?? "single");
31153
31844
  if (run2.underlineColor)
31154
- setAttribute6(underline, "color", run2.underlineColor.replace(/^#/, ""));
31845
+ setAttribute7(underline, "color", run2.underlineColor.replace(/^#/, ""));
31155
31846
  props.appendChild(underline);
31156
31847
  }
31157
31848
  }
@@ -31159,7 +31850,7 @@ function setRunProperties(doc, runNode, run2, base) {
31159
31850
  removeChildren3(props, "highlight");
31160
31851
  if (run2.highlight) {
31161
31852
  const highlight = makeW(doc, "highlight");
31162
- setAttribute6(highlight, "val", run2.highlight);
31853
+ setAttribute7(highlight, "val", run2.highlight);
31163
31854
  props.appendChild(highlight);
31164
31855
  }
31165
31856
  }
@@ -31167,7 +31858,7 @@ function setRunProperties(doc, runNode, run2, base) {
31167
31858
  removeChildren3(props, "vertAlign");
31168
31859
  if (run2.verticalAlign) {
31169
31860
  const verticalAlign = makeW(doc, "vertAlign");
31170
- setAttribute6(verticalAlign, "val", run2.verticalAlign);
31861
+ setAttribute7(verticalAlign, "val", run2.verticalAlign);
31171
31862
  props.appendChild(verticalAlign);
31172
31863
  }
31173
31864
  }
@@ -31180,7 +31871,7 @@ function setRunProperties(doc, runNode, run2, base) {
31180
31871
  removeChildren3(props, "sz");
31181
31872
  if (run2.fontSize !== void 0) {
31182
31873
  const size = makeW(doc, "sz");
31183
- setAttribute6(size, "val", String(Math.round(run2.fontSize * 2)));
31874
+ setAttribute7(size, "val", String(Math.round(run2.fontSize * 2)));
31184
31875
  props.appendChild(size);
31185
31876
  }
31186
31877
  }
@@ -31189,11 +31880,11 @@ function setRunProperties(doc, runNode, run2, base) {
31189
31880
  if (run2.fontFamily || run2.fontTheme || run2.fontFamilyEastAsia || run2.fontFamilyComplexScript) {
31190
31881
  const fonts = makeW(doc, "rFonts");
31191
31882
  if (run2.fontFamily) {
31192
- setAttribute6(fonts, "ascii", run2.fontFamily);
31193
- setAttribute6(fonts, "hAnsi", run2.fontFamily);
31883
+ setAttribute7(fonts, "ascii", run2.fontFamily);
31884
+ setAttribute7(fonts, "hAnsi", run2.fontFamily);
31194
31885
  }
31195
- if (run2.fontFamilyEastAsia) setAttribute6(fonts, "eastAsia", run2.fontFamilyEastAsia);
31196
- if (run2.fontFamilyComplexScript) setAttribute6(fonts, "cs", run2.fontFamilyComplexScript);
31886
+ if (run2.fontFamilyEastAsia) setAttribute7(fonts, "eastAsia", run2.fontFamilyEastAsia);
31887
+ if (run2.fontFamilyComplexScript) setAttribute7(fonts, "cs", run2.fontFamilyComplexScript);
31197
31888
  const themeAttribute = {
31198
31889
  ascii: ["asciiTheme", "Ascii"],
31199
31890
  hAnsi: ["hAnsiTheme", "HAnsi"],
@@ -31203,7 +31894,7 @@ function setRunProperties(doc, runNode, run2, base) {
31203
31894
  for (const script of ["ascii", "hAnsi", "eastAsia", "cs"]) {
31204
31895
  const role = run2.fontTheme?.[script];
31205
31896
  const [attribute2, suffix] = themeAttribute[script];
31206
- if (role) setAttribute6(fonts, attribute2, `${role}${suffix}`);
31897
+ if (role) setAttribute7(fonts, attribute2, `${role}${suffix}`);
31207
31898
  }
31208
31899
  props.appendChild(fonts);
31209
31900
  }
@@ -31213,13 +31904,13 @@ function setRunProperties(doc, runNode, run2, base) {
31213
31904
  const hex = run2.color && /^#?([0-9a-f]{6})$/i.exec(run2.color)?.[1];
31214
31905
  if (hex || run2.colorTheme) {
31215
31906
  const color = makeW(doc, "color");
31216
- setAttribute6(color, "val", hex || "auto");
31907
+ setAttribute7(color, "val", hex || "auto");
31217
31908
  if (run2.colorTheme) {
31218
- setAttribute6(color, "themeColor", run2.colorTheme.token);
31909
+ setAttribute7(color, "themeColor", run2.colorTheme.token);
31219
31910
  if (run2.colorTheme.tint !== void 0)
31220
- setAttribute6(color, "themeTint", fractionToThemeByte(run2.colorTheme.tint));
31911
+ setAttribute7(color, "themeTint", fractionToThemeByte(run2.colorTheme.tint));
31221
31912
  if (run2.colorTheme.shade !== void 0)
31222
- setAttribute6(color, "themeShade", fractionToThemeByte(run2.colorTheme.shade));
31913
+ setAttribute7(color, "themeShade", fractionToThemeByte(run2.colorTheme.shade));
31223
31914
  }
31224
31915
  props.appendChild(color);
31225
31916
  }
@@ -31268,13 +31959,13 @@ function createRun(doc, run2, base, old, allocator) {
31268
31959
  if (child7.nodeType !== 1 || child7.localName !== "rPr") node.removeChild(child7);
31269
31960
  if (run2.break) {
31270
31961
  const br = makeW(doc, "br");
31271
- setAttribute6(br, "type", run2.break);
31962
+ setAttribute7(br, "type", run2.break);
31272
31963
  node.appendChild(br);
31273
31964
  return node;
31274
31965
  }
31275
31966
  if (run2.fieldChar) {
31276
31967
  const marker = makeW(doc, "fldChar");
31277
- setAttribute6(marker, "fldCharType", run2.fieldChar);
31968
+ setAttribute7(marker, "fldCharType", run2.fieldChar);
31278
31969
  writeFieldFlags(marker, run2.fieldFlags);
31279
31970
  if (run2.fieldChar === "begin" && run2.formField)
31280
31971
  marker.appendChild(writeFormFieldData(doc, run2.formField, formData));
@@ -31301,7 +31992,7 @@ function createRun(doc, run2, base, old, allocator) {
31301
31992
  doc,
31302
31993
  run2.noteReference.kind === "footnote" ? "footnoteReference" : "endnoteReference"
31303
31994
  );
31304
- setAttribute6(reference, "id", run2.noteReference.id);
31995
+ setAttribute7(reference, "id", run2.noteReference.id);
31305
31996
  node.appendChild(reference);
31306
31997
  return node;
31307
31998
  }
@@ -32037,7 +32728,7 @@ function runsToWriteAnew(paragraph2, base, slots) {
32037
32728
  }
32038
32729
 
32039
32730
  // docx/write-paragraph.ts
32040
- function setAttribute7(element4, local, value) {
32731
+ function setAttribute8(element4, local, value) {
32041
32732
  element4.setAttributeNS(WORD_NS, `w:${local}`, value);
32042
32733
  }
32043
32734
  function removeChildren4(element4, local) {
@@ -32081,7 +32772,7 @@ function writeParagraphImpl(doc, paragraph2, node, base, allocator, spans) {
32081
32772
  const jc = paragraphJustification(paragraph2);
32082
32773
  if (jc) {
32083
32774
  const align = makeW(doc, "jc");
32084
- setAttribute7(align, "val", jc);
32775
+ setAttribute8(align, "val", jc);
32085
32776
  pPr.appendChild(align);
32086
32777
  }
32087
32778
  }
@@ -32089,7 +32780,7 @@ function writeParagraphImpl(doc, paragraph2, node, base, allocator, spans) {
32089
32780
  removeChildren4(pPr, "pStyle");
32090
32781
  if (paragraph2.style) {
32091
32782
  const style = makeW(doc, "pStyle");
32092
- setAttribute7(style, "val", paragraph2.style);
32783
+ setAttribute8(style, "val", paragraph2.style);
32093
32784
  pPr.appendChild(style);
32094
32785
  }
32095
32786
  }
@@ -32114,7 +32805,14 @@ function writeParagraphImpl(doc, paragraph2, node, base, allocator, spans) {
32114
32805
  const source2 = new Set(sourceBookmarks);
32115
32806
  const kept = /* @__PURE__ */ new Set([...starts, ...ends]);
32116
32807
  const sourcePositions = runPositions(base?.runs ?? []);
32117
- const read = markers.filter((marker) => !isBookmark(marker.element) || kept.has(marker.element)).map((marker) => {
32808
+ const permissions = changedPermissionMarkers(
32809
+ doc,
32810
+ paragraph2,
32811
+ base,
32812
+ markers.map((marker) => marker.element),
32813
+ runPositions(paragraph2.runs).at(-1)
32814
+ );
32815
+ const read = markers.filter((marker) => !isBookmark(marker.element) || kept.has(marker.element)).filter((marker) => !permissions?.drop.has(marker.element)).map((marker) => {
32118
32816
  const position2 = sourcePositions[marker.boundary] ?? 0;
32119
32817
  const annotation = marker.annotation;
32120
32818
  return {
@@ -32129,8 +32827,8 @@ function writeParagraphImpl(doc, paragraph2, node, base, allocator, spans) {
32129
32827
  });
32130
32828
  const end = runPositions(paragraph2.runs).at(-1);
32131
32829
  const sources = containerSources(paragraph2.runs, base?.runs, slots);
32132
- const carried = orderRangeEnds(
32133
- base ? followFormFieldBookmarks(
32830
+ const carried = orderRangeEnds([
32831
+ ...base ? followFormFieldBookmarks(
32134
32832
  followContainers(
32135
32833
  moveMarkers(base.runs, paragraph2.runs, read),
32136
32834
  sources,
@@ -32139,8 +32837,9 @@ function writeParagraphImpl(doc, paragraph2, node, base, allocator, spans) {
32139
32837
  ),
32140
32838
  base.runs,
32141
32839
  paragraph2.runs
32142
- ) : read.map((marker) => ({ ...marker, position: marker.opening ? 0 : end }))
32143
- );
32840
+ ) : read.map((marker) => ({ ...marker, position: marker.opening ? 0 : end })),
32841
+ ...permissions?.added ?? []
32842
+ ]);
32144
32843
  for (const marker of markers) marker.element.parentNode?.removeChild(marker.element);
32145
32844
  for (const oldNode of replaceableInlineChildren(node)) node.removeChild(oldNode);
32146
32845
  const { nodes, placed, containers } = buildInlineContent(
@@ -32289,21 +32988,21 @@ function applyModel(doc, model, original, reservedRelationshipIds = [], baseSect
32289
32988
  size = makeW(doc, "pgSz");
32290
32989
  section.appendChild(size);
32291
32990
  }
32292
- setAttribute7(size, "w", twips2(model.page.width));
32293
- setAttribute7(size, "h", twips2(model.page.height));
32991
+ setAttribute8(size, "w", twips2(model.page.width));
32992
+ setAttribute8(size, "h", twips2(model.page.height));
32294
32993
  let margins = first2(section, "pgMar");
32295
32994
  if (!margins) {
32296
32995
  margins = makeW(doc, "pgMar");
32297
32996
  section.appendChild(margins);
32298
32997
  }
32299
32998
  for (const side of ["Top", "Right", "Bottom", "Left"])
32300
- setAttribute7(margins, side.toLowerCase(), twips2(model.page[`margin${side}`]));
32999
+ setAttribute8(margins, side.toLowerCase(), twips2(model.page[`margin${side}`]));
32301
33000
  for (const [name, fallback] of [
32302
33001
  ["header", "720"],
32303
33002
  ["footer", "720"],
32304
33003
  ["gutter", "0"]
32305
33004
  ])
32306
- if (!margins.getAttributeNS(WORD_NS, name)) setAttribute7(margins, name, fallback);
33005
+ if (!margins.getAttributeNS(WORD_NS, name)) setAttribute8(margins, name, fallback);
32307
33006
  orderSectionProperties(section);
32308
33007
  if (model.sections)
32309
33008
  applySectionEdits(
@@ -32777,6 +33476,122 @@ function assertValidDocumentModel(model) {
32777
33476
  if (issues.length) throw new DocxModelValidationError(issues);
32778
33477
  }
32779
33478
 
33479
+ // docx/numbering-picture.ts
33480
+ var NUMBERING_PART = "word/numbering.xml";
33481
+ var descendants4 = (root, local) => Array.from(root.getElementsByTagName("*")).filter(
33482
+ (node) => node.nodeType === 1 && node.localName === local
33483
+ );
33484
+ var points = (style, property) => {
33485
+ const match = new RegExp(`(?:^|;)\\s*${property}:\\s*([\\d.]+)(pt|px|in|cm|mm)?`, "i").exec(
33486
+ style
33487
+ );
33488
+ if (!match) return void 0;
33489
+ const value = Number(match[1]);
33490
+ const unit = (match[2] ?? "pt").toLowerCase();
33491
+ const factor = { pt: 1, px: 0.75, in: 72, cm: 72 / 2.54, mm: 72 / 25.4 }[unit] ?? 1;
33492
+ return Number.isFinite(value) && value > 0 ? value * factor : void 0;
33493
+ };
33494
+ function parsePictureBullet(element4, rels) {
33495
+ const id = getW(element4, "numPicBulletId");
33496
+ if (id === void 0) return void 0;
33497
+ const imagedata = descendants4(element4, "imagedata")[0];
33498
+ const blip = descendants4(element4, "blip")[0];
33499
+ const relId = imagedata && getR(imagedata, "id") || blip && getR(blip, "embed") || void 0;
33500
+ const rel = relId ? rels.get(relId) : void 0;
33501
+ if (!rel || rel.mode === "External") return void 0;
33502
+ const partName = resolvePartPath(NUMBERING_PART, rel.target);
33503
+ const result = {
33504
+ id,
33505
+ partName,
33506
+ contentType: imageContentType(partName)
33507
+ };
33508
+ const style = descendants4(element4, "shape")[0]?.getAttribute("style") ?? "";
33509
+ let width = points(style, "width");
33510
+ let height = points(style, "height");
33511
+ const extent = descendants4(element4, "extent")[0];
33512
+ if (extent && width === void 0 && height === void 0) {
33513
+ const cx = Number(extent.getAttribute("cx"));
33514
+ const cy = Number(extent.getAttribute("cy"));
33515
+ if (cx > 0 && cy > 0) {
33516
+ width = cx / 12700;
33517
+ height = cy / 12700;
33518
+ }
33519
+ }
33520
+ if (width !== void 0) result.widthPt = width;
33521
+ if (height !== void 0) result.heightPt = height;
33522
+ return result;
33523
+ }
33524
+ function parseNumberingPictureBullets(root, rels) {
33525
+ const bullets = /* @__PURE__ */ Object.create(null);
33526
+ if (!rels) return bullets;
33527
+ for (const element4 of descendants4(root, "numPicBullet")) {
33528
+ const parsed = parsePictureBullet(element4, rels);
33529
+ if (parsed) bullets[parsed.id] = parsed;
33530
+ }
33531
+ return bullets;
33532
+ }
33533
+
33534
+ // docx/numbering-picture-save.ts
33535
+ var VML_NS3 = "urn:schemas-microsoft-com:vml";
33536
+ var OFFICE_NS2 = "urn:schemas-microsoft-com:office:office";
33537
+ var R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
33538
+ var IMAGE_REL = `${R_NS}/image`;
33539
+ function addedPictureBullets(prior, next) {
33540
+ for (const [id, bullet] of Object.entries(prior?.pictureBullets ?? {}))
33541
+ if (JSON.stringify(next.pictureBullets?.[id]) !== JSON.stringify(bullet))
33542
+ throw new Error(
33543
+ `Cannot edit picture bullet "${id}"; the original numbering.xml and its images are preserved unchanged.`
33544
+ );
33545
+ return Object.values(next.pictureBullets ?? {}).filter(
33546
+ (bullet) => !prior?.pictureBullets?.[bullet.id]
33547
+ );
33548
+ }
33549
+ function buildPictureBullet(doc, bullet, relId, serial) {
33550
+ const element4 = makeW(doc, "numPicBullet");
33551
+ element4.setAttributeNS(WORD_NS, "w:numPicBulletId", bullet.id);
33552
+ const pict = makeW(doc, "pict");
33553
+ const shape = makeNS(doc, VML_NS3, "v:shape");
33554
+ shape.setAttribute("id", `_x0000_i${1025 + serial}`);
33555
+ shape.setAttribute("type", "#_x0000_t75");
33556
+ const width = bullet.widthPt ?? bullet.heightPt ?? 9;
33557
+ const height = bullet.heightPt ?? width;
33558
+ shape.setAttribute("style", `width:${+width.toFixed(2)}pt;height:${+height.toFixed(2)}pt`);
33559
+ shape.setAttributeNS(OFFICE_NS2, "o:bullet", "t");
33560
+ const imagedata = makeNS(doc, VML_NS3, "v:imagedata");
33561
+ imagedata.setAttributeNS(R_NS, "r:id", relId);
33562
+ imagedata.setAttributeNS(OFFICE_NS2, "o:title", "");
33563
+ shape.appendChild(imagedata);
33564
+ pict.appendChild(shape);
33565
+ element4.appendChild(pict);
33566
+ return element4;
33567
+ }
33568
+ async function writePictureBullets(zip, doc, added, before, pendingMedia) {
33569
+ if (!added.length) return;
33570
+ const used = new Set(
33571
+ parseRelationships(
33572
+ await zip.file(relationshipsPartFor2(NUMBERING_PART))?.async("string")
33573
+ ).keys()
33574
+ );
33575
+ let serial = 1;
33576
+ const relationships = added.map((bullet, index) => {
33577
+ while (used.has(`rId${serial}`)) serial++;
33578
+ const id = `rId${serial}`;
33579
+ used.add(id);
33580
+ doc.documentElement.insertBefore(buildPictureBullet(doc, bullet, id, index), before);
33581
+ const stored = zip.file(bullet.partName) !== null;
33582
+ if (!stored && !pendingMedia?.get(bullet.partName))
33583
+ throw new Error(`Missing bytes for picture bullet image: ${bullet.partName}`);
33584
+ return {
33585
+ id,
33586
+ type: IMAGE_REL,
33587
+ target: bullet.partName.replace(/^word\//, ""),
33588
+ mode: "Internal",
33589
+ ...stored ? {} : { partName: bullet.partName }
33590
+ };
33591
+ });
33592
+ await writeNewRelationships(zip, NUMBERING_PART, relationships, pendingMedia);
33593
+ }
33594
+
32780
33595
  // docx/numbering-parts.ts
32781
33596
  var CT_NS = "http://schemas.openxmlformats.org/package/2006/content-types";
32782
33597
  var REL_NS2 = "http://schemas.openxmlformats.org/package/2006/relationships";
@@ -32868,6 +33683,8 @@ function parseNumberingLevel(lvl) {
32868
33683
  if (flag(first2(lvl, "isLgl"))) result.isLgl = true;
32869
33684
  const restart = getW(first2(lvl, "lvlRestart"), "val");
32870
33685
  if (restart !== void 0) result.lvlRestart = integer3(restart, 0);
33686
+ const pictureBulletId = getW(first2(lvl, "lvlPicBulletId"), "val");
33687
+ if (pictureBulletId !== void 0) result.pictureBulletId = pictureBulletId;
32871
33688
  const marker = parseMarkerFormat(first2(lvl, "rPr"));
32872
33689
  if (marker) result.markerFormat = marker;
32873
33690
  result.suffix = suffRaw === "space" ? "space" : suffRaw === "nothing" ? "none" : "tab";
@@ -32903,7 +33720,7 @@ function parseNum(element4) {
32903
33720
  ...Object.keys(levelOverrides).length ? { levelOverrides } : {}
32904
33721
  };
32905
33722
  }
32906
- function parseNumberingCatalog(xml) {
33723
+ function parseNumberingCatalog(xml, relationships) {
32907
33724
  const document = parseXml2(xml);
32908
33725
  const root = document.documentElement;
32909
33726
  const abstractNums = dictionary();
@@ -32917,17 +33734,30 @@ function parseNumberingCatalog(xml) {
32917
33734
  warnings.push(
32918
33735
  `Numbering definition abstractNum ${parsed.id} links to style "${link}"; style-linked numbering levels are not resolved.`
32919
33736
  );
32920
- if (byName(element4, "lvlPicBulletId").length)
32921
- warnings.push(
32922
- `Numbering definition abstractNum ${parsed.id} uses a picture bullet; picture bullets are not rendered.`
32923
- );
32924
33737
  }
33738
+ const pictureBullets = parseNumberingPictureBullets(
33739
+ root,
33740
+ relationships
33741
+ );
33742
+ for (const element4 of byName(root, "abstractNum"))
33743
+ for (const ref of byName(element4, "lvlPicBulletId")) {
33744
+ const id = getW(ref, "val");
33745
+ if (id !== void 0 && !own(pictureBullets, id))
33746
+ warnings.push(
33747
+ `Numbering definition abstractNum ${getW(element4, "abstractNumId")} uses picture bullet ${id}, whose image could not be resolved; the level falls back to its bullet glyph.`
33748
+ );
33749
+ }
32925
33750
  const nums = dictionary();
32926
33751
  for (const element4 of byName(root, "num")) {
32927
33752
  const parsed = parseNum(element4);
32928
33753
  if (parsed) nums[parsed.id] = parsed;
32929
33754
  }
32930
- return { abstractNums, nums, warnings: [...new Set(warnings)] };
33755
+ return {
33756
+ abstractNums,
33757
+ nums,
33758
+ ...Object.keys(pictureBullets).length ? { pictureBullets } : {},
33759
+ warnings: [...new Set(warnings)]
33760
+ };
32931
33761
  }
32932
33762
  function resolveNumberingLevel(catalog, numId, level3) {
32933
33763
  const num2 = own(catalog.nums, numId);
@@ -33033,17 +33863,18 @@ function patchNumberingStarts(doc, changes) {
33033
33863
  }
33034
33864
 
33035
33865
  // docx/numbering-package.ts
33036
- function setAttribute8(element4, local, value) {
33866
+ var addedAbstractIds = (prior, next) => Object.keys(next.abstractNums).filter((id) => !prior?.abstractNums[id]);
33867
+ function setAttribute9(element4, local, value) {
33037
33868
  element4.setAttributeNS(WORD_NS, `w:${local}`, value);
33038
33869
  }
33039
33870
  function valueElement(doc, local, value) {
33040
33871
  const element4 = makeW(doc, local);
33041
- setAttribute8(element4, "val", value);
33872
+ setAttribute9(element4, "val", value);
33042
33873
  return element4;
33043
33874
  }
33044
33875
  function buildLevelElement(doc, def) {
33045
33876
  const lvl = makeW(doc, "lvl");
33046
- setAttribute8(lvl, "ilvl", String(def.level));
33877
+ setAttribute9(lvl, "ilvl", String(def.level));
33047
33878
  if (!def.startWasOmitted || def.start !== 1)
33048
33879
  lvl.appendChild(valueElement(doc, "start", String(def.start)));
33049
33880
  lvl.appendChild(valueElement(doc, "numFmt", def.numFmt));
@@ -33059,22 +33890,24 @@ function buildLevelElement(doc, def) {
33059
33890
  )
33060
33891
  );
33061
33892
  lvl.appendChild(valueElement(doc, "lvlText", def.lvlText));
33893
+ if (def.pictureBulletId !== void 0)
33894
+ lvl.appendChild(valueElement(doc, "lvlPicBulletId", def.pictureBulletId));
33062
33895
  if (def.lvlJc) lvl.appendChild(valueElement(doc, "lvlJc", def.lvlJc));
33063
33896
  if (def.tabStopTwips !== void 0 || def.indentLeftTwips !== void 0 || def.hangingTwips !== void 0 || def.firstLineTwips !== void 0) {
33064
33897
  const pPr = makeW(doc, "pPr");
33065
33898
  if (def.tabStopTwips !== void 0) {
33066
33899
  const tabs = makeW(doc, "tabs");
33067
33900
  const tab = makeW(doc, "tab");
33068
- setAttribute8(tab, "val", "num");
33069
- setAttribute8(tab, "pos", String(def.tabStopTwips));
33901
+ setAttribute9(tab, "val", "num");
33902
+ setAttribute9(tab, "pos", String(def.tabStopTwips));
33070
33903
  tabs.appendChild(tab);
33071
33904
  pPr.appendChild(tabs);
33072
33905
  }
33073
33906
  const ind = makeW(doc, "ind");
33074
- if (def.indentLeftTwips !== void 0) setAttribute8(ind, "left", String(def.indentLeftTwips));
33075
- if (def.hangingTwips !== void 0) setAttribute8(ind, "hanging", String(def.hangingTwips));
33907
+ if (def.indentLeftTwips !== void 0) setAttribute9(ind, "left", String(def.indentLeftTwips));
33908
+ if (def.hangingTwips !== void 0) setAttribute9(ind, "hanging", String(def.hangingTwips));
33076
33909
  if (def.firstLineTwips !== void 0)
33077
- setAttribute8(ind, "firstLine", String(def.firstLineTwips));
33910
+ setAttribute9(ind, "firstLine", String(def.firstLineTwips));
33078
33911
  if (ind.attributes.length) pPr.appendChild(ind);
33079
33912
  lvl.appendChild(pPr);
33080
33913
  }
@@ -33083,8 +33916,8 @@ function buildLevelElement(doc, def) {
33083
33916
  const rPr = makeW(doc, "rPr");
33084
33917
  if (marker.fontFamily) {
33085
33918
  const fonts = makeW(doc, "rFonts");
33086
- setAttribute8(fonts, "ascii", marker.fontFamily);
33087
- setAttribute8(fonts, "hAnsi", marker.fontFamily);
33919
+ setAttribute9(fonts, "ascii", marker.fontFamily);
33920
+ setAttribute9(fonts, "hAnsi", marker.fontFamily);
33088
33921
  rPr.appendChild(fonts);
33089
33922
  }
33090
33923
  if (marker.bold) rPr.appendChild(makeW(doc, "b"));
@@ -33099,7 +33932,7 @@ function buildLevelElement(doc, def) {
33099
33932
  }
33100
33933
  function buildAbstractNumElement(doc, def) {
33101
33934
  const element4 = makeW(doc, "abstractNum");
33102
- setAttribute8(element4, "abstractNumId", def.id);
33935
+ setAttribute9(element4, "abstractNumId", def.id);
33103
33936
  element4.appendChild(valueElement(doc, "multiLevelType", "hybridMultilevel"));
33104
33937
  for (const level3 of Object.values(def.levels).sort((a2, b) => a2.level - b.level))
33105
33938
  element4.appendChild(buildLevelElement(doc, level3));
@@ -33107,11 +33940,11 @@ function buildAbstractNumElement(doc, def) {
33107
33940
  }
33108
33941
  function buildNumElement(doc, def) {
33109
33942
  const element4 = makeW(doc, "num");
33110
- setAttribute8(element4, "numId", def.id);
33943
+ setAttribute9(element4, "numId", def.id);
33111
33944
  element4.appendChild(valueElement(doc, "abstractNumId", def.abstractNumId));
33112
33945
  for (const [level3, override] of Object.entries(def.levelOverrides ?? {})) {
33113
33946
  const lvlOverride = makeW(doc, "lvlOverride");
33114
- setAttribute8(lvlOverride, "ilvl", level3);
33947
+ setAttribute9(lvlOverride, "ilvl", level3);
33115
33948
  if (override.startOverride !== void 0)
33116
33949
  lvlOverride.appendChild(valueElement(doc, "startOverride", String(override.startOverride)));
33117
33950
  if (override.lvl) lvlOverride.appendChild(buildLevelElement(doc, override.lvl));
@@ -33119,7 +33952,7 @@ function buildNumElement(doc, def) {
33119
33952
  }
33120
33953
  return element4;
33121
33954
  }
33122
- async function applyNumberingCatalog(zip, model, binding) {
33955
+ async function applyNumberingCatalog(zip, model, binding, pendingMedia) {
33123
33956
  const next = model.numberingCatalog;
33124
33957
  const prior = binding?.base.numberingCatalog;
33125
33958
  if (JSON.stringify(next ?? null) === JSON.stringify(prior ?? null)) return;
@@ -33131,6 +33964,14 @@ async function applyNumberingCatalog(zip, model, binding) {
33131
33964
  throw new Error(
33132
33965
  "Removing the numbering catalog is not supported; the source numbering.xml is preserved unchanged."
33133
33966
  );
33967
+ const addedPictures = addedPictureBullets(prior, next);
33968
+ for (const level3 of addedAbstractIds(prior, next).flatMap(
33969
+ (id) => Object.values(next.abstractNums[id]?.levels ?? {})
33970
+ ))
33971
+ if (level3.pictureBulletId !== void 0 && !next.pictureBullets?.[level3.pictureBulletId])
33972
+ throw new Error(
33973
+ `Level ${level3.level} references picture bullet "${level3.pictureBulletId}", which the numbering part does not define.`
33974
+ );
33134
33975
  for (const id of Object.keys(prior?.abstractNums ?? {}))
33135
33976
  if (JSON.stringify(next.abstractNums[id]) !== JSON.stringify(prior?.abstractNums[id]))
33136
33977
  throw new Error(
@@ -33139,12 +33980,20 @@ async function applyNumberingCatalog(zip, model, binding) {
33139
33980
  const startChanges = numberingStartChanges(prior, next);
33140
33981
  const newAbstractIds = Object.keys(next.abstractNums).filter((id) => !prior?.abstractNums[id]);
33141
33982
  const newNumIds = Object.keys(next.nums).filter((id) => !prior?.nums[id]);
33142
- if (!newAbstractIds.length && !newNumIds.length && !startChanges.length) return;
33983
+ if (!newAbstractIds.length && !newNumIds.length && !startChanges.length && !addedPictures.length)
33984
+ return;
33143
33985
  const existingFile = zip.file("word/numbering.xml");
33144
33986
  const doc = existingFile ? parseXml2(await existingFile.async("string")) : parseXml2(`<w:numbering xmlns:w="${WORD_NS}"/>`);
33145
33987
  const root = doc.documentElement;
33146
33988
  patchNumberingStarts(doc, startChanges);
33147
33989
  const cleanup = children2(root, "numIdMacAtCleanup")[0] ?? null;
33990
+ await writePictureBullets(
33991
+ zip,
33992
+ doc,
33993
+ addedPictures,
33994
+ children2(root, "abstractNum")[0] ?? children2(root, "num")[0] ?? cleanup,
33995
+ pendingMedia
33996
+ );
33148
33997
  const firstNum = children2(root, "num")[0] ?? cleanup;
33149
33998
  for (const id of newAbstractIds) {
33150
33999
  const abstractNum = next.abstractNums[id];
@@ -33423,6 +34272,55 @@ async function applyNoteEdits(zip, model, base, pendingMedia, docPrIds) {
33423
34272
  }
33424
34273
  }
33425
34274
 
34275
+ // docx/protection.ts
34276
+ var DIGEST_BY_SID = {
34277
+ 1: "MD2",
34278
+ 2: "MD4",
34279
+ 3: "MD5",
34280
+ 4: "SHA-1",
34281
+ 7: "RIPEMD-128",
34282
+ 8: "RIPEMD-160",
34283
+ 12: "SHA-256",
34284
+ 13: "SHA-384",
34285
+ 14: "SHA-512"
34286
+ };
34287
+ var integer4 = (value) => {
34288
+ const number2 = value === void 0 ? NaN : Number(value);
34289
+ return Number.isInteger(number2) ? number2 : void 0;
34290
+ };
34291
+ function readProtectionPassword(element4) {
34292
+ const hashValue = getW(element4, "hashValue");
34293
+ const saltValue = getW(element4, "saltValue");
34294
+ const algorithmName = getW(element4, "algorithmName");
34295
+ if (hashValue && saltValue && algorithmName) {
34296
+ const spinCount2 = integer4(getW(element4, "spinCount"));
34297
+ return {
34298
+ password: {
34299
+ algorithmName,
34300
+ hashValue,
34301
+ saltValue,
34302
+ ...spinCount2 !== void 0 && { spinCount: spinCount2 }
34303
+ }
34304
+ };
34305
+ }
34306
+ const hash = getW(element4, "hash");
34307
+ if (!hash) return {};
34308
+ const sid = integer4(getW(element4, "cryptAlgorithmSid"));
34309
+ const salt = getW(element4, "salt");
34310
+ const digest = sid === void 0 ? void 0 : DIGEST_BY_SID[sid];
34311
+ if (sid === void 0 || !digest || !salt) return { unverifiable: true };
34312
+ const spinCount = integer4(getW(element4, "cryptSpinCount"));
34313
+ return {
34314
+ password: {
34315
+ algorithmName: digest,
34316
+ hashValue: hash,
34317
+ saltValue: salt,
34318
+ ...spinCount !== void 0 && { spinCount },
34319
+ word: { algorithmSid: sid }
34320
+ }
34321
+ };
34322
+ }
34323
+
33426
34324
  // docx/settings.ts
33427
34325
  var SETTINGS_PATH = "word/settings.xml";
33428
34326
  var SETTINGS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml";
@@ -33537,10 +34435,14 @@ function parseFormSettings(xml) {
33537
34435
  if (!root) return {};
33538
34436
  const protect = children2(root, "documentProtection")[0];
33539
34437
  const edit = protect && getW(protect, "edit");
34438
+ const secret = protect && readProtectionPassword(protect);
33540
34439
  return {
33541
34440
  ...protect && {
33542
34441
  protection: {
33543
34442
  edit: isStDocProtect(edit) ? edit : "none",
34443
+ ...parseOnOff(getW(protect, "formatting")) === true && { formatting: true },
34444
+ ...secret?.password && { password: secret.password },
34445
+ ...secret?.unverifiable && { unverifiablePassword: true },
33544
34446
  // Word enforces the protection unless `w:enforcement` turns it off ([MS-OE376]
33545
34447
  // 2.1.410), where ECMA-376 would ignore it when the attribute is missing.
33546
34448
  enforced: parseOnOff(getW(protect, "enforcement")) !== false
@@ -33629,6 +34531,51 @@ async function applyCompatibilityMode(zip, mode) {
33629
34531
  await ensureDocumentRelationship(zip, SETTINGS_RELATIONSHIP_TYPE, "settings.xml");
33630
34532
  }
33631
34533
  }
34534
+ function protectionElement(doc, protection) {
34535
+ const element4 = makeW(doc, "documentProtection");
34536
+ const set2 = (name, value) => element4.setAttributeNS(WORD_NS, `w:${name}`, String(value));
34537
+ set2("edit", protection.edit);
34538
+ if (protection.formatting) set2("formatting", 1);
34539
+ set2("enforcement", protection.enforced ? 1 : 0);
34540
+ const secret = protection.password;
34541
+ if (secret?.word) {
34542
+ set2("cryptProviderType", "rsaAES");
34543
+ set2("cryptAlgorithmClass", "hash");
34544
+ set2("cryptAlgorithmType", "typeAny");
34545
+ set2("cryptAlgorithmSid", secret.word.algorithmSid);
34546
+ if (secret.spinCount !== void 0) set2("cryptSpinCount", secret.spinCount);
34547
+ set2("hash", secret.hashValue);
34548
+ set2("salt", secret.saltValue);
34549
+ } else if (secret) {
34550
+ set2("algorithmName", secret.algorithmName);
34551
+ set2("hashValue", secret.hashValue);
34552
+ set2("saltValue", secret.saltValue);
34553
+ if (secret.spinCount !== void 0) set2("spinCount", secret.spinCount);
34554
+ }
34555
+ return element4;
34556
+ }
34557
+ async function applyDocumentProtection(zip, protection) {
34558
+ const file = zip.file(SETTINGS_PATH);
34559
+ if (!file && !protection) return;
34560
+ const doc = parseXml2(
34561
+ await file?.async("string") ?? `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:settings xmlns:w="${WORD_NS}"></w:settings>`
34562
+ );
34563
+ const root = doc.documentElement;
34564
+ for (const element4 of children2(root, "documentProtection")) root.removeChild(element4);
34565
+ if (protection) {
34566
+ const rank2 = SETTINGS_ORDER.indexOf("documentProtection");
34567
+ const after = Array.from(root.childNodes).find((node) => {
34568
+ const index = SETTINGS_ORDER.indexOf(node.localName ?? "");
34569
+ return node.nodeType === 1 && index > rank2;
34570
+ });
34571
+ root.insertBefore(protectionElement(doc, protection), after ?? null);
34572
+ }
34573
+ zip.file(SETTINGS_PATH, buildXml(doc));
34574
+ if (!file) {
34575
+ await ensureContentTypeOverride(zip, SETTINGS_PATH, SETTINGS_CONTENT_TYPE);
34576
+ await ensureDocumentRelationship(zip, SETTINGS_RELATIONSHIP_TYPE, "settings.xml");
34577
+ }
34578
+ }
33632
34579
 
33633
34580
  // docx/page-background.ts
33634
34581
  var HEX = /^[0-9a-fA-F]{6}$/;
@@ -33981,6 +34928,7 @@ function computeListLabels(model) {
33981
34928
  if (def.numFmt === "none") continue;
33982
34929
  counters.advance(numId, level3, def, catalog);
33983
34930
  const text = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId, level3, catalog, counters, Boolean(def.isLgl));
34931
+ const picture = def.pictureBulletId !== void 0 ? catalog.pictureBullets?.[def.pictureBulletId] : void 0;
33984
34932
  labels.set(paragraph2.id, {
33985
34933
  numId,
33986
34934
  level: level3,
@@ -33992,7 +34940,8 @@ function computeListLabels(model) {
33992
34940
  hangingTwips: def.hangingTwips,
33993
34941
  firstLineTwips: def.firstLineTwips,
33994
34942
  markerFormat: def.markerFormat,
33995
- tabStopTwips: def.tabStopTwips
34943
+ tabStopTwips: def.tabStopTwips,
34944
+ picture
33996
34945
  })
33997
34946
  });
33998
34947
  }
@@ -34425,6 +35374,7 @@ async function applyGeneratedDiagramCaches(zip, blocks, baseBlocks, theme) {
34425
35374
  const colorsXml = await read("colors");
34426
35375
  const quickStyleXml = await read("quickStyle");
34427
35376
  const source2 = {
35377
+ ...diagram.layoutSource,
34428
35378
  ...layoutXml3 ? { layoutXml: layoutXml3 } : {},
34429
35379
  ...colorsXml ? { colorsXml } : {},
34430
35380
  ...quickStyleXml ? { quickStyleXml } : {}
@@ -34449,6 +35399,8 @@ async function applyGeneratedDiagramCaches(zip, blocks, baseBlocks, theme) {
34449
35399
  );
34450
35400
  zip.file(name, withDiagramDrawingRelationship(cache.dataXml, relationship2));
34451
35401
  zip.file(drawingName, cache.drawingXml);
35402
+ const pictureRels = diagramPictureRelationships(drawingName, diagram.layoutSource);
35403
+ if (pictureRels) zip.file(drawingName.replace(/([^/]+)$/, "_rels/$1.rels"), pictureRels);
34452
35404
  await ensureContentTypeOverride(zip, drawingName, DIAGRAM_CONTENT_TYPES.drawing);
34453
35405
  }
34454
35406
  }
@@ -34695,7 +35647,7 @@ async function saveDocx(model, pendingMedia, options) {
34695
35647
  docPrIds
34696
35648
  );
34697
35649
  await applyChartPartEdits(zip, model, binding?.base);
34698
- await applyNumberingCatalog(zip, model, binding);
35650
+ await applyNumberingCatalog(zip, model, binding, pendingMedia);
34699
35651
  await applyCoreProperties(zip, model.properties, binding?.base.properties);
34700
35652
  if (binding) await applyStyleNumbering(zip, model, binding.base);
34701
35653
  if (binding) await applyStyleFormatting(zip, model, binding.base);
@@ -34709,6 +35661,8 @@ async function saveDocx(model, pendingMedia, options) {
34709
35661
  await applySettingsFlag(zip, "autoHyphenation", Boolean(model.autoHyphenation));
34710
35662
  if (model.trackChanges !== binding?.base.trackChanges)
34711
35663
  await applyTrackChangesSetting(zip, model.trackChanges === true);
35664
+ if (JSON.stringify(model.protection) !== JSON.stringify(binding?.base.protection))
35665
+ await applyDocumentProtection(zip, model.protection);
34712
35666
  for (const [key, flag2] of [
34713
35667
  ["trackFormatting", "doNotTrackFormatting"],
34714
35668
  ["trackMoves", "doNotTrackMoves"]
@@ -34917,6 +35871,71 @@ function parseSimpleHyperlinkField(instr) {
34917
35871
  return void 0;
34918
35872
  }
34919
35873
 
35874
+ // docx/permissions.ts
35875
+ var pending = /* @__PURE__ */ new WeakMap();
35876
+ function readParagraphPermissionMarkers(node, paragraph2) {
35877
+ if (!node.getElementsByTagNameNS("*", "permStart").length && !node.getElementsByTagNameNS("*", "permEnd").length)
35878
+ return;
35879
+ const found = collectInlineSlots(node);
35880
+ if (!found || found.slots.length !== paragraph2.runs.length) return;
35881
+ const positions = runPositions(paragraph2.runs);
35882
+ const events = [];
35883
+ for (const { element: element4, boundary } of found.markers) {
35884
+ const start = named2(element4, "permStart");
35885
+ if (!start && !named2(element4, "permEnd")) continue;
35886
+ const id = getW(element4, "id");
35887
+ if (id === void 0) continue;
35888
+ const group = getW(element4, "edGrp");
35889
+ const user = getW(element4, "ed");
35890
+ events.push({
35891
+ start,
35892
+ id,
35893
+ position: positions[boundary] ?? 0,
35894
+ ...group !== void 0 && { group },
35895
+ ...user !== void 0 && { user }
35896
+ });
35897
+ }
35898
+ if (events.length) pending.set(paragraph2, events);
35899
+ }
35900
+ function resolvePermissions(blocks) {
35901
+ const open = /* @__PURE__ */ new Map();
35902
+ forEachParagraph2(blocks, (paragraph2) => {
35903
+ const events = pending.get(paragraph2) ?? [];
35904
+ const end = runPositions(paragraph2.runs).at(-1) ?? 0;
35905
+ const ranges = [];
35906
+ const begun = new Map(
35907
+ [...open].map(([id, who]) => [id, { ...who, from: 0, previous: true }])
35908
+ );
35909
+ const add4 = (id, begin, to, next) => ranges.push({
35910
+ id,
35911
+ ...begin.group !== void 0 && { group: begin.group },
35912
+ ...begin.user !== void 0 && { user: begin.user },
35913
+ from: begin.from,
35914
+ to,
35915
+ ...begin.previous && { fromPrevious: true },
35916
+ ...next && { toNext: true }
35917
+ });
35918
+ for (const event of events) {
35919
+ if (event.start) {
35920
+ const who = {
35921
+ ...event.group !== void 0 && { group: event.group },
35922
+ ...event.user !== void 0 && { user: event.user }
35923
+ };
35924
+ begun.set(event.id, { ...who, from: event.position });
35925
+ open.set(event.id, who);
35926
+ continue;
35927
+ }
35928
+ const begin = begun.get(event.id);
35929
+ if (begin) add4(event.id, begin, event.position);
35930
+ begun.delete(event.id);
35931
+ open.delete(event.id);
35932
+ }
35933
+ for (const [id, begin] of begun) add4(id, begin, end, true);
35934
+ if (ranges.length) paragraph2.permissions = ranges;
35935
+ pending.delete(paragraph2);
35936
+ });
35937
+ }
35938
+
34920
35939
  // docx/field-runs.ts
34921
35940
  function createFieldTracker() {
34922
35941
  const stack = [];
@@ -35174,6 +36193,7 @@ function parseParagraph2(node, id, fields) {
35174
36193
  if (props) paragraph2.sourceParagraphPropertiesXml = buildXml(props);
35175
36194
  const bookmarks = paragraphBookmarkNames(node);
35176
36195
  if (bookmarks.length) paragraph2.bookmarks = bookmarks;
36196
+ readParagraphPermissionMarkers(node, paragraph2);
35177
36197
  const markRevision = paragraphMarkRevision(props);
35178
36198
  if (markRevision) paragraph2.markRevision = markRevision;
35179
36199
  const formatRevision = paragraphFormatRevision(props);
@@ -35212,6 +36232,7 @@ function parseContainer(container, idPrefix) {
35212
36232
  if (control) block.contentControl = control;
35213
36233
  blocks.push(block);
35214
36234
  }
36235
+ resolvePermissions(blocks);
35215
36236
  return blocks;
35216
36237
  }
35217
36238
 
@@ -35618,16 +36639,16 @@ async function readPlaceholderTexts(zip, relationships, model) {
35618
36639
 
35619
36640
  // docx/parse.ts
35620
36641
  var px = (twips3, fallback) => twips3 === void 0 ? fallback : Number(twips3) * 96 / 1440;
35621
- var RESTRICTED_TO = {
35622
- readOnly: "reading",
35623
- comments: "comments",
35624
- trackedChanges: "tracked changes"
35625
- };
35626
36642
  function protectionWarning(edit) {
35627
36643
  if (edit === "forms")
35628
- return "The document is protected for filling in forms: the editor lets only form fields, content controls and sections left unprotected change. The protection password is not checked.";
35629
- const allowed = RESTRICTED_TO[edit];
35630
- return allowed ? `The document limits editing to ${allowed}; the restriction is kept but not enforced while editing.` : void 0;
36644
+ return "The document is protected for filling in forms: the editor lets only form fields, content controls and sections left unprotected change. The protection password is checked only when you stop the protection.";
36645
+ if (edit === "readOnly")
36646
+ return "The document is protected against changes: the editor lets only its editable regions change. Stop protection (Review > Restrict Editing) to edit the rest.";
36647
+ if (edit === "comments")
36648
+ return "The document is protected for comments: the editor lets you add comments and change its editable regions. Stop protection (Review > Restrict Editing) to edit the rest.";
36649
+ if (edit === "trackedChanges")
36650
+ return "The document is protected for tracked changes: every change is recorded and cannot be accepted or rejected until the protection is stopped (Review > Restrict Editing).";
36651
+ return void 0;
35631
36652
  }
35632
36653
  async function readPackage(input) {
35633
36654
  const original = input instanceof Uint8Array ? new Uint8Array(input) : new Uint8Array(input.slice(0));
@@ -35708,12 +36729,16 @@ async function readPackage(input) {
35708
36729
  const numberingFile = zip.file("word/numbering.xml");
35709
36730
  if (numberingFile) {
35710
36731
  const numberingXml = await numberingFile.async("string");
36732
+ const numberingRels = zip.file("word/_rels/numbering.xml.rels");
36733
+ const numberingRelationships = parseRelationships(
36734
+ numberingRels ? await numberingRels.async("string") : void 0
36735
+ );
35711
36736
  model.numberingCatalog = withParseWarnings(
35712
36737
  schemaWarnings,
35713
- () => parseNumberingCatalog(numberingXml)
36738
+ () => parseNumberingCatalog(numberingXml, numberingRelationships)
35714
36739
  );
35715
36740
  model.warnings.push(
35716
- "Numbering is resolved for decimal, Roman numeral, letter, ordinal, cardinal/ordinal text and bullet formats, including multilevel lvlText and legal numbering. Picture bullets, style-linked numbering and other custom formats fall back to Decimal Number and are not rendered as Word would.",
36741
+ "Numbering is resolved for decimal, Roman numeral, letter, ordinal, cardinal/ordinal text and bullet formats, including multilevel lvlText and legal numbering. Style-linked numbering and other custom formats fall back to Decimal Number and are not rendered as Word would.",
35717
36742
  ...model.numberingCatalog.warnings
35718
36743
  );
35719
36744
  } else if (document.getElementsByTagNameNS(WORD_NS, "numPr").length > 0) {
@@ -35793,10 +36818,13 @@ async function readPackage(input) {
35793
36818
  for (const part of [
35794
36819
  run2.image?.partName,
35795
36820
  run2.image?.svgPartName,
35796
- ...Object.values(run2.image?.diagram?.drawing?.pictureParts ?? {})
36821
+ ...Object.values(run2.image?.diagram?.drawing?.pictureParts ?? {}),
36822
+ ...Object.values(run2.image?.diagram?.layoutSource?.pictureParts ?? {})
35797
36823
  ])
35798
36824
  if (part) imagePartNames.add(part);
35799
36825
  });
36826
+ for (const bullet of Object.values(model.numberingCatalog?.pictureBullets ?? {}))
36827
+ imagePartNames.add(bullet.partName);
35800
36828
  const media = /* @__PURE__ */ new Map();
35801
36829
  for (const partName of imagePartNames) {
35802
36830
  const part = zip.file(partName);