ooxml-core 1.30.0 → 1.31.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 (363) hide show
  1. package/dist/{PptxHandler-3OLZT5YW.cjs → PptxHandler-DHQPVTUI.cjs} +2 -2
  2. package/dist/{PptxHandler-LOFY2PRO.mjs → PptxHandler-E4DDV3FQ.mjs} +1 -1
  3. package/dist/{PptxHandler-FJHKJEZU.mjs → PptxHandler-KKLAYUGQ.mjs} +2 -2
  4. package/dist/{PresentationBuilder-LVIVJZIL.cjs → PresentationBuilder-JORMF5CP.cjs} +4 -4
  5. package/dist/{PresentationBuilder-W5VRPFLM.mjs → PresentationBuilder-Q2Z33LLM.mjs} +2 -2
  6. package/dist/{PresentationBuilder-23M6WQK3.mjs → PresentationBuilder-YYZYCKTZ.mjs} +1 -1
  7. package/dist/automation/index.cjs +5829 -3266
  8. package/dist/automation/index.mjs +5829 -3266
  9. package/dist/automation/node.cjs +2 -1
  10. package/dist/automation/node.d.ts.map +1 -1
  11. package/dist/automation/node.mjs +2 -1
  12. package/dist/automation/tools/define.d.ts +2 -0
  13. package/dist/automation/tools/define.d.ts.map +1 -1
  14. package/dist/automation/tools/types.d.ts +6 -0
  15. package/dist/automation/tools/types.d.ts.map +1 -1
  16. package/dist/{chunk-JZ64GVIB.mjs → chunk-6FXOAMNL.mjs} +1 -1
  17. package/dist/{chunk-SCK5U362.cjs → chunk-B4LXDHBX.cjs} +19 -1
  18. package/dist/{chunk-5YZFO55V.mjs → chunk-FFJBOR2Y.mjs} +4 -4
  19. package/dist/{chunk-SCTM27HK.mjs → chunk-GJDFCP2T.mjs} +20 -2
  20. package/dist/{chunk-HDHUJM5M.mjs → chunk-KWJYMAEF.mjs} +19 -1
  21. package/dist/{chunk-HK7DVTEF.mjs → chunk-MKDONWNO.mjs} +1 -1
  22. package/dist/{chunk-UVYWAI4M.mjs → chunk-WZJ25K7P.mjs} +1 -1
  23. package/dist/collab/index.cjs +35 -4
  24. package/dist/collab/index.mjs +35 -4
  25. package/dist/collab/websocket-transport.d.ts +9 -1
  26. package/dist/collab/websocket-transport.d.ts.map +1 -1
  27. package/dist/docx/data-binding.d.ts +9 -0
  28. package/dist/docx/data-binding.d.ts.map +1 -0
  29. package/dist/docx/document-parts.d.ts +1 -0
  30. package/dist/docx/document-parts.d.ts.map +1 -1
  31. package/dist/docx/drawing.d.ts.map +1 -1
  32. package/dist/docx/embedded.cjs +1383 -609
  33. package/dist/docx/embedded.mjs +1383 -609
  34. package/dist/docx/index.cjs +1394 -618
  35. package/dist/docx/index.mjs +1394 -618
  36. package/dist/docx/inline-model.d.ts +2 -0
  37. package/dist/docx/inline-model.d.ts.map +1 -1
  38. package/dist/docx/layout/adapt-floats.d.ts.map +1 -1
  39. package/dist/docx/layout/adapt-table.d.ts.map +1 -1
  40. package/dist/docx/layout/adapter.d.ts.map +1 -1
  41. package/dist/docx/layout/equation-object.d.ts +1 -1
  42. package/dist/docx/layout/equation-object.d.ts.map +1 -1
  43. package/dist/docx/layout/floats.d.ts +1 -1
  44. package/dist/docx/layout/floats.d.ts.map +1 -1
  45. package/dist/docx/layout/flow-paragraph.d.ts +4 -0
  46. package/dist/docx/layout/flow-paragraph.d.ts.map +1 -1
  47. package/dist/docx/layout/flow-table.d.ts.map +1 -1
  48. package/dist/docx/layout/index.cjs +452 -203
  49. package/dist/docx/layout/index.mjs +452 -203
  50. package/dist/docx/layout/input.d.ts +12 -0
  51. package/dist/docx/layout/input.d.ts.map +1 -1
  52. package/dist/docx/layout/nested-frame-profile.d.ts +3 -1
  53. package/dist/docx/layout/nested-frame-profile.d.ts.map +1 -1
  54. package/dist/docx/layout/page-cursor.d.ts +11 -2
  55. package/dist/docx/layout/page-cursor.d.ts.map +1 -1
  56. package/dist/docx/layout/paragraph-fragments.d.ts.map +1 -1
  57. package/dist/docx/layout/paragraph-layout.d.ts +5 -0
  58. package/dist/docx/layout/paragraph-layout.d.ts.map +1 -1
  59. package/dist/docx/layout/result.d.ts +4 -0
  60. package/dist/docx/layout/result.d.ts.map +1 -1
  61. package/dist/docx/layout/section-flow.d.ts +2 -0
  62. package/dist/docx/layout/section-flow.d.ts.map +1 -1
  63. package/dist/docx/layout/table-layout.d.ts +4 -14
  64. package/dist/docx/layout/table-layout.d.ts.map +1 -1
  65. package/dist/docx/layout/table-merged-rows.d.ts +21 -0
  66. package/dist/docx/layout/table-merged-rows.d.ts.map +1 -0
  67. package/dist/docx/layout/table-row-split.d.ts +16 -0
  68. package/dist/docx/layout/table-row-split.d.ts.map +1 -0
  69. package/dist/docx/layout/wrap.d.ts +2 -0
  70. package/dist/docx/layout/wrap.d.ts.map +1 -1
  71. package/dist/docx/load/index.cjs +1397 -623
  72. package/dist/docx/load/index.mjs +1397 -623
  73. package/dist/docx/model-paragraph.d.ts +4 -1
  74. package/dist/docx/model-paragraph.d.ts.map +1 -1
  75. package/dist/docx/model.d.ts +24 -1
  76. package/dist/docx/model.d.ts.map +1 -1
  77. package/dist/docx/paragraph-properties.d.ts.map +1 -1
  78. package/dist/docx/paragraph-styles.d.ts.map +1 -1
  79. package/dist/docx/parse-table.d.ts.map +1 -1
  80. package/dist/docx/parse.d.ts.map +1 -1
  81. package/dist/docx/run-segmentation.d.ts.map +1 -1
  82. package/dist/docx/save-modified.d.ts +4 -0
  83. package/dist/docx/save-modified.d.ts.map +1 -0
  84. package/dist/docx/save.d.ts +2 -2
  85. package/dist/docx/save.d.ts.map +1 -1
  86. package/dist/docx/style-formatting-package.d.ts +9 -0
  87. package/dist/docx/style-formatting-package.d.ts.map +1 -0
  88. package/dist/docx/style-numbering-package.d.ts +4 -1
  89. package/dist/docx/style-numbering-package.d.ts.map +1 -1
  90. package/dist/docx/table-grid.d.ts +35 -0
  91. package/dist/docx/table-grid.d.ts.map +1 -0
  92. package/dist/docx/table-structure-cells.d.ts +19 -0
  93. package/dist/docx/table-structure-cells.d.ts.map +1 -0
  94. package/dist/docx/table-structure-check.d.ts +12 -0
  95. package/dist/docx/table-structure-check.d.ts.map +1 -0
  96. package/dist/docx/table-structure-merge.d.ts +28 -0
  97. package/dist/docx/table-structure-merge.d.ts.map +1 -0
  98. package/dist/docx/table-structure.d.ts +30 -0
  99. package/dist/docx/table-structure.d.ts.map +1 -0
  100. package/dist/docx/ui/index.cjs +717 -256
  101. package/dist/docx/ui/index.d.ts +4 -0
  102. package/dist/docx/ui/index.d.ts.map +1 -1
  103. package/dist/docx/ui/index.mjs +703 -257
  104. package/dist/docx/ui/ribbon-action-ids.d.ts +1 -1
  105. package/dist/docx/ui/ribbon-action-ids.d.ts.map +1 -1
  106. package/dist/docx/ui/table-structure-guard.d.ts +2 -0
  107. package/dist/docx/ui/table-structure-guard.d.ts.map +1 -1
  108. package/dist/docx/word-content-control-docs.d.ts +5 -0
  109. package/dist/docx/word-content-control-docs.d.ts.map +1 -0
  110. package/dist/docx/word-corpus-gaps.d.ts +10 -0
  111. package/dist/docx/word-corpus-gaps.d.ts.map +1 -0
  112. package/dist/docx/word-measurer.d.ts +6 -0
  113. package/dist/docx/word-measurer.d.ts.map +1 -0
  114. package/dist/docx/word-spacing-docs.d.ts +12 -0
  115. package/dist/docx/word-spacing-docs.d.ts.map +1 -0
  116. package/dist/docx/word-table-docs.d.ts +9 -0
  117. package/dist/docx/word-table-docs.d.ts.map +1 -0
  118. package/dist/docx/write-drawing.d.ts.map +1 -1
  119. package/dist/docx/write-fallback.d.ts +5 -0
  120. package/dist/docx/write-fallback.d.ts.map +1 -0
  121. package/dist/docx/write-table-properties.d.ts +1 -0
  122. package/dist/docx/write-table-properties.d.ts.map +1 -1
  123. package/dist/docx/write-table-structure.d.ts +14 -0
  124. package/dist/docx/write-table-structure.d.ts.map +1 -0
  125. package/dist/docx/write-table.d.ts +3 -4
  126. package/dist/docx/write-table.d.ts.map +1 -1
  127. package/dist/index.cjs +22 -22
  128. package/dist/index.mjs +22 -22
  129. package/dist/math/index.cjs +22 -22
  130. package/dist/math/index.mjs +22 -22
  131. package/dist/math/omml-box-grouped.d.ts.map +1 -1
  132. package/dist/math/omml-box-layout.d.ts +3 -1
  133. package/dist/math/omml-box-layout.d.ts.map +1 -1
  134. package/dist/math/omml-box-structures.d.ts.map +1 -1
  135. package/dist/math/omml-box.d.ts +2 -0
  136. package/dist/math/omml-box.d.ts.map +1 -1
  137. package/dist/math/omml-svg.d.ts +6 -2
  138. package/dist/math/omml-svg.d.ts.map +1 -1
  139. package/dist/pptx/automation/index.cjs +20 -1
  140. package/dist/pptx/automation/index.d.ts +6 -0
  141. package/dist/pptx/automation/index.d.ts.map +1 -1
  142. package/dist/pptx/automation/index.mjs +6 -5
  143. package/dist/pptx/chunks/index-PdM5zpmu.d.ts.map +1 -1
  144. package/dist/pptx/cli/index.cjs +19 -1
  145. package/dist/pptx/cli/index.mjs +4 -4
  146. package/dist/pptx/converter/index.mjs +2 -2
  147. package/dist/pptx/editor/render/slide-operations.cjs +1 -1
  148. package/dist/pptx/editor/render/slide-operations.mjs +1 -1
  149. package/dist/pptx/index.cjs +19 -1
  150. package/dist/pptx/index.mjs +5 -5
  151. package/dist/teams/chat-rooms.d.ts.map +1 -1
  152. package/dist/teams/chat.d.ts +7 -0
  153. package/dist/teams/chat.d.ts.map +1 -1
  154. package/dist/teams/files.d.ts +1 -1
  155. package/dist/teams/files.d.ts.map +1 -1
  156. package/dist/teams/index.cjs +2735 -1148
  157. package/dist/teams/index.d.ts +3 -0
  158. package/dist/teams/index.d.ts.map +1 -1
  159. package/dist/teams/index.mjs +2710 -1148
  160. package/dist/teams/message-transfer.d.ts +1 -1
  161. package/dist/teams/message-transfer.d.ts.map +1 -1
  162. package/dist/teams/protocol.d.ts +30 -0
  163. package/dist/teams/protocol.d.ts.map +1 -0
  164. package/dist/teams/schema.d.ts +59 -0
  165. package/dist/teams/schema.d.ts.map +1 -0
  166. package/dist/teams/server-config.d.ts +19 -2
  167. package/dist/teams/server-config.d.ts.map +1 -1
  168. package/dist/teams/server-file-storage.d.ts +11 -1
  169. package/dist/teams/server-file-storage.d.ts.map +1 -1
  170. package/dist/teams/server-session.d.ts +2 -0
  171. package/dist/teams/server-session.d.ts.map +1 -1
  172. package/dist/teams/signaling.d.ts +2 -0
  173. package/dist/teams/signaling.d.ts.map +1 -1
  174. package/dist/teams/store.d.ts +9 -0
  175. package/dist/teams/store.d.ts.map +1 -1
  176. package/dist/teams/stored-file.d.ts +1 -1
  177. package/dist/teams/stored-file.d.ts.map +1 -1
  178. package/dist/teams/sync-transport.d.ts.map +1 -1
  179. package/dist/teams/validate-members.d.ts +28 -0
  180. package/dist/teams/validate-members.d.ts.map +1 -0
  181. package/dist/teams/validate-owned.d.ts +20 -0
  182. package/dist/teams/validate-owned.d.ts.map +1 -0
  183. package/dist/teams/validate-update.d.ts +70 -0
  184. package/dist/teams/validate-update.d.ts.map +1 -0
  185. package/dist/teams/workspace.d.ts +12 -0
  186. package/dist/teams/workspace.d.ts.map +1 -1
  187. package/dist/visio/connector-route-walk.d.ts +2 -0
  188. package/dist/visio/connector-route-walk.d.ts.map +1 -1
  189. package/dist/visio/edit-connector-reroute.d.ts.map +1 -1
  190. package/dist/visio/edit-connector.d.ts +2 -0
  191. package/dist/visio/edit-connector.d.ts.map +1 -1
  192. package/dist/visio/edit-delete.d.ts.map +1 -1
  193. package/dist/visio/edit-duplicate-line.d.ts +40 -0
  194. package/dist/visio/edit-duplicate-line.d.ts.map +1 -0
  195. package/dist/visio/edit-duplicate.d.ts.map +1 -1
  196. package/dist/visio/edit-formatting-scope.d.ts +5 -1
  197. package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
  198. package/dist/visio/edit-geometry.d.ts.map +1 -1
  199. package/dist/visio/edit-instance-duplicate.d.ts +2 -1
  200. package/dist/visio/edit-instance-duplicate.d.ts.map +1 -1
  201. package/dist/visio/edit-master-move.d.ts.map +1 -1
  202. package/dist/visio/edit-recalculate-index.d.ts +23 -0
  203. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  204. package/dist/visio/edit-recalculate-text.d.ts +12 -0
  205. package/dist/visio/edit-recalculate-text.d.ts.map +1 -0
  206. package/dist/visio/edit-recalculate-values.d.ts.map +1 -1
  207. package/dist/visio/edit-recalculate.d.ts +15 -3
  208. package/dist/visio/edit-recalculate.d.ts.map +1 -1
  209. package/dist/visio/edit-resize-anchor.d.ts.map +1 -1
  210. package/dist/visio/edit-stencil-connector-layout.d.ts +1 -1
  211. package/dist/visio/edit-stencil-connector-layout.d.ts.map +1 -1
  212. package/dist/visio/edit-text-scope.d.ts +4 -1
  213. package/dist/visio/edit-text-scope.d.ts.map +1 -1
  214. package/dist/visio/formula-analyze.d.ts +18 -0
  215. package/dist/visio/formula-analyze.d.ts.map +1 -0
  216. package/dist/visio/formula-bound.d.ts +4 -0
  217. package/dist/visio/formula-bound.d.ts.map +1 -0
  218. package/dist/visio/formula-evaluate.d.ts +2 -9
  219. package/dist/visio/formula-evaluate.d.ts.map +1 -1
  220. package/dist/visio/formula-extra-functions.d.ts +23 -0
  221. package/dist/visio/formula-extra-functions.d.ts.map +1 -0
  222. package/dist/visio/formula-indirect.d.ts +6 -0
  223. package/dist/visio/formula-indirect.d.ts.map +1 -0
  224. package/dist/visio/formula-master.d.ts +1 -0
  225. package/dist/visio/formula-master.d.ts.map +1 -1
  226. package/dist/visio/formula-operators.d.ts +6 -0
  227. package/dist/visio/formula-operators.d.ts.map +1 -0
  228. package/dist/visio/formula-text-functions.d.ts +5 -1
  229. package/dist/visio/formula-text-functions.d.ts.map +1 -1
  230. package/dist/visio/formula.d.ts +12 -0
  231. package/dist/visio/formula.d.ts.map +1 -1
  232. package/dist/visio/index.cjs +1354 -396
  233. package/dist/visio/index.mjs +1354 -396
  234. package/dist/visio/ui/index.cjs +1341 -383
  235. package/dist/visio/ui/index.mjs +1341 -383
  236. package/dist/xlsx/collab/apply.d.ts.map +1 -1
  237. package/dist/xlsx/collab/codec.d.ts +2 -0
  238. package/dist/xlsx/collab/codec.d.ts.map +1 -1
  239. package/dist/xlsx/collab/dirty.d.ts +4 -1
  240. package/dist/xlsx/collab/dirty.d.ts.map +1 -1
  241. package/dist/xlsx/collab/index.cjs +551 -106
  242. package/dist/xlsx/collab/index.mjs +551 -106
  243. package/dist/xlsx/collab/keyed.d.ts +36 -0
  244. package/dist/xlsx/collab/keyed.d.ts.map +1 -0
  245. package/dist/xlsx/collab/names.d.ts +2 -0
  246. package/dist/xlsx/collab/names.d.ts.map +1 -1
  247. package/dist/xlsx/collab/part-specs.d.ts +13 -0
  248. package/dist/xlsx/collab/part-specs.d.ts.map +1 -0
  249. package/dist/xlsx/collab/schema.d.ts +8 -0
  250. package/dist/xlsx/collab/schema.d.ts.map +1 -1
  251. package/dist/xlsx/collab/sheet-parts.d.ts +19 -0
  252. package/dist/xlsx/collab/sheet-parts.d.ts.map +1 -0
  253. package/dist/xlsx/collab/sheets.d.ts +6 -0
  254. package/dist/xlsx/collab/sheets.d.ts.map +1 -1
  255. package/dist/xlsx/collab/write.d.ts +3 -0
  256. package/dist/xlsx/collab/write.d.ts.map +1 -1
  257. package/dist/xlsx/edit/clipboard-areas.d.ts +17 -0
  258. package/dist/xlsx/edit/clipboard-areas.d.ts.map +1 -0
  259. package/dist/xlsx/edit/custom-views.d.ts +21 -0
  260. package/dist/xlsx/edit/custom-views.d.ts.map +1 -0
  261. package/dist/xlsx/edit/data-table.d.ts.map +1 -1
  262. package/dist/xlsx/edit/history.d.ts +1 -1
  263. package/dist/xlsx/edit/history.d.ts.map +1 -1
  264. package/dist/xlsx/edit/index.d.ts +2 -0
  265. package/dist/xlsx/edit/index.d.ts.map +1 -1
  266. package/dist/xlsx/edit/paste-selection.d.ts.map +1 -1
  267. package/dist/xlsx/edit/scenario-merge.d.ts +7 -0
  268. package/dist/xlsx/edit/scenario-merge.d.ts.map +1 -0
  269. package/dist/xlsx/edit/session.d.ts.map +1 -1
  270. package/dist/xlsx/edit/shift-data-tables.d.ts +7 -0
  271. package/dist/xlsx/edit/shift-data-tables.d.ts.map +1 -0
  272. package/dist/xlsx/edit/shift-scenarios.d.ts +7 -0
  273. package/dist/xlsx/edit/shift-scenarios.d.ts.map +1 -0
  274. package/dist/xlsx/edit/shift-sheet.d.ts.map +1 -1
  275. package/dist/xlsx/edit/sparkline-grouping.d.ts +10 -0
  276. package/dist/xlsx/edit/sparkline-grouping.d.ts.map +1 -0
  277. package/dist/xlsx/edit/types.d.ts +21 -0
  278. package/dist/xlsx/edit/types.d.ts.map +1 -1
  279. package/dist/xlsx/formula/ets-excel-compare.d.ts +24 -0
  280. package/dist/xlsx/formula/ets-excel-compare.d.ts.map +1 -0
  281. package/dist/xlsx/formula/functions/ets-core.d.ts +36 -0
  282. package/dist/xlsx/formula/functions/ets-core.d.ts.map +1 -0
  283. package/dist/xlsx/formula/functions/ets-grid.d.ts +15 -0
  284. package/dist/xlsx/formula/functions/ets-grid.d.ts.map +1 -0
  285. package/dist/xlsx/formula/functions/ets-init.d.ts +15 -0
  286. package/dist/xlsx/formula/functions/ets-init.d.ts.map +1 -0
  287. package/dist/xlsx/formula/functions/ets-input.d.ts +13 -0
  288. package/dist/xlsx/formula/functions/ets-input.d.ts.map +1 -0
  289. package/dist/xlsx/formula/functions/ets-season.d.ts +6 -0
  290. package/dist/xlsx/formula/functions/ets-season.d.ts.map +1 -0
  291. package/dist/xlsx/formula/functions/forecast-ets.d.ts +3 -0
  292. package/dist/xlsx/formula/functions/forecast-ets.d.ts.map +1 -0
  293. package/dist/xlsx/formula/functions/statistical.d.ts.map +1 -1
  294. package/dist/xlsx/index.cjs +4444 -2447
  295. package/dist/xlsx/index.mjs +4423 -2448
  296. package/dist/xlsx/layout/form-control-link.d.ts +20 -0
  297. package/dist/xlsx/layout/form-control-link.d.ts.map +1 -0
  298. package/dist/xlsx/layout/form-control-state.d.ts +49 -0
  299. package/dist/xlsx/layout/form-control-state.d.ts.map +1 -0
  300. package/dist/xlsx/layout/form-control-view.d.ts +11 -0
  301. package/dist/xlsx/layout/form-control-view.d.ts.map +1 -0
  302. package/dist/xlsx/layout/header-footer-edit.d.ts +4 -2
  303. package/dist/xlsx/layout/header-footer-edit.d.ts.map +1 -1
  304. package/dist/xlsx/layout/header-footer.d.ts +16 -0
  305. package/dist/xlsx/layout/header-footer.d.ts.map +1 -1
  306. package/dist/xlsx/layout/index.d.ts +5 -0
  307. package/dist/xlsx/layout/index.d.ts.map +1 -1
  308. package/dist/xlsx/layout/ref-evaluator.d.ts +6 -0
  309. package/dist/xlsx/layout/ref-evaluator.d.ts.map +1 -1
  310. package/dist/xlsx/layout/shape-paint.d.ts +25 -0
  311. package/dist/xlsx/layout/shape-paint.d.ts.map +1 -0
  312. package/dist/xlsx/layout/shape-view.d.ts +15 -0
  313. package/dist/xlsx/layout/shape-view.d.ts.map +1 -0
  314. package/dist/xlsx/load/index.cjs +2134 -1103
  315. package/dist/xlsx/load/index.mjs +2134 -1103
  316. package/dist/xlsx/model-custom-views.d.ts +33 -0
  317. package/dist/xlsx/model-custom-views.d.ts.map +1 -0
  318. package/dist/xlsx/model-shapes.d.ts +78 -0
  319. package/dist/xlsx/model-shapes.d.ts.map +1 -0
  320. package/dist/xlsx/model.d.ts +38 -1
  321. package/dist/xlsx/model.d.ts.map +1 -1
  322. package/dist/xlsx/read/custom-views.d.ts +5 -0
  323. package/dist/xlsx/read/custom-views.d.ts.map +1 -0
  324. package/dist/xlsx/read/drawing.d.ts.map +1 -1
  325. package/dist/xlsx/read/form-control.d.ts +14 -0
  326. package/dist/xlsx/read/form-control.d.ts.map +1 -0
  327. package/dist/xlsx/read/header-footer-images.d.ts +5 -0
  328. package/dist/xlsx/read/header-footer-images.d.ts.map +1 -0
  329. package/dist/xlsx/read/load.d.ts.map +1 -1
  330. package/dist/xlsx/read/shape.d.ts +5 -0
  331. package/dist/xlsx/read/shape.d.ts.map +1 -0
  332. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  333. package/dist/xlsx/read/workbook-part.d.ts +5 -1
  334. package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
  335. package/dist/xlsx/read/worksheet-children.d.ts +3 -0
  336. package/dist/xlsx/read/worksheet-children.d.ts.map +1 -0
  337. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  338. package/dist/xlsx/ui/commands/i18n/sparklines.d.ts.map +1 -1
  339. package/dist/xlsx/ui/commands/i18n/what-if.d.ts.map +1 -1
  340. package/dist/xlsx/ui/commands/what-if.d.ts +0 -1
  341. package/dist/xlsx/ui/commands/what-if.d.ts.map +1 -1
  342. package/dist/xlsx/ui/dialogs/forecast-sheet.d.ts +51 -0
  343. package/dist/xlsx/ui/dialogs/forecast-sheet.d.ts.map +1 -0
  344. package/dist/xlsx/ui/dialogs/scenario-summary.d.ts +15 -0
  345. package/dist/xlsx/ui/dialogs/scenario-summary.d.ts.map +1 -0
  346. package/dist/xlsx/ui/index.cjs +4411 -2195
  347. package/dist/xlsx/ui/index.d.ts +2 -0
  348. package/dist/xlsx/ui/index.d.ts.map +1 -1
  349. package/dist/xlsx/ui/index.mjs +4404 -2194
  350. package/dist/xlsx/ui/locales/de/grid.d.ts.map +1 -1
  351. package/dist/xlsx/ui/locales/en/grid.d.ts.map +1 -1
  352. package/dist/xlsx/ui/locales/es/grid.d.ts.map +1 -1
  353. package/dist/xlsx/ui/locales/fr/grid.d.ts.map +1 -1
  354. package/dist/xlsx/ui/locales/zh-CN/grid.d.ts.map +1 -1
  355. package/dist/xlsx/write/custom-views.d.ts +4 -0
  356. package/dist/xlsx/write/custom-views.d.ts.map +1 -0
  357. package/dist/xlsx/write/drawing.d.ts.map +1 -1
  358. package/dist/xlsx/write/form-control.d.ts +4 -0
  359. package/dist/xlsx/write/form-control.d.ts.map +1 -0
  360. package/dist/xlsx/write/sheet-data.d.ts.map +1 -1
  361. package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
  362. package/dist/xlsx/write/worksheet.d.ts.map +1 -1
  363. package/package.json +1 -1
@@ -703,11 +703,11 @@ function inspectDeclaration(value3, encoding) {
703
703
  if (declarations.length) fail("INVALID_XML", "Invalid XML declaration attributes");
704
704
  }
705
705
  function decodeXmlAttribute(value3) {
706
- const entities = { amp: "&", lt: "<", gt: ">", apos: "'", quot: '"' };
706
+ const entities2 = { amp: "&", lt: "<", gt: ">", apos: "'", quot: '"' };
707
707
  return value3.replace(/[\t\r\n]/g, " ").replace(/&(amp|lt|gt|apos|quot|#x[\da-fA-F]+|#\d+);/g, (_, entity) => {
708
708
  if (entity.startsWith("#x")) return String.fromCodePoint(parseInt(entity.slice(2), 16));
709
709
  if (entity.startsWith("#")) return String.fromCodePoint(Number(entity.slice(1)));
710
- return entities[entity] ?? "";
710
+ return entities2[entity] ?? "";
711
711
  });
712
712
  }
713
713
  function inspectNamespaces(root2, check) {
@@ -2054,6 +2054,60 @@ function evaluateNumericFormulaFunction(name3, args) {
2054
2054
  return formulaFailure("unsupported", `Unsupported numeric function ${name3}`);
2055
2055
  }
2056
2056
 
2057
+ // visio/formula-extra-functions.ts
2058
+ var IGNORE_CASE = 1;
2059
+ var IGNORE_NONSPACE = 2;
2060
+ var IGNORE_SYMBOLS = 4;
2061
+ function strSameEx(a2, b, flags) {
2062
+ if (!Number.isInteger(flags) || flags < 0)
2063
+ return formulaFailure("value", "STRSAMEEX flags must be a whole number");
2064
+ if (flags & -8)
2065
+ return formulaFailure("unsupported", "STRSAMEEX with kana or width comparison flags");
2066
+ const fold = (text5) => {
2067
+ let result2 = text5;
2068
+ if (flags & IGNORE_NONSPACE) result2 = result2.normalize("NFD").replace(/\p{Mn}/gu, "");
2069
+ if (flags & IGNORE_SYMBOLS) result2 = result2.replace(/[\p{P}\p{S}\s]/gu, "");
2070
+ return flags & IGNORE_CASE ? result2.toLowerCase() : result2;
2071
+ };
2072
+ return fold(a2) === fold(b);
2073
+ }
2074
+ function formatNumberPicture(value3, picture) {
2075
+ if (value3.unit !== "scalar") return formulaFailure("unit", "FORMAT requires a plain number");
2076
+ const match = /^([#,0]*)(?:\.([0#]*))?(%?)$/.exec(picture);
2077
+ const integerPicture = match?.[1] ?? "";
2078
+ if (!match || !integerPicture.includes("0") || /0,*#/.test(integerPicture) || integerPicture.startsWith(",") || integerPicture.endsWith(",") || integerPicture.includes(",,") || /0#/.test(match[2] ?? ""))
2079
+ return formulaFailure("unsupported", `FORMAT picture "${picture}"`);
2080
+ const fractionPicture = match[2] ?? "", percent = match[3] === "%", grouped = integerPicture.includes(",");
2081
+ const minInteger = (integerPicture.match(/0/g) ?? []).length;
2082
+ const minFraction = (fractionPicture.match(/0/g) ?? []).length;
2083
+ const maxFraction = fractionPicture.length;
2084
+ const scaled = percent ? value3.value * 100 : value3.value;
2085
+ const factor = 10 ** maxFraction;
2086
+ const rounded = Math.sign(scaled) * Math.round(Math.abs(scaled) * factor + 1e-9) / factor;
2087
+ const [digits = "", decimals = ""] = Math.abs(rounded).toFixed(maxFraction).split(".");
2088
+ let whole = digits.replace(/^0+/, "").padStart(minInteger, "0");
2089
+ if (grouped) whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2090
+ let fraction = decimals;
2091
+ while (fraction.length > minFraction && fraction.endsWith("0")) fraction = fraction.slice(0, -1);
2092
+ const negative = rounded < 0;
2093
+ return `${negative ? "-" : ""}${whole}${fraction ? `.${fraction}` : ""}${percent ? "%" : ""}`;
2094
+ }
2095
+ function visioDateSerial(year, month, day) {
2096
+ if (![year, month, day].every(Number.isInteger))
2097
+ return formulaFailure("value", "DATE requires whole numbers");
2098
+ if (year < 1 || year > 9999 || month < 1 || month > 12 || day < 1 || day > 31)
2099
+ return formulaFailure("value", "DATE is outside the calendar");
2100
+ const date2 = /* @__PURE__ */ new Date(0);
2101
+ date2.setUTCFullYear(year, month - 1, day);
2102
+ if (date2.getUTCMonth() !== month - 1) return formulaFailure("value", "DATE is not a real day");
2103
+ return (date2.getTime() - Date.UTC(1899, 11, 30)) / 864e5;
2104
+ }
2105
+ var angleToLocal = (frame, angle) => angle - frame.angle;
2106
+ function localToParent(frame, x, y) {
2107
+ const dx = x - frame.locPinX, dy = y - frame.locPinY, cos = Math.cos(frame.angle), sin = Math.sin(frame.angle);
2108
+ return [frame.pinX + dx * cos - dy * sin, frame.pinY + dx * sin + dy * cos];
2109
+ }
2110
+
2057
2111
  // visio/formula-text-functions.ts
2058
2112
  var textResultFunctions = /* @__PURE__ */ new Set([
2059
2113
  "MID",
@@ -2065,12 +2119,15 @@ var textResultFunctions = /* @__PURE__ */ new Set([
2065
2119
  "SUBSTITUTE",
2066
2120
  "REPLACE",
2067
2121
  "CHAR",
2068
- "INDEX"
2122
+ "INDEX",
2123
+ "FORMAT",
2124
+ "SHAPETEXT"
2069
2125
  ]);
2070
2126
  var textNumberFunctions = /* @__PURE__ */ new Set([
2071
2127
  "LEN",
2072
2128
  "FIND",
2073
2129
  "STRSAME",
2130
+ "STRSAMEEX",
2074
2131
  "LOOKUP"
2075
2132
  ]);
2076
2133
  var LIST_SEPARATOR = ";";
@@ -2086,6 +2143,7 @@ function exactInteger(context, node3, name3) {
2086
2143
  if (!Number.isInteger(value3.value)) return unsupported2(`${name3} with a fractional number`);
2087
2144
  return value3.value;
2088
2145
  }
2146
+ var isTheText = (node3) => node3.kind === "reference" && node3.reference.cell.toLowerCase() === "thetext";
2089
2147
  function evaluateFormulaText(node3, context, depth = 0) {
2090
2148
  context.tick();
2091
2149
  if (depth > 64) return formulaFailure("limit", "Formula evaluation limit");
@@ -2096,6 +2154,10 @@ function evaluateFormulaText(node3, context, depth = 0) {
2096
2154
  if (node3.kind === "string") return node3.value;
2097
2155
  if (node3.kind === "binary" && node3.operator === "&")
2098
2156
  return text5(node3.left, "&") + text5(node3.right, "&");
2157
+ if (node3.kind === "reference" && isTheText(node3)) {
2158
+ const read = context.textOf?.(node3.reference);
2159
+ return read === void 0 ? unsupported2("Text read from a cell") : read;
2160
+ }
2099
2161
  if (node3.kind !== "call") {
2100
2162
  let value3;
2101
2163
  try {
@@ -2117,6 +2179,12 @@ function evaluateFormulaText(node3, context, depth = 0) {
2117
2179
  if (value3.unit !== "scalar") return unsupported2("Text from a number with a unit");
2118
2180
  return String(value3.value);
2119
2181
  }
2182
+ if (name3 === "SHAPETEXT") {
2183
+ arity(1);
2184
+ const target2 = args[0];
2185
+ if (!isTheText(target2)) return unsupported2("SHAPETEXT of something other than TheText");
2186
+ return text5(target2, name3);
2187
+ }
2120
2188
  if (name3 === "MID") {
2121
2189
  arity(3);
2122
2190
  const source = text5(args[0], name3), start = integer(context, args[1], name3), length = integer(context, args[2], name3);
@@ -2171,6 +2239,10 @@ function evaluateFormulaText(node3, context, depth = 0) {
2171
2239
  if (code >= 128 && code <= 159) return unsupported2("CHAR in the Windows-1252 range");
2172
2240
  return String.fromCharCode(code);
2173
2241
  }
2242
+ if (name3 === "FORMAT") {
2243
+ arity(2);
2244
+ return formatNumberPicture(context.number(args[0]), text5(args[1], name3));
2245
+ }
2174
2246
  arity(2);
2175
2247
  const index2 = integer(context, args[0], name3);
2176
2248
  const items = text5(args[1], name3).split(LIST_SEPARATOR);
@@ -2203,6 +2275,11 @@ function evaluateTextNumberFunction(name3, args, context) {
2203
2275
  const ignoreCase = args[2] ? context.number(args[2]).value !== 0 : false;
2204
2276
  return scalar4(ignoreCase ? Number(a2.toLowerCase() === b.toLowerCase()) : Number(a2 === b));
2205
2277
  }
2278
+ if (name3 === "STRSAMEEX") {
2279
+ if (args.length === 4) return formulaFailure("unsupported", "STRSAMEEX with a locale");
2280
+ arity(3);
2281
+ return scalar4(Number(strSameEx(text5(0), text5(1), context.number(args[2]).value)));
2282
+ }
2206
2283
  arity(2);
2207
2284
  const wanted = text5(0).toLowerCase();
2208
2285
  return scalar4(
@@ -2210,6 +2287,23 @@ function evaluateTextNumberFunction(name3, args, context) {
2210
2287
  );
2211
2288
  }
2212
2289
 
2290
+ // visio/formula-indirect.ts
2291
+ var FRAME_INPUTS = {
2292
+ ANGLETOLOC: ["Angle", "FlipX", "FlipY"],
2293
+ LOCTOPAR: ["PinX", "PinY", "LocPinX", "LocPinY", "Angle", "FlipX", "FlipY"]
2294
+ };
2295
+ function literalIndirectTarget(node3) {
2296
+ if (node3.kind !== "call" || node3.args.length !== 1) return void 0;
2297
+ const address = node3.args[0];
2298
+ if (address.kind !== "string") return void 0;
2299
+ try {
2300
+ const target2 = parseVisioFormula(address.value);
2301
+ return target2.kind === "reference" && !(target2.reference.shapeId === void 0 && /^(true|false)$/i.test(target2.reference.cell)) && target2.reference.cell.toLowerCase() !== "thetext" ? target2.reference : void 0;
2302
+ } catch {
2303
+ return void 0;
2304
+ }
2305
+ }
2306
+
2213
2307
  // visio/formula-math-functions.ts
2214
2308
  var mathFormulaFunctions = /* @__PURE__ */ new Set([
2215
2309
  "ROUND",
@@ -2314,7 +2408,7 @@ function evaluateMathFormulaFunction(name3, args) {
2314
2408
  return formulaFailure("unsupported", `Unsupported function ${name3}`);
2315
2409
  }
2316
2410
 
2317
- // visio/formula-evaluate.ts
2411
+ // visio/formula-analyze.ts
2318
2412
  var supported = /* @__PURE__ */ new Set([
2319
2413
  "GUARD",
2320
2414
  "IF",
@@ -2336,6 +2430,11 @@ var supported = /* @__PURE__ */ new Set([
2336
2430
  "PNTY",
2337
2431
  "ISERROR",
2338
2432
  "IFERROR",
2433
+ "INDIRECT",
2434
+ "DATE",
2435
+ "ANGLETOLOC",
2436
+ "LOCTOPAR",
2437
+ "SHEETREF",
2339
2438
  ...textNumberFunctions,
2340
2439
  ...textResultFunctions,
2341
2440
  ...numericFormulaFunctions,
@@ -2388,10 +2487,11 @@ var staticUnsupported = /* @__PURE__ */ new Set([
2388
2487
  "MSOTINT",
2389
2488
  "SHADE",
2390
2489
  "LUMDIFF",
2391
- "MODULUS"
2490
+ "MODULUS",
2491
+ // Reads an argument of the master the shape was dropped from; pure, evaluated in master scope.
2492
+ "ARG"
2392
2493
  ]);
2393
2494
  var dynamic = /* @__PURE__ */ new Set([
2394
- "INDIRECT",
2395
2495
  "EVALCELL",
2396
2496
  "EVALTEXT",
2397
2497
  "DEPENDSON",
@@ -2408,6 +2508,19 @@ var dynamic = /* @__PURE__ */ new Set([
2408
2508
  "PAR"
2409
2509
  ]);
2410
2510
  var isClassifiedVisioFunction = (name3) => supported.has(name3) || staticUnsupported.has(name3) || dynamic.has(name3);
2511
+ var opaqueFunctions = /* @__PURE__ */ new Set([
2512
+ "EVALCELL",
2513
+ "EVALTEXT",
2514
+ "GETREF",
2515
+ "REF",
2516
+ "_SHEETCELL",
2517
+ // Structure lookups: the result changes when shapes are created, moved or reparented.
2518
+ "CONTAINERSHEETREF",
2519
+ "MEMBERSHEETREF",
2520
+ "CALLOUTTARGET",
2521
+ "PARENT",
2522
+ "PAR"
2523
+ ]);
2411
2524
  function traverse(ast, limits, visit) {
2412
2525
  const maxNodes = formulaLimit(limits.maxNodes, 1024), maxDepth = formulaLimit(limits.maxDepth, 64);
2413
2526
  const queue = [[ast, 0]];
@@ -2425,7 +2538,7 @@ function traverse(ast, limits, visit) {
2425
2538
  function analyzeVisioFormula(source, limits = {}) {
2426
2539
  const ast = typeof source === "string" ? parseVisioFormula(source, limits) : source;
2427
2540
  const references = /* @__PURE__ */ new Map(), unsupportedFunctions = /* @__PURE__ */ new Set();
2428
- let unsafe2 = false, guarded = false;
2541
+ let unsafe2 = false, opaque = false, guarded = false;
2429
2542
  traverse(ast, limits, (node3) => {
2430
2543
  if (node3.kind === "reference")
2431
2544
  references.set(
@@ -2435,9 +2548,23 @@ function analyzeVisioFormula(source, limits = {}) {
2435
2548
  if (node3.kind === "call") {
2436
2549
  const inputs = node3.name === "ISTHEMED" ? ["ColorSchemeIndex"] : ["THEMEVAL", "THEME"].includes(node3.name) ? themeInputs : [];
2437
2550
  for (const cell of inputs) references.set(`!${cell.toLowerCase()}`, { cell });
2551
+ for (const cell of FRAME_INPUTS[node3.name] ?? [])
2552
+ references.set(`!${cell.toLowerCase()}`, { cell });
2553
+ if (node3.name === "INDIRECT") {
2554
+ const target2 = literalIndirectTarget(node3);
2555
+ if (target2 && limits.literalIndirect)
2556
+ references.set(`${target2.shapeId ?? ""}!${target2.cell.toLowerCase()}`, target2);
2557
+ else {
2558
+ unsafe2 = true;
2559
+ opaque = true;
2560
+ }
2561
+ }
2438
2562
  if (!supported.has(node3.name)) unsupportedFunctions.add(node3.name);
2439
- if (dynamic.has(node3.name) || !supported.has(node3.name) && !staticUnsupported.has(node3.name))
2563
+ const shapeText2 = node3.name === "SHAPETEXT" && limits.shapeTextReads === true && node3.args.length === 1 && isTheText(node3.args[0]);
2564
+ if (dynamic.has(node3.name) && !shapeText2 || !supported.has(node3.name) && !staticUnsupported.has(node3.name))
2440
2565
  unsafe2 = true;
2566
+ if (opaqueFunctions.has(node3.name) || node3.name === "SHAPETEXT" && !shapeText2 || !supported.has(node3.name) && !staticUnsupported.has(node3.name) && !dynamic.has(node3.name) && node3.name !== "_SHEETCALL")
2567
+ opaque = true;
2441
2568
  if (node3.name === "GUARD") guarded = true;
2442
2569
  }
2443
2570
  });
@@ -2445,10 +2572,56 @@ function analyzeVisioFormula(source, limits = {}) {
2445
2572
  references: [...references.values()],
2446
2573
  unsupportedFunctions: [...unsupportedFunctions],
2447
2574
  dynamic: unsafe2,
2575
+ opaque,
2448
2576
  guarded
2449
2577
  };
2450
2578
  }
2451
- function binary(operator, a2, b) {
2579
+
2580
+ // visio/formula-bound.ts
2581
+ function evaluateBound(args, arg) {
2582
+ if (args.length < 5 || (args.length - 2) % 3 !== 0 || args.length > 302)
2583
+ return formulaFailure("arity", "Invalid BOUND argument count");
2584
+ const value3 = arg(0), type = arg(1);
2585
+ if (type.unit !== "scalar" || ![0, 1, 2].includes(type.value))
2586
+ return formulaFailure("value", "BOUND type must be 0, 1 or 2");
2587
+ if (type.value === 2) return value3;
2588
+ if (type.value === 1) {
2589
+ let current = value3.value, unit4 = value3.unit;
2590
+ for (let pass = 0; pass <= (args.length - 2) / 3; pass++) {
2591
+ let moved = false;
2592
+ for (let index2 = 2; index2 < args.length; index2 += 3) {
2593
+ if (arg(index2).value !== 0) continue;
2594
+ const a2 = arg(index2 + 1), b = arg(index2 + 2);
2595
+ unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, a2);
2596
+ unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, b);
2597
+ const low = Math.min(a2.value, b.value), high = Math.max(a2.value, b.value);
2598
+ if (current > low && current < high) {
2599
+ current = current - low < high - current ? low : high;
2600
+ moved = true;
2601
+ }
2602
+ }
2603
+ if (!moved) break;
2604
+ }
2605
+ return finiteFormulaValue({ value: current, unit: unit4 });
2606
+ }
2607
+ let nearest;
2608
+ let unit3 = value3.unit;
2609
+ for (let index2 = 2; index2 < args.length; index2 += 3) {
2610
+ if (arg(index2).value !== 0) continue;
2611
+ const a2 = arg(index2 + 1), b = arg(index2 + 2);
2612
+ unit3 = compatibleFormulaUnits({ value: value3.value, unit: unit3 }, a2);
2613
+ unit3 = compatibleFormulaUnits({ value: value3.value, unit: unit3 }, b);
2614
+ const low = Math.min(a2.value, b.value), high = Math.max(a2.value, b.value);
2615
+ if (value3.value >= low && value3.value <= high) return finiteFormulaValue({ value: value3.value, unit: unit3 });
2616
+ const edge2 = value3.value < low ? low : high;
2617
+ if (nearest === void 0 || Math.abs(edge2 - value3.value) < Math.abs(nearest - value3.value))
2618
+ nearest = edge2;
2619
+ }
2620
+ return finiteFormulaValue({ value: nearest ?? value3.value, unit: unit3 });
2621
+ }
2622
+
2623
+ // visio/formula-operators.ts
2624
+ function binaryOperator(operator, a2, b) {
2452
2625
  let unit3;
2453
2626
  if (operator === "+" || operator === "-") {
2454
2627
  unit3 = compatibleFormulaUnits(a2, b);
@@ -2478,12 +2651,36 @@ function binary(operator, a2, b) {
2478
2651
  return formulaFailure("syntax", `Unsupported operator ${operator}`);
2479
2652
  return { value: comparisons[operator] ? 1 : 0, unit: "scalar" };
2480
2653
  }
2654
+ function evaluatedShapeFrame(sheet, resolve) {
2655
+ if (sheet.kind !== "call" || sheet.name !== "SHEETREF" || sheet.args.length)
2656
+ return formulaFailure("unsupported", "A sheet other than SHEETREF()");
2657
+ const read = (cell, fallback) => {
2658
+ try {
2659
+ return finiteFormulaValue(resolve({ cell })).value;
2660
+ } catch (error) {
2661
+ if (fallback === void 0) throw error;
2662
+ return fallback;
2663
+ }
2664
+ };
2665
+ if (read("FlipX", 0) !== 0 || read("FlipY", 0) !== 0)
2666
+ return formulaFailure("unsupported", "A coordinate conversion on a flipped shape");
2667
+ return {
2668
+ pinX: read("PinX"),
2669
+ pinY: read("PinY"),
2670
+ locPinX: read("LocPinX", 0),
2671
+ locPinY: read("LocPinY", 0),
2672
+ angle: read("Angle", 0)
2673
+ };
2674
+ }
2675
+
2676
+ // visio/formula-evaluate.ts
2481
2677
  function evaluateVisioFormula(source, resolve, limits = {}) {
2482
2678
  const ast = typeof source === "string" ? parseVisioFormula(source, limits) : source;
2483
2679
  const maxSteps = formulaLimit(limits.maxSteps, 8192), maxDepth = formulaLimit(limits.maxDepth, 64);
2484
2680
  traverse(ast, limits, () => {
2485
2681
  });
2486
2682
  let steps = 0;
2683
+ const shapeFrame = (sheet) => evaluatedShapeFrame(sheet, resolve);
2487
2684
  const evaluate = (node3, depth = 0) => {
2488
2685
  if (++steps > maxSteps || depth > maxDepth)
2489
2686
  return formulaFailure("limit", "Formula evaluation limit");
@@ -2507,7 +2704,7 @@ function evaluateVisioFormula(source, resolve, limits = {}) {
2507
2704
  else if (right2.unit === "length" && left.unit === "scalar" && node3.left.kind === "number")
2508
2705
  left = { ...left, unit: "length" };
2509
2706
  }
2510
- return binary(node3.operator, left, right2);
2707
+ return binaryOperator(node3.operator, left, right2);
2511
2708
  }
2512
2709
  const name3 = node3.name;
2513
2710
  if ((name3 === "TEXTWIDTH" || name3 === "TEXTHEIGHT") && limits.text) {
@@ -2536,18 +2733,57 @@ function evaluateVisioFormula(source, resolve, limits = {}) {
2536
2733
  return formulaFailure("context", `${name3} requires a valid document context`);
2537
2734
  return { value: value4, unit: "scalar" };
2538
2735
  }
2736
+ const textContext = {
2737
+ number: (child4) => evaluate(child4, depth + 1),
2738
+ ...limits.textOf ? { textOf: limits.textOf } : {},
2739
+ tick: () => {
2740
+ if (++steps > maxSteps) formulaFailure("limit", "Formula evaluation limit");
2741
+ }
2742
+ };
2539
2743
  if (textNumberFunctions.has(name3))
2540
- return evaluateTextNumberFunction(name3, node3.args, {
2541
- number: (child4) => evaluate(child4, depth + 1),
2542
- tick: () => {
2543
- if (++steps > maxSteps) formulaFailure("limit", "Formula evaluation limit");
2544
- }
2744
+ return evaluateTextNumberFunction(name3, node3.args, textContext);
2745
+ if (name3 === "INDIRECT") {
2746
+ arity(1);
2747
+ const target2 = parseVisioFormula(evaluateFormulaText(node3.args[0], textContext, 1));
2748
+ if (target2.kind !== "reference")
2749
+ return formulaFailure("value", "INDIRECT needs a cell address");
2750
+ return finiteFormulaValue(resolve(target2.reference));
2751
+ }
2752
+ if (name3 === "DATE") {
2753
+ arity(3);
2754
+ const [year, month, day] = node3.args.map((_, index2) => {
2755
+ const part = arg(index2);
2756
+ if (part.unit !== "scalar") return formulaFailure("unit", "DATE requires plain numbers");
2757
+ return part.value;
2545
2758
  });
2759
+ return { value: visioDateSerial(year, month, day), unit: "time" };
2760
+ }
2761
+ if (name3 === "SHEETREF" || name3 === "LOCTOPAR")
2762
+ return formulaFailure("unsupported", `${name3} does not return a number`);
2763
+ if (name3 === "ANGLETOLOC") {
2764
+ arity(2);
2765
+ const angle = arg(1);
2766
+ if (angle.unit !== "angle" && angle.unit !== "scalar")
2767
+ return formulaFailure("unit", "ANGLETOLOC requires an angle");
2768
+ return { value: angleToLocal(shapeFrame(node3.args[0]), angle.value), unit: "angle" };
2769
+ }
2546
2770
  if (textResultFunctions.has(name3) || name3 === "PNT")
2547
2771
  return formulaFailure("unsupported", `${name3} does not return a number`);
2548
2772
  if (name3 === "PNTX" || name3 === "PNTY") {
2549
2773
  arity(1);
2550
2774
  const point2 = node3.args[0];
2775
+ if (point2.kind === "call" && point2.name === "LOCTOPAR") {
2776
+ if (point2.args.length !== 3)
2777
+ return formulaFailure("arity", "Invalid LOCTOPAR argument count");
2778
+ const [x2, y2] = [1, 2].map((index2) => {
2779
+ const part = evaluate(point2.args[index2], depth + 2);
2780
+ if (part.unit !== "scalar" && part.unit !== "length")
2781
+ return formulaFailure("unit", "LOCTOPAR requires lengths");
2782
+ return part.value;
2783
+ });
2784
+ const parent = localToParent(shapeFrame(point2.args[0]), x2, y2);
2785
+ return finiteFormulaValue({ value: parent[name3 === "PNTX" ? 0 : 1], unit: "length" });
2786
+ }
2551
2787
  if (point2.kind !== "call" || point2.name !== "PNT")
2552
2788
  return formulaFailure("unsupported", `${name3} of something other than PNT(x,y)`);
2553
2789
  if (point2.args.length !== 2) return formulaFailure("arity", "Invalid PNT argument count");
@@ -2605,47 +2841,7 @@ function evaluateVisioFormula(source, resolve, limits = {}) {
2605
2841
  }
2606
2842
  return finiteFormulaValue(result2);
2607
2843
  }
2608
- if (name3 === "BOUND") {
2609
- if (node3.args.length < 5 || (node3.args.length - 2) % 3 !== 0 || node3.args.length > 302)
2610
- return formulaFailure("arity", "Invalid BOUND argument count");
2611
- const value4 = arg(0), type = arg(1);
2612
- if (type.unit !== "scalar" || ![0, 1, 2].includes(type.value))
2613
- return formulaFailure("value", "BOUND type must be 0, 1 or 2");
2614
- if (type.value === 2) return value4;
2615
- if (type.value === 1) {
2616
- let current = value4.value, unit4 = value4.unit;
2617
- for (let pass = 0; pass <= (node3.args.length - 2) / 3; pass++) {
2618
- let moved = false;
2619
- for (let index2 = 2; index2 < node3.args.length; index2 += 3) {
2620
- if (arg(index2).value !== 0) continue;
2621
- const a2 = arg(index2 + 1), b = arg(index2 + 2);
2622
- unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, a2);
2623
- unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, b);
2624
- const low = Math.min(a2.value, b.value), high = Math.max(a2.value, b.value);
2625
- if (current > low && current < high) {
2626
- current = current - low < high - current ? low : high;
2627
- moved = true;
2628
- }
2629
- }
2630
- if (!moved) break;
2631
- }
2632
- return finiteFormulaValue({ value: current, unit: unit4 });
2633
- }
2634
- let nearest;
2635
- let unit3 = value4.unit;
2636
- for (let index2 = 2; index2 < node3.args.length; index2 += 3) {
2637
- if (arg(index2).value !== 0) continue;
2638
- const a2 = arg(index2 + 1), b = arg(index2 + 2);
2639
- unit3 = compatibleFormulaUnits({ value: value4.value, unit: unit3 }, a2);
2640
- unit3 = compatibleFormulaUnits({ value: value4.value, unit: unit3 }, b);
2641
- const low = Math.min(a2.value, b.value), high = Math.max(a2.value, b.value);
2642
- if (value4.value >= low && value4.value <= high) return finiteFormulaValue({ value: value4.value, unit: unit3 });
2643
- const edge2 = value4.value < low ? low : high;
2644
- if (nearest === void 0 || Math.abs(edge2 - value4.value) < Math.abs(nearest - value4.value))
2645
- nearest = edge2;
2646
- }
2647
- return finiteFormulaValue({ value: nearest ?? value4.value, unit: unit3 });
2648
- }
2844
+ if (name3 === "BOUND") return evaluateBound(node3.args, arg);
2649
2845
  if (name3 === "ATAN2") {
2650
2846
  arity(2);
2651
2847
  const y = arg(0), x = arg(1);
@@ -2795,14 +2991,18 @@ function parseVisioFormula(source, limits = {}) {
2795
2991
  offset += identifier[0].length;
2796
2992
  whitespace();
2797
2993
  if (source[offset] === "(") {
2798
- if (!/^[A-Za-z_][A-Za-z_0-9]*$/.test(identifier[0]))
2994
+ const qualified = /^Sheet\.(\d+)!([A-Za-z_][A-Za-z_0-9]*)$/i.exec(identifier[0]);
2995
+ if (!qualified && !/^[A-Za-z_][A-Za-z_0-9]*$/.test(identifier[0]))
2799
2996
  return formulaFailure("syntax", "Qualified function names are unsupported");
2800
2997
  offset++;
2801
2998
  const args = [];
2802
2999
  whitespace();
2803
3000
  if (source[offset] !== ")") {
2804
3001
  for (; ; ) {
2805
- args.push(expression(0, depth + 1));
3002
+ whitespace();
3003
+ args.push(
3004
+ /^[,)]/.test(source.slice(offset)) ? node3({ kind: "string", value: "" }) : expression(0, depth + 1)
3005
+ );
2806
3006
  whitespace();
2807
3007
  if (source[offset] !== ",") break;
2808
3008
  offset++;
@@ -2810,7 +3010,27 @@ function parseVisioFormula(source, limits = {}) {
2810
3010
  }
2811
3011
  if (source[offset++] !== ")")
2812
3012
  return formulaFailure("syntax", "Expected function closing parenthesis");
2813
- left = node3({ kind: "call", name: identifier[0].toUpperCase(), args });
3013
+ left = node3({
3014
+ kind: "call",
3015
+ name: (qualified ? qualified[2] : identifier[0]).toUpperCase(),
3016
+ args
3017
+ });
3018
+ if (qualified)
3019
+ left = node3({
3020
+ kind: "call",
3021
+ name: "_SHEETCALL",
3022
+ args: [node3({ kind: "string", value: qualified[1] }), left]
3023
+ });
3024
+ whitespace();
3025
+ const member = source[offset] === "!" && /^!([A-Za-z_][A-Za-z_0-9.]*)/.exec(source.slice(offset));
3026
+ if (member) {
3027
+ offset += member[0].length;
3028
+ left = node3({
3029
+ kind: "call",
3030
+ name: "_SHEETCELL",
3031
+ args: [left, node3({ kind: "string", value: member[1] })]
3032
+ });
3033
+ }
2814
3034
  } else {
2815
3035
  const ref = /^Sheet\.(\d+)!(.+)$/i.exec(identifier[0]);
2816
3036
  left = node3({
@@ -4397,20 +4617,36 @@ function indexCells(roots, options2) {
4397
4617
  if (executableCellFormula(source) && !independentTextFieldFormula(node3, source) && !inertDoubleClickFormula(cell, source) && !(glue2 && isNativeGlueCell(cell, source)) && // A trigger only counts events of the sheet it names; an unglued connector keeps one
4398
4618
  // (Visio's freshly dropped connector names its own sheet).
4399
4619
  !(/^(BegTrigger|EndTrigger)$/.test(cell) && isNativeGlueCell(cell, source))) {
4620
+ const lenient = options2.scope === "affected";
4621
+ const unprovable = (message, opaque) => {
4622
+ if (!lenient) fail("EDIT_UNKNOWN_DEPENDENCY", message);
4623
+ item2.unsafe = true;
4624
+ item2.refusal = message;
4625
+ if (opaque) item2.opaque = true;
4626
+ };
4400
4627
  try {
4401
4628
  item2.formula = parseVisioFormula(source);
4402
- const plain4 = analyzeVisioFormula(item2.formula);
4629
+ const plain4 = analyzeVisioFormula(item2.formula, {
4630
+ shapeTextReads: true,
4631
+ literalIndirect: true
4632
+ });
4403
4633
  const analysis = plain4.dynamic && textSizeFormula(item2.formula) || plain4;
4404
- if (analysis.dynamic)
4405
- fail(
4406
- "EDIT_DYNAMIC_DEPENDENCY",
4407
- "Dynamic ShapeSheet dependencies cannot be safely edited."
4634
+ if (analysis.dynamic) {
4635
+ if (!lenient)
4636
+ fail(
4637
+ "EDIT_DYNAMIC_DEPENDENCY",
4638
+ "Dynamic ShapeSheet dependencies cannot be safely edited."
4639
+ );
4640
+ unprovable(
4641
+ `${cell} on shape ${sheet.shapeId || "page"} has dynamic ShapeSheet dependencies that cannot be followed.`,
4642
+ "opaque" in analysis && analysis.opaque
4408
4643
  );
4644
+ }
4409
4645
  item2.dependencies = analysis.references.filter((ref) => !isBooleanLiteral(ref)).map((ref) => key({ pageId: pageId2, shapeId: ref.shapeId ?? sheet.shapeId, cell: ref.cell }));
4410
4646
  } catch (error) {
4411
- fail(
4412
- "EDIT_UNKNOWN_DEPENDENCY",
4413
- `Cannot prove ShapeSheet dependency closure: ${error instanceof Error ? error.message : "invalid formula"}`
4647
+ unprovable(
4648
+ `Cannot prove ShapeSheet dependency closure: ${error instanceof Error ? error.message : "invalid formula"}`,
4649
+ true
4414
4650
  );
4415
4651
  }
4416
4652
  }
@@ -4493,13 +4729,20 @@ function createVisioCellEvaluator(cells4, options2 = {}, verifyCaches = false) {
4493
4729
  if (!item2 || item2.unsafe && (!item2.node || !options2.masterMovePins?.has(item2.node) && !options2.groupRotationCells?.has(item2.node)))
4494
4730
  fail(
4495
4731
  "EDIT_UNSUPPORTED_DEPENDENCY",
4496
- "Affected formula references missing, inherited or grouped cells."
4732
+ item2?.refusal ? `Affected formula cannot be evaluated: ${item2.refusal}` : "Affected formula references missing, inherited or grouped cells."
4497
4733
  );
4498
4734
  if (item2.node?.hasAttribute("E"))
4499
4735
  fail("EDIT_FORMULA_ERROR", "Affected ShapeSheet cell has an error cache.");
4500
4736
  active.add(id3);
4737
+ try {
4738
+ return evaluateCell(id3, item2);
4739
+ } finally {
4740
+ active.delete(id3);
4741
+ }
4742
+ };
4743
+ const evaluateCell = (id3, item2) => {
4501
4744
  let result2;
4502
- const analysis = item2.formula ? analyzeVisioFormula(item2.formula) : void 0;
4745
+ const analysis = item2.formula ? analyzeVisioFormula(item2.formula, { literalIndirect: true }) : void 0;
4503
4746
  if (item2.formula && item2.node && analysis.unsupportedFunctions.length) {
4504
4747
  if (!textSizeFormula(item2.formula))
4505
4748
  fail("EDIT_UNSUPPORTED_FORMULA", "Affected formula uses unsupported functions.");
@@ -4515,6 +4758,9 @@ function createVisioCellEvaluator(cells4, options2 = {}, verifyCaches = false) {
4515
4758
  ),
4516
4759
  {
4517
4760
  ...options2.pageContext?.get(item2.pageId),
4761
+ ...options2.textOf ? {
4762
+ textOf: (ref) => options2.textOf(item2.pageId, ref.shapeId ?? item2.shapeId)
4763
+ } : {},
4518
4764
  onStep: () => {
4519
4765
  if (--steps < 0)
4520
4766
  fail("LIMIT_FORMULA_STEPS", "ShapeSheet dependency evaluation limit exceeded.");
@@ -4538,16 +4784,63 @@ function createVisioCellEvaluator(cells4, options2 = {}, verifyCaches = false) {
4538
4784
  if (Math.abs(cachedValue2.value - result2.value) > 1e-10 * Math.max(1, Math.abs(result2.value)))
4539
4785
  fail("EDIT_FORMULA_CACHE", "Source formula and numeric cache disagree.");
4540
4786
  }
4541
- active.delete(id3);
4542
4787
  values.set(id3, result2);
4543
4788
  return result2;
4544
4789
  };
4545
4790
  return evaluate;
4546
4791
  }
4547
4792
 
4793
+ // visio/edit-recalculate-text.ts
4794
+ function plainShapeText(root2, shapeId2) {
4795
+ if (!root2) return void 0;
4796
+ const pending2 = children2(children2(root2, "Shapes")[0], "Shape");
4797
+ while (pending2.length) {
4798
+ const shape = pending2.pop();
4799
+ if (attribute2(shape, "ID") === shapeId2) {
4800
+ if (shape.hasAttribute("Master") || shape.hasAttribute("MasterShape")) return void 0;
4801
+ if (children2(shape, "Section").some((section3) => attribute2(section3, "N") === "Field"))
4802
+ return void 0;
4803
+ const texts = children2(shape, "Text");
4804
+ if (texts.length > 1) return void 0;
4805
+ const node3 = texts[0];
4806
+ if (!node3) return "";
4807
+ const plain4 = Array.from(node3.childNodes).every(
4808
+ (item2) => item2.nodeType === 3 || item2.nodeType === 4
4809
+ );
4810
+ return plain4 ? decodeVisioPlainText(node3.textContent ?? "") : void 0;
4811
+ }
4812
+ pending2.push(...children2(children2(shape, "Shapes")[0], "Shape"));
4813
+ }
4814
+ return void 0;
4815
+ }
4816
+ var TEXT_READERS = /* @__PURE__ */ new Set([...textNumberFunctions, ...textResultFunctions]);
4817
+ function textReadFormula(source) {
4818
+ try {
4819
+ const ast = parseVisioFormula(source);
4820
+ const analysis = analyzeVisioFormula(ast, { shapeTextReads: true });
4821
+ if (analysis.dynamic || analysis.unsupportedFunctions.length) return false;
4822
+ const textResult = ast.kind === "string" || isTheText(ast) || ast.kind === "binary" && ast.operator === "&" || ast.kind === "call" && textResultFunctions.has(ast.name);
4823
+ if (textResult) return false;
4824
+ let reads = 0;
4825
+ const walk = (node3, parent) => {
4826
+ if (isTheText(node3)) {
4827
+ reads++;
4828
+ return parent?.kind === "call" && TEXT_READERS.has(parent.name);
4829
+ }
4830
+ if (node3.kind === "unary") return walk(node3.operand, node3);
4831
+ if (node3.kind === "binary") return walk(node3.left, node3) && walk(node3.right, node3);
4832
+ if (node3.kind === "call") return node3.args.every((arg) => walk(arg, node3));
4833
+ return true;
4834
+ };
4835
+ return walk(ast) && reads > 0;
4836
+ } catch {
4837
+ return false;
4838
+ }
4839
+ }
4840
+
4548
4841
  // visio/edit-recalculate.ts
4549
4842
  function recalculateVisioCells(roots, changed, options2 = {}) {
4550
- const cells4 = indexCells(roots, options2);
4843
+ const cells4 = indexCells(roots, { scope: "affected", ...options2 });
4551
4844
  const reverse = /* @__PURE__ */ new Map();
4552
4845
  for (const [id3, item2] of cells4)
4553
4846
  for (const dependency of item2.dependencies) {
@@ -4556,6 +4849,8 @@ function recalculateVisioCells(roots, changed, options2 = {}) {
4556
4849
  reverse.set(dependency, next);
4557
4850
  }
4558
4851
  const affected = new Set(changed.map(key));
4852
+ const editedPages = new Set(changed.map((cell) => cell.pageId));
4853
+ for (const [id3, item2] of cells4) if (item2.opaque && editedPages.has(item2.pageId)) affected.add(id3);
4559
4854
  const pending2 = [...affected];
4560
4855
  const maxAffected = bound(options2.maxAffectedCells, 1e4);
4561
4856
  for (let i = 0; i < pending2.length; i++) {
@@ -4568,13 +4863,29 @@ function recalculateVisioCells(roots, changed, options2 = {}) {
4568
4863
  if (affected.size > maxAffected)
4569
4864
  fail("LIMIT_FORMULA_AFFECTED", "Affected ShapeSheet cell limit exceeded.");
4570
4865
  }
4571
- const evaluate = createVisioCellEvaluator(cells4, options2);
4866
+ const evaluate = createVisioCellEvaluator(cells4, {
4867
+ textOf: (pageId2, shapeId2) => plainShapeText(roots.get(pageId2), shapeId2),
4868
+ ...options2
4869
+ });
4572
4870
  const values = /* @__PURE__ */ new Map();
4573
- for (const id3 of affected) values.set(id3, evaluate(id3));
4871
+ for (const id3 of affected) {
4872
+ if (!cells4.has(id3) && /,"thetext"]$/.test(id3)) continue;
4873
+ try {
4874
+ values.set(id3, evaluate(id3));
4875
+ } catch (error) {
4876
+ if (options2.cycles !== "keep" || !(error instanceof VisioPackageError) || error.code !== "EDIT_FORMULA_CYCLE")
4877
+ throw error;
4878
+ const cyclic = cells4.get(id3);
4879
+ options2.diagnostics?.push({
4880
+ code: "FORMULA_CYCLE",
4881
+ message: `Kept the cached value of ${cyclic.cell} on shape ${cyclic.shapeId || "page"} (page ${cyclic.pageId}): it is part of, or depends on, a dependency cycle.`
4882
+ });
4883
+ }
4884
+ }
4574
4885
  const pages = /* @__PURE__ */ new Set();
4575
4886
  for (const id3 of affected) {
4576
4887
  const item2 = cells4.get(id3);
4577
- if (item2.node && item2.formula) {
4888
+ if (item2?.node && item2.formula && values.has(id3)) {
4578
4889
  const value3 = String(values.get(id3).value);
4579
4890
  if (item2.node.getAttribute("V") !== value3) {
4580
4891
  item2.node.setAttribute("V", value3);
@@ -4585,15 +4896,29 @@ function recalculateVisioCells(roots, changed, options2 = {}) {
4585
4896
  return [...pages];
4586
4897
  }
4587
4898
  function assertVisioShapesUnreferenced(roots, removed, options2 = {}) {
4588
- const cells4 = indexCells(roots, options2);
4899
+ const cells4 = indexCells(roots, { scope: "affected", ...options2 });
4900
+ const frozen = [];
4589
4901
  for (const cell of cells4.values()) {
4590
4902
  options2.check?.();
4903
+ if (cell.opaque && removed.has(cell.pageId) && !removed.get(cell.pageId).has(cell.shapeId))
4904
+ fail(
4905
+ "EDIT_REFERENCED_DELETE",
4906
+ `${cell.cell} on shape ${cell.shapeId || "page"} may read the removed shape through a dynamic dependency.`
4907
+ );
4591
4908
  if (removed.get(cell.pageId)?.has(cell.shapeId)) continue;
4592
4909
  if (cell.dependencies.some((id3) => {
4593
4910
  const parts = JSON.parse(id3);
4594
4911
  return removed.get(parts[0])?.has(parts[1]) ?? false;
4595
- }))
4596
- fail("EDIT_REFERENCED_DELETE", "Shape is referenced by a ShapeSheet formula.");
4912
+ })) {
4913
+ if (!options2.freeze || !cell.node || !cell.formula || cell.unsafe || cell.node.hasAttribute("E") || analyzeVisioFormula(cell.formula, { literalIndirect: true }).guarded || !Number.isFinite(
4914
+ visioFormulaCachedValue(
4915
+ cell.node.getAttribute("V") ?? "",
4916
+ cell.node.getAttribute("U") ?? void 0
4917
+ ).value
4918
+ ))
4919
+ fail("EDIT_REFERENCED_DELETE", "Shape is referenced by a ShapeSheet formula.");
4920
+ frozen.push(cell.node);
4921
+ }
4597
4922
  }
4598
4923
  for (const [pageId2, ids] of removed)
4599
4924
  for (const connections2 of children2(roots.get(pageId2), "Connects"))
@@ -4602,12 +4927,16 @@ function assertVisioShapesUnreferenced(roots, removed, options2 = {}) {
4602
4927
  if (["FromSheet", "ToSheet"].some((name3) => ids.has(attribute2(connection, name3) ?? "")))
4603
4928
  fail("EDIT_REFERENCED_DELETE", "Shape participates in a Connect record.");
4604
4929
  }
4930
+ return frozen;
4605
4931
  }
4932
+ var freezeVisioCells = (nodes) => {
4933
+ for (const node3 of nodes) node3.removeAttribute("F");
4934
+ };
4606
4935
  function assertVisioShapeUnreferenced(roots, pageId2, shapeId2, options2 = {}) {
4607
- assertVisioShapesUnreferenced(roots, /* @__PURE__ */ new Map([[pageId2, /* @__PURE__ */ new Set([shapeId2])]]), options2);
4936
+ return assertVisioShapesUnreferenced(roots, /* @__PURE__ */ new Map([[pageId2, /* @__PURE__ */ new Set([shapeId2])]]), options2);
4608
4937
  }
4609
4938
  function createVisioDependencyQuery(roots, options2 = {}) {
4610
- const cells4 = indexCells(roots, options2);
4939
+ const cells4 = indexCells(roots, { scope: "affected", ...options2 });
4611
4940
  return (source, targets) => {
4612
4941
  const wanted = new Set(targets.map(key));
4613
4942
  const seen = /* @__PURE__ */ new Set();
@@ -4622,7 +4951,7 @@ function createVisioDependencyQuery(roots, options2 = {}) {
4622
4951
  if (seen.size > maxSteps) fail("LIMIT_FORMULA_STEPS", "Dependency analysis limit exceeded.");
4623
4952
  const item2 = cells4.get(id3);
4624
4953
  if (!item2 || item2.unsafe || item2.node?.hasAttribute("E")) return false;
4625
- if (item2.formula && analyzeVisioFormula(item2.formula).unsupportedFunctions.length)
4954
+ if (item2.formula && analyzeVisioFormula(item2.formula, { literalIndirect: true }).unsupportedFunctions.length)
4626
4955
  return false;
4627
4956
  if (wanted.has(id3)) found = true;
4628
4957
  else pending2.push(...item2.dependencies);
@@ -11950,10 +12279,10 @@ async function* streamEntryGuarded(entry3, alreadyRead, limits) {
11950
12279
  }
11951
12280
  }
11952
12281
  function toBase64(bytes) {
11953
- let binary2 = "";
12282
+ let binary = "";
11954
12283
  for (let i = 0; i < bytes.length; i += 32768)
11955
- binary2 += String.fromCharCode(...bytes.subarray(i, i + 32768));
11956
- return btoa(binary2);
12284
+ binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
12285
+ return btoa(binary);
11957
12286
  }
11958
12287
  function guardZip(zip, limits = {}) {
11959
12288
  const r = resolveLimits(limits);
@@ -14397,6 +14726,332 @@ function parseStyles(xml, warnings) {
14397
14726
  return result2;
14398
14727
  }
14399
14728
 
14729
+ // xlsx/read/print-options.ts
14730
+ var KEYS = ["gridLines", "headings", "horizontalCentered", "verticalCentered"];
14731
+ function readPrintOptions(node3) {
14732
+ if (!node3) return void 0;
14733
+ const out = {};
14734
+ for (const key2 of KEYS) if (boolAttr(node3, key2)) out[key2] = true;
14735
+ return Object.keys(out).length ? out : void 0;
14736
+ }
14737
+
14738
+ // xlsx/read/password-hash.ts
14739
+ function modernHashAttributeNames(prefix2 = "") {
14740
+ const name3 = (base2) => prefix2 ? `${prefix2}${base2[0].toUpperCase()}${base2.slice(1)}` : base2;
14741
+ return {
14742
+ algorithmName: name3("algorithmName"),
14743
+ hashValue: name3("hashValue"),
14744
+ saltValue: name3("saltValue"),
14745
+ spinCount: name3("spinCount")
14746
+ };
14747
+ }
14748
+ function readModernHash(node3, prefix2 = "") {
14749
+ const names = modernHashAttributeNames(prefix2);
14750
+ const algorithmName = att(node3, names.algorithmName);
14751
+ const hashValue = att(node3, names.hashValue);
14752
+ const saltValue = att(node3, names.saltValue);
14753
+ if (!algorithmName || !hashValue || !saltValue) return void 0;
14754
+ const hash2 = { algorithmName, hashValue, saltValue };
14755
+ const spin = att(node3, names.spinCount);
14756
+ const spinCount = spin === void 0 || spin.trim() === "" ? Number.NaN : Number(spin);
14757
+ if (Number.isFinite(spinCount)) hash2.spinCount = spinCount;
14758
+ return hash2;
14759
+ }
14760
+
14761
+ // xlsx/read/sheet-props.ts
14762
+ var defaultSheetView = () => ({
14763
+ showGridLines: true,
14764
+ showHeaders: true,
14765
+ showZeros: true,
14766
+ rightToLeft: false,
14767
+ zoom: 100
14768
+ });
14769
+ function parseSqref(sqref) {
14770
+ if (!sqref) return [];
14771
+ return sqref.split(/\s+/).filter(Boolean).map((part) => parseRange(part)).filter((range2) => range2 !== void 0);
14772
+ }
14773
+ var readTabColor = (sheetPr, palette) => parseColor(xFirst(sheetPr, "tabColor"), palette);
14774
+ var readFitToPage = (sheetPr) => boolAttr(xFirst(sheetPr, "pageSetUpPr"), "fitToPage") ?? false;
14775
+ function readSheetView(sheetViews) {
14776
+ const view2 = defaultSheetView();
14777
+ const node3 = xFirst(sheetViews, "sheetView");
14778
+ if (!node3) return view2;
14779
+ view2.showGridLines = boolAttr(node3, "showGridLines", true);
14780
+ view2.showHeaders = boolAttr(node3, "showRowColHeaders", true);
14781
+ view2.showZeros = boolAttr(node3, "showZeros", true);
14782
+ view2.rightToLeft = boolAttr(node3, "rightToLeft", false);
14783
+ view2.zoom = numAttr(node3, "zoomScale") || 100;
14784
+ if (boolAttr(node3, "showFormulas")) view2.showFormulas = true;
14785
+ const mode = att(node3, "view");
14786
+ if (mode === "pageLayout" || mode === "pageBreakPreview") view2.mode = mode;
14787
+ const pane = xFirst(node3, "pane");
14788
+ const state = att(pane, "state");
14789
+ const frozen = pane && (state === "frozen" || state === "frozenSplit");
14790
+ if (frozen) {
14791
+ const rows = Math.max(0, Math.round(numAttr(pane, "ySplit") ?? 0));
14792
+ const cols = Math.max(0, Math.round(numAttr(pane, "xSplit") ?? 0));
14793
+ if (rows || cols) view2.freeze = { rows, cols };
14794
+ }
14795
+ const topLeft = parseAddress(
14796
+ (frozen ? att(pane, "topLeftCell") : att(node3, "topLeftCell")) ?? ""
14797
+ );
14798
+ if (topLeft) view2.topLeft = topLeft;
14799
+ const selections = xChildren(node3, "selection");
14800
+ const activePane = att(pane, "activePane") ?? "topLeft";
14801
+ const selection = selections.find((sel) => (att(sel, "pane") ?? "topLeft") === activePane) ?? selections[0];
14802
+ if (selection) {
14803
+ const ranges = parseSqref(att(selection, "sqref") ?? att(selection, "activeCell") ?? "A1");
14804
+ const active = parseAddress(att(selection, "activeCell") ?? "") ?? ranges[0]?.start ?? { row: 0, col: 0 };
14805
+ view2.selection = {
14806
+ active,
14807
+ ranges: ranges.length ? ranges : [{ start: active, end: { ...active } }]
14808
+ };
14809
+ }
14810
+ return view2;
14811
+ }
14812
+ var FORMAT_FLAGS = ["zeroHeight", "customHeight", "thickTop", "thickBottom"];
14813
+ function readSheetFormat(format5) {
14814
+ const result2 = {
14815
+ defaultRowHeight: numAttr(format5, "defaultRowHeight") ?? 15
14816
+ };
14817
+ const width = numAttr(format5, "defaultColWidth");
14818
+ if (width !== void 0) result2.defaultColWidth = width;
14819
+ const flags = {};
14820
+ for (const key2 of FORMAT_FLAGS) {
14821
+ const value3 = boolAttr(format5, key2);
14822
+ if (value3 !== void 0) flags[key2] = value3;
14823
+ }
14824
+ const base2 = numAttr(format5, "baseColWidth");
14825
+ if (base2 !== void 0) flags.baseColWidth = base2;
14826
+ if (Object.keys(flags).length) result2.format = flags;
14827
+ return result2;
14828
+ }
14829
+ function readColumns(cols, xfMap) {
14830
+ const out = [];
14831
+ for (const col of cols ? xChildren(cols, "col") : []) {
14832
+ const min = (numAttr(col, "min") ?? 1) - 1;
14833
+ const max = (numAttr(col, "max") ?? min + 1) - 1;
14834
+ const info = { min, max };
14835
+ const width = numAttr(col, "width");
14836
+ if (width !== void 0) info.width = width;
14837
+ if (boolAttr(col, "customWidth")) info.customWidth = true;
14838
+ if (boolAttr(col, "hidden")) info.hidden = true;
14839
+ const style2 = numAttr(col, "style");
14840
+ const styleId = style2 === void 0 ? 0 : xfMap[style2] ?? 0;
14841
+ if (styleId) info.styleId = styleId;
14842
+ const outline = numAttr(col, "outlineLevel");
14843
+ if (outline) info.outlineLevel = outline;
14844
+ if (boolAttr(col, "collapsed")) info.collapsed = true;
14845
+ if (boolAttr(col, "bestFit")) info.bestFit = true;
14846
+ out.push(info);
14847
+ }
14848
+ return out;
14849
+ }
14850
+ var MAIN_NS_DECL = /(?<=^<[^>]*) xmlns="http:\/\/schemas\.openxmlformats\.org\/spreadsheetml\/2006\/main"/;
14851
+ function readAutoFilter(node3) {
14852
+ const range2 = parseRange(att(node3, "ref") ?? "");
14853
+ if (!node3 || !range2) return void 0;
14854
+ const filter = { range: range2 };
14855
+ const columns = [];
14856
+ for (const column of xChildren(node3, "filterColumn")) {
14857
+ const entry3 = {
14858
+ offset: numAttr(column, "colId") ?? 0
14859
+ };
14860
+ const filters = xFirst(column, "filters");
14861
+ if (filters) {
14862
+ entry3.values = xChildren(filters, "filter").map((f) => att(f, "val") ?? "");
14863
+ if (boolAttr(filters, "blank")) entry3.blank = true;
14864
+ }
14865
+ entry3.sourceXml = outerXml(column).replace(MAIN_NS_DECL, "");
14866
+ columns.push(entry3);
14867
+ }
14868
+ if (columns.length) filter.columns = columns;
14869
+ return filter;
14870
+ }
14871
+ var HEADER_FOOTER_TEXT = {
14872
+ header: "oddHeader",
14873
+ footer: "oddFooter",
14874
+ evenHeader: "evenHeader",
14875
+ evenFooter: "evenFooter",
14876
+ firstHeader: "firstHeader",
14877
+ firstFooter: "firstFooter"
14878
+ };
14879
+ var HEADER_FOOTER_FLAGS = [
14880
+ "differentOddEven",
14881
+ "differentFirst",
14882
+ "scaleWithDoc",
14883
+ "alignWithMargins"
14884
+ ];
14885
+ function readHeaderFooter(node3) {
14886
+ const out = {};
14887
+ for (const key2 of HEADER_FOOTER_FLAGS) {
14888
+ const value3 = boolAttr(node3, key2);
14889
+ if (value3 !== void 0) out[key2] = value3;
14890
+ }
14891
+ for (const [key2, local] of Object.entries(HEADER_FOOTER_TEXT)) {
14892
+ const child4 = xFirst(node3, local);
14893
+ if (child4) out[key2] = xText(child4);
14894
+ }
14895
+ return out;
14896
+ }
14897
+ var ORIENTATIONS = /* @__PURE__ */ new Set(["portrait", "landscape"]);
14898
+ function readPageSetup(margins, setup, headerFooter, fitToPage) {
14899
+ const page = {};
14900
+ if (setup) {
14901
+ if (/^(1|true)$/.test(att(setup, "useFirstPageNumber") ?? "")) {
14902
+ page.firstPageNumber = numAttr(setup, "firstPageNumber") ?? 1;
14903
+ }
14904
+ const order = att(setup, "pageOrder");
14905
+ if (order === "downThenOver" || order === "overThenDown") page.pageOrder = order;
14906
+ const orientation = att(setup, "orientation");
14907
+ if (orientation && ORIENTATIONS.has(orientation))
14908
+ page.orientation = orientation;
14909
+ const paper = numAttr(setup, "paperSize");
14910
+ if (paper !== void 0) page.paperSize = paper;
14911
+ const scale = numAttr(setup, "scale");
14912
+ if (scale !== void 0) page.scale = scale;
14913
+ }
14914
+ if (fitToPage) {
14915
+ page.fitToWidth = numAttr(setup, "fitToWidth") ?? 1;
14916
+ page.fitToHeight = numAttr(setup, "fitToHeight") ?? 1;
14917
+ }
14918
+ if (margins) {
14919
+ const m = (name3, fallback) => numAttr(margins, name3) ?? fallback;
14920
+ page.margins = {
14921
+ left: m("left", 0.7),
14922
+ right: m("right", 0.7),
14923
+ top: m("top", 0.75),
14924
+ bottom: m("bottom", 0.75),
14925
+ header: m("header", 0.3),
14926
+ footer: m("footer", 0.3)
14927
+ };
14928
+ }
14929
+ if (headerFooter) Object.assign(page, readHeaderFooter(headerFooter));
14930
+ return Object.keys(page).length ? page : void 0;
14931
+ }
14932
+ var PROTECTION_META = /* @__PURE__ */ new Set([
14933
+ "sheet",
14934
+ "password",
14935
+ "algorithmName",
14936
+ "hashValue",
14937
+ "saltValue",
14938
+ "spinCount"
14939
+ ]);
14940
+ function readProtection(node3) {
14941
+ if (!node3) return void 0;
14942
+ const protection2 = { sheet: boolAttr(node3, "sheet", false) };
14943
+ const password = att(node3, "password");
14944
+ if (password) protection2.passwordHash = password;
14945
+ const modernHash = readModernHash(node3);
14946
+ if (modernHash) protection2.modernHash = modernHash;
14947
+ const allow = [];
14948
+ for (const attribute4 of Array.from(node3.attributes)) {
14949
+ if (PROTECTION_META.has(attribute4.name)) continue;
14950
+ if (attribute4.value === "0" || attribute4.value === "false") allow.push(attribute4.name);
14951
+ }
14952
+ if (allow.length) protection2.allow = allow.sort();
14953
+ return protection2;
14954
+ }
14955
+
14956
+ // xlsx/read/custom-views.ts
14957
+ var SHEET_VIEW_ATTRS = [
14958
+ "guid",
14959
+ "scale",
14960
+ "showGridLines",
14961
+ "showRowCol",
14962
+ "zeroValues",
14963
+ "topLeftCell",
14964
+ "view",
14965
+ "showFormulas",
14966
+ "hiddenRows",
14967
+ "hiddenColumns",
14968
+ "filter",
14969
+ "showAutoFilter",
14970
+ "fitToPage"
14971
+ ];
14972
+ var WORKBOOK_VIEW_KNOWN = ["name", "guid", "includePrintSettings", "includeHiddenRowCol"];
14973
+ function readCustomWorkbookViews(node3) {
14974
+ return xChildren(node3, "customWorkbookView").flatMap((view2) => {
14975
+ const guid3 = att(view2, "guid");
14976
+ if (!guid3) return [];
14977
+ const attrs = {};
14978
+ for (const attribute4 of Array.from(view2.attributes))
14979
+ if (!WORKBOOK_VIEW_KNOWN.includes(attribute4.name) && !attribute4.name.startsWith("xmlns"))
14980
+ attrs[attribute4.name] = attribute4.value;
14981
+ return [
14982
+ {
14983
+ guid: guid3,
14984
+ name: att(view2, "name") ?? "",
14985
+ includePrintSettings: boolAttr(view2, "includePrintSettings", true),
14986
+ includeHiddenRowCol: boolAttr(view2, "includeHiddenRowCol", true),
14987
+ attrs
14988
+ }
14989
+ ];
14990
+ });
14991
+ }
14992
+ var escape2 = (value3) => value3.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
14993
+ function asSheetViews(view2) {
14994
+ const map = [
14995
+ ["scale", "zoomScale"],
14996
+ ["showGridLines", "showGridLines"],
14997
+ ["showRowCol", "showRowColHeaders"],
14998
+ ["zeroValues", "showZeros"],
14999
+ ["topLeftCell", "topLeftCell"],
15000
+ ["view", "view"],
15001
+ ["showFormulas", "showFormulas"]
15002
+ ];
15003
+ const attributes = map.flatMap(([from, to]) => {
15004
+ const value3 = att(view2, from);
15005
+ return value3 === void 0 ? [] : [` ${to}="${escape2(value3)}"`];
15006
+ }).join("");
15007
+ const children5 = elements(view2).filter((child4) => child4.localName === "pane" || child4.localName === "selection").map((child4) => outerXml(child4)).join("");
15008
+ return parseXml(
15009
+ `<sheetViews xmlns="${NS.x}"><sheetView${attributes}>${children5}</sheetView></sheetViews>`
15010
+ ).documentElement;
15011
+ }
15012
+ function readCustomSheetViews(node3) {
15013
+ return xChildren(node3, "customSheetView").flatMap((view2) => {
15014
+ const guid3 = att(view2, "guid");
15015
+ if (!guid3) return [];
15016
+ const child4 = (name3) => xChildren(view2, name3)[0];
15017
+ const pageSetup = readPageSetup(
15018
+ child4("pageMargins"),
15019
+ child4("pageSetup"),
15020
+ child4("headerFooter"),
15021
+ boolAttr(view2, "fitToPage", false)
15022
+ );
15023
+ const printOptions = readPrintOptions(child4("printOptions"));
15024
+ const filter = readAutoFilter(child4("autoFilter"));
15025
+ const attrs = {};
15026
+ for (const attribute4 of Array.from(view2.attributes))
15027
+ if (!SHEET_VIEW_ATTRS.includes(attribute4.name) && !attribute4.name.startsWith("xmlns"))
15028
+ attrs[attribute4.name] = attribute4.value;
15029
+ const modelled = [
15030
+ "pane",
15031
+ "selection",
15032
+ "pageMargins",
15033
+ "printOptions",
15034
+ "pageSetup",
15035
+ "headerFooter",
15036
+ "autoFilter"
15037
+ ];
15038
+ return [
15039
+ {
15040
+ guid: guid3,
15041
+ view: readSheetView(asSheetViews(view2)),
15042
+ ...boolAttr(view2, "hiddenRows", false) ? { hiddenRows: true } : {},
15043
+ ...boolAttr(view2, "hiddenColumns", false) ? { hiddenColumns: true } : {},
15044
+ ...filter ? { filter } : {},
15045
+ ...boolAttr(view2, "showAutoFilter", false) ? { showAutoFilter: true } : {},
15046
+ ...pageSetup ? { pageSetup } : {},
15047
+ ...printOptions ? { printOptions } : {},
15048
+ attrs,
15049
+ extra: elements(view2).filter((c2) => !modelled.includes(c2.localName ?? "")).map((c2) => outerXml(c2))
15050
+ }
15051
+ ];
15052
+ });
15053
+ }
15054
+
14400
15055
  // xlsx/read/formula-storage.ts
14401
15056
  function tokens(formula2) {
14402
15057
  try {
@@ -14494,30 +15149,20 @@ function stripFuturePrefixes(formula2) {
14494
15149
  return fromStoredSyntax(plain4);
14495
15150
  }
14496
15151
 
14497
- // xlsx/read/password-hash.ts
14498
- function modernHashAttributeNames(prefix2 = "") {
14499
- const name3 = (base2) => prefix2 ? `${prefix2}${base2[0].toUpperCase()}${base2.slice(1)}` : base2;
14500
- return {
14501
- algorithmName: name3("algorithmName"),
14502
- hashValue: name3("hashValue"),
14503
- saltValue: name3("saltValue"),
14504
- spinCount: name3("spinCount")
14505
- };
14506
- }
14507
- function readModernHash(node3, prefix2 = "") {
14508
- const names = modernHashAttributeNames(prefix2);
14509
- const algorithmName = att(node3, names.algorithmName);
14510
- const hashValue = att(node3, names.hashValue);
14511
- const saltValue = att(node3, names.saltValue);
14512
- if (!algorithmName || !hashValue || !saltValue) return void 0;
14513
- const hash2 = { algorithmName, hashValue, saltValue };
14514
- const spin = att(node3, names.spinCount);
14515
- const spinCount = spin === void 0 || spin.trim() === "" ? Number.NaN : Number(spin);
14516
- if (Number.isFinite(spinCount)) hash2.spinCount = spinCount;
14517
- return hash2;
14518
- }
14519
-
14520
15152
  // xlsx/read/workbook-part.ts
15153
+ var NAME_EXTRA_ATTRIBUTES = [
15154
+ "function",
15155
+ "vbProcedure",
15156
+ "xlm",
15157
+ "customMenu",
15158
+ "description",
15159
+ "help",
15160
+ "statusBar",
15161
+ "shortcutKey",
15162
+ "functionGroupId",
15163
+ "publishToServer",
15164
+ "workbookParameter"
15165
+ ];
14521
15166
  function parseWorkbookPart(xml) {
14522
15167
  const root2 = parseXml(xml, { label: "XLSX workbook" }).documentElement;
14523
15168
  const sheets = [];
@@ -14541,6 +15186,12 @@ function parseWorkbookPart(xml) {
14541
15186
  if (boolAttr(node3, "hidden")) name3.hidden = true;
14542
15187
  const comment = att(node3, "comment");
14543
15188
  if (comment) name3.comment = comment;
15189
+ const extra = {};
15190
+ for (const key2 of NAME_EXTRA_ATTRIBUTES) {
15191
+ const value3 = att(node3, key2);
15192
+ if (value3 !== void 0) extra[key2] = value3;
15193
+ }
15194
+ if (Object.keys(extra).length) name3.extra = extra;
14544
15195
  if (name3.name) definedNames.push(name3);
14545
15196
  }
14546
15197
  const view2 = xFirst(xFirst(root2, "bookViews"), "workbookView");
@@ -14554,7 +15205,9 @@ function parseWorkbookPart(xml) {
14554
15205
  delta: numAttr(calcPr, "iterateDelta") ?? 1e-3
14555
15206
  } : void 0;
14556
15207
  const oleSize = att(xFirst(root2, "oleSize"), "ref");
15208
+ const customViews = xFirst(root2, "customWorkbookViews");
14557
15209
  return {
15210
+ ...customViews ? { customViews: readCustomWorkbookViews(customViews) } : {},
14558
15211
  ...oleSize ? { oleSize } : {},
14559
15212
  ...iterate ? { iterate } : {},
14560
15213
  ...password ? { workbookPasswordHash: password } : {},
@@ -14588,9 +15241,9 @@ function parseFormula(fmla) {
14588
15241
  return { op, args };
14589
15242
  }
14590
15243
  function resolveOperand(token, variables) {
14591
- const num = Number(token);
14592
- if (Number.isFinite(num)) {
14593
- return num;
15244
+ const num2 = Number(token);
15245
+ if (Number.isFinite(num2)) {
15246
+ return num2;
14594
15247
  }
14595
15248
  const value3 = variables.get(token);
14596
15249
  if (value3 !== void 0) {
@@ -16263,18 +16916,18 @@ function groupTransform(group2, parent) {
16263
16916
  const ext = first(xfrm, "ext", NS.a);
16264
16917
  const chOff = first(xfrm, "chOff", NS.a);
16265
16918
  const chExt = first(xfrm, "chExt", NS.a);
16266
- const num = (element2, name3) => Number.parseInt(element2?.getAttribute(name3) ?? "", 10);
16267
- const cx = num(ext, "cx");
16268
- const cy = num(ext, "cy");
16269
- const chCx = num(chExt, "cx");
16270
- const chCy = num(chExt, "cy");
16919
+ const num2 = (element2, name3) => Number.parseInt(element2?.getAttribute(name3) ?? "", 10);
16920
+ const cx = num2(ext, "cx");
16921
+ const cy = num2(ext, "cy");
16922
+ const chCx = num2(chExt, "cx");
16923
+ const chCy = num2(chExt, "cy");
16271
16924
  if (!off || ![cx, cy, chCx, chCy].every(Number.isFinite) || chCx === 0 || chCy === 0)
16272
16925
  return parent;
16273
16926
  const scaleX = cx / chCx;
16274
16927
  const scaleY = cy / chCy;
16275
16928
  const local = {
16276
- offsetX: num(off, "x") - (num(chOff, "x") || 0) * scaleX,
16277
- offsetY: num(off, "y") - (num(chOff, "y") || 0) * scaleY,
16929
+ offsetX: num2(off, "x") - (num2(chOff, "x") || 0) * scaleX,
16930
+ offsetY: num2(off, "y") - (num2(chOff, "y") || 0) * scaleY,
16278
16931
  scaleX,
16279
16932
  scaleY
16280
16933
  };
@@ -16582,200 +17235,48 @@ async function resolveSmartArt(sheets, source, warn) {
16582
17235
  }
16583
17236
  }
16584
17237
 
16585
- // xlsx/read/sheet-props.ts
16586
- var defaultSheetView = () => ({
16587
- showGridLines: true,
16588
- showHeaders: true,
16589
- showZeros: true,
16590
- rightToLeft: false,
16591
- zoom: 100
16592
- });
16593
- function parseSqref(sqref) {
16594
- if (!sqref) return [];
16595
- return sqref.split(/\s+/).filter(Boolean).map((part) => parseRange(part)).filter((range2) => range2 !== void 0);
16596
- }
16597
- var readTabColor = (sheetPr, palette) => parseColor(xFirst(sheetPr, "tabColor"), palette);
16598
- var readFitToPage = (sheetPr) => boolAttr(xFirst(sheetPr, "pageSetUpPr"), "fitToPage") ?? false;
16599
- function readSheetView(sheetViews) {
16600
- const view2 = defaultSheetView();
16601
- const node3 = xFirst(sheetViews, "sheetView");
16602
- if (!node3) return view2;
16603
- view2.showGridLines = boolAttr(node3, "showGridLines", true);
16604
- view2.showHeaders = boolAttr(node3, "showRowColHeaders", true);
16605
- view2.showZeros = boolAttr(node3, "showZeros", true);
16606
- view2.rightToLeft = boolAttr(node3, "rightToLeft", false);
16607
- view2.zoom = numAttr(node3, "zoomScale") || 100;
16608
- if (boolAttr(node3, "showFormulas")) view2.showFormulas = true;
16609
- const mode = att(node3, "view");
16610
- if (mode === "pageLayout" || mode === "pageBreakPreview") view2.mode = mode;
16611
- const pane = xFirst(node3, "pane");
16612
- const state = att(pane, "state");
16613
- const frozen = pane && (state === "frozen" || state === "frozenSplit");
16614
- if (frozen) {
16615
- const rows = Math.max(0, Math.round(numAttr(pane, "ySplit") ?? 0));
16616
- const cols = Math.max(0, Math.round(numAttr(pane, "xSplit") ?? 0));
16617
- if (rows || cols) view2.freeze = { rows, cols };
16618
- }
16619
- const topLeft = parseAddress(
16620
- (frozen ? att(pane, "topLeftCell") : att(node3, "topLeftCell")) ?? ""
16621
- );
16622
- if (topLeft) view2.topLeft = topLeft;
16623
- const selections = xChildren(node3, "selection");
16624
- const activePane = att(pane, "activePane") ?? "topLeft";
16625
- const selection = selections.find((sel) => (att(sel, "pane") ?? "topLeft") === activePane) ?? selections[0];
16626
- if (selection) {
16627
- const ranges = parseSqref(att(selection, "sqref") ?? att(selection, "activeCell") ?? "A1");
16628
- const active = parseAddress(att(selection, "activeCell") ?? "") ?? ranges[0]?.start ?? { row: 0, col: 0 };
16629
- view2.selection = {
16630
- active,
16631
- ranges: ranges.length ? ranges : [{ start: active, end: { ...active } }]
16632
- };
16633
- }
16634
- return view2;
16635
- }
16636
- var FORMAT_FLAGS = ["zeroHeight", "customHeight", "thickTop", "thickBottom"];
16637
- function readSheetFormat(format5) {
16638
- const result2 = {
16639
- defaultRowHeight: numAttr(format5, "defaultRowHeight") ?? 15
16640
- };
16641
- const width = numAttr(format5, "defaultColWidth");
16642
- if (width !== void 0) result2.defaultColWidth = width;
16643
- const flags = {};
16644
- for (const key2 of FORMAT_FLAGS) {
16645
- const value3 = boolAttr(format5, key2);
16646
- if (value3 !== void 0) flags[key2] = value3;
16647
- }
16648
- const base2 = numAttr(format5, "baseColWidth");
16649
- if (base2 !== void 0) flags.baseColWidth = base2;
16650
- if (Object.keys(flags).length) result2.format = flags;
16651
- return result2;
16652
- }
16653
- function readColumns(cols, xfMap) {
16654
- const out = [];
16655
- for (const col of cols ? xChildren(cols, "col") : []) {
16656
- const min = (numAttr(col, "min") ?? 1) - 1;
16657
- const max = (numAttr(col, "max") ?? min + 1) - 1;
16658
- const info = { min, max };
16659
- const width = numAttr(col, "width");
16660
- if (width !== void 0) info.width = width;
16661
- if (boolAttr(col, "customWidth")) info.customWidth = true;
16662
- if (boolAttr(col, "hidden")) info.hidden = true;
16663
- const style2 = numAttr(col, "style");
16664
- const styleId = style2 === void 0 ? 0 : xfMap[style2] ?? 0;
16665
- if (styleId) info.styleId = styleId;
16666
- const outline = numAttr(col, "outlineLevel");
16667
- if (outline) info.outlineLevel = outline;
16668
- if (boolAttr(col, "collapsed")) info.collapsed = true;
16669
- if (boolAttr(col, "bestFit")) info.bestFit = true;
16670
- out.push(info);
16671
- }
16672
- return out;
16673
- }
16674
- var MAIN_NS_DECL = /(?<=^<[^>]*) xmlns="http:\/\/schemas\.openxmlformats\.org\/spreadsheetml\/2006\/main"/;
16675
- function readAutoFilter(node3) {
16676
- const range2 = parseRange(att(node3, "ref") ?? "");
16677
- if (!node3 || !range2) return void 0;
16678
- const filter = { range: range2 };
16679
- const columns = [];
16680
- for (const column of xChildren(node3, "filterColumn")) {
16681
- const entry3 = {
16682
- offset: numAttr(column, "colId") ?? 0
16683
- };
16684
- const filters = xFirst(column, "filters");
16685
- if (filters) {
16686
- entry3.values = xChildren(filters, "filter").map((f) => att(f, "val") ?? "");
16687
- if (boolAttr(filters, "blank")) entry3.blank = true;
16688
- }
16689
- entry3.sourceXml = outerXml(column).replace(MAIN_NS_DECL, "");
16690
- columns.push(entry3);
16691
- }
16692
- if (columns.length) filter.columns = columns;
16693
- return filter;
16694
- }
16695
- var HEADER_FOOTER_TEXT = {
16696
- header: "oddHeader",
16697
- footer: "oddFooter",
16698
- evenHeader: "evenHeader",
16699
- evenFooter: "evenFooter",
16700
- firstHeader: "firstHeader",
16701
- firstFooter: "firstFooter"
16702
- };
16703
- var HEADER_FOOTER_FLAGS = [
16704
- "differentOddEven",
16705
- "differentFirst",
16706
- "scaleWithDoc",
16707
- "alignWithMargins"
17238
+ // xlsx/read/worksheet-children.ts
17239
+ var WORKSHEET_CHILD_ORDER = [
17240
+ "sheetPr",
17241
+ "dimension",
17242
+ "sheetViews",
17243
+ "sheetFormatPr",
17244
+ "cols",
17245
+ "sheetData",
17246
+ "sheetCalcPr",
17247
+ "sheetProtection",
17248
+ "protectedRanges",
17249
+ "scenarios",
17250
+ "autoFilter",
17251
+ "sortState",
17252
+ "dataConsolidate",
17253
+ "customSheetViews",
17254
+ "mergeCells",
17255
+ "phoneticPr",
17256
+ "conditionalFormatting",
17257
+ "dataValidations",
17258
+ "hyperlinks",
17259
+ "printOptions",
17260
+ "pageMargins",
17261
+ "pageSetup",
17262
+ "headerFooter",
17263
+ "rowBreaks",
17264
+ "colBreaks",
17265
+ "customProperties",
17266
+ "cellWatches",
17267
+ "ignoredErrors",
17268
+ "smartTags",
17269
+ "drawing",
17270
+ "legacyDrawing",
17271
+ "legacyDrawingHF",
17272
+ "drawingHF",
17273
+ "picture",
17274
+ "oleObjects",
17275
+ "controls",
17276
+ "webPublishItems",
17277
+ "tableParts",
17278
+ "extLst"
16708
17279
  ];
16709
- function readHeaderFooter(node3) {
16710
- const out = {};
16711
- for (const key2 of HEADER_FOOTER_FLAGS) {
16712
- const value3 = boolAttr(node3, key2);
16713
- if (value3 !== void 0) out[key2] = value3;
16714
- }
16715
- for (const [key2, local] of Object.entries(HEADER_FOOTER_TEXT)) {
16716
- const child4 = xFirst(node3, local);
16717
- if (child4) out[key2] = xText(child4);
16718
- }
16719
- return out;
16720
- }
16721
- var ORIENTATIONS = /* @__PURE__ */ new Set(["portrait", "landscape"]);
16722
- function readPageSetup(margins, setup, headerFooter, fitToPage) {
16723
- const page = {};
16724
- if (setup) {
16725
- if (/^(1|true)$/.test(att(setup, "useFirstPageNumber") ?? "")) {
16726
- page.firstPageNumber = numAttr(setup, "firstPageNumber") ?? 1;
16727
- }
16728
- const order = att(setup, "pageOrder");
16729
- if (order === "downThenOver" || order === "overThenDown") page.pageOrder = order;
16730
- const orientation = att(setup, "orientation");
16731
- if (orientation && ORIENTATIONS.has(orientation))
16732
- page.orientation = orientation;
16733
- const paper = numAttr(setup, "paperSize");
16734
- if (paper !== void 0) page.paperSize = paper;
16735
- const scale = numAttr(setup, "scale");
16736
- if (scale !== void 0) page.scale = scale;
16737
- }
16738
- if (fitToPage) {
16739
- page.fitToWidth = numAttr(setup, "fitToWidth") ?? 1;
16740
- page.fitToHeight = numAttr(setup, "fitToHeight") ?? 1;
16741
- }
16742
- if (margins) {
16743
- const m = (name3, fallback) => numAttr(margins, name3) ?? fallback;
16744
- page.margins = {
16745
- left: m("left", 0.7),
16746
- right: m("right", 0.7),
16747
- top: m("top", 0.75),
16748
- bottom: m("bottom", 0.75),
16749
- header: m("header", 0.3),
16750
- footer: m("footer", 0.3)
16751
- };
16752
- }
16753
- if (headerFooter) Object.assign(page, readHeaderFooter(headerFooter));
16754
- return Object.keys(page).length ? page : void 0;
16755
- }
16756
- var PROTECTION_META = /* @__PURE__ */ new Set([
16757
- "sheet",
16758
- "password",
16759
- "algorithmName",
16760
- "hashValue",
16761
- "saltValue",
16762
- "spinCount"
16763
- ]);
16764
- function readProtection(node3) {
16765
- if (!node3) return void 0;
16766
- const protection2 = { sheet: boolAttr(node3, "sheet", false) };
16767
- const password = att(node3, "password");
16768
- if (password) protection2.passwordHash = password;
16769
- const modernHash = readModernHash(node3);
16770
- if (modernHash) protection2.modernHash = modernHash;
16771
- const allow = [];
16772
- for (const attribute4 of Array.from(node3.attributes)) {
16773
- if (PROTECTION_META.has(attribute4.name)) continue;
16774
- if (attribute4.value === "0" || attribute4.value === "false") allow.push(attribute4.name);
16775
- }
16776
- if (allow.length) protection2.allow = allow.sort();
16777
- return protection2;
16778
- }
16779
17280
 
16780
17281
  // xlsx/read/conditional.ts
16781
17282
  var CFVO_TYPES = /* @__PURE__ */ new Set(["min", "max", "num", "percent", "percentile", "formula"]);
@@ -20151,9 +20652,205 @@ function readSlicerFrame(content2, anchor, sourceXml) {
20151
20652
  return void 0;
20152
20653
  }
20153
20654
 
20154
- // xlsx/read/drawing.ts
20655
+ // xlsx/read/form-control.ts
20656
+ var TYPES = {
20657
+ checkbox: "checkbox",
20658
+ radio: "radio",
20659
+ drop: "dropdown",
20660
+ list: "list",
20661
+ button: "button",
20662
+ spin: "spin",
20663
+ scroll: "scroll",
20664
+ gbox: "groupBox",
20665
+ label: "label",
20666
+ edit: "edit"
20667
+ };
20668
+ function readFormControlFrame(alternate, anchorOf) {
20669
+ const choice2 = elements(alternate).find((node3) => node3.localName === "Choice");
20670
+ const anchorEl = choice2 ? elements(choice2).find((node3) => node3.localName?.endsWith("Anchor")) : void 0;
20671
+ if (!anchorEl) return void 0;
20672
+ const shape = elements(anchorEl).find((node3) => node3.localName === "sp");
20673
+ const nv = first(shape, "nvSpPr", NS.xdr);
20674
+ const cNvPr = first(nv, "cNvPr", NS.xdr);
20675
+ const spid = [...cNvPr?.getElementsByTagName("*") ?? []].find(
20676
+ (node3) => node3.localName === "compatExt"
20677
+ );
20678
+ if (!spid) return void 0;
20679
+ const shapeId2 = Number(att(cNvPr, "id"));
20680
+ if (!Number.isFinite(shapeId2)) return void 0;
20681
+ const name3 = att(cNvPr, "name");
20682
+ return {
20683
+ kind: "formControl",
20684
+ anchor: anchorOf(anchorEl),
20685
+ shapeId: shapeId2,
20686
+ controlType: "other",
20687
+ ...name3 ? { name: name3 } : {},
20688
+ sourceXml: selfContainedXml(alternate)
20689
+ };
20690
+ }
20691
+ var num = (value3) => {
20692
+ if (value3 === void 0 || value3 === "") return void 0;
20693
+ const parsed = Number(value3);
20694
+ return Number.isFinite(parsed) ? parsed : void 0;
20695
+ };
20696
+ function readProps(control, xml) {
20697
+ const props = parseXml(xml, { label: "XLSX form control" }).documentElement;
20698
+ control.controlType = TYPES[(att(props, "objectType") ?? "").toLowerCase()] ?? "other";
20699
+ const link = att(props, "fmlaLink");
20700
+ if (link) control.linkedCell = link;
20701
+ const range2 = att(props, "fmlaRange");
20702
+ if (range2) control.listRange = range2;
20703
+ if (control.controlType === "checkbox" || control.controlType === "radio") {
20704
+ const checked = att(props, "checked");
20705
+ control.checked = checked === "Checked" ? "checked" : checked === "Mixed" ? "mixed" : "unchecked";
20706
+ }
20707
+ if (att(props, "firstButton") === "1") control.firstButton = true;
20708
+ for (const [key2, attribute4] of [
20709
+ ["selected", "sel"],
20710
+ ["value", "val"],
20711
+ ["min", "min"],
20712
+ ["max", "max"],
20713
+ ["step", "inc"],
20714
+ ["page", "page"]
20715
+ ]) {
20716
+ const value3 = num(att(props, attribute4));
20717
+ if (value3 !== void 0) control[key2] = value3;
20718
+ }
20719
+ if (att(props, "horiz") === "1") control.horizontal = true;
20720
+ const style2 = att(props, "dropStyle");
20721
+ if (style2) control.dropStyle = style2;
20722
+ }
20723
+ var entities = {
20724
+ amp: "&",
20725
+ lt: "<",
20726
+ gt: ">",
20727
+ quot: '"',
20728
+ apos: "'",
20729
+ nbsp: " "
20730
+ };
20731
+ function vmlCaption(vml, shapeId2) {
20732
+ const start = vml.indexOf(`id="_x0000_s${shapeId2}"`);
20733
+ if (start < 0) return void 0;
20734
+ const end = vml.indexOf("</v:shape>", start);
20735
+ const shape = vml.slice(start, end < 0 ? void 0 : end);
20736
+ const box4 = /<v:textbox[^>]*>([\s\S]*?)<\/v:textbox>/.exec(shape)?.[1];
20737
+ if (!box4) return void 0;
20738
+ const text5 = box4.replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]*>/g, "").replace(/&(#x?[0-9a-f]+|\w+);/gi, (match, code) => {
20739
+ if (code.startsWith("#")) {
20740
+ const value3 = code[1]?.toLowerCase() === "x" ? parseInt(code.slice(2), 16) : Number(code.slice(1));
20741
+ return Number.isFinite(value3) ? String.fromCodePoint(value3) : match;
20742
+ }
20743
+ return entities[code.toLowerCase()] ?? match;
20744
+ }).replace(/\s+/g, " ").trim();
20745
+ return text5 || void 0;
20746
+ }
20747
+ function attachFormControls(source, sheetPart, root2, sheet, legacyDrawing) {
20748
+ const controls3 = sheet.drawings.filter(
20749
+ (object) => object.kind === "formControl"
20750
+ );
20751
+ if (!controls3.length) return;
20752
+ const rels = source.rels(sheetPart);
20753
+ const parts = /* @__PURE__ */ new Map();
20754
+ for (const control of Array.from(root2.getElementsByTagNameNS(NS.x, "control"))) {
20755
+ const shapeId2 = Number(att(control, "shapeId"));
20756
+ const rel = rels.get(relAttr(control, "id") ?? "");
20757
+ const target2 = rel ? source.target(sheetPart, rel) : void 0;
20758
+ if (target2) parts.set(shapeId2, target2);
20759
+ }
20760
+ const vmlRel = legacyDrawing ? rels.get(relAttr(legacyDrawing, "id") ?? "") : void 0;
20761
+ const vmlPart = vmlRel ? source.target(sheetPart, vmlRel) : void 0;
20762
+ const vml = vmlPart ? source.text(vmlPart) : void 0;
20763
+ for (const control of controls3) {
20764
+ const part = parts.get(control.shapeId);
20765
+ const xml = part ? source.text(part) : void 0;
20766
+ if (part && xml) {
20767
+ control.partName = part;
20768
+ try {
20769
+ readProps(control, xml);
20770
+ } catch {
20771
+ control.controlType = "other";
20772
+ }
20773
+ }
20774
+ const caption = vml ? vmlCaption(vml, control.shapeId) : void 0;
20775
+ if (caption) control.caption = caption;
20776
+ }
20777
+ }
20778
+
20779
+ // xlsx/read/shape.ts
20155
20780
  var xdr = (parent, local) => first(parent, local, NS.xdr);
20156
- var int2 = (parent, local) => Math.round(Number(xdr(parent, local)?.textContent ?? 0)) || 0;
20781
+ function styleRef2(style2, name3) {
20782
+ const ref = first(style2, name3, NS.a);
20783
+ if (!ref) return void 0;
20784
+ const idx = Number(att(ref, "idx") ?? 0);
20785
+ const color2 = parseDrawingColorIn(ref);
20786
+ return { idx: Number.isFinite(idx) ? idx : 0, ...color2 ? { color: color2 } : {} };
20787
+ }
20788
+ function readStyle(style2) {
20789
+ if (!style2) return void 0;
20790
+ const fill = styleRef2(style2, "fillRef");
20791
+ const line = styleRef2(style2, "lnRef");
20792
+ const fontColor = parseDrawingColorIn(first(style2, "fontRef", NS.a));
20793
+ return {
20794
+ ...fill ? { fill } : {},
20795
+ ...line ? { line } : {},
20796
+ ...fontColor ? { font: { color: fontColor } } : {}
20797
+ };
20798
+ }
20799
+ function readShapeNode(element2) {
20800
+ const local = element2.localName;
20801
+ if (local !== "sp" && local !== "cxnSp" && local !== "grpSp") return void 0;
20802
+ const isGroup = local === "grpSp";
20803
+ const nv = elements(element2).find((node4) => node4.localName?.startsWith("nv"));
20804
+ const cNvPr = xdr(nv, "cNvPr");
20805
+ const spPr = xdr(element2, isGroup ? "grpSpPr" : "spPr");
20806
+ const xfrm = first(spPr, "xfrm", NS.a);
20807
+ const transform2 = parseTransform(xfrm);
20808
+ const geometry = isGroup ? { geometry: "group" } : parseDrawingGeometry(spPr);
20809
+ const node3 = {
20810
+ kind: isGroup ? "group" : local === "cxnSp" ? "connector" : "shape",
20811
+ frame: transform2?.frame ?? { x: 0, y: 0, width: 0, height: 0 },
20812
+ geometry: geometry.geometry
20813
+ };
20814
+ const name3 = att(cNvPr, "name");
20815
+ if (name3) node3.name = name3;
20816
+ if (att(xdr(nv, "cNvSpPr"), "txBox") === "1") node3.textBox = true;
20817
+ if (transform2?.rotation) node3.rotation = transform2.rotation;
20818
+ if (transform2?.flipHorizontal) node3.flipH = true;
20819
+ if (transform2?.flipVertical) node3.flipV = true;
20820
+ if ("adjustments" in geometry && geometry.adjustments) node3.adjustments = geometry.adjustments;
20821
+ if ("paths" in geometry && geometry.paths) node3.paths = geometry.paths;
20822
+ if (!isGroup) {
20823
+ const fill = parseDrawingFill(spPr);
20824
+ if (fill) node3.fill = fill;
20825
+ const line = parseDrawingLine(first(spPr, "ln", NS.a));
20826
+ if (line) node3.line = line;
20827
+ const style2 = readStyle(xdr(element2, "style"));
20828
+ if (style2) node3.style = style2;
20829
+ const text5 = parseDrawingTextBody(xdr(element2, "txBody"));
20830
+ if (text5?.text) node3.text = text5;
20831
+ return node3;
20832
+ }
20833
+ const childFrame = parseFrameOf(first(xfrm, "chOff", NS.a), first(xfrm, "chExt", NS.a));
20834
+ if (childFrame) node3.childFrame = childFrame;
20835
+ node3.children = elements(element2).flatMap((child4) => {
20836
+ const read = readShapeNode(child4);
20837
+ return read ? [read] : [];
20838
+ });
20839
+ return node3;
20840
+ }
20841
+ function parseFrameOf(off, ext) {
20842
+ if (!off || !ext) return void 0;
20843
+ return {
20844
+ x: Number(att(off, "x") ?? 0),
20845
+ y: Number(att(off, "y") ?? 0),
20846
+ width: Number(att(ext, "cx") ?? 0),
20847
+ height: Number(att(ext, "cy") ?? 0)
20848
+ };
20849
+ }
20850
+
20851
+ // xlsx/read/drawing.ts
20852
+ var xdr2 = (parent, local) => first(parent, local, NS.xdr);
20853
+ var int2 = (parent, local) => Math.round(Number(xdr2(parent, local)?.textContent ?? 0)) || 0;
20157
20854
  function marker(node3) {
20158
20855
  return {
20159
20856
  col: int2(node3, "col"),
@@ -20164,7 +20861,7 @@ function marker(node3) {
20164
20861
  }
20165
20862
  function readAnchor(anchor) {
20166
20863
  if (anchor.localName === "absoluteAnchor") {
20167
- const pos = xdr(anchor, "pos");
20864
+ const pos = xdr2(anchor, "pos");
20168
20865
  const result3 = {
20169
20866
  from: {
20170
20867
  row: 0,
@@ -20173,26 +20870,26 @@ function readAnchor(anchor) {
20173
20870
  rowOffset: Number(att(pos, "y") ?? 0)
20174
20871
  }
20175
20872
  };
20176
- const ext2 = xdr(anchor, "ext");
20873
+ const ext2 = xdr2(anchor, "ext");
20177
20874
  if (ext2) result3.ext = { cx: Number(att(ext2, "cx") ?? 0), cy: Number(att(ext2, "cy") ?? 0) };
20178
20875
  return result3;
20179
20876
  }
20180
- const result2 = { from: marker(xdr(anchor, "from")) };
20181
- const to = xdr(anchor, "to");
20877
+ const result2 = { from: marker(xdr2(anchor, "from")) };
20878
+ const to = xdr2(anchor, "to");
20182
20879
  if (to) result2.to = marker(to);
20183
- const ext = xdr(anchor, "ext");
20880
+ const ext = xdr2(anchor, "ext");
20184
20881
  if (ext) result2.ext = { cx: Number(att(ext, "cx") ?? 0), cy: Number(att(ext, "cy") ?? 0) };
20185
20882
  return result2;
20186
20883
  }
20187
20884
  var ANCHOR_PARTS = /* @__PURE__ */ new Set(["from", "to", "ext", "pos", "clientData"]);
20188
20885
  function nonVisual(content2) {
20189
20886
  const nv = elements(content2).find((node3) => node3.localName?.startsWith("nv"));
20190
- return xdr(nv, "cNvPr");
20887
+ return xdr2(nv, "cNvPr");
20191
20888
  }
20192
20889
  function describe(content2) {
20193
20890
  switch (content2.localName) {
20194
20891
  case "sp":
20195
- return xdr(content2, "nvSpPr") && att(xdr(xdr(content2, "nvSpPr"), "cNvSpPr"), "txBox") === "1" ? "text box" : "shape";
20892
+ return xdr2(content2, "nvSpPr") && att(xdr2(xdr2(content2, "nvSpPr"), "cNvSpPr"), "txBox") === "1" ? "text box" : "shape";
20196
20893
  case "grpSp":
20197
20894
  return "group";
20198
20895
  case "cxnSp":
@@ -20212,6 +20909,11 @@ function parseDrawing(source, partName, warn) {
20212
20909
  const rels = source.rels(partName);
20213
20910
  const out = [];
20214
20911
  for (const anchorEl of elements(root2)) {
20912
+ if (anchorEl.localName === "AlternateContent") {
20913
+ const control = readFormControlFrame(anchorEl, readAnchor);
20914
+ if (control) out.push(control);
20915
+ continue;
20916
+ }
20215
20917
  if (!["twoCellAnchor", "oneCellAnchor", "absoluteAnchor"].includes(anchorEl.localName ?? ""))
20216
20918
  continue;
20217
20919
  const anchor = readAnchor(anchorEl);
@@ -20226,7 +20928,7 @@ function parseDrawing(source, partName, warn) {
20226
20928
  const cNvPr = nonVisual(content2);
20227
20929
  const name3 = att(cNvPr, "name");
20228
20930
  if (content2.localName === "pic") {
20229
- const blipFill = xdr(content2, "blipFill");
20931
+ const blipFill = xdr2(content2, "blipFill");
20230
20932
  const blip = first(blipFill, "blip", NS.a);
20231
20933
  const rel = rels.get(relAttr(blip, "embed") ?? "");
20232
20934
  const target2 = rel ? source.target(partName, rel) : void 0;
@@ -20301,11 +21003,50 @@ function parseDrawing(source, partName, warn) {
20301
21003
  continue;
20302
21004
  }
20303
21005
  }
20304
- out.push(unsupported4(describe(content2)));
21006
+ const shape = readShapeNode(content2);
21007
+ out.push({ ...unsupported4(describe(content2)), ...shape ? { shape } : {} });
20305
21008
  }
20306
21009
  return out;
20307
21010
  }
20308
21011
 
21012
+ // xlsx/read/header-footer-images.ts
21013
+ var UNIT_PT = { pt: 1, in: 72, cm: 72 / 2.54, mm: 72 / 25.4, px: 0.75 };
21014
+ function styleLength(style2, property2) {
21015
+ const match = new RegExp(
21016
+ `(?:^|[;\\s])${property2}\\s*:\\s*([\\d.]+)\\s*(pt|in|cm|mm|px)?`,
21017
+ "i"
21018
+ ).exec(style2);
21019
+ return match ? Number(match[1]) * (UNIT_PT[(match[2] ?? "pt").toLowerCase()] ?? 1) : 0;
21020
+ }
21021
+ function readHeaderFooterImages(source, sheetPart, legacyHF) {
21022
+ if (!legacyHF) return void 0;
21023
+ const rel = source.rels(sheetPart).get(relAttr(legacyHF, "id") ?? "");
21024
+ const vmlPart = rel ? source.target(sheetPart, rel) : void 0;
21025
+ const vml = vmlPart ? source.text(vmlPart) : void 0;
21026
+ if (!vmlPart || !vml) return void 0;
21027
+ const rels = source.rels(vmlPart);
21028
+ const images = {};
21029
+ for (const match of vml.matchAll(/<v:shape\b([^>]*)>([\s\S]*?)<\/v:shape>/g)) {
21030
+ const id3 = /\bid="([^"]+)"/.exec(match[1] ?? "")?.[1];
21031
+ const style2 = /style=(?:'([^']*)'|"([^"]*)")/.exec(match[1] ?? "");
21032
+ const data = /<v:imagedata\b([^>]*)>/.exec(match[2] ?? "")?.[1];
21033
+ const relId = /\bo:relid="([^"]+)"/.exec(data ?? "")?.[1];
21034
+ const imageRel = relId ? rels.get(relId) : void 0;
21035
+ const partName = imageRel ? source.target(vmlPart, imageRel) : void 0;
21036
+ if (!id3 || !partName || !source.has(partName)) continue;
21037
+ const css = style2?.[1] ?? style2?.[2] ?? "";
21038
+ const title = /\bo:title="([^"]*)"/.exec(data ?? "")?.[1];
21039
+ images[id3] = {
21040
+ partName,
21041
+ contentType: source.contentType(partName) ?? "application/octet-stream",
21042
+ widthPt: styleLength(css, "width"),
21043
+ heightPt: styleLength(css, "height"),
21044
+ ...title ? { title } : {}
21045
+ };
21046
+ }
21047
+ return Object.keys(images).length ? images : void 0;
21048
+ }
21049
+
20309
21050
  // xlsx/read/dates.ts
20310
21051
  var DAY_MS2 = 864e5;
20311
21052
  var EPOCH_19003 = Date.UTC(1899, 11, 30);
@@ -20447,6 +21188,8 @@ function readRowInfo(ctx, rowEl) {
20447
21188
  const outline = numAttr(rowEl, "outlineLevel");
20448
21189
  if (outline) info.outlineLevel = outline;
20449
21190
  if (boolAttr(rowEl, "collapsed")) info.collapsed = true;
21191
+ if (boolAttr(rowEl, "thickTop")) info.thickTop = true;
21192
+ if (boolAttr(rowEl, "thickBot")) info.thickBot = true;
20450
21193
  return Object.keys(info).length ? info : void 0;
20451
21194
  }
20452
21195
  function readSheetData(ctx, rows, sheet) {
@@ -20559,15 +21302,6 @@ function readScenarios(node3) {
20559
21302
  return set;
20560
21303
  }
20561
21304
 
20562
- // xlsx/read/print-options.ts
20563
- var KEYS = ["gridLines", "headings", "horizontalCentered", "verticalCentered"];
20564
- function readPrintOptions(node3) {
20565
- if (!node3) return void 0;
20566
- const out = {};
20567
- for (const key2 of KEYS) if (boolAttr(node3, key2)) out[key2] = true;
20568
- return Object.keys(out).length ? out : void 0;
20569
- }
20570
-
20571
21305
  // xlsx/read/tables.ts
20572
21306
  function parseTable(xml, partName) {
20573
21307
  const root2 = parseXml(xml, { label: "XLSX table" }).documentElement;
@@ -20658,8 +21392,14 @@ var MODELLED = /* @__PURE__ */ new Set([
20658
21392
  "drawing",
20659
21393
  "legacyDrawing",
20660
21394
  "tableParts",
20661
- "scenarios"
21395
+ "scenarios",
21396
+ "customSheetViews"
20662
21397
  ]);
21398
+ function reportUnplaceable(ctx, sheet, element2) {
21399
+ ctx.warn(
21400
+ `Sheet "${sheet}": the element "${element2}" is not part of the worksheet schema and is dropped on save.`
21401
+ );
21402
+ }
20663
21403
  function keep(sheet, key2, xml) {
20664
21404
  const list2 = sheet.preserved.get(key2);
20665
21405
  if (list2) list2.push(xml);
@@ -20741,9 +21481,15 @@ function readWorksheet(ctx, partName, name3, sheetId5, xml, rows) {
20741
21481
  else if (!byName.has(local)) byName.set(local, node3);
20742
21482
  if (SNAPSHOT_ELEMENTS.includes(local))
20743
21483
  keep(sheet, snapshotKey(local), outerXml(node3));
20744
- else if (local === "AlternateContent")
20745
- keep(sheet, alternateContentName(node3) ?? local, selfContainedXml(node3));
20746
- else if (!MODELLED.has(local)) keep(sheet, local, selfContainedXml(node3));
21484
+ else if (local === "AlternateContent") {
21485
+ const inner = alternateContentName(node3);
21486
+ if (!WORKSHEET_CHILD_ORDER.includes(inner ?? local))
21487
+ reportUnplaceable(ctx, name3, inner ?? local);
21488
+ keep(sheet, inner ?? local, selfContainedXml(node3));
21489
+ } else if (!MODELLED.has(local)) {
21490
+ if (!WORKSHEET_CHILD_ORDER.includes(local)) reportUnplaceable(ctx, name3, local);
21491
+ keep(sheet, local, selfContainedXml(node3));
21492
+ }
20747
21493
  }
20748
21494
  const sheetPr = byName.get("sheetPr");
20749
21495
  const tabColor = readTabColor(sheetPr, ctx.palette);
@@ -20779,6 +21525,10 @@ function readWorksheet(ctx, partName, name3, sheetId5, xml, rows) {
20779
21525
  readFitToPage(sheetPr)
20780
21526
  );
20781
21527
  if (page) sheet.pageSetup = page;
21528
+ const customViews = byName.get("customSheetViews");
21529
+ if (customViews) sheet.customViews = readCustomSheetViews(customViews);
21530
+ const hfImages = readHeaderFooterImages(ctx.source, partName, byName.get("legacyDrawingHF"));
21531
+ if (hfImages) sheet.headerFooterImages = hfImages;
20782
21532
  const printOptions = readPrintOptions(byName.get("printOptions"));
20783
21533
  if (printOptions) sheet.printOptions = printOptions;
20784
21534
  const drawing = byName.get("drawing");
@@ -20786,6 +21536,7 @@ function readWorksheet(ctx, partName, name3, sheetId5, xml, rows) {
20786
21536
  const rel = ctx.source.rels(partName).get(relAttr(drawing, "id") ?? "");
20787
21537
  const target2 = rel ? ctx.source.target(partName, rel) : void 0;
20788
21538
  if (target2) sheet.drawings = parseDrawing(ctx.source, target2, (m) => ctx.warn(m));
21539
+ attachFormControls(ctx.source, partName, root2, sheet, byName.get("legacyDrawing"));
20789
21540
  }
20790
21541
  readTables(ctx, partName, byName.get("tableParts"), sheet);
20791
21542
  readComments(ctx, partName, sheet);
@@ -20894,6 +21645,7 @@ async function loadXlsx(input, options2 = {}) {
20894
21645
  if (book.workbookPasswordHash) workbook.workbookPasswordHash = book.workbookPasswordHash;
20895
21646
  if (book.workbookModernHash) workbook.workbookModernHash = book.workbookModernHash;
20896
21647
  if (book.oleSize) workbook.oleSize = book.oleSize;
21648
+ if (book.customViews) workbook.customViews = book.customViews;
20897
21649
  if (book.calcMode) workbook.calcMode = book.calcMode;
20898
21650
  if (book.iterate) workbook.iterate = book.iterate;
20899
21651
  if (signatures.hasSignatures)
@@ -22677,9 +23429,9 @@ function sampleArc(start, rxIn, ryIn, xAxisRotationDeg, largeArcFlag, sweepFlag,
22677
23429
  ry *= scale;
22678
23430
  }
22679
23431
  const sign = largeArcFlag !== sweepFlag ? 1 : -1;
22680
- const num = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
23432
+ const num2 = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
22681
23433
  const den = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
22682
- const coef = sign * Math.sqrt(Math.max(0, num / den));
23434
+ const coef = sign * Math.sqrt(Math.max(0, num2 / den));
22683
23435
  const cxp = coef * (rx * y1p) / ry;
22684
23436
  const cyp = coef * -(ry * x1p) / rx;
22685
23437
  const cx = cosPhi * cxp - sinPhi * cyp + (start.x + end.x) / 2;
@@ -28469,10 +29221,10 @@ function processCompoundFileStream(input, path3, replacement) {
28469
29221
  if (input[0] !== 208 || input[1] !== 207 || input[2] !== 17 || input[3] !== 224 || input[4] !== 161 || input[5] !== 177 || input[6] !== 26 || input[7] !== 225 || // Readers tolerate a non-canonical byte-order mark; edits do not.
28470
29222
  replacement && view2.getUint16(28, true) !== 65534)
28471
29223
  return reject2();
28472
- const major = view2.getUint16(26, true), shift2 = view2.getUint16(30, true), miniShift = view2.getUint16(32, true);
28473
- if (major !== 3 && major !== 4 || shift2 !== (major === 3 ? 9 : 12) || miniShift !== 6)
29224
+ const major = view2.getUint16(26, true), shift3 = view2.getUint16(30, true), miniShift = view2.getUint16(32, true);
29225
+ if (major !== 3 && major !== 4 || shift3 !== (major === 3 ? 9 : 12) || miniShift !== 6)
28474
29226
  return reject2();
28475
- const sectorSize = 1 << shift2, miniSize = 1 << miniShift;
29227
+ const sectorSize = 1 << shift3, miniSize = 1 << miniShift;
28476
29228
  if (input.length < sectorSize || replacement && input.length % sectorSize !== 0)
28477
29229
  return reject2();
28478
29230
  const sectorCount = Math.ceil(input.length / sectorSize) - 1;
@@ -36216,7 +36968,7 @@ function readVsdDrawing(input) {
36216
36968
  }
36217
36969
  seen.add(offset);
36218
36970
  active.add(offset);
36219
- const compressed = (format5 & 2) !== 0, shift2 = compressed ? 4 : 0;
36971
+ const compressed = (format5 & 2) !== 0, shift3 = compressed ? 4 : 0;
36220
36972
  const bytes = compressed ? decodeVsdBlock(stream.subarray(offset, offset + length), decodedBudget) : stream.slice(offset, offset + length);
36221
36973
  decodedBudget -= bytes.length;
36222
36974
  if (decodedBudget < 0)
@@ -36231,17 +36983,17 @@ function readVsdDrawing(input) {
36231
36983
  if (page && [71, 72, 78].includes(type)) {
36232
36984
  shape = { id: id3, kind: type === 71 ? "group" : type === 78 ? "foreign" : "shape", coordinateSpace: "shape-local", unsupportedGeometry: false, unsafeTransform: false, geometry: [], unsafeText: false };
36233
36985
  page.shapes.push(shape);
36234
- if (bytes.length - shift2 >= 54) {
36986
+ if (bytes.length - shift3 >= 54) {
36235
36987
  const sv = view(bytes);
36236
- shape.parentId = sv.getUint32(shift2 + 10, true);
36237
- shape.masterPageId = sv.getUint32(shift2 + 18, true);
36238
- shape.masterShapeId = sv.getUint32(shift2 + 26, true);
36988
+ shape.parentId = sv.getUint32(shift3 + 10, true);
36989
+ shape.masterPageId = sv.getUint32(shift3 + 18, true);
36990
+ shape.masterShapeId = sv.getUint32(shift3 + 26, true);
36239
36991
  }
36240
36992
  }
36241
36993
  const mode = format5 >>> 4;
36242
36994
  if (mode === 5 || type === 20) {
36243
- bounded3(bytes, shift2, 4);
36244
- const table2 = view(bytes).getUint32(shift2, true) + shift2 - 4;
36995
+ bounded3(bytes, shift3, 4);
36996
+ const table2 = view(bytes).getUint32(shift3, true) + shift3 - 4;
36245
36997
  bounded3(bytes, table2, 12);
36246
36998
  const count = view(bytes).getInt32(table2 + 4, true), order = view(bytes).getUint32(table2, true);
36247
36999
  if (count < 0 || count > 1e5 || count > Math.floor((bytes.length - table2 - 12) / 18))
@@ -37378,8 +38130,13 @@ function resolveVisioPageVisibility(page, options2 = {}) {
37378
38130
  }
37379
38131
 
37380
38132
  // visio/edit-formatting-scope.ts
37381
- async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shape, changed, check, instanceView2) {
37382
- indexCells(roots, { check });
38133
+ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shape, changed, check, instanceView2, options2 = {}) {
38134
+ for (const item2 of indexCells(roots, { check, scope: "affected" }).values())
38135
+ if (item2.refusal && item2.pageId === pageId2)
38136
+ fail(
38137
+ "EDIT_UNKNOWN_DEPENDENCY",
38138
+ `Cannot prove ShapeSheet dependency closure: ${item2.refusal}`
38139
+ );
37383
38140
  const shapeId2 = attribute2(shape, "ID");
37384
38141
  const changedNames = new Set([...changed.keys()].map((name3) => name3.toLowerCase()));
37385
38142
  const jumpOnly = [...changedNames].every(
@@ -37434,11 +38191,17 @@ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shap
37434
38191
  if (textEdit && localShapeId === shapeId2 && sourcePageId === pageId2) continue;
37435
38192
  analysis = sized;
37436
38193
  }
38194
+ if (options2.textReads && textEdit && !named2 && sourcePageId !== void 0 && textReadFormula(source))
38195
+ continue;
37437
38196
  if (named2 && analysis.dynamic) {
37438
38197
  if (mentions()) failure2();
37439
38198
  continue;
37440
38199
  }
37441
- if (analysis.dynamic || analysis.references.some(
38200
+ if (analysis.dynamic && analysis.opaque) {
38201
+ if (sourcePageId === pageId2 || mentions()) failure2();
38202
+ continue;
38203
+ }
38204
+ if (analysis.references.some(
37442
38205
  (ref) => changedNames.has(canonical2(ref.cell)) && (sourcePageId === void 0 || sourcePageId === pageId2) && (ref.shapeId === shapeId2 || ref.shapeId === void 0 && (localShapeId === shapeId2 || sourcePageId === void 0))
37443
38206
  ))
37444
38207
  failure2();
@@ -37451,6 +38214,7 @@ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shap
37451
38214
  const part = await pkg.readXml(path3);
37452
38215
  const master2 = part.localName === "MasterContents";
37453
38216
  if (instanceView2 && master2) continue;
38217
+ if (master2 && !shape.hasAttribute("Master") && !shape.hasAttribute("MasterShape")) continue;
37454
38218
  inspect7(part, void 0, master2);
37455
38219
  }
37456
38220
  }
@@ -37653,7 +38417,7 @@ function masterTemplate(pkg) {
37653
38417
  return matches2.length === 1 ? matches2[0] : missing();
37654
38418
  };
37655
38419
  }
37656
- function replaceScopedPlainText(pkg, pagePaths, roots, document, edit, check) {
38420
+ function replaceScopedPlainText(pkg, pagePaths, roots, document, edit, check, diagnostics = []) {
37657
38421
  return replacePlainText(
37658
38422
  roots.get(edit.pageId),
37659
38423
  document,
@@ -37667,10 +38431,20 @@ function replaceScopedPlainText(pkg, pagePaths, roots, document, edit, check) {
37667
38431
  edit.pageId,
37668
38432
  shape,
37669
38433
  /* @__PURE__ */ new Map([["TheText", text5]]),
37670
- check
38434
+ check,
38435
+ void 0,
38436
+ { textReads: true }
37671
38437
  ),
37672
38438
  masterTemplate(pkg)
37673
- );
38439
+ ).then((changed) => {
38440
+ if (changed)
38441
+ recalculateVisioCells(
38442
+ roots,
38443
+ [{ pageId: edit.pageId, shapeId: edit.shapeId, cell: "TheText" }],
38444
+ { check, cycles: "keep", diagnostics }
38445
+ );
38446
+ return changed;
38447
+ });
37674
38448
  }
37675
38449
 
37676
38450
  // visio/edit-stencil-connector.ts
@@ -38934,9 +39708,16 @@ function visioWalkPath(begin, end) {
38934
39708
  return horizontal2 ? [p, { x: p.x + turn, y: p.y }, { x: p.x + turn, y: q.y }, q] : [p, { x: p.x, y: p.y + turn }, { x: q.x, y: p.y + turn }, q];
38935
39709
  };
38936
39710
  let path3;
38937
- if (gapX >= -EPSILON3 && inside2(from.y, b.minY, b.maxY))
38938
- path3 = jog(side(begin, sx, 0), side(end, -sx, 0), true);
38939
- else if (gapY >= -EPSILON3 && inside2(from.x, b.minX, b.maxX))
39711
+ if (gapX >= -EPSILON3 && inside2(from.y, b.minY, b.maxY)) {
39712
+ const p = side(begin, sx, 0), q = side(end, -sx, 0);
39713
+ if (begin.shape?.floating && end.shape?.floating) {
39714
+ const y = (Math.max(a2.minY, b.minY) + Math.min(a2.maxY, b.maxY)) / 2;
39715
+ path3 = [
39716
+ { x: p.x, y },
39717
+ { x: q.x, y }
39718
+ ];
39719
+ } else path3 = jog(p, q, true);
39720
+ } else if (gapY >= -EPSILON3 && inside2(from.x, b.minX, b.maxX))
38940
39721
  path3 = jog(side(begin, 0, sy), side(end, 0, -sy), false);
38941
39722
  else if (gapY < -EPSILON3 || gapY < CHANNEL && gapX >= CHANNEL) {
38942
39723
  const p = side(begin, sx, 0);
@@ -39572,7 +40353,7 @@ function writeStencilConnector(shape, route, vertices) {
39572
40353
 
39573
40354
  // visio/edit-stencil-connector-layout.ts
39574
40355
  var same6 = (a2, b) => Math.abs(a2 - b) <= 1e-9 * Math.max(1, Math.abs(a2), Math.abs(b));
39575
- function walkShape(box4) {
40356
+ function walkShape(box4, floating = false) {
39576
40357
  const [a2, b, c2, d, e, f] = box4.transform;
39577
40358
  const at2 = (x, y) => ({
39578
40359
  x: a2 * x + c2 * y + e,
@@ -39584,7 +40365,8 @@ function walkShape(box4) {
39584
40365
  sites: sites.map((site) => ({ point: site.point, normal: site.normal })),
39585
40366
  bounds: sites[0].box,
39586
40367
  center: at2(box4.width / 2, box4.height / 2),
39587
- corners: [at2(0, 0), at2(box4.width, 0), at2(box4.width, box4.height), at2(0, box4.height)]
40368
+ corners: [at2(0, 0), at2(box4.width, 0), at2(box4.width, box4.height), at2(0, box4.height)],
40369
+ ...floating ? { floating } : {}
39588
40370
  }
39589
40371
  };
39590
40372
  }
@@ -39805,6 +40587,11 @@ function connectionRows(shape) {
39805
40587
  }
39806
40588
  return rows;
39807
40589
  }
40590
+ function hasConnectionPoints(root2, shapeId2) {
40591
+ const target2 = topShape(root2, shapeId2);
40592
+ if (!target2) return false;
40593
+ return (stencilTemplate(target2) ? effectiveRows(target2, "Connection") : connectionRows(target2)).size > 0;
40594
+ }
39808
40595
  function glueSites(root2, end) {
39809
40596
  const box4 = glueBox(root2, end.target);
39810
40597
  if (end.point === void 0) return dynamicSites(box4);
@@ -39915,8 +40702,9 @@ function proveConnector(root2, connectorId) {
39915
40702
  const named2 = visioPointGlueTarget(source);
39916
40703
  return index2 === void 0 ? !named2 : !!named2 && named2.shapeId === target2 && named2.index === index2;
39917
40704
  };
39918
- if (!end || !target2 || ends[end] !== void 0 || (index2 === void 0 ? toCell !== "PinX" || attribute2(row2, "ToPart") !== "3" : attribute2(row2, "ToPart") !== String(100 + index2)) || // A line master has no glue trigger of its own unless Visio wrote one with the glue.
39919
- visioGlueTriggerTarget(formula2(triggerName(end))) !== target2 && !(isStencilLine(shape) && formula2(triggerName(end)) === void 0) || !glued("X") || !glued("Y"))
40705
+ if (!end || !target2 || ends[end] !== void 0 || (index2 === void 0 ? toCell !== "PinX" || attribute2(row2, "ToPart") !== "3" : attribute2(row2, "ToPart") !== String(100 + index2)) || // A line master has no glue trigger of its own unless Visio wrote one with the glue, and
40706
+ // point glue on a drawn line has none either (native-edit-families-flat-2026-10-29.json).
40707
+ visioGlueTriggerTarget(formula2(triggerName(end))) !== target2 && !(formula2(triggerName(end)) === void 0 && !local.has(triggerName(end)) && (isStencilLine(shape) || index2 !== void 0)) || !glued("X") || !glued("Y"))
39920
40708
  fail("UNSUPPORTED_GEOMETRY_EDIT", UNSUPPORTED2);
39921
40709
  ends[end] = { target: target2, ...index2 === void 0 ? {} : { point: index2 } };
39922
40710
  }
@@ -40182,7 +40970,7 @@ function rerouteConnector(roots, pageId2, glue, check, options2 = {}) {
40182
40970
  }
40183
40971
  const walk = (end) => {
40184
40972
  const target2 = glue.ends[end];
40185
- return target2 && target2.point === void 0 ? walkShape(glueBox(root2, target2.target)) : { point: sites(end)[0].point };
40973
+ return target2 && target2.point === void 0 ? walkShape(glueBox(root2, target2.target), !hasConnectionPoints(root2, target2.target)) : { point: sites(end)[0].point };
40186
40974
  };
40187
40975
  const route = options2.route ?? current;
40188
40976
  if (route === "straight" && current === "straight" && ENDS.every(
@@ -41453,7 +42241,7 @@ var unquotedVisioFormula = (source) => source.split(/("(?:[^"]|"")*")/g).map((pa
41453
42241
 
41454
42242
  // visio/formula-functions.ts
41455
42243
  var DOCUMENTED = new Set(
41456
- `ABS ACOS AND ANG360 ANGLEALONGPATH ANGLETOLOC ANGLETOPAR ASIN ATAN ATAN2 BITAND BITNOT BITOR
42244
+ `ABS ACOS AND ARG ANG360 ANGLEALONGPATH ANGLETOLOC ANGLETOPAR ASIN ATAN ATAN2 BITAND BITNOT BITOR
41457
42245
  BITXOR BKGPAGENAME BLEND BLOB BLUE BOUND CALLOUTCOUNT CALLOUTTARGETREF CALLTHIS CATEGORY CEILING
41458
42246
  CELLISTHEMED CHAR COMPANY CONTAINERCOUNT CONTAINERMEMBERCOUNT CONTAINERSHEETREF COS COSH CREATOR
41459
42247
  CY DATA1 DATA2 DATA3 DATE DATETIME DATEVALUE DAY DAYOFYEAR DECIMALSEP DEFAULTEVENT DEG DEPENDSON
@@ -42982,17 +43770,17 @@ function pageSettingConstant(node3, length) {
42982
43770
  }
42983
43771
  return value3.value;
42984
43772
  }
42985
- var escape2 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
43773
+ var escape3 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
42986
43774
  function assertDependencies(roots, pagesPart, pages, pagePaths, pageId2, changed, check) {
42987
43775
  const page = children2(pages, "Page").find((node3) => attribute2(node3, "ID") === pageId2);
42988
43776
  const targetNames = new Set(
42989
43777
  ["Name", "NameU"].map((name3) => attribute2(page, name3)?.toLowerCase())
42990
43778
  );
42991
43779
  const otherNames = children2(pages, "Page").filter((node3) => node3 !== page).flatMap((node3) => ["Name", "NameU"].map((name3) => attribute2(node3, name3))).filter((name3) => !!name3 && !targetNames.has(name3.toLowerCase()));
42992
- const cells4 = changed.map(escape2).join("|");
43780
+ const cells4 = changed.map(escape3).join("|");
42993
43781
  const reference2 = new RegExp(`(?:^|[^a-z0-9_.])(?:${cells4})(?:$|[^a-z0-9_.])`, "i");
42994
43782
  const other = otherNames.length ? new RegExp(
42995
- `Pages\\[(?:${otherNames.map(escape2).join("|")})\\]!(?:ThePage!)?(?:${cells4})(?![a-z0-9_.])`,
43783
+ `Pages\\[(?:${otherNames.map(escape3).join("|")})\\]!(?:ThePage!)?(?:${cells4})(?![a-z0-9_.])`,
42996
43784
  "gi"
42997
43785
  ) : void 0;
42998
43786
  const paths = new Map([...pagePaths].map(([id3, path3]) => [path3, id3]));
@@ -43411,7 +44199,7 @@ var VISIO_DEFAULT_TITLE = "Title";
43411
44199
  var ACCENT = { background: "Background Accent", border: "Border Accent" };
43412
44200
  function visioShade(color2, amount) {
43413
44201
  const value3 = Number.parseInt(color2.slice(1), 16);
43414
- const channel = (shift2) => Math.round((value3 >> shift2 & 255) * (1 - amount)).toString(16).padStart(2, "0");
44202
+ const channel = (shift3) => Math.round((value3 >> shift3 & 255) * (1 - amount)).toString(16).padStart(2, "0");
43415
44203
  return `#${channel(16)}${channel(8)}${channel(0)}`.toUpperCase();
43416
44204
  }
43417
44205
  function visioDecorationName(name3) {
@@ -43608,14 +44396,14 @@ function snapshotPageSetupEdit(edit) {
43608
44396
  }
43609
44397
 
43610
44398
  // visio/edit-data-commands.ts
43611
- var TYPES = [
44399
+ var TYPES2 = [
43612
44400
  "import-data-recordset",
43613
44401
  "refresh-data-recordset",
43614
44402
  "delete-data-recordset",
43615
44403
  "link-data-rows",
43616
44404
  "unlink-data-rows"
43617
44405
  ];
43618
- var isVisioDataEdit = (edit) => TYPES.includes(edit.type);
44406
+ var isVisioDataEdit = (edit) => TYPES2.includes(edit.type);
43619
44407
  var id = (value3, label) => {
43620
44408
  if (typeof value3 !== "string" || !/^(0|[1-9]\d{0,9})$/.test(value3) || Number(value3) > 4294967295)
43621
44409
  fail("INVALID_EDIT", `Invalid ${label}.`);
@@ -46088,6 +46876,7 @@ function resizeVisioShapeAtAnchor(roots, document, edit, check, glueShapes = /*
46088
46876
  fail("UNSUPPORTED_GEOMETRY_EDIT", "Glued shapes require routing outside this subset.");
46089
46877
  const graph = indexCells(roots, {
46090
46878
  check,
46879
+ scope: "affected",
46091
46880
  glueShapes,
46092
46881
  ...group2 ? { groupResizeShapes: group2.shapes } : {}
46093
46882
  });
@@ -46401,13 +47190,23 @@ function prepareMasterMovePins(roots, commands, bindings, check) {
46401
47190
  }
46402
47191
  }
46403
47192
  if (result2.size) {
46404
- const indexed = indexCells(roots, { check });
47193
+ const indexed = indexCells(roots, { check, scope: "affected" });
46405
47194
  const pins = new Set(
46406
47195
  [...indexed.values()].filter((cell) => cell.node && result2.has(cell.node)).map(key)
46407
47196
  );
46408
- for (const cell of indexed.values())
46409
- if (charge(), cell.dependencies.some((dependency) => pins.has(dependency)))
47197
+ const pinPages = new Set(
47198
+ [...indexed.values()].filter((cell) => cell.node && result2.has(cell.node)).map((c2) => c2.pageId)
47199
+ );
47200
+ for (const cell of indexed.values()) {
47201
+ charge();
47202
+ if (cell.opaque && pinPages.has(cell.pageId))
47203
+ fail(
47204
+ "EDIT_UNSUPPORTED_DEPENDENCY",
47205
+ "A formula that may read a master rotation pin exists."
47206
+ );
47207
+ if (cell.dependencies.some((dependency) => pins.has(dependency)))
46410
47208
  fail("EDIT_UNSUPPORTED_DEPENDENCY", "A page cache depends on a master rotation pin.");
47209
+ }
46411
47210
  }
46412
47211
  return { pins: result2, dimensions: provenDimensions };
46413
47212
  }
@@ -46504,8 +47303,12 @@ function applyGeometryEdit(roots, document, edit, check, masterMoveProof = empty
46504
47303
  if (edit.type === "delete-shape") {
46505
47304
  unlocked("LockDelete");
46506
47305
  releaseDeletedGlue(roots, /* @__PURE__ */ new Map([[edit.pageId, /* @__PURE__ */ new Set([edit.shapeId])]]));
46507
- assertVisioShapeUnreferenced(roots, edit.pageId, edit.shapeId, { check });
47306
+ const frozen = assertVisioShapeUnreferenced(roots, edit.pageId, edit.shapeId, {
47307
+ check,
47308
+ freeze: true
47309
+ });
46508
47310
  shape.parentNode.removeChild(shape);
47311
+ freezeVisioCells(frozen);
46509
47312
  return [edit.pageId];
46510
47313
  }
46511
47314
  if (edit.type === "rotate-shape" || edit.type === "flip-shape") {
@@ -47443,7 +48246,7 @@ async function recalculatePageFormulas(pkg, pagesPart, pages, paths, dirty, chec
47443
48246
  }
47444
48247
 
47445
48248
  // visio/edit-page-rename.ts
47446
- var escape3 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
48249
+ var escape4 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47447
48250
  function localCell(node3) {
47448
48251
  const row2 = node3.parentNode;
47449
48252
  const section3 = row2?.parentNode;
@@ -47472,7 +48275,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
47472
48275
  }
47473
48276
  const roots = await editableVisioPageRoots(pkg, pagesPart, pages, pagePaths, dirty, check);
47474
48277
  const changedCells = [];
47475
- const prefix2 = new RegExp(`Pages\\[${escape3(oldUniversal)}\\]!`, "gi");
48278
+ const prefix2 = new RegExp(`Pages\\[${escape4(oldUniversal)}\\]!`, "gi");
47476
48279
  const targetByPath = new Map([...pagePaths].map(([id3, path3]) => [path3, id3]));
47477
48280
  for (const [path3, root2] of roots) {
47478
48281
  let changed = false;
@@ -47506,7 +48309,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
47506
48309
  if (cell) changedCells.push({ node: node3, cell });
47507
48310
  }
47508
48311
  } else if (/\bPAGENAME\s*\(/i.test(code)) {
47509
- if (target2 === pageId2 || !target2 || new RegExp(`Pages\\[${escape3(oldUniversal)}\\]!`, "i").test(code))
48312
+ if (target2 === pageId2 || !target2 || new RegExp(`Pages\\[${escape4(oldUniversal)}\\]!`, "i").test(code))
47510
48313
  fail(
47511
48314
  "EDIT_UNSUPPORTED_PAGE_NAME_FORMULA",
47512
48315
  "Complex page-name formula caches cannot be safely refreshed."
@@ -47556,7 +48359,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
47556
48359
  for (const changed of changedCells) {
47557
48360
  if (changed.node === node3) continue;
47558
48361
  const reference2 = new RegExp(
47559
- `(?:^|[^a-z0-9_.])${escape3(changed.cell)}(?:$|[^a-z0-9_.])`,
48362
+ `(?:^|[^a-z0-9_.])${escape4(changed.cell)}(?:$|[^a-z0-9_.])`,
47560
48363
  "i"
47561
48364
  );
47562
48365
  if (reference2.test(unquotedVisioFormula(formula2)))
@@ -47578,7 +48381,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
47578
48381
  // visio/edit-page-delete.ts
47579
48382
  var officeRel = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
47580
48383
  var pageType = "http://schemas.microsoft.com/visio/2010/relationships/page";
47581
- var escape4 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
48384
+ var escape5 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47582
48385
  async function deleteVisioPage(pkg, pagesPart, pages, rels, types, pagePaths, parts, dirty, removed, pageId2, check) {
47583
48386
  const existing = children2(pages, "Page");
47584
48387
  const page = existing.find((node3) => attribute2(node3, "ID") === pageId2);
@@ -47587,7 +48390,7 @@ async function deleteVisioPage(pkg, pagesPart, pages, rels, types, pagePaths, pa
47587
48390
  const names = new Set(
47588
48391
  ["Name", "NameU"].map((key2) => attribute2(page, key2)).filter((value3) => !!value3)
47589
48392
  );
47590
- const reference2 = new RegExp(`Pages\\[(?:${[...names].map(escape4).join("|")})\\]!`, "i");
48393
+ const reference2 = new RegExp(`Pages\\[(?:${[...names].map(escape5).join("|")})\\]!`, "i");
47591
48394
  const documentPart2 = await related(pkg, "", "document");
47592
48395
  const roots = await editableVisioPageRoots(
47593
48396
  pkg,
@@ -47912,7 +48715,7 @@ function createVisioPagePart(parts, pages, pageId2, check) {
47912
48715
  }
47913
48716
 
47914
48717
  // visio/edit-page-decoration.ts
47915
- var escape5 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
48718
+ var escape6 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47916
48719
  var name2 = (page) => attribute2(page, "NameU") ?? attribute2(page, "Name") ?? "";
47917
48720
  function largestShapeId(root2) {
47918
48721
  let largest = 0;
@@ -47928,9 +48731,9 @@ function removeDecoration(root2, pageName, kind, pageRoots, check) {
47928
48731
  ) : [];
47929
48732
  if (!targets.length) return false;
47930
48733
  const ids = targets.map((shape) => attribute2(shape, "ID") ?? "");
47931
- const local = new RegExp(`\\bSheet\\.(?:${ids.map(escape5).join("|")})!`, "i");
48734
+ const local = new RegExp(`\\bSheet\\.(?:${ids.map(escape6).join("|")})!`, "i");
47932
48735
  const remote = new RegExp(
47933
- `Pages\\[${escape5(pageName)}\\]!Sheet\\.(?:${ids.map(escape5).join("|")})!`,
48736
+ `Pages\\[${escape6(pageName)}\\]!Sheet\\.(?:${ids.map(escape6).join("|")})!`,
47934
48737
  "i"
47935
48738
  );
47936
48739
  for (const connect of children2(root2, "Connects").flatMap((node3) => children2(node3, "Connect")))
@@ -48764,17 +49567,117 @@ async function formatTarget(pkg, pagePaths, roots, document, edit, check, instan
48764
49567
  return true;
48765
49568
  }
48766
49569
 
49570
+ // visio/edit-duplicate-line.ts
49571
+ var ENDS2 = ["BeginX", "BeginY", "EndX", "EndY"];
49572
+ var connects = (root2) => children2(root2, "Connects").flatMap((container) => children2(container, "Connect"));
49573
+ var gluedTargets = (root2, id3) => connects(root2).filter((row2) => attribute2(row2, "FromSheet") === id3).map((row2) => attribute2(row2, "ToSheet") ?? "");
49574
+ function assertGlueDroppable(root2, id3, copied, code = "UNSUPPORTED_DUPLICATE") {
49575
+ if (gluedTargets(root2, id3).some((target2) => copied.has(target2)))
49576
+ fail(code, "A glued connector cannot be copied together with a shape it is glued to yet.");
49577
+ }
49578
+ function assertEndFormulas(read, code) {
49579
+ for (const name3 of ENDS2) {
49580
+ const formula2 = executableCellFormula(attribute2(read(name3), "F"));
49581
+ if (formula2 && !isNativeGlueCell(name3, formula2))
49582
+ fail(code, `${name3} of the line holds a formula that is not native glue.`);
49583
+ }
49584
+ }
49585
+ var isLineSheet2 = (shape) => ENDS2.some((name3) => cells(shape).has(name3));
49586
+ function planLineCopy(shape, code = "UNSUPPORTED_DUPLICATE") {
49587
+ proveLocalLine(shape);
49588
+ assertEndFormulas((name3) => cells(shape).get(name3), code);
49589
+ const local = cells(shape);
49590
+ return { x: numeric(local.get("PinX")), y: numeric(local.get("PinY")) };
49591
+ }
49592
+ var shift2 = (node3, delta, name3) => {
49593
+ if (!node3) fail("UNSUPPORTED_DUPLICATE", `The line has no local ${name3}.`);
49594
+ const value3 = numeric(node3);
49595
+ node3.setAttribute("V", String(Object.is(value3 + delta, -0) ? 0 : value3 + delta));
49596
+ node3.removeAttribute("E");
49597
+ };
49598
+ function finishLineCopy(shape, dx, dy) {
49599
+ const local = cells(shape);
49600
+ for (const name3 of ENDS2) {
49601
+ const node3 = local.get(name3);
49602
+ const formula2 = executableCellFormula(attribute2(node3, "F"));
49603
+ if (formula2 && isNativeGlueCell(name3, formula2)) node3.removeAttribute("F");
49604
+ shift2(node3, name3.endsWith("X") ? dx : dy, name3);
49605
+ }
49606
+ shift2(local.get("PinX"), dx, "PinX");
49607
+ shift2(local.get("PinY"), dy, "PinY");
49608
+ }
49609
+ var isStencilConnector2 = (target2) => ENDS2.some((name3) => instanceCell(target2, name3));
49610
+ function planConnectorCopy(target2, code = "UNSUPPORTED_DUPLICATE") {
49611
+ const local = cells(target2.instance);
49612
+ for (const name3 of [...ENDS2, "PinX", "PinY"]) {
49613
+ const node3 = local.get(name3);
49614
+ if (!node3?.hasAttribute("V") || node3.hasAttribute("E"))
49615
+ fail(code, `The stencil connector has no usable local ${name3}.`);
49616
+ numeric(node3);
49617
+ }
49618
+ assertEndFormulas((name3) => local.get(name3), code);
49619
+ return { x: numeric(local.get("PinX")), y: numeric(local.get("PinY")) };
49620
+ }
49621
+ function finishConnectorCopy(shape, id3, dx, dy) {
49622
+ const local = cells(shape);
49623
+ for (const name3 of ENDS2) shift2(local.get(name3), name3.endsWith("X") ? dx : dy, name3);
49624
+ shift2(local.get("PinX"), dx, "PinX");
49625
+ shift2(local.get("PinY"), dy, "PinY");
49626
+ for (const name3 of ["BegTrigger", "EndTrigger"]) {
49627
+ const node3 = local.get(name3);
49628
+ if (!node3) continue;
49629
+ node3.setAttribute("F", visioGlueTrigger(id3));
49630
+ node3.setAttribute("V", "1");
49631
+ }
49632
+ }
49633
+ var CLEARANCE = 0.25;
49634
+ var endsBox = (shape, dx, dy) => {
49635
+ const local = cells(shape);
49636
+ const x = [numeric(local.get("BeginX")) + dx, numeric(local.get("EndX")) + dx];
49637
+ const y = [numeric(local.get("BeginY")) + dy, numeric(local.get("EndY")) + dy];
49638
+ return {
49639
+ minX: Math.min(...x) - CLEARANCE,
49640
+ maxX: Math.max(...x) + CLEARANCE,
49641
+ minY: Math.min(...y) - CLEARANCE,
49642
+ maxY: Math.max(...y) + CLEARANCE
49643
+ };
49644
+ };
49645
+ function assertConnectorCopyApart(root2, copies, dx, dy, code = "UNSUPPORTED_DUPLICATE") {
49646
+ const boxes = copies.map((shape) => endsBox(shape, dx, dy));
49647
+ for (const container of children2(root2, "Shapes"))
49648
+ for (const other of children2(container, "Shape")) {
49649
+ const local = cells(other);
49650
+ const formula2 = executableCellFormula(attribute2(local.get("BeginX"), "F")) ?? "";
49651
+ if (!/^_WALKGLUE\(/i.test(formula2)) continue;
49652
+ const box4 = endsBox(other, 0, 0);
49653
+ for (const copy8 of boxes)
49654
+ if (copy8.minX <= box4.maxX && box4.minX <= copy8.maxX && copy8.minY <= box4.maxY && box4.minY <= copy8.maxY)
49655
+ fail(
49656
+ code,
49657
+ "The copy of a connector would meet another connector, which Visio lays out again."
49658
+ );
49659
+ }
49660
+ }
49661
+
48767
49662
  // visio/edit-instance-duplicate.ts
48768
- async function planInstanceCopy(pkg, pageId2, sourceRoot, target2, offsetX, offsetY, code = "UNSUPPORTED_DUPLICATE") {
49663
+ async function planInstanceCopy(pkg, pageId2, sourceRoot, target2, offsetX, offsetY, code = "UNSUPPORTED_DUPLICATE", allowConnector = code === "UNSUPPORTED_DUPLICATE") {
48769
49664
  const id3 = attribute2(target2.instance, "ID");
48770
- if (["BeginX", "EndX"].some((name3) => instanceCell(target2, name3)) || connectRows(sourceRoot).some((row2) => attribute2(row2, "FromSheet") === id3))
49665
+ const connector2 = allowConnector && isStencilConnector2(target2);
49666
+ if (!connector2 && (isStencilConnector2(target2) || connectRows(sourceRoot).some((row2) => attribute2(row2, "FromSheet") === id3)))
48771
49667
  fail(code, "Lines and connectors that come from a stencil cannot be copied yet.");
48772
49668
  await assertInstanceUnlocked(pkg, pageId2, target2, ["LockSelect"], "selection");
49669
+ if (connector2) {
49670
+ const pin2 = planConnectorCopy(target2, code);
49671
+ const x2 = pin2.x + offsetX, y2 = pin2.y + offsetY;
49672
+ if (Math.abs(x2) > 1e6 || Math.abs(y2) > 1e6)
49673
+ fail(code, "Duplicated pins exceed coordinate limits.");
49674
+ return { x: x2, y: y2, connector: connector2 };
49675
+ }
48773
49676
  const pin = instancePin(target2);
48774
49677
  const x = pin.x + offsetX, y = pin.y + offsetY;
48775
49678
  if (Math.abs(x) > 1e6 || Math.abs(y) > 1e6)
48776
49679
  fail(code, "Duplicated pins exceed coordinate limits.");
48777
- return { x, y };
49680
+ return { x, y, connector: connector2 };
48778
49681
  }
48779
49682
  function finishInstanceCopy(clone, template, x, y, taken, check) {
48780
49683
  const mapping = /* @__PURE__ */ new Map();
@@ -48858,7 +49761,18 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48858
49761
  structural ||= !source || await shapeIsStructural(source, template);
48859
49762
  }
48860
49763
  await assertDuplicateScope(pkg, pagePaths, root2, newIds, check, structural);
48861
- const indexed = indexCells(detached ? /* @__PURE__ */ new Map([[sourcePageId, sourceRoot]]) : roots, { check });
49764
+ const glueTargets = new Set(
49765
+ children2(sourceRoot, "Connects").flatMap(
49766
+ (container2) => children2(container2, "Connect").map((row2) => attribute2(row2, "ToSheet"))
49767
+ )
49768
+ );
49769
+ const indexed = indexCells(detached ? /* @__PURE__ */ new Map([[sourcePageId, sourceRoot]]) : roots, {
49770
+ check,
49771
+ scope: "affected",
49772
+ glueShapes: new Set(
49773
+ pageShapes(sourceRoot).filter((shape) => glueTargets.has(attribute2(shape, "ID")))
49774
+ )
49775
+ });
48862
49776
  const evaluate = createVisioCellEvaluator(indexed, { check }, true);
48863
49777
  const containers = children2(root2, "Shapes");
48864
49778
  if (containers.length > 1) fail("INVALID_SHAPE_ID", "Duplicate Shapes containers.");
@@ -48872,6 +49786,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48872
49786
  if (value3 !== void 0) occupied.add(value3.toLowerCase());
48873
49787
  }
48874
49788
  const plans = [];
49789
+ const copied = new Set(edit.copies.map((copy8) => copy8.shapeId));
48875
49790
  let cloneNodes = 0, cloneCharacters = buildXml(root2).length;
48876
49791
  const size3 = (source) => {
48877
49792
  cloneNodes += source.getElementsByTagName("*").length + 1;
@@ -48888,6 +49803,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48888
49803
  "UNSUPPORTED_DUPLICATE"
48889
49804
  );
48890
49805
  if (stencil) {
49806
+ assertGlueDroppable(sourceRoot, copy8.shapeId, copied);
48891
49807
  const pin = await planInstanceCopy(
48892
49808
  pkg,
48893
49809
  edit.pageId,
@@ -48900,18 +49816,33 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48900
49816
  plans.push({
48901
49817
  source: stencil.instance,
48902
49818
  id: copy8.newShapeId,
48903
- ...pin,
49819
+ x: pin.x,
49820
+ y: pin.y,
49821
+ ...pin.connector ? { connector: true } : {},
48904
49822
  template: stencil.template
48905
49823
  });
48906
49824
  continue;
48907
49825
  }
49826
+ const line = pageShapes(sourceRoot).find((shape) => attribute2(shape, "ID") === copy8.shapeId);
49827
+ if (line && !line.hasAttribute("Master") && isLineSheet2(line)) {
49828
+ assertCloneLeaf(line);
49829
+ assertUnlayeredShape(line, document);
49830
+ assertShapeLocks(line, document, ["LockSelect"]);
49831
+ assertGlueDroppable(sourceRoot, copy8.shapeId, copied);
49832
+ const pin = planLineCopy(line);
49833
+ if (Math.abs(pin.x + edit.offsetX) > 1e6 || Math.abs(pin.y + edit.offsetY) > 1e6)
49834
+ fail("UNSUPPORTED_DUPLICATE", "Duplicated pins exceed coordinate limits.");
49835
+ size3(line);
49836
+ plans.push({ source: line, id: copy8.newShapeId, x: pin.x, y: pin.y, line: true });
49837
+ continue;
49838
+ }
48908
49839
  const source = admitted(sourceRoot, copy8.shapeId);
48909
49840
  assertCloneLeaf(source);
48910
49841
  assertUnlayeredShape(source, document);
48911
49842
  assertShapeLocks(source, document, ["LockSelect"]);
48912
- for (const connects of children2(sourceRoot, "Connects"))
48913
- for (const connection of children2(connects, "Connect"))
48914
- if (["FromSheet", "ToSheet"].some((name3) => attribute2(connection, name3) === copy8.shapeId))
49843
+ for (const connects2 of children2(sourceRoot, "Connects"))
49844
+ for (const connection of children2(connects2, "Connect"))
49845
+ if (attribute2(connection, "FromSheet") === copy8.shapeId)
48915
49846
  fail("UNSUPPORTED_DUPLICATE", "Glued shapes cannot be duplicated safely.");
48916
49847
  const x = numeric(formattingCell(source, "PinX")), y = numeric(formattingCell(source, "PinY"));
48917
49848
  for (const [name3, offset] of [
@@ -48926,6 +49857,9 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48926
49857
  size3(source);
48927
49858
  plans.push({ source, id: copy8.newShapeId, x: x + edit.offsetX, y: y + edit.offsetY });
48928
49859
  }
49860
+ const connectorSources = plans.filter((plan) => plan.connector).map((plan) => plan.source);
49861
+ if (connectorSources.length)
49862
+ assertConnectorCopyApart(root2, connectorSources, edit.offsetX, edit.offsetY);
48929
49863
  const order = new Map(
48930
49864
  children2(children2(sourceRoot, "Shapes")[0], "Shape").map((source, index2) => [source, index2])
48931
49865
  );
@@ -48936,6 +49870,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48936
49870
  check();
48937
49871
  const shape = root2.ownerDocument.importNode(plan.source, true);
48938
49872
  copyIdentity(shape, plan.id, names);
49873
+ if (plan.line) finishLineCopy(shape, edit.offsetX, edit.offsetY);
48939
49874
  for (const node3 of [shape, ...Array.from(shape.getElementsByTagName("*"))]) {
48940
49875
  const source = executableCellFormula(attribute2(node3, "F"));
48941
49876
  if (!source) continue;
@@ -48954,6 +49889,15 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48954
49889
  )
48955
49890
  );
48956
49891
  }
49892
+ if (plan.line) {
49893
+ container.appendChild(shape);
49894
+ continue;
49895
+ }
49896
+ if (plan.connector) {
49897
+ finishConnectorCopy(shape, plan.id, edit.offsetX, edit.offsetY);
49898
+ container.appendChild(shape);
49899
+ continue;
49900
+ }
48957
49901
  if (plan.template) {
48958
49902
  for (const id3 of newIds) ids.add(id3);
48959
49903
  finishInstanceCopy(shape, plan.template, plan.x, plan.y, ids, check);
@@ -48970,7 +49914,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48970
49914
  }
48971
49915
  container.appendChild(shape);
48972
49916
  }
48973
- const local = plans.filter((plan) => !plan.template);
49917
+ const local = plans.filter((plan) => !plan.template && !plan.line);
48974
49918
  if (changed.length) {
48975
49919
  await assertGeometryPackageScope(
48976
49920
  pkg,
@@ -49004,6 +49948,9 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
49004
49948
  }
49005
49949
  const dirty = /* @__PURE__ */ new Set([edit.pageId]);
49006
49950
  for (const id3 of recalculateVisioCells(roots, changed, { check })) dirty.add(id3);
49951
+ for (const plan of plans)
49952
+ if (!plan.line && !plan.connector)
49953
+ for (const id3 of rerouteBlockedConnectors(roots, edit.pageId, plan.id, check)) dirty.add(id3);
49007
49954
  return [...dirty];
49008
49955
  }
49009
49956
  function assertCloneLeaf(source) {
@@ -49334,9 +50281,10 @@ function deleteVisioShapes(roots, document, edits, check, instances = /* @__PURE
49334
50281
  }
49335
50282
  releaseStencilGlue(roots, removed);
49336
50283
  releaseDeletedGlue(roots, removed);
49337
- assertVisioShapesUnreferenced(roots, removed, { check });
50284
+ const frozen = assertVisioShapesUnreferenced(roots, removed, { check, freeze: true });
49338
50285
  check();
49339
50286
  for (const shape of shapes) shape.parentNode.removeChild(shape);
50287
+ freezeVisioCells(frozen);
49340
50288
  for (const pageId2 of removed.keys())
49341
50289
  for (const container of children2(roots.get(pageId2), "Connects"))
49342
50290
  if (!children2(container, "Connect").length) container.parentNode.removeChild(container);
@@ -49365,8 +50313,8 @@ function admittedShape(root2, document, shapeId2) {
49365
50313
  if (["1", "true"].includes(attribute2(shape, "Del") ?? "")) refuse3("The shape is deleted.");
49366
50314
  const local = cells(shape);
49367
50315
  if (isLineSheet(local)) refuse3("Lines and connectors (1D shapes) cannot change shape.");
49368
- for (const connects of children2(root2, "Connects"))
49369
- for (const connect of children2(connects, "Connect"))
50316
+ for (const connects2 of children2(root2, "Connects"))
50317
+ for (const connect of children2(connects2, "Connect"))
49370
50318
  if (["FromSheet", "ToSheet"].some((name3) => attribute2(connect, name3) === shapeId2))
49371
50319
  refuse3("Glued connectors would need rerouting, which is not supported yet.");
49372
50320
  if (children2(shape, "Section").some((section3) => attribute2(section3, "N") === "Controls"))
@@ -50809,8 +51757,8 @@ async function captureVisioClipboard(input, pageId2, shapeIds2, options2 = {}) {
50809
51757
  numeric(formattingCell(source, name3));
50810
51758
  evaluate(key({ pageId: pageId2, shapeId: id3, cell: name3 }));
50811
51759
  }
50812
- for (const connects of children2(root2, "Connects"))
50813
- for (const connection of children2(connects, "Connect"))
51760
+ for (const connects2 of children2(root2, "Connects"))
51761
+ for (const connection of children2(connects2, "Connect"))
50814
51762
  if (["FromSheet", "ToSheet"].some((name3) => attribute2(connection, name3) === id3))
50815
51763
  fail("UNSUPPORTED_CLIPBOARD", "Glued shapes cannot be captured safely.");
50816
51764
  }
@@ -51351,8 +52299,8 @@ function assertUnreferenced3(roots, shapeId2, check) {
51351
52299
  if (reference2.test(executableCellFormula(attribute2(cell, "F")) ?? ""))
51352
52300
  fail("UNSUPPORTED_GUIDE_EDIT", "A shape formula refers to this guide.");
51353
52301
  }
51354
- for (const connects of children2(root2, "Connects"))
51355
- for (const row2 of children2(connects, "Connect"))
52302
+ for (const connects2 of children2(root2, "Connects"))
52303
+ for (const row2 of children2(connects2, "Connect"))
51356
52304
  if (attribute2(row2, "ToSheet") === shapeId2 || attribute2(row2, "FromSheet") === shapeId2)
51357
52305
  fail("UNSUPPORTED_GUIDE_EDIT", "Shapes are glued to this guide.");
51358
52306
  }
@@ -51729,6 +52677,7 @@ async function editVsdxTransaction(input, edits, options2, clock = {
51729
52677
  if (deleteOnly)
51730
52678
  for (const pageId2 of deleteVisioShapes(roots, document, deletions, check, instanceDeletes))
51731
52679
  dirty.set(pages.get(pageId2), roots.get(pageId2));
52680
+ const formulaDiagnostics = [];
51732
52681
  const noteTextSize = async (target2, root2) => {
51733
52682
  if (await measuresOwnText(root2, target2.shapeId, masterTemplate(pkg), check))
51734
52683
  clock.textSizes.push({ pageId: target2.pageId, shapeId: target2.shapeId });
@@ -51744,7 +52693,15 @@ async function editVsdxTransaction(input, edits, options2, clock = {
51744
52693
  roots.set(command2.pageId, root2);
51745
52694
  }
51746
52695
  if (command2.type === "replace-plain-text" || command2.type === "replace-text-ranges") {
51747
- if (await (command2.type === "replace-plain-text" ? replaceScopedPlainText(pkg, new Set(pages.values()), roots, document, command2, check) : replaceScopedTextRanges(pkg, new Set(pages.values()), roots, document, command2, check))) {
52696
+ if (await (command2.type === "replace-plain-text" ? replaceScopedPlainText(
52697
+ pkg,
52698
+ new Set(pages.values()),
52699
+ roots,
52700
+ document,
52701
+ command2,
52702
+ check,
52703
+ formulaDiagnostics
52704
+ ) : replaceScopedTextRanges(pkg, new Set(pages.values()), roots, document, command2, check))) {
51748
52705
  dirty.set(path3, root2);
51749
52706
  textChanged = true;
51750
52707
  await noteTextSize(command2, root2);
@@ -51890,6 +52847,7 @@ async function editVsdxTransaction(input, edits, options2, clock = {
51890
52847
  bytes,
51891
52848
  changedParts: [...dirty.keys()],
51892
52849
  diagnostics: [
52850
+ ...formulaDiagnostics,
51893
52851
  ...pasteChanged ? [
51894
52852
  {
51895
52853
  code: "edit-paste-experimental",