@web-ppt/edit-core 0.5.0-beta.1 → 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 (367) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/README.md +165 -22
  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/collaboration-identity.d.ts +3 -0
  107. package/dist/commands/add-slide-identity.d.ts +4 -0
  108. package/dist/commands/bullet-image-resource.d.ts +11 -0
  109. package/dist/commands/clear-format.d.ts +4 -0
  110. package/dist/commands/common-object-slide-patch.d.ts +4 -0
  111. package/dist/commands/common-object-slide-types.d.ts +68 -0
  112. package/dist/commands/convert-to-custom-geometry.d.ts +4 -0
  113. package/dist/commands/direct-format-patches.d.ts +11 -5
  114. package/dist/commands/distribute-elements.d.ts +4 -0
  115. package/dist/commands/edit-table-grid.d.ts +10 -0
  116. package/dist/commands/element-alt-text.d.ts +8 -0
  117. package/dist/commands/element-arrangement.d.ts +17 -0
  118. package/dist/commands/element-effects.d.ts +1 -1
  119. package/dist/commands/element-fill.d.ts +1 -1
  120. package/dist/commands/element-geometry.d.ts +9 -0
  121. package/dist/commands/element-hierarchy.d.ts +6 -0
  122. package/dist/commands/element-image-content.d.ts +2 -2
  123. package/dist/commands/element-link.d.ts +1 -1
  124. package/dist/commands/element-name.d.ts +1 -1
  125. package/dist/commands/element-stroke.d.ts +1 -1
  126. package/dist/commands/element-table-style.d.ts +5 -0
  127. package/dist/commands/element-text.d.ts +1 -1
  128. package/dist/commands/element-transform.d.ts +2 -2
  129. package/dist/commands/frame-decomposition.d.ts +10 -0
  130. package/dist/commands/generated-creation-defaults.d.ts +4 -0
  131. package/dist/commands/geometry-types.d.ts +44 -0
  132. package/dist/commands/group-types.d.ts +24 -0
  133. package/dist/commands/group.d.ts +4 -0
  134. package/dist/commands/hierarchy-record.d.ts +5 -0
  135. package/dist/commands/image-resource.d.ts +8 -1
  136. package/dist/commands/insertion-host.d.ts +16 -0
  137. package/dist/commands/insertion-rect.d.ts +2 -0
  138. package/dist/commands/layout-property.d.ts +7 -0
  139. package/dist/commands/master-property.d.ts +5 -0
  140. package/dist/commands/master-text-style-types.d.ts +27 -0
  141. package/dist/commands/master-text-style.d.ts +7 -0
  142. package/dist/commands/paste-resources.d.ts +9 -5
  143. package/dist/commands/patch-apply.d.ts +3 -0
  144. package/dist/commands/patch-count.d.ts +1 -0
  145. package/dist/commands/patch-invalidation.d.ts +4 -0
  146. package/dist/commands/patch-stage.d.ts +4 -0
  147. package/dist/commands/patch.d.ts +4 -0
  148. package/dist/commands/record-clone.d.ts +3 -0
  149. package/dist/commands/record-override.d.ts +5 -0
  150. package/dist/commands/replace-image.d.ts +6 -1
  151. package/dist/commands/sections.d.ts +10 -0
  152. package/dist/commands/set-geometry.d.ts +4 -0
  153. package/dist/commands/set-preset.d.ts +5 -0
  154. package/dist/commands/set-table-style.d.ts +3 -0
  155. package/dist/commands/slide-property-types.d.ts +55 -5
  156. package/dist/commands/slide-size.d.ts +7 -0
  157. package/dist/commands/spid.d.ts +2 -1
  158. package/dist/commands/table-grid-patch.d.ts +12 -0
  159. package/dist/commands/table-style-types.d.ts +28 -0
  160. package/dist/commands/text-target.d.ts +3 -2
  161. package/dist/commands/theme-types.d.ts +47 -0
  162. package/dist/commands/theme.d.ts +9 -0
  163. package/dist/commands/types.d.ts +219 -17
  164. package/dist/commands/ungroup-source.d.ts +3 -0
  165. package/dist/commands/ungroup.d.ts +4 -0
  166. package/dist/comments/index.d.ts +35 -0
  167. package/dist/comments/save.d.ts +3 -0
  168. package/dist/comments/state.d.ts +10 -0
  169. package/dist/comments/xml.d.ts +12 -0
  170. package/dist/comments.js +782 -0
  171. package/dist/common-object-slide-types.d.ts +34 -0
  172. package/dist/custom-geometry-path.d.ts +3 -0
  173. package/dist/custom-geometry.d.ts +12 -0
  174. package/dist/data-validation.d.ts +1 -1
  175. package/dist/describe/budget.d.ts +3 -0
  176. package/dist/describe/index.d.ts +5 -0
  177. package/dist/describe/read.d.ts +4 -0
  178. package/dist/describe/types.d.ts +103 -0
  179. package/dist/describe.js +192 -0
  180. package/dist/design-dependencies.d.ts +8 -0
  181. package/dist/design-projection-package.d.ts +10 -0
  182. package/dist/design-target.d.ts +10 -0
  183. package/dist/design.d.ts +3 -0
  184. package/dist/document-extensions.d.ts +9 -0
  185. package/dist/document.d.ts +1 -1
  186. package/dist/dynamic-projection.d.ts +6 -0
  187. package/dist/edit-core.js +5680 -3413
  188. package/dist/editor.d.ts +19 -2
  189. package/dist/element-source.d.ts +11 -0
  190. package/dist/element-spids.d.ts +4 -0
  191. package/dist/extension-address-journal.d.ts +9 -0
  192. package/dist/extension-address-remap.d.ts +14 -0
  193. package/dist/extension-addresses.d.ts +20 -0
  194. package/dist/extension-copy-history.d.ts +7 -0
  195. package/dist/extension-copy.d.ts +16 -0
  196. package/dist/extension-migration-receipt.d.ts +34 -0
  197. package/dist/extension-recovery-context.d.ts +5 -0
  198. package/dist/extension-runtime.d.ts +64 -0
  199. package/dist/generate/comments.d.ts +3 -0
  200. package/dist/generate/compatibility-parts.d.ts +14 -0
  201. package/dist/generate/compatibility-references.d.ts +3 -0
  202. package/dist/generate/compatibility.d.ts +4 -0
  203. package/dist/generate/custom-geometry.d.ts +2 -0
  204. package/dist/generate/index.d.ts +13 -0
  205. package/dist/generate/links.d.ts +3 -0
  206. package/dist/generate/master-defaults.d.ts +4 -0
  207. package/dist/generate/materialize.d.ts +2 -0
  208. package/dist/generate/math.d.ts +3 -0
  209. package/dist/generate/media.d.ts +13 -0
  210. package/dist/generate/portable-clipboard.d.ts +4 -0
  211. package/dist/generate/projection-tree.d.ts +8 -0
  212. package/dist/generate/table.d.ts +4 -0
  213. package/dist/generate/template.d.ts +70 -0
  214. package/dist/generate/text-body.d.ts +2 -0
  215. package/dist/generate/text-effects.d.ts +5 -0
  216. package/dist/generate/text-override.d.ts +8 -0
  217. package/dist/generate/validation.d.ts +3 -0
  218. package/dist/generate/warp.d.ts +2 -0
  219. package/dist/generate.js +1464 -0
  220. package/dist/history.d.ts +11 -1
  221. package/dist/hyperlink.d.ts +2 -0
  222. package/dist/identities.d.ts +4 -0
  223. package/dist/identity-allocation.d.ts +12 -0
  224. package/dist/identity-watermark.d.ts +4 -0
  225. package/dist/image-content.d.ts +5 -2
  226. package/dist/image-resource-history.d.ts +2 -0
  227. package/dist/index-C2r7c6G6.js +714 -0
  228. package/dist/index-CYDvbiwF.js +1 -0
  229. package/dist/index.d.ts +43 -7
  230. package/dist/ink/index.d.ts +27 -0
  231. package/dist/ink/model.d.ts +4 -0
  232. package/dist/ink/save.d.ts +3 -0
  233. package/dist/ink/source.d.ts +7 -0
  234. package/dist/ink.js +324 -0
  235. package/dist/layout-assets.d.ts +3 -1
  236. package/dist/layout-projection.d.ts +19 -5
  237. package/dist/layout-state.d.ts +2 -0
  238. package/dist/layout-types.d.ts +42 -0
  239. package/dist/layout.d.ts +5 -0
  240. package/dist/lint/color.d.ts +5 -0
  241. package/dist/lint/index.d.ts +7 -0
  242. package/dist/lint/prompts.d.ts +3 -0
  243. package/dist/lint/report.d.ts +21 -0
  244. package/dist/lint/sampler-batch.d.ts +4 -0
  245. package/dist/lint/sampler-images.d.ts +2 -0
  246. package/dist/lint/sampler.d.ts +9 -0
  247. package/dist/lint/snapshot.d.ts +34 -0
  248. package/dist/lint/types.d.ts +67 -0
  249. package/dist/lint-sampler.js +187 -0
  250. package/dist/lint.js +659 -0
  251. package/dist/master-state.d.ts +3 -0
  252. package/dist/master-text-style-state.d.ts +3 -0
  253. package/dist/master-types.d.ts +55 -0
  254. package/dist/master.d.ts +5 -0
  255. package/dist/media/audio-icon.d.ts +2 -0
  256. package/dist/media/commands.d.ts +3 -0
  257. package/dist/media/index.d.ts +10 -0
  258. package/dist/media/markup.d.ts +10 -0
  259. package/dist/media/mp4-boxes.d.ts +12 -0
  260. package/dist/media/mp4-fragments.d.ts +8 -0
  261. package/dist/media/mp4-samples.d.ts +4 -0
  262. package/dist/media/mp4.d.ts +2 -0
  263. package/dist/media/poster.d.ts +2 -0
  264. package/dist/media/replace-poster.d.ts +3 -0
  265. package/dist/media/resource.d.ts +4 -0
  266. package/dist/media/source.d.ts +14 -0
  267. package/dist/media/types.d.ts +33 -0
  268. package/dist/media-properties.d.ts +4 -0
  269. package/dist/media.js +1630 -0
  270. package/dist/model-invariants-BM19JVxy.js +8980 -0
  271. package/dist/object-source.d.ts +11 -0
  272. package/dist/ole/container.d.ts +14 -0
  273. package/dist/ole/content.d.ts +94 -0
  274. package/dist/ole/index.d.ts +20 -0
  275. package/dist/ole/preview.d.ts +3 -0
  276. package/dist/ole/save.d.ts +2 -0
  277. package/dist/ole/state.d.ts +16 -0
  278. package/dist/ole.js +870 -0
  279. package/dist/opc/patch.d.ts +2 -0
  280. package/dist/opc.js +1 -1
  281. package/dist/paragraph-level.d.ts +11 -0
  282. package/dist/paragraph-property-schema.d.ts +5 -2
  283. package/dist/{patch-DO8497wO.js → patch-BwhfBbYE.js} +112 -95
  284. package/dist/patch-change.d.ts +4 -0
  285. package/dist/patch-events.d.ts +16 -0
  286. package/dist/ppt/appearance.d.ts +11 -0
  287. package/dist/ppt/binary.d.ts +20 -0
  288. package/dist/ppt/drawing.d.ts +18 -0
  289. package/dist/ppt/geometry.d.ts +4 -0
  290. package/dist/ppt/index.d.ts +12 -0
  291. package/dist/ppt/pictures.d.ts +11 -0
  292. package/dist/ppt/text.d.ts +9 -0
  293. package/dist/ppt.js +774 -0
  294. package/dist/preset-geometry.d.ts +6 -0
  295. package/dist/projection.d.ts +2 -0
  296. package/dist/query-BHLjWjnu.js +903 -0
  297. package/dist/recovery-identity.d.ts +3 -1
  298. package/dist/recovery-migrations.d.ts +3 -0
  299. package/dist/recovery.d.ts +3 -0
  300. package/dist/resize/index.d.ts +6 -0
  301. package/dist/resize/text.d.ts +4 -0
  302. package/dist/resize.js +5090 -0
  303. package/dist/retained-element-origins.d.ts +6 -0
  304. package/dist/run-property-fields.d.ts +12 -0
  305. package/dist/run-property-schema.d.ts +3 -1
  306. package/dist/run-style.d.ts +15 -0
  307. package/dist/save/alt-text.d.ts +4 -0
  308. package/dist/save/comments.d.ts +3 -0
  309. package/dist/save/effects.d.ts +2 -1
  310. package/dist/save/extension-availability.d.ts +3 -0
  311. package/dist/save/extension-elements.d.ts +26 -0
  312. package/dist/save/geometry.d.ts +5 -0
  313. package/dist/save/index.d.ts +6 -1
  314. package/dist/save/insertion.d.ts +7 -3
  315. package/dist/save/layout-properties.d.ts +4 -0
  316. package/dist/save/master-properties.d.ts +5 -0
  317. package/dist/save/notes.d.ts +2 -0
  318. package/dist/save/paragraph-overrides.d.ts +3 -0
  319. package/dist/save/run-overrides.d.ts +10 -0
  320. package/dist/save/shape-format.d.ts +3 -0
  321. package/dist/save/slide-parts.d.ts +1 -0
  322. package/dist/save/table-style-part.d.ts +11 -0
  323. package/dist/save/table.d.ts +5 -0
  324. package/dist/save/text-source-less.d.ts +6 -0
  325. package/dist/save/xfrm.d.ts +8 -2
  326. package/dist/save.js +502 -1480
  327. package/dist/sections.d.ts +8 -0
  328. package/dist/session-assets.d.ts +4 -0
  329. package/dist/slide-parts-D0o_DDhi.js +1331 -0
  330. package/dist/slide-size.d.ts +6 -0
  331. package/dist/smartart/drawing.d.ts +3 -0
  332. package/dist/smartart/index.d.ts +16 -0
  333. package/dist/smartart/model.d.ts +18 -0
  334. package/dist/smartart/save.d.ts +3 -0
  335. package/dist/smartart.js +604 -0
  336. package/dist/source-retention.d.ts +7 -0
  337. package/dist/space.d.ts +37 -0
  338. package/dist/table-cell.d.ts +7 -1
  339. package/dist/table-direct-markup.d.ts +7 -1
  340. package/dist/table-grid-projection.d.ts +6 -0
  341. package/dist/table-grid.d.ts +45 -0
  342. package/dist/table-invariants.d.ts +4 -0
  343. package/dist/table-rows.d.ts +2 -1
  344. package/dist/table-scale.d.ts +4 -0
  345. package/dist/table-style.d.ts +21 -0
  346. package/dist/templates/index.d.ts +4 -0
  347. package/dist/templates/recipes.d.ts +5 -0
  348. package/dist/templates/types.d.ts +17 -0
  349. package/dist/templates.js +543 -0
  350. package/dist/text-flatten.d.ts +6 -0
  351. package/dist/text-fragment.d.ts +5 -0
  352. package/dist/text-model.d.ts +8 -8
  353. package/dist/text-override-validation.d.ts +6 -2
  354. package/dist/text-selection.d.ts +4 -0
  355. package/dist/theme-projection.d.ts +8 -0
  356. package/dist/theme-xml.d.ts +3 -0
  357. package/dist/theme.d.ts +14 -0
  358. package/dist/types.d.ts +217 -8
  359. package/dist/xml/index.d.ts +1 -1
  360. package/dist/xml/nodes.d.ts +2 -2
  361. package/dist/xml/shape-ids.d.ts +3 -0
  362. package/dist/xml.js +19 -16
  363. package/package.json +77 -5
  364. package/schemas/describe.schema.json +479 -0
  365. package/schemas/lint.schema.json +145 -0
  366. package/dist/index-D4ZTaYOa.js +0 -706
  367. package/dist/insertion-DabLme_U.js +0 -5471
package/dist/save.js CHANGED
@@ -1,1559 +1,581 @@
1
- import { b as Tt, r as ie, a as Y, c as lt, n as E, d as U, e as wt, f as bt, o as D, g as kt, h as Et, i as xt, j as Mt, m as Ut, k as It, l as We, p as Ct, q as Rt, s as Ot, v as Lt, t as ft, u as At, w as Bt, x as $t, y as Ft, z as _t, A as Dt, B as pt, C as Xt, D as jt, E as Gt, F as zt, G as Ht, H as qt, I as Vt, J as Wt, K as Yt, L as Kt, M as Jt } from "./insertion-DabLme_U.js";
2
- import { p as Qt } from "./patch-DO8497wO.js";
3
- import { p as x, x as h, f as M, i as w, c as B, s as X, a as N, r as K, b as T, d as I, e as Oe, D as L, g as ke, P as g, h as Le, j as O, k as q, l as ne, m as ee, M as j, n as Zt, X as en, o as tn, q as Ye } from "./index-D4ZTaYOa.js";
4
- import { PLACEHOLDER_DIRECT_BITS as Q, findPlaceholderByIdentity as nn } from "@web-ppt/core";
5
- const rn = "http://schemas.openxmlformats.org/package/2006/relationships", on = "http://schemas.openxmlformats.org/package/2006/content-types";
6
- function an(e) {
7
- var r, a, s;
8
- const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = (i, c, f) => {
9
- const v = (c.relationships ?? []).filter((m) => m.targetId !== f), p = t.get(i) ?? [];
10
- p.push(...v), t.set(i, p);
11
- for (const m of c.resources ?? []) {
12
- if (!v.some((b) => !b.targetMode && ie(i, b.target) === m.targetPart)) continue;
13
- const y = n.get(m.targetPart);
14
- if (y && (y.hash !== m.hash || y.bytes !== m.bytes))
15
- throw new Error(`多个媒体资源争用目标 part:${m.targetPart}`);
16
- n.set(m.targetPart, m);
1
+ import { r as E, a as fe, b as Me, m as He, c as Le, d as Ne, e as Be, n as ae, l as Fe, o as ue, f as Ue, g as Ge, h as _e, v as We, i as Xe, j as qe, t as Ve, k as Je, p as Ke, q as ge, s as Pe, u as Qe, w as Ie, x as Ye, y as Ze, z as et, A as ze, B as tt, C as st, D as rt, E as at, F as nt, G as ot, H as it, I as ct, J as lt, K as pt, L as ft, M as ut, N as mt, O as dt, P as ht, Q as gt, R as Pt } from "./model-invariants-BM19JVxy.js";
2
+ import { p as D, r as ve, s as _, f as yt, a as W, i as ye, c as vt, b as Ae, x as ee, D as Z, d as me, e as wt, g as ne, P as A } from "./index-C2r7c6G6.js";
3
+ import { p as St } from "./patch-BwhfBbYE.js";
4
+ import { p as kt, m as Ot, c as bt, t as Et, a as xt, e as Tt, r as Mt, b as Nt, d as Ct, f as Ce, g as Rt, h as Re, i as $t, j as jt, k as Xt, l as It, n as zt, o as At, q as Dt, s as Ht, u as Lt, v as Bt, w as Ft } from "./slide-parts-D0o_DDhi.js";
5
+ import { PLACEHOLDER_DIRECT_BITS as K, findPlaceholderByIdentity as Ut } from "@web-ppt/core";
6
+ const v = (t, a) => {
7
+ var s;
8
+ return (s = Ae(t, { localName: a, namespaceUri: null })) == null ? void 0 : s.value;
9
+ }, L = (t, a) => ee(t, { localName: a, namespaceUri: t.namespaceUri }), $e = (t) => L(D(t).root, "Relationship");
10
+ function Gt(t, a, s, i, n) {
11
+ var R, w, te;
12
+ const c = (p) => {
13
+ var k;
14
+ return s[p] ?? ((k = t.package) == null ? void 0 : k.parts[p]);
15
+ }, u = a.flatMap((p) => {
16
+ var T, C;
17
+ const k = (T = p.creation) == null ? void 0 : T.duplicateSourcePart, X = (C = p.origin) == null ? void 0 : C.part, N = k && c(E(k));
18
+ return !N || !X ? [] : $e(N).filter((S) => {
19
+ var q;
20
+ return ((q = v(S, "Type")) == null ? void 0 : q.endsWith("/comments")) && v(S, "TargetMode") !== "External";
21
+ }).map((S) => ({ slide: X, id: v(S, "Id"), source: fe(k, v(S, "Target")) }));
22
+ }), f = [...i].filter((p) => /^ppt\/comments\/(?:_rels\/)?web-ppt-(?!edit-)/.test(p));
23
+ if (!u.length && !f.length) return;
24
+ const d = "ppt/presentation.xml", g = $e(c(E(d))).find((p) => {
25
+ var k;
26
+ return (k = v(p, "Type")) == null ? void 0 : k.endsWith("/commentAuthors");
27
+ }), M = g && fe(d, v(g, "Target")), B = M && c(M);
28
+ M && B && (s[M] ?? (s[M] = B.slice()));
29
+ const U = B ? D(B) : void 0, F = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
30
+ for (const p of U ? L(U.root, "cmAuthor") : [])
31
+ F.set(v(p, "id"), Number(v(p, "lastIdx")) || 0), o.set(v(p, "id"), /* @__PURE__ */ new Set());
32
+ const P = "[Content_Types].xml", x = D(n[P] ?? c(P));
33
+ for (const p of L(x.root, "Override")) {
34
+ const k = (R = v(p, "PartName")) == null ? void 0 : R.slice(1);
35
+ if (!k || i.has(k) || !((w = v(p, "ContentType")) != null && w.endsWith(".comments+xml"))) continue;
36
+ const X = c(k);
37
+ if (!X) throw new Error(`批注来源部件缺失:${k}`);
38
+ for (const N of L(D(X).root, "cm")) {
39
+ const T = v(N, "authorId"), C = Number(v(N, "idx"));
40
+ if (o.has(T) || o.set(T, /* @__PURE__ */ new Set()), !Number.isInteger(C) || C < 0 || C > 4294967295) throw new Error("批注作者或索引无效");
41
+ o.get(T).add(C), F.set(T, Math.max(F.get(T) ?? 0, C));
17
42
  }
18
- };
19
- for (const i of Object.values(e.elements)) {
20
- const c = (r = i.meta.origin) == null ? void 0 : r.part;
21
- if (!c) continue;
22
- const f = i.meta.imageReplacement, v = [i.meta.insertion, f ? {
23
- relationships: f.relationships,
24
- resources: [e.imageResources[f.resourceHash]]
25
- } : void 0];
26
- for (const p of v)
27
- p && o(c, p, (a = i.meta.imageReplacement) == null ? void 0 : a.suppressedRelationshipId);
28
- }
29
- for (const i of Object.values(e.slides)) {
30
- const c = (s = i.origin) == null ? void 0 : s.part, f = i.backgroundImage;
31
- if (!c || !f) continue;
32
- const v = f.resourceHashes.map((p) => e.imageResources[p]);
33
- if (v.some((p) => !p))
34
- throw new Error(`幻灯片 ${i.id} 的图片背景资源不存在`);
35
- o(c, { relationships: f.relationships, resources: v });
36
43
  }
37
- return { relationships: t, resources: n };
38
- }
39
- function z(e, t) {
40
- const n = e ? x(e) : x(`<Relationships xmlns="${rn}"/>`), o = new Map(h(n.root, { localName: "Relationship" }).flatMap((r) => {
41
- var f, v, p, m;
42
- const a = (f = M(r, { localName: "Id", namespaceUri: null })) == null ? void 0 : f.value, s = (v = M(r, { localName: "Type", namespaceUri: null })) == null ? void 0 : v.value, i = (p = M(r, { localName: "Target", namespaceUri: null })) == null ? void 0 : p.value, c = (m = M(r, { localName: "TargetMode", namespaceUri: null })) == null ? void 0 : m.value;
43
- return a && s && i ? [[a, { type: s, target: i, mode: c }]] : [];
44
- }));
45
- for (const r of t) {
46
- const a = o.get(r.targetId);
47
- if (a) {
48
- if (a.type === r.type && a.target === r.target && a.mode === r.targetMode) continue;
49
- throw new Error(`目标关系 id 冲突:${r.targetId}`);
44
+ for (const p of [...L(x.root, "Override")])
45
+ f.includes(((te = v(p, "PartName")) == null ? void 0 : te.slice(1)) ?? "") && ve(x.root, p);
46
+ const j = /* @__PURE__ */ new Set();
47
+ for (const p of u) {
48
+ const k = c(p.source);
49
+ if (!k) throw new Error(`复制批注缺少来源部件:${p.source}`);
50
+ const X = D(k);
51
+ let N = 0;
52
+ const T = /* @__PURE__ */ new Map();
53
+ for (const $ of L(X.root, "cm").sort((y, O) => Number(v(y, "idx")) - Number(v(O, "idx")))) {
54
+ const y = v($, "authorId");
55
+ if (!F.has(y)) throw new Error(`复制批注缺少作者:${y}`);
56
+ let O = N + 1;
57
+ for (; o.get(y).has(O); ) O++;
58
+ if (O > 4294967295) throw new Error("批注索引超出 OOXML 可表示范围");
59
+ o.get(y).add(O), F.set(y, Math.max(F.get(y), O)), N = O, T.set(`${y}:${v($, "idx")}`, O), _($, "idx", String(O));
50
60
  }
51
- o.set(r.targetId, {
52
- type: r.type,
53
- target: r.target,
54
- mode: r.targetMode
55
- }), w(n.root, B("Relationship", {
56
- attributes: [
57
- ["Id", r.targetId],
58
- ["Type", r.type],
59
- ["Target", r.target],
60
- ...r.targetMode ? [["TargetMode", r.targetMode]] : []
61
- ]
62
- }));
63
- }
64
- return X(n);
65
- }
66
- function sn(e, t) {
67
- var a, s;
68
- const n = e ? x(e) : x(`<Types xmlns="${on}"/>`), o = h(n.root, { localName: "Default" }), r = h(n.root, { localName: "Override" });
69
- for (const i of t) {
70
- const c = o.find((u) => {
71
- var y;
72
- return ((y = M(u, { localName: "Extension", namespaceUri: null })) == null ? void 0 : y.value.toLowerCase()) === i.extension.toLowerCase();
73
- });
74
- if ((c && ((a = M(c, { localName: "ContentType", namespaceUri: null })) == null ? void 0 : a.value)) === i.mime) continue;
75
- const v = `/${i.targetPart}`, p = r.find((u) => {
76
- var y;
77
- return ((y = M(u, { localName: "PartName", namespaceUri: null })) == null ? void 0 : y.value) === v;
78
- });
79
- if (p) {
80
- if (((s = M(p, {
81
- localName: "ContentType",
82
- namespaceUri: null
83
- })) == null ? void 0 : s.value) !== i.mime)
84
- throw new Error(`媒体资源与既有 Content-Type Override 冲突:${i.targetPart}`);
85
- continue;
61
+ for (const $ of L(X.root, "cm")) {
62
+ const y = yt($, { localName: "parentCm", namespaceUri: "http://schemas.microsoft.com/office/powerpoint/2012/main" }), O = y && T.get(`${v(y, "authorId")}:${v(y, "idx")}`);
63
+ y && O !== void 0 && _(y, "idx", String(O));
86
64
  }
87
- const m = B(c ? "Override" : "Default", {
88
- attributes: c ? [["PartName", v], ["ContentType", i.mime]] : [["Extension", i.extension], ["ContentType", i.mime]]
89
- });
90
- w(n.root, m), c ? r.push(m) : o.push(m);
91
- }
92
- return X(n);
93
- }
94
- function cn(e) {
95
- return Tt(e.bytes);
96
- }
97
- const ln = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml", fn = "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml", Ke = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide", Je = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
98
- function Ee(e) {
99
- return e.slideOrder.map((t) => e.slides[t]).filter((t) => !!t.creation);
100
- }
101
- function pn() {
102
- return new TextEncoder().encode(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
103
- <p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
104
- <p:cSld><p:spTree>
105
- <p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>
106
- <p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>
107
- </p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>
108
- </p:sld>`);
109
- }
110
- function mn(e, t) {
111
- if (!e.creation || !e.origin) throw new Error(`页面 ${e.id} 不是可物化的新页`);
112
- return mt(e, t);
113
- }
114
- function Qe(e) {
115
- const t = new Set(e ? h(x(e).root, { localName: "Relationship" }).flatMap((n) => C(n, "Id") ?? []) : []);
116
- for (let n = 1; ; n++) if (!t.has(`rId${n}`)) return `rId${n}`;
117
- }
118
- function mt(e, t) {
119
- var s, i;
120
- if (!e.origin || !e.layoutId) throw new Error(`页面 ${e.id} 缺少版式写回身份`);
121
- if (!t) {
122
- const c = ((s = e.creation) == null ? void 0 : s.layoutRelationshipId) ?? Qe();
123
- return z(void 0, [{
124
- sourceId: c,
125
- targetId: c,
126
- type: Je,
127
- target: Y(e.origin.part, e.layoutId)
128
- }]);
129
- }
130
- const n = x(t), r = h(n.root, { localName: "Relationship" }).find((c) => {
131
- var f;
132
- return ((f = C(c, "Type")) == null ? void 0 : f.endsWith("/slideLayout")) && C(c, "TargetMode") !== "External" && (e.creation === void 0 || C(c, "Id") === e.creation.layoutRelationshipId);
133
- });
134
- if (!r) {
135
- const c = ((i = e.creation) == null ? void 0 : i.layoutRelationshipId) ?? Qe(t);
136
- return z(t, [{
137
- sourceId: c,
138
- targetId: c,
139
- type: Je,
140
- target: Y(e.origin.part, e.layoutId)
141
- }]);
142
- }
143
- const a = Y(e.origin.part, e.layoutId);
144
- return C(r, "Target") === a && C(r, "TargetMode") === void 0 ? t : (N(r, "Target", a), K(r, "TargetMode"), X(n));
145
- }
146
- function un(e, t) {
147
- const n = x(e), o = String(t);
148
- let r = !1;
149
- const a = (s) => {
150
- var i, c;
151
- for (const f of h(s)) {
152
- if (f.namespaceUri === L && f.localName === "fld" && ((i = C(f, "type")) == null ? void 0 : i.toLowerCase()) === "slidenum") {
153
- const v = I(f, { localName: "t", namespaceUri: L });
154
- if (v && !(v.children.length === 1 && ((c = v.children[0]) == null ? void 0 : c.type) === "text" && v.children[0].value === o)) {
155
- for (const p of [...v.children]) T(v, p);
156
- w(v, ke(o)), r = !0;
157
- }
65
+ const C = `ppt/comments/web-ppt-${p.slide.slice(p.slide.lastIndexOf("/") + 1).replace(/\.xml$/, "")}`;
66
+ let S = `${C}.xml`, q = 1;
67
+ for (; c(S) && !i.has(S); ) S = `${C}-${q++}.xml`;
68
+ n[S] = W(X), j.add(S), i.add(S);
69
+ const se = E(p.slide), oe = D(n[se]), V = L(oe.root, "Relationship").find(($) => v($, "Id") === p.id);
70
+ if (!V) throw new Error("复制批注目标关系缺失");
71
+ _(V, "Target", Me(p.slide, S)), n[se] = W(oe);
72
+ const m = c(E(p.source));
73
+ if (m) {
74
+ const $ = E(S), y = D(m);
75
+ for (const O of L(y.root, "Relationship")) {
76
+ const J = v(O, "Target");
77
+ if (!J || v(O, "TargetMode") === "External") continue;
78
+ const ie = J.includes("#") ? J.slice(J.indexOf("#")) : "";
79
+ _(O, "Target", Me(S, fe(p.source, J)) + ie);
158
80
  }
159
- a(f);
81
+ n[$] = W(y), j.add($), i.add($);
160
82
  }
161
- };
162
- return a(n.root), r ? X(n) : e;
163
- }
164
- function dn(e) {
165
- var n, o, r;
166
- const t = /* @__PURE__ */ new Map();
167
- for (const a of h(x(e).root, { localName: "Relationship" })) {
168
- const s = (n = M(a, { localName: "Id", namespaceUri: null })) == null ? void 0 : n.value, i = (o = M(a, { localName: "Target", namespaceUri: null })) == null ? void 0 : o.value, c = (r = M(a, { localName: "TargetMode", namespaceUri: null })) == null ? void 0 : r.value;
169
- s && i && c !== "External" && t.set(s, ie("ppt/presentation.xml", i));
83
+ ye(x.root, vt("Override", { attributes: [
84
+ ["PartName", `/${S}`],
85
+ ["ContentType", "application/vnd.openxmlformats-officedocument.presentationml.comments+xml"]
86
+ ] }));
170
87
  }
171
- return t;
88
+ for (const p of f) j.has(p) || (n[p] = null);
89
+ for (const p of U ? L(U.root, "cmAuthor") : []) _(p, "lastIdx", String(F.get(v(p, "id")) ?? 0));
90
+ U && M && (n[M] = W(U)), n[P] = W(x);
172
91
  }
173
- function C(e, t) {
92
+ function De(t, a, s) {
174
93
  var n;
175
- return (n = M(e, { localName: t, namespaceUri: null })) == null ? void 0 : n.value;
176
- }
177
- function ut(e, t, n, o) {
178
- const r = h(e).find((a) => a.localName !== n || a.namespaceUri !== o) ?? null;
179
- w(e, t, r);
180
- }
181
- function hn(e, t, n, o) {
182
- const r = Le(e, {
183
- localName: "sectionLst",
184
- namespaceUri: O
185
- });
186
- if (r)
187
- for (const a of h(r, {
188
- localName: "section",
189
- namespaceUri: O
190
- })) {
191
- const s = I(a, {
192
- localName: "sldIdLst",
193
- namespaceUri: O
194
- });
195
- if (!s) continue;
196
- const i = h(s, {
197
- localName: "sldId",
198
- namespaceUri: O
199
- }), c = new Set(i.flatMap((u) => {
200
- const y = C(u, "id");
201
- return y ? [Number(y)] : [];
202
- }));
203
- for (const u of i) {
204
- const y = Number(C(u, "id"));
205
- o.has(y) && T(s, u);
206
- }
207
- const f = i.filter((u) => !o.has(Number(C(u, "id"))));
208
- let v = !0;
209
- for (; v; ) {
210
- v = !1;
211
- for (const u of t) {
212
- const y = u.creation;
213
- !y || c.has(y.presentationSlideId) || y.sectionAfterSlideId === void 0 || !c.has(y.sectionAfterSlideId) || (c.add(y.presentationSlideId), v = !0);
214
- }
215
- }
216
- const p = new Map(f.map((u) => [Number(C(u, "id")), u])), m = n.flatMap((u) => {
217
- if (!c.has(u)) return [];
218
- const y = p.get(u);
219
- if (y) return [y];
220
- const b = E(s, O, "sldId");
221
- return N(b, "id", String(u)), p.set(u, b), [b];
222
- });
223
- for (const u of m)
224
- h(s).includes(u) || ut(s, u, "sldId", O);
225
- Oe(s, m);
226
- }
227
- }
228
- function gn(e, t, n) {
229
- var m;
230
- const o = x(e), r = I(o.root, { localName: "sldIdLst", namespaceUri: g });
231
- if (!r) throw new Error("presentation.xml 缺少 p:sldIdLst");
232
- const a = dn(t), s = /* @__PURE__ */ new Map(), i = lt(n), c = /* @__PURE__ */ new Set();
233
- for (const u of h(r, { localName: "sldId", namespaceUri: g })) {
234
- const y = (m = M(u, {
235
- localName: "id",
236
- namespaceUri: "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
237
- })) == null ? void 0 : m.value, b = y ? a.get(y) : void 0;
238
- if (b && i.has(b)) {
239
- const A = Number(C(u, "id"));
240
- Number.isFinite(A) && c.add(A), T(r, u);
241
- } else b && s.set(b, u);
242
- }
243
- const f = Ee(n), v = new Map(f.map((u) => [u.id, u])), p = n.slideOrder.map((u) => {
244
- const y = n.slides[u], b = y.origin ? s.get(y.origin.part) : void 0;
245
- if (b) return b;
246
- const A = v.get(u);
247
- if (!(A != null && A.creation)) throw new Error(`页面 ${u} 无法映射到 presentation.xml`);
248
- const J = E(r, g, "sldId");
249
- return N(J, "id", String(A.creation.presentationSlideId)), N(J, "r:id", A.creation.presentationRelationshipId), J;
250
- });
251
- for (const u of p)
252
- h(r).includes(u) || ut(r, u, "sldId", g);
253
- return Oe(r, p), hn(
254
- o.root,
255
- f,
256
- p.map((u) => Number(C(u, "id"))),
257
- c
258
- ), X(o);
259
- }
260
- function vn(e, t) {
261
- const n = x(e), o = lt(t);
262
- for (const r of h(n.root, { localName: "Relationship" })) {
263
- const a = C(r, "Type"), s = C(r, "Target"), i = C(r, "TargetMode");
264
- a !== Ke || !s || i === "External" || o.has(ie("ppt/presentation.xml", s)) && T(n.root, r);
265
- }
266
- return z(X(n), Ee(t).map((r) => ({
267
- sourceId: r.creation.presentationRelationshipId,
268
- targetId: r.creation.presentationRelationshipId,
269
- type: Ke,
270
- target: Y("ppt/presentation.xml", r.origin.part)
271
- })));
272
- }
273
- function yn(e, t, n = /* @__PURE__ */ new Set()) {
274
- var a, s;
275
- const o = x(e);
276
- for (const i of h(o.root, { localName: "Override" })) {
277
- const c = (a = M(i, { localName: "PartName", namespaceUri: null })) == null ? void 0 : a.value;
278
- c && n.has(c.replace(/^\//, "")) && T(o.root, i);
279
- }
280
- const r = new Set(h(o.root, { localName: "Override" }).flatMap((i) => {
281
- var f;
282
- const c = (f = M(i, { localName: "PartName", namespaceUri: null })) == null ? void 0 : f.value;
283
- return c ? [c] : [];
284
- }));
285
- for (const i of Ee(t)) {
286
- const c = `/${i.origin.part}`;
287
- r.has(c) || (w(o.root, B("Override", {
288
- attributes: [["PartName", c], ["ContentType", ln]]
289
- })), r.add(c));
290
- }
291
- for (const i of Object.values(t.slides)) {
292
- const c = (s = i.notes) == null ? void 0 : s.targetPart;
293
- !c || r.has(`/${c}`) || (w(o.root, B("Override", {
294
- attributes: [["PartName", `/${c}`], ["ContentType", fn]]
295
- })), r.add(`/${c}`));
296
- }
297
- return X(o);
298
- }
299
- function dt(e, t, n) {
300
- var r;
301
- const o = t[n] ?? ((r = e.package) == null ? void 0 : r.parts[n]);
302
- if (!o) throw new Error(`页面副本缺少来源 OPC part:${n}`);
303
- return o;
304
- }
305
- function Nn(e, t, n) {
306
- var r;
307
- const o = (r = t.creation) == null ? void 0 : r.duplicateSourcePart;
308
- return o ? dt(e, n, o) : void 0;
309
- }
310
- function Pe(e, t, n) {
311
- var r;
312
- const o = (r = t.creation) == null ? void 0 : r.duplicateSourcePart;
313
- return o ? dt(e, n, U(o)) : void 0;
314
- }
315
- function Pn(e) {
316
- var n, o;
317
- const t = (n = e.origin) == null ? void 0 : n.part;
318
- return t ? (((o = e.creation) == null ? void 0 : o.duplicateRemovedSpids) ?? []).map((r) => ({
319
- id: `${e.id}-baseline-${r}`,
320
- parent: e.id,
321
- meta: { editable: "full", origin: { part: t, spid: r } }
322
- })) : [];
323
- }
324
- const Sn = /* @__PURE__ */ new Set(["noFill", "solidFill", "gradFill", "blipFill", "pattFill", "grpFill"]);
325
- function se(e, t) {
326
- return I(e, { localName: t, namespaceUri: L });
327
- }
328
- function re(e, t, n = []) {
329
- const o = se(e, t);
330
- if (o) return o;
331
- const r = E(e, L, t), a = h(e).find((s) => s.namespaceUri === L && n.includes(s.localName));
332
- return w(e, r, a ?? null), r;
333
- }
334
- function Tn(e, t) {
335
- const n = se(e, "alphaModFix");
336
- if (t === void 0) {
337
- n && T(e, n);
338
- return;
339
- }
340
- const o = n ?? re(e, "alphaModFix", ["extLst"]);
341
- N(o, "amt", String(Math.round(t * 1e5)));
342
- }
343
- function wn(e) {
344
- return e.attributes.some((t) => !["l", "t", "r", "b"].includes(t.localName)) || h(e).length > 0;
345
- }
346
- function bn(e, t) {
347
- const n = se(e, "srcRect");
348
- if (!t) {
349
- if (!n) return;
350
- for (const r of ["l", "t", "r", "b"]) K(n, r);
351
- wn(n) || T(e, n);
352
- return;
353
- }
354
- const o = n ?? re(e, "srcRect", ["tile", "stretch"]);
355
- for (const r of ["l", "t", "r", "b"])
356
- N(o, r, String(Math.round(t[r] * 1e5)));
357
- }
358
- function kn(e, t) {
359
- const n = se(e, "tile"), o = se(e, "stretch");
360
- if (t.tile) {
361
- o && T(e, o);
362
- const a = n ?? re(e, "tile");
363
- N(a, "sx", String(Math.round(t.tile.sx * 1e5))), N(a, "sy", String(Math.round(t.tile.sy * 1e5))), N(a, "flip", t.tile.flip), N(a, "tx", String(Math.round((t.tile.tx ?? 0) * 9525))), N(a, "ty", String(Math.round((t.tile.ty ?? 0) * 9525))), N(a, "algn", t.tile.algn ?? "tl");
364
- return;
365
- }
366
- n && T(e, n);
367
- const r = o ?? re(e, "stretch");
368
- re(r, "fillRect");
369
- }
370
- function En(e, t, n, o) {
371
- let r = se(e, "blipFill");
372
- for (const s of [...h(e)])
373
- s.namespaceUri !== L || !Sn.has(s.localName) || s !== r && T(e, s);
374
- r || (r = E(e, L, "blipFill"), q(e, r)), o || K(r, "dpi");
375
- const a = re(r, "blip", ["srcRect", "tile", "stretch"]);
376
- N(a, "r:embed", n), K(a, "r:link"), Tn(a, t.alpha), bn(r, t.crop), kn(r, t);
377
- }
378
- const ue = "http://schemas.microsoft.com/office/powerpoint/2015/09/main", Ae = /* @__PURE__ */ new Set([
379
- "vortex",
380
- "switch",
381
- "flip",
382
- "ripple",
383
- "honeycomb",
384
- "glitter",
385
- "warp",
386
- "flythrough",
387
- "flash",
388
- "shred",
389
- "reveal",
390
- "wheelReverse",
391
- "ferris",
392
- "gallery",
393
- "conveyor",
394
- "pan",
395
- "doors",
396
- "window",
397
- "prism"
398
- ]), xn = /* @__PURE__ */ new Set([
399
- "fade",
400
- "cut",
401
- "push",
402
- "pull",
403
- "cover",
404
- "wipe",
405
- "split",
406
- "zoom",
407
- "dissolve",
408
- "checker",
409
- "blinds",
410
- "comb",
411
- "wheel",
412
- "circle",
413
- "diamond",
414
- "plus",
415
- "wedge",
416
- "newsflash",
417
- "randomBar",
418
- "strips",
419
- "random",
420
- "fadeThroughBlack"
421
- ]), Mn = /* @__PURE__ */ new Set([O, ue]);
422
- function Un(e) {
423
- return e <= 625 ? "fast" : e <= 875 ? "med" : "slow";
424
- }
425
- function Te(e, t) {
426
- for (const n of [...e.attributes])
427
- t(n) && K(e, n.name);
428
- }
429
- function ht(e) {
430
- return e === "p" ? g : e === "p14" ? O : ue;
431
- }
432
- function In(e, t, n) {
433
- const o = ht(n);
434
- return e && h(e).find((r) => r.namespaceUri === o && gt(r) === t);
435
- }
436
- function gt(e) {
437
- if (e.namespaceUri === g)
438
- return e.localName === "random" ? "dissolve" : e.localName === "fadeThroughBlack" ? "fade" : xn.has(e.localName) ? e.localName : void 0;
439
- if (e.namespaceUri === O && Ae.has(e.localName)) return e.localName;
440
- if (e.namespaceUri === ue && e.localName === "morph") return "morph";
441
- }
442
- function vt(e) {
443
- return gt(e) !== void 0;
444
- }
445
- function Cn(e, t, n, o) {
446
- const r = In(o, e.type, t), a = r ? ee(r) : E(n, ht(t), e.type);
447
- if (Te(a, (s) => s.namespaceUri === null && ["dir", "orient", "option"].includes(s.localName)), e.type === "split" && e.dir) {
448
- const [s, i] = e.dir.split("-");
449
- N(a, "orient", s), N(a, "dir", i);
450
- } else e.dir && N(a, "dir", e.dir);
451
- return e.type === "morph" && N(a, "option", e.morphBy ?? "byObject"), a;
94
+ const i = a[s] ?? ((n = t.package) == null ? void 0 : n.parts[s]);
95
+ if (!i) throw new Error(`页面副本缺少来源 OPC part:${s}`);
96
+ return i;
452
97
  }
453
- function Ze(e, t, n, o, r) {
454
- const a = r ? ee(r) : E(o, g, "transition"), s = h(a).filter(vt);
455
- for (const c of s.slice(1)) T(a, c);
456
- Te(a, (c) => c.namespaceUri === null && ["spd", "advTm", "dur"].includes(c.localName) || c.namespaceUri === O && c.localName === "dur"), n || Te(a, (c) => c.namespaceUri === O || c.namespaceUri === ue), N(a, "spd", Un(e.durationMs)), n && (N(a, "xmlns:p14", O), N(a, "p14:dur", String(e.durationMs))), e.advanceAfterMs !== void 0 && N(a, "advTm", String(e.advanceAfterMs));
457
- const i = Cn(e, t, a, r);
458
- if (s[0]) ne(a, s[0], [i]);
459
- else {
460
- const c = a.children.find((f) => f.type === "element") ?? null;
461
- w(a, i, c);
462
- }
463
- return a;
464
- }
465
- function Rn(e) {
466
- if (!Ae.has(e.type) && e.type !== "morph") return e;
467
- const t = ["gallery", "conveyor", "pan", "reveal"].includes(e.type) ? "push" : "fade";
468
- return {
469
- type: t,
470
- durationMs: e.durationMs,
471
- ...t === "push" && e.dir && ["l", "r", "u", "d"].includes(e.dir) ? { dir: e.dir } : {},
472
- ...e.advanceAfterMs !== void 0 ? { advanceAfterMs: e.advanceAfterMs } : {}
473
- };
474
- }
475
- function G(e) {
476
- return e && h(e).find((t) => t.namespaceUri === g && t.localName === "transition");
477
- }
478
- function On(e) {
479
- var o;
480
- const t = ((o = e.attributes.find((r) => r.namespaceUri === null && r.localName === "Requires")) == null ? void 0 : o.value.trim().split(/\s+/).filter(Boolean)) ?? [], n = Zt(e).namespaces;
481
- return t.length > 0 && t.every((r) => Mn.has(n.get(r) ?? ""));
482
- }
483
- function Re(e) {
484
- const t = h(e);
485
- return {
486
- choice: t.find((n) => n.namespaceUri === j && n.localName === "Choice" && On(n)),
487
- fallback: t.find((n) => n.namespaceUri === j && n.localName === "Fallback")
488
- };
489
- }
490
- function pe(e, t) {
491
- const n = G(e);
492
- if (n) ne(e, n, [t]);
493
- else {
494
- const o = e.children.find((r) => r.type === "element") ?? null;
495
- w(e, t, o);
496
- }
497
- }
498
- function yt(e, t) {
499
- const n = h(e), o = n.findIndex((s) => s.namespaceUri === j && s.localName === "Choice"), r = n.indexOf(t);
500
- if (o < 0 || r <= o) return;
501
- const a = [...n];
502
- a.splice(r, 1), a.splice(o, 0, t), Oe(e, a);
503
- }
504
- function Ln(e, t) {
505
- const n = (t == null ? void 0 : t.namespaceUri) === g ? t : void 0, o = (t == null ? void 0 : t.namespaceUri) === j ? ee(t) : B("mc:AlternateContent", { selfClosing: !1 });
506
- N(o, "xmlns:mc", j);
507
- const r = e.type === "morph";
508
- let { choice: a, fallback: s } = Re(o);
509
- if (!a || !G(a)) {
510
- a = B("mc:Choice", { selfClosing: !1 });
511
- const v = o.children.find((p) => p.type === "element") ?? null;
512
- w(o, a, v);
513
- }
514
- const i = G(a) ?? n;
515
- N(a, "xmlns:p14", O), r && N(a, "xmlns:p159", ue), N(a, "Requires", r ? "p159" : "p14"), yt(o, a), pe(a, Ze(
516
- e,
517
- r ? "p159" : Ae.has(e.type) ? "p14" : "p",
518
- !0,
519
- a,
520
- i
521
- )), s || (s = B("mc:Fallback", { selfClosing: !1 }), w(o, s));
522
- const c = G(s) ?? n, f = Rn(e);
523
- return pe(s, Ze(
524
- f,
525
- "p",
526
- !1,
527
- s,
528
- c
529
- )), o;
530
- }
531
- function An(e) {
532
- return e.namespaceUri !== j || e.localName !== "AlternateContent" ? !1 : h(e).some((t) => t.namespaceUri === j && (t.localName === "Choice" || t.localName === "Fallback") && G(t) !== void 0);
533
- }
534
- function Bn(e) {
535
- return h(e).filter((t) => t.namespaceUri === g && t.localName === "transition" || An(t));
536
- }
537
- function Ce(e, t) {
538
- const n = ee(e);
539
- for (const o of h(n).filter(vt))
540
- T(n, o);
541
- return Te(n, (o) => o.namespaceUri === null && ["spd", "dur", "advTm"].includes(o.localName) || o.namespaceUri === O && o.localName === "dur"), t.advanceAfterMs !== void 0 && N(n, "advTm", String(t.advanceAfterMs)), n;
542
- }
543
- function $n(e, t) {
544
- if (e.namespaceUri === g) return Ce(e, t);
545
- const n = ee(e);
546
- let o = Re(n), r = o.choice;
547
- if (!r || !G(r)) {
548
- r = B("mc:Choice", { selfClosing: !1 });
549
- const c = n.children.find((f) => f.type === "element") ?? null;
550
- w(n, r, c);
551
- }
552
- N(r, "xmlns:p14", O), N(r, "Requires", "p14");
553
- const a = G(r), s = G(o.fallback), i = a ?? s;
554
- if (i ? pe(r, Ce(i, t)) : pe(r, E(r, g, "transition")), yt(n, r), o = Re(n), o.fallback) {
555
- const c = G(o.fallback);
556
- c ? ne(o.fallback, c, [Ce(c, t)]) : pe(
557
- o.fallback,
558
- E(o.fallback, g, "transition")
559
- );
560
- } else {
561
- const c = B("mc:Fallback", { selfClosing: !1 });
562
- w(n, c), w(c, E(c, g, "transition"));
563
- }
564
- return n;
565
- }
566
- function Fn(e) {
567
- const t = (o, r = []) => o.attributes.some((a) => a.name !== "xmlns" && a.prefix !== "xmlns" && !(a.namespaceUri === null && r.includes(a.localName))), n = (o) => t(o) || o.children.some((r) => r.type === "element" || r.type === "text" && r.value.trim() || r.type !== "text");
568
- return e.namespaceUri === g ? n(e) : t(e) || h(e).some((o) => t(o, ["Requires"]) || o.children.some((r) => r.type !== "element" ? r.type !== "text" || !!r.value.trim() : r.namespaceUri === g && r.localName === "transition" ? n(r) : !0));
569
- }
570
- function _n(e, t, n = !1) {
571
- const o = Bn(e.root);
572
- if (t.type === "none") {
573
- if (o[0]) {
574
- const s = $n(o[0], t), i = n || t.advanceAfterMs !== void 0 || Fn(s) ? [s] : [];
575
- ne(e.root, o[0], i);
576
- for (const c of o.slice(1)) T(e.root, c);
577
- } else if (n || t.advanceAfterMs !== void 0) {
578
- const s = E(e.root, g, "transition");
579
- t.advanceAfterMs !== void 0 && N(s, "advTm", String(t.advanceAfterMs)), q(e.root, s);
580
- }
581
- return;
582
- }
583
- const r = Ln(t, o[0]);
584
- if (o[0]) {
585
- ne(e.root, o[0], [r]);
586
- for (const s of o.slice(1)) T(e.root, s);
587
- return;
588
- }
589
- const a = E(e.root, g, "transition");
590
- q(e.root, a), ne(e.root, a, [r]);
591
- }
592
- const Dn = Object.freeze({
593
- u: 1,
594
- r: 2,
595
- d: 4,
596
- l: 8,
597
- rd: 3,
598
- ru: 6,
599
- lu: 9,
600
- ld: 12,
601
- horz: 5,
602
- vert: 10,
603
- in: 16,
604
- out: 32
605
- });
606
- function S(e, t, n = {}) {
607
- const o = E(e, g, t);
608
- for (const [r, a] of Object.entries(n)) N(o, r, String(a));
609
- return w(e, o), o;
610
- }
611
- function oe(e, t, n = {}) {
612
- return S(e, "cTn", { id: t(), ...n });
613
- }
614
- function Be(e, t) {
615
- const n = S(e, "stCondLst");
616
- S(n, "cond", { delay: t });
617
- }
618
- function Se(e, t, n, o, r = []) {
619
- const a = S(e, "cBhvr");
620
- oe(a, o, { dur: n, fill: "hold" });
621
- const s = S(a, "tgtEl");
622
- if (S(s, "spTgt", { spid: t }), r.length) {
623
- const i = S(a, "attrNameLst");
624
- for (const c of r) {
625
- const f = S(i, "attrName");
626
- w(f, ke(c));
627
- }
628
- }
629
- }
630
- function et(e, t, n, o, r) {
631
- const a = S(e, "set"), s = S(a, "cBhvr"), i = oe(s, r, { dur: 1, fill: "hold" });
632
- Be(i, o);
633
- const c = S(s, "tgtEl");
634
- S(c, "spTgt", { spid: t });
635
- const f = S(s, "attrNameLst"), v = S(f, "attrName");
636
- w(v, ke("style.visibility"));
637
- const p = S(a, "to");
638
- S(p, "strVal", { val: n });
639
- }
640
- function Xn(e, t, n, o) {
641
- if (t.kind === "emphasis" && t.effect === "spin") {
642
- const s = S(e, "animRot", { by: 216e5 });
643
- Se(s, n, t.durationMs, o, ["r"]);
644
- return;
645
- }
646
- if (t.kind === "emphasis" && t.effect === "grow") {
647
- const s = S(e, "animScale");
648
- Se(s, n, t.durationMs, o, ["ppt_w", "ppt_h"]), S(s, "by", { x: 125e3, y: 125e3 });
649
- return;
650
- }
651
- if (t.effect === "appear") return;
652
- const r = bt(t.effect, t.dir);
653
- if (!r) throw new Error(`动画 ${t.effect} 缺少可保存 filter`);
654
- const a = S(e, "animEffect", {
655
- transition: t.kind === "exit" ? "out" : "in",
656
- filter: r
657
- });
658
- Se(a, n, t.durationMs, o);
659
- }
660
- function tt(e) {
661
- const t = Math.abs(e) < 5e-10 ? 0 : Math.round(e * 1e9) / 1e9;
662
- return String(t);
663
- }
664
- function jn(e, t, n, o, r) {
665
- const a = t.motionPath.map(([i, c], f) => `${f ? "L" : "M"} ${tt(i / o.meta.width)} ${tt(c / o.meta.height)}`).join(" "), s = S(e, "animMotion", {
666
- origin: "layout",
667
- path: `${a} E`,
668
- pathEditMode: "relative"
669
- });
670
- Se(s, n, t.durationMs, r, ["ppt_x", "ppt_y"]);
671
- }
672
- function Gn(e, t, n, o) {
673
- var f;
674
- const r = n.elements[t.target], a = ((f = r == null ? void 0 : r.meta.origin) == null ? void 0 : f.spid) ?? (r == null ? void 0 : r.src.id);
675
- if (a === void 0) throw new Error(`动画目标缺少 OOXML spid:${t.target}`);
676
- const s = S(e, "par"), i = oe(s, o, {
677
- presetID: t.kind === "motion" ? 0 : wt(t.effect).preset,
678
- presetClass: t.kind === "motion" ? "path" : t.kind === "entrance" ? "entr" : t.kind === "exit" ? "exit" : "emph",
679
- ...t.kind !== "motion" && t.dir !== void 0 ? { presetSubtype: Dn[t.dir] ?? 0 } : {},
680
- dur: t.durationMs,
681
- fill: "hold",
682
- nodeType: t.trigger === "click" ? "clickEffect" : t.trigger === "withPrev" ? "withEffect" : "afterEffect"
683
- });
684
- Be(i, t.delayMs);
685
- const c = S(i, "childTnLst");
686
- t.kind === "entrance" && et(c, a, "visible", 0, o), t.kind === "motion" ? jn(c, t, a, n, o) : Xn(c, t, a, o), t.kind === "exit" && et(c, a, "hidden", t.durationMs, o);
687
- }
688
- function zn(e, t, n) {
689
- let o = 0;
690
- const r = () => ++o, a = S(e, "par"), s = oe(a, r, {
691
- dur: "indefinite",
692
- restart: "never",
693
- nodeType: "tmRoot"
694
- }), i = S(s, "childTnLst"), c = S(i, "seq", { concurrent: 1, nextAc: "seek" }), f = oe(c, r, { dur: "indefinite", nodeType: "mainSeq" }), v = S(f, "childTnLst");
695
- let p = null;
696
- for (const m of t) {
697
- if (!p || m.trigger === "click") {
698
- const u = S(v, "par"), y = oe(u, r, { fill: "hold", nodeType: "clickEffect" });
699
- Be(y, "indefinite"), p = S(y, "childTnLst");
700
- }
701
- Gn(p, m, n, r);
702
- }
703
- }
704
- function xe(e) {
705
- return e.attributes.some((t) => t.namespaceUri !== en);
706
- }
707
- function we(e) {
708
- return h(e).filter((t) => t.namespaceUri === g && t.localName === "timing");
709
- }
710
- function Hn(e) {
711
- if (e.namespaceUri !== j || e.localName !== "AlternateContent") return [];
712
- const n = h(e).filter((o) => o.namespaceUri === j && (o.localName === "Choice" || o.localName === "Fallback")).map((o) => ({ parent: o, timings: we(o) }));
713
- if (n.some(({ timings: o }) => o.length > 1))
714
- throw new Error("mc:AlternateContent 分支包含多个 p:timing");
715
- return n.some(({ timings: o }) => o.length) ? n.map(({ parent: o, timings: r }) => ({ parent: o, timing: r[0] })) : [];
716
- }
717
- function qn(e) {
718
- const t = we(e), n = h(e).map(Hn).filter((o) => o.length);
719
- if (t.length > 1 || n.length > 1 || t.length && n.length)
720
- throw new Error("幻灯片包含多个 p:timing 载体");
721
- return t.length ? [{ parent: e, timing: t[0] }] : n[0] ?? [];
722
- }
723
- const Vn = /* @__PURE__ */ new Set([
724
- "set",
725
- "anim",
726
- "animClr",
727
- "animEffect",
728
- "animMotion",
729
- "animRot",
730
- "animScale",
731
- "audio",
732
- "video",
733
- "cmd"
734
- ]);
735
- function $(e) {
736
- const t = tn(e).parent;
737
- return (t == null ? void 0 : t.type) === "element" ? t : null;
738
- }
739
- function ae(e, t) {
98
+ function _t(t, a, s) {
740
99
  var n;
741
- return (n = e.attributes.find((o) => o.namespaceUri === null && o.localName === t)) == null ? void 0 : n.value;
742
- }
743
- function H(e) {
744
- const t = [], n = [e];
745
- for (; n.length; ) {
746
- const o = n.pop();
747
- if (t.push(o), t.length > 1e5) throw new Error("动画时间树节点超过保存安全上限");
748
- const r = h(o);
749
- for (let a = r.length - 1; a >= 0; a--) n.push(r[a]);
750
- }
751
- return t;
752
- }
753
- function Wn(e, t) {
754
- return H(e).some((n) => {
755
- const o = ae(n, "spid");
756
- return o !== void 0 && t.has(Number(o));
757
- });
758
- }
759
- function Yn(e) {
760
- let t = $(e), n = (t == null ? void 0 : t.localName) === "tgtEl" ? t : e;
761
- for (; t; ) {
762
- if (t.namespaceUri === g && (t.localName === "cBhvr" || t.localName === "cond") || Vn.has(t.localName)) return t;
763
- t = $(t);
764
- }
765
- return n;
766
- }
767
- function me(e) {
768
- if (!(e.namespaceUri !== g || e.localName !== "par"))
769
- return h(e).find((t) => t.namespaceUri === g && t.localName === "cTn" && !!ae(t, "presetClass"));
100
+ const i = (n = a.creation) == null ? void 0 : n.duplicateSourcePart;
101
+ return i ? De(t, s, i) : void 0;
770
102
  }
771
- function Kn(e, t) {
772
- const n = H(e).filter((r) => !!me(r));
773
- let o = null;
774
- for (let r = n.length - 1; r >= 0; r--) {
775
- const a = n[r], s = me(a);
776
- if (!t.has(a)) {
777
- o = a;
778
- continue;
779
- }
780
- ae(s, "nodeType") === "clickEffect" && o && N(me(o), "nodeType", "clickEffect");
781
- }
782
- }
783
- function Jn(e) {
784
- for (let t = 0; t < 64; t++) {
785
- let n = !1;
786
- const o = H(e).reverse();
787
- for (const r of o) {
788
- if (r.namespaceUri !== g || r.localName !== "par" && r.localName !== "seq") continue;
789
- const a = h(r).find((c) => c.namespaceUri === g && c.localName === "cTn"), s = a && h(a).find((c) => c.namespaceUri === g && c.localName === "childTnLst"), i = $(r);
790
- s && h(s).length === 0 && i && (T(i, r), n = !0);
791
- }
792
- if (!n) break;
793
- }
794
- for (const t of H(e).reverse()) {
795
- if (t.namespaceUri !== g || t.localName !== "tnLst" && t.localName !== "bldLst" || h(t).length !== 0 || xe(t)) continue;
796
- const n = $(t);
797
- n && T(n, t);
798
- }
799
- }
800
- function nt(e) {
801
- return H(e).filter((t) => t.namespaceUri === g && t.localName === "spTgt");
802
- }
803
- function Qn(e) {
804
- const t = $(e);
805
- if (t && (T(t, e), t.localName === "tgtEl" && h(t).length === 0 && !xe(t))) {
806
- const n = $(t);
807
- n && T(n, t);
808
- }
809
- }
810
- const Zn = /* @__PURE__ */ new Set([
811
- "timing",
812
- "tnLst",
813
- "childTnLst",
814
- "subTnLst",
815
- "par",
816
- "seq",
817
- "cTn"
818
- ]);
819
- function er(e) {
820
- const t = /* @__PURE__ */ new Set();
821
- for (const o of e) {
822
- if (o.namespaceUri !== g || o.localName !== "cBhvr") continue;
823
- const r = $(o);
824
- r && !Zn.has(r.localName) && t.add(r);
825
- }
826
- const n = /* @__PURE__ */ new Set();
827
- for (const o of t) {
828
- const r = h(o).filter((a) => a.namespaceUri === g && a.localName === "cBhvr");
829
- r.length && r.every((a) => e.has(a)) && n.add(o);
830
- }
831
- return n;
832
- }
833
- function tr(e) {
834
- const t = /* @__PURE__ */ new Set();
835
- for (const o of e) {
836
- if (o.namespaceUri !== g || o.localName !== "cond") continue;
837
- const r = $(o);
838
- r && (r.localName === "stCondLst" || r.localName === "endCondLst") && t.add(r);
839
- }
840
- const n = /* @__PURE__ */ new Set();
841
- for (const o of t) {
842
- const r = h(o).filter((i) => i.namespaceUri === g && i.localName === "cond");
843
- if (!r.length || !r.every((i) => e.has(i))) continue;
844
- const a = $(o), s = a && $(a);
845
- s && s.namespaceUri === g && (s.localName === "par" || s.localName === "seq") && n.add(s);
846
- }
847
- return n;
848
- }
849
- function nr(e, t) {
850
- for (let n = $(e); n; n = $(n))
851
- if (t.has(n)) return !0;
852
- return !1;
853
- }
854
- function rr(e) {
855
- return H(e).filter((t) => {
856
- const n = me(t), o = n && h(n).find((r) => r.namespaceUri === g && r.localName === "childTnLst");
857
- return !!o && h(o).length === 0;
858
- });
859
- }
860
- function rt(e) {
861
- for (const t of e) {
862
- const n = $(t);
863
- n && T(n, t);
864
- }
865
- }
866
- function or(e) {
867
- const t = we(e).map((n) => ({ parent: e, timing: n }));
868
- for (const n of h(e))
869
- if (!(n.namespaceUri !== j || n.localName !== "AlternateContent")) {
870
- for (const o of h(n))
871
- if (!(o.namespaceUri !== j || o.localName !== "Choice" && o.localName !== "Fallback"))
872
- for (const r of we(o)) t.push({ parent: o, timing: r });
873
- }
874
- return t;
875
- }
876
- function ar(e, t) {
877
- if (!t.length) return;
878
- const n = new Set(t);
879
- for (const o of or(e.root)) {
880
- const r = o.timing, a = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
881
- for (const m of H(r))
882
- if (m.namespaceUri === g && m.localName === "spTgt" && n.has(Number(ae(m, "spid")))) {
883
- const u = Yn(m);
884
- u && i.set(u, [...i.get(u) ?? [], m]);
885
- }
886
- for (const [m, u] of i)
887
- nt(m).some((b) => !n.has(Number(ae(b, "spid")))) ? u.forEach((b) => s.add(b)) : a.add(m);
888
- s.forEach(Qn);
889
- const c = er(a), f = tr(a);
890
- c.forEach((m) => a.add(m));
891
- const v = new Set([...a].filter((m) => !f.has(m)));
892
- rt(v);
893
- const p = new Set(rr(r));
894
- for (const m of H(r).filter((u) => !!me(u)))
895
- (f.has(m) || nr(m, f)) && p.add(m);
896
- Kn(r, p), rt(f);
897
- for (const m of H(r).filter((u) => u.namespaceUri === g && u.localName === "bldLst"))
898
- for (const u of [...h(m)])
899
- Wn(u, n) && T(m, u);
900
- if (Jn(r), nt(r).some((m) => n.has(Number(ae(m, "spid")))))
901
- throw new Error("删除动画目标后仍存在悬空 spTgt");
902
- !xe(r) && h(r).length === 0 && T(o.parent, r);
903
- }
904
- }
905
- function sr(e, t, n, o) {
906
- for (const r of [...h(t)])
907
- r.namespaceUri === g && r.localName === "tnLst" && T(t, r);
908
- if (n.length) {
909
- const r = E(t, g, "tnLst"), a = h(t).find((s) => s.namespaceUri === g && (s.localName === "bldLst" || s.localName === "extLst")) ?? null;
910
- w(t, r, a), zn(r, n, o);
911
- } else !xe(t) && h(t).length === 0 && T(e, t);
912
- }
913
- function ir(e, t, n, o) {
914
- let r = qn(e.root);
915
- if (!r.length && o.length) {
916
- const a = E(e.root, g, "timing");
917
- q(e.root, a), r = [{ parent: e.root, timing: a }];
918
- }
919
- for (const a of r) {
920
- let s = a.timing;
921
- !s && o.length && (s = E(a.parent, g, "timing"), q(a.parent, s)), s && sr(a.parent, s, o, t);
922
- }
923
- }
924
- const cr = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
925
- function lr(e, t) {
926
- var r;
927
- const n = new Map(((r = t.backgroundImage) == null ? void 0 : r.relationships.map((a) => [a.sourceId, a.targetId])) ?? []), o = (a) => {
928
- for (const s of a.attributes) {
929
- const i = s.namespaceUri === cr ? n.get(s.value) : null;
930
- i && N(a, s.name, i, s.quote);
931
- }
932
- for (const s of h(a)) o(s);
933
- };
934
- o(e);
935
- }
936
- function Nt(e) {
937
- return D(e.ovr, "background") || D(e.ovr, "hidden") || D(e.ovr, "transition") || D(e.ovr, "animations");
938
- }
939
- function fr(e, t) {
940
- const n = I(e.root, {
941
- localName: "cSld",
942
- namespaceUri: g
943
- });
944
- if (!n) throw new Error(`幻灯片 ${t.id} 缺少 p:cSld`);
945
- return n;
103
+ function pe(t, a, s) {
104
+ var n;
105
+ const i = (n = a.creation) == null ? void 0 : n.duplicateSourcePart;
106
+ return i ? De(t, s, E(i)) : void 0;
946
107
  }
947
- function pr(e, t, n) {
108
+ function Wt(t) {
948
109
  var s, i;
949
- const o = (s = e.package) == null ? void 0 : s.parts[U(t)];
950
- if (!o) return null;
951
- const r = h(x(o).root, { localName: "Relationship" }).find((c) => {
952
- var f;
953
- return (f = M(c, { localName: "Type", namespaceUri: null })) == null ? void 0 : f.value.endsWith(n);
954
- }), a = r && ((i = M(r, { localName: "Target", namespaceUri: null })) == null ? void 0 : i.value);
955
- return a ? ie(t, a) : null;
956
- }
957
- function mr(e, t) {
958
- var i;
959
- const n = (i = e.package) == null ? void 0 : i.parts[t];
960
- if (!n) return { found: !1, image: null };
961
- const o = I(x(n).root, {
962
- localName: "cSld",
963
- namespaceUri: g
964
- }), r = o && I(o, {
965
- localName: "bg",
966
- namespaceUri: g
967
- });
968
- if (!r) return { found: !1, image: null };
969
- const a = I(r, {
970
- localName: "bgPr",
971
- namespaceUri: g
972
- });
973
- return { found: !0, image: a && I(a, {
974
- localName: "blipFill",
975
- namespaceUri: L
976
- }) ? r : null };
977
- }
978
- function ur(e, t) {
979
- var o;
980
- if (((o = t.src.background) == null ? void 0 : o.type) !== "image" || !t.layoutId) return null;
981
- const n = pr(e, t.layoutId, "/slideMaster");
982
- for (const r of [t.layoutId, n]) {
983
- if (!r) continue;
984
- const a = mr(e, r);
985
- if (a.found) return a.image;
986
- }
987
- return null;
988
- }
989
- function dr(e, t, n) {
990
- if (!D(n.ovr, "background")) return;
991
- const o = n.ovr.background;
992
- (o == null ? void 0 : o.type) === "image" ? kt(o, `幻灯片 ${n.id} 的背景覆盖`) : Et(o, `幻灯片 ${n.id} 的背景覆盖`);
993
- const r = fr(e, n);
994
- let a = I(r, {
995
- localName: "bg",
996
- namespaceUri: g
997
- });
998
- if (!a) {
999
- const i = o.type === "image" ? ur(t, n) : null;
1000
- a = i ? ee(i) : E(r, g, "bg"), i && lr(a, n), q(r, a);
1001
- }
1002
- let s = I(a, {
1003
- localName: "bgPr",
1004
- namespaceUri: g
1005
- });
1006
- for (const i of [...h(a)])
1007
- i.namespaceUri === g && i.localName === "bgRef" && T(a, i);
1008
- if (s || (s = E(a, g, "bgPr"), q(a, s)), o.type === "image") {
1009
- const i = n.backgroundImage;
1010
- if (!i) throw new Error(`幻灯片 ${n.id} 的图片背景缺少关系`);
1011
- En(
1012
- s,
1013
- o,
1014
- i.imageRelationshipId,
1015
- i.sourcePart !== void 0
1016
- );
1017
- } else
1018
- xt(s), Mt(s, o);
1019
- }
1020
- function hr(e, t, n) {
1021
- var o;
1022
- if (Nt(n)) {
1023
- if (D(n.ovr, "hidden") && (n.ovr.hidden ? N(e.root, "show", "0") : K(e.root, "show")), D(n.ovr, "transition")) {
1024
- const r = n.layoutId ? (o = t.layouts[n.layoutId]) == null ? void 0 : o.transition : void 0;
1025
- _n(
1026
- e,
1027
- n.ovr.transition,
1028
- r !== void 0
1029
- );
1030
- }
1031
- D(n.ovr, "animations") && ir(e, t, n, n.ovr.animations), dr(e, t, n);
1032
- }
1033
- }
1034
- function gr(e, t) {
1035
- const { host: n } = Rt(e, t), o = I(n, { localName: "spPr", namespaceUri: g });
1036
- if (!o) throw new Error(`元素 ${t.id} 缺少 p:spPr`);
1037
- return o;
110
+ const a = (s = t.origin) == null ? void 0 : s.part;
111
+ return a ? (((i = t.creation) == null ? void 0 : i.duplicateRemovedSpids) ?? []).map((n) => ({
112
+ id: `${t.id}-baseline-${n}`,
113
+ parent: t.id,
114
+ meta: { editable: "full", origin: { part: a, spid: n } }
115
+ })) : [];
1038
116
  }
1039
- function vr(e, t, n, o) {
1040
- if (!n && !o) return;
1041
- const r = gr(e, t);
1042
- for (const i of [...h(r)])
1043
- i.namespaceUri === L && ["prstGeom", "custGeom"].includes(i.localName) && T(r, i);
1044
- if (o) {
1045
- q(r, ee(o));
117
+ function qt(t, a) {
118
+ const { host: s } = Fe(t, a), i = ne(s, { localName: "spPr", namespaceUri: A });
119
+ if (!i) throw new Error(`元素 ${a.id} 缺少 p:spPr`);
120
+ return i;
121
+ }
122
+ function Vt(t, a, s, i) {
123
+ if (!s && !i) return;
124
+ const n = qt(t, a);
125
+ for (const f of [...ee(n)])
126
+ f.namespaceUri === Z && ["prstGeom", "custGeom"].includes(f.localName) && ve(n, f);
127
+ if (i) {
128
+ me(n, wt(i));
1046
129
  return;
1047
130
  }
1048
- if (!n) return;
1049
- const a = E(r, L, "prstGeom");
1050
- N(a, "prst", n.preset), q(r, a);
1051
- const s = E(a, L, "avLst");
1052
- w(a, s);
1053
- for (const i of Object.keys(n.adj)) {
1054
- const c = n.adj[i], f = E(s, L, "gd");
1055
- N(f, "name", i), N(f, "fmla", `val ${Math.round(c)}`), w(s, f);
131
+ if (!s) return;
132
+ const c = ae(n, Z, "prstGeom");
133
+ _(c, "prst", s.preset), me(n, c);
134
+ const u = ae(c, Z, "avLst");
135
+ ye(c, u);
136
+ for (const f of Object.keys(s.adj)) {
137
+ const d = s.adj[f], g = ae(u, Z, "gd");
138
+ _(g, "name", f), _(g, "fmla", `val ${Math.round(d)}`), ye(u, g);
1056
139
  }
1057
140
  }
1058
- function yr(e, t, n, o, r) {
1059
- var i;
1060
- const a = t.meta.placeholderDirect ?? 0, s = !!(a & Q.style);
1061
- a & Q.transform || Ut(e, t, n), (t.src.kind === "shape" || t.src.kind === "image") && !(a & Q.geometry) && vr(e, t, o, r), t.src.kind === "shape" && n.kind === "shape" ? (!s && !(a & Q.fill) && It(
1062
- e,
141
+ function Jt(t, a, s, i, n) {
142
+ var f;
143
+ const c = a.meta.placeholderDirect ?? 0, u = !!(c & K.style);
144
+ c & K.transform || He(t, a, s), (a.src.kind === "shape" || a.src.kind === "image") && !(c & K.geometry) && Vt(t, a, i, n), a.src.kind === "shape" && s.kind === "shape" ? (!u && !(c & K.fill) && Le(
1063
145
  t,
1064
- ((i = n.fill) == null ? void 0 : i.type) === "image" ? { type: "none" } : n.fill
1065
- ), !s && !(a & Q.stroke) && n.stroke && We(e, t, n.stroke)) : t.src.kind === "image" && n.kind === "image" && !s && !(a & Q.stroke) && n.stroke && We(e, t, n.stroke), (t.src.kind === "shape" || t.src.kind === "image" || t.src.kind === "group") && !s && !(a & Q.effects) && n.effects && Ct(e, t, n.effects);
146
+ a,
147
+ ((f = s.fill) == null ? void 0 : f.type) === "image" ? { type: "none" } : s.fill
148
+ ), !u && !(c & K.stroke) && s.stroke && Ne(t, a, s.stroke)) : a.src.kind === "image" && s.kind === "image" && !u && !(c & K.stroke) && s.stroke && Ne(t, a, s.stroke), (a.src.kind === "shape" || a.src.kind === "image" || a.src.kind === "group") && !u && !(c & K.effects) && s.effects && Be(t, a, s.effects);
1066
149
  }
1067
- function Z(e, t, n) {
1068
- return e && I(e, {
1069
- localName: t,
1070
- ...n ? { namespaceUri: n } : {}
150
+ function Q(t, a, s) {
151
+ return t && ne(t, {
152
+ localName: a,
153
+ ...s ? { namespaceUri: s } : {}
1071
154
  });
1072
155
  }
1073
- function be(e, t) {
1074
- var n;
1075
- return e ? ((n = M(e, { localName: t })) == null ? void 0 : n.value) ?? null : null;
156
+ function de(t, a) {
157
+ var s;
158
+ return t ? ((s = Ae(t, { localName: a })) == null ? void 0 : s.value) ?? null : null;
1076
159
  }
1077
- function Nr(e) {
1078
- const t = h(e).find((r) => [
160
+ function Kt(t) {
161
+ const a = ee(t).find((n) => [
1079
162
  "nvSpPr",
1080
163
  "nvPicPr",
1081
164
  "nvCxnSpPr",
1082
165
  "nvGraphicFramePr"
1083
- ].includes(r.localName)) ?? null, n = Z(Z(t, "nvPr", g), "ph", g);
1084
- if (!n) return null;
1085
- const o = be(n, "idx");
1086
- return { type: be(n, "type") ?? "obj", ...o === null ? {} : { idx: o } };
1087
- }
1088
- function ot(e, t) {
1089
- if (!e) return;
1090
- const n = Z(
1091
- Z(e.root, "cSld", g),
166
+ ].includes(n.localName)) ?? null, s = Q(Q(a, "nvPr", A), "ph", A);
167
+ if (!s) return null;
168
+ const i = de(s, "idx");
169
+ return { type: de(s, "type") ?? "obj", ...i === null ? {} : { idx: i } };
170
+ }
171
+ function je(t, a) {
172
+ if (!t) return;
173
+ const s = Q(
174
+ Q(t.root, "cSld", A),
1092
175
  "spTree",
1093
- g
176
+ A
1094
177
  );
1095
- if (!n) return;
1096
- const o = nn(
1097
- h(n).filter((a) => [
178
+ if (!s) return;
179
+ const i = Ut(
180
+ ee(s).filter((c) => [
1098
181
  "sp",
1099
182
  "pic",
1100
183
  "cxnSp",
1101
184
  "graphicFrame"
1102
- ].includes(a.localName)),
1103
- Nr,
1104
- t
1105
- ), r = o ? Z(o, "spPr", g) : null;
1106
- return Z(r, "custGeom", L) ?? Z(r, "prstGeom", L) ?? void 0;
1107
- }
1108
- function Pr(e) {
1109
- const t = /* @__PURE__ */ new Map(), n = (r) => {
1110
- var a;
1111
- if (!t.has(r)) {
1112
- const s = (a = e.package) == null ? void 0 : a.parts[r];
1113
- t.set(r, s ? x(s) : null);
185
+ ].includes(c.localName)),
186
+ Kt,
187
+ a
188
+ ), n = i ? Q(i, "spPr", A) : null;
189
+ return Q(n, "custGeom", Z) ?? Q(n, "prstGeom", Z) ?? void 0;
190
+ }
191
+ function Qt(t) {
192
+ const a = /* @__PURE__ */ new Map(), s = (n) => {
193
+ var c;
194
+ if (!a.has(n)) {
195
+ const u = (c = t.package) == null ? void 0 : c.parts[n];
196
+ a.set(n, u ? D(u) : null);
1114
197
  }
1115
- return t.get(r) ?? null;
1116
- }, o = (r) => {
1117
- const a = n(U(r)), s = a && h(a.root).find((c) => {
1118
- var f;
1119
- return c.localName === "Relationship" && ((f = be(c, "Type")) == null ? void 0 : f.endsWith("/slideMaster"));
1120
- }), i = s ? be(s, "Target") : null;
1121
- return i ? ie(r, i) : null;
198
+ return a.get(n) ?? null;
199
+ }, i = (n) => {
200
+ const c = s(E(n)), u = c && ee(c.root).find((d) => {
201
+ var g;
202
+ return d.localName === "Relationship" && ((g = de(d, "Type")) == null ? void 0 : g.endsWith("/slideMaster"));
203
+ }), f = u ? de(u, "Target") : null;
204
+ return f ? fe(n, f) : null;
1122
205
  };
1123
- return (r, a) => {
1124
- const s = r.sourceLayoutId, i = a.meta.ph;
1125
- if (!(!s || !i))
1126
- return ot(n(s), i) ?? (o(s) ? ot(n(o(s)), i) : void 0);
206
+ return (n, c) => {
207
+ const u = n.sourceLayoutId, f = c.meta.ph;
208
+ if (!(!u || !f))
209
+ return je(s(u), f) ?? (i(u) ? je(s(i(u)), f) : void 0);
1127
210
  };
1128
211
  }
1129
- const at = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide", fe = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide";
1130
- function Sr(e) {
1131
- var n;
1132
- const t = Le(e, {
1133
- localName: "spTree",
1134
- namespaceUri: g
1135
- });
1136
- for (const o of t ? h(t, {
1137
- localName: "sp",
1138
- namespaceUri: g
1139
- }) : []) {
1140
- const r = I(o, {
1141
- localName: "nvSpPr",
1142
- namespaceUri: g
1143
- }), a = r && I(r, {
1144
- localName: "nvPr",
1145
- namespaceUri: g
1146
- }), s = a && I(a, {
1147
- localName: "ph",
1148
- namespaceUri: g
1149
- }), i = (n = s == null ? void 0 : s.attributes.find((f) => f.namespaceUri === null && f.localName === "type")) == null ? void 0 : n.value, c = I(o, {
1150
- localName: "txBody",
1151
- namespaceUri: g
1152
- });
1153
- if (i === "body" && c) return c;
1154
- }
1155
- throw new Error("notesSlide 缺少可编辑的 body 占位符");
1156
- }
1157
- function st(e, t) {
1158
- for (const n of [...e.children]) T(e, n);
1159
- w(e, ke(t));
1160
- }
1161
- function Tr(e, t) {
1162
- const n = e ? Ye(e) : B("a:p", { selfClosing: !1 });
1163
- let o = Le(n, { localName: "t" });
1164
- if (!o) {
1165
- const s = n.prefix ? `${n.prefix}:` : "", i = B(`${s}r`, { selfClosing: !1 }), c = h(n).find((f) => f.localName === "endParaRPr");
1166
- if (c) {
1167
- const f = B(`${s}rPr`);
1168
- for (const v of c.attributes)
1169
- N(f, v.name, v.value, v.quote);
1170
- for (const v of c.children)
1171
- w(f, Ye(v));
1172
- w(i, f);
1173
- }
1174
- o = B(`${s}t`, { selfClosing: !1 }), w(i, o), w(n, i, c ?? null);
1175
- }
1176
- st(o, t);
1177
- let r = !1;
1178
- const a = (s) => {
1179
- for (const i of h(s))
1180
- i.localName === "t" ? r ? st(i, "") : r = !0 : a(i);
1181
- };
1182
- return a(n), n;
212
+ function Yt(t) {
213
+ return ue(t.ovr, "background") || ue(t.ovr, "transition");
1183
214
  }
1184
- function it(e, t) {
1185
- const n = x(e), o = Sr(n.root), r = h(o, {
1186
- localName: "p",
1187
- namespaceUri: L
215
+ function Zt(t, a) {
216
+ if (ue(a.ovr, "transition") && kt(t, a.ovr.transition, !0), !ue(a.ovr, "background")) return;
217
+ const s = a.ovr.background;
218
+ Ue(s, `版式 ${a.id} 的背景覆盖`);
219
+ const i = ne(t.root, {
220
+ localName: "cSld",
221
+ namespaceUri: A
222
+ });
223
+ if (!i) throw new Error(`版式 ${a.id} 缺少 p:cSld`);
224
+ let n = ne(i, {
225
+ localName: "bg",
226
+ namespaceUri: A
1188
227
  });
1189
- for (const a of r) T(o, a);
1190
- for (const [a, s] of t.split(`
1191
- `).entries()) {
1192
- const i = r[a] ?? r[r.length - 1] ?? null;
1193
- w(o, Tr(i, s));
228
+ n || (n = ae(i, A, "bg"), me(i, n));
229
+ for (const u of [...ee(n)])
230
+ u.namespaceUri === A && u.localName === "bgRef" && ve(n, u);
231
+ let c = ne(n, {
232
+ localName: "bgPr",
233
+ namespaceUri: A
234
+ });
235
+ c || (c = ae(n, A, "bgPr"), me(n, c)), Ge(c), _e(c, s);
236
+ }
237
+ function es(t) {
238
+ const a = /* @__PURE__ */ new Map();
239
+ return t.slideOrder.forEach((s, i) => {
240
+ var u;
241
+ const n = t.slides[s], c = (u = n.origin) == null ? void 0 : u.part;
242
+ c && n.dynamicSlideNumbers.some((f) => {
243
+ var g;
244
+ const d = t.elements[f];
245
+ return ((g = d == null ? void 0 : d.meta.origin) == null ? void 0 : g.part) === c && gt(Ie(t, f));
246
+ }) && a.set(c, i + 1);
247
+ }), a;
248
+ }
249
+ function ts(t) {
250
+ const a = /* @__PURE__ */ new Map();
251
+ for (const s of Object.values(t.elements)) {
252
+ if (!st(s) && !rt(s) && !at(s) && !nt(s) && !ot(s) && !it(s) && !ct(s) && !lt(s) && !pt(s) && !ft(s) && !ut(s) && !mt(s) && !Xe(s) && !dt(s) && s.meta.sourceParent === void 0 && !s.meta.insertion) continue;
253
+ const i = s.meta.origin;
254
+ if (!i) throw new Error(`元素 ${s.id} 缺少 OOXML 回写锚点`);
255
+ const n = a.get(i.part) ?? [];
256
+ n.push(s), a.set(i.part, n);
1194
257
  }
1195
- return X(n);
1196
- }
1197
- function wr() {
1198
- return new TextEncoder().encode(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1199
- <p:notes xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
1200
- <p:cSld><p:spTree>
1201
- <p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>
1202
- <p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>
1203
- <p:sp><p:nvSpPr><p:cNvPr id="2" name="备注正文"/><p:cNvSpPr/><p:nvPr><p:ph type="body" idx="1"/></p:nvPr></p:nvSpPr><p:spPr/><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:r><a:t></a:t></a:r></a:p></p:txBody></p:sp>
1204
- </p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>
1205
- </p:notes>`);
1206
- }
1207
- const _ = (e, t) => {
1208
- var n;
1209
- return (n = e.attributes.find((o) => o.localName === t && o.namespaceUri === null)) == null ? void 0 : n.value;
1210
- };
1211
- function br(e, t, n) {
1212
- const o = x(e);
1213
- let r = !1;
1214
- for (const a of h(o.root, { localName: "Relationship" }))
1215
- _(a, "Type") !== t || _(a, "TargetMode") === "External" || (N(a, "Target", n), K(a, "TargetMode"), r = !0);
1216
- return { bytes: r ? X(o) : e, found: r };
258
+ return a;
1217
259
  }
1218
- function kr(e) {
1219
- const t = new Set(e ? h(
1220
- x(e).root,
1221
- { localName: "Relationship" }
1222
- ).flatMap((n) => _(n, "Id") ?? []) : []);
1223
- for (let n = 1; Number.isSafeInteger(n); n++) {
1224
- const o = `rId${n}`;
1225
- if (!t.has(o)) return o;
260
+ function ss(t) {
261
+ const a = /* @__PURE__ */ new Map();
262
+ for (const s of Object.values(t.removedElements)) {
263
+ const i = s.meta.origin;
264
+ if (!i) continue;
265
+ const n = a.get(i.part) ?? [];
266
+ n.push(s), a.set(i.part, n);
1226
267
  }
1227
- throw new Error("备注页的页面回指关系身份已耗尽");
268
+ return a;
1228
269
  }
1229
- function Er(e, t, n) {
1230
- const o = Y(t, n);
1231
- if (e) {
1232
- const a = br(e, at, o);
1233
- if (a.found) return a.bytes;
270
+ function rs(t) {
271
+ var s;
272
+ const a = /* @__PURE__ */ new Map();
273
+ for (const i of Object.values(t.slides)) {
274
+ if (!Ft(i)) continue;
275
+ const n = (s = i.origin) == null ? void 0 : s.part;
276
+ if (!n) throw new Error(`幻灯片 ${i.id} 缺少 OOXML 回写锚点`);
277
+ a.set(n, i);
1234
278
  }
1235
- const r = kr(e);
1236
- return z(e, [{
1237
- sourceId: r,
1238
- targetId: r,
1239
- type: at,
1240
- target: o
1241
- }]);
279
+ return a;
1242
280
  }
1243
- function ct(e, t) {
1244
- if (!e.origin) throw new Error(`页面 ${e.id} 缺少 notes 关系宿主`);
1245
- if (!t)
1246
- return e.notes ? z(void 0, [{
1247
- sourceId: e.notes.relationshipId,
1248
- targetId: e.notes.relationshipId,
1249
- type: fe,
1250
- target: Y(e.origin.part, e.notes.targetPart)
1251
- }]) : z(void 0, []);
1252
- const n = x(t), o = h(n.root, { localName: "Relationship" });
1253
- if (!e.notes) {
1254
- let s = !1;
1255
- for (const i of o)
1256
- _(i, "Type") === fe && _(i, "TargetMode") !== "External" && (T(n.root, i), s = !0);
1257
- return s ? X(n) : t;
1258
- }
1259
- const r = o.find((s) => _(s, "Id") === e.notes.relationshipId);
1260
- if (!r) return z(t, [{
1261
- sourceId: e.notes.relationshipId,
1262
- targetId: e.notes.relationshipId,
1263
- type: fe,
1264
- target: Y(e.origin.part, e.notes.targetPart)
1265
- }]);
1266
- if (_(r, "Type") !== fe)
1267
- throw new Error(`页面 ${e.id} 的 notes 关系 id 与其它关系冲突`);
1268
- const a = Y(e.origin.part, e.notes.targetPart);
1269
- return _(r, "Target") === a && _(r, "TargetMode") === void 0 ? t : (N(r, "Target", a), K(r, "TargetMode"), X(n));
281
+ function as(t) {
282
+ return new Map(t.layoutOrder.flatMap((a) => {
283
+ const s = t.layouts[a];
284
+ return Yt(s) ? [[s.origin.part, s]] : [];
285
+ }));
1270
286
  }
1271
- function xr(e, t, n) {
1272
- var a;
1273
- const o = t.origin && U(t.origin.part), r = o && ((a = e.package) == null ? void 0 : a.parts[o]);
1274
- return !r || !t.origin ? !1 : h(x(r).root, { localName: "Relationship" }).some((s) => {
1275
- const i = _(s, "Target");
1276
- return _(s, "Type") === fe && _(s, "TargetMode") !== "External" && !!i && n.has(ie(t.origin.part, i));
1277
- });
287
+ function ns(t) {
288
+ return new Map(t.masterOrder.flatMap((a) => {
289
+ const s = t.masters[a];
290
+ return ht(s) ? [[s.id, s]] : [];
291
+ }));
1278
292
  }
1279
- function Mr(e, t, n) {
1280
- var a, s, i;
1281
- const o = new Set([...n].filter(Ot));
1282
- for (const c of Object.values(e.slides)) {
1283
- const f = c.notes;
1284
- if (f) {
1285
- if (o.has(f.targetPart) || !((a = e.package) != null && a.parts[f.targetPart]) && !t[f.targetPart])
1286
- o.add(f.targetPart), n.add(f.targetPart), n.add(U(f.targetPart));
1287
- else if (D(c.ovr, "notes") && !t[f.targetPart]) {
1288
- const v = f.sourcePart ?? f.targetPart, p = (s = e.package) == null ? void 0 : s.parts[v];
1289
- if (!p) throw new Error(`找不到备注保存基线:${v}`);
1290
- t[f.targetPart] = p.slice();
293
+ async function os(t) {
294
+ var n;
295
+ const a = ze();
296
+ Pt(t);
297
+ const s = /* @__PURE__ */ Object.create(null), i = /* @__PURE__ */ Object.create(null);
298
+ for (const c of a.values()) {
299
+ const u = await ((n = c.beforeSave) == null ? void 0 : n.call(c, t));
300
+ if (u) {
301
+ for (const [f, d] of Object.entries(u.changes)) {
302
+ if (Object.prototype.hasOwnProperty.call(s, f))
303
+ throw new Error(`多个编辑扩展同时修改 OPC part:${f}`);
304
+ s[f] = d;
305
+ }
306
+ for (const [f, d] of Object.entries(u.baselines)) {
307
+ const g = i[f];
308
+ if (g && (g.length !== d.length || !g.every((M, B) => M === d[B])))
309
+ throw new Error(`多个编辑扩展的保存基线冲突:${f}`);
310
+ i[f] = d;
1291
311
  }
1292
312
  }
1293
313
  }
1294
- const r = /* @__PURE__ */ new Map();
1295
- for (const c of Object.values(e.slides)) {
1296
- if (!c.origin || !(!!c.notes && o.has(c.notes.targetPart) || xr(e, c, o)) || (r.set(c.origin.part, c), c.creation)) continue;
1297
- const v = U(c.origin.part);
1298
- if (t[v] || n.has(v)) continue;
1299
- const p = (i = e.package) == null ? void 0 : i.parts[v];
1300
- p ? t[v] = p.slice() : n.add(v);
1301
- }
1302
- return { relationshipSlides: r, trackedParts: o };
1303
- }
1304
- function Ur(e, t, n, o) {
1305
- var r, a, s;
1306
- for (const i of Object.values(e.slides)) {
1307
- const c = i.notes;
1308
- if (!c) continue;
1309
- if (n.trackedParts.has(c.targetPart)) {
1310
- const m = c.sourcePart ? t[c.sourcePart] ?? ((r = e.package) == null ? void 0 : r.parts[c.sourcePart]) : void 0;
1311
- if (c.sourcePart && !m) throw new Error(`找不到备注克隆来源:${c.sourcePart}`);
1312
- const u = D(i.ovr, "notes") ? i.ovr.notes : i.src.notes ?? "";
1313
- o[c.targetPart] = it(m ?? wr(), u);
1314
- const y = c.sourcePart ? t[U(c.sourcePart)] ?? ((a = e.package) == null ? void 0 : a.parts[U(c.sourcePart)]) : void 0;
1315
- o[U(c.targetPart)] = Er(
1316
- y,
1317
- c.targetPart,
1318
- i.origin.part
1319
- );
1320
- continue;
1321
- }
1322
- const f = t[c.targetPart];
1323
- if (!f) continue;
1324
- const v = (s = e.package) == null ? void 0 : s.parts[c.targetPart];
1325
- (D(i.ovr, "notes") || v && (v.length !== f.length || v.some((m, u) => m !== f[u]))) && (o[c.targetPart] = D(i.ovr, "notes") ? it(f, i.ovr.notes) : f);
1326
- }
1327
- }
1328
- function Ir(e) {
1329
- const t = /* @__PURE__ */ new Map();
1330
- return e.slideOrder.forEach((n, o) => {
1331
- var s;
1332
- const r = e.slides[n], a = (s = r.origin) == null ? void 0 : s.part;
1333
- a && r.dynamicSlideNumbers.some((i) => {
1334
- var f;
1335
- const c = e.elements[i];
1336
- return ((f = c == null ? void 0 : c.meta.origin) == null ? void 0 : f.part) === a && Jt(pt(e, i));
1337
- }) && t.set(a, o + 1);
1338
- }), t;
1339
- }
1340
- function Cr(e) {
1341
- const t = /* @__PURE__ */ new Map();
1342
- for (const n of Object.values(e.elements)) {
1343
- if (!Gt(n) && !zt(n) && !Ht(n) && !qt(n) && !Vt(n) && !Wt(n) && !Yt(n) && !Kt(n) && !ft(n) && !n.meta.insertion) continue;
1344
- const o = n.meta.origin;
1345
- if (!o) throw new Error(`元素 ${n.id} 缺少 OOXML 回写锚点`);
1346
- const r = t.get(o.part) ?? [];
1347
- r.push(n), t.set(o.part, r);
1348
- }
1349
- return t;
314
+ return { changes: s, baselines: i };
1350
315
  }
1351
- function Rr(e) {
1352
- const t = /* @__PURE__ */ new Map();
1353
- for (const n of Object.values(e.removedElements)) {
1354
- const o = n.meta.origin;
1355
- if (!o) continue;
1356
- const r = t.get(o.part) ?? [];
1357
- r.push(n), t.set(o.part, r);
1358
- }
1359
- return t;
316
+ async function is(t) {
317
+ return cs(t, await os(t));
1360
318
  }
1361
- function Or(e) {
1362
- var n;
1363
- const t = /* @__PURE__ */ new Map();
1364
- for (const o of Object.values(e.slides)) {
1365
- if (!Nt(o)) continue;
1366
- const r = (n = o.origin) == null ? void 0 : n.part;
1367
- if (!r) throw new Error(`幻灯片 ${o.id} 缺少 OOXML 回写锚点`);
1368
- t.set(r, o);
1369
- }
1370
- return t;
319
+ async function ds(t) {
320
+ return t.meta.source === "pptx" && t.package && !t.package.disposed ? is(t) : (await import("./generate.js")).generateEditDoc(t);
1371
321
  }
1372
- function Fr(e) {
1373
- var je, Ge, ze, He;
1374
- if (Lt(e), e.meta.readonly) throw new Error("只读编辑文档不能保存");
1375
- if (e.meta.source !== "pptx" || !e.package)
322
+ function cs(t, a = { changes: {}, baselines: {} }) {
323
+ var Se, ke, Oe, be, Ee;
324
+ if (We(t), t.meta.readonly) throw new Error("只读编辑文档不能保存");
325
+ if (t.meta.source !== "pptx" || !t.package)
1376
326
  throw new Error("当前版本尚未实现生成式 PPTX 保存");
1377
- const t = Cr(e), n = Or(e), o = new Set([...t].flatMap(([l, d]) => d.some(ft) ? [l] : [])), r = Rr(e), a = an(e), s = Ee(e), i = new Map(Object.values(e.slides).flatMap((l) => l.layoutId !== l.sourceLayoutId && l.origin ? [[l.origin.part, l]] : [])), c = new Map(Object.values(e.slides).flatMap((l) => {
1378
- const d = At(e, l.id);
1379
- return l.origin && d.length ? [[l.origin.part, d]] : [];
1380
- })), f = new Map(Object.values(e.slides).flatMap((l) => l.origin ? [[l.origin.part, l]] : [])), v = Pr(e), p = Object.assign(
327
+ const s = ts(t), i = rs(t), n = as(t), c = ns(t), u = new Set([...s].flatMap(([e, r]) => r.some(Xe) ? [e] : [])), f = ss(t), d = Ot(t), g = bt(t), M = new Map(Object.values(t.slides).flatMap((e) => e.layoutId !== e.sourceLayoutId && e.origin ? [[e.origin.part, e]] : [])), B = new Map(Object.values(t.slides).flatMap((e) => {
328
+ const r = qe(t, e.id);
329
+ return e.origin && r.length ? [[e.origin.part, r]] : [];
330
+ })), U = new Map(Object.values(t.slides).flatMap((e) => e.origin ? [[e.origin.part, e]] : [])), F = Qt(t), o = Object.assign(
1381
331
  /* @__PURE__ */ Object.create(null),
1382
- e.saveState.baselines
1383
- ), m = new Set(e.saveState.createdParts), u = "[Content_Types].xml", y = "ppt/presentation.xml", b = "ppt/_rels/presentation.xml.rels", A = Mr(e, p, m), J = s.length > 0 || [...m].some((l) => /^ppt\/slides\/slide\d+\.xml$/.test(l)), $e = e.slideOrder.flatMap((l) => {
1384
- var d;
1385
- return ((d = e.slides[l].origin) == null ? void 0 : d.part) ?? [];
1386
- }), ce = Bt(e, m), de = ce.slideParts.size > 0, Fe = /* @__PURE__ */ new Set();
1387
- if (de)
1388
- for (const l of e.slideOrder) {
1389
- const d = e.slides[l], P = (je = d.origin) == null ? void 0 : je.part;
1390
- if (!P) continue;
1391
- const k = U(P), V = p[k] ?? (d.creation ? Pe(e, d, p) : void 0) ?? e.package.parts[k];
1392
- $t(e, P, V) && Fe.add(P);
332
+ t.saveState.baselines,
333
+ a.baselines
334
+ ), P = new Set(t.saveState.createdParts), x = "[Content_Types].xml", j = "ppt/presentation.xml", R = "ppt/_rels/presentation.xml.rels", w = Et(t), te = t.themeOrder.filter((e) => Ve(t.themes[e]) || !!o[e]);
335
+ for (const e of te) {
336
+ if (o[e]) continue;
337
+ const r = t.package.parts[e];
338
+ if (!r) throw new Error(`找不到主题 OPC part:${e}`);
339
+ o[e] = r.slice();
340
+ }
341
+ if (w != null && w.definitions.length && !o[w.part]) {
342
+ const e = t.package.parts[w.part];
343
+ if (e) o[w.part] = e.slice();
344
+ else {
345
+ P.add(w.part);
346
+ for (const r of [x, R]) {
347
+ if (o[r]) continue;
348
+ const l = t.package.parts[r];
349
+ if (!l) throw new Error(`PPTX 缺少 ${r}`);
350
+ o[r] = l.slice();
351
+ }
1393
352
  }
1394
- const Me = /* @__PURE__ */ new Set([...o, ...Fe]), _e = $e.length !== e.saveState.sourceSlideParts.length || $e.some((l, d) => l !== e.saveState.sourceSlideParts[d]), Pt = J || de || _e || !!p[y];
1395
- if (_e && !p[y]) {
1396
- const l = e.package.parts[y];
1397
- if (!l) throw new Error("PPTX 缺少 ppt/presentation.xml");
1398
- p[y] = l.slice();
1399
353
  }
1400
- const he = Pt ? Ir(e) : /* @__PURE__ */ new Map();
1401
- for (const l of /* @__PURE__ */ new Set([
1402
- ...t.keys(),
354
+ const p = xt(t, o, P), k = g.length > 0 || [...P].some((e) => /^ppt\/slides\/slide\d+\.xml$/.test(e)), X = t.slideOrder.flatMap((e) => {
355
+ var r;
356
+ return ((r = t.slides[e].origin) == null ? void 0 : r.part) ?? [];
357
+ }), N = Je(t, P), T = N.slideParts.size > 0, C = /* @__PURE__ */ new Set();
358
+ if (T)
359
+ for (const e of t.slideOrder) {
360
+ const r = t.slides[e], l = (Se = r.origin) == null ? void 0 : Se.part;
361
+ if (!l) continue;
362
+ const h = E(l), I = o[h] ?? (r.creation ? pe(t, r, o) : void 0) ?? t.package.parts[h];
363
+ Ke(t, l, I) && C.add(l);
364
+ }
365
+ const S = /* @__PURE__ */ new Set([...u, ...C]), q = X.length !== t.saveState.sourceSlideParts.length || X.some((e, r) => e !== t.saveState.sourceSlideParts[r]), se = t.meta.width !== t.meta.sourceWidth || t.meta.height !== t.meta.sourceHeight || t.sections.edited, oe = k || T || q || se || !!o[j];
366
+ if ((q || se) && !o[j]) {
367
+ const e = t.package.parts[j];
368
+ if (!e) throw new Error("PPTX 缺少 ppt/presentation.xml");
369
+ o[j] = e.slice();
370
+ }
371
+ const V = oe ? es(t) : /* @__PURE__ */ new Map();
372
+ for (const e of /* @__PURE__ */ new Set([
373
+ ...s.keys(),
374
+ ...i.keys(),
1403
375
  ...n.keys(),
1404
- ...r.keys(),
1405
- ...he.keys(),
1406
- ...Me,
1407
- ...c.keys()
376
+ ...c.keys(),
377
+ ...f.keys(),
378
+ ...V.keys(),
379
+ ...S,
380
+ ...B.keys()
1408
381
  ])) {
1409
- if (p[l] || s.some((P) => {
1410
- var k;
1411
- return ((k = P.origin) == null ? void 0 : k.part) === l;
382
+ if (o[e] || g.some((l) => {
383
+ var h;
384
+ return ((h = l.origin) == null ? void 0 : h.part) === e;
1412
385
  })) continue;
1413
- const d = e.package.parts[l];
1414
- if (!d) throw new Error(`找不到待写回的 OPC part:${l}`);
1415
- p[l] = d.slice();
1416
- }
1417
- for (const l of a.relationships.keys()) {
1418
- const d = U(l);
1419
- if (p[d] || m.has(d)) continue;
1420
- const P = e.package.parts[d];
1421
- P ? p[d] = P.slice() : m.add(d);
1422
- }
1423
- for (const l of Me) {
1424
- const d = U(l);
1425
- if (p[d] || m.has(d)) continue;
1426
- const P = e.package.parts[d];
1427
- P ? p[d] = P.slice() : m.add(d);
1428
- }
1429
- for (const [l, d] of i) {
1430
- if (d.creation) continue;
1431
- const P = U(l);
1432
- if (p[P] || m.has(P)) continue;
1433
- const k = e.package.parts[P];
1434
- k ? p[P] = k.slice() : m.add(P);
1435
- }
1436
- for (const l of ce.packageParts) {
1437
- if (m.has(l) || p[l]) continue;
1438
- const d = e.package.parts[l];
1439
- d && (p[l] = d.slice());
1440
- }
1441
- if ((a.resources.size || J || de || A.trackedParts.size) && !p[u]) {
1442
- const l = e.package.parts[u];
1443
- if (!l) throw new Error("PPTX 缺少 [Content_Types].xml");
1444
- p[u] = l.slice();
1445
- }
1446
- if (J || de)
1447
- for (const l of [y, b]) {
1448
- if (p[l]) continue;
1449
- const d = e.package.parts[l];
1450
- if (!d) throw new Error(`PPTX 缺少 ${l}`);
1451
- p[l] = d.slice();
386
+ const r = t.package.parts[e];
387
+ if (!r) throw new Error(`找不到待写回的 OPC part:${e}`);
388
+ o[e] = r.slice();
389
+ }
390
+ for (const e of d.relationships.keys()) {
391
+ const r = E(e);
392
+ if (o[r] || P.has(r)) continue;
393
+ const l = t.package.parts[r];
394
+ l ? o[r] = l.slice() : P.add(r);
395
+ }
396
+ for (const e of S) {
397
+ const r = E(e);
398
+ if (o[r] || P.has(r)) continue;
399
+ const l = t.package.parts[r];
400
+ l ? o[r] = l.slice() : P.add(r);
401
+ }
402
+ for (const [e, r] of M) {
403
+ if (r.creation) continue;
404
+ const l = E(e);
405
+ if (o[l] || P.has(l)) continue;
406
+ const h = t.package.parts[l];
407
+ h ? o[l] = h.slice() : P.add(l);
408
+ }
409
+ for (const e of N.packageParts) {
410
+ if (P.has(e) || o[e]) continue;
411
+ const r = t.package.parts[e];
412
+ r && (o[e] = r.slice());
413
+ }
414
+ if ((d.resources.size || k || T || p.trackedParts.size) && !o[x]) {
415
+ const e = t.package.parts[x];
416
+ if (!e) throw new Error("PPTX 缺少 [Content_Types].xml");
417
+ o[x] = e.slice();
418
+ }
419
+ if (k || T)
420
+ for (const e of [j, R]) {
421
+ if (o[e]) continue;
422
+ const r = t.package.parts[e];
423
+ if (!r) throw new Error(`PPTX 缺少 ${e}`);
424
+ o[e] = r.slice();
1452
425
  }
1453
- for (const l of s) {
1454
- const d = l.origin.part;
1455
- m.add(d), m.add(U(d));
426
+ for (const e of g) {
427
+ const r = e.origin.part;
428
+ P.add(r), P.add(E(r));
1456
429
  }
1457
- for (const l of a.resources.values())
1458
- l.created && m.add(l.targetPart);
1459
- const R = /* @__PURE__ */ Object.create(null);
1460
- for (const l of m) R[l] = null;
1461
- for (const [l, d] of Object.entries(p))
1462
- !e.package.parts[l] && !ce.packageParts.has(l) && !m.has(l) && (R[l] = d);
1463
- const St = new Set(e.slideOrder.flatMap((l) => {
1464
- var k;
1465
- const d = e.slides[l], P = (k = d.origin) == null ? void 0 : k.part;
1466
- return P && (p[P] || d.creation || he.has(P)) ? [P] : [];
1467
- })), Ue = /* @__PURE__ */ new Map();
1468
- for (const l of St) {
1469
- const d = s.find((W) => {
1470
- var te;
1471
- return ((te = W.origin) == null ? void 0 : te.part) === l;
1472
- }), P = p[l] ?? (d ? Nn(e, d, p) ?? pn() : void 0);
1473
- if (!P) throw new Error(`找不到页面保存基线:${l}`);
1474
- const k = x(P), V = t.get(l) ?? [], ge = U(l), ve = p[ge] ?? (d ? Pe(e, d, p) : void 0), F = Me.has(l) ? Ft(
430
+ for (const e of d.resources.values())
431
+ e.created && P.add(e.targetPart);
432
+ const m = Object.assign(
433
+ /* @__PURE__ */ Object.create(null),
434
+ a.changes
435
+ );
436
+ for (const e of P) m[e] = null;
437
+ for (const [e, r] of Object.entries(o))
438
+ !t.package.parts[e] && !N.packageParts.has(e) && !P.has(e) && (m[e] = r);
439
+ const $ = new Set(t.slideOrder.flatMap((e) => {
440
+ var h;
441
+ const r = t.slides[e], l = (h = r.origin) == null ? void 0 : h.part;
442
+ return l && (o[l] || r.creation || V.has(l)) ? [l] : [];
443
+ })), y = /* @__PURE__ */ new Map();
444
+ for (const e of $) {
445
+ const r = g.find((G) => {
446
+ var Y;
447
+ return ((Y = G.origin) == null ? void 0 : Y.part) === e;
448
+ }), l = o[e] ?? (r ? _t(t, r, o) ?? Tt() : void 0);
449
+ if (!l) throw new Error(`找不到页面保存基线:${e}`);
450
+ const h = D(l), I = s.get(e) ?? [], b = E(e), H = o[b] ?? (r ? pe(t, r, o) : void 0), z = S.has(e) ? ge(
451
+ t,
1475
452
  e,
1476
- l,
1477
- ve,
1478
- a.relationships.get(l) ?? []
453
+ H,
454
+ d.relationships.get(e) ?? []
1479
455
  ) : void 0;
1480
- F && Ue.set(l, F), F == null || F.removeDanglingHyperlinks(k);
1481
- const ye = [
1482
- ...d ? Pn(d) : [],
1483
- ...r.get(l) ?? []
456
+ z && y.set(e, z), z == null || z.removeDanglingHyperlinks(h);
457
+ const ce = [
458
+ ...r ? Wt(r) : [],
459
+ ...f.get(e) ?? []
1484
460
  ];
1485
- _t(k, e, l, V, ye, { links: F });
1486
- const Ne = ((Ge = d == null ? void 0 : d.creation) == null ? void 0 : Ge.duplicateRemovedAnimationSpids) ?? ((ze = d == null ? void 0 : d.creation) == null ? void 0 : ze.duplicateRemovedSpids) ?? [], Ie = (r.get(l) ?? []).flatMap((W) => W.sourceSpids ?? (W.meta.origin ? [W.meta.origin.spid] : []));
1487
- ar(k, [...Ne, ...Ie]);
1488
- for (const W of c.get(l) ?? []) {
1489
- const te = e.elements[W], Ve = f.get(l);
1490
- yr(
1491
- k,
1492
- te,
1493
- pt(e, W),
1494
- Dt(te),
1495
- Ve ? v(Ve, te) : void 0
461
+ Pe(h, t, e, I, ce, { links: z });
462
+ const le = ((ke = r == null ? void 0 : r.creation) == null ? void 0 : ke.duplicateRemovedAnimationSpids) ?? ((Oe = r == null ? void 0 : r.creation) == null ? void 0 : Oe.duplicateRemovedSpids) ?? [], he = (f.get(e) ?? []).flatMap((G) => G.sourceSpids ?? (G.meta.origin ? [G.meta.origin.spid] : []));
463
+ Mt(h, [...le, ...he]);
464
+ for (const G of B.get(e) ?? []) {
465
+ const Y = t.elements[G], Te = U.get(e);
466
+ Jt(
467
+ h,
468
+ Y,
469
+ Ie(t, G),
470
+ Qe(Y),
471
+ Te ? F(Te, Y) : void 0
1496
472
  );
1497
473
  }
1498
- const le = n.get(l);
1499
- le && hr(k, e, le);
1500
- const qe = X(k);
1501
- R[l] = he.has(l) ? un(qe, he.get(l)) : qe;
1502
- }
1503
- const De = /* @__PURE__ */ new Set();
1504
- for (const l of /* @__PURE__ */ new Set([
1505
- ...a.relationships.keys(),
1506
- ...Ue.keys(),
1507
- ...i.keys(),
1508
- ...A.relationshipSlides.keys()
474
+ const re = i.get(e);
475
+ re && Nt(h, t, re);
476
+ const xe = W(h);
477
+ m[e] = V.has(e) ? Ct(xe, V.get(e)) : xe;
478
+ }
479
+ const O = new Set(t.layoutOrder.filter((e) => o[e] || s.has(e) || f.has(e) || n.has(e)));
480
+ for (const e of O) {
481
+ const r = o[e];
482
+ if (!r) throw new Error(`找不到版式保存基线:${e}`);
483
+ const l = D(r), h = s.get(e) ?? [], I = o[E(e)], b = S.has(e) ? ge(
484
+ t,
485
+ e,
486
+ I,
487
+ d.relationships.get(e) ?? []
488
+ ) : void 0;
489
+ b && y.set(e, b), b == null || b.removeDanglingHyperlinks(l), Pe(l, t, e, h, f.get(e) ?? [], { links: b });
490
+ const H = n.get(e);
491
+ H && Zt(l, H), m[e] = W(l);
492
+ }
493
+ const J = new Set(t.masterOrder.filter((e) => o[e] || s.has(e) || f.has(e) || c.has(e)));
494
+ for (const e of J) {
495
+ const r = o[e];
496
+ if (!r) throw new Error(`找不到母版保存基线:${e}`);
497
+ const l = D(r), h = s.get(e) ?? [], I = o[E(e)], b = S.has(e) ? ge(
498
+ t,
499
+ e,
500
+ I,
501
+ d.relationships.get(e) ?? []
502
+ ) : void 0;
503
+ b && y.set(e, b), b == null || b.removeDanglingHyperlinks(l), Pe(l, t, e, h, f.get(e) ?? [], { links: b });
504
+ const H = c.get(e);
505
+ H && Ye(l, H), m[e] = W(l);
506
+ }
507
+ const ie = /* @__PURE__ */ new Set();
508
+ for (const e of /* @__PURE__ */ new Set([
509
+ ...d.relationships.keys(),
510
+ ...y.keys(),
511
+ ...M.keys(),
512
+ ...p.relationshipSlides.keys()
1509
513
  ])) {
1510
- const d = a.relationships.get(l) ?? [], P = U(l);
1511
- De.add(P);
1512
- const k = s.find((Ie) => {
1513
- var le;
1514
- return ((le = Ie.origin) == null ? void 0 : le.part) === l;
1515
- }), V = p[P] ?? (k ? Pe(e, k, p) : void 0), ge = Ue.get(l), ve = R[l];
1516
- let F = ge && ve instanceof Uint8Array ? Xt(V, d, ge, ve) : z(V, d);
1517
- const ye = i.get(l);
1518
- ye && (F = mt(ye, F));
1519
- const Ne = A.relationshipSlides.get(l);
1520
- Ne && (F = ct(Ne, F)), R[P] = F;
1521
- }
1522
- for (const [l, d] of Object.entries(p))
1523
- l.endsWith(".rels") && !De.has(l) && (R[l] = z(d, []));
1524
- for (const [l, d] of a.resources) R[l] = cn(d);
1525
- if (Ur(e, p, A, R), p[u]) {
1526
- const l = sn(
1527
- p[u],
1528
- [...a.resources.values()]
514
+ const r = d.relationships.get(e) ?? [], l = E(e);
515
+ ie.add(l);
516
+ const h = g.find((he) => {
517
+ var re;
518
+ return ((re = he.origin) == null ? void 0 : re.part) === e;
519
+ }), I = o[l] ?? (h ? pe(t, h, o) : void 0), b = y.get(e), H = m[e];
520
+ let z = b && H instanceof Uint8Array ? Ze(I, r, b, H) : Ce(I, r);
521
+ const ce = M.get(e);
522
+ ce && (z = Rt(ce, z));
523
+ const le = p.relationshipSlides.get(e);
524
+ le && (z = Re(le, z)), m[l] = z;
525
+ }
526
+ for (const [e, r] of Object.entries(o))
527
+ e.endsWith(".rels") && !ie.has(e) && (m[e] = Ce(r, []));
528
+ for (const [e, r] of d.resources) m[e] = $t(r);
529
+ if (jt(t, o, p, m), o[x]) {
530
+ const e = Xt(
531
+ o[x],
532
+ [...d.resources.values()]
1529
533
  );
1530
- R[u] = yn(
1531
- l,
534
+ m[x] = It(
1532
535
  e,
1533
- ce.contentTypeParts
536
+ t,
537
+ N.contentTypeParts
1534
538
  );
1535
539
  }
1536
- for (const l of s) {
1537
- const d = U(l.origin.part), P = R[d], k = P instanceof Uint8Array ? P : Pe(e, l, p), V = (He = l.creation) != null && He.duplicateSourcePart ? k : mn(l, k);
1538
- R[d] = ct(l, V);
540
+ for (const e of g) {
541
+ const r = E(e.origin.part), l = m[r], h = l instanceof Uint8Array ? l : pe(t, e, o), I = (be = e.creation) != null && be.duplicateSourcePart ? h : zt(e, h);
542
+ m[r] = Re(e, I);
1539
543
  }
1540
- if (p[y]) {
1541
- const l = p[b] ?? e.package.parts[b];
1542
- if (!l) throw new Error("PPTX 缺少 ppt/_rels/presentation.xml.rels");
1543
- R[y] = gn(
1544
- p[y],
1545
- l,
1546
- e
544
+ if (o[j]) {
545
+ const e = o[R] ?? t.package.parts[R];
546
+ if (!e) throw new Error("PPTX 缺少 ppt/_rels/presentation.xml.rels");
547
+ m[j] = At(
548
+ o[j],
549
+ e,
550
+ t
1547
551
  );
1548
552
  }
1549
- p[b] && (R[b] = vn(
1550
- p[b],
1551
- e
1552
- ));
1553
- for (const l of ce.packageParts) R[l] = null;
1554
- const Xe = Qt(e.package, R);
1555
- return jt(e, Xe.package, p, [...m].sort()), Xe;
553
+ if (o[R] && (m[R] = Dt(
554
+ o[R],
555
+ t
556
+ )), w != null && w.definitions.length && P.has(w.part)) {
557
+ const e = m[x] ?? o[x], r = m[R] ?? o[R];
558
+ if (!(e instanceof Uint8Array) || !(r instanceof Uint8Array))
559
+ throw new Error("创建 tableStyles.xml 缺少 OPC 闭包基线");
560
+ m[x] = Ht(e, w.part), m[R] = Lt(
561
+ r,
562
+ w.part
563
+ );
564
+ }
565
+ for (const e of N.packageParts) m[e] = null;
566
+ if (w) {
567
+ const e = o[w.part];
568
+ w.definitions.length ? m[w.part] = Bt(e, w.definitions) : e && (m[w.part] = e);
569
+ }
570
+ for (const e of te)
571
+ m[e] = et(o[e], t.themes[e]);
572
+ Gt(t, g, o, P, m);
573
+ for (const e of ze().values()) (Ee = e.materializePackage) == null || Ee.call(e, t, o, P, m);
574
+ const we = St(t.package, m);
575
+ return tt(t, we.package, o, [...P].sort()), we;
1556
576
  }
1557
577
  export {
1558
- Fr as saveEditDoc
578
+ cs as saveEditDoc,
579
+ is as saveEditDocWithExtensions,
580
+ ds as serializeEditDoc
1559
581
  };