ooxml-core 1.20.0 → 1.22.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 (422) 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 +39159 -14352
  11. package/dist/automation/index.d.ts +5 -0
  12. package/dist/automation/index.d.ts.map +1 -1
  13. package/dist/automation/index.mjs +39145 -14353
  14. package/dist/automation/node.cjs +37 -0
  15. package/dist/automation/node.d.ts +32 -1
  16. package/dist/automation/node.d.ts.map +1 -1
  17. package/dist/automation/node.mjs +36 -1
  18. package/dist/automation/proposal.d.ts +25 -0
  19. package/dist/automation/proposal.d.ts.map +1 -0
  20. package/dist/automation/tools/define.d.ts +27 -0
  21. package/dist/automation/tools/define.d.ts.map +1 -0
  22. package/dist/automation/tools/docx-tools.d.ts +4 -0
  23. package/dist/automation/tools/docx-tools.d.ts.map +1 -0
  24. package/dist/automation/tools/index.d.ts +16 -0
  25. package/dist/automation/tools/index.d.ts.map +1 -0
  26. package/dist/automation/tools/types.d.ts +52 -0
  27. package/dist/automation/tools/types.d.ts.map +1 -0
  28. package/dist/automation/tools/visio-tools.d.ts +4 -0
  29. package/dist/automation/tools/visio-tools.d.ts.map +1 -0
  30. package/dist/automation/tools/xlsx-tools.d.ts +8 -0
  31. package/dist/automation/tools/xlsx-tools.d.ts.map +1 -0
  32. package/dist/automation/xlsx-edits.d.ts +88 -0
  33. package/dist/automation/xlsx-edits.d.ts.map +1 -0
  34. package/dist/automation/xlsx-proposal.d.ts +34 -0
  35. package/dist/automation/xlsx-proposal.d.ts.map +1 -0
  36. package/dist/automation/xlsx.d.ts +10 -5
  37. package/dist/automation/xlsx.d.ts.map +1 -1
  38. package/dist/chart/axis-range.d.ts.map +1 -1
  39. package/dist/chart/bubble-radius.d.ts +0 -5
  40. package/dist/chart/bubble-radius.d.ts.map +1 -1
  41. package/dist/chart/extent.d.ts +9 -0
  42. package/dist/chart/extent.d.ts.map +1 -0
  43. package/dist/chart/histogram-binning.d.ts.map +1 -1
  44. package/dist/chart/index.cjs +56 -18
  45. package/dist/chart/index.mjs +56 -18
  46. package/dist/chart/render/chart-svg-cartesian.d.ts.map +1 -1
  47. package/dist/chart/render/chart-svg-legend.d.ts.map +1 -1
  48. package/dist/chart/render/chart-view-ex.d.ts.map +1 -1
  49. package/dist/chart/render/chart-view.d.ts.map +1 -1
  50. package/dist/chart/trendline-fit.d.ts.map +1 -1
  51. package/dist/{chunk-3IENHIFD.cjs → chunk-4LZIUJI3.cjs} +52 -12
  52. package/dist/{chunk-LEV2SVMK.mjs → chunk-4QPOJCJG.mjs} +45 -8
  53. package/dist/{chunk-CC5UNZOO.mjs → chunk-6IIMI5RS.mjs} +52 -12
  54. package/dist/{chunk-MN27HKHM.mjs → chunk-BA7Z6ATM.mjs} +5 -5
  55. package/dist/{chunk-LVM3IZJ2.mjs → chunk-DLFMCZZT.mjs} +1 -1
  56. package/dist/{chunk-M4XLF4R7.mjs → chunk-GBKBR4CX.mjs} +20 -8
  57. package/dist/{chunk-NXKATFM5.cjs → chunk-HL3FBJ6X.cjs} +1065 -1016
  58. package/dist/{chunk-WXY5EDGT.mjs → chunk-LF5E5ZOH.mjs} +51 -2
  59. package/dist/chunk-MHNETXQB.mjs +1 -0
  60. package/dist/{chunk-MNXKRXFB.mjs → chunk-Q5PKBQXH.mjs} +52 -3
  61. package/dist/{chunk-GQYQQ3GA.mjs → chunk-VQF6HQEE.mjs} +1 -1
  62. package/dist/collab/embedding.d.ts +108 -0
  63. package/dist/collab/embedding.d.ts.map +1 -0
  64. package/dist/collab/index.cjs +423 -293
  65. package/dist/collab/index.d.ts +2 -0
  66. package/dist/collab/index.d.ts.map +1 -1
  67. package/dist/collab/index.mjs +415 -294
  68. package/dist/collab/webrtc-provider.d.ts +21 -0
  69. package/dist/collab/webrtc-provider.d.ts.map +1 -0
  70. package/dist/color/theme-palette.d.ts +5 -1
  71. package/dist/color/theme-palette.d.ts.map +1 -1
  72. package/dist/crypto/index.cjs +27 -2
  73. package/dist/crypto/index.mjs +27 -2
  74. package/dist/diagram/index.cjs +31 -3
  75. package/dist/diagram/index.mjs +31 -3
  76. package/dist/docx/block-parser.d.ts.map +1 -1
  77. package/dist/docx/cell-blocks.d.ts +7 -1
  78. package/dist/docx/cell-blocks.d.ts.map +1 -1
  79. package/dist/docx/content-control-edit.d.ts +14 -0
  80. package/dist/docx/content-control-edit.d.ts.map +1 -1
  81. package/dist/docx/content-control-model.d.ts +8 -0
  82. package/dist/docx/content-control-model.d.ts.map +1 -1
  83. package/dist/docx/content-control-values.d.ts +20 -0
  84. package/dist/docx/content-control-values.d.ts.map +1 -0
  85. package/dist/docx/content-control.d.ts +7 -1
  86. package/dist/docx/content-control.d.ts.map +1 -1
  87. package/dist/docx/element-order.d.ts +10 -5
  88. package/dist/docx/element-order.d.ts.map +1 -1
  89. package/dist/docx/embedded.cjs +3861 -1379
  90. package/dist/docx/embedded.mjs +3861 -1379
  91. package/dist/docx/field-instruction.d.ts +22 -0
  92. package/dist/docx/field-instruction.d.ts.map +1 -0
  93. package/dist/docx/form-field-model.d.ts +48 -0
  94. package/dist/docx/form-field-model.d.ts.map +1 -0
  95. package/dist/docx/form-fields.d.ts +31 -0
  96. package/dist/docx/form-fields.d.ts.map +1 -0
  97. package/dist/docx/form-fill-fields.d.ts +61 -0
  98. package/dist/docx/form-fill-fields.d.ts.map +1 -0
  99. package/dist/docx/form-fill-labels.d.ts +8 -0
  100. package/dist/docx/form-fill-labels.d.ts.map +1 -0
  101. package/dist/docx/form-fill-sites.d.ts +59 -0
  102. package/dist/docx/form-fill-sites.d.ts.map +1 -0
  103. package/dist/docx/form-fill-values.d.ts +28 -0
  104. package/dist/docx/form-fill-values.d.ts.map +1 -0
  105. package/dist/docx/form-fill-write.d.ts +26 -0
  106. package/dist/docx/form-fill-write.d.ts.map +1 -0
  107. package/dist/docx/glossary.d.ts +15 -0
  108. package/dist/docx/glossary.d.ts.map +1 -0
  109. package/dist/docx/index.cjs +5929 -3153
  110. package/dist/docx/index.d.ts +7 -0
  111. package/dist/docx/index.d.ts.map +1 -1
  112. package/dist/docx/index.mjs +5913 -3154
  113. package/dist/docx/inline-annotations.d.ts +21 -0
  114. package/dist/docx/inline-annotations.d.ts.map +1 -0
  115. package/dist/docx/inline-container-markers.d.ts +14 -0
  116. package/dist/docx/inline-container-markers.d.ts.map +1 -0
  117. package/dist/docx/inline-containers.d.ts +54 -0
  118. package/dist/docx/inline-containers.d.ts.map +1 -0
  119. package/dist/docx/inline-form-field-bookmarks.d.ts +15 -0
  120. package/dist/docx/inline-form-field-bookmarks.d.ts.map +1 -0
  121. package/dist/docx/inline-marker-positions.d.ts +15 -0
  122. package/dist/docx/inline-marker-positions.d.ts.map +1 -0
  123. package/dist/docx/inline-markers.d.ts +63 -0
  124. package/dist/docx/inline-markers.d.ts.map +1 -0
  125. package/dist/docx/inline-slots.d.ts +24 -0
  126. package/dist/docx/inline-slots.d.ts.map +1 -0
  127. package/dist/docx/layout/adapter.d.ts.map +1 -1
  128. package/dist/docx/layout/index.cjs +1176 -563
  129. package/dist/docx/layout/index.d.ts +2 -1
  130. package/dist/docx/layout/index.d.ts.map +1 -1
  131. package/dist/docx/layout/index.mjs +1175 -564
  132. package/dist/docx/layout/input.d.ts +5 -1
  133. package/dist/docx/layout/input.d.ts.map +1 -1
  134. package/dist/docx/layout/page-style-refs.d.ts +21 -0
  135. package/dist/docx/layout/page-style-refs.d.ts.map +1 -0
  136. package/dist/docx/layout/paragraph-fragments.d.ts.map +1 -1
  137. package/dist/docx/layout/result.d.ts +1 -0
  138. package/dist/docx/layout/result.d.ts.map +1 -1
  139. package/dist/docx/layout/tab-stops.d.ts +8 -1
  140. package/dist/docx/layout/tab-stops.d.ts.map +1 -1
  141. package/dist/docx/load/index.cjs +3969 -1487
  142. package/dist/docx/load/index.mjs +3969 -1487
  143. package/dist/docx/model-run.d.ts +24 -2
  144. package/dist/docx/model-run.d.ts.map +1 -1
  145. package/dist/docx/model.d.ts +5 -0
  146. package/dist/docx/model.d.ts.map +1 -1
  147. package/dist/docx/numbering-format.d.ts.map +1 -1
  148. package/dist/docx/parse-warnings.d.ts.map +1 -1
  149. package/dist/docx/parse.d.ts.map +1 -1
  150. package/dist/docx/run-segmentation.d.ts +11 -0
  151. package/dist/docx/run-segmentation.d.ts.map +1 -0
  152. package/dist/docx/save.d.ts.map +1 -1
  153. package/dist/docx/section-model.d.ts +5 -0
  154. package/dist/docx/section-model.d.ts.map +1 -1
  155. package/dist/docx/sections.d.ts +4 -2
  156. package/dist/docx/sections.d.ts.map +1 -1
  157. package/dist/docx/settings.d.ts +9 -0
  158. package/dist/docx/settings.d.ts.map +1 -1
  159. package/dist/docx/special-characters.d.ts +34 -0
  160. package/dist/docx/special-characters.d.ts.map +1 -0
  161. package/dist/docx/style-ref-fields.d.ts +40 -0
  162. package/dist/docx/style-ref-fields.d.ts.map +1 -0
  163. package/dist/docx/style-ref.d.ts +85 -0
  164. package/dist/docx/style-ref.d.ts.map +1 -0
  165. package/dist/docx/table-model.d.ts +2 -2
  166. package/dist/docx/table-model.d.ts.map +1 -1
  167. package/dist/docx/ui/break-note-schema.d.ts.map +1 -1
  168. package/dist/docx/ui/content-control-commands.d.ts +20 -8
  169. package/dist/docx/ui/content-control-commands.d.ts.map +1 -1
  170. package/dist/docx/ui/content-control-guard.d.ts +4 -1
  171. package/dist/docx/ui/content-control-guard.d.ts.map +1 -1
  172. package/dist/docx/ui/content-control-paste.d.ts +23 -0
  173. package/dist/docx/ui/content-control-paste.d.ts.map +1 -0
  174. package/dist/docx/ui/content-control-rows.d.ts +15 -0
  175. package/dist/docx/ui/content-control-rows.d.ts.map +1 -0
  176. package/dist/docx/ui/content-control-sources.d.ts +12 -0
  177. package/dist/docx/ui/content-control-sources.d.ts.map +1 -0
  178. package/dist/docx/ui/content-control-spans.d.ts +29 -6
  179. package/dist/docx/ui/content-control-spans.d.ts.map +1 -1
  180. package/dist/docx/ui/content-control-temporary.d.ts +10 -0
  181. package/dist/docx/ui/content-control-temporary.d.ts.map +1 -0
  182. package/dist/docx/ui/form-field-commands.d.ts +41 -0
  183. package/dist/docx/ui/form-field-commands.d.ts.map +1 -0
  184. package/dist/docx/ui/form-field-guard.d.ts +24 -0
  185. package/dist/docx/ui/form-field-guard.d.ts.map +1 -0
  186. package/dist/docx/ui/form-text-blank.d.ts +18 -0
  187. package/dist/docx/ui/form-text-blank.d.ts.map +1 -0
  188. package/dist/docx/ui/index.cjs +9276 -7132
  189. package/dist/docx/ui/index.d.ts +5 -0
  190. package/dist/docx/ui/index.d.ts.map +1 -1
  191. package/dist/docx/ui/index.mjs +9259 -7137
  192. package/dist/docx/ui/positional-tab-input.d.ts +7 -0
  193. package/dist/docx/ui/positional-tab-input.d.ts.map +1 -0
  194. package/dist/docx/ui/run-compare.d.ts.map +1 -1
  195. package/dist/docx/ui/run-extra-mark.d.ts +1 -1
  196. package/dist/docx/ui/run-extra-mark.d.ts.map +1 -1
  197. package/dist/docx/ui/schema-marks.d.ts +1 -1
  198. package/dist/docx/ui/schema-marks.d.ts.map +1 -1
  199. package/dist/docx/ui/symbol-font.d.ts +4 -0
  200. package/dist/docx/ui/symbol-font.d.ts.map +1 -0
  201. package/dist/docx/ui/yjs-collaboration.d.ts +12 -1
  202. package/dist/docx/ui/yjs-collaboration.d.ts.map +1 -1
  203. package/dist/docx/write-block-placement.d.ts +7 -0
  204. package/dist/docx/write-block-placement.d.ts.map +1 -1
  205. package/dist/docx/write-content-control.d.ts +6 -0
  206. package/dist/docx/write-content-control.d.ts.map +1 -1
  207. package/dist/docx/write-header-footer.d.ts +6 -2
  208. package/dist/docx/write-header-footer.d.ts.map +1 -1
  209. package/dist/docx/write-inline.d.ts +12 -16
  210. package/dist/docx/write-inline.d.ts.map +1 -1
  211. package/dist/docx/write-paragraph.d.ts.map +1 -1
  212. package/dist/docx/write-revisions.d.ts.map +1 -1
  213. package/dist/docx/write-run.d.ts.map +1 -1
  214. package/dist/docx/write-section-properties.d.ts +5 -0
  215. package/dist/docx/write-section-properties.d.ts.map +1 -0
  216. package/dist/docx/write-sections.d.ts.map +1 -1
  217. package/dist/docx/write-table-controls.d.ts +15 -0
  218. package/dist/docx/write-table-controls.d.ts.map +1 -0
  219. package/dist/docx/write-table-properties.d.ts.map +1 -1
  220. package/dist/docx/write-table.d.ts.map +1 -1
  221. package/dist/docx/write.d.ts.map +1 -1
  222. package/dist/docx/xml.d.ts +6 -0
  223. package/dist/docx/xml.d.ts.map +1 -1
  224. package/dist/drawingml/index.cjs +31 -3
  225. package/dist/drawingml/index.mjs +31 -3
  226. package/dist/index.cjs +77 -26
  227. package/dist/index.mjs +77 -26
  228. package/dist/math/index.cjs +27 -2
  229. package/dist/math/index.mjs +27 -2
  230. package/dist/opc/index.cjs +51 -11
  231. package/dist/opc/index.mjs +51 -11
  232. package/dist/opc/zip-folders.d.ts +11 -0
  233. package/dist/opc/zip-folders.d.ts.map +1 -0
  234. package/dist/opc/zip-limits.d.ts +9 -0
  235. package/dist/opc/zip-limits.d.ts.map +1 -1
  236. package/dist/pptx/automation/index.cjs +28818 -7388
  237. package/dist/pptx/automation/index.d.ts +93 -3
  238. package/dist/pptx/automation/index.d.ts.map +1 -1
  239. package/dist/pptx/automation/index.mjs +740 -63
  240. package/dist/pptx/automation/schemas/chart-formatting-schemas.d.ts +1 -1
  241. package/dist/pptx/automation/schemas/chart-schemas.d.ts +1 -1
  242. package/dist/pptx/automation/schemas/chart-user-shape-schemas.d.ts +1 -1
  243. package/dist/pptx/automation/schemas/element-schemas.d.ts +1 -1
  244. package/dist/pptx/automation/schemas/export-schemas.d.ts +1 -1
  245. package/dist/pptx/automation/schemas/geometry-schemas.d.ts +1 -1
  246. package/dist/pptx/automation/schemas/hyperlink-schemas.d.ts +1 -1
  247. package/dist/pptx/automation/schemas/index.mjs +1 -0
  248. package/dist/pptx/automation/schemas/json-schemas.d.ts +1 -1
  249. package/dist/pptx/automation/schemas/layout-schemas.d.ts +1 -1
  250. package/dist/pptx/automation/schemas/lock-schemas.d.ts +1 -1
  251. package/dist/pptx/automation/schemas/metadata-schemas.d.ts +1 -1
  252. package/dist/pptx/automation/schemas/ole-schemas.d.ts +1 -1
  253. package/dist/pptx/automation/schemas/presentation-schemas.d.ts +1 -1
  254. package/dist/pptx/automation/schemas/section-schemas.d.ts +1 -1
  255. package/dist/pptx/automation/schemas/slide-schemas.d.ts +1 -1
  256. package/dist/pptx/automation/schemas/smartart-schemas.d.ts +1 -1
  257. package/dist/pptx/automation/schemas/table-style-schemas.d.ts +1 -1
  258. package/dist/pptx/automation/schemas/template-schemas.d.ts +1 -1
  259. package/dist/pptx/automation/schemas/theme-schemas.d.ts +1 -1
  260. package/dist/pptx/automation/schemas/validation-schemas.d.ts +1 -1
  261. package/dist/pptx/chunks/{index-CgFX0T7b.d.ts → index-CPhsd7Df.d.ts} +9 -1
  262. package/dist/pptx/chunks/{index-CgFX0T7b.d.ts.map → index-CPhsd7Df.d.ts.map} +1 -1
  263. package/dist/pptx/chunks/{index-qwVYoFn6.d.ts → index-Q5mM8kIR.d.ts} +2 -2
  264. package/dist/pptx/chunks/{index-qwVYoFn6.d.ts.map → index-Q5mM8kIR.d.ts.map} +1 -1
  265. package/dist/pptx/chunks/{schemas-CWr181Wx.d.ts → schemas-fuDGetRe.d.ts} +2 -2
  266. package/dist/pptx/chunks/{schemas-CWr181Wx.d.ts.map → schemas-fuDGetRe.d.ts.map} +1 -1
  267. package/dist/pptx/cli/index.cjs +116 -17
  268. package/dist/pptx/cli/index.mjs +5 -5
  269. package/dist/pptx/converter/index.cjs +12 -3
  270. package/dist/pptx/converter/index.d.ts +1 -1
  271. package/dist/pptx/converter/index.mjs +3 -3
  272. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  273. package/dist/pptx/editor/render/find-replace.d.ts +1 -1
  274. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  275. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  276. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  277. package/dist/pptx/index.cjs +116 -17
  278. package/dist/pptx/index.d.ts +2 -2
  279. package/dist/pptx/index.mjs +6 -6
  280. package/dist/pptx/signature-node/index.cjs +20 -8
  281. package/dist/pptx/signature-node/index.mjs +2 -2
  282. package/dist/teams/index.cjs +105 -70
  283. package/dist/teams/index.mjs +105 -70
  284. package/dist/text/text-diff.d.ts +15 -0
  285. package/dist/text/text-diff.d.ts.map +1 -0
  286. package/dist/visio/collab/bind.d.ts +44 -0
  287. package/dist/visio/collab/bind.d.ts.map +1 -0
  288. package/dist/visio/collab/compose.d.ts +15 -0
  289. package/dist/visio/collab/compose.d.ts.map +1 -0
  290. package/dist/visio/collab/index.cjs +1194 -0
  291. package/dist/visio/collab/index.d.ts +8 -0
  292. package/dist/visio/collab/index.d.ts.map +1 -0
  293. package/dist/visio/collab/index.mjs +1152 -0
  294. package/dist/visio/collab/keys.d.ts +22 -0
  295. package/dist/visio/collab/keys.d.ts.map +1 -0
  296. package/dist/visio/collab/order.d.ts +11 -0
  297. package/dist/visio/collab/order.d.ts.map +1 -0
  298. package/dist/visio/collab/package.d.ts +37 -0
  299. package/dist/visio/collab/package.d.ts.map +1 -0
  300. package/dist/visio/collab/read.d.ts +41 -0
  301. package/dist/visio/collab/read.d.ts.map +1 -0
  302. package/dist/visio/collab/scan.d.ts +28 -0
  303. package/dist/visio/collab/scan.d.ts.map +1 -0
  304. package/dist/visio/collab/schema.d.ts +70 -0
  305. package/dist/visio/collab/schema.d.ts.map +1 -0
  306. package/dist/visio/collab/snapshot.d.ts +61 -0
  307. package/dist/visio/collab/snapshot.d.ts.map +1 -0
  308. package/dist/visio/collab/write.d.ts +20 -0
  309. package/dist/visio/collab/write.d.ts.map +1 -0
  310. package/dist/visio/index.cjs +159 -39
  311. package/dist/visio/index.mjs +159 -39
  312. package/dist/visio/ui/collab-options.d.ts +24 -0
  313. package/dist/visio/ui/collab-options.d.ts.map +1 -0
  314. package/dist/visio/ui/collab-presence.d.ts +31 -0
  315. package/dist/visio/ui/collab-presence.d.ts.map +1 -0
  316. package/dist/visio/ui/contract.d.ts +9 -3
  317. package/dist/visio/ui/contract.d.ts.map +1 -1
  318. package/dist/visio/ui/document-history.d.ts +3 -1
  319. package/dist/visio/ui/document-history.d.ts.map +1 -1
  320. package/dist/visio/ui/index.cjs +284 -95
  321. package/dist/visio/ui/index.d.ts +2 -0
  322. package/dist/visio/ui/index.d.ts.map +1 -1
  323. package/dist/visio/ui/index.mjs +278 -95
  324. package/dist/xlsx/collab/index.cjs +8 -3
  325. package/dist/xlsx/collab/index.mjs +8 -3
  326. package/dist/xlsx/compare/cells.d.ts +22 -0
  327. package/dist/xlsx/compare/cells.d.ts.map +1 -0
  328. package/dist/xlsx/compare/compare.d.ts +12 -0
  329. package/dist/xlsx/compare/compare.d.ts.map +1 -0
  330. package/dist/xlsx/compare/conditional.d.ts +7 -0
  331. package/dist/xlsx/compare/conditional.d.ts.map +1 -0
  332. package/dist/xlsx/compare/format-key.d.ts +34 -0
  333. package/dist/xlsx/compare/format-key.d.ts.map +1 -0
  334. package/dist/xlsx/compare/group.d.ts +8 -0
  335. package/dist/xlsx/compare/group.d.ts.map +1 -0
  336. package/dist/xlsx/compare/index.d.ts +5 -0
  337. package/dist/xlsx/compare/index.d.ts.map +1 -0
  338. package/dist/xlsx/compare/rich-text.d.ts +7 -0
  339. package/dist/xlsx/compare/rich-text.d.ts.map +1 -0
  340. package/dist/xlsx/compare/sheets.d.ts +22 -0
  341. package/dist/xlsx/compare/sheets.d.ts.map +1 -0
  342. package/dist/xlsx/compare/structure.d.ts +11 -0
  343. package/dist/xlsx/compare/structure.d.ts.map +1 -0
  344. package/dist/xlsx/compare/text.d.ts +8 -0
  345. package/dist/xlsx/compare/text.d.ts.map +1 -0
  346. package/dist/xlsx/compare/types.d.ts +173 -0
  347. package/dist/xlsx/compare/types.d.ts.map +1 -0
  348. package/dist/xlsx/edit/cell-values.d.ts.map +1 -1
  349. package/dist/xlsx/edit/clipboard-html.d.ts.map +1 -1
  350. package/dist/xlsx/edit/clipboard-text.d.ts.map +1 -1
  351. package/dist/xlsx/edit/clipboard.d.ts.map +1 -1
  352. package/dist/xlsx/edit/clone-cell.d.ts +9 -0
  353. package/dist/xlsx/edit/clone-cell.d.ts.map +1 -0
  354. package/dist/xlsx/edit/history.d.ts +8 -3
  355. package/dist/xlsx/edit/history.d.ts.map +1 -1
  356. package/dist/xlsx/edit/timelines.d.ts.map +1 -1
  357. package/dist/xlsx/formula/change-areas.d.ts +9 -0
  358. package/dist/xlsx/formula/change-areas.d.ts.map +1 -0
  359. package/dist/xlsx/formula/engine-prepare.d.ts +8 -0
  360. package/dist/xlsx/formula/engine-prepare.d.ts.map +1 -1
  361. package/dist/xlsx/formula/engine.d.ts.map +1 -1
  362. package/dist/xlsx/formula/spill.d.ts +5 -1
  363. package/dist/xlsx/formula/spill.d.ts.map +1 -1
  364. package/dist/xlsx/index.cjs +2461 -1192
  365. package/dist/xlsx/index.d.ts +1 -0
  366. package/dist/xlsx/index.d.ts.map +1 -1
  367. package/dist/xlsx/index.mjs +2454 -1193
  368. package/dist/xlsx/layout/cell-view.d.ts.map +1 -1
  369. package/dist/xlsx/layout/navigate.d.ts.map +1 -1
  370. package/dist/xlsx/layout/style-view.d.ts +5 -0
  371. package/dist/xlsx/layout/style-view.d.ts.map +1 -1
  372. package/dist/xlsx/load/csv-dates.d.ts +22 -0
  373. package/dist/xlsx/load/csv-dates.d.ts.map +1 -0
  374. package/dist/xlsx/load/csv-import.d.ts +64 -0
  375. package/dist/xlsx/load/csv-import.d.ts.map +1 -0
  376. package/dist/xlsx/load/csv-separators.d.ts +13 -0
  377. package/dist/xlsx/load/csv-separators.d.ts.map +1 -0
  378. package/dist/xlsx/load/csv-traits.d.ts +20 -0
  379. package/dist/xlsx/load/csv-traits.d.ts.map +1 -0
  380. package/dist/xlsx/load/csv.d.ts +8 -4
  381. package/dist/xlsx/load/csv.d.ts.map +1 -1
  382. package/dist/xlsx/load/detect.d.ts +13 -0
  383. package/dist/xlsx/load/detect.d.ts.map +1 -1
  384. package/dist/xlsx/load/errors.d.ts +1 -0
  385. package/dist/xlsx/load/errors.d.ts.map +1 -1
  386. package/dist/xlsx/load/index.cjs +537 -91
  387. package/dist/xlsx/load/index.d.ts +3 -1
  388. package/dist/xlsx/load/index.d.ts.map +1 -1
  389. package/dist/xlsx/load/index.mjs +536 -92
  390. package/dist/xlsx/numfmt/input-date.d.ts +2 -0
  391. package/dist/xlsx/numfmt/input-date.d.ts.map +1 -1
  392. package/dist/xlsx/pivot/cache-xml.d.ts.map +1 -1
  393. package/dist/xlsx/pivot/groups.d.ts.map +1 -1
  394. package/dist/xlsx/read/index.d.ts +2 -1
  395. package/dist/xlsx/read/index.d.ts.map +1 -1
  396. package/dist/xlsx/read/limits.d.ts +50 -0
  397. package/dist/xlsx/read/limits.d.ts.map +1 -0
  398. package/dist/xlsx/read/load.d.ts +11 -1
  399. package/dist/xlsx/read/load.d.ts.map +1 -1
  400. package/dist/xlsx/read/package.d.ts +5 -23
  401. package/dist/xlsx/read/package.d.ts.map +1 -1
  402. package/dist/xlsx/read/shared-strings.d.ts +2 -2
  403. package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
  404. package/dist/xlsx/read/worksheet.d.ts +2 -0
  405. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  406. package/dist/xlsx/stable-key.d.ts +3 -0
  407. package/dist/xlsx/stable-key.d.ts.map +1 -0
  408. package/dist/xlsx/styles.d.ts.map +1 -1
  409. package/dist/xlsx/ui/index.cjs +662 -372
  410. package/dist/xlsx/ui/index.mjs +662 -372
  411. package/dist/xlsx/ui/locales/de/shell.d.ts.map +1 -1
  412. package/dist/xlsx/ui/locales/en/shell.d.ts.map +1 -1
  413. package/dist/xlsx/ui/locales/es/shell.d.ts.map +1 -1
  414. package/dist/xlsx/ui/locales/fr/shell.d.ts.map +1 -1
  415. package/dist/xlsx/ui/locales/zh-CN/shell.d.ts.map +1 -1
  416. package/dist/xlsx/write/sheet-props.d.ts.map +1 -1
  417. package/dist/xml/index.cjs +32 -3
  418. package/dist/xml/index.mjs +32 -4
  419. package/dist/xml/xml.d.ts +11 -1
  420. package/dist/xml/xml.d.ts.map +1 -1
  421. package/package.json +6 -1
  422. package/dist/PptxHandler-SITN3K3F.mjs +0 -4
@@ -12,6 +12,19 @@ var DEFAULT_XML_LIMITS = {
12
12
  maxDepth: 512,
13
13
  maxNodes: 5e6
14
14
  };
15
+ var XmlLimitError = class extends Error {
16
+ code = "xml-limit";
17
+ /** The limit that was exceeded. */
18
+ limit;
19
+ /** Its value: the largest depth or element count allowed. */
20
+ maximum;
21
+ constructor(message, limit, maximum) {
22
+ super(message);
23
+ this.name = "XmlLimitError";
24
+ this.limit = limit;
25
+ this.maximum = maximum;
26
+ }
27
+ };
15
28
  var TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
16
29
  var MARKUP_SKIPS = [
17
30
  ["<!--", "-->"],
@@ -45,11 +58,22 @@ function checkXmlLimits(xml, label, limits = {}) {
45
58
  continue;
46
59
  }
47
60
  nodes++;
48
- if (nodes > maxNodes) throw new Error(`${label} XML exceeds the limit of ${maxNodes} elements`);
61
+ if (nodes > maxNodes)
62
+ throw new XmlLimitError(
63
+ `${label} XML exceeds the limit of ${maxNodes} elements`,
64
+ "maxNodes",
65
+ maxNodes
66
+ );
49
67
  if (!selfClosing && ++depth > maxDepth)
50
- throw new Error(`${label} XML exceeds the nesting depth limit of ${maxDepth}`);
68
+ throw new XmlLimitError(
69
+ `${label} XML exceeds the nesting depth limit of ${maxDepth}`,
70
+ "maxDepth",
71
+ maxDepth
72
+ );
51
73
  }
52
74
  }
75
+ var CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
76
+ var crlfDeclarations = /* @__PURE__ */ new WeakSet();
53
77
  function parseXml(xml, options2 = {}) {
54
78
  const label = options2.label ?? "OOXML";
55
79
  if (/<!DOCTYPE|<!ENTITY/i.test(xml))
@@ -71,9 +95,13 @@ function parseXml(xml, options2 = {}) {
71
95
  }
72
96
  if (parseError || !parsed.documentElement)
73
97
  throw new Error(`Invalid ${label} XML: ${parseError || "missing root element"}`);
98
+ if (CRLF_DECLARATION.test(xml)) crlfDeclarations.add(parsed);
74
99
  return parsed;
75
100
  }
76
- var buildXml = (node) => new xmldom.XMLSerializer().serializeToString(node);
101
+ var buildXml = (node) => {
102
+ const xml = new xmldom.XMLSerializer().serializeToString(node);
103
+ return crlfDeclarations.has(node) ? xml.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml;
104
+ };
77
105
  var isElement = (node) => node.nodeType === 1;
78
106
  var elements = (parent) => Array.from(parent.childNodes).filter(isElement);
79
107
  function named(element, local, ns, lenient = true) {
@@ -1491,9 +1519,10 @@ function expectDefined(value, context) {
1491
1519
  // docx/element-order.ts
1492
1520
  function orderChildren(parent, order) {
1493
1521
  const elements2 = Array.from(parent.childNodes).filter(isElement);
1522
+ const rankOf = (name) => order.findIndex((entry) => typeof entry === "string" ? entry === name : entry.includes(name));
1494
1523
  let previousRank = -1;
1495
1524
  const ranked = elements2.map((element, index) => {
1496
- const rank = element.namespaceURI === WORD_NS ? order.indexOf(element.localName ?? "") : -1;
1525
+ const rank = element.namespaceURI === WORD_NS ? rankOf(element.localName ?? "") : -1;
1497
1526
  if (rank >= 0) previousRank = rank;
1498
1527
  return { element, index, rank: rank >= 0 ? rank : previousRank + 0.5 };
1499
1528
  });
@@ -1556,6 +1585,35 @@ function orderParagraphProperties(props) {
1556
1585
  orderChildren(props, PPR_ORDER);
1557
1586
  }
1558
1587
 
1588
+ // docx/special-characters.ts
1589
+ function symbolCharacter(char) {
1590
+ const code = /^[0-9a-f]{1,6}$/i.test(char) ? Number.parseInt(char, 16) : Number.NaN;
1591
+ if (!Number.isInteger(code) || code > 1114111 || code >= 55296 && code <= 57343) return "";
1592
+ return String.fromCodePoint(code < 256 ? 61440 + code : code);
1593
+ }
1594
+ function symbolOnly(run) {
1595
+ const symbol = run.symbol && symbolCharacter(run.symbol.char);
1596
+ return Boolean(symbol && run.text && [...run.text].every((character) => character === symbol));
1597
+ }
1598
+ function symbolSegments(run) {
1599
+ const symbol = run.symbol && symbolCharacter(run.symbol.char);
1600
+ if (!symbol || symbolOnly(run) || !run.text.includes(symbol)) return [run];
1601
+ const segments = [];
1602
+ let piece = "";
1603
+ let symbols = false;
1604
+ for (const character of run.text) {
1605
+ const isSymbol = character === symbol;
1606
+ if (piece && isSymbol !== symbols) {
1607
+ segments.push({ ...run, text: piece });
1608
+ piece = "";
1609
+ }
1610
+ piece += character;
1611
+ symbols = isSymbol;
1612
+ }
1613
+ if (piece) segments.push({ ...run, text: piece });
1614
+ return segments;
1615
+ }
1616
+
1559
1617
  // docx/revision-properties.ts
1560
1618
  function parsePropertiesSnapshot(xml, local) {
1561
1619
  const element = parseXml2(xml).documentElement;
@@ -1564,142 +1622,6 @@ function parsePropertiesSnapshot(xml, local) {
1564
1622
  return element;
1565
1623
  }
1566
1624
 
1567
- // docx/write-run-validation.ts
1568
- var modeledRunProperties = /* @__PURE__ */ new Set([
1569
- "b",
1570
- "i",
1571
- "bCs",
1572
- "iCs",
1573
- "szCs",
1574
- "strike",
1575
- "u",
1576
- "highlight",
1577
- "vertAlign",
1578
- "sz",
1579
- "rFonts",
1580
- "color",
1581
- "lang",
1582
- "rtl",
1583
- "rStyle",
1584
- "caps",
1585
- "smallCaps",
1586
- "dstrike",
1587
- "vanish",
1588
- "spacing",
1589
- "w",
1590
- "kern",
1591
- "position",
1592
- "shd"
1593
- ]);
1594
- var simpleToggleProperties = [
1595
- "b",
1596
- "i",
1597
- "bCs",
1598
- "iCs",
1599
- "strike",
1600
- "caps",
1601
- "smallCaps",
1602
- "dstrike",
1603
- "vanish"
1604
- ];
1605
- var allowedRunPropertyAttributes = {
1606
- rFonts: [
1607
- "ascii",
1608
- "hAnsi",
1609
- "eastAsia",
1610
- "cs",
1611
- "asciiTheme",
1612
- "hAnsiTheme",
1613
- "eastAsiaTheme",
1614
- "cstheme"
1615
- ],
1616
- lang: ["val", "eastAsia", "bidi"],
1617
- highlight: ["val"],
1618
- vertAlign: ["val"],
1619
- sz: ["val"],
1620
- szCs: ["val"],
1621
- rtl: ["val"],
1622
- rStyle: ["val"],
1623
- spacing: ["val"],
1624
- w: ["val"],
1625
- kern: ["val"],
1626
- position: ["val"],
1627
- u: ["val", "color"],
1628
- color: ["val", "themeColor", "themeTint", "themeShade"],
1629
- shd: ["val", "fill", "color", "themeFill", "themeFillTint", "themeFillShade"]
1630
- };
1631
- function hasUnexpectedAttributes(element, allowed, allowDateUtc = false) {
1632
- for (const attribute of Array.from(element.attributes)) {
1633
- if (attribute.namespaceURI === "http://www.w3.org/2000/xmlns/") continue;
1634
- if (allowDateUtc && attribute.namespaceURI === WORD_DATE_UTC_NS && attribute.localName === "dateUtc")
1635
- continue;
1636
- if (attribute.namespaceURI !== WORD_NS || !allowed.includes(attribute.localName)) return true;
1637
- }
1638
- return false;
1639
- }
1640
- function runPropertiesHaveUnknownContent(properties2) {
1641
- if (!properties2) return false;
1642
- if (hasUnexpectedAttributes(properties2, [])) return true;
1643
- for (const node of Array.from(properties2.childNodes)) {
1644
- if (node.nodeType !== 1) {
1645
- if (node.nodeType === 3 && node.textContent?.trim()) return true;
1646
- continue;
1647
- }
1648
- const property = node;
1649
- if (property.namespaceURI === WORD_NS && property.localName === "rPrChange") {
1650
- if (hasUnexpectedAttributes(property, ["id", "author", "date"], true) || Array.from(property.childNodes).some(
1651
- (child2) => child2.nodeType === 3 && child2.textContent?.trim()
1652
- ) || elements(property).length !== 1 || !first2(property, "rPr") || !getW(property, "id") || !getW(property, "author"))
1653
- return true;
1654
- continue;
1655
- }
1656
- if (property.namespaceURI === WORD_2010_NS && property.localName === "ligatures") {
1657
- if (!isLigatures(property.getAttributeNS(WORD_2010_NS, "val")) || elements(property).length)
1658
- return true;
1659
- if (Array.from(property.attributes).some(
1660
- (attribute) => attribute.namespaceURI !== "http://www.w3.org/2000/xmlns/" && (attribute.namespaceURI !== WORD_2010_NS || attribute.localName !== "val")
1661
- ))
1662
- return true;
1663
- continue;
1664
- }
1665
- if (property.namespaceURI !== WORD_NS || !modeledRunProperties.has(property.localName))
1666
- return true;
1667
- const allowed = simpleToggleProperties.includes(property.localName) ? ["val"] : allowedRunPropertyAttributes[property.localName] ?? [];
1668
- if (hasUnexpectedAttributes(property, allowed) || elements(property).length > 0) return true;
1669
- const value = getW(property, "val");
1670
- if (property.localName === "w" && parseTextScale(value ?? "100") === void 0) return true;
1671
- if (property.localName === "kern" && parseHalfPoints(value) === void 0) return true;
1672
- if (property.localName === "position" && parseSignedHalfPoints(value) === void 0)
1673
- return true;
1674
- if (property.localName === "highlight" && value && !isWordHighlightToken(value)) return true;
1675
- if (property.localName === "rtl" && value && !["1", "true", "on", "0", "false", "off", "no"].includes(value))
1676
- return true;
1677
- if (property.localName === "lang" && ["val", "eastAsia", "bidi"].some((key) => {
1678
- const language = getW(property, key);
1679
- return language !== void 0 && !isValidLanguageTag(language);
1680
- }))
1681
- return true;
1682
- if (property.localName === "vertAlign" && !isStVerticalAlignRun(value)) return true;
1683
- if (property.localName === "u" && value && !isWordUnderlineStyle(value) && !["0", "false", "off", "1", "true", "on"].includes(value))
1684
- return true;
1685
- if (property.localName === "u") {
1686
- const color = getW(property, "color");
1687
- if (color && parseHexColor(color) === void 0) return true;
1688
- }
1689
- if (["sz", "szCs"].includes(property.localName) && value && parseHalfPoints(value) === void 0)
1690
- return true;
1691
- if (property.localName === "spacing" && value && parseSignedTwips(value) === void 0)
1692
- return true;
1693
- if (property.localName === "color" || property.localName === "shd") {
1694
- const fillValue = property.localName === "shd" ? getW(property, "fill") : value;
1695
- if (fillValue && parseHexColor(fillValue) === void 0) return true;
1696
- const themeValue = getW(property, property.localName === "shd" ? "themeFill" : "themeColor");
1697
- if (themeValue && !isThemeColorToken(themeValue)) return true;
1698
- }
1699
- }
1700
- return false;
1701
- }
1702
-
1703
1625
  // docx/defined-props.ts
1704
1626
  function definedProps(source) {
1705
1627
  return Object.fromEntries(Object.entries(source).filter(([, value]) => value !== void 0));
@@ -11625,6 +11547,17 @@ function composeDataLabelText(input) {
11625
11547
  return { text: text2, color: parts.length === 1 && flags.showValue ? valueColor : void 0 };
11626
11548
  }
11627
11549
 
11550
+ // chart/extent.ts
11551
+ function extentOf(values) {
11552
+ let min = Infinity;
11553
+ let max = -Infinity;
11554
+ for (const value of values) {
11555
+ min = Math.min(min, value);
11556
+ max = Math.max(max, value);
11557
+ }
11558
+ return { min, max };
11559
+ }
11560
+
11628
11561
  // chart/bubble-radius.ts
11629
11562
  function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options2) {
11630
11563
  const scale = (options2?.bubbleScale ?? 100) / 100;
@@ -11635,7 +11568,7 @@ function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options2) {
11635
11568
  return medianRadius * scale * 0.5 + ratio * medianRadius * scale * 1.5;
11636
11569
  }
11637
11570
  function maxBubbleSize(sizes) {
11638
- return sizes.length > 0 ? Math.max(1, ...sizes.map(Math.abs)) : 1;
11571
+ return Math.max(1, extentOf(sizes.map(Math.abs)).max);
11639
11572
  }
11640
11573
  function medianBubbleRadius(plotWidth, plotHeight) {
11641
11574
  return Math.min(plotWidth, plotHeight) * 0.04;
@@ -11981,8 +11914,7 @@ function computeHistogramBins(values, options2, format = String) {
11981
11914
  });
11982
11915
  }
11983
11916
  if (regular.length > 0) {
11984
- const min = Math.min(...regular.map((item) => item.value));
11985
- const max = Math.max(...regular.map((item) => item.value));
11917
+ const { min, max } = extentOf(regular.map((item) => item.value));
11986
11918
  const requestedSize = options2.binSize && options2.binSize > 0 ? options2.binSize : void 0;
11987
11919
  const requestedCount = options2.binCount && options2.binCount > 0 ? options2.binCount : void 0;
11988
11920
  const start = requestedSize ? Math.floor(min / requestedSize) * requestedSize : min;
@@ -12182,8 +12114,9 @@ function fitChartTrendline(options2, xVals, yVals) {
12182
12114
  }
12183
12115
  const model = fitModel(options2, xVals, yVals);
12184
12116
  if (!model) return noFit();
12185
- const startX = Math.min(...xVals) - (options2.backward ?? 0);
12186
- const endX = Math.max(...xVals) + (options2.forward ?? 0);
12117
+ const xRange = extentOf(xVals);
12118
+ const startX = xRange.min - (options2.backward ?? 0);
12119
+ const endX = xRange.max + (options2.forward ?? 0);
12187
12120
  const steps = Math.max(Math.ceil((endX - startX) * 4), 20);
12188
12121
  const points = [];
12189
12122
  for (let step = 0; step <= steps; step++) {
@@ -13716,8 +13649,7 @@ function computeLogValueRange(series, logBase) {
13716
13649
  if (allValues.length === 0) {
13717
13650
  return { min: 1, max: logBase, span: 1, logScale: true, logBase };
13718
13651
  }
13719
- const dataMin = Math.min(...allValues);
13720
- const dataMax = Math.max(...allValues);
13652
+ const { min: dataMin, max: dataMax } = extentOf(allValues);
13721
13653
  const logMin = Math.floor(Math.log(dataMin) / Math.log(logBase));
13722
13654
  const logMax = Math.ceil(Math.log(dataMax) / Math.log(logBase));
13723
13655
  const min = logBase ** logMin;
@@ -14282,8 +14214,9 @@ function waterfallView(chart, model, ctx) {
14282
14214
  colors: { increase: role(0), decrease: role(1), total: role(2) }
14283
14215
  };
14284
14216
  const ends = steps.flatMap((step) => [step.startValue, step.endValue]);
14217
+ const range = extentOf(ends);
14285
14218
  model.valueAxis = {
14286
- ...ends.length ? niceScale(Math.min(...ends), Math.max(...ends)) : niceScale(0, 1),
14219
+ ...ends.length ? niceScale(range.min, range.max) : niceScale(0, 1),
14287
14220
  percent: false
14288
14221
  };
14289
14222
  const labels = model.categories;
@@ -14399,7 +14332,8 @@ function chartSummaryView(chart, theme, options2 = {}) {
14399
14332
  s.xValues = s.values.map((_, k) => numeric ? toNumber(cats[k] ?? null) : k + 1);
14400
14333
  });
14401
14334
  const xs = series.flatMap((s) => s.xValues ?? []).filter((x) => x !== null);
14402
- model.xAxis = xs.length ? niceScale(Math.min(...xs), Math.max(...xs)) : niceScale(0, 1);
14335
+ const range = extentOf(xs);
14336
+ model.xAxis = xs.length ? niceScale(range.min, range.max) : niceScale(0, 1);
14403
14337
  }
14404
14338
  if (type === "stock") model.stock = stockView(chart.stock, ctx);
14405
14339
  if (type === "bubble") bubbleView(chart, model, ctx.evaluateRef);
@@ -14431,7 +14365,7 @@ function cartesianAxes(model, area, out) {
14431
14365
  const cats = Math.max(1, model.categories.length);
14432
14366
  const catW = Math.min(
14433
14367
  area.w * 0.3,
14434
- Math.max(...model.categories.map((c) => textWidth(c, categorySize)), 8) + 6
14368
+ Math.max(extentOf(model.categories.map((c) => textWidth(c, categorySize))).max, 8) + 6
14435
14369
  );
14436
14370
  const second = horizontal ? void 0 : model.secondaryAxis;
14437
14371
  const secondLabels = second?.ticks.map((t) => axisTickText(t, model.axes?.secondary, second.percent)) ?? [];
@@ -15124,13 +15058,11 @@ function chartLegendSvg(model, area, frame2, options2) {
15124
15058
  chartAreaRect(model, "legend", { x: manual.x, y: manual.y, w: manual.width, h: manual.height })
15125
15059
  ];
15126
15060
  const baselineOffset = font ? (font.ascent - font.descent) / 2 : size * 0.35;
15061
+ const widest = extentOf(widths).max;
15127
15062
  entries.forEach((entry, i) => {
15128
15063
  const available = horizontal ? chartTextWidth(entry.label, attrs, options2) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
15129
15064
  const label = fitChartText(entry.label, available, attrs, options2);
15130
- const contentWidth = Math.min(
15131
- horizontal ? widths[i] ?? 0 : Math.max(...widths),
15132
- rowWidth - size / 2
15133
- );
15065
+ const contentWidth = Math.min(horizontal ? widths[i] ?? 0 : widest, rowWidth - size / 2);
15134
15066
  const x = horizontal ? horizontalX : manual.x + Math.max(size / 4, (rowWidth - contentWidth) / 2);
15135
15067
  const centerY = manual.y + (horizontal ? 0 : i * rowHeight) + rowHeight / 2;
15136
15068
  markup.push(rect2(x, centerY - keySize / 2, keySize, keySize, entry.color));
@@ -15202,7 +15134,7 @@ function automaticLegend(model, area, out, options2, bounds) {
15202
15134
  }
15203
15135
  const width = Math.min(
15204
15136
  area.w * 0.35,
15205
- Math.max(...entries.map((e) => chartTextWidth(e.label, attrs, options2))) + 22
15137
+ extentOf(entries.map((e) => chartTextWidth(e.label, attrs, options2))).max + 22
15206
15138
  );
15207
15139
  const height = entries.length * rowH;
15208
15140
  const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
@@ -15540,41 +15472,195 @@ function renderChartSummarySvg(summary, options2) {
15540
15472
  return renderChartSvg(view, width, height, svg);
15541
15473
  }
15542
15474
 
15543
- // docx/restore-run-format.ts
15544
- function parseRunPropertiesSnapshot(xml) {
15545
- return parsePropertiesSnapshot(xml, "rPr");
15546
- }
15547
- function restoreRunFormatting(run) {
15548
- const nested = run.formatRevision;
15549
- const xml = (nested ?? run.revision)?.previousRunPropertiesXml;
15550
- if (!xml)
15551
- throw new Error(
15552
- "Cannot reject a formatting revision without its prior run-properties snapshot."
15553
- );
15554
- const snapshot2 = parseRunPropertiesSnapshot(xml);
15555
- const previous = parseDirectRunProperties(snapshot2);
15556
- for (const key of DIRECT_RUN_PROPERTY_KEYS) delete run[key];
15557
- Object.assign(run, previous);
15558
- run.restoredRunPropertiesXml = xml;
15559
- if (runPropertiesHaveUnknownContent(snapshot2)) run.sourceRunPropertiesXml = buildXml(snapshot2);
15560
- else delete run.sourceRunPropertiesXml;
15561
- if (nested) delete run.formatRevision;
15562
- else delete run.revision;
15563
- }
15564
-
15565
- // docx/field-lock.ts
15566
- function isFieldLocked(run) {
15567
- return run?.fieldFlags?.locked === true;
15475
+ // docx/write-run-validation.ts
15476
+ var modeledRunProperties = /* @__PURE__ */ new Set([
15477
+ "b",
15478
+ "i",
15479
+ "bCs",
15480
+ "iCs",
15481
+ "szCs",
15482
+ "strike",
15483
+ "u",
15484
+ "highlight",
15485
+ "vertAlign",
15486
+ "sz",
15487
+ "rFonts",
15488
+ "color",
15489
+ "lang",
15490
+ "rtl",
15491
+ "rStyle",
15492
+ "caps",
15493
+ "smallCaps",
15494
+ "dstrike",
15495
+ "vanish",
15496
+ "spacing",
15497
+ "w",
15498
+ "kern",
15499
+ "position",
15500
+ "shd"
15501
+ ]);
15502
+ var simpleToggleProperties = [
15503
+ "b",
15504
+ "i",
15505
+ "bCs",
15506
+ "iCs",
15507
+ "strike",
15508
+ "caps",
15509
+ "smallCaps",
15510
+ "dstrike",
15511
+ "vanish"
15512
+ ];
15513
+ var allowedRunPropertyAttributes = {
15514
+ rFonts: [
15515
+ "ascii",
15516
+ "hAnsi",
15517
+ "eastAsia",
15518
+ "cs",
15519
+ "asciiTheme",
15520
+ "hAnsiTheme",
15521
+ "eastAsiaTheme",
15522
+ "cstheme"
15523
+ ],
15524
+ lang: ["val", "eastAsia", "bidi"],
15525
+ highlight: ["val"],
15526
+ vertAlign: ["val"],
15527
+ sz: ["val"],
15528
+ szCs: ["val"],
15529
+ rtl: ["val"],
15530
+ rStyle: ["val"],
15531
+ spacing: ["val"],
15532
+ w: ["val"],
15533
+ kern: ["val"],
15534
+ position: ["val"],
15535
+ u: ["val", "color"],
15536
+ color: ["val", "themeColor", "themeTint", "themeShade"],
15537
+ shd: ["val", "fill", "color", "themeFill", "themeFillTint", "themeFillShade"]
15538
+ };
15539
+ function hasUnexpectedAttributes(element, allowed, allowDateUtc = false) {
15540
+ for (const attribute of Array.from(element.attributes)) {
15541
+ if (attribute.namespaceURI === "http://www.w3.org/2000/xmlns/") continue;
15542
+ if (allowDateUtc && attribute.namespaceURI === WORD_DATE_UTC_NS && attribute.localName === "dateUtc")
15543
+ continue;
15544
+ if (attribute.namespaceURI !== WORD_NS || !allowed.includes(attribute.localName)) return true;
15545
+ }
15546
+ return false;
15568
15547
  }
15569
-
15570
- // docx/paragraph-properties.ts
15571
- var signedTwipValue = parseSignedTwips;
15572
- var twipValue = parseTwips;
15573
- function parseDirectParagraphProperties(props) {
15574
- const paragraph = {};
15575
- const bidi = onOffElement(first2(props, "bidi"));
15576
- if (bidi !== void 0) paragraph.direction = bidi ? "rtl" : "ltr";
15577
- const { align, justification } = parseJustification(props);
15548
+ function runPropertiesHaveUnknownContent(properties2) {
15549
+ if (!properties2) return false;
15550
+ if (hasUnexpectedAttributes(properties2, [])) return true;
15551
+ for (const node of Array.from(properties2.childNodes)) {
15552
+ if (node.nodeType !== 1) {
15553
+ if (node.nodeType === 3 && node.textContent?.trim()) return true;
15554
+ continue;
15555
+ }
15556
+ const property = node;
15557
+ if (property.namespaceURI === WORD_NS && property.localName === "rPrChange") {
15558
+ if (hasUnexpectedAttributes(property, ["id", "author", "date"], true) || Array.from(property.childNodes).some(
15559
+ (child2) => child2.nodeType === 3 && child2.textContent?.trim()
15560
+ ) || elements(property).length !== 1 || !first2(property, "rPr") || !getW(property, "id") || !getW(property, "author"))
15561
+ return true;
15562
+ continue;
15563
+ }
15564
+ if (property.namespaceURI === WORD_2010_NS && property.localName === "ligatures") {
15565
+ if (!isLigatures(property.getAttributeNS(WORD_2010_NS, "val")) || elements(property).length)
15566
+ return true;
15567
+ if (Array.from(property.attributes).some(
15568
+ (attribute) => attribute.namespaceURI !== "http://www.w3.org/2000/xmlns/" && (attribute.namespaceURI !== WORD_2010_NS || attribute.localName !== "val")
15569
+ ))
15570
+ return true;
15571
+ continue;
15572
+ }
15573
+ if (property.namespaceURI !== WORD_NS || !modeledRunProperties.has(property.localName))
15574
+ return true;
15575
+ const allowed = simpleToggleProperties.includes(property.localName) ? ["val"] : allowedRunPropertyAttributes[property.localName] ?? [];
15576
+ if (hasUnexpectedAttributes(property, allowed) || elements(property).length > 0) return true;
15577
+ const value = getW(property, "val");
15578
+ if (property.localName === "w" && parseTextScale(value ?? "100") === void 0) return true;
15579
+ if (property.localName === "kern" && parseHalfPoints(value) === void 0) return true;
15580
+ if (property.localName === "position" && parseSignedHalfPoints(value) === void 0)
15581
+ return true;
15582
+ if (property.localName === "highlight" && value && !isWordHighlightToken(value)) return true;
15583
+ if (property.localName === "rtl" && value && !["1", "true", "on", "0", "false", "off", "no"].includes(value))
15584
+ return true;
15585
+ if (property.localName === "lang" && ["val", "eastAsia", "bidi"].some((key) => {
15586
+ const language = getW(property, key);
15587
+ return language !== void 0 && !isValidLanguageTag(language);
15588
+ }))
15589
+ return true;
15590
+ if (property.localName === "vertAlign" && !isStVerticalAlignRun(value)) return true;
15591
+ if (property.localName === "u" && value && !isWordUnderlineStyle(value) && !["0", "false", "off", "1", "true", "on"].includes(value))
15592
+ return true;
15593
+ if (property.localName === "u") {
15594
+ const color = getW(property, "color");
15595
+ if (color && parseHexColor(color) === void 0) return true;
15596
+ }
15597
+ if (["sz", "szCs"].includes(property.localName) && value && parseHalfPoints(value) === void 0)
15598
+ return true;
15599
+ if (property.localName === "spacing" && value && parseSignedTwips(value) === void 0)
15600
+ return true;
15601
+ if (property.localName === "color" || property.localName === "shd") {
15602
+ const fillValue = property.localName === "shd" ? getW(property, "fill") : value;
15603
+ if (fillValue && parseHexColor(fillValue) === void 0) return true;
15604
+ const themeValue = getW(property, property.localName === "shd" ? "themeFill" : "themeColor");
15605
+ if (themeValue && !isThemeColorToken(themeValue)) return true;
15606
+ }
15607
+ }
15608
+ return false;
15609
+ }
15610
+
15611
+ // docx/restore-run-format.ts
15612
+ function parseRunPropertiesSnapshot(xml) {
15613
+ return parsePropertiesSnapshot(xml, "rPr");
15614
+ }
15615
+ function restoreRunFormatting(run) {
15616
+ const nested = run.formatRevision;
15617
+ const xml = (nested ?? run.revision)?.previousRunPropertiesXml;
15618
+ if (!xml)
15619
+ throw new Error(
15620
+ "Cannot reject a formatting revision without its prior run-properties snapshot."
15621
+ );
15622
+ const snapshot2 = parseRunPropertiesSnapshot(xml);
15623
+ const previous = parseDirectRunProperties(snapshot2);
15624
+ for (const key of DIRECT_RUN_PROPERTY_KEYS) delete run[key];
15625
+ Object.assign(run, previous);
15626
+ run.restoredRunPropertiesXml = xml;
15627
+ if (runPropertiesHaveUnknownContent(snapshot2)) run.sourceRunPropertiesXml = buildXml(snapshot2);
15628
+ else delete run.sourceRunPropertiesXml;
15629
+ if (nested) delete run.formatRevision;
15630
+ else delete run.revision;
15631
+ }
15632
+
15633
+ // docx/form-fields.ts
15634
+ var formCheckboxChecked = (field) => field.checkBox?.checked ?? field.checkBox?.default ?? false;
15635
+ function formDropDownIndex(field) {
15636
+ const entries = field.dropDown?.entries ?? [];
15637
+ for (const index of [field.dropDown?.result, field.dropDown?.default, 0])
15638
+ if (index !== void 0 && index >= 0 && index < entries.length) return index;
15639
+ return void 0;
15640
+ }
15641
+ function formFieldDisplayText(run) {
15642
+ const field = run.fieldChar === "begin" ? run.formField : void 0;
15643
+ if (field?.kind === "checkbox") return formCheckboxChecked(field) ? "\u2612" : "\u2610";
15644
+ if (field?.kind === "dropDown") {
15645
+ const index = formDropDownIndex(field);
15646
+ return index === void 0 ? "" : field.dropDown.entries[index];
15647
+ }
15648
+ return void 0;
15649
+ }
15650
+
15651
+ // docx/field-lock.ts
15652
+ function isFieldLocked(run) {
15653
+ return run?.fieldFlags?.locked === true;
15654
+ }
15655
+
15656
+ // docx/paragraph-properties.ts
15657
+ var signedTwipValue = parseSignedTwips;
15658
+ var twipValue = parseTwips;
15659
+ function parseDirectParagraphProperties(props) {
15660
+ const paragraph = {};
15661
+ const bidi = onOffElement(first2(props, "bidi"));
15662
+ if (bidi !== void 0) paragraph.direction = bidi ? "rtl" : "ltr";
15663
+ const { align, justification } = parseJustification(props);
15578
15664
  if (align) paragraph.align = align;
15579
15665
  if (justification) paragraph.justification = justification;
15580
15666
  const style = getW(first2(props, "pStyle"), "val");
@@ -15664,62 +15750,54 @@ function resolveNumberingLevel(catalog, numId, level2) {
15664
15750
  return start !== base.start ? { ...base, start } : base;
15665
15751
  }
15666
15752
 
15667
- // docx/document-paragraphs.ts
15668
- function mapBlockParagraphs(blocks, map) {
15669
- return blocks.map(
15670
- (block) => block.type === "paragraph" ? map(block) : {
15671
- ...block,
15672
- rows: block.rows.map(
15673
- (row2) => row2.map((cell) => ({ ...cell, paragraphs: cell.paragraphs.map(map) }))
15674
- )
15753
+ // docx/field-instruction.ts
15754
+ function fieldTokens(instr) {
15755
+ const tokens = [];
15756
+ let index = 0;
15757
+ while (index < instr.length) {
15758
+ const char = instr[index];
15759
+ if (/\s/.test(char)) {
15760
+ index++;
15761
+ continue;
15675
15762
  }
15676
- );
15763
+ if (char === '"') {
15764
+ let value = "";
15765
+ index++;
15766
+ while (index < instr.length && instr[index] !== '"') {
15767
+ if (instr[index] === "\\" && /["\\]/.test(instr[index + 1] ?? "")) index++;
15768
+ value += instr[index++];
15769
+ }
15770
+ index++;
15771
+ tokens.push({ kind: "text", value });
15772
+ continue;
15773
+ }
15774
+ const switchMatch = /^\\([*#@!]|[A-Za-z]{1,2}(?![A-Za-z]))/.exec(instr.slice(index));
15775
+ if (switchMatch) {
15776
+ tokens.push({ kind: "switch", value: switchMatch[1].toLowerCase() });
15777
+ index += switchMatch[0].length;
15778
+ continue;
15779
+ }
15780
+ const word = /^\S+/.exec(instr.slice(index))[0];
15781
+ tokens.push({ kind: "text", value: word });
15782
+ index += word.length;
15783
+ }
15784
+ return tokens;
15677
15785
  }
15678
- function mapDocumentParagraphs(model, map) {
15679
- const slots = (value) => Object.fromEntries(
15680
- Object.entries(value).map(
15681
- ([key, content]) => [
15682
- key,
15683
- content ? { ...content, blocks: mapBlockParagraphs(content.blocks, map) } : content
15684
- ]
15685
- )
15786
+ var TEXT_CASES = /* @__PURE__ */ new Set(["upper", "lower", "firstcap", "caps"]);
15787
+ var isFieldTextCase = (format) => TEXT_CASES.has(format.toLowerCase());
15788
+ function applyFieldTextCase(text2, format) {
15789
+ if (format === "upper") return text2.toUpperCase();
15790
+ if (format === "lower") return text2.toLowerCase();
15791
+ const capitalize = (word) => word.replace(
15792
+ /^(\P{L}*)(\p{L})/u,
15793
+ (_match, lead, letter) => `${lead}${letter.toUpperCase()}`
15686
15794
  );
15687
- return {
15688
- ...model,
15689
- blocks: mapBlockParagraphs(model.blocks, map),
15690
- ...model.sections ? {
15691
- sections: model.sections.map((section) => ({
15692
- ...section,
15693
- ...section.headers ? { headers: slots(section.headers) } : {},
15694
- ...section.footers ? { footers: slots(section.footers) } : {}
15695
- }))
15696
- } : {},
15697
- ...model.footnoteSeparators ? {
15698
- footnoteSeparators: Object.fromEntries(
15699
- Object.entries(model.footnoteSeparators).map(([kind, note]) => [
15700
- kind,
15701
- { ...note, blocks: mapBlockParagraphs(note.blocks, map) }
15702
- ])
15703
- )
15704
- } : {},
15705
- ...model.footnotes ? {
15706
- footnotes: model.footnotes.map((note) => ({
15707
- ...note,
15708
- blocks: mapBlockParagraphs(note.blocks, map)
15709
- }))
15710
- } : {},
15711
- ...model.endnotes ? {
15712
- endnotes: model.endnotes.map((note) => ({
15713
- ...note,
15714
- blocks: mapBlockParagraphs(note.blocks, map)
15715
- }))
15716
- } : {}
15717
- };
15718
- }
15719
-
15720
- // docx/field-runs.ts
15721
- function fieldName(instr) {
15722
- return instr.trim().split(/\s+/)[0]?.toUpperCase() ?? "";
15795
+ if (format === "firstcap")
15796
+ return text2.replace(
15797
+ /^(\s*)(\S+)/,
15798
+ (_match, space, word) => `${space}${capitalize(word)}`
15799
+ );
15800
+ return text2.replace(/\S+/g, capitalize);
15723
15801
  }
15724
15802
 
15725
15803
  // docx/cell-blocks.ts
@@ -15747,195 +15825,70 @@ function cellSourceBlocks(cell) {
15747
15825
  blocks.push(...cell.paragraphs.slice(cursor));
15748
15826
  return blocks;
15749
15827
  }
15828
+ function documentParagraphs(blocks) {
15829
+ const result = [];
15830
+ const visit = (items) => {
15831
+ for (const block of items) {
15832
+ if (block.type === "paragraph") result.push(block);
15833
+ else for (const row2 of block.rows) for (const cell of row2) visit(cellSourceBlocks(cell));
15834
+ }
15835
+ };
15836
+ visit(blocks);
15837
+ return result;
15838
+ }
15750
15839
 
15751
- // docx/notes.ts
15752
- var romanNumerals = [
15753
- [1e3, "M"],
15754
- [900, "CM"],
15755
- [500, "D"],
15756
- [400, "CD"],
15757
- [100, "C"],
15758
- [90, "XC"],
15759
- [50, "L"],
15760
- [40, "XL"],
15761
- [10, "X"],
15762
- [9, "IX"],
15763
- [5, "V"],
15764
- [4, "IV"],
15765
- [1, "I"]
15766
- ];
15767
- function toRoman(value) {
15768
- let remaining = Math.max(1, Math.round(value));
15840
+ // docx/numbering-text.ts
15841
+ function romanNumeral(n2) {
15842
+ const values = [1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
15843
+ const numerals = [
15844
+ "M",
15845
+ "CM",
15846
+ "D",
15847
+ "CD",
15848
+ "C",
15849
+ "XC",
15850
+ "L",
15851
+ "XL",
15852
+ "X",
15853
+ "IX",
15854
+ "V",
15855
+ "IV",
15856
+ "I"
15857
+ ];
15858
+ let remaining = Math.max(1, Math.min(Math.trunc(n2), 3999));
15769
15859
  let result = "";
15770
- for (const [amount, numeral] of romanNumerals) {
15771
- while (remaining >= amount) {
15772
- result += numeral;
15773
- remaining -= amount;
15860
+ for (const [i, value] of values.entries()) {
15861
+ while (remaining >= value) {
15862
+ result += numerals[i] ?? "";
15863
+ remaining -= value;
15774
15864
  }
15775
15865
  }
15776
- return result || "I";
15866
+ return result;
15777
15867
  }
15778
- function toLetters(value) {
15779
- let remaining = Math.max(1, Math.round(value));
15780
- let result = "";
15781
- while (remaining > 0) {
15782
- remaining--;
15783
- result = String.fromCharCode(97 + remaining % 26) + result;
15784
- remaining = Math.floor(remaining / 26);
15868
+ var LATIN_LOWER = Array.from("abcdefghijklmnopqrstuvwxyz");
15869
+ var MAX_LETTER_LABEL = 64;
15870
+ function letterLabel(n2) {
15871
+ const index = Math.max(0, Math.trunc(n2) - 1);
15872
+ const letter = LATIN_LOWER[index % LATIN_LOWER.length] ?? "a";
15873
+ const repeats = Math.min(Math.floor(index / LATIN_LOWER.length) + 1, MAX_LETTER_LABEL);
15874
+ return letter.repeat(repeats);
15875
+ }
15876
+ var ORDINAL_SUFFIX = (n2) => {
15877
+ const abs = Math.abs(Math.trunc(n2));
15878
+ if (abs % 100 >= 11 && abs % 100 <= 13) return "th";
15879
+ switch (abs % 10) {
15880
+ case 1:
15881
+ return "st";
15882
+ case 2:
15883
+ return "nd";
15884
+ case 3:
15885
+ return "rd";
15886
+ default:
15887
+ return "th";
15785
15888
  }
15786
- return result || "a";
15787
- }
15788
- function formatNoteNumber(value, format) {
15789
- switch (format) {
15790
- case "upperRoman":
15791
- return toRoman(value);
15792
- case "lowerRoman":
15793
- return toRoman(value).toLowerCase();
15794
- case "upperLetter":
15795
- return toLetters(value).toUpperCase();
15796
- case "lowerLetter":
15797
- return toLetters(value);
15798
- case "decimalZero":
15799
- return value < 10 ? `0${value}` : String(value);
15800
- default:
15801
- return String(value);
15802
- }
15803
- }
15804
- function walkParagraph(paragraph, kind, order) {
15805
- for (const run of paragraph.runs) {
15806
- if (run.noteReference?.kind === kind && !order.has(run.noteReference.id))
15807
- order.set(run.noteReference.id, order.size + 1);
15808
- }
15809
- }
15810
- function walkBlocks(blocks, kind, order) {
15811
- for (const block of blocks) {
15812
- if (block.type === "paragraph") walkParagraph(block, kind, order);
15813
- else
15814
- for (const row2 of block.rows)
15815
- for (const cell of row2) walkBlocks(cellSourceBlocks(cell), kind, order);
15816
- }
15817
- }
15818
- function numberNotesInOrder(blocks, kind) {
15819
- const order = /* @__PURE__ */ new Map();
15820
- walkBlocks(blocks, kind, order);
15821
- return order;
15822
- }
15823
-
15824
- // docx/chart-paint.ts
15825
- function themeCatalogColorScheme(theme) {
15826
- const colors = {};
15827
- for (const [slot, value] of Object.entries(theme?.colors ?? {}))
15828
- if (value) colors[slot] = { kind: "srgb", value: value.replace(/^#/, ""), transforms: [] };
15829
- return { colors };
15830
- }
15831
- function docxChartPaint(chart, widthPx, heightPx, theme) {
15832
- const space = chart?.chartSpace;
15833
- const extended = chart?.chartEx;
15834
- if (chart && extended) return paintExtended(chart, extended, widthPx, heightPx, theme);
15835
- if (chart && chart.layoutId) return { label: `Chart (${chart.layoutId})` };
15836
- if (!space) return { label: "Chart" };
15837
- const kind = chartSpaceKind(space);
15838
- if (!kind.drawn) return { label: kind.type ? `Chart (${kind.type})` : "Chart" };
15839
- try {
15840
- const fonts = {
15841
- ...theme?.fonts.major.latin ? { major: theme.fonts.major.latin } : {},
15842
- ...theme?.fonts.minor.latin ? { minor: theme.fonts.minor.latin } : {}
15843
- };
15844
- const svg = renderChartSpaceSvg(space, {
15845
- width: Math.max(1, Math.round(widthPx)),
15846
- height: Math.max(1, Math.round(heightPx)),
15847
- theme: themeCatalogColorScheme(theme),
15848
- fonts,
15849
- ...chart.formatting ? { formatting: chart.formatting } : {},
15850
- ...chart.colorPalette !== void 0 ? { colorPalette: chart.colorPalette } : {}
15851
- });
15852
- return { svg, label: chart.title ? `Chart: ${chart.title}` : "Chart" };
15853
- } catch {
15854
- return { label: kind.type ? `Chart (${kind.type})` : "Chart" };
15855
- }
15856
- }
15857
- function paintExtended(chart, summary, widthPx, heightPx, theme) {
15858
- try {
15859
- const fonts = {
15860
- ...theme?.fonts.major.latin ? { major: theme.fonts.major.latin } : {},
15861
- ...theme?.fonts.minor.latin ? { minor: theme.fonts.minor.latin } : {}
15862
- };
15863
- const svg = renderChartSummarySvg(summary, {
15864
- width: Math.max(1, Math.round(widthPx)),
15865
- height: Math.max(1, Math.round(heightPx)),
15866
- theme: themeCatalogColorScheme(theme),
15867
- fonts
15868
- });
15869
- return { svg, label: chart.title ? `Chart: ${chart.title}` : "Chart" };
15870
- } catch {
15871
- return { label: `Chart (${chart.layoutId ?? "extended"})` };
15872
- }
15873
- }
15874
-
15875
- // docx/diagram-theme.ts
15876
- function diagramColorTheme(theme) {
15877
- return {
15878
- scheme(name) {
15879
- if (!theme) return void 0;
15880
- const slot = themeColorSlotFor(name, theme.colorMapping);
15881
- const hex = slot ? theme.colors[slot] : void 0;
15882
- return hex ? `#${hex.replace(/^#/, "").toUpperCase()}` : void 0;
15883
- }
15884
- };
15885
- }
15886
-
15887
- // docx/numbering-text.ts
15888
- function romanNumeral(n2) {
15889
- const values = [1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
15890
- const numerals = [
15891
- "M",
15892
- "CM",
15893
- "D",
15894
- "CD",
15895
- "C",
15896
- "XC",
15897
- "L",
15898
- "XL",
15899
- "X",
15900
- "IX",
15901
- "V",
15902
- "IV",
15903
- "I"
15904
- ];
15905
- let remaining = Math.max(1, Math.min(Math.trunc(n2), 3999));
15906
- let result = "";
15907
- for (const [i, value] of values.entries()) {
15908
- while (remaining >= value) {
15909
- result += numerals[i] ?? "";
15910
- remaining -= value;
15911
- }
15912
- }
15913
- return result;
15914
- }
15915
- var LATIN_LOWER = Array.from("abcdefghijklmnopqrstuvwxyz");
15916
- var MAX_LETTER_LABEL = 64;
15917
- function letterLabel(n2) {
15918
- const index = Math.max(0, Math.trunc(n2) - 1);
15919
- const letter = LATIN_LOWER[index % LATIN_LOWER.length] ?? "a";
15920
- const repeats = Math.min(Math.floor(index / LATIN_LOWER.length) + 1, MAX_LETTER_LABEL);
15921
- return letter.repeat(repeats);
15922
- }
15923
- var ORDINAL_SUFFIX = (n2) => {
15924
- const abs = Math.abs(Math.trunc(n2));
15925
- if (abs % 100 >= 11 && abs % 100 <= 13) return "th";
15926
- switch (abs % 10) {
15927
- case 1:
15928
- return "st";
15929
- case 2:
15930
- return "nd";
15931
- case 3:
15932
- return "rd";
15933
- default:
15934
- return "th";
15935
- }
15936
- };
15937
- function ordinalNumeral(n2) {
15938
- return `${Math.trunc(n2)}${ORDINAL_SUFFIX(n2)}`;
15889
+ };
15890
+ function ordinalNumeral(n2) {
15891
+ return `${Math.trunc(n2)}${ORDINAL_SUFFIX(n2)}`;
15939
15892
  }
15940
15893
  var ONES = [
15941
15894
  "",
@@ -16036,135 +15989,623 @@ function formatListNumber(numFmt, value) {
16036
15989
  return String(value);
16037
15990
  }
16038
15991
  }
16039
- function resolveParagraphNumbering(paragraph, styleCatalog, numberingCatalog) {
16040
- if (paragraph.numbering)
16041
- return paragraph.numbering.numId > 0 ? paragraph.numbering : void 0;
16042
- if (!styleCatalog) return void 0;
16043
- const inherited = resolveStyleNumbering(paragraph.style, styleCatalog);
16044
- if (!inherited || inherited.numId <= 0) return void 0;
16045
- if (numberingCatalog && paragraph.style && styleCatalog.styles[paragraph.style]) {
16046
- for (let level2 = 0; level2 < 9; level2++) {
16047
- const definition = resolveNumberingLevel(numberingCatalog, String(inherited.numId), level2);
16048
- if (definition?.paragraphStyleId === paragraph.style)
16049
- return { numId: inherited.numId, level: level2 };
16050
- }
15992
+ function resolveParagraphNumbering(paragraph, styleCatalog, numberingCatalog) {
15993
+ if (paragraph.numbering)
15994
+ return paragraph.numbering.numId > 0 ? paragraph.numbering : void 0;
15995
+ if (!styleCatalog) return void 0;
15996
+ const inherited = resolveStyleNumbering(paragraph.style, styleCatalog);
15997
+ if (!inherited || inherited.numId <= 0) return void 0;
15998
+ if (numberingCatalog && paragraph.style && styleCatalog.styles[paragraph.style]) {
15999
+ for (let level2 = 0; level2 < 9; level2++) {
16000
+ const definition = resolveNumberingLevel(numberingCatalog, String(inherited.numId), level2);
16001
+ if (definition?.paragraphStyleId === paragraph.style)
16002
+ return { numId: inherited.numId, level: level2 };
16003
+ }
16004
+ }
16005
+ return inherited;
16006
+ }
16007
+ var NumberingCounters = class {
16008
+ counts = /* @__PURE__ */ new Map();
16009
+ started = /* @__PURE__ */ new Map();
16010
+ forNum(numId) {
16011
+ let counts = this.counts.get(numId);
16012
+ if (!counts) {
16013
+ counts = /* @__PURE__ */ new Map();
16014
+ this.counts.set(numId, counts);
16015
+ }
16016
+ return counts;
16017
+ }
16018
+ startedLevels(numId) {
16019
+ let started = this.started.get(numId);
16020
+ if (!started) {
16021
+ started = /* @__PURE__ */ new Set();
16022
+ this.started.set(numId, started);
16023
+ }
16024
+ return started;
16025
+ }
16026
+ /** Advances one level and resets deeper counters according to their resolved restart rules. */
16027
+ advance(numId, level2, def, catalog) {
16028
+ const counts = this.forNum(numId);
16029
+ const started = this.startedLevels(numId);
16030
+ const next = started.has(level2) ? (counts.get(level2) ?? def.start) + 1 : def.start;
16031
+ counts.set(level2, next);
16032
+ started.add(level2);
16033
+ for (const deeper of [...started]) {
16034
+ if (deeper <= level2) continue;
16035
+ const deeperDef = resolveNumberingLevel(catalog, numId, deeper);
16036
+ const restart = deeperDef?.lvlRestart;
16037
+ if (restart === 0) continue;
16038
+ const trigger = restart !== void 0 && restart > 0 && restart <= deeper ? restart - 1 : deeper - 1;
16039
+ if (level2 > trigger) continue;
16040
+ counts.delete(deeper);
16041
+ started.delete(deeper);
16042
+ }
16043
+ for (let ancestor = 0; ancestor < level2; ancestor++) {
16044
+ if (started.has(ancestor)) continue;
16045
+ const ancestorDef = resolveNumberingLevel(catalog, numId, ancestor);
16046
+ if (!ancestorDef) continue;
16047
+ counts.set(ancestor, ancestorDef.start);
16048
+ started.add(ancestor);
16049
+ }
16050
+ return next;
16051
+ }
16052
+ /** Current value for an ancestor placeholder, defaulting to its own start when never instantiated. */
16053
+ current(numId, level2, start) {
16054
+ return this.forNum(numId).get(level2) ?? start;
16055
+ }
16056
+ };
16057
+ function substituteLvlText(lvlText, numId, level2, catalog, counters, forceDecimal) {
16058
+ return lvlText.replace(/%([1-9])/g, (match, digit) => {
16059
+ const ancestorLevel = Number(digit) - 1;
16060
+ if (ancestorLevel > level2) return match;
16061
+ const ancestorDef = resolveNumberingLevel(catalog, numId, ancestorLevel);
16062
+ const start = ancestorDef?.start ?? 1;
16063
+ const value = counters.current(numId, ancestorLevel, start);
16064
+ const fmt = forceDecimal ? "decimal" : ancestorDef?.numFmt ?? "decimal";
16065
+ return formatListNumber(fmt, value);
16066
+ });
16067
+ }
16068
+ function computeListLabels(model) {
16069
+ const catalog = model.numberingCatalog;
16070
+ const labels = /* @__PURE__ */ new Map();
16071
+ if (!catalog) return labels;
16072
+ const counters = new NumberingCounters();
16073
+ for (const paragraph of documentParagraphs(model.blocks)) {
16074
+ const numbering = resolveParagraphNumbering(paragraph, model.paragraphStyles, catalog);
16075
+ if (!numbering) continue;
16076
+ const numId = String(numbering.numId);
16077
+ const level2 = Math.min(8, Math.max(0, numbering.level));
16078
+ const def = resolveNumberingLevel(catalog, numId, level2);
16079
+ if (!def) continue;
16080
+ if (def.numFmt === "none") continue;
16081
+ counters.advance(numId, level2, def, catalog);
16082
+ const text2 = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId, level2, catalog, counters, Boolean(def.isLgl));
16083
+ labels.set(paragraph.id, {
16084
+ numId,
16085
+ level: level2,
16086
+ text: text2,
16087
+ suffix: def.suffix ?? "tab",
16088
+ ...definedProps({
16089
+ alignment: def.lvlJc,
16090
+ indentLeftTwips: def.indentLeftTwips,
16091
+ hangingTwips: def.hangingTwips,
16092
+ firstLineTwips: def.firstLineTwips,
16093
+ markerFormat: def.markerFormat,
16094
+ tabStopTwips: def.tabStopTwips
16095
+ })
16096
+ });
16097
+ }
16098
+ return labels;
16099
+ }
16100
+ var SYMBOL_BULLETS = {
16101
+ "\uF0B7": "\u2022",
16102
+ "\uF0A7": "\u25AA",
16103
+ "\uF0D8": "\u27A2",
16104
+ "\uF076": "\u2756",
16105
+ "\uF0FC": "\u2713",
16106
+ "\uF06E": "\u25A0",
16107
+ "\uF071": "\u2751",
16108
+ "\uF0E0": "\u27A9",
16109
+ "\uF0B2": "\u25CB"
16110
+ };
16111
+ function displayListLabel(text2) {
16112
+ return text2.replace(/[-]/g, (char) => SYMBOL_BULLETS[char] ?? "\u2022");
16113
+ }
16114
+
16115
+ // docx/style-ref.ts
16116
+ function parseStyleReference(instr) {
16117
+ const tokens = fieldTokens(instr);
16118
+ if (tokens[0]?.kind !== "text" || tokens[0].value.toUpperCase() !== "STYLEREF") return void 0;
16119
+ let style;
16120
+ const reference = {
16121
+ style: "",
16122
+ last: false,
16123
+ number: false,
16124
+ numberOnly: false
16125
+ };
16126
+ for (let index = 1; index < tokens.length; index++) {
16127
+ const token = tokens[index];
16128
+ if (token.kind === "text") {
16129
+ if (style !== void 0) return void 0;
16130
+ style = token.value;
16131
+ } else if (token.value === "l") reference.last = true;
16132
+ else if (token.value === "n") reference.number = true;
16133
+ else if (token.value === "t") reference.numberOnly = true;
16134
+ else if (token.value === "s") {
16135
+ reference.number = true;
16136
+ reference.numberOnly = true;
16137
+ } else if (token.value === "*") {
16138
+ const format = tokens[++index];
16139
+ if (format?.kind !== "text") return void 0;
16140
+ const name = format.value.toLowerCase();
16141
+ if (isFieldTextCase(name)) reference.textCase = name;
16142
+ else if (name === "charformat") reference.charFormat = true;
16143
+ else if (name !== "mergeformat") return void 0;
16144
+ } else return void 0;
16145
+ }
16146
+ if (!style) return void 0;
16147
+ reference.style = style;
16148
+ return reference;
16149
+ }
16150
+ function styleTarget(model, style) {
16151
+ const name = /^[1-9]$/.test(style) ? `heading ${style}` : style;
16152
+ const key = name.toLowerCase();
16153
+ const paragraphs = Object.values(model.paragraphStyles?.styles ?? {});
16154
+ const characters = Object.values(model.characterStyles?.styles ?? {}).filter(
16155
+ (definition) => definition.type === "character"
16156
+ );
16157
+ const paragraph = (definition) => definition && {
16158
+ kind: "paragraph",
16159
+ id: definition.id,
16160
+ ...definition.isDefault ? { isDefault: true } : {}
16161
+ };
16162
+ const character = (definition) => definition && { kind: "character", id: definition.id };
16163
+ const named3 = (list) => list.find((definition) => definition.name?.toLowerCase() === key);
16164
+ const withId = (list) => list.find((definition) => definition.id === name) ?? list.find((definition) => definition.id.toLowerCase() === key);
16165
+ return paragraph(named3(paragraphs)) ?? character(named3(characters)) ?? paragraph(withId(paragraphs)) ?? character(withId(characters));
16166
+ }
16167
+ var shownText = (run) => run.vanish || run.revision?.kind === "delete" || run.revision?.kind === "moveFrom" ? "" : run.text;
16168
+ function characterPortions(paragraph, id, hidden, skip) {
16169
+ const portions = [];
16170
+ let open;
16171
+ paragraph.runs.forEach((run, index) => {
16172
+ if (skip && index >= skip.from && index <= skip.to) {
16173
+ open = void 0;
16174
+ return;
16175
+ }
16176
+ if (!run.text || run.revision?.kind === "delete" || run.revision?.kind === "moveFrom") return;
16177
+ if (run.style !== id) {
16178
+ open = void 0;
16179
+ return;
16180
+ }
16181
+ const text2 = hidden(run, paragraph) ? "" : run.text;
16182
+ if (open) {
16183
+ open.text += text2;
16184
+ open.to = index;
16185
+ } else portions.push(open = { text: text2, from: index, to: index });
16186
+ });
16187
+ return portions;
16188
+ }
16189
+ var inParagraphStyle = (paragraph, target) => paragraph.style === target.id || paragraph.style === void 0 && target.isDefault === true;
16190
+ var deletedWhole = (paragraph) => (paragraph.markRevision?.kind === "delete" || paragraph.markRevision?.kind === "moveFrom") && paragraph.runs.every(
16191
+ (run) => !run.text || run.revision?.kind === "delete" || run.revision?.kind === "moveFrom"
16192
+ );
16193
+ function styleRefSource(model) {
16194
+ const paragraphs = documentParagraphs(model.blocks);
16195
+ const hidden = (run, paragraph) => resolveRunFormatting(run, {
16196
+ runCatalog: model.characterStyles,
16197
+ paragraphCatalog: model.paragraphStyles,
16198
+ paragraphStyleId: paragraph.style
16199
+ }).vanish === true;
16200
+ const index = new Map(paragraphs.map((paragraph, at) => [paragraph.id, at]));
16201
+ const targets = /* @__PURE__ */ new Map();
16202
+ let labels;
16203
+ const number = (paragraph, numberOnly) => {
16204
+ labels ??= computeListLabels(model);
16205
+ const label = labels.get(paragraph.id);
16206
+ if (!label || !model.numberingCatalog) return "0";
16207
+ const level2 = resolveNumberingLevel(model.numberingCatalog, label.numId, label.level);
16208
+ if (!level2 || level2.numFmt === "bullet") return null;
16209
+ let text2 = label.text;
16210
+ if (numberOnly) {
16211
+ const first3 = level2.lvlText.indexOf("%");
16212
+ const end = level2.lvlText.search(/%[1-9](?!.*%[1-9])/);
16213
+ const prefix2 = first3 < 0 ? "" : level2.lvlText.slice(0, first3);
16214
+ const suffix = end < 0 ? "" : level2.lvlText.slice(end + 2);
16215
+ const inner = first3 < 0 || end < 0 ? "" : level2.lvlText.slice(first3, end + 2);
16216
+ if (/\p{L}/u.test(inner.replace(/%[1-9]/g, ""))) return null;
16217
+ if (prefix2 && text2.startsWith(prefix2)) text2 = text2.slice(prefix2.length);
16218
+ if (suffix && text2.endsWith(suffix)) text2 = text2.slice(0, -suffix.length);
16219
+ }
16220
+ return text2.trim().replace(/\.+$/, "");
16221
+ };
16222
+ const portions = (at, reference, target, skip) => {
16223
+ const paragraph = paragraphs[at];
16224
+ if (!paragraph) return [];
16225
+ let found;
16226
+ if (target.kind === "character") found = characterPortions(paragraph, target.id, hidden, skip);
16227
+ else
16228
+ found = inParagraphStyle(paragraph, target) && !deletedWhole(paragraph) ? [
16229
+ {
16230
+ text: paragraph.runs.map((run) => hidden(run, paragraph) ? "" : shownText(run)).join(""),
16231
+ from: 0,
16232
+ to: paragraph.runs.length - 1
16233
+ }
16234
+ ] : [];
16235
+ if (reference.number && found.length) {
16236
+ const label = number(paragraph, reference.numberOnly);
16237
+ found = found.map((portion) => ({ ...portion, text: label ?? void 0 }));
16238
+ }
16239
+ return reference.textCase ? found.map((portion) => ({
16240
+ ...portion,
16241
+ text: portion.text === void 0 ? void 0 : applyFieldTextCase(portion.text, reference.textCase)
16242
+ })) : found;
16243
+ };
16244
+ return {
16245
+ paragraphs,
16246
+ index,
16247
+ target(style) {
16248
+ if (!targets.has(style)) targets.set(style, styleTarget(model, style));
16249
+ return targets.get(style);
16250
+ },
16251
+ portions,
16252
+ results: (at, reference, target) => portions(at, reference, target).map((portion) => portion.text)
16253
+ };
16254
+ }
16255
+
16256
+ // docx/style-ref-fields.ts
16257
+ var removed = (run) => run.revision?.kind === "delete" || run.revision?.kind === "moveFrom";
16258
+ function fieldResults(runs) {
16259
+ const found = [];
16260
+ const open = [];
16261
+ runs.forEach((run, index) => {
16262
+ const top = open.at(-1);
16263
+ if (run.fieldChar === "begin")
16264
+ open.push({ begin: index, code: "", locked: isFieldLocked(run) });
16265
+ else if (run.fieldCode !== void 0 && top && top.separate === void 0) {
16266
+ top.code += run.fieldCode;
16267
+ top.codeRun ??= index;
16268
+ if (top.nameRun === void 0 && /\S/.test(run.fieldCode)) top.nameRun = index;
16269
+ } else if (run.fieldChar === "separate" && top) top.separate = index;
16270
+ else if (run.fieldChar === "end" && top) {
16271
+ open.pop();
16272
+ if (top.separate === void 0) return;
16273
+ const instr = top.code.trim();
16274
+ const results = [];
16275
+ let gone = false;
16276
+ for (let at = top.separate + 1; at < index; at++) {
16277
+ const item = runs[at];
16278
+ if (item.field?.instr !== instr || item.fieldChar || item.fieldCode !== void 0) continue;
16279
+ if (removed(item)) gone = true;
16280
+ else results.push(at);
16281
+ }
16282
+ found.push({
16283
+ from: top.begin,
16284
+ to: index,
16285
+ instr,
16286
+ locked: top.locked || results.some((at) => isFieldLocked(runs[at])),
16287
+ runs: results,
16288
+ ...top.codeRun !== void 0 ? { code: top.codeRun } : {},
16289
+ ...top.nameRun !== void 0 ? { name: top.nameRun } : {},
16290
+ insertAt: top.separate + 1,
16291
+ ...gone && !results.length ? { removed: true } : {}
16292
+ });
16293
+ }
16294
+ });
16295
+ let simple;
16296
+ let identity;
16297
+ runs.forEach((run, index) => {
16298
+ if (!run.field?.simple) {
16299
+ simple = void 0;
16300
+ return;
16301
+ }
16302
+ if (simple && simple.instr === run.field.instr && identity === run.fieldInstanceId) {
16303
+ if (!removed(run)) simple.runs.push(index);
16304
+ simple.to = index;
16305
+ } else {
16306
+ simple = {
16307
+ from: index,
16308
+ to: index,
16309
+ instr: run.field.instr,
16310
+ locked: false,
16311
+ runs: removed(run) ? [] : [index],
16312
+ insertAt: index
16313
+ };
16314
+ identity = run.fieldInstanceId;
16315
+ found.push(simple);
16316
+ }
16317
+ simple.locked ||= isFieldLocked(run);
16318
+ });
16319
+ return found;
16320
+ }
16321
+ var STRUCTURE = [
16322
+ "fieldChar",
16323
+ "fieldCode",
16324
+ "fieldInstanceId",
16325
+ "fieldFlags",
16326
+ "break",
16327
+ "noteReference",
16328
+ "noteMark",
16329
+ "noteSeparator",
16330
+ "equation",
16331
+ "image"
16332
+ ];
16333
+ var NOT_FORMATTING = [
16334
+ ...STRUCTURE,
16335
+ "text",
16336
+ "field",
16337
+ "revision",
16338
+ "formatRevision",
16339
+ "restoredRunPropertiesXml",
16340
+ "commentIds",
16341
+ "link",
16342
+ "contentControl"
16343
+ ];
16344
+ function withFieldCodeFormatting(result, code, text2) {
16345
+ const formatted = { ...code };
16346
+ const own2 = {};
16347
+ for (const key of NOT_FORMATTING) {
16348
+ delete formatted[key];
16349
+ if (result[key] !== void 0) Object.assign(own2, { [key]: result[key] });
16350
+ }
16351
+ return { ...formatted, ...own2, text: text2 };
16352
+ }
16353
+ function replaceResult(runs, field, text2, charFormat) {
16354
+ const current = field.runs.map((at) => runs[at].text).join("") === text2;
16355
+ const next = [...runs];
16356
+ const [first3, ...rest] = field.runs;
16357
+ const name = field.name ?? field.code;
16358
+ if (first3 !== void 0) {
16359
+ const formatted = charFormat && name !== void 0 ? withFieldCodeFormatting(runs[first3], runs[name], text2) : void 0;
16360
+ if (current && (!formatted || sameRun(formatted, runs[first3]) && rest.every((at) => !runs[at].text)))
16361
+ return void 0;
16362
+ next[first3] = formatted ?? { ...runs[first3], text: text2 };
16363
+ for (const at of rest) next[at] = { ...runs[at], text: "" };
16364
+ return next;
16365
+ }
16366
+ const code = charFormat ? name : field.code;
16367
+ if (current || code === void 0 || field.removed) return void 0;
16368
+ next.splice(field.insertAt, 0, fieldResultRun(runs[code], field.instr, text2));
16369
+ return next;
16370
+ }
16371
+ function sameRun(a, b) {
16372
+ const keys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
16373
+ return [...keys].every((key) => JSON.stringify(a[key]) === JSON.stringify(b[key]));
16374
+ }
16375
+ function fieldResultRun(code, instr, text2) {
16376
+ const formatted = { ...code };
16377
+ for (const key of STRUCTURE) delete formatted[key];
16378
+ return { ...formatted, text: text2, field: { instr } };
16379
+ }
16380
+ function paragraphWithResults(paragraph, evaluate) {
16381
+ let runs = paragraph.runs;
16382
+ const start = (field) => field.runs[0] ?? field.insertAt;
16383
+ for (const field of fieldResults(runs).sort((a, b) => start(b) - start(a))) {
16384
+ const reference = field.locked ? void 0 : parseStyleReference(field.instr);
16385
+ const text2 = reference && evaluate(reference, paragraph, field);
16386
+ if (text2 !== void 0)
16387
+ runs = replaceResult(runs, field, text2, reference?.charFormat === true) ?? runs;
16388
+ }
16389
+ return runs === paragraph.runs ? paragraph : { ...paragraph, runs: [...runs] };
16390
+ }
16391
+ function tableWithResults(table, evaluate) {
16392
+ let changed = false;
16393
+ const rows = table.rows.map(
16394
+ (row2) => row2.map((cell) => {
16395
+ const paragraphs = cell.paragraphs.map((item) => paragraphWithResults(item, evaluate));
16396
+ const sourceBlocks = cell.sourceBlocks?.map(
16397
+ (item) => item.type === "table" ? tableWithResults(item, evaluate) : item
16398
+ );
16399
+ if (paragraphs.every((item, index) => item === cell.paragraphs[index]) && (sourceBlocks ?? []).every((item, index) => item === cell.sourceBlocks[index]))
16400
+ return cell;
16401
+ changed = true;
16402
+ return { ...cell, paragraphs, ...sourceBlocks ? { sourceBlocks } : {} };
16403
+ })
16404
+ );
16405
+ return changed ? { ...table, rows } : table;
16406
+ }
16407
+ function withStyleRefResults(blocks, evaluate) {
16408
+ let changed = false;
16409
+ const next = blocks.map((block) => {
16410
+ const updated = block.type === "paragraph" ? paragraphWithResults(block, evaluate) : tableWithResults(block, evaluate);
16411
+ changed ||= updated !== block;
16412
+ return updated;
16413
+ });
16414
+ return changed ? next : blocks;
16415
+ }
16416
+
16417
+ // docx/document-paragraphs.ts
16418
+ function mapBlockParagraphs(blocks, map) {
16419
+ return blocks.map(
16420
+ (block) => block.type === "paragraph" ? map(block) : {
16421
+ ...block,
16422
+ rows: block.rows.map(
16423
+ (row2) => row2.map((cell) => ({ ...cell, paragraphs: cell.paragraphs.map(map) }))
16424
+ )
16425
+ }
16426
+ );
16427
+ }
16428
+ function mapDocumentParagraphs(model, map) {
16429
+ const slots = (value) => Object.fromEntries(
16430
+ Object.entries(value).map(
16431
+ ([key, content]) => [
16432
+ key,
16433
+ content ? { ...content, blocks: mapBlockParagraphs(content.blocks, map) } : content
16434
+ ]
16435
+ )
16436
+ );
16437
+ return {
16438
+ ...model,
16439
+ blocks: mapBlockParagraphs(model.blocks, map),
16440
+ ...model.sections ? {
16441
+ sections: model.sections.map((section) => ({
16442
+ ...section,
16443
+ ...section.headers ? { headers: slots(section.headers) } : {},
16444
+ ...section.footers ? { footers: slots(section.footers) } : {}
16445
+ }))
16446
+ } : {},
16447
+ ...model.footnoteSeparators ? {
16448
+ footnoteSeparators: Object.fromEntries(
16449
+ Object.entries(model.footnoteSeparators).map(([kind, note]) => [
16450
+ kind,
16451
+ { ...note, blocks: mapBlockParagraphs(note.blocks, map) }
16452
+ ])
16453
+ )
16454
+ } : {},
16455
+ ...model.footnotes ? {
16456
+ footnotes: model.footnotes.map((note) => ({
16457
+ ...note,
16458
+ blocks: mapBlockParagraphs(note.blocks, map)
16459
+ }))
16460
+ } : {},
16461
+ ...model.endnotes ? {
16462
+ endnotes: model.endnotes.map((note) => ({
16463
+ ...note,
16464
+ blocks: mapBlockParagraphs(note.blocks, map)
16465
+ }))
16466
+ } : {}
16467
+ };
16468
+ }
16469
+
16470
+ // docx/field-runs.ts
16471
+ function fieldName(instr) {
16472
+ return instr.trim().split(/\s+/)[0]?.toUpperCase() ?? "";
16473
+ }
16474
+
16475
+ // docx/notes.ts
16476
+ var romanNumerals = [
16477
+ [1e3, "M"],
16478
+ [900, "CM"],
16479
+ [500, "D"],
16480
+ [400, "CD"],
16481
+ [100, "C"],
16482
+ [90, "XC"],
16483
+ [50, "L"],
16484
+ [40, "XL"],
16485
+ [10, "X"],
16486
+ [9, "IX"],
16487
+ [5, "V"],
16488
+ [4, "IV"],
16489
+ [1, "I"]
16490
+ ];
16491
+ function toRoman(value) {
16492
+ let remaining = Math.max(1, Math.round(value));
16493
+ let result = "";
16494
+ for (const [amount, numeral] of romanNumerals) {
16495
+ while (remaining >= amount) {
16496
+ result += numeral;
16497
+ remaining -= amount;
16498
+ }
16499
+ }
16500
+ return result || "I";
16501
+ }
16502
+ function toLetters(value) {
16503
+ let remaining = Math.max(1, Math.round(value));
16504
+ let result = "";
16505
+ while (remaining > 0) {
16506
+ remaining--;
16507
+ result = String.fromCharCode(97 + remaining % 26) + result;
16508
+ remaining = Math.floor(remaining / 26);
16509
+ }
16510
+ return result || "a";
16511
+ }
16512
+ function formatNoteNumber(value, format) {
16513
+ switch (format) {
16514
+ case "upperRoman":
16515
+ return toRoman(value);
16516
+ case "lowerRoman":
16517
+ return toRoman(value).toLowerCase();
16518
+ case "upperLetter":
16519
+ return toLetters(value).toUpperCase();
16520
+ case "lowerLetter":
16521
+ return toLetters(value);
16522
+ case "decimalZero":
16523
+ return value < 10 ? `0${value}` : String(value);
16524
+ default:
16525
+ return String(value);
16526
+ }
16527
+ }
16528
+ function walkParagraph(paragraph, kind, order) {
16529
+ for (const run of paragraph.runs) {
16530
+ if (run.noteReference?.kind === kind && !order.has(run.noteReference.id))
16531
+ order.set(run.noteReference.id, order.size + 1);
16051
16532
  }
16052
- return inherited;
16053
16533
  }
16054
- function flattenParagraphs(blocks) {
16055
- const result = [];
16534
+ function walkBlocks(blocks, kind, order) {
16056
16535
  for (const block of blocks) {
16057
- if (block.type === "paragraph") result.push(block);
16058
- else for (const row2 of block.rows) for (const cell of row2) result.push(...cell.paragraphs);
16536
+ if (block.type === "paragraph") walkParagraph(block, kind, order);
16537
+ else
16538
+ for (const row2 of block.rows)
16539
+ for (const cell of row2) walkBlocks(cellSourceBlocks(cell), kind, order);
16059
16540
  }
16060
- return result;
16061
16541
  }
16062
- var NumberingCounters = class {
16063
- counts = /* @__PURE__ */ new Map();
16064
- started = /* @__PURE__ */ new Map();
16065
- forNum(numId) {
16066
- let counts = this.counts.get(numId);
16067
- if (!counts) {
16068
- counts = /* @__PURE__ */ new Map();
16069
- this.counts.set(numId, counts);
16070
- }
16071
- return counts;
16072
- }
16073
- startedLevels(numId) {
16074
- let started = this.started.get(numId);
16075
- if (!started) {
16076
- started = /* @__PURE__ */ new Set();
16077
- this.started.set(numId, started);
16078
- }
16079
- return started;
16080
- }
16081
- /** Advances one level and resets deeper counters according to their resolved restart rules. */
16082
- advance(numId, level2, def, catalog) {
16083
- const counts = this.forNum(numId);
16084
- const started = this.startedLevels(numId);
16085
- const next = started.has(level2) ? (counts.get(level2) ?? def.start) + 1 : def.start;
16086
- counts.set(level2, next);
16087
- started.add(level2);
16088
- for (const deeper of [...started]) {
16089
- if (deeper <= level2) continue;
16090
- const deeperDef = resolveNumberingLevel(catalog, numId, deeper);
16091
- const restart = deeperDef?.lvlRestart;
16092
- if (restart === 0) continue;
16093
- const trigger = restart !== void 0 && restart > 0 && restart <= deeper ? restart - 1 : deeper - 1;
16094
- if (level2 > trigger) continue;
16095
- counts.delete(deeper);
16096
- started.delete(deeper);
16097
- }
16098
- for (let ancestor = 0; ancestor < level2; ancestor++) {
16099
- if (started.has(ancestor)) continue;
16100
- const ancestorDef = resolveNumberingLevel(catalog, numId, ancestor);
16101
- if (!ancestorDef) continue;
16102
- counts.set(ancestor, ancestorDef.start);
16103
- started.add(ancestor);
16104
- }
16105
- return next;
16106
- }
16107
- /** Current value for an ancestor placeholder, defaulting to its own start when never instantiated. */
16108
- current(numId, level2, start) {
16109
- return this.forNum(numId).get(level2) ?? start;
16542
+ function numberNotesInOrder(blocks, kind) {
16543
+ const order = /* @__PURE__ */ new Map();
16544
+ walkBlocks(blocks, kind, order);
16545
+ return order;
16546
+ }
16547
+
16548
+ // docx/chart-paint.ts
16549
+ function themeCatalogColorScheme(theme) {
16550
+ const colors = {};
16551
+ for (const [slot, value] of Object.entries(theme?.colors ?? {}))
16552
+ if (value) colors[slot] = { kind: "srgb", value: value.replace(/^#/, ""), transforms: [] };
16553
+ return { colors };
16554
+ }
16555
+ function docxChartPaint(chart, widthPx, heightPx, theme) {
16556
+ const space = chart?.chartSpace;
16557
+ const extended = chart?.chartEx;
16558
+ if (chart && extended) return paintExtended(chart, extended, widthPx, heightPx, theme);
16559
+ if (chart && chart.layoutId) return { label: `Chart (${chart.layoutId})` };
16560
+ if (!space) return { label: "Chart" };
16561
+ const kind = chartSpaceKind(space);
16562
+ if (!kind.drawn) return { label: kind.type ? `Chart (${kind.type})` : "Chart" };
16563
+ try {
16564
+ const fonts = {
16565
+ ...theme?.fonts.major.latin ? { major: theme.fonts.major.latin } : {},
16566
+ ...theme?.fonts.minor.latin ? { minor: theme.fonts.minor.latin } : {}
16567
+ };
16568
+ const svg = renderChartSpaceSvg(space, {
16569
+ width: Math.max(1, Math.round(widthPx)),
16570
+ height: Math.max(1, Math.round(heightPx)),
16571
+ theme: themeCatalogColorScheme(theme),
16572
+ fonts,
16573
+ ...chart.formatting ? { formatting: chart.formatting } : {},
16574
+ ...chart.colorPalette !== void 0 ? { colorPalette: chart.colorPalette } : {}
16575
+ });
16576
+ return { svg, label: chart.title ? `Chart: ${chart.title}` : "Chart" };
16577
+ } catch {
16578
+ return { label: kind.type ? `Chart (${kind.type})` : "Chart" };
16110
16579
  }
16111
- };
16112
- function substituteLvlText(lvlText, numId, level2, catalog, counters, forceDecimal) {
16113
- return lvlText.replace(/%([1-9])/g, (match, digit) => {
16114
- const ancestorLevel = Number(digit) - 1;
16115
- if (ancestorLevel > level2) return match;
16116
- const ancestorDef = resolveNumberingLevel(catalog, numId, ancestorLevel);
16117
- const start = ancestorDef?.start ?? 1;
16118
- const value = counters.current(numId, ancestorLevel, start);
16119
- const fmt = forceDecimal ? "decimal" : ancestorDef?.numFmt ?? "decimal";
16120
- return formatListNumber(fmt, value);
16121
- });
16122
16580
  }
16123
- function computeListLabels(model) {
16124
- const catalog = model.numberingCatalog;
16125
- const labels = /* @__PURE__ */ new Map();
16126
- if (!catalog) return labels;
16127
- const counters = new NumberingCounters();
16128
- for (const paragraph of flattenParagraphs(model.blocks)) {
16129
- const numbering = resolveParagraphNumbering(paragraph, model.paragraphStyles, catalog);
16130
- if (!numbering) continue;
16131
- const numId = String(numbering.numId);
16132
- const level2 = Math.min(8, Math.max(0, numbering.level));
16133
- const def = resolveNumberingLevel(catalog, numId, level2);
16134
- if (!def) continue;
16135
- if (def.numFmt === "none") continue;
16136
- counters.advance(numId, level2, def, catalog);
16137
- const text2 = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId, level2, catalog, counters, Boolean(def.isLgl));
16138
- labels.set(paragraph.id, {
16139
- numId,
16140
- level: level2,
16141
- text: text2,
16142
- suffix: def.suffix ?? "tab",
16143
- ...definedProps({
16144
- alignment: def.lvlJc,
16145
- indentLeftTwips: def.indentLeftTwips,
16146
- hangingTwips: def.hangingTwips,
16147
- firstLineTwips: def.firstLineTwips,
16148
- markerFormat: def.markerFormat,
16149
- tabStopTwips: def.tabStopTwips
16150
- })
16581
+ function paintExtended(chart, summary, widthPx, heightPx, theme) {
16582
+ try {
16583
+ const fonts = {
16584
+ ...theme?.fonts.major.latin ? { major: theme.fonts.major.latin } : {},
16585
+ ...theme?.fonts.minor.latin ? { minor: theme.fonts.minor.latin } : {}
16586
+ };
16587
+ const svg = renderChartSummarySvg(summary, {
16588
+ width: Math.max(1, Math.round(widthPx)),
16589
+ height: Math.max(1, Math.round(heightPx)),
16590
+ theme: themeCatalogColorScheme(theme),
16591
+ fonts
16151
16592
  });
16593
+ return { svg, label: chart.title ? `Chart: ${chart.title}` : "Chart" };
16594
+ } catch {
16595
+ return { label: `Chart (${chart.layoutId ?? "extended"})` };
16152
16596
  }
16153
- return labels;
16154
16597
  }
16155
- var SYMBOL_BULLETS = {
16156
- "\uF0B7": "\u2022",
16157
- "\uF0A7": "\u25AA",
16158
- "\uF0D8": "\u27A2",
16159
- "\uF076": "\u2756",
16160
- "\uF0FC": "\u2713",
16161
- "\uF06E": "\u25A0",
16162
- "\uF071": "\u2751",
16163
- "\uF0E0": "\u27A9",
16164
- "\uF0B2": "\u25CB"
16165
- };
16166
- function displayListLabel(text2) {
16167
- return text2.replace(/[-]/g, (char) => SYMBOL_BULLETS[char] ?? "\u2022");
16598
+
16599
+ // docx/diagram-theme.ts
16600
+ function diagramColorTheme(theme) {
16601
+ return {
16602
+ scheme(name) {
16603
+ if (!theme) return void 0;
16604
+ const slot = themeColorSlotFor(name, theme.colorMapping);
16605
+ const hex = slot ? theme.colors[slot] : void 0;
16606
+ return hex ? `#${hex.replace(/^#/, "").toUpperCase()}` : void 0;
16607
+ }
16608
+ };
16168
16609
  }
16169
16610
 
16170
16611
  // docx/restore-paragraph-format.ts
@@ -16611,6 +17052,155 @@ function headerFooterForPage(model, page, pageNumber, kind) {
16611
17052
  return void 0;
16612
17053
  }
16613
17054
 
17055
+ // docx/layout/review-display.ts
17056
+ function reviewSourceLength(run) {
17057
+ return run.equation || run.break || run.fieldChar || run.fieldCode !== void 0 || run.noteReference || run.image ? 1 : run.text.length;
17058
+ }
17059
+ function visibleReviewParagraph(paragraph, mode) {
17060
+ return mode === "all" ? paragraph : {
17061
+ ...paragraph,
17062
+ runs: paragraph.runs.filter((run) => !isRunHiddenForReview(run, mode))
17063
+ };
17064
+ }
17065
+ function visibleReviewModel(model, mode) {
17066
+ return mode === "all" ? model : mapDocumentParagraphs(model, (paragraph) => visibleReviewParagraph(paragraph, mode));
17067
+ }
17068
+
17069
+ // docx/layout/page-style-refs.ts
17070
+ function paragraphsByPage(pages, source) {
17071
+ return pages.map((page) => {
17072
+ const found = /* @__PURE__ */ new Map();
17073
+ const add = (box) => {
17074
+ const at = source.index.get(box.blockId);
17075
+ if (at === void 0) return;
17076
+ const shown = found.get(at) ?? [];
17077
+ if (!box.lines.length) shown.push([0, Number.POSITIVE_INFINITY]);
17078
+ for (const line3 of box.lines) shown.push([line3.sourceStart, line3.sourceEnd]);
17079
+ found.set(at, shown);
17080
+ };
17081
+ const visit = (blocks) => {
17082
+ for (const block of blocks)
17083
+ if (block.kind === "paragraph") add(block);
17084
+ else
17085
+ for (const row2 of block.rows)
17086
+ if (!row2.repeated) for (const cell of row2.cells) for (const box of cell) add(box);
17087
+ };
17088
+ for (const column of page.columns) visit(column.blocks);
17089
+ return found;
17090
+ });
17091
+ }
17092
+ var shows2 = (shown, start, end) => shown.some(
17093
+ ([from, to]) => start === end ? from <= start && start <= to : start < to && end > from
17094
+ );
17095
+ function pageStyleRefs(model, pages) {
17096
+ let source;
17097
+ let onPage;
17098
+ let pagesOf;
17099
+ const matches = /* @__PURE__ */ new Map();
17100
+ const offsets = /* @__PURE__ */ new Map();
17101
+ const read = () => {
17102
+ if (!source) {
17103
+ source = styleRefSource(model);
17104
+ onPage = paragraphsByPage(pages, source);
17105
+ pagesOf = /* @__PURE__ */ new Map();
17106
+ onPage.forEach((here, page) => {
17107
+ for (const at of here.keys()) {
17108
+ const list = pagesOf.get(at);
17109
+ if (list) list.push(page);
17110
+ else pagesOf.set(at, [page]);
17111
+ }
17112
+ });
17113
+ }
17114
+ return source;
17115
+ };
17116
+ const span = (at, portion) => {
17117
+ let starts = offsets.get(at);
17118
+ if (!starts) {
17119
+ starts = [0];
17120
+ for (const run of source.paragraphs[at].runs)
17121
+ starts.push(starts.at(-1) + reviewSourceLength(run));
17122
+ offsets.set(at, starts);
17123
+ }
17124
+ return [starts[portion.from], starts[portion.to + 1]];
17125
+ };
17126
+ const place2 = (portions) => {
17127
+ const count = source.paragraphs.length;
17128
+ const lastBefore = [];
17129
+ for (let at = 0, last = -1; at < count; at++) {
17130
+ lastBefore[at] = last;
17131
+ last = pagesOf.get(at)?.at(-1) ?? last;
17132
+ }
17133
+ const firstAfter = [];
17134
+ for (let at = count - 1, first3 = pages.length; at >= 0; at--) {
17135
+ firstAfter[at] = first3;
17136
+ first3 = pagesOf.get(at)?.[0] ?? first3;
17137
+ }
17138
+ const placed2 = [];
17139
+ for (const [at, found] of portions) {
17140
+ const showing = pagesOf.get(at);
17141
+ for (const portion of found) {
17142
+ if (!showing) {
17143
+ placed2.push({ text: portion.text, first: firstAfter[at], last: lastBefore[at] });
17144
+ continue;
17145
+ }
17146
+ const [start, end] = span(at, portion);
17147
+ const on = showing.filter((page) => shows2(onPage[page].get(at), start, end));
17148
+ const list = on.length ? on : showing;
17149
+ placed2.push({ text: portion.text, first: list[0], last: list.at(-1) });
17150
+ }
17151
+ }
17152
+ const before = new Array(pages.length).fill(-1);
17153
+ const after = new Array(pages.length).fill(-1);
17154
+ placed2.forEach((item, index) => {
17155
+ if (item.last + 1 < pages.length) before[Math.max(0, item.last + 1)] = index;
17156
+ });
17157
+ for (let index = placed2.length - 1; index >= 0; index--) {
17158
+ const page = placed2[index].first - 1;
17159
+ if (page >= 0) after[Math.min(page, pages.length - 1)] = index;
17160
+ }
17161
+ for (let page = 1; page < pages.length; page++)
17162
+ before[page] = Math.max(before[page], before[page - 1]);
17163
+ for (let page = pages.length - 2; page >= 0; page--)
17164
+ if (after[page] < 0 || after[page + 1] >= 0 && after[page + 1] < after[page])
17165
+ after[page] = after[page + 1];
17166
+ return { portions, placed: placed2, before, after };
17167
+ };
17168
+ const result = (page, reference) => {
17169
+ const document = read();
17170
+ const target = document.target(reference.style);
17171
+ if (!target) return void 0;
17172
+ const key = JSON.stringify(reference);
17173
+ let found = matches.get(key);
17174
+ if (!found) {
17175
+ const portions = /* @__PURE__ */ new Map();
17176
+ for (let at = 0; at < document.paragraphs.length; at++) {
17177
+ const results = document.portions(at, reference, target);
17178
+ if (results.length) portions.set(at, results);
17179
+ }
17180
+ found = place2(portions);
17181
+ matches.set(key, found);
17182
+ }
17183
+ const here = onPage[page] ?? /* @__PURE__ */ new Map();
17184
+ const order = [...here.keys()];
17185
+ for (const at of reference.last ? order.reverse() : order) {
17186
+ const shown = here.get(at);
17187
+ const texts = (found.portions.get(at) ?? []).filter(
17188
+ (portion) => shows2(shown, ...span(at, portion))
17189
+ );
17190
+ if (texts.length) return (reference.last ? texts.at(-1) : texts[0]).text;
17191
+ }
17192
+ const nearest = (found.before[page] ?? -1) >= 0 ? found.before[page] : found.after[page] ?? -1;
17193
+ return nearest >= 0 ? found.placed[nearest].text : void 0;
17194
+ };
17195
+ return {
17196
+ result,
17197
+ content(content, page) {
17198
+ const blocks = withStyleRefResults(content.blocks, (reference) => result(page, reference));
17199
+ return blocks === content.blocks ? content : { ...content, blocks };
17200
+ }
17201
+ };
17202
+ }
17203
+
16614
17204
  // docx/layout/tab-stops.ts
16615
17205
  function placeTab(positionPx, stops, hangingStopPx, followingPx, beforeDecimalPx) {
16616
17206
  const epsilon = 0.5;
@@ -16628,6 +17218,15 @@ function placeTab(positionPx, stops, hangingStopPx, followingPx, beforeDecimalPx
16628
17218
  const next = (Math.floor(positionPx / DEFAULT_TAB_STOP_PX) + 1) * DEFAULT_TAB_STOP_PX;
16629
17219
  return { widthPx: next - positionPx };
16630
17220
  }
17221
+ function placePositionalTab(positionPx, tab, startPx, endPx, followingPx) {
17222
+ const target = tab.alignment === "left" ? startPx : tab.alignment === "center" ? (startPx + endPx) / 2 : endPx;
17223
+ if (positionPx > target + 0.5) return void 0;
17224
+ const shift = tab.alignment === "right" ? followingPx : tab.alignment === "center" ? followingPx / 2 : 0;
17225
+ return {
17226
+ widthPx: Math.max(0, target - shift - positionPx),
17227
+ ...tab.leader && tab.leader !== "none" ? { leader: tab.leader } : {}
17228
+ };
17229
+ }
16631
17230
 
16632
17231
  // docx/layout/paragraph-tokens.ts
16633
17232
  var SCRIPT_SCALE = 0.65;
@@ -16754,6 +17353,7 @@ function buildFragments(tokensOnLine, paragraph) {
16754
17353
  ...leader ? { leader } : {},
16755
17354
  ...run?.script ? { script: run.script } : {},
16756
17355
  ...run?.color ? { color: run.color } : {},
17356
+ ...run?.background ? { background: run.background } : {},
16757
17357
  ...run?.underline ? { underline: true } : {},
16758
17358
  ...run?.strike ? { strike: true } : {},
16759
17359
  ...token.kind === "object" && run?.object ? { object: run.object } : {}
@@ -16849,6 +17449,7 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
16849
17449
  let widthOverflowNoted = false;
16850
17450
  let placed2 = [];
16851
17451
  let lineWidthPx = 0;
17452
+ let marginReachPx = 0;
16852
17453
  let tokenCursor = startToken;
16853
17454
  let firstToken = startToken;
16854
17455
  const boxes = [];
@@ -16944,6 +17545,7 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
16944
17545
  if (forcedByBreak === "column") columnBreakAfterLine.add(lineIndex);
16945
17546
  placed2 = [];
16946
17547
  lineWidthPx = 0;
17548
+ marginReachPx = 0;
16947
17549
  }
16948
17550
  for (const [tokenIndex, token] of tokens.entries()) {
16949
17551
  if (tokenIndex < startToken) continue;
@@ -16963,7 +17565,23 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
16963
17565
  const marker = paragraph.runs[token.runIndex]?.marker;
16964
17566
  const markerFactor = marker && token.kind === "word" && tokenIndex === 0 ? marker.alignment === "right" ? 1 : marker.alignment === "center" ? 0.5 : 0 : 0;
16965
17567
  const advance = width * (1 - markerFactor);
16966
- if (token.kind === "tab") {
17568
+ const positional = token.kind === "tab" && paragraph.runs[token.runIndex]?.positionalTab;
17569
+ if (positional) {
17570
+ const { followingPx } = segmentAfter(tokenIndex);
17571
+ const [startPx, endPx] = positional.relativeTo === "indent" ? [Math.max(leftPx, 0), Math.min(contentWidthPx - rightPx, contentWidthPx)] : [0, contentWidthPx];
17572
+ const placeAt = (positionPx) => placePositionalTab(positionPx, positional, startPx, endPx, followingPx);
17573
+ let tab = placeAt(lineStart(lines.length) + lineWidthPx);
17574
+ if (!tab && placed2.length) {
17575
+ tokenCursor = tokenIndex;
17576
+ flushLine(false, void 0);
17577
+ tokenCursor = tokenIndex + 1;
17578
+ tab = placeAt(lineStart(lines.length));
17579
+ }
17580
+ width = tab?.widthPx ?? 0;
17581
+ leader = tab?.leader === "none" ? void 0 : tab?.leader;
17582
+ if (positional.relativeTo === "margin")
17583
+ marginReachPx = contentWidthPx - lineStart(lines.length);
17584
+ } else if (token.kind === "tab") {
16967
17585
  const { followingPx, beforeDecimalPx } = segmentAfter(tokenIndex);
16968
17586
  const tab = placeTab(
16969
17587
  lineStart(lines.length) + lineWidthPx,
@@ -16976,7 +17594,7 @@ function measureParagraph(paragraph, contentWidthPx, measurer, note, lineBox, st
16976
17594
  leader = tab.leader === "none" ? void 0 : tab.leader;
16977
17595
  }
16978
17596
  const lineIndex = lines.length;
16979
- const limit = availableWidth(lineIndex);
17597
+ const limit = Math.max(availableWidth(lineIndex), marginReachPx);
16980
17598
  const wouldFit = lineWidthPx + (token.kind === "tab" ? width : advance) <= limit || placed2.every((placed3) => paragraph.runs[placed3.token.runIndex]?.synthetic);
16981
17599
  if (!wouldFit && token.kind !== "space") {
16982
17600
  tokenCursor = tokenIndex;
@@ -20858,21 +21476,8 @@ function endnoteParagraphs(model, label, adaptParagraph) {
20858
21476
  });
20859
21477
  }
20860
21478
 
20861
- // docx/layout/review-display.ts
20862
- function reviewSourceLength(run) {
20863
- return run.equation || run.break || run.fieldChar || run.fieldCode !== void 0 || run.noteReference || run.image ? 1 : run.text.length;
20864
- }
20865
- function visibleReviewParagraph(paragraph, mode) {
20866
- return mode === "all" ? paragraph : {
20867
- ...paragraph,
20868
- runs: paragraph.runs.filter((run) => !isRunHiddenForReview(run, mode))
20869
- };
20870
- }
20871
- function visibleReviewModel(model, mode) {
20872
- return mode === "all" ? model : mapDocumentParagraphs(model, (paragraph) => visibleReviewParagraph(paragraph, mode));
20873
- }
20874
-
20875
21479
  // docx/layout/adapter.ts
21480
+ var FORM_FIELD_SHADING = "#d9d9d9";
20876
21481
  var TABLE_ROW_NOTE = "Table rows with an exact height clip content that does not fit; text in them is not shrunk.";
20877
21482
  var VERTICAL_MERGE_NOTE = "Vertically merged table cells are drawn as one cell, but their text stays in the first row of the merge.";
20878
21483
  var DROP_CAP_NOTE = "Drop caps are laid out as an enlarged first letter (a raised cap), not as a dropped cap.";
@@ -20915,7 +21520,7 @@ function adaptDocumentModel(model, note = () => {
20915
21520
  paragraphStyleId
20916
21521
  });
20917
21522
  const role = formatting.fontTheme?.ascii ?? formatting.fontTheme?.hAnsi;
20918
- const family = formatting.fontFamily ?? (role && theme ? theme.fonts[role]?.latin : void 0);
21523
+ const family = symbolOnly(run) && run.symbol?.font || (formatting.fontFamily ?? (role && theme ? theme.fonts[role]?.latin : void 0));
20919
21524
  const color = formatting.color ?? (formatting.colorTheme && theme ? resolveThemeColorReference(formatting.colorTheme, theme) : void 0);
20920
21525
  return { formatting, family, color };
20921
21526
  }
@@ -20928,7 +21533,9 @@ function adaptDocumentModel(model, note = () => {
20928
21533
  if (run.equation && !equation) reportOnce(EQUATION_NOTE);
20929
21534
  const name = run.field ? fieldName(run.field.instr) : "";
20930
21535
  const noteText = run.noteReference ? noteLabel(run.noteReference.kind, run.noteReference.id) : run.noteMark ? markLabel ?? "" : void 0;
20931
- const text2 = noteText ?? (run.field && !isFieldLocked(run) && (name === "DATE" || name === "TIME") ? dateFieldResult(name, run.field.instr, now) : run.equation ? equation ? "" : "[Equation]" : run.text);
21536
+ const formText = formFieldDisplayText(run);
21537
+ const shaded = model.formFieldShading !== false && (formText !== void 0 || name === "FORMTEXT");
21538
+ const text2 = noteText ?? formText ?? (run.field && !isFieldLocked(run) && (name === "DATE" || name === "TIME") ? dateFieldResult(name, run.field.instr, now) : run.equation ? equation ? "" : "[Equation]" : run.text);
20932
21539
  const script = formatting.verticalAlign === "superscript" || noteText !== void 0 && formatting.verticalAlign === void 0 ? "super" : formatting.verticalAlign === "subscript" ? "sub" : void 0;
20933
21540
  const image = run.image;
20934
21541
  if (image?.unsupported === "Text box") reportOnce(TEXT_BOX_NOTE);
@@ -20964,6 +21571,8 @@ function adaptDocumentModel(model, note = () => {
20964
21571
  positionPx: formatting.positionHalfPoints === void 0 ? void 0 : formatting.positionHalfPoints * 2 / 3
20965
21572
  }),
20966
21573
  ...color && /^#[0-9a-f]{6}$/i.test(color) ? { color } : {},
21574
+ ...shaded ? { background: FORM_FIELD_SHADING } : {},
21575
+ ...run.positionalTab ? { positionalTab: run.positionalTab } : {},
20967
21576
  ...formatting.underline ? { underline: true } : {},
20968
21577
  ...formatting.strike || formatting.doubleStrike ? { strike: true } : {},
20969
21578
  ...run.break ? { breakAfter: run.break } : {},
@@ -21002,7 +21611,9 @@ function adaptDocumentModel(model, note = () => {
21002
21611
  const resolved = catalog ? resolveParagraphFormatting(paragraph, catalog) : paragraph;
21003
21612
  const label = labels.get(paragraph.id);
21004
21613
  const ownFirstLine = resolved.firstLineTwips !== void 0 || resolved.hangingTwips !== void 0;
21005
- const runs = paragraph.runs.map((run) => adaptRun(run, paragraph.style, markLabel));
21614
+ const runs = paragraph.runs.flatMap(
21615
+ (run) => symbolSegments(run).map((segment2) => adaptRun(segment2, paragraph.style, markLabel))
21616
+ );
21006
21617
  const visible = visibleReviewParagraph(paragraph, reviewMode);
21007
21618
  const footnotes = paragraphFootnotes(visible, visibleModel, noteLabel, adaptParagraph);
21008
21619
  const { betweenBorder: _between, ...box } = paragraphBox(resolved, model.theme);
@@ -21524,6 +22135,7 @@ exports.layoutSections = layoutSections;
21524
22135
  exports.ligatureCss = ligatureCss;
21525
22136
  exports.pageNumberValues = pageNumberValues;
21526
22137
  exports.pageNumbers = pageNumbers;
22138
+ exports.pageStyleRefs = pageStyleRefs;
21527
22139
  exports.paragraphFloats = paragraphFloats;
21528
22140
  exports.placeParagraph = placeParagraph;
21529
22141
  exports.placeTab = placeTab;
@@ -21531,6 +22143,7 @@ exports.placeTable = placeTable;
21531
22143
  exports.positionFloats = positionFloats;
21532
22144
  exports.ptToPx = ptToPx;
21533
22145
  exports.pxToTwips = pxToTwips;
22146
+ exports.reviewSourceLength = reviewSourceLength;
21534
22147
  exports.sectionPageCounts = sectionPageCounts;
21535
22148
  exports.splitRowAtHeight = splitRowAtHeight;
21536
22149
  exports.suppressesSpacing = suppressesSpacing;