ooxml-core 1.37.0 → 1.38.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 (335) hide show
  1. package/README.md +7 -0
  2. package/dist/automation/index.cjs +207 -207
  3. package/dist/automation/index.mjs +207 -207
  4. package/dist/{chunk-M2DFN3SP.mjs → chunk-XBIZIBTJ.mjs} +507 -10
  5. package/dist/collab/merge-values.d.ts +14 -0
  6. package/dist/collab/merge-values.d.ts.map +1 -0
  7. package/dist/docx/embedded.cjs +476 -474
  8. package/dist/docx/embedded.mjs +476 -474
  9. package/dist/docx/index.cjs +1075 -719
  10. package/dist/docx/index.d.ts +1 -0
  11. package/dist/docx/index.d.ts.map +1 -1
  12. package/dist/docx/index.mjs +1075 -720
  13. package/dist/docx/layout/index.cjs +4 -0
  14. package/dist/docx/layout/index.mjs +4 -0
  15. package/dist/docx/load/index.cjs +164 -164
  16. package/dist/docx/load/index.mjs +164 -164
  17. package/dist/docx/merge-snapshots.d.ts +9 -0
  18. package/dist/docx/merge-snapshots.d.ts.map +1 -0
  19. package/dist/docx/ui/index.cjs +155 -155
  20. package/dist/docx/ui/index.mjs +155 -155
  21. package/dist/embedding/index.cjs +207 -0
  22. package/dist/embedding/index.d.ts +3 -0
  23. package/dist/embedding/index.d.ts.map +1 -1
  24. package/dist/embedding/index.mjs +205 -1
  25. package/dist/embedding/onedrive/client.d.ts +4 -0
  26. package/dist/embedding/onedrive/client.d.ts.map +1 -0
  27. package/dist/embedding/onedrive/index.cjs +617 -0
  28. package/dist/embedding/onedrive/index.d.ts +6 -0
  29. package/dist/embedding/onedrive/index.d.ts.map +1 -0
  30. package/dist/embedding/onedrive/index.mjs +611 -0
  31. package/dist/embedding/onedrive/metadata.d.ts +6 -0
  32. package/dist/embedding/onedrive/metadata.d.ts.map +1 -0
  33. package/dist/embedding/onedrive/requests.d.ts +8 -0
  34. package/dist/embedding/onedrive/requests.d.ts.map +1 -0
  35. package/dist/embedding/onedrive/session.d.ts +4 -0
  36. package/dist/embedding/onedrive/session.d.ts.map +1 -0
  37. package/dist/embedding/onedrive/transport.d.ts +9 -0
  38. package/dist/embedding/onedrive/transport.d.ts.map +1 -0
  39. package/dist/embedding/onedrive/types.d.ts +86 -0
  40. package/dist/embedding/onedrive/types.d.ts.map +1 -0
  41. package/dist/embedding/onedrive/upload.d.ts +3 -0
  42. package/dist/embedding/onedrive/upload.d.ts.map +1 -0
  43. package/dist/embedding/storage-merge.d.ts +8 -0
  44. package/dist/embedding/storage-merge.d.ts.map +1 -0
  45. package/dist/embedding/storage-session.d.ts +7 -0
  46. package/dist/embedding/storage-session.d.ts.map +1 -0
  47. package/dist/embedding/versioned-storage.d.ts +67 -0
  48. package/dist/embedding/versioned-storage.d.ts.map +1 -0
  49. package/dist/index.cjs +1013 -340
  50. package/dist/index.mjs +1013 -340
  51. package/dist/opc/index.cjs +680 -216
  52. package/dist/opc/index.d.ts +1 -0
  53. package/dist/opc/index.d.ts.map +1 -1
  54. package/dist/opc/index.mjs +680 -217
  55. package/dist/opc/merge-snapshots.d.ts +26 -0
  56. package/dist/opc/merge-snapshots.d.ts.map +1 -0
  57. package/dist/pptx/automation/index.cjs +20 -6
  58. package/dist/pptx/automation/index.d.ts +8 -17
  59. package/dist/pptx/automation/index.d.ts.map +1 -1
  60. package/dist/pptx/automation/index.mjs +1 -1
  61. package/dist/pptx/automation/schemas/chart-formatting-schemas.d.ts +1 -3
  62. package/dist/pptx/automation/schemas/chart-formatting-schemas.d.ts.map +1 -1
  63. package/dist/pptx/automation/schemas/chart-schemas.d.ts +1 -3
  64. package/dist/pptx/automation/schemas/chart-schemas.d.ts.map +1 -1
  65. package/dist/pptx/automation/schemas/chart-user-shape-schemas.d.ts +1 -3
  66. package/dist/pptx/automation/schemas/chart-user-shape-schemas.d.ts.map +1 -1
  67. package/dist/pptx/automation/schemas/element-schemas.d.ts +1 -3
  68. package/dist/pptx/automation/schemas/element-schemas.d.ts.map +1 -1
  69. package/dist/pptx/automation/schemas/export-schemas.d.ts +1 -3
  70. package/dist/pptx/automation/schemas/export-schemas.d.ts.map +1 -1
  71. package/dist/pptx/automation/schemas/geometry-schemas.d.ts +1 -3
  72. package/dist/pptx/automation/schemas/geometry-schemas.d.ts.map +1 -1
  73. package/dist/pptx/automation/schemas/hyperlink-schemas.d.ts +1 -3
  74. package/dist/pptx/automation/schemas/hyperlink-schemas.d.ts.map +1 -1
  75. package/dist/pptx/automation/schemas/index.d.ts +1 -3
  76. package/dist/pptx/automation/schemas/index.d.ts.map +1 -1
  77. package/dist/pptx/automation/schemas/json-schemas.d.ts +1 -3
  78. package/dist/pptx/automation/schemas/json-schemas.d.ts.map +1 -1
  79. package/dist/pptx/automation/schemas/layout-schemas.d.ts +1 -3
  80. package/dist/pptx/automation/schemas/layout-schemas.d.ts.map +1 -1
  81. package/dist/pptx/automation/schemas/lock-schemas.d.ts +1 -3
  82. package/dist/pptx/automation/schemas/lock-schemas.d.ts.map +1 -1
  83. package/dist/pptx/automation/schemas/metadata-schemas.d.ts +1 -3
  84. package/dist/pptx/automation/schemas/metadata-schemas.d.ts.map +1 -1
  85. package/dist/pptx/automation/schemas/ole-schemas.d.ts +1 -3
  86. package/dist/pptx/automation/schemas/ole-schemas.d.ts.map +1 -1
  87. package/dist/pptx/automation/schemas/presentation-schemas.d.ts +1 -3
  88. package/dist/pptx/automation/schemas/presentation-schemas.d.ts.map +1 -1
  89. package/dist/pptx/automation/schemas/section-schemas.d.ts +1 -3
  90. package/dist/pptx/automation/schemas/section-schemas.d.ts.map +1 -1
  91. package/dist/pptx/automation/schemas/slide-schemas.d.ts +1 -3
  92. package/dist/pptx/automation/schemas/slide-schemas.d.ts.map +1 -1
  93. package/dist/pptx/automation/schemas/smartart-schemas.d.ts +1 -3
  94. package/dist/pptx/automation/schemas/smartart-schemas.d.ts.map +1 -1
  95. package/dist/pptx/automation/schemas/table-style-schemas.d.ts +1 -3
  96. package/dist/pptx/automation/schemas/table-style-schemas.d.ts.map +1 -1
  97. package/dist/pptx/automation/schemas/template-schemas.d.ts +1 -3
  98. package/dist/pptx/automation/schemas/template-schemas.d.ts.map +1 -1
  99. package/dist/pptx/automation/schemas/theme-schemas.d.ts +1 -3
  100. package/dist/pptx/automation/schemas/theme-schemas.d.ts.map +1 -1
  101. package/dist/pptx/automation/schemas/validation-schemas.d.ts +1 -3
  102. package/dist/pptx/automation/schemas/validation-schemas.d.ts.map +1 -1
  103. package/dist/pptx/chunks/{collaboration-text-codec-Du_XeE_i.d.ts → collaboration-text-codec-1VmwD3yq.d.ts} +1 -3
  104. package/dist/pptx/chunks/collaboration-text-codec-1VmwD3yq.d.ts.map +1 -0
  105. package/dist/pptx/chunks/{collaboration-text-merge-DWWWdT_t.d.ts → collaboration-text-merge-B-tth-0W.d.ts} +2 -4
  106. package/dist/pptx/chunks/collaboration-text-merge-B-tth-0W.d.ts.map +1 -0
  107. package/dist/pptx/chunks/{collaboration-text-positions-MMT3GkZi.d.ts → collaboration-text-positions-D-1Jo1Fz.d.ts} +1 -3
  108. package/dist/pptx/chunks/collaboration-text-positions-D-1Jo1Fz.d.ts.map +1 -0
  109. package/dist/pptx/chunks/{collaboration-text-session-D0NOLQk7.d.ts → collaboration-text-session-CWHTaWF4.d.ts} +4 -6
  110. package/dist/pptx/chunks/collaboration-text-session-CWHTaWF4.d.ts.map +1 -0
  111. package/dist/pptx/chunks/{collaboration-text-session-delta-CzJGrTKJ.d.ts → collaboration-text-session-delta-Dxzybssp.d.ts} +2 -4
  112. package/dist/pptx/chunks/collaboration-text-session-delta-Dxzybssp.d.ts.map +1 -0
  113. package/dist/pptx/chunks/{color-ref-DT599vEx.d.ts → color-ref-CwUQoKPJ.d.ts} +1 -3
  114. package/dist/pptx/chunks/color-ref-CwUQoKPJ.d.ts.map +1 -0
  115. package/dist/pptx/chunks/{elements-f3UbFph-.d.ts → elements-DheCTwi0.d.ts} +4 -54
  116. package/dist/pptx/chunks/elements-DheCTwi0.d.ts.map +1 -0
  117. package/dist/pptx/chunks/{index-Bp-1pGo1.d.ts → index-B4ofjG6_.d.ts} +6 -384
  118. package/dist/pptx/chunks/index-B4ofjG6_.d.ts.map +1 -0
  119. package/dist/pptx/chunks/{index-BnH2QjYm.d.ts → index-Jcce8TlI.d.ts} +5 -37
  120. package/dist/pptx/chunks/index-Jcce8TlI.d.ts.map +1 -0
  121. package/dist/pptx/chunks/{index-pLLN4OTz.d.ts → index-bgj0Ztnq.d.ts} +23 -543
  122. package/dist/pptx/chunks/index-bgj0Ztnq.d.ts.map +1 -0
  123. package/dist/pptx/chunks/{inspection-status-DjiWd_Aa.d.ts → inspection-status-TKac7eqb.d.ts} +1 -13
  124. package/dist/pptx/chunks/inspection-status-TKac7eqb.d.ts.map +1 -0
  125. package/dist/pptx/chunks/{schemas-fuDGetRe.d.ts → schemas-LHsDbVOw.d.ts} +1 -29
  126. package/dist/pptx/chunks/schemas-LHsDbVOw.d.ts.map +1 -0
  127. package/dist/pptx/chunks/{smart-art-CmOrPLLQ.d.ts → smart-art-DB37AsFP.d.ts} +2 -46
  128. package/dist/pptx/chunks/smart-art-DB37AsFP.d.ts.map +1 -0
  129. package/dist/pptx/chunks/{text-operations-D5sgspO6.d.ts → text-operations-CdgEnFuK.d.ts} +4 -32
  130. package/dist/pptx/chunks/text-operations-CdgEnFuK.d.ts.map +1 -0
  131. package/dist/pptx/chunks/{text-P9xVnXXf.d.ts → text-t_wJ2OwM.d.ts} +2 -12
  132. package/dist/pptx/chunks/text-t_wJ2OwM.d.ts.map +1 -0
  133. package/dist/pptx/cli/index.cjs +20 -6
  134. package/dist/pptx/cli/index.d.ts +1 -3
  135. package/dist/pptx/cli/index.d.ts.map +1 -1
  136. package/dist/pptx/converter/index.cjs +7 -0
  137. package/dist/pptx/converter/index.d.ts +1 -1
  138. package/dist/pptx/editor/ai/table-merge.d.ts +0 -2
  139. package/dist/pptx/editor/ai/table-merge.d.ts.map +1 -1
  140. package/dist/pptx/editor/loader/element-patch-walker.d.ts +0 -2
  141. package/dist/pptx/editor/loader/element-patch-walker.d.ts.map +1 -1
  142. package/dist/pptx/editor/loader/is-external-url.d.ts +0 -2
  143. package/dist/pptx/editor/loader/is-external-url.d.ts.map +1 -1
  144. package/dist/pptx/editor/loader/lazy-image-resolution.d.ts +0 -2
  145. package/dist/pptx/editor/loader/lazy-image-resolution.d.ts.map +1 -1
  146. package/dist/pptx/editor/loader/load-content-helpers.d.ts +0 -2
  147. package/dist/pptx/editor/loader/load-content-helpers.d.ts.map +1 -1
  148. package/dist/pptx/editor/loader/table-style-image-paths.d.ts +0 -2
  149. package/dist/pptx/editor/loader/table-style-image-paths.d.ts.map +1 -1
  150. package/dist/pptx/editor/loader/text-fill-image-paths.d.ts +0 -2
  151. package/dist/pptx/editor/loader/text-fill-image-paths.d.ts.map +1 -1
  152. package/dist/pptx/editor/render/bullet-list.d.ts +0 -2
  153. package/dist/pptx/editor/render/bullet-list.d.ts.map +1 -1
  154. package/dist/pptx/editor/render/bullet-toggle.d.ts +0 -2
  155. package/dist/pptx/editor/render/bullet-toggle.d.ts.map +1 -1
  156. package/dist/pptx/editor/render/chart-user-shape-edit.d.ts +0 -2
  157. package/dist/pptx/editor/render/chart-user-shape-edit.d.ts.map +1 -1
  158. package/dist/pptx/editor/render/clone.d.ts +0 -2
  159. package/dist/pptx/editor/render/clone.d.ts.map +1 -1
  160. package/dist/pptx/editor/render/collaboration-active-session.d.ts +0 -2
  161. package/dist/pptx/editor/render/collaboration-active-session.d.ts.map +1 -1
  162. package/dist/pptx/editor/render/collaboration-departure.d.ts +0 -2
  163. package/dist/pptx/editor/render/collaboration-departure.d.ts.map +1 -1
  164. package/dist/pptx/editor/render/collaboration-live-patch-target.d.ts +0 -2
  165. package/dist/pptx/editor/render/collaboration-live-patch-target.d.ts.map +1 -1
  166. package/dist/pptx/editor/render/collaboration-load-origin.d.ts +0 -2
  167. package/dist/pptx/editor/render/collaboration-load-origin.d.ts.map +1 -1
  168. package/dist/pptx/editor/render/collaboration-reconcile.d.ts +0 -2
  169. package/dist/pptx/editor/render/collaboration-reconcile.d.ts.map +1 -1
  170. package/dist/pptx/editor/render/collaboration-sync.d.ts +4 -8
  171. package/dist/pptx/editor/render/collaboration-sync.d.ts.map +1 -1
  172. package/dist/pptx/editor/render/collaboration-text-codec.d.ts +1 -1
  173. package/dist/pptx/editor/render/collaboration-text-lease.d.ts +0 -2
  174. package/dist/pptx/editor/render/collaboration-text-lease.d.ts.map +1 -1
  175. package/dist/pptx/editor/render/collaboration-text-merge.d.ts +1 -1
  176. package/dist/pptx/editor/render/collaboration-text-native-edit.d.ts +2 -4
  177. package/dist/pptx/editor/render/collaboration-text-native-edit.d.ts.map +1 -1
  178. package/dist/pptx/editor/render/collaboration-text-positions.d.ts +1 -1
  179. package/dist/pptx/editor/render/collaboration-text-projection.d.ts +1 -3
  180. package/dist/pptx/editor/render/collaboration-text-projection.d.ts.map +1 -1
  181. package/dist/pptx/editor/render/collaboration-text-session-apply.d.ts +3 -5
  182. package/dist/pptx/editor/render/collaboration-text-session-apply.d.ts.map +1 -1
  183. package/dist/pptx/editor/render/collaboration-text-session-delta.d.ts +1 -1
  184. package/dist/pptx/editor/render/collaboration-text-session-paragraph.d.ts +1 -3
  185. package/dist/pptx/editor/render/collaboration-text-session-paragraph.d.ts.map +1 -1
  186. package/dist/pptx/editor/render/collaboration-text-session.d.ts +1 -1
  187. package/dist/pptx/editor/render/collaboration-text-snapshot-positions.d.ts +2 -4
  188. package/dist/pptx/editor/render/collaboration-text-snapshot-positions.d.ts.map +1 -1
  189. package/dist/pptx/editor/render/custom-show-operations.d.ts +0 -2
  190. package/dist/pptx/editor/render/custom-show-operations.d.ts.map +1 -1
  191. package/dist/pptx/editor/render/deck-save-encryption.d.ts +0 -2
  192. package/dist/pptx/editor/render/deck-save-encryption.d.ts.map +1 -1
  193. package/dist/pptx/editor/render/editor-history.d.ts +0 -2
  194. package/dist/pptx/editor/render/editor-history.d.ts.map +1 -1
  195. package/dist/pptx/editor/render/editor-mutations.d.ts +0 -2
  196. package/dist/pptx/editor/render/editor-mutations.d.ts.map +1 -1
  197. package/dist/pptx/editor/render/element-locks.d.ts +0 -2
  198. package/dist/pptx/editor/render/element-locks.d.ts.map +1 -1
  199. package/dist/pptx/editor/render/element-operations.d.ts +0 -2
  200. package/dist/pptx/editor/render/element-operations.d.ts.map +1 -1
  201. package/dist/pptx/editor/render/element.d.ts +0 -2
  202. package/dist/pptx/editor/render/element.d.ts.map +1 -1
  203. package/dist/pptx/editor/render/find-replace.d.ts +2 -4
  204. package/dist/pptx/editor/render/find-replace.d.ts.map +1 -1
  205. package/dist/pptx/editor/render/font-family-update.d.ts +1 -3
  206. package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -1
  207. package/dist/pptx/editor/render/group-drill.d.ts +0 -2
  208. package/dist/pptx/editor/render/group-drill.d.ts.map +1 -1
  209. package/dist/pptx/editor/render/inline-list-body.d.ts +0 -2
  210. package/dist/pptx/editor/render/inline-list-body.d.ts.map +1 -1
  211. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +1 -3
  212. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -1
  213. package/dist/pptx/editor/render/remap-empty-paragraph.d.ts +0 -2
  214. package/dist/pptx/editor/render/remap-empty-paragraph.d.ts.map +1 -1
  215. package/dist/pptx/editor/render/remap-paragraph-sources.d.ts +0 -2
  216. package/dist/pptx/editor/render/remap-paragraph-sources.d.ts.map +1 -1
  217. package/dist/pptx/editor/render/remap-text-bullets.d.ts +0 -2
  218. package/dist/pptx/editor/render/remap-text-bullets.d.ts.map +1 -1
  219. package/dist/pptx/editor/render/remap-text.d.ts +0 -2
  220. package/dist/pptx/editor/render/remap-text.d.ts.map +1 -1
  221. package/dist/pptx/editor/render/schema-label-keys.d.ts +0 -2
  222. package/dist/pptx/editor/render/schema-label-keys.d.ts.map +1 -1
  223. package/dist/pptx/editor/render/section-operations.d.ts +0 -2
  224. package/dist/pptx/editor/render/section-operations.d.ts.map +1 -1
  225. package/dist/pptx/editor/render/slide-background-patch.d.ts +0 -2
  226. package/dist/pptx/editor/render/slide-background-patch.d.ts.map +1 -1
  227. package/dist/pptx/editor/render/slide-operations.d.ts +0 -2
  228. package/dist/pptx/editor/render/slide-operations.d.ts.map +1 -1
  229. package/dist/pptx/editor/render/slide-search.d.ts +0 -2
  230. package/dist/pptx/editor/render/slide-search.d.ts.map +1 -1
  231. package/dist/pptx/editor/render/slide-size-rescale.d.ts +0 -2
  232. package/dist/pptx/editor/render/slide-size-rescale.d.ts.map +1 -1
  233. package/dist/pptx/editor/render/slide-transition-edits.d.ts +0 -2
  234. package/dist/pptx/editor/render/slide-transition-edits.d.ts.map +1 -1
  235. package/dist/pptx/editor/render/table-cell-edit.d.ts +0 -2
  236. package/dist/pptx/editor/render/table-cell-edit.d.ts.map +1 -1
  237. package/dist/pptx/editor/render/table-cell-merge.d.ts +0 -2
  238. package/dist/pptx/editor/render/table-cell-merge.d.ts.map +1 -1
  239. package/dist/pptx/editor/render/table-data-grid-ops.d.ts +0 -2
  240. package/dist/pptx/editor/render/table-data-grid-ops.d.ts.map +1 -1
  241. package/dist/pptx/editor/render/table-layout.d.ts +0 -2
  242. package/dist/pptx/editor/render/table-layout.d.ts.map +1 -1
  243. package/dist/pptx/editor/render/table-merge.d.ts +0 -2
  244. package/dist/pptx/editor/render/table-merge.d.ts.map +1 -1
  245. package/dist/pptx/editor/render/table-style-editor-descriptor.d.ts +0 -2
  246. package/dist/pptx/editor/render/table-style-editor-descriptor.d.ts.map +1 -1
  247. package/dist/pptx/editor/render/table-style-editor-edit.d.ts +0 -2
  248. package/dist/pptx/editor/render/table-style-editor-edit.d.ts.map +1 -1
  249. package/dist/pptx/editor/render/table-style-editor-parts.d.ts +0 -2
  250. package/dist/pptx/editor/render/table-style-editor-parts.d.ts.map +1 -1
  251. package/dist/pptx/editor/render/table-style-map-edits.d.ts +0 -2
  252. package/dist/pptx/editor/render/table-style-map-edits.d.ts.map +1 -1
  253. package/dist/pptx/editor/render/template-editing.d.ts +0 -2
  254. package/dist/pptx/editor/render/template-editing.d.ts.map +1 -1
  255. package/dist/pptx/editor/render/text-content-style.d.ts +1 -3
  256. package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -1
  257. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +2 -4
  258. package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -1
  259. package/dist/pptx/editor/render/text-segment-paragraph-break.d.ts +0 -2
  260. package/dist/pptx/editor/render/text-segment-paragraph-break.d.ts.map +1 -1
  261. package/dist/pptx/editor/render/text-style-scope.d.ts +2 -4
  262. package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -1
  263. package/dist/pptx/editor/render/text-theme.d.ts +0 -2
  264. package/dist/pptx/editor/render/text-theme.d.ts.map +1 -1
  265. package/dist/pptx/editor/render/theme-editor-model.d.ts +0 -2
  266. package/dist/pptx/editor/render/theme-editor-model.d.ts.map +1 -1
  267. package/dist/pptx/editor/render/theme-editor-presets.d.ts +0 -2
  268. package/dist/pptx/editor/render/theme-editor-presets.d.ts.map +1 -1
  269. package/dist/pptx/editor/render/update-text-segment-style.d.ts +1 -3
  270. package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -1
  271. package/dist/pptx/index.cjs +1687 -1159
  272. package/dist/pptx/index.d.ts +10 -10
  273. package/dist/pptx/index.mjs +1 -1
  274. package/dist/pptx/node/index.d.ts +1 -3
  275. package/dist/pptx/node/index.d.ts.map +1 -1
  276. package/dist/pptx/signature-node/index.d.ts +1 -21
  277. package/dist/pptx/signature-node/index.d.ts.map +1 -1
  278. package/dist/pptx/smartart-layouts/index.d.ts +1 -7
  279. package/dist/pptx/smartart-layouts/index.d.ts.map +1 -1
  280. package/dist/pptx/ui/index.d.ts +1 -9
  281. package/dist/pptx/ui/index.d.ts.map +1 -1
  282. package/dist/teams/index.cjs +215 -201
  283. package/dist/teams/index.mjs +215 -201
  284. package/dist/text/index.cjs +193 -0
  285. package/dist/text/index.d.ts +1 -0
  286. package/dist/text/index.d.ts.map +1 -1
  287. package/dist/text/index.mjs +193 -1
  288. package/dist/text/merge-three-way.d.ts +9 -0
  289. package/dist/text/merge-three-way.d.ts.map +1 -0
  290. package/dist/visio/collab/index.cjs +226 -7
  291. package/dist/visio/collab/index.d.ts +1 -0
  292. package/dist/visio/collab/index.d.ts.map +1 -1
  293. package/dist/visio/collab/index.mjs +225 -7
  294. package/dist/visio/collab/merge-snapshots.d.ts +14 -0
  295. package/dist/visio/collab/merge-snapshots.d.ts.map +1 -0
  296. package/dist/visio/index.cjs +9 -9
  297. package/dist/visio/index.mjs +9 -9
  298. package/dist/visio/ui/index.cjs +9 -9
  299. package/dist/visio/ui/index.mjs +9 -9
  300. package/dist/xlsx/collab/index.cjs +49966 -507
  301. package/dist/xlsx/collab/index.d.ts +1 -0
  302. package/dist/xlsx/collab/index.d.ts.map +1 -1
  303. package/dist/xlsx/collab/index.mjs +49961 -507
  304. package/dist/xlsx/collab/merge-residual.d.ts +16 -0
  305. package/dist/xlsx/collab/merge-residual.d.ts.map +1 -0
  306. package/dist/xlsx/collab/merge-snapshots.d.ts +8 -0
  307. package/dist/xlsx/collab/merge-snapshots.d.ts.map +1 -0
  308. package/dist/xlsx/index.cjs +202 -202
  309. package/dist/xlsx/index.mjs +202 -202
  310. package/dist/xlsx/load/index.cjs +155 -155
  311. package/dist/xlsx/load/index.mjs +155 -155
  312. package/dist/xlsx/ui/index.cjs +202 -202
  313. package/dist/xlsx/ui/index.mjs +202 -202
  314. package/dist/xml/index.cjs +390 -22
  315. package/dist/xml/index.d.ts +1 -0
  316. package/dist/xml/index.d.ts.map +1 -1
  317. package/dist/xml/index.mjs +390 -23
  318. package/dist/xml/merge-three-way.d.ts +16 -0
  319. package/dist/xml/merge-three-way.d.ts.map +1 -0
  320. package/package.json +13 -8
  321. package/dist/pptx/chunks/collaboration-text-codec-Du_XeE_i.d.ts.map +0 -1
  322. package/dist/pptx/chunks/collaboration-text-merge-DWWWdT_t.d.ts.map +0 -1
  323. package/dist/pptx/chunks/collaboration-text-positions-MMT3GkZi.d.ts.map +0 -1
  324. package/dist/pptx/chunks/collaboration-text-session-D0NOLQk7.d.ts.map +0 -1
  325. package/dist/pptx/chunks/collaboration-text-session-delta-CzJGrTKJ.d.ts.map +0 -1
  326. package/dist/pptx/chunks/color-ref-DT599vEx.d.ts.map +0 -1
  327. package/dist/pptx/chunks/elements-f3UbFph-.d.ts.map +0 -1
  328. package/dist/pptx/chunks/index-BnH2QjYm.d.ts.map +0 -1
  329. package/dist/pptx/chunks/index-Bp-1pGo1.d.ts.map +0 -1
  330. package/dist/pptx/chunks/index-pLLN4OTz.d.ts.map +0 -1
  331. package/dist/pptx/chunks/inspection-status-DjiWd_Aa.d.ts.map +0 -1
  332. package/dist/pptx/chunks/schemas-fuDGetRe.d.ts.map +0 -1
  333. package/dist/pptx/chunks/smart-art-CmOrPLLQ.d.ts.map +0 -1
  334. package/dist/pptx/chunks/text-P9xVnXXf.d.ts.map +0 -1
  335. package/dist/pptx/chunks/text-operations-D5sgspO6.d.ts.map +0 -1
@@ -158,28 +158,28 @@ var MARKUP_SKIPS = [
158
158
  ["<![CDATA[", "]]>"],
159
159
  ["<?", "?>"]
160
160
  ];
161
- function checkXmlLimits(xml, label, limits = {}) {
161
+ function checkXmlLimits(xml2, label, limits = {}) {
162
162
  const maxDepth = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
163
163
  const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
164
164
  let depth = 0;
165
165
  let nodes = 0;
166
- let at = xml.indexOf("<");
166
+ let at = xml2.indexOf("<");
167
167
  while (at !== -1) {
168
- const skip = MARKUP_SKIPS.find(([open]) => xml.startsWith(open, at));
168
+ const skip = MARKUP_SKIPS.find(([open]) => xml2.startsWith(open, at));
169
169
  if (skip) {
170
- const end = xml.indexOf(skip[1], at + skip[0].length);
170
+ const end = xml2.indexOf(skip[1], at + skip[0].length);
171
171
  if (end === -1) return;
172
- at = xml.indexOf("<", end + skip[1].length);
172
+ at = xml2.indexOf("<", end + skip[1].length);
173
173
  continue;
174
174
  }
175
175
  TAG_RE.lastIndex = at;
176
- const match = TAG_RE.exec(xml);
176
+ const match = TAG_RE.exec(xml2);
177
177
  if (!match) {
178
- at = xml.indexOf("<", at + 1);
178
+ at = xml2.indexOf("<", at + 1);
179
179
  continue;
180
180
  }
181
181
  const [, closing, , selfClosing] = match;
182
- at = xml.indexOf("<", at + match[0].length);
182
+ at = xml2.indexOf("<", at + match[0].length);
183
183
  if (closing) {
184
184
  depth--;
185
185
  continue;
@@ -201,11 +201,11 @@ function checkXmlLimits(xml, label, limits = {}) {
201
201
  }
202
202
  var CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
203
203
  var crlfDeclarations = /* @__PURE__ */ new WeakSet();
204
- function parseXml(xml, options = {}) {
204
+ function parseXml(xml2, options = {}) {
205
205
  const label = options.label ?? "OOXML";
206
- if (/<!DOCTYPE|<!ENTITY/i.test(xml))
206
+ if (/<!DOCTYPE|<!ENTITY/i.test(xml2))
207
207
  throw new Error(`${label} XML with DTD or entity declarations is not supported`);
208
- checkXmlLimits(xml, label, options.limits);
208
+ checkXmlLimits(xml2, label, options.limits);
209
209
  let parseError = "";
210
210
  let parsed;
211
211
  try {
@@ -213,7 +213,7 @@ function parseXml(xml, options = {}) {
213
213
  onError: (level, message) => {
214
214
  if (level !== "warning" || options.warningsAsErrors) parseError = message;
215
215
  }
216
- }).parseFromString(xml, "application/xml");
216
+ }).parseFromString(xml2, "application/xml");
217
217
  } catch (error) {
218
218
  throw new Error(
219
219
  `Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}`,
@@ -222,12 +222,12 @@ function parseXml(xml, options = {}) {
222
222
  }
223
223
  if (parseError || !parsed.documentElement)
224
224
  throw new Error(`Invalid ${label} XML: ${parseError || "missing root element"}`);
225
- if (CRLF_DECLARATION.test(xml)) crlfDeclarations.add(parsed);
225
+ if (CRLF_DECLARATION.test(xml2)) crlfDeclarations.add(parsed);
226
226
  return parsed;
227
227
  }
228
228
  var buildXml = (node) => {
229
- const xml = new xmldom.XMLSerializer().serializeToString(node);
230
- return crlfDeclarations.has(node) ? xml.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml;
229
+ const xml2 = new xmldom.XMLSerializer().serializeToString(node);
230
+ return crlfDeclarations.has(node) ? xml2.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml2;
231
231
  };
232
232
  var isElement = (node) => node.nodeType === 1;
233
233
  var elements = (parent) => Array.from(parent.childNodes).filter(isElement);
@@ -242,11 +242,378 @@ function attr(element, local, ns, prefix) {
242
242
  }
243
243
  var relAttr = (element, local) => attr(element, local, NS.r, "r");
244
244
 
245
+ // text/text-diff.ts
246
+ var isLowSurrogate = (text, at) => {
247
+ const code = text.charCodeAt(at);
248
+ return code >= 56320 && code <= 57343;
249
+ };
250
+ function shortestEdit(n, m, same2, maxEdits) {
251
+ const max = Math.min(n + m, maxEdits);
252
+ const offset = max + 1;
253
+ const v = new Int32Array(2 * max + 3);
254
+ const trace = [];
255
+ for (let d = 0; d <= max; d++) {
256
+ for (let k = -d; k <= d; k += 2) {
257
+ const down = k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1];
258
+ let x = down ? v[offset + k + 1] : v[offset + k - 1] + 1;
259
+ let y = x - k;
260
+ while (x < n && y < m && same2(x, y)) {
261
+ x++;
262
+ y++;
263
+ }
264
+ v[offset + k] = x;
265
+ if (x >= n && y >= m) return backtrack(trace, n, m, d);
266
+ }
267
+ trace.push(v.slice(offset - d, offset + d + 1));
268
+ }
269
+ return void 0;
270
+ }
271
+ function backtrack(trace, n, m, d) {
272
+ const edits = [];
273
+ let x = n;
274
+ let y = m;
275
+ for (let step = d; step > 0; step--) {
276
+ const previous = trace[step - 1];
277
+ const at = (k2) => previous[k2 + step - 1];
278
+ const k = x - y;
279
+ const down = k === -step || k !== step && at(k - 1) < at(k + 1);
280
+ const before = down ? k + 1 : k - 1;
281
+ const startX = at(before);
282
+ const startY = startX - before;
283
+ edits.push(down ? [startX, startY, true] : [startX, startY, false]);
284
+ x = startX;
285
+ y = startY;
286
+ }
287
+ return edits.reverse();
288
+ }
289
+ function changesOf(edits) {
290
+ const changes = [];
291
+ for (const [x, y, inserts] of edits) {
292
+ const last = changes.at(-1);
293
+ if (last && last.fromEnd === x && last.toEnd === y) {
294
+ if (inserts) last.toEnd++;
295
+ else last.fromEnd++;
296
+ } else
297
+ changes.push({
298
+ fromStart: x,
299
+ fromEnd: inserts ? x : x + 1,
300
+ toStart: y,
301
+ toEnd: inserts ? y + 1 : y
302
+ });
303
+ }
304
+ return changes;
305
+ }
306
+ function characterChanges(a, b, maxEdits) {
307
+ const edits = shortestEdit(
308
+ a.length,
309
+ b.length,
310
+ (x, y) => a.charCodeAt(x) === b.charCodeAt(y),
311
+ maxEdits
312
+ );
313
+ return edits && changesOf(edits);
314
+ }
315
+ var TOKEN = /[\p{L}\p{N}\p{M}]+|\s+|[\s\S]/gu;
316
+ function tokensOf(text, ids) {
317
+ const tokens = [];
318
+ const starts = [];
319
+ for (const match of text.matchAll(TOKEN)) {
320
+ let id = ids.get(match[0]);
321
+ if (id === void 0) ids.set(match[0], id = ids.size);
322
+ tokens.push(id);
323
+ starts.push(match.index);
324
+ }
325
+ starts.push(text.length);
326
+ return { tokens, starts };
327
+ }
328
+ function tokenChanges(a, b, maxEdits) {
329
+ const ids = /* @__PURE__ */ new Map();
330
+ const from = tokensOf(a, ids);
331
+ const to = tokensOf(b, ids);
332
+ const edits = shortestEdit(
333
+ from.tokens.length,
334
+ to.tokens.length,
335
+ (x, y) => from.tokens[x] === to.tokens[y],
336
+ maxEdits
337
+ );
338
+ if (!edits) return void 0;
339
+ let budget = maxEdits;
340
+ return changesOf(edits).flatMap((stretch) => {
341
+ const change = {
342
+ fromStart: from.starts[stretch.fromStart],
343
+ fromEnd: from.starts[stretch.fromEnd],
344
+ toStart: to.starts[stretch.toStart],
345
+ toEnd: to.starts[stretch.toEnd]
346
+ };
347
+ const inner = change.fromEnd > change.fromStart && change.toEnd > change.toStart ? characterChanges(
348
+ a.slice(change.fromStart, change.fromEnd),
349
+ b.slice(change.toStart, change.toEnd),
350
+ budget
351
+ ) : void 0;
352
+ if (!inner) return [change];
353
+ for (const found of inner)
354
+ budget -= found.fromEnd - found.fromStart + found.toEnd - found.toStart;
355
+ return inner.map((found) => ({
356
+ fromStart: found.fromStart + change.fromStart,
357
+ fromEnd: found.fromEnd + change.fromStart,
358
+ toStart: found.toStart + change.toStart,
359
+ toEnd: found.toEnd + change.toStart
360
+ }));
361
+ });
362
+ }
363
+ function diffText(from, to, maxEdits = 500) {
364
+ let start = 0;
365
+ while (start < from.length && start < to.length && from.charCodeAt(start) === to.charCodeAt(start))
366
+ start++;
367
+ let end = 0;
368
+ while (end < from.length - start && end < to.length - start && from.charCodeAt(from.length - 1 - end) === to.charCodeAt(to.length - 1 - end))
369
+ end++;
370
+ const a = from.slice(start, from.length - end);
371
+ const b = to.slice(start, to.length - end);
372
+ if (!a.length && !b.length) return [];
373
+ const found = a.length && b.length ? characterChanges(a, b, maxEdits) ?? tokenChanges(a, b, maxEdits) : void 0;
374
+ const changes = found ?? [{ fromStart: 0, fromEnd: a.length, toStart: 0, toEnd: b.length }];
375
+ const result = [];
376
+ for (const change of changes) {
377
+ const placed = {
378
+ fromStart: change.fromStart + start,
379
+ fromEnd: change.fromEnd + start,
380
+ toStart: change.toStart + start,
381
+ toEnd: change.toEnd + start
382
+ };
383
+ if (placed.fromStart > 0 && placed.toStart > 0 && (isLowSurrogate(from, placed.fromStart) || isLowSurrogate(to, placed.toStart))) {
384
+ placed.fromStart--;
385
+ placed.toStart--;
386
+ }
387
+ if (isLowSurrogate(from, placed.fromEnd) || isLowSurrogate(to, placed.toEnd)) {
388
+ placed.fromEnd++;
389
+ placed.toEnd++;
390
+ }
391
+ const last = result.at(-1);
392
+ if (last && placed.fromStart <= last.fromEnd) {
393
+ last.fromEnd = Math.max(last.fromEnd, placed.fromEnd);
394
+ last.toEnd = Math.max(last.toEnd, placed.toEnd);
395
+ } else result.push(placed);
396
+ }
397
+ return result;
398
+ }
399
+
400
+ // text/merge-three-way.ts
401
+ function mergeTextThreeWay(base, local, remote) {
402
+ if (local === remote || base === remote) return { status: "merged", text: local };
403
+ if (base === local) return { status: "merged", text: remote };
404
+ if (Math.max(base.length, local.length, remote.length) > 1e6)
405
+ return { status: "unresolved" };
406
+ const changes = (value) => diffText(base, value).map((change) => ({
407
+ start: change.fromStart,
408
+ end: change.fromEnd,
409
+ text: value.slice(change.toStart, change.toEnd)
410
+ }));
411
+ const edits = changes(local);
412
+ for (const next of changes(remote)) {
413
+ if (edits.some(
414
+ (edit) => edit.start === next.start && edit.end === next.end && edit.text === next.text
415
+ ))
416
+ continue;
417
+ if (edits.some((edit) => {
418
+ if (edit.start === edit.end && next.start === next.end) return false;
419
+ if (edit.start === edit.end) return edit.start > next.start && edit.start < next.end;
420
+ if (next.start === next.end) return next.start > edit.start && next.start < edit.end;
421
+ return edit.start < next.end && next.start < edit.end;
422
+ }))
423
+ return { status: "unresolved" };
424
+ edits.push(next);
425
+ }
426
+ edits.sort(
427
+ (a, b) => a.start - b.start || a.end - b.end || (a.text < b.text ? -1 : a.text > b.text ? 1 : 0)
428
+ );
429
+ let text = "", cursor = 0;
430
+ for (const edit of edits) {
431
+ text += base.slice(cursor, edit.start) + edit.text;
432
+ cursor = edit.end;
433
+ }
434
+ return { status: "merged", text: text + base.slice(cursor) };
435
+ }
436
+
437
+ // xml/merge-three-way.ts
438
+ var tag = (node) => `${node.namespaceURI ?? ""}|${node.localName ?? node.tagName}`;
439
+ var xml = (node) => node ? buildXml(node) : void 0;
440
+ function childrenByKey(parent, options, repeated) {
441
+ const result = /* @__PURE__ */ new Map();
442
+ const counts = /* @__PURE__ */ new Map();
443
+ for (const child of elements(parent)) {
444
+ const name = tag(child), explicit = options.keyElement?.(child, parent);
445
+ const index = counts.get(name) ?? 0;
446
+ counts.set(name, index + 1);
447
+ if (!explicit && repeated.has(name) && !options.allowPositional?.(parent))
448
+ throw new Error("Ambiguous repeated elements");
449
+ const key = explicit ? `${name}@${explicit}` : `${name}#${index}`;
450
+ if (result.has(key)) throw new Error("Duplicate element identity");
451
+ result.set(key, child);
452
+ }
453
+ return result;
454
+ }
455
+ function orderKeys(base, local, remote) {
456
+ const same2 = (a, b) => a.length === b.length && a.every((key, index) => key === b[index]);
457
+ if (same2(base, local)) return [...remote];
458
+ if (same2(base, remote) || same2(local, remote)) return [...local];
459
+ const keys = [.../* @__PURE__ */ new Set([...remote, ...local])].sort();
460
+ const edges = new Map(keys.map((key) => [key, /* @__PURE__ */ new Set()]));
461
+ const degree = new Map(keys.map((key) => [key, 0]));
462
+ for (const sequence of [local, remote])
463
+ for (let i = 1; i < sequence.length; i++) {
464
+ const previous = sequence[i - 1], next = sequence[i];
465
+ if (!edges.get(previous).has(next)) {
466
+ edges.get(previous).add(next);
467
+ degree.set(next, degree.get(next) + 1);
468
+ }
469
+ }
470
+ const out = [];
471
+ const ready = keys.filter((key) => degree.get(key) === 0);
472
+ while (ready.length) {
473
+ const next = ready.sort().shift();
474
+ out.push(next);
475
+ for (const key of edges.get(next)) {
476
+ degree.set(key, degree.get(key) - 1);
477
+ if (degree.get(key) === 0) ready.push(key);
478
+ }
479
+ }
480
+ return out.length === keys.length ? out : void 0;
481
+ }
482
+ function mergeXmlThreeWay(baseXml, localXml, remoteXml, options = {}) {
483
+ if (localXml === remoteXml || baseXml === remoteXml) return { status: "merged", xml: localXml };
484
+ if (baseXml === localXml) return { status: "merged", xml: remoteXml };
485
+ const issues = [];
486
+ try {
487
+ let merge2 = function(b, l, r, path) {
488
+ const bx = xml(b), lx = xml(l), rx = xml(r);
489
+ if (lx === rx || bx === rx) return l ? copy(l) : void 0;
490
+ if (bx === lx) return r ? copy(r) : void 0;
491
+ if (!b && l && r && tag(l) === tag(r) && !elements(l).length && !elements(r).length) {
492
+ const resolved = options.resolveText?.(r, l, r);
493
+ if (resolved !== void 0) {
494
+ const node = copy(r);
495
+ node.textContent = resolved;
496
+ return node;
497
+ }
498
+ }
499
+ if (!b || !l || !r || tag(b) !== tag(l) || tag(b) !== tag(r)) {
500
+ issues.push(`${path}: overlapping structural changes`);
501
+ return void 0;
502
+ }
503
+ const out = remote.createElementNS(r.namespaceURI, r.tagName);
504
+ const attrs = (node) => new Map(
505
+ Array.from(node.attributes).map((a) => [
506
+ `${a.namespaceURI ?? ""}|${a.localName ?? a.name}`,
507
+ a
508
+ ])
509
+ );
510
+ const ba = attrs(b), la = attrs(l), ra = attrs(r);
511
+ for (const key of /* @__PURE__ */ new Set([...ba.keys(), ...la.keys(), ...ra.keys()])) {
512
+ const old = ba.get(key)?.value, left = la.get(key)?.value, right = ra.get(key)?.value;
513
+ const value = left === right || right === old ? left : left === old ? right : void 0;
514
+ if (left !== right && left !== old && right !== old) {
515
+ issues.push(`${path}: overlapping attribute ${key}`);
516
+ continue;
517
+ }
518
+ const source = ra.get(key) ?? la.get(key) ?? ba.get(key);
519
+ if (value !== void 0) out.setAttributeNS(source.namespaceURI, source.name, value);
520
+ }
521
+ const lists = [b, l, r].map(elements);
522
+ if (lists.every((list) => list.length === 0)) {
523
+ if ([b, l, r].some(
524
+ (node) => Array.from(node.childNodes).some(
525
+ (child) => child.nodeType !== 3 && child.nodeType !== 4
526
+ )
527
+ )) {
528
+ issues.push(`${path}: non-text leaf content requires explicit preservation`);
529
+ return void 0;
530
+ }
531
+ const texts = [b, l, r].map((node) => node.textContent ?? "");
532
+ const override = options.resolveText?.(b, l, r);
533
+ const value = override !== void 0 ? { status: "merged", text: override } : texts[1] === texts[2] || texts[0] === texts[2] ? { status: "merged", text: texts[1] } : texts[0] === texts[1] ? { status: "merged", text: texts[2] } : options.allowText?.(b) ? mergeTextThreeWay(texts[0], texts[1], texts[2]) : { status: "unresolved" };
534
+ if (value.status !== "merged") issues.push(`${path}: overlapping text changes`);
535
+ else if (value.text) out.appendChild(remote.createTextNode(value.text));
536
+ return out;
537
+ }
538
+ if ([b, l, r].some(
539
+ (node) => Array.from(node.childNodes).some(
540
+ (child) => child.nodeType !== 1 && (child.nodeType !== 3 || Boolean(child.textContent?.trim()))
541
+ )
542
+ )) {
543
+ issues.push(`${path}: mixed content cannot be matched safely`);
544
+ return void 0;
545
+ }
546
+ const repeated = /* @__PURE__ */ new Set();
547
+ const groups = lists.map((list) => {
548
+ const grouped = /* @__PURE__ */ new Map();
549
+ for (const child of list) {
550
+ const name = tag(child), group = grouped.get(name) ?? [];
551
+ group.push(child);
552
+ grouped.set(name, group);
553
+ if (group.length > 1) repeated.add(name);
554
+ }
555
+ return grouped;
556
+ });
557
+ for (const name of repeated) {
558
+ const rows = groups.map((group) => group.get(name) ?? []);
559
+ if (rows.some((row) => row.some((child) => options.keyElement?.(child, b) !== void 0)))
560
+ continue;
561
+ if (rows.some((row) => row.length !== rows[0].length)) {
562
+ issues.push(`${path}: unkeyed structural changes`);
563
+ return void 0;
564
+ }
565
+ const before = rows[0].map((child) => buildXml(child));
566
+ const known = new Set(before);
567
+ for (const row of rows.slice(1))
568
+ if (row.some((child, i) => {
569
+ const value = buildXml(child);
570
+ return before[i] !== value && known.has(value);
571
+ })) {
572
+ issues.push(`${path}: reordered unkeyed elements`);
573
+ return void 0;
574
+ }
575
+ }
576
+ let maps;
577
+ try {
578
+ maps = [b, l, r].map((parent) => childrenByKey(parent, options, repeated));
579
+ } catch {
580
+ issues.push(`${path}: ambiguous element identities`);
581
+ return void 0;
582
+ }
583
+ const [bm, lm, rm] = maps;
584
+ const merged = /* @__PURE__ */ new Map();
585
+ for (const key of /* @__PURE__ */ new Set([...bm.keys(), ...lm.keys(), ...rm.keys()])) {
586
+ const node = merge2(bm.get(key), lm.get(key), rm.get(key), `${path}/${key}`);
587
+ if (node) merged.set(key, node);
588
+ }
589
+ const surviving = (map) => [...map.keys()].filter((key) => merged.has(key));
590
+ const order = orderKeys(surviving(bm), surviving(lm), surviving(rm));
591
+ if (!order) {
592
+ issues.push(`${path}: incompatible element order`);
593
+ return void 0;
594
+ }
595
+ for (const key of order) out.appendChild(merged.get(key));
596
+ return out;
597
+ };
598
+ var merge = merge2;
599
+ const base = parseXml(baseXml, { warningsAsErrors: true });
600
+ const local = parseXml(localXml, { warningsAsErrors: true });
601
+ const remote = parseXml(remoteXml, { warningsAsErrors: true });
602
+ const copy = (node) => remote.importNode(node, true);
603
+ const root = merge2(base.documentElement, local.documentElement, remote.documentElement, "root");
604
+ if (!root || issues.length) return { status: "unresolved", issues };
605
+ remote.replaceChild(root, remote.documentElement);
606
+ return { status: "merged", xml: buildXml(remote) };
607
+ } catch {
608
+ return { status: "unresolved", issues: ["Invalid or unsupported XML input"] };
609
+ }
610
+ }
611
+
245
612
  // opc/relationships.ts
246
- function parseRelationships(xml) {
613
+ function parseRelationships(xml2) {
247
614
  const map = /* @__PURE__ */ new Map();
248
- if (!xml) return map;
249
- const root = parseXml(xml).documentElement;
615
+ if (!xml2) return map;
616
+ const root = parseXml(xml2).documentElement;
250
617
  for (const node of elements(root)) {
251
618
  if (node.localName !== "Relationship") continue;
252
619
  const id = node.getAttribute("Id");
@@ -293,11 +660,11 @@ var getRelationshipId = (element) => relAttr(element, "id") || void 0;
293
660
 
294
661
  // opc/content-types.ts
295
662
  var escapeAttr2 = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
296
- function parseContentTypes(xml) {
663
+ function parseContentTypes(xml2) {
297
664
  const defaults = /* @__PURE__ */ new Map();
298
665
  const overrides = /* @__PURE__ */ new Map();
299
- if (!xml) return { defaults, overrides };
300
- for (const node of elements(parseXml(xml).documentElement)) {
666
+ if (!xml2) return { defaults, overrides };
667
+ for (const node of elements(parseXml(xml2).documentElement)) {
301
668
  const contentType = node.getAttribute("ContentType");
302
669
  if (!contentType) continue;
303
670
  if (node.localName === "Default") {
@@ -326,9 +693,9 @@ function buildContentTypesXml(types) {
326
693
  ).join("");
327
694
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="${NS.contentTypes}">${defaults}${overrides}</Types>`;
328
695
  }
329
- function ensureContentTypeDefault(xml, extension, contentType) {
330
- const types = parseContentTypes(xml);
331
- if (types.defaults.has(extension.toLowerCase())) return xml ?? buildContentTypesXml(types);
696
+ function ensureContentTypeDefault(xml2, extension, contentType) {
697
+ const types = parseContentTypes(xml2);
698
+ if (types.defaults.has(extension.toLowerCase())) return xml2 ?? buildContentTypesXml(types);
332
699
  types.defaults.set(extension.toLowerCase(), contentType);
333
700
  return buildContentTypesXml(types);
334
701
  }
@@ -338,35 +705,35 @@ var CONTENT_TYPES_PATH = "[Content_Types].xml";
338
705
  var XML_DECLARATION = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
339
706
  var EMPTY_TYPES = `${XML_DECLARATION}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"></Types>`;
340
707
  var EMPTY_RELS = `${XML_DECLARATION}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>`;
341
- function attr2(tag, name) {
708
+ function attr2(tag2, name) {
342
709
  const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
343
- const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(tag);
710
+ const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(tag2);
344
711
  return match ? match[1] ?? match[2] : void 0;
345
712
  }
346
713
  async function ensureContentTypeOverride(zip, partName, contentType) {
347
- const xml = await zip.file(CONTENT_TYPES_PATH)?.async("string") ?? EMPTY_TYPES;
714
+ const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string") ?? EMPTY_TYPES;
348
715
  const target = `/${partName}`;
349
- for (const tag of xml.match(/<Override\b[^>]*\/>/g) ?? [])
350
- if (attr2(tag, "PartName") === target) return;
716
+ for (const tag2 of xml2.match(/<Override\b[^>]*\/>/g) ?? [])
717
+ if (attr2(tag2, "PartName") === target) return;
351
718
  const insertion = `<Override PartName="${target}" ContentType="${contentType}"/>`;
352
- zip.file(CONTENT_TYPES_PATH, xml.replace("</Types>", `${insertion}</Types>`));
719
+ zip.file(CONTENT_TYPES_PATH, xml2.replace("</Types>", `${insertion}</Types>`));
353
720
  }
354
721
  async function removeContentTypeOverride(zip, partName) {
355
- const xml = await zip.file(CONTENT_TYPES_PATH)?.async("string");
356
- if (!xml) return;
722
+ const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string");
723
+ if (!xml2) return;
357
724
  const target = `/${partName}`;
358
- const tag = (xml.match(/<Override\b[^>]*\/>/g) ?? []).find(
725
+ const tag2 = (xml2.match(/<Override\b[^>]*\/>/g) ?? []).find(
359
726
  (candidate) => attr2(candidate, "PartName") === target
360
727
  );
361
- if (tag) zip.file(CONTENT_TYPES_PATH, xml.replace(tag, ""));
728
+ if (tag2) zip.file(CONTENT_TYPES_PATH, xml2.replace(tag2, ""));
362
729
  }
363
730
  async function ensureRelationship(zip, relsPath, type, target) {
364
- const xml = await zip.file(relsPath)?.async("string") ?? EMPTY_RELS;
731
+ const xml2 = await zip.file(relsPath)?.async("string") ?? EMPTY_RELS;
365
732
  const used = /* @__PURE__ */ new Set();
366
- for (const tag of xml.match(/<Relationship\b[^>]*\/>/g) ?? []) {
367
- const id2 = attr2(tag, "Id");
733
+ for (const tag2 of xml2.match(/<Relationship\b[^>]*\/>/g) ?? []) {
734
+ const id2 = attr2(tag2, "Id");
368
735
  if (id2) used.add(id2);
369
- if (id2 && attr2(tag, "Type") === type && attr2(tag, "Target") === target) return id2;
736
+ if (id2 && attr2(tag2, "Type") === type && attr2(tag2, "Target") === target) return id2;
370
737
  }
371
738
  const highest = Math.max(
372
739
  0,
@@ -375,128 +742,15 @@ async function ensureRelationship(zip, relsPath, type, target) {
375
742
  let id = `rId${highest + 1}`;
376
743
  if (used.has(id)) id = nextRelationshipId(used);
377
744
  const insertion = `<Relationship Id="${id}" Type="${type}" Target="${target}"/>`;
378
- zip.file(relsPath, xml.replace("</Relationships>", `${insertion}</Relationships>`));
745
+ zip.file(relsPath, xml2.replace("</Relationships>", `${insertion}</Relationships>`));
379
746
  return id;
380
747
  }
381
748
  async function findOfficeDocumentPart(zip) {
382
- const xml = await zip.file("_rels/.rels")?.async("string");
383
- for (const tag of xml?.match(/<Relationship\b[^>]*\/>/g) ?? [])
384
- if (attr2(tag, "Type") === RELATIONSHIP_TYPES.officeDocument) return attr2(tag, "Target");
749
+ const xml2 = await zip.file("_rels/.rels")?.async("string");
750
+ for (const tag2 of xml2?.match(/<Relationship\b[^>]*\/>/g) ?? [])
751
+ if (attr2(tag2, "Type") === RELATIONSHIP_TYPES.officeDocument) return attr2(tag2, "Target");
385
752
  return void 0;
386
753
  }
387
-
388
- // opc/clone-part-graph.ts
389
- function relativePartTarget(basePart, targetPart) {
390
- const base = basePart.split("/").slice(0, -1);
391
- const target = targetPart.split("/");
392
- while (base.length > 0 && base[0] === target[0]) {
393
- base.shift();
394
- target.shift();
395
- }
396
- return [...base.map(() => ".."), ...target].join("/");
397
- }
398
- async function clonePartGraph(options) {
399
- const { zip, sourcePart, targetPart, shouldClone } = options;
400
- const sourceZip = options.sourceZip ?? zip;
401
- const copies = options.copies ?? /* @__PURE__ */ new Map();
402
- copies.set(sourcePart, targetPart);
403
- const types = parseContentTypes(await sourceZip.file("[Content_Types].xml")?.async("string"));
404
- const reserved = new Set(Object.keys(zip.files));
405
- reserved.add(targetPart);
406
- for (const target of copies.values()) reserved.add(target);
407
- const allocate = (source) => {
408
- const match = /^(?<stem>.*?)(?:\d+)?(?<extension>\.[^/.]+)$/u.exec(source);
409
- const stem = match?.groups?.stem ?? source;
410
- const extension = match?.groups?.extension ?? "";
411
- let index = 1;
412
- while (reserved.has(`${stem}${index}${extension}`)) index += 1;
413
- const path = `${stem}${index}${extension}`;
414
- reserved.add(path);
415
- return path;
416
- };
417
- const copyRelationships = async (source, destination) => {
418
- const contentType = contentTypeForPart(types, source);
419
- if (contentType) await ensureContentTypeOverride(zip, destination, contentType);
420
- const xml = await sourceZip.file(relationshipsPartFor(source))?.async("string");
421
- if (!xml) return;
422
- const relationships = parseRelationships(xml);
423
- for (const relationship of relationships.values()) {
424
- if (relationship.mode === "External") continue;
425
- const originalTarget = resolvePartPath(source, relationship.target);
426
- let newTarget = copies.get(originalTarget);
427
- if (!newTarget && shouldClone(relationship, originalTarget)) {
428
- const file = sourceZip.file(originalTarget);
429
- if (!file) throw new Error(`Cannot clone missing package part: ${originalTarget}`);
430
- newTarget = allocate(originalTarget);
431
- copies.set(originalTarget, newTarget);
432
- zip.file(newTarget, await file.async("uint8array"));
433
- await copyRelationships(originalTarget, newTarget);
434
- }
435
- relationship.target = relativePartTarget(destination, newTarget ?? originalTarget);
436
- }
437
- zip.file(relationshipsPartFor(destination), buildRelationshipsXml(relationships));
438
- };
439
- await copyRelationships(sourcePart, targetPart);
440
- return copies;
441
- }
442
-
443
- // opc/safe-href.ts
444
- var SAFE_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]);
445
- function isSafeHyperlinkHref(href) {
446
- const scheme = /^([a-z][a-z0-9+.-]*:)/i.exec(href.trim())?.[1];
447
- return scheme !== void 0 && SAFE_SCHEMES.has(scheme.toLowerCase());
448
- }
449
- var OPEN_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "mailto"]);
450
- var STORE_SCHEMES = /* @__PURE__ */ new Set([...OPEN_SCHEMES, "ftp", "file"]);
451
- var SCRIPT_SCHEMES = /* @__PURE__ */ new Set([
452
- "javascript",
453
- "vbscript",
454
- "livescript",
455
- "jscript",
456
- "mocha",
457
- "data",
458
- "mhtml",
459
- "ms-its",
460
- "mk",
461
- "x-javascript",
462
- "blob"
463
- ]);
464
- var IGNORABLE = new RegExp(
465
- "[\\u0000-\\u0020\\u007f\\u00ad\\u200b-\\u200f\\u202a-\\u202e\\u2060-\\u2064\\ufeff]",
466
- "gu"
467
- );
468
- var CONTROL = new RegExp("[\\u0000-\\u001f\\u007f]", "u");
469
- var SCHEME = /^([a-z][a-z0-9+.-]*):/;
470
- var STORE_ONLY = { store: true, open: false, reason: "not-openable" };
471
- var reject = (reason) => ({
472
- store: false,
473
- open: false,
474
- reason
475
- });
476
- function hyperlinkPolicy(href, options = {}) {
477
- if (typeof href !== "string") return reject("empty");
478
- const trimmed = href.trim();
479
- const normalized = trimmed.replace(IGNORABLE, "").toLowerCase();
480
- if (normalized.length === 0) return reject("empty");
481
- const scheme = SCHEME.exec(normalized)?.[1];
482
- if (scheme !== void 0 && SCRIPT_SCHEMES.has(scheme)) return reject("script-scheme");
483
- if (scheme !== void 0 && !trimmed.toLowerCase().startsWith(`${scheme}:`))
484
- return reject("obfuscated-scheme");
485
- if (CONTROL.test(trimmed)) return reject("control-characters");
486
- if (scheme === void 0) return options.openRelative ? { store: true, open: true } : STORE_ONLY;
487
- if (scheme.length === 1) return STORE_ONLY;
488
- if (OPEN_SCHEMES.has(scheme)) return { store: true, open: true };
489
- if (options.additionalOpenSchemes?.some((allowed) => allowed.toLowerCase() === scheme))
490
- return { store: true, open: true };
491
- if (STORE_SCHEMES.has(scheme)) return STORE_ONLY;
492
- return reject("unsupported-scheme");
493
- }
494
- function isStorableHyperlinkHref(href, options) {
495
- return hyperlinkPolicy(href, options).store;
496
- }
497
- function isOpenableHyperlinkHref(href, options) {
498
- return hyperlinkPolicy(href, options).open;
499
- }
500
754
  var DEFAULT_ZIP_LIMITS = {
501
755
  maxInputBytes: 100 * 1024 * 1024,
502
756
  maxEntries: 1e4,
@@ -719,6 +973,215 @@ async function openZip(input, limits = {}) {
719
973
  return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
720
974
  }
721
975
 
976
+ // opc/merge-snapshots.ts
977
+ var equal = (a, b) => a === b || Boolean(a && b && a.length === b.length && a.every((value, index) => value === b[index]));
978
+ var decoder = new TextDecoder("utf-8", { fatal: true });
979
+ var encoder = new TextEncoder();
980
+ function mergeManifest(input) {
981
+ const { path, base, local, remote } = input;
982
+ if (!base || !local || !remote) return void 0;
983
+ if (!path.endsWith(".rels") && path !== "[Content_Types].xml" && path !== "docProps/core.xml")
984
+ return void 0;
985
+ try {
986
+ const result = mergeXmlThreeWay(
987
+ decoder.decode(base),
988
+ decoder.decode(local),
989
+ decoder.decode(remote),
990
+ {
991
+ keyElement: (element) => {
992
+ const attribute = element.localName === "Relationship" ? "Id" : element.localName === "Override" ? "PartName" : element.localName === "Default" ? "Extension" : void 0;
993
+ return attribute ? element.getAttribute(attribute) ?? void 0 : void 0;
994
+ },
995
+ resolveText: (_b, _l, r) => path === "docProps/core.xml" && (r.namespaceURI === "http://purl.org/dc/terms/" && r.localName === "modified" || r.namespaceURI === "http://schemas.openxmlformats.org/package/2006/metadata/core-properties" && r.localName === "lastModifiedBy") ? r.textContent ?? "" : void 0
996
+ }
997
+ );
998
+ return result.status === "merged" ? { status: "merged", bytes: encoder.encode(result.xml) } : result;
999
+ } catch {
1000
+ return { status: "unresolved", issues: [`${path}: invalid metadata XML`] };
1001
+ }
1002
+ }
1003
+ async function mergeOpcSnapshots(baseBytes, localBytes, remoteBytes, options = {}) {
1004
+ if (equal(localBytes, remoteBytes) || equal(baseBytes, remoteBytes))
1005
+ return { status: "merged", bytes: localBytes.slice() };
1006
+ if (equal(baseBytes, localBytes)) return { status: "merged", bytes: remoteBytes.slice() };
1007
+ try {
1008
+ const [base, local, remote] = await Promise.all([
1009
+ openZip(baseBytes, { label: "Merge" }),
1010
+ openZip(localBytes, { label: "Merge" }),
1011
+ openZip(remoteBytes, { label: "Merge" })
1012
+ ]);
1013
+ const paths = [
1014
+ ...new Set(
1015
+ [base, local, remote].flatMap(
1016
+ (zip) => Object.keys(zip.files).filter((path) => !zip.files[path].dir)
1017
+ )
1018
+ )
1019
+ ].sort();
1020
+ if (paths.some((path) => path.startsWith("_xmlsignatures/")))
1021
+ return {
1022
+ status: "unresolved",
1023
+ issues: ["Signed packages require explicit signature handling before merging"]
1024
+ };
1025
+ const issues = [];
1026
+ for (const path of paths) {
1027
+ const [b, l, r] = await Promise.all(
1028
+ [base, local, remote].map((zip) => zip.file(path)?.async("uint8array"))
1029
+ );
1030
+ let chosen;
1031
+ if (equal(l, r) || equal(b, r)) chosen = l;
1032
+ else if (equal(b, l)) chosen = r;
1033
+ else {
1034
+ const input = {
1035
+ path,
1036
+ ...b ? { base: b } : {},
1037
+ ...l ? { local: l } : {},
1038
+ ...r ? { remote: r } : {}
1039
+ };
1040
+ const result = mergeManifest(input) ?? await options.mergePart?.(input);
1041
+ if (!result || result.status === "unresolved") {
1042
+ issues.push(...result?.issues ?? [`${path}: both versions changed the same part`]);
1043
+ continue;
1044
+ }
1045
+ chosen = result.bytes;
1046
+ }
1047
+ if (chosen) remote.file(path, chosen);
1048
+ else remote.remove(path);
1049
+ }
1050
+ if (issues.length) return { status: "unresolved", issues };
1051
+ for (const path of Object.keys(remote.files).filter((name) => name.endsWith(".rels"))) {
1052
+ const source = path === "_rels/.rels" ? "" : path.replace(/(^|\/)_rels\/([^/]+)\.rels$/u, "$1$2");
1053
+ for (const relation of parseRelationships(
1054
+ await remote.file(path).async("string")
1055
+ ).values()) {
1056
+ if (relation.mode === "External") continue;
1057
+ const target = resolvePartPath(source, relation.target.split("#")[0] ?? "");
1058
+ if (!remote.file(target) && !remote.file(decodeURIComponent(target)))
1059
+ issues.push(`${path}: merged relationship target is missing`);
1060
+ }
1061
+ }
1062
+ if (issues.length) return { status: "unresolved", issues };
1063
+ return {
1064
+ status: "merged",
1065
+ bytes: await remote.generateAsync({ type: "uint8array", compression: "DEFLATE" })
1066
+ };
1067
+ } catch {
1068
+ return { status: "unresolved", issues: ["Invalid or oversized Office package"] };
1069
+ }
1070
+ }
1071
+
1072
+ // opc/clone-part-graph.ts
1073
+ function relativePartTarget(basePart, targetPart) {
1074
+ const base = basePart.split("/").slice(0, -1);
1075
+ const target = targetPart.split("/");
1076
+ while (base.length > 0 && base[0] === target[0]) {
1077
+ base.shift();
1078
+ target.shift();
1079
+ }
1080
+ return [...base.map(() => ".."), ...target].join("/");
1081
+ }
1082
+ async function clonePartGraph(options) {
1083
+ const { zip, sourcePart, targetPart, shouldClone } = options;
1084
+ const sourceZip = options.sourceZip ?? zip;
1085
+ const copies = options.copies ?? /* @__PURE__ */ new Map();
1086
+ copies.set(sourcePart, targetPart);
1087
+ const types = parseContentTypes(await sourceZip.file("[Content_Types].xml")?.async("string"));
1088
+ const reserved = new Set(Object.keys(zip.files));
1089
+ reserved.add(targetPart);
1090
+ for (const target of copies.values()) reserved.add(target);
1091
+ const allocate = (source) => {
1092
+ const match = /^(?<stem>.*?)(?:\d+)?(?<extension>\.[^/.]+)$/u.exec(source);
1093
+ const stem = match?.groups?.stem ?? source;
1094
+ const extension = match?.groups?.extension ?? "";
1095
+ let index = 1;
1096
+ while (reserved.has(`${stem}${index}${extension}`)) index += 1;
1097
+ const path = `${stem}${index}${extension}`;
1098
+ reserved.add(path);
1099
+ return path;
1100
+ };
1101
+ const copyRelationships = async (source, destination) => {
1102
+ const contentType = contentTypeForPart(types, source);
1103
+ if (contentType) await ensureContentTypeOverride(zip, destination, contentType);
1104
+ const xml2 = await sourceZip.file(relationshipsPartFor(source))?.async("string");
1105
+ if (!xml2) return;
1106
+ const relationships = parseRelationships(xml2);
1107
+ for (const relationship of relationships.values()) {
1108
+ if (relationship.mode === "External") continue;
1109
+ const originalTarget = resolvePartPath(source, relationship.target);
1110
+ let newTarget = copies.get(originalTarget);
1111
+ if (!newTarget && shouldClone(relationship, originalTarget)) {
1112
+ const file = sourceZip.file(originalTarget);
1113
+ if (!file) throw new Error(`Cannot clone missing package part: ${originalTarget}`);
1114
+ newTarget = allocate(originalTarget);
1115
+ copies.set(originalTarget, newTarget);
1116
+ zip.file(newTarget, await file.async("uint8array"));
1117
+ await copyRelationships(originalTarget, newTarget);
1118
+ }
1119
+ relationship.target = relativePartTarget(destination, newTarget ?? originalTarget);
1120
+ }
1121
+ zip.file(relationshipsPartFor(destination), buildRelationshipsXml(relationships));
1122
+ };
1123
+ await copyRelationships(sourcePart, targetPart);
1124
+ return copies;
1125
+ }
1126
+
1127
+ // opc/safe-href.ts
1128
+ var SAFE_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]);
1129
+ function isSafeHyperlinkHref(href) {
1130
+ const scheme = /^([a-z][a-z0-9+.-]*:)/i.exec(href.trim())?.[1];
1131
+ return scheme !== void 0 && SAFE_SCHEMES.has(scheme.toLowerCase());
1132
+ }
1133
+ var OPEN_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "mailto"]);
1134
+ var STORE_SCHEMES = /* @__PURE__ */ new Set([...OPEN_SCHEMES, "ftp", "file"]);
1135
+ var SCRIPT_SCHEMES = /* @__PURE__ */ new Set([
1136
+ "javascript",
1137
+ "vbscript",
1138
+ "livescript",
1139
+ "jscript",
1140
+ "mocha",
1141
+ "data",
1142
+ "mhtml",
1143
+ "ms-its",
1144
+ "mk",
1145
+ "x-javascript",
1146
+ "blob"
1147
+ ]);
1148
+ var IGNORABLE = new RegExp(
1149
+ "[\\u0000-\\u0020\\u007f\\u00ad\\u200b-\\u200f\\u202a-\\u202e\\u2060-\\u2064\\ufeff]",
1150
+ "gu"
1151
+ );
1152
+ var CONTROL = new RegExp("[\\u0000-\\u001f\\u007f]", "u");
1153
+ var SCHEME = /^([a-z][a-z0-9+.-]*):/;
1154
+ var STORE_ONLY = { store: true, open: false, reason: "not-openable" };
1155
+ var reject = (reason) => ({
1156
+ store: false,
1157
+ open: false,
1158
+ reason
1159
+ });
1160
+ function hyperlinkPolicy(href, options = {}) {
1161
+ if (typeof href !== "string") return reject("empty");
1162
+ const trimmed = href.trim();
1163
+ const normalized = trimmed.replace(IGNORABLE, "").toLowerCase();
1164
+ if (normalized.length === 0) return reject("empty");
1165
+ const scheme = SCHEME.exec(normalized)?.[1];
1166
+ if (scheme !== void 0 && SCRIPT_SCHEMES.has(scheme)) return reject("script-scheme");
1167
+ if (scheme !== void 0 && !trimmed.toLowerCase().startsWith(`${scheme}:`))
1168
+ return reject("obfuscated-scheme");
1169
+ if (CONTROL.test(trimmed)) return reject("control-characters");
1170
+ if (scheme === void 0) return options.openRelative ? { store: true, open: true } : STORE_ONLY;
1171
+ if (scheme.length === 1) return STORE_ONLY;
1172
+ if (OPEN_SCHEMES.has(scheme)) return { store: true, open: true };
1173
+ if (options.additionalOpenSchemes?.some((allowed) => allowed.toLowerCase() === scheme))
1174
+ return { store: true, open: true };
1175
+ if (STORE_SCHEMES.has(scheme)) return STORE_ONLY;
1176
+ return reject("unsupported-scheme");
1177
+ }
1178
+ function isStorableHyperlinkHref(href, options) {
1179
+ return hyperlinkPolicy(href, options).store;
1180
+ }
1181
+ function isOpenableHyperlinkHref(href, options) {
1182
+ return hyperlinkPolicy(href, options).open;
1183
+ }
1184
+
722
1185
  // opc/embedded-packages.ts
723
1186
  var EMBEDDED_ZIP_LIMITS = {
724
1187
  label: "Embedded",
@@ -771,10 +1234,10 @@ var PROPERTY_CONTENT_TYPES = {
771
1234
 
772
1235
  // opc/properties/patch.ts
773
1236
  var XMLNS = "http://www.w3.org/2000/xmlns/";
774
- function tagEnd(xml, from) {
1237
+ function tagEnd(xml2, from) {
775
1238
  let quote = "";
776
- for (let i = from + 1; i < xml.length; i++) {
777
- const ch = xml[i];
1239
+ for (let i = from + 1; i < xml2.length; i++) {
1240
+ const ch = xml2[i];
778
1241
  if (quote) {
779
1242
  if (ch === quote) quote = "";
780
1243
  } else if (ch === '"' || ch === "'") quote = ch;
@@ -782,24 +1245,24 @@ function tagEnd(xml, from) {
782
1245
  }
783
1246
  throw new Error("Unterminated tag in property part");
784
1247
  }
785
- function skipMarkup(xml, at) {
786
- if (xml.startsWith("<!--", at)) return xml.indexOf("-->", at) + 3;
787
- if (xml.startsWith("<![CDATA[", at)) return xml.indexOf("]]>", at) + 3;
788
- if (xml.startsWith("<?", at)) return xml.indexOf("?>", at) + 2;
1248
+ function skipMarkup(xml2, at) {
1249
+ if (xml2.startsWith("<!--", at)) return xml2.indexOf("-->", at) + 3;
1250
+ if (xml2.startsWith("<![CDATA[", at)) return xml2.indexOf("]]>", at) + 3;
1251
+ if (xml2.startsWith("<?", at)) return xml2.indexOf("?>", at) + 2;
789
1252
  return void 0;
790
1253
  }
791
- function scan(xml) {
1254
+ function scan(xml2) {
792
1255
  let i = 0;
793
1256
  let rootStart = -1;
794
1257
  while (rootStart < 0) {
795
- const lt = xml.indexOf("<", i);
1258
+ const lt = xml2.indexOf("<", i);
796
1259
  if (lt < 0) throw new Error("Property part has no root element");
797
- const skipped = skipMarkup(xml, lt);
1260
+ const skipped = skipMarkup(xml2, lt);
798
1261
  if (skipped !== void 0) i = skipped;
799
1262
  else rootStart = lt;
800
1263
  }
801
- const openEnd = tagEnd(xml, rootStart);
802
- if (xml[openEnd - 2] === "/") {
1264
+ const openEnd = tagEnd(xml2, rootStart);
1265
+ if (xml2[openEnd - 2] === "/") {
803
1266
  const root = {
804
1267
  start: rootStart,
805
1268
  openEnd,
@@ -814,16 +1277,16 @@ function scan(xml) {
814
1277
  let child;
815
1278
  i = openEnd;
816
1279
  for (; ; ) {
817
- const lt = xml.indexOf("<", i);
1280
+ const lt = xml2.indexOf("<", i);
818
1281
  if (lt < 0) throw new Error("Property part root is not closed");
819
- const skipped = skipMarkup(xml, lt);
1282
+ const skipped = skipMarkup(xml2, lt);
820
1283
  if (skipped !== void 0) {
821
1284
  i = skipped;
822
1285
  continue;
823
1286
  }
824
- const end = tagEnd(xml, lt);
1287
+ const end = tagEnd(xml2, lt);
825
1288
  i = end;
826
- if (xml[lt + 1] === "/") {
1289
+ if (xml2[lt + 1] === "/") {
827
1290
  if (depth === 0) {
828
1291
  const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
829
1292
  return { root, children: children2 };
@@ -831,7 +1294,7 @@ function scan(xml) {
831
1294
  depth--;
832
1295
  if (depth === 0 && child)
833
1296
  children2.push({ ...child, closeStart: lt, end, selfClosing: false });
834
- } else if (xml[end - 2] === "/") {
1297
+ } else if (xml2[end - 2] === "/") {
835
1298
  if (depth === 0)
836
1299
  children2.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
837
1300
  } else {
@@ -841,11 +1304,11 @@ function scan(xml) {
841
1304
  }
842
1305
  }
843
1306
  var escapeText = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\r/g, "&#xD;");
844
- var qualifiedName = (xml, span) => /^<([^\s/>]+)/.exec(xml.slice(span.start, span.openEnd))?.[1] ?? "";
1307
+ var qualifiedName = (xml2, span) => /^<([^\s/>]+)/.exec(xml2.slice(span.start, span.openEnd))?.[1] ?? "";
845
1308
  var PartPatch = class {
846
- constructor(xml, rootElement) {
847
- this.xml = xml;
848
- const { root, children: children2 } = scan(xml);
1309
+ constructor(xml2, rootElement) {
1310
+ this.xml = xml2;
1311
+ const { root, children: children2 } = scan(xml2);
849
1312
  const kids = elements(rootElement);
850
1313
  if (kids.length !== children2.length) throw new Error("Property part markup is not supported");
851
1314
  kids.forEach((kid, index) => this.spans.set(kid, children2[index]));
@@ -960,10 +1423,10 @@ var FIELDS = [
960
1423
  var CORE_PROPERTY_FIELDS = FIELDS.map(([field]) => field);
961
1424
  var EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
962
1425
  <cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
963
- function parseCoreProperties(xml) {
1426
+ function parseCoreProperties(xml2) {
964
1427
  const out = {};
965
- if (!xml) return out;
966
- const root = parseXml(xml, { label: "core properties" }).documentElement;
1428
+ if (!xml2) return out;
1429
+ const root = parseXml(xml2, { label: "core properties" }).documentElement;
967
1430
  for (const [field, prefix] of FIELDS) {
968
1431
  const text = first(root, field, NS[prefix])?.textContent ?? "";
969
1432
  if (text !== "") out[field] = text;
@@ -972,9 +1435,9 @@ function parseCoreProperties(xml) {
972
1435
  }
973
1436
  var formatW3cdtf = (date) => date.toISOString().replace(/\.\d{3}Z$/, "Z");
974
1437
  function writeCoreProperties(props, sourceXml) {
975
- const xml = sourceXml ?? EMPTY_CORE;
976
- const root = parseXml(xml, { label: "core properties" }).documentElement;
977
- const patch = new PartPatch(xml, root);
1438
+ const xml2 = sourceXml ?? EMPTY_CORE;
1439
+ const root = parseXml(xml2, { label: "core properties" }).documentElement;
1440
+ const patch = new PartPatch(xml2, root);
978
1441
  for (const [field, prefix, isDate] of FIELDS) {
979
1442
  const ns = NS[prefix];
980
1443
  const value = props[field];
@@ -1072,9 +1535,9 @@ function readKnown(root, ns) {
1072
1535
  }
1073
1536
  return out;
1074
1537
  }
1075
- function parseAppProperties(xml) {
1076
- if (!xml) return {};
1077
- const root = parseXml(xml, { label: "app properties" }).documentElement;
1538
+ function parseAppProperties(xml2) {
1539
+ if (!xml2) return {};
1540
+ const root = parseXml(xml2, { label: "app properties" }).documentElement;
1078
1541
  const ns = namespacesOf(root);
1079
1542
  return ns ? readKnown(root, ns) : {};
1080
1543
  }
@@ -1092,11 +1555,11 @@ function content(kind, value, vt) {
1092
1555
  return `<${vt}:vector size="${items.length}" baseType="${baseType}">${items.join("")}</${vt}:vector>`;
1093
1556
  }
1094
1557
  function writeAppProperties(props, sourceXml) {
1095
- const xml = sourceXml ?? EMPTY_APP;
1096
- const root = parseXml(xml, { label: "app properties" }).documentElement;
1558
+ const xml2 = sourceXml ?? EMPTY_APP;
1559
+ const root = parseXml(xml2, { label: "app properties" }).documentElement;
1097
1560
  const ns = namespacesOf(root);
1098
1561
  if (!ns) throw new Error("app properties root is not an extended-properties element");
1099
- const patch = new PartPatch(xml, root);
1562
+ const patch = new PartPatch(xml2, root);
1100
1563
  const prior = readKnown(root, ns);
1101
1564
  const ownPrefix = root.prefix ? `${root.prefix}:` : "";
1102
1565
  FIELDS2.forEach(([field, local, kind], index) => {
@@ -1147,9 +1610,9 @@ function readValue(variant) {
1147
1610
  return void 0;
1148
1611
  }
1149
1612
  }
1150
- function parseCustomProperties(xml) {
1151
- if (!xml) return [];
1152
- const root = parseXml(xml, { label: "custom properties" }).documentElement;
1613
+ function parseCustomProperties(xml2) {
1614
+ if (!xml2) return [];
1615
+ const root = parseXml(xml2, { label: "custom properties" }).documentElement;
1153
1616
  const out = [];
1154
1617
  for (const property of children(root, "property", NS.customProperties)) {
1155
1618
  const name = property.getAttribute("name") ?? "";
@@ -1215,9 +1678,9 @@ function writeCustomProperties(properties) {
1215
1678
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1216
1679
  <Properties xmlns="${NS.customProperties}" xmlns:vt="${NS.vt}">${body}</Properties>`;
1217
1680
  }
1218
- function parseCustomPropertyTexts(xml) {
1219
- if (!xml) return [];
1220
- const root = parseXml(xml, { label: "custom properties" }).documentElement;
1681
+ function parseCustomPropertyTexts(xml2) {
1682
+ if (!xml2) return [];
1683
+ const root = parseXml(xml2, { label: "custom properties" }).documentElement;
1221
1684
  const out = [];
1222
1685
  for (const property of children(root, "property", NS.customProperties)) {
1223
1686
  const name = property.getAttribute("name") ?? "";
@@ -1555,63 +2018,63 @@ function escapeXmlText(value) {
1555
2018
  function isValidBase64(value) {
1556
2019
  return typeof value === "string" && value.length > 0 && /^[A-Za-z0-9+/=\s]+$/.test(value);
1557
2020
  }
1558
- function extractTagAttribute(xml, tagName, attributeName) {
2021
+ function extractTagAttribute(xml2, tagName, attributeName) {
1559
2022
  const pattern = new RegExp(
1560
2023
  `<${tagName}\\b[^>]*\\b${attributeName}="(?<attributeValue>[^"]+)"`,
1561
2024
  "i"
1562
2025
  );
1563
- const match = xml.match(pattern);
2026
+ const match = xml2.match(pattern);
1564
2027
  return match?.groups?.["attributeValue"]?.trim();
1565
2028
  }
1566
2029
  var isNameChar = (c) => c !== void 0 && /[\w.-]/.test(c);
1567
2030
  var isWordChar = (c) => c !== void 0 && /\w/.test(c);
1568
- function matchName(xml, lowerXml, from, lname) {
2031
+ function matchName(xml2, lowerXml, from, lname) {
1569
2032
  let pos = from;
1570
2033
  if (!lowerXml.startsWith(lname, pos)) {
1571
2034
  let end = pos;
1572
- while (isNameChar(xml[end])) end++;
1573
- if (end === pos || xml[end] !== ":") return -1;
2035
+ while (isNameChar(xml2[end])) end++;
2036
+ if (end === pos || xml2[end] !== ":") return -1;
1574
2037
  pos = end + 1;
1575
2038
  if (!lowerXml.startsWith(lname, pos)) return -1;
1576
2039
  }
1577
2040
  return pos + lname.length;
1578
2041
  }
1579
- function findTagText(xml, lowerXml, lname, from) {
1580
- let lt = xml.indexOf("<", from);
2042
+ function findTagText(xml2, lowerXml, lname, from) {
2043
+ let lt = xml2.indexOf("<", from);
1581
2044
  while (lt !== -1) {
1582
- const afterName = matchName(xml, lowerXml, lt + 1, lname);
1583
- if (afterName !== -1 && !isWordChar(xml[afterName])) {
1584
- const gt = xml.indexOf(">", afterName);
2045
+ const afterName = matchName(xml2, lowerXml, lt + 1, lname);
2046
+ if (afterName !== -1 && !isWordChar(xml2[afterName])) {
2047
+ const gt = xml2.indexOf(">", afterName);
1585
2048
  if (gt === -1) return null;
1586
- let close = xml.indexOf("</", gt + 1);
2049
+ let close = xml2.indexOf("</", gt + 1);
1587
2050
  while (close !== -1) {
1588
- const closeEnd = matchName(xml, lowerXml, close + 2, lname);
1589
- if (closeEnd !== -1 && xml[closeEnd] === ">") {
1590
- return { text: xml.slice(gt + 1, close), end: closeEnd + 1 };
2051
+ const closeEnd = matchName(xml2, lowerXml, close + 2, lname);
2052
+ if (closeEnd !== -1 && xml2[closeEnd] === ">") {
2053
+ return { text: xml2.slice(gt + 1, close), end: closeEnd + 1 };
1591
2054
  }
1592
- close = xml.indexOf("</", close + 2);
2055
+ close = xml2.indexOf("</", close + 2);
1593
2056
  }
1594
2057
  return null;
1595
2058
  }
1596
- lt = xml.indexOf("<", lt + 1);
2059
+ lt = xml2.indexOf("<", lt + 1);
1597
2060
  }
1598
2061
  return null;
1599
2062
  }
1600
- function extractFirstTagText(xml, localName) {
1601
- const found = findTagText(xml, xml.toLowerCase(), localName.toLowerCase(), 0);
2063
+ function extractFirstTagText(xml2, localName) {
2064
+ const found = findTagText(xml2, xml2.toLowerCase(), localName.toLowerCase(), 0);
1602
2065
  return found?.text.replace(/\s+/g, "").trim() || void 0;
1603
2066
  }
1604
- function extractAllTagText(xml, localName) {
2067
+ function extractAllTagText(xml2, localName) {
1605
2068
  const result = [];
1606
- const lowerXml = xml.toLowerCase();
2069
+ const lowerXml = xml2.toLowerCase();
1607
2070
  const lname = localName.toLowerCase();
1608
- let found = findTagText(xml, lowerXml, lname, 0);
2071
+ let found = findTagText(xml2, lowerXml, lname, 0);
1609
2072
  while (found) {
1610
2073
  const value = found.text.replace(/\s+/g, "").trim();
1611
2074
  if (value) {
1612
2075
  result.push(value);
1613
2076
  }
1614
- found = findTagText(xml, lowerXml, lname, found.end);
2077
+ found = findTagText(xml2, lowerXml, lname, found.end);
1615
2078
  }
1616
2079
  return result;
1617
2080
  }
@@ -1812,6 +2275,7 @@ exports.isSafeHyperlinkHref = isSafeHyperlinkHref;
1812
2275
  exports.isSafePartName = isSafePartName;
1813
2276
  exports.isStorableHyperlinkHref = isStorableHyperlinkHref;
1814
2277
  exports.listEmbeddedPackages = listEmbeddedPackages;
2278
+ exports.mergeOpcSnapshots = mergeOpcSnapshots;
1815
2279
  exports.nextRelationshipId = nextRelationshipId;
1816
2280
  exports.openZip = openZip;
1817
2281
  exports.parseAppProperties = parseAppProperties;