ooxml-core 1.12.2 → 1.14.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 (682) hide show
  1. package/dist/PptxHandler-5YP75BPO.cjs +12 -0
  2. package/dist/PptxHandler-GT5Q66TG.mjs +3 -0
  3. package/dist/{PptxHandler-FIN6XDTI.mjs → PptxHandler-KNBFECUE.mjs} +3 -3
  4. package/dist/PresentationBuilder-5DCCFHWJ.mjs +7 -0
  5. package/dist/PresentationBuilder-CVM6LJ7L.mjs +3 -0
  6. package/dist/PresentationBuilder-II7C4A3R.cjs +20 -0
  7. package/dist/automation/docx.d.ts +18 -0
  8. package/dist/automation/docx.d.ts.map +1 -1
  9. package/dist/automation/index.cjs +22549 -8585
  10. package/dist/automation/index.d.ts +1 -0
  11. package/dist/automation/index.d.ts.map +1 -1
  12. package/dist/automation/index.mjs +22546 -8586
  13. package/dist/automation/node.cjs +66 -6
  14. package/dist/automation/node.d.ts +10 -0
  15. package/dist/automation/node.d.ts.map +1 -1
  16. package/dist/automation/node.mjs +67 -7
  17. package/dist/automation/outline.d.ts +29 -0
  18. package/dist/automation/outline.d.ts.map +1 -0
  19. package/dist/automation/xlsx.d.ts +21 -0
  20. package/dist/automation/xlsx.d.ts.map +1 -1
  21. package/dist/chart/auto-title.d.ts +31 -0
  22. package/dist/chart/auto-title.d.ts.map +1 -0
  23. package/dist/chart/axis-format.d.ts +13 -0
  24. package/dist/chart/axis-format.d.ts.map +1 -0
  25. package/dist/chart/bubble-radius.d.ts +30 -0
  26. package/dist/chart/bubble-radius.d.ts.map +1 -0
  27. package/dist/chart/error-bar-amount.d.ts +22 -0
  28. package/dist/chart/error-bar-amount.d.ts.map +1 -0
  29. package/dist/chart/hierarchy.d.ts +69 -0
  30. package/dist/chart/hierarchy.d.ts.map +1 -0
  31. package/dist/chart/index.cjs +2377 -527
  32. package/dist/chart/index.d.ts +12 -0
  33. package/dist/chart/index.d.ts.map +1 -1
  34. package/dist/chart/index.mjs +2338 -528
  35. package/dist/chart/model-analysis.d.ts +66 -0
  36. package/dist/chart/model-analysis.d.ts.map +1 -0
  37. package/dist/chart/model-series.d.ts +5 -0
  38. package/dist/chart/model-series.d.ts.map +1 -1
  39. package/dist/chart/number-format-pattern.d.ts +35 -0
  40. package/dist/chart/number-format-pattern.d.ts.map +1 -0
  41. package/dist/chart/number-format.d.ts +21 -0
  42. package/dist/chart/number-format.d.ts.map +1 -0
  43. package/dist/chart/parse-analysis.d.ts +13 -0
  44. package/dist/chart/parse-analysis.d.ts.map +1 -0
  45. package/dist/chart/parse-series.d.ts +1 -1
  46. package/dist/chart/parse-series.d.ts.map +1 -1
  47. package/dist/chart/parse-util.d.ts +2 -0
  48. package/dist/chart/parse-util.d.ts.map +1 -1
  49. package/dist/chart/render/chart-svg-analysis.d.ts +7 -0
  50. package/dist/chart/render/chart-svg-analysis.d.ts.map +1 -0
  51. package/dist/chart/render/chart-svg-bars.d.ts +5 -0
  52. package/dist/chart/render/chart-svg-bars.d.ts.map +1 -1
  53. package/dist/chart/render/chart-svg-cartesian.d.ts +7 -2
  54. package/dist/chart/render/chart-svg-cartesian.d.ts.map +1 -1
  55. package/dist/chart/render/chart-svg-hierarchy.d.ts +5 -0
  56. package/dist/chart/render/chart-svg-hierarchy.d.ts.map +1 -0
  57. package/dist/chart/render/chart-svg-plots.d.ts +5 -0
  58. package/dist/chart/render/chart-svg-plots.d.ts.map +1 -0
  59. package/dist/chart/render/chart-svg-stock.d.ts +4 -0
  60. package/dist/chart/render/chart-svg-stock.d.ts.map +1 -0
  61. package/dist/chart/render/chart-svg-waterfall.d.ts +4 -0
  62. package/dist/chart/render/chart-svg-waterfall.d.ts.map +1 -0
  63. package/dist/chart/render/chart-svg-xy.d.ts +4 -0
  64. package/dist/chart/render/chart-svg-xy.d.ts.map +1 -0
  65. package/dist/chart/render/chart-svg.d.ts +1 -1
  66. package/dist/chart/render/chart-svg.d.ts.map +1 -1
  67. package/dist/chart/render/chart-value-axis.d.ts +6 -1
  68. package/dist/chart/render/chart-value-axis.d.ts.map +1 -1
  69. package/dist/chart/render/chart-view-analysis.d.ts +30 -0
  70. package/dist/chart/render/chart-view-analysis.d.ts.map +1 -0
  71. package/dist/chart/render/chart-view-ex.d.ts +24 -0
  72. package/dist/chart/render/chart-view-ex.d.ts.map +1 -0
  73. package/dist/chart/render/chart-view-families.d.ts +10 -0
  74. package/dist/chart/render/chart-view-families.d.ts.map +1 -0
  75. package/dist/chart/render/chart-view-series.d.ts +36 -0
  76. package/dist/chart/render/chart-view-series.d.ts.map +1 -0
  77. package/dist/chart/render/chart-view-stock.d.ts +23 -0
  78. package/dist/chart/render/chart-view-stock.d.ts.map +1 -0
  79. package/dist/chart/render/chart-view.d.ts +49 -18
  80. package/dist/chart/render/chart-view.d.ts.map +1 -1
  81. package/dist/chart/render/index.d.ts +2 -0
  82. package/dist/chart/render/index.d.ts.map +1 -1
  83. package/dist/chart/render/render-space.d.ts +6 -1
  84. package/dist/chart/render/render-space.d.ts.map +1 -1
  85. package/dist/chart/render/summary-analysis.d.ts +11 -0
  86. package/dist/chart/render/summary-analysis.d.ts.map +1 -0
  87. package/dist/chart/render/summary-from-chartex.d.ts +11 -0
  88. package/dist/chart/render/summary-from-chartex.d.ts.map +1 -0
  89. package/dist/chart/render/summary-from-space.d.ts.map +1 -1
  90. package/dist/chart/render/summary.d.ts +86 -3
  91. package/dist/chart/render/summary.d.ts.map +1 -1
  92. package/dist/chart/stock-candles.d.ts +72 -0
  93. package/dist/chart/stock-candles.d.ts.map +1 -0
  94. package/dist/chart/style-palette.d.ts +29 -0
  95. package/dist/chart/style-palette.d.ts.map +1 -0
  96. package/dist/chart/sunburst-arcs.d.ts +41 -0
  97. package/dist/chart/sunburst-arcs.d.ts.map +1 -0
  98. package/dist/chart/trendline-fit.d.ts +39 -0
  99. package/dist/chart/trendline-fit.d.ts.map +1 -0
  100. package/dist/chart/waterfall.d.ts +31 -0
  101. package/dist/chart/waterfall.d.ts.map +1 -0
  102. package/dist/chart/write-analysis.d.ts +12 -0
  103. package/dist/chart/write-analysis.d.ts.map +1 -0
  104. package/dist/chart/write-series.d.ts.map +1 -1
  105. package/dist/{chunk-G5PQKHCG.mjs → chunk-2D4IFQ5M.mjs} +1 -1
  106. package/dist/{chunk-UAY26XOI.mjs → chunk-2EBMHIGJ.mjs} +1303 -994
  107. package/dist/{chunk-TVE6UIJF.mjs → chunk-4WZLFUUA.mjs} +54 -13
  108. package/dist/{chunk-H2FRDUNV.mjs → chunk-54ASP65T.mjs} +868 -585
  109. package/dist/chunk-M4XLF4R7.mjs +387 -0
  110. package/dist/{chunk-O6NIA4NG.mjs → chunk-ORH32TO3.mjs} +5798 -5742
  111. package/dist/{chunk-B2JBBAEQ.mjs → chunk-TNNXOW2O.mjs} +1 -1
  112. package/dist/{chunk-IT3U6QD6.cjs → chunk-TQE7FFNT.cjs} +6754 -6695
  113. package/dist/{chunk-7QZGRB3T.cjs → chunk-X7MGZQ6C.cjs} +1321 -995
  114. package/dist/{chunk-6DELVMYB.mjs → chunk-XGXIS4PN.mjs} +12316 -12260
  115. package/dist/crypto/decrypt.d.ts +17 -3
  116. package/dist/crypto/decrypt.d.ts.map +1 -1
  117. package/dist/crypto/encryption-info.d.ts.map +1 -1
  118. package/dist/crypto/index.cjs +252 -78
  119. package/dist/crypto/index.d.ts +19 -4
  120. package/dist/crypto/index.d.ts.map +1 -1
  121. package/dist/crypto/index.mjs +252 -79
  122. package/dist/crypto/key-derivation.d.ts +2 -3
  123. package/dist/crypto/key-derivation.d.ts.map +1 -1
  124. package/dist/crypto/validate.d.ts +22 -0
  125. package/dist/crypto/validate.d.ts.map +1 -0
  126. package/dist/diagram/engine/layout-def-parse.d.ts.map +1 -1
  127. package/dist/diagram/engine/pres-tree.d.ts.map +1 -1
  128. package/dist/diagram/index.cjs +102 -52
  129. package/dist/diagram/index.mjs +102 -52
  130. package/dist/digest/index.cjs +23 -11
  131. package/dist/digest/index.d.ts +2 -1
  132. package/dist/digest/index.d.ts.map +1 -1
  133. package/dist/digest/index.mjs +21 -12
  134. package/dist/digest/password-hash.d.ts +19 -5
  135. package/dist/digest/password-hash.d.ts.map +1 -1
  136. package/dist/digest/timing-safe.d.ts +7 -0
  137. package/dist/digest/timing-safe.d.ts.map +1 -0
  138. package/dist/docx/block-parser.d.ts.map +1 -1
  139. package/dist/docx/chart-paint.d.ts.map +1 -1
  140. package/dist/docx/chart.d.ts +10 -2
  141. package/dist/docx/chart.d.ts.map +1 -1
  142. package/dist/docx/content-control-edit.d.ts +26 -0
  143. package/dist/docx/content-control-edit.d.ts.map +1 -0
  144. package/dist/docx/content-control-model.d.ts +51 -0
  145. package/dist/docx/content-control-model.d.ts.map +1 -0
  146. package/dist/docx/content-control.d.ts +9 -0
  147. package/dist/docx/content-control.d.ts.map +1 -0
  148. package/dist/docx/default-styles.d.ts.map +1 -1
  149. package/dist/docx/drawing.d.ts.map +1 -1
  150. package/dist/docx/embedded.cjs +9932 -935
  151. package/dist/docx/embedded.mjs +9932 -935
  152. package/dist/docx/equation.d.ts +7 -3
  153. package/dist/docx/equation.d.ts.map +1 -1
  154. package/dist/docx/index.cjs +14117 -1513
  155. package/dist/docx/index.d.ts +6 -0
  156. package/dist/docx/index.d.ts.map +1 -1
  157. package/dist/docx/index.mjs +14093 -1514
  158. package/dist/docx/inline-model.d.ts +3 -0
  159. package/dist/docx/inline-model.d.ts.map +1 -1
  160. package/dist/docx/layout/adapt-floats.d.ts +3 -3
  161. package/dist/docx/layout/adapt-floats.d.ts.map +1 -1
  162. package/dist/docx/layout/adapter.d.ts.map +1 -1
  163. package/dist/docx/layout/equation-object.d.ts +7 -0
  164. package/dist/docx/layout/equation-object.d.ts.map +1 -0
  165. package/dist/docx/layout/floats.d.ts +8 -0
  166. package/dist/docx/layout/floats.d.ts.map +1 -1
  167. package/dist/docx/layout/incremental-layout.d.ts +39 -0
  168. package/dist/docx/layout/incremental-layout.d.ts.map +1 -0
  169. package/dist/docx/layout/index.cjs +14177 -1707
  170. package/dist/docx/layout/index.d.ts +2 -2
  171. package/dist/docx/layout/index.d.ts.map +1 -1
  172. package/dist/docx/layout/index.mjs +14176 -1708
  173. package/dist/docx/layout/input.d.ts +4 -0
  174. package/dist/docx/layout/input.d.ts.map +1 -1
  175. package/dist/docx/layout/layout-session.d.ts +13 -2
  176. package/dist/docx/layout/layout-session.d.ts.map +1 -1
  177. package/dist/docx/layout/layout.d.ts +1 -1
  178. package/dist/docx/layout/layout.d.ts.map +1 -1
  179. package/dist/docx/layout/line-metrics.d.ts.map +1 -1
  180. package/dist/docx/layout/page-cursor.d.ts +1 -1
  181. package/dist/docx/layout/page-cursor.d.ts.map +1 -1
  182. package/dist/docx/layout/page-fields.d.ts +3 -1
  183. package/dist/docx/layout/page-fields.d.ts.map +1 -1
  184. package/dist/docx/layout/result.d.ts +14 -1
  185. package/dist/docx/layout/result.d.ts.map +1 -1
  186. package/dist/docx/layout/section-flow.d.ts +11 -1
  187. package/dist/docx/layout/section-flow.d.ts.map +1 -1
  188. package/dist/docx/ligatures.d.ts +2 -0
  189. package/dist/docx/ligatures.d.ts.map +1 -1
  190. package/dist/docx/load/index.cjs +12709 -3590
  191. package/dist/docx/load/index.mjs +12709 -3590
  192. package/dist/docx/model-paragraph.d.ts +3 -0
  193. package/dist/docx/model-paragraph.d.ts.map +1 -1
  194. package/dist/docx/model-run.d.ts +3 -0
  195. package/dist/docx/model-run.d.ts.map +1 -1
  196. package/dist/docx/model.d.ts +3 -0
  197. package/dist/docx/model.d.ts.map +1 -1
  198. package/dist/docx/numbering-parse.d.ts.map +1 -1
  199. package/dist/docx/numbering-text.d.ts.map +1 -1
  200. package/dist/docx/package-limits.d.ts +6 -0
  201. package/dist/docx/package-limits.d.ts.map +1 -0
  202. package/dist/docx/parse-content-control.d.ts +28 -0
  203. package/dist/docx/parse-content-control.d.ts.map +1 -0
  204. package/dist/docx/parse-table.d.ts.map +1 -1
  205. package/dist/docx/parse.d.ts.map +1 -1
  206. package/dist/docx/save.d.ts.map +1 -1
  207. package/dist/docx/shape-model.d.ts +31 -0
  208. package/dist/docx/shape-model.d.ts.map +1 -0
  209. package/dist/docx/shape-palette.d.ts +19 -0
  210. package/dist/docx/shape-palette.d.ts.map +1 -0
  211. package/dist/docx/shape-parse.d.ts +16 -0
  212. package/dist/docx/shape-parse.d.ts.map +1 -0
  213. package/dist/docx/shape-svg.d.ts +20 -0
  214. package/dist/docx/shape-svg.d.ts.map +1 -0
  215. package/dist/docx/table-model.d.ts +4 -0
  216. package/dist/docx/table-model.d.ts.map +1 -1
  217. package/dist/docx/ui/content-control-commands.d.ts +37 -0
  218. package/dist/docx/ui/content-control-commands.d.ts.map +1 -0
  219. package/dist/docx/ui/content-control-guard.d.ts +8 -0
  220. package/dist/docx/ui/content-control-guard.d.ts.map +1 -0
  221. package/dist/docx/ui/content-control-spans.d.ts +19 -0
  222. package/dist/docx/ui/content-control-spans.d.ts.map +1 -0
  223. package/dist/docx/ui/index.cjs +3132 -506
  224. package/dist/docx/ui/index.d.ts +3 -0
  225. package/dist/docx/ui/index.d.ts.map +1 -1
  226. package/dist/docx/ui/index.mjs +3117 -507
  227. package/dist/docx/ui/inline-content-schema.d.ts.map +1 -1
  228. package/dist/docx/ui/paragraph-attributes.d.ts.map +1 -1
  229. package/dist/docx/ui/ribbon-action-ids.d.ts +1 -1
  230. package/dist/docx/ui/ribbon-action-ids.d.ts.map +1 -1
  231. package/dist/docx/ui/run-adapter.d.ts.map +1 -1
  232. package/dist/docx/ui/run-compare.d.ts.map +1 -1
  233. package/dist/docx/ui/run-mark-properties.d.ts.map +1 -1
  234. package/dist/docx/ui/run-marks.d.ts.map +1 -1
  235. package/dist/docx/ui/schema-marks.d.ts +16 -1
  236. package/dist/docx/ui/schema-marks.d.ts.map +1 -1
  237. package/dist/docx/ui/table-structure-guard.d.ts.map +1 -1
  238. package/dist/docx/write-block-placement.d.ts +9 -0
  239. package/dist/docx/write-block-placement.d.ts.map +1 -0
  240. package/dist/docx/write-content-control.d.ts +12 -0
  241. package/dist/docx/write-content-control.d.ts.map +1 -0
  242. package/dist/docx/write-drawing.d.ts +2 -0
  243. package/dist/docx/write-drawing.d.ts.map +1 -1
  244. package/dist/docx/write-inline.d.ts.map +1 -1
  245. package/dist/docx/write-paragraph.d.ts.map +1 -1
  246. package/dist/docx/write-shape.d.ts +16 -0
  247. package/dist/docx/write-shape.d.ts.map +1 -0
  248. package/dist/docx/write-table.d.ts.map +1 -1
  249. package/dist/docx/write.d.ts.map +1 -1
  250. package/dist/drawingml/index.cjs +24 -0
  251. package/dist/drawingml/index.mjs +24 -0
  252. package/dist/geometry/index.cjs +63 -48
  253. package/dist/geometry/index.mjs +63 -48
  254. package/dist/geometry/preset-shape-definitions-table.d.ts.map +1 -1
  255. package/dist/i18n/index.cjs +266 -0
  256. package/dist/i18n/index.d.ts +1 -0
  257. package/dist/i18n/index.d.ts.map +1 -1
  258. package/dist/i18n/index.mjs +265 -1
  259. package/dist/i18n/option-strings.d.ts +17 -0
  260. package/dist/i18n/option-strings.d.ts.map +1 -0
  261. package/dist/index.cjs +4558 -1579
  262. package/dist/index.mjs +4558 -1579
  263. package/dist/math/equation-gallery.d.ts +10 -0
  264. package/dist/math/equation-gallery.d.ts.map +1 -0
  265. package/dist/math/index.cjs +777 -139
  266. package/dist/math/index.d.ts +3 -0
  267. package/dist/math/index.d.ts.map +1 -1
  268. package/dist/math/index.mjs +772 -140
  269. package/dist/math/latex-omml-siblings.d.ts.map +1 -1
  270. package/dist/math/latex-to-omml.d.ts.map +1 -1
  271. package/dist/math/omml-box-grouped.d.ts +9 -0
  272. package/dist/math/omml-box-grouped.d.ts.map +1 -0
  273. package/dist/math/omml-box-layout.d.ts +15 -0
  274. package/dist/math/omml-box-layout.d.ts.map +1 -0
  275. package/dist/math/omml-box-structures.d.ts +7 -0
  276. package/dist/math/omml-box-structures.d.ts.map +1 -0
  277. package/dist/math/omml-box.d.ts +85 -0
  278. package/dist/math/omml-box.d.ts.map +1 -0
  279. package/dist/math/omml-dom.d.ts.map +1 -1
  280. package/dist/math/omml-mathml-converters.d.ts.map +1 -1
  281. package/dist/math/omml-svg.d.ts +14 -0
  282. package/dist/math/omml-svg.d.ts.map +1 -0
  283. package/dist/math/omml-to-xml.d.ts +10 -0
  284. package/dist/math/omml-to-xml.d.ts.map +1 -0
  285. package/dist/opc/embedded-packages.d.ts.map +1 -1
  286. package/dist/opc/index.cjs +257 -22
  287. package/dist/opc/index.d.ts +1 -0
  288. package/dist/opc/index.d.ts.map +1 -1
  289. package/dist/opc/index.mjs +251 -23
  290. package/dist/opc/package.d.ts.map +1 -1
  291. package/dist/opc/signature/detection.d.ts +22 -6
  292. package/dist/opc/signature/detection.d.ts.map +1 -1
  293. package/dist/opc/signature/index.d.ts +1 -1
  294. package/dist/opc/signature/index.d.ts.map +1 -1
  295. package/dist/opc/signature/xml-utils.d.ts.map +1 -1
  296. package/dist/opc/zip-limits.d.ts +52 -0
  297. package/dist/opc/zip-limits.d.ts.map +1 -0
  298. package/dist/pptx/automation/index.cjs +1848 -1320
  299. package/dist/pptx/automation/index.d.ts +4 -4
  300. package/dist/pptx/automation/index.mjs +6 -6
  301. package/dist/pptx/chunks/{elements-DmbzOhFu.d.ts → elements-tK7xnWeS.d.ts} +20 -9
  302. package/dist/pptx/chunks/elements-tK7xnWeS.d.ts.map +1 -0
  303. package/dist/pptx/chunks/{index-Cija6Dih.d.ts → index-BSpNQuvz.d.ts} +30 -5
  304. package/dist/pptx/chunks/{index-Cija6Dih.d.ts.map → index-BSpNQuvz.d.ts.map} +1 -1
  305. package/dist/pptx/chunks/{index-BmvOxbsh.d.ts → index-DS9Y4Ne3.d.ts} +25 -9
  306. package/dist/pptx/chunks/index-DS9Y4Ne3.d.ts.map +1 -0
  307. package/dist/pptx/chunks/inspection-status-DjiWd_Aa.d.ts.map +1 -1
  308. package/dist/pptx/chunks/{text-operations-sXxhsKDd.d.ts → text-operations-BdD_UQ11.d.ts} +2 -2
  309. package/dist/pptx/chunks/{text-operations-sXxhsKDd.d.ts.map → text-operations-BdD_UQ11.d.ts.map} +1 -1
  310. package/dist/pptx/cli/index.cjs +1795 -1275
  311. package/dist/pptx/cli/index.d.ts +1 -1
  312. package/dist/pptx/cli/index.mjs +5 -5
  313. package/dist/pptx/converter/index.cjs +80 -54
  314. package/dist/pptx/converter/index.d.ts +1 -1
  315. package/dist/pptx/converter/index.mjs +3 -3
  316. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  317. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  318. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  319. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  320. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  321. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +1 -1
  322. package/dist/pptx/editor/render/text-style-scope.d.ts +1 -1
  323. package/dist/pptx/index.cjs +1117 -351
  324. package/dist/pptx/index.d.ts +5 -5
  325. package/dist/pptx/index.mjs +6 -6
  326. package/dist/pptx/signature-node/index.cjs +342 -65
  327. package/dist/pptx/signature-node/index.d.ts +12 -1
  328. package/dist/pptx/signature-node/index.d.ts.map +1 -1
  329. package/dist/pptx/signature-node/index.mjs +112 -52
  330. package/dist/teams/activity-feed.d.ts +19 -0
  331. package/dist/teams/activity-feed.d.ts.map +1 -0
  332. package/dist/teams/activity-state.d.ts +12 -0
  333. package/dist/teams/activity-state.d.ts.map +1 -0
  334. package/dist/teams/activity.d.ts +52 -0
  335. package/dist/teams/activity.d.ts.map +1 -0
  336. package/dist/teams/calendar.d.ts +57 -0
  337. package/dist/teams/calendar.d.ts.map +1 -0
  338. package/dist/teams/chat-actions.d.ts +20 -0
  339. package/dist/teams/chat-actions.d.ts.map +1 -0
  340. package/dist/teams/chat-rooms.d.ts +42 -0
  341. package/dist/teams/chat-rooms.d.ts.map +1 -0
  342. package/dist/teams/chat-view.d.ts +56 -0
  343. package/dist/teams/chat-view.d.ts.map +1 -0
  344. package/dist/teams/chat.d.ts +25 -3
  345. package/dist/teams/chat.d.ts.map +1 -1
  346. package/dist/teams/chats.d.ts +52 -0
  347. package/dist/teams/chats.d.ts.map +1 -0
  348. package/dist/teams/ics-timezone.d.ts +17 -0
  349. package/dist/teams/ics-timezone.d.ts.map +1 -0
  350. package/dist/teams/ics.d.ts +20 -0
  351. package/dist/teams/ics.d.ts.map +1 -0
  352. package/dist/teams/index.cjs +12462 -7011
  353. package/dist/teams/index.d.ts +25 -0
  354. package/dist/teams/index.d.ts.map +1 -1
  355. package/dist/teams/index.mjs +12349 -7012
  356. package/dist/teams/meeting-actions.d.ts +31 -0
  357. package/dist/teams/meeting-actions.d.ts.map +1 -0
  358. package/dist/teams/meeting-exceptions.d.ts +28 -0
  359. package/dist/teams/meeting-exceptions.d.ts.map +1 -0
  360. package/dist/teams/meeting-reminders.d.ts +13 -0
  361. package/dist/teams/meeting-reminders.d.ts.map +1 -0
  362. package/dist/teams/meetings.d.ts +71 -0
  363. package/dist/teams/meetings.d.ts.map +1 -0
  364. package/dist/teams/mention-text.d.ts +11 -0
  365. package/dist/teams/mention-text.d.ts.map +1 -0
  366. package/dist/teams/mentions.d.ts +68 -0
  367. package/dist/teams/mentions.d.ts.map +1 -0
  368. package/dist/teams/model.d.ts +7 -0
  369. package/dist/teams/model.d.ts.map +1 -1
  370. package/dist/teams/notifications.d.ts +21 -0
  371. package/dist/teams/notifications.d.ts.map +1 -0
  372. package/dist/teams/pins.d.ts +22 -0
  373. package/dist/teams/pins.d.ts.map +1 -0
  374. package/dist/teams/presence-controller.d.ts +39 -0
  375. package/dist/teams/presence-controller.d.ts.map +1 -0
  376. package/dist/teams/presence.d.ts +55 -0
  377. package/dist/teams/presence.d.ts.map +1 -0
  378. package/dist/teams/recurrence.d.ts +18 -0
  379. package/dist/teams/recurrence.d.ts.map +1 -0
  380. package/dist/teams/roster.d.ts +12 -0
  381. package/dist/teams/roster.d.ts.map +1 -0
  382. package/dist/teams/server-config.d.ts +23 -2
  383. package/dist/teams/server-config.d.ts.map +1 -1
  384. package/dist/teams/server-session.d.ts +19 -0
  385. package/dist/teams/server-session.d.ts.map +1 -0
  386. package/dist/teams/shared-chat.d.ts +83 -0
  387. package/dist/teams/shared-chat.d.ts.map +1 -0
  388. package/dist/teams/store.d.ts +79 -5
  389. package/dist/teams/store.d.ts.map +1 -1
  390. package/dist/teams/sync-transport.d.ts +12 -0
  391. package/dist/teams/sync-transport.d.ts.map +1 -0
  392. package/dist/teams/time-zone.d.ts +32 -0
  393. package/dist/teams/time-zone.d.ts.map +1 -0
  394. package/dist/teams/view.d.ts +8 -0
  395. package/dist/teams/view.d.ts.map +1 -1
  396. package/dist/teams/workspace.d.ts +23 -4
  397. package/dist/teams/workspace.d.ts.map +1 -1
  398. package/dist/visio/edit-connector-follow.d.ts +15 -0
  399. package/dist/visio/edit-connector-follow.d.ts.map +1 -0
  400. package/dist/visio/edit-connector-obstacles.d.ts +9 -3
  401. package/dist/visio/edit-connector-obstacles.d.ts.map +1 -1
  402. package/dist/visio/edit-connector-reroute.d.ts.map +1 -1
  403. package/dist/visio/edit-connector.d.ts.map +1 -1
  404. package/dist/visio/edit-master-add.d.ts +37 -0
  405. package/dist/visio/edit-master-add.d.ts.map +1 -0
  406. package/dist/visio/edit-master-drop.d.ts +6 -0
  407. package/dist/visio/edit-master-drop.d.ts.map +1 -1
  408. package/dist/visio/edit-recalculate-index.d.ts +5 -0
  409. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  410. package/dist/visio/edit-recalculate-values.d.ts.map +1 -1
  411. package/dist/visio/edit-stencil-connector-layout.d.ts +2 -0
  412. package/dist/visio/edit-stencil-connector-layout.d.ts.map +1 -1
  413. package/dist/visio/edit-stencil-connector.d.ts +1 -0
  414. package/dist/visio/edit-stencil-connector.d.ts.map +1 -1
  415. package/dist/visio/edit-stencil-import.d.ts +10 -0
  416. package/dist/visio/edit-stencil-import.d.ts.map +1 -0
  417. package/dist/visio/edit-stencil-line.d.ts +29 -0
  418. package/dist/visio/edit-stencil-line.d.ts.map +1 -0
  419. package/dist/visio/edit-stencil-master.d.ts +3 -8
  420. package/dist/visio/edit-stencil-master.d.ts.map +1 -1
  421. package/dist/visio/edit.d.ts.map +1 -1
  422. package/dist/visio/formula-evaluate.d.ts.map +1 -1
  423. package/dist/visio/formula-math-functions.d.ts +11 -0
  424. package/dist/visio/formula-math-functions.d.ts.map +1 -0
  425. package/dist/visio/formula-text-functions.d.ts +23 -0
  426. package/dist/visio/formula-text-functions.d.ts.map +1 -0
  427. package/dist/visio/formula.d.ts.map +1 -1
  428. package/dist/visio/index.cjs +2552 -1833
  429. package/dist/visio/index.d.ts +1 -0
  430. package/dist/visio/index.d.ts.map +1 -1
  431. package/dist/visio/index.mjs +2552 -1834
  432. package/dist/visio/parser.d.ts +6 -0
  433. package/dist/visio/parser.d.ts.map +1 -1
  434. package/dist/visio/stencil-file.d.ts +14 -0
  435. package/dist/visio/stencil-file.d.ts.map +1 -0
  436. package/dist/visio/ui/index.cjs +2398 -1679
  437. package/dist/visio/ui/index.mjs +2398 -1680
  438. package/dist/visio/ui/master-drop.d.ts +10 -0
  439. package/dist/visio/ui/master-drop.d.ts.map +1 -1
  440. package/dist/xlsx/edit/cell-values.d.ts.map +1 -1
  441. package/dist/xlsx/edit/clipboard-html-parse.d.ts +4 -0
  442. package/dist/xlsx/edit/clipboard-html-parse.d.ts.map +1 -1
  443. package/dist/xlsx/edit/data-table.d.ts +38 -0
  444. package/dist/xlsx/edit/data-table.d.ts.map +1 -0
  445. package/dist/xlsx/edit/drawings.d.ts.map +1 -1
  446. package/dist/xlsx/edit/goal-seek.d.ts +30 -0
  447. package/dist/xlsx/edit/goal-seek.d.ts.map +1 -0
  448. package/dist/xlsx/edit/goal-solver.d.ts +20 -0
  449. package/dist/xlsx/edit/goal-solver.d.ts.map +1 -0
  450. package/dist/xlsx/edit/history.d.ts +1 -1
  451. package/dist/xlsx/edit/history.d.ts.map +1 -1
  452. package/dist/xlsx/edit/index.d.ts +5 -0
  453. package/dist/xlsx/edit/index.d.ts.map +1 -1
  454. package/dist/xlsx/edit/input-text.d.ts.map +1 -1
  455. package/dist/xlsx/edit/pivots.d.ts +2 -1
  456. package/dist/xlsx/edit/pivots.d.ts.map +1 -1
  457. package/dist/xlsx/edit/scenarios.d.ts +41 -0
  458. package/dist/xlsx/edit/scenarios.d.ts.map +1 -0
  459. package/dist/xlsx/edit/session.d.ts.map +1 -1
  460. package/dist/xlsx/edit/slicers.d.ts +34 -0
  461. package/dist/xlsx/edit/slicers.d.ts.map +1 -0
  462. package/dist/xlsx/edit/table-edits.d.ts.map +1 -1
  463. package/dist/xlsx/edit/timelines.d.ts +26 -0
  464. package/dist/xlsx/edit/timelines.d.ts.map +1 -0
  465. package/dist/xlsx/edit/types.d.ts +39 -0
  466. package/dist/xlsx/edit/types.d.ts.map +1 -1
  467. package/dist/xlsx/formula/context.d.ts +13 -0
  468. package/dist/xlsx/formula/context.d.ts.map +1 -1
  469. package/dist/xlsx/formula/engine.d.ts.map +1 -1
  470. package/dist/xlsx/formula/evaluator.d.ts.map +1 -1
  471. package/dist/xlsx/formula/functions/amordegrc.d.ts +6 -0
  472. package/dist/xlsx/formula/functions/amordegrc.d.ts.map +1 -0
  473. package/dist/xlsx/formula/functions/bahttext.d.ts +4 -0
  474. package/dist/xlsx/formula/functions/bahttext.d.ts.map +1 -0
  475. package/dist/xlsx/formula/functions/bessel.d.ts +7 -0
  476. package/dist/xlsx/formula/functions/bessel.d.ts.map +1 -0
  477. package/dist/xlsx/formula/functions/bonds.d.ts +3 -0
  478. package/dist/xlsx/formula/functions/bonds.d.ts.map +1 -1
  479. package/dist/xlsx/formula/functions/engineering.d.ts.map +1 -1
  480. package/dist/xlsx/formula/functions/financial.d.ts.map +1 -1
  481. package/dist/xlsx/formula/functions/getpivotdata.d.ts +2 -0
  482. package/dist/xlsx/formula/functions/getpivotdata.d.ts.map +1 -0
  483. package/dist/xlsx/formula/functions/groupby.d.ts +3 -0
  484. package/dist/xlsx/formula/functions/groupby.d.ts.map +1 -0
  485. package/dist/xlsx/formula/functions/helpers.d.ts +3 -2
  486. package/dist/xlsx/formula/functions/helpers.d.ts.map +1 -1
  487. package/dist/xlsx/formula/functions/logical.d.ts.map +1 -1
  488. package/dist/xlsx/formula/functions/modern.d.ts +3 -0
  489. package/dist/xlsx/formula/functions/modern.d.ts.map +1 -0
  490. package/dist/xlsx/formula/functions/odd-securities.d.ts +3 -0
  491. package/dist/xlsx/formula/functions/odd-securities.d.ts.map +1 -0
  492. package/dist/xlsx/formula/functions/registry.d.ts.map +1 -1
  493. package/dist/xlsx/formula/functions/text-regex.d.ts +8 -0
  494. package/dist/xlsx/formula/functions/text-regex.d.ts.map +1 -1
  495. package/dist/xlsx/formula/functions/text.d.ts.map +1 -1
  496. package/dist/xlsx/formula/functions/wildcard.d.ts +8 -0
  497. package/dist/xlsx/formula/functions/wildcard.d.ts.map +1 -0
  498. package/dist/xlsx/formula/values.d.ts +11 -0
  499. package/dist/xlsx/formula/values.d.ts.map +1 -1
  500. package/dist/xlsx/index.cjs +11696 -4994
  501. package/dist/xlsx/index.d.ts +1 -0
  502. package/dist/xlsx/index.d.ts.map +1 -1
  503. package/dist/xlsx/index.mjs +11612 -4994
  504. package/dist/xlsx/layout/chart-view.d.ts.map +1 -1
  505. package/dist/xlsx/layout/header-footer-edit.d.ts +16 -0
  506. package/dist/xlsx/layout/header-footer-edit.d.ts.map +1 -0
  507. package/dist/xlsx/layout/index.d.ts +3 -0
  508. package/dist/xlsx/layout/index.d.ts.map +1 -1
  509. package/dist/xlsx/layout/page-break-view.d.ts +39 -0
  510. package/dist/xlsx/layout/page-break-view.d.ts.map +1 -0
  511. package/dist/xlsx/layout/page-view.d.ts +69 -0
  512. package/dist/xlsx/layout/page-view.d.ts.map +1 -0
  513. package/dist/xlsx/layout/ref-evaluator.d.ts.map +1 -1
  514. package/dist/xlsx/load/index.cjs +5718 -2191
  515. package/dist/xlsx/load/index.mjs +5717 -2190
  516. package/dist/xlsx/model-pivots.d.ts +88 -2
  517. package/dist/xlsx/model-pivots.d.ts.map +1 -1
  518. package/dist/xlsx/model-slicers.d.ts +146 -0
  519. package/dist/xlsx/model-slicers.d.ts.map +1 -0
  520. package/dist/xlsx/model-whatif.d.ts +51 -0
  521. package/dist/xlsx/model-whatif.d.ts.map +1 -0
  522. package/dist/xlsx/model.d.ts +26 -1
  523. package/dist/xlsx/model.d.ts.map +1 -1
  524. package/dist/xlsx/pivot/admission.d.ts.map +1 -1
  525. package/dist/xlsx/pivot/aggregate.d.ts +15 -6
  526. package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
  527. package/dist/xlsx/pivot/axes.d.ts +6 -0
  528. package/dist/xlsx/pivot/axes.d.ts.map +1 -0
  529. package/dist/xlsx/pivot/cache-xml.d.ts.map +1 -1
  530. package/dist/xlsx/pivot/columns.d.ts +48 -0
  531. package/dist/xlsx/pivot/columns.d.ts.map +1 -0
  532. package/dist/xlsx/pivot/data.d.ts +9 -3
  533. package/dist/xlsx/pivot/data.d.ts.map +1 -1
  534. package/dist/xlsx/pivot/date-axes.d.ts +12 -0
  535. package/dist/xlsx/pivot/date-axes.d.ts.map +1 -0
  536. package/dist/xlsx/pivot/date-group-read.d.ts +11 -0
  537. package/dist/xlsx/pivot/date-group-read.d.ts.map +1 -0
  538. package/dist/xlsx/pivot/date-groups.d.ts +60 -0
  539. package/dist/xlsx/pivot/date-groups.d.ts.map +1 -0
  540. package/dist/xlsx/pivot/date-read.d.ts +10 -0
  541. package/dist/xlsx/pivot/date-read.d.ts.map +1 -0
  542. package/dist/xlsx/pivot/dates.d.ts +17 -0
  543. package/dist/xlsx/pivot/dates.d.ts.map +1 -0
  544. package/dist/xlsx/pivot/group-read.d.ts +9 -0
  545. package/dist/xlsx/pivot/group-read.d.ts.map +1 -0
  546. package/dist/xlsx/pivot/groups.d.ts +31 -0
  547. package/dist/xlsx/pivot/groups.d.ts.map +1 -0
  548. package/dist/xlsx/pivot/hierarchy.d.ts +4 -1
  549. package/dist/xlsx/pivot/hierarchy.d.ts.map +1 -1
  550. package/dist/xlsx/pivot/index.d.ts +7 -0
  551. package/dist/xlsx/pivot/index.d.ts.map +1 -1
  552. package/dist/xlsx/pivot/item-filters-read.d.ts +7 -0
  553. package/dist/xlsx/pivot/item-filters-read.d.ts.map +1 -0
  554. package/dist/xlsx/pivot/item-filters.d.ts +23 -0
  555. package/dist/xlsx/pivot/item-filters.d.ts.map +1 -0
  556. package/dist/xlsx/pivot/measures.d.ts +6 -4
  557. package/dist/xlsx/pivot/measures.d.ts.map +1 -1
  558. package/dist/xlsx/pivot/nested.d.ts +8 -0
  559. package/dist/xlsx/pivot/nested.d.ts.map +1 -0
  560. package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -1
  561. package/dist/xlsx/pivot/page-filter.d.ts.map +1 -1
  562. package/dist/xlsx/pivot/read.d.ts +2 -1
  563. package/dist/xlsx/pivot/read.d.ts.map +1 -1
  564. package/dist/xlsx/pivot/subtotal-read.d.ts +9 -0
  565. package/dist/xlsx/pivot/subtotal-read.d.ts.map +1 -0
  566. package/dist/xlsx/pivot/subtotals.d.ts +23 -0
  567. package/dist/xlsx/pivot/subtotals.d.ts.map +1 -0
  568. package/dist/xlsx/pivot/table-xml.d.ts +1 -1
  569. package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
  570. package/dist/xlsx/pivot/values-axis.d.ts +2 -2
  571. package/dist/xlsx/pivot/values-axis.d.ts.map +1 -1
  572. package/dist/xlsx/read/chart-ex.d.ts +9 -0
  573. package/dist/xlsx/read/chart-ex.d.ts.map +1 -0
  574. package/dist/xlsx/read/chart.d.ts.map +1 -1
  575. package/dist/xlsx/read/drawing.d.ts.map +1 -1
  576. package/dist/xlsx/read/load.d.ts.map +1 -1
  577. package/dist/xlsx/read/package.d.ts +2 -1
  578. package/dist/xlsx/read/package.d.ts.map +1 -1
  579. package/dist/xlsx/read/scenarios.d.ts +4 -0
  580. package/dist/xlsx/read/scenarios.d.ts.map +1 -0
  581. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  582. package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
  583. package/dist/xlsx/read/tables.d.ts +3 -0
  584. package/dist/xlsx/read/tables.d.ts.map +1 -1
  585. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  586. package/dist/xlsx/slicer/book.d.ts +16 -0
  587. package/dist/xlsx/slicer/book.d.ts.map +1 -0
  588. package/dist/xlsx/slicer/frame.d.ts +14 -0
  589. package/dist/xlsx/slicer/frame.d.ts.map +1 -0
  590. package/dist/xlsx/slicer/index.d.ts +10 -0
  591. package/dist/xlsx/slicer/index.d.ts.map +1 -0
  592. package/dist/xlsx/slicer/items.d.ts +30 -0
  593. package/dist/xlsx/slicer/items.d.ts.map +1 -0
  594. package/dist/xlsx/slicer/layout.d.ts +67 -0
  595. package/dist/xlsx/slicer/layout.d.ts.map +1 -0
  596. package/dist/xlsx/slicer/read-slicers.d.ts +11 -0
  597. package/dist/xlsx/slicer/read-slicers.d.ts.map +1 -0
  598. package/dist/xlsx/slicer/read-timelines.d.ts +5 -0
  599. package/dist/xlsx/slicer/read-timelines.d.ts.map +1 -0
  600. package/dist/xlsx/slicer/read.d.ts +26 -0
  601. package/dist/xlsx/slicer/read.d.ts.map +1 -0
  602. package/dist/xlsx/slicer/select.d.ts +10 -0
  603. package/dist/xlsx/slicer/select.d.ts.map +1 -0
  604. package/dist/xlsx/slicer/styles.d.ts +36 -0
  605. package/dist/xlsx/slicer/styles.d.ts.map +1 -0
  606. package/dist/xlsx/slicer/table-filter.d.ts +28 -0
  607. package/dist/xlsx/slicer/table-filter.d.ts.map +1 -0
  608. package/dist/xlsx/slicer/timeline-periods.d.ts +35 -0
  609. package/dist/xlsx/slicer/timeline-periods.d.ts.map +1 -0
  610. package/dist/xlsx/slicer/timeline-view.d.ts +60 -0
  611. package/dist/xlsx/slicer/timeline-view.d.ts.map +1 -0
  612. package/dist/xlsx/slicer/write-plan.d.ts +31 -0
  613. package/dist/xlsx/slicer/write-plan.d.ts.map +1 -0
  614. package/dist/xlsx/slicer/write-timeline.d.ts +7 -0
  615. package/dist/xlsx/slicer/write-timeline.d.ts.map +1 -0
  616. package/dist/xlsx/slicer/write-xml.d.ts +17 -0
  617. package/dist/xlsx/slicer/write-xml.d.ts.map +1 -0
  618. package/dist/xlsx/ui/commands/i18n/index.d.ts.map +1 -1
  619. package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
  620. package/dist/xlsx/ui/commands/i18n/print-layout.d.ts.map +1 -1
  621. package/dist/xlsx/ui/commands/i18n/slicers.d.ts +3 -0
  622. package/dist/xlsx/ui/commands/i18n/slicers.d.ts.map +1 -0
  623. package/dist/xlsx/ui/commands/i18n/what-if.d.ts +3 -0
  624. package/dist/xlsx/ui/commands/i18n/what-if.d.ts.map +1 -0
  625. package/dist/xlsx/ui/commands/icons.d.ts.map +1 -1
  626. package/dist/xlsx/ui/commands/slicers.d.ts +37 -0
  627. package/dist/xlsx/ui/commands/slicers.d.ts.map +1 -0
  628. package/dist/xlsx/ui/commands/what-if.d.ts +4 -0
  629. package/dist/xlsx/ui/commands/what-if.d.ts.map +1 -0
  630. package/dist/xlsx/ui/commands.d.ts +2 -0
  631. package/dist/xlsx/ui/commands.d.ts.map +1 -1
  632. package/dist/xlsx/ui/index.cjs +6999 -3052
  633. package/dist/xlsx/ui/index.d.ts +2 -0
  634. package/dist/xlsx/ui/index.d.ts.map +1 -1
  635. package/dist/xlsx/ui/index.mjs +6994 -3053
  636. package/dist/xlsx/ui/locales/de/index.d.ts.map +1 -1
  637. package/dist/xlsx/ui/locales/de/options.d.ts +2 -0
  638. package/dist/xlsx/ui/locales/de/options.d.ts.map +1 -0
  639. package/dist/xlsx/ui/locales/de/shell.d.ts.map +1 -1
  640. package/dist/xlsx/ui/locales/en/index.d.ts.map +1 -1
  641. package/dist/xlsx/ui/locales/en/options.d.ts +2 -0
  642. package/dist/xlsx/ui/locales/en/options.d.ts.map +1 -0
  643. package/dist/xlsx/ui/locales/en/shell.d.ts.map +1 -1
  644. package/dist/xlsx/ui/locales/es/index.d.ts.map +1 -1
  645. package/dist/xlsx/ui/locales/es/options.d.ts +2 -0
  646. package/dist/xlsx/ui/locales/es/options.d.ts.map +1 -0
  647. package/dist/xlsx/ui/locales/es/shell.d.ts.map +1 -1
  648. package/dist/xlsx/ui/locales/fr/index.d.ts.map +1 -1
  649. package/dist/xlsx/ui/locales/fr/options.d.ts +2 -0
  650. package/dist/xlsx/ui/locales/fr/options.d.ts.map +1 -0
  651. package/dist/xlsx/ui/locales/fr/shell.d.ts.map +1 -1
  652. package/dist/xlsx/ui/locales/zh-CN/index.d.ts.map +1 -1
  653. package/dist/xlsx/ui/locales/zh-CN/options.d.ts +2 -0
  654. package/dist/xlsx/ui/locales/zh-CN/options.d.ts.map +1 -0
  655. package/dist/xlsx/ui/locales/zh-CN/shell.d.ts.map +1 -1
  656. package/dist/xlsx/ui/ribbon/tabs/review-view.d.ts.map +1 -1
  657. package/dist/xlsx/write/carried-refs.d.ts.map +1 -1
  658. package/dist/xlsx/write/drawing.d.ts.map +1 -1
  659. package/dist/xlsx/write/package-writer.d.ts +2 -0
  660. package/dist/xlsx/write/package-writer.d.ts.map +1 -1
  661. package/dist/xlsx/write/save.d.ts.map +1 -1
  662. package/dist/xlsx/write/scenarios.d.ts +4 -0
  663. package/dist/xlsx/write/scenarios.d.ts.map +1 -0
  664. package/dist/xlsx/write/sheet-data.d.ts.map +1 -1
  665. package/dist/xlsx/write/sheet-parts.d.ts +1 -0
  666. package/dist/xlsx/write/sheet-parts.d.ts.map +1 -1
  667. package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
  668. package/dist/xlsx/write/table-patch.d.ts.map +1 -1
  669. package/dist/xlsx/write/tables.d.ts.map +1 -1
  670. package/dist/xlsx/write/worksheet.d.ts.map +1 -1
  671. package/dist/xml/index.cjs +28 -0
  672. package/dist/xml/index.mjs +27 -1
  673. package/dist/xml/namespaces.d.ts +2 -0
  674. package/dist/xml/namespaces.d.ts.map +1 -1
  675. package/dist/xml/xml.d.ts +15 -0
  676. package/dist/xml/xml.d.ts.map +1 -1
  677. package/package.json +1 -1
  678. package/dist/PptxHandler-RWTOUCLC.mjs +0 -3
  679. package/dist/PptxHandler-UU4ZCT6H.cjs +0 -12
  680. package/dist/chunk-KBIJI6P5.mjs +0 -166
  681. package/dist/pptx/chunks/elements-DmbzOhFu.d.ts.map +0 -1
  682. package/dist/pptx/chunks/index-BmvOxbsh.d.ts.map +0 -1
@@ -201,13 +201,13 @@ function updatedInlineRunAttributes(node, format) {
201
201
  if (Object.hasOwn(desired, key)) metadata[key] = desired[key];
202
202
  else delete metadata[key];
203
203
  }
204
- const attrs = {
204
+ const attrs2 = {
205
205
  ...node.attrs,
206
206
  format: Object.keys(metadata).length ? JSON.stringify(metadata) : null
207
207
  };
208
208
  for (const key of DIRECT_RUN_PROPERTY_KEYS)
209
- attrs[attributeName(key)] = JSON.stringify(base[key]) === JSON.stringify(desired[key]) ? null : JSON.stringify(desired[key] ?? null);
210
- return attrs;
209
+ attrs2[attributeName(key)] = JSON.stringify(base[key]) === JSON.stringify(desired[key]) ? null : JSON.stringify(desired[key] ?? null);
210
+ return attrs2;
211
211
  }
212
212
  function wordInlinePropertyCodec(schema) {
213
213
  return Object.values(schema.nodes).some((type) => type.spec.attrs?.[attributeName("bold")]) ? schema.marks.inlineCommentAnchors ? "word-yjs-v3" : "word-yjs-v2" : "word-yjs-v1";
@@ -224,7 +224,7 @@ var hardBreakNodeSpec = {
224
224
  parseDOM: [
225
225
  {
226
226
  tag: "br",
227
- getAttrs: (el3) => ({ format: el3.dataset.runProperties ?? null })
227
+ getAttrs: (el4) => ({ format: el4.dataset.runProperties ?? null })
228
228
  }
229
229
  ],
230
230
  toDOM: (node) => ["br", inlineRunPropertiesDomAttrs(node)]
@@ -239,9 +239,9 @@ var pageBreakNodeSpec = {
239
239
  parseDOM: [
240
240
  {
241
241
  tag: "span[data-docx-break]",
242
- getAttrs: (el3) => ({
243
- kind: el3.dataset.docxBreak === "column" ? "column" : "page",
244
- format: el3.dataset.runProperties ?? null
242
+ getAttrs: (el4) => ({
243
+ kind: el4.dataset.docxBreak === "column" ? "column" : "page",
244
+ format: el4.dataset.runProperties ?? null
245
245
  })
246
246
  }
247
247
  ],
@@ -277,11 +277,11 @@ var noteReferenceNodeSpec = {
277
277
  {
278
278
  tag: "sup[data-docx-note-kind]",
279
279
  priority: 60,
280
- getAttrs: (el3) => ({
281
- kind: el3.dataset.docxNoteKind === "endnote" ? "endnote" : "footnote",
282
- format: el3.dataset.runProperties ?? null,
283
- id: el3.dataset.docxNoteId || "",
284
- number: Number(el3.textContent) || 1
280
+ getAttrs: (el4) => ({
281
+ kind: el4.dataset.docxNoteKind === "endnote" ? "endnote" : "footnote",
282
+ format: el4.dataset.runProperties ?? null,
283
+ id: el4.dataset.docxNoteId || "",
284
+ number: Number(el4.textContent) || 1
285
285
  })
286
286
  }
287
287
  ],
@@ -312,10 +312,10 @@ var fieldMarkerNodeSpec = {
312
312
  parseDOM: [
313
313
  {
314
314
  tag: "span[data-field-marker]",
315
- getAttrs: (el3) => ({
316
- kind: el3.dataset.fieldMarker || "begin",
317
- format: el3.dataset.runProperties ?? null,
318
- code: el3.dataset.fieldCode ?? null
315
+ getAttrs: (el4) => ({
316
+ kind: el4.dataset.fieldMarker || "begin",
317
+ format: el4.dataset.runProperties ?? null,
318
+ code: el4.dataset.fieldCode ?? null
319
319
  })
320
320
  }
321
321
  ],
@@ -650,14 +650,14 @@ function repairCollaborativeDocumentIds(state, clientId, idGenerator = createCol
650
650
  seen.add(id);
651
651
  return;
652
652
  }
653
- let generated = "";
653
+ let generated2 = "";
654
654
  const kind = node.type.name === "table" ? "table" : "paragraph";
655
655
  do
656
- generated = idGenerator(kind);
657
- while (reserved.has(generated));
658
- reserved.add(generated);
659
- seen.add(generated);
660
- transaction = transaction.setNodeMarkup(pos, void 0, { ...node.attrs, id: generated });
656
+ generated2 = idGenerator(kind);
657
+ while (reserved.has(generated2));
658
+ reserved.add(generated2);
659
+ seen.add(generated2);
660
+ transaction = transaction.setNodeMarkup(pos, void 0, { ...node.attrs, id: generated2 });
661
661
  });
662
662
  return transaction.docChanged ? transaction : null;
663
663
  }
@@ -776,10 +776,34 @@ var NS = {
776
776
  w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
777
777
  /** DrawingML main. */
778
778
  a: "http://schemas.openxmlformats.org/drawingml/2006/main"};
779
+ var DEFAULT_XML_LIMITS = {
780
+ maxDepth: 512,
781
+ maxNodes: 5e6
782
+ };
783
+ var MARKUP_RE = /<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<\?[\s\S]*?\?>|<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/g;
784
+ function checkXmlLimits(xml, label, limits = {}) {
785
+ const maxDepth = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
786
+ const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
787
+ let depth = 0;
788
+ let nodes = 0;
789
+ for (const match of xml.matchAll(MARKUP_RE)) {
790
+ const [, closing, name, selfClosing] = match;
791
+ if (name === void 0) continue;
792
+ if (closing) {
793
+ depth--;
794
+ continue;
795
+ }
796
+ nodes++;
797
+ if (nodes > maxNodes) throw new Error(`${label} XML exceeds the limit of ${maxNodes} elements`);
798
+ if (!selfClosing && ++depth > maxDepth)
799
+ throw new Error(`${label} XML exceeds the nesting depth limit of ${maxDepth}`);
800
+ }
801
+ }
779
802
  function parseXml(xml, options = {}) {
780
803
  const label = options.label ?? "OOXML";
781
804
  if (/<!DOCTYPE|<!ENTITY/i.test(xml))
782
805
  throw new Error(`${label} XML with DTD or entity declarations is not supported`);
806
+ checkXmlLimits(xml, label, options.limits);
783
807
  let parseError = "";
784
808
  let parsed;
785
809
  try {
@@ -1034,16 +1058,20 @@ function extensionPrefix(doc, ns, preferred) {
1034
1058
  root.setAttributeNS(XMLNS, `xmlns:${prefix}`, ns);
1035
1059
  return prefix;
1036
1060
  }
1037
- function writeLigatures(doc, props, value) {
1038
- for (const element2 of ligatureElements(props)) props.removeChild(element2);
1039
- if (value === void 0) return;
1040
- const prefix = extensionPrefix(doc, WORD_2010_NS, "w14");
1061
+ function declareIgnorableExtension(doc, ns, preferred) {
1062
+ const prefix = extensionPrefix(doc, ns, preferred);
1041
1063
  const mc = extensionPrefix(doc, MC, "mc");
1042
1064
  const ignored = new Set(
1043
1065
  (doc.documentElement.getAttributeNS(MC, "Ignorable") ?? "").split(/\s+/).filter(Boolean)
1044
1066
  );
1045
1067
  ignored.add(prefix);
1046
1068
  doc.documentElement.setAttributeNS(MC, `${mc}:Ignorable`, [...ignored].join(" "));
1069
+ return prefix;
1070
+ }
1071
+ function writeLigatures(doc, props, value) {
1072
+ for (const element2 of ligatureElements(props)) props.removeChild(element2);
1073
+ if (value === void 0) return;
1074
+ const prefix = declareIgnorableExtension(doc, WORD_2010_NS, "w14");
1047
1075
  const element = doc.createElementNS(WORD_2010_NS, `${prefix}:ligatures`);
1048
1076
  element.setAttributeNS(WORD_2010_NS, `${prefix}:val`, value);
1049
1077
  props.appendChild(element);
@@ -1152,8 +1180,8 @@ function parseRunProperties(props) {
1152
1180
  if (scale !== void 0) result.textScalePercent = scale;
1153
1181
  const kerning = parseHalfPoints(getW(first2(props, "kern"), "val"));
1154
1182
  if (kerning !== void 0) result.kerningHalfPoints = kerning;
1155
- const position = parseSignedHalfPoints(getW(first2(props, "position"), "val"));
1156
- if (position !== void 0) result.positionHalfPoints = position;
1183
+ const position2 = parseSignedHalfPoints(getW(first2(props, "position"), "val"));
1184
+ if (position2 !== void 0) result.positionHalfPoints = position2;
1157
1185
  const shd = first2(props, "shd");
1158
1186
  const fill = parseRgbColor(getW(shd, "fill"));
1159
1187
  if (fill) result.shadingFill = fill;
@@ -1528,7 +1556,7 @@ var W = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
1528
1556
  var heading = (id, name, level, before, size, color) => `<w:style w:type="paragraph" w:styleId="${id}"><w:name w:val="${name}"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="9"/><w:qFormat/><w:pPr><w:keepNext/><w:keepLines/><w:spacing w:before="${before}" w:after="0"/><w:outlineLvl w:val="${level}"/></w:pPr><w:rPr><w:rFonts w:ascii="Calibri Light" w:hAnsi="Calibri Light" w:eastAsia="Calibri Light" w:cs="Times New Roman"/><w:color w:val="${color}"/><w:sz w:val="${size}"/><w:szCs w:val="${size}"/></w:rPr></w:style>`;
1529
1557
  var toc = (level) => `<w:style w:type="paragraph" w:styleId="TOC${level}"><w:name w:val="toc ${level}"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="39"/><w:unhideWhenUsed/><w:pPr><w:spacing w:after="100"/>${level > 1 ? `<w:ind w:left="${(level - 1) * 220}"/>` : ""}</w:pPr></w:style>`;
1530
1558
  var noteStyles = (id, name) => `<w:style w:type="paragraph" w:styleId="${id}Text"><w:name w:val="${name} text"/><w:basedOn w:val="Normal"/><w:link w:val="${id}TextChar"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:rPr><w:sz w:val="20"/><w:szCs w:val="20"/></w:rPr></w:style><w:style w:type="character" w:styleId="${id}TextChar"><w:name w:val="${name} Text Char"/><w:basedOn w:val="DefaultParagraphFont"/><w:link w:val="${id}Text"/><w:uiPriority w:val="99"/><w:semiHidden/><w:rPr><w:sz w:val="20"/><w:szCs w:val="20"/></w:rPr></w:style><w:style w:type="character" w:styleId="${id}Reference"><w:name w:val="${name} reference"/><w:basedOn w:val="DefaultParagraphFont"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/><w:rPr><w:vertAlign w:val="superscript"/></w:rPr></w:style>`;
1531
- var DEFAULT_STYLES_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="${W}"><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Calibri" w:eastAsia="Calibri" w:hAnsi="Calibri" w:cs="Times New Roman"/><w:sz w:val="22"/><w:szCs w:val="22"/><w:lang w:val="en-US" w:eastAsia="en-US" w:bidi="ar-SA"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after="160" w:line="259" w:lineRule="auto"/></w:pPr></w:pPrDefault></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style><w:style w:type="character" w:default="1" w:styleId="DefaultParagraphFont"><w:name w:val="Default Paragraph Font"/><w:uiPriority w:val="1"/><w:semiHidden/><w:unhideWhenUsed/></w:style><w:style w:type="table" w:default="1" w:styleId="TableNormal"><w:name w:val="Normal Table"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/><w:tblPr><w:tblInd w:w="0" w:type="dxa"/><w:tblCellMar><w:top w:w="0" w:type="dxa"/><w:left w:w="108" w:type="dxa"/><w:bottom w:w="0" w:type="dxa"/><w:right w:w="108" w:type="dxa"/></w:tblCellMar></w:tblPr></w:style><w:style w:type="numbering" w:default="1" w:styleId="NoList"><w:name w:val="No List"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/></w:style><w:style w:type="paragraph" w:styleId="Title"><w:name w:val="Title"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="10"/><w:qFormat/><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/><w:contextualSpacing/></w:pPr><w:rPr><w:rFonts w:ascii="Calibri Light" w:hAnsi="Calibri Light" w:eastAsia="Calibri Light" w:cs="Times New Roman"/><w:spacing w:val="-10"/><w:kern w:val="28"/><w:sz w:val="56"/><w:szCs w:val="56"/></w:rPr></w:style>` + heading("Heading1", "heading 1", 0, 240, 32, "2F5496") + heading("Heading2", "heading 2", 1, 40, 26, "2F5496") + heading("Heading3", "heading 3", 2, 40, 24, "1F3763") + toc(1) + toc(2) + toc(3) + noteStyles("Footnote", "footnote") + noteStyles("Endnote", "endnote") + '<w:style w:type="character" w:styleId="Hyperlink"><w:name w:val="Hyperlink"/><w:basedOn w:val="DefaultParagraphFont"/><w:uiPriority w:val="99"/><w:unhideWhenUsed/><w:rPr><w:color w:val="0563C1"/><w:u w:val="single"/></w:rPr></w:style></w:styles>';
1559
+ var DEFAULT_STYLES_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="${W}"><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Calibri" w:eastAsia="Calibri" w:hAnsi="Calibri" w:cs="Times New Roman"/><w:sz w:val="22"/><w:szCs w:val="22"/><w:lang w:val="en-US" w:eastAsia="en-US" w:bidi="ar-SA"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after="160" w:line="259" w:lineRule="auto"/></w:pPr></w:pPrDefault></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style><w:style w:type="character" w:default="1" w:styleId="DefaultParagraphFont"><w:name w:val="Default Paragraph Font"/><w:uiPriority w:val="1"/><w:semiHidden/><w:unhideWhenUsed/></w:style><w:style w:type="table" w:default="1" w:styleId="TableNormal"><w:name w:val="Normal Table"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/><w:tblPr><w:tblInd w:w="0" w:type="dxa"/><w:tblCellMar><w:top w:w="0" w:type="dxa"/><w:left w:w="108" w:type="dxa"/><w:bottom w:w="0" w:type="dxa"/><w:right w:w="108" w:type="dxa"/></w:tblCellMar></w:tblPr></w:style><w:style w:type="numbering" w:default="1" w:styleId="NoList"><w:name w:val="No List"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/></w:style><w:style w:type="paragraph" w:styleId="Title"><w:name w:val="Title"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="10"/><w:qFormat/><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/><w:contextualSpacing/></w:pPr><w:rPr><w:rFonts w:ascii="Calibri Light" w:hAnsi="Calibri Light" w:eastAsia="Calibri Light" w:cs="Times New Roman"/><w:spacing w:val="-10"/><w:kern w:val="28"/><w:sz w:val="56"/><w:szCs w:val="56"/></w:rPr></w:style>` + heading("Heading1", "heading 1", 0, 240, 32, "2F5496") + heading("Heading2", "heading 2", 1, 40, 26, "2F5496") + heading("Heading3", "heading 3", 2, 40, 24, "1F3763") + toc(1) + toc(2) + toc(3) + noteStyles("Footnote", "footnote") + noteStyles("Endnote", "endnote") + '<w:style w:type="character" w:styleId="Hyperlink"><w:name w:val="Hyperlink"/><w:basedOn w:val="DefaultParagraphFont"/><w:uiPriority w:val="99"/><w:unhideWhenUsed/><w:rPr><w:color w:val="0563C1"/><w:u w:val="single"/></w:rPr></w:style><w:style w:type="character" w:styleId="PlaceholderText"><w:name w:val="Placeholder Text"/><w:basedOn w:val="DefaultParagraphFont"/><w:uiPriority w:val="99"/><w:semiHidden/><w:rPr><w:color w:val="808080"/></w:rPr></w:style></w:styles>';
1532
1560
  var cached;
1533
1561
  function defaultStyleCatalogs() {
1534
1562
  cached ??= {
@@ -2318,6 +2346,279 @@ function escapeXmlAttr(value) {
2318
2346
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
2319
2347
  }
2320
2348
 
2349
+ // docx/content-control.ts
2350
+ var WORD_2012_NS = "http://schemas.microsoft.com/office/word/2012/wordml";
2351
+ var sdtContent = (sdt) => first2(sdt, "sdtContent");
2352
+ var isSdt = (element) => named2(element, "sdt");
2353
+ var TYPE_ELEMENTS = {
2354
+ text: "text",
2355
+ dropDownList: "dropDownList",
2356
+ comboBox: "comboBox",
2357
+ date: "date",
2358
+ picture: "picture",
2359
+ group: "group",
2360
+ equation: "equation",
2361
+ citation: "citation",
2362
+ bibliography: "bibliography",
2363
+ docPartObj: "docPartObj",
2364
+ docPartList: "docPartList"
2365
+ };
2366
+ function attrW14(element, local) {
2367
+ return element?.getAttributeNS(WORD_2010_NS, local) ?? void 0;
2368
+ }
2369
+ function glyph(element) {
2370
+ const code = attrW14(element, "val");
2371
+ if (!code) return void 0;
2372
+ const font = attrW14(element, "font");
2373
+ return { code, ...font ? { font } : {} };
2374
+ }
2375
+ function parseKind(sdtPr) {
2376
+ for (const child of Array.from(sdtPr.childNodes).filter(isElement)) {
2377
+ if (child.namespaceURI === WORD_NS && TYPE_ELEMENTS[child.localName])
2378
+ return TYPE_ELEMENTS[child.localName];
2379
+ if (child.namespaceURI === WORD_2010_NS && child.localName === "checkbox") return "checkbox";
2380
+ if (child.namespaceURI === WORD_2012_NS && child.localName === "repeatingSection")
2381
+ return "repeatingSection";
2382
+ }
2383
+ return "richText";
2384
+ }
2385
+ var generated = 0;
2386
+ function parseContentControl(sdt, level) {
2387
+ const sdtPr = first2(sdt, "sdtPr");
2388
+ if (!sdtPr) return { id: `sdt-gen-${++generated}`, level, kind: "richText" };
2389
+ const kind = parseKind(sdtPr);
2390
+ const control = {
2391
+ id: getW(first2(sdtPr, "id"), "val") ?? `sdt-gen-${++generated}`,
2392
+ level,
2393
+ kind
2394
+ };
2395
+ const alias = getW(first2(sdtPr, "alias"), "val");
2396
+ if (alias !== void 0) control.alias = alias;
2397
+ const tag = getW(first2(sdtPr, "tag"), "val");
2398
+ if (tag !== void 0) control.tag = tag;
2399
+ const lock = getW(first2(sdtPr, "lock"), "val");
2400
+ if (lock === "sdtLocked" || lock === "contentLocked" || lock === "sdtContentLocked")
2401
+ control.lock = lock;
2402
+ const showing = first2(sdtPr, "showingPlcHdr");
2403
+ if (showing) control.showingPlaceholder = parseOnOff(getW(showing, "val")) ?? true;
2404
+ if (first2(sdtPr, "dataBinding")) control.dataBound = true;
2405
+ if (first2(sdtPr, "temporary")) control.temporary = true;
2406
+ if (kind === "text") {
2407
+ const multi = parseOnOff(getW(first2(sdtPr, "text"), "multiLine"));
2408
+ if (multi) control.multiLine = true;
2409
+ }
2410
+ if (kind === "checkbox") {
2411
+ const box = children(sdtPr, "checkbox", WORD_2010_NS, false)[0];
2412
+ const checked = first(box, "checked", WORD_2010_NS, false);
2413
+ control.checked = parseOnOff(attrW14(checked, "val")) ?? false;
2414
+ const on = glyph(first(box, "checkedState", WORD_2010_NS, false));
2415
+ const off = glyph(first(box, "uncheckedState", WORD_2010_NS, false));
2416
+ if (on) control.checkedGlyph = on;
2417
+ if (off) control.uncheckedGlyph = off;
2418
+ }
2419
+ if (kind === "dropDownList" || kind === "comboBox") {
2420
+ const list = first2(sdtPr, kind);
2421
+ control.items = (list ? Array.from(list.childNodes).filter(isElement) : []).filter((item) => named2(item, "listItem")).map((item) => {
2422
+ const display = getW(item, "displayText");
2423
+ const value = getW(item, "value") ?? display ?? "";
2424
+ return { display: display ?? value, value };
2425
+ });
2426
+ }
2427
+ if (kind === "date") {
2428
+ const date = first2(sdtPr, "date");
2429
+ const fullDate = getW(date, "fullDate");
2430
+ if (fullDate) control.fullDate = fullDate;
2431
+ const format = getW(first2(date, "dateFormat"), "val");
2432
+ if (format) control.dateFormat = format;
2433
+ const lid = getW(first2(date, "lid"), "val");
2434
+ if (lid) control.dateLocale = lid;
2435
+ }
2436
+ control.sourceXml = buildXml(sdtPr);
2437
+ return control;
2438
+ }
2439
+
2440
+ // docx/expect-defined.ts
2441
+ function expectDefined2(value, context) {
2442
+ if (value === void 0 || value === null) {
2443
+ throw new Error(`Internal invariant violated: ${context} is missing.`);
2444
+ }
2445
+ return value;
2446
+ }
2447
+ function isCommentReferenceRun(run) {
2448
+ const content = Array.from(run.childNodes).filter(
2449
+ (child) => isElement(child) && !named2(child, "rPr")
2450
+ );
2451
+ return content.length > 0 && content.every((child) => named2(child, "commentReference"));
2452
+ }
2453
+
2454
+ // docx/write-content-control.ts
2455
+ var PROPERTY_ORDER = [
2456
+ "rPr",
2457
+ "alias",
2458
+ "tag",
2459
+ "id",
2460
+ "lock",
2461
+ "placeholder",
2462
+ "temporary",
2463
+ "showingPlcHdr",
2464
+ "dataBinding",
2465
+ "label",
2466
+ "tabIndex"
2467
+ ];
2468
+ var rank = (element) => {
2469
+ const index = element.namespaceURI === WORD_NS ? PROPERTY_ORDER.indexOf(element.localName) : -1;
2470
+ return index < 0 ? PROPERTY_ORDER.length : index;
2471
+ };
2472
+ function place(sdtPr, element) {
2473
+ const siblings = Array.from(sdtPr.childNodes).filter((n2) => n2.nodeType === 1);
2474
+ const after = siblings.find((sibling) => rank(sibling) > rank(element));
2475
+ sdtPr.insertBefore(element, after ?? null);
2476
+ }
2477
+ function setValued(doc, sdtPr, local, value) {
2478
+ for (const existing of children2(sdtPr, local)) sdtPr.removeChild(existing);
2479
+ if (value === void 0) return;
2480
+ const element = makeW(doc, local);
2481
+ element.setAttributeNS(WORD_NS, "w:val", value);
2482
+ place(sdtPr, element);
2483
+ }
2484
+ var same = (left, right) => JSON.stringify(left) === JSON.stringify(right);
2485
+ function w14(doc, local) {
2486
+ const prefix = declareIgnorableExtension(doc, WORD_2010_NS, "w14");
2487
+ return doc.createElementNS(WORD_2010_NS, `${prefix}:${local}`);
2488
+ }
2489
+ function w14Attribute(element, local, value) {
2490
+ const prefix = element.lookupPrefix(WORD_2010_NS) ?? "w14";
2491
+ element.setAttributeNS(WORD_2010_NS, `${prefix}:${local}`, value);
2492
+ }
2493
+ function checkboxElement(sdtPr) {
2494
+ return Array.from(sdtPr.childNodes).find(
2495
+ (n2) => n2.nodeType === 1 && n2.localName === "checkbox" && n2.namespaceURI === WORD_2010_NS
2496
+ );
2497
+ }
2498
+ function writeCheckbox(doc, sdtPr, control) {
2499
+ let box = checkboxElement(sdtPr);
2500
+ if (!box) {
2501
+ box = w14(doc, "checkbox");
2502
+ sdtPr.appendChild(box);
2503
+ }
2504
+ const replace = (local, build, order) => {
2505
+ for (const old of Array.from(box.childNodes))
2506
+ if (old.localName === local) box.removeChild(old);
2507
+ const element = w14(doc, local);
2508
+ build(element);
2509
+ const siblings = Array.from(box.childNodes);
2510
+ box.insertBefore(element, siblings[order] ?? null);
2511
+ };
2512
+ replace("checked", (el4) => w14Attribute(el4, "val", control.checked ? "1" : "0"), 0);
2513
+ if (control.checkedGlyph)
2514
+ replace(
2515
+ "checkedState",
2516
+ (el4) => {
2517
+ w14Attribute(el4, "val", control.checkedGlyph.code);
2518
+ if (control.checkedGlyph.font) w14Attribute(el4, "font", control.checkedGlyph.font);
2519
+ },
2520
+ 1
2521
+ );
2522
+ if (control.uncheckedGlyph)
2523
+ replace(
2524
+ "uncheckedState",
2525
+ (el4) => {
2526
+ w14Attribute(el4, "val", control.uncheckedGlyph.code);
2527
+ if (control.uncheckedGlyph.font) w14Attribute(el4, "font", control.uncheckedGlyph.font);
2528
+ },
2529
+ 2
2530
+ );
2531
+ }
2532
+ function writeItems(doc, sdtPr, control) {
2533
+ const list = first2(sdtPr, control.kind);
2534
+ if (!list) return;
2535
+ for (const item of children2(list, "listItem")) list.removeChild(item);
2536
+ for (const item of control.items ?? []) {
2537
+ const element = makeW(doc, "listItem");
2538
+ element.setAttributeNS(WORD_NS, "w:displayText", item.display);
2539
+ element.setAttributeNS(WORD_NS, "w:value", item.value);
2540
+ list.appendChild(element);
2541
+ }
2542
+ }
2543
+ function writeDate(doc, sdtPr, control) {
2544
+ const date = first2(sdtPr, "date");
2545
+ if (!date) return;
2546
+ if (control.fullDate) date.setAttributeNS(WORD_NS, "w:fullDate", control.fullDate);
2547
+ else date.removeAttributeNS(WORD_NS, "fullDate");
2548
+ const set = (local, value, order) => {
2549
+ for (const old of children2(date, local)) date.removeChild(old);
2550
+ if (value === void 0) return;
2551
+ const element = makeW(doc, local);
2552
+ element.setAttributeNS(WORD_NS, "w:val", value);
2553
+ date.insertBefore(element, Array.from(date.childNodes)[order] ?? null);
2554
+ };
2555
+ set("dateFormat", control.dateFormat, 0);
2556
+ set("lid", control.dateLocale, 1);
2557
+ }
2558
+ function patchContentControl(doc, sdt, control) {
2559
+ const sdtPr = first2(sdt, "sdtPr");
2560
+ if (!sdtPr) return;
2561
+ const current = parseContentControl(sdt, control.level);
2562
+ if (control.alias !== current.alias) setValued(doc, sdtPr, "alias", control.alias);
2563
+ if (control.tag !== current.tag) setValued(doc, sdtPr, "tag", control.tag);
2564
+ if (control.lock !== current.lock) setValued(doc, sdtPr, "lock", control.lock);
2565
+ if (Boolean(control.showingPlaceholder) !== Boolean(current.showingPlaceholder)) {
2566
+ for (const old of children2(sdtPr, "showingPlcHdr")) sdtPr.removeChild(old);
2567
+ if (control.showingPlaceholder) place(sdtPr, makeW(doc, "showingPlcHdr"));
2568
+ }
2569
+ if (control.kind === "checkbox") {
2570
+ if (Boolean(control.checked) !== Boolean(current.checked) || !same(control.checkedGlyph, current.checkedGlyph) || !same(control.uncheckedGlyph, current.uncheckedGlyph))
2571
+ writeCheckbox(doc, sdtPr, control);
2572
+ }
2573
+ if ((control.kind === "dropDownList" || control.kind === "comboBox") && !same(control.items, current.items))
2574
+ writeItems(doc, sdtPr, control);
2575
+ if (control.kind === "date" && (control.fullDate !== current.fullDate || control.dateFormat !== current.dateFormat || control.dateLocale !== current.dateLocale))
2576
+ writeDate(doc, sdtPr, control);
2577
+ }
2578
+ function buildProperties(doc, control) {
2579
+ if (control.sourceXml)
2580
+ return doc.importNode(parseXml2(control.sourceXml).documentElement, true);
2581
+ const sdtPr = makeW(doc, "sdtPr");
2582
+ if (control.alias !== void 0) setValued(doc, sdtPr, "alias", control.alias);
2583
+ if (control.tag !== void 0) setValued(doc, sdtPr, "tag", control.tag);
2584
+ setValued(doc, sdtPr, "id", control.id);
2585
+ if (control.lock) setValued(doc, sdtPr, "lock", control.lock);
2586
+ if (control.showingPlaceholder) place(sdtPr, makeW(doc, "showingPlcHdr"));
2587
+ switch (control.kind) {
2588
+ case "text": {
2589
+ const text2 = makeW(doc, "text");
2590
+ if (control.multiLine) text2.setAttributeNS(WORD_NS, "w:multiLine", "1");
2591
+ sdtPr.appendChild(text2);
2592
+ break;
2593
+ }
2594
+ case "checkbox":
2595
+ writeCheckbox(doc, sdtPr, control);
2596
+ break;
2597
+ case "dropDownList":
2598
+ case "comboBox":
2599
+ sdtPr.appendChild(makeW(doc, control.kind));
2600
+ writeItems(doc, sdtPr, control);
2601
+ break;
2602
+ case "date":
2603
+ sdtPr.appendChild(makeW(doc, "date"));
2604
+ writeDate(doc, sdtPr, control);
2605
+ break;
2606
+ case "richText":
2607
+ break;
2608
+ default:
2609
+ sdtPr.appendChild(makeW(doc, control.kind));
2610
+ }
2611
+ return sdtPr;
2612
+ }
2613
+ function createContentControl(doc, control) {
2614
+ const sdt = makeW(doc, "sdt");
2615
+ sdt.appendChild(buildProperties(doc, control));
2616
+ const content = makeW(doc, "sdtContent");
2617
+ sdt.appendChild(content);
2618
+ patchContentControl(doc, sdt, control);
2619
+ return { sdt, content };
2620
+ }
2621
+
2321
2622
  // docx/comment-spans.ts
2322
2623
  function rangeKeys(run) {
2323
2624
  const keys = (run.commentIds ?? []).map((id) => `comment:${id}`);
@@ -2403,14 +2704,6 @@ function rangeEdges(runs, ranges) {
2403
2704
  return { opens, closes };
2404
2705
  }
2405
2706
 
2406
- // docx/expect-defined.ts
2407
- function expectDefined2(value, context) {
2408
- if (value === void 0 || value === null) {
2409
- throw new Error(`Internal invariant violated: ${context} is missing.`);
2410
- }
2411
- return value;
2412
- }
2413
-
2414
2707
  // docx/element-order.ts
2415
2708
  var RPR_ORDER = [
2416
2709
  "rStyle",
@@ -2462,9 +2755,9 @@ function orderChildren(parent, order) {
2462
2755
  const elements2 = Array.from(parent.childNodes).filter(isElement);
2463
2756
  let previousRank = -1;
2464
2757
  const ranked = elements2.map((element, index) => {
2465
- const rank = element.namespaceURI === WORD_NS ? order.indexOf(element.localName ?? "") : -1;
2466
- if (rank >= 0) previousRank = rank;
2467
- return { element, index, rank: rank >= 0 ? rank : previousRank + 0.5 };
2758
+ const rank2 = element.namespaceURI === WORD_NS ? order.indexOf(element.localName ?? "") : -1;
2759
+ if (rank2 >= 0) previousRank = rank2;
2760
+ return { element, index, rank: rank2 >= 0 ? rank2 : previousRank + 0.5 };
2468
2761
  });
2469
2762
  const sorted = [...ranked].sort((a, b) => a.rank - b.rank || a.index - b.index);
2470
2763
  if (sorted.every((entry, index) => entry.element === elements2[index])) return;
@@ -2728,9 +3021,9 @@ function reconcileBookmarks(doc, starts, ends, names, baseNames, nextId) {
2728
3021
  return !removed;
2729
3022
  });
2730
3023
  const keptEnds = ends.filter((end) => !removedIds.has(getW(end, "id") ?? ""));
2731
- const present = new Set(keptStarts.map((start) => getW(start, "name")));
3024
+ const present2 = new Set(keptStarts.map((start) => getW(start, "name")));
2732
3025
  for (const name of names) {
2733
- if (present.has(name)) continue;
3026
+ if (present2.has(name)) continue;
2734
3027
  const id = nextId();
2735
3028
  const start = makeW(doc, "bookmarkStart");
2736
3029
  start.setAttributeNS(WORD_NS, "w:id", id);
@@ -2783,7 +3076,7 @@ function parsePropertiesSnapshot(xml, local) {
2783
3076
  }
2784
3077
 
2785
3078
  // docx/write-revisions.ts
2786
- var REVISION_WRAPPER_NAMES = ["ins", "del", "moveFrom", "moveTo"];
3079
+ var REVISION_WRAPPER_NAMES2 = ["ins", "del", "moveFrom", "moveTo"];
2787
3080
  var COMMENT_ANCHOR_NAMES = [
2788
3081
  "commentRangeStart",
2789
3082
  "commentRangeEnd",
@@ -2796,7 +3089,7 @@ var COMMENT_ANCHOR_NAMES = [
2796
3089
  function isWordElement(element, names) {
2797
3090
  return (!element.namespaceURI || element.namespaceURI === WORD_NS) && names.includes(element.localName);
2798
3091
  }
2799
- var isRevisionWrapperElement = (element) => isWordElement(element, REVISION_WRAPPER_NAMES);
3092
+ var isRevisionWrapperElement = (element) => isWordElement(element, REVISION_WRAPPER_NAMES2);
2800
3093
  var isCommentAnchorElement = (element) => isWordElement(element, COMMENT_ANCHOR_NAMES);
2801
3094
  function setAttribute4(element, local, value) {
2802
3095
  element.setAttributeNS(WORD_NS, `w:${local}`, value);
@@ -3271,6 +3564,110 @@ function svgDropShadowElement(s, format) {
3271
3564
  const num = format.number;
3272
3565
  return `<feDropShadow dx="${num(s.dx)}" dy="${num(s.dy)}" stdDeviation="${num(s.blur / 2)}" flood-color="${format.color(s.color, "#000000")}" flood-opacity="${num(s.opacity)}" result="shadow"/>`;
3273
3566
  }
3567
+
3568
+ // drawingml/write-color.ts
3569
+ var ELEMENTS = {
3570
+ srgb: "srgbClr",
3571
+ scheme: "schemeClr",
3572
+ system: "sysClr",
3573
+ preset: "prstClr",
3574
+ scrgb: "scrgbClr",
3575
+ hsl: "hslClr"
3576
+ };
3577
+ function drawingColorXml(color) {
3578
+ const local = ELEMENTS[color.kind];
3579
+ const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
3580
+ const root = doc.documentElement;
3581
+ if (color.kind === "scrgb" || color.kind === "hsl") {
3582
+ const keys = color.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
3583
+ const values = color.value.split(",");
3584
+ keys.forEach((key, i) => root.setAttribute(key, values[i] ?? "0"));
3585
+ } else root.setAttribute("val", color.value);
3586
+ if (color.fallback !== void 0 && color.kind === "system")
3587
+ root.setAttribute("lastClr", color.fallback);
3588
+ for (const transform of color.transforms) {
3589
+ if (!/^[A-Za-z_][\w.-]*$/.test(transform.name))
3590
+ throw new Error(`Invalid DrawingML transform ${transform.name}`);
3591
+ const node = doc.createElementNS(NS.a, `a:${transform.name}`);
3592
+ if (transform.value !== "") node.setAttribute("val", transform.value);
3593
+ root.appendChild(node);
3594
+ }
3595
+ return buildXml(doc);
3596
+ }
3597
+
3598
+ // drawingml/write-fill.ts
3599
+ function drawingFillXml(fill) {
3600
+ if (fill.kind === "none") return "<a:noFill/>";
3601
+ if (fill.kind === "solid") return `<a:solidFill>${drawingColorXml(fill.color)}</a:solidFill>`;
3602
+ if (fill.kind !== "gradient") return void 0;
3603
+ const doc = parseXml(fill.sourceXml ?? `<a:gradFill xmlns:a="${NS.a}"/>`);
3604
+ const root = doc.documentElement;
3605
+ if (root.namespaceURI !== NS.a || root.localName !== "gradFill")
3606
+ throw new Error("Invalid gradient source XML");
3607
+ const fragment = (xml) => doc.importNode(elements(parseXml(`<w xmlns:a="${NS.a}">${xml}</w>`).documentElement)[0], true);
3608
+ let list = first(root, "gsLst", NS.a);
3609
+ if (!list) {
3610
+ list = doc.createElementNS(NS.a, "a:gsLst");
3611
+ root.insertBefore(list, root.firstChild);
3612
+ }
3613
+ const stops = children(list, "gs", NS.a).filter(
3614
+ (node) => parseDrawingColorIn(node) && Number.isFinite(Number.parseInt(node.getAttribute("pos") ?? "", 10))
3615
+ );
3616
+ fill.stops.forEach((stop, index) => {
3617
+ const node = stops[index] ?? doc.createElementNS(NS.a, "a:gs");
3618
+ if (!node.parentNode) list.appendChild(node);
3619
+ node.setAttribute("pos", String(Math.round(stop.position * 1e3)));
3620
+ for (const old of elements(node))
3621
+ if (old.namespaceURI === NS.a && old.localName.endsWith("Clr")) node.removeChild(old);
3622
+ node.insertBefore(fragment(drawingColorXml(stop.color)), node.firstChild);
3623
+ });
3624
+ for (const stop of stops.slice(fill.stops.length)) list.removeChild(stop);
3625
+ for (const node of elements(root))
3626
+ if (node.namespaceURI === NS.a && (node.localName === "lin" && (fill.angle === void 0 || fill.path !== void 0) || node.localName === "path" && fill.path === void 0))
3627
+ root.removeChild(node);
3628
+ if (fill.angle !== void 0 && fill.path === void 0) {
3629
+ let linear = first(root, "lin", NS.a);
3630
+ if (!linear) {
3631
+ linear = doc.createElementNS(NS.a, "a:lin");
3632
+ root.insertBefore(
3633
+ linear,
3634
+ first(root, "tileRect", NS.a) ?? first(root, "extLst", NS.a) ?? null
3635
+ );
3636
+ }
3637
+ linear.setAttribute("ang", String(Math.round(fill.angle * 6e4)));
3638
+ if (fill.scaled !== void 0) linear.setAttribute("scaled", fill.scaled ? "1" : "0");
3639
+ }
3640
+ if (fill.path !== void 0) {
3641
+ let path = first(root, "path", NS.a);
3642
+ if (!path) {
3643
+ path = doc.createElementNS(NS.a, "a:path");
3644
+ root.insertBefore(path, first(root, "tileRect", NS.a) ?? first(root, "extLst", NS.a) ?? null);
3645
+ }
3646
+ path.setAttribute("path", fill.path);
3647
+ if (!fill.fillToRect) {
3648
+ const old = first(path, "fillToRect", NS.a);
3649
+ if (old) path.removeChild(old);
3650
+ } else {
3651
+ let focus = first(path, "fillToRect", NS.a);
3652
+ if (!focus) {
3653
+ focus = doc.createElementNS(NS.a, "a:fillToRect");
3654
+ path.appendChild(focus);
3655
+ }
3656
+ for (const [key, value] of Object.entries(fill.fillToRect))
3657
+ focus.setAttribute(key, String(Math.round(value * 1e5)));
3658
+ }
3659
+ }
3660
+ if (fill.tileRect) {
3661
+ let tile = first(root, "tileRect", NS.a);
3662
+ if (!tile) {
3663
+ tile = doc.createElementNS(NS.a, "a:tileRect");
3664
+ root.insertBefore(tile, first(root, "extLst", NS.a) ?? null);
3665
+ }
3666
+ for (const [key, value] of Object.entries(fill.tileRect))
3667
+ tile.setAttribute(key, String(Math.round(value * 1e5)));
3668
+ }
3669
+ return buildXml(doc);
3670
+ }
3274
3671
  function hexToRgb(color) {
3275
3672
  const parsed = hexToRgbChannels(color);
3276
3673
  if (parsed) return parsed;
@@ -3294,21 +3691,21 @@ function lerpStops(a, b, t) {
3294
3691
  opacity: oa + (ob - oa) * t
3295
3692
  };
3296
3693
  }
3297
- function colorAt(stops, position) {
3694
+ function colorAt(stops, position2) {
3298
3695
  const first3 = stops[0];
3299
3696
  const last = stops[stops.length - 1];
3300
- if (position <= first3.position) {
3697
+ if (position2 <= first3.position) {
3301
3698
  return { color: first3.color, opacity: first3.opacity ?? 1 };
3302
3699
  }
3303
- if (position >= last.position) {
3700
+ if (position2 >= last.position) {
3304
3701
  return { color: last.color, opacity: last.opacity ?? 1 };
3305
3702
  }
3306
3703
  for (let i = 0; i < stops.length - 1; i += 1) {
3307
3704
  const from = stops[i];
3308
3705
  const to = stops[i + 1];
3309
- if (position >= from.position && position <= to.position) {
3706
+ if (position2 >= from.position && position2 <= to.position) {
3310
3707
  const span = to.position - from.position;
3311
- const t = span > 0 ? (position - from.position) / span : 0;
3708
+ const t = span > 0 ? (position2 - from.position) / span : 0;
3312
3709
  return lerpStops(from, to, t);
3313
3710
  }
3314
3711
  }
@@ -3365,8 +3762,714 @@ function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options) {
3365
3762
  );
3366
3763
  }
3367
3764
  }
3368
- const paint = masked ? `<defs><mask id="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="100" height="100" mask-type="luminance" color-interpolation="sRGB">${alphaRects.join("")}</mask></defs><g mask="url(#alpha)">${rects.join("")}</g>` : rects.join("");
3369
- return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">${paint}</svg>`;
3765
+ const paint2 = masked ? `<defs><mask id="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="100" height="100" mask-type="luminance" color-interpolation="sRGB">${alphaRects.join("")}</mask></defs><g mask="url(#alpha)">${rects.join("")}</g>` : rects.join("");
3766
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">${paint2}</svg>`;
3767
+ }
3768
+
3769
+ // docx/shape-parse.ts
3770
+ var A_NS2 = "http://schemas.openxmlformats.org/drawingml/2006/main";
3771
+ var WPS_NS2 = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
3772
+ var W_NS2 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
3773
+
3774
+ // chart/regression.ts
3775
+ function computeLinearRegression(xVals, yVals) {
3776
+ const n2 = xVals.length;
3777
+ if (n2 < 2) {
3778
+ return { slope: 0, intercept: 0, rSquared: 0 };
3779
+ }
3780
+ let sumX = 0;
3781
+ let sumY = 0;
3782
+ let sumXY = 0;
3783
+ let sumXX = 0;
3784
+ for (let i = 0; i < n2; i++) {
3785
+ sumX += xVals[i];
3786
+ sumY += yVals[i];
3787
+ sumXY += xVals[i] * yVals[i];
3788
+ sumXX += xVals[i] * xVals[i];
3789
+ }
3790
+ const denom = n2 * sumXX - sumX * sumX;
3791
+ if (Math.abs(denom) < 1e-12) {
3792
+ return { slope: 0, intercept: sumY / n2, rSquared: 0 };
3793
+ }
3794
+ const slope = (n2 * sumXY - sumX * sumY) / denom;
3795
+ const intercept = (sumY - slope * sumX) / n2;
3796
+ const ssRes = yVals.reduce((s, y, i) => s + (y - (slope * xVals[i] + intercept)) ** 2, 0);
3797
+ const meanY = sumY / n2;
3798
+ const ssTot = yVals.reduce((s, y) => s + (y - meanY) ** 2, 0);
3799
+ const rSquared = ssTot > 0 ? 1 - ssRes / ssTot : 0;
3800
+ return { slope, intercept, rSquared };
3801
+ }
3802
+ function fitPolynomial(xVals, yVals, order) {
3803
+ const n2 = xVals.length;
3804
+ const m = order + 1;
3805
+ const matrix = Array.from({ length: m }, () => Array(m + 1).fill(0));
3806
+ for (let i = 0; i < m; i++) {
3807
+ for (let j = 0; j < m; j++) {
3808
+ let sum2 = 0;
3809
+ for (let k = 0; k < n2; k++) {
3810
+ sum2 += xVals[k] ** (i + j);
3811
+ }
3812
+ matrix[i][j] = sum2;
3813
+ }
3814
+ let sum = 0;
3815
+ for (let k = 0; k < n2; k++) {
3816
+ sum += yVals[k] * xVals[k] ** i;
3817
+ }
3818
+ matrix[i][m] = sum;
3819
+ }
3820
+ for (let i = 0; i < m; i++) {
3821
+ let maxRow = i;
3822
+ for (let k = i + 1; k < m; k++) {
3823
+ if (Math.abs(matrix[k][i]) > Math.abs(matrix[maxRow][i])) {
3824
+ maxRow = k;
3825
+ }
3826
+ }
3827
+ [matrix[i], matrix[maxRow]] = [matrix[maxRow], matrix[i]];
3828
+ const pivot = matrix[i][i];
3829
+ if (Math.abs(pivot) < 1e-12) {
3830
+ continue;
3831
+ }
3832
+ for (let j = i; j <= m; j++) {
3833
+ matrix[i][j] = matrix[i][j] / pivot;
3834
+ }
3835
+ for (let k = 0; k < m; k++) {
3836
+ if (k === i) {
3837
+ continue;
3838
+ }
3839
+ const factor = matrix[k][i];
3840
+ for (let j = i; j <= m; j++) {
3841
+ matrix[k][j] = matrix[k][j] - factor * matrix[i][j];
3842
+ }
3843
+ }
3844
+ }
3845
+ return matrix.map((row) => row[m]);
3846
+ }
3847
+ function computeRSquared(xVals, yVals, evalFn) {
3848
+ const n2 = xVals.length;
3849
+ if (n2 === 0) {
3850
+ return 0;
3851
+ }
3852
+ const meanY = yVals.reduce((s, y) => s + y, 0) / n2;
3853
+ let ssRes = 0;
3854
+ let ssTot = 0;
3855
+ for (let i = 0; i < n2; i++) {
3856
+ ssRes += (yVals[i] - evalFn(xVals[i])) ** 2;
3857
+ ssTot += (yVals[i] - meanY) ** 2;
3858
+ }
3859
+ return ssTot > 0 ? 1 - ssRes / ssTot : 0;
3860
+ }
3861
+
3862
+ // chart/box-stats.ts
3863
+ function groupRowsByCategory(rawCategories) {
3864
+ const uniqueCategories = [];
3865
+ const rowIndexesByCategory = /* @__PURE__ */ new Map();
3866
+ rawCategories.forEach((rawLabel, rowIndex) => {
3867
+ const label = rawLabel ?? "";
3868
+ let rows = rowIndexesByCategory.get(label);
3869
+ if (!rows) {
3870
+ rows = [];
3871
+ rowIndexesByCategory.set(label, rows);
3872
+ uniqueCategories.push(label);
3873
+ }
3874
+ rows.push(rowIndex);
3875
+ });
3876
+ return { uniqueCategories, rowIndexesByCategory };
3877
+ }
3878
+
3879
+ // chart/bubble-radius.ts
3880
+ function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options) {
3881
+ const scale = (options?.bubbleScale ?? 100) / 100;
3882
+ if (sizeVal === void 0) return medianRadius * scale;
3883
+ const denom = maxBubble > 0 ? maxBubble : 1;
3884
+ const magnitude = Math.abs(sizeVal);
3885
+ const ratio = (options?.sizeRepresents ?? "w") === "area" ? Math.sqrt(magnitude) / Math.sqrt(denom) : magnitude / denom;
3886
+ return medianRadius * scale * 0.5 + ratio * medianRadius * scale * 1.5;
3887
+ }
3888
+ function maxBubbleSize(sizes) {
3889
+ return sizes.length > 0 ? Math.max(1, ...sizes.map(Math.abs)) : 1;
3890
+ }
3891
+ function medianBubbleRadius(plotWidth, plotHeight) {
3892
+ return Math.min(plotWidth, plotHeight) * 0.04;
3893
+ }
3894
+
3895
+ // chart/stock-candles.ts
3896
+ var STOCK_DEFAULT_UP_FILL = "#FFFFFF";
3897
+ var STOCK_DEFAULT_DOWN_FILL = "#404040";
3898
+ var STOCK_DEFAULT_WICK_COLOR = "#334155";
3899
+ var STOCK_TICK_WIDTH = 1.5;
3900
+ function stockSlots(count, closeLast = false) {
3901
+ if (count < 3) return void 0;
3902
+ const four = count >= 4;
3903
+ return {
3904
+ ...four ? { open: 0 } : {},
3905
+ high: four ? 1 : 0,
3906
+ low: four ? 2 : 1,
3907
+ close: closeLast ? count - 1 : four ? 3 : 2
3908
+ };
3909
+ }
3910
+ var present = (v) => v !== null && v !== void 0;
3911
+ function stockCandle(input) {
3912
+ const { high, low, close, open, x, band, y } = input;
3913
+ if (!present(high) || !present(low)) return void 0;
3914
+ const candleWidth = band * (input.bodyShare ?? 0.5);
3915
+ const candle = { wick: { x, y1: y(high), y2: y(low) } };
3916
+ if (input.hasOpen && present(open) && present(close)) {
3917
+ const openY = y(open);
3918
+ const closeY = y(close);
3919
+ candle.body = {
3920
+ x: x - candleWidth / 2,
3921
+ y: Math.min(openY, closeY),
3922
+ w: candleWidth,
3923
+ h: Math.max(Math.abs(openY - closeY), 1),
3924
+ up: close >= open
3925
+ };
3926
+ } else if (present(close)) {
3927
+ candle.tick = {
3928
+ x1: x,
3929
+ x2: x + Math.max(candleWidth * 0.4, 4),
3930
+ y: y(close)
3931
+ };
3932
+ }
3933
+ return candle;
3934
+ }
3935
+
3936
+ // chart/treemap-squarify.ts
3937
+ function worstAspectRatio(areas, side) {
3938
+ const sum = areas.reduce((total, area) => total + area, 0);
3939
+ const max = Math.max(...areas);
3940
+ const min = Math.min(...areas);
3941
+ const sideSq = side * side;
3942
+ const sumSq = sum * sum;
3943
+ return Math.max(sideSq * max / sumSq, sumSq / (sideSq * min));
3944
+ }
3945
+ function squarify(nodes, box) {
3946
+ const sorted = [...nodes].sort((a, b) => b.weight - a.weight);
3947
+ const total = sorted.reduce((sum, node) => sum + node.weight, 0);
3948
+ const scale = total > 0 ? box.w * box.h / total : box.w * box.h / sorted.length;
3949
+ const items = sorted.map((node) => ({ node, area: (total > 0 ? node.weight : 1) * scale }));
3950
+ const result = [];
3951
+ let rect2 = { ...box };
3952
+ let remaining = items;
3953
+ for (let first3 = remaining[0]; first3 !== void 0; first3 = remaining[0]) {
3954
+ const side = Math.min(rect2.w, rect2.h);
3955
+ let row = [first3];
3956
+ let rowAreas = [first3.area];
3957
+ let worst = worstAspectRatio(rowAreas, side);
3958
+ let cursor = 1;
3959
+ for (let next = remaining[cursor]; next !== void 0; next = remaining[cursor]) {
3960
+ const candidateAreas = [...rowAreas, next.area];
3961
+ const candidateWorst = worstAspectRatio(candidateAreas, side);
3962
+ if (candidateWorst > worst) {
3963
+ break;
3964
+ }
3965
+ row = [...row, next];
3966
+ rowAreas = candidateAreas;
3967
+ worst = candidateWorst;
3968
+ cursor++;
3969
+ }
3970
+ const rowTotalArea = rowAreas.reduce((sum, area) => sum + area, 0);
3971
+ const thickness = side > 0 ? rowTotalArea / side : 0;
3972
+ const layoutVertically = rect2.w >= rect2.h;
3973
+ let offset = layoutVertically ? rect2.y : rect2.x;
3974
+ for (const item of row) {
3975
+ const length = thickness > 0 ? item.area / thickness : 0;
3976
+ if (layoutVertically) {
3977
+ result.push([item.node, { x: rect2.x, y: offset, w: thickness, h: length }]);
3978
+ } else {
3979
+ result.push([item.node, { x: offset, y: rect2.y, w: length, h: thickness }]);
3980
+ }
3981
+ offset += length;
3982
+ }
3983
+ rect2 = layoutVertically ? { ...rect2, x: rect2.x + thickness, w: rect2.w - thickness } : { ...rect2, y: rect2.y + thickness, h: rect2.h - thickness };
3984
+ remaining = remaining.slice(row.length);
3985
+ }
3986
+ return result;
3987
+ }
3988
+
3989
+ // chart/hierarchy.ts
3990
+ function normalizeLevels(levels, pointCount) {
3991
+ return levels.map((level) => {
3992
+ let previous = "";
3993
+ return Array.from({ length: pointCount }, (_, index) => {
3994
+ const label = level[index]?.trim() ?? "";
3995
+ if (label) previous = label;
3996
+ return label || previous;
3997
+ });
3998
+ });
3999
+ }
4000
+ function findOrAddParent(children3, label, colorIndex, parentLabelLayout) {
4001
+ const existing = children3.find((child) => child.children && child.label === label);
4002
+ if (existing?.children) return existing;
4003
+ const parent = { label, weight: 0, children: [], colorIndex, parentLabelLayout };
4004
+ children3.push(parent);
4005
+ return parent;
4006
+ }
4007
+ function buildSeriesHierarchy(series, seriesIndex, categoryLabels, categoryLevels, colorStride) {
4008
+ const pointCount = series.values.length;
4009
+ const levels = normalizeLevels(categoryLevels ?? [], pointCount);
4010
+ const layout = series.parentLabelLayout ?? "banner";
4011
+ const roots = [];
4012
+ for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
4013
+ let children3 = roots;
4014
+ for (let levelIndex = levels.length - 1; levelIndex >= 1; levelIndex--) {
4015
+ const label = levels[levelIndex]?.[pointIndex] || `Group ${levelIndex}`;
4016
+ children3 = findOrAddParent(children3, label, pointIndex, layout).children;
4017
+ }
4018
+ children3.push({
4019
+ label: levels[0]?.[pointIndex] || categoryLabels[pointIndex] || String(pointIndex + 1),
4020
+ weight: Math.abs(series.values[pointIndex] ?? 0),
4021
+ seriesIndex,
4022
+ pointIndex,
4023
+ colorIndex: seriesIndex * colorStride + pointIndex,
4024
+ parentLabelLayout: layout
4025
+ });
4026
+ }
4027
+ return roots;
4028
+ }
4029
+ function aggregate(node) {
4030
+ if (node.children) node.weight = node.children.reduce((sum, child) => sum + aggregate(child), 0);
4031
+ return node.weight;
4032
+ }
4033
+ function propagateColor(node, colorIndex) {
4034
+ node.colorIndex = colorIndex;
4035
+ for (const child of node.children ?? []) propagateColor(child, colorIndex);
4036
+ }
4037
+ function buildHierarchyRoots(series, categoryLabels, categoryLevels) {
4038
+ const colorStride = Math.max(categoryLabels.length, ...series.map((s) => s.values.length), 1);
4039
+ let roots = series.flatMap(
4040
+ (s, index) => buildSeriesHierarchy(s, index, categoryLabels, categoryLevels, colorStride)
4041
+ );
4042
+ if (series.length > 1)
4043
+ roots = series.map((s, index) => ({
4044
+ label: s.name,
4045
+ weight: 0,
4046
+ children: buildSeriesHierarchy(s, index, categoryLabels, categoryLevels, colorStride),
4047
+ colorIndex: index * colorStride,
4048
+ parentLabelLayout: s.parentLabelLayout ?? "banner"
4049
+ }));
4050
+ for (const root of roots) aggregate(root);
4051
+ roots.forEach((root, index) => propagateColor(root, index));
4052
+ return roots;
4053
+ }
4054
+ function hierarchyBranchLabels(series, categoryLabels, categoryLevels) {
4055
+ if (series.length > 1) return series.map((s) => s.name);
4056
+ if (categoryLevels && categoryLevels.length > 1) {
4057
+ const pointCount = series[0]?.values.length ?? categoryLabels.length;
4058
+ const topLevel = normalizeLevels(categoryLevels, pointCount).at(-1) ?? [];
4059
+ const seen = [];
4060
+ for (const label of topLevel) if (!seen.includes(label)) seen.push(label);
4061
+ return seen;
4062
+ }
4063
+ return [...categoryLabels];
4064
+ }
4065
+ var BANNER_HEIGHT = 16;
4066
+ function layoutTreemap(nodes, box) {
4067
+ const cells = [];
4068
+ for (const [node, allocation] of squarify(nodes, box)) {
4069
+ const cell = {
4070
+ x: allocation.x + 1,
4071
+ y: allocation.y + 1,
4072
+ w: Math.max(allocation.w - 2, 1),
4073
+ h: Math.max(allocation.h - 2, 1)
4074
+ };
4075
+ if (node.children) {
4076
+ const showParent = node.parentLabelLayout !== "none" && cell.w > 28 && cell.h > 16;
4077
+ if (showParent)
4078
+ cells.push({ kind: "parent", label: node.label, x: cell.x + 4, y: cell.y + 11 });
4079
+ const banner = showParent && node.parentLabelLayout === "banner" ? BANNER_HEIGHT : 0;
4080
+ cells.push(
4081
+ ...layoutTreemap(node.children, {
4082
+ ...cell,
4083
+ y: cell.y + banner,
4084
+ h: Math.max(cell.h - banner, 1)
4085
+ })
4086
+ );
4087
+ continue;
4088
+ }
4089
+ cells.push({
4090
+ kind: "leaf",
4091
+ ...cell,
4092
+ label: node.label,
4093
+ colorIndex: node.colorIndex,
4094
+ seriesIndex: node.seriesIndex ?? 0,
4095
+ pointIndex: node.pointIndex ?? 0,
4096
+ labelFits: cell.w > 30 && cell.h > 14,
4097
+ labelSize: Math.min(10, cell.h * 0.3)
4098
+ });
4099
+ }
4100
+ return cells;
4101
+ }
4102
+
4103
+ // chart/sunburst-arcs.ts
4104
+ function arcLabelPlacement(cx, cy, radius, startAngle, endAngle) {
4105
+ const midAngle = (startAngle + endAngle) / 2;
4106
+ let rotation = midAngle * 180 / Math.PI + 90;
4107
+ if (rotation > 90 && rotation < 270) rotation -= 180;
4108
+ return {
4109
+ labelX: cx + radius * Math.cos(midAngle),
4110
+ labelY: cy + radius * Math.sin(midAngle),
4111
+ labelRotation: rotation
4112
+ };
4113
+ }
4114
+ function sunburstArcPath(cx, cy, innerRadius, outerRadius, startAngle, endAngle) {
4115
+ const sweep = endAngle - startAngle;
4116
+ const largeArc = sweep > Math.PI ? 1 : 0;
4117
+ const x1 = cx + outerRadius * Math.cos(startAngle);
4118
+ const y1 = cy + outerRadius * Math.sin(startAngle);
4119
+ const x2 = cx + outerRadius * Math.cos(endAngle);
4120
+ const y2 = cy + outerRadius * Math.sin(endAngle);
4121
+ const x3 = cx + innerRadius * Math.cos(endAngle);
4122
+ const y3 = cy + innerRadius * Math.sin(endAngle);
4123
+ const x4 = cx + innerRadius * Math.cos(startAngle);
4124
+ const y4 = cy + innerRadius * Math.sin(startAngle);
4125
+ return `M ${x1} ${y1} A ${outerRadius} ${outerRadius} 0 ${largeArc} 1 ${x2} ${y2} L ${x3} ${y3} A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${x4} ${y4} Z`;
4126
+ }
4127
+ function computeSunburstArcs(series, cx, cy, maxR) {
4128
+ const seriesCount = Math.max(series.length, 1);
4129
+ const ringWidth = maxR / (seriesCount + 0.5);
4130
+ const out = [];
4131
+ series.forEach((s, si) => {
4132
+ const values = s.values;
4133
+ const innerRadius = ringWidth * (si + 0.5);
4134
+ const outerRadius = ringWidth * (si + 1.5);
4135
+ const total = values.reduce((acc, value) => acc + Math.abs(value), 0) || 1;
4136
+ let startAngle = -Math.PI / 2;
4137
+ for (let pointIndex = 0; pointIndex < values.length; pointIndex++) {
4138
+ const endAngle = startAngle + Math.abs(values[pointIndex] ?? 0) / total * Math.PI * 2;
4139
+ out.push({
4140
+ d: sunburstArcPath(cx, cy, innerRadius, outerRadius, startAngle, endAngle),
4141
+ colorIndex: pointIndex,
4142
+ opacity: Math.max(0.1, 0.9 - si * 0.1),
4143
+ pointIndex,
4144
+ level: si,
4145
+ ...arcLabelPlacement(cx, cy, (innerRadius + outerRadius) / 2, startAngle, endAngle)
4146
+ });
4147
+ startAngle = endAngle;
4148
+ }
4149
+ });
4150
+ return out;
4151
+ }
4152
+ function hierarchyKey(levels, level, index) {
4153
+ return levels.slice(level).map((labels) => labels[index] ?? "").join("\0");
4154
+ }
4155
+ function computeHierarchicalSunburstArcs(categoryLevels, values, cx, cy, maxR) {
4156
+ const levels = categoryLevels.filter((level) => level.length > 0);
4157
+ const leafCount = Math.max(values.length, ...levels.map((level) => level.length), 0);
4158
+ if (levels.length === 0 || leafCount === 0) return [];
4159
+ const rawWeights = Array.from({ length: leafCount }, (_, index) => Math.abs(values[index] ?? 0));
4160
+ const weights = rawWeights.some((value) => value !== 0) ? rawWeights : rawWeights.map(() => 1);
4161
+ const total = weights.reduce((sum, value) => sum + value, 0);
4162
+ const prefix = [0];
4163
+ for (const weight of weights) prefix.push((prefix[prefix.length - 1] ?? 0) + weight);
4164
+ const ringWidth = maxR / (levels.length + 0.5);
4165
+ const rootLabels = levels[levels.length - 1] ?? [];
4166
+ const rootColors = /* @__PURE__ */ new Map();
4167
+ const out = [];
4168
+ for (let level = levels.length - 1; level >= 0; level--) {
4169
+ const ringIndex = levels.length - 1 - level;
4170
+ const innerRadius = ringWidth * (ringIndex + 0.5);
4171
+ const outerRadius = ringWidth * (ringIndex + 1.5);
4172
+ let start = 0;
4173
+ while (start < leafCount) {
4174
+ const key = hierarchyKey(levels, level, start);
4175
+ let end = start + 1;
4176
+ while (end < leafCount && hierarchyKey(levels, level, end) === key) end++;
4177
+ const startAngle = -Math.PI / 2 + (prefix[start] ?? 0) / total * Math.PI * 2;
4178
+ const endAngle = -Math.PI / 2 + (prefix[end] ?? 0) / total * Math.PI * 2;
4179
+ const rootLabel = rootLabels[start] ?? "";
4180
+ if (!rootColors.has(rootLabel)) rootColors.set(rootLabel, rootColors.size);
4181
+ out.push({
4182
+ d: sunburstArcPath(cx, cy, innerRadius, outerRadius, startAngle, endAngle),
4183
+ colorIndex: rootColors.get(rootLabel) ?? start,
4184
+ opacity: Math.max(0.1, 0.9 - ringIndex * 0.1),
4185
+ level: ringIndex,
4186
+ label: levels[level]?.[start] ?? "",
4187
+ ...level === 0 && end === start + 1 ? { pointIndex: start } : {},
4188
+ ...arcLabelPlacement(cx, cy, (innerRadius + outerRadius) / 2, startAngle, endAngle)
4189
+ });
4190
+ start = end;
4191
+ }
4192
+ }
4193
+ return out;
4194
+ }
4195
+
4196
+ // chart/histogram-binning.ts
4197
+ function binLabel(lower, upper, closed, format) {
4198
+ return closed === "r" ? `(${format(lower)}, ${format(upper)}]` : `[${format(lower)}, ${format(upper)})`;
4199
+ }
4200
+ function scottBinCount(values, min, max) {
4201
+ if (values.length < 2 || max <= min) {
4202
+ return 1;
4203
+ }
4204
+ const mean = values.reduce((sum, value) => sum + value, 0) / values.length;
4205
+ const variance = values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / (values.length - 1);
4206
+ const sd = Math.sqrt(variance);
4207
+ if (!(sd > 0)) {
4208
+ return 1;
4209
+ }
4210
+ const width = 3.49 * sd * values.length ** (-1 / 3);
4211
+ return Math.max(1, Math.ceil((max - min) / width));
4212
+ }
4213
+ function computeHistogramBins(values, options, format = String) {
4214
+ const closed = options.intervalClosed ?? "l";
4215
+ const finite2 = values.map((value, sourceIndex) => ({ value, sourceIndex })).filter((item) => Number.isFinite(item.value));
4216
+ if (finite2.length === 0) {
4217
+ return [];
4218
+ }
4219
+ const underflow = typeof options.underflow === "number" ? options.underflow : void 0;
4220
+ const overflow = typeof options.overflow === "number" ? options.overflow : void 0;
4221
+ const under = underflow === void 0 ? [] : finite2.filter(
4222
+ (item) => closed === "r" ? item.value <= underflow : item.value < underflow
4223
+ );
4224
+ const over = overflow === void 0 ? [] : finite2.filter((item) => closed === "l" ? item.value >= overflow : item.value > overflow);
4225
+ const regular = finite2.filter((item) => !under.includes(item) && !over.includes(item));
4226
+ const result = [];
4227
+ if (underflow !== void 0) {
4228
+ result.push({
4229
+ value: under.length,
4230
+ label: `${closed === "r" ? "\u2264" : "<"} ${format(underflow)}`,
4231
+ sourceIndices: under.map((item) => item.sourceIndex)
4232
+ });
4233
+ }
4234
+ if (regular.length > 0) {
4235
+ const min = Math.min(...regular.map((item) => item.value));
4236
+ const max = Math.max(...regular.map((item) => item.value));
4237
+ const requestedSize = options.binSize && options.binSize > 0 ? options.binSize : void 0;
4238
+ const requestedCount = options.binCount && options.binCount > 0 ? options.binCount : void 0;
4239
+ const start = requestedSize ? Math.floor(min / requestedSize) * requestedSize : min;
4240
+ const count = requestedSize ? Math.max(
4241
+ closed === "l" ? Math.floor((max - start) / requestedSize) + 1 : Math.ceil((max - start) / requestedSize),
4242
+ 1
4243
+ ) : Math.max(
4244
+ requestedCount ?? scottBinCount(
4245
+ regular.map((item) => item.value),
4246
+ min,
4247
+ max
4248
+ ),
4249
+ 1
4250
+ );
4251
+ const width = requestedSize ?? Math.max((max - start) / count, 1);
4252
+ const bins = Array.from({ length: count }, (_, index) => ({
4253
+ value: 0,
4254
+ label: binLabel(start + index * width, start + (index + 1) * width, closed, format),
4255
+ sourceIndices: []
4256
+ }));
4257
+ for (const item of regular) {
4258
+ const rawIndex = closed === "r" ? Math.ceil((item.value - start) / width) - 1 : Math.floor((item.value - start) / width);
4259
+ const index = Math.max(0, Math.min(rawIndex, bins.length - 1));
4260
+ const bin = bins[index];
4261
+ if (!bin) continue;
4262
+ bin.value += 1;
4263
+ bin.sourceIndices.push(item.sourceIndex);
4264
+ }
4265
+ result.push(...bins);
4266
+ }
4267
+ if (overflow !== void 0) {
4268
+ result.push({
4269
+ value: over.length,
4270
+ label: `${closed === "l" ? "\u2265" : ">"} ${format(overflow)}`,
4271
+ sourceIndices: over.map((item) => item.sourceIndex)
4272
+ });
4273
+ }
4274
+ return result;
4275
+ }
4276
+ function aggregateByCategory(values, rawCategories) {
4277
+ const { uniqueCategories, rowIndexesByCategory } = groupRowsByCategory(rawCategories);
4278
+ return uniqueCategories.map((label) => {
4279
+ const rows = rowIndexesByCategory.get(label) ?? [];
4280
+ return {
4281
+ value: rows.reduce((sum, row) => sum + (values[row] ?? 0), 0),
4282
+ label,
4283
+ sourceIndices: rows
4284
+ };
4285
+ });
4286
+ }
4287
+
4288
+ // chart/waterfall.ts
4289
+ function buildWaterfallSteps(values, options) {
4290
+ const subtotalIndices = new Set(
4291
+ options?.subtotalIndices ?? (values.length > 0 ? [values.length - 1] : [])
4292
+ );
4293
+ const steps = [];
4294
+ let runningTotal = 0;
4295
+ for (let sourceIndex = 0; sourceIndex < values.length; sourceIndex++) {
4296
+ const value = values[sourceIndex] ?? 0;
4297
+ const isSubtotal = subtotalIndices.has(sourceIndex);
4298
+ const startValue = isSubtotal ? 0 : runningTotal;
4299
+ const endValue = isSubtotal ? value : runningTotal + value;
4300
+ steps.push({ sourceIndex, value, startValue, endValue, isSubtotal });
4301
+ runningTotal = endValue;
4302
+ }
4303
+ return steps;
4304
+ }
4305
+
4306
+ // chart/trendline-equation.ts
4307
+ var SIGNIFICANT_DIGITS = 4;
4308
+ function formatTrendlineCoefficient(value) {
4309
+ if (!Number.isFinite(value) || value === 0) {
4310
+ return "0";
4311
+ }
4312
+ const rounded = Number(value.toPrecision(SIGNIFICANT_DIGITS));
4313
+ return rounded === 0 ? "0" : String(rounded);
4314
+ }
4315
+ function signedTerm(value) {
4316
+ return { sign: value < 0 ? "-" : "+", abs: formatTrendlineCoefficient(Math.abs(value)) };
4317
+ }
4318
+ function formatLinearEquation(slope, intercept) {
4319
+ const { sign, abs } = signedTerm(intercept);
4320
+ return `y = ${formatTrendlineCoefficient(slope)}x ${sign} ${abs}`;
4321
+ }
4322
+ function formatExponentialEquation(a, b) {
4323
+ return `y = ${formatTrendlineCoefficient(a)} e^(${formatTrendlineCoefficient(b)}x)`;
4324
+ }
4325
+ function formatLogarithmicEquation(slope, intercept) {
4326
+ const { sign, abs } = signedTerm(intercept);
4327
+ return `y = ${formatTrendlineCoefficient(slope)}ln(x) ${sign} ${abs}`;
4328
+ }
4329
+ function formatPowerEquation(a, b) {
4330
+ return `y = ${formatTrendlineCoefficient(a)}x^${formatTrendlineCoefficient(b)}`;
4331
+ }
4332
+ function formatPolynomialEquation(coeffsAscending) {
4333
+ const order = coeffsAscending.length - 1;
4334
+ let out = "y = ";
4335
+ for (let power = order; power >= 0; power--) {
4336
+ const coeff = coeffsAscending[power] ?? 0;
4337
+ const { sign, abs } = signedTerm(coeff);
4338
+ const variable = power === 0 ? "" : power === 1 ? "x" : `x^${power}`;
4339
+ out += power === order ? `${sign === "-" ? "-" : ""}${abs}${variable}` : ` ${sign} ${abs}${variable}`;
4340
+ }
4341
+ return out;
4342
+ }
4343
+
4344
+ // chart/trendline-fit.ts
4345
+ var noFit = () => ({
4346
+ points: [],
4347
+ equation: "",
4348
+ rSquared: 0,
4349
+ coefficients: []
4350
+ });
4351
+ function fitModel(options, xVals, yVals) {
4352
+ const xs = [...xVals];
4353
+ const ys = [...yVals];
4354
+ switch (options.kind) {
4355
+ case "linear": {
4356
+ const reg = computeLinearRegression(xs, ys);
4357
+ const fixed = options.intercept;
4358
+ const slope = fixed !== void 0 ? ys.reduce((s, y, i) => s + (y - fixed) * xs[i], 0) / xs.reduce((s, x) => s + x * x, 0) : reg.slope;
4359
+ const b = fixed ?? reg.intercept;
4360
+ return {
4361
+ evaluate: (x) => slope * x + b,
4362
+ equation: formatLinearEquation(slope, b),
4363
+ rSquared: reg.rSquared,
4364
+ coefficients: [b, slope]
4365
+ };
4366
+ }
4367
+ case "exponential": {
4368
+ const logY = ys.filter((y) => y > 0).map((y) => Math.log(y));
4369
+ const posX = xs.filter((_x, i) => ys[i] > 0);
4370
+ if (logY.length < 2) return void 0;
4371
+ const reg = computeLinearRegression(posX, logY);
4372
+ const a = Math.exp(reg.intercept);
4373
+ const b = reg.slope;
4374
+ return {
4375
+ evaluate: (x) => a * Math.exp(b * x),
4376
+ equation: formatExponentialEquation(a, b),
4377
+ rSquared: reg.rSquared,
4378
+ coefficients: [a, b]
4379
+ };
4380
+ }
4381
+ case "logarithmic": {
4382
+ const lnX = xs.filter((x) => x > 0).map((x) => Math.log(x));
4383
+ const posY = ys.filter((_y, i) => xs[i] > 0);
4384
+ if (lnX.length < 2) return void 0;
4385
+ const reg = computeLinearRegression(lnX, posY);
4386
+ return {
4387
+ evaluate: (x) => x > 0 ? reg.slope * Math.log(x) + reg.intercept : 0,
4388
+ equation: formatLogarithmicEquation(reg.slope, reg.intercept),
4389
+ rSquared: reg.rSquared,
4390
+ coefficients: [reg.intercept, reg.slope]
4391
+ };
4392
+ }
4393
+ case "power": {
4394
+ const logX = xs.filter((x, i) => x > 0 && ys[i] > 0).map((x) => Math.log(x));
4395
+ const logY = ys.filter((y, i) => y > 0 && xs[i] > 0).map((y) => Math.log(y));
4396
+ if (logX.length < 2) return void 0;
4397
+ const reg = computeLinearRegression(logX, logY);
4398
+ const a = Math.exp(reg.intercept);
4399
+ return {
4400
+ evaluate: (x) => x > 0 ? a * x ** reg.slope : 0,
4401
+ equation: formatPowerEquation(a, reg.slope),
4402
+ rSquared: reg.rSquared,
4403
+ coefficients: [a, reg.slope]
4404
+ };
4405
+ }
4406
+ case "polynomial": {
4407
+ const order = Math.min(options.order ?? 2, 6);
4408
+ const coeffs = fitPolynomial(xs, ys, order);
4409
+ const evaluate = (x) => coeffs.reduce((s, c, i) => s + c * x ** i, 0);
4410
+ return {
4411
+ evaluate,
4412
+ equation: formatPolynomialEquation(coeffs),
4413
+ rSquared: computeRSquared(xs, ys, evaluate),
4414
+ coefficients: coeffs
4415
+ };
4416
+ }
4417
+ default:
4418
+ return void 0;
4419
+ }
4420
+ }
4421
+ function fitChartTrendline(options, xVals, yVals) {
4422
+ const count = yVals.length;
4423
+ if (count < 2) return noFit();
4424
+ if (options.kind === "movingAvg") {
4425
+ const period = options.period ?? 2;
4426
+ const points2 = [];
4427
+ for (let i = period - 1; i < count; i++) {
4428
+ let sum = 0;
4429
+ for (let j = i - period + 1; j <= i; j++) sum += yVals[j];
4430
+ points2.push({ x: xVals[i], y: sum / period });
4431
+ }
4432
+ return { points: points2, equation: `${period}-period moving average`, rSquared: 0, coefficients: [] };
4433
+ }
4434
+ const model = fitModel(options, xVals, yVals);
4435
+ if (!model) return noFit();
4436
+ const startX = Math.min(...xVals) - (options.backward ?? 0);
4437
+ const endX = Math.max(...xVals) + (options.forward ?? 0);
4438
+ const steps = Math.max(Math.ceil((endX - startX) * 4), 20);
4439
+ const points = [];
4440
+ for (let step = 0; step <= steps; step++) {
4441
+ const x = startX + (endX - startX) * step / steps;
4442
+ const y = model.evaluate(x);
4443
+ if (Number.isFinite(y)) points.push({ x, y });
4444
+ }
4445
+ return {
4446
+ points,
4447
+ equation: model.equation,
4448
+ rSquared: model.rSquared,
4449
+ coefficients: model.coefficients
4450
+ };
4451
+ }
4452
+
4453
+ // chart/error-bar-amount.ts
4454
+ function chartSampleVariance(values) {
4455
+ const count = values.length;
4456
+ if (count === 0) return 0;
4457
+ const mean = values.reduce((sum, value) => sum + value, 0) / count;
4458
+ return values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / Math.max(count - 1, 1);
4459
+ }
4460
+ function chartErrorBarAmount(options, values, displayIndex, sourceIndex, side) {
4461
+ switch (options.valueType) {
4462
+ case "fixedVal":
4463
+ return options.value ?? 0;
4464
+ case "percentage":
4465
+ return Math.abs(values[displayIndex] ?? 0) * ((options.value ?? 0) / 100);
4466
+ case "stdDev":
4467
+ return Math.sqrt(chartSampleVariance(values)) * (options.value ?? 1);
4468
+ case "stdErr":
4469
+ return Math.sqrt(chartSampleVariance(values) / Math.max(values.length, 1));
4470
+ case "cust":
4471
+ return side === "plus" ? options.customPlus?.[sourceIndex] ?? 0 : options.customMinus?.[sourceIndex] ?? 0;
4472
+ }
3370
4473
  }
3371
4474
 
3372
4475
  // chart/color-palettes.ts
@@ -3637,12 +4740,12 @@ function buildChartGradientDef(id, fill, bounds) {
3637
4740
  function chartGradientMarkup(def) {
3638
4741
  if (def.kind === "rectPath")
3639
4742
  return `<pattern id="${escapeXmlAttr(def.id)}" patternUnits="objectBoundingBox" patternContentUnits="objectBoundingBox" width="1" height="1"><image href="${escapeXmlAttr(def.href)}" width="1" height="1" preserveAspectRatio="none"/></pattern>`;
3640
- const geometry = def.kind === "linearGradient" ? `${def.gradientUnits ? `gradientUnits="${def.gradientUnits}" ` : ""}x1="${def.x1}" y1="${def.y1}" x2="${def.x2}" y2="${def.y2}"` : `cx="${def.cx}" cy="${def.cy}" r="${def.r}"`;
4743
+ const geometry2 = def.kind === "linearGradient" ? `${def.gradientUnits ? `gradientUnits="${def.gradientUnits}" ` : ""}x1="${def.x1}" y1="${def.y1}" x2="${def.x2}" y2="${def.y2}"` : `cx="${def.cx}" cy="${def.cy}" r="${def.r}"`;
3641
4744
  const stops = def.stops.map(
3642
4745
  (stop) => `<stop offset="${stop.offset}" stop-color="${escapeXmlAttr(stop.color)}" stop-opacity="${stop.opacity ?? 1}"/>`
3643
4746
  ).join("");
3644
4747
  const transform = def.kind === "radialGradient" && def.gradientTransform ? ` gradientTransform="${escapeXmlAttr(def.gradientTransform)}"` : "";
3645
- return `<${def.kind} id="${escapeXmlAttr(def.id)}" ${geometry}${transform}>${stops}</${def.kind}>`;
4748
+ return `<${def.kind} id="${escapeXmlAttr(def.id)}" ${geometry2}${transform}>${stops}</${def.kind}>`;
3646
4749
  }
3647
4750
 
3648
4751
  // chart/bar-cluster-geometry.ts
@@ -3656,6 +4759,17 @@ function clusteredBarGeometry(barGroupWidth, seriesCount, chartData) {
3656
4759
  return { singleBarWidth, step, clusterWidth: singleBarWidth + step * (seriesCount - 1) };
3657
4760
  }
3658
4761
 
4762
+ // chart/model-analysis.ts
4763
+ var KIND_OF_TYPE = {
4764
+ linear: "linear",
4765
+ exp: "exponential",
4766
+ log: "logarithmic",
4767
+ poly: "polynomial",
4768
+ power: "power",
4769
+ movingAvg: "movingAvg"
4770
+ };
4771
+ var chartTrendlineKind = (type) => type !== void 0 && Object.hasOwn(KIND_OF_TYPE, type) ? KIND_OF_TYPE[type] : void 0;
4772
+
3659
4773
  // chart/data-cache.ts
3660
4774
  function chartCacheValues(cache) {
3661
4775
  if (!cache) return [];
@@ -3671,6 +4785,91 @@ function chartCacheValues(cache) {
3671
4785
  }
3672
4786
  var chartSourceValues = (source) => chartCacheValues(source?.cache ?? source?.levels?.[0]);
3673
4787
 
4788
+ // drawingml/write-line.ts
4789
+ var FILLS = /* @__PURE__ */ new Set(["noFill", "solidFill", "gradFill", "pattFill"]);
4790
+ function dropDrawingDeclarations(element) {
4791
+ if (element.getAttribute("xmlns:a") === NS.a) element.removeAttribute("xmlns:a");
4792
+ for (const child of elements(element)) dropDrawingDeclarations(child);
4793
+ }
4794
+ function patchDrawingLine(ln, line2) {
4795
+ if (line2.widthEmu === void 0) ln.removeAttribute("w");
4796
+ else ln.setAttribute("w", String(Math.round(line2.widthEmu)));
4797
+ if (line2.cap === void 0) ln.removeAttribute("cap");
4798
+ else ln.setAttribute("cap", line2.cap);
4799
+ const fill = line2.fill && drawingFillXml(line2.fill);
4800
+ if (fill || !line2.fill) {
4801
+ for (const node of elements(ln))
4802
+ if (node.namespaceURI === NS.a && FILLS.has(node.localName)) ln.removeChild(node);
4803
+ }
4804
+ if (fill) {
4805
+ const parsed = parseXml(`<w xmlns:a="${NS.a}">${fill}</w>`).documentElement;
4806
+ for (const node of elements(parsed).reverse()) {
4807
+ const imported = ln.ownerDocument.importNode(node, true);
4808
+ dropDrawingDeclarations(imported);
4809
+ ln.insertBefore(imported, ln.firstChild);
4810
+ }
4811
+ }
4812
+ const dashes = elements(ln).filter(
4813
+ (node) => node.namespaceURI === NS.a && (node.localName === "prstDash" || node.localName === "custDash")
4814
+ );
4815
+ if (line2.dash === void 0) {
4816
+ for (const node of dashes) if (node.localName === "prstDash") ln.removeChild(node);
4817
+ return;
4818
+ }
4819
+ const dash = ln.ownerDocument.createElementNS(NS.a, "a:prstDash");
4820
+ dash.setAttribute("val", line2.dash);
4821
+ for (const node of dashes) ln.removeChild(node);
4822
+ const afterFill = elements(ln).find(
4823
+ (node) => node.namespaceURI !== NS.a || !FILLS.has(node.localName)
4824
+ );
4825
+ ln.insertBefore(dash, afterFill ?? null);
4826
+ }
4827
+ function drawingLineXml(line2) {
4828
+ const doc = parseXml(`<a:ln xmlns:a="${NS.a}"/>`);
4829
+ patchDrawingLine(doc.documentElement, line2);
4830
+ return buildXml(doc);
4831
+ }
4832
+
4833
+ // chart/render/summary-analysis.ts
4834
+ function summaryTrendline(source) {
4835
+ const kind = chartTrendlineKind(source.trendlineType);
4836
+ if (!kind) return void 0;
4837
+ const out = { kind };
4838
+ if (source.order !== void 0) out.order = source.order;
4839
+ if (source.period !== void 0) out.period = source.period;
4840
+ if (source.forward !== void 0) out.forward = source.forward;
4841
+ if (source.backward !== void 0) out.backward = source.backward;
4842
+ if (source.intercept !== void 0) out.intercept = source.intercept;
4843
+ if (source.name !== void 0) out.name = source.name;
4844
+ if (source.spPr?.line) out.line = source.spPr.line;
4845
+ return out;
4846
+ }
4847
+ var amounts = (source) => chartSourceValues(source).map((value) => typeof value === "number" ? value : 0);
4848
+ function summaryErrorBars(source) {
4849
+ if (!source.valueType) return void 0;
4850
+ const out = {
4851
+ direction: source.direction ?? "y",
4852
+ barType: source.barType ?? "both",
4853
+ valueType: source.valueType
4854
+ };
4855
+ if (source.value !== void 0) out.value = source.value;
4856
+ if (source.valueType === "cust") {
4857
+ out.customPlus = amounts(source.plus);
4858
+ out.customMinus = amounts(source.minus);
4859
+ }
4860
+ if (source.noEndCap !== void 0) out.noEndCap = source.noEndCap;
4861
+ if (source.spPr?.line) out.line = source.spPr.line;
4862
+ return out;
4863
+ }
4864
+ function summaryAnalysis(series) {
4865
+ const trendlines2 = (series.trendlines ?? []).map(summaryTrendline).filter((entry) => entry !== void 0);
4866
+ const errorBars = (series.errorBars ?? []).map(summaryErrorBars).filter((entry) => entry !== void 0);
4867
+ return {
4868
+ ...trendlines2.length ? { trendlines: trendlines2 } : {},
4869
+ ...errorBars.length ? { errorBars } : {}
4870
+ };
4871
+ }
4872
+
3674
4873
  // chart/render/summary-from-space.ts
3675
4874
  var solidColor = (fill) => fill?.kind === "solid" ? fill.color : void 0;
3676
4875
  var isSolidFill = (fill) => fill?.kind === "solid" || fill?.kind === "unsupported" && fill.element === "solidFill";
@@ -3691,12 +4890,15 @@ var GROUPINGS = /* @__PURE__ */ new Set(["clustered", "stacked", "percentStacked
3691
4890
  function chartSummarySeries(source, chartType) {
3692
4891
  const categories = source.categories ?? source.xValues;
3693
4892
  const values = source.values ?? source.yValues;
4893
+ const numeric = (v) => typeof v === "number" ? v : v === "" ? null : Number.isFinite(Number(v)) ? Number(v) : null;
3694
4894
  const out = {
3695
4895
  categories: chartSourceValues(categories),
3696
- values: chartSourceValues(values).map(
3697
- (v) => typeof v === "number" ? v : v === "" ? null : Number.isFinite(Number(v)) ? Number(v) : null
3698
- )
4896
+ values: chartSourceValues(values).map(numeric)
3699
4897
  };
4898
+ if (source.bubbleSizes) {
4899
+ out.bubbleSizes = chartSourceValues(source.bubbleSizes).map(numeric);
4900
+ if (source.bubbleSizes.formula) out.bubbleSizesRef = source.bubbleSizes.formula;
4901
+ }
3700
4902
  if (source.tx?.text !== void 0) out.name = source.tx.text;
3701
4903
  const nameRef = source.tx?.reference?.formula;
3702
4904
  if (nameRef) out.nameRef = nameRef;
@@ -3721,18 +4923,68 @@ function chartSummarySeries(source, chartType) {
3721
4923
  }
3722
4924
  if (Object.keys(points).length) out.pointColors = points;
3723
4925
  if (Object.keys(pointFills).length) out.pointFills = pointFills;
4926
+ Object.assign(out, summaryAnalysis(source));
3724
4927
  return out;
3725
4928
  }
3726
- function chartSummaryFromSpace(chartSpace, extras = {}) {
3727
- const group = chartSpace.plotArea.groups[0];
3728
- let chartType = group ? GROUP_TYPES[group.kind] : "column";
3729
- if (chartType === "bar" && group?.barDirection !== "bar") chartType = "column";
3730
- const series = (group?.series ?? []).map((source) => chartSummarySeries(source, chartType));
3731
- const summary = {
3732
- chartType,
3733
- series,
3734
- showLegend: chartSpace.legend !== void 0
3735
- };
4929
+ function valueAxisId(chartSpace, axisIds) {
4930
+ return axisIds.find(
4931
+ (id) => chartSpace.plotArea.axes.some((a) => a.id === id && a.kind === "val")
4932
+ );
4933
+ }
4934
+ function stockStyle(group) {
4935
+ return {
4936
+ ...group.hiLowLinesSpPr ? { hiLowLines: group.hiLowLinesSpPr } : {},
4937
+ ...group.upBars?.spPr ? { upBars: group.upBars.spPr } : {},
4938
+ ...group.downBars?.spPr ? { downBars: group.downBars.spPr } : {},
4939
+ ...group.upDownBarsGapWidth === void 0 ? {} : { gapWidth: group.upDownBarsGapWidth }
4940
+ };
4941
+ }
4942
+ function extraGroups(chartSpace, firstType) {
4943
+ const [first3, ...rest] = chartSpace.plotArea.groups;
4944
+ if (!first3 || !["column", "line", "area"].includes(firstType)) return [];
4945
+ const primary = valueAxisId(chartSpace, first3.axisIds);
4946
+ const out = [];
4947
+ for (const group of rest) {
4948
+ const stockOverColumns = group.kind === "stock" && firstType === "column";
4949
+ if (group.is3D || !(["bar", "line", "area"].includes(group.kind) || stockOverColumns)) continue;
4950
+ const type = group.kind === "bar" ? "column" : group.kind;
4951
+ const entry = {
4952
+ chartType: type,
4953
+ series: group.series.map((source) => chartSummarySeries(source, type)),
4954
+ secondary: valueAxisId(chartSpace, group.axisIds) !== primary
4955
+ };
4956
+ if (group.grouping && GROUPINGS.has(group.grouping))
4957
+ entry.grouping = group.grouping;
4958
+ if (type === "stock") entry.stock = stockStyle(group);
4959
+ if (type === "column") {
4960
+ if (group.gapWidth !== void 0) entry.barGapWidth = group.gapWidth;
4961
+ if (group.overlap !== void 0) entry.barOverlap = group.overlap;
4962
+ }
4963
+ if (entry.series.length) out.push(entry);
4964
+ }
4965
+ return out;
4966
+ }
4967
+ function chartSummaryFromSpace(chartSpace, extras = {}) {
4968
+ const group = chartSpace.plotArea.groups[0];
4969
+ let chartType = group ? GROUP_TYPES[group.kind] : "column";
4970
+ if (chartType === "bar" && group?.barDirection !== "bar") chartType = "column";
4971
+ const series = (group?.series ?? []).map((source) => chartSummarySeries(source, chartType));
4972
+ const summary = {
4973
+ chartType,
4974
+ series,
4975
+ showLegend: chartSpace.legend !== void 0
4976
+ };
4977
+ const combined = extraGroups(chartSpace, chartType);
4978
+ if (combined.length) summary.extraGroups = combined;
4979
+ if (chartType === "stock" && group) summary.stock = stockStyle(group);
4980
+ if (chartType === "bubble" && group) {
4981
+ const sizeRepresents = group.sizeRepresents === "w" ? "w" : "area";
4982
+ summary.bubble = {
4983
+ sizeRepresents,
4984
+ ...group.bubbleScale === void 0 ? {} : { bubbleScale: group.bubbleScale },
4985
+ showNegativeBubbles: group.showNegativeBubbles === true
4986
+ };
4987
+ }
3736
4988
  const grouping = group?.grouping;
3737
4989
  if (grouping && GROUPINGS.has(grouping))
3738
4990
  summary.grouping = grouping;
@@ -3760,6 +5012,193 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
3760
5012
  return summary;
3761
5013
  }
3762
5014
 
5015
+ // chart/render/chart-svg-util.ts
5016
+ var TEXT_COLOR = "#595959";
5017
+ var GRID_COLOR = "#D9D9D9";
5018
+ var AXIS_COLOR = "#BFBFBF";
5019
+ var FONT_SIZE = 10;
5020
+ function esc(text2) {
5021
+ return text2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
5022
+ }
5023
+ var n = (value) => String(Math.round(value * 100) / 100);
5024
+ var textWidth = (text2, size = FONT_SIZE) => text2.length * size * 0.55;
5025
+ function text(x, y, content, attrs2 = {}) {
5026
+ const parts = [`x="${n(x)}"`, `y="${n(y)}"`];
5027
+ parts.push(`font-size="${attrs2.size ?? FONT_SIZE}"`);
5028
+ parts.push(`fill="${esc(attrs2.fill ?? TEXT_COLOR)}"`);
5029
+ if (attrs2.anchor && attrs2.anchor !== "start") parts.push(`text-anchor="${attrs2.anchor}"`);
5030
+ if (attrs2.weight) parts.push(`font-weight="${attrs2.weight}"`);
5031
+ if (attrs2.baseline) parts.push(`dominant-baseline="${attrs2.baseline}"`);
5032
+ if (attrs2.family) parts.push(`font-family="${esc(attrs2.family)}"`);
5033
+ if (attrs2.filter) parts.push(`filter="${esc(attrs2.filter)}"`);
5034
+ if (attrs2.italic !== void 0) parts.push(`font-style="${attrs2.italic ? "italic" : "normal"}"`);
5035
+ if (attrs2.underline !== void 0)
5036
+ parts.push(`text-decoration="${attrs2.underline ? "underline" : "none"}"`);
5037
+ return `<text ${parts.join(" ")}>${esc(content)}</text>`;
5038
+ }
5039
+ var line = (x1, y1, x2, y2, stroke, width = 1) => `<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" stroke="${stroke}" stroke-width="${width}"/>`;
5040
+ var rect = (x, y, w, h, fill, filter) => `<rect x="${n(x)}" y="${n(y)}" width="${n(Math.max(0, w))}" height="${n(Math.max(0, h))}" fill="${fill}"${filter ? ` filter="${esc(filter)}"` : ""}/>`;
5041
+ function fit(content, maxWidth, size = FONT_SIZE) {
5042
+ if (textWidth(content, size) <= maxWidth) return content;
5043
+ const chars = Math.max(1, Math.floor(maxWidth / (size * 0.55)) - 1);
5044
+ return `${content.slice(0, chars)}\u2026`;
5045
+ }
5046
+
5047
+ // chart/render/chart-spacing.ts
5048
+ function chartBarSpacing(chart) {
5049
+ const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
5050
+ return {
5051
+ barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
5052
+ barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
5053
+ };
5054
+ }
5055
+
5056
+ // chart/render/chart-svg-bars.ts
5057
+ function barLayout(model, frame) {
5058
+ const count = Math.max(1, model.series.length);
5059
+ const geometry2 = clusteredBarGeometry(frame.bandSize, count, chartBarSpacing(model));
5060
+ const barSize = geometry2.singleBarWidth;
5061
+ const offset = (si) => model.horizontal ? geometry2.clusterWidth / 2 - barSize - si * geometry2.step : -geometry2.clusterWidth / 2 + si * geometry2.step;
5062
+ return { barSize, offset };
5063
+ }
5064
+ function bars(model, frame, out, values) {
5065
+ const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
5066
+ const { barSize, offset: barOffset } = barLayout(model, frame);
5067
+ const base = frame.value(0);
5068
+ const pos = new Array(model.categories.length).fill(0);
5069
+ const neg = new Array(model.categories.length).fill(0);
5070
+ model.series.forEach((s, si) => {
5071
+ values[si]?.forEach((v, i) => {
5072
+ if (v === null || i >= model.categories.length) return;
5073
+ let from = 0;
5074
+ let to = v;
5075
+ if (stacked) {
5076
+ const acc = v >= 0 ? pos : neg;
5077
+ from = acc[i] ?? 0;
5078
+ to = from + v;
5079
+ acc[i] = to;
5080
+ }
5081
+ const a = stacked ? frame.value(from) : base;
5082
+ const b = frame.value(to);
5083
+ const offset = barOffset(si);
5084
+ const center = frame.band(i);
5085
+ const width = model.horizontal ? Math.abs(b - a) : barSize;
5086
+ const height = model.horizontal ? barSize : Math.abs(b - a);
5087
+ let color = s.pointColors?.[i] ?? s.color;
5088
+ const gradient = s.pointGradients?.[i] ?? (s.pointColors?.[i] === void 0 ? s.gradient : void 0);
5089
+ if (gradient && (gradient.path === "circle" || gradient.path === "shape")) {
5090
+ const baseId = color.match(/^url\(#(.+)\)$/)?.[1];
5091
+ if (baseId) {
5092
+ const id = baseId.replace(/(-s\d+(?:-p\d+)?)$/, `-mark${i}$1`);
5093
+ const def = buildChartGradientDef(id, gradient, {
5094
+ width: Number(n(width)),
5095
+ height: Number(n(height)),
5096
+ shape: "rect"
5097
+ });
5098
+ out.push(`<defs>${chartGradientMarkup(def)}</defs>`);
5099
+ color = `url(#${id})`;
5100
+ }
5101
+ }
5102
+ out.push(`<g data-chart-series="${si}" data-chart-point="${i}">`);
5103
+ if (model.horizontal)
5104
+ out.push(
5105
+ rect(Math.min(a, b), center + offset, Math.abs(b - a), barSize, color, s.shadowFilter)
5106
+ );
5107
+ else
5108
+ out.push(
5109
+ rect(center + offset, Math.min(a, b), barSize, Math.abs(b - a), color, s.shadowFilter)
5110
+ );
5111
+ out.push("</g>");
5112
+ });
5113
+ });
5114
+ }
5115
+
5116
+ // chart/render/chart-svg-analysis.ts
5117
+ var DASHES = {
5118
+ dot: [1, 3],
5119
+ dash: [4, 3],
5120
+ lgDash: [8, 3],
5121
+ dashDot: [4, 3, 1, 3],
5122
+ lgDashDot: [8, 3, 1, 3],
5123
+ lgDashDotDot: [8, 3, 1, 3, 1, 3],
5124
+ sysDash: [3, 1],
5125
+ sysDot: [1, 1],
5126
+ sysDashDot: [3, 1, 1, 1],
5127
+ sysDashDotDot: [3, 1, 1, 1, 1, 1]
5128
+ };
5129
+ var CAP = 4;
5130
+ function strokeAttributes(stroke) {
5131
+ const pattern = stroke.dash ? DASHES[stroke.dash] : void 0;
5132
+ const dash = pattern ? ` stroke-dasharray="${pattern.map((step) => n(step * stroke.width)).join(" ")}"` : "";
5133
+ return `stroke="${esc(stroke.color)}" stroke-width="${n(stroke.width)}"${dash}`;
5134
+ }
5135
+ var segment = (x1, y1, x2, y2, stroke) => `<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" ${stroke}/>`;
5136
+ function trendlines(series, si, xs, ys, plane, out) {
5137
+ for (const trendline of series.trendlines ?? []) {
5138
+ const fit2 = fitChartTrendline(trendline.fit, xs, ys);
5139
+ if (fit2.points.length < 2) continue;
5140
+ const points = fit2.points.map(({ x, y }) => plane(x, y).map(n).join(",")).join(" ");
5141
+ out.push(
5142
+ `<polyline points="${points}" fill="none" ${strokeAttributes(trendline.stroke)} data-chart-part="trendline" data-chart-series="${si}"/>`
5143
+ );
5144
+ }
5145
+ }
5146
+ function errorBar(bars2, at, values, plane, out) {
5147
+ const stroke = strokeAttributes(bars2.stroke);
5148
+ for (const side of ["plus", "minus"]) {
5149
+ if (bars2.barType !== side && bars2.barType !== "both") continue;
5150
+ const amount = chartErrorBarAmount(bars2.amount, values, at.displayIndex, at.sourceIndex, side);
5151
+ const sign = side === "plus" ? 1 : -1;
5152
+ const [x1, y1] = plane(at.x, at.y);
5153
+ const [x2, y2] = bars2.direction === "x" ? plane(at.x + sign * amount, at.y) : plane(at.x, at.y + sign * amount);
5154
+ out.push(segment(x1, y1, x2, y2, stroke));
5155
+ if (!bars2.endCap) continue;
5156
+ if (x1 === x2) out.push(segment(x2 - CAP, y2, x2 + CAP, y2, stroke));
5157
+ else out.push(segment(x2, y2 - CAP, x2, y2 + CAP, stroke));
5158
+ }
5159
+ }
5160
+ function plottedPoints(series, xOf) {
5161
+ return series.values.flatMap((y, index) => {
5162
+ const x = xOf(index);
5163
+ return y === null || x === null ? [] : [{ x, y, index }];
5164
+ });
5165
+ }
5166
+ function seriesAnalysis(series, si, xOf, plane, barPlane, categoryAxis, out) {
5167
+ const points = plottedPoints(series, xOf);
5168
+ const xs = points.map((p) => p.x);
5169
+ const ys = points.map((p) => p.y);
5170
+ trendlines(series, si, xs, ys, plane, out);
5171
+ for (const bars2 of series.errorBars ?? []) {
5172
+ if (categoryAxis && bars2.direction === "x") continue;
5173
+ const values = bars2.direction === "x" ? xs : ys;
5174
+ points.forEach(
5175
+ (p, displayIndex) => errorBar(bars2, { x: p.x, y: p.y, displayIndex, sourceIndex: p.index }, values, barPlane, out)
5176
+ );
5177
+ }
5178
+ }
5179
+ function categoryAnalysis(model, frame, out) {
5180
+ if (model.grouping === "stacked" || model.grouping === "percentStacked") return;
5181
+ const plane = (x, y) => model.horizontal ? [frame.value(y), frame.band(x - 1)] : [frame.band(x - 1), frame.value(y)];
5182
+ const barred = model.type === "bar" || model.type === "column";
5183
+ const layout = barred ? barLayout(model, frame) : void 0;
5184
+ model.series.forEach((series, si) => {
5185
+ if (!series.trendlines && !series.errorBars) return;
5186
+ const shift = layout ? layout.offset(si) + layout.barSize / 2 : 0;
5187
+ const barPlane = (x, y) => {
5188
+ const [px, py] = plane(x, y);
5189
+ return model.horizontal ? [px, py + shift] : [px + shift, py];
5190
+ };
5191
+ seriesAnalysis(series, si, (i) => i + 1, plane, barPlane, true, out);
5192
+ });
5193
+ }
5194
+ function scatterAnalysis(model, px, py, out) {
5195
+ const plane = (x, y) => [px(x), py(y)];
5196
+ model.series.forEach((series, si) => {
5197
+ if (!series.trendlines && !series.errorBars) return;
5198
+ seriesAnalysis(series, si, (i) => series.xValues?.[i] ?? null, plane, plane, false, out);
5199
+ });
5200
+ }
5201
+
3763
5202
  // chart/render/chart-scale.ts
3764
5203
  var clean = (n2) => Number(n2.toPrecision(12));
3765
5204
  function* units(raw) {
@@ -3826,38 +5265,6 @@ function formatAxisValue(value, percent = false) {
3826
5265
  return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
3827
5266
  }
3828
5267
 
3829
- // chart/render/chart-svg-util.ts
3830
- var TEXT_COLOR = "#595959";
3831
- var GRID_COLOR = "#D9D9D9";
3832
- var AXIS_COLOR = "#BFBFBF";
3833
- var FONT_SIZE = 10;
3834
- function esc(text2) {
3835
- return text2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
3836
- }
3837
- var n = (value) => String(Math.round(value * 100) / 100);
3838
- var textWidth = (text2, size = FONT_SIZE) => text2.length * size * 0.55;
3839
- function text(x, y, content, attrs = {}) {
3840
- const parts = [`x="${n(x)}"`, `y="${n(y)}"`];
3841
- parts.push(`font-size="${attrs.size ?? FONT_SIZE}"`);
3842
- parts.push(`fill="${esc(attrs.fill ?? TEXT_COLOR)}"`);
3843
- if (attrs.anchor && attrs.anchor !== "start") parts.push(`text-anchor="${attrs.anchor}"`);
3844
- if (attrs.weight) parts.push(`font-weight="${attrs.weight}"`);
3845
- if (attrs.baseline) parts.push(`dominant-baseline="${attrs.baseline}"`);
3846
- if (attrs.family) parts.push(`font-family="${esc(attrs.family)}"`);
3847
- if (attrs.filter) parts.push(`filter="${esc(attrs.filter)}"`);
3848
- if (attrs.italic !== void 0) parts.push(`font-style="${attrs.italic ? "italic" : "normal"}"`);
3849
- if (attrs.underline !== void 0)
3850
- parts.push(`text-decoration="${attrs.underline ? "underline" : "none"}"`);
3851
- return `<text ${parts.join(" ")}>${esc(content)}</text>`;
3852
- }
3853
- var line = (x1, y1, x2, y2, stroke, width = 1) => `<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" stroke="${stroke}" stroke-width="${width}"/>`;
3854
- var rect = (x, y, w, h, fill, filter) => `<rect x="${n(x)}" y="${n(y)}" width="${n(Math.max(0, w))}" height="${n(Math.max(0, h))}" fill="${fill}"${filter ? ` filter="${esc(filter)}"` : ""}/>`;
3855
- function fit(content, maxWidth, size = FONT_SIZE) {
3856
- if (textWidth(content, size) <= maxWidth) return content;
3857
- const chars = Math.max(1, Math.floor(maxWidth / (size * 0.55)) - 1);
3858
- return `${content.slice(0, chars)}\u2026`;
3859
- }
3860
-
3861
5268
  // chart/render/theme-palette.ts
3862
5269
  var THEME_SLOTS = [
3863
5270
  "lt1",
@@ -3910,45 +5317,6 @@ function autoSeriesColor(theme, index) {
3910
5317
  return chartPaletteSeriesColor(findChartColorPalette(10), i, i + 1, chartColorScheme(theme));
3911
5318
  }
3912
5319
 
3913
- // chart/render/chart-value-axis.ts
3914
- function valueAxis(model) {
3915
- const stackable = model.type === "bar" || model.type === "column" || model.type === "line" || model.type === "area";
3916
- if (stackable && model.grouping === "percentStacked")
3917
- return { ...PERCENT_SCALE, ticks: [...PERCENT_SCALE.ticks], percent: true };
3918
- let min = Infinity;
3919
- let max = -Infinity;
3920
- if (stackable && model.grouping === "stacked") {
3921
- for (let i = 0; i < model.categories.length; i++) {
3922
- let pos = 0;
3923
- let neg = 0;
3924
- for (const s of model.series) {
3925
- const v = s.values[i] ?? 0;
3926
- if (v >= 0) pos += v;
3927
- else neg += v;
3928
- }
3929
- min = Math.min(min, neg);
3930
- max = Math.max(max, pos);
3931
- }
3932
- } else {
3933
- for (const s of model.series)
3934
- for (const v of s.values)
3935
- if (v !== null) {
3936
- min = Math.min(min, v);
3937
- max = Math.max(max, v);
3938
- }
3939
- }
3940
- if (min === Infinity) {
3941
- min = 0;
3942
- max = 1;
3943
- }
3944
- return { ...niceScale(min, max), percent: false };
3945
- }
3946
- function categoryTotals(model) {
3947
- return model.categories.map(
3948
- (_, i) => model.series.reduce((sum, s) => sum + Math.abs(s.values[i] ?? 0), 0)
3949
- );
3950
- }
3951
-
3952
5320
  // chart/text-inheritance.ts
3953
5321
  var TEXT_KEYS = [
3954
5322
  "fontSize",
@@ -4037,6 +5405,218 @@ function chartAppearance(chart, theme) {
4037
5405
  return out;
4038
5406
  }
4039
5407
 
5408
+ // chart/render/chart-view-analysis.ts
5409
+ function strokeOf(line2, fallback, resolve) {
5410
+ if (line2?.fill?.kind === "none") return void 0;
5411
+ const color = (line2?.fill?.kind === "solid" ? resolve(line2.fill.color) : void 0) ?? fallback.color;
5412
+ const width = line2?.widthEmu === void 0 ? fallback.width : chartPointsToPixels(line2.widthEmu / 12700);
5413
+ const dash = line2?.dash ?? fallback.dash;
5414
+ return { color, width, ...dash && dash !== "solid" ? { dash } : {} };
5415
+ }
5416
+ function analysisView(source, seriesColor, resolve) {
5417
+ const plain = seriesColor === "none" || seriesColor.startsWith("url(") ? TEXT_COLOR : seriesColor;
5418
+ const trendlines2 = (source.trendlines ?? []).flatMap((entry) => {
5419
+ const { name: _name, line: line2, ...fit2 } = entry;
5420
+ const fallback = { color: plain, width: chartPointsToPixels(1.5), dash: "sysDot" };
5421
+ const stroke = strokeOf(line2, fallback, resolve);
5422
+ return stroke ? [{ fit: fit2, stroke }] : [];
5423
+ });
5424
+ const errorBars = (source.errorBars ?? []).flatMap((entry) => {
5425
+ const { direction, barType, noEndCap, line: line2, ...amount } = entry;
5426
+ const stroke = strokeOf(line2, { color: TEXT_COLOR, width: chartPointsToPixels(0.75) }, resolve);
5427
+ return stroke ? [{ direction, barType, amount, endCap: noEndCap !== true, stroke }] : [];
5428
+ });
5429
+ return {
5430
+ ...trendlines2.length ? { trendlines: trendlines2 } : {},
5431
+ ...errorBars.length ? { errorBars } : {}
5432
+ };
5433
+ }
5434
+
5435
+ // chart/render/chart-view-series.ts
5436
+ var isRefError = (value) => typeof value === "object" && value !== null && "error" in value;
5437
+ function toText(value) {
5438
+ if (value === null) return "";
5439
+ if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
5440
+ if (isRefError(value)) return value.error;
5441
+ return String(value);
5442
+ }
5443
+ var toNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
5444
+ function resolveRef(ref, evaluateRef) {
5445
+ if (!ref) return void 0;
5446
+ try {
5447
+ const values = evaluateRef(ref);
5448
+ return values.length ? values : void 0;
5449
+ } catch {
5450
+ return void 0;
5451
+ }
5452
+ }
5453
+ function seriesName(series, index, evaluateRef) {
5454
+ const fromRef = resolveRef(series.nameRef, evaluateRef)?.map(toText).filter((t) => t !== "").join(" ");
5455
+ return fromRef || series.name || `Series${index + 1}`;
5456
+ }
5457
+ function seriesContext(chart, theme, options) {
5458
+ const scheme = chartColorScheme(theme);
5459
+ const resolver = { scheme: (name) => scheme[name] };
5460
+ return {
5461
+ theme,
5462
+ scheme,
5463
+ palette: chart.colorPalette === void 0 ? void 0 : findChartColorPalette(chart.colorPalette),
5464
+ evaluateRef: options.evaluateRef ?? (() => []),
5465
+ seriesColor: options.seriesColor,
5466
+ drawingColor: (color) => color && drawingColorCss(resolveDrawingColor(color, resolver, { transformOrder: "document" })),
5467
+ gradient: (fill) => fill?.kind === "gradient" ? resolveChartGradient(
5468
+ fill,
5469
+ (color) => resolveDrawingColor(color, resolver, { transformOrder: "document" })
5470
+ ) : void 0
5471
+ };
5472
+ }
5473
+ function seriesView(ctx, s, index, total, categoriesOf) {
5474
+ const { theme, scheme, palette, evaluateRef } = ctx;
5475
+ const values = resolveRef(s.valuesRef, evaluateRef)?.map(toNumber) ?? s.values.map(toNumber);
5476
+ categoriesOf(resolveRef(s.categoriesRef, evaluateRef) ?? s.categories);
5477
+ const paletteColor = palette && chartPaletteSeriesColor(palette, index, total, scheme);
5478
+ const color = s.fill?.kind === "none" ? "none" : ctx.drawingColor(s.fill?.kind === "solid" ? s.fill.color : s.drawingColor) ?? ctx.seriesColor?.(s, index) ?? paletteColor ?? autoSeriesColor(theme, index);
5479
+ const view = { name: seriesName(s, index, evaluateRef), values, color };
5480
+ const shadow = resolveDrawingShadowXml(s.effectsXml, { scheme: (name) => scheme[name] });
5481
+ if (shadow) view.shadow = shadow;
5482
+ const resolvedGradient = ctx.gradient(s.fill);
5483
+ if (resolvedGradient) view.gradient = resolvedGradient;
5484
+ const points = Object.fromEntries(
5485
+ Object.entries(s.pointFills ?? {}).flatMap(([key, fill]) => {
5486
+ const value = ctx.gradient(fill);
5487
+ return value ? [[key, value]] : [];
5488
+ })
5489
+ );
5490
+ if (Object.keys(points).length) view.pointGradients = points;
5491
+ Object.assign(view, analysisView(s, color, ctx.drawingColor));
5492
+ return view;
5493
+ }
5494
+
5495
+ // chart/render/chart-view-families.ts
5496
+ function bubbleView(chart, model, evaluateRef) {
5497
+ chart.series.forEach((source, i) => {
5498
+ const view = model.series[i];
5499
+ if (!view) return;
5500
+ const live = resolveRef(source.bubbleSizesRef, evaluateRef)?.map(toNumber);
5501
+ const sizes = live ?? source.bubbleSizes;
5502
+ if (sizes) view.sizes = sizes;
5503
+ });
5504
+ model.bubble = {
5505
+ sizeRepresents: chart.bubble?.sizeRepresents ?? "area",
5506
+ ...chart.bubble?.bubbleScale === void 0 ? {} : { bubbleScale: chart.bubble.bubbleScale },
5507
+ showNegativeBubbles: chart.bubble?.showNegativeBubbles === true
5508
+ };
5509
+ }
5510
+ var columnNumber = (letters) => [...letters].reduce((n2, ch) => n2 * 26 + ch.charCodeAt(0) - 64, 0);
5511
+ function refColumns(ref) {
5512
+ const match = /\$?([A-Z]{1,3})\$?\d+:\$?([A-Z]{1,3})\$?\d+\s*$/i.exec(ref);
5513
+ if (!match) return 1;
5514
+ return Math.max(
5515
+ 1,
5516
+ columnNumber((match[2] ?? "").toUpperCase()) - columnNumber((match[1] ?? "").toUpperCase()) + 1
5517
+ );
5518
+ }
5519
+ function liveLevels(ref, evaluateRef) {
5520
+ const columns = ref ? refColumns(ref) : 1;
5521
+ const flat = columns > 1 ? resolveRef(ref, evaluateRef)?.map(toText) : void 0;
5522
+ if (!flat || flat.length % columns !== 0) return void 0;
5523
+ const levels = Array.from({ length: columns }, () => []);
5524
+ flat.forEach((label, i) => levels[columns - 1 - i % columns]?.push(label));
5525
+ return levels;
5526
+ }
5527
+ function hierarchyView(chart, model, evaluateRef) {
5528
+ const first3 = model.series[0];
5529
+ const live = liveLevels(chart.series[0]?.categoriesRef, evaluateRef);
5530
+ if (live?.[0]) model.categories = live[0];
5531
+ const count = Math.max(first3?.values.length ?? 0, model.categories.length);
5532
+ const supplied = live ?? chart.hierarchy?.levels ?? [];
5533
+ const levels = supplied.length > 1 ? normalizeLevels(supplied, count) : [];
5534
+ model.hierarchy = {
5535
+ levels,
5536
+ parentLabelLayout: chart.hierarchy?.parentLabelLayout ?? "banner",
5537
+ labels: chart.hierarchy?.dataLabels !== false,
5538
+ branches: hierarchyBranchLabels(
5539
+ model.series.map((s) => ({ name: s.name, values: s.values.map((v) => v ?? 0) })),
5540
+ model.categories,
5541
+ levels.length > 1 ? levels : void 0
5542
+ )
5543
+ };
5544
+ }
5545
+
5546
+ // chart/render/chart-view-stock.ts
5547
+ var EMU_PER_PX = 9525;
5548
+ function paintOf(fill, ctx) {
5549
+ if (fill?.kind === "none") return "none";
5550
+ return fill?.kind === "solid" ? ctx.drawingColor(fill.color) : void 0;
5551
+ }
5552
+ function lineOf(shape, ctx, color) {
5553
+ const line2 = shape?.line;
5554
+ return {
5555
+ color: paintOf(line2?.fill, ctx) ?? color,
5556
+ width: line2?.widthEmu === void 0 ? 1 : Math.max(0.5, line2.widthEmu / EMU_PER_PX)
5557
+ };
5558
+ }
5559
+ function barOf(shape, ctx, fallback) {
5560
+ const stroke = lineOf(shape, ctx, "#404040");
5561
+ return {
5562
+ fill: paintOf(shape?.fill, ctx) ?? fallback,
5563
+ stroke: stroke.color,
5564
+ strokeWidth: stroke.width
5565
+ };
5566
+ }
5567
+ function stockView(style, ctx) {
5568
+ return {
5569
+ wick: lineOf(style?.hiLowLines, ctx, STOCK_DEFAULT_WICK_COLOR),
5570
+ up: barOf(style?.upBars, ctx, STOCK_DEFAULT_UP_FILL),
5571
+ down: barOf(style?.downBars, ctx, STOCK_DEFAULT_DOWN_FILL),
5572
+ bodyShare: 1 / (1 + Math.max(0, style?.gapWidth ?? 150) / 100)
5573
+ };
5574
+ }
5575
+
5576
+ // chart/render/chart-value-axis.ts
5577
+ function valueExtent(type, grouping, series, categories) {
5578
+ const stackable = type === "bar" || type === "column" || type === "line" || type === "area";
5579
+ let min = Infinity;
5580
+ let max = -Infinity;
5581
+ if (stackable && grouping === "stacked") {
5582
+ for (let i = 0; i < categories; i++) {
5583
+ let pos = 0;
5584
+ let neg = 0;
5585
+ for (const s of series) {
5586
+ const v = s.values[i] ?? 0;
5587
+ if (v >= 0) pos += v;
5588
+ else neg += v;
5589
+ }
5590
+ min = Math.min(min, neg);
5591
+ max = Math.max(max, pos);
5592
+ }
5593
+ } else {
5594
+ for (const s of series)
5595
+ for (const v of s.values)
5596
+ if (v !== null) {
5597
+ min = Math.min(min, v);
5598
+ max = Math.max(max, v);
5599
+ }
5600
+ }
5601
+ return { min, max };
5602
+ }
5603
+ function valueAxis(model) {
5604
+ const stackable = model.type === "bar" || model.type === "column" || model.type === "line" || model.type === "area";
5605
+ if (stackable && model.grouping === "percentStacked")
5606
+ return { ...PERCENT_SCALE, ticks: [...PERCENT_SCALE.ticks], percent: true };
5607
+ let { min, max } = valueExtent(model.type, model.grouping, model.series, model.categories.length);
5608
+ if (min === Infinity) {
5609
+ min = 0;
5610
+ max = 1;
5611
+ }
5612
+ return { ...niceScale(min, max), percent: false };
5613
+ }
5614
+ function categoryTotals(model) {
5615
+ return model.categories.map(
5616
+ (_, i) => model.series.reduce((sum, s) => sum + Math.abs(s.values[i] ?? 0), 0)
5617
+ );
5618
+ }
5619
+
4040
5620
  // chart/render/chart-title-text.ts
4041
5621
  function properties(run) {
4042
5622
  return {
@@ -4081,8 +5661,87 @@ function chartTitleText(chart, theme) {
4081
5661
  };
4082
5662
  }
4083
5663
 
5664
+ // chart/render/chart-view-ex.ts
5665
+ function groupsAxis(groups, categories) {
5666
+ let min = Infinity;
5667
+ let max = -Infinity;
5668
+ for (const group of groups) {
5669
+ const extent = valueExtent(group.type, group.grouping, group.series, categories);
5670
+ min = Math.min(min, extent.min);
5671
+ max = Math.max(max, extent.max);
5672
+ }
5673
+ return min === Infinity ? { ...niceScale(0, 1), percent: false } : { ...niceScale(min, max), percent: false };
5674
+ }
5675
+ function chartExtraView(chart, model, ctx, total, categoriesOf) {
5676
+ let index = chart.series.length;
5677
+ const groups = [];
5678
+ for (const group of chart.extraGroups ?? []) {
5679
+ const series = group.series.map((s) => seriesView(ctx, s, index++, total, categoriesOf));
5680
+ const view = {
5681
+ type: group.chartType,
5682
+ grouping: group.grouping ?? (group.chartType === "column" ? "clustered" : "standard"),
5683
+ series,
5684
+ secondary: group.secondary
5685
+ };
5686
+ if (group.chartType === "stock") view.stock = stockView(group.stock, ctx);
5687
+ if (group.barGapWidth !== void 0) view.barGapWidth = group.barGapWidth;
5688
+ if (group.barOverlap !== void 0) view.barOverlap = group.barOverlap;
5689
+ groups.push(view);
5690
+ }
5691
+ if (!groups.length) return;
5692
+ model.extraGroups = groups;
5693
+ }
5694
+ function chartExtraAxes(model) {
5695
+ const groups = model.extraGroups;
5696
+ if (!groups || !model.valueAxis) return;
5697
+ const count = model.categories.length;
5698
+ const secondary = groups.filter((g) => g.secondary);
5699
+ if (secondary.length) model.secondaryAxis = groupsAxis(secondary, count);
5700
+ const shared = groups.filter((g) => !g.secondary);
5701
+ if (!shared.length || model.valueAxis.percent) return;
5702
+ const own2 = valueExtent(model.type, model.grouping, model.series, count);
5703
+ let min = own2.min;
5704
+ let max = own2.max;
5705
+ for (const group of shared) {
5706
+ const extent = valueExtent(group.type, group.grouping, group.series, count);
5707
+ min = Math.min(min, extent.min);
5708
+ max = Math.max(max, extent.max);
5709
+ }
5710
+ model.valueAxis = { ...niceScale(min, max), percent: false };
5711
+ }
5712
+ function waterfallView(chart, model, ctx) {
5713
+ const values = (model.series[0]?.values ?? []).map((v) => v ?? 0);
5714
+ const steps = buildWaterfallSteps(values, chart.waterfall);
5715
+ const role = (i) => ctx.palette && chartPaletteSeriesColor(ctx.palette, i, 3, ctx.scheme) || autoSeriesColor(ctx.theme, i);
5716
+ model.waterfall = {
5717
+ steps,
5718
+ connectors: chart.waterfall?.connectorLines !== false,
5719
+ colors: { increase: role(0), decrease: role(1), total: role(2) }
5720
+ };
5721
+ const ends = steps.flatMap((step) => [step.startValue, step.endValue]);
5722
+ model.valueAxis = {
5723
+ ...ends.length ? niceScale(Math.min(...ends), Math.max(...ends)) : niceScale(0, 1),
5724
+ percent: false
5725
+ };
5726
+ const labels = model.categories;
5727
+ model.categories = steps.map((_, i) => labels[i] ?? String(i + 1));
5728
+ }
5729
+ function histogramView(chart, model) {
5730
+ const first3 = model.series[0];
5731
+ if (!first3) return;
5732
+ const raw = first3.values.map((v) => v ?? Number.NaN);
5733
+ const options = chart.histogram ?? {};
5734
+ const bins = options.aggregateByCategory ? aggregateByCategory(
5735
+ first3.values.map((v) => v ?? 0),
5736
+ model.categories
5737
+ ) : computeHistogramBins(raw, options, formatAxisValue);
5738
+ model.categories = bins.map((bin) => bin.label);
5739
+ first3.values = bins.map((bin) => bin.value);
5740
+ model.barGapWidth = 0;
5741
+ model.barOverlap = 0;
5742
+ }
5743
+
4084
5744
  // chart/render/chart-view.ts
4085
- var isRefError = (value) => typeof value === "object" && value !== null && "error" in value;
4086
5745
  var SUPPORTED = /* @__PURE__ */ new Set([
4087
5746
  "bar",
4088
5747
  "column",
@@ -4091,85 +5750,37 @@ var SUPPORTED = /* @__PURE__ */ new Set([
4091
5750
  "pie",
4092
5751
  "doughnut",
4093
5752
  "scatter",
4094
- "radar"
5753
+ "radar",
5754
+ "waterfall",
5755
+ "histogram",
5756
+ "bubble",
5757
+ "stock",
5758
+ "treemap",
5759
+ "sunburst"
4095
5760
  ]);
4096
- function toText(value) {
4097
- if (value === null) return "";
4098
- if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
4099
- if (isRefError(value)) return value.error;
4100
- return String(value);
4101
- }
4102
- var toNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
4103
- function resolveRef(ref, evaluateRef) {
4104
- if (!ref) return void 0;
4105
- try {
4106
- const values = evaluateRef(ref);
4107
- return values.length ? values : void 0;
4108
- } catch {
4109
- return void 0;
4110
- }
4111
- }
4112
- function seriesName(series, index, evaluateRef) {
4113
- const fromRef = resolveRef(series.nameRef, evaluateRef)?.map(toText).filter((t) => t !== "").join(" ");
4114
- return fromRef || series.name || `Series${index + 1}`;
4115
- }
4116
5761
  function chartSummaryView(chart, theme, options = {}) {
4117
- const evaluateRef = options.evaluateRef ?? (() => []);
4118
5762
  const type = chart.chartType;
4119
5763
  const radial = type === "pie" || type === "doughnut";
4120
- const palette = chart.colorPalette === void 0 ? void 0 : findChartColorPalette(chart.colorPalette);
4121
- const scheme = chartColorScheme(theme);
4122
- const drawingColor = (color) => color && drawingColorCss(
4123
- resolveDrawingColor(
4124
- color,
4125
- {
4126
- scheme: (name) => scheme[name]
4127
- },
4128
- { transformOrder: "document" }
4129
- )
4130
- );
4131
- const gradient = (fill) => fill?.kind === "gradient" ? resolveChartGradient(
4132
- fill,
4133
- (color) => resolveDrawingColor(
4134
- color,
4135
- {
4136
- scheme: (name) => scheme[name]
4137
- },
4138
- { transformOrder: "document" }
4139
- )
4140
- ) : void 0;
5764
+ const byPoint = radial || type === "treemap" || type === "sunburst";
5765
+ const ctx = seriesContext(chart, theme, options);
5766
+ const { palette, scheme, drawingColor } = ctx;
4141
5767
  const grouping = chart.grouping ?? (type === "bar" || type === "column" ? "clustered" : "standard");
4142
- let categories = [];
4143
5768
  const rawCategories = [];
4144
- const series = chart.series.map((s, i) => {
4145
- const values = resolveRef(s.valuesRef, evaluateRef)?.map(toNumber) ?? s.values.map(toNumber);
4146
- const cats = resolveRef(s.categoriesRef, evaluateRef) ?? s.categories;
4147
- rawCategories.push(cats);
4148
- const paletteColor = palette && chartPaletteSeriesColor(palette, i, chart.series.length, scheme);
4149
- const color = s.fill?.kind === "none" ? "none" : drawingColor(s.fill?.kind === "solid" ? s.fill.color : s.drawingColor) ?? options.seriesColor?.(s, i) ?? paletteColor ?? autoSeriesColor(theme, i);
4150
- const view = { name: seriesName(s, i, evaluateRef), values, color };
4151
- const shadow = resolveDrawingShadowXml(s.effectsXml, {
4152
- scheme: (name) => scheme[name]
4153
- });
4154
- if (shadow) view.shadow = shadow;
4155
- const resolvedGradient = gradient(s.fill);
4156
- if (resolvedGradient) view.gradient = resolvedGradient;
4157
- const points = Object.fromEntries(
4158
- Object.entries(s.pointFills ?? {}).flatMap(([key, fill]) => {
4159
- const value = gradient(fill);
4160
- return value ? [[key, value]] : [];
4161
- })
4162
- );
4163
- if (Object.keys(points).length) view.pointGradients = points;
4164
- return view;
4165
- });
4166
- const longest = Math.max(0, ...series.map((s) => s.values.length));
5769
+ const collect = (cats) => void rawCategories.push(cats);
5770
+ const extra = chart.extraGroups ?? [];
5771
+ const total = chart.series.length + extra.reduce((n2, g) => n2 + g.series.length, 0);
5772
+ const series = chart.series.map((s, i) => seriesView(ctx, s, i, total, collect));
5773
+ const longest = Math.max(
5774
+ 0,
5775
+ ...series.map((s) => s.values.length),
5776
+ ...extra.flatMap((g) => g.series.map((s) => s.values.length))
5777
+ );
4167
5778
  const firstCats = rawCategories.find((c) => c.length > 0) ?? [];
4168
- categories = Array.from(
5779
+ const categories = Array.from(
4169
5780
  { length: Math.max(longest, firstCats.length) },
4170
5781
  (_, i) => firstCats[i] !== void 0 ? toText(firstCats[i] ?? null) : String(i + 1)
4171
5782
  );
4172
- if (radial) {
5783
+ if (byPoint) {
4173
5784
  series.forEach((s, seriesIndex) => {
4174
5785
  s.pointColors = s.values.map((_, i) => {
4175
5786
  const explicit = drawingColor(chart.series[seriesIndex]?.pointColors?.[i]);
@@ -4190,8 +5801,8 @@ function chartSummaryView(chart, theme, options = {}) {
4190
5801
  for (const [key, fill] of Object.entries(source.pointFills ?? {})) {
4191
5802
  if (fill.kind === "none") (s.pointColors ??= [])[Number(key)] = "none";
4192
5803
  else if (fill.kind === "solid") {
4193
- const paint = drawingColor(fill.color);
4194
- if (paint) (s.pointColors ??= [])[Number(key)] = paint;
5804
+ const paint2 = drawingColor(fill.color);
5805
+ if (paint2) (s.pointColors ??= [])[Number(key)] = paint2;
4195
5806
  }
4196
5807
  }
4197
5808
  });
@@ -4218,7 +5829,7 @@ function chartSummaryView(chart, theme, options = {}) {
4218
5829
  if (titleText) model.titleText = titleText;
4219
5830
  const appearance = chartAppearance(chart, theme);
4220
5831
  if (appearance) model.appearance = appearance;
4221
- if (type === "scatter") {
5832
+ if (type === "scatter" || type === "bubble") {
4222
5833
  series.forEach((s, i) => {
4223
5834
  const cats = rawCategories[i] ?? [];
4224
5835
  const numeric = cats.length > 0 && cats.every((c) => typeof c === "number");
@@ -4227,7 +5838,15 @@ function chartSummaryView(chart, theme, options = {}) {
4227
5838
  const xs = series.flatMap((s) => s.xValues ?? []).filter((x) => x !== null);
4228
5839
  model.xAxis = xs.length ? niceScale(Math.min(...xs), Math.max(...xs)) : niceScale(0, 1);
4229
5840
  }
4230
- if (!radial) model.valueAxis = valueAxis(model);
5841
+ if (type === "stock") model.stock = stockView(chart.stock, ctx);
5842
+ if (type === "bubble") bubbleView(chart, model, ctx.evaluateRef);
5843
+ if (type === "treemap" || type === "sunburst") hierarchyView(chart, model, ctx.evaluateRef);
5844
+ if (type === "histogram") histogramView(chart, model);
5845
+ if (extra.length && (type === "column" || type === "line" || type === "area"))
5846
+ chartExtraView(chart, model, ctx, total, collect);
5847
+ if (type === "waterfall") waterfallView(chart, model, ctx);
5848
+ else if (!byPoint) model.valueAxis = valueAxis(model);
5849
+ chartExtraAxes(model);
4231
5850
  return model;
4232
5851
  }
4233
5852
 
@@ -4269,7 +5888,7 @@ function chartGradientPaint(model, width = 1024, height = 768) {
4269
5888
  textShadowFilter: shadowPaint(entry.textShadow, `${part}-text-shadow`)
4270
5889
  };
4271
5890
  }
4272
- const paint = (gradient, suffix, bounds) => {
5891
+ const paint2 = (gradient, suffix, bounds) => {
4273
5892
  const def = buildChartGradientDef(`${prefix}-${suffix}`, gradient, bounds);
4274
5893
  defs.push(chartGradientMarkup(def));
4275
5894
  return `url(#${def.id})`;
@@ -4280,18 +5899,18 @@ function chartGradientPaint(model, width = 1024, height = 768) {
4280
5899
  if (part === "plotArea" && ["circle", "shape"].includes(entry.gradient.path ?? "")) continue;
4281
5900
  appearance[part] = {
4282
5901
  ...entry,
4283
- fillColor: paint(entry.gradient, part, { width, height, shape: "rect" })
5902
+ fillColor: paint2(entry.gradient, part, { width, height, shape: "rect" })
4284
5903
  };
4285
5904
  }
4286
5905
  const series = model.series.map((source, index) => {
4287
5906
  const view = { ...source };
4288
5907
  if (source.shadow) view.shadowFilter = shadowPaint(source.shadow, `s${index}-shadow`);
4289
5908
  const bounds = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
4290
- if (source.gradient) view.color = paint(source.gradient, `s${index}`, bounds);
5909
+ if (source.gradient) view.color = paint2(source.gradient, `s${index}`, bounds);
4291
5910
  if (source.pointGradients) {
4292
5911
  view.pointColors = [...source.pointColors ?? []];
4293
5912
  for (const [key, gradient] of Object.entries(source.pointGradients))
4294
- view.pointColors[Number(key)] = paint(gradient, `s${index}-p${key}`, bounds);
5913
+ view.pointColors[Number(key)] = paint2(gradient, `s${index}-p${key}`, bounds);
4295
5914
  }
4296
5915
  return view;
4297
5916
  });
@@ -4336,72 +5955,8 @@ function chartAreaRect(model, part, area) {
4336
5955
  return `${defs}<rect x="${n(area.x)}" y="${n(area.y)}" width="${n(area.w)}" height="${n(area.h)}" fill="${esc(fill)}" stroke="${esc(stroke)}" stroke-width="${n(width)}" data-chart-part="${part}"/>`;
4337
5956
  }
4338
5957
 
4339
- // chart/render/chart-spacing.ts
4340
- function chartBarSpacing(chart) {
4341
- const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
4342
- return {
4343
- barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
4344
- barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
4345
- };
4346
- }
4347
-
4348
- // chart/render/chart-svg-bars.ts
4349
- function bars(model, frame, out, values) {
4350
- const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
4351
- const count = Math.max(1, model.series.length);
4352
- const geometry = clusteredBarGeometry(frame.bandSize, count, chartBarSpacing(model));
4353
- const barSize = geometry.singleBarWidth;
4354
- const base = frame.value(0);
4355
- const pos = new Array(model.categories.length).fill(0);
4356
- const neg = new Array(model.categories.length).fill(0);
4357
- model.series.forEach((s, si) => {
4358
- values[si]?.forEach((v, i) => {
4359
- if (v === null || i >= model.categories.length) return;
4360
- let from = 0;
4361
- let to = v;
4362
- if (stacked) {
4363
- const acc = v >= 0 ? pos : neg;
4364
- from = acc[i] ?? 0;
4365
- to = from + v;
4366
- acc[i] = to;
4367
- }
4368
- const a = stacked ? frame.value(from) : base;
4369
- const b = frame.value(to);
4370
- const offset = model.horizontal ? geometry.clusterWidth / 2 - barSize - si * geometry.step : -geometry.clusterWidth / 2 + si * geometry.step;
4371
- const center = frame.band(i);
4372
- const width = model.horizontal ? Math.abs(b - a) : barSize;
4373
- const height = model.horizontal ? barSize : Math.abs(b - a);
4374
- let color = s.pointColors?.[i] ?? s.color;
4375
- const gradient = s.pointGradients?.[i] ?? (s.pointColors?.[i] === void 0 ? s.gradient : void 0);
4376
- if (gradient && (gradient.path === "circle" || gradient.path === "shape")) {
4377
- const baseId = color.match(/^url\(#(.+)\)$/)?.[1];
4378
- if (baseId) {
4379
- const id = baseId.replace(/(-s\d+(?:-p\d+)?)$/, `-mark${i}$1`);
4380
- const def = buildChartGradientDef(id, gradient, {
4381
- width: Number(n(width)),
4382
- height: Number(n(height)),
4383
- shape: "rect"
4384
- });
4385
- out.push(`<defs>${chartGradientMarkup(def)}</defs>`);
4386
- color = `url(#${id})`;
4387
- }
4388
- }
4389
- out.push(`<g data-chart-series="${si}" data-chart-point="${i}">`);
4390
- if (model.horizontal)
4391
- out.push(
4392
- rect(Math.min(a, b), center + offset, Math.abs(b - a), barSize, color, s.shadowFilter)
4393
- );
4394
- else
4395
- out.push(
4396
- rect(center + offset, Math.min(a, b), barSize, Math.abs(b - a), color, s.shadowFilter)
4397
- );
4398
- out.push("</g>");
4399
- });
4400
- });
4401
- }
4402
-
4403
5958
  // chart/render/chart-svg-cartesian.ts
4404
- function axes(model, area, out) {
5959
+ function cartesianAxes(model, area, out) {
4405
5960
  const scale = model.valueAxis;
4406
5961
  if (!scale) return void 0;
4407
5962
  const labels = scale.ticks.map((t) => formatAxisValue(t, scale.percent));
@@ -4420,6 +5975,9 @@ function axes(model, area, out) {
4420
5975
  area.w * 0.3,
4421
5976
  Math.max(...model.categories.map((c) => textWidth(c, categorySize)), 8) + 6
4422
5977
  );
5978
+ const second = horizontal ? void 0 : model.secondaryAxis;
5979
+ const secondLabels = second?.ticks.map((t) => formatAxisValue(t, second.percent)) ?? [];
5980
+ const secondW = second ? valueLabels ? Math.max(...secondLabels.map((l) => textWidth(l, valueSize)), 8) + 8 : 4 : 0;
4423
5981
  const plot = horizontal ? {
4424
5982
  x: area.x + catW,
4425
5983
  y: area.y,
@@ -4428,7 +5986,7 @@ function axes(model, area, out) {
4428
5986
  } : {
4429
5987
  x: area.x + labelW,
4430
5988
  y: area.y + 4,
4431
- w: Math.max(1, area.w - labelW - 4),
5989
+ w: Math.max(1, area.w - labelW - 4 - secondW),
4432
5990
  h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
4433
5991
  };
4434
5992
  const span = scale.max - scale.min || 1;
@@ -4476,7 +6034,32 @@ function axes(model, area, out) {
4476
6034
  })
4477
6035
  );
4478
6036
  });
4479
- return { plot, value, band, bandSize };
6037
+ const frame = { plot, value, band, bandSize };
6038
+ if (second) {
6039
+ const secondSpan = second.max - second.min || 1;
6040
+ frame.secondary = (v) => plot.y + plot.h - (v - second.min) / secondSpan * plot.h;
6041
+ const secondAxis = chartStroke(model, "valueAxis");
6042
+ out.push(
6043
+ line(
6044
+ plot.x + plot.w,
6045
+ plot.y,
6046
+ plot.x + plot.w,
6047
+ plot.y + plot.h,
6048
+ secondAxis.color,
6049
+ secondAxis.width
6050
+ )
6051
+ );
6052
+ if (valueLabels)
6053
+ second.ticks.forEach(
6054
+ (t, i) => out.push(
6055
+ text(plot.x + plot.w + 4, frame.secondary(t) + valueSize * 0.3, secondLabels[i] ?? "", {
6056
+ anchor: "start",
6057
+ ...valueAttrs
6058
+ })
6059
+ )
6060
+ );
6061
+ }
6062
+ return frame;
4480
6063
  }
4481
6064
  function plotted(model) {
4482
6065
  if (model.grouping !== "percentStacked") return model.series.map((s) => s.values);
@@ -4519,17 +6102,17 @@ function linesAndAreas(model, frame, out) {
4519
6102
  out.push(`<polygon points="${poly}" fill="${color}" fill-opacity="0.85"${filter}/>`);
4520
6103
  continue;
4521
6104
  }
4522
- let segment = [];
6105
+ let segment2 = [];
4523
6106
  const flush = () => {
4524
- if (segment.length > 1)
6107
+ if (segment2.length > 1)
4525
6108
  out.push(
4526
- `<polyline points="${segment.join(" ")}" fill="none" stroke="${color}" stroke-width="2.25" stroke-linejoin="round"${filter}/>`
6109
+ `<polyline points="${segment2.join(" ")}" fill="none" stroke="${color}" stroke-width="2.25" stroke-linejoin="round"${filter}/>`
4527
6110
  );
4528
- segment = [];
6111
+ segment2 = [];
4529
6112
  };
4530
6113
  for (const [x, y] of points) {
4531
6114
  if (Number.isNaN(x)) flush();
4532
- else segment.push(`${n(x)},${n(y)}`);
6115
+ else segment2.push(`${n(x)},${n(y)}`);
4533
6116
  }
4534
6117
  flush();
4535
6118
  for (const [x, y] of points)
@@ -4537,6 +6120,8 @@ function linesAndAreas(model, frame, out) {
4537
6120
  out.push(`<circle cx="${n(x)}" cy="${n(y)}" r="2.5" fill="${color}"${filter}/>`);
4538
6121
  }
4539
6122
  }
6123
+
6124
+ // chart/render/chart-svg-xy.ts
4540
6125
  function scatter(model, area, out) {
4541
6126
  const ys = model.valueAxis;
4542
6127
  const xs = model.xAxis;
@@ -4558,26 +6143,42 @@ function scatter(model, area, out) {
4558
6143
  w: Math.max(1, area.w - labelW - 8),
4559
6144
  h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
4560
6145
  };
4561
- const px = (v, s) => plot.x + (v - s.min) / (s.max - s.min || 1) * plot.w;
4562
- const py = (v, s) => plot.y + plot.h - (v - s.min) / (s.max - s.min || 1) * plot.h;
6146
+ const bubble = model.type === "bubble" ? model.bubble : void 0;
6147
+ const biggest = maxBubbleSize(
6148
+ model.series.flatMap((s) => (s.sizes ?? []).filter((v) => v !== null))
6149
+ );
6150
+ const median = medianBubbleRadius(plot.w, plot.h);
6151
+ const radiusOf = (size) => bubble && !(size !== void 0 && size < 0 && !bubble.showNegativeBubbles) ? computeBubbleRadius(size, biggest, median, bubble) : void 0;
6152
+ let reach = 0;
6153
+ if (bubble)
6154
+ for (const s of model.series)
6155
+ s.values.forEach((_, i) => {
6156
+ reach = Math.max(reach, radiusOf(s.sizes?.[i] ?? void 0) ?? 0);
6157
+ });
6158
+ const widen = (s, length) => {
6159
+ const pad = reach * (s.max - s.min || 1) / Math.max(1, length - 2 * reach);
6160
+ return { ...s, min: s.min - pad, max: s.max + pad };
6161
+ };
6162
+ const xView = widen(xs, plot.w);
6163
+ const yView = widen(ys, plot.h);
6164
+ const px = (v) => plot.x + (v - xView.min) / (xView.max - xView.min || 1) * plot.w;
6165
+ const py = (v) => plot.y + plot.h - (v - yView.min) / (yView.max - yView.min || 1) * plot.h;
4563
6166
  out.push(chartAreaRect(model, "plotArea", plot));
4564
6167
  ys.ticks.forEach((t, i) => {
4565
- out.push(line(plot.x, py(t, ys), plot.x + plot.w, py(t, ys), grid.color, grid.width));
6168
+ out.push(line(plot.x, py(t), plot.x + plot.w, py(t), grid.color, grid.width));
4566
6169
  if (valueLabels)
4567
6170
  out.push(
4568
- text(plot.x - 4, py(t, ys) + valueSize * 0.3, yLabels[i] ?? "", {
6171
+ text(plot.x - 4, py(t) + valueSize * 0.3, yLabels[i] ?? "", {
4569
6172
  anchor: "end",
4570
6173
  ...valueAttrs
4571
6174
  })
4572
6175
  );
4573
6176
  });
4574
6177
  for (const t of xs.ticks) {
4575
- out.push(
4576
- line(px(t, xs), plot.y + plot.h, px(t, xs), plot.y + plot.h + 3, xAxis.color, xAxis.width)
4577
- );
6178
+ out.push(line(px(t), plot.y + plot.h, px(t), plot.y + plot.h + 3, xAxis.color, xAxis.width));
4578
6179
  if (categoryLabels)
4579
6180
  out.push(
4580
- text(px(t, xs), plot.y + plot.h + categorySize + 3, formatAxisValue(t), {
6181
+ text(px(t), plot.y + plot.h + categorySize + 3, formatAxisValue(t), {
4581
6182
  anchor: "middle",
4582
6183
  ...categoryAttrs
4583
6184
  })
@@ -4587,25 +6188,159 @@ function scatter(model, area, out) {
4587
6188
  line(plot.x, plot.y + plot.h, plot.x + plot.w, plot.y + plot.h, xAxis.color, xAxis.width)
4588
6189
  );
4589
6190
  out.push(line(plot.x, plot.y, plot.x, plot.y + plot.h, yAxis.color, yAxis.width));
4590
- for (const s of model.series)
6191
+ for (const [si, s] of model.series.entries())
4591
6192
  s.values.forEach((v, i) => {
4592
6193
  const x = s.xValues?.[i] ?? null;
4593
6194
  if (v === null || x === null) return;
6195
+ const filter = s.shadowFilter ? ` filter="${s.shadowFilter}"` : "";
6196
+ const fill = s.pointColors?.[i] ?? s.color;
6197
+ if (!bubble) {
6198
+ out.push(`<circle cx="${n(px(x))}" cy="${n(py(v))}" r="3" fill="${fill}"${filter}/>`);
6199
+ return;
6200
+ }
6201
+ const r = radiusOf(s.sizes?.[i] ?? void 0);
6202
+ if (r === void 0) return;
4594
6203
  out.push(
4595
- `<circle cx="${n(px(x, xs))}" cy="${n(py(v, ys))}" r="3" fill="${s.pointColors?.[i] ?? s.color}"${s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""}/>`
6204
+ `<circle cx="${n(px(x))}" cy="${n(py(v))}" r="${n(r)}" fill="${fill}" fill-opacity="0.6" data-chart-series="${si}" data-chart-point="${i}"${filter}/>`
4596
6205
  );
4597
6206
  });
6207
+ scatterAnalysis(model, px, py, out);
6208
+ }
6209
+
6210
+ // chart/render/chart-svg-stock.ts
6211
+ function stockBars(model, frame, out) {
6212
+ const slots = stockSlots(model.series.length);
6213
+ if (!slots) return;
6214
+ const style = model.stock ?? stockView(void 0, { drawingColor: () => void 0 });
6215
+ const at = (role, i) => role === void 0 ? void 0 : model.series[role]?.values[i];
6216
+ const closeColor = model.series[slots.close]?.color ?? style.wick.color;
6217
+ model.categories.forEach((_, i) => {
6218
+ const candle = stockCandle({
6219
+ x: frame.band(i),
6220
+ band: frame.bandSize,
6221
+ high: at(slots.high, i),
6222
+ low: at(slots.low, i),
6223
+ close: at(slots.close, i),
6224
+ open: at(slots.open, i),
6225
+ hasOpen: slots.open !== void 0,
6226
+ bodyShare: style.bodyShare,
6227
+ y: frame.value
6228
+ });
6229
+ if (!candle) return;
6230
+ out.push(`<g data-chart-series="${slots.close}" data-chart-point="${i}">`);
6231
+ out.push(
6232
+ line(
6233
+ candle.wick.x,
6234
+ candle.wick.y1,
6235
+ candle.wick.x,
6236
+ candle.wick.y2,
6237
+ style.wick.color,
6238
+ style.wick.width
6239
+ )
6240
+ );
6241
+ if (candle.body) {
6242
+ const { x, y, w, h, up } = candle.body;
6243
+ const bar = up ? style.up : style.down;
6244
+ const stroke = bar.stroke === "none" ? "" : ` stroke="${esc(bar.stroke)}" stroke-width="${n(bar.strokeWidth)}"`;
6245
+ out.push(rect(x, y, w, h, bar.fill).replace("/>", `${stroke}/>`));
6246
+ } else if (candle.tick) {
6247
+ out.push(
6248
+ line(
6249
+ candle.tick.x1,
6250
+ candle.tick.y,
6251
+ candle.tick.x2,
6252
+ candle.tick.y,
6253
+ closeColor,
6254
+ STOCK_TICK_WIDTH
6255
+ )
6256
+ );
6257
+ }
6258
+ out.push("</g>");
6259
+ });
6260
+ }
6261
+
6262
+ // chart/render/chart-svg-waterfall.ts
6263
+ var CONNECTOR_COLOR = "#7F7F7F";
6264
+ var BAR_SHARE = 2 / 3;
6265
+ function waterfallBars(model, frame, out) {
6266
+ const view = model.waterfall;
6267
+ if (!view) return;
6268
+ const width = frame.bandSize * BAR_SHARE;
6269
+ view.steps.forEach((step, i) => {
6270
+ const a = frame.value(step.startValue);
6271
+ const b = frame.value(step.endValue);
6272
+ const color = step.isSubtotal ? view.colors.total : step.value >= 0 ? view.colors.increase : view.colors.decrease;
6273
+ const x = frame.band(i) - width / 2;
6274
+ out.push(`<g data-chart-series="0" data-chart-point="${step.sourceIndex}">`);
6275
+ out.push(rect(x, Math.min(a, b), width, Math.max(Math.abs(b - a), 1), color));
6276
+ out.push("</g>");
6277
+ const next = view.steps[i + 1];
6278
+ if (view.connectors && next) {
6279
+ const xNext = frame.band(i + 1) - width / 2;
6280
+ out.push(
6281
+ line(x + width, b, xNext, b, CONNECTOR_COLOR, 0.75).replace(
6282
+ "/>",
6283
+ ` stroke-dasharray="${n(3)} ${n(2)}"/>`
6284
+ )
6285
+ );
6286
+ }
6287
+ });
6288
+ }
6289
+
6290
+ // chart/render/chart-svg-plots.ts
6291
+ var RANK = {
6292
+ area: 0,
6293
+ bar: 1,
6294
+ column: 1,
6295
+ histogram: 1,
6296
+ line: 2,
6297
+ stock: 2
6298
+ };
6299
+ function paint(layer, out) {
6300
+ const { model, frame } = layer;
6301
+ if (model.type === "stock") stockBars(model, frame, out);
6302
+ else if (model.type === "bar" || model.type === "column" || model.type === "histogram")
6303
+ bars(model, frame, out, plotted(model));
6304
+ else linesAndAreas(model, frame, out);
4598
6305
  }
4599
6306
  function cartesianSvg(model, area) {
4600
6307
  const out = [];
4601
- if (model.type === "scatter") {
6308
+ if (model.type === "scatter" || model.type === "bubble") {
4602
6309
  scatter(model, area, out);
4603
6310
  return out.join("");
4604
6311
  }
4605
- const frame = axes(model, area, out);
6312
+ const frame = cartesianAxes(model, area, out);
4606
6313
  if (!frame) return "";
4607
- if (model.type === "bar" || model.type === "column") bars(model, frame, out, plotted(model));
4608
- else linesAndAreas(model, frame, out);
6314
+ if (model.type === "waterfall") {
6315
+ waterfallBars(model, frame, out);
6316
+ return out.join("");
6317
+ }
6318
+ if (model.type === "stock") {
6319
+ stockBars(model, frame, out);
6320
+ return out.join("");
6321
+ }
6322
+ const layers = [{ model, frame }];
6323
+ for (const group of model.extraGroups ?? []) {
6324
+ const grouped = {
6325
+ ...model,
6326
+ type: group.type,
6327
+ grouping: group.grouping,
6328
+ series: group.series,
6329
+ horizontal: false
6330
+ };
6331
+ if (group.stock) grouped.stock = group.stock;
6332
+ else delete grouped.stock;
6333
+ if (group.barGapWidth !== void 0) grouped.barGapWidth = group.barGapWidth;
6334
+ else delete grouped.barGapWidth;
6335
+ if (group.barOverlap !== void 0) grouped.barOverlap = group.barOverlap;
6336
+ else delete grouped.barOverlap;
6337
+ const value = group.secondary && frame.secondary ? frame.secondary : frame.value;
6338
+ layers.push({ model: grouped, frame: { ...frame, value } });
6339
+ }
6340
+ layers.map((layer, order) => ({ layer, order })).sort(
6341
+ (a, b) => (RANK[a.layer.model.type] ?? 1) - (RANK[b.layer.model.type] ?? 1) || a.order - b.order
6342
+ ).forEach(({ layer }) => paint(layer, out));
6343
+ categoryAnalysis(model, frame, out);
4609
6344
  return out.join("");
4610
6345
  }
4611
6346
 
@@ -4707,28 +6442,110 @@ function radarSvg(model, area) {
4707
6442
  return out.join("");
4708
6443
  }
4709
6444
 
6445
+ // chart/render/chart-svg-hierarchy.ts
6446
+ var colorAt2 = (model, index) => {
6447
+ const first3 = model.series[0];
6448
+ const colors = first3?.pointColors;
6449
+ return (colors && colors.length > 0 ? colors[index % colors.length] : void 0) ?? first3?.color ?? "#4472C4";
6450
+ };
6451
+ var leafValues = (model) => (model.series[0]?.values ?? []).map((v) => v ?? 0);
6452
+ function treemapSvg(model, area) {
6453
+ const out = [chartAreaRect(model, "plotArea", area)];
6454
+ const hierarchy = model.hierarchy;
6455
+ const series = model.series.map((s) => ({
6456
+ name: s.name,
6457
+ values: s.values.map((v) => v ?? 0),
6458
+ // Without data labels Office draws no parent banners either, so no space is reserved.
6459
+ parentLabelLayout: hierarchy?.labels === false ? "none" : hierarchy?.parentLabelLayout
6460
+ }));
6461
+ const roots = buildHierarchyRoots(
6462
+ series,
6463
+ model.categories,
6464
+ hierarchy && hierarchy.levels.length > 1 ? hierarchy.levels : void 0
6465
+ );
6466
+ const cells = layoutTreemap(roots, { x: area.x, y: area.y, w: area.w, h: area.h });
6467
+ for (const cell of cells) {
6468
+ if (cell.kind === "parent") {
6469
+ if (hierarchy?.labels !== false)
6470
+ out.push(text(cell.x, cell.y, cell.label, { size: 10, weight: "bold", fill: "#303030" }));
6471
+ continue;
6472
+ }
6473
+ out.push(`<g data-chart-series="${cell.seriesIndex}" data-chart-point="${cell.pointIndex}">`);
6474
+ out.push(
6475
+ rect(cell.x, cell.y, cell.w, cell.h, colorAt2(model, cell.colorIndex)).replace(
6476
+ "/>",
6477
+ ' rx="2"/>'
6478
+ )
6479
+ );
6480
+ if (cell.labelFits && hierarchy?.labels !== false)
6481
+ out.push(
6482
+ text(
6483
+ cell.x + cell.w / 2,
6484
+ cell.y + cell.h / 2,
6485
+ fit(cell.label, cell.w - 4, cell.labelSize),
6486
+ {
6487
+ anchor: "middle",
6488
+ size: cell.labelSize,
6489
+ weight: "bold",
6490
+ fill: "#FFFFFF",
6491
+ baseline: "central"
6492
+ }
6493
+ )
6494
+ );
6495
+ out.push("</g>");
6496
+ }
6497
+ return out.join("");
6498
+ }
6499
+ function sunburstSvg(model, area) {
6500
+ const out = [chartAreaRect(model, "plotArea", area)];
6501
+ const cx = area.x + area.w / 2;
6502
+ const cy = area.y + area.h / 2;
6503
+ const maxR = Math.min(area.w, area.h) / 2 - 4;
6504
+ if (maxR <= 0) return out.join("");
6505
+ const levels = model.hierarchy?.levels ?? [];
6506
+ const arcs = levels.length > 1 ? computeHierarchicalSunburstArcs(levels, leafValues(model), cx, cy, maxR) : computeSunburstArcs(
6507
+ model.series.map((s) => ({ values: s.values.map((v) => v ?? 0) })),
6508
+ cx,
6509
+ cy,
6510
+ maxR
6511
+ );
6512
+ for (const arc of arcs)
6513
+ out.push(
6514
+ `<path d="${arc.d}" fill="${colorAt2(model, arc.colorIndex)}" stroke="#FFFFFF" stroke-width="1.5"${arc.pointIndex === void 0 ? "" : ` data-chart-series="0" data-chart-point="${arc.pointIndex}"`}/>`
6515
+ );
6516
+ const flatLabels = levels.length > 1 || model.series.length !== 1 ? void 0 : model.categories;
6517
+ for (const arc of model.hierarchy?.labels === false ? [] : arcs) {
6518
+ const label = arc.label ?? (arc.pointIndex === void 0 ? void 0 : flatLabels?.[arc.pointIndex]);
6519
+ if (!label) continue;
6520
+ out.push(
6521
+ `<text x="${n(arc.labelX)}" y="${n(arc.labelY)}" font-size="10" fill="#FFFFFF" text-anchor="middle" dominant-baseline="central" transform="rotate(${n(arc.labelRotation)}, ${n(arc.labelX)}, ${n(arc.labelY)})">${esc(label)}</text>`
6522
+ );
6523
+ }
6524
+ return out.join("");
6525
+ }
6526
+
4710
6527
  // chart/render/chart-svg-text-metrics.ts
4711
6528
  var CHART_FONT_FAMILY = "Calibri, Carlito, Arial, sans-serif";
4712
- function cssFont(attrs) {
4713
- return `${attrs.italic ? "italic" : "normal"} ${attrs.weight ?? "normal"} ${attrs.size ?? 10}px ${attrs.family ?? CHART_FONT_FAMILY}`;
6529
+ function cssFont(attrs2) {
6530
+ return `${attrs2.italic ? "italic" : "normal"} ${attrs2.weight ?? "normal"} ${attrs2.size ?? 10}px ${attrs2.family ?? CHART_FONT_FAMILY}`;
4714
6531
  }
4715
- function chartFontMetrics(attrs, options) {
4716
- const metrics = options.measureFont?.(cssFont(attrs));
6532
+ function chartFontMetrics(attrs2, options) {
6533
+ const metrics = options.measureFont?.(cssFont(attrs2));
4717
6534
  return metrics && Number.isFinite(metrics.ascent) && Number.isFinite(metrics.descent) && metrics.ascent >= 0 && metrics.descent >= 0 && metrics.ascent + metrics.descent > 0 ? metrics : void 0;
4718
6535
  }
4719
- function chartTextWidth(content, attrs, options) {
4720
- const width = options.measureText?.(content, cssFont(attrs));
4721
- return width !== void 0 && Number.isFinite(width) && width >= 0 ? width : textWidth(content, attrs.size);
6536
+ function chartTextWidth(content, attrs2, options) {
6537
+ const width = options.measureText?.(content, cssFont(attrs2));
6538
+ return width !== void 0 && Number.isFinite(width) && width >= 0 ? width : textWidth(content, attrs2.size);
4722
6539
  }
4723
- function fitChartText(content, maxWidth, attrs, options) {
4724
- if (!options.measureText) return fit(content, maxWidth, attrs.size);
4725
- if (chartTextWidth(content, attrs, options) <= maxWidth) return content;
6540
+ function fitChartText(content, maxWidth, attrs2, options) {
6541
+ if (!options.measureText) return fit(content, maxWidth, attrs2.size);
6542
+ if (chartTextWidth(content, attrs2, options) <= maxWidth) return content;
4726
6543
  const points = [...content];
4727
6544
  let low = 0;
4728
6545
  let high = points.length;
4729
6546
  while (low < high) {
4730
6547
  const mid = Math.ceil((low + high) / 2);
4731
- if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs, options) <= maxWidth) low = mid;
6548
+ if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs2, options) <= maxWidth) low = mid;
4732
6549
  else high = mid - 1;
4733
6550
  }
4734
6551
  return `${points.slice(0, low).join("")}\u2026`;
@@ -4750,13 +6567,13 @@ function chartLegendSvg(model, area, frame, options) {
4750
6567
  });
4751
6568
  if (!manual) return { plot, markup: automatic.join(""), foreground: !!model.legendOverlay };
4752
6569
  const entries = legendEntries(model);
4753
- const attrs = chartTextAttributes(model, "legend");
4754
- const size = attrs.size ?? 10;
4755
- const font = chartFontMetrics(attrs, options);
6570
+ const attrs2 = chartTextAttributes(model, "legend");
6571
+ const size = attrs2.size ?? 10;
6572
+ const font = chartFontMetrics(attrs2, options);
4756
6573
  const keySize = size / 2;
4757
6574
  const keyGap = size / 4;
4758
6575
  const widths = entries.map(
4759
- (entry) => chartTextWidth(entry.label, attrs, options) + keySize + keyGap
6576
+ (entry) => chartTextWidth(entry.label, attrs2, options) + keySize + keyGap
4760
6577
  );
4761
6578
  const horizontal = manual.width > manual.height && widths.reduce((sum, width) => sum + width, 0) + size <= manual.width;
4762
6579
  const rowWidth = horizontal ? manual.width / entries.length : manual.width;
@@ -4771,8 +6588,8 @@ function chartLegendSvg(model, area, frame, options) {
4771
6588
  ];
4772
6589
  const baselineOffset = font ? (font.ascent - font.descent) / 2 : size * 0.35;
4773
6590
  entries.forEach((entry, i) => {
4774
- const available = horizontal ? chartTextWidth(entry.label, attrs, options) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
4775
- const label = fitChartText(entry.label, available, attrs, options);
6591
+ const available = horizontal ? chartTextWidth(entry.label, attrs2, options) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
6592
+ const label = fitChartText(entry.label, available, attrs2, options);
4776
6593
  const contentWidth = Math.min(
4777
6594
  horizontal ? widths[i] ?? 0 : Math.max(...widths),
4778
6595
  rowWidth - size / 2
@@ -4780,7 +6597,7 @@ function chartLegendSvg(model, area, frame, options) {
4780
6597
  const x = horizontal ? horizontalX : manual.x + Math.max(size / 4, (rowWidth - contentWidth) / 2);
4781
6598
  const centerY = manual.y + (horizontal ? 0 : i * rowHeight) + rowHeight / 2;
4782
6599
  markup.push(rect(x, centerY - keySize / 2, keySize, keySize, entry.color));
4783
- markup.push(text(x + keySize + keyGap, centerY + baselineOffset, label, attrs));
6600
+ markup.push(text(x + keySize + keyGap, centerY + baselineOffset, label, attrs2));
4784
6601
  if (horizontal) horizontalX += (widths[i] ?? 0) + horizontalGap;
4785
6602
  });
4786
6603
  return {
@@ -4797,18 +6614,34 @@ function legendEntries(model) {
4797
6614
  color: first3?.pointColors?.[i] ?? first3?.color ?? "#4472C4"
4798
6615
  }));
4799
6616
  }
4800
- return model.series.map((s) => ({ label: s.name, color: s.color }));
6617
+ if ((model.type === "treemap" || model.type === "sunburst") && model.hierarchy) {
6618
+ const first3 = model.series[0];
6619
+ return model.hierarchy.branches.map((label, i) => ({
6620
+ label,
6621
+ color: first3?.pointColors?.[i % Math.max(1, first3.pointColors.length)] ?? first3?.color ?? "#4472C4"
6622
+ }));
6623
+ }
6624
+ if (model.type === "waterfall" && model.waterfall)
6625
+ return [
6626
+ { label: "Increase", color: model.waterfall.colors.increase },
6627
+ { label: "Decrease", color: model.waterfall.colors.decrease },
6628
+ { label: "Total", color: model.waterfall.colors.total }
6629
+ ];
6630
+ return [...model.series, ...(model.extraGroups ?? []).flatMap((g) => g.series)].map((s) => ({
6631
+ label: s.name,
6632
+ color: s.color
6633
+ }));
4801
6634
  }
4802
6635
  function automaticLegend(model, area, out, options, bounds) {
4803
6636
  const entries = legendEntries(model);
4804
6637
  if (!model.showLegend || entries.length === 0) return area;
4805
6638
  const pos = model.legendPosition;
4806
- const attrs = chartTextAttributes(model, "legend");
4807
- const size = attrs.size ?? 10;
6639
+ const attrs2 = chartTextAttributes(model, "legend");
6640
+ const size = attrs2.size ?? 10;
4808
6641
  const rowH = Math.max(16, size * 1.4);
4809
6642
  if (pos === "t" || pos === "b") {
4810
6643
  const widths = entries.map(
4811
- (e) => Math.min(chartTextWidth(e.label, attrs, options) + 20, area.w / 2)
6644
+ (e) => Math.min(chartTextWidth(e.label, attrs2, options) + 20, area.w / 2)
4812
6645
  );
4813
6646
  const total = widths.reduce((a, b) => a + b, 0);
4814
6647
  let x2 = area.x + Math.max(0, (area.w - total) / 2);
@@ -4825,14 +6658,14 @@ function automaticLegend(model, area, out, options, bounds) {
4825
6658
  entries.forEach((e, i) => {
4826
6659
  const w = widths[i] ?? 0;
4827
6660
  out.push(rect(x2, y, 8, 8, e.color));
4828
- out.push(text(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs, options), attrs));
6661
+ out.push(text(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs2, options), attrs2));
4829
6662
  x2 += w;
4830
6663
  });
4831
6664
  return pos === "t" ? { x: area.x, y: area.y + rowH + 4, w: area.w, h: area.h - rowH - 4 } : { x: area.x, y: area.y, w: area.w, h: area.h - rowH - 4 };
4832
6665
  }
4833
6666
  const width = Math.min(
4834
6667
  area.w * 0.35,
4835
- Math.max(...entries.map((e) => chartTextWidth(e.label, attrs, options))) + 22
6668
+ Math.max(...entries.map((e) => chartTextWidth(e.label, attrs2, options))) + 22
4836
6669
  );
4837
6670
  const height = entries.length * rowH;
4838
6671
  const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
@@ -4850,7 +6683,7 @@ function automaticLegend(model, area, out, options, bounds) {
4850
6683
  const y = y0 + i * rowH;
4851
6684
  if (y + rowH > area.y + area.h + 2) return;
4852
6685
  out.push(rect(x, y + 3, 8, 8, e.color));
4853
- out.push(text(x + 12, y + 11, fitChartText(e.label, width - 16, attrs, options), attrs));
6686
+ out.push(text(x + 12, y + 11, fitChartText(e.label, width - 16, attrs2, options), attrs2));
4854
6687
  });
4855
6688
  return pos === "l" ? { x: area.x + width + 8, y: area.y, w: area.w - width - 8, h: area.h } : { x: area.x, y: area.y, w: area.w - width - 8, h: area.h };
4856
6689
  }
@@ -4907,8 +6740,8 @@ function wrapStyledRuns(runs, maxWidth, measure, options = {}) {
4907
6740
  spaces = [];
4908
6741
  if (options.breakWords && wordWidth > maxWidth) {
4909
6742
  for (const piece of group.pieces) {
4910
- for (const { segment } of graphemes.segment(piece.text)) {
4911
- const next = { ...piece, text: segment };
6743
+ for (const { segment: segment2 } of graphemes.segment(piece.text)) {
6744
+ const next = { ...piece, text: segment2 };
4912
6745
  if (line2.length && width(merged(line2, [next])) > maxWidth) flush();
4913
6746
  line2 = merged(line2, [next]);
4914
6747
  }
@@ -4990,7 +6823,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
4990
6823
  width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs, options), 0),
4991
6824
  size: runs.length ? Math.max(...runs.map((run) => run.attrs.size ?? 14)) : base.size ?? 14,
4992
6825
  fontMetrics: (runs.length ? runs.map((run) => run.attrs) : [base]).map(
4993
- (attrs) => chartFontMetrics(attrs, options)
6826
+ (attrs2) => chartFontMetrics(attrs2, options)
4994
6827
  )
4995
6828
  };
4996
6829
  });
@@ -5055,8 +6888,8 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
5055
6888
 
5056
6889
  // chart/render/chart-svg.ts
5057
6890
  function renderChartSvg(model, width, height, options = {}) {
5058
- const paint = chartGradientPaint(model, Math.max(1, width), Math.max(1, height));
5059
- model = paint.model;
6891
+ const paint2 = chartGradientPaint(model, Math.max(1, width), Math.max(1, height));
6892
+ model = paint2.model;
5060
6893
  const w = Math.max(1, width);
5061
6894
  const h = Math.max(1, height);
5062
6895
  const out = [];
@@ -5065,7 +6898,7 @@ function renderChartSvg(model, width, height, options = {}) {
5065
6898
  `<svg xmlns="http://www.w3.org/2000/svg" width="${n(w)}" height="${n(h)}" viewBox="0 0 ${n(w)} ${n(h)}" font-family="${esc(CHART_FONT_FAMILY)}" role="img">`
5066
6899
  );
5067
6900
  if (model.title) out.push(`<title>${esc(model.title)}</title>`);
5068
- if (paint.defs) out.push(paint.defs);
6901
+ if (paint2.defs) out.push(paint2.defs);
5069
6902
  out.push(chartAreaRect(model, "chartArea", { x: 0, y: 0, w, h }));
5070
6903
  let area = { x: 8, y: 8, w: w - 16, h: h - 16 };
5071
6904
  const richTitle = chartRichTitleSvg(model, w, options, h);
@@ -5075,11 +6908,11 @@ function renderChartSvg(model, width, height, options = {}) {
5075
6908
  if (!model.titleOverlay)
5076
6909
  area = { ...area, y: area.y + richTitle.height, h: area.h - richTitle.height };
5077
6910
  } else if (model.title) {
5078
- const attrs = chartTextAttributes(model, "title", 14);
5079
- const size = attrs.size ?? 14;
5080
- const label = fitChartText(model.title, w - 16, attrs, options);
5081
- const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs, options) + 8);
5082
- const font = chartFontMetrics(attrs, options);
6911
+ const attrs2 = chartTextAttributes(model, "title", 14);
6912
+ const size = attrs2.size ?? 14;
6913
+ const label = fitChartText(model.title, w - 16, attrs2, options);
6914
+ const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs2, options) + 8);
6915
+ const font = chartFontMetrics(attrs2, options);
5083
6916
  const titleHeight = Math.max(24, font ? font.ascent + font.descent + 4 : size * 1.4 + 4);
5084
6917
  out.push(
5085
6918
  chartAreaRect(model, "title", {
@@ -5093,7 +6926,7 @@ function renderChartSvg(model, width, height, options = {}) {
5093
6926
  text(w / 2, 8 + size, label, {
5094
6927
  anchor: "middle",
5095
6928
  fill: "#404040",
5096
- ...attrs
6929
+ ...attrs2
5097
6930
  })
5098
6931
  );
5099
6932
  if (!model.titleOverlay)
@@ -5113,6 +6946,8 @@ function renderChartSvg(model, width, height, options = {}) {
5113
6946
  if (area.w > 4 && area.h > 4) {
5114
6947
  if (model.type === "pie" || model.type === "doughnut") out.push(pieSvg(model, area));
5115
6948
  else if (model.type === "radar") out.push(radarSvg(model, area));
6949
+ else if (model.type === "treemap") out.push(treemapSvg(model, area));
6950
+ else if (model.type === "sunburst") out.push(sunburstSvg(model, area));
5116
6951
  else out.push(cartesianSvg(model, area));
5117
6952
  }
5118
6953
  if (legend.foreground) out.push(legend.markup);
@@ -5130,7 +6965,13 @@ var DRAWN_CHART_TYPES = /* @__PURE__ */ new Set([
5130
6965
  "pie",
5131
6966
  "doughnut",
5132
6967
  "scatter",
5133
- "radar"
6968
+ "radar",
6969
+ "waterfall",
6970
+ "histogram",
6971
+ "bubble",
6972
+ "stock",
6973
+ "treemap",
6974
+ "sunburst"
5134
6975
  ]);
5135
6976
  function chartThemePalette(theme, fonts = {}) {
5136
6977
  return {
@@ -5156,6 +6997,11 @@ function renderChartSpaceSvg(space, options) {
5156
6997
  const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
5157
6998
  return renderChartSvg(view, width, height, svg);
5158
6999
  }
7000
+ function renderChartSummarySvg(summary, options) {
7001
+ const { width, height, theme, fonts, ...svg } = options;
7002
+ const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
7003
+ return renderChartSvg(view, width, height, svg);
7004
+ }
5159
7005
 
5160
7006
  // docx/breaks.ts
5161
7007
  function isCachedPageBreak(element) {
@@ -5189,13 +7035,286 @@ function isModeledBreak(element) {
5189
7035
  return true;
5190
7036
  }
5191
7037
 
5192
- // docx/write-drawing.ts
5193
- var A_NS2 = "http://schemas.openxmlformats.org/drawingml/2006/main";
7038
+ // docx/write-shape.ts
5194
7039
  var WP_NS2 = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
5195
- function findDrawingChild(run) {
7040
+ var el2 = (doc, ns, name) => makeNS(doc, ns, name);
7041
+ var add2 = (parent, ...items) => {
7042
+ for (const item of items) parent.appendChild(item);
7043
+ return parent;
7044
+ };
7045
+ var emu2 = (px) => String(Math.max(1, Math.round(px * EMU_PER_PIXEL)));
7046
+ var emuOffset = (px) => String(Math.round(px * EMU_PER_PIXEL));
7047
+ var attrs = (element, values) => {
7048
+ for (const [name, value] of Object.entries(values)) element.setAttribute(name, value);
7049
+ return element;
7050
+ };
7051
+ function dropDeclarations(element) {
7052
+ if (element.getAttribute("xmlns:a") === A_NS2) element.removeAttribute("xmlns:a");
7053
+ for (const node of Array.from(element.childNodes))
7054
+ if (node.nodeType === 1) dropDeclarations(node);
7055
+ }
7056
+ function importFragment(doc, xml) {
7057
+ const wrapper = parseXml(`<w xmlns:a="${A_NS2}">${xml}</w>`).documentElement;
7058
+ return Array.from(wrapper.childNodes).filter((node) => node.nodeType === 1).map((node) => {
7059
+ const imported = doc.importNode(node, true);
7060
+ dropDeclarations(imported);
7061
+ return imported;
7062
+ });
7063
+ }
7064
+ var srgb = (fill) => fill?.kind === "solid" && fill.color.kind === "srgb" ? fill.color.value : void 0;
7065
+ function explicitTextColor(spec) {
7066
+ if (!spec.fill) return void 0;
7067
+ if (spec.fill.kind === "none") return "000000";
7068
+ const hex = srgb(spec.fill);
7069
+ if (!hex || !/^[0-9a-f]{6}$/i.test(hex)) return void 0;
7070
+ const channel = (i) => Number.parseInt(hex.slice(i, i + 2), 16) / 255;
7071
+ const light = 0.2126 * channel(0) + 0.7152 * channel(2) + 0.0722 * channel(4) > 0.6;
7072
+ return light ? "000000" : void 0;
7073
+ }
7074
+ function textParagraphs(doc, lines, color) {
7075
+ return lines.map((line2) => {
7076
+ const paragraph = makeW(doc, "p");
7077
+ const props = makeW(doc, "pPr");
7078
+ const jc = makeW(doc, "jc");
7079
+ jc.setAttributeNS(W_NS2, "w:val", "center");
7080
+ add2(paragraph, add2(props, jc));
7081
+ if (line2) {
7082
+ const run = makeW(doc, "r");
7083
+ if (color) {
7084
+ const rPr = makeW(doc, "rPr");
7085
+ const c = makeW(doc, "color");
7086
+ c.setAttributeNS(W_NS2, "w:val", color);
7087
+ add2(run, add2(rPr, c));
7088
+ }
7089
+ const t = makeW(doc, "t");
7090
+ if (/^\s|\s$/.test(line2))
7091
+ t.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
7092
+ t.textContent = line2;
7093
+ add2(paragraph, add2(run, t));
7094
+ }
7095
+ return paragraph;
7096
+ });
7097
+ }
7098
+ function shapeStyle(doc) {
7099
+ const ref = (name, idx, scheme, shade) => {
7100
+ const node = attrs(el2(doc, A_NS2, `a:${name}`), { idx });
7101
+ const color = attrs(el2(doc, A_NS2, "a:schemeClr"), { val: scheme });
7102
+ if (shade) add2(color, attrs(el2(doc, A_NS2, "a:shade"), { val: shade }));
7103
+ return add2(node, color);
7104
+ };
7105
+ return add2(
7106
+ el2(doc, WPS_NS2, "wps:style"),
7107
+ ref("lnRef", "2", "accent1", "50000"),
7108
+ ref("fillRef", "1", "accent1"),
7109
+ ref("effectRef", "0", "accent1"),
7110
+ ref("fontRef", "minor", "lt1")
7111
+ );
7112
+ }
7113
+ function wrapElement(doc, placement) {
7114
+ switch (placement.wrap) {
7115
+ case "square":
7116
+ return attrs(el2(doc, WP_NS2, "wp:wrapSquare"), { wrapText: "bothSides" });
7117
+ case "tight":
7118
+ case "through": {
7119
+ const wrap = attrs(
7120
+ el2(doc, WP_NS2, `wp:wrap${placement.wrap === "tight" ? "Tight" : "Through"}`),
7121
+ {
7122
+ wrapText: "bothSides"
7123
+ }
7124
+ );
7125
+ const polygon = attrs(el2(doc, WP_NS2, "wp:wrapPolygon"), { edited: "0" });
7126
+ const point = (name, x, y) => attrs(el2(doc, WP_NS2, `wp:${name}`), { x, y });
7127
+ return add2(
7128
+ wrap,
7129
+ add2(
7130
+ polygon,
7131
+ point("start", "0", "0"),
7132
+ point("lineTo", "0", "21600"),
7133
+ point("lineTo", "21600", "21600"),
7134
+ point("lineTo", "21600", "0"),
7135
+ point("lineTo", "0", "0")
7136
+ )
7137
+ );
7138
+ }
7139
+ case "topAndBottom":
7140
+ return el2(doc, WP_NS2, "wp:wrapTopAndBottom");
7141
+ default:
7142
+ return el2(doc, WP_NS2, "wp:wrapNone");
7143
+ }
7144
+ }
7145
+ function position(doc, axis, relativeFrom, align, offsetPx) {
7146
+ const node = attrs(el2(doc, WP_NS2, `wp:position${axis}`), { relativeFrom });
7147
+ if (align) {
7148
+ const a = el2(doc, WP_NS2, "wp:align");
7149
+ a.textContent = align;
7150
+ return add2(node, a);
7151
+ }
7152
+ const offset = el2(doc, WP_NS2, "wp:posOffset");
7153
+ offset.textContent = emuOffset(offsetPx ?? 0);
7154
+ return add2(node, offset);
7155
+ }
7156
+ function geometry(doc, spec) {
7157
+ const prst = attrs(el2(doc, A_NS2, "a:prstGeom"), { prst: spec.preset });
7158
+ const avLst = el2(doc, A_NS2, "a:avLst");
7159
+ for (const [name, value] of Object.entries(spec.adjustments ?? {}))
7160
+ add2(avLst, attrs(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
7161
+ const nodes = [add2(prst, avLst)];
7162
+ if (spec.fill) {
7163
+ const xml = drawingFillXml(spec.fill);
7164
+ if (xml) nodes.push(...importFragment(doc, xml));
7165
+ }
7166
+ if (spec.line) nodes.push(...importFragment(doc, drawingLineXml(spec.line)));
7167
+ return nodes;
7168
+ }
7169
+ function buildShapeDrawing(doc, image, identity, relativeHeight = 251658240) {
7170
+ const spec = image.shape;
7171
+ const drawing = makeW(doc, "drawing");
7172
+ const placement = image.placement;
7173
+ const anchored = Boolean(image.anchored);
7174
+ const holder = el2(doc, WP_NS2, anchored ? "wp:anchor" : "wp:inline");
7175
+ if (anchored) {
7176
+ attrs(holder, {
7177
+ distT: "0",
7178
+ distB: "0",
7179
+ distL: "114300",
7180
+ distR: "114300",
7181
+ simplePos: "0",
7182
+ relativeHeight: String(relativeHeight),
7183
+ behindDoc: placement?.behindText ? "1" : "0",
7184
+ locked: "0",
7185
+ layoutInCell: "1",
7186
+ allowOverlap: "1"
7187
+ });
7188
+ add2(
7189
+ holder,
7190
+ attrs(el2(doc, WP_NS2, "wp:simplePos"), { x: "0", y: "0" }),
7191
+ position(
7192
+ doc,
7193
+ "H",
7194
+ placement?.relativeFrom ?? "column",
7195
+ placement?.align,
7196
+ placement?.offsetXPx
7197
+ ),
7198
+ position(
7199
+ doc,
7200
+ "V",
7201
+ placement?.relativeFromV ?? "paragraph",
7202
+ placement?.alignV,
7203
+ placement?.offsetYPx
7204
+ )
7205
+ );
7206
+ } else for (const side of ["distT", "distB", "distL", "distR"]) holder.setAttribute(side, "0");
7207
+ add2(
7208
+ holder,
7209
+ attrs(el2(doc, WP_NS2, "wp:extent"), { cx: emu2(image.widthPx), cy: emu2(image.heightPx) }),
7210
+ attrs(el2(doc, WP_NS2, "wp:effectExtent"), { l: "0", t: "0", r: "0", b: "0" })
7211
+ );
7212
+ if (anchored) add2(holder, wrapElement(doc, placement ?? { wrap: "none" }));
7213
+ const docPr = attrs(el2(doc, WP_NS2, "wp:docPr"), {
7214
+ id: identity.id,
7215
+ name: identity.name ?? `Shape ${identity.id}`
7216
+ });
7217
+ if (identity.descr) docPr.setAttribute("descr", identity.descr);
7218
+ if (identity.title) docPr.setAttribute("title", identity.title);
7219
+ const xfrm = attrs(el2(doc, A_NS2, "a:xfrm"), {});
7220
+ if (spec.rotation) xfrm.setAttribute("rot", String(Math.round(spec.rotation * 6e4)));
7221
+ if (spec.flipH) xfrm.setAttribute("flipH", "1");
7222
+ if (spec.flipV) xfrm.setAttribute("flipV", "1");
7223
+ add2(
7224
+ xfrm,
7225
+ attrs(el2(doc, A_NS2, "a:off"), { x: "0", y: "0" }),
7226
+ attrs(el2(doc, A_NS2, "a:ext"), { cx: emu2(image.widthPx), cy: emu2(image.heightPx) })
7227
+ );
7228
+ const spPr = add2(el2(doc, WPS_NS2, "wps:spPr"), xfrm, ...geometry(doc, spec));
7229
+ const wsp = add2(
7230
+ el2(doc, WPS_NS2, "wps:wsp"),
7231
+ el2(doc, WPS_NS2, "wps:cNvSpPr"),
7232
+ spPr,
7233
+ shapeStyle(doc)
7234
+ );
7235
+ if (spec.text?.length) {
7236
+ const content = add2(
7237
+ el2(doc, W_NS2, "w:txbxContent"),
7238
+ ...textParagraphs(doc, spec.text, explicitTextColor(spec))
7239
+ );
7240
+ add2(wsp, add2(el2(doc, WPS_NS2, "wps:txbx"), content));
7241
+ }
7242
+ const body = attrs(el2(doc, WPS_NS2, "wps:bodyPr"), {
7243
+ rot: "0",
7244
+ vert: "horz",
7245
+ wrap: "square",
7246
+ lIns: "91440",
7247
+ tIns: "45720",
7248
+ rIns: "91440",
7249
+ bIns: "45720",
7250
+ anchor: "ctr",
7251
+ anchorCtr: "0"
7252
+ });
7253
+ add2(wsp, add2(body, el2(doc, A_NS2, "a:noAutofit")));
7254
+ const graphicData = attrs(el2(doc, A_NS2, "a:graphicData"), { uri: WPS_NS2 });
7255
+ add2(
7256
+ holder,
7257
+ docPr,
7258
+ el2(doc, WP_NS2, "wp:cNvGraphicFramePr"),
7259
+ add2(el2(doc, A_NS2, "a:graphic"), add2(graphicData, wsp))
7260
+ );
7261
+ return add2(drawing, holder);
7262
+ }
7263
+ var firstNs = (root, ns, local) => root.getElementsByTagNameNS(ns, local)[0];
7264
+ function rebuildShapeDrawing(doc, image, old) {
7265
+ const oldDocPr = firstNs(old, WP_NS2, "docPr");
7266
+ const identity = {
7267
+ id: oldDocPr?.getAttribute("id") ?? "1",
7268
+ ...oldDocPr?.getAttribute("name") ? { name: oldDocPr.getAttribute("name") } : {},
7269
+ ...oldDocPr?.getAttribute("descr") ? { descr: oldDocPr.getAttribute("descr") } : {},
7270
+ ...oldDocPr?.getAttribute("title") ? { title: oldDocPr.getAttribute("title") } : {}
7271
+ };
7272
+ const oldAnchor = firstNs(old, WP_NS2, "anchor");
7273
+ const relativeHeight = Number(oldAnchor?.getAttribute("relativeHeight")) || void 0;
7274
+ const next = buildShapeDrawing(doc, image, identity, relativeHeight);
7275
+ const wsp = firstNs(next, WPS_NS2, "wsp");
7276
+ const keep = (local) => {
7277
+ const previous = firstNs(old, WPS_NS2, local);
7278
+ const current = firstNs(next, WPS_NS2, local);
7279
+ if (previous && current) wsp.replaceChild(previous.cloneNode(true), current);
7280
+ };
7281
+ keep("style");
7282
+ keep("bodyPr");
7283
+ if (!image.shape?.textEditable) {
7284
+ const text2 = firstNs(old, WPS_NS2, "txbx");
7285
+ const current = firstNs(next, WPS_NS2, "txbx");
7286
+ if (text2 && current) wsp.replaceChild(text2.cloneNode(true), current);
7287
+ else if (text2) wsp.insertBefore(text2.cloneNode(true), firstNs(next, WPS_NS2, "bodyPr") ?? null);
7288
+ }
7289
+ return next;
7290
+ }
7291
+
7292
+ // docx/write-drawing.ts
7293
+ var A_NS3 = "http://schemas.openxmlformats.org/drawingml/2006/main";
7294
+ var WP_NS3 = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing";
7295
+ function alternateContentDrawing(content) {
7296
+ const choice = Array.from(content.childNodes).filter(isElement).find((node) => node.localName === "Choice");
7297
+ return choice && findDrawingChild(choice);
7298
+ }
7299
+ function drawingContainer(run) {
5196
7300
  if (!run) return void 0;
5197
7301
  for (const child of Array.from(run.childNodes))
5198
7302
  if (isElement(child) && (named2(child, "drawing") || named2(child, "pict"))) return child;
7303
+ for (const child of Array.from(run.childNodes))
7304
+ if (isElement(child) && child.localName === "AlternateContent" && alternateContentDrawing(child))
7305
+ return child;
7306
+ return void 0;
7307
+ }
7308
+ function findDrawingChild(run) {
7309
+ if (!run) return void 0;
7310
+ for (const child of Array.from(run.childNodes)) {
7311
+ if (!isElement(child)) continue;
7312
+ if (named2(child, "drawing") || named2(child, "pict")) return child;
7313
+ if (child.localName === "AlternateContent") {
7314
+ const inner = alternateContentDrawing(child);
7315
+ if (inner) return inner;
7316
+ }
7317
+ }
5199
7318
  return void 0;
5200
7319
  }
5201
7320
  function sameUnderlyingImage(a, b) {
@@ -5213,9 +7332,9 @@ function updateExtent(drawing, widthPx, heightPx) {
5213
7332
  const cx = String(Math.max(1, Math.round(widthPx * EMU_PER_PIXEL)));
5214
7333
  const cy = String(Math.max(1, Math.round(heightPx * EMU_PER_PIXEL)));
5215
7334
  walk(drawing, (node) => {
5216
- const isExtent = node.namespaceURI === WP_NS2 && node.localName === "extent";
7335
+ const isExtent = node.namespaceURI === WP_NS3 && node.localName === "extent";
5217
7336
  const parent = node.parentNode;
5218
- const isExt = node.namespaceURI === A_NS2 && node.localName === "ext" && parent?.namespaceURI === A_NS2 && parent.localName === "xfrm";
7337
+ const isExt = node.namespaceURI === A_NS3 && node.localName === "ext" && parent?.namespaceURI === A_NS3 && parent.localName === "xfrm";
5219
7338
  if (isExtent || isExt) {
5220
7339
  node.setAttribute("cx", cx);
5221
7340
  node.setAttribute("cy", cy);
@@ -5224,13 +7343,47 @@ function updateExtent(drawing, widthPx, heightPx) {
5224
7343
  }
5225
7344
  function updateDocPr(drawing, altText, title) {
5226
7345
  walk(drawing, (node) => {
5227
- if (node.namespaceURI !== WP_NS2 || node.localName !== "docPr") return;
7346
+ if (node.namespaceURI !== WP_NS3 || node.localName !== "docPr") return;
5228
7347
  if (altText) node.setAttribute("descr", altText);
5229
7348
  else node.removeAttribute("descr");
5230
7349
  if (title) node.setAttribute("title", title);
5231
7350
  else node.removeAttribute("title");
5232
7351
  });
5233
7352
  }
7353
+ function patchPosition(doc, anchor, name, relativeFrom, align, offsetPx) {
7354
+ const position2 = Array.from(anchor.childNodes).find(
7355
+ (child) => isElement(child) && child.namespaceURI === WP_NS3 && child.localName === name
7356
+ );
7357
+ if (!position2) return;
7358
+ if (relativeFrom) position2.setAttribute("relativeFrom", relativeFrom);
7359
+ for (const child of Array.from(position2.childNodes)) position2.removeChild(child);
7360
+ const value = align ? makeNS(doc, WP_NS3, "wp:align") : makeNS(doc, WP_NS3, "wp:posOffset");
7361
+ value.appendChild(
7362
+ doc.createTextNode(align ?? String(Math.round((offsetPx ?? 0) * EMU_PER_PIXEL)))
7363
+ );
7364
+ position2.appendChild(value);
7365
+ }
7366
+ function updatePlacement(drawing, doc, placement) {
7367
+ walk(drawing, (node) => {
7368
+ if (node.namespaceURI !== WP_NS3 || node.localName !== "anchor") return;
7369
+ patchPosition(
7370
+ doc,
7371
+ node,
7372
+ "positionH",
7373
+ placement.relativeFrom,
7374
+ placement.align,
7375
+ placement.offsetXPx
7376
+ );
7377
+ patchPosition(
7378
+ doc,
7379
+ node,
7380
+ "positionV",
7381
+ placement.relativeFromV,
7382
+ placement.alignV,
7383
+ placement.offsetYPx
7384
+ );
7385
+ });
7386
+ }
5234
7387
  function clearNonProperties(node, keep) {
5235
7388
  for (const child of Array.from(node.childNodes)) {
5236
7389
  if (isElement(child) && (named2(child, "rPr") || child === keep)) continue;
@@ -5240,19 +7393,29 @@ function clearNonProperties(node, keep) {
5240
7393
  function createImageRun(doc, image, base, old, allocator) {
5241
7394
  const node = old ?? makeW(doc, "r");
5242
7395
  const oldDrawing = findDrawingChild(old);
7396
+ const oldContainer = drawingContainer(old);
5243
7397
  if (!base && oldDrawing)
5244
7398
  throw new Error(
5245
7399
  "Cannot safely insert a picture here: this position lines up with a different existing picture. Edit further away from surrounding pictures, then save."
5246
7400
  );
5247
7401
  if (base && oldDrawing && image.textBoxEditable && base.textBoxEditable) {
5248
7402
  patchTextBox(doc, oldDrawing, image, base);
5249
- clearNonProperties(node, oldDrawing);
7403
+ clearNonProperties(node, oldContainer);
5250
7404
  return node;
5251
7405
  }
5252
7406
  if (base && oldDrawing && image.unsupported && JSON.stringify(image) === JSON.stringify(base)) {
5253
- clearNonProperties(node, oldDrawing);
7407
+ clearNonProperties(node, oldContainer);
7408
+ return node;
7409
+ }
7410
+ if (base && oldDrawing && image.shape?.editable && base.shape?.editable) {
7411
+ const next = rebuildShapeDrawing(doc, image, oldDrawing);
7412
+ clearNonProperties(node);
7413
+ node.appendChild(next);
5254
7414
  return node;
5255
7415
  }
7416
+ if (!base && image.shape?.editable && !image.partName) {
7417
+ throw new Error("Cannot insert a shape without an id allocator.");
7418
+ }
5256
7419
  if (image.watermark) {
5257
7420
  clearNonProperties(node);
5258
7421
  node.appendChild(
@@ -5268,7 +7431,9 @@ function createImageRun(doc, image, base, old, allocator) {
5268
7431
  updateExtent(oldDrawing, image.widthPx, image.heightPx);
5269
7432
  if (image.altText !== base.altText || image.title !== base.title)
5270
7433
  updateDocPr(oldDrawing, image.altText, image.title);
5271
- clearNonProperties(node, oldDrawing);
7434
+ if (image.anchored && image.placement && JSON.stringify(image.placement) !== JSON.stringify(base.placement))
7435
+ updatePlacement(oldDrawing, doc, image.placement);
7436
+ clearNonProperties(node, oldContainer);
5272
7437
  return node;
5273
7438
  }
5274
7439
  if (base)
@@ -5590,20 +7755,39 @@ var MATH_NAMESPACES = /* @__PURE__ */ new Set([
5590
7755
  "http://schemas.openxmlformats.org/officeDocument/2006/math",
5591
7756
  "http://purl.oclc.org/ooxml/officeDocument/math"
5592
7757
  ]);
7758
+ var MATH_NS = "http://schemas.openxmlformats.org/officeDocument/2006/math";
5593
7759
  function isEquationElement(element) {
5594
7760
  return MATH_NAMESPACES.has(element.namespaceURI ?? "") && (element.localName === "oMath" || element.localName === "oMathPara");
5595
7761
  }
5596
- function preserveEquation(run, base, old) {
5597
- if (!old || !isEquationElement(old) || true)
7762
+ function writeEquation(doc, run, base, old) {
7763
+ const equation = run.equation;
7764
+ if (!equation || run.text !== "") throw new Error("An equation run holds no text.");
7765
+ if (old && isEquationElement(old) && base?.equation?.omml === equation.omml && base.equation.display === equation.display)
7766
+ return old.cloneNode(true);
7767
+ let source;
7768
+ try {
7769
+ source = parseXml2(equation.omml).documentElement;
7770
+ } catch (cause) {
5598
7771
  throw new Error(
5599
- "Equation editing or insertion is unsupported; imported OMML must remain unchanged."
7772
+ `Equation markup could not be read: ${cause instanceof Error ? cause.message : String(cause)}`,
7773
+ { cause }
5600
7774
  );
5601
- }
5602
- function isCommentReferenceRun(run) {
5603
- const content = Array.from(run.childNodes).filter(
5604
- (child) => isElement(child) && !named2(child, "rPr")
5605
- );
5606
- return content.length > 0 && content.every((child) => named2(child, "commentReference"));
7775
+ }
7776
+ if (!isEquationElement(source))
7777
+ throw new Error("Equation markup must be an m:oMath or m:oMathPara element.");
7778
+ let element = doc.importNode(source, true);
7779
+ if (equation.display && element.localName === "oMath") {
7780
+ const para = doc.createElementNS(MATH_NS, "m:oMathPara");
7781
+ para.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:m", MATH_NS);
7782
+ para.appendChild(element);
7783
+ element = para;
7784
+ } else if (!equation.display && element.localName === "oMathPara") {
7785
+ const inner = Array.from(element.childNodes).find(
7786
+ (node) => node.nodeType === 1 && node.localName === "oMath"
7787
+ );
7788
+ if (inner) element = inner;
7789
+ }
7790
+ return element;
5607
7791
  }
5608
7792
 
5609
7793
  // docx/write-inline.ts
@@ -5624,6 +7808,11 @@ function runIsSafe(run) {
5624
7808
  for (const element of content) {
5625
7809
  if (element.localName === "br" && hasSpecialBreak(element)) return false;
5626
7810
  if (element.localName === "cr" && element.attributes.length > 0) return false;
7811
+ if (element.localName === "AlternateContent") {
7812
+ if (!alternateContentDrawing(element)) return false;
7813
+ kinds.add("drawing");
7814
+ continue;
7815
+ }
5627
7816
  const allowed = ["t", "tab", "br", "cr", "noBreakHyphen", "delText", "drawing", "pict"];
5628
7817
  if (!allowed.includes(element.localName)) return false;
5629
7818
  kinds.add(element.localName);
@@ -5642,8 +7831,8 @@ function runsOf(parent, container, slots) {
5642
7831
  if (isCommentReferenceRun(child)) continue;
5643
7832
  if (!runIsSafe(child)) return false;
5644
7833
  slots.push({ element: child, ...container && { container } });
5645
- } else if (isRevisionWrapperElement(child) && !container) {
5646
- if (!runsOf(child, void 0, slots)) return false;
7834
+ } else if (isRevisionWrapperElement(child) && (!container || isSdt(container))) {
7835
+ if (!runsOf(child, container, slots)) return false;
5647
7836
  } else if ((named2(child, "hyperlink") || named2(child, "fldSimple")) && !container) {
5648
7837
  const before = slots.length;
5649
7838
  if (!runsOf(child, child, slots)) return false;
@@ -5670,6 +7859,11 @@ function collectInlineSlots(paragraph) {
5670
7859
  slots.push({ element: child });
5671
7860
  } else if (isRevisionWrapperElement(child)) {
5672
7861
  if (!runsOf(child, void 0, slots)) return void 0;
7862
+ } else if (isSdt(child)) {
7863
+ const content = sdtContent(child);
7864
+ const before = slots.length;
7865
+ if (content && !runsOf(content, child, slots)) return void 0;
7866
+ if (slots.length === before) slots.push({ container: child });
5673
7867
  } else if (named2(child, "hyperlink") || named2(child, "fldSimple")) {
5674
7868
  const before = slots.length;
5675
7869
  if (!runsOf(child, child, slots)) return void 0;
@@ -5680,7 +7874,7 @@ function collectInlineSlots(paragraph) {
5680
7874
  }
5681
7875
  function replaceableInlineChildren(paragraph) {
5682
7876
  return Array.from(paragraph.childNodes).filter(
5683
- (child) => isElement(child) && (isEquationElement(child) || named2(child, "r") || named2(child, "hyperlink") || named2(child, "fldSimple") || isRevisionWrapperElement(child) || isCommentAnchorElement(child))
7877
+ (child) => isElement(child) && (isEquationElement(child) || named2(child, "r") || named2(child, "hyperlink") || named2(child, "fldSimple") || isSdt(child) || isRevisionWrapperElement(child) || isCommentAnchorElement(child))
5684
7878
  );
5685
7879
  }
5686
7880
  function sameLink(a, b) {
@@ -5703,7 +7897,7 @@ function newHyperlink(doc, link, allocator) {
5703
7897
  }
5704
7898
  function runNodes(doc, run, base, old, opens, closes, allocator) {
5705
7899
  const nodes = opens.flatMap((edge) => rangeStartNodes(doc, edge));
5706
- const node = run.equation ? preserveEquation(run, base, old) : createRun(doc, run, base, old);
7900
+ const node = run.equation ? writeEquation(doc, run, base, old) : createRun(doc, run, base, old);
5707
7901
  const revision = run.revision;
5708
7902
  if (revision && ["insert", "delete", "moveFrom", "moveTo"].includes(revision.kind)) {
5709
7903
  if (revision.kind === "delete") convertToDeleteText(doc, node);
@@ -5742,9 +7936,14 @@ function buildInlineContent(doc, runs, base, slots, allocator, ranges) {
5742
7936
  while (index < runs.length && sameGroup(containerGroup(runAt(index)), group)) index++;
5743
7937
  const oldContainers = new Set(slots.slice(start, index).map((slot) => slot?.container));
5744
7938
  const [onlyContainer] = oldContainers;
5745
- oldContainers.size === 1 && onlyContainer !== void 0 && onlyContainer.localName === (group.kind === "link" ? "hyperlink" : "fldSimple") && base?.slice(start, index).every((run) => sameGroup(run && containerGroup(run), group)) === true;
7939
+ oldContainers.size === 1 && onlyContainer !== void 0 && onlyContainer.localName === (group.kind === "link" ? "hyperlink" : group.kind === "control" ? "sdt" : "fldSimple") && base?.slice(start, index).every((run) => sameGroup(run && containerGroup(run), group)) === true;
5746
7940
  let container;
5747
- if (group.kind === "link") container = newHyperlink(doc, group.link);
7941
+ let target;
7942
+ if (group.kind === "control") {
7943
+ const created = createContentControl(doc, group.control);
7944
+ container = created.sdt;
7945
+ target = created.content;
7946
+ } else if (group.kind === "link") container = newHyperlink(doc, group.link);
5748
7947
  else {
5749
7948
  container = makeW(doc, "fldSimple");
5750
7949
  setW2(container, "instr", ` ${group.instr} `);
@@ -5752,12 +7951,13 @@ function buildInlineContent(doc, runs, base, slots, allocator, ranges) {
5752
7951
  if (group.kind === "simpleField") writeFieldFlags(container, runAt(start).fieldFlags);
5753
7952
  const edges = group.kind === "simpleField" ? takeSimpleFieldCommentEdges(doc, runs, start, index, opens, closes) : { before: [], after: [] };
5754
7953
  for (let item = start; item < index; item++)
5755
- for (const node of nodesFor(item)) container.appendChild(node);
7954
+ for (const node of nodesFor(item)) (target ?? container).appendChild(node);
5756
7955
  output.push(...edges.before, container, ...edges.after);
5757
7956
  }
5758
7957
  return output;
5759
7958
  }
5760
7959
  function containerGroup(run) {
7960
+ if (run.contentControl) return { kind: "control", control: run.contentControl };
5761
7961
  if (run.link) return { kind: "link", link: run.link };
5762
7962
  if (run.field?.simple)
5763
7963
  return {
@@ -5770,6 +7970,8 @@ function containerGroup(run) {
5770
7970
  }
5771
7971
  function sameGroup(a, b) {
5772
7972
  if (!a || !b) return a === b;
7973
+ if (a.kind === "control" || b.kind === "control")
7974
+ return a.kind === "control" && b.kind === "control" && a.control.id === b.control.id;
5773
7975
  if (a.kind === "link" && b.kind === "link") return sameLink(a.link, b.link);
5774
7976
  return a.kind === "simpleField" && b.kind === "simpleField" && a.instr === b.instr && a.instanceId === b.instanceId && sameFieldFlags(a.fieldFlags, b.fieldFlags);
5775
7977
  }
@@ -5944,11 +8146,12 @@ function createParagraph(doc, paragraph, allocator, spans) {
5944
8146
  }
5945
8147
 
5946
8148
  // docx/numbering-parse.ts
8149
+ var own = (map, key) => Object.prototype.hasOwnProperty.call(map, key) ? map[key] : void 0;
5947
8150
  function resolveNumberingLevel(catalog, numId, level) {
5948
- const num = catalog.nums[numId];
8151
+ const num = own(catalog.nums, numId);
5949
8152
  if (!num) return void 0;
5950
8153
  const override = num.levelOverrides?.[level];
5951
- const sourceAbstract = catalog.abstractNums[num.abstractNumId]?.levels[level];
8154
+ const sourceAbstract = own(catalog.abstractNums, num.abstractNumId)?.levels[level];
5952
8155
  const abstract = sourceAbstract?.startWasOmitted && sourceAbstract.start === 1 ? { ...sourceAbstract, start: 0 } : sourceAbstract;
5953
8156
  let base = override?.lvl ?? abstract;
5954
8157
  if (!base) return void 0;
@@ -5991,6 +8194,9 @@ function themeCatalogColorScheme(theme) {
5991
8194
  }
5992
8195
  function docxChartPaint(chart, widthPx, heightPx, theme) {
5993
8196
  const space = chart?.chartSpace;
8197
+ const extended = chart?.chartEx;
8198
+ if (chart && extended) return paintExtended(chart, extended, widthPx, heightPx, theme);
8199
+ if (chart && chart.layoutId) return { label: `Chart (${chart.layoutId})` };
5994
8200
  if (!space) return { label: "Chart" };
5995
8201
  const kind = chartSpaceKind(space);
5996
8202
  if (!kind.drawn) return { label: kind.type ? `Chart (${kind.type})` : "Chart" };
@@ -6012,6 +8218,23 @@ function docxChartPaint(chart, widthPx, heightPx, theme) {
6012
8218
  return { label: kind.type ? `Chart (${kind.type})` : "Chart" };
6013
8219
  }
6014
8220
  }
8221
+ function paintExtended(chart, summary, widthPx, heightPx, theme) {
8222
+ try {
8223
+ const fonts = {
8224
+ ...theme?.fonts.major.latin ? { major: theme.fonts.major.latin } : {},
8225
+ ...theme?.fonts.minor.latin ? { minor: theme.fonts.minor.latin } : {}
8226
+ };
8227
+ const svg = renderChartSummarySvg(summary, {
8228
+ width: Math.max(1, Math.round(widthPx)),
8229
+ height: Math.max(1, Math.round(heightPx)),
8230
+ theme: themeCatalogColorScheme(theme),
8231
+ fonts
8232
+ });
8233
+ return { svg, label: chart.title ? `Chart: ${chart.title}` : "Chart" };
8234
+ } catch {
8235
+ return { label: `Chart (${chart.layoutId ?? "extended"})` };
8236
+ }
8237
+ }
6015
8238
 
6016
8239
  // docx/diagram-theme.ts
6017
8240
  function diagramColorTheme(theme) {
@@ -6261,6 +8484,56 @@ function applyAll(model, apply) {
6261
8484
  var acceptAllRevisions = (model) => applyAll(model, acceptRevision);
6262
8485
  var rejectAllRevisions = (model) => applyAll(model, rejectRevision);
6263
8486
 
8487
+ // docx/field-date.ts
8488
+ var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|am\/pm|AM\/PM|'[^']*'/g;
8489
+ function formatWordDate(date, picture, locale = "en-US") {
8490
+ const name = (options) => new Intl.DateTimeFormat(locale, options).format(date);
8491
+ const pad = (value) => String(value).padStart(2, "0");
8492
+ const hours12 = date.getHours() % 12 || 12;
8493
+ return picture.replace(TOKENS, (token) => {
8494
+ switch (token) {
8495
+ case "yyyy":
8496
+ return String(date.getFullYear());
8497
+ case "yy":
8498
+ return pad(date.getFullYear() % 100);
8499
+ case "MMMM":
8500
+ return name({ month: "long" });
8501
+ case "MMM":
8502
+ return name({ month: "short" });
8503
+ case "MM":
8504
+ return pad(date.getMonth() + 1);
8505
+ case "M":
8506
+ return String(date.getMonth() + 1);
8507
+ case "dddd":
8508
+ return name({ weekday: "long" });
8509
+ case "ddd":
8510
+ return name({ weekday: "short" });
8511
+ case "dd":
8512
+ return pad(date.getDate());
8513
+ case "d":
8514
+ return String(date.getDate());
8515
+ case "HH":
8516
+ return pad(date.getHours());
8517
+ case "H":
8518
+ return String(date.getHours());
8519
+ case "hh":
8520
+ return pad(hours12);
8521
+ case "h":
8522
+ return String(hours12);
8523
+ case "mm":
8524
+ return pad(date.getMinutes());
8525
+ case "ss":
8526
+ return pad(date.getSeconds());
8527
+ case "am/pm":
8528
+ return date.getHours() < 12 ? "am" : "pm";
8529
+ case "AM/PM":
8530
+ return date.getHours() < 12 ? "AM" : "PM";
8531
+ default:
8532
+ return token.slice(1, -1);
8533
+ }
8534
+ });
8535
+ }
8536
+
6264
8537
  // docx/table-visuals.ts
6265
8538
  var NONE = { style: "none" };
6266
8539
  function edgeFrom(borders, side, onBoundary) {
@@ -6310,7 +8583,7 @@ function sectionsFromLayout(json, prior, blocks) {
6310
8583
  return kept.map((section, index) => {
6311
8584
  const end = endOf(section, index, kept);
6312
8585
  const source = priorSections.find((candidate) => candidate.endsAtBlockId === section.endsAtBlockId) ?? priorSections.find(
6313
- (candidate, position) => endOf(candidate, position, priorSections) >= end
8586
+ (candidate, position2) => endOf(candidate, position2, priorSections) >= end
6314
8587
  ) ?? priorSections.at(-1);
6315
8588
  return {
6316
8589
  ...section,
@@ -6348,17 +8621,17 @@ function twipsAttr(value) {
6348
8621
  function signedTwipsAttr(value) {
6349
8622
  return typeof value === "number" && Number.isFinite(value) ? roundSignedTwips(value) : void 0;
6350
8623
  }
6351
- function paragraphTwipsFromAttrs(attrs) {
8624
+ function paragraphTwipsFromAttrs(attrs2) {
6352
8625
  const result = {};
6353
- const spacingBefore = twipsAttr(attrs.spacingBeforeTwips);
6354
- const spacingAfter = twipsAttr(attrs.spacingAfterTwips);
6355
- const lineSpacing = signedTwipsAttr(attrs.lineSpacingTwips);
6356
- const left = signedTwipsAttr(attrs.indentLeftTwips);
6357
- const right = signedTwipsAttr(attrs.indentRightTwips);
6358
- const start = signedTwipsAttr(attrs.indentStartTwips);
6359
- const end = signedTwipsAttr(attrs.indentEndTwips);
6360
- const firstLine = twipsAttr(attrs.firstLineTwips);
6361
- const hanging = twipsAttr(attrs.hangingTwips);
8626
+ const spacingBefore = twipsAttr(attrs2.spacingBeforeTwips);
8627
+ const spacingAfter = twipsAttr(attrs2.spacingAfterTwips);
8628
+ const lineSpacing = signedTwipsAttr(attrs2.lineSpacingTwips);
8629
+ const left = signedTwipsAttr(attrs2.indentLeftTwips);
8630
+ const right = signedTwipsAttr(attrs2.indentRightTwips);
8631
+ const start = signedTwipsAttr(attrs2.indentStartTwips);
8632
+ const end = signedTwipsAttr(attrs2.indentEndTwips);
8633
+ const firstLine = twipsAttr(attrs2.firstLineTwips);
8634
+ const hanging = twipsAttr(attrs2.hangingTwips);
6362
8635
  if (spacingBefore !== void 0) result.spacingBeforeTwips = spacingBefore;
6363
8636
  if (spacingAfter !== void 0) result.spacingAfterTwips = spacingAfter;
6364
8637
  if (lineSpacing !== void 0) result.lineSpacingTwips = lineSpacing;
@@ -6371,6 +8644,60 @@ function paragraphTwipsFromAttrs(attrs) {
6371
8644
  return result;
6372
8645
  }
6373
8646
 
8647
+ // docx/content-control-model.ts
8648
+ var isContentControlLocked = (control, scope) => {
8649
+ if (!control?.lock) return false;
8650
+ return scope === "content" ? control.lock === "contentLocked" || control.lock === "sdtContentLocked" : control.lock === "sdtLocked" || control.lock === "sdtContentLocked";
8651
+ };
8652
+
8653
+ // docx/content-control-edit.ts
8654
+ var DEFAULT_GLYPHS = {
8655
+ checked: { code: "2612", font: "MS Gothic" },
8656
+ unchecked: { code: "2610", font: "MS Gothic" }
8657
+ };
8658
+ var glyphText = (code) => String.fromCodePoint(Number.parseInt(code, 16) || 9744);
8659
+ var canEditControlContent = (control) => !isContentControlLocked(control, "content");
8660
+ function checkboxState(control, checked) {
8661
+ const glyph2 = (checked ? control.checkedGlyph : control.uncheckedGlyph) ?? (checked ? DEFAULT_GLYPHS.checked : DEFAULT_GLYPHS.unchecked);
8662
+ return {
8663
+ control: { ...control, checked },
8664
+ text: glyphText(glyph2.code),
8665
+ ...glyph2.font ? { font: glyph2.font } : {}
8666
+ };
8667
+ }
8668
+ var toggleCheckbox = (control) => checkboxState(control, !control.checked);
8669
+ function selectListItem(control, index) {
8670
+ const item = control.items?.[index];
8671
+ if (!item) return void 0;
8672
+ const { showingPlaceholder: _placeholder, ...rest } = control;
8673
+ return { control: rest, text: item.display };
8674
+ }
8675
+ var fullDateOf = (date) => `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}T00:00:00Z`;
8676
+ function setControlDate(control, date) {
8677
+ const { showingPlaceholder: _placeholder, ...rest } = control;
8678
+ return {
8679
+ control: { ...rest, fullDate: fullDateOf(date) },
8680
+ text: formatWordDate(date, control.dateFormat ?? "M/d/yyyy", control.dateLocale ?? "en-US")
8681
+ };
8682
+ }
8683
+ function defaultPlaceholder(control) {
8684
+ switch (control.kind) {
8685
+ case "date":
8686
+ return "Click or tap to enter a date.";
8687
+ case "dropDownList":
8688
+ case "comboBox":
8689
+ return "Choose an item.";
8690
+ case "picture":
8691
+ return "";
8692
+ default:
8693
+ return "Click or tap here to enter text.";
8694
+ }
8695
+ }
8696
+ function withValue(control) {
8697
+ const { showingPlaceholder: _placeholder, ...rest } = control;
8698
+ return rest;
8699
+ }
8700
+
6374
8701
  // docx/layout/ligatures.ts
6375
8702
  function ligatureCss(value) {
6376
8703
  const enabled2 = (token) => value === "all" || value.toLowerCase().includes(token);
@@ -6451,9 +8778,9 @@ var runPropertiesMark = {
6451
8778
  parseDOM: [
6452
8779
  {
6453
8780
  tag: "span[data-run-props]",
6454
- getAttrs: (el3) => {
8781
+ getAttrs: (el4) => {
6455
8782
  try {
6456
- return { props: JSON.parse(el3.dataset.runProps || "null") };
8783
+ return { props: JSON.parse(el4.dataset.runProps || "null") };
6457
8784
  } catch {
6458
8785
  return { props: null };
6459
8786
  }
@@ -6533,6 +8860,8 @@ function applyMarkFormatting(run, child) {
6533
8860
  }
6534
8861
  const commentIds = commentIdsFromMarks(child.marks);
6535
8862
  if (commentIds.length) run.commentIds = commentIds;
8863
+ const control = propertyOfMark(child, "contentControl");
8864
+ if (control?.attrs.data) run.contentControl = JSON.parse(String(control.attrs.data));
6536
8865
  const field = propertyOfMark(child, "field");
6537
8866
  if (field)
6538
8867
  run.field = {
@@ -6602,6 +8931,12 @@ function marksForRun(run, schema) {
6602
8931
  color: run.color || null
6603
8932
  })
6604
8933
  );
8934
+ if (run.contentControl)
8935
+ marks.push(
8936
+ expectDefined(schema.marks.contentControl, "contentControl mark").create({
8937
+ data: JSON.stringify(run.contentControl)
8938
+ })
8939
+ );
6605
8940
  if (run.field)
6606
8941
  marks.push(
6607
8942
  expectDefined(schema.marks.field, "field mark").create({
@@ -6718,7 +9053,8 @@ function runToInlineNodes(run, schema, noteNumber) {
6718
9053
  textBoxEditable: run.image.textBoxEditable ?? null,
6719
9054
  textBoxBorder: run.image.textBoxBorder ?? null,
6720
9055
  diagram: run.image.diagram ? JSON.stringify(run.image.diagram) : null,
6721
- chart: run.image.chart ? JSON.stringify(run.image.chart) : null
9056
+ chart: run.image.chart ? JSON.stringify(run.image.chart) : null,
9057
+ shape: run.image.shape ? JSON.stringify(run.image.shape) : null
6722
9058
  },
6723
9059
  void 0,
6724
9060
  marks2
@@ -6803,6 +9139,7 @@ function appendInlineNode(runs, child) {
6803
9139
  ...child.attrs.unsupported ? { unsupported: child.attrs.unsupported } : {},
6804
9140
  ...typeof child.attrs.diagram === "string" ? { diagram: JSON.parse(child.attrs.diagram) } : {},
6805
9141
  ...typeof child.attrs.chart === "string" ? { chart: JSON.parse(child.attrs.chart) } : {},
9142
+ ...typeof child.attrs.shape === "string" ? { shape: JSON.parse(child.attrs.shape) } : {},
6806
9143
  ...typeof child.attrs.placement === "string" ? { placement: JSON.parse(child.attrs.placement) } : {},
6807
9144
  ...typeof child.attrs.textBoxText === "string" ? { textBoxText: JSON.parse(child.attrs.textBoxText) } : {},
6808
9145
  ...child.attrs.textBoxEditable ? { textBoxEditable: true } : {},
@@ -6840,7 +9177,7 @@ function appendInlineNode(runs, child) {
6840
9177
  const sameComments = JSON.stringify(previous?.commentIds) === JSON.stringify(run.commentIds);
6841
9178
  const sameLink2 = JSON.stringify(previous?.link ?? null) === JSON.stringify(run.link ?? null);
6842
9179
  const sameExtra = JSON.stringify(previous && extraRunProperties(previous)) === JSON.stringify(extraRunProperties(run));
6843
- if (previous && !previous.break && !previous.image && !previous.equation && !previous.noteReference && !previous.fieldChar && previous.fieldCode === void 0 && JSON.stringify(previous.field) === JSON.stringify(run.field) && sameRevision && sameComments && sameExtra && sameLink2 && fields.every((field) => previous[field] === run[field]))
9180
+ if (previous && !previous.break && !previous.image && !previous.equation && !previous.noteReference && !previous.fieldChar && previous.fieldCode === void 0 && JSON.stringify(previous.field) === JSON.stringify(run.field) && JSON.stringify(previous.contentControl) === JSON.stringify(run.contentControl) && sameRevision && sameComments && sameExtra && sameLink2 && fields.every((field) => previous[field] === run[field]))
6844
9181
  previous.text += run.text;
6845
9182
  else runs.push(run);
6846
9183
  }
@@ -6863,8 +9200,8 @@ var RUN_FORMAT_MARKS = /* @__PURE__ */ new Set([
6863
9200
  function setInlineRunFormatting(tr, pos, run) {
6864
9201
  const node = tr.doc.nodeAt(pos);
6865
9202
  const projected = runToInlineNodes(run, tr.doc.type.schema)[0];
6866
- const attrs = updatedInlineRunAttributes(node, projected.attrs.format);
6867
- for (const [key, value] of Object.entries(attrs))
9203
+ const attrs2 = updatedInlineRunAttributes(node, projected.attrs.format);
9204
+ for (const [key, value] of Object.entries(attrs2))
6868
9205
  if (node.attrs[key] !== value) tr.setNodeAttribute(pos, key, value);
6869
9206
  for (const mark of node.marks)
6870
9207
  if (RUN_FORMAT_MARKS.has(mark.type.name)) tr.removeMark(pos, pos + node.nodeSize, mark.type);
@@ -7496,8 +9833,8 @@ var WordYjsInlineCommentAnchors = class {
7496
9833
  capture(doc, from, to, mapping) {
7497
9834
  const ranges = [];
7498
9835
  const relative = (pos, assoc) => {
7499
- const position = yProsemirror.absolutePositionToRelativePosition(pos, this.fragment, mapping);
7500
- const absolute = Y2__namespace.createAbsolutePositionFromRelativePosition(position, this.fragment.doc);
9836
+ const position2 = yProsemirror.absolutePositionToRelativePosition(pos, this.fragment, mapping);
9837
+ const absolute = Y2__namespace.createAbsolutePositionFromRelativePosition(position2, this.fragment.doc);
7501
9838
  if (!absolute) throw new Error("Cannot resolve an inline comment anchor.");
7502
9839
  return Array.from(
7503
9840
  Y2__namespace.encodeRelativePosition(
@@ -7706,8 +10043,8 @@ function removeSharedAnchor(fragment, id) {
7706
10043
  let offset = 0;
7707
10044
  for (const part of child.toDelta()) {
7708
10045
  const length = typeof part.insert === "string" ? part.insert.length : 1;
7709
- for (const [key, attrs] of Object.entries(part.attributes ?? {})) {
7710
- if (key.startsWith("comment--") && Array.isArray(attrs.ids) && attrs.ids.includes(id))
10046
+ for (const [key, attrs2] of Object.entries(part.attributes ?? {})) {
10047
+ if (key.startsWith("comment--") && Array.isArray(attrs2.ids) && attrs2.ids.includes(id))
7711
10048
  child.format(offset, length, { [key]: null });
7712
10049
  }
7713
10050
  offset += length;
@@ -7764,10 +10101,10 @@ function guardDeletedNodeSelection(doc, view, binding) {
7764
10101
  doc.on("beforeObserverCalls", guard);
7765
10102
  return () => doc.off("beforeObserverCalls", guard);
7766
10103
  }
7767
- function wordYjsDocumentAttributes(attrs, canWrite) {
10104
+ function wordYjsDocumentAttributes(attrs2, canWrite) {
7768
10105
  const patch = (state) => {
7769
10106
  const tr = state.tr;
7770
- for (const [key, value] of attrs.entries()) {
10107
+ for (const [key, value] of attrs2.entries()) {
7771
10108
  if (key !== "commentThreads" && key in (state.doc.type.spec.attrs ?? {}) && JSON.stringify(state.doc.attrs[key]) !== JSON.stringify(value))
7772
10109
  tr.setDocAttribute(key, value);
7773
10110
  }
@@ -7784,18 +10121,18 @@ function wordYjsDocumentAttributes(attrs, canWrite) {
7784
10121
  binding?.mux(() => view.dispatch(tr));
7785
10122
  }
7786
10123
  };
7787
- attrs.observe(changed);
10124
+ attrs2.observe(changed);
7788
10125
  return {
7789
10126
  update: (next, previous) => {
7790
10127
  if (previous.doc.attrs === next.state.doc.attrs || !canWrite()) return;
7791
- attrs.doc.transact((transaction) => {
10128
+ attrs2.doc.transact((transaction) => {
7792
10129
  transaction.meta.set("addToHistory", thisPlugin.getState(next.state));
7793
10130
  for (const [key, value] of Object.entries(next.state.doc.attrs))
7794
- if (key !== "commentThreads" && JSON.stringify(attrs.get(key)) !== JSON.stringify(value))
7795
- attrs.set(key, value);
10131
+ if (key !== "commentThreads" && JSON.stringify(attrs2.get(key)) !== JSON.stringify(value))
10132
+ attrs2.set(key, value);
7796
10133
  }, yProsemirror.ySyncPluginKey);
7797
10134
  },
7798
- destroy: () => attrs.unobserve(changed)
10135
+ destroy: () => attrs2.unobserve(changed)
7799
10136
  };
7800
10137
  }
7801
10138
  });
@@ -8046,6 +10383,8 @@ function tableStructureGuardPlugin() {
8046
10383
  if (child.type !== other.type) return false;
8047
10384
  if (child.type.name === "paragraph") {
8048
10385
  if (child.attrs.id !== other.attrs.id) return false;
10386
+ } else if (child.type.name === "table") {
10387
+ if (!child.sameMarkup(other) || !sameStructure(child, other)) return false;
8049
10388
  } else if (!child.eq(other)) return false;
8050
10389
  }
8051
10390
  }
@@ -8091,8 +10430,8 @@ function restoreSectionParts(layout, json, blocks) {
8091
10430
  const base = layout.at(-1);
8092
10431
  if (!base) return layout;
8093
10432
  const sources = parts.map((part, i) => {
8094
- const { headers: _headers, footers: _footers, ...geometry } = layout[i] ?? base;
8095
- return { ...geometry, ...part };
10433
+ const { headers: _headers, footers: _footers, ...geometry2 } = layout[i] ?? base;
10434
+ return { ...geometry2, ...part };
8096
10435
  });
8097
10436
  return sectionsFromLayout(sectionLayoutJson(layout), sources, blocks);
8098
10437
  }
@@ -8129,10 +10468,10 @@ var insertWordHardBreak = (state, dispatch, view) => {
8129
10468
  // docx/ui/chart-spec.ts
8130
10469
  var SVG_NS2 = "http://www.w3.org/2000/svg";
8131
10470
  function elementSpec(element, root) {
8132
- const attrs = {};
10471
+ const attrs2 = {};
8133
10472
  for (const attr2 of Array.from(element.attributes)) {
8134
10473
  if (attr2.name === "xmlns" || attr2.name.startsWith("xmlns:") || /^on/i.test(attr2.name)) continue;
8135
- attrs[attr2.name] = attr2.value;
10474
+ attrs2[attr2.name] = attr2.value;
8136
10475
  }
8137
10476
  const children3 = [];
8138
10477
  for (const child of Array.from(element.childNodes)) {
@@ -8140,7 +10479,7 @@ function elementSpec(element, root) {
8140
10479
  else if (child.nodeType === 3 && child.nodeValue) children3.push(child.nodeValue);
8141
10480
  }
8142
10481
  const tag = root ? `${SVG_NS2} ${element.localName}` : element.localName;
8143
- return [tag, attrs, ...children3];
10482
+ return [tag, attrs2, ...children3];
8144
10483
  }
8145
10484
  function svgMarkupSpec(svg) {
8146
10485
  return elementSpec(parseXml(svg, { label: "Chart SVG" }).documentElement, true);
@@ -8157,9 +10496,9 @@ function nodeChart(node) {
8157
10496
  function chartNodeSpec(node, theme) {
8158
10497
  const width = Number(node.attrs.widthPx) || 96;
8159
10498
  const height = Number(node.attrs.heightPx) || 96;
8160
- const paint = docxChartPaint(nodeChart(node), width, height, theme);
10499
+ const paint2 = docxChartPaint(nodeChart(node), width, height, theme);
8161
10500
  const style = `width:${width}px;height:${height}px`;
8162
- if (!paint.svg)
10501
+ if (!paint2.svg)
8163
10502
  return [
8164
10503
  "span",
8165
10504
  {
@@ -8169,7 +10508,7 @@ function chartNodeSpec(node, theme) {
8169
10508
  class: "dve-image-placeholder",
8170
10509
  style
8171
10510
  },
8172
- paint.label
10511
+ paint2.label
8173
10512
  ];
8174
10513
  return [
8175
10514
  "span",
@@ -8178,9 +10517,9 @@ function chartNodeSpec(node, theme) {
8178
10517
  ...inlineRunPropertiesDomAttrs(node),
8179
10518
  class: "dve-chart",
8180
10519
  style,
8181
- title: paint.label
10520
+ title: paint2.label
8182
10521
  },
8183
- svgMarkupSpec(paint.svg)
10522
+ svgMarkupSpec(paint2.svg)
8184
10523
  ];
8185
10524
  }
8186
10525
 
@@ -8238,22 +10577,24 @@ var imageNodeSpec = {
8238
10577
  /** A SmartArt graphic (`DocxDiagram`) as JSON; shown read-only by the SmartArt node view. */
8239
10578
  diagram: { default: null },
8240
10579
  /** A chart (`DocxChart`) as JSON; painted read-only from its cached values (`chart-spec.ts`). */
8241
- chart: { default: null }
10580
+ chart: { default: null },
10581
+ /** A drawing shape (`ShapeSpec`) as JSON; drawn as SVG by the shape node view. */
10582
+ shape: { default: null }
8242
10583
  },
8243
10584
  parseDOM: [
8244
10585
  {
8245
10586
  tag: "img[data-docx-image], span[data-docx-image-placeholder]",
8246
- getAttrs: (el3) => ({
8247
- format: el3.dataset.runProperties ?? null,
8248
- relId: el3.dataset.relId || "",
8249
- partName: el3.dataset.partName || "",
8250
- contentType: el3.dataset.contentType || "",
8251
- widthPx: Number(el3.dataset.widthPx) || 96,
8252
- heightPx: Number(el3.dataset.heightPx) || 96,
8253
- altText: el3.getAttribute("alt") || null,
8254
- title: el3.getAttribute("title") || null,
8255
- anchored: el3.dataset.anchored === "1",
8256
- unsupported: el3.dataset.unsupported || null
10587
+ getAttrs: (el4) => ({
10588
+ format: el4.dataset.runProperties ?? null,
10589
+ relId: el4.dataset.relId || "",
10590
+ partName: el4.dataset.partName || "",
10591
+ contentType: el4.dataset.contentType || "",
10592
+ widthPx: Number(el4.dataset.widthPx) || 96,
10593
+ heightPx: Number(el4.dataset.heightPx) || 96,
10594
+ altText: el4.getAttribute("alt") || null,
10595
+ title: el4.getAttribute("title") || null,
10596
+ anchored: el4.dataset.anchored === "1",
10597
+ unsupported: el4.dataset.unsupported || null
8257
10598
  })
8258
10599
  }
8259
10600
  ],
@@ -8304,10 +10645,10 @@ var linkMarkSpec = {
8304
10645
  parseDOM: [
8305
10646
  {
8306
10647
  tag: "a[data-docx-link]",
8307
- getAttrs: (el3) => ({
8308
- href: el3.dataset.href || (el3.dataset.anchor ? null : el3.getAttribute("href")) || null,
8309
- anchor: el3.dataset.anchor || null,
8310
- tooltip: el3.getAttribute("title") || null
10648
+ getAttrs: (el4) => ({
10649
+ href: el4.dataset.href || (el4.dataset.anchor ? null : el4.getAttribute("href")) || null,
10650
+ anchor: el4.dataset.anchor || null,
10651
+ tooltip: el4.getAttribute("title") || null
8311
10652
  })
8312
10653
  }
8313
10654
  ],
@@ -8535,32 +10876,33 @@ var PARAGRAPH_KEEP_KEYS = [
8535
10876
  "contextualSpacing",
8536
10877
  "suppressLineNumbers"
8537
10878
  ];
8538
- function paragraphFromAttrs(attrs, id, runs) {
10879
+ function paragraphFromAttrs(attrs2, id, runs) {
8539
10880
  return {
8540
10881
  type: "paragraph",
8541
10882
  id,
8542
10883
  runs,
8543
- ...attrs.restoredParagraphPropertiesXml ? { restoredParagraphPropertiesXml: String(attrs.restoredParagraphPropertiesXml) } : {},
8544
- ...attrs.sourceParagraphPropertiesXml ? { sourceParagraphPropertiesXml: String(attrs.sourceParagraphPropertiesXml) } : {},
8545
- ...attrs.markRevision ? { markRevision: structuredClone(attrs.markRevision) } : {},
8546
- ...attrs.formatRevision ? { formatRevision: structuredClone(attrs.formatRevision) } : {},
8547
- ...attrs.align != null ? { align: attrs.align } : {},
8548
- ...attrs.justification != null ? { justification: attrs.justification } : {},
8549
- ...attrs.outlineLevel != null ? { outlineLevel: Number(attrs.outlineLevel) } : {},
8550
- ...attrs.direction != null ? { direction: attrs.direction } : {},
8551
- ...attrs.style ? { style: attrs.style } : {},
8552
- ...paragraphTwipsFromAttrs(attrs),
8553
- ...attrs.lineSpacingRule != null ? { lineSpacingRule: attrs.lineSpacingRule } : {},
8554
- ...attrs.numId != null ? { numbering: { numId: attrs.numId, level: attrs.ilvl ?? 0 } } : {},
8555
- ...attrs.pageBreakBefore != null ? { pageBreakBefore: Boolean(attrs.pageBreakBefore) } : {},
8556
- ...attrs.tabStops?.length ? { tabStops: structuredClone(attrs.tabStops) } : {},
10884
+ ...attrs2.restoredParagraphPropertiesXml ? { restoredParagraphPropertiesXml: String(attrs2.restoredParagraphPropertiesXml) } : {},
10885
+ ...attrs2.sourceParagraphPropertiesXml ? { sourceParagraphPropertiesXml: String(attrs2.sourceParagraphPropertiesXml) } : {},
10886
+ ...attrs2.markRevision ? { markRevision: structuredClone(attrs2.markRevision) } : {},
10887
+ ...attrs2.formatRevision ? { formatRevision: structuredClone(attrs2.formatRevision) } : {},
10888
+ ...attrs2.align != null ? { align: attrs2.align } : {},
10889
+ ...attrs2.justification != null ? { justification: attrs2.justification } : {},
10890
+ ...attrs2.outlineLevel != null ? { outlineLevel: Number(attrs2.outlineLevel) } : {},
10891
+ ...attrs2.direction != null ? { direction: attrs2.direction } : {},
10892
+ ...attrs2.style ? { style: attrs2.style } : {},
10893
+ ...paragraphTwipsFromAttrs(attrs2),
10894
+ ...attrs2.lineSpacingRule != null ? { lineSpacingRule: attrs2.lineSpacingRule } : {},
10895
+ ...attrs2.numId != null ? { numbering: { numId: attrs2.numId, level: attrs2.ilvl ?? 0 } } : {},
10896
+ ...attrs2.pageBreakBefore != null ? { pageBreakBefore: Boolean(attrs2.pageBreakBefore) } : {},
10897
+ ...attrs2.tabStops?.length ? { tabStops: structuredClone(attrs2.tabStops) } : {},
8557
10898
  ...Object.fromEntries(
8558
- PARAGRAPH_KEEP_KEYS.filter((key) => attrs[key] != null).map((key) => [key, attrs[key]])
10899
+ PARAGRAPH_KEEP_KEYS.filter((key) => attrs2[key] != null).map((key) => [key, attrs2[key]])
8559
10900
  ),
8560
- ...attrs.dropCap ? { dropCap: { ...attrs.dropCap } } : {},
8561
- ...attrs.borders ? { borders: structuredClone(attrs.borders) } : {},
8562
- ...attrs.shadingFill ? { shadingFill: attrs.shadingFill } : {},
8563
- ...attrs.bookmarks?.length ? { bookmarks: [...attrs.bookmarks] } : {}
10901
+ ...attrs2.dropCap ? { dropCap: { ...attrs2.dropCap } } : {},
10902
+ ...attrs2.borders ? { borders: structuredClone(attrs2.borders) } : {},
10903
+ ...attrs2.shadingFill ? { shadingFill: attrs2.shadingFill } : {},
10904
+ ...attrs2.bookmarks?.length ? { bookmarks: [...attrs2.bookmarks] } : {},
10905
+ ...attrs2.contentControl ? { contentControl: structuredClone(attrs2.contentControl) } : {}
8564
10906
  };
8565
10907
  }
8566
10908
  function paragraphAttrs(paragraph) {
@@ -8597,7 +10939,8 @@ function paragraphAttrs(paragraph) {
8597
10939
  dropCap: paragraph.dropCap ?? null,
8598
10940
  borders: paragraph.borders ?? null,
8599
10941
  shadingFill: paragraph.shadingFill ?? null,
8600
- bookmarks: paragraph.bookmarks ?? []
10942
+ bookmarks: paragraph.bookmarks ?? [],
10943
+ contentControl: paragraph.contentControl ?? null
8601
10944
  };
8602
10945
  }
8603
10946
 
@@ -8633,8 +10976,8 @@ var reviewMarks = {
8633
10976
  parseDOM: [
8634
10977
  {
8635
10978
  tag: "span[data-inline-comment-ids]",
8636
- getAttrs: (el3) => ({
8637
- ids: (el3.dataset.inlineCommentIds ?? "").split(",").filter(Boolean)
10979
+ getAttrs: (el4) => ({
10980
+ ids: (el4.dataset.inlineCommentIds ?? "").split(",").filter(Boolean)
8638
10981
  })
8639
10982
  }
8640
10983
  ],
@@ -8662,11 +11005,11 @@ var reviewMarks = {
8662
11005
  parseDOM: [
8663
11006
  {
8664
11007
  tag: "ins[data-revision-id]",
8665
- getAttrs: (el3) => ({
8666
- author: el3.dataset.author || "",
8667
- date: el3.dataset.date || null,
8668
- dateUtc: el3.dataset.dateUtc || null,
8669
- id: el3.dataset.revisionId || "",
11008
+ getAttrs: (el4) => ({
11009
+ author: el4.dataset.author || "",
11010
+ date: el4.dataset.date || null,
11011
+ dateUtc: el4.dataset.dateUtc || null,
11012
+ id: el4.dataset.revisionId || "",
8670
11013
  move: null
8671
11014
  })
8672
11015
  }
@@ -8697,11 +11040,11 @@ var reviewMarks = {
8697
11040
  parseDOM: [
8698
11041
  {
8699
11042
  tag: "del[data-revision-id]",
8700
- getAttrs: (el3) => ({
8701
- author: el3.dataset.author || "",
8702
- date: el3.dataset.date || null,
8703
- dateUtc: el3.dataset.dateUtc || null,
8704
- id: el3.dataset.revisionId || "",
11043
+ getAttrs: (el4) => ({
11044
+ author: el4.dataset.author || "",
11045
+ date: el4.dataset.date || null,
11046
+ dateUtc: el4.dataset.dateUtc || null,
11047
+ id: el4.dataset.revisionId || "",
8705
11048
  move: null
8706
11049
  })
8707
11050
  }
@@ -8727,8 +11070,8 @@ var reviewMarks = {
8727
11070
  parseDOM: [
8728
11071
  {
8729
11072
  tag: "span[data-comment-ids]",
8730
- getAttrs: (el3) => ({
8731
- ids: (el3.dataset.commentIds || "").split(",").filter(Boolean)
11073
+ getAttrs: (el4) => ({
11074
+ ids: (el4.dataset.commentIds || "").split(",").filter(Boolean)
8732
11075
  })
8733
11076
  }
8734
11077
  ],
@@ -8929,7 +11272,7 @@ function resolveParagraphFormatting(tr, pos, mode) {
8929
11272
  if (!node) return;
8930
11273
  const revision = paragraphFormattingRevision(node);
8931
11274
  if (!revision) return;
8932
- const attrs = { ...node.attrs, formatRevision: null };
11275
+ const attrs2 = { ...node.attrs, formatRevision: null };
8933
11276
  if (mode === "reject") {
8934
11277
  const paragraph = {
8935
11278
  type: "paragraph",
@@ -8941,14 +11284,14 @@ function resolveParagraphFormatting(tr, pos, mode) {
8941
11284
  restoreParagraphFormatting(paragraph);
8942
11285
  for (const key of PARAGRAPH_FORMAT_KEYS)
8943
11286
  if (Object.hasOwn(node.attrs, key))
8944
- attrs[key] = paragraph[key] ?? node.type.spec.attrs?.[key]?.default ?? null;
8945
- attrs.numId = paragraph.numbering?.numId ?? null;
8946
- attrs.ilvl = paragraph.numbering?.level ?? null;
8947
- attrs.restoredParagraphPropertiesXml = paragraph.restoredParagraphPropertiesXml;
11287
+ attrs2[key] = paragraph[key] ?? node.type.spec.attrs?.[key]?.default ?? null;
11288
+ attrs2.numId = paragraph.numbering?.numId ?? null;
11289
+ attrs2.ilvl = paragraph.numbering?.level ?? null;
11290
+ attrs2.restoredParagraphPropertiesXml = paragraph.restoredParagraphPropertiesXml;
8948
11291
  if (paragraph.sourceParagraphPropertiesXml)
8949
- attrs.sourceParagraphPropertiesXml = paragraph.sourceParagraphPropertiesXml;
11292
+ attrs2.sourceParagraphPropertiesXml = paragraph.sourceParagraphPropertiesXml;
8950
11293
  }
8951
- tr.setNodeMarkup(pos, void 0, attrs);
11294
+ tr.setNodeMarkup(pos, void 0, attrs2);
8952
11295
  }
8953
11296
 
8954
11297
  // docx/ui/track-paragraph-formatting.ts
@@ -9189,22 +11532,22 @@ function applyTrackedReplace(transform, { from, to, slice }, author, date, nextR
9189
11532
  const schema = transform.doc.type.schema;
9190
11533
  const change = { deletionIds: [], deletedText: "", insertedText: "" };
9191
11534
  const segments = segmentsOf(transform.doc, from, to, author);
9192
- const keptLength = segments.filter((segment) => !segment.ownInsertion).reduce((sum, segment) => sum + (segment.to - segment.from), 0);
11535
+ const keptLength = segments.filter((segment2) => !segment2.ownInsertion).reduce((sum, segment2) => sum + (segment2.to - segment2.from), 0);
9193
11536
  const insertAt = from + keptLength;
9194
- for (const segment of segments)
9195
- if (!segment.ownInsertion)
9196
- change.deletedText += transform.doc.textBetween(segment.from, segment.to, "\n");
9197
- for (const segment of [...segments].reverse()) {
9198
- if (segment.ownInsertion) transform.delete(segment.from, segment.to);
11537
+ for (const segment2 of segments)
11538
+ if (!segment2.ownInsertion)
11539
+ change.deletedText += transform.doc.textBetween(segment2.from, segment2.to, "\n");
11540
+ for (const segment2 of [...segments].reverse()) {
11541
+ if (segment2.ownInsertion) transform.delete(segment2.from, segment2.to);
9199
11542
  else {
9200
11543
  const id = nextRevisionId();
9201
11544
  change.deletionIds.push(id);
9202
11545
  transform.addMark(
9203
- segment.from,
9204
- segment.to,
11546
+ segment2.from,
11547
+ segment2.to,
9205
11548
  expectDefined(schema.marks.deletion, "deletion mark").create({ author, date, id })
9206
11549
  );
9207
- canonicalizeHardBreaks(transform, segment.from, segment.to);
11550
+ canonicalizeHardBreaks(transform, segment2.from, segment2.to);
9208
11551
  }
9209
11552
  }
9210
11553
  if (slice.size) {
@@ -9406,8 +11749,8 @@ function partModel(doc) {
9406
11749
  const model = { ...createDocument(), blocks: [] };
9407
11750
  if (typeof doc.attrs.sectionParts !== "string") return model;
9408
11751
  const parts = JSON.parse(doc.attrs.sectionParts);
9409
- const geometry = sectionsOf(model)[0];
9410
- return { ...model, sections: parts.map((part) => ({ ...geometry, ...part })) };
11752
+ const geometry2 = sectionsOf(model)[0];
11753
+ return { ...model, sections: parts.map((part) => ({ ...geometry2, ...part })) };
9411
11754
  }
9412
11755
  function hasSectionPartRevisions(doc) {
9413
11756
  return listRevisions(partModel(doc)).length > 0;
@@ -9775,6 +12118,15 @@ var RIBBON_ACTION_IDS = [
9775
12118
  "line-numbers",
9776
12119
  "multilevel-list",
9777
12120
  "drop-cap",
12121
+ "content-control",
12122
+ "shapes",
12123
+ "shape-fill",
12124
+ "shape-outline",
12125
+ "shape-outline-weight",
12126
+ "wrap-text",
12127
+ "shape-height",
12128
+ "shape-width",
12129
+ "equation",
9778
12130
  "change-case",
9779
12131
  "format-painter",
9780
12132
  "show-paragraph-marks",
@@ -9947,6 +12299,15 @@ var RIBBON_ACTION_LABELS = {
9947
12299
  "line-numbers": "Line numbers",
9948
12300
  "multilevel-list": "Multilevel list",
9949
12301
  "drop-cap": "Drop cap",
12302
+ "content-control": "Content control",
12303
+ shapes: "Shapes",
12304
+ "shape-fill": "Shape fill",
12305
+ "shape-outline": "Shape outline",
12306
+ "shape-outline-weight": "Shape outline weight",
12307
+ "wrap-text": "Wrap text",
12308
+ "shape-height": "Shape height (inches)",
12309
+ "shape-width": "Shape width (inches)",
12310
+ equation: "Equation",
9950
12311
  "change-case": "Change case",
9951
12312
  "format-painter": "Format painter",
9952
12313
  "show-paragraph-marks": "Show paragraph marks",
@@ -10097,7 +12458,7 @@ function swatchColor(value) {
10097
12458
  // docx/ui/run-compare.ts
10098
12459
  var sameJson2 = (left, right) => JSON.stringify(left ?? null) === JSON.stringify(right ?? null);
10099
12460
  function sameRevisionMeta(left, right) {
10100
- return JSON.stringify(left.revision) === JSON.stringify(right.revision) && JSON.stringify(left.commentIds) === JSON.stringify(right.commentIds) && JSON.stringify(extraRunProperties(left)) === JSON.stringify(extraRunProperties(right)) && JSON.stringify(left.field) === JSON.stringify(right.field) && left.fieldChar === right.fieldChar && left.fieldCode === right.fieldCode;
12461
+ return JSON.stringify(left.revision) === JSON.stringify(right.revision) && JSON.stringify(left.commentIds) === JSON.stringify(right.commentIds) && JSON.stringify(extraRunProperties(left)) === JSON.stringify(extraRunProperties(right)) && JSON.stringify(left.field) === JSON.stringify(right.field) && JSON.stringify(left.contentControl) === JSON.stringify(right.contentControl) && left.fieldChar === right.fieldChar && left.fieldCode === right.fieldCode;
10101
12462
  }
10102
12463
  function sameRuns(left, right) {
10103
12464
  const compact = (runs) => runs.reduce((result, run) => {
@@ -10199,6 +12560,27 @@ var wordHighlightColors = {
10199
12560
  darkGray: "#808080",
10200
12561
  lightGray: "#c0c0c0"
10201
12562
  };
12563
+ function contentControlDom(data) {
12564
+ let control = {};
12565
+ try {
12566
+ control = JSON.parse(data);
12567
+ } catch {
12568
+ control = {};
12569
+ }
12570
+ return [
12571
+ "span",
12572
+ {
12573
+ class: "dve-sdt",
12574
+ "data-sdt": data,
12575
+ "data-sdt-id": String(control.id ?? ""),
12576
+ "data-sdt-kind": String(control.kind ?? "richText"),
12577
+ ...control.alias ? { "data-sdt-title": String(control.alias) } : {},
12578
+ ...control.showingPlaceholder ? { "data-sdt-placeholder": "1" } : {},
12579
+ ...control.lock ? { "data-sdt-lock": String(control.lock) } : {}
12580
+ },
12581
+ 0
12582
+ ];
12583
+ }
10202
12584
  var markSpecs = {
10203
12585
  bold: { parseDOM: [{ tag: "strong" }, { tag: "b" }], toDOM: () => ["strong", 0] },
10204
12586
  italic: { parseDOM: [{ tag: "em" }, { tag: "i" }], toDOM: () => ["em", 0] },
@@ -10212,8 +12594,8 @@ var markSpecs = {
10212
12594
  parseDOM: [
10213
12595
  {
10214
12596
  tag: 'span[style*="background-color"]',
10215
- getAttrs: (el3) => {
10216
- const color = el3.style.backgroundColor.toLowerCase();
12597
+ getAttrs: (el4) => {
12598
+ const color = el4.style.backgroundColor.toLowerCase();
10217
12599
  if (color === "white" || color === "rgb(255, 255, 255)" || color === "#ffffff")
10218
12600
  return false;
10219
12601
  const entry = Object.entries(wordHighlightColors).find(([, css]) => {
@@ -10250,20 +12632,20 @@ var markSpecs = {
10250
12632
  parseDOM: [
10251
12633
  {
10252
12634
  tag: "span[lang], span[data-docx-east-asia-language], span[data-docx-bidi-language]",
10253
- getAttrs: (el3) => ({
10254
- language: el3.getAttribute("lang"),
10255
- eastAsiaLanguage: el3.dataset.docxEastAsiaLanguage || null,
10256
- bidiLanguage: el3.dataset.docxBidiLanguage || null
12635
+ getAttrs: (el4) => ({
12636
+ language: el4.getAttribute("lang"),
12637
+ eastAsiaLanguage: el4.dataset.docxEastAsiaLanguage || null,
12638
+ bidiLanguage: el4.dataset.docxBidiLanguage || null
10257
12639
  })
10258
12640
  }
10259
12641
  ],
10260
12642
  toDOM: (mark) => {
10261
- const attrs = {};
10262
- if (mark.attrs.language) attrs.lang = mark.attrs.language;
12643
+ const attrs2 = {};
12644
+ if (mark.attrs.language) attrs2.lang = mark.attrs.language;
10263
12645
  if (mark.attrs.eastAsiaLanguage)
10264
- attrs["data-docx-east-asia-language"] = mark.attrs.eastAsiaLanguage;
10265
- if (mark.attrs.bidiLanguage) attrs["data-docx-bidi-language"] = mark.attrs.bidiLanguage;
10266
- return ["span", attrs, 0];
12646
+ attrs2["data-docx-east-asia-language"] = mark.attrs.eastAsiaLanguage;
12647
+ if (mark.attrs.bidiLanguage) attrs2["data-docx-bidi-language"] = mark.attrs.bidiLanguage;
12648
+ return ["span", attrs2, 0];
10267
12649
  }
10268
12650
  },
10269
12651
  runRtl: {
@@ -10283,14 +12665,14 @@ var markSpecs = {
10283
12665
  parseDOM: [
10284
12666
  {
10285
12667
  tag: "span",
10286
- getAttrs: (el3) => {
10287
- const style = el3.style;
10288
- const attrs = {
12668
+ getAttrs: (el4) => {
12669
+ const style = el4.style;
12670
+ const attrs2 = {
10289
12671
  family: pastedFontFamily(style.fontFamily),
10290
12672
  size: style.fontSize ? parseFontSize(style.fontSize) : null,
10291
12673
  color: pastedColor(style.color)
10292
12674
  };
10293
- return attrs.family || attrs.size || attrs.color ? attrs : false;
12675
+ return attrs2.family || attrs2.size || attrs2.color ? attrs2 : false;
10294
12676
  }
10295
12677
  }
10296
12678
  ],
@@ -10312,11 +12694,22 @@ var markSpecs = {
10312
12694
  parseDOM: [
10313
12695
  {
10314
12696
  tag: "span[data-docx-style]",
10315
- getAttrs: (el3) => ({ id: el3.dataset.docxStyle || null })
12697
+ getAttrs: (el4) => ({ id: el4.dataset.docxStyle || null })
10316
12698
  }
10317
12699
  ],
10318
12700
  toDOM: (mark) => ["span", { "data-docx-style": mark.attrs.id }, 0]
10319
12701
  },
12702
+ /** Inline content control (`w:sdt`): the whole control as JSON, drawn with Word's outline and title tab. */
12703
+ contentControl: {
12704
+ attrs: { data: { default: "" } },
12705
+ parseDOM: [
12706
+ {
12707
+ tag: "span[data-sdt]",
12708
+ getAttrs: (el4) => ({ data: el4.dataset.sdt || "" })
12709
+ }
12710
+ ],
12711
+ toDOM: (mark) => contentControlDom(String(mark.attrs.data))
12712
+ },
10320
12713
  /** Field result text: carries the field code so results can be recalculated and re-wrapped. */
10321
12714
  field: {
10322
12715
  attrs: { instr: { default: "" }, simple: { default: false } },
@@ -10324,9 +12717,9 @@ var markSpecs = {
10324
12717
  parseDOM: [
10325
12718
  {
10326
12719
  tag: "span[data-field]",
10327
- getAttrs: (el3) => ({
10328
- instr: el3.dataset.field || "",
10329
- simple: el3.dataset.fieldSimple === "1"
12720
+ getAttrs: (el4) => ({
12721
+ instr: el4.dataset.field || "",
12722
+ simple: el4.dataset.fieldSimple === "1"
10330
12723
  })
10331
12724
  }
10332
12725
  ],
@@ -10415,15 +12808,15 @@ function parseBordersJson(value) {
10415
12808
  }
10416
12809
  }
10417
12810
  var twipsPx = (value) => Number.isSafeInteger(value) ? `${Number(value) / 15}px` : null;
10418
- function tableStyle(attrs) {
10419
- const borders = parseBordersJson(attrs.borders);
10420
- const margins = marginValues(attrs.cellMargins);
12811
+ function tableStyle(attrs2) {
12812
+ const borders = parseBordersJson(attrs2.borders);
12813
+ const margins = marginValues(attrs2.cellMargins);
10421
12814
  const declarations = [
10422
12815
  "border-collapse:collapse",
10423
- twipsPx(attrs.widthTwips) && `width:${twipsPx(attrs.widthTwips)}`,
10424
- attrs.alignment === "center" && "margin-left:auto;margin-right:auto",
10425
- attrs.alignment === "right" && "margin-left:auto",
10426
- twipsPx(attrs.indentTwips) && attrs.alignment !== "center" && `margin-left:${twipsPx(attrs.indentTwips)}`,
12816
+ twipsPx(attrs2.widthTwips) && `width:${twipsPx(attrs2.widthTwips)}`,
12817
+ attrs2.alignment === "center" && "margin-left:auto;margin-right:auto",
12818
+ attrs2.alignment === "right" && "margin-left:auto",
12819
+ twipsPx(attrs2.indentTwips) && attrs2.alignment !== "center" && `margin-left:${twipsPx(attrs2.indentTwips)}`,
10427
12820
  // Cells without their own resolved borders (e.g. a table inserted in the editor) draw the
10428
12821
  // table's inside line; tables with no border information fall back to dashed gridlines.
10429
12822
  borders && `--dve-cell-border:${cssBorderSide(borders.insideH ?? borders.top) ?? "none"}`,
@@ -10453,14 +12846,14 @@ function cellPadding(value) {
10453
12846
  (side) => margins[side] === void 0 ? `var(--dve-cell-padding-${side}, ${DEFAULT_CELL_MARGINS[side] / 15}px)` : `${margins[side]}px`
10454
12847
  ).join(" ")}`;
10455
12848
  }
10456
- function tableCellStyle(attrs) {
10457
- const borders = parseBordersJson(attrs.borders);
10458
- const verticalAlign = attrs.verticalAlign === "center" ? "middle" : attrs.verticalAlign === "bottom" ? "bottom" : "top";
12849
+ function tableCellStyle(attrs2) {
12850
+ const borders = parseBordersJson(attrs2.borders);
12851
+ const verticalAlign = attrs2.verticalAlign === "center" ? "middle" : attrs2.verticalAlign === "bottom" ? "bottom" : "top";
10459
12852
  const declarations = [
10460
- cellPadding(attrs.margins),
12853
+ cellPadding(attrs2.margins),
10461
12854
  `vertical-align:${verticalAlign}`,
10462
- twipsPx(attrs.widthTwips) && `width:${twipsPx(attrs.widthTwips)}`,
10463
- typeof attrs.shadingFill === "string" && `background-color:${attrs.shadingFill}`,
12855
+ twipsPx(attrs2.widthTwips) && `width:${twipsPx(attrs2.widthTwips)}`,
12856
+ typeof attrs2.shadingFill === "string" && `background-color:${attrs2.shadingFill}`,
10464
12857
  ...["top", "bottom", "left", "right"].map(
10465
12858
  (side) => borders && (cssBorderSide(borders[side]) ? `border-${side}:${cssBorderSide(borders[side])}` : `border-${side}-style:none`)
10466
12859
  )
@@ -10622,6 +13015,224 @@ function fitZoomPercent(mode, viewport, page) {
10622
13015
  return Math.max(10, Math.min(500, Math.floor(ratio * 100)));
10623
13016
  }
10624
13017
 
13018
+ // docx/ui/content-control-spans.ts
13019
+ function controlOfMark(mark) {
13020
+ if (!mark?.attrs.data) return void 0;
13021
+ try {
13022
+ return JSON.parse(String(mark.attrs.data));
13023
+ } catch {
13024
+ return void 0;
13025
+ }
13026
+ }
13027
+ var markOf = (node) => node.marks.find((mark) => mark.type.name === "contentControl");
13028
+ function controlSpans(doc) {
13029
+ const spans = [];
13030
+ doc.descendants((node, pos) => {
13031
+ if (node.type.name === "paragraph" && node.attrs.contentControl) {
13032
+ const control2 = node.attrs.contentControl;
13033
+ const previous2 = spans.at(-1);
13034
+ if (previous2?.level === "block" && previous2.control.id === control2.id && previous2.to === pos)
13035
+ previous2.to = pos + node.nodeSize;
13036
+ else spans.push({ control: control2, level: "block", from: pos, to: pos + node.nodeSize });
13037
+ }
13038
+ if (!node.isInline) return true;
13039
+ const control = controlOfMark(markOf(node));
13040
+ if (!control) return false;
13041
+ const previous = spans.at(-1);
13042
+ if (previous?.level === "inline" && previous.control.id === control.id && previous.to === pos) {
13043
+ previous.to = pos + node.nodeSize;
13044
+ previous.control = control;
13045
+ } else spans.push({ control, level: "inline", from: pos, to: pos + node.nodeSize });
13046
+ return false;
13047
+ });
13048
+ return spans;
13049
+ }
13050
+ function controlAt(spans, pos, edges = false) {
13051
+ const inside = spans.filter((span) => pos > span.from && pos < span.to);
13052
+ const found = inside.find((span) => span.level === "inline") ?? inside[0];
13053
+ if (found || !edges) return found;
13054
+ return spans.find((span) => span.level === "inline" && (pos === span.from || pos === span.to));
13055
+ }
13056
+ var controlAtSelection = (state, edges = true) => controlAt(controlSpans(state.doc), state.selection.from, edges);
13057
+
13058
+ // docx/ui/content-control-commands.ts
13059
+ var CONTROL_EDIT_META = "dve-content-control";
13060
+ var PLACEHOLDER_STYLE = "PlaceholderText";
13061
+ var isPlaceholderStyle = (mark) => mark.type.name === "characterStyle" && mark.attrs.id === PLACEHOLDER_STYLE;
13062
+ function contentMarks(state, span, change) {
13063
+ const schema = state.schema;
13064
+ const first3 = state.doc.nodeAt(span.from);
13065
+ const kept = (first3?.marks ?? []).filter(
13066
+ (mark) => mark.type.name !== "contentControl" && !isPlaceholderStyle(mark)
13067
+ );
13068
+ const marks = change.font ? kept.filter((mark) => mark.type.name !== "font") : kept.filter(() => true);
13069
+ if (change.font) {
13070
+ const font = kept.find((mark) => mark.type.name === "font");
13071
+ marks.push(
13072
+ schema.marks.font.create({ size: null, color: null, ...font?.attrs, family: change.font })
13073
+ );
13074
+ }
13075
+ marks.push(schema.marks.contentControl.create({ data: JSON.stringify(change.control) }));
13076
+ return marks;
13077
+ }
13078
+ function replaceControlContent(state, span, change) {
13079
+ const tr = state.tr.replaceWith(
13080
+ span.from,
13081
+ span.to,
13082
+ state.schema.text(change.text, contentMarks(state, span, change))
13083
+ );
13084
+ return tr.setMeta(CONTROL_EDIT_META, true);
13085
+ }
13086
+ function updateControlProperties(state, span, control) {
13087
+ const tr = state.tr.setMeta(CONTROL_EDIT_META, true);
13088
+ if (span.level === "block") {
13089
+ state.doc.nodesBetween(span.from, span.to, (node, pos) => {
13090
+ if (node.type.name === "paragraph" && node.attrs.contentControl?.id === span.control.id)
13091
+ tr.setNodeMarkup(pos, void 0, { ...node.attrs, contentControl: control });
13092
+ return node.type.name !== "paragraph";
13093
+ });
13094
+ return tr;
13095
+ }
13096
+ const type = state.schema.marks.contentControl;
13097
+ tr.removeMark(span.from, span.to, type);
13098
+ return tr.addMark(span.from, span.to, type.create({ data: JSON.stringify(control) }));
13099
+ }
13100
+ var spanById = (state, id) => controlSpans(state.doc).find((span) => span.level === "inline" && span.control.id === id);
13101
+ function toggleCheckboxControl(state, id) {
13102
+ const span = spanById(state, id);
13103
+ if (!span || span.control.kind !== "checkbox" || !canEditControlContent(span.control))
13104
+ return void 0;
13105
+ return replaceControlContent(state, span, toggleCheckbox(span.control));
13106
+ }
13107
+ function chooseListItem(state, id, index) {
13108
+ const span = spanById(state, id);
13109
+ const change = span && canEditControlContent(span.control) && selectListItem(span.control, index);
13110
+ return span && change ? replaceControlContent(state, span, change) : void 0;
13111
+ }
13112
+ function chooseDate(state, id, date) {
13113
+ const span = spanById(state, id);
13114
+ if (!span || span.control.kind !== "date" || !canEditControlContent(span.control))
13115
+ return void 0;
13116
+ return replaceControlContent(state, span, setControlDate(span.control, date));
13117
+ }
13118
+ var placeholderChange = (control) => ({
13119
+ control: { ...control, showingPlaceholder: true },
13120
+ text: defaultPlaceholder(control)
13121
+ });
13122
+ function typeOverPlaceholder(state, from, text2, to = from) {
13123
+ const span = controlAt(controlSpans(state.doc), from, true);
13124
+ if (span?.level !== "inline") return void 0;
13125
+ const { control } = span;
13126
+ if (control.kind === "checkbox" || control.kind === "dropDownList") {
13127
+ const inside = from > span.from && from < span.to || from === span.from && to === span.to;
13128
+ if (inside || from === span.from && to > from) return "blocked";
13129
+ const type = state.schema.marks.contentControl;
13130
+ return state.tr.insertText(text2, from).removeMark(from, from + text2.length, type);
13131
+ }
13132
+ if (!control.showingPlaceholder) return void 0;
13133
+ if (!canEditControlContent(control)) return "blocked";
13134
+ const tr = replaceControlContent(state, span, { control: withValue(control), text: text2 });
13135
+ const end = tr.mapping.map(span.to);
13136
+ return tr.setSelection(prosemirrorState.TextSelection.near(tr.doc.resolve(end)));
13137
+ }
13138
+ function deleteToPlaceholder(state, direction) {
13139
+ const { selection } = state;
13140
+ const span = controlAt(controlSpans(state.doc), selection.from, true);
13141
+ if (span?.level !== "inline" || span.control.showingPlaceholder) return void 0;
13142
+ if (!canEditControlContent(span.control) || span.control.kind === "checkbox") return void 0;
13143
+ const [from, to] = selection.empty ? direction === "backward" ? [selection.from - 1, selection.from] : [selection.from, selection.from + 1] : [selection.from, selection.to];
13144
+ if (from > span.from || to < span.to) return void 0;
13145
+ return replaceControlContent(state, span, placeholderChange(span.control));
13146
+ }
13147
+ var newControlId = (doc) => {
13148
+ const used = new Set(controlSpans(doc).map((span) => span.control.id));
13149
+ let id;
13150
+ do
13151
+ id = String(Math.floor(Math.random() * 2 ** 31) + 1);
13152
+ while (used.has(id));
13153
+ return id;
13154
+ };
13155
+ function insertContentControl(state, kind, options = {}) {
13156
+ const type = state.schema.marks.contentControl;
13157
+ if (!type) return void 0;
13158
+ const { selection } = state;
13159
+ const base = {
13160
+ id: newControlId(state.doc),
13161
+ level: "inline",
13162
+ kind,
13163
+ ...options.alias ? { alias: options.alias } : {},
13164
+ ...options.tag ? { tag: options.tag } : {},
13165
+ ...options.items ? { items: options.items } : {},
13166
+ ...kind === "date" ? { dateFormat: options.dateFormat ?? "M/d/yyyy", dateLocale: "en-US" } : {}
13167
+ };
13168
+ const wrapsText = !selection.empty && (kind === "richText" || kind === "text");
13169
+ if (wrapsText) {
13170
+ return state.tr.addMark(selection.from, selection.to, type.create({ data: JSON.stringify(base) })).setMeta(CONTROL_EDIT_META, true);
13171
+ }
13172
+ const change = kind === "checkbox" ? checkboxState({ ...base, checked: false }, false) : placeholderChange(base);
13173
+ const marks = [type.create({ data: JSON.stringify(change.control) })];
13174
+ if (kind !== "checkbox" && state.schema.marks.characterStyle)
13175
+ marks.push(state.schema.marks.characterStyle.create({ id: PLACEHOLDER_STYLE }));
13176
+ if (change.font && state.schema.marks.font)
13177
+ marks.push(state.schema.marks.font.create({ family: change.font, size: null, color: null }));
13178
+ const start = state.selection.from;
13179
+ const tr = state.tr.replaceSelectionWith(state.schema.text(change.text, marks), false);
13180
+ if (kind !== "checkbox")
13181
+ tr.setSelection(prosemirrorState.TextSelection.create(tr.doc, start, start + change.text.length));
13182
+ return tr.setMeta(CONTROL_EDIT_META, true);
13183
+ }
13184
+ var isRemote = (tr) => tr.getMeta("y-sync$") !== void 0;
13185
+ var isRangeStep = (step) => step instanceof prosemirrorTransform.ReplaceStep || step instanceof prosemirrorTransform.ReplaceAroundStep || step instanceof prosemirrorTransform.AddMarkStep || step instanceof prosemirrorTransform.RemoveMarkStep;
13186
+ function violatesControlLock(tr, state) {
13187
+ const locked = controlSpans(state.doc).filter((span) => span.control.lock);
13188
+ if (!locked.length) return false;
13189
+ return tr.steps.some((step, index) => {
13190
+ if (!isRangeStep(step)) return false;
13191
+ const { from, to } = step;
13192
+ const inserts = from === to;
13193
+ const before = tr.mapping.slice(0, index);
13194
+ return locked.some((span) => {
13195
+ const spanFrom = before.map(span.from, 1);
13196
+ const spanTo = before.map(span.to, -1);
13197
+ const removesWhole = !inserts && from <= spanFrom && to >= spanTo;
13198
+ if (isContentControlLocked(span.control, "control") && removesWhole) return true;
13199
+ if (!isContentControlLocked(span.control, "content") || removesWhole) return false;
13200
+ if (span.level === "block") {
13201
+ const innerFrom = spanFrom + 1;
13202
+ const innerTo = spanTo - 1;
13203
+ return inserts ? from >= innerFrom && from <= innerTo : from < innerTo && to > innerFrom;
13204
+ }
13205
+ return inserts ? from > spanFrom && from < spanTo : from < spanTo && to > spanFrom;
13206
+ });
13207
+ });
13208
+ }
13209
+ function contentControlPlugin() {
13210
+ return new prosemirrorState.Plugin({
13211
+ filterTransaction: (tr, state) => !tr.docChanged || Boolean(tr.getMeta(CONTROL_EDIT_META)) || isRemote(tr) || !violatesControlLock(tr, state),
13212
+ props: {
13213
+ handleTextInput: (view, from, to, text2) => {
13214
+ if (!view.editable) return false;
13215
+ const result = typeOverPlaceholder(view.state, from, text2, to);
13216
+ if (result === "blocked") return true;
13217
+ if (!result) return false;
13218
+ view.dispatch(result);
13219
+ return true;
13220
+ },
13221
+ handleKeyDown: (view, event) => {
13222
+ if (!view.editable || event.key !== "Backspace" && event.key !== "Delete") return false;
13223
+ const tr = deleteToPlaceholder(
13224
+ view.state,
13225
+ event.key === "Backspace" ? "backward" : "forward"
13226
+ );
13227
+ if (!tr) return false;
13228
+ view.dispatch(tr);
13229
+ return true;
13230
+ }
13231
+ }
13232
+ });
13233
+ }
13234
+
13235
+ exports.CONTROL_EDIT_META = CONTROL_EDIT_META;
10625
13236
  exports.CollaborationAuthority = CollaborationAuthority;
10626
13237
  exports.CollaborationClient = CollaborationClient;
10627
13238
  exports.DirtyState = DirtyState;
@@ -10651,6 +13262,8 @@ exports.applyWordLink = applyWordLink;
10651
13262
  exports.authorColor = authorColor;
10652
13263
  exports.backstageFocus = backstageFocus;
10653
13264
  exports.chartNodeSpec = chartNodeSpec;
13265
+ exports.chooseDate = chooseDate;
13266
+ exports.chooseListItem = chooseListItem;
10654
13267
  exports.clearDirectRunFormatting = clearDirectRunFormatting;
10655
13268
  exports.collectRevisionRanges = collectRevisionRanges;
10656
13269
  exports.commentAnchors = commentAnchors;
@@ -10659,6 +13272,11 @@ exports.commentIdsAtSelection = commentIdsAtSelection;
10659
13272
  exports.commentIdsFromMarks = commentIdsFromMarks;
10660
13273
  exports.commentIdsFromNode = commentIdsFromNode;
10661
13274
  exports.commentThreadsFromDoc = commentThreadsFromDoc;
13275
+ exports.contentControlPlugin = contentControlPlugin;
13276
+ exports.controlAt = controlAt;
13277
+ exports.controlAtSelection = controlAtSelection;
13278
+ exports.controlOfMark = controlOfMark;
13279
+ exports.controlSpans = controlSpans;
10662
13280
  exports.countWords = countWords;
10663
13281
  exports.createCollaborationIdGenerator = createCollaborationIdGenerator;
10664
13282
  exports.createToggleFormat = createToggleFormat;
@@ -10667,6 +13285,7 @@ exports.darkTheme = darkTheme;
10667
13285
  exports.deleteAroundMarkers = deleteAroundMarkers;
10668
13286
  exports.deleteComment = deleteComment;
10669
13287
  exports.deleteFieldSelection = deleteFieldSelection;
13288
+ exports.deleteToPlaceholder = deleteToPlaceholder;
10670
13289
  exports.dispatchIsolatedCommand = dispatchIsolatedCommand;
10671
13290
  exports.documentWordCount = documentWordCount;
10672
13291
  exports.expectDefined = expectDefined;
@@ -10689,6 +13308,7 @@ exports.hasChangeAtCursor = hasChangeAtCursor;
10689
13308
  exports.hasNoteRevisions = hasNoteRevisions;
10690
13309
  exports.imageNodeSpec = imageNodeSpec;
10691
13310
  exports.inlineNodeRun = inlineNodeRun;
13311
+ exports.insertContentControl = insertContentControl;
10692
13312
  exports.insertWordHardBreak = insertWordHardBreak;
10693
13313
  exports.isNavigableHref = isNavigableHref;
10694
13314
  exports.isRibbonActionId = isRibbonActionId;
@@ -10701,6 +13321,7 @@ exports.linkMarkSpec = linkMarkSpec;
10701
13321
  exports.markSpecs = markSpecs;
10702
13322
  exports.marksForRun = marksForRun;
10703
13323
  exports.moveName = moveName;
13324
+ exports.newControlId = newControlId;
10704
13325
  exports.nodeChart = nodeChart;
10705
13326
  exports.nodeNumbering = nodeNumbering;
10706
13327
  exports.normalizeRibbonActions = normalizeRibbonActions;
@@ -10725,6 +13346,7 @@ exports.removeWordLink = removeWordLink;
10725
13346
  exports.repairCollaborativeDocumentIds = repairCollaborativeDocumentIds;
10726
13347
  exports.repairCollaborativeParagraphIds = repairCollaborativeParagraphIds;
10727
13348
  exports.replaceAroundMarkers = replaceAroundMarkers;
13349
+ exports.replaceControlContent = replaceControlContent;
10728
13350
  exports.replyToComment = replyToComment;
10729
13351
  exports.resolveCellVisuals = resolveCellVisuals;
10730
13352
  exports.resolveComment = resolveComment;
@@ -10747,12 +13369,16 @@ exports.tableStructureGuardPlugin = tableStructureGuardPlugin;
10747
13369
  exports.tableStyle = tableStyle;
10748
13370
  exports.themeDrawing = themeDrawing;
10749
13371
  exports.themeToCssVars = themeToCssVars;
13372
+ exports.toggleCheckboxControl = toggleCheckboxControl;
10750
13373
  exports.toggleTrackChanges = toggleTrackChanges;
10751
13374
  exports.toggleTrackFormatting = toggleTrackFormatting;
10752
13375
  exports.toggleTrackMoves = toggleTrackMoves;
10753
13376
  exports.trackChangesPlugin = trackChangesPlugin;
10754
13377
  exports.trackChangesPluginKey = trackChangesPluginKey;
13378
+ exports.typeOverPlaceholder = typeOverPlaceholder;
10755
13379
  exports.updateCommentThreads = updateCommentThreads;
13380
+ exports.updateControlProperties = updateControlProperties;
13381
+ exports.violatesControlLock = violatesControlLock;
10756
13382
  exports.wordHighlightColors = wordHighlightColors;
10757
13383
  exports.wordLinkRangeAt = wordLinkRangeAt;
10758
13384
  exports.wordYjsPluginKey = wordYjsPluginKey;