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

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 (72) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -1
  3. package/dist/collaboration-identity.d.ts +3 -0
  4. package/dist/commands/add-slide-identity.d.ts +2 -0
  5. package/dist/commands/convert-to-custom-geometry.d.ts +4 -0
  6. package/dist/commands/element-geometry.d.ts +6 -0
  7. package/dist/commands/element-hierarchy.d.ts +6 -0
  8. package/dist/commands/element-table-style.d.ts +5 -0
  9. package/dist/commands/frame-decomposition.d.ts +10 -0
  10. package/dist/commands/generated-creation-defaults.d.ts +4 -0
  11. package/dist/commands/geometry-types.d.ts +22 -0
  12. package/dist/commands/group-types.d.ts +24 -0
  13. package/dist/commands/group.d.ts +4 -0
  14. package/dist/commands/insertion-host.d.ts +3 -0
  15. package/dist/commands/insertion-rect.d.ts +2 -0
  16. package/dist/commands/patch-invalidation.d.ts +4 -0
  17. package/dist/commands/patch.d.ts +4 -0
  18. package/dist/commands/record-clone.d.ts +3 -0
  19. package/dist/commands/set-geometry.d.ts +4 -0
  20. package/dist/commands/set-table-style.d.ts +3 -0
  21. package/dist/commands/spid.d.ts +1 -0
  22. package/dist/commands/table-style-types.d.ts +28 -0
  23. package/dist/commands/text-target.d.ts +1 -0
  24. package/dist/commands/types.d.ts +29 -4
  25. package/dist/commands/ungroup.d.ts +4 -0
  26. package/dist/custom-geometry-path.d.ts +3 -0
  27. package/dist/custom-geometry.d.ts +12 -0
  28. package/dist/document-B1jjN-QB.js +274 -0
  29. package/dist/edit-core.js +3597 -2639
  30. package/dist/editor.d.ts +6 -1
  31. package/dist/generate/custom-geometry.d.ts +2 -0
  32. package/dist/generate/index.d.ts +12 -0
  33. package/dist/generate/links.d.ts +3 -0
  34. package/dist/generate/materialize.d.ts +2 -0
  35. package/dist/generate/media.d.ts +13 -0
  36. package/dist/generate/table.d.ts +4 -0
  37. package/dist/generate/template.d.ts +3 -0
  38. package/dist/generate.js +744 -0
  39. package/dist/hyperlink.d.ts +2 -0
  40. package/dist/identity-allocation.d.ts +12 -0
  41. package/dist/identity-watermark.d.ts +4 -0
  42. package/dist/image-resource-DbgJS9n-.js +24 -0
  43. package/dist/{index-D4ZTaYOa.js → index-D2JizcOQ.js} +7 -7
  44. package/dist/index.d.ts +11 -3
  45. package/dist/insertion-CGpb504L.js +6152 -0
  46. package/dist/layout-projection.d.ts +2 -0
  47. package/dist/opc/patch.d.ts +2 -0
  48. package/dist/opc.js +1 -1
  49. package/dist/paragraph-level.d.ts +11 -0
  50. package/dist/paragraph-property-schema.d.ts +1 -1
  51. package/dist/{patch-DO8497wO.js → patch-D7lZelRa.js} +111 -94
  52. package/dist/patch-change.d.ts +4 -0
  53. package/dist/patch-events.d.ts +12 -0
  54. package/dist/recovery-identity.d.ts +2 -1
  55. package/dist/run-property-schema.d.ts +1 -1
  56. package/dist/save/geometry.d.ts +5 -0
  57. package/dist/save/insertion.d.ts +3 -0
  58. package/dist/save/notes.d.ts +2 -0
  59. package/dist/save/run-overrides.d.ts +10 -0
  60. package/dist/save/shape-format.d.ts +3 -0
  61. package/dist/save/table-style-part.d.ts +11 -0
  62. package/dist/save/table.d.ts +3 -0
  63. package/dist/save/text-source-less.d.ts +6 -0
  64. package/dist/save.js +468 -1441
  65. package/dist/table-direct-markup.d.ts +7 -1
  66. package/dist/table-style-part-DBtpxmuo.js +1042 -0
  67. package/dist/table-style.d.ts +20 -0
  68. package/dist/text-model.d.ts +1 -1
  69. package/dist/types.d.ts +44 -1
  70. package/dist/xml.js +1 -1
  71. package/package.json +6 -2
  72. package/dist/insertion-DabLme_U.js +0 -5471
@@ -0,0 +1,744 @@
1
+ import { _ as de, g as B, $ as te, P as re, a0 as he, b as ae, s as se, D as ne, Z as fe, a1 as ue, a2 as oe, l as q, E as ge, a3 as Y, a4 as xe, a5 as V, A as $e, B as ye, a6 as ve, p as be, a7 as we, a8 as Se, a9 as Pe, u as Ie } from "./insertion-CGpb504L.js";
2
+ import { c as le, d as Te } from "./patch-D7lZelRa.js";
3
+ import { TEXT_RUN_DIRECT_BITS as H } from "@web-ppt/core";
4
+ import { P as _, D as j, p as Me, a as ke } from "./index-D2JizcOQ.js";
5
+ import { i as Ce, g as Le, h as Ee, m as Fe, p as W, k as Ne, d as Oe, f as Re, b as Ae } from "./table-style-part-DBtpxmuo.js";
6
+ import { c as Z } from "./image-resource-DbgJS9n-.js";
7
+ const Be = /[A-Za-z]|[-+]?(?:\d*\.?\d+)(?:e[-+]?\d+)?/gi;
8
+ function O(a, t) {
9
+ const r = Math.round(a * 9525);
10
+ if (!Number.isSafeInteger(r)) throw new Error(`自定义几何 ${t} 超出 OOXML 安全整数范围`);
11
+ return String(r);
12
+ }
13
+ function C(a, t, r) {
14
+ const s = Number(a[t]), e = Number(a[t + 1]);
15
+ if (!Number.isFinite(s) || !Number.isFinite(e)) throw new Error(`自定义几何 ${r} 坐标无效`);
16
+ return [s, e];
17
+ }
18
+ const z = ([a, t], r) => `<a:pt x="${O(a, `${r}.x`)}" y="${O(t, `${r}.y`)}"/>`;
19
+ function K(a, t) {
20
+ const r = Math.round(a * 180 * 6e4 / Math.PI);
21
+ if (!Number.isSafeInteger(r)) throw new Error(`自定义几何 ${t} 角度无效`);
22
+ return String(r);
23
+ }
24
+ function _e(a, t, r) {
25
+ if (!r) throw new Error("生成保存的自定义圆弧缺少起点");
26
+ let s = Math.abs(Number(a[t])), e = Math.abs(Number(a[t + 1]));
27
+ const o = Number(a[t + 2]), n = Number(a[t + 3]), l = Number(a[t + 4]), c = C(a, t + 5, "A");
28
+ if (![s, e, o, n, l].every(Number.isFinite) || n !== 0 && n !== 1 || l !== 0 && l !== 1)
29
+ throw new Error("自定义几何 A 参数无效");
30
+ if (Math.abs(o) > 1e-9) throw new Error("生成保存不支持旋转椭圆的自定义圆弧");
31
+ if (s === 0 || e === 0)
32
+ return { markup: `<a:lnTo>${z(c, "A")}</a:lnTo>`, target: c };
33
+ const [m, i] = r, [d, p] = c;
34
+ if (m === d && i === p) return { markup: "", target: c };
35
+ const h = (m - d) / 2, f = (i - p) / 2, x = h * h / (s * s) + f * f / (e * e);
36
+ if (x > 1) {
37
+ const Q = Math.sqrt(x);
38
+ s *= Q, e *= Q;
39
+ }
40
+ const g = s * s, b = e * e, I = g * f * f + b * h * h, k = Math.max(0, g * b - I), y = I === 0 ? 0 : (n === l ? -1 : 1) * Math.sqrt(k / I), w = (m + d) / 2 + y * (s * f / e), S = (i + p) / 2 - y * (e * h / s), L = Math.atan2((i - S) / e, (m - w) / s);
41
+ let R = Math.atan2((p - S) / e, (d - w) / s) - L;
42
+ return l === 1 && R < 0 && (R += Math.PI * 2), l === 0 && R > 0 && (R -= Math.PI * 2), {
43
+ markup: `<a:arcTo wR="${O(s, "A.rx")}" hR="${O(e, "A.ry")}" stAng="${K(L, "A.start")}" swAng="${K(R, "A.sweep")}"/>`,
44
+ target: c
45
+ };
46
+ }
47
+ function ie(a, t, r, s) {
48
+ const e = a.match(Be) ?? [], o = [];
49
+ let n = 0, l = null, c = null;
50
+ for (; n < e.length; ) {
51
+ const d = e[n++];
52
+ if (d === "Z" || d === "z") {
53
+ o.push("<a:close/>"), l = c;
54
+ continue;
55
+ }
56
+ if (d === "M" || d === "L") {
57
+ const p = C(e, n, d);
58
+ n += 2;
59
+ const h = d === "M" ? "moveTo" : "lnTo";
60
+ o.push(`<a:${h}>${z(p, d)}</a:${h}>`), l = p, d === "M" && (c = p);
61
+ continue;
62
+ }
63
+ if (d === "C") {
64
+ const p = [
65
+ C(e, n, "C1"),
66
+ C(e, n + 2, "C2"),
67
+ C(e, n + 4, "C3")
68
+ ];
69
+ n += 6, o.push(`<a:cubicBezTo>${p.map((h, f) => z(h, `C${f + 1}`)).join("")}</a:cubicBezTo>`), l = p[2];
70
+ continue;
71
+ }
72
+ if (d === "Q") {
73
+ const p = [C(e, n, "Q1"), C(e, n + 2, "Q2")];
74
+ n += 4, o.push(`<a:quadBezTo>${p.map((h, f) => z(h, `Q${f + 1}`)).join("")}</a:quadBezTo>`), l = p[1];
75
+ continue;
76
+ }
77
+ if (d === "A") {
78
+ const p = _e(e, n, l);
79
+ n += 7, p.markup && o.push(p.markup), l = p.target;
80
+ continue;
81
+ }
82
+ throw new Error(`生成保存不支持自定义路径命令:${d}`);
83
+ }
84
+ if (!o.length) throw new Error("生成保存的自定义路径为空");
85
+ const m = O(t, "width"), i = O(r, "height");
86
+ return `<a:custGeom><a:avLst/><a:gdLst/><a:ahLst/><a:cxnLst/><a:rect l="0" t="0" r="r" b="b"/>
87
+ <a:pathLst><a:path w="${m}" h="${i}" fill="${s ? "none" : "norm"}" stroke="1">${o.join("")}</a:path></a:pathLst></a:custGeom>`;
88
+ }
89
+ function pe(a, t, r, s) {
90
+ const e = de(a, r);
91
+ if (!e) return;
92
+ if (e.kind === "external" || e.kind === "slide") return e;
93
+ if (e.kind === "unsupported") throw new Error(`${s} 的来源链接无法生成`);
94
+ const o = a.slideOrder.indexOf(t), n = e.action === "first" ? 0 : e.action === "last" ? a.slideOrder.length - 1 : e.action === "next" ? Math.min(o + 1, a.slideOrder.length - 1) : Math.max(o - 1, 0), l = a.slideOrder[n];
95
+ return l ? { kind: "slide", slideId: l } : void 0;
96
+ }
97
+ const je = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", Ge = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", ze = {
98
+ "audio/mpeg": "mp3",
99
+ "audio/mp4": "m4a",
100
+ "audio/wav": "wav",
101
+ "video/mp4": "mp4",
102
+ "video/webm": "webm",
103
+ "video/quicktime": "mov"
104
+ };
105
+ function De(a, t) {
106
+ if (t.src.startsWith("web-ppt-resource:")) {
107
+ const e = a.imageResources[t.src.slice(17)];
108
+ if (!e) throw new Error(`图片 ${t.name ?? t.id ?? ""} 缺少会话资源`);
109
+ return {
110
+ hash: e.hash,
111
+ mime: e.mime,
112
+ extension: e.extension,
113
+ bytes: e.bytes
114
+ };
115
+ }
116
+ const r = te(a, t.src);
117
+ if (r) return Z(r.bytes, r.mime, "生成图片");
118
+ const s = /^data:([^;,]+)((?:;[^,]*)?),(.*)$/is.exec(t.src);
119
+ if (s) {
120
+ const e = /;base64/i.test(s[2]) ? re(s[3]) : new TextEncoder().encode(decodeURIComponent(s[3]));
121
+ return s[1] === "image/svg+xml" ? (he(e, s[1], "svg", "生成图片", !0), {
122
+ hash: se(e),
123
+ mime: s[1],
124
+ extension: "svg",
125
+ bytes: ae(e)
126
+ }) : Z(e, s[1], "生成图片");
127
+ }
128
+ if (/^https?:\/\//i.test(t.src)) return null;
129
+ throw new Error(`图片 ${t.name ?? t.id ?? ""} 缺少可生成的资源字节`);
130
+ }
131
+ function X(a, t, r, s) {
132
+ const e = De(a, t), o = e ? {
133
+ ...e,
134
+ targetPart: `ppt/media/web-ppt-${e.hash}.${e.extension}`,
135
+ created: !0
136
+ } : null;
137
+ return {
138
+ resource: o,
139
+ relationship: {
140
+ sourceId: r,
141
+ targetId: r,
142
+ type: je,
143
+ target: o ? B(s, o.targetPart) : t.src,
144
+ ...o ? {} : { targetMode: "External" }
145
+ }
146
+ };
147
+ }
148
+ function He(a, t, r, s) {
149
+ if (!t.src) return {};
150
+ const e = te(a, t.src), o = /^data:([^;,]+);base64,(.*)$/is.exec(t.src), n = (e == null ? void 0 : e.bytes) ?? (o ? re(o[2]) : null), l = (e == null ? void 0 : e.mime) ?? (o == null ? void 0 : o[1]) ?? t.mime ?? (t.kind === "audio" ? "audio/mpeg" : "video/mp4"), c = `http://schemas.openxmlformats.org/officeDocument/2006/relationships/${t.kind}`;
151
+ if (!n) {
152
+ if (!t.external && !/^https?:\/\//i.test(t.src))
153
+ throw new Error(`媒体 ${t.src} 缺少可生成的资源字节`);
154
+ return { relationship: {
155
+ sourceId: r,
156
+ targetId: r,
157
+ type: c,
158
+ target: t.src,
159
+ targetMode: "External"
160
+ } };
161
+ }
162
+ const m = se(n), i = ze[l] ?? (t.kind === "audio" ? "mp3" : "mp4"), d = {
163
+ hash: m,
164
+ mime: l,
165
+ extension: i,
166
+ bytes: ae(n),
167
+ created: !0,
168
+ targetPart: `ppt/media/web-ppt-${m}.${i}`
169
+ };
170
+ return {
171
+ resource: d,
172
+ relationship: {
173
+ sourceId: r,
174
+ targetId: r,
175
+ type: c,
176
+ target: B(s, d.targetPart)
177
+ }
178
+ };
179
+ }
180
+ const U = (a) => a.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
181
+ function Xe(a, t, r, s) {
182
+ const e = t.src;
183
+ if (e.kind !== "image") throw new Error(`元素 ${t.id} 不是图片`);
184
+ const o = e.src ? X(a, e, `rIdImage${r}`, s) : null, n = e.media ? He(a, e.media, `rIdMedia${r}`, s) : null, l = o != null && o.resource ? "embed" : "link", c = e.alpha === void 0 ? "" : `<a:alphaModFix amt="${Math.round(e.alpha * 1e5)}"/>`, m = U(e.name ?? `图片 ${r}`), i = e.media ? `<a:${e.media.kind}File${n != null && n.relationship ? ` r:link="${n.relationship.targetId}"` : ""}/>` : "", d = o ? `<a:blip r:${l}="${o.relationship.targetId}">${c}</a:blip>` : "", p = t.meta.geom ? Object.entries(t.meta.geom.adj).map(([g, b]) => {
185
+ if (!Number.isSafeInteger(Math.round(b)))
186
+ throw new Error(`图片 ${t.id} 的几何调整值无效`);
187
+ return `<a:gd name="${U(g)}" fmla="val ${Math.round(b)}"/>`;
188
+ }).join("") : "", h = t.meta.geom ? `<a:prstGeom prst="${U(t.meta.geom.preset)}"><a:avLst>${p}</a:avLst></a:prstGeom>` : e.clipPath ? ie(e.clipPath, e.w, e.h, !1) : '<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>', f = [o == null ? void 0 : o.relationship, n == null ? void 0 : n.relationship].filter((g) => !!g), x = [o == null ? void 0 : o.resource, n == null ? void 0 : n.resource].filter((g) => !!g);
189
+ return {
190
+ markup: `<p:pic><p:nvPicPr><p:cNvPr id="${r}" name="${m}"/><p:cNvPicPr/><p:nvPr>${i}</p:nvPr></p:nvPicPr>
191
+ <p:blipFill>${d}<a:stretch><a:fillRect/></a:stretch></p:blipFill>
192
+ <p:spPr><a:xfrm/>${h}</p:spPr></p:pic>`,
193
+ namespaces: {
194
+ "xmlns:a": j,
195
+ "xmlns:p": _,
196
+ "xmlns:r": Ge
197
+ },
198
+ spids: { [String(r)]: r },
199
+ ...f.length ? { relationships: f } : {},
200
+ ...x.length ? { resources: x } : {}
201
+ };
202
+ }
203
+ const J = (a) => a.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), qe = {
204
+ anchor: "top",
205
+ insets: [4.8, 9.6, 4.8, 9.6],
206
+ wrap: !0,
207
+ fontScale: 1,
208
+ paragraphs: [{
209
+ align: "left",
210
+ lvl: 0,
211
+ marL: 0,
212
+ indent: 0,
213
+ bullet: null,
214
+ lineHeight: null,
215
+ spaceBefore: 0,
216
+ spaceAfter: 0,
217
+ runs: [{
218
+ text: "",
219
+ b: !1,
220
+ i: !1,
221
+ u: !1,
222
+ strike: !1,
223
+ size: 18,
224
+ color: "#000000",
225
+ fonts: []
226
+ }]
227
+ }]
228
+ };
229
+ function We(a, t, r) {
230
+ var s;
231
+ for (let e = 0; e <= t; e++)
232
+ for (let o = 0; o <= r; o++) {
233
+ const n = (s = a[e]) == null ? void 0 : s.cells[o];
234
+ if (!(n != null && n.merged) && e + n.rowSpan > t && o + n.colSpan > r) return { row: e, column: o };
235
+ }
236
+ return null;
237
+ }
238
+ function Ue(a, t, r, s) {
239
+ var f, x, g, b, I, k, u, y, w, S;
240
+ const e = a[t].cells[r], o = [];
241
+ if (!e.merged)
242
+ e.colSpan > 1 && o.push(`gridSpan="${e.colSpan}"`), e.rowSpan > 1 && o.push(`rowSpan="${e.rowSpan}"`);
243
+ else {
244
+ const L = We(a, t, r);
245
+ if (!L) throw new Error(`表格合并占位格缺少起始格:${t},${r}`);
246
+ r > L.column && o.push('hMerge="1"'), t > L.row && o.push('vMerge="1"');
247
+ }
248
+ const n = s ? (f = e.editInfo) == null ? void 0 : f.styleBase : void 0, l = (n == null ? void 0 : n.textTemplate) ?? (n == null ? void 0 : n.text), c = l == null ? void 0 : l.paragraphs[0], m = c == null ? void 0 : c.runs[0], i = (((x = c == null ? void 0 : c.editInfo) == null ? void 0 : x.directRun) ?? 0) | (((g = m == null ? void 0 : m.editInfo) == null ? void 0 : g.direct) ?? 0), d = n ? {
249
+ ...e,
250
+ fill: structuredClone(n.fill),
251
+ borders: structuredClone(n.borders),
252
+ text: structuredClone(n.text),
253
+ editInfo: {
254
+ ...e.editInfo,
255
+ ...n.textTemplate ? { textTemplate: structuredClone(n.textTemplate) } : {}
256
+ }
257
+ } : e, p = { color: "rgba(0,0,0,0.25)", width: 1, dash: null }, h = ue({
258
+ ...d,
259
+ ...!((b = d.editInfo) != null && b.textTemplate) && !((k = (I = d.text) == null ? void 0 : I.paragraphs[0]) != null && k.runs[0]) ? { editInfo: { textTemplate: qe } } : {},
260
+ ...n ? {} : { borders: {
261
+ l: ((u = e.borders) == null ? void 0 : u.l) === void 0 ? p : e.borders.l,
262
+ r: ((y = e.borders) == null ? void 0 : y.r) === void 0 ? p : e.borders.r,
263
+ t: ((w = e.borders) == null ? void 0 : w.t) === void 0 ? p : e.borders.t,
264
+ b: ((S = e.borders) == null ? void 0 : S.b) === void 0 ? p : e.borders.b
265
+ } }
266
+ }, n ? {
267
+ sparseAppearance: !0,
268
+ omitTextBold: !(i & H.b),
269
+ omitTextColor: !(i & H.color)
270
+ } : {});
271
+ return o.length ? h.replace("<a:tc>", `<a:tc ${o.join(" ")}>`) : h;
272
+ }
273
+ function Qe(a, t) {
274
+ var i, d;
275
+ const r = a.src;
276
+ if (r.kind !== "table") throw new Error(`元素 ${a.id} 不是表格`);
277
+ const s = r.colWidths.map((p) => `<a:gridCol w="${Math.round(p * 9525)}"/>`).join(""), e = !!((i = r.editInfo) != null && i.tableStyle), o = r.rows.map((p, h) => `<a:tr h="${Math.round(p.height * 9525)}">${p.cells.map((f, x) => Ue(r.rows, h, x, e)).join("")}</a:tr>`).join(""), n = J(r.name ?? `表格 ${t}`), l = (d = r.editInfo) == null ? void 0 : d.tableStyle, c = l ? [
278
+ "firstRow",
279
+ "lastRow",
280
+ "bandRow",
281
+ "firstCol",
282
+ "lastCol",
283
+ "bandCol"
284
+ ].filter((p) => l[p]).map((p) => `${p}="1"`).join(" ") : "", m = l ? `<a:tblPr${c ? ` ${c}` : ""}><a:tableStyleId>${J(l.styleId)}</a:tableStyleId></a:tblPr>` : "<a:tblPr/>";
285
+ return {
286
+ markup: `<p:graphicFrame><p:nvGraphicFramePr><p:cNvPr id="${t}" name="${n}"/><p:cNvGraphicFramePr/><p:nvPr/></p:nvGraphicFramePr>
287
+ <p:xfrm/><a:graphic><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/table"><a:tbl>
288
+ ${m}<a:tblGrid>${s}</a:tblGrid>${o}</a:tbl></a:graphicData></a:graphic></p:graphicFrame>`,
289
+ namespaces: { "xmlns:a": j, "xmlns:p": _ },
290
+ spids: { [String(t)]: t }
291
+ };
292
+ }
293
+ function Ye(a) {
294
+ var r;
295
+ const t = /* @__PURE__ */ new Map();
296
+ for (const s of Object.values(a.elements)) {
297
+ const e = s.src.kind === "table" ? (r = ne(a, s.id).editInfo) == null ? void 0 : r.tableStyle : void 0;
298
+ if (!e) continue;
299
+ const o = fe(a, s.id, e.styleId);
300
+ if (!o) throw new Error(`表格 ${s.id} 的样式定义不存在:${e.styleId}`);
301
+ t.set(o.styleId.toUpperCase(), o);
302
+ }
303
+ return [...t.values()];
304
+ }
305
+ const M = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
306
+ `, F = "http://schemas.openxmlformats.org/drawingml/2006/main", A = "http://schemas.openxmlformats.org/presentationml/2006/main", $ = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", Ve = "http://schemas.openxmlformats.org/package/2006/relationships", Ze = "http://schemas.openxmlformats.org/package/2006/content-types", Ke = new TextEncoder(), v = (a) => Ke.encode(a);
307
+ function P(a, t) {
308
+ const r = Math.round(a * 9525);
309
+ if (!Number.isSafeInteger(r)) throw new Error(`${t} 超出 OOXML 安全整数范围`);
310
+ return String(r);
311
+ }
312
+ const E = (a) => `${M}<Relationships xmlns="${Ve}">${a}</Relationships>`, D = `<p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>
313
+ <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>`;
314
+ function G(a, t, r, s, e) {
315
+ const o = `<p:ph type="${r}"${e === void 0 ? "" : ` idx="${e}"`}/>`;
316
+ return `<p:sp><p:nvSpPr><p:cNvPr id="${a}" name="${t}"/><p:cNvSpPr/><p:nvPr>${o}</p:nvPr></p:nvSpPr>
317
+ <p:spPr><a:xfrm><a:off x="${P(s.x, `${t} x`)}" y="${P(s.y, `${t} y`)}"/><a:ext cx="${P(s.w, `${t} 宽度`)}" cy="${P(s.h, `${t} 高度`)}"/></a:xfrm></p:spPr>
318
+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="zh-CN"/></a:p></p:txBody></p:sp>`;
319
+ }
320
+ function Je(a, t, r) {
321
+ return `<p:sp><p:nvSpPr><p:cNvPr id="${a}" name="页码"/><p:cNvSpPr/><p:nvPr><p:ph type="sldNum" idx="12"/></p:nvPr></p:nvSpPr>
322
+ <p:spPr><a:xfrm><a:off x="${P(r.x, "页码 x")}" y="${P(r.y, "页码 y")}"/><a:ext cx="${P(r.w, "页码宽度")}" cy="${P(r.h, "页码高度")}"/></a:xfrm></p:spPr>
323
+ <p:txBody><a:bodyPr anchor="ctr"/><a:lstStyle/><a:p><a:pPr algn="r"/><a:fld id="{00000000-0000-0000-0000-${String(t).padStart(12, "0")}}" type="slidenum"><a:rPr lang="zh-CN" sz="1100"/><a:t>1</a:t></a:fld><a:endParaRPr lang="zh-CN" sz="1100"/></a:p></p:txBody></p:sp>`;
324
+ }
325
+ function et(a, t) {
326
+ const r = a / 1280, s = t / 720, e = (n, l, c, m) => ({
327
+ x: n * r,
328
+ y: l * s,
329
+ w: c * r,
330
+ h: m * s
331
+ }), o = (n, l) => Je(n, l, e(1120, 662, 96, 34));
332
+ return [
333
+ {
334
+ part: 1,
335
+ type: "title",
336
+ name: "标题页",
337
+ shapes: G(2, "标题", "ctrTitle", e(120, 196, 1040, 154)) + G(3, "副标题", "subTitle", e(200, 374, 880, 92), 1) + o(4, 1)
338
+ },
339
+ {
340
+ part: 2,
341
+ type: "obj",
342
+ name: "标题和内容",
343
+ shapes: G(2, "标题", "title", e(80, 52, 1120, 92)) + G(3, "内容", "body", e(96, 166, 1088, 446), 1) + o(4, 2)
344
+ },
345
+ { part: 3, type: "blank", name: "空白", shapes: o(2, 3) }
346
+ ];
347
+ }
348
+ function ce(a, t, r = 0, s = []) {
349
+ const e = /* @__PURE__ */ Object.create(null), o = s.some(Boolean), n = Array.from({ length: r }, (m, i) => `<Override PartName="/ppt/slides/slide${i + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>`).join(`
350
+ `), l = s.map((m, i) => m ? `<Override PartName="/ppt/notesSlides/notesSlide${i + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml"/>` : "").filter(Boolean).join(`
351
+ `);
352
+ e["[Content_Types].xml"] = v(`${M}<Types xmlns="${Ze}">
353
+ <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
354
+ <Default Extension="xml" ContentType="application/xml"/>
355
+ <Override PartName="/ppt/presentation.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"/>
356
+ <Override PartName="/ppt/slideMasters/slideMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"/>
357
+ <Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>
358
+ <Override PartName="/ppt/slideLayouts/slideLayout2.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>
359
+ <Override PartName="/ppt/slideLayouts/slideLayout3.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>
360
+ <Override PartName="/ppt/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>
361
+ ${n}
362
+ ${l}
363
+ ${o ? '<Override PartName="/ppt/notesMasters/notesMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml"/>' : ""}
364
+ </Types>`), e["_rels/.rels"] = v(E(
365
+ `<Relationship Id="rId1" Type="${$}/officeDocument" Target="ppt/presentation.xml"/>`
366
+ )), e["ppt/presentation.xml"] = v(`${M}<p:presentation xmlns:a="${F}" xmlns:r="${$}" xmlns:p="${A}">
367
+ <p:sldMasterIdLst><p:sldMasterId id="2147483648" r:id="rId1"/></p:sldMasterIdLst>
368
+ ${o ? `<p:notesMasterIdLst><p:notesMasterId r:id="rId${r + 2}"/></p:notesMasterIdLst>` : ""}
369
+ <p:sldIdLst>${Array.from({ length: r }, (m, i) => `<p:sldId id="${256 + i}" r:id="rId${i + 2}"/>`).join("")}</p:sldIdLst>
370
+ <p:sldSz cx="${P(a, "页面宽度")}" cy="${P(t, "页面高度")}"/>
371
+ <p:notesSz cx="6858000" cy="9144000"/><p:defaultTextStyle/></p:presentation>`), e["ppt/_rels/presentation.xml.rels"] = v(E(
372
+ `<Relationship Id="rId1" Type="${$}/slideMaster" Target="slideMasters/slideMaster1.xml"/>` + Array.from({ length: r }, (m, i) => `<Relationship Id="rId${i + 2}" Type="${$}/slide" Target="slides/slide${i + 1}.xml"/>`).join("") + (o ? `<Relationship Id="rId${r + 2}" Type="${$}/notesMaster" Target="notesMasters/notesMaster1.xml"/>` : "")
373
+ )), e["ppt/theme/theme1.xml"] = v(`${M}<a:theme xmlns:a="${F}" name="Web PPT">
374
+ <a:themeElements><a:clrScheme name="Web PPT">
375
+ <a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1>
376
+ <a:dk2><a:srgbClr val="1F3864"/></a:dk2><a:lt2><a:srgbClr val="F2F2F2"/></a:lt2>
377
+ <a:accent1><a:srgbClr val="4472C4"/></a:accent1><a:accent2><a:srgbClr val="ED7D31"/></a:accent2>
378
+ <a:accent3><a:srgbClr val="A5A5A5"/></a:accent3><a:accent4><a:srgbClr val="FFC000"/></a:accent4>
379
+ <a:accent5><a:srgbClr val="5B9BD5"/></a:accent5><a:accent6><a:srgbClr val="70AD47"/></a:accent6>
380
+ <a:hlink><a:srgbClr val="0563C1"/></a:hlink><a:folHlink><a:srgbClr val="954F72"/></a:folHlink>
381
+ </a:clrScheme><a:fontScheme name="Web PPT">
382
+ <a:majorFont><a:latin typeface=""/><a:ea typeface=""/><a:cs typeface=""/></a:majorFont>
383
+ <a:minorFont><a:latin typeface=""/><a:ea typeface=""/><a:cs typeface=""/></a:minorFont>
384
+ </a:fontScheme><a:fmtScheme name="Web PPT">
385
+ <a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:fillStyleLst>
386
+ <a:lnStyleLst><a:ln w="6350"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln><a:ln w="12700"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln><a:ln w="19050"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln></a:lnStyleLst>
387
+ <a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle></a:effectStyleLst>
388
+ <a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:bgFillStyleLst>
389
+ </a:fmtScheme></a:themeElements></a:theme>`), e["ppt/slideMasters/slideMaster1.xml"] = v(`${M}<p:sldMaster xmlns:a="${F}" xmlns:r="${$}" xmlns:p="${A}">
390
+ <p:cSld><p:bg><p:bgPr><a:solidFill><a:srgbClr val="FFFFFF"/></a:solidFill><a:effectLst/></p:bgPr></p:bg><p:spTree>${D}</p:spTree></p:cSld>
391
+ <p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>
392
+ <p:sldLayoutIdLst><p:sldLayoutId id="2147483649" r:id="rId1"/><p:sldLayoutId id="2147483650" r:id="rId2"/><p:sldLayoutId id="2147483651" r:id="rId3"/></p:sldLayoutIdLst>
393
+ <p:txStyles><p:titleStyle/><p:bodyStyle/><p:otherStyle/></p:txStyles></p:sldMaster>`), e["ppt/slideMasters/_rels/slideMaster1.xml.rels"] = v(E(
394
+ `<Relationship Id="rId1" Type="${$}/slideLayout" Target="../slideLayouts/slideLayout1.xml"/><Relationship Id="rId2" Type="${$}/slideLayout" Target="../slideLayouts/slideLayout2.xml"/><Relationship Id="rId3" Type="${$}/slideLayout" Target="../slideLayouts/slideLayout3.xml"/><Relationship Id="rId4" Type="${$}/theme" Target="../theme/theme1.xml"/>`
395
+ ));
396
+ const c = et(a, t);
397
+ for (const m of c)
398
+ e[`ppt/slideLayouts/slideLayout${m.part}.xml`] = v(`${M}<p:sldLayout xmlns:a="${F}" xmlns:r="${$}" xmlns:p="${A}" type="${m.type}" showMasterSp="0">
399
+ <p:cSld name="${m.name}"><p:spTree>${D}${m.shapes}</p:spTree></p:cSld>
400
+ <p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:sldLayout>`), e[`ppt/slideLayouts/_rels/slideLayout${m.part}.xml.rels`] = v(E(
401
+ `<Relationship Id="rId1" Type="${$}/slideMaster" Target="../slideMasters/slideMaster1.xml"/>`
402
+ ));
403
+ o && (e["ppt/notesMasters/notesMaster1.xml"] = v(`${M}<p:notesMaster xmlns:a="${F}" xmlns:r="${$}" xmlns:p="${A}">
404
+ <p:cSld><p:spTree>${D}</p:spTree></p:cSld>
405
+ <p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>
406
+ <p:hf/><p:notesStyle/></p:notesMaster>`), e["ppt/notesMasters/_rels/notesMaster1.xml.rels"] = v(E(
407
+ `<Relationship Id="rId1" Type="${$}/theme" Target="../theme/theme1.xml"/>`
408
+ )));
409
+ for (let m = 0; m < r; m++)
410
+ e[`ppt/slides/slide${m + 1}.xml`] = v(me()), e[`ppt/slides/_rels/slide${m + 1}.xml.rels`] = v(E(
411
+ `<Relationship Id="rId1" Type="${$}/slideLayout" Target="../slideLayouts/slideLayout3.xml"/>`
412
+ ));
413
+ return e;
414
+ }
415
+ function me() {
416
+ return `${M}<p:sld xmlns:a="${F}" xmlns:r="${$}" xmlns:p="${A}">
417
+ <p:cSld><p:spTree>${D}</p:spTree></p:cSld>
418
+ <p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:sld>`;
419
+ }
420
+ const N = (a) => a.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), tt = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide", rt = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster", at = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
421
+ function ee(a, t, r, s = !1) {
422
+ if (!r) return;
423
+ if (r.warp) throw new Error("生成保存暂不支持艺术字变形");
424
+ for (const n of r.paragraphs) {
425
+ if (n.bulletImage) throw new Error("生成保存暂不支持图片项目符号");
426
+ for (const l of n.runs)
427
+ if (l.field || l.caps || l.outline || l.gradient || l.highlight || l.underlineColor || l.shadow || l.math)
428
+ throw new Error("生成保存暂不支持当前文字的高级字符语义");
429
+ }
430
+ const e = Pe(r), o = r.autoFitShape ? "shape" : r.autoFitNormal ? "normal" : "none";
431
+ return {
432
+ ...e,
433
+ bodyOverrides: {
434
+ anchor: r.anchor,
435
+ insets: r.insets,
436
+ wrap: r.wrap,
437
+ vert: r.vert ?? "horz",
438
+ anchorCtr: r.anchorCtr ?? !1,
439
+ columns: r.columns ?? 1,
440
+ columnGap: r.columnGap ?? 0,
441
+ autoFit: o
442
+ },
443
+ paragraphs: e.paragraphs.map((n, l) => ({
444
+ ...n,
445
+ sourceParagraph: void 0,
446
+ paragraphOverrides: {
447
+ align: n.props.align,
448
+ lineHeight: n.props.lineHeight,
449
+ spaceBefore: n.props.spaceBefore,
450
+ spaceAfter: n.props.spaceAfter,
451
+ marginLeft: n.props.marL,
452
+ indent: n.props.indent
453
+ },
454
+ marks: n.marks.map((c, m) => {
455
+ var h, f;
456
+ const i = r.paragraphs[l], d = i == null ? void 0 : i.runs[m], p = (((h = i == null ? void 0 : i.editInfo) == null ? void 0 : h.directRun) ?? 0) | (((f = d == null ? void 0 : d.editInfo) == null ? void 0 : f.direct) ?? 0);
457
+ return {
458
+ ...c,
459
+ source: void 0,
460
+ preserveSource: void 0,
461
+ // 生成包不再拥有原主题继承链;表样式控制的 b/color 只有真实直设才固定。
462
+ runOverrides: {
463
+ size: c.props.size,
464
+ ...!s || p & H.b ? { b: c.props.b } : {},
465
+ ...s && p & H.color ? { color: c.props.color } : {},
466
+ i: c.props.i,
467
+ u: c.props.u,
468
+ strike: c.props.strike,
469
+ ...c.props.link ? { link: pe(a, t, c.props.link, "文字链接") } : {}
470
+ }
471
+ };
472
+ })
473
+ }))
474
+ };
475
+ }
476
+ function st(a, t, r) {
477
+ const s = r.src, e = {
478
+ x: s.x,
479
+ y: s.y,
480
+ w: s.w,
481
+ h: s.h,
482
+ rot: s.rot,
483
+ flipH: s.flipH,
484
+ flipV: s.flipV,
485
+ ...s.name ? { name: s.name } : {},
486
+ ...s.effects ? { effects: s.effects } : {},
487
+ ...s.link && we(s.kind) ? { link: pe(a, t, s.link, `元素 ${r.id} 链接`) } : {}
488
+ };
489
+ if (s.kind === "shape") {
490
+ const o = ee(a, t, s.text);
491
+ return {
492
+ ...e,
493
+ ...s.fill && s.fill.type !== "image" ? { fill: s.fill } : {},
494
+ ...o ? { text: o } : {}
495
+ };
496
+ }
497
+ if (s.kind === "image")
498
+ return { ...e, ...s.crop ? { crop: s.crop } : {} };
499
+ if (s.kind === "table") {
500
+ const o = {};
501
+ return s.rows.forEach((n, l) => n.cells.forEach((c, m) => {
502
+ var d, p;
503
+ const i = !c.merged && ee(
504
+ a,
505
+ t,
506
+ c.text,
507
+ !!((d = s.editInfo) != null && d.tableStyle) && !!((p = c.editInfo) != null && p.styleBase)
508
+ );
509
+ i && (o[Se({ r: l, c: m })] = { text: i });
510
+ })), { ...e, ...Object.keys(o).length ? { tableCells: o } : {} };
511
+ }
512
+ return e;
513
+ }
514
+ function nt(a, t, r, s) {
515
+ var h;
516
+ const e = t.src;
517
+ if (e.kind !== "shape") throw new Error(`生成保存暂不支持元素类型:${e.kind}`);
518
+ const o = t.meta.geom, n = o == null ? void 0 : o.preset, l = Object.entries((o == null ? void 0 : o.adj) ?? {}).map(([f, x]) => {
519
+ if (!Number.isSafeInteger(Math.round(x))) throw new Error(`形状 ${t.id} 的几何调整值无效`);
520
+ return `<a:gd name="${N(f)}" fmla="val ${Math.round(x)}"/>`;
521
+ }).join(""), c = e.text ? "<p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr/></a:p></p:txBody>" : "", m = N(e.name ?? `形状 ${r}`), i = e.path === null, d = i ? "" : n ? `<a:prstGeom prst="${N(n)}"><a:avLst>${l}</a:avLst></a:prstGeom>` : ie(e.path, e.w, e.h, !!e.openGeom), p = ((h = e.fill) == null ? void 0 : h.type) === "image" ? X(a, e.fill, `rIdFill${r}`, s) : null;
522
+ if (p && !p.resource)
523
+ throw new Error(`形状 ${t.id} 的外链图片填充不能生成独立包`);
524
+ return {
525
+ markup: `<p:sp><p:nvSpPr><p:cNvPr id="${r}" name="${m}"/><p:cNvSpPr${i ? ' txBox="1"' : ""}/><p:nvPr/></p:nvSpPr>
526
+ <p:spPr><a:xfrm/>${d}</p:spPr>${c}</p:sp>`,
527
+ namespaces: { "xmlns:a": j, "xmlns:p": _ },
528
+ spids: { [String(r)]: r },
529
+ ...p ? { relationships: [p.relationship] } : {},
530
+ ...p != null && p.resource ? { resources: [p.resource] } : {}
531
+ };
532
+ }
533
+ function T(a, t) {
534
+ const r = Math.round(a * 9525);
535
+ if (!Number.isSafeInteger(r)) throw new Error(`组合 ${t} 超出 OOXML 安全整数范围`);
536
+ return String(r);
537
+ }
538
+ function ot(a, t) {
539
+ const r = a.src;
540
+ if (r.kind !== "group") throw new Error(`元素 ${a.id} 不是组合`);
541
+ const s = r.w / r.scaleX, e = r.h / r.scaleY, o = N(r.name ?? `组合 ${t}`);
542
+ return {
543
+ markup: `<p:grpSp><p:nvGrpSpPr><p:cNvPr id="${t}" name="${o}"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>
544
+ <p:grpSpPr><a:xfrm><a:off x="${T(r.x, "x")}" y="${T(r.y, "y")}"/>
545
+ <a:ext cx="${T(r.w, "w")}" cy="${T(r.h, "h")}"/>
546
+ <a:chOff x="${T(r.childX, "childX")}" y="${T(r.childY, "childY")}"/>
547
+ <a:chExt cx="${T(s, "childWidth")}" cy="${T(e, "childHeight")}"/>
548
+ </a:xfrm></p:grpSpPr></p:grpSp>`,
549
+ namespaces: { "xmlns:a": j, "xmlns:p": _ },
550
+ spids: { [String(t)]: t }
551
+ };
552
+ }
553
+ function lt(a, t, r, s) {
554
+ const e = t.src;
555
+ if (e.kind !== "unsupported") throw new Error(`元素 ${t.id} 不是框架占位`);
556
+ const o = N(e.name ?? `未支持对象 ${r}`), n = N(e.label).replace(/>/g, "&gt;"), l = e.preview ? X(a, { src: e.preview, name: e.name, id: e.id }, `rIdUnsupportedPreview${r}`, s) : null;
557
+ if (l && !l.resource) throw new Error(`框架占位 ${t.id} 的外链预览不能生成独立包`);
558
+ const c = l ? `<a:blipFill><a:blip r:embed="${l.relationship.targetId}"/><a:stretch><a:fillRect/></a:stretch></a:blipFill>` : '<a:solidFill><a:srgbClr val="F2F2F2"/></a:solidFill>';
559
+ return {
560
+ markup: `<p:sp><p:nvSpPr><p:cNvPr id="${r}" name="${o}"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>
561
+ <p:spPr><a:xfrm/><a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
562
+ ${c}<a:ln w="12700"><a:solidFill><a:srgbClr val="AAAAAA"/></a:solidFill><a:prstDash val="dash"/></a:ln></p:spPr>
563
+ <p:txBody><a:bodyPr anchor="ctr"/><a:lstStyle/><a:p><a:pPr algn="ctr"/><a:r><a:rPr lang="zh-CN" sz="1200"><a:solidFill><a:srgbClr val="777777"/></a:solidFill></a:rPr><a:t>${n}</a:t></a:r><a:endParaRPr lang="zh-CN"/></a:p></p:txBody></p:sp>`,
564
+ namespaces: {
565
+ "xmlns:a": j,
566
+ "xmlns:p": _,
567
+ ...l ? { "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships" } : {}
568
+ },
569
+ spids: { [String(r)]: r },
570
+ ...l ? { relationships: [l.relationship] } : {},
571
+ ...l != null && l.resource ? { resources: [l.resource] } : {}
572
+ };
573
+ }
574
+ function it(a, t, r, s) {
575
+ if (t.src.scene3d) throw new Error(`生成保存暂不支持三维元素:${t.id}`);
576
+ if (t.src.kind === "image" && t.src.filter)
577
+ throw new Error(`生成保存暂不支持图片滤镜:${t.id}`);
578
+ if (t.src.kind === "shape") return nt(a, t, r, s);
579
+ if (t.src.kind === "image") return Xe(a, t, r, s);
580
+ if (t.src.kind === "table") return Qe(t, r);
581
+ if (t.src.kind === "group") return ot(t, r);
582
+ if (t.src.kind === "unsupported") return lt(a, t, r, s);
583
+ const e = t.src;
584
+ throw new Error(`生成保存遇到未知元素类型:${String(e)}`);
585
+ }
586
+ function pt(a, t) {
587
+ const r = /* @__PURE__ */ new Set([1]), s = /* @__PURE__ */ new Map();
588
+ let e = 2;
589
+ const o = (n) => {
590
+ const l = a.elements[n].src.id;
591
+ let c = l && Number.isSafeInteger(l) && l > 1 && !r.has(l) ? l : 0;
592
+ for (; !c && r.has(e); ) e++;
593
+ c || (c = e++), r.add(c), s.set(n, c);
594
+ for (const m of a.elements[n].children ?? []) o(m);
595
+ };
596
+ for (const n of a.slides[t].children) o(n);
597
+ return s;
598
+ }
599
+ function ct(a, t, r, s) {
600
+ var k;
601
+ const e = `ppt/slides/slide${r + 1}.xml`, o = pt(a, t), n = /* @__PURE__ */ Object.create(null);
602
+ for (const [u, y] of Object.entries(a.elements)) {
603
+ if (!o.has(u)) continue;
604
+ const w = structuredClone(ne(a, u)), S = {
605
+ ...structuredClone(y),
606
+ src: w,
607
+ ovr: {},
608
+ meta: {
609
+ ...structuredClone(y.meta),
610
+ editable: "full",
611
+ created: !0,
612
+ inherited: void 0,
613
+ origin: { part: e, spid: o.get(u) }
614
+ }
615
+ };
616
+ S.meta.insertion = it(a, S, o.get(u), e), S.ovr = st(a, t, S), n[u] = S;
617
+ }
618
+ const l = structuredClone(a.slides[t]);
619
+ l.origin = { part: e };
620
+ const c = oe(a, t), m = c.background, i = (m == null ? void 0 : m.type) === "image" ? X(a, m, "rIdBackground", e) : null;
621
+ if (i && !i.resource)
622
+ throw new Error(`页面 ${t} 的外链图片背景不能生成独立包`);
623
+ if ((m == null ? void 0 : m.type) === "image" && (i != null && i.resource)) {
624
+ const u = Y(i.resource.hash);
625
+ l.backgroundImage = {
626
+ src: u,
627
+ relationships: [i.relationship],
628
+ resourceHash: i.resource.hash,
629
+ resourceHashes: [i.resource.hash],
630
+ imageRelationshipId: i.relationship.targetId
631
+ };
632
+ }
633
+ const d = xe(a, [t]).value, p = (m == null ? void 0 : m.type) === "image" && (i != null && i.resource) ? { ...m, src: Y(i.resource.hash) } : m;
634
+ l.ovr = {
635
+ ...p ? { background: p } : {},
636
+ hidden: !!c.hidden,
637
+ ...c.transition ? { transition: c.transition } : {},
638
+ ...d.length ? { animations: d } : {}
639
+ };
640
+ const h = Object.fromEntries(a.slideOrder.map((u, y) => {
641
+ const w = structuredClone(a.slides[u]);
642
+ return w.origin = { part: `ppt/slides/slide${y + 1}.xml` }, delete w.backgroundImage, [u, w];
643
+ }));
644
+ h[t] = l;
645
+ const f = {
646
+ ...structuredClone({ ...a, package: null }),
647
+ slides: h,
648
+ elements: n,
649
+ imageResources: {
650
+ ...structuredClone(a.imageResources),
651
+ ...i != null && i.resource ? { [i.resource.hash]: i.resource } : {}
652
+ },
653
+ removedElements: {},
654
+ package: null
655
+ }, x = [...l.children].sort((u, y) => V(n[u]).localeCompare(V(n[y])));
656
+ l.children = x;
657
+ const g = Me(me()), b = Object.values(n).flatMap((u) => {
658
+ var y;
659
+ return ((y = u.meta.insertion) == null ? void 0 : y.relationships) ?? [];
660
+ });
661
+ i && b.push(i.relationship);
662
+ const I = $e(f, e, s, b);
663
+ ye(g, f, e, x.map((u) => n[u]), [], { links: I }), Ae(g, f, l);
664
+ for (const u of Object.values(n))
665
+ u.src.kind === "shape" && ((k = u.src.fill) == null ? void 0 : k.type) === "image" && ve(g, u, u.src.fill, `rIdFill${o.get(u.id)}`), (u.src.kind === "shape" || u.src.kind === "image") && be(g, u, u.src.stroke ?? null);
666
+ return { bytes: ke(g), work: f, links: I };
667
+ }
668
+ function mt(a) {
669
+ const t = a.slideOrder.map((n) => oe(a, n)), r = a.slideOrder.map((n, l) => !!a.slides[n].notes || t[l].notes !== void 0), s = ce(
670
+ a.meta.width,
671
+ a.meta.height,
672
+ a.slideOrder.length,
673
+ r
674
+ ), e = Ye(a);
675
+ if (e.length) {
676
+ const n = "ppt/tableStyles.xml";
677
+ s[n] = Ce(void 0, e), s["[Content_Types].xml"] = Le(s["[Content_Types].xml"], n), s["ppt/_rels/presentation.xml.rels"] = Ee(
678
+ s["ppt/_rels/presentation.xml.rels"],
679
+ n
680
+ );
681
+ }
682
+ const o = /* @__PURE__ */ new Map();
683
+ a.slideOrder.forEach((n, l) => {
684
+ const c = `ppt/slides/slide${l + 1}.xml`, m = q(c), i = ct(a, n, l, s[m]);
685
+ s[c] = i.bytes;
686
+ const d = Fe(i.work);
687
+ for (const [p, h] of d.relationships) {
688
+ const f = q(p);
689
+ s[f] = p === c ? ge(
690
+ s[f],
691
+ h,
692
+ i.links,
693
+ i.bytes
694
+ ) : W(s[f], h);
695
+ }
696
+ for (const [p, h] of d.resources) {
697
+ const f = o.get(p);
698
+ if (f && f.hash !== h.hash) throw new Error(`生成媒体 part 冲突:${p}`);
699
+ o.set(p, h);
700
+ }
701
+ if (r[l]) {
702
+ const p = `ppt/notesSlides/notesSlide${l + 1}.xml`;
703
+ s[p] = Ne(t[l].notes ?? ""), s[q(p)] = W(void 0, [{
704
+ sourceId: "rId1",
705
+ targetId: "rId1",
706
+ type: rt,
707
+ target: B(p, "ppt/notesMasters/notesMaster1.xml")
708
+ }, {
709
+ sourceId: "rId2",
710
+ targetId: "rId2",
711
+ type: at,
712
+ target: B(p, c)
713
+ }]), s[m] = W(s[m], [{
714
+ sourceId: "rIdNotes",
715
+ targetId: "rIdNotes",
716
+ type: tt,
717
+ target: B(c, p)
718
+ }]);
719
+ }
720
+ });
721
+ for (const [n, l] of o) s[n] = Oe(l);
722
+ return s["[Content_Types].xml"] = Re(
723
+ s["[Content_Types].xml"],
724
+ [...o.values()]
725
+ ), s;
726
+ }
727
+ function yt(a = {}) {
728
+ const t = a.width ?? 1280, r = a.height ?? 720;
729
+ if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(r) || r <= 0)
730
+ throw new Error("页面宽高必须是有限正数");
731
+ const s = le(ce(t, r, 1));
732
+ return Te(s.package), s.bytes;
733
+ }
734
+ function vt(a) {
735
+ var t;
736
+ if (a.meta.readonly) throw new Error("只读编辑文档不能生成保存");
737
+ if (Ie((t = a.package) != null && t.disposed ? { ...a, meta: { ...a.meta, readonly: !0 }, package: null } : a), a.meta.source === "pptx" && a.package && !a.package.disposed)
738
+ throw new Error("存在可补丁原包时必须使用补丁保存");
739
+ return le(mt(a));
740
+ }
741
+ export {
742
+ yt as createBlankPptx,
743
+ vt as generateEditDoc
744
+ };