@web-ppt/edit-core 0.5.0-beta.2 → 0.5.0-beta.7

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 (337) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/README.md +164 -21
  3. package/dist/alt-text.d.ts +5 -0
  4. package/dist/appearance/index.d.ts +12 -0
  5. package/dist/appearance/materialize.d.ts +4 -0
  6. package/dist/appearance/types.d.ts +26 -0
  7. package/dist/appearance/values.d.ts +9 -0
  8. package/dist/appearance.js +301 -0
  9. package/dist/cfb/index.d.ts +5 -0
  10. package/dist/cfb/read.d.ts +16 -0
  11. package/dist/cfb/write.d.ts +3 -0
  12. package/dist/cfb.js +208 -0
  13. package/dist/change-classification.d.ts +3 -3
  14. package/dist/chart/category-binding.d.ts +4 -0
  15. package/dist/chart/category-commands.d.ts +23 -0
  16. package/dist/chart/category-levels.d.ts +14 -0
  17. package/dist/chart/category-matrix.d.ts +2 -0
  18. package/dist/chart/category-value.d.ts +2 -0
  19. package/dist/chart/category-workbook.d.ts +13 -0
  20. package/dist/chart/commands.d.ts +28 -0
  21. package/dist/chart/context.d.ts +12 -0
  22. package/dist/chart/dataset-merge.d.ts +5 -0
  23. package/dist/chart/formula.d.ts +13 -0
  24. package/dist/chart/identity-frames.d.ts +4 -0
  25. package/dist/chart/identity-scopes.d.ts +6 -0
  26. package/dist/chart/identity.d.ts +24 -0
  27. package/dist/chart/index.d.ts +8 -0
  28. package/dist/chart/limits.d.ts +6 -0
  29. package/dist/chart/locator.d.ts +4 -0
  30. package/dist/chart/materialize.d.ts +7 -0
  31. package/dist/chart/ordering.d.ts +9 -0
  32. package/dist/chart/part-graph.d.ts +5 -0
  33. package/dist/chart/patch-validation.d.ts +3 -0
  34. package/dist/chart/plot-kinds.d.ts +2 -0
  35. package/dist/chart/projection.d.ts +8 -0
  36. package/dist/chart/save.d.ts +4 -0
  37. package/dist/chart/shared-added-plan.d.ts +19 -0
  38. package/dist/chart/shared-added-records.d.ts +8 -0
  39. package/dist/chart/shared-address.d.ts +5 -0
  40. package/dist/chart/shared-allocate.d.ts +7 -0
  41. package/dist/chart/shared-cache-codec.d.ts +5 -0
  42. package/dist/chart/shared-cache-identities.d.ts +3 -0
  43. package/dist/chart/shared-cache-migration.d.ts +7 -0
  44. package/dist/chart/shared-cache-save.d.ts +3 -0
  45. package/dist/chart/shared-cache-scopes.d.ts +13 -0
  46. package/dist/chart/shared-cache.d.ts +11 -0
  47. package/dist/chart/shared-category.d.ts +4 -0
  48. package/dist/chart/shared-cell.d.ts +9 -0
  49. package/dist/chart/shared-family.d.ts +26 -0
  50. package/dist/chart/shared-fields.d.ts +18 -0
  51. package/dist/chart/shared-graph.d.ts +19 -0
  52. package/dist/chart/shared-growth-space.d.ts +5 -0
  53. package/dist/chart/shared-inserted-cells.d.ts +14 -0
  54. package/dist/chart/shared-inserted-command.d.ts +7 -0
  55. package/dist/chart/shared-inserted-layout.d.ts +16 -0
  56. package/dist/chart/shared-inserted-project.d.ts +14 -0
  57. package/dist/chart/shared-inserted-records.d.ts +16 -0
  58. package/dist/chart/shared-inserted-save.d.ts +6 -0
  59. package/dist/chart/shared-joint-command.d.ts +9 -0
  60. package/dist/chart/shared-joint-records.d.ts +9 -0
  61. package/dist/chart/shared-record-axis.d.ts +25 -0
  62. package/dist/chart/shared-record-remove.d.ts +13 -0
  63. package/dist/chart/shared-record-stage.d.ts +2 -0
  64. package/dist/chart/shared-records.d.ts +2 -0
  65. package/dist/chart/shared-rows.d.ts +17 -0
  66. package/dist/chart/shared-runtime.d.ts +19 -0
  67. package/dist/chart/shared-save-plan.d.ts +4 -0
  68. package/dist/chart/shared-save.d.ts +3 -0
  69. package/dist/chart/shared-series.d.ts +6 -0
  70. package/dist/chart/shared-source-cache.d.ts +4 -0
  71. package/dist/chart/shared-topology.d.ts +9 -0
  72. package/dist/chart/shared-unresolved.d.ts +3 -0
  73. package/dist/chart/shared-validation.d.ts +6 -0
  74. package/dist/chart/shared-workbook-source.d.ts +6 -0
  75. package/dist/chart/shared-xy-command.d.ts +7 -0
  76. package/dist/chart/shared-xy-family.d.ts +16 -0
  77. package/dist/chart/shared-xy-project.d.ts +6 -0
  78. package/dist/chart/shared-xy-records.d.ts +23 -0
  79. package/dist/chart/shared-xy-save.d.ts +5 -0
  80. package/dist/chart/shared-xy-source.d.ts +39 -0
  81. package/dist/chart/shared.d.ts +13 -0
  82. package/dist/chart/source.d.ts +11 -0
  83. package/dist/chart/types.d.ts +86 -0
  84. package/dist/chart/validation.d.ts +24 -0
  85. package/dist/chart/workbook-range.d.ts +16 -0
  86. package/dist/chart/workbook-read.d.ts +7 -0
  87. package/dist/chart/workbook-write.d.ts +9 -0
  88. package/dist/chart/workbook.d.ts +25 -0
  89. package/dist/chart/xml-data.d.ts +14 -0
  90. package/dist/chart/xml-namespaces.d.ts +16 -0
  91. package/dist/chart-design/index.d.ts +10 -0
  92. package/dist/chart-design/types.d.ts +11 -0
  93. package/dist/chart-design/xml.d.ts +2 -0
  94. package/dist/chart-design.js +361 -0
  95. package/dist/chart-ex/index.d.ts +15 -0
  96. package/dist/chart-ex/workbook.d.ts +6 -0
  97. package/dist/chart-ex/xml.d.ts +14 -0
  98. package/dist/chart-ex.js +457 -0
  99. package/dist/chart-shared/index.d.ts +12 -0
  100. package/dist/chart-shared.js +1 -0
  101. package/dist/chart.js +1 -0
  102. package/dist/clipboard-links-GuPtqr1z.js +778 -0
  103. package/dist/clipboard-package.d.ts +4 -0
  104. package/dist/clipboard-source.d.ts +6 -2
  105. package/dist/clipboard-trees.d.ts +9 -0
  106. package/dist/commands/add-slide-identity.d.ts +2 -0
  107. package/dist/commands/bullet-image-resource.d.ts +11 -0
  108. package/dist/commands/clear-format.d.ts +4 -0
  109. package/dist/commands/common-object-slide-patch.d.ts +4 -0
  110. package/dist/commands/common-object-slide-types.d.ts +68 -0
  111. package/dist/commands/direct-format-patches.d.ts +11 -5
  112. package/dist/commands/distribute-elements.d.ts +4 -0
  113. package/dist/commands/edit-table-grid.d.ts +10 -0
  114. package/dist/commands/element-alt-text.d.ts +8 -0
  115. package/dist/commands/element-arrangement.d.ts +17 -0
  116. package/dist/commands/element-effects.d.ts +1 -1
  117. package/dist/commands/element-fill.d.ts +1 -1
  118. package/dist/commands/element-geometry.d.ts +5 -2
  119. package/dist/commands/element-image-content.d.ts +2 -2
  120. package/dist/commands/element-link.d.ts +1 -1
  121. package/dist/commands/element-name.d.ts +1 -1
  122. package/dist/commands/element-stroke.d.ts +1 -1
  123. package/dist/commands/element-text.d.ts +1 -1
  124. package/dist/commands/element-transform.d.ts +2 -2
  125. package/dist/commands/geometry-types.d.ts +23 -1
  126. package/dist/commands/hierarchy-record.d.ts +5 -0
  127. package/dist/commands/image-resource.d.ts +8 -1
  128. package/dist/commands/insertion-host.d.ts +14 -1
  129. package/dist/commands/layout-property.d.ts +7 -0
  130. package/dist/commands/master-property.d.ts +5 -0
  131. package/dist/commands/master-text-style-types.d.ts +27 -0
  132. package/dist/commands/master-text-style.d.ts +7 -0
  133. package/dist/commands/paste-resources.d.ts +9 -5
  134. package/dist/commands/patch-apply.d.ts +3 -0
  135. package/dist/commands/patch-count.d.ts +1 -0
  136. package/dist/commands/patch-invalidation.d.ts +1 -1
  137. package/dist/commands/patch-stage.d.ts +4 -0
  138. package/dist/commands/record-override.d.ts +5 -0
  139. package/dist/commands/replace-image.d.ts +6 -1
  140. package/dist/commands/sections.d.ts +10 -0
  141. package/dist/commands/set-preset.d.ts +5 -0
  142. package/dist/commands/slide-property-types.d.ts +55 -5
  143. package/dist/commands/slide-size.d.ts +7 -0
  144. package/dist/commands/spid.d.ts +1 -1
  145. package/dist/commands/table-grid-patch.d.ts +12 -0
  146. package/dist/commands/text-target.d.ts +2 -2
  147. package/dist/commands/theme-types.d.ts +47 -0
  148. package/dist/commands/theme.d.ts +9 -0
  149. package/dist/commands/types.d.ts +194 -17
  150. package/dist/commands/ungroup-source.d.ts +3 -0
  151. package/dist/comments/index.d.ts +35 -0
  152. package/dist/comments/save.d.ts +3 -0
  153. package/dist/comments/state.d.ts +10 -0
  154. package/dist/comments/xml.d.ts +12 -0
  155. package/dist/comments.js +782 -0
  156. package/dist/common-object-slide-types.d.ts +34 -0
  157. package/dist/data-validation.d.ts +1 -1
  158. package/dist/describe/budget.d.ts +3 -0
  159. package/dist/describe/index.d.ts +5 -0
  160. package/dist/describe/read.d.ts +4 -0
  161. package/dist/describe/types.d.ts +103 -0
  162. package/dist/describe.js +192 -0
  163. package/dist/design-dependencies.d.ts +8 -0
  164. package/dist/design-projection-package.d.ts +10 -0
  165. package/dist/design-target.d.ts +10 -0
  166. package/dist/design.d.ts +3 -0
  167. package/dist/document-extensions.d.ts +9 -0
  168. package/dist/document.d.ts +1 -1
  169. package/dist/dynamic-projection.d.ts +6 -0
  170. package/dist/edit-core.js +5420 -4111
  171. package/dist/editor.d.ts +15 -3
  172. package/dist/element-source.d.ts +11 -0
  173. package/dist/element-spids.d.ts +4 -0
  174. package/dist/extension-address-journal.d.ts +9 -0
  175. package/dist/extension-address-remap.d.ts +14 -0
  176. package/dist/extension-addresses.d.ts +20 -0
  177. package/dist/extension-copy-history.d.ts +7 -0
  178. package/dist/extension-copy.d.ts +16 -0
  179. package/dist/extension-migration-receipt.d.ts +34 -0
  180. package/dist/extension-recovery-context.d.ts +5 -0
  181. package/dist/extension-runtime.d.ts +64 -0
  182. package/dist/generate/comments.d.ts +3 -0
  183. package/dist/generate/compatibility-parts.d.ts +14 -0
  184. package/dist/generate/compatibility-references.d.ts +3 -0
  185. package/dist/generate/compatibility.d.ts +4 -0
  186. package/dist/generate/index.d.ts +1 -0
  187. package/dist/generate/master-defaults.d.ts +4 -0
  188. package/dist/generate/materialize.d.ts +2 -2
  189. package/dist/generate/math.d.ts +3 -0
  190. package/dist/generate/portable-clipboard.d.ts +4 -0
  191. package/dist/generate/projection-tree.d.ts +8 -0
  192. package/dist/generate/template.d.ts +68 -1
  193. package/dist/generate/text-body.d.ts +2 -0
  194. package/dist/generate/text-effects.d.ts +5 -0
  195. package/dist/generate/text-override.d.ts +8 -0
  196. package/dist/generate/validation.d.ts +3 -0
  197. package/dist/generate/warp.d.ts +2 -0
  198. package/dist/generate.js +1232 -512
  199. package/dist/history.d.ts +11 -1
  200. package/dist/identities.d.ts +4 -0
  201. package/dist/image-content.d.ts +5 -2
  202. package/dist/image-resource-history.d.ts +2 -0
  203. package/dist/index-C2r7c6G6.js +714 -0
  204. package/dist/index-CYDvbiwF.js +1 -0
  205. package/dist/index.d.ts +35 -7
  206. package/dist/ink/index.d.ts +27 -0
  207. package/dist/ink/model.d.ts +4 -0
  208. package/dist/ink/save.d.ts +3 -0
  209. package/dist/ink/source.d.ts +7 -0
  210. package/dist/ink.js +324 -0
  211. package/dist/layout-assets.d.ts +3 -1
  212. package/dist/layout-projection.d.ts +17 -5
  213. package/dist/layout-state.d.ts +2 -0
  214. package/dist/layout-types.d.ts +42 -0
  215. package/dist/layout.d.ts +5 -0
  216. package/dist/lint/color.d.ts +5 -0
  217. package/dist/lint/index.d.ts +7 -0
  218. package/dist/lint/prompts.d.ts +3 -0
  219. package/dist/lint/report.d.ts +21 -0
  220. package/dist/lint/sampler-batch.d.ts +4 -0
  221. package/dist/lint/sampler-images.d.ts +2 -0
  222. package/dist/lint/sampler.d.ts +9 -0
  223. package/dist/lint/snapshot.d.ts +34 -0
  224. package/dist/lint/types.d.ts +67 -0
  225. package/dist/lint-sampler.js +187 -0
  226. package/dist/lint.js +659 -0
  227. package/dist/master-state.d.ts +3 -0
  228. package/dist/master-text-style-state.d.ts +3 -0
  229. package/dist/master-types.d.ts +55 -0
  230. package/dist/master.d.ts +5 -0
  231. package/dist/media/audio-icon.d.ts +2 -0
  232. package/dist/media/commands.d.ts +3 -0
  233. package/dist/media/index.d.ts +10 -0
  234. package/dist/media/markup.d.ts +10 -0
  235. package/dist/media/mp4-boxes.d.ts +12 -0
  236. package/dist/media/mp4-fragments.d.ts +8 -0
  237. package/dist/media/mp4-samples.d.ts +4 -0
  238. package/dist/media/mp4.d.ts +2 -0
  239. package/dist/media/poster.d.ts +2 -0
  240. package/dist/media/replace-poster.d.ts +3 -0
  241. package/dist/media/resource.d.ts +4 -0
  242. package/dist/media/source.d.ts +14 -0
  243. package/dist/media/types.d.ts +33 -0
  244. package/dist/media-properties.d.ts +4 -0
  245. package/dist/media.js +1630 -0
  246. package/dist/model-invariants-BM19JVxy.js +8980 -0
  247. package/dist/object-source.d.ts +11 -0
  248. package/dist/ole/container.d.ts +14 -0
  249. package/dist/ole/content.d.ts +94 -0
  250. package/dist/ole/index.d.ts +20 -0
  251. package/dist/ole/preview.d.ts +3 -0
  252. package/dist/ole/save.d.ts +2 -0
  253. package/dist/ole/state.d.ts +16 -0
  254. package/dist/ole.js +870 -0
  255. package/dist/opc.js +1 -1
  256. package/dist/paragraph-level.d.ts +2 -2
  257. package/dist/paragraph-property-schema.d.ts +4 -1
  258. package/dist/{patch-D7lZelRa.js → patch-BwhfBbYE.js} +10 -10
  259. package/dist/patch-events.d.ts +5 -1
  260. package/dist/ppt/appearance.d.ts +11 -0
  261. package/dist/ppt/binary.d.ts +20 -0
  262. package/dist/ppt/drawing.d.ts +18 -0
  263. package/dist/ppt/geometry.d.ts +4 -0
  264. package/dist/ppt/index.d.ts +12 -0
  265. package/dist/ppt/pictures.d.ts +11 -0
  266. package/dist/ppt/text.d.ts +9 -0
  267. package/dist/ppt.js +774 -0
  268. package/dist/preset-geometry.d.ts +6 -0
  269. package/dist/projection.d.ts +2 -0
  270. package/dist/query-BHLjWjnu.js +903 -0
  271. package/dist/recovery-identity.d.ts +1 -0
  272. package/dist/recovery-migrations.d.ts +3 -0
  273. package/dist/recovery.d.ts +3 -0
  274. package/dist/resize/index.d.ts +6 -0
  275. package/dist/resize/text.d.ts +4 -0
  276. package/dist/resize.js +5090 -0
  277. package/dist/retained-element-origins.d.ts +6 -0
  278. package/dist/run-property-fields.d.ts +12 -0
  279. package/dist/run-property-schema.d.ts +3 -1
  280. package/dist/run-style.d.ts +15 -0
  281. package/dist/save/alt-text.d.ts +4 -0
  282. package/dist/save/comments.d.ts +3 -0
  283. package/dist/save/effects.d.ts +2 -1
  284. package/dist/save/extension-availability.d.ts +3 -0
  285. package/dist/save/extension-elements.d.ts +26 -0
  286. package/dist/save/index.d.ts +6 -1
  287. package/dist/save/insertion.d.ts +6 -5
  288. package/dist/save/layout-properties.d.ts +4 -0
  289. package/dist/save/master-properties.d.ts +5 -0
  290. package/dist/save/paragraph-overrides.d.ts +3 -0
  291. package/dist/save/slide-parts.d.ts +1 -0
  292. package/dist/save/table.d.ts +2 -0
  293. package/dist/save/xfrm.d.ts +8 -2
  294. package/dist/save.js +493 -498
  295. package/dist/sections.d.ts +8 -0
  296. package/dist/session-assets.d.ts +4 -0
  297. package/dist/slide-parts-D0o_DDhi.js +1331 -0
  298. package/dist/slide-size.d.ts +6 -0
  299. package/dist/smartart/drawing.d.ts +3 -0
  300. package/dist/smartart/index.d.ts +16 -0
  301. package/dist/smartart/model.d.ts +18 -0
  302. package/dist/smartart/save.d.ts +3 -0
  303. package/dist/smartart.js +604 -0
  304. package/dist/source-retention.d.ts +7 -0
  305. package/dist/space.d.ts +37 -0
  306. package/dist/table-cell.d.ts +7 -1
  307. package/dist/table-grid-projection.d.ts +6 -0
  308. package/dist/table-grid.d.ts +45 -0
  309. package/dist/table-invariants.d.ts +4 -0
  310. package/dist/table-rows.d.ts +2 -1
  311. package/dist/table-scale.d.ts +4 -0
  312. package/dist/table-style.d.ts +5 -4
  313. package/dist/templates/index.d.ts +4 -0
  314. package/dist/templates/recipes.d.ts +5 -0
  315. package/dist/templates/types.d.ts +17 -0
  316. package/dist/templates.js +543 -0
  317. package/dist/text-flatten.d.ts +6 -0
  318. package/dist/text-fragment.d.ts +5 -0
  319. package/dist/text-model.d.ts +8 -8
  320. package/dist/text-override-validation.d.ts +6 -2
  321. package/dist/text-selection.d.ts +4 -0
  322. package/dist/theme-projection.d.ts +8 -0
  323. package/dist/theme-xml.d.ts +3 -0
  324. package/dist/theme.d.ts +14 -0
  325. package/dist/types.d.ts +174 -8
  326. package/dist/xml/index.d.ts +1 -1
  327. package/dist/xml/nodes.d.ts +2 -2
  328. package/dist/xml/shape-ids.d.ts +3 -0
  329. package/dist/xml.js +19 -16
  330. package/package.json +73 -5
  331. package/schemas/describe.schema.json +479 -0
  332. package/schemas/lint.schema.json +145 -0
  333. package/dist/document-B1jjN-QB.js +0 -274
  334. package/dist/image-resource-DbgJS9n-.js +0 -24
  335. package/dist/index-D2JizcOQ.js +0 -706
  336. package/dist/insertion-CGpb504L.js +0 -6152
  337. package/dist/table-style-part-DBtpxmuo.js +0 -1042
@@ -0,0 +1,782 @@
1
+ const St = (t, e) => Object.prototype.hasOwnProperty.call(t, e);
2
+ function nt(t, e, n) {
3
+ if (!t || typeof t != "object" || Object.getPrototypeOf(t) !== Object.prototype && Object.getPrototypeOf(t) !== null)
4
+ throw new Error(`${n} 必须是纯数据对象`);
5
+ const s = Array.isArray(e) ? new Set(e) : e;
6
+ for (const o of Reflect.ownKeys(t)) {
7
+ const r = Object.getOwnPropertyDescriptor(t, o);
8
+ if (typeof o != "string" || !s.has(o) || !(r != null && r.enumerable) || !("value" in r))
9
+ throw new Error(`${n} 包含不可序列化或未知字段:${String(o)}`);
10
+ }
11
+ }
12
+ const S = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap();
13
+ function E(t) {
14
+ const e = S.get(t);
15
+ if (!e) throw new Error("XML 节点不属于保留型 XML 树");
16
+ return e;
17
+ }
18
+ function k(t) {
19
+ const e = T.get(t);
20
+ if (!e) throw new Error("XML 元素不属于保留型 XML 树");
21
+ return e;
22
+ }
23
+ function Q(t) {
24
+ let e = t;
25
+ for (; e; ) {
26
+ const n = E(e);
27
+ if (n.dirty) break;
28
+ n.dirty = !0, e = n.parent;
29
+ }
30
+ }
31
+ const Lt = "http://www.w3.org/XML/1998/namespace", Bt = "http://www.w3.org/2000/xmlns/", Nt = "http://schemas.openxmlformats.org/presentationml/2006/main", kt = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", Qt = /^[A-Za-z_][A-Za-z0-9_.-]*$/, Ht = /^[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{N}\p{M}\p{Pc}_.\-\u00B7\u203F-\u2040]*$/u, rt = (t) => Qt.test(t) || Ht.test(t);
32
+ function at(t) {
33
+ const e = t.indexOf(":");
34
+ return e < 0 ? rt(t) : e === t.lastIndexOf(":") && rt(t.slice(0, e)) && rt(t.slice(e + 1));
35
+ }
36
+ function Ft(t, e) {
37
+ if (!at(t)) throw new Error(`非法 XML ${e}名:${t}`);
38
+ }
39
+ const H = (t) => {
40
+ const e = t.indexOf(":");
41
+ return e < 0 ? { prefix: null, localName: t } : { prefix: t.slice(0, e), localName: t.slice(e + 1) };
42
+ };
43
+ function Z(t, e, n) {
44
+ const s = H(t);
45
+ return n && (t === "xmlns" || s.prefix === "xmlns") ? Bt : s.prefix === "xml" ? Lt : s.prefix ? e.get(s.prefix) || null : n ? null : e.get("") || null;
46
+ }
47
+ function Zt(t, e) {
48
+ const n = new Map(t);
49
+ for (const s of e.attributes)
50
+ s.name === "xmlns" ? n.set("", s.value) : s.name.startsWith("xmlns:") && n.set(s.name.slice(6), s.value);
51
+ return n;
52
+ }
53
+ function Jt(t) {
54
+ const e = k(t).parent;
55
+ return (e == null ? void 0 : e.type) === "element" ? k(e).namespaces : /* @__PURE__ */ new Map();
56
+ }
57
+ function z(t, e = Jt(t)) {
58
+ const n = k(t), s = Zt(e, t);
59
+ n.namespaces = s, t.namespaceUri = Z(t.name, s, !1);
60
+ for (const o of t.attributes)
61
+ o.namespaceUri = Z(o.name, s, !0);
62
+ for (const o of t.children)
63
+ o.type === "element" && z(o, s);
64
+ }
65
+ const D = (t) => t.attributes, Gt = (t, e) => {
66
+ t.value = e;
67
+ };
68
+ function Vt(t, e) {
69
+ return Z(e, k(t).namespaces, !0);
70
+ }
71
+ function Kt(t, e) {
72
+ const n = k(t), s = n.sourceAttributes.indexOf(e);
73
+ if (s < 0) return D(t).length;
74
+ const o = D(t);
75
+ for (let r = 0; r < o.length; r++) {
76
+ const i = n.sourceAttributes.indexOf(o[r]);
77
+ if (i >= 0 && i > s) return r;
78
+ }
79
+ return o.findIndex((r) => {
80
+ var i;
81
+ return !((i = X.get(r)) != null && i.source);
82
+ }) >= 0 ? o.findIndex((r) => {
83
+ var i;
84
+ return !((i = X.get(r)) != null && i.source);
85
+ }) : o.length;
86
+ }
87
+ function q(t, e, n, s = '"') {
88
+ Ft(e, "属性");
89
+ let r = k(t).sourceAttributes.find((l) => l.name === e) ?? D(t).find((l) => l.name === e);
90
+ if (r) {
91
+ const l = X.get(r);
92
+ let a = !1;
93
+ return l.present || (l.present = !0, D(t).splice(Kt(t, r), 0, r), a = !0), r.value !== n && (Gt(r, n), l.changed = !0, a = !0), a && ((e === "xmlns" || e.startsWith("xmlns:")) && z(t), Q(t)), r;
94
+ }
95
+ const i = H(e);
96
+ r = {
97
+ name: e,
98
+ prefix: i.prefix,
99
+ localName: i.localName,
100
+ namespaceUri: Vt(t, e),
101
+ value: n,
102
+ quote: s
103
+ };
104
+ const c = {
105
+ source: !1,
106
+ present: !0,
107
+ changed: !0,
108
+ start: -1,
109
+ nameStart: -1,
110
+ valueStart: -1,
111
+ valueEnd: -1,
112
+ end: -1
113
+ };
114
+ return X.set(r, c), D(t).push(r), (e === "xmlns" || e.startsWith("xmlns:")) && z(t), Q(t), r;
115
+ }
116
+ function Yt(t, e) {
117
+ const n = D(t), s = n.findIndex((r) => r.name === e);
118
+ if (s < 0) return !1;
119
+ const [o] = n.splice(s, 1);
120
+ return X.get(o).present = !1, e.startsWith("xmlns:") && z(t), Q(t), !0;
121
+ }
122
+ function It(t, e) {
123
+ let n = t.replace(/&/g, "&amp;").replace(/</g, "&lt;");
124
+ return n = e === '"' ? n.replace(/"/g, "&quot;") : n.replace(/'/g, "&apos;"), n;
125
+ }
126
+ function te(t) {
127
+ let e = t.length - 1;
128
+ for (; e > 0 && /\s/.test(t[e - 1]); ) e--;
129
+ if (t[e - 1] === "/")
130
+ for (e--; e > 0 && /\s/.test(t[e - 1]); ) e--;
131
+ return e;
132
+ }
133
+ function ee(t) {
134
+ const e = k(t), n = [];
135
+ for (const r of e.sourceAttributes) {
136
+ const i = X.get(r);
137
+ i.present ? i.changed && n.push({
138
+ start: i.valueStart,
139
+ end: i.valueEnd,
140
+ value: It(r.value, r.quote)
141
+ }) : n.push({ start: i.start, end: i.end, value: "" });
142
+ }
143
+ n.sort((r, i) => i.start - r.start);
144
+ let s = e.openRaw;
145
+ for (const r of n) s = s.slice(0, r.start) + r.value + s.slice(r.end);
146
+ const o = t.attributes.filter((r) => !X.get(r).source);
147
+ if (o.length) {
148
+ const r = te(s), i = o.map((c) => ` ${c.name}=${c.quote}${It(c.value, c.quote)}${c.quote}`).join("");
149
+ s = s.slice(0, r) + i + s.slice(r);
150
+ }
151
+ return e.sourceSelfClosing && t.children.length && (s = s.replace(/\s*\/\s*>$/, ">")), s;
152
+ }
153
+ const Ut = /* @__PURE__ */ new WeakMap(), se = {
154
+ amp: "&",
155
+ lt: "<",
156
+ gt: ">",
157
+ quot: '"',
158
+ apos: "'"
159
+ }, B = (t) => t === " " || t === " " || t === "\r" || t === `
160
+ `, Ct = (t) => B(t) || t === "=" || t === "/" || t === ">";
161
+ function ne(t) {
162
+ let e = t.length - 2;
163
+ for (; B(t[e]); ) e--;
164
+ return t[e] === "/";
165
+ }
166
+ function G(t) {
167
+ return t.includes("&") ? t.replace(/&(#x[0-9a-f]+|#[0-9]+|[A-Za-z][\w.-]*);/gi, (e, n) => {
168
+ if (n[0] !== "#") return se[n] ?? e;
169
+ const s = n[1].toLowerCase() === "x", o = Number.parseInt(n.slice(s ? 2 : 1), s ? 16 : 10);
170
+ return Number.isFinite(o) && o >= 0 && o <= 1114111 ? String.fromCodePoint(o) : e;
171
+ }) : t;
172
+ }
173
+ function re(t) {
174
+ let e = "utf-8", n = !1, s = 0;
175
+ return t[0] === 239 && t[1] === 187 && t[2] === 191 ? (n = !0, s = 3) : t[0] === 255 && t[1] === 254 ? (e = "utf-16le", n = !0, s = 2) : t[0] === 254 && t[1] === 255 ? (e = "utf-16be", n = !0, s = 2) : t[0] === 60 && t[1] === 0 ? e = "utf-16le" : t[0] === 0 && t[1] === 60 && (e = "utf-16be"), { text: new TextDecoder(e, { fatal: !0 }).decode(t.subarray(s)), encoding: e, bom: n };
176
+ }
177
+ function oe(t, e, n) {
178
+ if (e === "utf-8") {
179
+ const r = new TextEncoder().encode(t);
180
+ if (!n) return r;
181
+ const i = new Uint8Array(r.length + 3);
182
+ return i.set([239, 187, 191]), i.set(r, 3), i;
183
+ }
184
+ const s = new Uint8Array(t.length * 2 + (n ? 2 : 0));
185
+ let o = 0;
186
+ n && (s.set(e === "utf-16le" ? [255, 254] : [254, 255]), o = 2);
187
+ for (let r = 0; r < t.length; r++) {
188
+ const i = t.charCodeAt(r);
189
+ e === "utf-16le" ? (s[o++] = i & 255, s[o++] = i >>> 8) : (s[o++] = i >>> 8, s[o++] = i & 255);
190
+ }
191
+ return s;
192
+ }
193
+ function ie(t) {
194
+ const e = t.children.find((r) => r.type === "processing-instruction" && r.target.toLowerCase() === "xml"), n = e == null ? void 0 : e.value.match(/\bencoding\s*=\s*(['"])([^'"]+)\1/i), s = (n == null ? void 0 : n[2].toLowerCase()) ?? "utf-8", o = E(t).raw.startsWith("\uFEFF");
195
+ if (s === "utf-8" || s === "utf8") return { encoding: "utf-8", bom: o };
196
+ if (s === "utf-16") return { encoding: "utf-16le", bom: !0 };
197
+ if (s === "utf-16le") return { encoding: "utf-16le", bom: o };
198
+ if (s === "utf-16be") return { encoding: "utf-16be", bom: o };
199
+ throw new Error(`无法按 XML 声明输出 ${n == null ? void 0 : n[2]} 字节;仅支持 UTF-8 与 UTF-16`);
200
+ }
201
+ class Ot {
202
+ constructor(e) {
203
+ this.source = e, this.offset = 0;
204
+ }
205
+ parse() {
206
+ const e = [], n = { type: "document", children: e, root: null };
207
+ let s = null;
208
+ for (; this.offset < this.source.length; ) {
209
+ const o = this.source[this.offset] === "<" ? this.parseMarkup(n, /* @__PURE__ */ new Map()) : this.parseText(n);
210
+ e.push(o), o.type === "element" ? (s && this.fail("XML 只能有一个根元素"), s = o) : o.type === "text" && o.value.replace(/^\uFEFF/, "").trim() && this.fail("根元素外不能出现文本");
211
+ }
212
+ return s || this.fail("未找到根元素"), Object.defineProperty(n, "root", { value: s, enumerable: !0 }), S.set(n, { raw: this.source, parent: null, dirty: !1 }), n;
213
+ }
214
+ parseText(e) {
215
+ const n = this.offset, s = this.source.indexOf("<", n);
216
+ this.offset = s < 0 ? this.source.length : s;
217
+ const o = this.source.slice(n, this.offset), r = { type: "text", value: G(o) };
218
+ return S.set(r, { raw: o, parent: e, dirty: !1 }), r;
219
+ }
220
+ parseMarkup(e, n) {
221
+ const s = this.offset;
222
+ if (this.source.startsWith("<!--", s)) {
223
+ const o = this.source.indexOf("-->", s + 4);
224
+ o < 0 && this.fail("注释未闭合"), this.offset = o + 3;
225
+ const r = this.source.slice(s, this.offset), i = { type: "comment", value: r.slice(4, -3) };
226
+ return S.set(i, { raw: r, parent: e, dirty: !1 }), i;
227
+ }
228
+ if (this.source.startsWith("<![CDATA[", s)) {
229
+ const o = this.source.indexOf("]]>", s + 9);
230
+ o < 0 && this.fail("CDATA 未闭合"), this.offset = o + 3;
231
+ const r = this.source.slice(s, this.offset), i = { type: "cdata", value: r.slice(9, -3) };
232
+ return S.set(i, { raw: r, parent: e, dirty: !1 }), i;
233
+ }
234
+ return this.source.startsWith("<?", s) ? this.parseInstruction(e) : this.source.startsWith("<!", s) ? this.parseDeclaration(e) : (this.source.startsWith("</", s) && this.fail("遇到意外的闭合标签"), this.parseElement(e, n));
235
+ }
236
+ parseInstruction(e) {
237
+ const n = this.offset, s = this.source.indexOf("?>", n + 2);
238
+ s < 0 && this.fail("处理指令未闭合"), this.offset = s + 2;
239
+ const o = this.source.slice(n, this.offset), r = o.slice(2, -2), i = r.search(/\s/), c = {
240
+ type: "processing-instruction",
241
+ target: i < 0 ? r : r.slice(0, i),
242
+ value: i < 0 ? "" : r.slice(i).trimStart()
243
+ };
244
+ return S.set(c, { raw: o, parent: e, dirty: !1 }), c;
245
+ }
246
+ parseDeclaration(e) {
247
+ const n = this.offset;
248
+ let s = "", o = 0;
249
+ for (this.offset += 2; this.offset < this.source.length; ) {
250
+ const c = this.source[this.offset++];
251
+ if (s)
252
+ c === s && (s = "");
253
+ else if (c === '"' || c === "'") s = c;
254
+ else if (c === "[") o++;
255
+ else if (c === "]") o = Math.max(0, o - 1);
256
+ else if (c === ">" && o === 0) break;
257
+ }
258
+ this.source[this.offset - 1] !== ">" && this.fail("声明未闭合");
259
+ const r = this.source.slice(n, this.offset), i = { type: "declaration", value: r.slice(2, -1) };
260
+ return S.set(i, { raw: r, parent: e, dirty: !1 }), i;
261
+ }
262
+ parseElement(e, n) {
263
+ const s = this.offset, o = this.scanOpenEnd(s), r = this.source.slice(s, o + 1), i = this.scanNameEnd(s + 1, o), c = this.source.slice(s + 1, i);
264
+ at(c) || this.fail(`非法元素名 ${c || "(空)"}`);
265
+ const l = this.parseAttributes(r, c.length + 1), a = new Map(n);
266
+ a.set("xml", Lt);
267
+ for (const x of l)
268
+ x.name === "xmlns" ? a.set("", G(x.value)) : x.name.startsWith("xmlns:") && a.set(x.name.slice(6), G(x.value));
269
+ const u = l.map((x) => {
270
+ const I = H(x.name), A = {
271
+ name: x.name,
272
+ prefix: I.prefix,
273
+ localName: I.localName,
274
+ namespaceUri: Z(x.name, a, !0),
275
+ value: G(x.value),
276
+ quote: x.quote
277
+ };
278
+ return X.set(A, x.state), A;
279
+ }), m = H(c), h = ne(r), y = [], N = {
280
+ type: "element",
281
+ name: c,
282
+ prefix: m.prefix,
283
+ localName: m.localName,
284
+ namespaceUri: Z(c, a, !1),
285
+ attributes: u,
286
+ children: y,
287
+ selfClosing: h
288
+ };
289
+ this.offset = o + 1;
290
+ let F = "";
291
+ if (!h) {
292
+ for (; this.offset < this.source.length && !this.source.startsWith("</", this.offset); ) {
293
+ const W = this.source[this.offset] === "<" ? this.parseMarkup(N, a) : this.parseText(N);
294
+ y.push(W);
295
+ }
296
+ this.source.startsWith("</", this.offset) || this.fail(`元素 <${c}> 未闭合`);
297
+ const x = this.offset, I = this.source.indexOf(">", x + 2);
298
+ I < 0 && this.fail(`元素 <${c}> 未闭合`);
299
+ const A = this.source.slice(x + 2, I).trim();
300
+ A !== c && this.fail(`闭合标签 </${A}> 与 <${c}> 不匹配`), this.offset = I + 1, F = this.source.slice(x, this.offset);
301
+ }
302
+ const w = {
303
+ raw: this.source.slice(s, this.offset),
304
+ parent: e,
305
+ dirty: !1,
306
+ openRaw: r,
307
+ closeRaw: F,
308
+ sourceSelfClosing: h,
309
+ // 源属性表必须与公开的当前属性表分离;删除/新增只改当前表,序列化仍靠源表定位原始字节。
310
+ sourceAttributes: [...u],
311
+ namespaces: a
312
+ };
313
+ return S.set(N, w), T.set(N, w), N;
314
+ }
315
+ scanOpenEnd(e) {
316
+ let n = "";
317
+ for (let s = e + 1; s < this.source.length; s++) {
318
+ const o = this.source[s];
319
+ if (n)
320
+ o === n && (n = "");
321
+ else if (o === '"' || o === "'") n = o;
322
+ else if (o === ">") return s;
323
+ }
324
+ this.fail("开始标签未闭合");
325
+ }
326
+ scanNameEnd(e, n) {
327
+ let s = e;
328
+ for (; s < n && !Ct(this.source[s]); ) s++;
329
+ return s;
330
+ }
331
+ parseAttributes(e, n) {
332
+ const s = [], o = /* @__PURE__ */ new Set();
333
+ let r = n;
334
+ for (; r < e.length - 1; ) {
335
+ const i = r;
336
+ for (; B(e[r]); ) r++;
337
+ if (e[r] === "/" || e[r] === ">" || r >= e.length - 1) break;
338
+ r === i && this.fail("属性前缺少空白");
339
+ const c = r;
340
+ for (; r < e.length && !Ct(e[r]); ) r++;
341
+ const l = e.slice(c, r);
342
+ for (at(l) || this.fail(`非法属性名 ${l || "(空)"}`), o.has(l) && this.fail(`属性 ${l} 重复`), o.add(l); B(e[r]); ) r++;
343
+ for (e[r++] !== "=" && this.fail(`属性 ${l} 缺少等号`); B(e[r]); ) r++;
344
+ const a = e[r++];
345
+ a !== '"' && a !== "'" && this.fail(`属性 ${l} 必须使用引号`);
346
+ const u = r, m = e.indexOf(a, u);
347
+ m < 0 && this.fail(`属性 ${l} 未闭合`), r = m + 1, s.push({
348
+ name: l,
349
+ value: e.slice(u, m),
350
+ quote: a,
351
+ state: {
352
+ source: !0,
353
+ present: !0,
354
+ changed: !1,
355
+ start: i,
356
+ nameStart: c,
357
+ valueStart: u,
358
+ valueEnd: m,
359
+ end: r
360
+ }
361
+ });
362
+ }
363
+ return s;
364
+ }
365
+ fail(e) {
366
+ throw new Error(`XML 解析失败(偏移 ${this.offset}):${e}`);
367
+ }
368
+ }
369
+ function _t(t) {
370
+ const e = E(t);
371
+ if (!e.dirty || t.type !== "element") return e.raw;
372
+ const n = T.get(t), s = n.sourceSelfClosing && t.children.length ? `</${t.name}>` : n.closeRaw;
373
+ return ee(t) + t.children.map(_t).join("") + s;
374
+ }
375
+ function M(t) {
376
+ if (typeof t == "string") return new Ot(t).parse();
377
+ const e = re(t), n = new Ot(e.text).parse();
378
+ return Ut.set(n, { encoding: e.encoding, bom: e.bom, source: t }), n;
379
+ }
380
+ function le(t) {
381
+ const e = E(t);
382
+ return e.dirty ? t.children.map(_t).join("") : e.raw;
383
+ }
384
+ function j(t) {
385
+ const e = Ut.get(t);
386
+ if (e && !E(t).dirty) return e.source.slice();
387
+ const n = e ?? ie(t), s = le(t).replace(/^\uFEFF/, "");
388
+ return oe(s, n.encoding, n.bom);
389
+ }
390
+ function J(t, e = {}) {
391
+ if ("namespaceUri" in e)
392
+ throw new Error("namespaceUri 由 QName 与 xmlns 声明决定,不能脱离序列化文本覆盖");
393
+ Ft(t, "元素");
394
+ const n = H(t), s = e.selfClosing !== !1, o = [], r = [], i = {
395
+ type: "element",
396
+ name: t,
397
+ prefix: n.prefix,
398
+ localName: n.localName,
399
+ namespaceUri: null,
400
+ attributes: o,
401
+ children: r,
402
+ selfClosing: s
403
+ }, c = {
404
+ raw: s ? `<${t}/>` : `<${t}></${t}>`,
405
+ parent: null,
406
+ dirty: !0,
407
+ openRaw: s ? `<${t}/>` : `<${t}>`,
408
+ closeRaw: s ? "" : `</${t}>`,
409
+ sourceSelfClosing: s,
410
+ sourceAttributes: [],
411
+ namespaces: /* @__PURE__ */ new Map()
412
+ };
413
+ S.set(i, c), T.set(i, c);
414
+ for (const [l, a, u] of e.attributes ?? [])
415
+ q(i, l, a, u);
416
+ return i;
417
+ }
418
+ function jt(t) {
419
+ if (t.type !== "element") {
420
+ const n = { ...t };
421
+ return S.set(n, { raw: E(t).raw, parent: null, dirty: !1 }), n;
422
+ }
423
+ const e = J(t.name, {
424
+ selfClosing: t.selfClosing,
425
+ attributes: t.attributes.map((n) => [n.name, n.value, n.quote])
426
+ });
427
+ for (const n of t.children) L(e, jt(n));
428
+ return e;
429
+ }
430
+ function At(t, e) {
431
+ const n = jt(t), s = e ? T.get(e).namespaces : void 0, o = new Set(n.attributes.filter((r) => r.name === "xmlns" || r.name.startsWith("xmlns:")).map((r) => r.name === "xmlns" ? "" : r.name.slice(6)));
432
+ for (const [r, i] of T.get(t).namespaces)
433
+ r === "xml" || o.has(r) || (s == null ? void 0 : s.get(r)) === i || q(n, r ? `xmlns:${r}` : "xmlns", i);
434
+ return s && z(n, s), n;
435
+ }
436
+ function ce(t, e) {
437
+ if (E(e).parent) throw new Error("XML 节点已经属于另一棵树;请先显式移除");
438
+ let s = t;
439
+ for (; s; ) {
440
+ if (s === e) throw new Error("不能把 XML 节点插入自身后代");
441
+ s = E(s).parent;
442
+ }
443
+ }
444
+ function ae(t, e) {
445
+ e.type === "element" && z(e, T.get(t).namespaces);
446
+ }
447
+ function L(t, e, n = null) {
448
+ ce(t, e);
449
+ const s = t.children;
450
+ let o = n === null ? s.length : s.indexOf(n);
451
+ if (o < 0) throw new Error("before 不是该父元素的子节点");
452
+ let r = n !== null && o > 0 ? s[o - 1] : null, i = (r == null ? void 0 : r.type) === "text" && !r.value.trim() ? ft(r.value) : null;
453
+ if (n === null && o > 0) {
454
+ const c = s[o - 1];
455
+ if (c.type === "text" && !c.value.trim()) {
456
+ r = [...s.slice(0, -1)].reverse().find((a) => a.type === "text" && !a.value.trim()) ?? null;
457
+ const l = (r == null ? void 0 : r.type) === "text" ? r.value : c.value.replace(/([^\r\n])?$/, " $&");
458
+ i = ft(l), o--, s.splice(o, 0, i, e), o++;
459
+ } else
460
+ s.splice(o, 0, e);
461
+ } else
462
+ s.splice(o, 0, e, ...i ? [i] : []);
463
+ return ae(t, e), E(e).parent = t, i && (E(i).parent = t), t.selfClosing = !1, Q(t), o;
464
+ }
465
+ function K(t, e) {
466
+ const n = t.children, s = n.indexOf(e);
467
+ if (s < 0) return !1;
468
+ const o = n[s - 1], r = n[s + 1];
469
+ return e.type === "element" && (o == null ? void 0 : o.type) === "text" && !o.value.trim() && /[\r\n]/.test(o.value) && (r == null ? void 0 : r.type) === "text" && !r.value.trim() ? (n.splice(s - 1, 2), E(o).parent = null) : n.splice(s, 1), E(e).parent = null, t.selfClosing = T.get(t).sourceSelfClosing && n.length === 0, Q(t), !0;
470
+ }
471
+ function ft(t) {
472
+ const e = { type: "text", value: t }, n = t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
473
+ return S.set(e, { raw: n, parent: null, dirty: !0 }), e;
474
+ }
475
+ const Dt = (t, e) => t.localName === e.localName && (!Object.prototype.hasOwnProperty.call(e, "namespaceUri") || t.namespaceUri === e.namespaceUri);
476
+ function fe(t, e) {
477
+ const n = t.children.filter((s) => s.type === "element");
478
+ return e ? n.filter((s) => Dt(s, e)) : n;
479
+ }
480
+ function ue(t, e) {
481
+ return t.attributes.find((n) => Dt(n, e)) ?? null;
482
+ }
483
+ function ot(t) {
484
+ const e = t.lastIndexOf("/"), n = e < 0 ? "" : t.slice(0, e + 1), s = e < 0 ? t : t.slice(e + 1);
485
+ return `${n}_rels/${s}.rels`;
486
+ }
487
+ function Mt(t, e) {
488
+ const n = t.split("/").slice(0, -1), s = e.split("/");
489
+ let o = 0;
490
+ for (; o < n.length && o < s.length && n[o] === s[o]; ) o++;
491
+ return `${"../".repeat(n.length - o)}${s.slice(o).join("/")}`;
492
+ }
493
+ function Tt(t, e) {
494
+ const n = e.split("#", 1)[0], s = [
495
+ ...n.startsWith("/") ? [] : t.split("/").slice(0, -1),
496
+ ...n.replace(/^\//, "").split("/")
497
+ ], o = [];
498
+ for (const r of s)
499
+ if (!(!r || r === "."))
500
+ if (r === "..") {
501
+ if (!o.length) throw new Error(`OPC 关系越出包根:${e}`);
502
+ o.pop();
503
+ } else o.push(r);
504
+ return o.join("/");
505
+ }
506
+ const it = Symbol.for("@web-ppt/edit-core/extensions/v1"), Xt = Symbol.for("@web-ppt/edit-core/extensions-generation/v1"), lt = Symbol.for("@web-ppt/edit-core/extensions-listeners/v1"), de = /^[a-z][a-z0-9-]{0,63}$/;
507
+ function ct() {
508
+ const t = globalThis;
509
+ return t[lt] ?? (t[lt] = { documents: /* @__PURE__ */ new WeakMap(), pending: /* @__PURE__ */ new Map(), active: /* @__PURE__ */ new Set(), resolvers: /* @__PURE__ */ new WeakMap() });
510
+ }
511
+ function pe(t) {
512
+ if (!de.test(t))
513
+ throw new Error(`编辑扩展命名空间无效:${t}`);
514
+ }
515
+ function he() {
516
+ const t = globalThis;
517
+ return t[it] ?? (t[it] = /* @__PURE__ */ new Map());
518
+ }
519
+ function me(t, e) {
520
+ var o;
521
+ pe(t), he().set(t, e);
522
+ const n = globalThis;
523
+ n[Xt] = (n[Xt] ?? 0) + 1;
524
+ const s = new Set(ct().pending.get(t));
525
+ if (e.migrate) for (const r of ct().active) s.add(r);
526
+ ct().pending.delete(t);
527
+ for (const r of s ?? [])
528
+ try {
529
+ r(t);
530
+ } catch (i) {
531
+ (o = globalThis.reportError) == null || o.call(globalThis, i);
532
+ }
533
+ }
534
+ const qt = (t, e) => {
535
+ var n, s;
536
+ return ((s = (n = t.slides[e]) == null ? void 0 : n.ovr.extensions) == null ? void 0 : s.comments) ?? {};
537
+ };
538
+ function Y(t, e) {
539
+ const n = t.slides[e];
540
+ if (!n) throw new Error(`找不到幻灯片:${e}`);
541
+ const s = new Map((n.ovr.comments ?? n.src.comments ?? []).map((l, a) => [l.id ?? `source:${a}`, { ...l, id: l.id ?? `source:${a}` }]));
542
+ for (const [l, a] of Object.entries(qt(t, e)).sort(([u], [m]) => u < m ? -1 : u > m ? 1 : 0)) {
543
+ if (a.deleted) {
544
+ s.delete(l);
545
+ continue;
546
+ }
547
+ const { deleted: u, ...m } = a, h = { ...s.get(l), ...m, id: l };
548
+ typeof h.author == "string" && typeof h.text == "string" && typeof h.x == "number" && typeof h.y == "number" && s.set(l, h);
549
+ }
550
+ const o = [...s.values()];
551
+ for (const l of o) (!l.parentId || !s.has(l.parentId)) && delete l.parentId;
552
+ for (const l of [...o].sort((a, u) => a.id < u.id ? -1 : 1)) {
553
+ const a = /* @__PURE__ */ new Set();
554
+ let u = l;
555
+ for (; u != null && u.parentId; ) {
556
+ if (a.has(u.id)) {
557
+ delete u.parentId;
558
+ break;
559
+ }
560
+ a.add(u.id), u = s.get(u.parentId);
561
+ }
562
+ }
563
+ const r = /* @__PURE__ */ new Map();
564
+ for (const l of o) {
565
+ const a = r.get(l.parentId) ?? [];
566
+ a.push(l), r.set(l.parentId, a);
567
+ }
568
+ const i = [], c = [...r.get(void 0) ?? []].reverse();
569
+ for (; c.length; ) {
570
+ const l = c.pop();
571
+ i.push(l), c.push(...[...r.get(l.id) ?? []].reverse());
572
+ }
573
+ return i;
574
+ }
575
+ function zt(t, e) {
576
+ const n = e.path[6];
577
+ if (e.path[0] !== "slides" || e.path.length !== 7 || !e.path[5] || !["author", "initials", "date", "text", "x", "y", "parentId", "deleted"].includes(n)) throw new Error("批注补丁字段无效");
578
+ if (e.op === "del") return;
579
+ const s = e.value;
580
+ if (n === "deleted" ? typeof s != "boolean" : n === "x" || n === "y" ? typeof s != "number" || !Number.isFinite(s) || Math.abs(s) > 2255e4 : typeof s != "string" || s.length > (n === "text" ? 1e6 : 1024)) throw new Error(`批注 ${n} 无效`);
581
+ if (typeof s == "string" && /[\u0000-\u0008\u000b\u000c\u000e-\u001f\ud800-\udfff\ufffe\uffff]/u.test(s)) throw new Error("批注包含 XML 不允许的字符");
582
+ if (n === "date" && s && (!/^\d{4}-\d{2}-\d{2}T/.test(s) || !Number.isFinite(Date.parse(s)))) throw new Error("批注日期需要 ISO 8601 字符串");
583
+ if (n === "parentId" && s === e.path[5]) throw new Error("批注不能回复自身");
584
+ }
585
+ const Wt = "{C676402C-5697-4E1C-873F-D02D1690AC5C}", xe = "http://schemas.microsoft.com/office/powerpoint/2012/main", g = (t, e) => {
586
+ var n;
587
+ return (n = ue(t, { localName: e, namespaceUri: null })) == null ? void 0 : n.value;
588
+ }, v = (t, e) => fe(t, { localName: e });
589
+ function P(t, e, n = {}) {
590
+ const s = J(e, { attributes: Object.entries(n) });
591
+ return L(t, s), s;
592
+ }
593
+ function ge(t, e, n, s) {
594
+ q(t, "authorId", n.author), q(t, "idx", String(n.idx)), e.date ? q(t, "dt", e.date) : Yt(t, "dt");
595
+ for (const h of ["pos", "text"]) for (const y of v(t, h)) K(t, y);
596
+ const o = t.prefix ? t.prefix + ":" : "", r = (h) => String(Math.round(h * 9525)), i = J(`${o}pos`, { attributes: [["x", r(e.x)], ["y", r(e.y)]] }), c = J(`${o}text`);
597
+ L(c, ft(e.text));
598
+ const l = t.children[0] ?? null;
599
+ L(t, i, l), L(t, c, l);
600
+ let a = v(t, "extLst")[0];
601
+ if (a)
602
+ for (const h of v(a, "ext")) g(h, "uri") === Wt && K(a, h);
603
+ if (!s) return;
604
+ a ?? (a = P(t, `${o}extLst`));
605
+ const u = P(a, `${o}ext`, { uri: Wt }), m = P(u, "p15:threadingInfo", { "xmlns:p15": xe });
606
+ P(m, "p15:parentCm", { authorId: s.author, idx: String(s.idx) });
607
+ }
608
+ const V = "ppt/comments/web-ppt-edit-", we = `${kt}/comments`;
609
+ function ye(t, e, n, s) {
610
+ var pt, ht, mt, xt, gt, wt;
611
+ const o = t.slideOrder.filter((f) => {
612
+ var d;
613
+ return ((d = t.slides[f].ovr.extensions) == null ? void 0 : d.comments) !== void 0;
614
+ });
615
+ if (!o.length && ![...n].some((f) => f.startsWith(V))) return;
616
+ const r = (f) => {
617
+ var d;
618
+ return e[f] ?? ((d = t.package) == null ? void 0 : d.parts[f]);
619
+ }, i = (f) => {
620
+ let d = `${f}.xml`, b = 1;
621
+ for (; r(d) && !n.has(d); ) d = `${f}-${b++}.xml`;
622
+ return d;
623
+ }, c = (f) => i(`${V}${f.split("/").pop().replace(/\.xml$/, "")}`), l = i(`${V}authors`), a = (f) => s[f] ?? r(f), u = (f) => {
624
+ const d = r(f);
625
+ d && !n.has(f) && (e[f] ?? (e[f] = d.slice()));
626
+ }, m = (f) => M(a(f)), h = (f) => {
627
+ const d = ot(f);
628
+ return u(d), { path: d, tree: M(a(d) ?? '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"/>') };
629
+ }, y = m("[Content_Types].xml");
630
+ u("[Content_Types].xml");
631
+ for (const f of [...v(y.root, "Override")]) (pt = g(f, "PartName")) != null && pt.slice(1).startsWith(V) && n.has(g(f, "PartName").slice(1)) && K(y.root, f);
632
+ const N = h("ppt/presentation.xml"), F = v(N.tree.root, "Relationship").find((f) => {
633
+ var d;
634
+ return (d = g(f, "Type")) == null ? void 0 : d.endsWith("/commentAuthors");
635
+ }), w = F ? Tt("ppt/presentation.xml", g(F, "Target")) : l;
636
+ u(w);
637
+ const x = M((n.has(w) ? s[w] : a(w)) ?? `<p:cmAuthorLst xmlns:p="${Nt}"/>`), I = new Map(v(x.root, "cmAuthor").map((f) => [JSON.stringify([g(f, "name"), g(f, "initials") ?? ""]), f])), A = new Set([...I.values()].map((f) => g(f, "id")));
638
+ let W = 0, U = 0;
639
+ const tt = /* @__PURE__ */ new Set();
640
+ for (const f of v(y.root, "Override")) {
641
+ if (!((ht = g(f, "ContentType")) != null && ht.endsWith(".comments+xml"))) continue;
642
+ const d = a(g(f, "PartName").slice(1));
643
+ if (d)
644
+ for (const b of v(M(d).root, "cm")) tt.add(Number(g(b, "idx")) || 0);
645
+ }
646
+ const ut = (f, d) => P(y.root, "Override", {
647
+ PartName: `/${f}`,
648
+ ContentType: `application/vnd.openxmlformats-officedocument.presentationml.${d}+xml`
649
+ }), dt = (f, d, b) => {
650
+ const _ = new Set(v(f, "Relationship").map((C) => g(C, "Id")));
651
+ let R = 1;
652
+ for (; _.has(`rId${R}`); ) R++;
653
+ P(f, "Relationship", { Id: `rId${R}`, Type: b, Target: d });
654
+ };
655
+ for (const f of t.slideOrder) {
656
+ const d = t.slides[f], b = (mt = d.origin) == null ? void 0 : mt.part;
657
+ if (!b) continue;
658
+ const _ = ot(b), R = r(_);
659
+ if (!o.includes(f) && !n.has(c(b))) continue;
660
+ const C = h(b), yt = ((xt = d.creation) == null ? void 0 : xt.duplicateSourcePart) ?? b, bt = r(ot(yt)), vt = bt && v(M(bt).root, "Relationship").find((p) => {
661
+ var $;
662
+ return ($ = g(p, "Type")) == null ? void 0 : $.endsWith("/comments");
663
+ });
664
+ for (const p of [...v(C.tree.root, "Relationship")]) (gt = g(p, "Type")) != null && gt.endsWith("/comments") && K(C.tree.root, p);
665
+ if (!o.includes(f)) {
666
+ const p = d.creation ? a(_) : R;
667
+ if (p)
668
+ for (const $ of v(M(p).root, "Relationship")) (wt = g($, "Type")) != null && wt.endsWith("/comments") && L(C.tree.root, At($, C.tree.root));
669
+ s[_] = j(C.tree);
670
+ continue;
671
+ }
672
+ const Et = vt && r(Tt(yt, g(vt, "Target"))), Rt = new Map(Et ? v(M(Et).root, "cm").map((p) => [`${g(p, "authorId")}:${g(p, "idx")}`, p]) : []), et = M(`<p:cmLst xmlns:p="${Nt}"/>`), $t = Y(t, f), st = /* @__PURE__ */ new Map();
673
+ for (const p of $t) {
674
+ const $ = JSON.stringify([p.author, p.initials ?? ""]);
675
+ let O = I.get($);
676
+ if (!O) {
677
+ for (; A.has(String(W)); ) W++;
678
+ O = P(x.root, "p:cmAuthor", {
679
+ id: String(W),
680
+ name: p.author,
681
+ initials: p.initials ?? "",
682
+ lastIdx: "0",
683
+ clrIdx: String(W)
684
+ }), A.add(String(W++)), I.set($, O);
685
+ }
686
+ do
687
+ U++;
688
+ while (tt.has(U));
689
+ if (U > 4294967295) throw new Error("批注索引超出 OOXML 范围");
690
+ tt.add(U), q(O, "lastIdx", String(Math.max(Number(g(O, "lastIdx")) || 0, U))), st.set(p.id, { author: g(O, "id"), idx: U });
691
+ }
692
+ for (const p of $t) {
693
+ const $ = Rt.get(p.id), O = $ ? At($, et.root) : J("p:cm");
694
+ ge(O, p, st.get(p.id), p.parentId ? st.get(p.parentId) : void 0), L(et.root, O);
695
+ }
696
+ {
697
+ const p = c(b);
698
+ n.add(p), s[p] = j(et), ut(p, "comments"), dt(C.tree.root, Mt(b, p), we);
699
+ }
700
+ s[_] = j(C.tree);
701
+ }
702
+ o.length ? (s[w] = j(x), w === l && (n.add(w), ut(w, "commentAuthors"), F || dt(N.tree.root, Mt("ppt/presentation.xml", w), `${kt}/commentAuthors`))) : e[w] && !s[w] && (s[w] = e[w]), s[N.path] = j(N.tree), s["[Content_Types].xml"] = j(y);
703
+ }
704
+ function be(t, e, n) {
705
+ const s = e.payload;
706
+ if (nt(s, ["type", "slideId", "id", "comment", "fields"], "批注命令"), e.scope !== "slide" || e.id !== s.slideId || !t.slides[s.slideId] || t.meta.readonly) throw new Error("目标不允许修改批注");
707
+ const o = Y(t, s.slideId);
708
+ let r, i;
709
+ if (s.type === "AddComment") {
710
+ if (nt(s.comment, ["id", "author", "initials", "date", "text", "x", "y", "parentId"], "新增批注"), { id: r, ...i } = s.comment, o.some((u) => u.id === r)) throw new Error("批注身份已存在");
711
+ if (typeof i.author != "string" || typeof i.text != "string" || typeof i.x != "number" || typeof i.y != "number") throw new Error("新增批注缺少作者、正文或锚点");
712
+ i.deleted = !1;
713
+ } else {
714
+ if (r = s.id, !o.some((u) => u.id === r)) throw new Error("找不到批注");
715
+ if (s.type === "RemoveComment") i = { deleted: !0 };
716
+ else if (s.type === "UpdateComment")
717
+ nt(s.fields, ["author", "initials", "date", "text", "x", "y", "parentId"], "批注字段"), i = s.fields;
718
+ else throw new Error("批注命令无效");
719
+ }
720
+ if (typeof r != "string" || !r) throw new Error("批注身份不能为空");
721
+ if (i.parentId) {
722
+ const u = /* @__PURE__ */ new Set([r]);
723
+ let m = i.parentId;
724
+ for (; m; ) {
725
+ if (u.has(m)) throw new Error("批注回复关系不能成环");
726
+ u.add(m);
727
+ const h = o.find((y) => y.id === m);
728
+ if (!h) throw new Error("回复的父批注不存在");
729
+ m = h.parentId;
730
+ }
731
+ }
732
+ const c = qt(t, s.slideId)[r] ?? {}, l = [], a = [];
733
+ for (const [u, m] of Object.entries(i)) {
734
+ const h = ["slides", s.slideId, "ovr", "extensions", "comments", r, u], y = { op: "set", path: h, value: m, origin: n };
735
+ zt(t, y), !(St(c, u) && c[u] === m) && (l.push(y), a.unshift(St(c, u) ? { op: "set", path: h, value: c[u], origin: n } : { op: "del", path: h, origin: n }));
736
+ }
737
+ return { forward: l, inverse: a };
738
+ }
739
+ let Pt = !1;
740
+ function ve() {
741
+ Pt || (me("comments", {
742
+ scope: "slide",
743
+ command: be,
744
+ validatePatch: zt,
745
+ projectSlide(t, e, n) {
746
+ return { ...n, comments: Y(t, e) };
747
+ },
748
+ materializePackage: ye
749
+ }), Pt = !0);
750
+ }
751
+ function Ee(t) {
752
+ ve();
753
+ const e = (n) => t.exec({
754
+ type: "Extension",
755
+ namespace: "comments",
756
+ scope: "slide",
757
+ id: n.slideId,
758
+ payload: n
759
+ });
760
+ return {
761
+ exec: e,
762
+ query: (n) => Y(t.doc, n),
763
+ add(n, s) {
764
+ const o = s.id ?? `new:${globalThis.crypto.randomUUID()}`;
765
+ return e({ type: "AddComment", slideId: n, comment: { ...s, id: o } }), o;
766
+ },
767
+ update(n, s, o) {
768
+ return e({ type: "UpdateComment", slideId: n, id: s, fields: o });
769
+ },
770
+ remove(n, s) {
771
+ return e({ type: "RemoveComment", slideId: n, id: s });
772
+ },
773
+ reply(n, s, o) {
774
+ return this.add(n, { ...o, parentId: s });
775
+ }
776
+ };
777
+ }
778
+ export {
779
+ Ee as createCommentEditor,
780
+ Y as queryComments,
781
+ ve as registerCommentEditing
782
+ };