ooxml-core 1.20.0 → 1.21.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 (334) hide show
  1. package/README.md +35 -0
  2. package/dist/{PptxHandler-TEKISCJO.cjs → PptxHandler-DNSXWTQV.cjs} +3 -3
  3. package/dist/{PptxHandler-FYD7IYXT.mjs → PptxHandler-FSKKPZZC.mjs} +3 -3
  4. package/dist/PptxHandler-H7MEWJJJ.mjs +4 -0
  5. package/dist/{PresentationBuilder-IMB4DVRN.mjs → PresentationBuilder-7TSENZTX.mjs} +2 -2
  6. package/dist/{PresentationBuilder-NCKASKXU.cjs → PresentationBuilder-A5NI35VN.cjs} +5 -5
  7. package/dist/{PresentationBuilder-EYI6Z2JP.mjs → PresentationBuilder-RIJWQSEU.mjs} +3 -3
  8. package/dist/automation/docx-forms.d.ts +26 -0
  9. package/dist/automation/docx-forms.d.ts.map +1 -0
  10. package/dist/automation/index.cjs +6084 -2537
  11. package/dist/automation/index.d.ts +1 -0
  12. package/dist/automation/index.d.ts.map +1 -1
  13. package/dist/automation/index.mjs +6083 -2538
  14. package/dist/chart/axis-range.d.ts.map +1 -1
  15. package/dist/chart/bubble-radius.d.ts +0 -5
  16. package/dist/chart/bubble-radius.d.ts.map +1 -1
  17. package/dist/chart/extent.d.ts +9 -0
  18. package/dist/chart/extent.d.ts.map +1 -0
  19. package/dist/chart/histogram-binning.d.ts.map +1 -1
  20. package/dist/chart/index.cjs +56 -18
  21. package/dist/chart/index.mjs +56 -18
  22. package/dist/chart/render/chart-svg-cartesian.d.ts.map +1 -1
  23. package/dist/chart/render/chart-svg-legend.d.ts.map +1 -1
  24. package/dist/chart/render/chart-view-ex.d.ts.map +1 -1
  25. package/dist/chart/render/chart-view.d.ts.map +1 -1
  26. package/dist/chart/trendline-fit.d.ts.map +1 -1
  27. package/dist/{chunk-3IENHIFD.cjs → chunk-4LZIUJI3.cjs} +52 -12
  28. package/dist/{chunk-LEV2SVMK.mjs → chunk-4QPOJCJG.mjs} +45 -8
  29. package/dist/{chunk-CC5UNZOO.mjs → chunk-6IIMI5RS.mjs} +52 -12
  30. package/dist/{chunk-MN27HKHM.mjs → chunk-BA7Z6ATM.mjs} +5 -5
  31. package/dist/{chunk-LVM3IZJ2.mjs → chunk-DLFMCZZT.mjs} +1 -1
  32. package/dist/{chunk-M4XLF4R7.mjs → chunk-GBKBR4CX.mjs} +20 -8
  33. package/dist/{chunk-NXKATFM5.cjs → chunk-HL3FBJ6X.cjs} +1065 -1016
  34. package/dist/{chunk-WXY5EDGT.mjs → chunk-LF5E5ZOH.mjs} +51 -2
  35. package/dist/{chunk-MNXKRXFB.mjs → chunk-Q5PKBQXH.mjs} +52 -3
  36. package/dist/{chunk-GQYQQ3GA.mjs → chunk-VQF6HQEE.mjs} +1 -1
  37. package/dist/collab/embedding.d.ts +103 -0
  38. package/dist/collab/embedding.d.ts.map +1 -0
  39. package/dist/collab/index.cjs +450 -342
  40. package/dist/collab/index.d.ts +1 -0
  41. package/dist/collab/index.d.ts.map +1 -1
  42. package/dist/collab/index.mjs +443 -343
  43. package/dist/color/theme-palette.d.ts +5 -1
  44. package/dist/color/theme-palette.d.ts.map +1 -1
  45. package/dist/crypto/index.cjs +27 -2
  46. package/dist/crypto/index.mjs +27 -2
  47. package/dist/diagram/index.cjs +31 -3
  48. package/dist/diagram/index.mjs +31 -3
  49. package/dist/docx/block-parser.d.ts.map +1 -1
  50. package/dist/docx/cell-blocks.d.ts +7 -1
  51. package/dist/docx/cell-blocks.d.ts.map +1 -1
  52. package/dist/docx/content-control-edit.d.ts +14 -0
  53. package/dist/docx/content-control-edit.d.ts.map +1 -1
  54. package/dist/docx/content-control-model.d.ts +8 -0
  55. package/dist/docx/content-control-model.d.ts.map +1 -1
  56. package/dist/docx/content-control-values.d.ts +20 -0
  57. package/dist/docx/content-control-values.d.ts.map +1 -0
  58. package/dist/docx/content-control.d.ts +7 -1
  59. package/dist/docx/content-control.d.ts.map +1 -1
  60. package/dist/docx/element-order.d.ts +10 -5
  61. package/dist/docx/element-order.d.ts.map +1 -1
  62. package/dist/docx/embedded.cjs +3861 -1379
  63. package/dist/docx/embedded.mjs +3861 -1379
  64. package/dist/docx/field-instruction.d.ts +22 -0
  65. package/dist/docx/field-instruction.d.ts.map +1 -0
  66. package/dist/docx/form-field-model.d.ts +48 -0
  67. package/dist/docx/form-field-model.d.ts.map +1 -0
  68. package/dist/docx/form-fields.d.ts +31 -0
  69. package/dist/docx/form-fields.d.ts.map +1 -0
  70. package/dist/docx/form-fill-fields.d.ts +61 -0
  71. package/dist/docx/form-fill-fields.d.ts.map +1 -0
  72. package/dist/docx/form-fill-labels.d.ts +8 -0
  73. package/dist/docx/form-fill-labels.d.ts.map +1 -0
  74. package/dist/docx/form-fill-sites.d.ts +59 -0
  75. package/dist/docx/form-fill-sites.d.ts.map +1 -0
  76. package/dist/docx/form-fill-values.d.ts +28 -0
  77. package/dist/docx/form-fill-values.d.ts.map +1 -0
  78. package/dist/docx/form-fill-write.d.ts +26 -0
  79. package/dist/docx/form-fill-write.d.ts.map +1 -0
  80. package/dist/docx/glossary.d.ts +15 -0
  81. package/dist/docx/glossary.d.ts.map +1 -0
  82. package/dist/docx/index.cjs +5929 -3153
  83. package/dist/docx/index.d.ts +7 -0
  84. package/dist/docx/index.d.ts.map +1 -1
  85. package/dist/docx/index.mjs +5913 -3154
  86. package/dist/docx/inline-annotations.d.ts +21 -0
  87. package/dist/docx/inline-annotations.d.ts.map +1 -0
  88. package/dist/docx/inline-container-markers.d.ts +14 -0
  89. package/dist/docx/inline-container-markers.d.ts.map +1 -0
  90. package/dist/docx/inline-containers.d.ts +54 -0
  91. package/dist/docx/inline-containers.d.ts.map +1 -0
  92. package/dist/docx/inline-form-field-bookmarks.d.ts +15 -0
  93. package/dist/docx/inline-form-field-bookmarks.d.ts.map +1 -0
  94. package/dist/docx/inline-marker-positions.d.ts +15 -0
  95. package/dist/docx/inline-marker-positions.d.ts.map +1 -0
  96. package/dist/docx/inline-markers.d.ts +63 -0
  97. package/dist/docx/inline-markers.d.ts.map +1 -0
  98. package/dist/docx/inline-slots.d.ts +24 -0
  99. package/dist/docx/inline-slots.d.ts.map +1 -0
  100. package/dist/docx/layout/adapter.d.ts.map +1 -1
  101. package/dist/docx/layout/index.cjs +1176 -563
  102. package/dist/docx/layout/index.d.ts +2 -1
  103. package/dist/docx/layout/index.d.ts.map +1 -1
  104. package/dist/docx/layout/index.mjs +1175 -564
  105. package/dist/docx/layout/input.d.ts +5 -1
  106. package/dist/docx/layout/input.d.ts.map +1 -1
  107. package/dist/docx/layout/page-style-refs.d.ts +21 -0
  108. package/dist/docx/layout/page-style-refs.d.ts.map +1 -0
  109. package/dist/docx/layout/paragraph-fragments.d.ts.map +1 -1
  110. package/dist/docx/layout/result.d.ts +1 -0
  111. package/dist/docx/layout/result.d.ts.map +1 -1
  112. package/dist/docx/layout/tab-stops.d.ts +8 -1
  113. package/dist/docx/layout/tab-stops.d.ts.map +1 -1
  114. package/dist/docx/load/index.cjs +3969 -1487
  115. package/dist/docx/load/index.mjs +3969 -1487
  116. package/dist/docx/model-run.d.ts +24 -2
  117. package/dist/docx/model-run.d.ts.map +1 -1
  118. package/dist/docx/model.d.ts +5 -0
  119. package/dist/docx/model.d.ts.map +1 -1
  120. package/dist/docx/numbering-format.d.ts.map +1 -1
  121. package/dist/docx/parse-warnings.d.ts.map +1 -1
  122. package/dist/docx/parse.d.ts.map +1 -1
  123. package/dist/docx/run-segmentation.d.ts +11 -0
  124. package/dist/docx/run-segmentation.d.ts.map +1 -0
  125. package/dist/docx/save.d.ts.map +1 -1
  126. package/dist/docx/section-model.d.ts +5 -0
  127. package/dist/docx/section-model.d.ts.map +1 -1
  128. package/dist/docx/sections.d.ts +4 -2
  129. package/dist/docx/sections.d.ts.map +1 -1
  130. package/dist/docx/settings.d.ts +9 -0
  131. package/dist/docx/settings.d.ts.map +1 -1
  132. package/dist/docx/special-characters.d.ts +34 -0
  133. package/dist/docx/special-characters.d.ts.map +1 -0
  134. package/dist/docx/style-ref-fields.d.ts +40 -0
  135. package/dist/docx/style-ref-fields.d.ts.map +1 -0
  136. package/dist/docx/style-ref.d.ts +85 -0
  137. package/dist/docx/style-ref.d.ts.map +1 -0
  138. package/dist/docx/table-model.d.ts +2 -2
  139. package/dist/docx/table-model.d.ts.map +1 -1
  140. package/dist/docx/ui/break-note-schema.d.ts.map +1 -1
  141. package/dist/docx/ui/content-control-commands.d.ts +20 -8
  142. package/dist/docx/ui/content-control-commands.d.ts.map +1 -1
  143. package/dist/docx/ui/content-control-guard.d.ts +4 -1
  144. package/dist/docx/ui/content-control-guard.d.ts.map +1 -1
  145. package/dist/docx/ui/content-control-paste.d.ts +23 -0
  146. package/dist/docx/ui/content-control-paste.d.ts.map +1 -0
  147. package/dist/docx/ui/content-control-rows.d.ts +15 -0
  148. package/dist/docx/ui/content-control-rows.d.ts.map +1 -0
  149. package/dist/docx/ui/content-control-sources.d.ts +12 -0
  150. package/dist/docx/ui/content-control-sources.d.ts.map +1 -0
  151. package/dist/docx/ui/content-control-spans.d.ts +29 -6
  152. package/dist/docx/ui/content-control-spans.d.ts.map +1 -1
  153. package/dist/docx/ui/content-control-temporary.d.ts +10 -0
  154. package/dist/docx/ui/content-control-temporary.d.ts.map +1 -0
  155. package/dist/docx/ui/form-field-commands.d.ts +41 -0
  156. package/dist/docx/ui/form-field-commands.d.ts.map +1 -0
  157. package/dist/docx/ui/form-field-guard.d.ts +24 -0
  158. package/dist/docx/ui/form-field-guard.d.ts.map +1 -0
  159. package/dist/docx/ui/form-text-blank.d.ts +18 -0
  160. package/dist/docx/ui/form-text-blank.d.ts.map +1 -0
  161. package/dist/docx/ui/index.cjs +9276 -7132
  162. package/dist/docx/ui/index.d.ts +5 -0
  163. package/dist/docx/ui/index.d.ts.map +1 -1
  164. package/dist/docx/ui/index.mjs +9259 -7137
  165. package/dist/docx/ui/positional-tab-input.d.ts +7 -0
  166. package/dist/docx/ui/positional-tab-input.d.ts.map +1 -0
  167. package/dist/docx/ui/run-compare.d.ts.map +1 -1
  168. package/dist/docx/ui/run-extra-mark.d.ts +1 -1
  169. package/dist/docx/ui/run-extra-mark.d.ts.map +1 -1
  170. package/dist/docx/ui/schema-marks.d.ts +1 -1
  171. package/dist/docx/ui/schema-marks.d.ts.map +1 -1
  172. package/dist/docx/ui/symbol-font.d.ts +4 -0
  173. package/dist/docx/ui/symbol-font.d.ts.map +1 -0
  174. package/dist/docx/ui/yjs-collaboration.d.ts +12 -1
  175. package/dist/docx/ui/yjs-collaboration.d.ts.map +1 -1
  176. package/dist/docx/write-block-placement.d.ts +7 -0
  177. package/dist/docx/write-block-placement.d.ts.map +1 -1
  178. package/dist/docx/write-content-control.d.ts +6 -0
  179. package/dist/docx/write-content-control.d.ts.map +1 -1
  180. package/dist/docx/write-header-footer.d.ts +6 -2
  181. package/dist/docx/write-header-footer.d.ts.map +1 -1
  182. package/dist/docx/write-inline.d.ts +12 -16
  183. package/dist/docx/write-inline.d.ts.map +1 -1
  184. package/dist/docx/write-paragraph.d.ts.map +1 -1
  185. package/dist/docx/write-revisions.d.ts.map +1 -1
  186. package/dist/docx/write-run.d.ts.map +1 -1
  187. package/dist/docx/write-section-properties.d.ts +5 -0
  188. package/dist/docx/write-section-properties.d.ts.map +1 -0
  189. package/dist/docx/write-sections.d.ts.map +1 -1
  190. package/dist/docx/write-table-controls.d.ts +15 -0
  191. package/dist/docx/write-table-controls.d.ts.map +1 -0
  192. package/dist/docx/write-table-properties.d.ts.map +1 -1
  193. package/dist/docx/write-table.d.ts.map +1 -1
  194. package/dist/docx/write.d.ts.map +1 -1
  195. package/dist/docx/xml.d.ts +6 -0
  196. package/dist/docx/xml.d.ts.map +1 -1
  197. package/dist/drawingml/index.cjs +31 -3
  198. package/dist/drawingml/index.mjs +31 -3
  199. package/dist/index.cjs +77 -26
  200. package/dist/index.mjs +77 -26
  201. package/dist/math/index.cjs +27 -2
  202. package/dist/math/index.mjs +27 -2
  203. package/dist/opc/index.cjs +51 -11
  204. package/dist/opc/index.mjs +51 -11
  205. package/dist/opc/zip-folders.d.ts +11 -0
  206. package/dist/opc/zip-folders.d.ts.map +1 -0
  207. package/dist/opc/zip-limits.d.ts +9 -0
  208. package/dist/opc/zip-limits.d.ts.map +1 -1
  209. package/dist/pptx/automation/index.cjs +116 -17
  210. package/dist/pptx/automation/index.d.ts +2 -2
  211. package/dist/pptx/automation/index.mjs +6 -6
  212. package/dist/pptx/chunks/{index-CgFX0T7b.d.ts → index-CPhsd7Df.d.ts} +9 -1
  213. package/dist/pptx/chunks/{index-CgFX0T7b.d.ts.map → index-CPhsd7Df.d.ts.map} +1 -1
  214. package/dist/pptx/chunks/{index-qwVYoFn6.d.ts → index-Q5mM8kIR.d.ts} +2 -2
  215. package/dist/pptx/chunks/{index-qwVYoFn6.d.ts.map → index-Q5mM8kIR.d.ts.map} +1 -1
  216. package/dist/pptx/cli/index.cjs +116 -17
  217. package/dist/pptx/cli/index.mjs +5 -5
  218. package/dist/pptx/converter/index.cjs +12 -3
  219. package/dist/pptx/converter/index.d.ts +1 -1
  220. package/dist/pptx/converter/index.mjs +3 -3
  221. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  222. package/dist/pptx/editor/render/find-replace.d.ts +1 -1
  223. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  224. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  225. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  226. package/dist/pptx/index.cjs +116 -17
  227. package/dist/pptx/index.d.ts +2 -2
  228. package/dist/pptx/index.mjs +6 -6
  229. package/dist/pptx/signature-node/index.cjs +20 -8
  230. package/dist/pptx/signature-node/index.mjs +2 -2
  231. package/dist/teams/index.cjs +105 -70
  232. package/dist/teams/index.mjs +105 -70
  233. package/dist/text/text-diff.d.ts +15 -0
  234. package/dist/text/text-diff.d.ts.map +1 -0
  235. package/dist/visio/index.cjs +159 -39
  236. package/dist/visio/index.mjs +159 -39
  237. package/dist/visio/ui/contract.d.ts +7 -2
  238. package/dist/visio/ui/contract.d.ts.map +1 -1
  239. package/dist/visio/ui/index.cjs +165 -43
  240. package/dist/visio/ui/index.mjs +165 -43
  241. package/dist/xlsx/collab/index.cjs +8 -3
  242. package/dist/xlsx/collab/index.mjs +8 -3
  243. package/dist/xlsx/compare/cells.d.ts +22 -0
  244. package/dist/xlsx/compare/cells.d.ts.map +1 -0
  245. package/dist/xlsx/compare/compare.d.ts +12 -0
  246. package/dist/xlsx/compare/compare.d.ts.map +1 -0
  247. package/dist/xlsx/compare/conditional.d.ts +7 -0
  248. package/dist/xlsx/compare/conditional.d.ts.map +1 -0
  249. package/dist/xlsx/compare/format-key.d.ts +34 -0
  250. package/dist/xlsx/compare/format-key.d.ts.map +1 -0
  251. package/dist/xlsx/compare/group.d.ts +8 -0
  252. package/dist/xlsx/compare/group.d.ts.map +1 -0
  253. package/dist/xlsx/compare/index.d.ts +5 -0
  254. package/dist/xlsx/compare/index.d.ts.map +1 -0
  255. package/dist/xlsx/compare/rich-text.d.ts +7 -0
  256. package/dist/xlsx/compare/rich-text.d.ts.map +1 -0
  257. package/dist/xlsx/compare/sheets.d.ts +22 -0
  258. package/dist/xlsx/compare/sheets.d.ts.map +1 -0
  259. package/dist/xlsx/compare/structure.d.ts +11 -0
  260. package/dist/xlsx/compare/structure.d.ts.map +1 -0
  261. package/dist/xlsx/compare/text.d.ts +8 -0
  262. package/dist/xlsx/compare/text.d.ts.map +1 -0
  263. package/dist/xlsx/compare/types.d.ts +173 -0
  264. package/dist/xlsx/compare/types.d.ts.map +1 -0
  265. package/dist/xlsx/edit/cell-values.d.ts.map +1 -1
  266. package/dist/xlsx/edit/clipboard-html.d.ts.map +1 -1
  267. package/dist/xlsx/edit/clipboard-text.d.ts.map +1 -1
  268. package/dist/xlsx/edit/clipboard.d.ts.map +1 -1
  269. package/dist/xlsx/edit/clone-cell.d.ts +9 -0
  270. package/dist/xlsx/edit/clone-cell.d.ts.map +1 -0
  271. package/dist/xlsx/edit/history.d.ts +8 -3
  272. package/dist/xlsx/edit/history.d.ts.map +1 -1
  273. package/dist/xlsx/edit/timelines.d.ts.map +1 -1
  274. package/dist/xlsx/formula/change-areas.d.ts +9 -0
  275. package/dist/xlsx/formula/change-areas.d.ts.map +1 -0
  276. package/dist/xlsx/formula/engine-prepare.d.ts +8 -0
  277. package/dist/xlsx/formula/engine-prepare.d.ts.map +1 -1
  278. package/dist/xlsx/formula/engine.d.ts.map +1 -1
  279. package/dist/xlsx/formula/spill.d.ts +5 -1
  280. package/dist/xlsx/formula/spill.d.ts.map +1 -1
  281. package/dist/xlsx/index.cjs +2461 -1192
  282. package/dist/xlsx/index.d.ts +1 -0
  283. package/dist/xlsx/index.d.ts.map +1 -1
  284. package/dist/xlsx/index.mjs +2454 -1193
  285. package/dist/xlsx/layout/cell-view.d.ts.map +1 -1
  286. package/dist/xlsx/layout/navigate.d.ts.map +1 -1
  287. package/dist/xlsx/layout/style-view.d.ts +5 -0
  288. package/dist/xlsx/layout/style-view.d.ts.map +1 -1
  289. package/dist/xlsx/load/csv-dates.d.ts +22 -0
  290. package/dist/xlsx/load/csv-dates.d.ts.map +1 -0
  291. package/dist/xlsx/load/csv-import.d.ts +64 -0
  292. package/dist/xlsx/load/csv-import.d.ts.map +1 -0
  293. package/dist/xlsx/load/csv-separators.d.ts +13 -0
  294. package/dist/xlsx/load/csv-separators.d.ts.map +1 -0
  295. package/dist/xlsx/load/csv-traits.d.ts +20 -0
  296. package/dist/xlsx/load/csv-traits.d.ts.map +1 -0
  297. package/dist/xlsx/load/csv.d.ts +8 -4
  298. package/dist/xlsx/load/csv.d.ts.map +1 -1
  299. package/dist/xlsx/load/detect.d.ts +13 -0
  300. package/dist/xlsx/load/detect.d.ts.map +1 -1
  301. package/dist/xlsx/load/errors.d.ts +1 -0
  302. package/dist/xlsx/load/errors.d.ts.map +1 -1
  303. package/dist/xlsx/load/index.cjs +537 -91
  304. package/dist/xlsx/load/index.d.ts +3 -1
  305. package/dist/xlsx/load/index.d.ts.map +1 -1
  306. package/dist/xlsx/load/index.mjs +536 -92
  307. package/dist/xlsx/numfmt/input-date.d.ts +2 -0
  308. package/dist/xlsx/numfmt/input-date.d.ts.map +1 -1
  309. package/dist/xlsx/pivot/cache-xml.d.ts.map +1 -1
  310. package/dist/xlsx/pivot/groups.d.ts.map +1 -1
  311. package/dist/xlsx/read/index.d.ts +2 -1
  312. package/dist/xlsx/read/index.d.ts.map +1 -1
  313. package/dist/xlsx/read/limits.d.ts +50 -0
  314. package/dist/xlsx/read/limits.d.ts.map +1 -0
  315. package/dist/xlsx/read/load.d.ts +11 -1
  316. package/dist/xlsx/read/load.d.ts.map +1 -1
  317. package/dist/xlsx/read/package.d.ts +5 -23
  318. package/dist/xlsx/read/package.d.ts.map +1 -1
  319. package/dist/xlsx/read/shared-strings.d.ts +2 -2
  320. package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
  321. package/dist/xlsx/read/worksheet.d.ts +2 -0
  322. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  323. package/dist/xlsx/stable-key.d.ts +3 -0
  324. package/dist/xlsx/stable-key.d.ts.map +1 -0
  325. package/dist/xlsx/styles.d.ts.map +1 -1
  326. package/dist/xlsx/ui/index.cjs +657 -372
  327. package/dist/xlsx/ui/index.mjs +657 -372
  328. package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
  329. package/dist/xml/index.cjs +32 -3
  330. package/dist/xml/index.mjs +32 -4
  331. package/dist/xml/xml.d.ts +11 -1
  332. package/dist/xml/xml.d.ts.map +1 -1
  333. package/package.json +1 -1
  334. package/dist/PptxHandler-SITN3K3F.mjs +0 -4
package/dist/index.cjs CHANGED
@@ -1383,6 +1383,17 @@ function formatCompactAxisValue(value, formatCode) {
1383
1383
  return value.toFixed(1);
1384
1384
  }
1385
1385
 
1386
+ // chart/extent.ts
1387
+ function extentOf(values) {
1388
+ let min = Infinity;
1389
+ let max = -Infinity;
1390
+ for (const value of values) {
1391
+ min = Math.min(min, value);
1392
+ max = Math.max(max, value);
1393
+ }
1394
+ return { min, max };
1395
+ }
1396
+
1386
1397
  // chart/bubble-radius.ts
1387
1398
  function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options2) {
1388
1399
  const scale = (options2?.bubbleScale ?? 100) / 100;
@@ -1393,7 +1404,7 @@ function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options2) {
1393
1404
  return medianRadius * scale * 0.5 + ratio * medianRadius * scale * 1.5;
1394
1405
  }
1395
1406
  function maxBubbleSize(sizes) {
1396
- return sizes.length > 0 ? Math.max(1, ...sizes.map(Math.abs)) : 1;
1407
+ return Math.max(1, extentOf(sizes.map(Math.abs)).max);
1397
1408
  }
1398
1409
  function medianBubbleRadius(plotWidth, plotHeight) {
1399
1410
  return Math.min(plotWidth, plotHeight) * 0.04;
@@ -1812,8 +1823,7 @@ function computeHistogramBins(values, options2, format = String) {
1812
1823
  });
1813
1824
  }
1814
1825
  if (regular.length > 0) {
1815
- const min = Math.min(...regular.map((item) => item.value));
1816
- const max = Math.max(...regular.map((item) => item.value));
1826
+ const { min, max } = extentOf(regular.map((item) => item.value));
1817
1827
  const requestedSize = options2.binSize && options2.binSize > 0 ? options2.binSize : void 0;
1818
1828
  const requestedCount = options2.binCount && options2.binCount > 0 ? options2.binCount : void 0;
1819
1829
  const start = requestedSize ? Math.floor(min / requestedSize) * requestedSize : min;
@@ -2029,8 +2039,9 @@ function fitChartTrendline(options2, xVals, yVals) {
2029
2039
  }
2030
2040
  const model = fitModel(options2, xVals, yVals);
2031
2041
  if (!model) return noFit();
2032
- const startX = Math.min(...xVals) - (options2.backward ?? 0);
2033
- const endX = Math.max(...xVals) + (options2.forward ?? 0);
2042
+ const xRange = extentOf(xVals);
2043
+ const startX = xRange.min - (options2.backward ?? 0);
2044
+ const endX = xRange.max + (options2.forward ?? 0);
2034
2045
  const steps = Math.max(Math.ceil((endX - startX) * 4), 20);
2035
2046
  const points = [];
2036
2047
  for (let step = 0; step <= steps; step++) {
@@ -2209,6 +2220,7 @@ __export(xml_exports, {
2209
2220
  DEFAULT_XML_LIMITS: () => DEFAULT_XML_LIMITS,
2210
2221
  LiteElement: () => LiteElement,
2211
2222
  NS: () => NS,
2223
+ XmlLimitError: () => XmlLimitError,
2212
2224
  attr: () => attr,
2213
2225
  buildXml: () => buildXml,
2214
2226
  checkXmlLimits: () => checkXmlLimits,
@@ -2297,6 +2309,19 @@ var DEFAULT_XML_LIMITS = {
2297
2309
  maxDepth: 512,
2298
2310
  maxNodes: 5e6
2299
2311
  };
2312
+ var XmlLimitError = class extends Error {
2313
+ code = "xml-limit";
2314
+ /** The limit that was exceeded. */
2315
+ limit;
2316
+ /** Its value: the largest depth or element count allowed. */
2317
+ maximum;
2318
+ constructor(message, limit, maximum) {
2319
+ super(message);
2320
+ this.name = "XmlLimitError";
2321
+ this.limit = limit;
2322
+ this.maximum = maximum;
2323
+ }
2324
+ };
2300
2325
  var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
2301
2326
  var MARKUP_SKIPS = [
2302
2327
  ["<!--", "-->"],
@@ -2330,11 +2355,22 @@ function checkXmlLimits(xml, label, limits = {}) {
2330
2355
  continue;
2331
2356
  }
2332
2357
  nodes++;
2333
- if (nodes > maxNodes) throw new Error(`${label} XML exceeds the limit of ${maxNodes} elements`);
2358
+ if (nodes > maxNodes)
2359
+ throw new XmlLimitError(
2360
+ `${label} XML exceeds the limit of ${maxNodes} elements`,
2361
+ "maxNodes",
2362
+ maxNodes
2363
+ );
2334
2364
  if (!selfClosing && ++depth > maxDepth2)
2335
- throw new Error(`${label} XML exceeds the nesting depth limit of ${maxDepth2}`);
2365
+ throw new XmlLimitError(
2366
+ `${label} XML exceeds the nesting depth limit of ${maxDepth2}`,
2367
+ "maxDepth",
2368
+ maxDepth2
2369
+ );
2336
2370
  }
2337
2371
  }
2372
+ var CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
2373
+ var crlfDeclarations = /* @__PURE__ */ new WeakSet();
2338
2374
  function parseXml(xml, options2 = {}) {
2339
2375
  const label = options2.label ?? "OOXML";
2340
2376
  if (/<!DOCTYPE|<!ENTITY/i.test(xml))
@@ -2356,9 +2392,13 @@ function parseXml(xml, options2 = {}) {
2356
2392
  }
2357
2393
  if (parseError || !parsed.documentElement)
2358
2394
  throw new Error(`Invalid ${label} XML: ${parseError || "missing root element"}`);
2395
+ if (CRLF_DECLARATION.test(xml)) crlfDeclarations.add(parsed);
2359
2396
  return parsed;
2360
2397
  }
2361
- var buildXml = (node) => new xmldom.XMLSerializer().serializeToString(node);
2398
+ var buildXml = (node) => {
2399
+ const xml = new xmldom.XMLSerializer().serializeToString(node);
2400
+ return crlfDeclarations.has(node) ? xml.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml;
2401
+ };
2362
2402
  var isElement = (node) => node.nodeType === 1;
2363
2403
  var elements = (parent) => Array.from(parent.childNodes).filter(isElement);
2364
2404
  var textContent = (element2) => element2.textContent ?? "";
@@ -7005,8 +7045,7 @@ function computeLogValueRange(series, logBase) {
7005
7045
  if (allValues.length === 0) {
7006
7046
  return { min: 1, max: logBase, span: 1, logScale: true, logBase };
7007
7047
  }
7008
- const dataMin = Math.min(...allValues);
7009
- const dataMax = Math.max(...allValues);
7048
+ const { min: dataMin, max: dataMax } = extentOf(allValues);
7010
7049
  const logMin = Math.floor(Math.log(dataMin) / Math.log(logBase));
7011
7050
  const logMax = Math.ceil(Math.log(dataMax) / Math.log(logBase));
7012
7051
  const min = logBase ** logMin;
@@ -7621,8 +7660,9 @@ function waterfallView(chart, model, ctx) {
7621
7660
  colors: { increase: role(0), decrease: role(1), total: role(2) }
7622
7661
  };
7623
7662
  const ends = steps.flatMap((step) => [step.startValue, step.endValue]);
7663
+ const range = extentOf(ends);
7624
7664
  model.valueAxis = {
7625
- ...ends.length ? niceScale(Math.min(...ends), Math.max(...ends)) : niceScale(0, 1),
7665
+ ...ends.length ? niceScale(range.min, range.max) : niceScale(0, 1),
7626
7666
  percent: false
7627
7667
  };
7628
7668
  const labels = model.categories;
@@ -7738,7 +7778,8 @@ function chartSummaryView(chart, theme, options2 = {}) {
7738
7778
  s2.xValues = s2.values.map((_, k) => numeric ? toNumber(cats[k] ?? null) : k + 1);
7739
7779
  });
7740
7780
  const xs = series.flatMap((s2) => s2.xValues ?? []).filter((x) => x !== null);
7741
- model.xAxis = xs.length ? niceScale(Math.min(...xs), Math.max(...xs)) : niceScale(0, 1);
7781
+ const range = extentOf(xs);
7782
+ model.xAxis = xs.length ? niceScale(range.min, range.max) : niceScale(0, 1);
7742
7783
  }
7743
7784
  if (type === "stock") model.stock = stockView(chart.stock, ctx);
7744
7785
  if (type === "bubble") bubbleView(chart, model, ctx.evaluateRef);
@@ -7770,7 +7811,7 @@ function cartesianAxes(model, area, out) {
7770
7811
  const cats = Math.max(1, model.categories.length);
7771
7812
  const catW = Math.min(
7772
7813
  area.w * 0.3,
7773
- Math.max(...model.categories.map((c2) => textWidth(c2, categorySize)), 8) + 6
7814
+ Math.max(extentOf(model.categories.map((c2) => textWidth(c2, categorySize))).max, 8) + 6
7774
7815
  );
7775
7816
  const second = horizontal ? void 0 : model.secondaryAxis;
7776
7817
  const secondLabels = second?.ticks.map((t) => axisTickText(t, model.axes?.secondary, second.percent)) ?? [];
@@ -8463,13 +8504,11 @@ function chartLegendSvg(model, area, frame2, options2) {
8463
8504
  chartAreaRect(model, "legend", { x: manual.x, y: manual.y, w: manual.width, h: manual.height })
8464
8505
  ];
8465
8506
  const baselineOffset = font ? (font.ascent - font.descent) / 2 : size * 0.35;
8507
+ const widest = extentOf(widths).max;
8466
8508
  entries.forEach((entry3, i2) => {
8467
8509
  const available = horizontal ? chartTextWidth(entry3.label, attrs, options2) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
8468
8510
  const label = fitChartText(entry3.label, available, attrs, options2);
8469
- const contentWidth = Math.min(
8470
- horizontal ? widths[i2] ?? 0 : Math.max(...widths),
8471
- rowWidth - size / 2
8472
- );
8511
+ const contentWidth = Math.min(horizontal ? widths[i2] ?? 0 : widest, rowWidth - size / 2);
8473
8512
  const x = horizontal ? horizontalX : manual.x + Math.max(size / 4, (rowWidth - contentWidth) / 2);
8474
8513
  const centerY = manual.y + (horizontal ? 0 : i2 * rowHeight) + rowHeight / 2;
8475
8514
  markup.push(rect(x, centerY - keySize / 2, keySize, keySize, entry3.color));
@@ -8541,7 +8580,7 @@ function automaticLegend(model, area, out, options2, bounds2) {
8541
8580
  }
8542
8581
  const width = Math.min(
8543
8582
  area.w * 0.35,
8544
- Math.max(...entries.map((e) => chartTextWidth(e.label, attrs, options2))) + 22
8583
+ extentOf(entries.map((e) => chartTextWidth(e.label, attrs, options2))).max + 22
8545
8584
  );
8546
8585
  const height = entries.length * rowH;
8547
8586
  const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
@@ -33223,10 +33262,13 @@ var DEFAULT_ZIP_LIMITS = {
33223
33262
  var ZipLimitError = class extends Error {
33224
33263
  code = "ZIP_BOMB";
33225
33264
  limit;
33265
+ /** The check that failed (absent when the error was built without one). */
33266
+ kind;
33226
33267
  constructor(message, details) {
33227
33268
  super(message);
33228
33269
  this.name = "ZipLimitError";
33229
33270
  this.limit = details.limit;
33271
+ this.kind = details.kind;
33230
33272
  }
33231
33273
  };
33232
33274
  var mib = (bytes) => Math.round(bytes / 1048576);
@@ -33249,7 +33291,7 @@ function resolveLimits(limits) {
33249
33291
  maxEntryBytes: limits.maxEntryBytes ?? DEFAULT_ZIP_LIMITS.maxEntryBytes,
33250
33292
  maxTotalBytes: limits.maxTotalBytes ?? DEFAULT_ZIP_LIMITS.maxTotalBytes,
33251
33293
  label: limits.label ?? "ZIP",
33252
- fail: (message, limit) => create ? create(message, { limit }) : new ZipLimitError(message, { limit })
33294
+ fail: (message, limit, kind) => create ? create(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
33253
33295
  };
33254
33296
  }
33255
33297
  function inflateEntryGuarded(entry3, alreadyRead, limits) {
@@ -33272,13 +33314,18 @@ function inflateEntryGuarded(entry3, alreadyRead, limits) {
33272
33314
  size += chunk.byteLength;
33273
33315
  if (size > declared || size > r.maxEntryBytes)
33274
33316
  return abort(
33275
- r.fail(`${r.label} part ${entry3.name} inflates past its declared size`, r.maxEntryBytes)
33317
+ r.fail(
33318
+ `${r.label} part ${entry3.name} inflates past its declared size`,
33319
+ r.maxEntryBytes,
33320
+ size > declared ? "declaredSize" : "maxEntryBytes"
33321
+ )
33276
33322
  );
33277
33323
  if (alreadyRead + size > r.maxTotalBytes)
33278
33324
  return abort(
33279
33325
  r.fail(
33280
33326
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
33281
- r.maxTotalBytes
33327
+ r.maxTotalBytes,
33328
+ "maxTotalBytes"
33282
33329
  )
33283
33330
  );
33284
33331
  chunks.push(chunk);
@@ -33311,26 +33358,29 @@ function guardZip(zip, limits = {}) {
33311
33358
  if (entries.length > r.maxEntries)
33312
33359
  throw r.fail(
33313
33360
  `${r.label} package exceeds the ${r.maxEntries.toLocaleString("en-US")} part limit`,
33314
- r.maxEntries
33361
+ r.maxEntries,
33362
+ "maxEntries"
33315
33363
  );
33316
33364
  let declared = 0;
33317
33365
  for (const entry3 of entries) {
33318
33366
  const original = entry3.unsafeOriginalName;
33319
33367
  if (!isSafePartName(entry3.name) || original !== void 0 && !isSafePartName(original))
33320
- throw r.fail(`${r.label} package has an unsafe part name`, r.maxEntries);
33368
+ throw r.fail(`${r.label} package has an unsafe part name`, r.maxEntries, "partName");
33321
33369
  if (entry3.dir) continue;
33322
33370
  const size = declaredEntrySize(entry3);
33323
33371
  if (size > r.maxEntryBytes)
33324
33372
  throw r.fail(
33325
33373
  `${r.label} part ${entry3.name} exceeds the uncompressed part size limit`,
33326
- r.maxEntryBytes
33374
+ r.maxEntryBytes,
33375
+ "maxEntryBytes"
33327
33376
  );
33328
33377
  declared += size;
33329
33378
  }
33330
33379
  if (declared > r.maxTotalBytes)
33331
33380
  throw r.fail(
33332
33381
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
33333
- r.maxTotalBytes
33382
+ r.maxTotalBytes,
33383
+ "maxTotalBytes"
33334
33384
  );
33335
33385
  const produced = /* @__PURE__ */ new Map();
33336
33386
  let total = 0;
@@ -33368,7 +33418,8 @@ async function openZip(input, limits = {}) {
33368
33418
  if (bytes.byteLength > maxInput)
33369
33419
  throw r.fail(
33370
33420
  `${r.label} package exceeds the ${mib(maxInput)} MiB compressed input limit`,
33371
- maxInput
33421
+ maxInput,
33422
+ "maxInputBytes"
33372
33423
  );
33373
33424
  return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
33374
33425
  }
package/dist/index.mjs CHANGED
@@ -1377,6 +1377,17 @@ function formatCompactAxisValue(value, formatCode) {
1377
1377
  return value.toFixed(1);
1378
1378
  }
1379
1379
 
1380
+ // chart/extent.ts
1381
+ function extentOf(values) {
1382
+ let min = Infinity;
1383
+ let max = -Infinity;
1384
+ for (const value of values) {
1385
+ min = Math.min(min, value);
1386
+ max = Math.max(max, value);
1387
+ }
1388
+ return { min, max };
1389
+ }
1390
+
1380
1391
  // chart/bubble-radius.ts
1381
1392
  function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options2) {
1382
1393
  const scale = (options2?.bubbleScale ?? 100) / 100;
@@ -1387,7 +1398,7 @@ function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options2) {
1387
1398
  return medianRadius * scale * 0.5 + ratio * medianRadius * scale * 1.5;
1388
1399
  }
1389
1400
  function maxBubbleSize(sizes) {
1390
- return sizes.length > 0 ? Math.max(1, ...sizes.map(Math.abs)) : 1;
1401
+ return Math.max(1, extentOf(sizes.map(Math.abs)).max);
1391
1402
  }
1392
1403
  function medianBubbleRadius(plotWidth, plotHeight) {
1393
1404
  return Math.min(plotWidth, plotHeight) * 0.04;
@@ -1806,8 +1817,7 @@ function computeHistogramBins(values, options2, format = String) {
1806
1817
  });
1807
1818
  }
1808
1819
  if (regular.length > 0) {
1809
- const min = Math.min(...regular.map((item) => item.value));
1810
- const max = Math.max(...regular.map((item) => item.value));
1820
+ const { min, max } = extentOf(regular.map((item) => item.value));
1811
1821
  const requestedSize = options2.binSize && options2.binSize > 0 ? options2.binSize : void 0;
1812
1822
  const requestedCount = options2.binCount && options2.binCount > 0 ? options2.binCount : void 0;
1813
1823
  const start = requestedSize ? Math.floor(min / requestedSize) * requestedSize : min;
@@ -2023,8 +2033,9 @@ function fitChartTrendline(options2, xVals, yVals) {
2023
2033
  }
2024
2034
  const model = fitModel(options2, xVals, yVals);
2025
2035
  if (!model) return noFit();
2026
- const startX = Math.min(...xVals) - (options2.backward ?? 0);
2027
- const endX = Math.max(...xVals) + (options2.forward ?? 0);
2036
+ const xRange = extentOf(xVals);
2037
+ const startX = xRange.min - (options2.backward ?? 0);
2038
+ const endX = xRange.max + (options2.forward ?? 0);
2028
2039
  const steps = Math.max(Math.ceil((endX - startX) * 4), 20);
2029
2040
  const points = [];
2030
2041
  for (let step = 0; step <= steps; step++) {
@@ -2203,6 +2214,7 @@ __export(xml_exports, {
2203
2214
  DEFAULT_XML_LIMITS: () => DEFAULT_XML_LIMITS,
2204
2215
  LiteElement: () => LiteElement,
2205
2216
  NS: () => NS,
2217
+ XmlLimitError: () => XmlLimitError,
2206
2218
  attr: () => attr,
2207
2219
  buildXml: () => buildXml,
2208
2220
  checkXmlLimits: () => checkXmlLimits,
@@ -2291,6 +2303,19 @@ var DEFAULT_XML_LIMITS = {
2291
2303
  maxDepth: 512,
2292
2304
  maxNodes: 5e6
2293
2305
  };
2306
+ var XmlLimitError = class extends Error {
2307
+ code = "xml-limit";
2308
+ /** The limit that was exceeded. */
2309
+ limit;
2310
+ /** Its value: the largest depth or element count allowed. */
2311
+ maximum;
2312
+ constructor(message, limit, maximum) {
2313
+ super(message);
2314
+ this.name = "XmlLimitError";
2315
+ this.limit = limit;
2316
+ this.maximum = maximum;
2317
+ }
2318
+ };
2294
2319
  var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
2295
2320
  var MARKUP_SKIPS = [
2296
2321
  ["<!--", "-->"],
@@ -2324,11 +2349,22 @@ function checkXmlLimits(xml, label, limits = {}) {
2324
2349
  continue;
2325
2350
  }
2326
2351
  nodes++;
2327
- if (nodes > maxNodes) throw new Error(`${label} XML exceeds the limit of ${maxNodes} elements`);
2352
+ if (nodes > maxNodes)
2353
+ throw new XmlLimitError(
2354
+ `${label} XML exceeds the limit of ${maxNodes} elements`,
2355
+ "maxNodes",
2356
+ maxNodes
2357
+ );
2328
2358
  if (!selfClosing && ++depth > maxDepth2)
2329
- throw new Error(`${label} XML exceeds the nesting depth limit of ${maxDepth2}`);
2359
+ throw new XmlLimitError(
2360
+ `${label} XML exceeds the nesting depth limit of ${maxDepth2}`,
2361
+ "maxDepth",
2362
+ maxDepth2
2363
+ );
2330
2364
  }
2331
2365
  }
2366
+ var CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
2367
+ var crlfDeclarations = /* @__PURE__ */ new WeakSet();
2332
2368
  function parseXml(xml, options2 = {}) {
2333
2369
  const label = options2.label ?? "OOXML";
2334
2370
  if (/<!DOCTYPE|<!ENTITY/i.test(xml))
@@ -2350,9 +2386,13 @@ function parseXml(xml, options2 = {}) {
2350
2386
  }
2351
2387
  if (parseError || !parsed.documentElement)
2352
2388
  throw new Error(`Invalid ${label} XML: ${parseError || "missing root element"}`);
2389
+ if (CRLF_DECLARATION.test(xml)) crlfDeclarations.add(parsed);
2353
2390
  return parsed;
2354
2391
  }
2355
- var buildXml = (node) => new XMLSerializer().serializeToString(node);
2392
+ var buildXml = (node) => {
2393
+ const xml = new XMLSerializer().serializeToString(node);
2394
+ return crlfDeclarations.has(node) ? xml.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml;
2395
+ };
2356
2396
  var isElement = (node) => node.nodeType === 1;
2357
2397
  var elements = (parent) => Array.from(parent.childNodes).filter(isElement);
2358
2398
  var textContent = (element2) => element2.textContent ?? "";
@@ -6999,8 +7039,7 @@ function computeLogValueRange(series, logBase) {
6999
7039
  if (allValues.length === 0) {
7000
7040
  return { min: 1, max: logBase, span: 1, logScale: true, logBase };
7001
7041
  }
7002
- const dataMin = Math.min(...allValues);
7003
- const dataMax = Math.max(...allValues);
7042
+ const { min: dataMin, max: dataMax } = extentOf(allValues);
7004
7043
  const logMin = Math.floor(Math.log(dataMin) / Math.log(logBase));
7005
7044
  const logMax = Math.ceil(Math.log(dataMax) / Math.log(logBase));
7006
7045
  const min = logBase ** logMin;
@@ -7615,8 +7654,9 @@ function waterfallView(chart, model, ctx) {
7615
7654
  colors: { increase: role(0), decrease: role(1), total: role(2) }
7616
7655
  };
7617
7656
  const ends = steps.flatMap((step) => [step.startValue, step.endValue]);
7657
+ const range = extentOf(ends);
7618
7658
  model.valueAxis = {
7619
- ...ends.length ? niceScale(Math.min(...ends), Math.max(...ends)) : niceScale(0, 1),
7659
+ ...ends.length ? niceScale(range.min, range.max) : niceScale(0, 1),
7620
7660
  percent: false
7621
7661
  };
7622
7662
  const labels = model.categories;
@@ -7732,7 +7772,8 @@ function chartSummaryView(chart, theme, options2 = {}) {
7732
7772
  s2.xValues = s2.values.map((_, k) => numeric ? toNumber(cats[k] ?? null) : k + 1);
7733
7773
  });
7734
7774
  const xs = series.flatMap((s2) => s2.xValues ?? []).filter((x) => x !== null);
7735
- model.xAxis = xs.length ? niceScale(Math.min(...xs), Math.max(...xs)) : niceScale(0, 1);
7775
+ const range = extentOf(xs);
7776
+ model.xAxis = xs.length ? niceScale(range.min, range.max) : niceScale(0, 1);
7736
7777
  }
7737
7778
  if (type === "stock") model.stock = stockView(chart.stock, ctx);
7738
7779
  if (type === "bubble") bubbleView(chart, model, ctx.evaluateRef);
@@ -7764,7 +7805,7 @@ function cartesianAxes(model, area, out) {
7764
7805
  const cats = Math.max(1, model.categories.length);
7765
7806
  const catW = Math.min(
7766
7807
  area.w * 0.3,
7767
- Math.max(...model.categories.map((c2) => textWidth(c2, categorySize)), 8) + 6
7808
+ Math.max(extentOf(model.categories.map((c2) => textWidth(c2, categorySize))).max, 8) + 6
7768
7809
  );
7769
7810
  const second = horizontal ? void 0 : model.secondaryAxis;
7770
7811
  const secondLabels = second?.ticks.map((t) => axisTickText(t, model.axes?.secondary, second.percent)) ?? [];
@@ -8457,13 +8498,11 @@ function chartLegendSvg(model, area, frame2, options2) {
8457
8498
  chartAreaRect(model, "legend", { x: manual.x, y: manual.y, w: manual.width, h: manual.height })
8458
8499
  ];
8459
8500
  const baselineOffset = font ? (font.ascent - font.descent) / 2 : size * 0.35;
8501
+ const widest = extentOf(widths).max;
8460
8502
  entries.forEach((entry3, i2) => {
8461
8503
  const available = horizontal ? chartTextWidth(entry3.label, attrs, options2) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
8462
8504
  const label = fitChartText(entry3.label, available, attrs, options2);
8463
- const contentWidth = Math.min(
8464
- horizontal ? widths[i2] ?? 0 : Math.max(...widths),
8465
- rowWidth - size / 2
8466
- );
8505
+ const contentWidth = Math.min(horizontal ? widths[i2] ?? 0 : widest, rowWidth - size / 2);
8467
8506
  const x = horizontal ? horizontalX : manual.x + Math.max(size / 4, (rowWidth - contentWidth) / 2);
8468
8507
  const centerY = manual.y + (horizontal ? 0 : i2 * rowHeight) + rowHeight / 2;
8469
8508
  markup.push(rect(x, centerY - keySize / 2, keySize, keySize, entry3.color));
@@ -8535,7 +8574,7 @@ function automaticLegend(model, area, out, options2, bounds2) {
8535
8574
  }
8536
8575
  const width = Math.min(
8537
8576
  area.w * 0.35,
8538
- Math.max(...entries.map((e) => chartTextWidth(e.label, attrs, options2))) + 22
8577
+ extentOf(entries.map((e) => chartTextWidth(e.label, attrs, options2))).max + 22
8539
8578
  );
8540
8579
  const height = entries.length * rowH;
8541
8580
  const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
@@ -33217,10 +33256,13 @@ var DEFAULT_ZIP_LIMITS = {
33217
33256
  var ZipLimitError = class extends Error {
33218
33257
  code = "ZIP_BOMB";
33219
33258
  limit;
33259
+ /** The check that failed (absent when the error was built without one). */
33260
+ kind;
33220
33261
  constructor(message, details) {
33221
33262
  super(message);
33222
33263
  this.name = "ZipLimitError";
33223
33264
  this.limit = details.limit;
33265
+ this.kind = details.kind;
33224
33266
  }
33225
33267
  };
33226
33268
  var mib = (bytes) => Math.round(bytes / 1048576);
@@ -33243,7 +33285,7 @@ function resolveLimits(limits) {
33243
33285
  maxEntryBytes: limits.maxEntryBytes ?? DEFAULT_ZIP_LIMITS.maxEntryBytes,
33244
33286
  maxTotalBytes: limits.maxTotalBytes ?? DEFAULT_ZIP_LIMITS.maxTotalBytes,
33245
33287
  label: limits.label ?? "ZIP",
33246
- fail: (message, limit) => create ? create(message, { limit }) : new ZipLimitError(message, { limit })
33288
+ fail: (message, limit, kind) => create ? create(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
33247
33289
  };
33248
33290
  }
33249
33291
  function inflateEntryGuarded(entry3, alreadyRead, limits) {
@@ -33266,13 +33308,18 @@ function inflateEntryGuarded(entry3, alreadyRead, limits) {
33266
33308
  size += chunk.byteLength;
33267
33309
  if (size > declared || size > r.maxEntryBytes)
33268
33310
  return abort(
33269
- r.fail(`${r.label} part ${entry3.name} inflates past its declared size`, r.maxEntryBytes)
33311
+ r.fail(
33312
+ `${r.label} part ${entry3.name} inflates past its declared size`,
33313
+ r.maxEntryBytes,
33314
+ size > declared ? "declaredSize" : "maxEntryBytes"
33315
+ )
33270
33316
  );
33271
33317
  if (alreadyRead + size > r.maxTotalBytes)
33272
33318
  return abort(
33273
33319
  r.fail(
33274
33320
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
33275
- r.maxTotalBytes
33321
+ r.maxTotalBytes,
33322
+ "maxTotalBytes"
33276
33323
  )
33277
33324
  );
33278
33325
  chunks.push(chunk);
@@ -33305,26 +33352,29 @@ function guardZip(zip, limits = {}) {
33305
33352
  if (entries.length > r.maxEntries)
33306
33353
  throw r.fail(
33307
33354
  `${r.label} package exceeds the ${r.maxEntries.toLocaleString("en-US")} part limit`,
33308
- r.maxEntries
33355
+ r.maxEntries,
33356
+ "maxEntries"
33309
33357
  );
33310
33358
  let declared = 0;
33311
33359
  for (const entry3 of entries) {
33312
33360
  const original = entry3.unsafeOriginalName;
33313
33361
  if (!isSafePartName(entry3.name) || original !== void 0 && !isSafePartName(original))
33314
- throw r.fail(`${r.label} package has an unsafe part name`, r.maxEntries);
33362
+ throw r.fail(`${r.label} package has an unsafe part name`, r.maxEntries, "partName");
33315
33363
  if (entry3.dir) continue;
33316
33364
  const size = declaredEntrySize(entry3);
33317
33365
  if (size > r.maxEntryBytes)
33318
33366
  throw r.fail(
33319
33367
  `${r.label} part ${entry3.name} exceeds the uncompressed part size limit`,
33320
- r.maxEntryBytes
33368
+ r.maxEntryBytes,
33369
+ "maxEntryBytes"
33321
33370
  );
33322
33371
  declared += size;
33323
33372
  }
33324
33373
  if (declared > r.maxTotalBytes)
33325
33374
  throw r.fail(
33326
33375
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
33327
- r.maxTotalBytes
33376
+ r.maxTotalBytes,
33377
+ "maxTotalBytes"
33328
33378
  );
33329
33379
  const produced = /* @__PURE__ */ new Map();
33330
33380
  let total = 0;
@@ -33362,7 +33412,8 @@ async function openZip(input, limits = {}) {
33362
33412
  if (bytes.byteLength > maxInput)
33363
33413
  throw r.fail(
33364
33414
  `${r.label} package exceeds the ${mib(maxInput)} MiB compressed input limit`,
33365
- maxInput
33415
+ maxInput,
33416
+ "maxInputBytes"
33366
33417
  );
33367
33418
  return guardZip(await JSZip.loadAsync(bytes), limits);
33368
33419
  }
@@ -2122,6 +2122,19 @@ var DEFAULT_XML_LIMITS = {
2122
2122
  maxDepth: 512,
2123
2123
  maxNodes: 5e6
2124
2124
  };
2125
+ var XmlLimitError = class extends Error {
2126
+ code = "xml-limit";
2127
+ /** The limit that was exceeded. */
2128
+ limit;
2129
+ /** Its value: the largest depth or element count allowed. */
2130
+ maximum;
2131
+ constructor(message, limit, maximum) {
2132
+ super(message);
2133
+ this.name = "XmlLimitError";
2134
+ this.limit = limit;
2135
+ this.maximum = maximum;
2136
+ }
2137
+ };
2125
2138
  var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
2126
2139
  var MARKUP_SKIPS = [
2127
2140
  ["<!--", "-->"],
@@ -2155,11 +2168,22 @@ function checkXmlLimits(xml, label, limits = {}) {
2155
2168
  continue;
2156
2169
  }
2157
2170
  nodes++;
2158
- if (nodes > maxNodes) throw new Error(`${label} XML exceeds the limit of ${maxNodes} elements`);
2171
+ if (nodes > maxNodes)
2172
+ throw new XmlLimitError(
2173
+ `${label} XML exceeds the limit of ${maxNodes} elements`,
2174
+ "maxNodes",
2175
+ maxNodes
2176
+ );
2159
2177
  if (!selfClosing && ++depth > maxDepth)
2160
- throw new Error(`${label} XML exceeds the nesting depth limit of ${maxDepth}`);
2178
+ throw new XmlLimitError(
2179
+ `${label} XML exceeds the nesting depth limit of ${maxDepth}`,
2180
+ "maxDepth",
2181
+ maxDepth
2182
+ );
2161
2183
  }
2162
2184
  }
2185
+ var CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
2186
+ var crlfDeclarations = /* @__PURE__ */ new WeakSet();
2163
2187
  function parseXml(xml, options = {}) {
2164
2188
  const label = options.label ?? "OOXML";
2165
2189
  if (/<!DOCTYPE|<!ENTITY/i.test(xml))
@@ -2181,6 +2205,7 @@ function parseXml(xml, options = {}) {
2181
2205
  }
2182
2206
  if (parseError || !parsed.documentElement)
2183
2207
  throw new Error(`Invalid ${label} XML: ${parseError || "missing root element"}`);
2208
+ if (CRLF_DECLARATION.test(xml)) crlfDeclarations.add(parsed);
2184
2209
  return parsed;
2185
2210
  }
2186
2211
  var isElement = (node) => node.nodeType === 1;
@@ -2120,6 +2120,19 @@ var DEFAULT_XML_LIMITS = {
2120
2120
  maxDepth: 512,
2121
2121
  maxNodes: 5e6
2122
2122
  };
2123
+ var XmlLimitError = class extends Error {
2124
+ code = "xml-limit";
2125
+ /** The limit that was exceeded. */
2126
+ limit;
2127
+ /** Its value: the largest depth or element count allowed. */
2128
+ maximum;
2129
+ constructor(message, limit, maximum) {
2130
+ super(message);
2131
+ this.name = "XmlLimitError";
2132
+ this.limit = limit;
2133
+ this.maximum = maximum;
2134
+ }
2135
+ };
2123
2136
  var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
2124
2137
  var MARKUP_SKIPS = [
2125
2138
  ["<!--", "-->"],
@@ -2153,11 +2166,22 @@ function checkXmlLimits(xml, label, limits = {}) {
2153
2166
  continue;
2154
2167
  }
2155
2168
  nodes++;
2156
- if (nodes > maxNodes) throw new Error(`${label} XML exceeds the limit of ${maxNodes} elements`);
2169
+ if (nodes > maxNodes)
2170
+ throw new XmlLimitError(
2171
+ `${label} XML exceeds the limit of ${maxNodes} elements`,
2172
+ "maxNodes",
2173
+ maxNodes
2174
+ );
2157
2175
  if (!selfClosing && ++depth > maxDepth)
2158
- throw new Error(`${label} XML exceeds the nesting depth limit of ${maxDepth}`);
2176
+ throw new XmlLimitError(
2177
+ `${label} XML exceeds the nesting depth limit of ${maxDepth}`,
2178
+ "maxDepth",
2179
+ maxDepth
2180
+ );
2159
2181
  }
2160
2182
  }
2183
+ var CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
2184
+ var crlfDeclarations = /* @__PURE__ */ new WeakSet();
2161
2185
  function parseXml(xml, options = {}) {
2162
2186
  const label = options.label ?? "OOXML";
2163
2187
  if (/<!DOCTYPE|<!ENTITY/i.test(xml))
@@ -2179,6 +2203,7 @@ function parseXml(xml, options = {}) {
2179
2203
  }
2180
2204
  if (parseError || !parsed.documentElement)
2181
2205
  throw new Error(`Invalid ${label} XML: ${parseError || "missing root element"}`);
2206
+ if (CRLF_DECLARATION.test(xml)) crlfDeclarations.add(parsed);
2182
2207
  return parsed;
2183
2208
  }
2184
2209
  var isElement = (node) => node.nodeType === 1;