ooxml-core 1.30.1 → 1.32.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 (418) hide show
  1. package/dist/{PptxHandler-KKLAYUGQ.mjs → PptxHandler-QY5VL3CY.mjs} +2 -2
  2. package/dist/PptxHandler-SJ5ZUIUX.mjs +4 -0
  3. package/dist/{PptxHandler-DHQPVTUI.cjs → PptxHandler-TESZUH66.cjs} +3 -3
  4. package/dist/{PresentationBuilder-YYZYCKTZ.mjs → PresentationBuilder-3CH5TR4W.mjs} +2 -2
  5. package/dist/{PresentationBuilder-JORMF5CP.cjs → PresentationBuilder-5NFBUP7Y.cjs} +5 -5
  6. package/dist/{PresentationBuilder-Q2Z33LLM.mjs → PresentationBuilder-S6HXHKEJ.mjs} +2 -2
  7. package/dist/automation/index.cjs +6446 -3410
  8. package/dist/automation/index.mjs +6446 -3410
  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-GJDFCP2T.mjs → chunk-3H5UAJB3.mjs} +258 -155
  17. package/dist/{chunk-MKDONWNO.mjs → chunk-4R65YYAD.mjs} +32 -14
  18. package/dist/{chunk-KWJYMAEF.mjs → chunk-IOTGRLJH.mjs} +255 -152
  19. package/dist/{chunk-6FXOAMNL.mjs → chunk-N6424WKA.mjs} +1 -1
  20. package/dist/{chunk-WZJ25K7P.mjs → chunk-NAWLWKOJ.mjs} +1 -1
  21. package/dist/{chunk-DJ3CDTMX.mjs → chunk-O7SVHLD7.mjs} +23 -5
  22. package/dist/{chunk-CZXM4ZJH.cjs → chunk-Q6NM64J2.cjs} +23 -4
  23. package/dist/{chunk-FFJBOR2Y.mjs → chunk-UYMSFJQZ.mjs} +76 -4
  24. package/dist/{chunk-B4LXDHBX.cjs → chunk-X6VNUBES.cjs} +1419 -1316
  25. package/dist/collab/index.cjs +35 -4
  26. package/dist/collab/index.mjs +35 -4
  27. package/dist/collab/websocket-transport.d.ts +9 -1
  28. package/dist/collab/websocket-transport.d.ts.map +1 -1
  29. package/dist/diagram/index.cjs +8 -4
  30. package/dist/diagram/index.mjs +8 -4
  31. package/dist/docx/data-binding.d.ts +9 -0
  32. package/dist/docx/data-binding.d.ts.map +1 -0
  33. package/dist/docx/document-parts.d.ts +1 -0
  34. package/dist/docx/document-parts.d.ts.map +1 -1
  35. package/dist/docx/drawing.d.ts.map +1 -1
  36. package/dist/docx/embedded.cjs +1391 -613
  37. package/dist/docx/embedded.mjs +1391 -613
  38. package/dist/docx/index.cjs +1402 -622
  39. package/dist/docx/index.mjs +1402 -622
  40. package/dist/docx/inline-model.d.ts +2 -0
  41. package/dist/docx/inline-model.d.ts.map +1 -1
  42. package/dist/docx/layout/adapt-floats.d.ts.map +1 -1
  43. package/dist/docx/layout/adapt-table.d.ts.map +1 -1
  44. package/dist/docx/layout/adapter.d.ts.map +1 -1
  45. package/dist/docx/layout/equation-object.d.ts +1 -1
  46. package/dist/docx/layout/equation-object.d.ts.map +1 -1
  47. package/dist/docx/layout/floats.d.ts +1 -1
  48. package/dist/docx/layout/floats.d.ts.map +1 -1
  49. package/dist/docx/layout/flow-paragraph.d.ts +4 -0
  50. package/dist/docx/layout/flow-paragraph.d.ts.map +1 -1
  51. package/dist/docx/layout/flow-table.d.ts.map +1 -1
  52. package/dist/docx/layout/index.cjs +460 -207
  53. package/dist/docx/layout/index.mjs +460 -207
  54. package/dist/docx/layout/input.d.ts +12 -0
  55. package/dist/docx/layout/input.d.ts.map +1 -1
  56. package/dist/docx/layout/nested-frame-profile.d.ts +3 -1
  57. package/dist/docx/layout/nested-frame-profile.d.ts.map +1 -1
  58. package/dist/docx/layout/page-cursor.d.ts +11 -2
  59. package/dist/docx/layout/page-cursor.d.ts.map +1 -1
  60. package/dist/docx/layout/paragraph-fragments.d.ts.map +1 -1
  61. package/dist/docx/layout/paragraph-layout.d.ts +5 -0
  62. package/dist/docx/layout/paragraph-layout.d.ts.map +1 -1
  63. package/dist/docx/layout/result.d.ts +4 -0
  64. package/dist/docx/layout/result.d.ts.map +1 -1
  65. package/dist/docx/layout/section-flow.d.ts +2 -0
  66. package/dist/docx/layout/section-flow.d.ts.map +1 -1
  67. package/dist/docx/layout/table-layout.d.ts +4 -14
  68. package/dist/docx/layout/table-layout.d.ts.map +1 -1
  69. package/dist/docx/layout/table-merged-rows.d.ts +21 -0
  70. package/dist/docx/layout/table-merged-rows.d.ts.map +1 -0
  71. package/dist/docx/layout/table-row-split.d.ts +16 -0
  72. package/dist/docx/layout/table-row-split.d.ts.map +1 -0
  73. package/dist/docx/layout/wrap.d.ts +2 -0
  74. package/dist/docx/layout/wrap.d.ts.map +1 -1
  75. package/dist/docx/load/index.cjs +1405 -627
  76. package/dist/docx/load/index.mjs +1405 -627
  77. package/dist/docx/model-paragraph.d.ts +4 -1
  78. package/dist/docx/model-paragraph.d.ts.map +1 -1
  79. package/dist/docx/model.d.ts +24 -1
  80. package/dist/docx/model.d.ts.map +1 -1
  81. package/dist/docx/paragraph-properties.d.ts.map +1 -1
  82. package/dist/docx/paragraph-styles.d.ts.map +1 -1
  83. package/dist/docx/parse-table.d.ts.map +1 -1
  84. package/dist/docx/parse.d.ts.map +1 -1
  85. package/dist/docx/run-segmentation.d.ts.map +1 -1
  86. package/dist/docx/save-modified.d.ts +4 -0
  87. package/dist/docx/save-modified.d.ts.map +1 -0
  88. package/dist/docx/save.d.ts +2 -2
  89. package/dist/docx/save.d.ts.map +1 -1
  90. package/dist/docx/style-formatting-package.d.ts +9 -0
  91. package/dist/docx/style-formatting-package.d.ts.map +1 -0
  92. package/dist/docx/style-numbering-package.d.ts +4 -1
  93. package/dist/docx/style-numbering-package.d.ts.map +1 -1
  94. package/dist/docx/table-grid.d.ts +35 -0
  95. package/dist/docx/table-grid.d.ts.map +1 -0
  96. package/dist/docx/table-structure-cells.d.ts +19 -0
  97. package/dist/docx/table-structure-cells.d.ts.map +1 -0
  98. package/dist/docx/table-structure-check.d.ts +12 -0
  99. package/dist/docx/table-structure-check.d.ts.map +1 -0
  100. package/dist/docx/table-structure-merge.d.ts +28 -0
  101. package/dist/docx/table-structure-merge.d.ts.map +1 -0
  102. package/dist/docx/table-structure.d.ts +30 -0
  103. package/dist/docx/table-structure.d.ts.map +1 -0
  104. package/dist/docx/ui/index.cjs +725 -260
  105. package/dist/docx/ui/index.d.ts +4 -0
  106. package/dist/docx/ui/index.d.ts.map +1 -1
  107. package/dist/docx/ui/index.mjs +711 -261
  108. package/dist/docx/ui/ribbon-action-ids.d.ts +1 -1
  109. package/dist/docx/ui/ribbon-action-ids.d.ts.map +1 -1
  110. package/dist/docx/ui/table-structure-guard.d.ts +2 -0
  111. package/dist/docx/ui/table-structure-guard.d.ts.map +1 -1
  112. package/dist/docx/word-content-control-docs.d.ts +5 -0
  113. package/dist/docx/word-content-control-docs.d.ts.map +1 -0
  114. package/dist/docx/word-corpus-gaps.d.ts +10 -0
  115. package/dist/docx/word-corpus-gaps.d.ts.map +1 -0
  116. package/dist/docx/word-measurer.d.ts +6 -0
  117. package/dist/docx/word-measurer.d.ts.map +1 -0
  118. package/dist/docx/word-spacing-docs.d.ts +12 -0
  119. package/dist/docx/word-spacing-docs.d.ts.map +1 -0
  120. package/dist/docx/word-table-docs.d.ts +9 -0
  121. package/dist/docx/word-table-docs.d.ts.map +1 -0
  122. package/dist/docx/write-drawing.d.ts.map +1 -1
  123. package/dist/docx/write-fallback.d.ts +5 -0
  124. package/dist/docx/write-fallback.d.ts.map +1 -0
  125. package/dist/docx/write-table-properties.d.ts +1 -0
  126. package/dist/docx/write-table-properties.d.ts.map +1 -1
  127. package/dist/docx/write-table-structure.d.ts +14 -0
  128. package/dist/docx/write-table-structure.d.ts.map +1 -0
  129. package/dist/docx/write-table.d.ts +3 -4
  130. package/dist/docx/write-table.d.ts.map +1 -1
  131. package/dist/geometry/index.cjs +16 -12
  132. package/dist/geometry/index.mjs +16 -12
  133. package/dist/geometry/preset-shape-definitions-table.d.ts.map +1 -1
  134. package/dist/index.cjs +38 -34
  135. package/dist/index.mjs +38 -34
  136. package/dist/math/index.cjs +22 -22
  137. package/dist/math/index.mjs +22 -22
  138. package/dist/math/omml-box-grouped.d.ts.map +1 -1
  139. package/dist/math/omml-box-layout.d.ts +3 -1
  140. package/dist/math/omml-box-layout.d.ts.map +1 -1
  141. package/dist/math/omml-box-structures.d.ts.map +1 -1
  142. package/dist/math/omml-box.d.ts +2 -0
  143. package/dist/math/omml-box.d.ts.map +1 -1
  144. package/dist/math/omml-svg.d.ts +6 -2
  145. package/dist/math/omml-svg.d.ts.map +1 -1
  146. package/dist/pptx/automation/index.cjs +295 -157
  147. package/dist/pptx/automation/index.d.ts +9 -3
  148. package/dist/pptx/automation/index.d.ts.map +1 -1
  149. package/dist/pptx/automation/index.mjs +6 -5
  150. package/dist/pptx/chunks/{index-PdM5zpmu.d.ts → index-D-FdgqrP.d.ts} +102 -3
  151. package/dist/pptx/chunks/index-D-FdgqrP.d.ts.map +1 -0
  152. package/dist/pptx/chunks/{index-BQDcu_0a.d.ts → index-DKybuHPT.d.ts} +51 -3
  153. package/dist/pptx/chunks/{index-BQDcu_0a.d.ts.map → index-DKybuHPT.d.ts.map} +1 -1
  154. package/dist/pptx/chunks/{index-CBV1oHN7.d.ts → index-DnWlmYCy.d.ts} +2 -2
  155. package/dist/pptx/chunks/{index-CBV1oHN7.d.ts.map → index-DnWlmYCy.d.ts.map} +1 -1
  156. package/dist/pptx/cli/index.cjs +294 -157
  157. package/dist/pptx/cli/index.mjs +4 -4
  158. package/dist/pptx/converter/index.cjs +8 -4
  159. package/dist/pptx/converter/index.d.ts +1 -1
  160. package/dist/pptx/converter/index.mjs +2 -2
  161. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  162. package/dist/pptx/editor/render/find-replace.d.ts +1 -1
  163. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  164. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  165. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  166. package/dist/pptx/index.cjs +380 -171
  167. package/dist/pptx/index.d.ts +4 -4
  168. package/dist/pptx/index.mjs +5 -5
  169. package/dist/pptx/node/index.d.ts +1 -1
  170. package/dist/teams/chat-rooms.d.ts.map +1 -1
  171. package/dist/teams/chat-view.d.ts +10 -1
  172. package/dist/teams/chat-view.d.ts.map +1 -1
  173. package/dist/teams/chat.d.ts +7 -0
  174. package/dist/teams/chat.d.ts.map +1 -1
  175. package/dist/teams/files.d.ts +1 -1
  176. package/dist/teams/files.d.ts.map +1 -1
  177. package/dist/teams/index.cjs +3471 -1223
  178. package/dist/teams/index.d.ts +4 -0
  179. package/dist/teams/index.d.ts.map +1 -1
  180. package/dist/teams/index.mjs +3435 -1223
  181. package/dist/teams/message-transfer.d.ts +1 -1
  182. package/dist/teams/message-transfer.d.ts.map +1 -1
  183. package/dist/teams/presence-controller.d.ts +18 -3
  184. package/dist/teams/presence-controller.d.ts.map +1 -1
  185. package/dist/teams/presence-meetings.d.ts +21 -0
  186. package/dist/teams/presence-meetings.d.ts.map +1 -0
  187. package/dist/teams/presence.d.ts +40 -2
  188. package/dist/teams/presence.d.ts.map +1 -1
  189. package/dist/teams/protocol.d.ts +30 -0
  190. package/dist/teams/protocol.d.ts.map +1 -0
  191. package/dist/teams/schema.d.ts +59 -0
  192. package/dist/teams/schema.d.ts.map +1 -0
  193. package/dist/teams/server-config.d.ts +19 -2
  194. package/dist/teams/server-config.d.ts.map +1 -1
  195. package/dist/teams/server-file-storage.d.ts +11 -1
  196. package/dist/teams/server-file-storage.d.ts.map +1 -1
  197. package/dist/teams/server-session.d.ts +2 -0
  198. package/dist/teams/server-session.d.ts.map +1 -1
  199. package/dist/teams/signaling.d.ts +2 -0
  200. package/dist/teams/signaling.d.ts.map +1 -1
  201. package/dist/teams/store.d.ts +14 -0
  202. package/dist/teams/store.d.ts.map +1 -1
  203. package/dist/teams/stored-file.d.ts +1 -1
  204. package/dist/teams/stored-file.d.ts.map +1 -1
  205. package/dist/teams/sync-transport.d.ts.map +1 -1
  206. package/dist/teams/validate-members.d.ts +28 -0
  207. package/dist/teams/validate-members.d.ts.map +1 -0
  208. package/dist/teams/validate-owned.d.ts +20 -0
  209. package/dist/teams/validate-owned.d.ts.map +1 -0
  210. package/dist/teams/validate-update.d.ts +70 -0
  211. package/dist/teams/validate-update.d.ts.map +1 -0
  212. package/dist/teams/view.d.ts +5 -0
  213. package/dist/teams/view.d.ts.map +1 -1
  214. package/dist/teams/workspace.d.ts +17 -2
  215. package/dist/teams/workspace.d.ts.map +1 -1
  216. package/dist/visio/connector-route-walk.d.ts +2 -0
  217. package/dist/visio/connector-route-walk.d.ts.map +1 -1
  218. package/dist/visio/edit-connector-reroute.d.ts.map +1 -1
  219. package/dist/visio/edit-connector.d.ts +2 -0
  220. package/dist/visio/edit-connector.d.ts.map +1 -1
  221. package/dist/visio/edit-delete.d.ts.map +1 -1
  222. package/dist/visio/edit-duplicate-line.d.ts +40 -0
  223. package/dist/visio/edit-duplicate-line.d.ts.map +1 -0
  224. package/dist/visio/edit-duplicate.d.ts.map +1 -1
  225. package/dist/visio/edit-formatting-scope.d.ts +5 -1
  226. package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
  227. package/dist/visio/edit-geometry.d.ts.map +1 -1
  228. package/dist/visio/edit-instance-duplicate.d.ts +2 -1
  229. package/dist/visio/edit-instance-duplicate.d.ts.map +1 -1
  230. package/dist/visio/edit-master-move.d.ts.map +1 -1
  231. package/dist/visio/edit-recalculate-index.d.ts +23 -0
  232. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  233. package/dist/visio/edit-recalculate-text.d.ts +12 -0
  234. package/dist/visio/edit-recalculate-text.d.ts.map +1 -0
  235. package/dist/visio/edit-recalculate-values.d.ts.map +1 -1
  236. package/dist/visio/edit-recalculate.d.ts +15 -3
  237. package/dist/visio/edit-recalculate.d.ts.map +1 -1
  238. package/dist/visio/edit-resize-anchor.d.ts.map +1 -1
  239. package/dist/visio/edit-stencil-connector-layout.d.ts +1 -1
  240. package/dist/visio/edit-stencil-connector-layout.d.ts.map +1 -1
  241. package/dist/visio/edit-text-scope.d.ts +4 -1
  242. package/dist/visio/edit-text-scope.d.ts.map +1 -1
  243. package/dist/visio/formula-analyze.d.ts +18 -0
  244. package/dist/visio/formula-analyze.d.ts.map +1 -0
  245. package/dist/visio/formula-bound.d.ts +4 -0
  246. package/dist/visio/formula-bound.d.ts.map +1 -0
  247. package/dist/visio/formula-evaluate.d.ts +2 -9
  248. package/dist/visio/formula-evaluate.d.ts.map +1 -1
  249. package/dist/visio/formula-extra-functions.d.ts +23 -0
  250. package/dist/visio/formula-extra-functions.d.ts.map +1 -0
  251. package/dist/visio/formula-indirect.d.ts +6 -0
  252. package/dist/visio/formula-indirect.d.ts.map +1 -0
  253. package/dist/visio/formula-master.d.ts +1 -0
  254. package/dist/visio/formula-master.d.ts.map +1 -1
  255. package/dist/visio/formula-operators.d.ts +6 -0
  256. package/dist/visio/formula-operators.d.ts.map +1 -0
  257. package/dist/visio/formula-text-functions.d.ts +5 -1
  258. package/dist/visio/formula-text-functions.d.ts.map +1 -1
  259. package/dist/visio/formula.d.ts +12 -0
  260. package/dist/visio/formula.d.ts.map +1 -1
  261. package/dist/visio/index.cjs +1359 -396
  262. package/dist/visio/index.mjs +1359 -396
  263. package/dist/visio/ui/index.cjs +1346 -383
  264. package/dist/visio/ui/index.mjs +1346 -383
  265. package/dist/xlsx/collab/apply.d.ts.map +1 -1
  266. package/dist/xlsx/collab/codec.d.ts +2 -0
  267. package/dist/xlsx/collab/codec.d.ts.map +1 -1
  268. package/dist/xlsx/collab/dirty.d.ts +4 -1
  269. package/dist/xlsx/collab/dirty.d.ts.map +1 -1
  270. package/dist/xlsx/collab/index.cjs +551 -106
  271. package/dist/xlsx/collab/index.mjs +551 -106
  272. package/dist/xlsx/collab/keyed.d.ts +36 -0
  273. package/dist/xlsx/collab/keyed.d.ts.map +1 -0
  274. package/dist/xlsx/collab/names.d.ts +2 -0
  275. package/dist/xlsx/collab/names.d.ts.map +1 -1
  276. package/dist/xlsx/collab/part-specs.d.ts +13 -0
  277. package/dist/xlsx/collab/part-specs.d.ts.map +1 -0
  278. package/dist/xlsx/collab/schema.d.ts +8 -0
  279. package/dist/xlsx/collab/schema.d.ts.map +1 -1
  280. package/dist/xlsx/collab/sheet-parts.d.ts +19 -0
  281. package/dist/xlsx/collab/sheet-parts.d.ts.map +1 -0
  282. package/dist/xlsx/collab/sheets.d.ts +6 -0
  283. package/dist/xlsx/collab/sheets.d.ts.map +1 -1
  284. package/dist/xlsx/collab/write.d.ts +3 -0
  285. package/dist/xlsx/collab/write.d.ts.map +1 -1
  286. package/dist/xlsx/edit/clipboard-areas.d.ts +17 -0
  287. package/dist/xlsx/edit/clipboard-areas.d.ts.map +1 -0
  288. package/dist/xlsx/edit/custom-views.d.ts +21 -0
  289. package/dist/xlsx/edit/custom-views.d.ts.map +1 -0
  290. package/dist/xlsx/edit/data-table.d.ts.map +1 -1
  291. package/dist/xlsx/edit/history.d.ts +1 -1
  292. package/dist/xlsx/edit/history.d.ts.map +1 -1
  293. package/dist/xlsx/edit/index.d.ts +2 -0
  294. package/dist/xlsx/edit/index.d.ts.map +1 -1
  295. package/dist/xlsx/edit/paste-selection.d.ts.map +1 -1
  296. package/dist/xlsx/edit/scenario-merge.d.ts +7 -0
  297. package/dist/xlsx/edit/scenario-merge.d.ts.map +1 -0
  298. package/dist/xlsx/edit/session.d.ts.map +1 -1
  299. package/dist/xlsx/edit/shift-data-tables.d.ts +7 -0
  300. package/dist/xlsx/edit/shift-data-tables.d.ts.map +1 -0
  301. package/dist/xlsx/edit/shift-scenarios.d.ts +7 -0
  302. package/dist/xlsx/edit/shift-scenarios.d.ts.map +1 -0
  303. package/dist/xlsx/edit/shift-sheet.d.ts.map +1 -1
  304. package/dist/xlsx/edit/sparkline-grouping.d.ts +10 -0
  305. package/dist/xlsx/edit/sparkline-grouping.d.ts.map +1 -0
  306. package/dist/xlsx/edit/types.d.ts +21 -0
  307. package/dist/xlsx/edit/types.d.ts.map +1 -1
  308. package/dist/xlsx/formula/ets-drift-compare.d.ts +19 -0
  309. package/dist/xlsx/formula/ets-drift-compare.d.ts.map +1 -0
  310. package/dist/xlsx/formula/ets-excel-compare.d.ts +36 -0
  311. package/dist/xlsx/formula/ets-excel-compare.d.ts.map +1 -0
  312. package/dist/xlsx/formula/ets-init-compare.d.ts +24 -0
  313. package/dist/xlsx/formula/ets-init-compare.d.ts.map +1 -0
  314. package/dist/xlsx/formula/ets-init-maps.d.ts +21 -0
  315. package/dist/xlsx/formula/ets-init-maps.d.ts.map +1 -0
  316. package/dist/xlsx/formula/functions/ets-core.d.ts +36 -0
  317. package/dist/xlsx/formula/functions/ets-core.d.ts.map +1 -0
  318. package/dist/xlsx/formula/functions/ets-grid.d.ts +15 -0
  319. package/dist/xlsx/formula/functions/ets-grid.d.ts.map +1 -0
  320. package/dist/xlsx/formula/functions/ets-init-chain.d.ts +11 -0
  321. package/dist/xlsx/formula/functions/ets-init-chain.d.ts.map +1 -0
  322. package/dist/xlsx/formula/functions/ets-init-four.d.ts +3 -0
  323. package/dist/xlsx/formula/functions/ets-init-four.d.ts.map +1 -0
  324. package/dist/xlsx/formula/functions/ets-init-short.d.ts +17 -0
  325. package/dist/xlsx/formula/functions/ets-init-short.d.ts.map +1 -0
  326. package/dist/xlsx/formula/functions/ets-init-states.d.ts +5 -0
  327. package/dist/xlsx/formula/functions/ets-init-states.d.ts.map +1 -0
  328. package/dist/xlsx/formula/functions/ets-init-three.d.ts +23 -0
  329. package/dist/xlsx/formula/functions/ets-init-three.d.ts.map +1 -0
  330. package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts +13 -0
  331. package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts.map +1 -0
  332. package/dist/xlsx/formula/functions/ets-init.d.ts +33 -0
  333. package/dist/xlsx/formula/functions/ets-init.d.ts.map +1 -0
  334. package/dist/xlsx/formula/functions/ets-input.d.ts +13 -0
  335. package/dist/xlsx/formula/functions/ets-input.d.ts.map +1 -0
  336. package/dist/xlsx/formula/functions/ets-search-map.d.ts +24 -0
  337. package/dist/xlsx/formula/functions/ets-search-map.d.ts.map +1 -0
  338. package/dist/xlsx/formula/functions/ets-search.d.ts +17 -0
  339. package/dist/xlsx/formula/functions/ets-search.d.ts.map +1 -0
  340. package/dist/xlsx/formula/functions/ets-season.d.ts +6 -0
  341. package/dist/xlsx/formula/functions/ets-season.d.ts.map +1 -0
  342. package/dist/xlsx/formula/functions/ets-validate.d.ts +16 -0
  343. package/dist/xlsx/formula/functions/ets-validate.d.ts.map +1 -0
  344. package/dist/xlsx/formula/functions/forecast-ets.d.ts +3 -0
  345. package/dist/xlsx/formula/functions/forecast-ets.d.ts.map +1 -0
  346. package/dist/xlsx/formula/functions/statistical.d.ts.map +1 -1
  347. package/dist/xlsx/index.cjs +5118 -2648
  348. package/dist/xlsx/index.mjs +5097 -2649
  349. package/dist/xlsx/layout/form-control-link.d.ts +20 -0
  350. package/dist/xlsx/layout/form-control-link.d.ts.map +1 -0
  351. package/dist/xlsx/layout/form-control-state.d.ts +49 -0
  352. package/dist/xlsx/layout/form-control-state.d.ts.map +1 -0
  353. package/dist/xlsx/layout/form-control-view.d.ts +11 -0
  354. package/dist/xlsx/layout/form-control-view.d.ts.map +1 -0
  355. package/dist/xlsx/layout/header-footer-edit.d.ts +4 -2
  356. package/dist/xlsx/layout/header-footer-edit.d.ts.map +1 -1
  357. package/dist/xlsx/layout/header-footer.d.ts +16 -0
  358. package/dist/xlsx/layout/header-footer.d.ts.map +1 -1
  359. package/dist/xlsx/layout/index.d.ts +5 -0
  360. package/dist/xlsx/layout/index.d.ts.map +1 -1
  361. package/dist/xlsx/layout/ref-evaluator.d.ts +6 -0
  362. package/dist/xlsx/layout/ref-evaluator.d.ts.map +1 -1
  363. package/dist/xlsx/layout/shape-paint.d.ts +25 -0
  364. package/dist/xlsx/layout/shape-paint.d.ts.map +1 -0
  365. package/dist/xlsx/layout/shape-view.d.ts +15 -0
  366. package/dist/xlsx/layout/shape-view.d.ts.map +1 -0
  367. package/dist/xlsx/load/index.cjs +2667 -1163
  368. package/dist/xlsx/load/index.mjs +2667 -1163
  369. package/dist/xlsx/model-custom-views.d.ts +33 -0
  370. package/dist/xlsx/model-custom-views.d.ts.map +1 -0
  371. package/dist/xlsx/model-shapes.d.ts +78 -0
  372. package/dist/xlsx/model-shapes.d.ts.map +1 -0
  373. package/dist/xlsx/model.d.ts +38 -1
  374. package/dist/xlsx/model.d.ts.map +1 -1
  375. package/dist/xlsx/read/custom-views.d.ts +5 -0
  376. package/dist/xlsx/read/custom-views.d.ts.map +1 -0
  377. package/dist/xlsx/read/drawing.d.ts.map +1 -1
  378. package/dist/xlsx/read/form-control.d.ts +14 -0
  379. package/dist/xlsx/read/form-control.d.ts.map +1 -0
  380. package/dist/xlsx/read/header-footer-images.d.ts +5 -0
  381. package/dist/xlsx/read/header-footer-images.d.ts.map +1 -0
  382. package/dist/xlsx/read/load.d.ts.map +1 -1
  383. package/dist/xlsx/read/shape.d.ts +5 -0
  384. package/dist/xlsx/read/shape.d.ts.map +1 -0
  385. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  386. package/dist/xlsx/read/workbook-part.d.ts +5 -1
  387. package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
  388. package/dist/xlsx/read/worksheet-children.d.ts +3 -0
  389. package/dist/xlsx/read/worksheet-children.d.ts.map +1 -0
  390. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  391. package/dist/xlsx/ui/commands/i18n/sparklines.d.ts.map +1 -1
  392. package/dist/xlsx/ui/commands/i18n/what-if.d.ts.map +1 -1
  393. package/dist/xlsx/ui/commands/what-if.d.ts +0 -1
  394. package/dist/xlsx/ui/commands/what-if.d.ts.map +1 -1
  395. package/dist/xlsx/ui/dialogs/forecast-sheet.d.ts +51 -0
  396. package/dist/xlsx/ui/dialogs/forecast-sheet.d.ts.map +1 -0
  397. package/dist/xlsx/ui/dialogs/scenario-summary.d.ts +15 -0
  398. package/dist/xlsx/ui/dialogs/scenario-summary.d.ts.map +1 -0
  399. package/dist/xlsx/ui/index.cjs +5088 -2399
  400. package/dist/xlsx/ui/index.d.ts +2 -0
  401. package/dist/xlsx/ui/index.d.ts.map +1 -1
  402. package/dist/xlsx/ui/index.mjs +5081 -2398
  403. package/dist/xlsx/ui/locales/de/grid.d.ts.map +1 -1
  404. package/dist/xlsx/ui/locales/en/grid.d.ts.map +1 -1
  405. package/dist/xlsx/ui/locales/es/grid.d.ts.map +1 -1
  406. package/dist/xlsx/ui/locales/fr/grid.d.ts.map +1 -1
  407. package/dist/xlsx/ui/locales/zh-CN/grid.d.ts.map +1 -1
  408. package/dist/xlsx/write/custom-views.d.ts +4 -0
  409. package/dist/xlsx/write/custom-views.d.ts.map +1 -0
  410. package/dist/xlsx/write/drawing.d.ts.map +1 -1
  411. package/dist/xlsx/write/form-control.d.ts +4 -0
  412. package/dist/xlsx/write/form-control.d.ts.map +1 -0
  413. package/dist/xlsx/write/sheet-data.d.ts.map +1 -1
  414. package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
  415. package/dist/xlsx/write/worksheet.d.ts.map +1 -1
  416. package/package.json +1 -1
  417. package/dist/PptxHandler-E4DDV3FQ.mjs +0 -4
  418. package/dist/pptx/chunks/index-PdM5zpmu.d.ts.map +0 -1
@@ -1759,11 +1759,11 @@ function inspectDeclaration(value3, encoding) {
1759
1759
  if (declarations.length) fail("INVALID_XML", "Invalid XML declaration attributes");
1760
1760
  }
1761
1761
  function decodeXmlAttribute(value3) {
1762
- const entities = { amp: "&", lt: "<", gt: ">", apos: "'", quot: '"' };
1762
+ const entities2 = { amp: "&", lt: "<", gt: ">", apos: "'", quot: '"' };
1763
1763
  return value3.replace(/[\t\r\n]/g, " ").replace(/&(amp|lt|gt|apos|quot|#x[\da-fA-F]+|#\d+);/g, (_, entity) => {
1764
1764
  if (entity.startsWith("#x")) return String.fromCodePoint(parseInt(entity.slice(2), 16));
1765
1765
  if (entity.startsWith("#")) return String.fromCodePoint(Number(entity.slice(1)));
1766
- return entities[entity] ?? "";
1766
+ return entities2[entity] ?? "";
1767
1767
  });
1768
1768
  }
1769
1769
  function inspectNamespaces(root2, check) {
@@ -2988,6 +2988,60 @@ function evaluateNumericFormulaFunction(name3, args) {
2988
2988
  return formulaFailure("unsupported", `Unsupported numeric function ${name3}`);
2989
2989
  }
2990
2990
 
2991
+ // visio/formula-extra-functions.ts
2992
+ var IGNORE_CASE = 1;
2993
+ var IGNORE_NONSPACE = 2;
2994
+ var IGNORE_SYMBOLS = 4;
2995
+ function strSameEx(a2, b, flags) {
2996
+ if (!Number.isInteger(flags) || flags < 0)
2997
+ return formulaFailure("value", "STRSAMEEX flags must be a whole number");
2998
+ if (flags & -8)
2999
+ return formulaFailure("unsupported", "STRSAMEEX with kana or width comparison flags");
3000
+ const fold = (text7) => {
3001
+ let result2 = text7;
3002
+ if (flags & IGNORE_NONSPACE) result2 = result2.normalize("NFD").replace(/\p{Mn}/gu, "");
3003
+ if (flags & IGNORE_SYMBOLS) result2 = result2.replace(/[\p{P}\p{S}\s]/gu, "");
3004
+ return flags & IGNORE_CASE ? result2.toLowerCase() : result2;
3005
+ };
3006
+ return fold(a2) === fold(b);
3007
+ }
3008
+ function formatNumberPicture(value3, picture) {
3009
+ if (value3.unit !== "scalar") return formulaFailure("unit", "FORMAT requires a plain number");
3010
+ const match = /^([#,0]*)(?:\.([0#]*))?(%?)$/.exec(picture);
3011
+ const integerPicture = match?.[1] ?? "";
3012
+ if (!match || !integerPicture.includes("0") || /0,*#/.test(integerPicture) || integerPicture.startsWith(",") || integerPicture.endsWith(",") || integerPicture.includes(",,") || /0#/.test(match[2] ?? ""))
3013
+ return formulaFailure("unsupported", `FORMAT picture "${picture}"`);
3014
+ const fractionPicture = match[2] ?? "", percent = match[3] === "%", grouped = integerPicture.includes(",");
3015
+ const minInteger = (integerPicture.match(/0/g) ?? []).length;
3016
+ const minFraction = (fractionPicture.match(/0/g) ?? []).length;
3017
+ const maxFraction = fractionPicture.length;
3018
+ const scaled = percent ? value3.value * 100 : value3.value;
3019
+ const factor = 10 ** maxFraction;
3020
+ const rounded = Math.sign(scaled) * Math.round(Math.abs(scaled) * factor + 1e-9) / factor;
3021
+ const [digits = "", decimals = ""] = Math.abs(rounded).toFixed(maxFraction).split(".");
3022
+ let whole = digits.replace(/^0+/, "").padStart(minInteger, "0");
3023
+ if (grouped) whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
3024
+ let fraction = decimals;
3025
+ while (fraction.length > minFraction && fraction.endsWith("0")) fraction = fraction.slice(0, -1);
3026
+ const negative = rounded < 0;
3027
+ return `${negative ? "-" : ""}${whole}${fraction ? `.${fraction}` : ""}${percent ? "%" : ""}`;
3028
+ }
3029
+ function visioDateSerial(year, month, day) {
3030
+ if (![year, month, day].every(Number.isInteger))
3031
+ return formulaFailure("value", "DATE requires whole numbers");
3032
+ if (year < 1 || year > 9999 || month < 1 || month > 12 || day < 1 || day > 31)
3033
+ return formulaFailure("value", "DATE is outside the calendar");
3034
+ const date2 = /* @__PURE__ */ new Date(0);
3035
+ date2.setUTCFullYear(year, month - 1, day);
3036
+ if (date2.getUTCMonth() !== month - 1) return formulaFailure("value", "DATE is not a real day");
3037
+ return (date2.getTime() - Date.UTC(1899, 11, 30)) / 864e5;
3038
+ }
3039
+ var angleToLocal = (frame, angle) => angle - frame.angle;
3040
+ function localToParent(frame, x, y) {
3041
+ const dx = x - frame.locPinX, dy = y - frame.locPinY, cos = Math.cos(frame.angle), sin = Math.sin(frame.angle);
3042
+ return [frame.pinX + dx * cos - dy * sin, frame.pinY + dx * sin + dy * cos];
3043
+ }
3044
+
2991
3045
  // visio/formula-text-functions.ts
2992
3046
  var textResultFunctions = /* @__PURE__ */ new Set([
2993
3047
  "MID",
@@ -2999,12 +3053,15 @@ var textResultFunctions = /* @__PURE__ */ new Set([
2999
3053
  "SUBSTITUTE",
3000
3054
  "REPLACE",
3001
3055
  "CHAR",
3002
- "INDEX"
3056
+ "INDEX",
3057
+ "FORMAT",
3058
+ "SHAPETEXT"
3003
3059
  ]);
3004
3060
  var textNumberFunctions = /* @__PURE__ */ new Set([
3005
3061
  "LEN",
3006
3062
  "FIND",
3007
3063
  "STRSAME",
3064
+ "STRSAMEEX",
3008
3065
  "LOOKUP"
3009
3066
  ]);
3010
3067
  var LIST_SEPARATOR = ";";
@@ -3020,6 +3077,7 @@ function exactInteger(context, node3, name3) {
3020
3077
  if (!Number.isInteger(value3.value)) return unsupported2(`${name3} with a fractional number`);
3021
3078
  return value3.value;
3022
3079
  }
3080
+ var isTheText = (node3) => node3.kind === "reference" && node3.reference.cell.toLowerCase() === "thetext";
3023
3081
  function evaluateFormulaText(node3, context, depth = 0) {
3024
3082
  context.tick();
3025
3083
  if (depth > 64) return formulaFailure("limit", "Formula evaluation limit");
@@ -3030,6 +3088,10 @@ function evaluateFormulaText(node3, context, depth = 0) {
3030
3088
  if (node3.kind === "string") return node3.value;
3031
3089
  if (node3.kind === "binary" && node3.operator === "&")
3032
3090
  return text7(node3.left, "&") + text7(node3.right, "&");
3091
+ if (node3.kind === "reference" && isTheText(node3)) {
3092
+ const read = context.textOf?.(node3.reference);
3093
+ return read === void 0 ? unsupported2("Text read from a cell") : read;
3094
+ }
3033
3095
  if (node3.kind !== "call") {
3034
3096
  let value3;
3035
3097
  try {
@@ -3051,6 +3113,12 @@ function evaluateFormulaText(node3, context, depth = 0) {
3051
3113
  if (value3.unit !== "scalar") return unsupported2("Text from a number with a unit");
3052
3114
  return String(value3.value);
3053
3115
  }
3116
+ if (name3 === "SHAPETEXT") {
3117
+ arity(1);
3118
+ const target2 = args[0];
3119
+ if (!isTheText(target2)) return unsupported2("SHAPETEXT of something other than TheText");
3120
+ return text7(target2, name3);
3121
+ }
3054
3122
  if (name3 === "MID") {
3055
3123
  arity(3);
3056
3124
  const source = text7(args[0], name3), start = integer(context, args[1], name3), length = integer(context, args[2], name3);
@@ -3105,6 +3173,10 @@ function evaluateFormulaText(node3, context, depth = 0) {
3105
3173
  if (code >= 128 && code <= 159) return unsupported2("CHAR in the Windows-1252 range");
3106
3174
  return String.fromCharCode(code);
3107
3175
  }
3176
+ if (name3 === "FORMAT") {
3177
+ arity(2);
3178
+ return formatNumberPicture(context.number(args[0]), text7(args[1], name3));
3179
+ }
3108
3180
  arity(2);
3109
3181
  const index2 = integer(context, args[0], name3);
3110
3182
  const items = text7(args[1], name3).split(LIST_SEPARATOR);
@@ -3137,6 +3209,11 @@ function evaluateTextNumberFunction(name3, args, context) {
3137
3209
  const ignoreCase = args[2] ? context.number(args[2]).value !== 0 : false;
3138
3210
  return scalar4(ignoreCase ? Number(a2.toLowerCase() === b.toLowerCase()) : Number(a2 === b));
3139
3211
  }
3212
+ if (name3 === "STRSAMEEX") {
3213
+ if (args.length === 4) return formulaFailure("unsupported", "STRSAMEEX with a locale");
3214
+ arity(3);
3215
+ return scalar4(Number(strSameEx(text7(0), text7(1), context.number(args[2]).value)));
3216
+ }
3140
3217
  arity(2);
3141
3218
  const wanted = text7(0).toLowerCase();
3142
3219
  return scalar4(
@@ -3144,6 +3221,23 @@ function evaluateTextNumberFunction(name3, args, context) {
3144
3221
  );
3145
3222
  }
3146
3223
 
3224
+ // visio/formula-indirect.ts
3225
+ var FRAME_INPUTS = {
3226
+ ANGLETOLOC: ["Angle", "FlipX", "FlipY"],
3227
+ LOCTOPAR: ["PinX", "PinY", "LocPinX", "LocPinY", "Angle", "FlipX", "FlipY"]
3228
+ };
3229
+ function literalIndirectTarget(node3) {
3230
+ if (node3.kind !== "call" || node3.args.length !== 1) return void 0;
3231
+ const address = node3.args[0];
3232
+ if (address.kind !== "string") return void 0;
3233
+ try {
3234
+ const target2 = parseVisioFormula(address.value);
3235
+ 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;
3236
+ } catch {
3237
+ return void 0;
3238
+ }
3239
+ }
3240
+
3147
3241
  // visio/formula-math-functions.ts
3148
3242
  var mathFormulaFunctions = /* @__PURE__ */ new Set([
3149
3243
  "ROUND",
@@ -3248,7 +3342,7 @@ function evaluateMathFormulaFunction(name3, args) {
3248
3342
  return formulaFailure("unsupported", `Unsupported function ${name3}`);
3249
3343
  }
3250
3344
 
3251
- // visio/formula-evaluate.ts
3345
+ // visio/formula-analyze.ts
3252
3346
  var supported = /* @__PURE__ */ new Set([
3253
3347
  "GUARD",
3254
3348
  "IF",
@@ -3270,6 +3364,11 @@ var supported = /* @__PURE__ */ new Set([
3270
3364
  "PNTY",
3271
3365
  "ISERROR",
3272
3366
  "IFERROR",
3367
+ "INDIRECT",
3368
+ "DATE",
3369
+ "ANGLETOLOC",
3370
+ "LOCTOPAR",
3371
+ "SHEETREF",
3273
3372
  ...textNumberFunctions,
3274
3373
  ...textResultFunctions,
3275
3374
  ...numericFormulaFunctions,
@@ -3322,10 +3421,11 @@ var staticUnsupported = /* @__PURE__ */ new Set([
3322
3421
  "MSOTINT",
3323
3422
  "SHADE",
3324
3423
  "LUMDIFF",
3325
- "MODULUS"
3424
+ "MODULUS",
3425
+ // Reads an argument of the master the shape was dropped from; pure, evaluated in master scope.
3426
+ "ARG"
3326
3427
  ]);
3327
3428
  var dynamic = /* @__PURE__ */ new Set([
3328
- "INDIRECT",
3329
3429
  "EVALCELL",
3330
3430
  "EVALTEXT",
3331
3431
  "DEPENDSON",
@@ -3342,6 +3442,19 @@ var dynamic = /* @__PURE__ */ new Set([
3342
3442
  "PAR"
3343
3443
  ]);
3344
3444
  var isClassifiedVisioFunction = (name3) => supported.has(name3) || staticUnsupported.has(name3) || dynamic.has(name3);
3445
+ var opaqueFunctions = /* @__PURE__ */ new Set([
3446
+ "EVALCELL",
3447
+ "EVALTEXT",
3448
+ "GETREF",
3449
+ "REF",
3450
+ "_SHEETCELL",
3451
+ // Structure lookups: the result changes when shapes are created, moved or reparented.
3452
+ "CONTAINERSHEETREF",
3453
+ "MEMBERSHEETREF",
3454
+ "CALLOUTTARGET",
3455
+ "PARENT",
3456
+ "PAR"
3457
+ ]);
3345
3458
  function traverse(ast, limits, visit) {
3346
3459
  const maxNodes = formulaLimit(limits.maxNodes, 1024), maxDepth = formulaLimit(limits.maxDepth, 64);
3347
3460
  const queue = [[ast, 0]];
@@ -3359,7 +3472,7 @@ function traverse(ast, limits, visit) {
3359
3472
  function analyzeVisioFormula(source, limits = {}) {
3360
3473
  const ast = typeof source === "string" ? parseVisioFormula(source, limits) : source;
3361
3474
  const references = /* @__PURE__ */ new Map(), unsupportedFunctions = /* @__PURE__ */ new Set();
3362
- let unsafe2 = false, guarded = false;
3475
+ let unsafe2 = false, opaque = false, guarded = false;
3363
3476
  traverse(ast, limits, (node3) => {
3364
3477
  if (node3.kind === "reference")
3365
3478
  references.set(
@@ -3369,9 +3482,23 @@ function analyzeVisioFormula(source, limits = {}) {
3369
3482
  if (node3.kind === "call") {
3370
3483
  const inputs = node3.name === "ISTHEMED" ? ["ColorSchemeIndex"] : ["THEMEVAL", "THEME"].includes(node3.name) ? themeInputs : [];
3371
3484
  for (const cell of inputs) references.set(`!${cell.toLowerCase()}`, { cell });
3485
+ for (const cell of FRAME_INPUTS[node3.name] ?? [])
3486
+ references.set(`!${cell.toLowerCase()}`, { cell });
3487
+ if (node3.name === "INDIRECT") {
3488
+ const target2 = literalIndirectTarget(node3);
3489
+ if (target2 && limits.literalIndirect)
3490
+ references.set(`${target2.shapeId ?? ""}!${target2.cell.toLowerCase()}`, target2);
3491
+ else {
3492
+ unsafe2 = true;
3493
+ opaque = true;
3494
+ }
3495
+ }
3372
3496
  if (!supported.has(node3.name)) unsupportedFunctions.add(node3.name);
3373
- if (dynamic.has(node3.name) || !supported.has(node3.name) && !staticUnsupported.has(node3.name))
3497
+ const shapeText2 = node3.name === "SHAPETEXT" && limits.shapeTextReads === true && node3.args.length === 1 && isTheText(node3.args[0]);
3498
+ if (dynamic.has(node3.name) && !shapeText2 || !supported.has(node3.name) && !staticUnsupported.has(node3.name))
3374
3499
  unsafe2 = true;
3500
+ if (opaqueFunctions.has(node3.name) || node3.name === "SHAPETEXT" && !shapeText2 || !supported.has(node3.name) && !staticUnsupported.has(node3.name) && !dynamic.has(node3.name) && node3.name !== "_SHEETCALL")
3501
+ opaque = true;
3375
3502
  if (node3.name === "GUARD") guarded = true;
3376
3503
  }
3377
3504
  });
@@ -3379,10 +3506,56 @@ function analyzeVisioFormula(source, limits = {}) {
3379
3506
  references: [...references.values()],
3380
3507
  unsupportedFunctions: [...unsupportedFunctions],
3381
3508
  dynamic: unsafe2,
3509
+ opaque,
3382
3510
  guarded
3383
3511
  };
3384
3512
  }
3385
- function binary(operator, a2, b) {
3513
+
3514
+ // visio/formula-bound.ts
3515
+ function evaluateBound(args, arg) {
3516
+ if (args.length < 5 || (args.length - 2) % 3 !== 0 || args.length > 302)
3517
+ return formulaFailure("arity", "Invalid BOUND argument count");
3518
+ const value3 = arg(0), type = arg(1);
3519
+ if (type.unit !== "scalar" || ![0, 1, 2].includes(type.value))
3520
+ return formulaFailure("value", "BOUND type must be 0, 1 or 2");
3521
+ if (type.value === 2) return value3;
3522
+ if (type.value === 1) {
3523
+ let current = value3.value, unit4 = value3.unit;
3524
+ for (let pass = 0; pass <= (args.length - 2) / 3; pass++) {
3525
+ let moved = false;
3526
+ for (let index2 = 2; index2 < args.length; index2 += 3) {
3527
+ if (arg(index2).value !== 0) continue;
3528
+ const a2 = arg(index2 + 1), b = arg(index2 + 2);
3529
+ unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, a2);
3530
+ unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, b);
3531
+ const low2 = Math.min(a2.value, b.value), high2 = Math.max(a2.value, b.value);
3532
+ if (current > low2 && current < high2) {
3533
+ current = current - low2 < high2 - current ? low2 : high2;
3534
+ moved = true;
3535
+ }
3536
+ }
3537
+ if (!moved) break;
3538
+ }
3539
+ return finiteFormulaValue({ value: current, unit: unit4 });
3540
+ }
3541
+ let nearest;
3542
+ let unit3 = value3.unit;
3543
+ for (let index2 = 2; index2 < args.length; index2 += 3) {
3544
+ if (arg(index2).value !== 0) continue;
3545
+ const a2 = arg(index2 + 1), b = arg(index2 + 2);
3546
+ unit3 = compatibleFormulaUnits({ value: value3.value, unit: unit3 }, a2);
3547
+ unit3 = compatibleFormulaUnits({ value: value3.value, unit: unit3 }, b);
3548
+ const low2 = Math.min(a2.value, b.value), high2 = Math.max(a2.value, b.value);
3549
+ if (value3.value >= low2 && value3.value <= high2) return finiteFormulaValue({ value: value3.value, unit: unit3 });
3550
+ const edge = value3.value < low2 ? low2 : high2;
3551
+ if (nearest === void 0 || Math.abs(edge - value3.value) < Math.abs(nearest - value3.value))
3552
+ nearest = edge;
3553
+ }
3554
+ return finiteFormulaValue({ value: nearest ?? value3.value, unit: unit3 });
3555
+ }
3556
+
3557
+ // visio/formula-operators.ts
3558
+ function binaryOperator(operator, a2, b) {
3386
3559
  let unit3;
3387
3560
  if (operator === "+" || operator === "-") {
3388
3561
  unit3 = compatibleFormulaUnits(a2, b);
@@ -3412,12 +3585,36 @@ function binary(operator, a2, b) {
3412
3585
  return formulaFailure("syntax", `Unsupported operator ${operator}`);
3413
3586
  return { value: comparisons[operator] ? 1 : 0, unit: "scalar" };
3414
3587
  }
3588
+ function evaluatedShapeFrame(sheet, resolve) {
3589
+ if (sheet.kind !== "call" || sheet.name !== "SHEETREF" || sheet.args.length)
3590
+ return formulaFailure("unsupported", "A sheet other than SHEETREF()");
3591
+ const read = (cell, fallback) => {
3592
+ try {
3593
+ return finiteFormulaValue(resolve({ cell })).value;
3594
+ } catch (error) {
3595
+ if (fallback === void 0) throw error;
3596
+ return fallback;
3597
+ }
3598
+ };
3599
+ if (read("FlipX", 0) !== 0 || read("FlipY", 0) !== 0)
3600
+ return formulaFailure("unsupported", "A coordinate conversion on a flipped shape");
3601
+ return {
3602
+ pinX: read("PinX"),
3603
+ pinY: read("PinY"),
3604
+ locPinX: read("LocPinX", 0),
3605
+ locPinY: read("LocPinY", 0),
3606
+ angle: read("Angle", 0)
3607
+ };
3608
+ }
3609
+
3610
+ // visio/formula-evaluate.ts
3415
3611
  function evaluateVisioFormula(source, resolve, limits = {}) {
3416
3612
  const ast = typeof source === "string" ? parseVisioFormula(source, limits) : source;
3417
3613
  const maxSteps = formulaLimit(limits.maxSteps, 8192), maxDepth = formulaLimit(limits.maxDepth, 64);
3418
3614
  traverse(ast, limits, () => {
3419
3615
  });
3420
3616
  let steps = 0;
3617
+ const shapeFrame = (sheet) => evaluatedShapeFrame(sheet, resolve);
3421
3618
  const evaluate = (node3, depth = 0) => {
3422
3619
  if (++steps > maxSteps || depth > maxDepth)
3423
3620
  return formulaFailure("limit", "Formula evaluation limit");
@@ -3441,7 +3638,7 @@ function evaluateVisioFormula(source, resolve, limits = {}) {
3441
3638
  else if (right2.unit === "length" && left.unit === "scalar" && node3.left.kind === "number")
3442
3639
  left = { ...left, unit: "length" };
3443
3640
  }
3444
- return binary(node3.operator, left, right2);
3641
+ return binaryOperator(node3.operator, left, right2);
3445
3642
  }
3446
3643
  const name3 = node3.name;
3447
3644
  if ((name3 === "TEXTWIDTH" || name3 === "TEXTHEIGHT") && limits.text) {
@@ -3470,18 +3667,57 @@ function evaluateVisioFormula(source, resolve, limits = {}) {
3470
3667
  return formulaFailure("context", `${name3} requires a valid document context`);
3471
3668
  return { value: value4, unit: "scalar" };
3472
3669
  }
3670
+ const textContext = {
3671
+ number: (child3) => evaluate(child3, depth + 1),
3672
+ ...limits.textOf ? { textOf: limits.textOf } : {},
3673
+ tick: () => {
3674
+ if (++steps > maxSteps) formulaFailure("limit", "Formula evaluation limit");
3675
+ }
3676
+ };
3473
3677
  if (textNumberFunctions.has(name3))
3474
- return evaluateTextNumberFunction(name3, node3.args, {
3475
- number: (child3) => evaluate(child3, depth + 1),
3476
- tick: () => {
3477
- if (++steps > maxSteps) formulaFailure("limit", "Formula evaluation limit");
3478
- }
3678
+ return evaluateTextNumberFunction(name3, node3.args, textContext);
3679
+ if (name3 === "INDIRECT") {
3680
+ arity(1);
3681
+ const target2 = parseVisioFormula(evaluateFormulaText(node3.args[0], textContext, 1));
3682
+ if (target2.kind !== "reference")
3683
+ return formulaFailure("value", "INDIRECT needs a cell address");
3684
+ return finiteFormulaValue(resolve(target2.reference));
3685
+ }
3686
+ if (name3 === "DATE") {
3687
+ arity(3);
3688
+ const [year, month, day] = node3.args.map((_, index2) => {
3689
+ const part = arg(index2);
3690
+ if (part.unit !== "scalar") return formulaFailure("unit", "DATE requires plain numbers");
3691
+ return part.value;
3479
3692
  });
3693
+ return { value: visioDateSerial(year, month, day), unit: "time" };
3694
+ }
3695
+ if (name3 === "SHEETREF" || name3 === "LOCTOPAR")
3696
+ return formulaFailure("unsupported", `${name3} does not return a number`);
3697
+ if (name3 === "ANGLETOLOC") {
3698
+ arity(2);
3699
+ const angle = arg(1);
3700
+ if (angle.unit !== "angle" && angle.unit !== "scalar")
3701
+ return formulaFailure("unit", "ANGLETOLOC requires an angle");
3702
+ return { value: angleToLocal(shapeFrame(node3.args[0]), angle.value), unit: "angle" };
3703
+ }
3480
3704
  if (textResultFunctions.has(name3) || name3 === "PNT")
3481
3705
  return formulaFailure("unsupported", `${name3} does not return a number`);
3482
3706
  if (name3 === "PNTX" || name3 === "PNTY") {
3483
3707
  arity(1);
3484
3708
  const point2 = node3.args[0];
3709
+ if (point2.kind === "call" && point2.name === "LOCTOPAR") {
3710
+ if (point2.args.length !== 3)
3711
+ return formulaFailure("arity", "Invalid LOCTOPAR argument count");
3712
+ const [x2, y2] = [1, 2].map((index2) => {
3713
+ const part = evaluate(point2.args[index2], depth + 2);
3714
+ if (part.unit !== "scalar" && part.unit !== "length")
3715
+ return formulaFailure("unit", "LOCTOPAR requires lengths");
3716
+ return part.value;
3717
+ });
3718
+ const parent = localToParent(shapeFrame(point2.args[0]), x2, y2);
3719
+ return finiteFormulaValue({ value: parent[name3 === "PNTX" ? 0 : 1], unit: "length" });
3720
+ }
3485
3721
  if (point2.kind !== "call" || point2.name !== "PNT")
3486
3722
  return formulaFailure("unsupported", `${name3} of something other than PNT(x,y)`);
3487
3723
  if (point2.args.length !== 2) return formulaFailure("arity", "Invalid PNT argument count");
@@ -3539,47 +3775,7 @@ function evaluateVisioFormula(source, resolve, limits = {}) {
3539
3775
  }
3540
3776
  return finiteFormulaValue(result2);
3541
3777
  }
3542
- if (name3 === "BOUND") {
3543
- if (node3.args.length < 5 || (node3.args.length - 2) % 3 !== 0 || node3.args.length > 302)
3544
- return formulaFailure("arity", "Invalid BOUND argument count");
3545
- const value4 = arg(0), type = arg(1);
3546
- if (type.unit !== "scalar" || ![0, 1, 2].includes(type.value))
3547
- return formulaFailure("value", "BOUND type must be 0, 1 or 2");
3548
- if (type.value === 2) return value4;
3549
- if (type.value === 1) {
3550
- let current = value4.value, unit4 = value4.unit;
3551
- for (let pass = 0; pass <= (node3.args.length - 2) / 3; pass++) {
3552
- let moved = false;
3553
- for (let index2 = 2; index2 < node3.args.length; index2 += 3) {
3554
- if (arg(index2).value !== 0) continue;
3555
- const a2 = arg(index2 + 1), b = arg(index2 + 2);
3556
- unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, a2);
3557
- unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, b);
3558
- const low2 = Math.min(a2.value, b.value), high2 = Math.max(a2.value, b.value);
3559
- if (current > low2 && current < high2) {
3560
- current = current - low2 < high2 - current ? low2 : high2;
3561
- moved = true;
3562
- }
3563
- }
3564
- if (!moved) break;
3565
- }
3566
- return finiteFormulaValue({ value: current, unit: unit4 });
3567
- }
3568
- let nearest;
3569
- let unit3 = value4.unit;
3570
- for (let index2 = 2; index2 < node3.args.length; index2 += 3) {
3571
- if (arg(index2).value !== 0) continue;
3572
- const a2 = arg(index2 + 1), b = arg(index2 + 2);
3573
- unit3 = compatibleFormulaUnits({ value: value4.value, unit: unit3 }, a2);
3574
- unit3 = compatibleFormulaUnits({ value: value4.value, unit: unit3 }, b);
3575
- const low2 = Math.min(a2.value, b.value), high2 = Math.max(a2.value, b.value);
3576
- if (value4.value >= low2 && value4.value <= high2) return finiteFormulaValue({ value: value4.value, unit: unit3 });
3577
- const edge = value4.value < low2 ? low2 : high2;
3578
- if (nearest === void 0 || Math.abs(edge - value4.value) < Math.abs(nearest - value4.value))
3579
- nearest = edge;
3580
- }
3581
- return finiteFormulaValue({ value: nearest ?? value4.value, unit: unit3 });
3582
- }
3778
+ if (name3 === "BOUND") return evaluateBound(node3.args, arg);
3583
3779
  if (name3 === "ATAN2") {
3584
3780
  arity(2);
3585
3781
  const y = arg(0), x = arg(1);
@@ -3729,14 +3925,18 @@ function parseVisioFormula(source, limits = {}) {
3729
3925
  offset += identifier[0].length;
3730
3926
  whitespace();
3731
3927
  if (source[offset] === "(") {
3732
- if (!/^[A-Za-z_][A-Za-z_0-9]*$/.test(identifier[0]))
3928
+ const qualified = /^Sheet\.(\d+)!([A-Za-z_][A-Za-z_0-9]*)$/i.exec(identifier[0]);
3929
+ if (!qualified && !/^[A-Za-z_][A-Za-z_0-9]*$/.test(identifier[0]))
3733
3930
  return formulaFailure("syntax", "Qualified function names are unsupported");
3734
3931
  offset++;
3735
3932
  const args = [];
3736
3933
  whitespace();
3737
3934
  if (source[offset] !== ")") {
3738
3935
  for (; ; ) {
3739
- args.push(expression(0, depth + 1));
3936
+ whitespace();
3937
+ args.push(
3938
+ /^[,)]/.test(source.slice(offset)) ? node3({ kind: "string", value: "" }) : expression(0, depth + 1)
3939
+ );
3740
3940
  whitespace();
3741
3941
  if (source[offset] !== ",") break;
3742
3942
  offset++;
@@ -3744,7 +3944,27 @@ function parseVisioFormula(source, limits = {}) {
3744
3944
  }
3745
3945
  if (source[offset++] !== ")")
3746
3946
  return formulaFailure("syntax", "Expected function closing parenthesis");
3747
- left = node3({ kind: "call", name: identifier[0].toUpperCase(), args });
3947
+ left = node3({
3948
+ kind: "call",
3949
+ name: (qualified ? qualified[2] : identifier[0]).toUpperCase(),
3950
+ args
3951
+ });
3952
+ if (qualified)
3953
+ left = node3({
3954
+ kind: "call",
3955
+ name: "_SHEETCALL",
3956
+ args: [node3({ kind: "string", value: qualified[1] }), left]
3957
+ });
3958
+ whitespace();
3959
+ const member2 = source[offset] === "!" && /^!([A-Za-z_][A-Za-z_0-9.]*)/.exec(source.slice(offset));
3960
+ if (member2) {
3961
+ offset += member2[0].length;
3962
+ left = node3({
3963
+ kind: "call",
3964
+ name: "_SHEETCELL",
3965
+ args: [left, node3({ kind: "string", value: member2[1] })]
3966
+ });
3967
+ }
3748
3968
  } else {
3749
3969
  const ref = /^Sheet\.(\d+)!(.+)$/i.exec(identifier[0]);
3750
3970
  left = node3({
@@ -4915,20 +5135,36 @@ function indexCells(roots2, options2) {
4915
5135
  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
4916
5136
  // (Visio's freshly dropped connector names its own sheet).
4917
5137
  !(/^(BegTrigger|EndTrigger)$/.test(cell) && isNativeGlueCell(cell, source))) {
5138
+ const lenient = options2.scope === "affected";
5139
+ const unprovable = (message, opaque) => {
5140
+ if (!lenient) fail("EDIT_UNKNOWN_DEPENDENCY", message);
5141
+ item2.unsafe = true;
5142
+ item2.refusal = message;
5143
+ if (opaque) item2.opaque = true;
5144
+ };
4918
5145
  try {
4919
5146
  item2.formula = parseVisioFormula(source);
4920
- const plain4 = analyzeVisioFormula(item2.formula);
5147
+ const plain4 = analyzeVisioFormula(item2.formula, {
5148
+ shapeTextReads: true,
5149
+ literalIndirect: true
5150
+ });
4921
5151
  const analysis = plain4.dynamic && textSizeFormula(item2.formula) || plain4;
4922
- if (analysis.dynamic)
4923
- fail(
4924
- "EDIT_DYNAMIC_DEPENDENCY",
4925
- "Dynamic ShapeSheet dependencies cannot be safely edited."
5152
+ if (analysis.dynamic) {
5153
+ if (!lenient)
5154
+ fail(
5155
+ "EDIT_DYNAMIC_DEPENDENCY",
5156
+ "Dynamic ShapeSheet dependencies cannot be safely edited."
5157
+ );
5158
+ unprovable(
5159
+ `${cell} on shape ${sheet.shapeId || "page"} has dynamic ShapeSheet dependencies that cannot be followed.`,
5160
+ "opaque" in analysis && analysis.opaque
4926
5161
  );
5162
+ }
4927
5163
  item2.dependencies = analysis.references.filter((ref) => !isBooleanLiteral(ref)).map((ref) => key({ pageId: pageId2, shapeId: ref.shapeId ?? sheet.shapeId, cell: ref.cell }));
4928
5164
  } catch (error) {
4929
- fail(
4930
- "EDIT_UNKNOWN_DEPENDENCY",
4931
- `Cannot prove ShapeSheet dependency closure: ${error instanceof Error ? error.message : "invalid formula"}`
5165
+ unprovable(
5166
+ `Cannot prove ShapeSheet dependency closure: ${error instanceof Error ? error.message : "invalid formula"}`,
5167
+ true
4932
5168
  );
4933
5169
  }
4934
5170
  }
@@ -5011,13 +5247,20 @@ function createVisioCellEvaluator(cells4, options2 = {}, verifyCaches = false) {
5011
5247
  if (!item2 || item2.unsafe && (!item2.node || !options2.masterMovePins?.has(item2.node) && !options2.groupRotationCells?.has(item2.node)))
5012
5248
  fail(
5013
5249
  "EDIT_UNSUPPORTED_DEPENDENCY",
5014
- "Affected formula references missing, inherited or grouped cells."
5250
+ item2?.refusal ? `Affected formula cannot be evaluated: ${item2.refusal}` : "Affected formula references missing, inherited or grouped cells."
5015
5251
  );
5016
5252
  if (item2.node?.hasAttribute("E"))
5017
5253
  fail("EDIT_FORMULA_ERROR", "Affected ShapeSheet cell has an error cache.");
5018
5254
  active.add(id3);
5255
+ try {
5256
+ return evaluateCell(id3, item2);
5257
+ } finally {
5258
+ active.delete(id3);
5259
+ }
5260
+ };
5261
+ const evaluateCell = (id3, item2) => {
5019
5262
  let result2;
5020
- const analysis = item2.formula ? analyzeVisioFormula(item2.formula) : void 0;
5263
+ const analysis = item2.formula ? analyzeVisioFormula(item2.formula, { literalIndirect: true }) : void 0;
5021
5264
  if (item2.formula && item2.node && analysis.unsupportedFunctions.length) {
5022
5265
  if (!textSizeFormula(item2.formula))
5023
5266
  fail("EDIT_UNSUPPORTED_FORMULA", "Affected formula uses unsupported functions.");
@@ -5033,6 +5276,9 @@ function createVisioCellEvaluator(cells4, options2 = {}, verifyCaches = false) {
5033
5276
  ),
5034
5277
  {
5035
5278
  ...options2.pageContext?.get(item2.pageId),
5279
+ ...options2.textOf ? {
5280
+ textOf: (ref) => options2.textOf(item2.pageId, ref.shapeId ?? item2.shapeId)
5281
+ } : {},
5036
5282
  onStep: () => {
5037
5283
  if (--steps < 0)
5038
5284
  fail("LIMIT_FORMULA_STEPS", "ShapeSheet dependency evaluation limit exceeded.");
@@ -5056,16 +5302,63 @@ function createVisioCellEvaluator(cells4, options2 = {}, verifyCaches = false) {
5056
5302
  if (Math.abs(cachedValue2.value - result2.value) > 1e-10 * Math.max(1, Math.abs(result2.value)))
5057
5303
  fail("EDIT_FORMULA_CACHE", "Source formula and numeric cache disagree.");
5058
5304
  }
5059
- active.delete(id3);
5060
5305
  values.set(id3, result2);
5061
5306
  return result2;
5062
5307
  };
5063
5308
  return evaluate;
5064
5309
  }
5065
5310
 
5311
+ // visio/edit-recalculate-text.ts
5312
+ function plainShapeText(root2, shapeId2) {
5313
+ if (!root2) return void 0;
5314
+ const pending2 = children2(children2(root2, "Shapes")[0], "Shape");
5315
+ while (pending2.length) {
5316
+ const shape = pending2.pop();
5317
+ if (attribute2(shape, "ID") === shapeId2) {
5318
+ if (shape.hasAttribute("Master") || shape.hasAttribute("MasterShape")) return void 0;
5319
+ if (children2(shape, "Section").some((section3) => attribute2(section3, "N") === "Field"))
5320
+ return void 0;
5321
+ const texts = children2(shape, "Text");
5322
+ if (texts.length > 1) return void 0;
5323
+ const node3 = texts[0];
5324
+ if (!node3) return "";
5325
+ const plain4 = Array.from(node3.childNodes).every(
5326
+ (item2) => item2.nodeType === 3 || item2.nodeType === 4
5327
+ );
5328
+ return plain4 ? decodeVisioPlainText(node3.textContent ?? "") : void 0;
5329
+ }
5330
+ pending2.push(...children2(children2(shape, "Shapes")[0], "Shape"));
5331
+ }
5332
+ return void 0;
5333
+ }
5334
+ var TEXT_READERS = /* @__PURE__ */ new Set([...textNumberFunctions, ...textResultFunctions]);
5335
+ function textReadFormula(source) {
5336
+ try {
5337
+ const ast = parseVisioFormula(source);
5338
+ const analysis = analyzeVisioFormula(ast, { shapeTextReads: true });
5339
+ if (analysis.dynamic || analysis.unsupportedFunctions.length) return false;
5340
+ const textResult = ast.kind === "string" || isTheText(ast) || ast.kind === "binary" && ast.operator === "&" || ast.kind === "call" && textResultFunctions.has(ast.name);
5341
+ if (textResult) return false;
5342
+ let reads = 0;
5343
+ const walk = (node3, parent) => {
5344
+ if (isTheText(node3)) {
5345
+ reads++;
5346
+ return parent?.kind === "call" && TEXT_READERS.has(parent.name);
5347
+ }
5348
+ if (node3.kind === "unary") return walk(node3.operand, node3);
5349
+ if (node3.kind === "binary") return walk(node3.left, node3) && walk(node3.right, node3);
5350
+ if (node3.kind === "call") return node3.args.every((arg) => walk(arg, node3));
5351
+ return true;
5352
+ };
5353
+ return walk(ast) && reads > 0;
5354
+ } catch {
5355
+ return false;
5356
+ }
5357
+ }
5358
+
5066
5359
  // visio/edit-recalculate.ts
5067
5360
  function recalculateVisioCells(roots2, changed, options2 = {}) {
5068
- const cells4 = indexCells(roots2, options2);
5361
+ const cells4 = indexCells(roots2, { scope: "affected", ...options2 });
5069
5362
  const reverse = /* @__PURE__ */ new Map();
5070
5363
  for (const [id3, item2] of cells4)
5071
5364
  for (const dependency of item2.dependencies) {
@@ -5074,6 +5367,8 @@ function recalculateVisioCells(roots2, changed, options2 = {}) {
5074
5367
  reverse.set(dependency, next);
5075
5368
  }
5076
5369
  const affected = new Set(changed.map(key));
5370
+ const editedPages = new Set(changed.map((cell) => cell.pageId));
5371
+ for (const [id3, item2] of cells4) if (item2.opaque && editedPages.has(item2.pageId)) affected.add(id3);
5077
5372
  const pending2 = [...affected];
5078
5373
  const maxAffected = bound(options2.maxAffectedCells, 1e4);
5079
5374
  for (let i = 0; i < pending2.length; i++) {
@@ -5086,13 +5381,29 @@ function recalculateVisioCells(roots2, changed, options2 = {}) {
5086
5381
  if (affected.size > maxAffected)
5087
5382
  fail("LIMIT_FORMULA_AFFECTED", "Affected ShapeSheet cell limit exceeded.");
5088
5383
  }
5089
- const evaluate = createVisioCellEvaluator(cells4, options2);
5384
+ const evaluate = createVisioCellEvaluator(cells4, {
5385
+ textOf: (pageId2, shapeId2) => plainShapeText(roots2.get(pageId2), shapeId2),
5386
+ ...options2
5387
+ });
5090
5388
  const values = /* @__PURE__ */ new Map();
5091
- for (const id3 of affected) values.set(id3, evaluate(id3));
5389
+ for (const id3 of affected) {
5390
+ if (!cells4.has(id3) && /,"thetext"]$/.test(id3)) continue;
5391
+ try {
5392
+ values.set(id3, evaluate(id3));
5393
+ } catch (error) {
5394
+ if (options2.cycles !== "keep" || !(error instanceof VisioPackageError) || error.code !== "EDIT_FORMULA_CYCLE")
5395
+ throw error;
5396
+ const cyclic = cells4.get(id3);
5397
+ options2.diagnostics?.push({
5398
+ code: "FORMULA_CYCLE",
5399
+ 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.`
5400
+ });
5401
+ }
5402
+ }
5092
5403
  const pages = /* @__PURE__ */ new Set();
5093
5404
  for (const id3 of affected) {
5094
5405
  const item2 = cells4.get(id3);
5095
- if (item2.node && item2.formula) {
5406
+ if (item2?.node && item2.formula && values.has(id3)) {
5096
5407
  const value3 = String(values.get(id3).value);
5097
5408
  if (item2.node.getAttribute("V") !== value3) {
5098
5409
  item2.node.setAttribute("V", value3);
@@ -5103,15 +5414,29 @@ function recalculateVisioCells(roots2, changed, options2 = {}) {
5103
5414
  return [...pages];
5104
5415
  }
5105
5416
  function assertVisioShapesUnreferenced(roots2, removed, options2 = {}) {
5106
- const cells4 = indexCells(roots2, options2);
5417
+ const cells4 = indexCells(roots2, { scope: "affected", ...options2 });
5418
+ const frozen = [];
5107
5419
  for (const cell of cells4.values()) {
5108
5420
  options2.check?.();
5421
+ if (cell.opaque && removed.has(cell.pageId) && !removed.get(cell.pageId).has(cell.shapeId))
5422
+ fail(
5423
+ "EDIT_REFERENCED_DELETE",
5424
+ `${cell.cell} on shape ${cell.shapeId || "page"} may read the removed shape through a dynamic dependency.`
5425
+ );
5109
5426
  if (removed.get(cell.pageId)?.has(cell.shapeId)) continue;
5110
5427
  if (cell.dependencies.some((id3) => {
5111
5428
  const parts = JSON.parse(id3);
5112
5429
  return removed.get(parts[0])?.has(parts[1]) ?? false;
5113
- }))
5114
- fail("EDIT_REFERENCED_DELETE", "Shape is referenced by a ShapeSheet formula.");
5430
+ })) {
5431
+ if (!options2.freeze || !cell.node || !cell.formula || cell.unsafe || cell.node.hasAttribute("E") || analyzeVisioFormula(cell.formula, { literalIndirect: true }).guarded || !Number.isFinite(
5432
+ visioFormulaCachedValue(
5433
+ cell.node.getAttribute("V") ?? "",
5434
+ cell.node.getAttribute("U") ?? void 0
5435
+ ).value
5436
+ ))
5437
+ fail("EDIT_REFERENCED_DELETE", "Shape is referenced by a ShapeSheet formula.");
5438
+ frozen.push(cell.node);
5439
+ }
5115
5440
  }
5116
5441
  for (const [pageId2, ids] of removed)
5117
5442
  for (const connections2 of children2(roots2.get(pageId2), "Connects"))
@@ -5120,12 +5445,16 @@ function assertVisioShapesUnreferenced(roots2, removed, options2 = {}) {
5120
5445
  if (["FromSheet", "ToSheet"].some((name3) => ids.has(attribute2(connection, name3) ?? "")))
5121
5446
  fail("EDIT_REFERENCED_DELETE", "Shape participates in a Connect record.");
5122
5447
  }
5448
+ return frozen;
5123
5449
  }
5450
+ var freezeVisioCells = (nodes) => {
5451
+ for (const node3 of nodes) node3.removeAttribute("F");
5452
+ };
5124
5453
  function assertVisioShapeUnreferenced(roots2, pageId2, shapeId2, options2 = {}) {
5125
- assertVisioShapesUnreferenced(roots2, /* @__PURE__ */ new Map([[pageId2, /* @__PURE__ */ new Set([shapeId2])]]), options2);
5454
+ return assertVisioShapesUnreferenced(roots2, /* @__PURE__ */ new Map([[pageId2, /* @__PURE__ */ new Set([shapeId2])]]), options2);
5126
5455
  }
5127
5456
  function createVisioDependencyQuery(roots2, options2 = {}) {
5128
- const cells4 = indexCells(roots2, options2);
5457
+ const cells4 = indexCells(roots2, { scope: "affected", ...options2 });
5129
5458
  return (source, targets) => {
5130
5459
  const wanted = new Set(targets.map(key));
5131
5460
  const seen = /* @__PURE__ */ new Set();
@@ -5140,7 +5469,7 @@ function createVisioDependencyQuery(roots2, options2 = {}) {
5140
5469
  if (seen.size > maxSteps) fail("LIMIT_FORMULA_STEPS", "Dependency analysis limit exceeded.");
5141
5470
  const item2 = cells4.get(id3);
5142
5471
  if (!item2 || item2.unsafe || item2.node?.hasAttribute("E")) return false;
5143
- if (item2.formula && analyzeVisioFormula(item2.formula).unsupportedFunctions.length)
5472
+ if (item2.formula && analyzeVisioFormula(item2.formula, { literalIndirect: true }).unsupportedFunctions.length)
5144
5473
  return false;
5145
5474
  if (wanted.has(id3)) found = true;
5146
5475
  else pending2.push(...item2.dependencies);
@@ -6180,7 +6509,7 @@ var VISIO_DEFAULT_TITLE = "Title";
6180
6509
  var ACCENT = { background: "Background Accent", border: "Border Accent" };
6181
6510
  function visioShade(color2, amount) {
6182
6511
  const value3 = Number.parseInt(color2.slice(1), 16);
6183
- const channel = (shift2) => Math.round((value3 >> shift2 & 255) * (1 - amount)).toString(16).padStart(2, "0");
6512
+ const channel = (shift3) => Math.round((value3 >> shift3 & 255) * (1 - amount)).toString(16).padStart(2, "0");
6184
6513
  return `#${channel(16)}${channel(8)}${channel(0)}`.toUpperCase();
6185
6514
  }
6186
6515
  function visioDecorationName(name3) {
@@ -8310,9 +8639,16 @@ function visioWalkPath(begin, end) {
8310
8639
  return horizontal3 ? [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];
8311
8640
  };
8312
8641
  let path3;
8313
- if (gapX >= -EPSILON2 && inside2(from.y, b.minY, b.maxY))
8314
- path3 = jog(side(begin, sx, 0), side(end, -sx, 0), true);
8315
- else if (gapY >= -EPSILON2 && inside2(from.x, b.minX, b.maxX))
8642
+ if (gapX >= -EPSILON2 && inside2(from.y, b.minY, b.maxY)) {
8643
+ const p = side(begin, sx, 0), q = side(end, -sx, 0);
8644
+ if (begin.shape?.floating && end.shape?.floating) {
8645
+ const y = (Math.max(a2.minY, b.minY) + Math.min(a2.maxY, b.maxY)) / 2;
8646
+ path3 = [
8647
+ { x: p.x, y },
8648
+ { x: q.x, y }
8649
+ ];
8650
+ } else path3 = jog(p, q, true);
8651
+ } else if (gapY >= -EPSILON2 && inside2(from.x, b.minX, b.maxX))
8316
8652
  path3 = jog(side(begin, 0, sy), side(end, 0, -sy), false);
8317
8653
  else if (gapY < -EPSILON2 || gapY < CHANNEL && gapX >= CHANNEL) {
8318
8654
  const p = side(begin, sx, 0);
@@ -15369,10 +15705,10 @@ async function* streamEntryGuarded(entry3, alreadyRead, limits) {
15369
15705
  }
15370
15706
  }
15371
15707
  function toBase64(bytes) {
15372
- let binary2 = "";
15708
+ let binary = "";
15373
15709
  for (let i = 0; i < bytes.length; i += 32768)
15374
- binary2 += String.fromCharCode(...bytes.subarray(i, i + 32768));
15375
- return btoa(binary2);
15710
+ binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
15711
+ return btoa(binary);
15376
15712
  }
15377
15713
  function guardZip(zip, limits = {}) {
15378
15714
  const r = resolveLimits(limits);
@@ -17816,6 +18152,332 @@ function parseStyles(xml, warnings) {
17816
18152
  return result2;
17817
18153
  }
17818
18154
 
18155
+ // xlsx/read/print-options.ts
18156
+ var KEYS = ["gridLines", "headings", "horizontalCentered", "verticalCentered"];
18157
+ function readPrintOptions(node3) {
18158
+ if (!node3) return void 0;
18159
+ const out = {};
18160
+ for (const key2 of KEYS) if (boolAttr(node3, key2)) out[key2] = true;
18161
+ return Object.keys(out).length ? out : void 0;
18162
+ }
18163
+
18164
+ // xlsx/read/password-hash.ts
18165
+ function modernHashAttributeNames(prefix2 = "") {
18166
+ const name3 = (base2) => prefix2 ? `${prefix2}${base2[0].toUpperCase()}${base2.slice(1)}` : base2;
18167
+ return {
18168
+ algorithmName: name3("algorithmName"),
18169
+ hashValue: name3("hashValue"),
18170
+ saltValue: name3("saltValue"),
18171
+ spinCount: name3("spinCount")
18172
+ };
18173
+ }
18174
+ function readModernHash(node3, prefix2 = "") {
18175
+ const names = modernHashAttributeNames(prefix2);
18176
+ const algorithmName = att(node3, names.algorithmName);
18177
+ const hashValue = att(node3, names.hashValue);
18178
+ const saltValue = att(node3, names.saltValue);
18179
+ if (!algorithmName || !hashValue || !saltValue) return void 0;
18180
+ const hash = { algorithmName, hashValue, saltValue };
18181
+ const spin = att(node3, names.spinCount);
18182
+ const spinCount = spin === void 0 || spin.trim() === "" ? Number.NaN : Number(spin);
18183
+ if (Number.isFinite(spinCount)) hash.spinCount = spinCount;
18184
+ return hash;
18185
+ }
18186
+
18187
+ // xlsx/read/sheet-props.ts
18188
+ var defaultSheetView = () => ({
18189
+ showGridLines: true,
18190
+ showHeaders: true,
18191
+ showZeros: true,
18192
+ rightToLeft: false,
18193
+ zoom: 100
18194
+ });
18195
+ function parseSqref(sqref) {
18196
+ if (!sqref) return [];
18197
+ return sqref.split(/\s+/).filter(Boolean).map((part) => parseRange(part)).filter((range2) => range2 !== void 0);
18198
+ }
18199
+ var readTabColor = (sheetPr, palette) => parseColor(xFirst(sheetPr, "tabColor"), palette);
18200
+ var readFitToPage = (sheetPr) => boolAttr(xFirst(sheetPr, "pageSetUpPr"), "fitToPage") ?? false;
18201
+ function readSheetView(sheetViews) {
18202
+ const view = defaultSheetView();
18203
+ const node3 = xFirst(sheetViews, "sheetView");
18204
+ if (!node3) return view;
18205
+ view.showGridLines = boolAttr(node3, "showGridLines", true);
18206
+ view.showHeaders = boolAttr(node3, "showRowColHeaders", true);
18207
+ view.showZeros = boolAttr(node3, "showZeros", true);
18208
+ view.rightToLeft = boolAttr(node3, "rightToLeft", false);
18209
+ view.zoom = numAttr(node3, "zoomScale") || 100;
18210
+ if (boolAttr(node3, "showFormulas")) view.showFormulas = true;
18211
+ const mode = att(node3, "view");
18212
+ if (mode === "pageLayout" || mode === "pageBreakPreview") view.mode = mode;
18213
+ const pane = xFirst(node3, "pane");
18214
+ const state = att(pane, "state");
18215
+ const frozen = pane && (state === "frozen" || state === "frozenSplit");
18216
+ if (frozen) {
18217
+ const rows = Math.max(0, Math.round(numAttr(pane, "ySplit") ?? 0));
18218
+ const cols = Math.max(0, Math.round(numAttr(pane, "xSplit") ?? 0));
18219
+ if (rows || cols) view.freeze = { rows, cols };
18220
+ }
18221
+ const topLeft = parseAddress(
18222
+ (frozen ? att(pane, "topLeftCell") : att(node3, "topLeftCell")) ?? ""
18223
+ );
18224
+ if (topLeft) view.topLeft = topLeft;
18225
+ const selections = xChildren(node3, "selection");
18226
+ const activePane = att(pane, "activePane") ?? "topLeft";
18227
+ const selection = selections.find((sel) => (att(sel, "pane") ?? "topLeft") === activePane) ?? selections[0];
18228
+ if (selection) {
18229
+ const ranges = parseSqref(att(selection, "sqref") ?? att(selection, "activeCell") ?? "A1");
18230
+ const active = parseAddress(att(selection, "activeCell") ?? "") ?? ranges[0]?.start ?? { row: 0, col: 0 };
18231
+ view.selection = {
18232
+ active,
18233
+ ranges: ranges.length ? ranges : [{ start: active, end: { ...active } }]
18234
+ };
18235
+ }
18236
+ return view;
18237
+ }
18238
+ var FORMAT_FLAGS = ["zeroHeight", "customHeight", "thickTop", "thickBottom"];
18239
+ function readSheetFormat(format5) {
18240
+ const result2 = {
18241
+ defaultRowHeight: numAttr(format5, "defaultRowHeight") ?? 15
18242
+ };
18243
+ const width = numAttr(format5, "defaultColWidth");
18244
+ if (width !== void 0) result2.defaultColWidth = width;
18245
+ const flags = {};
18246
+ for (const key2 of FORMAT_FLAGS) {
18247
+ const value3 = boolAttr(format5, key2);
18248
+ if (value3 !== void 0) flags[key2] = value3;
18249
+ }
18250
+ const base2 = numAttr(format5, "baseColWidth");
18251
+ if (base2 !== void 0) flags.baseColWidth = base2;
18252
+ if (Object.keys(flags).length) result2.format = flags;
18253
+ return result2;
18254
+ }
18255
+ function readColumns(cols, xfMap) {
18256
+ const out = [];
18257
+ for (const col of cols ? xChildren(cols, "col") : []) {
18258
+ const min = (numAttr(col, "min") ?? 1) - 1;
18259
+ const max = (numAttr(col, "max") ?? min + 1) - 1;
18260
+ const info = { min, max };
18261
+ const width = numAttr(col, "width");
18262
+ if (width !== void 0) info.width = width;
18263
+ if (boolAttr(col, "customWidth")) info.customWidth = true;
18264
+ if (boolAttr(col, "hidden")) info.hidden = true;
18265
+ const style2 = numAttr(col, "style");
18266
+ const styleId = style2 === void 0 ? 0 : xfMap[style2] ?? 0;
18267
+ if (styleId) info.styleId = styleId;
18268
+ const outline = numAttr(col, "outlineLevel");
18269
+ if (outline) info.outlineLevel = outline;
18270
+ if (boolAttr(col, "collapsed")) info.collapsed = true;
18271
+ if (boolAttr(col, "bestFit")) info.bestFit = true;
18272
+ out.push(info);
18273
+ }
18274
+ return out;
18275
+ }
18276
+ var MAIN_NS_DECL = /(?<=^<[^>]*) xmlns="http:\/\/schemas\.openxmlformats\.org\/spreadsheetml\/2006\/main"/;
18277
+ function readAutoFilter(node3) {
18278
+ const range2 = parseRange(att(node3, "ref") ?? "");
18279
+ if (!node3 || !range2) return void 0;
18280
+ const filter = { range: range2 };
18281
+ const columns = [];
18282
+ for (const column of xChildren(node3, "filterColumn")) {
18283
+ const entry3 = {
18284
+ offset: numAttr(column, "colId") ?? 0
18285
+ };
18286
+ const filters = xFirst(column, "filters");
18287
+ if (filters) {
18288
+ entry3.values = xChildren(filters, "filter").map((f) => att(f, "val") ?? "");
18289
+ if (boolAttr(filters, "blank")) entry3.blank = true;
18290
+ }
18291
+ entry3.sourceXml = outerXml(column).replace(MAIN_NS_DECL, "");
18292
+ columns.push(entry3);
18293
+ }
18294
+ if (columns.length) filter.columns = columns;
18295
+ return filter;
18296
+ }
18297
+ var HEADER_FOOTER_TEXT = {
18298
+ header: "oddHeader",
18299
+ footer: "oddFooter",
18300
+ evenHeader: "evenHeader",
18301
+ evenFooter: "evenFooter",
18302
+ firstHeader: "firstHeader",
18303
+ firstFooter: "firstFooter"
18304
+ };
18305
+ var HEADER_FOOTER_FLAGS = [
18306
+ "differentOddEven",
18307
+ "differentFirst",
18308
+ "scaleWithDoc",
18309
+ "alignWithMargins"
18310
+ ];
18311
+ function readHeaderFooter(node3) {
18312
+ const out = {};
18313
+ for (const key2 of HEADER_FOOTER_FLAGS) {
18314
+ const value3 = boolAttr(node3, key2);
18315
+ if (value3 !== void 0) out[key2] = value3;
18316
+ }
18317
+ for (const [key2, local] of Object.entries(HEADER_FOOTER_TEXT)) {
18318
+ const child3 = xFirst(node3, local);
18319
+ if (child3) out[key2] = xText(child3);
18320
+ }
18321
+ return out;
18322
+ }
18323
+ var ORIENTATIONS = /* @__PURE__ */ new Set(["portrait", "landscape"]);
18324
+ function readPageSetup(margins, setup, headerFooter, fitToPage) {
18325
+ const page = {};
18326
+ if (setup) {
18327
+ if (/^(1|true)$/.test(att(setup, "useFirstPageNumber") ?? "")) {
18328
+ page.firstPageNumber = numAttr(setup, "firstPageNumber") ?? 1;
18329
+ }
18330
+ const order = att(setup, "pageOrder");
18331
+ if (order === "downThenOver" || order === "overThenDown") page.pageOrder = order;
18332
+ const orientation = att(setup, "orientation");
18333
+ if (orientation && ORIENTATIONS.has(orientation))
18334
+ page.orientation = orientation;
18335
+ const paper = numAttr(setup, "paperSize");
18336
+ if (paper !== void 0) page.paperSize = paper;
18337
+ const scale = numAttr(setup, "scale");
18338
+ if (scale !== void 0) page.scale = scale;
18339
+ }
18340
+ if (fitToPage) {
18341
+ page.fitToWidth = numAttr(setup, "fitToWidth") ?? 1;
18342
+ page.fitToHeight = numAttr(setup, "fitToHeight") ?? 1;
18343
+ }
18344
+ if (margins) {
18345
+ const m = (name3, fallback) => numAttr(margins, name3) ?? fallback;
18346
+ page.margins = {
18347
+ left: m("left", 0.7),
18348
+ right: m("right", 0.7),
18349
+ top: m("top", 0.75),
18350
+ bottom: m("bottom", 0.75),
18351
+ header: m("header", 0.3),
18352
+ footer: m("footer", 0.3)
18353
+ };
18354
+ }
18355
+ if (headerFooter) Object.assign(page, readHeaderFooter(headerFooter));
18356
+ return Object.keys(page).length ? page : void 0;
18357
+ }
18358
+ var PROTECTION_META = /* @__PURE__ */ new Set([
18359
+ "sheet",
18360
+ "password",
18361
+ "algorithmName",
18362
+ "hashValue",
18363
+ "saltValue",
18364
+ "spinCount"
18365
+ ]);
18366
+ function readProtection(node3) {
18367
+ if (!node3) return void 0;
18368
+ const protection2 = { sheet: boolAttr(node3, "sheet", false) };
18369
+ const password = att(node3, "password");
18370
+ if (password) protection2.passwordHash = password;
18371
+ const modernHash = readModernHash(node3);
18372
+ if (modernHash) protection2.modernHash = modernHash;
18373
+ const allow = [];
18374
+ for (const attribute4 of Array.from(node3.attributes)) {
18375
+ if (PROTECTION_META.has(attribute4.name)) continue;
18376
+ if (attribute4.value === "0" || attribute4.value === "false") allow.push(attribute4.name);
18377
+ }
18378
+ if (allow.length) protection2.allow = allow.sort();
18379
+ return protection2;
18380
+ }
18381
+
18382
+ // xlsx/read/custom-views.ts
18383
+ var SHEET_VIEW_ATTRS = [
18384
+ "guid",
18385
+ "scale",
18386
+ "showGridLines",
18387
+ "showRowCol",
18388
+ "zeroValues",
18389
+ "topLeftCell",
18390
+ "view",
18391
+ "showFormulas",
18392
+ "hiddenRows",
18393
+ "hiddenColumns",
18394
+ "filter",
18395
+ "showAutoFilter",
18396
+ "fitToPage"
18397
+ ];
18398
+ var WORKBOOK_VIEW_KNOWN = ["name", "guid", "includePrintSettings", "includeHiddenRowCol"];
18399
+ function readCustomWorkbookViews(node3) {
18400
+ return xChildren(node3, "customWorkbookView").flatMap((view) => {
18401
+ const guid2 = att(view, "guid");
18402
+ if (!guid2) return [];
18403
+ const attrs = {};
18404
+ for (const attribute4 of Array.from(view.attributes))
18405
+ if (!WORKBOOK_VIEW_KNOWN.includes(attribute4.name) && !attribute4.name.startsWith("xmlns"))
18406
+ attrs[attribute4.name] = attribute4.value;
18407
+ return [
18408
+ {
18409
+ guid: guid2,
18410
+ name: att(view, "name") ?? "",
18411
+ includePrintSettings: boolAttr(view, "includePrintSettings", true),
18412
+ includeHiddenRowCol: boolAttr(view, "includeHiddenRowCol", true),
18413
+ attrs
18414
+ }
18415
+ ];
18416
+ });
18417
+ }
18418
+ var escape3 = (value3) => value3.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
18419
+ function asSheetViews(view) {
18420
+ const map = [
18421
+ ["scale", "zoomScale"],
18422
+ ["showGridLines", "showGridLines"],
18423
+ ["showRowCol", "showRowColHeaders"],
18424
+ ["zeroValues", "showZeros"],
18425
+ ["topLeftCell", "topLeftCell"],
18426
+ ["view", "view"],
18427
+ ["showFormulas", "showFormulas"]
18428
+ ];
18429
+ const attributes = map.flatMap(([from, to]) => {
18430
+ const value3 = att(view, from);
18431
+ return value3 === void 0 ? [] : [` ${to}="${escape3(value3)}"`];
18432
+ }).join("");
18433
+ const children3 = elements(view).filter((child3) => child3.localName === "pane" || child3.localName === "selection").map((child3) => outerXml(child3)).join("");
18434
+ return parseXml(
18435
+ `<sheetViews xmlns="${NS.x}"><sheetView${attributes}>${children3}</sheetView></sheetViews>`
18436
+ ).documentElement;
18437
+ }
18438
+ function readCustomSheetViews(node3) {
18439
+ return xChildren(node3, "customSheetView").flatMap((view) => {
18440
+ const guid2 = att(view, "guid");
18441
+ if (!guid2) return [];
18442
+ const child3 = (name3) => xChildren(view, name3)[0];
18443
+ const pageSetup = readPageSetup(
18444
+ child3("pageMargins"),
18445
+ child3("pageSetup"),
18446
+ child3("headerFooter"),
18447
+ boolAttr(view, "fitToPage", false)
18448
+ );
18449
+ const printOptions = readPrintOptions(child3("printOptions"));
18450
+ const filter = readAutoFilter(child3("autoFilter"));
18451
+ const attrs = {};
18452
+ for (const attribute4 of Array.from(view.attributes))
18453
+ if (!SHEET_VIEW_ATTRS.includes(attribute4.name) && !attribute4.name.startsWith("xmlns"))
18454
+ attrs[attribute4.name] = attribute4.value;
18455
+ const modelled = [
18456
+ "pane",
18457
+ "selection",
18458
+ "pageMargins",
18459
+ "printOptions",
18460
+ "pageSetup",
18461
+ "headerFooter",
18462
+ "autoFilter"
18463
+ ];
18464
+ return [
18465
+ {
18466
+ guid: guid2,
18467
+ view: readSheetView(asSheetViews(view)),
18468
+ ...boolAttr(view, "hiddenRows", false) ? { hiddenRows: true } : {},
18469
+ ...boolAttr(view, "hiddenColumns", false) ? { hiddenColumns: true } : {},
18470
+ ...filter ? { filter } : {},
18471
+ ...boolAttr(view, "showAutoFilter", false) ? { showAutoFilter: true } : {},
18472
+ ...pageSetup ? { pageSetup } : {},
18473
+ ...printOptions ? { printOptions } : {},
18474
+ attrs,
18475
+ extra: elements(view).filter((c2) => !modelled.includes(c2.localName ?? "")).map((c2) => outerXml(c2))
18476
+ }
18477
+ ];
18478
+ });
18479
+ }
18480
+
17819
18481
  // xlsx/read/formula-storage.ts
17820
18482
  function tokens(formula2) {
17821
18483
  try {
@@ -17913,30 +18575,20 @@ function stripFuturePrefixes(formula2) {
17913
18575
  return fromStoredSyntax(plain4);
17914
18576
  }
17915
18577
 
17916
- // xlsx/read/password-hash.ts
17917
- function modernHashAttributeNames(prefix2 = "") {
17918
- const name3 = (base2) => prefix2 ? `${prefix2}${base2[0].toUpperCase()}${base2.slice(1)}` : base2;
17919
- return {
17920
- algorithmName: name3("algorithmName"),
17921
- hashValue: name3("hashValue"),
17922
- saltValue: name3("saltValue"),
17923
- spinCount: name3("spinCount")
17924
- };
17925
- }
17926
- function readModernHash(node3, prefix2 = "") {
17927
- const names = modernHashAttributeNames(prefix2);
17928
- const algorithmName = att(node3, names.algorithmName);
17929
- const hashValue = att(node3, names.hashValue);
17930
- const saltValue = att(node3, names.saltValue);
17931
- if (!algorithmName || !hashValue || !saltValue) return void 0;
17932
- const hash = { algorithmName, hashValue, saltValue };
17933
- const spin = att(node3, names.spinCount);
17934
- const spinCount = spin === void 0 || spin.trim() === "" ? Number.NaN : Number(spin);
17935
- if (Number.isFinite(spinCount)) hash.spinCount = spinCount;
17936
- return hash;
17937
- }
17938
-
17939
18578
  // xlsx/read/workbook-part.ts
18579
+ var NAME_EXTRA_ATTRIBUTES = [
18580
+ "function",
18581
+ "vbProcedure",
18582
+ "xlm",
18583
+ "customMenu",
18584
+ "description",
18585
+ "help",
18586
+ "statusBar",
18587
+ "shortcutKey",
18588
+ "functionGroupId",
18589
+ "publishToServer",
18590
+ "workbookParameter"
18591
+ ];
17940
18592
  function parseWorkbookPart(xml) {
17941
18593
  const root2 = parseXml(xml, { label: "XLSX workbook" }).documentElement;
17942
18594
  const sheets = [];
@@ -17960,6 +18612,12 @@ function parseWorkbookPart(xml) {
17960
18612
  if (boolAttr(node3, "hidden")) name3.hidden = true;
17961
18613
  const comment = att(node3, "comment");
17962
18614
  if (comment) name3.comment = comment;
18615
+ const extra = {};
18616
+ for (const key2 of NAME_EXTRA_ATTRIBUTES) {
18617
+ const value3 = att(node3, key2);
18618
+ if (value3 !== void 0) extra[key2] = value3;
18619
+ }
18620
+ if (Object.keys(extra).length) name3.extra = extra;
17963
18621
  if (name3.name) definedNames.push(name3);
17964
18622
  }
17965
18623
  const view = xFirst(xFirst(root2, "bookViews"), "workbookView");
@@ -17973,7 +18631,9 @@ function parseWorkbookPart(xml) {
17973
18631
  delta: numAttr(calcPr, "iterateDelta") ?? 1e-3
17974
18632
  } : void 0;
17975
18633
  const oleSize = att(xFirst(root2, "oleSize"), "ref");
18634
+ const customViews = xFirst(root2, "customWorkbookViews");
17976
18635
  return {
18636
+ ...customViews ? { customViews: readCustomWorkbookViews(customViews) } : {},
17977
18637
  ...oleSize ? { oleSize } : {},
17978
18638
  ...iterate ? { iterate } : {},
17979
18639
  ...password ? { workbookPasswordHash: password } : {},
@@ -18007,9 +18667,9 @@ function parseFormula(fmla) {
18007
18667
  return { op, args };
18008
18668
  }
18009
18669
  function resolveOperand(token, variables) {
18010
- const num = Number(token);
18011
- if (Number.isFinite(num)) {
18012
- return num;
18670
+ const num2 = Number(token);
18671
+ if (Number.isFinite(num2)) {
18672
+ return num2;
18013
18673
  }
18014
18674
  const value3 = variables.get(token);
18015
18675
  if (value3 !== void 0) {
@@ -19682,18 +20342,18 @@ function groupTransform(group2, parent) {
19682
20342
  const ext = first(xfrm, "ext", NS.a);
19683
20343
  const chOff = first(xfrm, "chOff", NS.a);
19684
20344
  const chExt = first(xfrm, "chExt", NS.a);
19685
- const num = (element2, name3) => Number.parseInt(element2?.getAttribute(name3) ?? "", 10);
19686
- const cx = num(ext, "cx");
19687
- const cy = num(ext, "cy");
19688
- const chCx = num(chExt, "cx");
19689
- const chCy = num(chExt, "cy");
20345
+ const num2 = (element2, name3) => Number.parseInt(element2?.getAttribute(name3) ?? "", 10);
20346
+ const cx = num2(ext, "cx");
20347
+ const cy = num2(ext, "cy");
20348
+ const chCx = num2(chExt, "cx");
20349
+ const chCy = num2(chExt, "cy");
19690
20350
  if (!off || ![cx, cy, chCx, chCy].every(Number.isFinite) || chCx === 0 || chCy === 0)
19691
20351
  return parent;
19692
20352
  const scaleX = cx / chCx;
19693
20353
  const scaleY = cy / chCy;
19694
20354
  const local = {
19695
- offsetX: num(off, "x") - (num(chOff, "x") || 0) * scaleX,
19696
- offsetY: num(off, "y") - (num(chOff, "y") || 0) * scaleY,
20355
+ offsetX: num2(off, "x") - (num2(chOff, "x") || 0) * scaleX,
20356
+ offsetY: num2(off, "y") - (num2(chOff, "y") || 0) * scaleY,
19697
20357
  scaleX,
19698
20358
  scaleY
19699
20359
  };
@@ -20001,200 +20661,48 @@ async function resolveSmartArt(sheets, source, warn) {
20001
20661
  }
20002
20662
  }
20003
20663
 
20004
- // xlsx/read/sheet-props.ts
20005
- var defaultSheetView = () => ({
20006
- showGridLines: true,
20007
- showHeaders: true,
20008
- showZeros: true,
20009
- rightToLeft: false,
20010
- zoom: 100
20011
- });
20012
- function parseSqref(sqref) {
20013
- if (!sqref) return [];
20014
- return sqref.split(/\s+/).filter(Boolean).map((part) => parseRange(part)).filter((range2) => range2 !== void 0);
20015
- }
20016
- var readTabColor = (sheetPr, palette) => parseColor(xFirst(sheetPr, "tabColor"), palette);
20017
- var readFitToPage = (sheetPr) => boolAttr(xFirst(sheetPr, "pageSetUpPr"), "fitToPage") ?? false;
20018
- function readSheetView(sheetViews) {
20019
- const view = defaultSheetView();
20020
- const node3 = xFirst(sheetViews, "sheetView");
20021
- if (!node3) return view;
20022
- view.showGridLines = boolAttr(node3, "showGridLines", true);
20023
- view.showHeaders = boolAttr(node3, "showRowColHeaders", true);
20024
- view.showZeros = boolAttr(node3, "showZeros", true);
20025
- view.rightToLeft = boolAttr(node3, "rightToLeft", false);
20026
- view.zoom = numAttr(node3, "zoomScale") || 100;
20027
- if (boolAttr(node3, "showFormulas")) view.showFormulas = true;
20028
- const mode = att(node3, "view");
20029
- if (mode === "pageLayout" || mode === "pageBreakPreview") view.mode = mode;
20030
- const pane = xFirst(node3, "pane");
20031
- const state = att(pane, "state");
20032
- const frozen = pane && (state === "frozen" || state === "frozenSplit");
20033
- if (frozen) {
20034
- const rows = Math.max(0, Math.round(numAttr(pane, "ySplit") ?? 0));
20035
- const cols = Math.max(0, Math.round(numAttr(pane, "xSplit") ?? 0));
20036
- if (rows || cols) view.freeze = { rows, cols };
20037
- }
20038
- const topLeft = parseAddress(
20039
- (frozen ? att(pane, "topLeftCell") : att(node3, "topLeftCell")) ?? ""
20040
- );
20041
- if (topLeft) view.topLeft = topLeft;
20042
- const selections = xChildren(node3, "selection");
20043
- const activePane = att(pane, "activePane") ?? "topLeft";
20044
- const selection = selections.find((sel) => (att(sel, "pane") ?? "topLeft") === activePane) ?? selections[0];
20045
- if (selection) {
20046
- const ranges = parseSqref(att(selection, "sqref") ?? att(selection, "activeCell") ?? "A1");
20047
- const active = parseAddress(att(selection, "activeCell") ?? "") ?? ranges[0]?.start ?? { row: 0, col: 0 };
20048
- view.selection = {
20049
- active,
20050
- ranges: ranges.length ? ranges : [{ start: active, end: { ...active } }]
20051
- };
20052
- }
20053
- return view;
20054
- }
20055
- var FORMAT_FLAGS = ["zeroHeight", "customHeight", "thickTop", "thickBottom"];
20056
- function readSheetFormat(format5) {
20057
- const result2 = {
20058
- defaultRowHeight: numAttr(format5, "defaultRowHeight") ?? 15
20059
- };
20060
- const width = numAttr(format5, "defaultColWidth");
20061
- if (width !== void 0) result2.defaultColWidth = width;
20062
- const flags = {};
20063
- for (const key2 of FORMAT_FLAGS) {
20064
- const value3 = boolAttr(format5, key2);
20065
- if (value3 !== void 0) flags[key2] = value3;
20066
- }
20067
- const base2 = numAttr(format5, "baseColWidth");
20068
- if (base2 !== void 0) flags.baseColWidth = base2;
20069
- if (Object.keys(flags).length) result2.format = flags;
20070
- return result2;
20071
- }
20072
- function readColumns(cols, xfMap) {
20073
- const out = [];
20074
- for (const col of cols ? xChildren(cols, "col") : []) {
20075
- const min = (numAttr(col, "min") ?? 1) - 1;
20076
- const max = (numAttr(col, "max") ?? min + 1) - 1;
20077
- const info = { min, max };
20078
- const width = numAttr(col, "width");
20079
- if (width !== void 0) info.width = width;
20080
- if (boolAttr(col, "customWidth")) info.customWidth = true;
20081
- if (boolAttr(col, "hidden")) info.hidden = true;
20082
- const style2 = numAttr(col, "style");
20083
- const styleId = style2 === void 0 ? 0 : xfMap[style2] ?? 0;
20084
- if (styleId) info.styleId = styleId;
20085
- const outline = numAttr(col, "outlineLevel");
20086
- if (outline) info.outlineLevel = outline;
20087
- if (boolAttr(col, "collapsed")) info.collapsed = true;
20088
- if (boolAttr(col, "bestFit")) info.bestFit = true;
20089
- out.push(info);
20090
- }
20091
- return out;
20092
- }
20093
- var MAIN_NS_DECL = /(?<=^<[^>]*) xmlns="http:\/\/schemas\.openxmlformats\.org\/spreadsheetml\/2006\/main"/;
20094
- function readAutoFilter(node3) {
20095
- const range2 = parseRange(att(node3, "ref") ?? "");
20096
- if (!node3 || !range2) return void 0;
20097
- const filter = { range: range2 };
20098
- const columns = [];
20099
- for (const column of xChildren(node3, "filterColumn")) {
20100
- const entry3 = {
20101
- offset: numAttr(column, "colId") ?? 0
20102
- };
20103
- const filters = xFirst(column, "filters");
20104
- if (filters) {
20105
- entry3.values = xChildren(filters, "filter").map((f) => att(f, "val") ?? "");
20106
- if (boolAttr(filters, "blank")) entry3.blank = true;
20107
- }
20108
- entry3.sourceXml = outerXml(column).replace(MAIN_NS_DECL, "");
20109
- columns.push(entry3);
20110
- }
20111
- if (columns.length) filter.columns = columns;
20112
- return filter;
20113
- }
20114
- var HEADER_FOOTER_TEXT = {
20115
- header: "oddHeader",
20116
- footer: "oddFooter",
20117
- evenHeader: "evenHeader",
20118
- evenFooter: "evenFooter",
20119
- firstHeader: "firstHeader",
20120
- firstFooter: "firstFooter"
20121
- };
20122
- var HEADER_FOOTER_FLAGS = [
20123
- "differentOddEven",
20124
- "differentFirst",
20125
- "scaleWithDoc",
20126
- "alignWithMargins"
20664
+ // xlsx/read/worksheet-children.ts
20665
+ var WORKSHEET_CHILD_ORDER = [
20666
+ "sheetPr",
20667
+ "dimension",
20668
+ "sheetViews",
20669
+ "sheetFormatPr",
20670
+ "cols",
20671
+ "sheetData",
20672
+ "sheetCalcPr",
20673
+ "sheetProtection",
20674
+ "protectedRanges",
20675
+ "scenarios",
20676
+ "autoFilter",
20677
+ "sortState",
20678
+ "dataConsolidate",
20679
+ "customSheetViews",
20680
+ "mergeCells",
20681
+ "phoneticPr",
20682
+ "conditionalFormatting",
20683
+ "dataValidations",
20684
+ "hyperlinks",
20685
+ "printOptions",
20686
+ "pageMargins",
20687
+ "pageSetup",
20688
+ "headerFooter",
20689
+ "rowBreaks",
20690
+ "colBreaks",
20691
+ "customProperties",
20692
+ "cellWatches",
20693
+ "ignoredErrors",
20694
+ "smartTags",
20695
+ "drawing",
20696
+ "legacyDrawing",
20697
+ "legacyDrawingHF",
20698
+ "drawingHF",
20699
+ "picture",
20700
+ "oleObjects",
20701
+ "controls",
20702
+ "webPublishItems",
20703
+ "tableParts",
20704
+ "extLst"
20127
20705
  ];
20128
- function readHeaderFooter(node3) {
20129
- const out = {};
20130
- for (const key2 of HEADER_FOOTER_FLAGS) {
20131
- const value3 = boolAttr(node3, key2);
20132
- if (value3 !== void 0) out[key2] = value3;
20133
- }
20134
- for (const [key2, local] of Object.entries(HEADER_FOOTER_TEXT)) {
20135
- const child3 = xFirst(node3, local);
20136
- if (child3) out[key2] = xText(child3);
20137
- }
20138
- return out;
20139
- }
20140
- var ORIENTATIONS = /* @__PURE__ */ new Set(["portrait", "landscape"]);
20141
- function readPageSetup(margins, setup, headerFooter, fitToPage) {
20142
- const page = {};
20143
- if (setup) {
20144
- if (/^(1|true)$/.test(att(setup, "useFirstPageNumber") ?? "")) {
20145
- page.firstPageNumber = numAttr(setup, "firstPageNumber") ?? 1;
20146
- }
20147
- const order = att(setup, "pageOrder");
20148
- if (order === "downThenOver" || order === "overThenDown") page.pageOrder = order;
20149
- const orientation = att(setup, "orientation");
20150
- if (orientation && ORIENTATIONS.has(orientation))
20151
- page.orientation = orientation;
20152
- const paper = numAttr(setup, "paperSize");
20153
- if (paper !== void 0) page.paperSize = paper;
20154
- const scale = numAttr(setup, "scale");
20155
- if (scale !== void 0) page.scale = scale;
20156
- }
20157
- if (fitToPage) {
20158
- page.fitToWidth = numAttr(setup, "fitToWidth") ?? 1;
20159
- page.fitToHeight = numAttr(setup, "fitToHeight") ?? 1;
20160
- }
20161
- if (margins) {
20162
- const m = (name3, fallback) => numAttr(margins, name3) ?? fallback;
20163
- page.margins = {
20164
- left: m("left", 0.7),
20165
- right: m("right", 0.7),
20166
- top: m("top", 0.75),
20167
- bottom: m("bottom", 0.75),
20168
- header: m("header", 0.3),
20169
- footer: m("footer", 0.3)
20170
- };
20171
- }
20172
- if (headerFooter) Object.assign(page, readHeaderFooter(headerFooter));
20173
- return Object.keys(page).length ? page : void 0;
20174
- }
20175
- var PROTECTION_META = /* @__PURE__ */ new Set([
20176
- "sheet",
20177
- "password",
20178
- "algorithmName",
20179
- "hashValue",
20180
- "saltValue",
20181
- "spinCount"
20182
- ]);
20183
- function readProtection(node3) {
20184
- if (!node3) return void 0;
20185
- const protection2 = { sheet: boolAttr(node3, "sheet", false) };
20186
- const password = att(node3, "password");
20187
- if (password) protection2.passwordHash = password;
20188
- const modernHash = readModernHash(node3);
20189
- if (modernHash) protection2.modernHash = modernHash;
20190
- const allow = [];
20191
- for (const attribute4 of Array.from(node3.attributes)) {
20192
- if (PROTECTION_META.has(attribute4.name)) continue;
20193
- if (attribute4.value === "0" || attribute4.value === "false") allow.push(attribute4.name);
20194
- }
20195
- if (allow.length) protection2.allow = allow.sort();
20196
- return protection2;
20197
- }
20198
20706
 
20199
20707
  // xlsx/read/conditional.ts
20200
20708
  var CFVO_TYPES = /* @__PURE__ */ new Set(["min", "max", "num", "percent", "percentile", "formula"]);
@@ -23570,9 +24078,210 @@ function readSlicerFrame(content2, anchor, sourceXml) {
23570
24078
  return void 0;
23571
24079
  }
23572
24080
 
23573
- // xlsx/read/drawing.ts
24081
+ // xlsx/read/form-control.ts
24082
+ var TYPES2 = {
24083
+ checkbox: "checkbox",
24084
+ radio: "radio",
24085
+ drop: "dropdown",
24086
+ list: "list",
24087
+ button: "button",
24088
+ spin: "spin",
24089
+ scroll: "scroll",
24090
+ gbox: "groupBox",
24091
+ label: "label",
24092
+ edit: "edit"
24093
+ };
24094
+ function readFormControlFrame(alternate, anchorOf) {
24095
+ const choice2 = elements(alternate).find((node3) => node3.localName === "Choice");
24096
+ const anchorEl = choice2 ? elements(choice2).find((node3) => node3.localName?.endsWith("Anchor")) : void 0;
24097
+ if (!anchorEl) return void 0;
24098
+ const shape = elements(anchorEl).find((node3) => node3.localName === "sp");
24099
+ const nv = first(shape, "nvSpPr", NS.xdr);
24100
+ const cNvPr = first(nv, "cNvPr", NS.xdr);
24101
+ const spid = [...cNvPr?.getElementsByTagName("*") ?? []].find(
24102
+ (node3) => node3.localName === "compatExt"
24103
+ );
24104
+ if (!spid) return void 0;
24105
+ const shapeId2 = Number(att(cNvPr, "id"));
24106
+ if (!Number.isFinite(shapeId2)) return void 0;
24107
+ const name3 = att(cNvPr, "name");
24108
+ return {
24109
+ kind: "formControl",
24110
+ anchor: anchorOf(anchorEl),
24111
+ shapeId: shapeId2,
24112
+ controlType: "other",
24113
+ ...name3 ? { name: name3 } : {},
24114
+ sourceXml: selfContainedXml(alternate)
24115
+ };
24116
+ }
24117
+ var num = (value3) => {
24118
+ if (value3 === void 0 || value3 === "") return void 0;
24119
+ const parsed = Number(value3);
24120
+ return Number.isFinite(parsed) ? parsed : void 0;
24121
+ };
24122
+ function readProps(control, xml) {
24123
+ const props = parseXml(xml, { label: "XLSX form control" }).documentElement;
24124
+ control.controlType = TYPES2[(att(props, "objectType") ?? "").toLowerCase()] ?? "other";
24125
+ const link = att(props, "fmlaLink");
24126
+ if (link) control.linkedCell = link;
24127
+ const range2 = att(props, "fmlaRange");
24128
+ if (range2) control.listRange = range2;
24129
+ if (control.controlType === "checkbox" || control.controlType === "radio") {
24130
+ const checked = att(props, "checked");
24131
+ control.checked = checked === "Checked" ? "checked" : checked === "Mixed" ? "mixed" : "unchecked";
24132
+ }
24133
+ if (att(props, "firstButton") === "1") control.firstButton = true;
24134
+ for (const [key2, attribute4] of [
24135
+ ["selected", "sel"],
24136
+ ["value", "val"],
24137
+ ["min", "min"],
24138
+ ["max", "max"],
24139
+ ["step", "inc"],
24140
+ ["page", "page"]
24141
+ ]) {
24142
+ const value3 = num(att(props, attribute4));
24143
+ if (value3 !== void 0) control[key2] = value3;
24144
+ }
24145
+ if (att(props, "horiz") === "1") control.horizontal = true;
24146
+ const style2 = att(props, "dropStyle");
24147
+ if (style2) control.dropStyle = style2;
24148
+ }
24149
+ var entities = {
24150
+ amp: "&",
24151
+ lt: "<",
24152
+ gt: ">",
24153
+ quot: '"',
24154
+ apos: "'",
24155
+ nbsp: " "
24156
+ };
24157
+ function vmlCaption(vml, shapeId2) {
24158
+ const start = vml.indexOf(`id="_x0000_s${shapeId2}"`);
24159
+ if (start < 0) return void 0;
24160
+ const end = vml.indexOf("</v:shape>", start);
24161
+ const shape = vml.slice(start, end < 0 ? void 0 : end);
24162
+ const box5 = /<v:textbox[^>]*>([\s\S]*?)<\/v:textbox>/.exec(shape)?.[1];
24163
+ if (!box5) return void 0;
24164
+ let stripped = box5.replace(/<br\s*\/?>/gi, "\n");
24165
+ for (let prev = ""; prev !== stripped; ) {
24166
+ prev = stripped;
24167
+ stripped = stripped.replace(/<[^>]*>/g, "");
24168
+ }
24169
+ const text7 = stripped.replace(/&(#x?[0-9a-f]+|\w+);/gi, (match, code) => {
24170
+ if (code.startsWith("#")) {
24171
+ const value3 = code[1]?.toLowerCase() === "x" ? parseInt(code.slice(2), 16) : Number(code.slice(1));
24172
+ return Number.isFinite(value3) ? String.fromCodePoint(value3) : match;
24173
+ }
24174
+ return entities[code.toLowerCase()] ?? match;
24175
+ }).replace(/\s+/g, " ").trim();
24176
+ return text7 || void 0;
24177
+ }
24178
+ function attachFormControls(source, sheetPart, root2, sheet, legacyDrawing) {
24179
+ const controls3 = sheet.drawings.filter(
24180
+ (object) => object.kind === "formControl"
24181
+ );
24182
+ if (!controls3.length) return;
24183
+ const rels = source.rels(sheetPart);
24184
+ const parts = /* @__PURE__ */ new Map();
24185
+ for (const control of Array.from(root2.getElementsByTagNameNS(NS.x, "control"))) {
24186
+ const shapeId2 = Number(att(control, "shapeId"));
24187
+ const rel = rels.get(relAttr(control, "id") ?? "");
24188
+ const target2 = rel ? source.target(sheetPart, rel) : void 0;
24189
+ if (target2) parts.set(shapeId2, target2);
24190
+ }
24191
+ const vmlRel = legacyDrawing ? rels.get(relAttr(legacyDrawing, "id") ?? "") : void 0;
24192
+ const vmlPart = vmlRel ? source.target(sheetPart, vmlRel) : void 0;
24193
+ const vml = vmlPart ? source.text(vmlPart) : void 0;
24194
+ for (const control of controls3) {
24195
+ const part = parts.get(control.shapeId);
24196
+ const xml = part ? source.text(part) : void 0;
24197
+ if (part && xml) {
24198
+ control.partName = part;
24199
+ try {
24200
+ readProps(control, xml);
24201
+ } catch {
24202
+ control.controlType = "other";
24203
+ }
24204
+ }
24205
+ const caption = vml ? vmlCaption(vml, control.shapeId) : void 0;
24206
+ if (caption) control.caption = caption;
24207
+ }
24208
+ }
24209
+
24210
+ // xlsx/read/shape.ts
23574
24211
  var xdr = (parent, local) => first(parent, local, NS.xdr);
23575
- var int2 = (parent, local) => Math.round(Number(xdr(parent, local)?.textContent ?? 0)) || 0;
24212
+ function styleRef2(style2, name3) {
24213
+ const ref = first(style2, name3, NS.a);
24214
+ if (!ref) return void 0;
24215
+ const idx = Number(att(ref, "idx") ?? 0);
24216
+ const color2 = parseDrawingColorIn(ref);
24217
+ return { idx: Number.isFinite(idx) ? idx : 0, ...color2 ? { color: color2 } : {} };
24218
+ }
24219
+ function readStyle(style2) {
24220
+ if (!style2) return void 0;
24221
+ const fill = styleRef2(style2, "fillRef");
24222
+ const line2 = styleRef2(style2, "lnRef");
24223
+ const fontColor = parseDrawingColorIn(first(style2, "fontRef", NS.a));
24224
+ return {
24225
+ ...fill ? { fill } : {},
24226
+ ...line2 ? { line: line2 } : {},
24227
+ ...fontColor ? { font: { color: fontColor } } : {}
24228
+ };
24229
+ }
24230
+ function readShapeNode(element2) {
24231
+ const local = element2.localName;
24232
+ if (local !== "sp" && local !== "cxnSp" && local !== "grpSp") return void 0;
24233
+ const isGroup = local === "grpSp";
24234
+ const nv = elements(element2).find((node4) => node4.localName?.startsWith("nv"));
24235
+ const cNvPr = xdr(nv, "cNvPr");
24236
+ const spPr = xdr(element2, isGroup ? "grpSpPr" : "spPr");
24237
+ const xfrm = first(spPr, "xfrm", NS.a);
24238
+ const transform2 = parseTransform(xfrm);
24239
+ const geometry = isGroup ? { geometry: "group" } : parseDrawingGeometry(spPr);
24240
+ const node3 = {
24241
+ kind: isGroup ? "group" : local === "cxnSp" ? "connector" : "shape",
24242
+ frame: transform2?.frame ?? { x: 0, y: 0, width: 0, height: 0 },
24243
+ geometry: geometry.geometry
24244
+ };
24245
+ const name3 = att(cNvPr, "name");
24246
+ if (name3) node3.name = name3;
24247
+ if (att(xdr(nv, "cNvSpPr"), "txBox") === "1") node3.textBox = true;
24248
+ if (transform2?.rotation) node3.rotation = transform2.rotation;
24249
+ if (transform2?.flipHorizontal) node3.flipH = true;
24250
+ if (transform2?.flipVertical) node3.flipV = true;
24251
+ if ("adjustments" in geometry && geometry.adjustments) node3.adjustments = geometry.adjustments;
24252
+ if ("paths" in geometry && geometry.paths) node3.paths = geometry.paths;
24253
+ if (!isGroup) {
24254
+ const fill = parseDrawingFill(spPr);
24255
+ if (fill) node3.fill = fill;
24256
+ const line2 = parseDrawingLine(first(spPr, "ln", NS.a));
24257
+ if (line2) node3.line = line2;
24258
+ const style2 = readStyle(xdr(element2, "style"));
24259
+ if (style2) node3.style = style2;
24260
+ const text7 = parseDrawingTextBody(xdr(element2, "txBody"));
24261
+ if (text7?.text) node3.text = text7;
24262
+ return node3;
24263
+ }
24264
+ const childFrame = parseFrameOf(first(xfrm, "chOff", NS.a), first(xfrm, "chExt", NS.a));
24265
+ if (childFrame) node3.childFrame = childFrame;
24266
+ node3.children = elements(element2).flatMap((child3) => {
24267
+ const read = readShapeNode(child3);
24268
+ return read ? [read] : [];
24269
+ });
24270
+ return node3;
24271
+ }
24272
+ function parseFrameOf(off, ext) {
24273
+ if (!off || !ext) return void 0;
24274
+ return {
24275
+ x: Number(att(off, "x") ?? 0),
24276
+ y: Number(att(off, "y") ?? 0),
24277
+ width: Number(att(ext, "cx") ?? 0),
24278
+ height: Number(att(ext, "cy") ?? 0)
24279
+ };
24280
+ }
24281
+
24282
+ // xlsx/read/drawing.ts
24283
+ var xdr2 = (parent, local) => first(parent, local, NS.xdr);
24284
+ var int2 = (parent, local) => Math.round(Number(xdr2(parent, local)?.textContent ?? 0)) || 0;
23576
24285
  function marker(node3) {
23577
24286
  return {
23578
24287
  col: int2(node3, "col"),
@@ -23583,7 +24292,7 @@ function marker(node3) {
23583
24292
  }
23584
24293
  function readAnchor(anchor) {
23585
24294
  if (anchor.localName === "absoluteAnchor") {
23586
- const pos = xdr(anchor, "pos");
24295
+ const pos = xdr2(anchor, "pos");
23587
24296
  const result3 = {
23588
24297
  from: {
23589
24298
  row: 0,
@@ -23592,26 +24301,26 @@ function readAnchor(anchor) {
23592
24301
  rowOffset: Number(att(pos, "y") ?? 0)
23593
24302
  }
23594
24303
  };
23595
- const ext2 = xdr(anchor, "ext");
24304
+ const ext2 = xdr2(anchor, "ext");
23596
24305
  if (ext2) result3.ext = { cx: Number(att(ext2, "cx") ?? 0), cy: Number(att(ext2, "cy") ?? 0) };
23597
24306
  return result3;
23598
24307
  }
23599
- const result2 = { from: marker(xdr(anchor, "from")) };
23600
- const to = xdr(anchor, "to");
24308
+ const result2 = { from: marker(xdr2(anchor, "from")) };
24309
+ const to = xdr2(anchor, "to");
23601
24310
  if (to) result2.to = marker(to);
23602
- const ext = xdr(anchor, "ext");
24311
+ const ext = xdr2(anchor, "ext");
23603
24312
  if (ext) result2.ext = { cx: Number(att(ext, "cx") ?? 0), cy: Number(att(ext, "cy") ?? 0) };
23604
24313
  return result2;
23605
24314
  }
23606
24315
  var ANCHOR_PARTS = /* @__PURE__ */ new Set(["from", "to", "ext", "pos", "clientData"]);
23607
24316
  function nonVisual(content2) {
23608
24317
  const nv = elements(content2).find((node3) => node3.localName?.startsWith("nv"));
23609
- return xdr(nv, "cNvPr");
24318
+ return xdr2(nv, "cNvPr");
23610
24319
  }
23611
24320
  function describe(content2) {
23612
24321
  switch (content2.localName) {
23613
24322
  case "sp":
23614
- return xdr(content2, "nvSpPr") && att(xdr(xdr(content2, "nvSpPr"), "cNvSpPr"), "txBox") === "1" ? "text box" : "shape";
24323
+ return xdr2(content2, "nvSpPr") && att(xdr2(xdr2(content2, "nvSpPr"), "cNvSpPr"), "txBox") === "1" ? "text box" : "shape";
23615
24324
  case "grpSp":
23616
24325
  return "group";
23617
24326
  case "cxnSp":
@@ -23631,6 +24340,11 @@ function parseDrawing(source, partName, warn) {
23631
24340
  const rels = source.rels(partName);
23632
24341
  const out = [];
23633
24342
  for (const anchorEl of elements(root2)) {
24343
+ if (anchorEl.localName === "AlternateContent") {
24344
+ const control = readFormControlFrame(anchorEl, readAnchor);
24345
+ if (control) out.push(control);
24346
+ continue;
24347
+ }
23634
24348
  if (!["twoCellAnchor", "oneCellAnchor", "absoluteAnchor"].includes(anchorEl.localName ?? ""))
23635
24349
  continue;
23636
24350
  const anchor = readAnchor(anchorEl);
@@ -23645,7 +24359,7 @@ function parseDrawing(source, partName, warn) {
23645
24359
  const cNvPr = nonVisual(content2);
23646
24360
  const name3 = att(cNvPr, "name");
23647
24361
  if (content2.localName === "pic") {
23648
- const blipFill = xdr(content2, "blipFill");
24362
+ const blipFill = xdr2(content2, "blipFill");
23649
24363
  const blip = first(blipFill, "blip", NS.a);
23650
24364
  const rel = rels.get(relAttr(blip, "embed") ?? "");
23651
24365
  const target2 = rel ? source.target(partName, rel) : void 0;
@@ -23720,11 +24434,50 @@ function parseDrawing(source, partName, warn) {
23720
24434
  continue;
23721
24435
  }
23722
24436
  }
23723
- out.push(unsupported4(describe(content2)));
24437
+ const shape = readShapeNode(content2);
24438
+ out.push({ ...unsupported4(describe(content2)), ...shape ? { shape } : {} });
23724
24439
  }
23725
24440
  return out;
23726
24441
  }
23727
24442
 
24443
+ // xlsx/read/header-footer-images.ts
24444
+ var UNIT_PT = { pt: 1, in: 72, cm: 72 / 2.54, mm: 72 / 25.4, px: 0.75 };
24445
+ function styleLength(style2, property2) {
24446
+ const match = new RegExp(
24447
+ `(?:^|[;\\s])${property2}\\s*:\\s*([\\d.]+)\\s*(pt|in|cm|mm|px)?`,
24448
+ "i"
24449
+ ).exec(style2);
24450
+ return match ? Number(match[1]) * (UNIT_PT[(match[2] ?? "pt").toLowerCase()] ?? 1) : 0;
24451
+ }
24452
+ function readHeaderFooterImages(source, sheetPart, legacyHF) {
24453
+ if (!legacyHF) return void 0;
24454
+ const rel = source.rels(sheetPart).get(relAttr(legacyHF, "id") ?? "");
24455
+ const vmlPart = rel ? source.target(sheetPart, rel) : void 0;
24456
+ const vml = vmlPart ? source.text(vmlPart) : void 0;
24457
+ if (!vmlPart || !vml) return void 0;
24458
+ const rels = source.rels(vmlPart);
24459
+ const images = {};
24460
+ for (const match of vml.matchAll(/<v:shape\b([^>]*)>([\s\S]*?)<\/v:shape>/g)) {
24461
+ const id3 = /\bid="([^"]+)"/.exec(match[1] ?? "")?.[1];
24462
+ const style2 = /style=(?:'([^']*)'|"([^"]*)")/.exec(match[1] ?? "");
24463
+ const data = /<v:imagedata\b([^>]*)>/.exec(match[2] ?? "")?.[1];
24464
+ const relId = /\bo:relid="([^"]+)"/.exec(data ?? "")?.[1];
24465
+ const imageRel = relId ? rels.get(relId) : void 0;
24466
+ const partName = imageRel ? source.target(vmlPart, imageRel) : void 0;
24467
+ if (!id3 || !partName || !source.has(partName)) continue;
24468
+ const css = style2?.[1] ?? style2?.[2] ?? "";
24469
+ const title = /\bo:title="([^"]*)"/.exec(data ?? "")?.[1];
24470
+ images[id3] = {
24471
+ partName,
24472
+ contentType: source.contentType(partName) ?? "application/octet-stream",
24473
+ widthPt: styleLength(css, "width"),
24474
+ heightPt: styleLength(css, "height"),
24475
+ ...title ? { title } : {}
24476
+ };
24477
+ }
24478
+ return Object.keys(images).length ? images : void 0;
24479
+ }
24480
+
23728
24481
  // xlsx/read/dates.ts
23729
24482
  var DAY_MS2 = 864e5;
23730
24483
  var EPOCH_19003 = Date.UTC(1899, 11, 30);
@@ -23866,6 +24619,8 @@ function readRowInfo(ctx, rowEl) {
23866
24619
  const outline = numAttr(rowEl, "outlineLevel");
23867
24620
  if (outline) info.outlineLevel = outline;
23868
24621
  if (boolAttr(rowEl, "collapsed")) info.collapsed = true;
24622
+ if (boolAttr(rowEl, "thickTop")) info.thickTop = true;
24623
+ if (boolAttr(rowEl, "thickBot")) info.thickBot = true;
23869
24624
  return Object.keys(info).length ? info : void 0;
23870
24625
  }
23871
24626
  function readSheetData(ctx, rows, sheet) {
@@ -23978,15 +24733,6 @@ function readScenarios(node3) {
23978
24733
  return set;
23979
24734
  }
23980
24735
 
23981
- // xlsx/read/print-options.ts
23982
- var KEYS = ["gridLines", "headings", "horizontalCentered", "verticalCentered"];
23983
- function readPrintOptions(node3) {
23984
- if (!node3) return void 0;
23985
- const out = {};
23986
- for (const key2 of KEYS) if (boolAttr(node3, key2)) out[key2] = true;
23987
- return Object.keys(out).length ? out : void 0;
23988
- }
23989
-
23990
24736
  // xlsx/read/tables.ts
23991
24737
  function parseTable(xml, partName) {
23992
24738
  const root2 = parseXml(xml, { label: "XLSX table" }).documentElement;
@@ -24077,8 +24823,14 @@ var MODELLED = /* @__PURE__ */ new Set([
24077
24823
  "drawing",
24078
24824
  "legacyDrawing",
24079
24825
  "tableParts",
24080
- "scenarios"
24826
+ "scenarios",
24827
+ "customSheetViews"
24081
24828
  ]);
24829
+ function reportUnplaceable(ctx, sheet, element2) {
24830
+ ctx.warn(
24831
+ `Sheet "${sheet}": the element "${element2}" is not part of the worksheet schema and is dropped on save.`
24832
+ );
24833
+ }
24082
24834
  function keep(sheet, key2, xml) {
24083
24835
  const list2 = sheet.preserved.get(key2);
24084
24836
  if (list2) list2.push(xml);
@@ -24160,9 +24912,15 @@ function readWorksheet(ctx, partName, name3, sheetId5, xml, rows) {
24160
24912
  else if (!byName.has(local)) byName.set(local, node3);
24161
24913
  if (SNAPSHOT_ELEMENTS.includes(local))
24162
24914
  keep(sheet, snapshotKey(local), outerXml(node3));
24163
- else if (local === "AlternateContent")
24164
- keep(sheet, alternateContentName(node3) ?? local, selfContainedXml(node3));
24165
- else if (!MODELLED.has(local)) keep(sheet, local, selfContainedXml(node3));
24915
+ else if (local === "AlternateContent") {
24916
+ const inner = alternateContentName(node3);
24917
+ if (!WORKSHEET_CHILD_ORDER.includes(inner ?? local))
24918
+ reportUnplaceable(ctx, name3, inner ?? local);
24919
+ keep(sheet, inner ?? local, selfContainedXml(node3));
24920
+ } else if (!MODELLED.has(local)) {
24921
+ if (!WORKSHEET_CHILD_ORDER.includes(local)) reportUnplaceable(ctx, name3, local);
24922
+ keep(sheet, local, selfContainedXml(node3));
24923
+ }
24166
24924
  }
24167
24925
  const sheetPr = byName.get("sheetPr");
24168
24926
  const tabColor = readTabColor(sheetPr, ctx.palette);
@@ -24198,6 +24956,10 @@ function readWorksheet(ctx, partName, name3, sheetId5, xml, rows) {
24198
24956
  readFitToPage(sheetPr)
24199
24957
  );
24200
24958
  if (page) sheet.pageSetup = page;
24959
+ const customViews = byName.get("customSheetViews");
24960
+ if (customViews) sheet.customViews = readCustomSheetViews(customViews);
24961
+ const hfImages = readHeaderFooterImages(ctx.source, partName, byName.get("legacyDrawingHF"));
24962
+ if (hfImages) sheet.headerFooterImages = hfImages;
24201
24963
  const printOptions = readPrintOptions(byName.get("printOptions"));
24202
24964
  if (printOptions) sheet.printOptions = printOptions;
24203
24965
  const drawing2 = byName.get("drawing");
@@ -24205,6 +24967,7 @@ function readWorksheet(ctx, partName, name3, sheetId5, xml, rows) {
24205
24967
  const rel = ctx.source.rels(partName).get(relAttr(drawing2, "id") ?? "");
24206
24968
  const target2 = rel ? ctx.source.target(partName, rel) : void 0;
24207
24969
  if (target2) sheet.drawings = parseDrawing(ctx.source, target2, (m) => ctx.warn(m));
24970
+ attachFormControls(ctx.source, partName, root2, sheet, byName.get("legacyDrawing"));
24208
24971
  }
24209
24972
  readTables(ctx, partName, byName.get("tableParts"), sheet);
24210
24973
  readComments(ctx, partName, sheet);
@@ -24313,6 +25076,7 @@ async function loadXlsx(input, options2 = {}) {
24313
25076
  if (book.workbookPasswordHash) workbook.workbookPasswordHash = book.workbookPasswordHash;
24314
25077
  if (book.workbookModernHash) workbook.workbookModernHash = book.workbookModernHash;
24315
25078
  if (book.oleSize) workbook.oleSize = book.oleSize;
25079
+ if (book.customViews) workbook.customViews = book.customViews;
24316
25080
  if (book.calcMode) workbook.calcMode = book.calcMode;
24317
25081
  if (book.iterate) workbook.iterate = book.iterate;
24318
25082
  if (signatures.hasSignatures)
@@ -26059,9 +26823,9 @@ function sampleArc(start, rxIn, ryIn, xAxisRotationDeg, largeArcFlag, sweepFlag,
26059
26823
  ry *= scale;
26060
26824
  }
26061
26825
  const sign2 = largeArcFlag !== sweepFlag ? 1 : -1;
26062
- const num = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
26826
+ const num2 = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
26063
26827
  const den = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
26064
- const coef = sign2 * Math.sqrt(Math.max(0, num / den));
26828
+ const coef = sign2 * Math.sqrt(Math.max(0, num2 / den));
26065
26829
  const cxp = coef * (rx * y1p) / ry;
26066
26830
  const cyp = coef * -(ry * x1p) / rx;
26067
26831
  const cx = cosPhi * cxp - sinPhi * cyp + (start.x + end.x) / 2;
@@ -33083,8 +33847,13 @@ var VISIO_VISIBILITY_LIMITS = Object.freeze({
33083
33847
  });
33084
33848
 
33085
33849
  // visio/edit-formatting-scope.ts
33086
- async function assertFormattingDependencies(pkg, pagePaths, roots2, pageId2, shape, changed, check, instanceView2) {
33087
- indexCells(roots2, { check });
33850
+ async function assertFormattingDependencies(pkg, pagePaths, roots2, pageId2, shape, changed, check, instanceView2, options2 = {}) {
33851
+ for (const item2 of indexCells(roots2, { check, scope: "affected" }).values())
33852
+ if (item2.refusal && item2.pageId === pageId2)
33853
+ fail(
33854
+ "EDIT_UNKNOWN_DEPENDENCY",
33855
+ `Cannot prove ShapeSheet dependency closure: ${item2.refusal}`
33856
+ );
33088
33857
  const shapeId2 = attribute2(shape, "ID");
33089
33858
  const changedNames = new Set([...changed.keys()].map((name3) => name3.toLowerCase()));
33090
33859
  const jumpOnly = [...changedNames].every(
@@ -33139,11 +33908,17 @@ async function assertFormattingDependencies(pkg, pagePaths, roots2, pageId2, sha
33139
33908
  if (textEdit && localShapeId === shapeId2 && sourcePageId === pageId2) continue;
33140
33909
  analysis = sized;
33141
33910
  }
33911
+ if (options2.textReads && textEdit && !named2 && sourcePageId !== void 0 && textReadFormula(source))
33912
+ continue;
33142
33913
  if (named2 && analysis.dynamic) {
33143
33914
  if (mentions()) failure2();
33144
33915
  continue;
33145
33916
  }
33146
- if (analysis.dynamic || analysis.references.some(
33917
+ if (analysis.dynamic && analysis.opaque) {
33918
+ if (sourcePageId === pageId2 || mentions()) failure2();
33919
+ continue;
33920
+ }
33921
+ if (analysis.references.some(
33147
33922
  (ref) => changedNames.has(canonical2(ref.cell)) && (sourcePageId === void 0 || sourcePageId === pageId2) && (ref.shapeId === shapeId2 || ref.shapeId === void 0 && (localShapeId === shapeId2 || sourcePageId === void 0))
33148
33923
  ))
33149
33924
  failure2();
@@ -33156,6 +33931,7 @@ async function assertFormattingDependencies(pkg, pagePaths, roots2, pageId2, sha
33156
33931
  const part = await pkg.readXml(path3);
33157
33932
  const master2 = part.localName === "MasterContents";
33158
33933
  if (instanceView2 && master2) continue;
33934
+ if (master2 && !shape.hasAttribute("Master") && !shape.hasAttribute("MasterShape")) continue;
33159
33935
  inspect3(part, void 0, master2);
33160
33936
  }
33161
33937
  }
@@ -33358,7 +34134,7 @@ function masterTemplate(pkg) {
33358
34134
  return matches2.length === 1 ? matches2[0] : missing();
33359
34135
  };
33360
34136
  }
33361
- function replaceScopedPlainText(pkg, pagePaths, roots2, document, edit, check) {
34137
+ function replaceScopedPlainText(pkg, pagePaths, roots2, document, edit, check, diagnostics = []) {
33362
34138
  return replacePlainText(
33363
34139
  roots2.get(edit.pageId),
33364
34140
  document,
@@ -33372,10 +34148,20 @@ function replaceScopedPlainText(pkg, pagePaths, roots2, document, edit, check) {
33372
34148
  edit.pageId,
33373
34149
  shape,
33374
34150
  /* @__PURE__ */ new Map([["TheText", text7]]),
33375
- check
34151
+ check,
34152
+ void 0,
34153
+ { textReads: true }
33376
34154
  ),
33377
34155
  masterTemplate(pkg)
33378
- );
34156
+ ).then((changed) => {
34157
+ if (changed)
34158
+ recalculateVisioCells(
34159
+ roots2,
34160
+ [{ pageId: edit.pageId, shapeId: edit.shapeId, cell: "TheText" }],
34161
+ { check, cycles: "keep", diagnostics }
34162
+ );
34163
+ return changed;
34164
+ });
33379
34165
  }
33380
34166
 
33381
34167
  // visio/edit-instance-sheet.ts
@@ -34283,7 +35069,7 @@ function layoutConnectorShape(roots2, pageId2, shape, route, sites, check, obsta
34283
35069
 
34284
35070
  // visio/edit-stencil-connector-layout.ts
34285
35071
  var same6 = (a2, b) => Math.abs(a2 - b) <= 1e-9 * Math.max(1, Math.abs(a2), Math.abs(b));
34286
- function walkShape(box5) {
35072
+ function walkShape(box5, floating = false) {
34287
35073
  const [a2, b, c2, d, e, f] = box5.transform;
34288
35074
  const at2 = (x, y) => ({
34289
35075
  x: a2 * x + c2 * y + e,
@@ -34295,7 +35081,8 @@ function walkShape(box5) {
34295
35081
  sites: sites.map((site) => ({ point: site.point, normal: site.normal })),
34296
35082
  bounds: sites[0].box,
34297
35083
  center: at2(box5.width / 2, box5.height / 2),
34298
- corners: [at2(0, 0), at2(box5.width, 0), at2(box5.width, box5.height), at2(0, box5.height)]
35084
+ corners: [at2(0, 0), at2(box5.width, 0), at2(box5.width, box5.height), at2(0, box5.height)],
35085
+ ...floating ? { floating } : {}
34299
35086
  }
34300
35087
  };
34301
35088
  }
@@ -34516,6 +35303,11 @@ function connectionRows(shape) {
34516
35303
  }
34517
35304
  return rows;
34518
35305
  }
35306
+ function hasConnectionPoints(root2, shapeId2) {
35307
+ const target2 = topShape(root2, shapeId2);
35308
+ if (!target2) return false;
35309
+ return (stencilTemplate(target2) ? effectiveRows(target2, "Connection") : connectionRows(target2)).size > 0;
35310
+ }
34519
35311
  function glueSites(root2, end) {
34520
35312
  const box5 = glueBox(root2, end.target);
34521
35313
  if (end.point === void 0) return dynamicSites(box5);
@@ -34626,8 +35418,9 @@ function proveConnector(root2, connectorId) {
34626
35418
  const named2 = visioPointGlueTarget(source);
34627
35419
  return index2 === void 0 ? !named2 : !!named2 && named2.shapeId === target2 && named2.index === index2;
34628
35420
  };
34629
- 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.
34630
- visioGlueTriggerTarget(formula2(triggerName(end))) !== target2 && !(isStencilLine(shape) && formula2(triggerName(end)) === void 0) || !glued("X") || !glued("Y"))
35421
+ 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
35422
+ // point glue on a drawn line has none either (native-edit-families-flat-2026-10-29.json).
35423
+ visioGlueTriggerTarget(formula2(triggerName(end))) !== target2 && !(formula2(triggerName(end)) === void 0 && !local.has(triggerName(end)) && (isStencilLine(shape) || index2 !== void 0)) || !glued("X") || !glued("Y"))
34631
35424
  fail("UNSUPPORTED_GEOMETRY_EDIT", UNSUPPORTED);
34632
35425
  ends[end] = { target: target2, ...index2 === void 0 ? {} : { point: index2 } };
34633
35426
  }
@@ -34893,7 +35686,7 @@ function rerouteConnector(roots2, pageId2, glue, check, options2 = {}) {
34893
35686
  }
34894
35687
  const walk = (end) => {
34895
35688
  const target2 = glue.ends[end];
34896
- return target2 && target2.point === void 0 ? walkShape(glueBox(root2, target2.target)) : { point: sites(end)[0].point };
35689
+ return target2 && target2.point === void 0 ? walkShape(glueBox(root2, target2.target), !hasConnectionPoints(root2, target2.target)) : { point: sites(end)[0].point };
34897
35690
  };
34898
35691
  const route = options2.route ?? current;
34899
35692
  if (route === "straight" && current === "straight" && ENDS.every(
@@ -36109,7 +36902,7 @@ async function assertInstanceLayersUnlocked(pkg, pageId2, layerMember) {
36109
36902
 
36110
36903
  // visio/formula-functions.ts
36111
36904
  var DOCUMENTED = new Set(
36112
- `ABS ACOS AND ANG360 ANGLEALONGPATH ANGLETOLOC ANGLETOPAR ASIN ATAN ATAN2 BITAND BITNOT BITOR
36905
+ `ABS ACOS AND ARG ANG360 ANGLEALONGPATH ANGLETOLOC ANGLETOPAR ASIN ATAN ATAN2 BITAND BITNOT BITOR
36113
36906
  BITXOR BKGPAGENAME BLEND BLOB BLUE BOUND CALLOUTCOUNT CALLOUTTARGETREF CALLTHIS CATEGORY CEILING
36114
36907
  CELLISTHEMED CHAR COMPANY CONTAINERCOUNT CONTAINERMEMBERCOUNT CONTAINERSHEETREF COS COSH CREATOR
36115
36908
  CY DATA1 DATA2 DATA3 DATE DATETIME DATEVALUE DAY DAYOFYEAR DECIMALSEP DEFAULTEVENT DEG DEPENDSON
@@ -37376,6 +38169,7 @@ function resizeVisioShapeAtAnchor(roots2, document, edit, check, glueShapes = /*
37376
38169
  fail("UNSUPPORTED_GEOMETRY_EDIT", "Glued shapes require routing outside this subset.");
37377
38170
  const graph = indexCells(roots2, {
37378
38171
  check,
38172
+ scope: "affected",
37379
38173
  glueShapes,
37380
38174
  ...group2 ? { groupResizeShapes: group2.shapes } : {}
37381
38175
  });
@@ -37689,13 +38483,23 @@ function prepareMasterMovePins(roots2, commands, bindings, check) {
37689
38483
  }
37690
38484
  }
37691
38485
  if (result2.size) {
37692
- const indexed = indexCells(roots2, { check });
38486
+ const indexed = indexCells(roots2, { check, scope: "affected" });
37693
38487
  const pins = new Set(
37694
38488
  [...indexed.values()].filter((cell) => cell.node && result2.has(cell.node)).map(key)
37695
38489
  );
37696
- for (const cell of indexed.values())
37697
- if (charge(), cell.dependencies.some((dependency) => pins.has(dependency)))
38490
+ const pinPages = new Set(
38491
+ [...indexed.values()].filter((cell) => cell.node && result2.has(cell.node)).map((c2) => c2.pageId)
38492
+ );
38493
+ for (const cell of indexed.values()) {
38494
+ charge();
38495
+ if (cell.opaque && pinPages.has(cell.pageId))
38496
+ fail(
38497
+ "EDIT_UNSUPPORTED_DEPENDENCY",
38498
+ "A formula that may read a master rotation pin exists."
38499
+ );
38500
+ if (cell.dependencies.some((dependency) => pins.has(dependency)))
37698
38501
  fail("EDIT_UNSUPPORTED_DEPENDENCY", "A page cache depends on a master rotation pin.");
38502
+ }
37699
38503
  }
37700
38504
  return { pins: result2, dimensions: provenDimensions };
37701
38505
  }
@@ -37792,8 +38596,12 @@ function applyGeometryEdit(roots2, document, edit, check, masterMoveProof = empt
37792
38596
  if (edit.type === "delete-shape") {
37793
38597
  unlocked("LockDelete");
37794
38598
  releaseDeletedGlue(roots2, /* @__PURE__ */ new Map([[edit.pageId, /* @__PURE__ */ new Set([edit.shapeId])]]));
37795
- assertVisioShapeUnreferenced(roots2, edit.pageId, edit.shapeId, { check });
38599
+ const frozen = assertVisioShapeUnreferenced(roots2, edit.pageId, edit.shapeId, {
38600
+ check,
38601
+ freeze: true
38602
+ });
37796
38603
  shape.parentNode.removeChild(shape);
38604
+ freezeVisioCells(frozen);
37797
38605
  return [edit.pageId];
37798
38606
  }
37799
38607
  if (edit.type === "rotate-shape" || edit.type === "flip-shape") {
@@ -38731,7 +39539,7 @@ async function recalculatePageFormulas(pkg, pagesPart, pages, paths, dirty, chec
38731
39539
  }
38732
39540
 
38733
39541
  // visio/edit-page-rename.ts
38734
- var escape3 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
39542
+ var escape4 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
38735
39543
  function localCell(node3) {
38736
39544
  const row2 = node3.parentNode;
38737
39545
  const section3 = row2?.parentNode;
@@ -38760,7 +39568,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
38760
39568
  }
38761
39569
  const roots2 = await editableVisioPageRoots(pkg, pagesPart, pages, pagePaths, dirty, check);
38762
39570
  const changedCells = [];
38763
- const prefix2 = new RegExp(`Pages\\[${escape3(oldUniversal)}\\]!`, "gi");
39571
+ const prefix2 = new RegExp(`Pages\\[${escape4(oldUniversal)}\\]!`, "gi");
38764
39572
  const targetByPath = new Map([...pagePaths].map(([id3, path3]) => [path3, id3]));
38765
39573
  for (const [path3, root2] of roots2) {
38766
39574
  let changed = false;
@@ -38794,7 +39602,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
38794
39602
  if (cell) changedCells.push({ node: node3, cell });
38795
39603
  }
38796
39604
  } else if (/\bPAGENAME\s*\(/i.test(code)) {
38797
- if (target2 === pageId2 || !target2 || new RegExp(`Pages\\[${escape3(oldUniversal)}\\]!`, "i").test(code))
39605
+ if (target2 === pageId2 || !target2 || new RegExp(`Pages\\[${escape4(oldUniversal)}\\]!`, "i").test(code))
38798
39606
  fail(
38799
39607
  "EDIT_UNSUPPORTED_PAGE_NAME_FORMULA",
38800
39608
  "Complex page-name formula caches cannot be safely refreshed."
@@ -38844,7 +39652,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
38844
39652
  for (const changed of changedCells) {
38845
39653
  if (changed.node === node3) continue;
38846
39654
  const reference2 = new RegExp(
38847
- `(?:^|[^a-z0-9_.])${escape3(changed.cell)}(?:$|[^a-z0-9_.])`,
39655
+ `(?:^|[^a-z0-9_.])${escape4(changed.cell)}(?:$|[^a-z0-9_.])`,
38848
39656
  "i"
38849
39657
  );
38850
39658
  if (reference2.test(unquotedVisioFormula(formula2)))
@@ -38866,7 +39674,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
38866
39674
  // visio/edit-page-delete.ts
38867
39675
  var officeRel = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
38868
39676
  var pageType = "http://schemas.microsoft.com/visio/2010/relationships/page";
38869
- var escape4 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
39677
+ var escape5 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
38870
39678
  async function deleteVisioPage(pkg, pagesPart, pages, rels, types, pagePaths, parts, dirty, removed, pageId2, check) {
38871
39679
  const existing = children2(pages, "Page");
38872
39680
  const page = existing.find((node3) => attribute2(node3, "ID") === pageId2);
@@ -38875,7 +39683,7 @@ async function deleteVisioPage(pkg, pagesPart, pages, rels, types, pagePaths, pa
38875
39683
  const names = new Set(
38876
39684
  ["Name", "NameU"].map((key2) => attribute2(page, key2)).filter((value3) => !!value3)
38877
39685
  );
38878
- const reference2 = new RegExp(`Pages\\[(?:${[...names].map(escape4).join("|")})\\]!`, "i");
39686
+ const reference2 = new RegExp(`Pages\\[(?:${[...names].map(escape5).join("|")})\\]!`, "i");
38879
39687
  const documentPart2 = await related(pkg, "", "document");
38880
39688
  const roots2 = await editableVisioPageRoots(
38881
39689
  pkg,
@@ -39200,7 +40008,7 @@ function createVisioPagePart(parts, pages, pageId2, check) {
39200
40008
  }
39201
40009
 
39202
40010
  // visio/edit-page-decoration.ts
39203
- var escape5 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
40011
+ var escape6 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
39204
40012
  var name2 = (page) => attribute2(page, "NameU") ?? attribute2(page, "Name") ?? "";
39205
40013
  function largestShapeId(root2) {
39206
40014
  let largest = 0;
@@ -39216,9 +40024,9 @@ function removeDecoration(root2, pageName, kind, pageRoots, check) {
39216
40024
  ) : [];
39217
40025
  if (!targets.length) return false;
39218
40026
  const ids = targets.map((shape) => attribute2(shape, "ID") ?? "");
39219
- const local = new RegExp(`\\bSheet\\.(?:${ids.map(escape5).join("|")})!`, "i");
40027
+ const local = new RegExp(`\\bSheet\\.(?:${ids.map(escape6).join("|")})!`, "i");
39220
40028
  const remote = new RegExp(
39221
- `Pages\\[${escape5(pageName)}\\]!Sheet\\.(?:${ids.map(escape5).join("|")})!`,
40029
+ `Pages\\[${escape6(pageName)}\\]!Sheet\\.(?:${ids.map(escape6).join("|")})!`,
39222
40030
  "i"
39223
40031
  );
39224
40032
  for (const connect of children2(root2, "Connects").flatMap((node3) => children2(node3, "Connect")))
@@ -40052,17 +40860,117 @@ async function formatTarget(pkg, pagePaths, roots2, document, edit, check, insta
40052
40860
  return true;
40053
40861
  }
40054
40862
 
40863
+ // visio/edit-duplicate-line.ts
40864
+ var ENDS2 = ["BeginX", "BeginY", "EndX", "EndY"];
40865
+ var connects = (root2) => children2(root2, "Connects").flatMap((container) => children2(container, "Connect"));
40866
+ var gluedTargets = (root2, id3) => connects(root2).filter((row2) => attribute2(row2, "FromSheet") === id3).map((row2) => attribute2(row2, "ToSheet") ?? "");
40867
+ function assertGlueDroppable(root2, id3, copied, code = "UNSUPPORTED_DUPLICATE") {
40868
+ if (gluedTargets(root2, id3).some((target2) => copied.has(target2)))
40869
+ fail(code, "A glued connector cannot be copied together with a shape it is glued to yet.");
40870
+ }
40871
+ function assertEndFormulas(read, code) {
40872
+ for (const name3 of ENDS2) {
40873
+ const formula2 = executableCellFormula(attribute2(read(name3), "F"));
40874
+ if (formula2 && !isNativeGlueCell(name3, formula2))
40875
+ fail(code, `${name3} of the line holds a formula that is not native glue.`);
40876
+ }
40877
+ }
40878
+ var isLineSheet2 = (shape) => ENDS2.some((name3) => cells(shape).has(name3));
40879
+ function planLineCopy(shape, code = "UNSUPPORTED_DUPLICATE") {
40880
+ proveLocalLine(shape);
40881
+ assertEndFormulas((name3) => cells(shape).get(name3), code);
40882
+ const local = cells(shape);
40883
+ return { x: numeric(local.get("PinX")), y: numeric(local.get("PinY")) };
40884
+ }
40885
+ var shift2 = (node3, delta, name3) => {
40886
+ if (!node3) fail("UNSUPPORTED_DUPLICATE", `The line has no local ${name3}.`);
40887
+ const value3 = numeric(node3);
40888
+ node3.setAttribute("V", String(Object.is(value3 + delta, -0) ? 0 : value3 + delta));
40889
+ node3.removeAttribute("E");
40890
+ };
40891
+ function finishLineCopy(shape, dx, dy) {
40892
+ const local = cells(shape);
40893
+ for (const name3 of ENDS2) {
40894
+ const node3 = local.get(name3);
40895
+ const formula2 = executableCellFormula(attribute2(node3, "F"));
40896
+ if (formula2 && isNativeGlueCell(name3, formula2)) node3.removeAttribute("F");
40897
+ shift2(node3, name3.endsWith("X") ? dx : dy, name3);
40898
+ }
40899
+ shift2(local.get("PinX"), dx, "PinX");
40900
+ shift2(local.get("PinY"), dy, "PinY");
40901
+ }
40902
+ var isStencilConnector2 = (target2) => ENDS2.some((name3) => instanceCell(target2, name3));
40903
+ function planConnectorCopy(target2, code = "UNSUPPORTED_DUPLICATE") {
40904
+ const local = cells(target2.instance);
40905
+ for (const name3 of [...ENDS2, "PinX", "PinY"]) {
40906
+ const node3 = local.get(name3);
40907
+ if (!node3?.hasAttribute("V") || node3.hasAttribute("E"))
40908
+ fail(code, `The stencil connector has no usable local ${name3}.`);
40909
+ numeric(node3);
40910
+ }
40911
+ assertEndFormulas((name3) => local.get(name3), code);
40912
+ return { x: numeric(local.get("PinX")), y: numeric(local.get("PinY")) };
40913
+ }
40914
+ function finishConnectorCopy(shape, id3, dx, dy) {
40915
+ const local = cells(shape);
40916
+ for (const name3 of ENDS2) shift2(local.get(name3), name3.endsWith("X") ? dx : dy, name3);
40917
+ shift2(local.get("PinX"), dx, "PinX");
40918
+ shift2(local.get("PinY"), dy, "PinY");
40919
+ for (const name3 of ["BegTrigger", "EndTrigger"]) {
40920
+ const node3 = local.get(name3);
40921
+ if (!node3) continue;
40922
+ node3.setAttribute("F", visioGlueTrigger(id3));
40923
+ node3.setAttribute("V", "1");
40924
+ }
40925
+ }
40926
+ var CLEARANCE = 0.25;
40927
+ var endsBox = (shape, dx, dy) => {
40928
+ const local = cells(shape);
40929
+ const x = [numeric(local.get("BeginX")) + dx, numeric(local.get("EndX")) + dx];
40930
+ const y = [numeric(local.get("BeginY")) + dy, numeric(local.get("EndY")) + dy];
40931
+ return {
40932
+ minX: Math.min(...x) - CLEARANCE,
40933
+ maxX: Math.max(...x) + CLEARANCE,
40934
+ minY: Math.min(...y) - CLEARANCE,
40935
+ maxY: Math.max(...y) + CLEARANCE
40936
+ };
40937
+ };
40938
+ function assertConnectorCopyApart(root2, copies, dx, dy, code = "UNSUPPORTED_DUPLICATE") {
40939
+ const boxes = copies.map((shape) => endsBox(shape, dx, dy));
40940
+ for (const container of children2(root2, "Shapes"))
40941
+ for (const other of children2(container, "Shape")) {
40942
+ const local = cells(other);
40943
+ const formula2 = executableCellFormula(attribute2(local.get("BeginX"), "F")) ?? "";
40944
+ if (!/^_WALKGLUE\(/i.test(formula2)) continue;
40945
+ const box5 = endsBox(other, 0, 0);
40946
+ for (const copy8 of boxes)
40947
+ if (copy8.minX <= box5.maxX && box5.minX <= copy8.maxX && copy8.minY <= box5.maxY && box5.minY <= copy8.maxY)
40948
+ fail(
40949
+ code,
40950
+ "The copy of a connector would meet another connector, which Visio lays out again."
40951
+ );
40952
+ }
40953
+ }
40954
+
40055
40955
  // visio/edit-instance-duplicate.ts
40056
- async function planInstanceCopy(pkg, pageId2, sourceRoot, target2, offsetX, offsetY, code = "UNSUPPORTED_DUPLICATE") {
40956
+ async function planInstanceCopy(pkg, pageId2, sourceRoot, target2, offsetX, offsetY, code = "UNSUPPORTED_DUPLICATE", allowConnector = code === "UNSUPPORTED_DUPLICATE") {
40057
40957
  const id3 = attribute2(target2.instance, "ID");
40058
- if (["BeginX", "EndX"].some((name3) => instanceCell(target2, name3)) || connectRows(sourceRoot).some((row2) => attribute2(row2, "FromSheet") === id3))
40958
+ const connector2 = allowConnector && isStencilConnector2(target2);
40959
+ if (!connector2 && (isStencilConnector2(target2) || connectRows(sourceRoot).some((row2) => attribute2(row2, "FromSheet") === id3)))
40059
40960
  fail(code, "Lines and connectors that come from a stencil cannot be copied yet.");
40060
40961
  await assertInstanceUnlocked(pkg, pageId2, target2, ["LockSelect"], "selection");
40962
+ if (connector2) {
40963
+ const pin2 = planConnectorCopy(target2, code);
40964
+ const x2 = pin2.x + offsetX, y2 = pin2.y + offsetY;
40965
+ if (Math.abs(x2) > 1e6 || Math.abs(y2) > 1e6)
40966
+ fail(code, "Duplicated pins exceed coordinate limits.");
40967
+ return { x: x2, y: y2, connector: connector2 };
40968
+ }
40061
40969
  const pin = instancePin(target2);
40062
40970
  const x = pin.x + offsetX, y = pin.y + offsetY;
40063
40971
  if (Math.abs(x) > 1e6 || Math.abs(y) > 1e6)
40064
40972
  fail(code, "Duplicated pins exceed coordinate limits.");
40065
- return { x, y };
40973
+ return { x, y, connector: connector2 };
40066
40974
  }
40067
40975
  function finishInstanceCopy(clone, template, x, y, taken, check) {
40068
40976
  const mapping = /* @__PURE__ */ new Map();
@@ -40146,7 +41054,18 @@ async function duplicateVisioShapes(pkg, pagePaths, roots2, document, edit, chec
40146
41054
  structural ||= !source || await shapeIsStructural(source, template);
40147
41055
  }
40148
41056
  await assertDuplicateScope(pkg, pagePaths, root2, newIds, check, structural);
40149
- const indexed = indexCells(detached ? /* @__PURE__ */ new Map([[sourcePageId, sourceRoot]]) : roots2, { check });
41057
+ const glueTargets = new Set(
41058
+ children2(sourceRoot, "Connects").flatMap(
41059
+ (container2) => children2(container2, "Connect").map((row2) => attribute2(row2, "ToSheet"))
41060
+ )
41061
+ );
41062
+ const indexed = indexCells(detached ? /* @__PURE__ */ new Map([[sourcePageId, sourceRoot]]) : roots2, {
41063
+ check,
41064
+ scope: "affected",
41065
+ glueShapes: new Set(
41066
+ pageShapes(sourceRoot).filter((shape) => glueTargets.has(attribute2(shape, "ID")))
41067
+ )
41068
+ });
40150
41069
  const evaluate = createVisioCellEvaluator(indexed, { check }, true);
40151
41070
  const containers = children2(root2, "Shapes");
40152
41071
  if (containers.length > 1) fail("INVALID_SHAPE_ID", "Duplicate Shapes containers.");
@@ -40160,6 +41079,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots2, document, edit, chec
40160
41079
  if (value3 !== void 0) occupied.add(value3.toLowerCase());
40161
41080
  }
40162
41081
  const plans = [];
41082
+ const copied = new Set(edit.copies.map((copy8) => copy8.shapeId));
40163
41083
  let cloneNodes = 0, cloneCharacters = buildXml(root2).length;
40164
41084
  const size3 = (source) => {
40165
41085
  cloneNodes += source.getElementsByTagName("*").length + 1;
@@ -40176,6 +41096,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots2, document, edit, chec
40176
41096
  "UNSUPPORTED_DUPLICATE"
40177
41097
  );
40178
41098
  if (stencil) {
41099
+ assertGlueDroppable(sourceRoot, copy8.shapeId, copied);
40179
41100
  const pin = await planInstanceCopy(
40180
41101
  pkg,
40181
41102
  edit.pageId,
@@ -40188,18 +41109,33 @@ async function duplicateVisioShapes(pkg, pagePaths, roots2, document, edit, chec
40188
41109
  plans.push({
40189
41110
  source: stencil.instance,
40190
41111
  id: copy8.newShapeId,
40191
- ...pin,
41112
+ x: pin.x,
41113
+ y: pin.y,
41114
+ ...pin.connector ? { connector: true } : {},
40192
41115
  template: stencil.template
40193
41116
  });
40194
41117
  continue;
40195
41118
  }
41119
+ const line2 = pageShapes(sourceRoot).find((shape) => attribute2(shape, "ID") === copy8.shapeId);
41120
+ if (line2 && !line2.hasAttribute("Master") && isLineSheet2(line2)) {
41121
+ assertCloneLeaf(line2);
41122
+ assertUnlayeredShape(line2, document);
41123
+ assertShapeLocks(line2, document, ["LockSelect"]);
41124
+ assertGlueDroppable(sourceRoot, copy8.shapeId, copied);
41125
+ const pin = planLineCopy(line2);
41126
+ if (Math.abs(pin.x + edit.offsetX) > 1e6 || Math.abs(pin.y + edit.offsetY) > 1e6)
41127
+ fail("UNSUPPORTED_DUPLICATE", "Duplicated pins exceed coordinate limits.");
41128
+ size3(line2);
41129
+ plans.push({ source: line2, id: copy8.newShapeId, x: pin.x, y: pin.y, line: true });
41130
+ continue;
41131
+ }
40196
41132
  const source = admitted(sourceRoot, copy8.shapeId);
40197
41133
  assertCloneLeaf(source);
40198
41134
  assertUnlayeredShape(source, document);
40199
41135
  assertShapeLocks(source, document, ["LockSelect"]);
40200
- for (const connects of children2(sourceRoot, "Connects"))
40201
- for (const connection of children2(connects, "Connect"))
40202
- if (["FromSheet", "ToSheet"].some((name3) => attribute2(connection, name3) === copy8.shapeId))
41136
+ for (const connects2 of children2(sourceRoot, "Connects"))
41137
+ for (const connection of children2(connects2, "Connect"))
41138
+ if (attribute2(connection, "FromSheet") === copy8.shapeId)
40203
41139
  fail("UNSUPPORTED_DUPLICATE", "Glued shapes cannot be duplicated safely.");
40204
41140
  const x = numeric(formattingCell(source, "PinX")), y = numeric(formattingCell(source, "PinY"));
40205
41141
  for (const [name3, offset] of [
@@ -40214,6 +41150,9 @@ async function duplicateVisioShapes(pkg, pagePaths, roots2, document, edit, chec
40214
41150
  size3(source);
40215
41151
  plans.push({ source, id: copy8.newShapeId, x: x + edit.offsetX, y: y + edit.offsetY });
40216
41152
  }
41153
+ const connectorSources = plans.filter((plan) => plan.connector).map((plan) => plan.source);
41154
+ if (connectorSources.length)
41155
+ assertConnectorCopyApart(root2, connectorSources, edit.offsetX, edit.offsetY);
40217
41156
  const order = new Map(
40218
41157
  children2(children2(sourceRoot, "Shapes")[0], "Shape").map((source, index2) => [source, index2])
40219
41158
  );
@@ -40224,6 +41163,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots2, document, edit, chec
40224
41163
  check();
40225
41164
  const shape = root2.ownerDocument.importNode(plan.source, true);
40226
41165
  copyIdentity(shape, plan.id, names);
41166
+ if (plan.line) finishLineCopy(shape, edit.offsetX, edit.offsetY);
40227
41167
  for (const node3 of [shape, ...Array.from(shape.getElementsByTagName("*"))]) {
40228
41168
  const source = executableCellFormula(attribute2(node3, "F"));
40229
41169
  if (!source) continue;
@@ -40242,6 +41182,15 @@ async function duplicateVisioShapes(pkg, pagePaths, roots2, document, edit, chec
40242
41182
  )
40243
41183
  );
40244
41184
  }
41185
+ if (plan.line) {
41186
+ container.appendChild(shape);
41187
+ continue;
41188
+ }
41189
+ if (plan.connector) {
41190
+ finishConnectorCopy(shape, plan.id, edit.offsetX, edit.offsetY);
41191
+ container.appendChild(shape);
41192
+ continue;
41193
+ }
40245
41194
  if (plan.template) {
40246
41195
  for (const id3 of newIds) ids.add(id3);
40247
41196
  finishInstanceCopy(shape, plan.template, plan.x, plan.y, ids, check);
@@ -40258,7 +41207,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots2, document, edit, chec
40258
41207
  }
40259
41208
  container.appendChild(shape);
40260
41209
  }
40261
- const local = plans.filter((plan) => !plan.template);
41210
+ const local = plans.filter((plan) => !plan.template && !plan.line);
40262
41211
  if (changed.length) {
40263
41212
  await assertGeometryPackageScope(
40264
41213
  pkg,
@@ -40292,6 +41241,9 @@ async function duplicateVisioShapes(pkg, pagePaths, roots2, document, edit, chec
40292
41241
  }
40293
41242
  const dirty = /* @__PURE__ */ new Set([edit.pageId]);
40294
41243
  for (const id3 of recalculateVisioCells(roots2, changed, { check })) dirty.add(id3);
41244
+ for (const plan of plans)
41245
+ if (!plan.line && !plan.connector)
41246
+ for (const id3 of rerouteBlockedConnectors(roots2, edit.pageId, plan.id, check)) dirty.add(id3);
40295
41247
  return [...dirty];
40296
41248
  }
40297
41249
  function assertCloneLeaf(source) {
@@ -40622,9 +41574,10 @@ function deleteVisioShapes(roots2, document, edits, check, instances = /* @__PUR
40622
41574
  }
40623
41575
  releaseStencilGlue(roots2, removed);
40624
41576
  releaseDeletedGlue(roots2, removed);
40625
- assertVisioShapesUnreferenced(roots2, removed, { check });
41577
+ const frozen = assertVisioShapesUnreferenced(roots2, removed, { check, freeze: true });
40626
41578
  check();
40627
41579
  for (const shape of shapes) shape.parentNode.removeChild(shape);
41580
+ freezeVisioCells(frozen);
40628
41581
  for (const pageId2 of removed.keys())
40629
41582
  for (const container of children2(roots2.get(pageId2), "Connects"))
40630
41583
  if (!children2(container, "Connect").length) container.parentNode.removeChild(container);
@@ -40653,8 +41606,8 @@ function admittedShape(root2, document, shapeId2) {
40653
41606
  if (["1", "true"].includes(attribute2(shape, "Del") ?? "")) refuse3("The shape is deleted.");
40654
41607
  const local = cells(shape);
40655
41608
  if (isLineSheet(local)) refuse3("Lines and connectors (1D shapes) cannot change shape.");
40656
- for (const connects of children2(root2, "Connects"))
40657
- for (const connect of children2(connects, "Connect"))
41609
+ for (const connects2 of children2(root2, "Connects"))
41610
+ for (const connect of children2(connects2, "Connect"))
40658
41611
  if (["FromSheet", "ToSheet"].some((name3) => attribute2(connect, name3) === shapeId2))
40659
41612
  refuse3("Glued connectors would need rerouting, which is not supported yet.");
40660
41613
  if (children2(shape, "Section").some((section3) => attribute2(section3, "N") === "Controls"))
@@ -42097,8 +43050,8 @@ async function captureVisioClipboard(input, pageId2, shapeIds2, options2 = {}) {
42097
43050
  numeric(formattingCell(source, name3));
42098
43051
  evaluate(key({ pageId: pageId2, shapeId: id3, cell: name3 }));
42099
43052
  }
42100
- for (const connects of children2(root2, "Connects"))
42101
- for (const connection of children2(connects, "Connect"))
43053
+ for (const connects2 of children2(root2, "Connects"))
43054
+ for (const connection of children2(connects2, "Connect"))
42102
43055
  if (["FromSheet", "ToSheet"].some((name3) => attribute2(connection, name3) === id3))
42103
43056
  fail("UNSUPPORTED_CLIPBOARD", "Glued shapes cannot be captured safely.");
42104
43057
  }
@@ -42639,8 +43592,8 @@ function assertUnreferenced3(roots2, shapeId2, check) {
42639
43592
  if (reference2.test(executableCellFormula(attribute2(cell, "F")) ?? ""))
42640
43593
  fail("UNSUPPORTED_GUIDE_EDIT", "A shape formula refers to this guide.");
42641
43594
  }
42642
- for (const connects of children2(root2, "Connects"))
42643
- for (const row2 of children2(connects, "Connect"))
43595
+ for (const connects2 of children2(root2, "Connects"))
43596
+ for (const row2 of children2(connects2, "Connect"))
42644
43597
  if (attribute2(row2, "ToSheet") === shapeId2 || attribute2(row2, "FromSheet") === shapeId2)
42645
43598
  fail("UNSUPPORTED_GUIDE_EDIT", "Shapes are glued to this guide.");
42646
43599
  }
@@ -43017,6 +43970,7 @@ async function editVsdxTransaction(input, edits, options2, clock = {
43017
43970
  if (deleteOnly)
43018
43971
  for (const pageId2 of deleteVisioShapes(roots2, document, deletions, check, instanceDeletes))
43019
43972
  dirty.set(pages.get(pageId2), roots2.get(pageId2));
43973
+ const formulaDiagnostics = [];
43020
43974
  const noteTextSize = async (target2, root2) => {
43021
43975
  if (await measuresOwnText(root2, target2.shapeId, masterTemplate(pkg), check))
43022
43976
  clock.textSizes.push({ pageId: target2.pageId, shapeId: target2.shapeId });
@@ -43032,7 +43986,15 @@ async function editVsdxTransaction(input, edits, options2, clock = {
43032
43986
  roots2.set(command2.pageId, root2);
43033
43987
  }
43034
43988
  if (command2.type === "replace-plain-text" || command2.type === "replace-text-ranges") {
43035
- if (await (command2.type === "replace-plain-text" ? replaceScopedPlainText(pkg, new Set(pages.values()), roots2, document, command2, check) : replaceScopedTextRanges(pkg, new Set(pages.values()), roots2, document, command2, check))) {
43989
+ if (await (command2.type === "replace-plain-text" ? replaceScopedPlainText(
43990
+ pkg,
43991
+ new Set(pages.values()),
43992
+ roots2,
43993
+ document,
43994
+ command2,
43995
+ check,
43996
+ formulaDiagnostics
43997
+ ) : replaceScopedTextRanges(pkg, new Set(pages.values()), roots2, document, command2, check))) {
43036
43998
  dirty.set(path3, root2);
43037
43999
  textChanged = true;
43038
44000
  await noteTextSize(command2, root2);
@@ -43178,6 +44140,7 @@ async function editVsdxTransaction(input, edits, options2, clock = {
43178
44140
  bytes,
43179
44141
  changedParts: [...dirty.keys()],
43180
44142
  diagnostics: [
44143
+ ...formulaDiagnostics,
43181
44144
  ...pasteChanged ? [
43182
44145
  {
43183
44146
  code: "edit-paste-experimental",
@@ -47008,7 +47971,7 @@ function checkVisioDiagram(document, options2 = {}) {
47008
47971
  }
47009
47972
 
47010
47973
  // visio/ui/shape-report.ts
47011
- var TYPES2 = {
47974
+ var TYPES3 = {
47012
47975
  shape: "Shape",
47013
47976
  group: "Group",
47014
47977
  connector: "1-D shape",
@@ -47054,7 +48017,7 @@ function visioShapeReport(document, options2 = {}) {
47054
48017
  pageId: page.id,
47055
48018
  id: shape.id,
47056
48019
  name: shape.name,
47057
- type: TYPES2[shape.kind],
48020
+ type: TYPES3[shape.kind],
47058
48021
  master: shape.masterId ?? "",
47059
48022
  width: round5(shape.width),
47060
48023
  height: round5(shape.height),