ooxml-core 1.5.0 → 1.6.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 (303) hide show
  1. package/dist/{PptxHandler-ZPJNHEZZ.mjs → PptxHandler-DDEJ6CKU.mjs} +2 -2
  2. package/dist/automation/index.cjs +15757 -8955
  3. package/dist/automation/index.mjs +15757 -8955
  4. package/dist/{chunk-XGLKW3JJ.mjs → chunk-5L4DHJV3.mjs} +23 -3
  5. package/dist/{chunk-IVDC75E5.mjs → chunk-EPNLABIU.mjs} +1 -1
  6. package/dist/{chunk-BB55ASTX.mjs → chunk-Q52O7SXQ.mjs} +3 -3
  7. package/dist/{chunk-QPQDLSJQ.mjs → chunk-QXZJOUW4.mjs} +1 -1
  8. package/dist/{chunk-H4TPDZV4.mjs → chunk-UQQGC6O3.mjs} +1 -1
  9. package/dist/drawingml/index.cjs +102 -24
  10. package/dist/drawingml/index.d.ts +1 -0
  11. package/dist/drawingml/index.d.ts.map +1 -1
  12. package/dist/drawingml/index.mjs +102 -25
  13. package/dist/drawingml/write-theme.d.ts +17 -0
  14. package/dist/drawingml/write-theme.d.ts.map +1 -0
  15. package/dist/geometry/auto-align.d.ts +32 -0
  16. package/dist/geometry/auto-align.d.ts.map +1 -0
  17. package/dist/geometry/graph-layout.d.ts +37 -0
  18. package/dist/geometry/graph-layout.d.ts.map +1 -0
  19. package/dist/geometry/index.cjs +361 -7
  20. package/dist/geometry/index.d.ts +2 -0
  21. package/dist/geometry/index.d.ts.map +1 -1
  22. package/dist/geometry/index.mjs +359 -8
  23. package/dist/index.cjs +624 -122
  24. package/dist/index.mjs +624 -122
  25. package/dist/pptx/automation/index.cjs +23 -2
  26. package/dist/pptx/automation/index.mjs +5 -5
  27. package/dist/pptx/cli/index.cjs +23 -2
  28. package/dist/pptx/cli/index.mjs +4 -4
  29. package/dist/pptx/converter/index.mjs +2 -2
  30. package/dist/pptx/index.cjs +23 -2
  31. package/dist/pptx/index.mjs +5 -5
  32. package/dist/text/change-case.d.ts +20 -0
  33. package/dist/text/change-case.d.ts.map +1 -0
  34. package/dist/text/index.cjs +70 -0
  35. package/dist/text/index.d.ts +1 -0
  36. package/dist/text/index.d.ts.map +1 -1
  37. package/dist/text/index.mjs +68 -1
  38. package/dist/visio/arrow-shapes.d.ts +16 -0
  39. package/dist/visio/arrow-shapes.d.ts.map +1 -0
  40. package/dist/visio/basic-shapes.d.ts +2 -0
  41. package/dist/visio/basic-shapes.d.ts.map +1 -1
  42. package/dist/visio/comments.d.ts +39 -0
  43. package/dist/visio/comments.d.ts.map +1 -0
  44. package/dist/visio/connector-route.d.ts +31 -0
  45. package/dist/visio/connector-route.d.ts.map +1 -0
  46. package/dist/visio/data-recordsets.d.ts +66 -0
  47. package/dist/visio/data-recordsets.d.ts.map +1 -0
  48. package/dist/visio/edit-change-shape-commands.d.ts +17 -0
  49. package/dist/visio/edit-change-shape-commands.d.ts.map +1 -0
  50. package/dist/visio/edit-change-shape.d.ts +4 -0
  51. package/dist/visio/edit-change-shape.d.ts.map +1 -0
  52. package/dist/visio/edit-commands.d.ts +41 -6
  53. package/dist/visio/edit-commands.d.ts.map +1 -1
  54. package/dist/visio/edit-comment-commands.d.ts +32 -0
  55. package/dist/visio/edit-comment-commands.d.ts.map +1 -0
  56. package/dist/visio/edit-comments.d.ts +7 -0
  57. package/dist/visio/edit-comments.d.ts.map +1 -0
  58. package/dist/visio/edit-connection-points.d.ts +19 -0
  59. package/dist/visio/edit-connection-points.d.ts.map +1 -0
  60. package/dist/visio/edit-connector-commands.d.ts +57 -0
  61. package/dist/visio/edit-connector-commands.d.ts.map +1 -0
  62. package/dist/visio/edit-connector-glue.d.ts +43 -0
  63. package/dist/visio/edit-connector-glue.d.ts.map +1 -0
  64. package/dist/visio/edit-connector-layout.d.ts +37 -0
  65. package/dist/visio/edit-connector-layout.d.ts.map +1 -0
  66. package/dist/visio/edit-connector-reroute.d.ts +30 -0
  67. package/dist/visio/edit-connector-reroute.d.ts.map +1 -0
  68. package/dist/visio/edit-connector.d.ts +42 -0
  69. package/dist/visio/edit-connector.d.ts.map +1 -0
  70. package/dist/visio/edit-data-commands.d.ts +49 -0
  71. package/dist/visio/edit-data-commands.d.ts.map +1 -0
  72. package/dist/visio/edit-data-parts.d.ts +34 -0
  73. package/dist/visio/edit-data-parts.d.ts.map +1 -0
  74. package/dist/visio/edit-data.d.ts +8 -0
  75. package/dist/visio/edit-data.d.ts.map +1 -0
  76. package/dist/visio/edit-delete.d.ts.map +1 -1
  77. package/dist/visio/edit-diagram-parts-commands.d.ts +55 -0
  78. package/dist/visio/edit-diagram-parts-commands.d.ts.map +1 -0
  79. package/dist/visio/edit-diagram-parts.d.ts +16 -0
  80. package/dist/visio/edit-diagram-parts.d.ts.map +1 -0
  81. package/dist/visio/edit-ellipse-geometry.d.ts +2 -0
  82. package/dist/visio/edit-ellipse-geometry.d.ts.map +1 -1
  83. package/dist/visio/edit-foreign-bitmap.d.ts +7 -0
  84. package/dist/visio/edit-foreign-bitmap.d.ts.map +1 -0
  85. package/dist/visio/edit-formatting-cell-admission.d.ts +2 -0
  86. package/dist/visio/edit-formatting-cell-admission.d.ts.map +1 -1
  87. package/dist/visio/edit-formatting-commands.d.ts +14 -1
  88. package/dist/visio/edit-formatting-commands.d.ts.map +1 -1
  89. package/dist/visio/edit-formatting-effects.d.ts +50 -0
  90. package/dist/visio/edit-formatting-effects.d.ts.map +1 -0
  91. package/dist/visio/edit-formatting-glow.d.ts +43 -0
  92. package/dist/visio/edit-formatting-glow.d.ts.map +1 -0
  93. package/dist/visio/edit-formatting-paint-scope.d.ts.map +1 -1
  94. package/dist/visio/edit-formatting-paint.d.ts +6 -0
  95. package/dist/visio/edit-formatting-paint.d.ts.map +1 -1
  96. package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
  97. package/dist/visio/edit-formatting-text-commands.d.ts +56 -0
  98. package/dist/visio/edit-formatting-text-commands.d.ts.map +1 -0
  99. package/dist/visio/edit-formatting-text-extra.d.ts +11 -0
  100. package/dist/visio/edit-formatting-text-extra.d.ts.map +1 -0
  101. package/dist/visio/edit-formatting-text.d.ts.map +1 -1
  102. package/dist/visio/edit-formatting-theme-context.d.ts +14 -0
  103. package/dist/visio/edit-formatting-theme-context.d.ts.map +1 -0
  104. package/dist/visio/edit-formatting.d.ts +2 -0
  105. package/dist/visio/edit-formatting.d.ts.map +1 -1
  106. package/dist/visio/edit-geometry-admission.d.ts +1 -1
  107. package/dist/visio/edit-geometry-admission.d.ts.map +1 -1
  108. package/dist/visio/edit-geometry.d.ts.map +1 -1
  109. package/dist/visio/edit-group-commands.d.ts +22 -0
  110. package/dist/visio/edit-group-commands.d.ts.map +1 -0
  111. package/dist/visio/edit-group-rotation.d.ts +7 -1
  112. package/dist/visio/edit-group-rotation.d.ts.map +1 -1
  113. package/dist/visio/edit-group.d.ts +17 -0
  114. package/dist/visio/edit-group.d.ts.map +1 -0
  115. package/dist/visio/edit-guide-commands.d.ts +26 -0
  116. package/dist/visio/edit-guide-commands.d.ts.map +1 -0
  117. package/dist/visio/edit-guides.d.ts +4 -0
  118. package/dist/visio/edit-guides.d.ts.map +1 -0
  119. package/dist/visio/edit-layer-commands.d.ts +20 -0
  120. package/dist/visio/edit-layer-commands.d.ts.map +1 -0
  121. package/dist/visio/edit-layers.d.ts +7 -0
  122. package/dist/visio/edit-layers.d.ts.map +1 -0
  123. package/dist/visio/edit-metadata-commands.d.ts +46 -0
  124. package/dist/visio/edit-metadata-commands.d.ts.map +1 -0
  125. package/dist/visio/edit-metadata.d.ts +4 -0
  126. package/dist/visio/edit-metadata.d.ts.map +1 -0
  127. package/dist/visio/edit-page-auto-size.d.ts +19 -0
  128. package/dist/visio/edit-page-auto-size.d.ts.map +1 -0
  129. package/dist/visio/edit-page-create.d.ts +24 -0
  130. package/dist/visio/edit-page-create.d.ts.map +1 -0
  131. package/dist/visio/edit-page-decoration.d.ts +14 -0
  132. package/dist/visio/edit-page-decoration.d.ts.map +1 -0
  133. package/dist/visio/edit-page-setup-commands.d.ts +57 -0
  134. package/dist/visio/edit-page-setup-commands.d.ts.map +1 -0
  135. package/dist/visio/edit-page-setup.d.ts +13 -0
  136. package/dist/visio/edit-page-setup.d.ts.map +1 -0
  137. package/dist/visio/edit-page-size.d.ts +4 -0
  138. package/dist/visio/edit-page-size.d.ts.map +1 -1
  139. package/dist/visio/edit-page-theme-commands.d.ts +15 -0
  140. package/dist/visio/edit-page-theme-commands.d.ts.map +1 -0
  141. package/dist/visio/edit-page-theme-recolor.d.ts +3 -0
  142. package/dist/visio/edit-page-theme-recolor.d.ts.map +1 -0
  143. package/dist/visio/edit-page-theme.d.ts +10 -0
  144. package/dist/visio/edit-page-theme.d.ts.map +1 -0
  145. package/dist/visio/edit-pages.d.ts.map +1 -1
  146. package/dist/visio/edit-path-commands.d.ts +19 -0
  147. package/dist/visio/edit-path-commands.d.ts.map +1 -0
  148. package/dist/visio/edit-path-create.d.ts +23 -0
  149. package/dist/visio/edit-path-create.d.ts.map +1 -0
  150. package/dist/visio/edit-picture.d.ts +7 -0
  151. package/dist/visio/edit-picture.d.ts.map +1 -0
  152. package/dist/visio/edit-recalculate-index.d.ts +2 -0
  153. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  154. package/dist/visio/edit-resize-anchor.d.ts +1 -1
  155. package/dist/visio/edit-resize-anchor.d.ts.map +1 -1
  156. package/dist/visio/edit-scope.d.ts.map +1 -1
  157. package/dist/visio/edit-shape-create.d.ts +8 -0
  158. package/dist/visio/edit-shape-create.d.ts.map +1 -1
  159. package/dist/visio/edit-shape-data-commands.d.ts +34 -0
  160. package/dist/visio/edit-shape-data-commands.d.ts.map +1 -0
  161. package/dist/visio/edit-shape-data.d.ts +22 -0
  162. package/dist/visio/edit-shape-data.d.ts.map +1 -0
  163. package/dist/visio/edit-shape-order.d.ts.map +1 -1
  164. package/dist/visio/edit-subprocess-commands.d.ts +27 -0
  165. package/dist/visio/edit-subprocess-commands.d.ts.map +1 -0
  166. package/dist/visio/edit-subprocess.d.ts +9 -0
  167. package/dist/visio/edit-subprocess.d.ts.map +1 -0
  168. package/dist/visio/edit-text-field-commands.d.ts +21 -0
  169. package/dist/visio/edit-text-field-commands.d.ts.map +1 -0
  170. package/dist/visio/edit-text-field.d.ts +5 -0
  171. package/dist/visio/edit-text-field.d.ts.map +1 -0
  172. package/dist/visio/edit-text-range-plan.d.ts.map +1 -1
  173. package/dist/visio/edit-text-ranges.d.ts.map +1 -1
  174. package/dist/visio/edit-text.d.ts.map +1 -1
  175. package/dist/visio/edit.d.ts +2 -1
  176. package/dist/visio/edit.d.ts.map +1 -1
  177. package/dist/visio/effects.d.ts +13 -0
  178. package/dist/visio/effects.d.ts.map +1 -0
  179. package/dist/visio/formula-evaluate.d.ts.map +1 -1
  180. package/dist/visio/index.cjs +26474 -19318
  181. package/dist/visio/index.d.ts +25 -1
  182. package/dist/visio/index.d.ts.map +1 -1
  183. package/dist/visio/index.mjs +26406 -19319
  184. package/dist/visio/model.d.ts +125 -0
  185. package/dist/visio/model.d.ts.map +1 -1
  186. package/dist/visio/page-decoration.d.ts +66 -0
  187. package/dist/visio/page-decoration.d.ts.map +1 -0
  188. package/dist/visio/page-scale.d.ts.map +1 -1
  189. package/dist/visio/page-setup.d.ts +8 -0
  190. package/dist/visio/page-setup.d.ts.map +1 -0
  191. package/dist/visio/page-theme.d.ts +9 -0
  192. package/dist/visio/page-theme.d.ts.map +1 -0
  193. package/dist/visio/paper-sizes.d.ts +24 -0
  194. package/dist/visio/paper-sizes.d.ts.map +1 -0
  195. package/dist/visio/parser.d.ts.map +1 -1
  196. package/dist/visio/path-fit.d.ts +69 -0
  197. package/dist/visio/path-fit.d.ts.map +1 -0
  198. package/dist/visio/shadow.d.ts +9 -0
  199. package/dist/visio/shadow.d.ts.map +1 -0
  200. package/dist/visio/shape-connections.d.ts +5 -0
  201. package/dist/visio/shape-connections.d.ts.map +1 -0
  202. package/dist/visio/shape-metadata.d.ts +3 -0
  203. package/dist/visio/shape-metadata.d.ts.map +1 -1
  204. package/dist/visio/shape-structure.d.ts +10 -0
  205. package/dist/visio/shape-structure.d.ts.map +1 -0
  206. package/dist/visio/shapes.d.ts.map +1 -1
  207. package/dist/visio/stencil-shapes.d.ts +20 -0
  208. package/dist/visio/stencil-shapes.d.ts.map +1 -0
  209. package/dist/visio/stencils.d.ts +30 -0
  210. package/dist/visio/stencils.d.ts.map +1 -0
  211. package/dist/visio/style.d.ts +3 -0
  212. package/dist/visio/style.d.ts.map +1 -1
  213. package/dist/visio/text-character.d.ts +5 -0
  214. package/dist/visio/text-character.d.ts.map +1 -0
  215. package/dist/visio/text-field-context.d.ts +6 -0
  216. package/dist/visio/text-field-context.d.ts.map +1 -0
  217. package/dist/visio/text-field-display.d.ts +12 -0
  218. package/dist/visio/text-field-display.d.ts.map +1 -0
  219. package/dist/visio/text-fields.d.ts +65 -0
  220. package/dist/visio/text-fields.d.ts.map +1 -0
  221. package/dist/visio/theme-builtins.d.ts +32 -0
  222. package/dist/visio/theme-builtins.d.ts.map +1 -0
  223. package/dist/visio/theme-write.d.ts +4 -0
  224. package/dist/visio/theme-write.d.ts.map +1 -0
  225. package/dist/visio/theme.d.ts +2 -0
  226. package/dist/visio/theme.d.ts.map +1 -1
  227. package/dist/visio/ui/auto-layout.d.ts +38 -0
  228. package/dist/visio/ui/auto-layout.d.ts.map +1 -0
  229. package/dist/visio/ui/change-case.d.ts +12 -0
  230. package/dist/visio/ui/change-case.d.ts.map +1 -0
  231. package/dist/visio/ui/connection-points.d.ts +45 -0
  232. package/dist/visio/ui/connection-points.d.ts.map +1 -0
  233. package/dist/visio/ui/connector-preview.d.ts +24 -0
  234. package/dist/visio/ui/connector-preview.d.ts.map +1 -0
  235. package/dist/visio/ui/data-graphic-rules.d.ts +45 -0
  236. package/dist/visio/ui/data-graphic-rules.d.ts.map +1 -0
  237. package/dist/visio/ui/data-graphics.d.ts +15 -0
  238. package/dist/visio/ui/data-graphics.d.ts.map +1 -0
  239. package/dist/visio/ui/data-table.d.ts +33 -0
  240. package/dist/visio/ui/data-table.d.ts.map +1 -0
  241. package/dist/visio/ui/diagram-check.d.ts +32 -0
  242. package/dist/visio/ui/diagram-check.d.ts.map +1 -0
  243. package/dist/visio/ui/diagram-parts.d.ts +20 -0
  244. package/dist/visio/ui/diagram-parts.d.ts.map +1 -0
  245. package/dist/visio/ui/draw-path-plan.d.ts +21 -0
  246. package/dist/visio/ui/draw-path-plan.d.ts.map +1 -0
  247. package/dist/visio/ui/draw-plan.d.ts +11 -3
  248. package/dist/visio/ui/draw-plan.d.ts.map +1 -1
  249. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  250. package/dist/visio/ui/format-painter.d.ts +25 -0
  251. package/dist/visio/ui/format-painter.d.ts.map +1 -0
  252. package/dist/visio/ui/guides.d.ts +34 -0
  253. package/dist/visio/ui/guides.d.ts.map +1 -0
  254. package/dist/visio/ui/index.cjs +8006 -2705
  255. package/dist/visio/ui/index.d.ts +25 -0
  256. package/dist/visio/ui/index.d.ts.map +1 -1
  257. package/dist/visio/ui/index.mjs +7894 -2706
  258. package/dist/visio/ui/insert.d.ts +26 -0
  259. package/dist/visio/ui/insert.d.ts.map +1 -0
  260. package/dist/visio/ui/layer-assign.d.ts +31 -0
  261. package/dist/visio/ui/layer-assign.d.ts.map +1 -0
  262. package/dist/visio/ui/page-edit.d.ts.map +1 -1
  263. package/dist/visio/ui/page-setup.d.ts +50 -0
  264. package/dist/visio/ui/page-setup.d.ts.map +1 -0
  265. package/dist/visio/ui/page-size.d.ts +2 -11
  266. package/dist/visio/ui/page-size.d.ts.map +1 -1
  267. package/dist/visio/ui/paste-text.d.ts +13 -0
  268. package/dist/visio/ui/paste-text.d.ts.map +1 -0
  269. package/dist/visio/ui/scene-data.d.ts +4 -0
  270. package/dist/visio/ui/scene-data.d.ts.map +1 -0
  271. package/dist/visio/ui/scene-details.d.ts.map +1 -1
  272. package/dist/visio/ui/scene-validation-text.d.ts +8 -0
  273. package/dist/visio/ui/scene-validation-text.d.ts.map +1 -0
  274. package/dist/visio/ui/scene-validation.d.ts.map +1 -1
  275. package/dist/visio/ui/select-by-type.d.ts +35 -0
  276. package/dist/visio/ui/select-by-type.d.ts.map +1 -0
  277. package/dist/visio/ui/shape-arrange.d.ts.map +1 -1
  278. package/dist/visio/ui/shape-change.d.ts +11 -0
  279. package/dist/visio/ui/shape-change.d.ts.map +1 -0
  280. package/dist/visio/ui/shape-effects.d.ts +14 -0
  281. package/dist/visio/ui/shape-effects.d.ts.map +1 -0
  282. package/dist/visio/ui/shape-formatting.d.ts +5 -0
  283. package/dist/visio/ui/shape-formatting.d.ts.map +1 -1
  284. package/dist/visio/ui/shape-group.d.ts +9 -0
  285. package/dist/visio/ui/shape-group.d.ts.map +1 -0
  286. package/dist/visio/ui/shape-move.d.ts +5 -2
  287. package/dist/visio/ui/shape-move.d.ts.map +1 -1
  288. package/dist/visio/ui/shape-report.d.ts +37 -0
  289. package/dist/visio/ui/shape-report.d.ts.map +1 -0
  290. package/dist/visio/ui/shape-resize.d.ts.map +1 -1
  291. package/dist/visio/ui/shape-rotation.d.ts.map +1 -1
  292. package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
  293. package/dist/visio/ui/subprocess.d.ts +13 -0
  294. package/dist/visio/ui/subprocess.d.ts.map +1 -0
  295. package/dist/visio/ui/text-block.d.ts +42 -0
  296. package/dist/visio/ui/text-block.d.ts.map +1 -0
  297. package/dist/visio/ui/text-dialog.d.ts +54 -0
  298. package/dist/visio/ui/text-dialog.d.ts.map +1 -0
  299. package/dist/visio/ui/text-draft.d.ts +25 -0
  300. package/dist/visio/ui/text-draft.d.ts.map +1 -0
  301. package/dist/visio/ui/text-field-catalog.d.ts +17 -0
  302. package/dist/visio/ui/text-field-catalog.d.ts.map +1 -0
  303. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -2458,7 +2458,7 @@ function drawingFillXml(fill) {
2458
2458
  const root = doc.documentElement;
2459
2459
  if (root.namespaceURI !== NS.a || root.localName !== "gradFill")
2460
2460
  throw new Error("Invalid gradient source XML");
2461
- const fragment = (xml) => doc.importNode(elements(parseXml(`<w xmlns:a="${NS.a}">${xml}</w>`).documentElement)[0], true);
2461
+ const fragment2 = (xml) => doc.importNode(elements(parseXml(`<w xmlns:a="${NS.a}">${xml}</w>`).documentElement)[0], true);
2462
2462
  let list2 = first(root, "gsLst", NS.a);
2463
2463
  if (!list2) {
2464
2464
  list2 = doc.createElementNS(NS.a, "a:gsLst");
@@ -2473,7 +2473,7 @@ function drawingFillXml(fill) {
2473
2473
  node.setAttribute("pos", String(Math.round(stop.position * 1e3)));
2474
2474
  for (const old of elements(node))
2475
2475
  if (old.namespaceURI === NS.a && old.localName.endsWith("Clr")) node.removeChild(old);
2476
- node.insertBefore(fragment(drawingColorXml(stop.color)), node.firstChild);
2476
+ node.insertBefore(fragment2(drawingColorXml(stop.color)), node.firstChild);
2477
2477
  });
2478
2478
  for (const stop of stops.slice(fill.stops.length)) list2.removeChild(stop);
2479
2479
  for (const node of elements(root))
@@ -2776,14 +2776,14 @@ function resolveChartGradient(fill, resolve) {
2776
2776
  ...focus ? { focalPoint: { x: (1 + focus.l - focus.r) / 2, y: (1 + focus.t - focus.b) / 2 } } : {}
2777
2777
  };
2778
2778
  }
2779
- function buildChartGradientDef(id, fill, bounds) {
2779
+ function buildChartGradientDef(id, fill, bounds2) {
2780
2780
  const sourceStops = sortGradientStops(fill.stops).map((stop) => ({
2781
2781
  offset: Math.min(Math.max(stop.position / 100, 0), 1),
2782
2782
  color: stop.color,
2783
2783
  ...stop.opacity !== void 0 ? { opacity: stop.opacity } : {}
2784
2784
  }));
2785
2785
  const stops = fill.interpolation === "sigma-gamma22" ? sigmaGradientStops(sourceStops) ?? sourceStops : sourceStops;
2786
- if (fill.type === "radial" && (fill.path === "rect" || fill.path === "shape" && bounds?.shape === "rect")) {
2786
+ if (fill.type === "radial" && (fill.path === "rect" || fill.path === "shape" && bounds2?.shape === "rect")) {
2787
2787
  const markup = buildRectPathGradientSvg(
2788
2788
  stops.map((stop) => ({
2789
2789
  position: stop.offset * 100,
@@ -2804,7 +2804,7 @@ function buildChartGradientDef(id, fill, bounds) {
2804
2804
  if (fill.type === "radial") {
2805
2805
  const cx = fill.focalPoint?.x ?? 0.5;
2806
2806
  const cy = fill.focalPoint?.y ?? 0.5;
2807
- const aspect = fill.path === "circle" && bounds && Number.isFinite(bounds.width) && Number.isFinite(bounds.height) && bounds.width > 0 && bounds.height > 0 ? bounds.height / bounds.width : 1;
2807
+ const aspect = fill.path === "circle" && bounds2 && Number.isFinite(bounds2.width) && Number.isFinite(bounds2.height) && bounds2.width > 0 && bounds2.height > 0 ? bounds2.height / bounds2.width : 1;
2808
2808
  return {
2809
2809
  kind: "radialGradient",
2810
2810
  id,
@@ -3659,17 +3659,17 @@ function parseView3D(context, element) {
3659
3659
  }
3660
3660
  );
3661
3661
  }
3662
- function chartStyle(context, space) {
3663
- const direct = cNumber(context, space, "style");
3662
+ function chartStyle(context, space3) {
3663
+ const direct = cNumber(context, space3, "style");
3664
3664
  if (direct !== void 0) return direct;
3665
- for (const alternate of children(space, "AlternateContent", NS.mc)) {
3665
+ for (const alternate of children(space3, "AlternateContent", NS.mc)) {
3666
3666
  const style = cNumber(context, first(alternate, "Fallback", NS.mc), "style");
3667
3667
  if (style !== void 0) return style;
3668
3668
  }
3669
3669
  return void 0;
3670
3670
  }
3671
- function c14Style(space) {
3672
- for (const alternate of children(space, "AlternateContent", NS.mc)) {
3671
+ function c14Style(space3) {
3672
+ for (const alternate of children(space3, "AlternateContent", NS.mc)) {
3673
3673
  const raw2 = attribute(first(first(alternate, "Choice", NS.mc), "style", NS.c14, false), "val");
3674
3674
  const value = raw2?.trim() ? Number(raw2) : Number.NaN;
3675
3675
  if (Number.isFinite(value)) return value;
@@ -4178,10 +4178,10 @@ function legendXml(context, legend) {
4178
4178
  valXml("legendPos", legend.position) + entries + layoutXml(context, legend.layout) + valXml("overlay", legend.overlay) + shapePropertiesXml(context, legend.spPr) + textBodyXml(context, legend.txPr) + raw(context, legend.extLst)
4179
4179
  );
4180
4180
  }
4181
- function styleXml(context, space) {
4182
- const style = valXml("style", space.style);
4183
- if (space.c14Style === void 0) return style;
4184
- const choice = `<mc:Choice Requires="c14" xmlns:c14="${NS.c14}"><c14:style val="${space.c14Style}"/></mc:Choice>`;
4181
+ function styleXml(context, space3) {
4182
+ const style = valXml("style", space3.style);
4183
+ if (space3.c14Style === void 0) return style;
4184
+ const choice = `<mc:Choice Requires="c14" xmlns:c14="${NS.c14}"><c14:style val="${space3.c14Style}"/></mc:Choice>`;
4185
4185
  const fallback = style ? `<mc:Fallback>${style}</mc:Fallback>` : "<mc:Fallback/>";
4186
4186
  return raw(
4187
4187
  context,
@@ -4189,21 +4189,21 @@ function styleXml(context, space) {
4189
4189
  );
4190
4190
  }
4191
4191
  var relationship = (local, id, content2 = "") => id === void 0 ? "" : elementXml(local, content2, ` r:id="${escapeAttribute(id)}"`);
4192
- function writeChartSpace(space, options = {}) {
4192
+ function writeChartSpace(space3, options = {}) {
4193
4193
  const bindings = new Map(CHART_ROOT_BINDINGS);
4194
- for (const { prefix, uri } of space.namespaceDeclarations ?? [])
4194
+ for (const { prefix, uri } of space3.namespaceDeclarations ?? [])
4195
4195
  if (!bindings.has(prefix) && /^[A-Za-z_][\w.-]*$/.test(prefix)) bindings.set(prefix, uri);
4196
4196
  const context = { bindings };
4197
4197
  const declarations = [...bindings].map(([prefix, uri]) => ` xmlns:${prefix}="${escapeAttribute(uri)}"`).join("");
4198
4198
  const chart = elementXml(
4199
4199
  "chart",
4200
- titleXml(context, space.title) + valXml("autoTitleDeleted", space.autoTitleDeleted) + view3DXml(space.view3D) + surfaceXml(context, "floor", space.floor) + surfaceXml(context, "sideWall", space.sideWall) + surfaceXml(context, "backWall", space.backWall) + plotAreaXml(context, space.plotArea) + legendXml(context, space.legend) + valXml("plotVisOnly", space.plotVisibleOnly) + valXml("dispBlanksAs", space.displayBlanksAs) + valXml("showDLblsOverMax", space.showDataLabelsOverMax) + raw(context, space.chartExtLst)
4200
+ titleXml(context, space3.title) + valXml("autoTitleDeleted", space3.autoTitleDeleted) + view3DXml(space3.view3D) + surfaceXml(context, "floor", space3.floor) + surfaceXml(context, "sideWall", space3.sideWall) + surfaceXml(context, "backWall", space3.backWall) + plotAreaXml(context, space3.plotArea) + legendXml(context, space3.legend) + valXml("plotVisOnly", space3.plotVisibleOnly) + valXml("dispBlanksAs", space3.displayBlanksAs) + valXml("showDLblsOverMax", space3.showDataLabelsOverMax) + raw(context, space3.chartExtLst)
4201
4201
  );
4202
- const body = valXml("date1904", space.date1904) + valXml("lang", space.language) + valXml("roundedCorners", space.roundedCorners) + styleXml(context, space) + chart + shapePropertiesXml(context, space.spPr) + textBodyXml(context, space.txPr) + relationship(
4202
+ const body = valXml("date1904", space3.date1904) + valXml("lang", space3.language) + valXml("roundedCorners", space3.roundedCorners) + styleXml(context, space3) + chart + shapePropertiesXml(context, space3.spPr) + textBodyXml(context, space3.txPr) + relationship(
4203
4203
  "externalData",
4204
- space.externalDataRelId,
4205
- valXml("autoUpdate", space.externalDataAutoUpdate)
4206
- ) + raw(context, space.printSettings) + relationship("userShapes", space.userShapesRelId) + raw(context, space.extLst);
4204
+ space3.externalDataRelId,
4205
+ valXml("autoUpdate", space3.externalDataAutoUpdate)
4206
+ ) + raw(context, space3.printSettings) + relationship("userShapes", space3.userShapesRelId) + raw(context, space3.extLst);
4207
4207
  const breakAfter = options.declarationBreak ?? "\r\n";
4208
4208
  return `${DECLARATION2}${breakAfter}<c:chartSpace${declarations}>${body}</c:chartSpace>`;
4209
4209
  }
@@ -4999,8 +4999,8 @@ function chartGradientPaint(model, width = 1024, height = 768) {
4999
4999
  textShadowFilter: shadowPaint(entry3.textShadow, `${part}-text-shadow`)
5000
5000
  };
5001
5001
  }
5002
- const paint = (gradient, suffix, bounds) => {
5003
- const def = buildChartGradientDef(`${prefix}-${suffix}`, gradient, bounds);
5002
+ const paint = (gradient, suffix, bounds2) => {
5003
+ const def = buildChartGradientDef(`${prefix}-${suffix}`, gradient, bounds2);
5004
5004
  defs.push(chartGradientMarkup(def));
5005
5005
  return `url(#${def.id})`;
5006
5006
  };
@@ -5016,12 +5016,12 @@ function chartGradientPaint(model, width = 1024, height = 768) {
5016
5016
  const series = model.series.map((source, index) => {
5017
5017
  const view = { ...source };
5018
5018
  if (source.shadow) view.shadowFilter = shadowPaint(source.shadow, `s${index}-shadow`);
5019
- const bounds = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
5020
- if (source.gradient) view.color = paint(source.gradient, `s${index}`, bounds);
5019
+ const bounds2 = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
5020
+ if (source.gradient) view.color = paint(source.gradient, `s${index}`, bounds2);
5021
5021
  if (source.pointGradients) {
5022
5022
  view.pointColors = [...source.pointColors ?? []];
5023
5023
  for (const [key, gradient] of Object.entries(source.pointGradients))
5024
- view.pointColors[Number(key)] = paint(gradient, `s${index}-p${key}`, bounds);
5024
+ view.pointColors[Number(key)] = paint(gradient, `s${index}-p${key}`, bounds2);
5025
5025
  }
5026
5026
  return view;
5027
5027
  });
@@ -5220,7 +5220,7 @@ function linesAndAreas(model, frame2, out) {
5220
5220
  const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
5221
5221
  const acc = new Array(model.categories.length).fill(0);
5222
5222
  const area = model.type === "area";
5223
- const layers = [];
5223
+ const layers2 = [];
5224
5224
  model.series.forEach((s, si) => {
5225
5225
  const points = [];
5226
5226
  const lower = [];
@@ -5236,14 +5236,14 @@ function linesAndAreas(model, frame2, out) {
5236
5236
  points.push([frame2.band(i2), frame2.value(top)]);
5237
5237
  lower.push([frame2.band(i2), frame2.value(below)]);
5238
5238
  });
5239
- layers.push({
5239
+ layers2.push({
5240
5240
  points,
5241
5241
  lower,
5242
5242
  color: s.color,
5243
5243
  filter: s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""
5244
5244
  });
5245
5245
  });
5246
- for (const { points, lower, color, filter } of area ? [...layers].reverse() : layers) {
5246
+ for (const { points, lower, color, filter } of area ? [...layers2].reverse() : layers2) {
5247
5247
  if (area) {
5248
5248
  const poly = [...points, ...[...lower].reverse()].map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
5249
5249
  out.push(`<polygon points="${poly}" fill="${color}" fill-opacity="0.85"${filter}/>`);
@@ -5467,10 +5467,10 @@ function fitChartText(content2, maxWidth, attrs, options) {
5467
5467
  // chart/render/chart-svg-legend.ts
5468
5468
  function chartLegendSvg(model, area, frame2, options) {
5469
5469
  const automatic = [];
5470
- const bounds = {};
5471
- const reserved = automaticLegend(model, area, automatic, options, bounds);
5470
+ const bounds2 = {};
5471
+ const reserved = automaticLegend(model, area, automatic, options, bounds2);
5472
5472
  const plot = model.legendOverlay ? area : reserved;
5473
- const box = bounds.box;
5473
+ const box = bounds2.box;
5474
5474
  if (!box) return { plot, markup: "", foreground: false };
5475
5475
  const manual = resolveManualLayoutRect(model.legendLayout, frame2, {
5476
5476
  x: box.x,
@@ -5529,7 +5529,7 @@ function legendEntries(model) {
5529
5529
  }
5530
5530
  return model.series.map((s) => ({ label: s.name, color: s.color }));
5531
5531
  }
5532
- function automaticLegend(model, area, out, options, bounds) {
5532
+ function automaticLegend(model, area, out, options, bounds2) {
5533
5533
  const entries = legendEntries(model);
5534
5534
  if (!model.showLegend || entries.length === 0) return area;
5535
5535
  const pos = model.legendPosition;
@@ -5543,7 +5543,7 @@ function automaticLegend(model, area, out, options, bounds) {
5543
5543
  const total = widths.reduce((a2, b) => a2 + b, 0);
5544
5544
  let x2 = area.x + Math.max(0, (area.w - total) / 2);
5545
5545
  const y = pos === "t" ? area.y + 4 : area.y + area.h - rowH + 4;
5546
- bounds.box = { x: x2 - 4, y: y - 4, w: Math.min(total, area.w) + 8, h: rowH + 4 };
5546
+ bounds2.box = { x: x2 - 4, y: y - 4, w: Math.min(total, area.w) + 8, h: rowH + 4 };
5547
5547
  out.push(
5548
5548
  chartAreaRect(model, "legend", {
5549
5549
  x: x2 - 4,
@@ -5567,7 +5567,7 @@ function automaticLegend(model, area, out, options, bounds) {
5567
5567
  const height = entries.length * rowH;
5568
5568
  const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
5569
5569
  const y0 = pos === "tr" ? area.y + 4 : area.y + Math.max(0, (area.h - height) / 2);
5570
- bounds.box = { x: x - 4, y: y0, w: width + 4, h: Math.min(height, area.y + area.h - y0) };
5570
+ bounds2.box = { x: x - 4, y: y0, w: width + 4, h: Math.min(height, area.y + area.h - y0) };
5571
5571
  out.push(
5572
5572
  chartAreaRect(model, "legend", {
5573
5573
  x: x - 4,
@@ -5871,14 +5871,14 @@ function chartThemePalette(theme, fonts = {}) {
5871
5871
  minorFont: fonts.minor ?? "Calibri"
5872
5872
  };
5873
5873
  }
5874
- function chartSpaceKind(space) {
5875
- if (!space.plotArea.groups.length) return { drawn: false };
5876
- const type = chartSummaryFromSpace(space).chartType;
5874
+ function chartSpaceKind(space3) {
5875
+ if (!space3.plotArea.groups.length) return { drawn: false };
5876
+ const type = chartSummaryFromSpace(space3).chartType;
5877
5877
  return { type, drawn: DRAWN_CHART_TYPES.has(type) };
5878
5878
  }
5879
- function renderChartSpaceSvg(space, options) {
5879
+ function renderChartSpaceSvg(space3, options) {
5880
5880
  const { width, height, theme, fonts, formatting, colorPalette, styleDefinition, ...svg } = options;
5881
- const summary = chartSummaryFromSpace(space, {
5881
+ const summary = chartSummaryFromSpace(space3, {
5882
5882
  ...formatting ? { formatting } : {},
5883
5883
  ...colorPalette !== void 0 ? { colorPalette } : {},
5884
5884
  ...styleDefinition ? { styleDefinition } : {}
@@ -5890,7 +5890,10 @@ function renderChartSpaceSvg(space, options) {
5890
5890
  // text/index.ts
5891
5891
  var text_exports = {};
5892
5892
  __export(text_exports, {
5893
+ TEXT_CASE_MODES: () => TEXT_CASE_MODES,
5893
5894
  buildLeaderString: () => buildLeaderString,
5895
+ changeTextCase: () => changeTextCase,
5896
+ changeTextCaseRanges: () => changeTextCaseRanges,
5894
5897
  decimalAnchorIndex: () => decimalAnchorIndex,
5895
5898
  decimalSeparatorForLanguage: () => decimalSeparatorForLanguage,
5896
5899
  detectFontScript: () => detectFontScript,
@@ -6085,6 +6088,73 @@ function decimalAnchorIndex(text3, separator) {
6085
6088
  return sep >= 0 ? first2 + sep : end;
6086
6089
  }
6087
6090
 
6091
+ // text/change-case.ts
6092
+ var TEXT_CASE_MODES = Object.freeze([
6093
+ "sentence",
6094
+ "lower",
6095
+ "upper",
6096
+ "capitalize",
6097
+ "toggle"
6098
+ ]);
6099
+ var letter = /\p{L}/u;
6100
+ var wordCharacter = /[\p{L}\p{N}\p{M}'’]/u;
6101
+ var sentenceEnd = /[.!?。!?]/u;
6102
+ var space = /\s/u;
6103
+ function convert(text3, mode) {
6104
+ if (!TEXT_CASE_MODES.includes(mode)) throw new TypeError(`Unknown text case mode: ${mode}`);
6105
+ const points = [];
6106
+ let offset = 0, sentenceStart = true, pendingEnd = false, previous = "";
6107
+ for (const point of text3) {
6108
+ let out = point;
6109
+ if (letter.test(point)) {
6110
+ const lower = point.toLowerCase(), upper = point.toUpperCase();
6111
+ if (mode === "upper") out = upper;
6112
+ else if (mode === "lower") out = lower;
6113
+ else if (mode === "toggle") out = point === upper && point !== lower ? lower : upper;
6114
+ else if (mode === "sentence") out = sentenceStart ? upper : lower;
6115
+ else out = previous && wordCharacter.test(previous) ? lower : upper;
6116
+ sentenceStart = false;
6117
+ pendingEnd = false;
6118
+ } else if (point === "\n") {
6119
+ sentenceStart = true;
6120
+ pendingEnd = false;
6121
+ } else if (sentenceEnd.test(point)) pendingEnd = true;
6122
+ else if (space.test(point)) {
6123
+ if (pendingEnd) sentenceStart = true;
6124
+ pendingEnd = false;
6125
+ } else if (/\p{N}/u.test(point)) {
6126
+ sentenceStart = false;
6127
+ pendingEnd = false;
6128
+ }
6129
+ points.push({ start: offset, end: offset + point.length, text: point, out });
6130
+ offset += point.length;
6131
+ previous = point;
6132
+ }
6133
+ return points;
6134
+ }
6135
+ function changeTextCase(text3, mode) {
6136
+ return convert(text3, mode).map((point) => point.out).join("");
6137
+ }
6138
+ function changeTextCaseRanges(text3, mode, boundaries = []) {
6139
+ const breaks = new Set(boundaries);
6140
+ const ranges = [];
6141
+ let current;
6142
+ for (const point of convert(text3, mode)) {
6143
+ if (point.out === point.text) {
6144
+ current = void 0;
6145
+ continue;
6146
+ }
6147
+ if (current && current.end === point.start && !breaks.has(point.start)) {
6148
+ current.end = point.end;
6149
+ current.text += point.out;
6150
+ } else {
6151
+ current = { start: point.start, end: point.end, text: point.out };
6152
+ ranges.push(current);
6153
+ }
6154
+ }
6155
+ return ranges;
6156
+ }
6157
+
6088
6158
  // i18n/index.ts
6089
6159
  var i18n_exports = {};
6090
6160
  __export(i18n_exports, {
@@ -6172,6 +6242,7 @@ __export(drawingml_exports, {
6172
6242
  drawingColorCss: () => drawingColorCss,
6173
6243
  drawingColorXml: () => drawingColorXml,
6174
6244
  drawingFillXml: () => drawingFillXml,
6245
+ drawingThemeXml: () => drawingThemeXml,
6175
6246
  fillElementOf: () => fillElementOf,
6176
6247
  integerAttribute: () => integerAttribute,
6177
6248
  isThemeColorSlot: () => isThemeColorSlot,
@@ -6343,6 +6414,83 @@ function parseDrawingGeometry(spPr) {
6343
6414
  return { geometry, ...Object.keys(adjustments).length > 0 ? { adjustments } : {} };
6344
6415
  }
6345
6416
 
6417
+ // drawingml/write-theme.ts
6418
+ function fragment(host, xml, namespaces) {
6419
+ const declarations = Object.entries({ a: NS.a, ...namespaces }).map(([prefix, uri]) => ` xmlns:${prefix}="${uri}"`).join("");
6420
+ const wrapper = parseXml(`<w${declarations}>${xml}</w>`, { label: "DrawingML theme fragment" });
6421
+ return elements(wrapper.documentElement).map(
6422
+ (node) => host.ownerDocument.importNode(node, true)
6423
+ );
6424
+ }
6425
+ function extensionList2(parent, extensions, namespaces) {
6426
+ const entries = Object.entries(extensions ?? {});
6427
+ if (!entries.length) return;
6428
+ const doc = parent.ownerDocument;
6429
+ const list2 = doc.createElementNS(NS.a, "a:extLst");
6430
+ for (const [uri, xml] of entries) {
6431
+ const ext = doc.createElementNS(NS.a, "a:ext");
6432
+ ext.setAttribute("uri", uri);
6433
+ for (const node of fragment(ext, xml, namespaces)) ext.appendChild(node);
6434
+ list2.appendChild(ext);
6435
+ }
6436
+ parent.appendChild(list2);
6437
+ }
6438
+ function fontCollection(parent, name, fonts) {
6439
+ const doc = parent.ownerDocument;
6440
+ const node = doc.createElementNS(NS.a, `a:${name}`);
6441
+ for (const [local, face] of [
6442
+ ["latin", fonts.latin],
6443
+ ["ea", fonts.eastAsia],
6444
+ ["cs", fonts.complexScript]
6445
+ ]) {
6446
+ const font = doc.createElementNS(NS.a, `a:${local}`);
6447
+ font.setAttribute("typeface", face ?? "");
6448
+ node.appendChild(font);
6449
+ }
6450
+ for (const [script, face] of Object.entries(fonts.scripts)) {
6451
+ const font = doc.createElementNS(NS.a, "a:font");
6452
+ font.setAttribute("script", script);
6453
+ font.setAttribute("typeface", face);
6454
+ node.appendChild(font);
6455
+ }
6456
+ parent.appendChild(node);
6457
+ }
6458
+ function drawingThemeXml(theme, parts) {
6459
+ const namespaces = parts.namespaces ?? {};
6460
+ const doc = parseXml(
6461
+ `<a:theme xmlns:a="${NS.a}"${Object.entries(namespaces).map(([prefix, uri]) => ` xmlns:${prefix}="${uri}"`).join("")}/>`
6462
+ );
6463
+ const root = doc.documentElement;
6464
+ if (theme.name !== void 0) root.setAttribute("name", theme.name);
6465
+ const elementsNode = doc.createElementNS(NS.a, "a:themeElements");
6466
+ root.appendChild(elementsNode);
6467
+ const scheme = doc.createElementNS(NS.a, "a:clrScheme");
6468
+ scheme.setAttribute("name", theme.colorScheme.name ?? theme.name ?? "Custom");
6469
+ for (const slot2 of THEME_COLOR_SLOTS) {
6470
+ const color = theme.colorScheme.colors[slot2];
6471
+ if (!color) throw new Error(`The theme colour scheme has no ${slot2} colour.`);
6472
+ const node = doc.createElementNS(NS.a, `a:${slot2}`);
6473
+ for (const child3 of fragment(node, drawingColorXml(color), namespaces)) node.appendChild(child3);
6474
+ scheme.appendChild(node);
6475
+ }
6476
+ extensionList2(scheme, parts.colorSchemeExtensions, namespaces);
6477
+ elementsNode.appendChild(scheme);
6478
+ const fonts = doc.createElementNS(NS.a, "a:fontScheme");
6479
+ fonts.setAttribute("name", theme.fontScheme.name ?? theme.name ?? "Custom");
6480
+ fontCollection(fonts, "majorFont", theme.fontScheme.major);
6481
+ fontCollection(fonts, "minorFont", theme.fontScheme.minor);
6482
+ elementsNode.appendChild(fonts);
6483
+ const format = fragment(elementsNode, parts.formatScheme, namespaces);
6484
+ if (format.length !== 1 || format[0].localName !== "fmtScheme" || format[0].namespaceURI !== NS.a)
6485
+ throw new Error("The theme format scheme must be one a:fmtScheme element.");
6486
+ elementsNode.appendChild(format[0]);
6487
+ extensionList2(elementsNode, parts.themeElementsExtensions, namespaces);
6488
+ root.appendChild(doc.createElementNS(NS.a, "a:objectDefaults"));
6489
+ root.appendChild(doc.createElementNS(NS.a, "a:extraClrSchemeLst"));
6490
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
6491
+ ${buildXml(doc)}`;
6492
+ }
6493
+
6346
6494
  // drawingml/gradient-preset-data.ts
6347
6495
  var OFFICE_GRADIENT_PRESET_DATA = [
6348
6496
  [
@@ -18407,13 +18555,13 @@ function textFitsAt(node, text3, sizePt, metrics, refSize) {
18407
18555
  }
18408
18556
  return paragraphsFit(text3, sizePt, availW, availH, metrics);
18409
18557
  }
18410
- function fitNodeFontPt(node, text3, bounds, metrics, refSize) {
18411
- for (let size = bounds.start; size > bounds.floor; size--) {
18558
+ function fitNodeFontPt(node, text3, bounds2, metrics, refSize) {
18559
+ for (let size = bounds2.start; size > bounds2.floor; size--) {
18412
18560
  if (textFitsAt(node, text3, size, metrics, refSize)) {
18413
18561
  return size;
18414
18562
  }
18415
18563
  }
18416
- return bounds.floor;
18564
+ return bounds2.floor;
18417
18565
  }
18418
18566
 
18419
18567
  // diagram/engine/text-grow.ts
@@ -19446,9 +19594,9 @@ function placeTwoColumns(shapes, centre, top, gap, sp) {
19446
19594
  const left = side === 0 ? centre - gap / 2 - width : centre + gap / 2;
19447
19595
  let y = top;
19448
19596
  for (const shape of column) {
19449
- const bounds = boundsOf(shape.rects);
19450
- rects.push(...shiftShape(shape, left - bounds.x, y - bounds.y).rects);
19451
- y += bounds.h + sp;
19597
+ const bounds2 = boundsOf(shape.rects);
19598
+ rects.push(...shiftShape(shape, left - bounds2.x, y - bounds2.y).rects);
19599
+ y += bounds2.h + sp;
19452
19600
  bottom = Math.max(bottom, y - sp);
19453
19601
  }
19454
19602
  }
@@ -19515,9 +19663,9 @@ function pack(shapes, vertical, gap, end) {
19515
19663
  const across = (s) => vertical ? boundsOf(s.rects).w : boundsOf(s.rects).h;
19516
19664
  const thickness = Math.max(0, ...shapes.map(across));
19517
19665
  for (const shape of shapes) {
19518
- const bounds = boundsOf(shape.rects);
19666
+ const bounds2 = boundsOf(shape.rects);
19519
19667
  const crossShift = end ? thickness - across(shape) : 0;
19520
- let placed = vertical ? shiftShape(shape, crossShift - bounds.x, 0) : shiftShape(shape, 0, crossShift - bounds.y);
19668
+ let placed = vertical ? shiftShape(shape, crossShift - bounds2.x, 0) : shiftShape(shape, 0, crossShift - bounds2.y);
19521
19669
  if (rects.length > 0 && vertical) {
19522
19670
  const above = boundsOf(rects);
19523
19671
  placed = shiftShape(placed, 0, above.y + above.h + gap - boundsOf(placed.rects).y);
@@ -19654,21 +19802,21 @@ function fitContainers(node) {
19654
19802
  if (boxes.length === 0) {
19655
19803
  return void 0;
19656
19804
  }
19657
- const bounds = boundsOf(boxes);
19805
+ const bounds2 = boundsOf(boxes);
19658
19806
  if (HIER_ALGS.has(node.alg.type) && hasHierAncestor(node)) {
19659
- node.box = bounds;
19807
+ node.box = bounds2;
19660
19808
  }
19661
- return bounds;
19809
+ return bounds2;
19662
19810
  }
19663
19811
  function placeScaled(node, shape) {
19664
19812
  const box = node.box;
19665
- const bounds = boundsOf(shape.rects);
19666
- if (!box || !(bounds.w > 0) || !(bounds.h > 0)) {
19813
+ const bounds2 = boundsOf(shape.rects);
19814
+ if (!box || !(bounds2.w > 0) || !(bounds2.h > 0)) {
19667
19815
  return;
19668
19816
  }
19669
- const scale = Math.min(box.w / bounds.w, box.h / bounds.h);
19670
- const ox = box.x + (box.w - bounds.w * scale) / 2 - bounds.x * scale;
19671
- const oy = box.y + (box.h - bounds.h * scale) / 2 - bounds.y * scale;
19817
+ const scale = Math.min(box.w / bounds2.w, box.h / bounds2.h);
19818
+ const ox = box.x + (box.w - bounds2.w * scale) / 2 - bounds2.x * scale;
19819
+ const oy = box.y + (box.h - bounds2.h * scale) / 2 - bounds2.y * scale;
19672
19820
  for (const r of shape.rects) {
19673
19821
  r.node.box = { x: ox + r.x * scale, y: oy + r.y * scale, w: r.w * scale, h: r.h * scale };
19674
19822
  }
@@ -20465,20 +20613,20 @@ var UnionFind = class {
20465
20613
  }
20466
20614
  };
20467
20615
  function allNodes(entries) {
20468
- const roots = /* @__PURE__ */ new Set();
20616
+ const roots2 = /* @__PURE__ */ new Set();
20469
20617
  for (const { node } of entries) {
20470
20618
  let top = node;
20471
20619
  while (top.parent) {
20472
20620
  top = top.parent;
20473
20621
  }
20474
- roots.add(top);
20622
+ roots2.add(top);
20475
20623
  }
20476
20624
  const out = [];
20477
20625
  const visit = (n2) => {
20478
20626
  out.push(n2);
20479
20627
  n2.children.forEach(visit);
20480
20628
  };
20481
- roots.forEach(visit);
20629
+ roots2.forEach(visit);
20482
20630
  return out;
20483
20631
  }
20484
20632
  function buildLinks(entries) {
@@ -20557,8 +20705,8 @@ function resolveEngineFonts(entries, metrics) {
20557
20705
  const refSize = (ref) => previous.get(ref) ?? starts.get(ref);
20558
20706
  const sizes = /* @__PURE__ */ new Map();
20559
20707
  for (const entry3 of entries) {
20560
- const bounds = nodeFontBounds(entry3.node);
20561
- sizes.set(entry3.node, fitNodeFontPt(entry3.node, entry3.text, bounds, metrics, refSize));
20708
+ const bounds2 = nodeFontBounds(entry3.node);
20709
+ sizes.set(entry3.node, fitNodeFontPt(entry3.node, entry3.text, bounds2, metrics, refSize));
20562
20710
  }
20563
20711
  equalise(sizes, starts, groups, caps);
20564
20712
  resolved = sizes;
@@ -21341,11 +21489,11 @@ function ancestorsOf(node, parentOf) {
21341
21489
  }
21342
21490
  return out;
21343
21491
  }
21344
- function siblingGroupOf(node, parentOf, childrenOf, roots) {
21492
+ function siblingGroupOf(node, parentOf, childrenOf, roots2) {
21345
21493
  const parent = parentOf.get(node.id);
21346
- return parent ? childrenOf.get(parent.id) ?? [] : roots;
21494
+ return parent ? childrenOf.get(parent.id) ?? [] : roots2;
21347
21495
  }
21348
- function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots) {
21496
+ function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots2) {
21349
21497
  const out = [];
21350
21498
  const seen = /* @__PURE__ */ new Set();
21351
21499
  const add = (node) => {
@@ -21390,7 +21538,7 @@ function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots) {
21390
21538
  break;
21391
21539
  case "followSib":
21392
21540
  case "precedSib": {
21393
- const siblings = siblingGroupOf(node, parentOf, childrenOf, roots);
21541
+ const siblings = siblingGroupOf(node, parentOf, childrenOf, roots2);
21394
21542
  const index = siblings.findIndex((sibling) => sibling.id === node.id);
21395
21543
  addAll(axis === "followSib" ? siblings.slice(index + 1) : siblings.slice(0, index));
21396
21544
  break;
@@ -21468,30 +21616,30 @@ function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
21468
21616
  }
21469
21617
  }
21470
21618
  }
21471
- const roots = nodes.filter((n2) => !n2.parentId || !byId.has(n2.parentId));
21619
+ const roots2 = nodes.filter((n2) => !n2.parentId || !byId.has(n2.parentId));
21472
21620
  let current;
21473
21621
  let nextHop;
21474
21622
  if (axis[0] === "root" && axis.length > 1) {
21475
- current = applyPointTypeAndRange(roots, pointTypes?.[1], start?.[1], count?.[1]);
21623
+ current = applyPointTypeAndRange(roots2, pointTypes?.[1], start?.[1], count?.[1]);
21476
21624
  nextHop = 2;
21477
21625
  } else if (axis[0] === "root") {
21478
- current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
21626
+ current = applyPointTypeAndRange(roots2, pointTypes?.[0], start?.[0], count?.[0]);
21479
21627
  nextHop = 1;
21480
21628
  } else if (context !== void 0) {
21481
21629
  current = applyPointTypeAndRange(
21482
- navigateAxisHop(context, axis[0], nodes, childrenOf, parentOf, roots),
21630
+ navigateAxisHop(context, axis[0], nodes, childrenOf, parentOf, roots2),
21483
21631
  pointTypes?.[0],
21484
21632
  start?.[0],
21485
21633
  count?.[0]
21486
21634
  );
21487
21635
  nextHop = 1;
21488
21636
  } else {
21489
- current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
21637
+ current = applyPointTypeAndRange(roots2, pointTypes?.[0], start?.[0], count?.[0]);
21490
21638
  nextHop = 1;
21491
21639
  }
21492
21640
  for (let hop = nextHop; hop < axis.length; hop += 1) {
21493
21641
  current = applyPointTypeAndRange(
21494
- navigateAxisHop(current, axis[hop], nodes, childrenOf, parentOf, roots),
21642
+ navigateAxisHop(current, axis[hop], nodes, childrenOf, parentOf, roots2),
21495
21643
  pointTypes?.[hop],
21496
21644
  start?.[hop],
21497
21645
  count?.[hop]
@@ -22671,12 +22819,12 @@ function collectFollowSibNodeCounts(node) {
22671
22819
  function isChildOnlyAxis(iter) {
22672
22820
  return iter.axis?.length === 1 && iter.axis[0] === "ch";
22673
22821
  }
22674
- function selectArrangedNodes(node, flat, roots) {
22822
+ function selectArrangedNodes(node, flat, roots2) {
22675
22823
  const iterators = qualifyingIterators(node);
22676
22824
  if (iterators.length === 0) {
22677
- return roots && roots.length > 1 ? roots : flat;
22825
+ return roots2 && roots2.length > 1 ? roots2 : flat;
22678
22826
  }
22679
- const base = roots && roots.length > 0 && iterators.every(isChildOnlyAxis) ? roots : flat;
22827
+ const base = roots2 && roots2.length > 0 && iterators.every(isChildOnlyAxis) ? roots2 : flat;
22680
22828
  const indices = /* @__PURE__ */ new Set();
22681
22829
  for (const iter of iterators) {
22682
22830
  for (const i2 of resolveIteratorIndices(iter, base.length)) {
@@ -22709,16 +22857,16 @@ function buildForest(nodes) {
22709
22857
  for (const n2 of nodes) {
22710
22858
  map.set(n2.id, { node: n2, children: [] });
22711
22859
  }
22712
- const roots = [];
22860
+ const roots2 = [];
22713
22861
  for (const n2 of nodes) {
22714
22862
  const tn = map.get(n2.id);
22715
22863
  if (n2.parentId && map.has(n2.parentId)) {
22716
22864
  map.get(n2.parentId).children.push(tn);
22717
22865
  } else {
22718
- roots.push(tn);
22866
+ roots2.push(tn);
22719
22867
  }
22720
22868
  }
22721
- return roots;
22869
+ return roots2;
22722
22870
  }
22723
22871
  function buildTree(nodes) {
22724
22872
  const hasNestedChildren = nodes.some((n2) => n2.children !== void 0 && n2.children.length > 0);
@@ -22730,8 +22878,8 @@ function buildTree(nodes) {
22730
22878
  children: (n2.children ?? []).map(toTreeNode)
22731
22879
  });
22732
22880
  const allIds = new Set(nodes.map((n2) => n2.id));
22733
- const roots = nodes.filter((n2) => !n2.parentId || !allIds.has(n2.parentId));
22734
- return roots.map(toTreeNode);
22881
+ const roots2 = nodes.filter((n2) => !n2.parentId || !allIds.has(n2.parentId));
22882
+ return roots2.map(toTreeNode);
22735
22883
  }
22736
22884
  var MAX_TREE_DEPTH = 256;
22737
22885
  function treeWidth(t, depth = 0) {
@@ -22878,8 +23026,8 @@ function resolveRoleFontSize(roleNode, index, items, fontName) {
22878
23026
  void 0
22879
23027
  );
22880
23028
  }
22881
- function fitSharedFontSize(bounds, index, items, fontName, naturalAspect) {
22882
- const { ceilingPx, floorPx, role } = bounds;
23029
+ function fitSharedFontSize(bounds2, index, items, fontName, naturalAspect) {
23030
+ const { ceilingPx, floorPx, role } = bounds2;
22883
23031
  if (items.length === 0) {
22884
23032
  return snapToWholePoint(ceilingPx);
22885
23033
  }
@@ -24376,9 +24524,9 @@ function smartArtChildrenOf(nodes, connections) {
24376
24524
 
24377
24525
  // diagram/layout/smartart-layout-interpreter-arranged-selection.ts
24378
24526
  function selectArrangedPoints(view, plan, nodes, flat, connections) {
24379
- const roots = topLevelSmartArtNodes(nodes);
24527
+ const roots2 = topLevelSmartArtNodes(nodes);
24380
24528
  const childrenOf = smartArtChildrenOf(nodes, connections);
24381
- const preArranged = plan.kind === "composite" ? roots.length > 0 ? roots : flat : selectArrangedNodes(plan.node, flat, roots);
24529
+ const preArranged = plan.kind === "composite" ? roots2.length > 0 ? roots2 : flat : selectArrangedNodes(plan.node, flat, roots2);
24382
24530
  const hub = plan.kind === "composite" ? void 0 : detectHubExpansion(view, plan.node, preArranged, childrenOf);
24383
24531
  const arranged = hub ? applyChildOrder(hub.satellites, buildChildOrder(connections)) : preArranged;
24384
24532
  return { childrenOf, hub, arranged };
@@ -25013,10 +25161,10 @@ function arrangeRecursiveTable(view, plan, nodes, box, palette, style, elementId
25013
25161
  childIds.add(c2.id);
25014
25162
  }
25015
25163
  }
25016
- const roots = nodes.filter((n2) => !childIds.has(n2.id));
25164
+ const roots2 = nodes.filter((n2) => !childIds.has(n2.id));
25017
25165
  const depthOf2 = /* @__PURE__ */ new Map();
25018
25166
  let maxDepth2 = 0;
25019
- const depthStack = roots.map((r) => ({
25167
+ const depthStack = roots2.map((r) => ({
25020
25168
  node: r,
25021
25169
  depth: 0
25022
25170
  }));
@@ -25058,7 +25206,7 @@ function arrangeRecursiveTable(view, plan, nodes, box, palette, style, elementId
25058
25206
  place(child3, childX, childWidth);
25059
25207
  }
25060
25208
  };
25061
- for (const [root, rootX, rootWidth] of splitAcross(roots, 0, w)) {
25209
+ for (const [root, rootX, rootWidth] of splitAcross(roots2, 0, w)) {
25062
25210
  place(root, rootX, rootWidth);
25063
25211
  }
25064
25212
  const itemShape = findCompositeItemShape(plan.node);
@@ -27190,13 +27338,13 @@ function allChildrenHangForRoot(root, orgChart, perRow) {
27190
27338
  return r.deepestFanLevel === childLevel;
27191
27339
  });
27192
27340
  }
27193
- function computeHangShape(roots, orgChart, perRow) {
27341
+ function computeHangShape(roots2, orgChart, perRow) {
27194
27342
  let fannedGenerations = 1;
27195
27343
  let maxHangDepth = 0;
27196
27344
  let maxHangRows = 0;
27197
27345
  let allChildrenHang = false;
27198
27346
  let hangingColumns = 0;
27199
- for (const root of roots) {
27347
+ for (const root of roots2) {
27200
27348
  const r = walk2(root, 0, perRow, orgChart, void 0);
27201
27349
  fannedGenerations = Math.max(fannedGenerations, r.deepestFanLevel + 1);
27202
27350
  maxHangDepth = Math.max(maxHangDepth, r.maxHangDepth);
@@ -27229,9 +27377,9 @@ function widthWalk(t, level2, perRow, orgChart, siblingCount, map) {
27229
27377
  map.set(t, width);
27230
27378
  return width;
27231
27379
  }
27232
- function buildFanAwareWidthMap(roots, orgChart, perRow) {
27380
+ function buildFanAwareWidthMap(roots2, orgChart, perRow) {
27233
27381
  const map = /* @__PURE__ */ new Map();
27234
- for (const root of roots) {
27382
+ for (const root of roots2) {
27235
27383
  widthWalk(root, 0, perRow, orgChart, void 0, map);
27236
27384
  }
27237
27385
  return map;
@@ -27343,7 +27491,7 @@ function placeDescendantColumn(hc, node, edgeX, side, y, descW, descH, stackGapP
27343
27491
  }
27344
27492
  return nextY;
27345
27493
  }
27346
- function arrangeFannedHangingForest(view, nodes, box, palette, style, elementId, roots, itemShape, connectorLabels, algorithmNode, index, fontName, presLayoutVars, orgChart) {
27494
+ function arrangeFannedHangingForest(view, nodes, box, palette, style, elementId, roots2, itemShape, connectorLabels, algorithmNode, index, fontName, presLayoutVars, orgChart) {
27347
27495
  if (orgChart) {
27348
27496
  return void 0;
27349
27497
  }
@@ -27353,7 +27501,7 @@ function arrangeFannedHangingForest(view, nodes, box, palette, style, elementId,
27353
27501
  index,
27354
27502
  nodes.length,
27355
27503
  presLayoutVars,
27356
- roots.length,
27504
+ roots2.length,
27357
27505
  box
27358
27506
  );
27359
27507
  if (!geometry) {
@@ -27372,8 +27520,8 @@ function arrangeFannedHangingForest(view, nodes, box, palette, style, elementId,
27372
27520
  resolveHierarchyItemFontSizePx(nodes, algorithmNode, index, descW, descH, fontName)
27373
27521
  );
27374
27522
  const rootChildGap = ROOT_CHILD_GAP_RATIO * descH;
27375
- const branchCount = roots.length;
27376
- roots.forEach((root, i2) => {
27523
+ const branchCount = roots2.length;
27524
+ roots2.forEach((root, i2) => {
27377
27525
  const columnIndex = reversed ? branchCount - 1 - i2 : i2;
27378
27526
  const branchX = columnIndex * (rootW + gap);
27379
27527
  pushNode(hc, root.node, branchX, 0, rootW, rootH);
@@ -27446,9 +27594,9 @@ function placeHangingTree(hc, t, x, options, cursor, size, level2 = 0) {
27446
27594
  placeHangingTree(hc, child3, childX, options, cursor, void 0, level2 + 1);
27447
27595
  }
27448
27596
  }
27449
- function placeHangingForest(hc, roots, startX, startY, options, rootSize) {
27597
+ function placeHangingForest(hc, roots2, startX, startY, options, rootSize) {
27450
27598
  const cursor = { y: startY };
27451
- for (const root of roots) {
27599
+ for (const root of roots2) {
27452
27600
  placeHangingTree(hc, root, startX, options, cursor, rootSize);
27453
27601
  }
27454
27602
  }
@@ -27530,16 +27678,16 @@ function countRows(t, level2, orgChart, fold) {
27530
27678
  }
27531
27679
  return count;
27532
27680
  }
27533
- function countHangingRows(roots, orgChart, fold) {
27534
- return roots.reduce((sum, root) => sum + countRows(root, 0, orgChart, fold), 0);
27681
+ function countHangingRows(roots2, orgChart, fold) {
27682
+ return roots2.reduce((sum, root) => sum + countRows(root, 0, orgChart, fold), 0);
27535
27683
  }
27536
27684
 
27537
27685
  // diagram/hierarchy/smartart-hierarchy-hanging-arrange.ts
27538
27686
  var HANGING_MODE_INSET = 6;
27539
- function arrangeFullyHangingTree(view, nodes, box, palette, style, elementId, roots, itemShape, connectorLabels, algorithmNode, index, fontName, linDir, orgChart, presLayoutVars, cornerSide) {
27687
+ function arrangeFullyHangingTree(view, nodes, box, palette, style, elementId, roots2, itemShape, connectorLabels, algorithmNode, index, fontName, linDir, orgChart, presLayoutVars, cornerSide) {
27540
27688
  const { width: w, height: h2 } = box;
27541
27689
  const foldDeeperGenerations = algorithmNode ? hierarchyLeafFoldsDescendants(algorithmNode) : false;
27542
- const rows = countHangingRows(roots, orgChart, foldDeeperGenerations);
27690
+ const rows = countHangingRows(roots2, orgChart, foldDeeperGenerations);
27543
27691
  const fit2 = fitHangingBox(view, algorithmNode, index, w, h2, rows, nodes.length, presLayoutVars);
27544
27692
  const { boxW, boxH, vGap } = fit2;
27545
27693
  const indent = boxW * 0.35;
@@ -27562,7 +27710,7 @@ function arrangeFullyHangingTree(view, nodes, box, palette, style, elementId, ro
27562
27710
  } : void 0;
27563
27711
  placeHangingForest(
27564
27712
  hc,
27565
- roots,
27713
+ roots2,
27566
27714
  HANGING_MODE_INSET + indent,
27567
27715
  columnAlign ? 0 : HANGING_MODE_INSET,
27568
27716
  {
@@ -27585,8 +27733,8 @@ function arrangeFullyHangingTree(view, nodes, box, palette, style, elementId, ro
27585
27733
  }
27586
27734
 
27587
27735
  // diagram/hierarchy/smartart-hierarchy-hang-dispatch.ts
27588
- function dispatchHangingMode(view, nodes, box, palette, style, elementId, roots, itemShape, connectorLabels, algorithmNode, index, fontName, presLayoutVars, orgChart, cornerPlan) {
27589
- if (roots.length > 1) {
27736
+ function dispatchHangingMode(view, nodes, box, palette, style, elementId, roots2, itemShape, connectorLabels, algorithmNode, index, fontName, presLayoutVars, orgChart, cornerPlan) {
27737
+ if (roots2.length > 1) {
27590
27738
  const fanned = arrangeFannedHangingForest(
27591
27739
  view,
27592
27740
  nodes,
@@ -27594,7 +27742,7 @@ function dispatchHangingMode(view, nodes, box, palette, style, elementId, roots,
27594
27742
  palette,
27595
27743
  style,
27596
27744
  elementId,
27597
- roots,
27745
+ roots2,
27598
27746
  itemShape,
27599
27747
  connectorLabels,
27600
27748
  algorithmNode,
@@ -27614,7 +27762,7 @@ function dispatchHangingMode(view, nodes, box, palette, style, elementId, roots,
27614
27762
  palette,
27615
27763
  style,
27616
27764
  elementId,
27617
- roots,
27765
+ roots2,
27618
27766
  itemShape,
27619
27767
  connectorLabels,
27620
27768
  algorithmNode,
@@ -28393,7 +28541,7 @@ function arrangeHierarchy(view, nodes, box, palette, style, elementId, presLayou
28393
28541
  const { width: w, height: h2 } = box;
28394
28542
  const orgChart = presLayoutVars?.orgChart === true;
28395
28543
  const orderedNodes = applyChildOrder(nodes, childOrder);
28396
- const roots = buildTree(flattenOrgChartGroupWrappers(orderedNodes, orgChart));
28544
+ const roots2 = buildTree(flattenOrgChartGroupWrappers(orderedNodes, orgChart));
28397
28545
  const cornerPlan = resolveCornerHangPlan(
28398
28546
  view,
28399
28547
  algorithmNode,
@@ -28411,7 +28559,7 @@ function arrangeHierarchy(view, nodes, box, palette, style, elementId, presLayou
28411
28559
  palette,
28412
28560
  style,
28413
28561
  elementId,
28414
- roots,
28562
+ roots2,
28415
28563
  itemShape,
28416
28564
  connectorLabels,
28417
28565
  algorithmNode,
@@ -28431,14 +28579,14 @@ function arrangeHierarchy(view, nodes, box, palette, style, elementId, presLayou
28431
28579
  presLayoutVars,
28432
28580
  box
28433
28581
  );
28434
- const rawDepth = roots.length > 0 ? Math.max(...roots.map((r) => treeDepth(r))) : 1;
28582
+ const rawDepth = roots2.length > 0 ? Math.max(...roots2.map((r) => treeDepth(r))) : 1;
28435
28583
  const rowSize = resolveRowSize(presLayoutVars);
28436
28584
  const noHang = { maxHangDepth: 0, maxHangRows: 0, allChildrenHang: false, hangingColumns: 0 };
28437
- const hangShape = mode === "tailed" ? computeHangShape(roots, orgChart, rowSize) : { fannedGenerations: rawDepth, ...noHang };
28585
+ const hangShape = mode === "tailed" ? computeHangShape(roots2, orgChart, rowSize) : { fannedGenerations: rawDepth, ...noHang };
28438
28586
  const depth = hangShape.fannedGenerations;
28439
- const fanAwareWidthMap = mode === "tailed" ? buildFanAwareWidthMap(roots, orgChart, rowSize) : void 0;
28587
+ const fanAwareWidthMap = mode === "tailed" ? buildFanAwareWidthMap(roots2, orgChart, rowSize) : void 0;
28440
28588
  const spanOfRoot = (r) => resolveSpanWidth(fanAwareWidthMap, r, orgChart);
28441
- const totalLeaves = roots.reduce((sum, r) => sum + spanOfRoot(r), 0);
28589
+ const totalLeaves = roots2.reduce((sum, r) => sum + spanOfRoot(r), 0);
28442
28590
  const { boxW, boxH } = fitItemBox(
28443
28591
  effectiveBox,
28444
28592
  totalLeaves,
@@ -28505,7 +28653,7 @@ function arrangeHierarchy(view, nodes, box, palette, style, elementId, presLayou
28505
28653
  orgChart
28506
28654
  );
28507
28655
  let offset = 0;
28508
- for (const root of roots) {
28656
+ for (const root of roots2) {
28509
28657
  placeStandardTree(hc, root, offset, 0, cellW, cellH, standardOptions);
28510
28658
  offset += spanOfRoot(root);
28511
28659
  }
@@ -32900,6 +33048,7 @@ __export(geometry_exports, {
32900
33048
  FLOWCHART_PRESET_DEFINITIONS: () => FLOWCHART_PRESET_DEFINITIONS,
32901
33049
  FLOWCHART_TEXT_RECTS: () => FLOWCHART_TEXT_RECTS,
32902
33050
  GEAR9_CONNECTION_SITES: () => GEAR9_CONNECTION_SITES,
33051
+ GRAPH_LAYOUT_STYLES: () => GRAPH_LAYOUT_STYLES,
32903
33052
  IDENTITY_AFFINE: () => IDENTITY_AFFINE,
32904
33053
  LEFT_CIRCULAR_ARROW_CONNECTION_SITES: () => LEFT_CIRCULAR_ARROW_CONNECTION_SITES,
32905
33054
  LEFT_RIGHT_CIRCULAR_ARROW_CONNECTION_SITES: () => LEFT_RIGHT_CIRCULAR_ARROW_CONNECTION_SITES,
@@ -32936,6 +33085,7 @@ __export(geometry_exports, {
32936
33085
  alignElements: () => alignElements,
32937
33086
  angleToRadians: () => angleToRadians,
32938
33087
  at: () => at,
33088
+ autoAlignBoxes: () => autoAlignBoxes,
32939
33089
  buildCalloutLeaderLineSvgPath: () => buildCalloutLeaderLineSvgPath,
32940
33090
  clipPolygons: () => clipPolygons,
32941
33091
  combineShapes: () => combineShapes,
@@ -32985,6 +33135,7 @@ __export(geometry_exports, {
32985
33135
  isConvex: () => isConvex,
32986
33136
  isHorizontalPrimaryAxis: () => isHorizontalPrimaryAxis,
32987
33137
  isStShapeType: () => isStShapeType,
33138
+ layoutGraph: () => layoutGraph,
32988
33139
  lineIntersection: () => lineIntersection,
32989
33140
  lookupPresetConnectionSites: () => lookupPresetConnectionSites,
32990
33141
  lookupPresetTextRectOverride: () => lookupPresetTextRectOverride,
@@ -39227,11 +39378,11 @@ function createRotationDrag(center, startPointer, startRotation, options = {}) {
39227
39378
 
39228
39379
  // geometry/rotate-handle-placement.ts
39229
39380
  function resolveRotateHandlePlacement(input) {
39230
- const { preferred, selection, bounds, hitWidth, hitHeight, obstacles } = input;
39381
+ const { preferred, selection, bounds: bounds2, hitWidth, hitHeight, obstacles } = input;
39231
39382
  if (![
39232
39383
  ...Object.values(preferred),
39233
39384
  ...Object.values(selection),
39234
- ...Object.values(bounds),
39385
+ ...Object.values(bounds2),
39235
39386
  hitWidth,
39236
39387
  hitHeight
39237
39388
  ].every(Number.isFinite) || hitWidth <= 0 || hitHeight <= 0) {
@@ -39245,7 +39396,7 @@ function resolveRotateHandlePlacement(input) {
39245
39396
  };
39246
39397
  const fits3 = ({ x, y }) => {
39247
39398
  const rect3 = { left: x - halfX, right: x + halfX, top: y - halfY, bottom: y + halfY };
39248
- return rect3.left >= bounds.left + 1 && rect3.right <= bounds.right - 1 && rect3.top >= bounds.top + 1 && rect3.bottom <= bounds.bottom - 1 && // A target over the rotation center has no usable initial bearing.
39399
+ return rect3.left >= bounds2.left + 1 && rect3.right <= bounds2.right - 1 && rect3.top >= bounds2.top + 1 && rect3.bottom <= bounds2.bottom - 1 && // A target over the rotation center has no usable initial bearing.
39249
39400
  !(center.x >= rect3.left && center.x <= rect3.right && center.y >= rect3.top && center.y <= rect3.bottom) && !obstacles.some(
39250
39401
  (other) => rect3.left < other.right + 2 && rect3.right > other.left - 2 && rect3.top < other.bottom + 2 && rect3.bottom > other.top - 2
39251
39402
  );
@@ -39273,10 +39424,10 @@ function resolveRotateHandlePlacement(input) {
39273
39424
  { x: center.x, y: selection.bottom + padY },
39274
39425
  { x: selection.left - padX, y: center.y }
39275
39426
  ];
39276
- const left = Math.max(selection.left, bounds.left) + halfX + 3;
39277
- const right = Math.min(selection.right, bounds.right) - halfX - 3;
39278
- const top = Math.max(selection.top, bounds.top) + halfY + 3;
39279
- const bottom = Math.min(selection.bottom, bounds.bottom) - halfY - 3;
39427
+ const left = Math.max(selection.left, bounds2.left) + halfX + 3;
39428
+ const right = Math.min(selection.right, bounds2.right) - halfX - 3;
39429
+ const top = Math.max(selection.top, bounds2.top) + halfY + 3;
39430
+ const bottom = Math.min(selection.bottom, bounds2.bottom) - halfY - 3;
39280
39431
  if (left <= right && top <= bottom) {
39281
39432
  for (const fraction of [0.25, 0.75]) {
39282
39433
  const x = left + (right - left) * fraction;
@@ -39290,6 +39441,357 @@ function resolveRotateHandlePlacement(input) {
39290
39441
  })[0] ?? null;
39291
39442
  }
39292
39443
 
39444
+ // geometry/graph-layout.ts
39445
+ var GRAPH_LAYOUT_STYLES = [
39446
+ "flowchart-tb",
39447
+ "flowchart-lr",
39448
+ "hierarchy",
39449
+ "compact-tree",
39450
+ "circular"
39451
+ ];
39452
+ function components(graph) {
39453
+ const seen = /* @__PURE__ */ new Set();
39454
+ const connected = [];
39455
+ const isolated = [];
39456
+ for (const node of graph.nodes) {
39457
+ if (seen.has(node.id)) continue;
39458
+ const ids = [];
39459
+ const stack = [node.id];
39460
+ seen.add(node.id);
39461
+ while (stack.length) {
39462
+ const id = stack.pop();
39463
+ ids.push(id);
39464
+ for (const next of [...graph.out.get(id), ...graph.into.get(id)])
39465
+ if (!seen.has(next)) {
39466
+ seen.add(next);
39467
+ stack.push(next);
39468
+ }
39469
+ }
39470
+ if (ids.length === 1) isolated.push(node.id);
39471
+ else {
39472
+ const order = new Map(graph.nodes.map((entry3, index) => [entry3.id, index]));
39473
+ connected.push(ids.sort((a2, b) => order.get(a2) - order.get(b)));
39474
+ }
39475
+ }
39476
+ return { connected, isolated };
39477
+ }
39478
+ function roots(ids, graph) {
39479
+ const found = ids.filter((id) => !graph.into.get(id).some((from) => ids.includes(from)));
39480
+ return found.length ? found : [ids[0]];
39481
+ }
39482
+ function forwardEdges(ids, graph) {
39483
+ const state = /* @__PURE__ */ new Map();
39484
+ const forward = new Map(ids.map((id) => [id, []]));
39485
+ const visit = (start) => {
39486
+ const stack = [{ id: start, next: 0 }];
39487
+ state.set(start, 1);
39488
+ while (stack.length) {
39489
+ const top = stack.at(-1);
39490
+ const targets = graph.out.get(top.id);
39491
+ if (top.next >= targets.length) {
39492
+ state.set(top.id, 2);
39493
+ stack.pop();
39494
+ continue;
39495
+ }
39496
+ const target = targets[top.next++];
39497
+ const mark = state.get(target);
39498
+ if (mark === 1) continue;
39499
+ forward.get(top.id).push(target);
39500
+ if (mark === void 0) {
39501
+ state.set(target, 1);
39502
+ stack.push({ id: target, next: 0 });
39503
+ }
39504
+ }
39505
+ };
39506
+ for (const root of roots(ids, graph)) if (!state.has(root)) visit(root);
39507
+ for (const id of ids) if (!state.has(id)) visit(id);
39508
+ return forward;
39509
+ }
39510
+ function layers(ids, forward, shortest) {
39511
+ const rank = /* @__PURE__ */ new Map();
39512
+ const incoming = new Map(ids.map((id) => [id, 0]));
39513
+ for (const targets of forward.values())
39514
+ for (const target of targets) incoming.set(target, incoming.get(target) + 1);
39515
+ const queue = ids.filter((id) => incoming.get(id) === 0);
39516
+ for (const id of queue) rank.set(id, 0);
39517
+ for (let index = 0; index < queue.length; index++) {
39518
+ const id = queue[index];
39519
+ for (const target of forward.get(id)) {
39520
+ const candidate = rank.get(id) + 1;
39521
+ if (shortest) {
39522
+ if (!rank.has(target)) rank.set(target, candidate);
39523
+ } else rank.set(target, Math.max(rank.get(target) ?? 0, candidate));
39524
+ incoming.set(target, incoming.get(target) - 1);
39525
+ if (incoming.get(target) === 0) queue.push(target);
39526
+ }
39527
+ }
39528
+ const result = [];
39529
+ for (const id of ids) {
39530
+ const level2 = rank.get(id) ?? 0;
39531
+ (result[level2] ??= []).push(id);
39532
+ }
39533
+ return result.filter((layer) => layer.length);
39534
+ }
39535
+ function orderLayers(layered, graph) {
39536
+ const result = layered.map((layer) => [...layer]);
39537
+ const position = /* @__PURE__ */ new Map();
39538
+ const index = () => result.forEach((layer) => layer.forEach((id, at2) => position.set(id, at2)));
39539
+ index();
39540
+ for (let sweep = 0; sweep < 4; sweep++) {
39541
+ const down = sweep % 2 === 0;
39542
+ const range = down ? result.map((_, at2) => at2).slice(1) : result.map((_, at2) => at2).slice(0, -1).reverse();
39543
+ for (const at2 of range) {
39544
+ const neighbour = new Set(result[down ? at2 - 1 : at2 + 1]);
39545
+ const weight = (id) => {
39546
+ const linked = [...graph.out.get(id), ...graph.into.get(id)].filter(
39547
+ (other) => neighbour.has(other)
39548
+ );
39549
+ return linked.length ? linked.reduce((sum, other) => sum + position.get(other), 0) / linked.length : position.get(id);
39550
+ };
39551
+ const weights = new Map(result[at2].map((id) => [id, weight(id)]));
39552
+ result[at2].sort(
39553
+ (a2, b) => weights.get(a2) - weights.get(b) || position.get(a2) - position.get(b)
39554
+ );
39555
+ index();
39556
+ }
39557
+ }
39558
+ return result;
39559
+ }
39560
+ function placeLayers(ordered2, size, horizontal, spacing3, layerSpacing) {
39561
+ const placed = [];
39562
+ const along = (node) => horizontal ? node.width : node.height;
39563
+ const across = (node) => horizontal ? node.height : node.width;
39564
+ let cursor = 0;
39565
+ for (const layer of ordered2) {
39566
+ const nodes = layer.map((id) => size.get(id));
39567
+ const depth = Math.max(...nodes.map(along));
39568
+ const span = nodes.reduce((sum, node) => sum + across(node), 0) + spacing3 * (nodes.length - 1);
39569
+ let offset = -span / 2;
39570
+ for (const node of nodes) {
39571
+ const centre = offset + across(node) / 2;
39572
+ const primary = cursor + depth / 2;
39573
+ placed.push({
39574
+ id: node.id,
39575
+ x: horizontal ? primary : centre,
39576
+ y: horizontal ? centre : primary,
39577
+ width: node.width,
39578
+ height: node.height
39579
+ });
39580
+ offset += across(node) + spacing3;
39581
+ }
39582
+ cursor += depth + layerSpacing;
39583
+ }
39584
+ return placed;
39585
+ }
39586
+ function placeCompactTree(ids, forward, graph, size, spacing3, layerSpacing) {
39587
+ const placed = [];
39588
+ const seen = /* @__PURE__ */ new Set();
39589
+ const indent = Math.max(...ids.map((id) => size.get(id).width)) / 2 + layerSpacing / 2;
39590
+ let y = 0;
39591
+ const visit = (start) => {
39592
+ const stack = [{ id: start, depth: 0 }];
39593
+ while (stack.length) {
39594
+ const { id, depth } = stack.pop();
39595
+ if (seen.has(id)) continue;
39596
+ seen.add(id);
39597
+ const node = size.get(id);
39598
+ placed.push({
39599
+ id,
39600
+ x: depth * indent + node.width / 2,
39601
+ y: y + node.height / 2,
39602
+ width: node.width,
39603
+ height: node.height
39604
+ });
39605
+ y += node.height + spacing3;
39606
+ const children2 = forward.get(id).filter((child3) => !seen.has(child3));
39607
+ for (const child3 of children2.reverse()) stack.push({ id: child3, depth: depth + 1 });
39608
+ }
39609
+ };
39610
+ for (const root of roots(ids, graph)) visit(root);
39611
+ for (const id of ids) visit(id);
39612
+ return placed;
39613
+ }
39614
+ function placeCircle(ids, forward, size, spacing3) {
39615
+ const order = [];
39616
+ const seen = /* @__PURE__ */ new Set();
39617
+ for (const start of ids) {
39618
+ const stack = [start];
39619
+ while (stack.length) {
39620
+ const id = stack.pop();
39621
+ if (seen.has(id)) continue;
39622
+ seen.add(id);
39623
+ order.push(id);
39624
+ stack.push(...[...forward.get(id)].reverse());
39625
+ }
39626
+ }
39627
+ const extent = (id) => Math.hypot(size.get(id).width, size.get(id).height);
39628
+ const circumference = order.reduce((sum, id) => sum + extent(id) + spacing3, 0);
39629
+ const radius = Math.max(circumference / (2 * Math.PI), Math.max(...order.map(extent)));
39630
+ return order.map((id, index) => {
39631
+ const angle = -Math.PI / 2 + 2 * Math.PI * index / order.length;
39632
+ const node = size.get(id);
39633
+ return {
39634
+ id,
39635
+ x: radius * Math.cos(angle),
39636
+ y: radius * Math.sin(angle),
39637
+ width: node.width,
39638
+ height: node.height
39639
+ };
39640
+ });
39641
+ }
39642
+ function bounds(placed) {
39643
+ const left = Math.min(...placed.map((box) => box.x - box.width / 2));
39644
+ const top = Math.min(...placed.map((box) => box.y - box.height / 2));
39645
+ const right = Math.max(...placed.map((box) => box.x + box.width / 2));
39646
+ const bottom = Math.max(...placed.map((box) => box.y + box.height / 2));
39647
+ return { left, top, width: right - left, height: bottom - top };
39648
+ }
39649
+ function placeGrid(ids, size, spacing3) {
39650
+ const columns = Math.ceil(Math.sqrt(ids.length));
39651
+ const cellWidth = Math.max(...ids.map((id) => size.get(id).width));
39652
+ const cellHeight = Math.max(...ids.map((id) => size.get(id).height));
39653
+ return ids.map((id, index) => ({
39654
+ id,
39655
+ x: index % columns * (cellWidth + spacing3) + cellWidth / 2,
39656
+ y: Math.floor(index / columns) * (cellHeight + spacing3) + cellHeight / 2,
39657
+ width: size.get(id).width,
39658
+ height: size.get(id).height
39659
+ }));
39660
+ }
39661
+ function layoutGraph(nodes, edges, style, options = {}) {
39662
+ if (!GRAPH_LAYOUT_STYLES.includes(style)) throw new Error("Unknown graph layout style.");
39663
+ const spacing3 = options.spacing ?? 0.5;
39664
+ const layerSpacing = options.layerSpacing ?? spacing3;
39665
+ if (![spacing3, layerSpacing].every((value) => Number.isFinite(value) && value >= 0))
39666
+ throw new Error("Layout spacing must be finite and not negative.");
39667
+ const size = /* @__PURE__ */ new Map();
39668
+ for (const node of nodes) {
39669
+ if (size.has(node.id)) throw new Error("Layout node IDs must be unique.");
39670
+ if (![node.width, node.height].every((value) => Number.isFinite(value) && value >= 0))
39671
+ throw new Error("Layout node sizes must be finite and not negative.");
39672
+ size.set(node.id, node);
39673
+ }
39674
+ const graph = {
39675
+ nodes,
39676
+ out: new Map(nodes.map((node) => [node.id, []])),
39677
+ into: new Map(nodes.map((node) => [node.id, []]))
39678
+ };
39679
+ for (const edge of edges) {
39680
+ if (!size.has(edge.from) || !size.has(edge.to) || edge.from === edge.to) continue;
39681
+ if (graph.out.get(edge.from).includes(edge.to)) continue;
39682
+ graph.out.get(edge.from).push(edge.to);
39683
+ graph.into.get(edge.to).push(edge.from);
39684
+ }
39685
+ const { connected, isolated } = components(graph);
39686
+ const horizontal = style === "flowchart-lr";
39687
+ const blocks = connected.map((ids) => {
39688
+ const forward = forwardEdges(ids, graph);
39689
+ if (style === "circular") return placeCircle(ids, forward, size, spacing3);
39690
+ if (style === "compact-tree")
39691
+ return placeCompactTree(ids, forward, graph, size, spacing3, layerSpacing);
39692
+ const ordered2 = orderLayers(layers(ids, forward, style === "hierarchy"), graph);
39693
+ return placeLayers(ordered2, size, horizontal, spacing3, layerSpacing);
39694
+ });
39695
+ const result = /* @__PURE__ */ new Map();
39696
+ let cursor = 0;
39697
+ let extent = 0;
39698
+ for (const block of blocks) {
39699
+ const box = bounds(block);
39700
+ for (const item of block)
39701
+ result.set(item.id, {
39702
+ x: item.x - box.left + (horizontal ? 0 : cursor),
39703
+ y: item.y - box.top + (horizontal ? cursor : 0)
39704
+ });
39705
+ cursor += (horizontal ? box.height : box.width) + spacing3 * 2;
39706
+ extent = Math.max(extent, horizontal ? box.width : box.height);
39707
+ }
39708
+ if (isolated.length) {
39709
+ const grid = placeGrid(isolated, size, spacing3);
39710
+ const offset = blocks.length ? extent + layerSpacing * 2 : 0;
39711
+ for (const item of grid)
39712
+ result.set(item.id, {
39713
+ x: item.x + (horizontal ? offset : 0),
39714
+ y: item.y + (horizontal ? 0 : offset)
39715
+ });
39716
+ }
39717
+ return result;
39718
+ }
39719
+
39720
+ // geometry/auto-align.ts
39721
+ var median = (values) => {
39722
+ const sorted = [...values].sort((a2, b) => a2 - b);
39723
+ const middle = Math.floor(sorted.length / 2);
39724
+ return sorted.length % 2 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
39725
+ };
39726
+ function clusters(boxes, centre, tolerance) {
39727
+ const sorted = [...boxes].sort((a2, b) => centre(a2) - centre(b));
39728
+ const result = [];
39729
+ let mean = 0;
39730
+ for (const box of sorted) {
39731
+ const current = result.at(-1);
39732
+ if (current && Math.abs(centre(box) - mean) <= tolerance) {
39733
+ current.push(box);
39734
+ mean += (centre(box) - mean) / current.length;
39735
+ } else {
39736
+ result.push([box]);
39737
+ mean = centre(box);
39738
+ }
39739
+ }
39740
+ return result;
39741
+ }
39742
+ function space2(groups, start, size, minimumGap) {
39743
+ const extents = groups.map((group) => {
39744
+ const centre = group.reduce((sum, box) => sum + start(box) + size(box) / 2, 0) / group.length;
39745
+ const half = Math.max(...group.map((box) => size(box) / 2));
39746
+ return { centre, half };
39747
+ });
39748
+ const gaps = extents.slice(1).map(
39749
+ (extent, index) => extent.centre - extent.half - extents[index].centre - extents[index].half
39750
+ );
39751
+ const gap = Math.max(
39752
+ minimumGap,
39753
+ gaps.length ? gaps.reduce((sum, value) => sum + value, 0) / gaps.length : 0
39754
+ );
39755
+ const result = /* @__PURE__ */ new Map();
39756
+ let cursor = extents[0] ? extents[0].centre - extents[0].half : 0;
39757
+ groups.forEach((group, index) => {
39758
+ const { half } = extents[index];
39759
+ for (const box of group) result.set(box.id, cursor + half);
39760
+ cursor += half * 2 + gap;
39761
+ });
39762
+ return result;
39763
+ }
39764
+ function autoAlignBoxes(boxes, options = {}) {
39765
+ if (new Set(boxes.map((box) => box.id)).size !== boxes.length)
39766
+ throw new Error("Auto align box IDs must be unique.");
39767
+ if (!boxes.every(
39768
+ (box) => [box.x, box.y, box.width, box.height].every((value) => Number.isFinite(value))
39769
+ ))
39770
+ throw new Error("Auto align boxes must be finite.");
39771
+ const result = /* @__PURE__ */ new Map();
39772
+ if (!boxes.length) return result;
39773
+ const toleranceX = options.tolerance?.x ?? median(boxes.map((box) => box.width)) / 2;
39774
+ const toleranceY = options.tolerance?.y ?? median(boxes.map((box) => box.height)) / 2;
39775
+ const minimumGap = options.minimumGap ?? 0;
39776
+ const rows = clusters(boxes, (box) => box.y + box.height / 2, toleranceY);
39777
+ const columns = clusters(boxes, (box) => box.x + box.width / 2, toleranceX);
39778
+ const ys = space2(
39779
+ rows,
39780
+ (box) => box.y,
39781
+ (box) => box.height,
39782
+ minimumGap
39783
+ );
39784
+ const xs = space2(
39785
+ columns,
39786
+ (box) => box.x,
39787
+ (box) => box.width,
39788
+ minimumGap
39789
+ );
39790
+ for (const box of boxes)
39791
+ result.set(box.id, { x: xs.get(box.id) - box.width / 2, y: ys.get(box.id) - box.height / 2 });
39792
+ return result;
39793
+ }
39794
+
39293
39795
  // units/index.ts
39294
39796
  var units_exports = {};
39295
39797
  __export(units_exports, {
@@ -40634,9 +41136,9 @@ function convertOmmlToLatex(omml) {
40634
41136
  return "";
40635
41137
  }
40636
41138
  const para = omml["m:oMathPara"];
40637
- const roots = para ? ensureArr(para).flatMap((p) => ensureArr(p["m:oMath"])) : [];
40638
- if (roots.length > 0) {
40639
- return roots.map((root) => childrenToLatex(root)).join(" ");
41139
+ const roots2 = para ? ensureArr(para).flatMap((p) => ensureArr(p["m:oMath"])) : [];
41140
+ if (roots2.length > 0) {
41141
+ return roots2.map((root) => childrenToLatex(root)).join(" ");
40640
41142
  }
40641
41143
  if (omml["m:oMath"]) {
40642
41144
  return ensureArr(omml["m:oMath"]).map((root) => childrenToLatex(root)).join(" ");