ooxml-core 1.29.0 → 1.30.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 (308) hide show
  1. package/dist/{PptxHandler-CZG6ISCZ.cjs → PptxHandler-3OLZT5YW.cjs} +3 -3
  2. package/dist/{PptxHandler-QIHYALOV.mjs → PptxHandler-FJHKJEZU.mjs} +2 -2
  3. package/dist/PptxHandler-LOFY2PRO.mjs +4 -0
  4. package/dist/{PresentationBuilder-UAINQZA2.mjs → PresentationBuilder-23M6WQK3.mjs} +2 -2
  5. package/dist/{PresentationBuilder-66EU3N3O.cjs → PresentationBuilder-LVIVJZIL.cjs} +5 -5
  6. package/dist/{PresentationBuilder-5YM2L7DA.mjs → PresentationBuilder-W5VRPFLM.mjs} +2 -2
  7. package/dist/automation/index.cjs +4250 -3145
  8. package/dist/automation/index.mjs +4250 -3145
  9. package/dist/chart/box-distribution.d.ts +10 -0
  10. package/dist/chart/box-distribution.d.ts.map +1 -0
  11. package/dist/chart/data-table-layout.d.ts +8 -0
  12. package/dist/chart/data-table-layout.d.ts.map +1 -0
  13. package/dist/chart/date-axis.d.ts +3 -0
  14. package/dist/chart/date-axis.d.ts.map +1 -0
  15. package/dist/chart/date-format.d.ts +39 -0
  16. package/dist/chart/date-format.d.ts.map +1 -0
  17. package/dist/chart/edit/chartex-action.d.ts.map +1 -1
  18. package/dist/chart/edit/chartex-axis.d.ts.map +1 -1
  19. package/dist/chart/edit/chartex-structure.d.ts.map +1 -1
  20. package/dist/chart/edit/chartex.d.ts +3 -1
  21. package/dist/chart/edit/chartex.d.ts.map +1 -1
  22. package/dist/chart/edit/draft.d.ts.map +1 -1
  23. package/dist/chart/funnel-geometry.d.ts +15 -0
  24. package/dist/chart/funnel-geometry.d.ts.map +1 -0
  25. package/dist/chart/index.cjs +1392 -404
  26. package/dist/chart/index.d.ts +6 -0
  27. package/dist/chart/index.d.ts.map +1 -1
  28. package/dist/chart/index.mjs +1379 -405
  29. package/dist/chart/line-path.d.ts +30 -0
  30. package/dist/chart/line-path.d.ts.map +1 -0
  31. package/dist/chart/manual-layout.d.ts +15 -0
  32. package/dist/chart/manual-layout.d.ts.map +1 -1
  33. package/dist/chart/render/chart-svg-analysis.d.ts +2 -0
  34. package/dist/chart/render/chart-svg-analysis.d.ts.map +1 -1
  35. package/dist/chart/render/chart-svg-bars.d.ts.map +1 -1
  36. package/dist/chart/render/chart-svg-box.d.ts +5 -0
  37. package/dist/chart/render/chart-svg-box.d.ts.map +1 -0
  38. package/dist/chart/render/chart-svg-cartesian.d.ts +3 -1
  39. package/dist/chart/render/chart-svg-cartesian.d.ts.map +1 -1
  40. package/dist/chart/render/chart-svg-data-table.d.ts +11 -0
  41. package/dist/chart/render/chart-svg-data-table.d.ts.map +1 -0
  42. package/dist/chart/render/chart-svg-date-axis.d.ts +9 -0
  43. package/dist/chart/render/chart-svg-date-axis.d.ts.map +1 -0
  44. package/dist/chart/render/chart-svg-funnel.d.ts +4 -0
  45. package/dist/chart/render/chart-svg-funnel.d.ts.map +1 -0
  46. package/dist/chart/render/chart-svg-labels.d.ts +16 -16
  47. package/dist/chart/render/chart-svg-labels.d.ts.map +1 -1
  48. package/dist/chart/render/chart-svg-line.d.ts +5 -0
  49. package/dist/chart/render/chart-svg-line.d.ts.map +1 -0
  50. package/dist/chart/render/chart-svg-plot-layout.d.ts +6 -0
  51. package/dist/chart/render/chart-svg-plot-layout.d.ts.map +1 -0
  52. package/dist/chart/render/chart-svg-plots.d.ts +2 -1
  53. package/dist/chart/render/chart-svg-plots.d.ts.map +1 -1
  54. package/dist/chart/render/chart-svg-radial.d.ts.map +1 -1
  55. package/dist/chart/render/chart-svg-slice-labels.d.ts +18 -0
  56. package/dist/chart/render/chart-svg-slice-labels.d.ts.map +1 -0
  57. package/dist/chart/render/chart-svg-xy.d.ts +2 -1
  58. package/dist/chart/render/chart-svg-xy.d.ts.map +1 -1
  59. package/dist/chart/render/chart-svg.d.ts.map +1 -1
  60. package/dist/chart/render/chart-title-text.d.ts +3 -1
  61. package/dist/chart/render/chart-title-text.d.ts.map +1 -1
  62. package/dist/chart/render/chart-view-analysis.d.ts +2 -1
  63. package/dist/chart/render/chart-view-analysis.d.ts.map +1 -1
  64. package/dist/chart/render/chart-view-data-table.d.ts +13 -0
  65. package/dist/chart/render/chart-view-data-table.d.ts.map +1 -0
  66. package/dist/chart/render/chart-view-labels.d.ts +6 -1
  67. package/dist/chart/render/chart-view-labels.d.ts.map +1 -1
  68. package/dist/chart/render/chart-view-series.d.ts.map +1 -1
  69. package/dist/chart/render/chart-view.d.ts +13 -0
  70. package/dist/chart/render/chart-view.d.ts.map +1 -1
  71. package/dist/chart/render/render-space.d.ts.map +1 -1
  72. package/dist/chart/render/summary-ex-series.d.ts +5 -0
  73. package/dist/chart/render/summary-ex-series.d.ts.map +1 -0
  74. package/dist/chart/render/summary-from-chartex.d.ts.map +1 -1
  75. package/dist/chart/render/summary-from-space.d.ts +1 -1
  76. package/dist/chart/render/summary-from-space.d.ts.map +1 -1
  77. package/dist/chart/render/summary-labels.d.ts.map +1 -1
  78. package/dist/chart/render/summary.d.ts +14 -1
  79. package/dist/chart/render/summary.d.ts.map +1 -1
  80. package/dist/{chunk-BBK3UB7M.mjs → chunk-5YZFO55V.mjs} +4 -4
  81. package/dist/{chunk-T7HBA3CW.cjs → chunk-7T3SJQA6.cjs} +11 -9
  82. package/dist/{chunk-XROY25LN.cjs → chunk-7XYVFUB3.cjs} +4 -0
  83. package/dist/{chunk-GUNTIFGT.cjs → chunk-CZXM4ZJH.cjs} +158 -26
  84. package/dist/{chunk-RYOJHYA3.mjs → chunk-DJ3CDTMX.mjs} +157 -27
  85. package/dist/{chunk-KBER3RAP.mjs → chunk-HDHUJM5M.mjs} +229 -227
  86. package/dist/{chunk-XCRDAVFN.mjs → chunk-HK7DVTEF.mjs} +237 -95
  87. package/dist/{chunk-6C4NLBLB.mjs → chunk-JZ64GVIB.mjs} +1 -1
  88. package/dist/{chunk-3UMDVJRN.mjs → chunk-NBMXEVHL.mjs} +4 -1
  89. package/dist/{chunk-TVJL7QIG.cjs → chunk-OGEL4Z4S.cjs} +8 -1
  90. package/dist/{chunk-HRU3KOE5.mjs → chunk-OORQCSVA.mjs} +5 -3
  91. package/dist/{chunk-7RJYOVQU.mjs → chunk-R7NS42KQ.mjs} +5 -2
  92. package/dist/{chunk-I2CGNAP2.cjs → chunk-SCK5U362.cjs} +1390 -1388
  93. package/dist/{chunk-DWEQWFQU.mjs → chunk-SCTM27HK.mjs} +229 -227
  94. package/dist/{chunk-PDZ4GQLI.mjs → chunk-UVYWAI4M.mjs} +1 -1
  95. package/dist/{chunk-DXOBT2JE.mjs → chunk-UZWV2HAJ.mjs} +8 -2
  96. package/dist/{chunk-IETFPVLN.cjs → chunk-XTUX5RMG.cjs} +15 -12
  97. package/dist/diagram/drawing.d.ts.map +1 -1
  98. package/dist/diagram/index.cjs +1218 -592
  99. package/dist/diagram/index.mjs +1218 -592
  100. package/dist/diagram/load.d.ts.map +1 -1
  101. package/dist/diagram/relationships.d.ts +1 -0
  102. package/dist/diagram/relationships.d.ts.map +1 -1
  103. package/dist/diagram/types.d.ts +2 -0
  104. package/dist/diagram/types.d.ts.map +1 -1
  105. package/dist/docx/diagram.d.ts.map +1 -1
  106. package/dist/docx/drawing.d.ts.map +1 -1
  107. package/dist/docx/embedded.cjs +1850 -1138
  108. package/dist/docx/embedded.mjs +1850 -1138
  109. package/dist/docx/index.cjs +3312 -1713
  110. package/dist/docx/index.mjs +3312 -1713
  111. package/dist/docx/layout/adapter.d.ts.map +1 -1
  112. package/dist/docx/layout/fonts.d.ts +1 -1
  113. package/dist/docx/layout/fonts.d.ts.map +1 -1
  114. package/dist/docx/layout/index.cjs +1933 -518
  115. package/dist/docx/layout/index.mjs +1933 -518
  116. package/dist/docx/layout/script-fonts.d.ts +6 -0
  117. package/dist/docx/layout/script-fonts.d.ts.map +1 -0
  118. package/dist/docx/load/index.cjs +1853 -1141
  119. package/dist/docx/load/index.mjs +1853 -1141
  120. package/dist/docx/parse.d.ts.map +1 -1
  121. package/dist/docx/shape-model.d.ts +2 -0
  122. package/dist/docx/shape-model.d.ts.map +1 -1
  123. package/dist/docx/shape-parse.d.ts.map +1 -1
  124. package/dist/docx/shape-svg.d.ts.map +1 -1
  125. package/dist/docx/ui/index.cjs +1763 -593
  126. package/dist/docx/ui/index.mjs +1763 -593
  127. package/dist/docx/write-shape.d.ts.map +1 -1
  128. package/dist/drawingml/custom-geometry.d.ts +5 -0
  129. package/dist/drawingml/custom-geometry.d.ts.map +1 -0
  130. package/dist/drawingml/drawing-fill.d.ts.map +1 -1
  131. package/dist/drawingml/drawing-geometry.d.ts.map +1 -1
  132. package/dist/drawingml/image-content-type.d.ts +2 -0
  133. package/dist/drawingml/image-content-type.d.ts.map +1 -0
  134. package/dist/drawingml/index.cjs +1128 -179
  135. package/dist/drawingml/index.d.ts +9 -0
  136. package/dist/drawingml/index.d.ts.map +1 -1
  137. package/dist/drawingml/index.mjs +1110 -180
  138. package/dist/drawingml/path-data.d.ts +4 -0
  139. package/dist/drawingml/path-data.d.ts.map +1 -0
  140. package/dist/drawingml/picture-crop.d.ts +8 -0
  141. package/dist/drawingml/picture-crop.d.ts.map +1 -0
  142. package/dist/drawingml/picture-effects.d.ts +37 -0
  143. package/dist/drawingml/picture-effects.d.ts.map +1 -0
  144. package/dist/drawingml/picture-fill.d.ts +7 -0
  145. package/dist/drawingml/picture-fill.d.ts.map +1 -0
  146. package/dist/drawingml/read-3d-values.d.ts +8 -0
  147. package/dist/drawingml/read-3d-values.d.ts.map +1 -0
  148. package/dist/drawingml/read-text-3d.d.ts +8 -0
  149. package/dist/drawingml/read-text-3d.d.ts.map +1 -0
  150. package/dist/drawingml/read-text-body.d.ts.map +1 -1
  151. package/dist/drawingml/scene3d-coordinate.d.ts +45 -0
  152. package/dist/drawingml/scene3d-coordinate.d.ts.map +1 -0
  153. package/dist/drawingml/scene3d-presets.d.ts +12 -0
  154. package/dist/drawingml/scene3d-presets.d.ts.map +1 -0
  155. package/dist/drawingml/text-3d-model.d.ts +71 -0
  156. package/dist/drawingml/text-3d-model.d.ts.map +1 -0
  157. package/dist/drawingml/text-model.d.ts +3 -0
  158. package/dist/drawingml/text-model.d.ts.map +1 -1
  159. package/dist/drawingml/types.d.ts +3 -0
  160. package/dist/drawingml/types.d.ts.map +1 -1
  161. package/dist/drawingml/write-pattern-picture.d.ts.map +1 -1
  162. package/dist/drawingml/write-text-3d.d.ts +6 -0
  163. package/dist/drawingml/write-text-3d.d.ts.map +1 -0
  164. package/dist/drawingml/write-text-body.d.ts.map +1 -1
  165. package/dist/geometry/element-transform.d.ts +3 -0
  166. package/dist/geometry/element-transform.d.ts.map +1 -1
  167. package/dist/geometry/index.cjs +69 -4
  168. package/dist/geometry/index.d.ts +2 -0
  169. package/dist/geometry/index.d.ts.map +1 -1
  170. package/dist/geometry/index.mjs +66 -5
  171. package/dist/geometry/picture-crop.d.ts +21 -0
  172. package/dist/geometry/picture-crop.d.ts.map +1 -0
  173. package/dist/geometry/resize-aspect.d.ts +12 -0
  174. package/dist/geometry/resize-aspect.d.ts.map +1 -0
  175. package/dist/index.cjs +4201 -2058
  176. package/dist/index.mjs +4201 -2058
  177. package/dist/opc/index.cjs +9 -6
  178. package/dist/opc/index.mjs +9 -6
  179. package/dist/opc/safe-href.d.ts +10 -3
  180. package/dist/opc/safe-href.d.ts.map +1 -1
  181. package/dist/pptx/automation/index.cjs +615 -360
  182. package/dist/pptx/automation/index.d.ts +6 -6
  183. package/dist/pptx/automation/index.mjs +5 -5
  184. package/dist/pptx/chunks/{elements-CCEghtE_.d.ts → elements-mSCZ84Tc.d.ts} +4 -4
  185. package/dist/pptx/chunks/elements-mSCZ84Tc.d.ts.map +1 -0
  186. package/dist/pptx/chunks/{index-D90lhgiE.d.ts → index-BQDcu_0a.d.ts} +19 -111
  187. package/dist/pptx/chunks/index-BQDcu_0a.d.ts.map +1 -0
  188. package/dist/pptx/chunks/{index-CmnbpSCL.d.ts → index-CBV1oHN7.d.ts} +5 -5
  189. package/dist/pptx/chunks/{index-CmnbpSCL.d.ts.map → index-CBV1oHN7.d.ts.map} +1 -1
  190. package/dist/pptx/chunks/{index-DJIPX0Ge.d.ts → index-PdM5zpmu.d.ts} +5 -5
  191. package/dist/pptx/chunks/{index-DJIPX0Ge.d.ts.map → index-PdM5zpmu.d.ts.map} +1 -1
  192. package/dist/pptx/chunks/{smart-art-BLBSej3J.d.ts → smart-art-DLumQo90.d.ts} +135 -103
  193. package/dist/pptx/chunks/smart-art-DLumQo90.d.ts.map +1 -0
  194. package/dist/pptx/chunks/{text-D49FKllA.d.ts → text-P9xVnXXf.d.ts} +49 -60
  195. package/dist/pptx/chunks/text-P9xVnXXf.d.ts.map +1 -0
  196. package/dist/pptx/chunks/{text-operations-DZ1IgDJN.d.ts → text-operations-hyPODwIQ.d.ts} +4 -4
  197. package/dist/pptx/chunks/{text-operations-DZ1IgDJN.d.ts.map → text-operations-hyPODwIQ.d.ts.map} +1 -1
  198. package/dist/pptx/cli/index.cjs +611 -356
  199. package/dist/pptx/cli/index.d.ts +1 -1
  200. package/dist/pptx/cli/index.mjs +4 -4
  201. package/dist/pptx/converter/index.cjs +102 -67
  202. package/dist/pptx/converter/index.d.ts +1 -1
  203. package/dist/pptx/converter/index.mjs +2 -2
  204. package/dist/pptx/editor/render/collaboration-assets.cjs +15 -11
  205. package/dist/pptx/editor/render/collaboration-assets.d.ts +2 -2
  206. package/dist/pptx/editor/render/collaboration-assets.mjs +1 -1
  207. package/dist/pptx/editor/render/collaboration-live-patch-target.cjs +5 -5
  208. package/dist/pptx/editor/render/collaboration-live-patch-target.mjs +3 -3
  209. package/dist/pptx/editor/render/collaboration-reconcile.cjs +9 -9
  210. package/dist/pptx/editor/render/collaboration-reconcile.d.ts.map +1 -1
  211. package/dist/pptx/editor/render/collaboration-reconcile.mjs +3 -3
  212. package/dist/pptx/editor/render/collaboration-sync.cjs +29 -25
  213. package/dist/pptx/editor/render/collaboration-sync.d.ts +7 -0
  214. package/dist/pptx/editor/render/collaboration-sync.d.ts.map +1 -1
  215. package/dist/pptx/editor/render/collaboration-sync.mjs +2 -2
  216. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  217. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  218. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  219. package/dist/pptx/editor/render/font-family-update.d.ts +1 -1
  220. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +1 -1
  221. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  222. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  223. package/dist/pptx/editor/render/table-cell-edit.cjs +8 -4
  224. package/dist/pptx/editor/render/table-cell-edit.d.ts +5 -0
  225. package/dist/pptx/editor/render/table-cell-edit.d.ts.map +1 -1
  226. package/dist/pptx/editor/render/table-cell-edit.mjs +1 -1
  227. package/dist/pptx/editor/render/table-cell-merge.cjs +3 -3
  228. package/dist/pptx/editor/render/table-cell-merge.mjs +1 -1
  229. package/dist/pptx/editor/render/table-data-grid-ops.cjs +2 -2
  230. package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
  231. package/dist/pptx/editor/render/table-merge.cjs +5 -5
  232. package/dist/pptx/editor/render/table-merge.mjs +1 -1
  233. package/dist/pptx/editor/render/text-content-style.d.ts +1 -1
  234. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +2 -2
  235. package/dist/pptx/editor/render/text-style-scope.d.ts +2 -2
  236. package/dist/pptx/editor/render/update-text-segment-style.d.ts +1 -1
  237. package/dist/pptx/index.cjs +677 -418
  238. package/dist/pptx/index.d.ts +8 -8
  239. package/dist/pptx/index.mjs +5 -5
  240. package/dist/pptx/node/index.d.ts +1 -1
  241. package/dist/pptx/smartart-layouts/index.d.ts +1 -1
  242. package/dist/teams/index.cjs +1816 -1049
  243. package/dist/teams/index.mjs +1816 -1049
  244. package/dist/text/font-style-name.d.ts +11 -0
  245. package/dist/text/font-style-name.d.ts.map +1 -0
  246. package/dist/text/font-substitution-map.d.ts +3 -0
  247. package/dist/text/font-substitution-map.d.ts.map +1 -0
  248. package/dist/text/font-substitution.d.ts +34 -0
  249. package/dist/text/font-substitution.d.ts.map +1 -0
  250. package/dist/text/index.cjs +460 -0
  251. package/dist/text/index.d.ts +3 -0
  252. package/dist/text/index.d.ts.map +1 -1
  253. package/dist/text/index.mjs +443 -1
  254. package/dist/text/metric-font-family.d.ts +7 -0
  255. package/dist/text/metric-font-family.d.ts.map +1 -0
  256. package/dist/text/panose.d.ts +55 -0
  257. package/dist/text/panose.d.ts.map +1 -0
  258. package/dist/text/script-fonts.d.ts +26 -0
  259. package/dist/text/script-fonts.d.ts.map +1 -0
  260. package/dist/visio/edit-geometry-admission.d.ts +1 -1
  261. package/dist/visio/edit-geometry-admission.d.ts.map +1 -1
  262. package/dist/visio/edit-group-resize.d.ts +26 -0
  263. package/dist/visio/edit-group-resize.d.ts.map +1 -0
  264. package/dist/visio/edit-recalculate-index.d.ts +2 -0
  265. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  266. package/dist/visio/edit-resize-anchor.d.ts.map +1 -1
  267. package/dist/visio/edit-resize-plan.d.ts +14 -0
  268. package/dist/visio/edit-resize-plan.d.ts.map +1 -0
  269. package/dist/visio/edit-scope.d.ts.map +1 -1
  270. package/dist/visio/index.cjs +1326 -389
  271. package/dist/visio/index.mjs +1326 -389
  272. package/dist/visio/ui/geometry-expectation.d.ts +17 -0
  273. package/dist/visio/ui/geometry-expectation.d.ts.map +1 -0
  274. package/dist/visio/ui/guides.d.ts +2 -0
  275. package/dist/visio/ui/guides.d.ts.map +1 -1
  276. package/dist/visio/ui/index.cjs +1582 -411
  277. package/dist/visio/ui/index.d.ts +2 -0
  278. package/dist/visio/ui/index.d.ts.map +1 -1
  279. package/dist/visio/ui/index.mjs +1579 -412
  280. package/dist/visio/ui/selection-resize.d.ts +19 -0
  281. package/dist/visio/ui/selection-resize.d.ts.map +1 -0
  282. package/dist/visio/ui/shape-move.d.ts +1 -1
  283. package/dist/visio/ui/shape-move.d.ts.map +1 -1
  284. package/dist/visio/ui/shape-resize.d.ts.map +1 -1
  285. package/dist/xlsx/edit/drawings.d.ts +5 -0
  286. package/dist/xlsx/edit/drawings.d.ts.map +1 -1
  287. package/dist/xlsx/edit/session.d.ts.map +1 -1
  288. package/dist/xlsx/edit/types.d.ts +4 -0
  289. package/dist/xlsx/edit/types.d.ts.map +1 -1
  290. package/dist/xlsx/index.cjs +3908 -2256
  291. package/dist/xlsx/index.mjs +3908 -2256
  292. package/dist/xlsx/layout/chart-view.d.ts.map +1 -1
  293. package/dist/xlsx/load/index.cjs +2003 -1239
  294. package/dist/xlsx/load/index.mjs +2003 -1239
  295. package/dist/xlsx/model.d.ts +4 -0
  296. package/dist/xlsx/model.d.ts.map +1 -1
  297. package/dist/xlsx/read/chart.d.ts.map +1 -1
  298. package/dist/xlsx/read/drawing.d.ts.map +1 -1
  299. package/dist/xlsx/read/smart-art.d.ts.map +1 -1
  300. package/dist/xlsx/ui/index.cjs +3880 -2228
  301. package/dist/xlsx/ui/index.mjs +3880 -2228
  302. package/dist/xlsx/write/drawing.d.ts.map +1 -1
  303. package/package.json +1 -1
  304. package/dist/PptxHandler-DSXSXMEG.mjs +0 -4
  305. package/dist/pptx/chunks/elements-CCEghtE_.d.ts.map +0 -1
  306. package/dist/pptx/chunks/index-D90lhgiE.d.ts.map +0 -1
  307. package/dist/pptx/chunks/smart-art-BLBSej3J.d.ts.map +0 -1
  308. package/dist/pptx/chunks/text-D49FKllA.d.ts.map +0 -1
@@ -150,25 +150,25 @@ var inlineRunFormattingAttrs = Object.fromEntries(
150
150
  [...RUN_PROPERTY_ATTRIBUTES].map((name) => [name, { default: null }])
151
151
  );
152
152
  function inlineRunProperties(node) {
153
- const properties4 = typeof node.attrs.format === "string" ? JSON.parse(node.attrs.format) : {};
153
+ const properties3 = typeof node.attrs.format === "string" ? JSON.parse(node.attrs.format) : {};
154
154
  for (const key of DIRECT_RUN_PROPERTY_KEYS) {
155
155
  const override = node.attrs[attributeName(key)];
156
156
  if (typeof override !== "string") continue;
157
157
  const value = JSON.parse(override);
158
- if (value === null) delete properties4[key];
159
- else properties4[key] = value;
158
+ if (value === null) delete properties3[key];
159
+ else properties3[key] = value;
160
160
  }
161
161
  const projection = node.marks.find((mark) => mark.type.name === "inlineCommentAnchors");
162
162
  if (projection) {
163
163
  const ids = projection.attrs.ids;
164
- if (ids.length) properties4.commentIds = [...ids];
165
- else delete properties4.commentIds;
164
+ if (ids.length) properties3.commentIds = [...ids];
165
+ else delete properties3.commentIds;
166
166
  }
167
- return properties4;
167
+ return properties3;
168
168
  }
169
169
  function inlineRunPropertiesDomAttrs(node) {
170
- const properties4 = inlineRunProperties(node);
171
- return Object.keys(properties4).length ? { "data-run-properties": JSON.stringify(properties4) } : {};
170
+ const properties3 = inlineRunProperties(node);
171
+ return Object.keys(properties3).length ? { "data-run-properties": JSON.stringify(properties3) } : {};
172
172
  }
173
173
  function updatedInlineRunAttributes(node, format) {
174
174
  if (!node.type.spec.attrs?.[attributeName("bold")]) return { ...node.attrs, format };
@@ -468,8 +468,8 @@ function parseHalfPoints(value) {
468
468
  function parseSignedHalfPoints(value) {
469
469
  if (value === null || value === void 0) return void 0;
470
470
  const text2 = value.trim();
471
- const integer2 = parseInteger(text2);
472
- if (integer2 !== void 0) return halfPoints(integer2);
471
+ const integer3 = parseInteger(text2);
472
+ if (integer3 !== void 0) return halfPoints(integer3);
473
473
  const twips2 = universalMeasureToTwips(text2);
474
474
  return twips2 === void 0 ? void 0 : halfPoints(Math.sign(twips2) * Math.round(Math.abs(twips2) / 10));
475
475
  }
@@ -664,20 +664,20 @@ function freshControlId(used) {
664
664
  var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|am\/pm|AM\/PM|'[^']*'/g;
665
665
  function formatWordDate(date, picture, locale = "en-US") {
666
666
  const name = (options2) => new Intl.DateTimeFormat(locale, options2).format(date);
667
- const pad = (value) => String(value).padStart(2, "0");
667
+ const pad2 = (value) => String(value).padStart(2, "0");
668
668
  const hours12 = date.getHours() % 12 || 12;
669
669
  return picture.replace(TOKENS, (token) => {
670
670
  switch (token) {
671
671
  case "yyyy":
672
672
  return String(date.getFullYear());
673
673
  case "yy":
674
- return pad(date.getFullYear() % 100);
674
+ return pad2(date.getFullYear() % 100);
675
675
  case "MMMM":
676
676
  return name({ month: "long" });
677
677
  case "MMM":
678
678
  return name({ month: "short" });
679
679
  case "MM":
680
- return pad(date.getMonth() + 1);
680
+ return pad2(date.getMonth() + 1);
681
681
  case "M":
682
682
  return String(date.getMonth() + 1);
683
683
  case "dddd":
@@ -685,21 +685,21 @@ function formatWordDate(date, picture, locale = "en-US") {
685
685
  case "ddd":
686
686
  return name({ weekday: "short" });
687
687
  case "dd":
688
- return pad(date.getDate());
688
+ return pad2(date.getDate());
689
689
  case "d":
690
690
  return String(date.getDate());
691
691
  case "HH":
692
- return pad(date.getHours());
692
+ return pad2(date.getHours());
693
693
  case "H":
694
694
  return String(date.getHours());
695
695
  case "hh":
696
- return pad(hours12);
696
+ return pad2(hours12);
697
697
  case "h":
698
698
  return String(hours12);
699
699
  case "mm":
700
- return pad(date.getMinutes());
700
+ return pad2(date.getMinutes());
701
701
  case "ss":
702
- return pad(date.getSeconds());
702
+ return pad2(date.getSeconds());
703
703
  case "am/pm":
704
704
  return date.getHours() < 12 ? "am" : "pm";
705
705
  case "AM/PM":
@@ -765,13 +765,13 @@ function withValue(control) {
765
765
  // docx/ui/content-control-rows.ts
766
766
  var rowControlOf = (node) => node.type.name === "tableRow" ? node.attrs.properties?.contentControl ?? void 0 : void 0;
767
767
  function rowControlSpans(doc) {
768
- const rows = [];
768
+ const rows2 = [];
769
769
  doc.descendants((node, pos) => {
770
770
  const control = rowControlOf(node);
771
- if (control) rows.push({ control, level: "row", from: pos, to: pos + node.nodeSize });
771
+ if (control) rows2.push({ control, level: "row", from: pos, to: pos + node.nodeSize });
772
772
  return !node.isTextblock;
773
773
  });
774
- return rows;
774
+ return rows2;
775
775
  }
776
776
 
777
777
  // docx/ui/content-control-spans.ts
@@ -1247,10 +1247,10 @@ function nodeControlOf(node) {
1247
1247
  }
1248
1248
  function attrsWithControl(node, control) {
1249
1249
  if (node.type.name !== "tableRow") return { ...node.attrs, contentControl: control ?? null };
1250
- const { contentControl: _held, ...properties4 } = node.attrs.properties ?? {};
1250
+ const { contentControl: _held, ...properties3 } = node.attrs.properties ?? {};
1251
1251
  return {
1252
1252
  ...node.attrs,
1253
- properties: control ? { ...properties4, contentControl: control } : Object.keys(properties4).length ? properties4 : null
1253
+ properties: control ? { ...properties3, contentControl: control } : Object.keys(properties3).length ? properties3 : null
1254
1254
  };
1255
1255
  }
1256
1256
  function otherControlSourcesOf(slice) {
@@ -2823,6 +2823,141 @@ function drawingColorCss(value) {
2823
2823
  return `rgba(${channels.join(",")},${value.alpha})`;
2824
2824
  }
2825
2825
 
2826
+ // drawingml/picture-crop.ts
2827
+ var SIDES = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
2828
+ function parsePictureCrop(blipFill) {
2829
+ const rect3 = first(blipFill, "srcRect", NS.a);
2830
+ if (!rect3) return void 0;
2831
+ const result = {};
2832
+ for (const [attr2, key] of Object.entries(SIDES)) {
2833
+ const raw = rect3.getAttribute(attr2);
2834
+ if (raw === null || !raw.trim()) continue;
2835
+ const percent = raw.endsWith("%");
2836
+ const value = Number(percent ? raw.slice(0, -1) : raw) / (percent ? 100 : 1e5);
2837
+ if (Number.isFinite(value)) result[key] = value;
2838
+ }
2839
+ return result;
2840
+ }
2841
+ function applyPictureCrop(blipFill, crop) {
2842
+ let rect3 = first(blipFill, "srcRect", NS.a);
2843
+ if (!rect3 && crop && Object.values(crop).some((value) => value !== void 0)) {
2844
+ rect3 = blipFill.ownerDocument.createElementNS(NS.a, "a:srcRect");
2845
+ const blip = first(blipFill, "blip", NS.a);
2846
+ blipFill.insertBefore(rect3, blip?.nextSibling ?? blipFill.firstChild);
2847
+ }
2848
+ if (!rect3) return;
2849
+ for (const [attr2, key] of Object.entries(SIDES)) {
2850
+ const value = crop?.[key];
2851
+ if (value === void 0) rect3.removeAttribute(attr2);
2852
+ else {
2853
+ if (!Number.isFinite(value)) throw new RangeError("Picture crop must be finite");
2854
+ rect3.setAttribute(attr2, String(Math.round(value * 1e5)));
2855
+ }
2856
+ }
2857
+ }
2858
+
2859
+ // drawingml/picture-effects.ts
2860
+ function picturePercentage(value) {
2861
+ const text2 = String(value ?? "").trim();
2862
+ if (!text2) return void 0;
2863
+ const percent = text2.endsWith("%");
2864
+ const n2 = Number(percent ? text2.slice(0, -1) : text2) / (percent ? 100 : 1e5);
2865
+ return Number.isFinite(n2) ? n2 : void 0;
2866
+ }
2867
+ function readPictureEffect(name, attribute) {
2868
+ if (name === "grayscl") return { kind: "grayscale" };
2869
+ if (name === "lum") {
2870
+ const brightness = picturePercentage(attribute("bright"));
2871
+ const contrast = picturePercentage(attribute("contrast"));
2872
+ for (const [name2, value] of [
2873
+ ["bright", brightness],
2874
+ ["contrast", contrast]
2875
+ ]) {
2876
+ const raw = attribute(name2);
2877
+ if (raw !== void 0 && raw !== null && (value === void 0 || Math.abs(value) > 1))
2878
+ return void 0;
2879
+ }
2880
+ return {
2881
+ kind: "luminance",
2882
+ ...brightness !== void 0 ? { brightness } : {},
2883
+ ...contrast !== void 0 ? { contrast } : {}
2884
+ };
2885
+ }
2886
+ if (name === "alphaModFix") {
2887
+ const raw = attribute("amt");
2888
+ const amount = raw === void 0 || raw === null ? 1 : picturePercentage(raw);
2889
+ if (amount !== void 0 && amount >= 0) return { kind: "alphaModFix", amount };
2890
+ }
2891
+ return void 0;
2892
+ }
2893
+ function parsePictureEffects(blip) {
2894
+ if (!blip) return [];
2895
+ return elements(blip).map((node) => ({
2896
+ ...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) : void 0) ?? { kind: "unsupported", name: node.localName },
2897
+ sourceXml: buildXml(node)
2898
+ }));
2899
+ }
2900
+ function applyPictureEffects(blip, effects) {
2901
+ if (JSON.stringify(parsePictureEffects(blip)) === JSON.stringify(effects)) return;
2902
+ const nodes = effects.map((effect) => {
2903
+ const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind;
2904
+ const source = effect.sourceXml ? parseXml(effect.sourceXml).documentElement : void 0;
2905
+ if (effect.kind === "unsupported" && !source)
2906
+ throw new Error("An unsupported picture effect needs source XML");
2907
+ const node = source ? blip.ownerDocument.importNode(source, true) : blip.ownerDocument.createElementNS(NS.a, `a:${name}`);
2908
+ if (effect.kind !== "unsupported" && (node.namespaceURI !== NS.a || node.localName !== name))
2909
+ throw new Error("Picture effect source does not match its kind");
2910
+ const set = (name2, value) => {
2911
+ const original = picturePercentage(node.getAttribute(name2));
2912
+ if (value === void 0) node.removeAttribute(name2);
2913
+ else if (value !== original) {
2914
+ if (!Number.isFinite(value)) throw new RangeError("Picture effect must be finite");
2915
+ node.setAttribute(name2, String(Math.round(value * 1e5)));
2916
+ }
2917
+ };
2918
+ if (effect.kind === "luminance") {
2919
+ if ([effect.brightness, effect.contrast].some(
2920
+ (value) => value !== void 0 && (!Number.isFinite(value) || Math.abs(value) > 1)
2921
+ ))
2922
+ throw new RangeError("Picture luminance must be between -1 and 1");
2923
+ set("bright", effect.brightness);
2924
+ set("contrast", effect.contrast);
2925
+ }
2926
+ if (effect.kind === "alphaModFix") {
2927
+ if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
2928
+ set("amt", effect.amount);
2929
+ }
2930
+ return node;
2931
+ });
2932
+ for (const node of elements(blip)) blip.removeChild(node);
2933
+ for (const node of nodes) blip.appendChild(node);
2934
+ }
2935
+
2936
+ // drawingml/picture-fill.ts
2937
+ function parseDrawingPictureFill(fill) {
2938
+ const blip = first(fill, "blip", NS.a);
2939
+ const relId = blip?.getAttributeNS(NS.r, "embed") || blip?.getAttribute("r:embed") || void 0;
2940
+ const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
2941
+ const crop = parsePictureCrop(fill);
2942
+ const effects = parsePictureEffects(blip);
2943
+ const tile = first(fill, "tile", NS.a);
2944
+ const rect3 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
2945
+ const unsupported = [
2946
+ ...tile ? ["tile"] : [],
2947
+ ...rect3 && ["l", "t", "r", "b"].some((key) => Number(rect3.getAttribute(key) ?? 0) !== 0) ? ["fillRect"] : [],
2948
+ ...fill.getAttribute("rotWithShape") === "0" || fill.getAttribute("rotWithShape") === "false" ? ["rotWithShape"] : []
2949
+ ];
2950
+ return {
2951
+ kind: "picture",
2952
+ sourceXml: buildXml(fill),
2953
+ ...relId ? { relId } : {},
2954
+ ...linkRelId ? { linkRelId } : {},
2955
+ ...crop ? { crop } : {},
2956
+ ...effects.length ? { effects } : {},
2957
+ ...unsupported.length ? { unsupportedPicture: unsupported } : {}
2958
+ };
2959
+ }
2960
+
2826
2961
  // drawingml/drawing-fill.ts
2827
2962
  var FILL_ELEMENTS = /* @__PURE__ */ new Set([
2828
2963
  "noFill",
@@ -2832,13 +2967,13 @@ var FILL_ELEMENTS = /* @__PURE__ */ new Set([
2832
2967
  "blipFill",
2833
2968
  "grpFill"
2834
2969
  ]);
2835
- function fillElementOf(properties4) {
2836
- return properties4 ? elements(properties4).find(
2970
+ function fillElementOf(properties3) {
2971
+ return properties3 ? elements(properties3).find(
2837
2972
  (element3) => FILL_ELEMENTS.has(element3.localName) && (!element3.namespaceURI || element3.namespaceURI === NS.a)
2838
2973
  ) : void 0;
2839
2974
  }
2840
- function parseDrawingFill(properties4) {
2841
- const fill = fillElementOf(properties4);
2975
+ function parseDrawingFill(properties3) {
2976
+ const fill = fillElementOf(properties3);
2842
2977
  if (!fill) return void 0;
2843
2978
  switch (fill.localName) {
2844
2979
  case "noFill":
@@ -2893,17 +3028,8 @@ function parseDrawingFill(properties4) {
2893
3028
  ...background ? { background } : {}
2894
3029
  };
2895
3030
  }
2896
- case "blipFill": {
2897
- const blip = first(fill, "blip", NS.a);
2898
- const relId = blip?.getAttributeNS(NS.r, "embed") || blip?.getAttribute("r:embed") || void 0;
2899
- const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
2900
- return {
2901
- kind: "picture",
2902
- sourceXml: buildXml(fill),
2903
- ...relId ? { relId } : {},
2904
- ...linkRelId ? { linkRelId } : {}
2905
- };
2906
- }
3031
+ case "blipFill":
3032
+ return parseDrawingPictureFill(fill);
2907
3033
  default:
2908
3034
  return { kind: "unsupported", element: fill.localName };
2909
3035
  }
@@ -2959,6 +3085,194 @@ function drawingDashLength(value) {
2959
3085
  return Number.isSafeInteger(number) && number <= 2147483647 ? number : void 0;
2960
3086
  }
2961
3087
 
3088
+ // geometry/guide-formula-eval.ts
3089
+ var ANGLE_SCALE = 6e4;
3090
+ function angleToRadians(ooxmlAngle) {
3091
+ return ooxmlAngle / ANGLE_SCALE * (Math.PI / 180);
3092
+ }
3093
+ function parseFormula(fmla) {
3094
+ const parts = fmla.trim().split(/\s+/);
3095
+ const op = parts[0] ?? "";
3096
+ const args = parts.slice(1);
3097
+ return { op, args };
3098
+ }
3099
+ function resolveOperand(token, variables) {
3100
+ const num2 = Number(token);
3101
+ if (Number.isFinite(num2)) {
3102
+ return num2;
3103
+ }
3104
+ const value = variables.get(token);
3105
+ if (value !== void 0) {
3106
+ return value;
3107
+ }
3108
+ return 0;
3109
+ }
3110
+ function evaluateFormula(parsed, vars) {
3111
+ const r = (idx) => resolveOperand(parsed.args[idx] ?? "0", vars);
3112
+ switch (parsed.op) {
3113
+ // val x — literal value
3114
+ case "val":
3115
+ return r(0);
3116
+ // abs x — absolute value
3117
+ case "abs":
3118
+ return Math.abs(r(0));
3119
+ // sqrt x — square root
3120
+ case "sqrt":
3121
+ return Math.sqrt(Math.max(r(0), 0));
3122
+ // +- x y z — x + y - z
3123
+ case "+-":
3124
+ return r(0) + r(1) - r(2);
3125
+ // */ x y z — (x * y) / z
3126
+ case "*/": {
3127
+ const z = r(2);
3128
+ if (z === 0) {
3129
+ return 0;
3130
+ }
3131
+ return r(0) * r(1) / z;
3132
+ }
3133
+ // +/ x y z — (x + y) / z
3134
+ case "+/": {
3135
+ const z = r(2);
3136
+ if (z === 0) {
3137
+ return 0;
3138
+ }
3139
+ return (r(0) + r(1)) / z;
3140
+ }
3141
+ // ?: x y z — if x > 0 then y else z
3142
+ case "?:":
3143
+ case "if":
3144
+ return r(0) > 0 ? r(1) : r(2);
3145
+ // min x y — minimum
3146
+ case "min":
3147
+ return Math.min(r(0), r(1));
3148
+ // max x y — maximum
3149
+ case "max":
3150
+ return Math.max(r(0), r(1));
3151
+ // mod x y z — sqrt(x² + y² + z²)
3152
+ case "mod": {
3153
+ const a = r(0);
3154
+ const b = r(1);
3155
+ const c = r(2);
3156
+ return Math.sqrt(a * a + b * b + c * c);
3157
+ }
3158
+ // pin x y z — clamp y between x and z
3159
+ case "pin": {
3160
+ const lo = r(0);
3161
+ const val = r(1);
3162
+ const hi = r(2);
3163
+ return Math.max(lo, Math.min(val, hi));
3164
+ }
3165
+ // sin x y — x * sin(y) where y is in OOXML angle units
3166
+ case "sin": {
3167
+ const sinVal = Math.sin(angleToRadians(r(1)));
3168
+ if (!Number.isFinite(sinVal)) {
3169
+ return 0;
3170
+ }
3171
+ return r(0) * sinVal;
3172
+ }
3173
+ // cos x y — x * cos(y) where y is in OOXML angle units
3174
+ case "cos": {
3175
+ const cosVal = Math.cos(angleToRadians(r(1)));
3176
+ if (!Number.isFinite(cosVal)) {
3177
+ return 0;
3178
+ }
3179
+ return r(0) * cosVal;
3180
+ }
3181
+ // tan x y — x * tan(y) where y is in OOXML angle units
3182
+ case "tan": {
3183
+ const angle = angleToRadians(r(1));
3184
+ const tanVal = Math.tan(angle);
3185
+ if (!Number.isFinite(tanVal)) {
3186
+ return 0;
3187
+ }
3188
+ return r(0) * tanVal;
3189
+ }
3190
+ // atan x — atan(x) result in OOXML angle units
3191
+ // x is a ratio scaled by the shape coordinate space
3192
+ case "atan": {
3193
+ const radians = Math.atan(r(0));
3194
+ return radians * 180 * ANGLE_SCALE / Math.PI;
3195
+ }
3196
+ // at2 x y -> arctan(y / x), i.e. Math.atan2(y, x), result in OOXML angle
3197
+ // units. ECMA-376 / ISO-IEC-29500-1 section 20.1.9.6 defines the operand
3198
+ // order as (x, y) with the ARGUMENTS REVERSED relative to Math.atan2, so
3199
+ // the first operand is the horizontal component and the second is the
3200
+ // vertical one. This matches the companion `cat2`/`sat2` operators below,
3201
+ // which take (x, y, z) and compute atan2(z, y).
3202
+ case "at2":
3203
+ case "atan2": {
3204
+ const radians = Math.atan2(r(1), r(0));
3205
+ return radians * 180 * ANGLE_SCALE / Math.PI;
3206
+ }
3207
+ // cat2 x y z — x * cos(atan2(z, y))
3208
+ // Computes the cosine-component of a vector scaled by x
3209
+ case "cat2": {
3210
+ const angle = Math.atan2(r(2), r(1));
3211
+ return r(0) * Math.cos(angle);
3212
+ }
3213
+ // sat2 x y z — x * sin(atan2(z, y))
3214
+ // Computes the sine-component of a vector scaled by x
3215
+ case "sat2": {
3216
+ const angle = Math.atan2(r(2), r(1));
3217
+ return r(0) * Math.sin(angle);
3218
+ }
3219
+ default:
3220
+ return Number(parsed.op) || 0;
3221
+ }
3222
+ }
3223
+
3224
+ // geometry/guide-formula-api.ts
3225
+ function createBuiltinVariables(ctx) {
3226
+ const { w, h } = ctx;
3227
+ const vars = /* @__PURE__ */ new Map();
3228
+ vars.set("w", w);
3229
+ vars.set("h", h);
3230
+ vars.set("l", 0);
3231
+ vars.set("t", 0);
3232
+ vars.set("r", w);
3233
+ vars.set("b", h);
3234
+ vars.set("hc", w / 2);
3235
+ vars.set("vc", h / 2);
3236
+ const widthDivisors = [2, 3, 4, 5, 6, 8, 10, 12, 16, 32];
3237
+ for (const d of widthDivisors) {
3238
+ vars.set(`wd${d}`, w / d);
3239
+ }
3240
+ const heightDivisors = [2, 3, 4, 5, 6, 8, 10, 12, 16, 32];
3241
+ for (const d of heightDivisors) {
3242
+ vars.set(`hd${d}`, h / d);
3243
+ }
3244
+ const ss = Math.min(w, h);
3245
+ const ls = Math.max(w, h);
3246
+ vars.set("ss", ss);
3247
+ vars.set("ls", ls);
3248
+ const ssDivisors = [2, 4, 6, 8, 16, 32];
3249
+ for (const d of ssDivisors) {
3250
+ vars.set(`ssd${d}`, ss / d);
3251
+ }
3252
+ vars.set("cd2", 180 * ANGLE_SCALE);
3253
+ vars.set("cd4", 90 * ANGLE_SCALE);
3254
+ vars.set("cd8", 45 * ANGLE_SCALE);
3255
+ vars.set("3cd4", 270 * ANGLE_SCALE);
3256
+ vars.set("3cd8", 135 * ANGLE_SCALE);
3257
+ vars.set("5cd8", 225 * ANGLE_SCALE);
3258
+ vars.set("7cd8", 315 * ANGLE_SCALE);
3259
+ return vars;
3260
+ }
3261
+ function evaluateGuides(guides, ctx, adjustments) {
3262
+ const vars = createBuiltinVariables(ctx);
3263
+ if (adjustments) {
3264
+ for (const [name, value] of adjustments) {
3265
+ vars.set(name, value);
3266
+ }
3267
+ }
3268
+ for (const guide of guides) {
3269
+ const parsed = parseFormula(guide.formula);
3270
+ const value = evaluateFormula(parsed, vars);
3271
+ vars.set(guide.name, Number.isFinite(value) ? value : 0);
3272
+ }
3273
+ return vars;
3274
+ }
3275
+
2962
3276
  // drawingml/write-color.ts
2963
3277
  var ELEMENTS = {
2964
3278
  srgb: "srgbClr",
@@ -3090,6 +3404,10 @@ function drawingPatternPictureXml(fill) {
3090
3404
  else if (blip.getAttributeNS(NS.r, attribute) !== value)
3091
3405
  blip.setAttributeNS(NS.r, `r:${attribute}`, value);
3092
3406
  }
3407
+ if (fill.crop !== void 0 && JSON.stringify(before?.kind === "picture" ? before.crop : void 0) !== JSON.stringify(fill.crop))
3408
+ applyPictureCrop(root, fill.crop);
3409
+ if (fill.effects !== void 0 && JSON.stringify(before?.kind === "picture" ? before.effects ?? [] : []) !== JSON.stringify(fill.effects ?? []))
3410
+ applyPictureEffects(blip, fill.effects ?? []);
3093
3411
  if (!fill.sourceXml) {
3094
3412
  const stretch = doc.createElementNS(NS.a, "a:stretch");
3095
3413
  stretch.appendChild(doc.createElementNS(NS.a, "a:fillRect"));
@@ -3867,36 +4185,243 @@ function parseDrawingParagraphProperties(element3) {
3867
4185
  return out;
3868
4186
  }
3869
4187
 
3870
- // drawingml/read-text-body.ts
3871
- var BODY_STRINGS = [
3872
- ["verticalOverflow", "vertOverflow"],
3873
- ["horizontalOverflow", "horzOverflow"],
3874
- ["vertical", "vert"],
3875
- ["wrap", "wrap"],
3876
- ["anchor", "anchor"]
3877
- ];
3878
- var BODY_INTEGERS = [
3879
- ["insetLeftEmu", "lIns"],
3880
- ["insetTopEmu", "tIns"],
3881
- ["insetRightEmu", "rIns"],
3882
- ["insetBottomEmu", "bIns"],
3883
- ["columnCount", "numCol"],
3884
- ["columnSpacingEmu", "spcCol"]
3885
- ];
3886
- var BODY_BOOLEANS = [
3887
- ["spaceFirstLastParagraph", "spcFirstLastPara"],
3888
- ["rightToLeftColumns", "rtlCol"],
3889
- ["fromWordArt", "fromWordArt"],
3890
- ["anchorCenter", "anchorCtr"],
3891
- ["forceAntiAlias", "forceAA"],
3892
- ["upright", "upright"],
3893
- ["compatibleLineSpacing", "compatLnSpc"]
3894
- ];
3895
- function parseDrawingBodyProperties(element3) {
3896
- if (!element3) return void 0;
3897
- const out = {};
3898
- const rotation = integerAttribute(element3, "rot");
3899
- if (rotation !== void 0) out.rotation = rotation / 6e4;
4188
+ // drawingml/scene3d-presets.ts
4189
+ var CAMERA_PRESETS = /* @__PURE__ */ new Set([
4190
+ "legacyObliqueTopLeft",
4191
+ "legacyObliqueTop",
4192
+ "legacyObliqueTopRight",
4193
+ "legacyObliqueLeft",
4194
+ "legacyObliqueFront",
4195
+ "legacyObliqueRight",
4196
+ "legacyObliqueBottomLeft",
4197
+ "legacyObliqueBottom",
4198
+ "legacyObliqueBottomRight",
4199
+ "legacyPerspectiveTopLeft",
4200
+ "legacyPerspectiveTop",
4201
+ "legacyPerspectiveTopRight",
4202
+ "legacyPerspectiveLeft",
4203
+ "legacyPerspectiveFront",
4204
+ "legacyPerspectiveRight",
4205
+ "legacyPerspectiveBottomLeft",
4206
+ "legacyPerspectiveBottom",
4207
+ "legacyPerspectiveBottomRight",
4208
+ "orthographicFront",
4209
+ "isometricTopUp",
4210
+ "isometricTopDown",
4211
+ "isometricBottomUp",
4212
+ "isometricBottomDown",
4213
+ "isometricLeftUp",
4214
+ "isometricLeftDown",
4215
+ "isometricRightUp",
4216
+ "isometricRightDown",
4217
+ "isometricOffAxis1Left",
4218
+ "isometricOffAxis1Right",
4219
+ "isometricOffAxis1Top",
4220
+ "isometricOffAxis2Left",
4221
+ "isometricOffAxis2Right",
4222
+ "isometricOffAxis2Top",
4223
+ "isometricOffAxis3Left",
4224
+ "isometricOffAxis3Right",
4225
+ "isometricOffAxis3Bottom",
4226
+ "isometricOffAxis4Left",
4227
+ "isometricOffAxis4Right",
4228
+ "isometricOffAxis4Bottom",
4229
+ "obliqueTopLeft",
4230
+ "obliqueTop",
4231
+ "obliqueTopRight",
4232
+ "obliqueLeft",
4233
+ "obliqueRight",
4234
+ "obliqueBottomLeft",
4235
+ "obliqueBottom",
4236
+ "obliqueBottomRight",
4237
+ "perspectiveFront",
4238
+ "perspectiveLeft",
4239
+ "perspectiveRight",
4240
+ "perspectiveAbove",
4241
+ "perspectiveBelow",
4242
+ "perspectiveAboveLeftFacing",
4243
+ "perspectiveAboveRightFacing",
4244
+ "perspectiveContrastingLeftFacing",
4245
+ "perspectiveContrastingRightFacing",
4246
+ "perspectiveHeroicLeftFacing",
4247
+ "perspectiveHeroicRightFacing",
4248
+ "perspectiveHeroicExtremeLeftFacing",
4249
+ "perspectiveHeroicExtremeRightFacing",
4250
+ "perspectiveRelaxed",
4251
+ "perspectiveRelaxedModerately"
4252
+ ]);
4253
+ var LIGHT_RIGS = /* @__PURE__ */ new Set([
4254
+ "legacyFlat1",
4255
+ "legacyFlat2",
4256
+ "legacyFlat3",
4257
+ "legacyFlat4",
4258
+ "legacyNormal1",
4259
+ "legacyNormal2",
4260
+ "legacyNormal3",
4261
+ "legacyNormal4",
4262
+ "legacyHarsh1",
4263
+ "legacyHarsh2",
4264
+ "legacyHarsh3",
4265
+ "legacyHarsh4",
4266
+ "threePt",
4267
+ "balanced",
4268
+ "soft",
4269
+ "harsh",
4270
+ "flood",
4271
+ "contrasting",
4272
+ "morning",
4273
+ "sunrise",
4274
+ "sunset",
4275
+ "chilly",
4276
+ "freezing",
4277
+ "flat",
4278
+ "twoPt",
4279
+ "glow",
4280
+ "brightRoom"
4281
+ ]);
4282
+ var LIGHT_DIRECTIONS = /* @__PURE__ */ new Set(["tl", "t", "tr", "l", "r", "bl", "b", "br"]);
4283
+
4284
+ // drawingml/read-3d-values.ts
4285
+ var integer2 = (value) => {
4286
+ if (value === void 0 || value === null || String(value).trim() === "") return void 0;
4287
+ const n2 = Number(value);
4288
+ return Number.isSafeInteger(n2) ? n2 : void 0;
4289
+ };
4290
+ function readScene3DValues(node, read) {
4291
+ const out = {};
4292
+ const camera = read.child(node, "camera");
4293
+ const light = read.child(node, "lightRig");
4294
+ for (const [key, source, attribute, choices] of [
4295
+ ["cameraPreset", camera, "prst", CAMERA_PRESETS],
4296
+ ["lightRigType", light, "rig", LIGHT_RIGS],
4297
+ ["lightRigDirection", light, "dir", LIGHT_DIRECTIONS]
4298
+ ]) {
4299
+ const token = String(read.attribute(source, attribute) ?? "").trim();
4300
+ if (choices.has(token)) out[key] = token;
4301
+ }
4302
+ const fov = integer2(read.attribute(camera, "fov"));
4303
+ if (fov !== void 0 && fov >= 0 && fov <= 108e5) out.cameraFieldOfView = fov;
4304
+ const zoom = picturePercentage(read.attribute(camera, "zoom"));
4305
+ if (zoom !== void 0 && zoom > 0) out.cameraZoom = zoom;
4306
+ for (const [prefix, source] of [
4307
+ ["camera", camera],
4308
+ ["lightRig", light]
4309
+ ]) {
4310
+ const rot = read.child(source, "rot");
4311
+ for (const [axis, key] of [
4312
+ ["lat", "RotX"],
4313
+ ["lon", "RotY"],
4314
+ ["rev", "RotZ"]
4315
+ ]) {
4316
+ const value = integer2(read.attribute(rot, axis));
4317
+ if (value !== void 0 && value >= 0 && value < 216e5) out[`${prefix}${key}`] = value;
4318
+ }
4319
+ }
4320
+ const backdrop = read.child(node, "backdrop");
4321
+ if (backdrop !== void 0) {
4322
+ out.hasBackdrop = true;
4323
+ for (const [name, prefix, attr2] of [
4324
+ ["anchor", "backdropAnchor", ""],
4325
+ ["norm", "backdropNormal", "d"],
4326
+ ["up", "backdropUp", "d"]
4327
+ ]) {
4328
+ const point = read.child(backdrop, name);
4329
+ for (const [axis, suffix] of [
4330
+ ["x", "X"],
4331
+ ["y", "Y"],
4332
+ ["z", "Z"]
4333
+ ]) {
4334
+ const value = integer2(read.attribute(point, `${attr2}${axis}`));
4335
+ if (value !== void 0) out[`${prefix}${suffix}`] = value;
4336
+ }
4337
+ }
4338
+ }
4339
+ return out;
4340
+ }
4341
+ function readText3DValues(node, read) {
4342
+ const out = {};
4343
+ for (const [key, attribute] of [
4344
+ ["extrusionHeight", "extrusionH"],
4345
+ ["contourWidth", "contourW"],
4346
+ ["z", "z"]
4347
+ ]) {
4348
+ const value = integer2(read.attribute(node, attribute));
4349
+ if (value !== void 0) out[key] = value;
4350
+ }
4351
+ const material = String(read.attribute(node, "prstMaterial") ?? "").trim();
4352
+ if (material) out.presetMaterial = material;
4353
+ for (const [name, prefix] of [
4354
+ ["bevelT", "bevelTop"],
4355
+ ["bevelB", "bevelBottom"]
4356
+ ]) {
4357
+ const bevel2 = read.child(node, name);
4358
+ if (!bevel2) continue;
4359
+ out[`${prefix}Type`] = String(read.attribute(bevel2, "prst") || "circle").trim();
4360
+ for (const [attribute, suffix] of [
4361
+ ["w", "Width"],
4362
+ ["h", "Height"]
4363
+ ]) {
4364
+ const value = integer2(read.attribute(bevel2, attribute));
4365
+ if (value !== void 0) out[`${prefix}${suffix}`] = value;
4366
+ }
4367
+ }
4368
+ return out;
4369
+ }
4370
+
4371
+ // drawingml/read-text-3d.ts
4372
+ var DOM_3D_READER = {
4373
+ attribute: (node, name) => node?.getAttribute(name),
4374
+ child: (node, name) => first(node, name, NS.a)
4375
+ };
4376
+ function parseDrawingTextScene3D(node) {
4377
+ return { ...readScene3DValues(node, DOM_3D_READER), sourceXml: buildXml(node) };
4378
+ }
4379
+ function parseDrawingTextShape3D(node) {
4380
+ const extrusionColor = parseDrawingColorIn(first(node, "extrusionClr", NS.a));
4381
+ const contourColor = parseDrawingColorIn(first(node, "contourClr", NS.a));
4382
+ return {
4383
+ ...readText3DValues(node, DOM_3D_READER),
4384
+ sourceXml: buildXml(node),
4385
+ ...extrusionColor ? { extrusionColor } : {},
4386
+ ...contourColor ? { contourColor } : {}
4387
+ };
4388
+ }
4389
+ function parseDrawingFlatText3D(node) {
4390
+ const raw = node.getAttribute("z");
4391
+ const z = raw === null || !raw.trim() ? NaN : Number(raw);
4392
+ return { sourceXml: buildXml(node), ...Number.isSafeInteger(z) ? { z } : {} };
4393
+ }
4394
+
4395
+ // drawingml/read-text-body.ts
4396
+ var BODY_STRINGS = [
4397
+ ["verticalOverflow", "vertOverflow"],
4398
+ ["horizontalOverflow", "horzOverflow"],
4399
+ ["vertical", "vert"],
4400
+ ["wrap", "wrap"],
4401
+ ["anchor", "anchor"]
4402
+ ];
4403
+ var BODY_INTEGERS = [
4404
+ ["insetLeftEmu", "lIns"],
4405
+ ["insetTopEmu", "tIns"],
4406
+ ["insetRightEmu", "rIns"],
4407
+ ["insetBottomEmu", "bIns"],
4408
+ ["columnCount", "numCol"],
4409
+ ["columnSpacingEmu", "spcCol"]
4410
+ ];
4411
+ var BODY_BOOLEANS = [
4412
+ ["spaceFirstLastParagraph", "spcFirstLastPara"],
4413
+ ["rightToLeftColumns", "rtlCol"],
4414
+ ["fromWordArt", "fromWordArt"],
4415
+ ["anchorCenter", "anchorCtr"],
4416
+ ["forceAntiAlias", "forceAA"],
4417
+ ["upright", "upright"],
4418
+ ["compatibleLineSpacing", "compatLnSpc"]
4419
+ ];
4420
+ function parseDrawingBodyProperties(element3) {
4421
+ if (!element3) return void 0;
4422
+ const out = {};
4423
+ const rotation = integerAttribute(element3, "rot");
4424
+ if (rotation !== void 0) out.rotation = rotation / 6e4;
3900
4425
  for (const [key, name] of BODY_STRINGS) {
3901
4426
  const value = stringAttribute(element3, name);
3902
4427
  if (value) out[key] = value;
@@ -3923,7 +4448,13 @@ function parseDrawingBodyProperties(element3) {
3923
4448
  ...read("fontScale") !== void 0 && fontScale !== void 0 ? { fontScale } : {},
3924
4449
  ...read("lnSpcReduction") !== void 0 && reduction !== void 0 ? { lineSpacingReduction: reduction } : {}
3925
4450
  };
3926
- } else extra.push(outerXml(child3));
4451
+ } else if (name === "scene3d" && children(element3, "scene3d", NS.a).length === 1)
4452
+ out.scene3d = parseDrawingTextScene3D(child3);
4453
+ else if (name === "sp3d" && children(element3, "sp3d", NS.a).length === 1 && !first(element3, "flatTx", NS.a))
4454
+ out.shape3d = parseDrawingTextShape3D(child3);
4455
+ else if (name === "flatTx" && children(element3, "flatTx", NS.a).length === 1 && !first(element3, "sp3d", NS.a))
4456
+ out.flatText3d = parseDrawingFlatText3D(child3);
4457
+ else extra.push(outerXml(child3));
3927
4458
  }
3928
4459
  if (extra.length) out.extraXml = extra;
3929
4460
  return out;
@@ -3950,15 +4481,15 @@ function readItem(child3) {
3950
4481
  const name = isDrawingElement(child3) ? child3.localName : "";
3951
4482
  if (name === "pPr" || name === "endParaRPr") return void 0;
3952
4483
  if (name === "r") {
3953
- const properties4 = parseDrawingRunProperties(first(child3, "rPr", NS.a));
3954
- return { kind: "run", text: textOf(child3), ...properties4 ? { properties: properties4 } : {} };
4484
+ const properties3 = parseDrawingRunProperties(first(child3, "rPr", NS.a));
4485
+ return { kind: "run", text: textOf(child3), ...properties3 ? { properties: properties3 } : {} };
3955
4486
  }
3956
4487
  if (name === "br") {
3957
- const properties4 = parseDrawingRunProperties(first(child3, "rPr", NS.a));
3958
- return { kind: "break", ...properties4 ? { properties: properties4 } : {} };
4488
+ const properties3 = parseDrawingRunProperties(first(child3, "rPr", NS.a));
4489
+ return { kind: "break", ...properties3 ? { properties: properties3 } : {} };
3959
4490
  }
3960
4491
  if (name === "fld") {
3961
- const properties4 = parseDrawingRunProperties(first(child3, "rPr", NS.a));
4492
+ const properties3 = parseDrawingRunProperties(first(child3, "rPr", NS.a));
3962
4493
  const paragraphProperties2 = parseDrawingParagraphProperties(first(child3, "pPr", NS.a));
3963
4494
  const type = child3.getAttribute("type");
3964
4495
  return {
@@ -3966,7 +4497,7 @@ function readItem(child3) {
3966
4497
  id: child3.getAttribute("id") ?? "",
3967
4498
  ...type ? { type } : {},
3968
4499
  text: textOf(child3),
3969
- ...properties4 ? { properties: properties4 } : {},
4500
+ ...properties3 ? { properties: properties3 } : {},
3970
4501
  ...paragraphProperties2 ? { paragraphProperties: paragraphProperties2 } : {}
3971
4502
  };
3972
4503
  }
@@ -3978,10 +4509,10 @@ function parseDrawingParagraph(element3) {
3978
4509
  const item2 = readItem(child3);
3979
4510
  if (item2) items.push(item2);
3980
4511
  }
3981
- const properties4 = parseDrawingParagraphProperties(first(element3, "pPr", NS.a));
4512
+ const properties3 = parseDrawingParagraphProperties(first(element3, "pPr", NS.a));
3982
4513
  const endProperties = parseDrawingRunProperties(first(element3, "endParaRPr", NS.a));
3983
4514
  return {
3984
- ...properties4 ? { properties: properties4 } : {},
4515
+ ...properties3 ? { properties: properties3 } : {},
3985
4516
  items,
3986
4517
  ...endProperties ? { endProperties } : {}
3987
4518
  };
@@ -4003,194 +4534,6 @@ function keptChildName(xml) {
4003
4534
  return match?.[1] ?? "";
4004
4535
  }
4005
4536
 
4006
- // geometry/guide-formula-eval.ts
4007
- var ANGLE_SCALE = 6e4;
4008
- function angleToRadians(ooxmlAngle) {
4009
- return ooxmlAngle / ANGLE_SCALE * (Math.PI / 180);
4010
- }
4011
- function parseFormula(fmla) {
4012
- const parts = fmla.trim().split(/\s+/);
4013
- const op = parts[0] ?? "";
4014
- const args = parts.slice(1);
4015
- return { op, args };
4016
- }
4017
- function resolveOperand(token, variables) {
4018
- const num2 = Number(token);
4019
- if (Number.isFinite(num2)) {
4020
- return num2;
4021
- }
4022
- const value = variables.get(token);
4023
- if (value !== void 0) {
4024
- return value;
4025
- }
4026
- return 0;
4027
- }
4028
- function evaluateFormula(parsed, vars) {
4029
- const r = (idx) => resolveOperand(parsed.args[idx] ?? "0", vars);
4030
- switch (parsed.op) {
4031
- // val x — literal value
4032
- case "val":
4033
- return r(0);
4034
- // abs x — absolute value
4035
- case "abs":
4036
- return Math.abs(r(0));
4037
- // sqrt x — square root
4038
- case "sqrt":
4039
- return Math.sqrt(Math.max(r(0), 0));
4040
- // +- x y z — x + y - z
4041
- case "+-":
4042
- return r(0) + r(1) - r(2);
4043
- // */ x y z — (x * y) / z
4044
- case "*/": {
4045
- const z = r(2);
4046
- if (z === 0) {
4047
- return 0;
4048
- }
4049
- return r(0) * r(1) / z;
4050
- }
4051
- // +/ x y z — (x + y) / z
4052
- case "+/": {
4053
- const z = r(2);
4054
- if (z === 0) {
4055
- return 0;
4056
- }
4057
- return (r(0) + r(1)) / z;
4058
- }
4059
- // ?: x y z — if x > 0 then y else z
4060
- case "?:":
4061
- case "if":
4062
- return r(0) > 0 ? r(1) : r(2);
4063
- // min x y — minimum
4064
- case "min":
4065
- return Math.min(r(0), r(1));
4066
- // max x y — maximum
4067
- case "max":
4068
- return Math.max(r(0), r(1));
4069
- // mod x y z — sqrt(x² + y² + z²)
4070
- case "mod": {
4071
- const a = r(0);
4072
- const b = r(1);
4073
- const c = r(2);
4074
- return Math.sqrt(a * a + b * b + c * c);
4075
- }
4076
- // pin x y z — clamp y between x and z
4077
- case "pin": {
4078
- const lo = r(0);
4079
- const val = r(1);
4080
- const hi = r(2);
4081
- return Math.max(lo, Math.min(val, hi));
4082
- }
4083
- // sin x y — x * sin(y) where y is in OOXML angle units
4084
- case "sin": {
4085
- const sinVal = Math.sin(angleToRadians(r(1)));
4086
- if (!Number.isFinite(sinVal)) {
4087
- return 0;
4088
- }
4089
- return r(0) * sinVal;
4090
- }
4091
- // cos x y — x * cos(y) where y is in OOXML angle units
4092
- case "cos": {
4093
- const cosVal = Math.cos(angleToRadians(r(1)));
4094
- if (!Number.isFinite(cosVal)) {
4095
- return 0;
4096
- }
4097
- return r(0) * cosVal;
4098
- }
4099
- // tan x y — x * tan(y) where y is in OOXML angle units
4100
- case "tan": {
4101
- const angle = angleToRadians(r(1));
4102
- const tanVal = Math.tan(angle);
4103
- if (!Number.isFinite(tanVal)) {
4104
- return 0;
4105
- }
4106
- return r(0) * tanVal;
4107
- }
4108
- // atan x — atan(x) result in OOXML angle units
4109
- // x is a ratio scaled by the shape coordinate space
4110
- case "atan": {
4111
- const radians = Math.atan(r(0));
4112
- return radians * 180 * ANGLE_SCALE / Math.PI;
4113
- }
4114
- // at2 x y -> arctan(y / x), i.e. Math.atan2(y, x), result in OOXML angle
4115
- // units. ECMA-376 / ISO-IEC-29500-1 section 20.1.9.6 defines the operand
4116
- // order as (x, y) with the ARGUMENTS REVERSED relative to Math.atan2, so
4117
- // the first operand is the horizontal component and the second is the
4118
- // vertical one. This matches the companion `cat2`/`sat2` operators below,
4119
- // which take (x, y, z) and compute atan2(z, y).
4120
- case "at2":
4121
- case "atan2": {
4122
- const radians = Math.atan2(r(1), r(0));
4123
- return radians * 180 * ANGLE_SCALE / Math.PI;
4124
- }
4125
- // cat2 x y z — x * cos(atan2(z, y))
4126
- // Computes the cosine-component of a vector scaled by x
4127
- case "cat2": {
4128
- const angle = Math.atan2(r(2), r(1));
4129
- return r(0) * Math.cos(angle);
4130
- }
4131
- // sat2 x y z — x * sin(atan2(z, y))
4132
- // Computes the sine-component of a vector scaled by x
4133
- case "sat2": {
4134
- const angle = Math.atan2(r(2), r(1));
4135
- return r(0) * Math.sin(angle);
4136
- }
4137
- default:
4138
- return Number(parsed.op) || 0;
4139
- }
4140
- }
4141
-
4142
- // geometry/guide-formula-api.ts
4143
- function createBuiltinVariables(ctx) {
4144
- const { w, h } = ctx;
4145
- const vars = /* @__PURE__ */ new Map();
4146
- vars.set("w", w);
4147
- vars.set("h", h);
4148
- vars.set("l", 0);
4149
- vars.set("t", 0);
4150
- vars.set("r", w);
4151
- vars.set("b", h);
4152
- vars.set("hc", w / 2);
4153
- vars.set("vc", h / 2);
4154
- const widthDivisors = [2, 3, 4, 5, 6, 8, 10, 12, 16, 32];
4155
- for (const d of widthDivisors) {
4156
- vars.set(`wd${d}`, w / d);
4157
- }
4158
- const heightDivisors = [2, 3, 4, 5, 6, 8, 10, 12, 16, 32];
4159
- for (const d of heightDivisors) {
4160
- vars.set(`hd${d}`, h / d);
4161
- }
4162
- const ss = Math.min(w, h);
4163
- const ls = Math.max(w, h);
4164
- vars.set("ss", ss);
4165
- vars.set("ls", ls);
4166
- const ssDivisors = [2, 4, 6, 8, 16, 32];
4167
- for (const d of ssDivisors) {
4168
- vars.set(`ssd${d}`, ss / d);
4169
- }
4170
- vars.set("cd2", 180 * ANGLE_SCALE);
4171
- vars.set("cd4", 90 * ANGLE_SCALE);
4172
- vars.set("cd8", 45 * ANGLE_SCALE);
4173
- vars.set("3cd4", 270 * ANGLE_SCALE);
4174
- vars.set("3cd8", 135 * ANGLE_SCALE);
4175
- vars.set("5cd8", 225 * ANGLE_SCALE);
4176
- vars.set("7cd8", 315 * ANGLE_SCALE);
4177
- return vars;
4178
- }
4179
- function evaluateGuides(guides, ctx, adjustments) {
4180
- const vars = createBuiltinVariables(ctx);
4181
- if (adjustments) {
4182
- for (const [name, value] of adjustments) {
4183
- vars.set(name, value);
4184
- }
4185
- }
4186
- for (const guide of guides) {
4187
- const parsed = parseFormula(guide.formula);
4188
- const value = evaluateFormula(parsed, vars);
4189
- vars.set(guide.name, Number.isFinite(value) ? value : 0);
4190
- }
4191
- return vars;
4192
- }
4193
-
4194
4537
  // geometry/ooxml-arc.ts
4195
4538
  function ooxmlArcToSvg(wR, hR, stAng, swAng, penX, penY) {
4196
4539
  if (![wR, hR, stAng, swAng, penX, penY].every(Number.isFinite) || wR <= 0 || hR <= 0 || swAng === 0) {
@@ -15493,10 +15836,10 @@ function textBoxAt(node, boxW, boxH) {
15493
15836
  const upright = (node.alg.params.autoTxRot ?? "upr") === "upr";
15494
15837
  return sideways && upright ? { w: th, h: tw } : { w: tw, h: th };
15495
15838
  }
15496
- var SIDES = ["lMarg", "rMarg", "tMarg", "bMarg"];
15839
+ var SIDES2 = ["lMarg", "rMarg", "tMarg", "bMarg"];
15497
15840
  function nodeMarginsPt(node, sizePt, refSize) {
15498
15841
  const out = { lMarg: 0, rMarg: 0, tMarg: 0, bMarg: 0 };
15499
- for (const side of SIDES) {
15842
+ for (const side of SIDES2) {
15500
15843
  const deferred = node.deferred.find((d) => d.type === side && FONT_TYPES.has(d.refType));
15501
15844
  if (deferred) {
15502
15845
  const base = deferred.ref === node ? sizePt : refSize?.(deferred.ref) ?? sizePt;
@@ -16712,7 +17055,7 @@ function measureHierRoot(root) {
16712
17055
  const { side, align } = parseHierAlign(root.alg.params.hierAlign);
16713
17056
  const vertical = side === "t" || side === "b";
16714
17057
  const assistantRows = side === "t" ? rowNodes.filter((row) => isAssistantRow(row, itemsOf(row))) : [];
16715
- const rows = rowNodes.filter((row) => !assistantRows.includes(row));
17058
+ const rows2 = rowNodes.filter((row) => !assistantRows.includes(row));
16716
17059
  let top = size.h + sp;
16717
17060
  const centre = size.dx + size.partW / 2;
16718
17061
  const assistants = [];
@@ -16727,26 +17070,26 @@ function measureHierRoot(root) {
16727
17070
  assistants.push(...band.rects);
16728
17071
  top = band.bottom + sp;
16729
17072
  }
16730
- if (rows.length === 0) {
17073
+ if (rows2.length === 0) {
16731
17074
  return { rects: [...own2, ...assistants], head };
16732
17075
  }
16733
- if (side === "t" && rows.every(isTwoColumnRow)) {
17076
+ if (side === "t" && rows2.every(isTwoColumnRow)) {
16734
17077
  const hung = placeTwoColumns(
16735
- rows.flatMap((row) => itemsOf(row).map(measureHierRoot)),
17078
+ rows2.flatMap((row) => itemsOf(row).map(measureHierRoot)),
16736
17079
  centre,
16737
17080
  top,
16738
- Math.max(0, rows[0].values.get("sibSp") ?? 0),
17081
+ Math.max(0, rows2[0].values.get("sibSp") ?? 0),
16739
17082
  sp
16740
17083
  );
16741
17084
  return { rects: [...own2, ...assistants, ...hung.rects], head };
16742
17085
  }
16743
- const group2 = pack(rows.map(measureHierChild), vertical, sp, false);
17086
+ const group2 = pack(rows2.map(measureHierChild), vertical, sp, false);
16744
17087
  const groupBounds = boundsOf(group2.rects);
16745
17088
  let placed;
16746
17089
  if (vertical) {
16747
17090
  const dy = side === "t" ? top - groupBounds.y : -sp - (groupBounds.y + groupBounds.h);
16748
17091
  let dx = alignShift(head, group2.head, align, true);
16749
- if (side === "t" && align !== "center" && rows.every(isColumn)) {
17092
+ if (side === "t" && align !== "center" && rows2.every(isColumn)) {
16750
17093
  const inset = hangInset(root) * size.w;
16751
17094
  dx = align === "start" ? head.x + inset - group2.head.x : head.x + head.w - inset - (group2.head.x + group2.head.w);
16752
17095
  }
@@ -18623,11 +18966,11 @@ function reflowBending(nodes, bounds) {
18623
18966
  const COLS = 4;
18624
18967
  const padding = 8;
18625
18968
  const gap = 6;
18626
- const rows = Math.ceil(nodes.length / COLS);
18969
+ const rows2 = Math.ceil(nodes.length / COLS);
18627
18970
  const usableW = bounds.width - padding * 2;
18628
18971
  const usableH = bounds.height - padding * 2;
18629
18972
  const cellW = (usableW - gap * (COLS - 1)) / COLS;
18630
- const cellH = (usableH - gap * (rows - 1)) / Math.max(rows, 1);
18973
+ const cellH = (usableH - gap * (rows2 - 1)) / Math.max(rows2, 1);
18631
18974
  const boxW = cellW * 0.85;
18632
18975
  const boxH = Math.min(cellH * 0.7, 40);
18633
18976
  const shapes = [];
@@ -18710,13 +19053,13 @@ function reflowCycle(nodes, bounds) {
18710
19053
  }
18711
19054
  function reflowMatrix(nodes, bounds) {
18712
19055
  const cols = Math.ceil(Math.sqrt(nodes.length));
18713
- const rows = Math.ceil(nodes.length / cols);
19056
+ const rows2 = Math.ceil(nodes.length / cols);
18714
19057
  const padding = 8;
18715
19058
  const gap = 6;
18716
19059
  const usableW = bounds.width - padding * 2;
18717
19060
  const usableH = bounds.height - padding * 2;
18718
19061
  const cellW = (usableW - gap * (cols - 1)) / cols;
18719
- const cellH = (usableH - gap * (rows - 1)) / rows;
19062
+ const cellH = (usableH - gap * (rows2 - 1)) / rows2;
18720
19063
  return nodes.map((node, i) => {
18721
19064
  const col = i % cols;
18722
19065
  const row = Math.floor(i / cols);
@@ -19188,9 +19531,9 @@ function parsePoint(element3) {
19188
19531
  text: paragraphs.join("\n"),
19189
19532
  ...textParagraphs2 ? { textParagraphs: textParagraphs2 } : {}
19190
19533
  };
19191
- const properties4 = first(element3, "spPr", NS.dgm);
19192
- const fill = parseDrawingFill(properties4);
19193
- const line3 = parseDrawingLine(first(properties4, "ln", NS.a));
19534
+ const properties3 = first(element3, "spPr", NS.dgm);
19535
+ const fill = parseDrawingFill(properties3);
19536
+ const line3 = parseDrawingLine(first(properties3, "ln", NS.a));
19194
19537
  if (fill) point.fill = fill;
19195
19538
  if (line3) point.line = line3;
19196
19539
  const optional = [
@@ -19431,15 +19774,15 @@ function diagramPreviewText(nodes, fontSize) {
19431
19774
  paragraphs.push(paragraph);
19432
19775
  continue;
19433
19776
  }
19434
- const properties4 = segment2.style.run;
19777
+ const properties3 = segment2.style.run;
19435
19778
  const run = {
19436
19779
  text: segment2.text,
19437
- sizePt: properties4.sizePt ?? fontSize * 0.75,
19438
- ...properties4.bold !== void 0 ? { bold: properties4.bold } : {},
19439
- ...properties4.italic !== void 0 ? { italic: properties4.italic } : {},
19440
- ...properties4.underline ? { underline: properties4.underline !== "none" } : {},
19441
- ...properties4.fill?.kind === "solid" ? { color: properties4.fill.color } : {},
19442
- ...properties4.latin?.typeface ? { typeface: properties4.latin.typeface } : {}
19780
+ sizePt: properties3.sizePt ?? fontSize * 0.75,
19781
+ ...properties3.bold !== void 0 ? { bold: properties3.bold } : {},
19782
+ ...properties3.italic !== void 0 ? { italic: properties3.italic } : {},
19783
+ ...properties3.underline ? { underline: properties3.underline !== "none" } : {},
19784
+ ...properties3.fill?.kind === "solid" ? { color: properties3.fill.color } : {},
19785
+ ...properties3.latin?.typeface ? { typeface: properties3.latin.typeface } : {}
19443
19786
  };
19444
19787
  const align = segment2.style.paragraph.align;
19445
19788
  if (align) paragraph.align = align;
@@ -19788,17 +20131,47 @@ function groupRowsByCategory(rawCategories) {
19788
20131
  const rowIndexesByCategory = /* @__PURE__ */ new Map();
19789
20132
  rawCategories.forEach((rawLabel, rowIndex) => {
19790
20133
  const label = rawLabel ?? "";
19791
- let rows = rowIndexesByCategory.get(label);
19792
- if (!rows) {
19793
- rows = [];
19794
- rowIndexesByCategory.set(label, rows);
20134
+ let rows2 = rowIndexesByCategory.get(label);
20135
+ if (!rows2) {
20136
+ rows2 = [];
20137
+ rowIndexesByCategory.set(label, rows2);
19795
20138
  uniqueCategories.push(label);
19796
20139
  }
19797
- rows.push(rowIndex);
20140
+ rows2.push(rowIndex);
19798
20141
  });
19799
20142
  return { uniqueCategories, rowIndexesByCategory };
19800
20143
  }
19801
-
20144
+ function percentile(sorted, p, method) {
20145
+ const rank2 = method === "inclusive" ? (sorted.length - 1) * p : (sorted.length + 1) * p - 1;
20146
+ const clamped = Math.max(0, Math.min(rank2, sorted.length - 1));
20147
+ const lower = Math.floor(clamped);
20148
+ const upper = Math.ceil(clamped);
20149
+ const fraction = clamped - lower;
20150
+ return sorted[lower] + (sorted[upper] - sorted[lower]) * fraction;
20151
+ }
20152
+ function computeBoxStats(values, method) {
20153
+ if (values.length < 2) {
20154
+ return void 0;
20155
+ }
20156
+ const sorted = [...values].sort((a, b) => a - b);
20157
+ if (!method) {
20158
+ return {
20159
+ min: sorted[0],
20160
+ q1: sorted[Math.floor(sorted.length * 0.25)],
20161
+ median: sorted[Math.floor(sorted.length * 0.5)],
20162
+ q3: sorted[Math.floor(sorted.length * 0.75)],
20163
+ max: sorted[sorted.length - 1]
20164
+ };
20165
+ }
20166
+ return {
20167
+ min: sorted[0],
20168
+ q1: percentile(sorted, 0.25, method),
20169
+ median: percentile(sorted, 0.5, method),
20170
+ q3: percentile(sorted, 0.75, method),
20171
+ max: sorted[sorted.length - 1]
20172
+ };
20173
+ }
20174
+
19802
20175
  // chart/number-format-pattern.ts
19803
20176
  var NAMED_FORMAT_COLORS = {
19804
20177
  black: "#000000",
@@ -20493,11 +20866,11 @@ function computeHistogramBins(values, options2, format = String) {
20493
20866
  function aggregateByCategory(values, rawCategories) {
20494
20867
  const { uniqueCategories, rowIndexesByCategory } = groupRowsByCategory(rawCategories);
20495
20868
  return uniqueCategories.map((label) => {
20496
- const rows = rowIndexesByCategory.get(label) ?? [];
20869
+ const rows2 = rowIndexesByCategory.get(label) ?? [];
20497
20870
  return {
20498
- value: rows.reduce((sum, row) => sum + (values[row] ?? 0), 0),
20871
+ value: rows2.reduce((sum, row) => sum + (values[row] ?? 0), 0),
20499
20872
  label,
20500
- sourceIndices: rows
20873
+ sourceIndices: rows2
20501
20874
  };
20502
20875
  });
20503
20876
  }
@@ -20749,6 +21122,62 @@ function placeBestFitLabel(slice, w, h) {
20749
21122
  return { x: slice.cx + outside * ux, y: slice.cy + outside * uy, inside: false };
20750
21123
  }
20751
21124
 
21125
+ // chart/pie-label-collision.ts
21126
+ var LABEL_COLLISION_GAP = 2;
21127
+ function boxDistanceToCentre(box, y, disc) {
21128
+ const nearestX = Math.max(box.x - box.w / 2, Math.min(disc.cx, box.x + box.w / 2));
21129
+ const nearestY = Math.max(y - box.h / 2, Math.min(disc.cy, y + box.h / 2));
21130
+ return Math.hypot(nearestX - disc.cx, nearestY - disc.cy);
21131
+ }
21132
+ function clearOfDisc(box, y, disc) {
21133
+ if (boxDistanceToCentre(box, y, disc) >= disc.r) {
21134
+ return 0;
21135
+ }
21136
+ const sign = box.x >= disc.cx ? 1 : -1;
21137
+ let dx = 0;
21138
+ while (dx < disc.r * 2 && boxDistanceToCentre({ ...box, x: box.x + sign * dx }, y, disc) < disc.r) {
21139
+ dx += 1;
21140
+ }
21141
+ return sign * dx;
21142
+ }
21143
+ function overlapsX(a, b) {
21144
+ return Math.abs(a.x - b.x) < (a.w + b.w) / 2;
21145
+ }
21146
+ function sweepSide(boxes, minY, maxY) {
21147
+ const sorted = [...boxes].sort((a, b) => a.y - b.y || a.id - b.id);
21148
+ const ys = sorted.map((box) => box.y);
21149
+ for (let i = 1; i < sorted.length; i++) {
21150
+ const prev = sorted[i - 1];
21151
+ const box = sorted[i];
21152
+ if (overlapsX(prev, box)) {
21153
+ ys[i] = Math.max(ys[i], ys[i - 1] + (prev.h + box.h) / 2 + LABEL_COLLISION_GAP);
21154
+ }
21155
+ }
21156
+ for (let i = sorted.length - 1; i >= 0; i--) {
21157
+ const box = sorted[i];
21158
+ const limit = i === sorted.length - 1 ? maxY - box.h / 2 : ys[i + 1] - (box.h + sorted[i + 1].h) / 2 - LABEL_COLLISION_GAP;
21159
+ if (ys[i] > limit) {
21160
+ ys[i] = Math.max(limit, minY + box.h / 2);
21161
+ }
21162
+ }
21163
+ return new Map(sorted.map((box, i) => [box.id, ys[i]]));
21164
+ }
21165
+ function nudgeOutsideLabels(boxes, disc, minY, maxY) {
21166
+ const resolved = /* @__PURE__ */ new Map();
21167
+ for (const side of [
21168
+ boxes.filter((box) => box.x >= disc.cx),
21169
+ boxes.filter((box) => box.x < disc.cx)
21170
+ ]) {
21171
+ for (const [id, y] of sweepSide(side, minY, maxY)) {
21172
+ resolved.set(id, y);
21173
+ }
21174
+ }
21175
+ return boxes.map((box) => {
21176
+ const y = resolved.get(box.id) ?? box.y;
21177
+ return { id: box.id, dx: y === box.y ? 0 : clearOfDisc(box, y, disc), dy: y - box.y };
21178
+ });
21179
+ }
21180
+
20752
21181
  // chart/color-palettes.ts
20753
21182
  var COLORFUL_VARIATIONS = [
20754
21183
  {},
@@ -20910,6 +21339,20 @@ function resolveManualLayoutRect(layout, frame2, auto) {
20910
21339
  const height = layout.height === void 0 ? auto.height : layout.heightMode === "edge" ? layout.height * frame2.height - y : layout.height * frame2.height;
20911
21340
  return { x, y, width: Math.max(width, 1), height: Math.max(height, 1) };
20912
21341
  }
21342
+ function resolveManualPlotRect(layout, frame2, auto, bands) {
21343
+ const rect3 = resolveManualLayoutRect(layout, frame2, auto);
21344
+ if (!rect3 || layout?.layoutTarget === "inner") return rect3;
21345
+ return {
21346
+ x: rect3.x + bands.left,
21347
+ y: rect3.y + bands.top,
21348
+ width: Math.max(1, rect3.width - bands.left - bands.right),
21349
+ height: Math.max(1, rect3.height - bands.top - bands.bottom)
21350
+ };
21351
+ }
21352
+ function applyLabelManualLayout(layout, frame2, point) {
21353
+ const rect3 = resolveManualLayoutRect(layout, frame2, { ...point, width: 1, height: 1 });
21354
+ return rect3 ? { x: rect3.x, y: rect3.y } : point;
21355
+ }
20913
21356
 
20914
21357
  // chart/gradient-stop-edit.ts
20915
21358
  function sortGradientStops(stops) {
@@ -21303,6 +21746,9 @@ function summaryAnalysis(series) {
21303
21746
  // chart/render/summary-labels.ts
21304
21747
  function level2(options2, custom) {
21305
21748
  const out = {};
21749
+ if (options2.layout) out.layout = options2.layout;
21750
+ if (options2.showLeaderLines !== void 0) out.showLeaderLines = options2.showLeaderLines;
21751
+ if (options2.leaderLines?.spPr?.line) out.leaderLine = options2.leaderLines.spPr.line;
21306
21752
  if (options2.deleted !== void 0) out.deleted = options2.deleted;
21307
21753
  if (options2.showValue !== void 0) out.showValue = options2.showValue;
21308
21754
  if (options2.showCategoryName !== void 0) out.showCategory = options2.showCategoryName;
@@ -21352,7 +21798,7 @@ var GROUP_TYPES = {
21352
21798
  surface: "surface"
21353
21799
  };
21354
21800
  var GROUPINGS = /* @__PURE__ */ new Set(["clustered", "stacked", "percentStacked", "standard"]);
21355
- function chartSummarySeries(source, chartType, groupLabels) {
21801
+ function chartSummarySeries(source, chartType, groupLabels, groupSmooth) {
21356
21802
  const categories = source.categories ?? source.xValues;
21357
21803
  const values = source.values ?? source.yValues;
21358
21804
  const numeric = (v) => typeof v === "number" ? v : v === "" ? null : Number.isFinite(Number(v)) ? Number(v) : null;
@@ -21360,6 +21806,9 @@ function chartSummarySeries(source, chartType, groupLabels) {
21360
21806
  categories: chartSourceValues(categories),
21361
21807
  values: chartSourceValues(values).map(numeric)
21362
21808
  };
21809
+ const smooth = source.smooth ?? groupSmooth;
21810
+ if (smooth !== void 0) out.smooth = smooth;
21811
+ if (source.spPr?.line) out.line = source.spPr.line;
21363
21812
  if (values?.cache?.formatCode !== void 0) out.numberFormat = values.cache.formatCode;
21364
21813
  if (source.bubbleSizes) {
21365
21814
  out.bubbleSizes = chartSourceValues(source.bubbleSizes).map(numeric);
@@ -21380,12 +21829,12 @@ function chartSummarySeries(source, chartType, groupLabels) {
21380
21829
  const points = {};
21381
21830
  const pointFills = {};
21382
21831
  for (const point of source.dataPoints) {
21383
- const properties4 = point.spPr ?? point.marker?.spPr;
21832
+ const properties3 = point.spPr ?? point.marker?.spPr;
21384
21833
  if (point.index === void 0) continue;
21385
- const pointColor = solidColor(properties4?.fill);
21834
+ const pointColor = solidColor(properties3?.fill);
21386
21835
  if (pointColor) points[point.index] = pointColor;
21387
- if (properties4?.fill && properties4.fill.kind !== "solid")
21388
- pointFills[point.index] = properties4.fill;
21836
+ if (properties3?.fill && properties3.fill.kind !== "solid")
21837
+ pointFills[point.index] = properties3.fill;
21389
21838
  }
21390
21839
  if (Object.keys(points).length) out.pointColors = points;
21391
21840
  if (Object.keys(pointFills).length) out.pointFills = pointFills;
@@ -21419,7 +21868,12 @@ function extraGroups(chartSpace, firstType) {
21419
21868
  const entry = {
21420
21869
  chartType: type,
21421
21870
  series: group2.series.map((source, index) => ({
21422
- ...chartSummarySeries(source, type, group2.dataLabels),
21871
+ ...chartSummarySeries(
21872
+ source,
21873
+ type,
21874
+ group2.dataLabels,
21875
+ group2.smooth ?? (group2.scatterStyle ? ["smooth", "smoothMarker"].includes(group2.scatterStyle) : void 0)
21876
+ ),
21423
21877
  ...summaryMarkers(source, group2, index)
21424
21878
  })),
21425
21879
  secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
@@ -21440,8 +21894,14 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
21440
21894
  let chartType = group2 ? GROUP_TYPES[group2.kind] : "column";
21441
21895
  if (chartType === "bar" && group2?.barDirection !== "bar") chartType = "column";
21442
21896
  const series = (group2?.series ?? []).map((source, index) => ({
21443
- ...chartSummarySeries(source, chartType, group2?.dataLabels),
21444
- ...group2 ? summaryMarkers(source, group2, index) : {}
21897
+ ...chartSummarySeries(
21898
+ source,
21899
+ chartType,
21900
+ group2?.dataLabels,
21901
+ group2?.smooth ?? (group2?.scatterStyle ? ["smooth", "smoothMarker"].includes(group2.scatterStyle) : void 0)
21902
+ ),
21903
+ ...group2 ? summaryMarkers(source, group2, index) : {},
21904
+ ...group2?.kind === "scatter" ? { showLine: !["marker", "none"].includes(group2.scatterStyle ?? "marker") } : {}
21445
21905
  }));
21446
21906
  const summary = {
21447
21907
  chartType,
@@ -21450,6 +21910,9 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
21450
21910
  axes: chartSpace.plotArea.axes,
21451
21911
  axisIds: group2?.axisIds ?? []
21452
21912
  };
21913
+ if (chartSpace.plotArea.dataTable) summary.dataTable = chartSpace.plotArea.dataTable;
21914
+ if (chartSpace.date1904 !== void 0) summary.date1904 = chartSpace.date1904;
21915
+ if (chartSpace.plotArea.layout) summary.plotLayout = chartSpace.plotArea.layout;
21453
21916
  const combined = extraGroups(chartSpace, chartType);
21454
21917
  if (combined.length) summary.extraGroups = combined;
21455
21918
  if (chartType === "stock" && group2) summary.stock = stockStyle(group2);
@@ -21488,45 +21951,15 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
21488
21951
  return summary;
21489
21952
  }
21490
21953
 
21491
- // chart/render/chart-svg-util.ts
21492
- var TEXT_COLOR = "#595959";
21493
- var GRID_COLOR = "#D9D9D9";
21494
- var AXIS_COLOR = "#BFBFBF";
21495
- var FONT_SIZE = 10;
21496
- function esc(text2) {
21497
- return text2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
21498
- }
21499
- var n = (value) => String(Math.round(value * 100) / 100);
21500
- var textWidth = (text2, size = FONT_SIZE) => text2.length * size * 0.55;
21501
- function text(x, y, content, attrs2 = {}) {
21502
- const parts = [`x="${n(x)}"`, `y="${n(y)}"`];
21503
- parts.push(`font-size="${attrs2.size ?? FONT_SIZE}"`);
21504
- parts.push(`fill="${esc(attrs2.fill ?? TEXT_COLOR)}"`);
21505
- if (attrs2.anchor && attrs2.anchor !== "start") parts.push(`text-anchor="${attrs2.anchor}"`);
21506
- if (attrs2.weight) parts.push(`font-weight="${attrs2.weight}"`);
21507
- if (attrs2.baseline) parts.push(`dominant-baseline="${attrs2.baseline}"`);
21508
- if (attrs2.family) parts.push(`font-family="${esc(attrs2.family)}"`);
21509
- if (attrs2.filter) parts.push(`filter="${esc(attrs2.filter)}"`);
21510
- if (attrs2.italic !== void 0) parts.push(`font-style="${attrs2.italic ? "italic" : "normal"}"`);
21511
- if (attrs2.underline !== void 0)
21512
- parts.push(`text-decoration="${attrs2.underline ? "underline" : "none"}"`);
21513
- return `<text ${parts.join(" ")}>${esc(content)}</text>`;
21514
- }
21515
- var line2 = (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}"/>`;
21516
- var rect2 = (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)}"` : ""}/>`;
21517
- function fit(content, maxWidth, size = FONT_SIZE) {
21518
- if (textWidth(content, size) <= maxWidth) return content;
21519
- const chars = Math.max(1, Math.floor(maxWidth / (size * 0.55)) - 1);
21520
- return `${content.slice(0, chars)}\u2026`;
21521
- }
21522
-
21523
- // chart/render/chart-spacing.ts
21524
- function chartBarSpacing(chart) {
21525
- const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
21526
- return {
21527
- barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
21528
- barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
21529
- };
21954
+ // chart/funnel-geometry.ts
21955
+ function computeFunnelGeometry(values, plot) {
21956
+ const max = Math.max(...values.map((v) => Math.abs(v)), 1);
21957
+ const height = plot.height / Math.max(1, values.length);
21958
+ const center = plot.x + plot.width / 2;
21959
+ return values.map((value, index) => {
21960
+ const width = Math.abs(value) / max * plot.width;
21961
+ return { index, x: center - width / 2, y: plot.y + index * height, width, height, center };
21962
+ });
21530
21963
  }
21531
21964
 
21532
21965
  // chart/render/theme-palette.ts
@@ -21669,6 +22102,38 @@ function chartAppearance(chart, theme) {
21669
22102
  return out;
21670
22103
  }
21671
22104
 
22105
+ // chart/render/chart-svg-util.ts
22106
+ var TEXT_COLOR = "#595959";
22107
+ var GRID_COLOR = "#D9D9D9";
22108
+ var AXIS_COLOR = "#BFBFBF";
22109
+ var FONT_SIZE = 10;
22110
+ function esc(text2) {
22111
+ return text2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
22112
+ }
22113
+ var n = (value) => String(Math.round(value * 100) / 100);
22114
+ var textWidth = (text2, size = FONT_SIZE) => text2.length * size * 0.55;
22115
+ function text(x, y, content, attrs2 = {}) {
22116
+ const parts = [`x="${n(x)}"`, `y="${n(y)}"`];
22117
+ parts.push(`font-size="${attrs2.size ?? FONT_SIZE}"`);
22118
+ parts.push(`fill="${esc(attrs2.fill ?? TEXT_COLOR)}"`);
22119
+ if (attrs2.anchor && attrs2.anchor !== "start") parts.push(`text-anchor="${attrs2.anchor}"`);
22120
+ if (attrs2.weight) parts.push(`font-weight="${attrs2.weight}"`);
22121
+ if (attrs2.baseline) parts.push(`dominant-baseline="${attrs2.baseline}"`);
22122
+ if (attrs2.family) parts.push(`font-family="${esc(attrs2.family)}"`);
22123
+ if (attrs2.filter) parts.push(`filter="${esc(attrs2.filter)}"`);
22124
+ if (attrs2.italic !== void 0) parts.push(`font-style="${attrs2.italic ? "italic" : "normal"}"`);
22125
+ if (attrs2.underline !== void 0)
22126
+ parts.push(`text-decoration="${attrs2.underline ? "underline" : "none"}"`);
22127
+ return `<text ${parts.join(" ")}>${esc(content)}</text>`;
22128
+ }
22129
+ var line2 = (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}"/>`;
22130
+ var rect2 = (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)}"` : ""}/>`;
22131
+ function fit(content, maxWidth, size = FONT_SIZE) {
22132
+ if (textWidth(content, size) <= maxWidth) return content;
22133
+ const chars = Math.max(1, Math.floor(maxWidth / (size * 0.55)) - 1);
22134
+ return `${content.slice(0, chars)}\u2026`;
22135
+ }
22136
+
21672
22137
  // text/css-font-family.ts
21673
22138
  var FALLBACKS = {
21674
22139
  calibri: '"Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
@@ -21694,9 +22159,9 @@ function chartGradientPaint(model, width = 1024, height = 768) {
21694
22159
  const defs = [];
21695
22160
  const shadowPaint = (shadow, suffix) => {
21696
22161
  const id = `${prefix}-${suffix}`;
21697
- const pad = Math.max(4, shadow.blur * 3 + Math.abs(shadow.dx) + Math.abs(shadow.dy));
22162
+ const pad2 = Math.max(4, shadow.blur * 3 + Math.abs(shadow.dx) + Math.abs(shadow.dy));
21698
22163
  defs.push(
21699
- `<filter id="${id}" filterUnits="userSpaceOnUse" x="${n(-pad)}" y="${n(-pad)}" width="${n(width + pad * 2)}" height="${n(height + pad * 2)}" color-interpolation-filters="sRGB">${svgDropShadowElement(shadow, { number: n, color: (value) => esc(value) })}</filter>`
22164
+ `<filter id="${id}" filterUnits="userSpaceOnUse" x="${n(-pad2)}" y="${n(-pad2)}" width="${n(width + pad2 * 2)}" height="${n(height + pad2 * 2)}" color-interpolation-filters="sRGB">${svgDropShadowElement(shadow, { number: n, color: (value) => esc(value) })}</filter>`
21700
22165
  );
21701
22166
  return `url(#${id})`;
21702
22167
  };
@@ -21774,6 +22239,155 @@ function chartAreaRect(model, part, area) {
21774
22239
  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}"/>`;
21775
22240
  }
21776
22241
 
22242
+ // chart/render/chart-svg-funnel.ts
22243
+ function funnelSvg(model, area) {
22244
+ const series = model.series[0];
22245
+ if (!series || series.hidden) return "";
22246
+ const attrs2 = chartTextAttributes(model, "categoryAxis", 10);
22247
+ const width = Math.min(
22248
+ area.w * 0.3,
22249
+ Math.max(32, ...model.categories.map((s) => s.length * (attrs2.size ?? 10) * 0.55 + 8))
22250
+ );
22251
+ const plot = { x: area.x + width, y: area.y, width: Math.max(1, area.w - width), height: area.h };
22252
+ const out = [
22253
+ chartAreaRect(model, "plotArea", { x: plot.x, y: plot.y, w: plot.width, h: plot.height })
22254
+ ];
22255
+ for (const bar of computeFunnelGeometry(
22256
+ series.values.map((v) => v ?? 0),
22257
+ plot
22258
+ )) {
22259
+ const value = series.values[bar.index];
22260
+ if (value === null || value === void 0) continue;
22261
+ out.push(`<g data-chart-series="${series.sourceIndex ?? 0}" data-chart-point="${bar.index}">`);
22262
+ out.push(
22263
+ rect2(bar.x, bar.y, bar.width, bar.height, series.pointColors?.[bar.index] ?? series.color)
22264
+ );
22265
+ const size = Math.min(10, bar.height * 0.4);
22266
+ const label = series.labels?.[bar.index];
22267
+ if (label)
22268
+ out.push(
22269
+ text(bar.center, bar.y + bar.height / 2 + size * 0.35, label.text, {
22270
+ ...chartTextAttributes(model, "dataLabel", size),
22271
+ size,
22272
+ anchor: "middle"
22273
+ })
22274
+ );
22275
+ out.push(
22276
+ text(
22277
+ plot.x - 8,
22278
+ bar.y + bar.height / 2 + (attrs2.size ?? 10) * 0.35,
22279
+ fit(model.categories[bar.index] ?? "", width - 8, attrs2.size ?? 10),
22280
+ { ...attrs2, anchor: "end" }
22281
+ )
22282
+ );
22283
+ out.push("</g>");
22284
+ }
22285
+ return out.join("");
22286
+ }
22287
+
22288
+ // chart/box-distribution.ts
22289
+ function boxWhiskerDistribution(values, method = "exclusive", trimOutliers = false) {
22290
+ const stats = computeBoxStats(values, method);
22291
+ if (!stats) return void 0;
22292
+ const iqr = stats.q3 - stats.q1;
22293
+ const lowerFence = stats.q1 - 1.5 * iqr;
22294
+ const upperFence = stats.q3 + 1.5 * iqr;
22295
+ const inliers = values.filter((v) => !trimOutliers || v >= lowerFence && v <= upperFence);
22296
+ return {
22297
+ stats,
22298
+ whiskerMin: inliers.length ? Math.min(...inliers) : stats.min,
22299
+ whiskerMax: inliers.length ? Math.max(...inliers) : stats.max,
22300
+ mean: values.reduce((a, b) => a + b, 0) / values.length
22301
+ };
22302
+ }
22303
+ function boxMeanMarkerPath(x, y, radius = 3) {
22304
+ return `M${x - radius},${y - radius} L${x + radius},${y + radius} M${x - radius},${y + radius} L${x + radius},${y - radius}`;
22305
+ }
22306
+
22307
+ // chart/render/chart-svg-box.ts
22308
+ function boxWhiskerSvg(model, frame2, out) {
22309
+ const visible = model.series.filter((s) => !s.hidden);
22310
+ const slot = frame2.bandSize / Math.max(1, visible.length);
22311
+ const width = slot * 0.7;
22312
+ visible.forEach((series, si) => {
22313
+ if (series.hidden) return;
22314
+ const groups = groupRowsByCategory(series.boxCategories ?? []);
22315
+ model.categories.forEach((category, ci) => {
22316
+ const observations = (groups.rowIndexesByCategory.get(category) ?? []).flatMap((row) => {
22317
+ const value = series.values[row];
22318
+ return value === null || value === void 0 ? [] : [{ row, value }];
22319
+ });
22320
+ const options2 = series.boxWhisker;
22321
+ const rawMethod = options2?.statistics?.quartileMethod;
22322
+ const method = rawMethod === "inclusive" ? "inclusive" : "exclusive";
22323
+ const visibility = options2?.visibility;
22324
+ const trim = rawMethod === "inclusive" || rawMethod === "exclusive" || !!visibility && Object.values(visibility).some((v) => v !== void 0);
22325
+ const distribution = boxWhiskerDistribution(
22326
+ observations.map((p) => p.value),
22327
+ method,
22328
+ trim
22329
+ );
22330
+ if (!distribution) return;
22331
+ const { stats, whiskerMin, whiskerMax, mean } = distribution;
22332
+ const x = frame2.band(ci) - frame2.bandSize / 2 + si * slot + (slot - width) / 2;
22333
+ const mid = x + width / 2;
22334
+ const y = frame2.value;
22335
+ out.push(
22336
+ `<g data-chart-part="box" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${ci}">`
22337
+ );
22338
+ out.push(line2(mid, y(whiskerMax), mid, y(stats.q3), "#64748b", 1));
22339
+ out.push(line2(mid, y(stats.q1), mid, y(whiskerMin), "#64748b", 1));
22340
+ out.push(
22341
+ line2(x + width * 0.25, y(whiskerMin), x + width * 0.75, y(whiskerMin), "#64748b", 1)
22342
+ );
22343
+ out.push(
22344
+ line2(x + width * 0.25, y(whiskerMax), x + width * 0.75, y(whiskerMax), "#64748b", 1)
22345
+ );
22346
+ out.push(
22347
+ rect2(
22348
+ x,
22349
+ Math.min(y(stats.q1), y(stats.q3)),
22350
+ width,
22351
+ Math.abs(y(stats.q1) - y(stats.q3)),
22352
+ series.pointColors?.[ci] ?? series.color
22353
+ )
22354
+ );
22355
+ out.push(line2(x, y(stats.median), x + width, y(stats.median), "#1e293b", 2));
22356
+ if (visibility?.meanLine) out.push(line2(x, y(mean), x + width, y(mean), "#0f766e", 1.5));
22357
+ if (visibility?.meanMarker !== false)
22358
+ out.push(
22359
+ `<path d="${boxMeanMarkerPath(mid, y(mean))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
22360
+ );
22361
+ observations.forEach((point, index) => {
22362
+ const outlier = point.value < whiskerMin || point.value > whiskerMax;
22363
+ if (outlier ? !visibility?.outliers : !visibility?.nonoutliers) return;
22364
+ const px = x + width * (0.2 + 0.6 * (index + 1) / (observations.length + 1));
22365
+ out.push(
22366
+ `<circle cx="${n(px)}" cy="${n(y(point.value))}" r="2.25" fill="${outlier ? "#dc2626" : "#1e293b"}" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${point.row}" data-chart-part="${outlier ? "outlier" : "observation"}"/>`
22367
+ );
22368
+ });
22369
+ out.push("</g>");
22370
+ });
22371
+ });
22372
+ }
22373
+
22374
+ // chart/data-table-layout.ts
22375
+ function chartDataTableMetrics(fontSize, names, showKeys = true) {
22376
+ const rowH = Math.max(14, Math.round(fontSize * 1.45));
22377
+ const longestName = names.reduce((m, name) => Math.max(m, name.length), 0);
22378
+ const keyW = Math.min(160, Math.max(40, longestName * fontSize * 0.55 + (showKeys ? 24 : 8)));
22379
+ return { fontSize, rowH, keyW, height: rowH * (1 + names.length) };
22380
+ }
22381
+
22382
+ // chart/render/chart-spacing.ts
22383
+ function chartBarSpacing(chart) {
22384
+ const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
22385
+ return {
22386
+ barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
22387
+ barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
22388
+ };
22389
+ }
22390
+
21777
22391
  // chart/render/chart-svg-labels.ts
21778
22392
  var GAP = 3;
21779
22393
  var LINE = 1.2;
@@ -21783,6 +22397,7 @@ function measure3(model, label) {
21783
22397
  const size = attrs2.size ?? 10;
21784
22398
  const lines = label.text.split("\n");
21785
22399
  return {
22400
+ ...model.frameSize ? { frame: model.frameSize } : {},
21786
22401
  lines,
21787
22402
  size,
21788
22403
  w: Math.max(...lines.map((l) => textWidth(l, size))),
@@ -21791,6 +22406,7 @@ function measure3(model, label) {
21791
22406
  };
21792
22407
  }
21793
22408
  function draw(m, label, x, y, anchor, out) {
22409
+ if (m.frame) ({ x, y } = applyLabelManualLayout(label.layout, m.frame, { x, y }));
21794
22410
  const fill = label.color && NAMED_COLORS.test(label.color) ? label.color.toLowerCase() : void 0;
21795
22411
  m.lines.forEach((line3, k) => {
21796
22412
  const lineY = y - m.h / 2 + (k + 0.5) * m.size * LINE + m.size * 0.35;
@@ -21850,46 +22466,6 @@ function pointLabels(model, marks, out) {
21850
22466
  }
21851
22467
  }
21852
22468
  }
21853
- function sliceLabels(model, marks, out) {
21854
- for (const mark of marks) {
21855
- const label = mark.series.labels?.[mark.index];
21856
- if (!label) continue;
21857
- const m = measure3(model, label);
21858
- const mid = (mark.start + mark.end) / 2;
21859
- const ux = Math.sin(mid);
21860
- const uy = -Math.cos(mid);
21861
- const place2 = (radius) => [
21862
- mark.cx + radius * ux,
21863
- mark.cy + radius * uy
21864
- ];
21865
- const position2 = model.type === "doughnut" ? "ctr" : label.position ?? "bestFit";
21866
- let x;
21867
- let y;
21868
- if (position2 === "ctr") [x, y] = place2(mark.inner + (mark.outer - mark.inner) / 2);
21869
- else if (position2 === "inEnd") {
21870
- const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
21871
- [x, y] = place2(Math.max(0, mark.outer - GAP - extent));
21872
- } else if (position2 === "outEnd") {
21873
- const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
21874
- [x, y] = place2(mark.outer + GAP + extent);
21875
- } else {
21876
- const placed = placeBestFitLabel(
21877
- {
21878
- cx: mark.cx,
21879
- cy: mark.cy,
21880
- outerR: mark.outer,
21881
- startAngle: mark.start - Math.PI / 2,
21882
- endAngle: mark.end - Math.PI / 2
21883
- },
21884
- m.w,
21885
- m.h
21886
- );
21887
- x = placed.x;
21888
- y = placed.y;
21889
- }
21890
- draw(m, label, x, y, "middle", out);
21891
- }
21892
- }
21893
22469
  function hasOutsideLabels(model) {
21894
22470
  return model.series.some(
21895
22471
  (s) => s.labels?.some(
@@ -21915,7 +22491,8 @@ function bars(model, frame2, out, values) {
21915
22491
  const marks = [];
21916
22492
  model.series.forEach((s, si) => {
21917
22493
  values[si]?.forEach((v, i) => {
21918
- if (v === null || i >= model.categories.length) return;
22494
+ if (v === null || i >= model.categories.length || frame2.order && !frame2.order.includes(i))
22495
+ return;
21919
22496
  let from = 0;
21920
22497
  let to = v;
21921
22498
  if (stacked) {
@@ -22033,12 +22610,482 @@ function categoryAnalysis(model, frame2, out) {
22033
22610
  seriesAnalysis(series, si, (i) => i + 1, plane, barPlane, true, out);
22034
22611
  });
22035
22612
  }
22036
- function scatterAnalysis(model, px, py, out) {
22037
- const plane = (x, y) => [px(x), py(y)];
22038
- model.series.forEach((series, si) => {
22039
- if (!series.trendlines && !series.errorBars) return;
22040
- seriesAnalysis(series, si, (i) => series.xValues?.[i] ?? null, plane, plane, false, out);
22041
- });
22613
+ function scatterAnalysis(model, px, py, out) {
22614
+ const plane = (x, y) => [px(x), py(y)];
22615
+ model.series.forEach((series, si) => {
22616
+ if (!series.trendlines && !series.errorBars) return;
22617
+ seriesAnalysis(series, si, (i) => series.xValues?.[i] ?? null, plane, plane, false, out);
22618
+ });
22619
+ }
22620
+
22621
+ // chart/render/chart-scale.ts
22622
+ var clean = (n2) => Number(n2.toPrecision(12));
22623
+ function* units(raw) {
22624
+ let exp = Math.floor(Math.log10(raw)) - 1;
22625
+ for (; ; ) {
22626
+ const base = 10 ** exp;
22627
+ for (const m of [1, 2, 5]) yield clean(m * base);
22628
+ exp++;
22629
+ }
22630
+ }
22631
+ function niceScale(dataMin, dataMax, options2 = {}) {
22632
+ const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
22633
+ let lo = Number.isFinite(dataMin) ? dataMin : 0;
22634
+ let hi = Number.isFinite(dataMax) ? dataMax : 0;
22635
+ if (lo > hi) [lo, hi] = [hi, lo];
22636
+ if (lo === hi) {
22637
+ if (lo === 0) hi = 1;
22638
+ else if (options2.noZero) {
22639
+ const pad2 = Math.abs(lo) * 0.1 || 1;
22640
+ lo -= pad2;
22641
+ hi += pad2;
22642
+ } else if (lo > 0) lo = 0;
22643
+ else hi = 0;
22644
+ }
22645
+ let fixedLo = false;
22646
+ let fixedHi = false;
22647
+ if (!options2.noZero) {
22648
+ if (lo >= 0 && hi - lo >= hi / 6) {
22649
+ lo = 0;
22650
+ fixedLo = true;
22651
+ } else if (hi <= 0 && hi - lo >= -lo / 6) {
22652
+ hi = 0;
22653
+ fixedHi = true;
22654
+ }
22655
+ }
22656
+ const range = hi - lo;
22657
+ const top = fixedHi ? hi : hi + range * 0.05;
22658
+ const bottom = fixedLo ? lo : lo - range * 0.05;
22659
+ for (const unit of units(range / maxIntervals)) {
22660
+ const min = fixedLo ? lo : Math.floor(clean(bottom / unit)) * unit;
22661
+ const max = fixedHi ? hi : Math.ceil(clean(top / unit)) * unit;
22662
+ const intervals = Math.round((max - min) / unit);
22663
+ if (intervals <= maxIntervals && intervals > 0) {
22664
+ const ticks = [];
22665
+ for (let i = 0; i <= intervals; i++) ticks.push(clean(min + i * unit));
22666
+ return { min: clean(min), max: clean(max), majorUnit: unit, ticks };
22667
+ }
22668
+ }
22669
+ return { min: lo, max: hi, majorUnit: range, ticks: [lo, hi] };
22670
+ }
22671
+ var PERCENT_SCALE = {
22672
+ min: 0,
22673
+ max: 1,
22674
+ majorUnit: 0.1,
22675
+ ticks: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
22676
+ };
22677
+ function formatAxisValue(value, percent = false) {
22678
+ if (percent) return `${clean(value * 100)}%`;
22679
+ const v = clean(value);
22680
+ if (Math.abs(v) >= 1e15 || v !== 0 && Math.abs(v) < 1e-6)
22681
+ return v.toExponential(2).replace("e+", "E+").replace("e-", "E-");
22682
+ const [int = "0", frac] = String(Math.abs(v)).split(".");
22683
+ const grouped = int.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
22684
+ return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
22685
+ }
22686
+
22687
+ // chart/render/chart-svg-data-table.ts
22688
+ var rows = (model) => [
22689
+ ...model.series,
22690
+ ...(model.extraGroups ?? []).flatMap((g) => g.series)
22691
+ ];
22692
+ function chartTableMetrics(model) {
22693
+ if (!model.dataTable) return void 0;
22694
+ const size = model.dataTable.text?.fontSize;
22695
+ return chartDataTableMetrics(
22696
+ size === void 0 ? 13.333333333333334 : chartPointsToPixels(size),
22697
+ rows(model).map((s) => s.name),
22698
+ model.dataTable.source.showKeys !== false
22699
+ );
22700
+ }
22701
+ function chartDataTableSvg(model, plot) {
22702
+ const table = model.dataTable;
22703
+ const metrics = chartTableMetrics(model);
22704
+ if (!table || !metrics) return "";
22705
+ const { source } = table;
22706
+ const { rowH, keyW, height, fontSize } = metrics;
22707
+ const series = rows(model);
22708
+ const top = plot.y + plot.h;
22709
+ const left = plot.x - keyW;
22710
+ const right = plot.x + plot.w;
22711
+ const bottom = top + height;
22712
+ const cellW = plot.w / Math.max(1, model.categories.length);
22713
+ const styled = { ...model, appearance: { ...model.appearance, dataLabel: table.text ?? {} } };
22714
+ const attrs2 = chartTextAttributes(styled, "dataLabel", fontSize);
22715
+ const out = ['<g data-chart-part="dataTable">'];
22716
+ const border = (x1, y1, x2, y2) => out.push(
22717
+ `<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" ${strokeAttributes(table.stroke)}/>`
22718
+ );
22719
+ const label = (x, y, value, width, anchor = "middle") => out.push(
22720
+ text(x, y + fontSize * 0.35, fit(value, Math.max(1, width), fontSize), { ...attrs2, anchor })
22721
+ );
22722
+ if (table.fill) out.push(rect2(left, top, right - left, height, table.fill));
22723
+ if (source.showOutline !== false) {
22724
+ border(plot.x, top, right, top);
22725
+ border(right, top, right, bottom);
22726
+ border(right, bottom, left, bottom);
22727
+ border(left, bottom, left, top + rowH);
22728
+ border(left, top + rowH, plot.x, top + rowH);
22729
+ border(plot.x, top, plot.x, top + rowH);
22730
+ }
22731
+ model.categories.forEach((category, i) => {
22732
+ label(plot.x + (i + 0.5) * cellW, top + rowH / 2, category, cellW - 4);
22733
+ if (source.showVerticalBorder !== false && i > 0)
22734
+ border(plot.x + i * cellW, top, plot.x + i * cellW, bottom);
22735
+ });
22736
+ if (source.showVerticalBorder !== false) border(plot.x, top, plot.x, bottom);
22737
+ series.forEach((s, i) => {
22738
+ const rowTop = top + rowH * (i + 1);
22739
+ const cy = rowTop + rowH / 2;
22740
+ if (source.showHorizontalBorder !== false) border(left, rowTop, right, rowTop);
22741
+ if (source.showKeys !== false) {
22742
+ const swatch = Math.max(6, Math.round(fontSize * 0.55));
22743
+ out.push(rect2(left + 4, cy - swatch / 2, swatch, swatch, s.color));
22744
+ }
22745
+ const keyInset = source.showKeys !== false ? Math.max(6, Math.round(fontSize * 0.55)) + 7 : 4;
22746
+ label(left + keyInset, cy, s.name, keyW - keyInset - 4, "start");
22747
+ model.categories.forEach((_, j) => {
22748
+ const value = s.values[j];
22749
+ const formatted = value === null || value === void 0 ? "" : formatChartNumber(value, s.numberFormat) ?? formatAxisValue(value);
22750
+ label(plot.x + (j + 0.5) * cellW, cy, formatted, cellW - 4);
22751
+ });
22752
+ });
22753
+ return out.join("") + "</g>";
22754
+ }
22755
+
22756
+ // chart/date-axis.ts
22757
+ var DAY_MS = 864e5;
22758
+ function excelSerialToDate(serial, date1904 = false) {
22759
+ const epoch = date1904 ? Date.UTC(1904, 0, 1) : Date.UTC(1899, 11, serial < 60 ? 31 : 30);
22760
+ return new Date(epoch + serial * DAY_MS);
22761
+ }
22762
+ function addUnit(date, amount, unit) {
22763
+ const next = new Date(date);
22764
+ if (unit === "days") {
22765
+ next.setUTCDate(next.getUTCDate() + amount);
22766
+ } else if (unit === "months") {
22767
+ next.setUTCMonth(next.getUTCMonth() + amount);
22768
+ } else {
22769
+ next.setUTCFullYear(next.getUTCFullYear() + amount);
22770
+ }
22771
+ return next;
22772
+ }
22773
+ function calendarTicks(min, max, date1904, unit, step) {
22774
+ const result = [];
22775
+ let date = excelSerialToDate(min, date1904);
22776
+ for (let guard = 0; guard < 1e3 && date.getTime() <= excelSerialToDate(max, date1904).getTime(); guard++) {
22777
+ result.push(min + (date.getTime() - excelSerialToDate(min, date1904).getTime()) / DAY_MS);
22778
+ date = addUnit(date, step, unit);
22779
+ }
22780
+ return result;
22781
+ }
22782
+
22783
+ // chart/date-format.ts
22784
+ var MONTH_ABBR = [
22785
+ "Jan",
22786
+ "Feb",
22787
+ "Mar",
22788
+ "Apr",
22789
+ "May",
22790
+ "Jun",
22791
+ "Jul",
22792
+ "Aug",
22793
+ "Sep",
22794
+ "Oct",
22795
+ "Nov",
22796
+ "Dec"
22797
+ ];
22798
+ var MONTH_FULL = [
22799
+ "January",
22800
+ "February",
22801
+ "March",
22802
+ "April",
22803
+ "May",
22804
+ "June",
22805
+ "July",
22806
+ "August",
22807
+ "September",
22808
+ "October",
22809
+ "November",
22810
+ "December"
22811
+ ];
22812
+ var WEEKDAY_ABBR = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
22813
+ var WEEKDAY_FULL = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
22814
+ function scanDateFormatTokens(code) {
22815
+ const tokens = [];
22816
+ let i = 0;
22817
+ while (i < code.length) {
22818
+ const ch = code[i];
22819
+ if (ch === '"') {
22820
+ const close = code.indexOf('"', i + 1);
22821
+ tokens.push({
22822
+ kind: "literal",
22823
+ text: close === -1 ? code.slice(i + 1) : code.slice(i + 1, close)
22824
+ });
22825
+ i = close === -1 ? code.length : close + 1;
22826
+ continue;
22827
+ }
22828
+ if (ch === "\\") {
22829
+ tokens.push({ kind: "literal", text: code[i + 1] ?? "" });
22830
+ i += 2;
22831
+ continue;
22832
+ }
22833
+ const rest = code.slice(i);
22834
+ if (/^am\/pm/iu.test(rest)) {
22835
+ tokens.push({ kind: "ampm", upper: ch === ch.toUpperCase(), short: false });
22836
+ i += 5;
22837
+ continue;
22838
+ }
22839
+ if (/^a\/p/iu.test(rest)) {
22840
+ tokens.push({ kind: "ampm", upper: ch === ch.toUpperCase(), short: true });
22841
+ i += 3;
22842
+ continue;
22843
+ }
22844
+ if (/[ymdhs]/iu.test(ch)) {
22845
+ let j = i + 1;
22846
+ while (j < code.length && code[j].toLowerCase() === ch.toLowerCase()) {
22847
+ j += 1;
22848
+ }
22849
+ tokens.push({
22850
+ kind: "letters",
22851
+ letter: ch.toLowerCase(),
22852
+ count: j - i
22853
+ });
22854
+ i = j;
22855
+ continue;
22856
+ }
22857
+ tokens.push({ kind: "literal", text: ch });
22858
+ i += 1;
22859
+ }
22860
+ return tokens;
22861
+ }
22862
+ function findNonLiteral(tokens, index, step) {
22863
+ for (let i = index + step; i >= 0 && i < tokens.length; i += step) {
22864
+ if (tokens[i].kind !== "literal") {
22865
+ return tokens[i];
22866
+ }
22867
+ }
22868
+ return void 0;
22869
+ }
22870
+ function pad(n2, width) {
22871
+ return String(n2).padStart(width, "0");
22872
+ }
22873
+ function renderDatePart(part, count, date, twelveHour) {
22874
+ switch (part) {
22875
+ case "year":
22876
+ return count >= 4 ? pad(date.getUTCFullYear(), 4) : pad(date.getUTCFullYear() % 100, 2);
22877
+ case "month":
22878
+ if (count >= 4) {
22879
+ return MONTH_FULL[date.getUTCMonth()] ?? "";
22880
+ }
22881
+ if (count === 3) {
22882
+ return MONTH_ABBR[date.getUTCMonth()] ?? "";
22883
+ }
22884
+ return count >= 2 ? pad(date.getUTCMonth() + 1, 2) : String(date.getUTCMonth() + 1);
22885
+ case "day":
22886
+ if (count >= 4) {
22887
+ return WEEKDAY_FULL[date.getUTCDay()] ?? "";
22888
+ }
22889
+ if (count === 3) {
22890
+ return WEEKDAY_ABBR[date.getUTCDay()] ?? "";
22891
+ }
22892
+ return count >= 2 ? pad(date.getUTCDate(), 2) : String(date.getUTCDate());
22893
+ case "hour": {
22894
+ const h24 = date.getUTCHours();
22895
+ const h = twelveHour ? h24 % 12 === 0 ? 12 : h24 % 12 : h24;
22896
+ return count >= 2 ? pad(h, 2) : String(h);
22897
+ }
22898
+ case "minute":
22899
+ return count >= 2 ? pad(date.getUTCMinutes(), 2) : String(date.getUTCMinutes());
22900
+ case "second":
22901
+ return count >= 2 ? pad(date.getUTCSeconds(), 2) : String(date.getUTCSeconds());
22902
+ }
22903
+ }
22904
+ function renderExcelDateFormat(date, code) {
22905
+ const tokens = scanDateFormatTokens(code);
22906
+ const hasAmPm = tokens.some((t) => t.kind === "ampm");
22907
+ let out = "";
22908
+ for (const [index, token] of tokens.entries()) {
22909
+ if (token.kind === "literal") {
22910
+ out += token.text;
22911
+ continue;
22912
+ }
22913
+ if (token.kind === "ampm") {
22914
+ const hour = date.getUTCHours(), text2 = token.short ? hour < 12 ? "A" : "P" : hour < 12 ? "AM" : "PM";
22915
+ out += token.upper ? text2 : text2.toLowerCase();
22916
+ continue;
22917
+ }
22918
+ if (token.letter === "m") {
22919
+ const prev = findNonLiteral(tokens, index, -1), next = findNonLiteral(tokens, index, 1), isMinute = prev?.kind === "letters" && prev.letter === "h" || next?.kind === "letters" && next.letter === "s";
22920
+ out += renderDatePart(isMinute ? "minute" : "month", token.count, date, hasAmPm);
22921
+ continue;
22922
+ }
22923
+ const part = { y: "year", d: "day", h: "hour", s: "second" };
22924
+ out += renderDatePart(part[token.letter], token.count, date, hasAmPm);
22925
+ }
22926
+ return out;
22927
+ }
22928
+ function formatDate(date, unit, format) {
22929
+ if (format && /[ymdhs]/iu.test(format)) {
22930
+ const rendered = renderExcelDateFormat(date, format);
22931
+ if (rendered.length > 0) {
22932
+ return rendered;
22933
+ }
22934
+ }
22935
+ const month = date.toLocaleString("en-US", { month: "short", timeZone: "UTC" }), year = String(date.getUTCFullYear()), day = String(date.getUTCDate());
22936
+ if (unit === "years") {
22937
+ return year;
22938
+ }
22939
+ if (unit === "months") {
22940
+ return `${month} ${year}`;
22941
+ }
22942
+ return `${day} ${month}`;
22943
+ }
22944
+
22945
+ // chart/render/chart-svg-date-axis.ts
22946
+ function chartDateAxis(model, plot, out) {
22947
+ const axis = model.axes?.category?.source;
22948
+ const values = model.dateCategories;
22949
+ if (axis?.kind !== "date" || !values?.length) return void 0;
22950
+ const points = values.flatMap(
22951
+ (value, index) => value === null || !Number.isFinite(value) ? [] : [{ value, index }]
22952
+ ).sort((a, b) => a.value - b.value);
22953
+ if (!points.length) return void 0;
22954
+ const min = axis.scaling.min ?? points[0].value;
22955
+ const max = axis.scaling.max ?? points.at(-1).value;
22956
+ if (!Number.isFinite(min) || !Number.isFinite(max) || max < min) return void 0;
22957
+ const position2 = (value) => {
22958
+ const ratio = max === min ? 0.5 : (value - min) / (max - min);
22959
+ const t = axis.scaling.orientation === "maxMin" ? 1 - ratio : ratio;
22960
+ return model.horizontal ? plot.y + plot.h * (1 - t) : plot.x + plot.w * t;
22961
+ };
22962
+ const visible = points.filter((p) => p.value >= min && p.value <= max);
22963
+ const unitOf = (unit2) => unit2 === "months" || unit2 === "years" ? unit2 : "days";
22964
+ const unit = unitOf(axis.majorTimeUnit ?? axis.baseTimeUnit);
22965
+ const ticks = calendarTicks(
22966
+ min,
22967
+ max,
22968
+ model.date1904 ?? false,
22969
+ unit,
22970
+ Math.max(1, axis.majorUnit ?? 1)
22971
+ );
22972
+ const attrs2 = chartTextAttributes(model, "categoryAxis");
22973
+ const size = attrs2.size ?? 10;
22974
+ const y = axis.position === "t" ? plot.y : plot.y + plot.h;
22975
+ const paint2 = model.axes?.category?.line;
22976
+ const stroke = { color: paint2?.color ?? "#BFBFBF", width: paint2?.width ?? 1 };
22977
+ const mark = (serial, placement, length) => {
22978
+ if (!placement || placement === "none" || axis.deleted) return;
22979
+ const inward = axis.position === "t" ? length : -length;
22980
+ const start = placement === "cross" ? -length : 0;
22981
+ const end = placement === "cross" ? length : placement === "in" ? inward : -inward;
22982
+ if (model.horizontal) {
22983
+ const x = axis.position === "r" ? plot.x + plot.w : plot.x;
22984
+ const direction = axis.position === "r" ? -1 : 1;
22985
+ const a = placement === "cross" ? -length : 0;
22986
+ const b = placement === "cross" ? length : placement === "in" ? direction * length : -direction * length;
22987
+ out.push(
22988
+ `<line x1="${x + a}" y1="${position2(serial)}" x2="${x + b}" y2="${position2(serial)}" ${strokeAttributes(stroke)} data-chart-part="dateTick"/>`
22989
+ );
22990
+ } else
22991
+ out.push(
22992
+ `<line x1="${position2(serial)}" y1="${y + start}" x2="${position2(serial)}" y2="${y + end}" ${strokeAttributes(stroke)} data-chart-part="dateTick"/>`
22993
+ );
22994
+ };
22995
+ ticks.forEach((serial, index) => {
22996
+ if (index % Math.max(1, axis.tickMarkSkip ?? 1) === 0) mark(serial, axis.majorTickMark, 4);
22997
+ if (axis.deleted || model.dataTable || axis.tickLabelPosition === "none" || index % Math.max(1, axis.tickLabelSkip ?? 1))
22998
+ return;
22999
+ const label = formatDate(
23000
+ excelSerialToDate(serial, model.date1904),
23001
+ unit,
23002
+ axis.numberFormat?.formatCode
23003
+ );
23004
+ if (model.horizontal)
23005
+ out.push(text(plot.x - 4, position2(serial) + size * 0.3, label, { ...attrs2, anchor: "end" }));
23006
+ else {
23007
+ const above = axis.tickLabelPosition === "high" || axis.tickLabelPosition !== "low" && axis.position === "t";
23008
+ const baseline = axis.tickLabelPosition === "high" ? plot.y : axis.tickLabelPosition === "low" ? plot.y + plot.h : y;
23009
+ out.push(
23010
+ text(position2(serial), baseline + (above ? -4 : size + 3), label, {
23011
+ ...attrs2,
23012
+ anchor: "middle"
23013
+ })
23014
+ );
23015
+ }
23016
+ });
23017
+ if (axis.minorTickMark && axis.minorTickMark !== "none")
23018
+ for (const serial of calendarTicks(
23019
+ min,
23020
+ max,
23021
+ model.date1904 ?? false,
23022
+ unitOf(axis.minorTimeUnit ?? axis.baseTimeUnit ?? unit),
23023
+ Math.max(1, axis.minorUnit ?? 1)
23024
+ ))
23025
+ mark(serial, axis.minorTickMark, 2.5);
23026
+ return {
23027
+ order: visible.map((p) => p.index),
23028
+ band: (index) => position2(values[index] ?? min),
23029
+ bandSize: (model.horizontal ? plot.h : plot.w) / Math.max(1, max - min + 1)
23030
+ };
23031
+ }
23032
+
23033
+ // chart/line-path.ts
23034
+ function smoothLinePath(points) {
23035
+ if (points.length === 0) {
23036
+ return "";
23037
+ }
23038
+ if (points.length === 1) {
23039
+ return `M${points[0].x.toFixed(2)},${points[0].y.toFixed(2)}`;
23040
+ }
23041
+ if (points.length === 2) {
23042
+ return `M${points[0].x.toFixed(2)},${points[0].y.toFixed(2)} L${points[1].x.toFixed(2)},${points[1].y.toFixed(2)}`;
23043
+ }
23044
+ let d = `M${points[0].x.toFixed(2)},${points[0].y.toFixed(2)}`;
23045
+ for (let i = 0; i < points.length - 1; i++) {
23046
+ const [cp1, cp2, end] = smoothSegment(points, i);
23047
+ d += ` C${cp1.x.toFixed(2)},${cp1.y.toFixed(2)} ${cp2.x.toFixed(2)},${cp2.y.toFixed(2)} ${end.x.toFixed(2)},${end.y.toFixed(2)}`;
23048
+ }
23049
+ return d;
23050
+ }
23051
+ function smoothSegment(points, i) {
23052
+ const p0 = points[i - 1] ?? points[i];
23053
+ const p1 = points[i];
23054
+ const p2 = points[i + 1];
23055
+ const p3 = points[i + 2] ?? p2;
23056
+ return [
23057
+ { x: p1.x + (p2.x - p0.x) / 6, y: p1.y + (p2.y - p0.y) / 6 },
23058
+ { x: p2.x - (p3.x - p1.x) / 6, y: p2.y - (p3.y - p1.y) / 6 },
23059
+ p2
23060
+ ];
23061
+ }
23062
+
23063
+ // chart/render/chart-svg-line.ts
23064
+ function chartLineSvg(points, series) {
23065
+ if (points.length < 2) return "";
23066
+ const stroke = series.stroke;
23067
+ const attrs2 = strokeAttributes(
23068
+ stroke ? { ...stroke, color: stroke.color === "none" ? "none" : series.color } : { color: series.color, width: 2.25 }
23069
+ );
23070
+ const filter = series.shadowFilter ? ` filter="${series.shadowFilter}"` : "";
23071
+ return series.smooth ? `<path d="${smoothLinePath(points)}" fill="none" ${attrs2} stroke-linejoin="round"${filter}/>` : `<polyline points="${points.map((p) => `${n(p.x)},${n(p.y)}`).join(" ")}" fill="none" ${attrs2} stroke-linejoin="round"${filter}/>`;
23072
+ }
23073
+
23074
+ // chart/render/chart-svg-plot-layout.ts
23075
+ function chartPlotRect(model, auto, outer, frame2) {
23076
+ if (!frame2) return auto;
23077
+ const rect3 = resolveManualPlotRect(
23078
+ model.plotLayout,
23079
+ frame2,
23080
+ { x: auto.x, y: auto.y, width: auto.w, height: auto.h },
23081
+ {
23082
+ left: auto.x - outer.x,
23083
+ top: auto.y - outer.y,
23084
+ right: Math.max(0, outer.x + outer.w - auto.x - auto.w),
23085
+ bottom: Math.max(0, outer.y + outer.h - auto.y - auto.h)
23086
+ }
23087
+ );
23088
+ return rect3 ? { x: rect3.x, y: rect3.y, w: rect3.width, h: rect3.height } : auto;
22042
23089
  }
22043
23090
 
22044
23091
  // chart/render/chart-svg-markers.ts
@@ -22095,72 +23142,6 @@ function chartLineDashArray(style, width) {
22095
23142
  return `${unit * 3} ${unit * 2}`;
22096
23143
  }
22097
23144
 
22098
- // chart/render/chart-scale.ts
22099
- var clean = (n2) => Number(n2.toPrecision(12));
22100
- function* units(raw) {
22101
- let exp = Math.floor(Math.log10(raw)) - 1;
22102
- for (; ; ) {
22103
- const base = 10 ** exp;
22104
- for (const m of [1, 2, 5]) yield clean(m * base);
22105
- exp++;
22106
- }
22107
- }
22108
- function niceScale(dataMin, dataMax, options2 = {}) {
22109
- const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
22110
- let lo = Number.isFinite(dataMin) ? dataMin : 0;
22111
- let hi = Number.isFinite(dataMax) ? dataMax : 0;
22112
- if (lo > hi) [lo, hi] = [hi, lo];
22113
- if (lo === hi) {
22114
- if (lo === 0) hi = 1;
22115
- else if (options2.noZero) {
22116
- const pad = Math.abs(lo) * 0.1 || 1;
22117
- lo -= pad;
22118
- hi += pad;
22119
- } else if (lo > 0) lo = 0;
22120
- else hi = 0;
22121
- }
22122
- let fixedLo = false;
22123
- let fixedHi = false;
22124
- if (!options2.noZero) {
22125
- if (lo >= 0 && hi - lo >= hi / 6) {
22126
- lo = 0;
22127
- fixedLo = true;
22128
- } else if (hi <= 0 && hi - lo >= -lo / 6) {
22129
- hi = 0;
22130
- fixedHi = true;
22131
- }
22132
- }
22133
- const range = hi - lo;
22134
- const top = fixedHi ? hi : hi + range * 0.05;
22135
- const bottom = fixedLo ? lo : lo - range * 0.05;
22136
- for (const unit of units(range / maxIntervals)) {
22137
- const min = fixedLo ? lo : Math.floor(clean(bottom / unit)) * unit;
22138
- const max = fixedHi ? hi : Math.ceil(clean(top / unit)) * unit;
22139
- const intervals = Math.round((max - min) / unit);
22140
- if (intervals <= maxIntervals && intervals > 0) {
22141
- const ticks = [];
22142
- for (let i = 0; i <= intervals; i++) ticks.push(clean(min + i * unit));
22143
- return { min: clean(min), max: clean(max), majorUnit: unit, ticks };
22144
- }
22145
- }
22146
- return { min: lo, max: hi, majorUnit: range, ticks: [lo, hi] };
22147
- }
22148
- var PERCENT_SCALE = {
22149
- min: 0,
22150
- max: 1,
22151
- majorUnit: 0.1,
22152
- ticks: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
22153
- };
22154
- function formatAxisValue(value, percent = false) {
22155
- if (percent) return `${clean(value * 100)}%`;
22156
- const v = clean(value);
22157
- if (Math.abs(v) >= 1e15 || v !== 0 && Math.abs(v) < 1e-6)
22158
- return v.toExponential(2).replace("e+", "E+").replace("e-", "E-");
22159
- const [int = "0", frac] = String(Math.abs(v)).split(".");
22160
- const grouped = int.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
22161
- return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
22162
- }
22163
-
22164
23145
  // chart/render/chart-svg-axes.ts
22165
23146
  function axisTickText(value, axis, percent = false) {
22166
23147
  return formatChartNumber(value, axis?.source.numberFormat?.formatCode) ?? formatAxisValue(value, percent);
@@ -22387,6 +23368,50 @@ function applyChartAxes(model, chart, color) {
22387
23368
  model.axes = out;
22388
23369
  }
22389
23370
 
23371
+ // chart/render/chart-title-text.ts
23372
+ function chartRunStyle(run) {
23373
+ return {
23374
+ ...run.sizePt === void 0 ? {} : { fontSize: run.sizePt },
23375
+ ...run.bold === void 0 ? {} : { bold: run.bold },
23376
+ ...run.italic === void 0 ? {} : { italic: run.italic },
23377
+ ...run.underline === void 0 ? {} : { underline: run.underline },
23378
+ ...run.typeface === void 0 ? {} : { typeface: run.typeface },
23379
+ ...run.color === void 0 ? {} : { textColor: run.color }
23380
+ };
23381
+ }
23382
+ function chartTitleText(chart, theme) {
23383
+ const formatting2 = chart.formatting;
23384
+ const entry = formatting2?.entries.title;
23385
+ const body = entry?.textBody;
23386
+ if (!formatting2 || !body || body.text !== chart.title) return void 0;
23387
+ if (body.paragraphs.length === 1 && body.paragraphs[0].runs.length <= 1 && !body.text.includes("\n") && !body.paragraphs[0].lineSpacing && !body.paragraphs[0].spaceBefore && !body.paragraphs[0].spaceAfter)
23388
+ return void 0;
23389
+ return {
23390
+ paragraphs: body.paragraphs.map((paragraph) => ({
23391
+ ...paragraph.align ? { align: paragraph.align } : {},
23392
+ ...paragraph.lineSpacing ? { lineSpacing: paragraph.lineSpacing } : {},
23393
+ ...paragraph.spaceBefore ? { spaceBefore: paragraph.spaceBefore } : {},
23394
+ ...paragraph.spaceAfter ? { spaceAfter: paragraph.spaceAfter } : {},
23395
+ runs: paragraph.runs.map((run) => {
23396
+ const direct = {
23397
+ sourceXml: "",
23398
+ ...entry.textBodyStyle,
23399
+ ...chartRunStyle(paragraph.defaultProperties ?? {}),
23400
+ ...chartRunStyle(run)
23401
+ };
23402
+ const appearance = chartAppearance(
23403
+ {
23404
+ ...chart,
23405
+ formatting: { ...formatting2, entries: { ...formatting2.entries, title: direct } }
23406
+ },
23407
+ theme
23408
+ )?.title ?? {};
23409
+ return { text: run.text, appearance };
23410
+ })
23411
+ }))
23412
+ };
23413
+ }
23414
+
22390
23415
  // chart/render/chart-view-analysis.ts
22391
23416
  function strokeOf(line3, fallback, resolve) {
22392
23417
  if (line3?.fill?.kind === "none") return void 0;
@@ -22414,6 +23439,40 @@ function analysisView(source, seriesColor, resolve) {
22414
23439
  };
22415
23440
  }
22416
23441
 
23442
+ // chart/render/chart-view-data-table.ts
23443
+ function chartDataTableView(chart, theme, color) {
23444
+ const source = chart.dataTable;
23445
+ if (!source) return void 0;
23446
+ const props = source.txPr?.paragraphs[0];
23447
+ const direct = {
23448
+ sourceXml: "",
23449
+ ...chartRunStyle(props?.defaultProperties ?? {}),
23450
+ ...chartRunStyle(props?.runs[0] ?? {})
23451
+ };
23452
+ const formatting2 = chart.formatting;
23453
+ const appearance = chartAppearance(
23454
+ {
23455
+ ...chart,
23456
+ formatting: {
23457
+ ...formatting2,
23458
+ sourceXml: formatting2?.sourceXml ?? "",
23459
+ entries: { ...formatting2?.entries, categoryAxis: direct }
23460
+ }
23461
+ },
23462
+ theme
23463
+ );
23464
+ const fill = source.spPr?.fill;
23465
+ return {
23466
+ source,
23467
+ stroke: strokeOf(source.spPr?.line, { color: "#D9D9D9", width: 1 }, color) ?? {
23468
+ color: "none",
23469
+ width: 0
23470
+ },
23471
+ ...fill?.kind === "solid" && color(fill.color) ? { fill: color(fill.color) } : {},
23472
+ ...appearance?.categoryAxis ? { text: appearance.categoryAxis } : {}
23473
+ };
23474
+ }
23475
+
22417
23476
  // chart/render/chart-view-series.ts
22418
23477
  var isRefError = (value) => typeof value === "object" && value !== null && "error" in value;
22419
23478
  function toText(value) {
@@ -22455,7 +23514,8 @@ function seriesContext(chart, theme, options2) {
22455
23514
  function seriesView(ctx, s, index, total, categoriesOf) {
22456
23515
  const { theme, scheme: scheme2, palette, evaluateRef } = ctx;
22457
23516
  const values = resolveRef(s.valuesRef, evaluateRef)?.map(toNumber) ?? s.values.map(toNumber);
22458
- categoriesOf(resolveRef(s.categoriesRef, evaluateRef) ?? s.categories);
23517
+ const categoryValues = resolveRef(s.categoriesRef, evaluateRef) ?? s.categories;
23518
+ categoriesOf(categoryValues);
22459
23519
  const paletteColor = palette && chartPaletteSeriesColor(palette, index, total, scheme2);
22460
23520
  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);
22461
23521
  const view = {
@@ -22464,6 +23524,19 @@ function seriesView(ctx, s, index, total, categoriesOf) {
22464
23524
  color,
22465
23525
  sourceIndex: index
22466
23526
  };
23527
+ if (s.hidden !== void 0) view.hidden = s.hidden;
23528
+ if (s.boxWhisker) {
23529
+ view.boxWhisker = s.boxWhisker;
23530
+ view.boxCategories = categoryValues.map(toText);
23531
+ }
23532
+ if (s.numberFormat !== void 0) view.numberFormat = s.numberFormat;
23533
+ if (s.showLine !== void 0) view.showLine = s.showLine;
23534
+ if (s.smooth !== void 0) view.smooth = s.smooth;
23535
+ if (s.line)
23536
+ view.stroke = strokeOf(s.line, { color, width: 2.25 }, ctx.drawingColor) ?? {
23537
+ color: "none",
23538
+ width: 0
23539
+ };
22467
23540
  const shadow = resolveDrawingShadowXml(s.effectsXml, { scheme: (name) => scheme2[name] });
22468
23541
  if (shadow) view.shadow = shadow;
22469
23542
  const resolvedGradient = ctx.gradient(s.fill);
@@ -22608,52 +23681,8 @@ function categoryTotals(model) {
22608
23681
  );
22609
23682
  }
22610
23683
 
22611
- // chart/render/chart-title-text.ts
22612
- function properties(run) {
22613
- return {
22614
- ...run.sizePt === void 0 ? {} : { fontSize: run.sizePt },
22615
- ...run.bold === void 0 ? {} : { bold: run.bold },
22616
- ...run.italic === void 0 ? {} : { italic: run.italic },
22617
- ...run.underline === void 0 ? {} : { underline: run.underline },
22618
- ...run.typeface === void 0 ? {} : { typeface: run.typeface },
22619
- ...run.color === void 0 ? {} : { textColor: run.color }
22620
- };
22621
- }
22622
- function chartTitleText(chart, theme) {
22623
- const formatting2 = chart.formatting;
22624
- const entry = formatting2?.entries.title;
22625
- const body = entry?.textBody;
22626
- if (!formatting2 || !body || body.text !== chart.title) return void 0;
22627
- if (body.paragraphs.length === 1 && body.paragraphs[0].runs.length <= 1 && !body.text.includes("\n") && !body.paragraphs[0].lineSpacing && !body.paragraphs[0].spaceBefore && !body.paragraphs[0].spaceAfter)
22628
- return void 0;
22629
- return {
22630
- paragraphs: body.paragraphs.map((paragraph) => ({
22631
- ...paragraph.align ? { align: paragraph.align } : {},
22632
- ...paragraph.lineSpacing ? { lineSpacing: paragraph.lineSpacing } : {},
22633
- ...paragraph.spaceBefore ? { spaceBefore: paragraph.spaceBefore } : {},
22634
- ...paragraph.spaceAfter ? { spaceAfter: paragraph.spaceAfter } : {},
22635
- runs: paragraph.runs.map((run) => {
22636
- const direct = {
22637
- sourceXml: "",
22638
- ...entry.textBodyStyle,
22639
- ...properties(paragraph.defaultProperties ?? {}),
22640
- ...properties(run)
22641
- };
22642
- const appearance = chartAppearance(
22643
- {
22644
- ...chart,
22645
- formatting: { ...formatting2, entries: { ...formatting2.entries, title: direct } }
22646
- },
22647
- theme
22648
- )?.title ?? {};
22649
- return { text: run.text, appearance };
22650
- })
22651
- }))
22652
- };
22653
- }
22654
-
22655
23684
  // chart/render/chart-view-labels.ts
22656
- function labelsOf(source, view, categories, numberFormat) {
23685
+ function labelsOf(source, view, categories, numberFormat, resolveColor) {
22657
23686
  const { chart, series, points } = source;
22658
23687
  if ((series?.deleted ?? chart?.deleted) === true) return void 0;
22659
23688
  const percentBase = view.values.reduce(
@@ -22689,19 +23718,35 @@ function labelsOf(source, view, categories, numberFormat) {
22689
23718
  });
22690
23719
  }
22691
23720
  if (!built) return;
23721
+ const layout = point?.layout;
23722
+ const showLeaderLines = series?.showLeaderLines ?? chart?.showLeaderLines;
23723
+ const leaderLine = strokeOf(
23724
+ series?.leaderLine ?? chart?.leaderLine,
23725
+ { color: "#94a3b8", width: 0.75 },
23726
+ resolveColor
23727
+ ) ?? { color: "none", width: 0 };
22692
23728
  any = true;
22693
23729
  out[i] = {
22694
23730
  text: built.text,
23731
+ ...layout ? { layout } : {},
23732
+ ...showLeaderLines !== void 0 ? { showLeaderLines } : {},
23733
+ ...leaderLine ? { leaderLine } : {},
22695
23734
  ...position2 ? { position: position2 } : {},
22696
23735
  ...built.color ? { color: built.color } : {}
22697
23736
  };
22698
23737
  });
22699
23738
  return any ? out : void 0;
22700
23739
  }
22701
- function applyDataLabels(model, sources, extra) {
23740
+ function applyDataLabels(model, sources, extra, resolveColor) {
22702
23741
  const apply = (source, view) => {
22703
23742
  if (!source?.dataLabels) return;
22704
- const labels = labelsOf(source.dataLabels, view, model.categories, source.numberFormat);
23743
+ const labels = labelsOf(
23744
+ source.dataLabels,
23745
+ view,
23746
+ model.categories,
23747
+ source.numberFormat,
23748
+ resolveColor
23749
+ );
22705
23750
  if (labels) view.labels = labels;
22706
23751
  };
22707
23752
  model.series.forEach((view, i) => apply(sources[i], view));
@@ -22806,7 +23851,9 @@ var SUPPORTED = /* @__PURE__ */ new Set([
22806
23851
  "bubble",
22807
23852
  "stock",
22808
23853
  "treemap",
22809
- "sunburst"
23854
+ "sunburst",
23855
+ "funnel",
23856
+ "boxWhisker"
22810
23857
  ]);
22811
23858
  function chartSummaryView(chart, theme, options2 = {}) {
22812
23859
  const type = chart.chartType;
@@ -22864,10 +23911,17 @@ function chartSummaryView(chart, theme, options2 = {}) {
22864
23911
  showLegend: chart.showLegend,
22865
23912
  legendPosition: chart.legendPosition ?? "r",
22866
23913
  categories,
22867
- series,
23914
+ series: type === "boxWhisker" ? series.filter((s) => !s.hidden) : series,
22868
23915
  horizontal: type === "bar",
22869
23916
  supported: SUPPORTED.has(type)
22870
23917
  };
23918
+ const table = chartDataTableView(chart, theme, ctx.drawingColor);
23919
+ if (table) model.dataTable = table;
23920
+ if (chart.date1904 !== void 0) model.date1904 = chart.date1904;
23921
+ if (chart.axes?.some((a) => a.kind === "date")) model.dateCategories = firstCats.map(toNumber);
23922
+ if (chart.plotLayout) model.plotLayout = chart.plotLayout;
23923
+ if (type === "boxWhisker")
23924
+ model.categories = [...new Set(model.series.flatMap((s) => s.boxCategories ?? []))];
22871
23925
  if (chart.title) model.title = chart.title;
22872
23926
  const titleFormatting = chart.formatting?.entries.title;
22873
23927
  if (titleFormatting?.layout) model.titleLayout = titleFormatting.layout;
@@ -22889,6 +23943,11 @@ function chartSummaryView(chart, theme, options2 = {}) {
22889
23943
  const range = extentOf(xs);
22890
23944
  model.xAxis = xs.length ? niceScale(range.min, range.max) : niceScale(0, 1);
22891
23945
  }
23946
+ if (type === "funnel" || type === "boxWhisker")
23947
+ series.forEach((s, i) => {
23948
+ const points = chart.series[i]?.pointColors;
23949
+ if (points) s.pointColors = s.values.map((_, j) => drawingColor(points[j]) ?? s.color);
23950
+ });
22892
23951
  if (type === "stock") model.stock = stockView(chart.stock, ctx);
22893
23952
  if (type === "bubble") bubbleView(chart, model, ctx.evaluateRef);
22894
23953
  if (type === "treemap" || type === "sunburst") hierarchyView(chart, model, ctx.evaluateRef);
@@ -22897,23 +23956,31 @@ function chartSummaryView(chart, theme, options2 = {}) {
22897
23956
  chartExtraView(chart, model, ctx, total, collect);
22898
23957
  if (type === "waterfall") waterfallView(chart, model, ctx);
22899
23958
  else if (!byPoint) model.valueAxis = valueAxis(model);
22900
- applyDataLabels(model, chart.series, extra);
23959
+ applyDataLabels(model, chart.series, extra, ctx.drawingColor);
22901
23960
  chartExtraAxes(model);
22902
23961
  applyChartAxes(model, chart, ctx.drawingColor);
22903
23962
  return model;
22904
23963
  }
22905
23964
 
22906
23965
  // chart/render/chart-svg-cartesian.ts
22907
- function cartesianAxes(model, area, out) {
23966
+ function cartesianAxes(model, area, out, size) {
22908
23967
  const scale = model.valueAxis;
22909
23968
  if (!scale) return void 0;
23969
+ const table = chartTableMetrics(model);
23970
+ if (table)
23971
+ area = {
23972
+ ...area,
23973
+ x: Math.max(area.x, table.keyW + 8),
23974
+ w: Math.max(1, area.w - Math.max(0, table.keyW + 8 - area.x)),
23975
+ h: Math.max(1, area.h - table.height)
23976
+ };
22910
23977
  const labels = scale.ticks.map((t) => axisTickText(t, model.axes?.value, scale.percent));
22911
23978
  const valueAttrs = chartTextAttributes(model, "valueAxis");
22912
23979
  const categoryAttrs = chartTextAttributes(model, "categoryAxis");
22913
23980
  const valueSize = valueAttrs.size ?? 10;
22914
23981
  const categorySize = categoryAttrs.size ?? 10;
22915
23982
  const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
22916
- const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
23983
+ const categoryLabels = !table && chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
22917
23984
  const labelW = valueLabels ? Math.max(...labels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
22918
23985
  const horizontal = model.horizontal;
22919
23986
  const cats = Math.max(1, model.categories.length);
@@ -22924,7 +23991,7 @@ function cartesianAxes(model, area, out) {
22924
23991
  const second = horizontal ? void 0 : model.secondaryAxis;
22925
23992
  const secondLabels = second?.ticks.map((t) => axisTickText(t, model.axes?.secondary, second.percent)) ?? [];
22926
23993
  const secondW = second ? valueLabels ? Math.max(...secondLabels.map((l) => textWidth(l, valueSize)), 8) + 8 : 4 : 0;
22927
- const plot = horizontal ? {
23994
+ const auto = horizontal ? {
22928
23995
  x: area.x + catW,
22929
23996
  y: area.y,
22930
23997
  w: Math.max(1, area.w - catW - 4),
@@ -22935,10 +24002,13 @@ function cartesianAxes(model, area, out) {
22935
24002
  w: Math.max(1, area.w - labelW - 4 - secondW),
22936
24003
  h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
22937
24004
  };
24005
+ const plot = chartPlotRect(model, auto, area, size);
22938
24006
  const value = horizontal ? (v) => plot.x + chartAxisRatio(v, scale, model.axes?.value) * plot.w : (v) => plot.y + plot.h - chartAxisRatio(v, scale, model.axes?.value) * plot.h;
22939
- const bandSize = (horizontal ? plot.h : plot.w) / cats;
24007
+ const dateMarkup = [];
24008
+ const dates = chartDateAxis(model, plot, dateMarkup);
24009
+ const bandSize = dates?.bandSize ?? (horizontal ? plot.h : plot.w) / cats;
22940
24010
  const index = (i) => model.axes?.category?.range.reverseOrder ? cats - 1 - i : i;
22941
- const band = horizontal ? (i) => plot.y + plot.h - bandSize * (index(i) + 0.5) : (i) => plot.x + bandSize * (index(i) + 0.5);
24011
+ const band = dates?.band ?? (horizontal ? (i) => plot.y + plot.h - bandSize * (index(i) + 0.5) : (i) => plot.x + bandSize * (index(i) + 0.5));
22942
24012
  out.push(chartAreaRect(model, "plotArea", plot));
22943
24013
  out.push(axisGridlines(model, model.axes?.value, scale.ticks, value, plot, horizontal));
22944
24014
  if (model.axes?.category?.source.majorGridlines || model.axes?.category?.source.minorGridlines)
@@ -22976,12 +24046,13 @@ function cartesianAxes(model, area, out) {
22976
24046
  out.push(
22977
24047
  axisLine(model, model.axes?.category, "categoryAxis", plot.x, zero, plot.x + plot.w, zero)
22978
24048
  );
24049
+ out.push(...dateMarkup);
22979
24050
  const step = Math.max(
22980
24051
  1,
22981
24052
  Math.ceil(cats / Math.max(1, Math.floor((horizontal ? plot.h : plot.w) / 14)))
22982
24053
  );
22983
24054
  model.categories.forEach((c, i) => {
22984
- if (!categoryLabels || i % step !== 0) return;
24055
+ if (dates || !categoryLabels || i % step !== 0) return;
22985
24056
  const p = band(i);
22986
24057
  if (horizontal)
22987
24058
  out.push(
@@ -22998,7 +24069,7 @@ function cartesianAxes(model, area, out) {
22998
24069
  })
22999
24070
  );
23000
24071
  });
23001
- const frame2 = { plot, value, band, bandSize };
24072
+ const frame2 = { plot, value, band, bandSize, ...dates ? { order: dates.order } : {} };
23002
24073
  if (second) {
23003
24074
  frame2.secondary = (v) => plot.y + plot.h - chartAxisRatio(v, second, model.axes?.secondary) * plot.h;
23004
24075
  out.push(
@@ -23045,7 +24116,7 @@ function linesAndAreas(model, frame2, out) {
23045
24116
  model.series.forEach((s, si) => {
23046
24117
  const points = [];
23047
24118
  const lower = [];
23048
- model.categories.forEach((_, i) => {
24119
+ (frame2.order ?? model.categories.map((_, i) => i)).forEach((i) => {
23049
24120
  const v = values[si]?.[i] ?? null;
23050
24121
  if (v === null && !area) {
23051
24122
  points.push([NaN, NaN]);
@@ -23080,26 +24151,24 @@ function linesAndAreas(model, frame2, out) {
23080
24151
  }
23081
24152
  let segment2 = [];
23082
24153
  const flush = () => {
23083
- if (segment2.length > 1)
23084
- out.push(
23085
- `<polyline points="${segment2.join(" ")}" fill="none" stroke="${color}" stroke-width="2.25" stroke-linejoin="round"${filter}/>`
23086
- );
24154
+ out.push(chartLineSvg(segment2, series));
23087
24155
  segment2 = [];
23088
24156
  };
23089
24157
  for (const [x, y] of points) {
23090
24158
  if (Number.isNaN(x)) flush();
23091
- else segment2.push(`${n(x)},${n(y)}`);
24159
+ else segment2.push({ x, y });
23092
24160
  }
23093
24161
  flush();
23094
24162
  points.forEach(([x, y], index) => {
23095
- if (!Number.isNaN(x)) out.push(chartSeriesMarkerSvg(series, index, x, y, 2.5));
24163
+ if (!Number.isNaN(x))
24164
+ out.push(chartSeriesMarkerSvg(series, frame2.order?.[index] ?? index, x, y, 2.5));
23096
24165
  });
23097
24166
  }
23098
24167
  pointLabels(model, marks, out);
23099
24168
  }
23100
24169
 
23101
24170
  // chart/render/chart-svg-xy.ts
23102
- function scatter(model, area, out) {
24171
+ function scatter(model, area, out, size) {
23103
24172
  const ys = model.valueAxis;
23104
24173
  const xs = model.xAxis;
23105
24174
  if (!ys || !xs) return;
@@ -23112,18 +24181,19 @@ function scatter(model, area, out) {
23112
24181
  const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
23113
24182
  const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
23114
24183
  const labelW = valueLabels ? Math.max(...yLabels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
23115
- const plot = {
24184
+ const auto = {
23116
24185
  x: area.x + labelW,
23117
24186
  y: area.y + 4,
23118
24187
  w: Math.max(1, area.w - labelW - 8),
23119
24188
  h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
23120
24189
  };
24190
+ const plot = chartPlotRect(model, auto, area, size);
23121
24191
  const bubble = model.type === "bubble" ? model.bubble : void 0;
23122
24192
  const biggest = maxBubbleSize(
23123
24193
  model.series.flatMap((s) => (s.sizes ?? []).filter((v) => v !== null))
23124
24194
  );
23125
24195
  const median = medianBubbleRadius(plot.w, plot.h);
23126
- const radiusOf = (size) => bubble && !(size !== void 0 && size < 0 && !bubble.showNegativeBubbles) ? computeBubbleRadius(size, biggest, median, bubble) : void 0;
24196
+ const radiusOf = (size2) => bubble && !(size2 !== void 0 && size2 < 0 && !bubble.showNegativeBubbles) ? computeBubbleRadius(size2, biggest, median, bubble) : void 0;
23127
24197
  let reach = 0;
23128
24198
  if (bubble)
23129
24199
  for (const s of model.series)
@@ -23132,11 +24202,11 @@ function scatter(model, area, out) {
23132
24202
  });
23133
24203
  const widen = (s, length, axis) => {
23134
24204
  if (axis?.range.logScale) return s;
23135
- const pad = reach * (s.max - s.min || 1) / Math.max(1, length - 2 * reach);
24205
+ const pad2 = reach * (s.max - s.min || 1) / Math.max(1, length - 2 * reach);
23136
24206
  return {
23137
24207
  ...s,
23138
- min: axis?.source.scaling.min === void 0 ? s.min - pad : s.min,
23139
- max: axis?.source.scaling.max === void 0 ? s.max + pad : s.max
24208
+ min: axis?.source.scaling.min === void 0 ? s.min - pad2 : s.min,
24209
+ max: axis?.source.scaling.max === void 0 ? s.max + pad2 : s.max
23140
24210
  };
23141
24211
  };
23142
24212
  const xView = widen(xs, plot.w, model.axes?.category);
@@ -23181,6 +24251,21 @@ function scatter(model, area, out) {
23181
24251
  out.push(
23182
24252
  axisLine(model, model.axes?.value, "valueAxis", plot.x, plot.y, plot.x, plot.y + plot.h)
23183
24253
  );
24254
+ if (!bubble)
24255
+ for (const series of model.series) {
24256
+ if (!series.showLine) continue;
24257
+ let run = [];
24258
+ const flush = () => {
24259
+ out.push(chartLineSvg(run, series));
24260
+ run = [];
24261
+ };
24262
+ series.values.forEach((value, i) => {
24263
+ const x = series.xValues?.[i];
24264
+ if (value === null || x === null || x === void 0) flush();
24265
+ else run.push({ x: px(x), y: py(value) });
24266
+ });
24267
+ flush();
24268
+ }
23184
24269
  const marks = [];
23185
24270
  for (const [si, s] of model.series.entries())
23186
24271
  s.values.forEach((v, i) => {
@@ -23312,14 +24397,19 @@ function clusterLayers(layers) {
23312
24397
  }
23313
24398
  return out;
23314
24399
  }
23315
- function cartesianSvg(model, area) {
24400
+ function cartesianSvg(model, area, size) {
23316
24401
  const out = [];
23317
24402
  if (model.type === "scatter" || model.type === "bubble") {
23318
- scatter(model, area, out);
24403
+ scatter(model, area, out, size);
23319
24404
  return out.join("");
23320
24405
  }
23321
- const frame2 = cartesianAxes(model, area, out);
24406
+ const frame2 = cartesianAxes(model, area, out, size);
23322
24407
  if (!frame2) return "";
24408
+ out.push(chartDataTableSvg(model, frame2.plot));
24409
+ if (model.type === "boxWhisker") {
24410
+ boxWhiskerSvg(model, frame2, out);
24411
+ return out.join("");
24412
+ }
23323
24413
  if (model.type === "waterfall") {
23324
24414
  waterfallBars(model, frame2, out);
23325
24415
  return out.join("");
@@ -23352,6 +24442,83 @@ function cartesianSvg(model, area) {
23352
24442
  return out.join("");
23353
24443
  }
23354
24444
 
24445
+ // chart/render/chart-svg-slice-labels.ts
24446
+ var GAP2 = 3;
24447
+ function sliceLabels(model, marks, out) {
24448
+ const items = [];
24449
+ for (const mark of marks) {
24450
+ const label = mark.series.labels?.[mark.index];
24451
+ if (!label) continue;
24452
+ const m = measure3(model, label);
24453
+ const mid = (mark.start + mark.end) / 2;
24454
+ const ux = Math.sin(mid);
24455
+ const uy = -Math.cos(mid);
24456
+ const place2 = (radius) => [
24457
+ mark.cx + radius * ux,
24458
+ mark.cy + radius * uy
24459
+ ];
24460
+ const position2 = label.position ?? (model.type === "doughnut" ? "ctr" : "bestFit");
24461
+ let x;
24462
+ let y;
24463
+ if (position2 === "ctr") [x, y] = place2(mark.inner + (mark.outer - mark.inner) / 2);
24464
+ else if (position2 === "inEnd") {
24465
+ const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
24466
+ [x, y] = place2(Math.max(0, mark.outer - GAP2 - extent));
24467
+ } else if (position2 === "outEnd") {
24468
+ const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
24469
+ [x, y] = place2(mark.outer + GAP2 + extent);
24470
+ } else {
24471
+ const placed = placeBestFitLabel(
24472
+ {
24473
+ cx: mark.cx,
24474
+ cy: mark.cy,
24475
+ outerR: mark.outer,
24476
+ startAngle: mark.start - Math.PI / 2,
24477
+ endAngle: mark.end - Math.PI / 2
24478
+ },
24479
+ m.w,
24480
+ m.h
24481
+ );
24482
+ x = placed.x;
24483
+ y = placed.y;
24484
+ }
24485
+ items.push({
24486
+ mark,
24487
+ label,
24488
+ m,
24489
+ x,
24490
+ y,
24491
+ outside: Math.hypot(x - mark.cx, y - mark.cy) > mark.outer
24492
+ });
24493
+ }
24494
+ const first3 = marks[0];
24495
+ if (!first3) return;
24496
+ const nudges = nudgeOutsideLabels(
24497
+ items.flatMap(
24498
+ (item2, id) => item2.outside && !item2.label.layout ? [{ id, x: item2.x, y: item2.y, w: item2.m.w, h: item2.m.h }] : []
24499
+ ),
24500
+ { cx: first3.cx, cy: first3.cy, r: first3.outer },
24501
+ first3.cy - first3.outer,
24502
+ first3.cy + first3.outer
24503
+ );
24504
+ for (const [id, item2] of items.entries()) {
24505
+ const { mark, label, m } = item2;
24506
+ const nudge = nudges.find((n2) => n2.id === id);
24507
+ let point = { x: item2.x + (nudge?.dx ?? 0), y: item2.y + (nudge?.dy ?? 0) };
24508
+ if (model.frameSize) point = applyLabelManualLayout(label.layout, model.frameSize, point);
24509
+ const moved = point.x !== item2.x || point.y !== item2.y;
24510
+ if (label.showLeaderLines !== false && (item2.outside || moved)) {
24511
+ const mid = (mark.start + mark.end) / 2;
24512
+ const stroke = label.leaderLine ?? { color: "#94a3b8", width: 0.75 };
24513
+ out.push(
24514
+ `<line x1="${n(mark.cx + mark.outer * Math.sin(mid))}" y1="${n(mark.cy - mark.outer * Math.cos(mid))}" x2="${n(point.x)}" y2="${n(point.y)}" ${strokeAttributes(stroke)} data-chart-part="leaderLine"/>`
24515
+ );
24516
+ }
24517
+ const { layout: _layout, ...fixed } = label;
24518
+ draw(m, fixed, point.x, point.y, "middle", out);
24519
+ }
24520
+ }
24521
+
23355
24522
  // chart/render/chart-svg-radial.ts
23356
24523
  var polar = (cx, cy, r, angle) => [
23357
24524
  cx + r * Math.sin(angle),
@@ -23834,9 +25001,9 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
23834
25001
  ),
23835
25002
  { breakWords: true }
23836
25003
  );
23837
- const { spaceBefore, spaceAfter, ...properties4 } = line3;
25004
+ const { spaceBefore, spaceAfter, ...properties3 } = line3;
23838
25005
  return wrapped.map((runs, index) => ({
23839
- ...properties4,
25006
+ ...properties3,
23840
25007
  runs,
23841
25008
  ...index === 0 && spaceBefore ? { spaceBefore } : {},
23842
25009
  ...index === wrapped.length - 1 && spaceAfter ? { spaceAfter } : {}
@@ -23923,7 +25090,7 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
23923
25090
  // chart/render/chart-svg.ts
23924
25091
  function renderChartSvg(model, width, height, options2 = {}) {
23925
25092
  const paint2 = chartGradientPaint(model, Math.max(1, width), Math.max(1, height));
23926
- model = paint2.model;
25093
+ model = { ...paint2.model, frameSize: { width: Math.max(1, width), height: Math.max(1, height) } };
23927
25094
  const w = Math.max(1, width);
23928
25095
  const h = Math.max(1, height);
23929
25096
  const out = [];
@@ -23979,10 +25146,11 @@ function renderChartSvg(model, width, height, options2 = {}) {
23979
25146
  if (!legend.foreground) out.push(legend.markup);
23980
25147
  if (area.w > 4 && area.h > 4) {
23981
25148
  if (model.type === "pie" || model.type === "doughnut") out.push(pieSvg(model, area));
25149
+ else if (model.type === "funnel") out.push(funnelSvg(model, area));
23982
25150
  else if (model.type === "radar") out.push(radarSvg(model, area));
23983
25151
  else if (model.type === "treemap") out.push(treemapSvg(model, area));
23984
25152
  else if (model.type === "sunburst") out.push(sunburstSvg(model, area));
23985
- else out.push(cartesianSvg(model, area));
25153
+ else out.push(cartesianSvg(model, area, { width: w, height: h }));
23986
25154
  }
23987
25155
  if (legend.foreground) out.push(legend.markup);
23988
25156
  if (foregroundTitle) out.push(foregroundTitle);
@@ -24005,7 +25173,9 @@ var DRAWN_CHART_TYPES = /* @__PURE__ */ new Set([
24005
25173
  "bubble",
24006
25174
  "stock",
24007
25175
  "treemap",
24008
- "sunburst"
25176
+ "sunburst",
25177
+ "funnel",
25178
+ "boxWhisker"
24009
25179
  ]);
24010
25180
  function chartThemePalette(theme, fonts = {}) {
24011
25181
  return {
@@ -24192,7 +25362,7 @@ function geometry(doc, spec) {
24192
25362
  const avLst = el2(doc, A_NS2, "a:avLst");
24193
25363
  for (const [name, value] of Object.entries(spec.adjustments ?? {}))
24194
25364
  add2(avLst, attrs(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
24195
- const nodes = [add2(prst, avLst)];
25365
+ const nodes = spec.customGeometryXml ? importFragment(doc, spec.customGeometryXml) : [add2(prst, avLst)];
24196
25366
  if (spec.fill) {
24197
25367
  const xml = drawingFillXml(spec.fill);
24198
25368
  if (xml) nodes.push(...importFragment(doc, xml));
@@ -24724,10 +25894,10 @@ function hasUnexpectedAttributes(element3, allowed, allowDateUtc = false) {
24724
25894
  }
24725
25895
  return false;
24726
25896
  }
24727
- function runPropertiesHaveUnknownContent(properties4) {
24728
- if (!properties4) return false;
24729
- if (hasUnexpectedAttributes(properties4, [])) return true;
24730
- for (const node of Array.from(properties4.childNodes)) {
25897
+ function runPropertiesHaveUnknownContent(properties3) {
25898
+ if (!properties3) return false;
25899
+ if (hasUnexpectedAttributes(properties3, [])) return true;
25900
+ for (const node of Array.from(properties3.childNodes)) {
24731
25901
  if (node.nodeType !== 1) {
24732
25902
  if (node.nodeType === 3 && node.textContent?.trim()) return true;
24733
25903
  continue;
@@ -25185,7 +26355,7 @@ function parseRunStyleCatalog(xml) {
25185
26355
  }
25186
26356
 
25187
26357
  // docx/table-borders.ts
25188
- var SIDES2 = [
26358
+ var SIDES3 = [
25189
26359
  "top",
25190
26360
  "bottom",
25191
26361
  "left",
@@ -25211,7 +26381,7 @@ function parseTableBorders(bordersElement) {
25211
26381
  if (!bordersElement) return void 0;
25212
26382
  const result = {};
25213
26383
  const alias = { left: "start", right: "end" };
25214
- for (const side of SIDES2) {
26384
+ for (const side of SIDES3) {
25215
26385
  const aliasName = alias[side];
25216
26386
  const value = borderSide(
25217
26387
  first2(bordersElement, side) ?? (aliasName ? first2(bordersElement, aliasName) : void 0)
@@ -26435,12 +27605,12 @@ function contentLength(child3) {
26435
27605
  }
26436
27606
  function splitRun(run, offset) {
26437
27607
  const children3 = Array.from(run.childNodes).filter(isElement);
26438
- const properties4 = children3.find((child3) => named2(child3, "rPr"));
27608
+ const properties3 = children3.find((child3) => named2(child3, "rPr"));
26439
27609
  const second = run.cloneNode(false);
26440
- if (properties4) second.appendChild(properties4.cloneNode(true));
27610
+ if (properties3) second.appendChild(properties3.cloneNode(true));
26441
27611
  let seen = 0;
26442
27612
  for (const child3 of children3) {
26443
- if (child3 === properties4) continue;
27613
+ if (child3 === properties3) continue;
26444
27614
  const length = contentLength(child3);
26445
27615
  if (seen >= offset) second.appendChild(child3);
26446
27616
  else if (seen + length > offset) {
@@ -26456,7 +27626,7 @@ function splitRun(run, offset) {
26456
27626
  }
26457
27627
  seen += length;
26458
27628
  }
26459
- if (second.childNodes.length === (properties4 ? 1 : 0)) return void 0;
27629
+ if (second.childNodes.length === (properties3 ? 1 : 0)) return void 0;
26460
27630
  run.parentNode.insertBefore(second, run.nextSibling);
26461
27631
  return second;
26462
27632
  }
@@ -26635,7 +27805,7 @@ function restoreAnnotations(markers, before, after) {
26635
27805
  }
26636
27806
 
26637
27807
  // docx/write-paragraph-decoration.ts
26638
- var SIDES3 = ["top", "left", "bottom", "right", "between"];
27808
+ var SIDES4 = ["top", "left", "bottom", "right", "between"];
26639
27809
  function wordColor(color) {
26640
27810
  const hex = /^#?([0-9a-f]{6})$/i.exec(color ?? "")?.[1];
26641
27811
  return hex ? hex.toUpperCase() : "auto";
@@ -26669,7 +27839,7 @@ function updateBorders(doc, props, paragraph, base) {
26669
27839
  const borders = paragraph.borders;
26670
27840
  if (!borders) return;
26671
27841
  const pBdr = makeW(doc, "pBdr");
26672
- for (const side of SIDES3) {
27842
+ for (const side of SIDES4) {
26673
27843
  const value = borders[side];
26674
27844
  if (value) pBdr.appendChild(borderElement(doc, side, value));
26675
27845
  }
@@ -27534,9 +28704,9 @@ function resolveNumberingLevel(catalog, numId, level3) {
27534
28704
  let base = override?.lvl ?? abstract;
27535
28705
  if (!base) return void 0;
27536
28706
  if (override?.lvl) {
27537
- const { lvlRestart: _ignored, ...properties4 } = base;
28707
+ const { lvlRestart: _ignored, ...properties3 } = base;
27538
28708
  base = {
27539
- ...properties4,
28709
+ ...properties3,
27540
28710
  ...abstract?.lvlRestart !== void 0 ? { lvlRestart: abstract.lvlRestart } : {}
27541
28711
  };
27542
28712
  }
@@ -27681,20 +28851,20 @@ function restoreParagraphFormatting(paragraph) {
27681
28851
  throw new Error(
27682
28852
  "Cannot reject a paragraph formatting revision without its prior properties snapshot."
27683
28853
  );
27684
- const properties4 = parsePropertiesSnapshot(xml, "pPr");
28854
+ const properties3 = parsePropertiesSnapshot(xml, "pPr");
27685
28855
  if (paragraph.sourceParagraphPropertiesXml) {
27686
28856
  const current = parsePropertiesSnapshot(paragraph.sourceParagraphPropertiesXml, "pPr");
27687
28857
  for (const name of ["rPr", "sectPr"]) {
27688
28858
  const element3 = first2(current, name);
27689
- if (element3 && !first2(properties4, name))
27690
- properties4.appendChild(properties4.ownerDocument.importNode(element3, true));
28859
+ if (element3 && !first2(properties3, name))
28860
+ properties3.appendChild(properties3.ownerDocument.importNode(element3, true));
27691
28861
  }
27692
- orderParagraphProperties(properties4);
28862
+ orderParagraphProperties(properties3);
27693
28863
  }
27694
- const previous = parseDirectParagraphProperties(properties4);
28864
+ const previous = parseDirectParagraphProperties(properties3);
27695
28865
  for (const key of PARAGRAPH_FORMAT_KEYS) delete paragraph[key];
27696
28866
  Object.assign(paragraph, previous);
27697
- paragraph.restoredParagraphPropertiesXml = buildXml(properties4);
28867
+ paragraph.restoredParagraphPropertiesXml = buildXml(properties3);
27698
28868
  if (paragraph.sourceParagraphPropertiesXml)
27699
28869
  paragraph.sourceParagraphPropertiesXml = paragraph.restoredParagraphPropertiesXml;
27700
28870
  delete paragraph.formatRevision;
@@ -28370,8 +29540,8 @@ function applyInlineFormat(run, child3) {
28370
29540
  Object.assign(run, inlineRunProperties(child3));
28371
29541
  const marks = { text: "", ...run.revision ? { revision: run.revision } : {} };
28372
29542
  applyMarkFormatting(marks, child3);
28373
- const { text: _text, ...properties4 } = marks;
28374
- Object.assign(run, properties4);
29543
+ const { text: _text, ...properties3 } = marks;
29544
+ Object.assign(run, properties3);
28375
29545
  const ids = commentIdsFromNode(child3);
28376
29546
  if (ids.length) run.commentIds = ids;
28377
29547
  else delete run.commentIds;
@@ -28530,14 +29700,14 @@ function resolveFormattingRange(tr, from, to, mode) {
28530
29700
  setInlineRunFormatting(tr, piece.from, run2);
28531
29701
  continue;
28532
29702
  }
28533
- const properties4 = piece.node.marks.find((mark) => mark.type.name === "runProperties");
29703
+ const properties3 = piece.node.marks.find((mark) => mark.type.name === "runProperties");
28534
29704
  if (mode === "accept") {
28535
- const props = { ...properties4.attrs.props };
29705
+ const props = { ...properties3.attrs.props };
28536
29706
  if (props.formatRevision) delete props.formatRevision;
28537
29707
  else delete props.revision;
28538
- tr.removeMark(piece.from, piece.to, properties4);
29708
+ tr.removeMark(piece.from, piece.to, properties3);
28539
29709
  if (Object.keys(props).length)
28540
- tr.addMark(piece.from, piece.to, properties4.type.create({ props }));
29710
+ tr.addMark(piece.from, piece.to, properties3.type.create({ props }));
28541
29711
  continue;
28542
29712
  }
28543
29713
  const run = { text: "", revision: piece.revision };
@@ -28549,7 +29719,7 @@ function resolveFormattingRange(tr, from, to, mode) {
28549
29719
  }
28550
29720
 
28551
29721
  // docx/ui/track-run-formatting.ts
28552
- function properties2(node) {
29722
+ function properties(node) {
28553
29723
  const run = inlineNodeRun(node) ?? { text: "" };
28554
29724
  run.text = "";
28555
29725
  delete run.image;
@@ -28585,8 +29755,8 @@ function trackRunFormatting(steps, oldState, newState, author, date, nextId) {
28585
29755
  if (!previous.isInline || previous.type.name === "equation") return;
28586
29756
  const start = Math.max(from, previousPos);
28587
29757
  const end = Math.min(to, previousPos + previous.nodeSize);
28588
- const before = properties2(previous);
28589
- const after = properties2(node);
29758
+ const before = properties(previous);
29759
+ const after = properties(node);
28590
29760
  if (propertiesSignature(before) === propertiesSignature(after)) {
28591
29761
  if (hasInlineRunAttributes(node) && node.marks.some((mark2) => RUN_FORMAT_MARKS.has(mark2.type.name)))
28592
29762
  setInlineRunFormatting(tr, start, inlineNodeRun(node));
@@ -28749,7 +29919,7 @@ function paragraphProperties(element3) {
28749
29919
  for (const child3 of children2(element3, name)) element3.removeChild(child3);
28750
29920
  return element3;
28751
29921
  }
28752
- function properties3(node) {
29922
+ function properties2(node) {
28753
29923
  const paragraph = paragraphFromAttrs(node.attrs, String(node.attrs.id), []);
28754
29924
  delete paragraph.formatRevision;
28755
29925
  delete paragraph.markRevision;
@@ -28767,8 +29937,8 @@ function trackParagraphFormatting(steps, oldState, newState, author, date, nextI
28767
29937
  if (node.type.name !== "paragraph" || !node.type.spec.attrs?.formatRevision) return;
28768
29938
  const previous = oldState.doc.nodeAt(pos);
28769
29939
  if (previous === node) return;
28770
- const before = properties3(previous);
28771
- const after = properties3(node);
29940
+ const before = properties2(previous);
29941
+ const after = properties2(node);
28772
29942
  if (propertiesSignature(before) === propertiesSignature(after)) return;
28773
29943
  const pending = paragraphFormattingRevision(previous);
28774
29944
  const priorXml = pending?.previousParagraphPropertiesXml ?? buildXml(before);
@@ -28890,9 +30060,9 @@ function fieldClipboardSlice(slice) {
28890
30060
  });
28891
30061
  return node.copy(Fragment.fromArray(children4));
28892
30062
  }
28893
- const properties4 = !node.isText && node.type.spec.attrs?.format ? inlineRunProperties(node) : void 0;
30063
+ const properties3 = !node.isText && node.type.spec.attrs?.format ? inlineRunProperties(node) : void 0;
28894
30064
  const field = node.marks.find((mark) => mark.type.name === "field");
28895
- const cached2 = properties4?.field;
30065
+ const cached2 = properties3?.field;
28896
30066
  if (!field && !cached2) return node;
28897
30067
  if (!(field?.attrs.simple ?? cached2?.simple) && complete.has(pos)) return node;
28898
30068
  const marks = node.marks.flatMap((mark) => {
@@ -28901,8 +30071,8 @@ function fieldClipboardSlice(slice) {
28901
30071
  const { fieldInstanceId: _identity, fieldFlags: _flags2, ...props } = mark.attrs.props ?? {};
28902
30072
  return Object.keys(props).length ? [mark.type.create({ ...mark.attrs, props })] : [];
28903
30073
  });
28904
- if (!properties4 || !cached2) return node.mark(marks);
28905
- const { field: _field, fieldInstanceId: _id, fieldFlags: _flags, ...literal2 } = properties4;
30074
+ if (!properties3 || !cached2) return node.mark(marks);
30075
+ const { field: _field, fieldInstanceId: _id, fieldFlags: _flags, ...literal2 } = properties3;
28906
30076
  return node.type.create(
28907
30077
  updatedInlineRunAttributes(
28908
30078
  node,
@@ -28965,14 +30135,14 @@ function trackSimpleFieldDeletion(transform, from, to, slice, author, date, next
28965
30135
  function sourceProperties(value) {
28966
30136
  if (typeof value !== "string" || !value) return value;
28967
30137
  try {
28968
- const properties4 = parsePropertiesSnapshot(value, "pPr");
28969
- const run = first2(properties4, "rPr");
30138
+ const properties3 = parsePropertiesSnapshot(value, "pPr");
30139
+ const run = first2(properties3, "rPr");
28970
30140
  if (run) {
28971
30141
  for (const name of ["ins", "del"])
28972
30142
  for (const revision of children2(run, name)) run.removeChild(revision);
28973
- if (!run.childNodes.length && !run.attributes.length) properties4.removeChild(run);
30143
+ if (!run.childNodes.length && !run.attributes.length) properties3.removeChild(run);
28974
30144
  }
28975
- return propertiesSignature(properties4);
30145
+ return propertiesSignature(properties3);
28976
30146
  } catch {
28977
30147
  return value;
28978
30148
  }
@@ -29068,14 +30238,14 @@ function resultMarks(node, field) {
29068
30238
  ...typeof id === "string" && { fieldInstanceId: id },
29069
30239
  ...source?.fieldFlags && { fieldFlags: source.fieldFlags }
29070
30240
  };
29071
- const properties4 = node.type.schema.marks.runProperties;
29072
- if (properties4) {
29073
- const old = properties4.isInSet(marks);
30241
+ const properties3 = node.type.schema.marks.runProperties;
30242
+ if (properties3) {
30243
+ const old = properties3.isInSet(marks);
29074
30244
  const { fieldInstanceId: _identity, fieldFlags: _flags, ...other } = old?.attrs.props ?? {};
29075
30245
  const props = { ...other, ...state };
29076
- marks = properties4.removeFromSet(marks);
30246
+ marks = properties3.removeFromSet(marks);
29077
30247
  if (Object.keys(props).length)
29078
- marks = properties4.create({ ...old?.attrs ?? {}, props }).addToSet(marks);
30248
+ marks = properties3.create({ ...old?.attrs ?? {}, props }).addToSet(marks);
29079
30249
  }
29080
30250
  return marks;
29081
30251
  }
@@ -29551,8 +30721,8 @@ function removeControl(tr, span) {
29551
30721
  const { id } = span.control;
29552
30722
  if (span.level === "row") {
29553
30723
  const row = tr.doc.nodeAt(span.from);
29554
- const { contentControl: _control, ...properties4 } = row?.attrs.properties ?? {};
29555
- if (row) tr.setNodeMarkup(span.from, void 0, { ...row.attrs, properties: properties4 });
30724
+ const { contentControl: _control, ...properties3 } = row?.attrs.properties ?? {};
30725
+ if (row) tr.setNodeMarkup(span.from, void 0, { ...row.attrs, properties: properties3 });
29556
30726
  return tr;
29557
30727
  }
29558
30728
  if (span.level === "cell") {
@@ -30714,12 +31884,12 @@ function independentCommentAnchors(node) {
30714
31884
  if (!node.isText && node.type.spec.attrs?.format && node.marks.some(
30715
31885
  (mark) => mark.type.name === "comment" || mark.type.name === "inlineCommentAnchors"
30716
31886
  )) {
30717
- const properties4 = inlineRunProperties(node);
31887
+ const properties3 = inlineRunProperties(node);
30718
31888
  const ids = commentIdsFromNode(node);
30719
- if (ids.length) properties4.commentIds = ids;
30720
- else delete properties4.commentIds;
31889
+ if (ids.length) properties3.commentIds = ids;
31890
+ else delete properties3.commentIds;
30721
31891
  return node.type.create(
30722
- updatedInlineRunAttributes(node, JSON.stringify(properties4)),
31892
+ updatedInlineRunAttributes(node, JSON.stringify(properties3)),
30723
31893
  void 0,
30724
31894
  marks.filter(
30725
31895
  (mark) => mark.type.name !== "inlineCommentAnchors" && mark.type.name !== "comment"
@@ -31391,10 +32561,10 @@ var removeWordLink = (state, dispatch, view) => {
31391
32561
  function patchedRun(node, patch) {
31392
32562
  const run = inlineNodeRun(node);
31393
32563
  if (!run) return void 0;
31394
- const properties4 = run;
32564
+ const properties3 = run;
31395
32565
  for (const [key, value] of Object.entries(patch)) {
31396
- if (value === void 0) delete properties4[key];
31397
- else properties4[key] = value;
32566
+ if (value === void 0) delete properties3[key];
32567
+ else properties3[key] = value;
31398
32568
  }
31399
32569
  return run;
31400
32570
  }