@web-ppt/edit-core 0.6.0 → 0.8.0-beta.1
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.
- package/CHANGELOG.md +16 -0
- package/README.md +8 -0
- package/dist/agent/base64.d.ts +2 -0
- package/dist/agent/errors.d.ts +9 -0
- package/dist/agent/generated-schema.d.ts +6038 -0
- package/dist/agent/generated-validator.d.ts +6 -0
- package/dist/agent/index.d.ts +6 -0
- package/dist/agent/query.d.ts +3 -0
- package/dist/agent/session.d.ts +33 -0
- package/dist/agent/targets.d.ts +5 -0
- package/dist/agent/tools.d.ts +2 -0
- package/dist/agent/types.d.ts +126 -0
- package/dist/agent/validation.d.ts +2 -0
- package/dist/agent.js +46364 -0
- package/dist/commands/types.d.ts +23 -23
- package/dist/fill/api.d.ts +29 -0
- package/dist/fill/chart-seed-chart.d.ts +7 -0
- package/dist/fill/chart-seed-workbook.d.ts +12 -0
- package/dist/fill/chart-seed-xml.d.ts +12 -0
- package/dist/fill/chart-seed.d.ts +17 -0
- package/dist/fill/content.d.ts +16 -0
- package/dist/fill/errors.d.ts +10 -0
- package/dist/fill/generated-schema.d.ts +291 -0
- package/dist/fill/generated-validator.d.ts +6 -0
- package/dist/fill/index.d.ts +10 -0
- package/dist/fill/layouts.d.ts +24 -0
- package/dist/fill/package.d.ts +2 -0
- package/dist/fill/repair.d.ts +32 -0
- package/dist/fill/text-validation.d.ts +3 -0
- package/dist/fill/types.d.ts +60 -0
- package/dist/fill/validation.d.ts +10 -0
- package/dist/fill.js +12 -0
- package/dist/generate.js +53 -53
- package/dist/index-2ti1e4_F.js +411 -0
- package/dist/index-BbsPmmoy.js +4046 -0
- package/dist/save/notes-master.d.ts +12 -0
- package/dist/save.js +650 -484
- package/dist/{slide-parts-D0o_DDhi.js → slide-parts-zyOP9lia.js} +5 -5
- package/dist/types.d.ts +4 -4
- package/package.json +13 -3
- package/schemas/agent-tools.schema.json +7999 -0
- package/schemas/template-fill.schema.json +371 -0
|
@@ -0,0 +1,4046 @@
|
|
|
1
|
+
import { sha256 as Rr, readImageMetadata as jr, findPlaceholderByIdentity as Wt, layoutText as Ur, fitTextShapeHeight as qr, parse as zr } from "@web-ppt/core";
|
|
2
|
+
import { sourcePartBytes as Dr, sourceElementXml as Lr, effectiveElement as W, queryTheme as dt, elementWorldBounds as ue, inverseTransformSpaceVector as Xt, elementParentToSlideMatrix as Bt, textPositionToIndex as ht, textPositionAtIndex as yt, transformSpacePoint as gt, elementFrameToParentMatrix as vt, createDoc as Zr, Editor as Wr, disposeDoc as Vt } from "@web-ppt/edit-core";
|
|
3
|
+
import { describePresentation as Ht } from "@web-ppt/edit-core/describe";
|
|
4
|
+
import { lintPresentation as me } from "@web-ppt/edit-core/lint";
|
|
5
|
+
import { serializeEditDoc as Xr } from "@web-ppt/edit-core/save";
|
|
6
|
+
import { patchOpcPackage as Br, disposeOpcPackage as Gt } from "@web-ppt/edit-core/opc";
|
|
7
|
+
import { xmlElementChildren as ae, parseXmlTree as oe, findXmlAttribute as se, setXmlAttribute as Yt, insertXmlChild as Ie, createXmlElement as Vr, createXmlText as Hr, serializeXmlTreeBytes as G, findXmlChild as wt } from "@web-ppt/edit-core/xml";
|
|
8
|
+
import { deflateSync as Kt, unzipSync as Qe } from "fflate";
|
|
9
|
+
const Gr = "http://schemas.openxmlformats.org/drawingml/2006/chart", Yr = "http://schemas.openxmlformats.org/drawingml/2006/main", Jt = "http://schemas.openxmlformats.org/presentationml/2006/main", Kr = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", Jr = "http://schemas.openxmlformats.org/package/2006/relationships", De = "http://purl.oclc.org/ooxml", Qr = `${De}/drawingml/chart`, es = `${De}/drawingml/main`, et = `${De}/presentationml/main`, ts = `${De}/officeDocument/relationships`, rs = Dr, bt = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
function ss(e) {
|
|
11
|
+
const t = e.lastIndexOf("/");
|
|
12
|
+
return `${e.slice(0, t + 1)}_rels/${e.slice(t + 1)}.rels`;
|
|
13
|
+
}
|
|
14
|
+
function ns(e, t) {
|
|
15
|
+
if (t.startsWith("/")) return t.slice(1);
|
|
16
|
+
const r = e.slice(0, e.lastIndexOf("/") + 1).split("/").filter(Boolean);
|
|
17
|
+
for (const s of t.split("/"))
|
|
18
|
+
s === ".." ? r.pop() : s && s !== "." && r.push(s);
|
|
19
|
+
return r.join("/");
|
|
20
|
+
}
|
|
21
|
+
function is(e, t) {
|
|
22
|
+
var n, a, c, h;
|
|
23
|
+
const r = rs(e, ss(t));
|
|
24
|
+
if (!r) return {};
|
|
25
|
+
let s = bt.get(r);
|
|
26
|
+
s || (s = /* @__PURE__ */ new Map(), bt.set(r, s));
|
|
27
|
+
const i = s.get(t);
|
|
28
|
+
if (i) return i;
|
|
29
|
+
const o = /* @__PURE__ */ Object.create(null);
|
|
30
|
+
for (const p of ae(oe(r).root, {
|
|
31
|
+
localName: "Relationship",
|
|
32
|
+
namespaceUri: Jr
|
|
33
|
+
})) {
|
|
34
|
+
const l = (n = se(p, { localName: "Id", namespaceUri: null })) == null ? void 0 : n.value, f = (a = se(p, { localName: "Type", namespaceUri: null })) == null ? void 0 : a.value, m = (c = se(p, { localName: "Target", namespaceUri: null })) == null ? void 0 : c.value, g = ((h = se(p, {
|
|
35
|
+
localName: "TargetMode",
|
|
36
|
+
namespaceUri: null
|
|
37
|
+
})) == null ? void 0 : h.value) === "External";
|
|
38
|
+
l && f && m && (o[l] = { type: f, target: g ? m : ns(t, m), ...g ? { external: !0 } : {} });
|
|
39
|
+
}
|
|
40
|
+
return s.set(t, o), o;
|
|
41
|
+
}
|
|
42
|
+
const xt = /* @__PURE__ */ new WeakMap(), ge = (e, t, r) => {
|
|
43
|
+
const s = e ? ae(e).filter((i) => i.localName === t && i.namespaceUri === r) : [];
|
|
44
|
+
return s.length === 1 ? s[0] : null;
|
|
45
|
+
}, Pt = (e, t, r = null) => {
|
|
46
|
+
var s;
|
|
47
|
+
return e ? ((s = se(e, { localName: t, namespaceUri: r })) == null ? void 0 : s.value) ?? null : null;
|
|
48
|
+
};
|
|
49
|
+
function os(e) {
|
|
50
|
+
const t = [], r = (s) => {
|
|
51
|
+
s.localName === "graphicFrame" && (s.namespaceUri === Jt || s.namespaceUri === et) ? t.push(s) : ae(s).forEach(r);
|
|
52
|
+
};
|
|
53
|
+
return r(e), t;
|
|
54
|
+
}
|
|
55
|
+
function as(e, t) {
|
|
56
|
+
var h;
|
|
57
|
+
let r = xt.get(e);
|
|
58
|
+
(!r || r.package !== e.package) && (r = { package: e.package, entries: /* @__PURE__ */ new Map() }, xt.set(e, r));
|
|
59
|
+
const s = r.entries;
|
|
60
|
+
if (s.has(t)) return s.get(t) ?? null;
|
|
61
|
+
const i = e.elements[t], o = i == null ? void 0 : i.meta.origin;
|
|
62
|
+
if (!i || i.src.kind !== "group" || i.meta.editable !== "frame" || !o)
|
|
63
|
+
return s.set(t, null), null;
|
|
64
|
+
const n = Lr(e, t);
|
|
65
|
+
if (!n)
|
|
66
|
+
return s.set(t, null), null;
|
|
67
|
+
let a = null;
|
|
68
|
+
const c = { ...is(e, n.part), ...n.relationships };
|
|
69
|
+
for (const p of os(oe(n.bytes).root)) {
|
|
70
|
+
const l = p.namespaceUri === et ? {
|
|
71
|
+
chart: Qr,
|
|
72
|
+
drawing: es,
|
|
73
|
+
presentation: et,
|
|
74
|
+
relationship: ts
|
|
75
|
+
} : {
|
|
76
|
+
chart: Gr,
|
|
77
|
+
drawing: Yr,
|
|
78
|
+
presentation: Jt,
|
|
79
|
+
relationship: Kr
|
|
80
|
+
}, f = ge(p, "nvGraphicFramePr", l.presentation), m = ge(f, "cNvPr", l.presentation), g = Pt(m, "id");
|
|
81
|
+
if (g === null || Number(g) !== o.spid) continue;
|
|
82
|
+
const u = ge(p, "graphic", l.drawing), d = ge(u, "graphicData", l.drawing);
|
|
83
|
+
if (Pt(d, "uri") !== l.chart) break;
|
|
84
|
+
const v = ge(d, "chart", l.chart), P = ((h = v == null ? void 0 : v.attributes.find((w) => w.localName === "id" && w.namespaceUri === l.relationship)) == null ? void 0 : h.value) ?? "", x = c[P];
|
|
85
|
+
x != null && x.type.endsWith("/chart") && (a = x.target);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
return s.set(t, a), a;
|
|
89
|
+
}
|
|
90
|
+
function ls(e) {
|
|
91
|
+
return [...Rr(e)].map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
92
|
+
}
|
|
93
|
+
function fs(e) {
|
|
94
|
+
const t = [];
|
|
95
|
+
for (let r = 0; r < e.length; r += 32768)
|
|
96
|
+
t.push(String.fromCharCode(...e.subarray(r, r + 32768)));
|
|
97
|
+
return btoa(t.join(""));
|
|
98
|
+
}
|
|
99
|
+
const cs = (e, t) => Object.prototype.hasOwnProperty.call(e, t);
|
|
100
|
+
function Qt(e, t, r) {
|
|
101
|
+
if (!e || typeof e != "object" || Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null)
|
|
102
|
+
throw new Error(`${r} 必须是纯数据对象`);
|
|
103
|
+
const s = Array.isArray(t) ? new Set(t) : t;
|
|
104
|
+
for (const i of Reflect.ownKeys(e)) {
|
|
105
|
+
const o = Object.getOwnPropertyDescriptor(e, i);
|
|
106
|
+
if (typeof i != "string" || !s.has(i) || !(o != null && o.enumerable) || !("value" in o))
|
|
107
|
+
throw new Error(`${r} 包含不可序列化或未知字段:${String(i)}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const _e = (e, t, r) => r.every((s, i) => e[t + i] === s), H = (e, t, r) => [...r].every((s, i) => e[t + i] === s.charCodeAt(0)), Se = (e, t) => e[t] * 256 + e[t + 1], Me = (e, t) => e[t] + e[t + 1] * 256, Xe = (e, t) => e[t] * 16777216 + e[t + 1] * 65536 + e[t + 2] * 256 + e[t + 3], Re = (e, t) => e[t] + e[t + 1] * 256 + e[t + 2] * 65536 + e[t + 3] * 16777216;
|
|
111
|
+
function us(e) {
|
|
112
|
+
if (e.length < 45 || !_e(e, 0, [137, 80, 78, 71, 13, 10, 26, 10])) return !1;
|
|
113
|
+
let t = 8, r = !0, s = !1;
|
|
114
|
+
for (; t + 12 <= e.length; ) {
|
|
115
|
+
const i = Xe(e, t);
|
|
116
|
+
if (i > e.length - t - 12 || r && (i !== 13 || !H(e, t + 4, "IHDR") || Xe(e, t + 8) === 0 || Xe(e, t + 12) === 0)) return !1;
|
|
117
|
+
const o = t + i + 12;
|
|
118
|
+
if (H(e, t + 4, "IDAT") && (s || (s = i > 0)), H(e, t + 4, "IEND"))
|
|
119
|
+
return s && i === 0 && o === e.length;
|
|
120
|
+
t = o, r = !1;
|
|
121
|
+
}
|
|
122
|
+
return !1;
|
|
123
|
+
}
|
|
124
|
+
function kt(e, t) {
|
|
125
|
+
let r = t;
|
|
126
|
+
for (; r < e.length; ) {
|
|
127
|
+
const s = e[r++];
|
|
128
|
+
if (s === 0) return r;
|
|
129
|
+
if (s > e.length - r) return -1;
|
|
130
|
+
r += s;
|
|
131
|
+
}
|
|
132
|
+
return -1;
|
|
133
|
+
}
|
|
134
|
+
function ps(e) {
|
|
135
|
+
if (e.length < 14 || !H(e, 0, "GIF87a") && !H(e, 0, "GIF89a") || Me(e, 6) === 0 || Me(e, 8) === 0) return !1;
|
|
136
|
+
const t = e[10];
|
|
137
|
+
let r = 13 + (t & 128 ? 3 * 2 ** ((t & 7) + 1) : 0), s = !1;
|
|
138
|
+
for (; r < e.length; ) {
|
|
139
|
+
const i = e[r++];
|
|
140
|
+
if (i === 59) return s && r === e.length;
|
|
141
|
+
if (i === 33) {
|
|
142
|
+
if (r >= e.length) return !1;
|
|
143
|
+
r = kt(e, r + 1);
|
|
144
|
+
} else if (i === 44) {
|
|
145
|
+
if (s = !0, r + 9 > e.length) return !1;
|
|
146
|
+
const o = e[r + 8];
|
|
147
|
+
if (r += 9 + (o & 128 ? 3 * 2 ** ((o & 7) + 1) : 0), r >= e.length) return !1;
|
|
148
|
+
r = kt(e, r + 1);
|
|
149
|
+
} else return !1;
|
|
150
|
+
if (r < 0) return !1;
|
|
151
|
+
}
|
|
152
|
+
return !1;
|
|
153
|
+
}
|
|
154
|
+
const ms = /* @__PURE__ */ new Set([
|
|
155
|
+
192,
|
|
156
|
+
193,
|
|
157
|
+
194,
|
|
158
|
+
195,
|
|
159
|
+
197,
|
|
160
|
+
198,
|
|
161
|
+
199,
|
|
162
|
+
201,
|
|
163
|
+
202,
|
|
164
|
+
203,
|
|
165
|
+
205,
|
|
166
|
+
206,
|
|
167
|
+
207
|
|
168
|
+
]);
|
|
169
|
+
function ds(e) {
|
|
170
|
+
if (e.length < 12 || !_e(e, 0, [255, 216]) || !_e(e, e.length - 2, [255, 217])) return !1;
|
|
171
|
+
let t = 2, r = !1;
|
|
172
|
+
for (; t < e.length - 2; ) {
|
|
173
|
+
if (e[t++] !== 255) continue;
|
|
174
|
+
for (; e[t] === 255; ) t++;
|
|
175
|
+
const s = e[t++];
|
|
176
|
+
if (s === 217) break;
|
|
177
|
+
if (s === 218) {
|
|
178
|
+
if (t + 2 > e.length) return !1;
|
|
179
|
+
const o = Se(e, t);
|
|
180
|
+
return r && o >= 6 && t + o < e.length - 2;
|
|
181
|
+
}
|
|
182
|
+
if (s === 1 || s >= 208 && s <= 215) continue;
|
|
183
|
+
if (t + 2 > e.length) return !1;
|
|
184
|
+
const i = Se(e, t);
|
|
185
|
+
if (i < 2 || t + i > e.length) return !1;
|
|
186
|
+
if (ms.has(s)) {
|
|
187
|
+
if (i < 7 || Se(e, t + 3) === 0 || Se(e, t + 5) === 0) return !1;
|
|
188
|
+
r = !0;
|
|
189
|
+
}
|
|
190
|
+
t += i;
|
|
191
|
+
}
|
|
192
|
+
return r;
|
|
193
|
+
}
|
|
194
|
+
function er(e, t, r, s) {
|
|
195
|
+
return H(e, t, "VP8L") ? s < 5 || e[r] !== 47 ? !1 : Re(e, r + 1) >>> 0 >>> 29 === 0 : H(e, t, "VP8 ") && s >= 10 && _e(e, r + 3, [157, 1, 42]) && (Me(e, r + 6) & 16383) > 0 && (Me(e, r + 8) & 16383) > 0;
|
|
196
|
+
}
|
|
197
|
+
function hs(e, t, r) {
|
|
198
|
+
let s = t;
|
|
199
|
+
for (; s + 8 <= r; ) {
|
|
200
|
+
const i = Re(e, s + 4), o = s + 8 + i + (i & 1);
|
|
201
|
+
if (o > r) return !1;
|
|
202
|
+
if (er(e, s, s + 8, i)) return !0;
|
|
203
|
+
s = o;
|
|
204
|
+
}
|
|
205
|
+
return !1;
|
|
206
|
+
}
|
|
207
|
+
function ys(e) {
|
|
208
|
+
if (e.length < 26 || !H(e, 0, "RIFF") || !H(e, 8, "WEBP") || Re(e, 4) + 8 !== e.length) return !1;
|
|
209
|
+
let t = 12, r = !1;
|
|
210
|
+
for (; t + 8 <= e.length; ) {
|
|
211
|
+
const s = Re(e, t + 4), i = t + 8, o = i + s + (s & 1);
|
|
212
|
+
if (o > e.length || H(e, t, "VP8X") && (t !== 12 || s !== 10)) return !1;
|
|
213
|
+
r || (r = er(e, t, i, s)), H(e, t, "ANMF") && (r || (r = s >= 16 && hs(e, i + 16, i + s))), t = o;
|
|
214
|
+
}
|
|
215
|
+
return t === e.length && r;
|
|
216
|
+
}
|
|
217
|
+
const tt = {
|
|
218
|
+
"image/png": { extension: "png", validate: us },
|
|
219
|
+
"image/jpeg": { extension: "jpg", validate: ds },
|
|
220
|
+
"image/gif": { extension: "gif", validate: ps },
|
|
221
|
+
"image/webp": { extension: "webp", validate: ys }
|
|
222
|
+
};
|
|
223
|
+
function gs(e) {
|
|
224
|
+
for (const [t, r] of Object.entries(tt))
|
|
225
|
+
if (r.validate(e)) return t;
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
function vs(e, t, r = "AddImage") {
|
|
229
|
+
if (typeof t != "string" || !cs(tt, t))
|
|
230
|
+
throw new Error(`${r}.mime 不支持:${String(t)}`);
|
|
231
|
+
const s = tt[t];
|
|
232
|
+
if (gs(e) !== t)
|
|
233
|
+
throw new Error(`${r}.bytes 与声明格式 ${t} 不一致或容器不完整`);
|
|
234
|
+
return { extension: s.extension };
|
|
235
|
+
}
|
|
236
|
+
function tr(e, t, r) {
|
|
237
|
+
if (!ArrayBuffer.isView(e) || Object.prototype.toString.call(e) !== "[object Uint8Array]")
|
|
238
|
+
throw new Error(`${t} 必须是 Uint8Array`);
|
|
239
|
+
const s = e;
|
|
240
|
+
if (!s.byteLength) throw new Error(`${t} 不能为空`);
|
|
241
|
+
return new Uint8Array(s.buffer.slice(s.byteOffset, s.byteOffset + s.byteLength));
|
|
242
|
+
}
|
|
243
|
+
function ws(e, t, r, s) {
|
|
244
|
+
const i = tr(e, `${r}.bytes`), o = vs(i, t, r);
|
|
245
|
+
return {
|
|
246
|
+
hash: ls(i),
|
|
247
|
+
mime: t,
|
|
248
|
+
extension: o.extension,
|
|
249
|
+
bytes: fs(i)
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
class E extends Error {
|
|
253
|
+
constructor(t, r, s = null, i = null, o = null, n) {
|
|
254
|
+
super(r), this.reason = t, this.slideNumber = s, this.field = i, this.elementId = o, this.lint = n, this.name = "TemplateFillError";
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function B(e) {
|
|
258
|
+
if (e != null && e.aborted) throw new E("aborted", "模板填充已取消");
|
|
259
|
+
}
|
|
260
|
+
class Tt extends Error {
|
|
261
|
+
constructor(t, r, s = null, i = null, o = null) {
|
|
262
|
+
super(r), this.reason = t, this.commandIndex = s, this.elementId = i, this.slideNumber = o, this.name = "AgentToolError";
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const bs = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
266
|
+
function xs(e, t) {
|
|
267
|
+
if (!bs.test(e))
|
|
268
|
+
throw new Tt("invalid-base64", `命令 ${t} 的图片字节不是规范 Base64`, t);
|
|
269
|
+
try {
|
|
270
|
+
return Uint8Array.from(atob(e), (r) => r.charCodeAt(0));
|
|
271
|
+
} catch {
|
|
272
|
+
throw new Tt("invalid-base64", `命令 ${t} 的图片字节无法解码`, t);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const Le = { properties: { level: { enum: [0, 1, 2, 3, 4, 5, 6, 7, 8] } } };
|
|
276
|
+
function q(e, { instancePath: t = "", parentData: r, parentDataProperty: s, rootData: i = e } = {}) {
|
|
277
|
+
let o = null, n = 0;
|
|
278
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
279
|
+
let p;
|
|
280
|
+
if (e.title === void 0 && (p = "title") || e.type === void 0 && (p = "type"))
|
|
281
|
+
return q.errors = [{ instancePath: t, schemaPath: "#/required", keyword: "required", params: { missingProperty: p }, message: "must have required property '" + p + "'" }], !1;
|
|
282
|
+
for (const l in e)
|
|
283
|
+
if (!(l === "title" || l === "notes" || l === "layoutId" || l === "type" || l === "body"))
|
|
284
|
+
return q.errors = [{ instancePath: t, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: l }, message: "must NOT have additional properties" }], !1;
|
|
285
|
+
{
|
|
286
|
+
if (e.title !== void 0) {
|
|
287
|
+
const l = n;
|
|
288
|
+
if (typeof e.title != "string")
|
|
289
|
+
return q.errors = [{ instancePath: t + "/title", schemaPath: "#/properties/title/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
290
|
+
var a = l === n;
|
|
291
|
+
} else
|
|
292
|
+
var a = !0;
|
|
293
|
+
if (a) {
|
|
294
|
+
if (e.notes !== void 0) {
|
|
295
|
+
const l = n;
|
|
296
|
+
if (typeof e.notes != "string")
|
|
297
|
+
return q.errors = [{ instancePath: t + "/notes", schemaPath: "#/properties/notes/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
298
|
+
var a = l === n;
|
|
299
|
+
} else
|
|
300
|
+
var a = !0;
|
|
301
|
+
if (a) {
|
|
302
|
+
if (e.layoutId !== void 0) {
|
|
303
|
+
const l = n;
|
|
304
|
+
if (typeof e.layoutId != "string")
|
|
305
|
+
return q.errors = [{ instancePath: t + "/layoutId", schemaPath: "#/properties/layoutId/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
306
|
+
var a = l === n;
|
|
307
|
+
} else
|
|
308
|
+
var a = !0;
|
|
309
|
+
if (a) {
|
|
310
|
+
if (e.type !== void 0) {
|
|
311
|
+
let l = e.type;
|
|
312
|
+
const f = n;
|
|
313
|
+
if (typeof l != "string")
|
|
314
|
+
return q.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
315
|
+
if (l !== "section")
|
|
316
|
+
return q.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/const", keyword: "const", params: { allowedValue: "section" }, message: "must be equal to constant" }], !1;
|
|
317
|
+
var a = f === n;
|
|
318
|
+
} else
|
|
319
|
+
var a = !0;
|
|
320
|
+
if (a)
|
|
321
|
+
if (e.body !== void 0) {
|
|
322
|
+
let l = e.body;
|
|
323
|
+
const f = n;
|
|
324
|
+
if (Array.isArray(l)) {
|
|
325
|
+
var c = !0;
|
|
326
|
+
const g = l.length;
|
|
327
|
+
for (let u = 0; u < g; u++) {
|
|
328
|
+
let d = l[u];
|
|
329
|
+
const v = n;
|
|
330
|
+
if (d && typeof d == "object" && !Array.isArray(d)) {
|
|
331
|
+
let x;
|
|
332
|
+
if (d.text === void 0 && (x = "text"))
|
|
333
|
+
return q.errors = [{ instancePath: t + "/body/" + u, schemaPath: "#/definitions/TemplateFillParagraph/required", keyword: "required", params: { missingProperty: x }, message: "must have required property '" + x + "'" }], !1;
|
|
334
|
+
for (const w in d)
|
|
335
|
+
if (!(w === "text" || w === "level" || w === "bullet"))
|
|
336
|
+
return q.errors = [{ instancePath: t + "/body/" + u, schemaPath: "#/definitions/TemplateFillParagraph/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: w }, message: "must NOT have additional properties" }], !1;
|
|
337
|
+
{
|
|
338
|
+
if (d.text !== void 0) {
|
|
339
|
+
const w = n;
|
|
340
|
+
if (typeof d.text != "string")
|
|
341
|
+
return q.errors = [{ instancePath: t + "/body/" + u + "/text", schemaPath: "#/definitions/TemplateFillParagraph/properties/text/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
342
|
+
var h = w === n;
|
|
343
|
+
} else
|
|
344
|
+
var h = !0;
|
|
345
|
+
if (h) {
|
|
346
|
+
if (d.level !== void 0) {
|
|
347
|
+
let w = d.level;
|
|
348
|
+
const k = n;
|
|
349
|
+
if (!(typeof w == "number" && isFinite(w)))
|
|
350
|
+
return q.errors = [{ instancePath: t + "/body/" + u + "/level", schemaPath: "#/definitions/TemplateFillParagraph/properties/level/type", keyword: "type", params: { type: "number" }, message: "must be number" }], !1;
|
|
351
|
+
if (!(w === 0 || w === 1 || w === 2 || w === 3 || w === 4 || w === 5 || w === 6 || w === 7 || w === 8))
|
|
352
|
+
return q.errors = [{ instancePath: t + "/body/" + u + "/level", schemaPath: "#/definitions/TemplateFillParagraph/properties/level/enum", keyword: "enum", params: { allowedValues: Le.properties.level.enum }, message: "must be equal to one of the allowed values" }], !1;
|
|
353
|
+
var h = k === n;
|
|
354
|
+
} else
|
|
355
|
+
var h = !0;
|
|
356
|
+
if (h)
|
|
357
|
+
if (d.bullet !== void 0) {
|
|
358
|
+
const w = n;
|
|
359
|
+
if (typeof d.bullet != "boolean")
|
|
360
|
+
return q.errors = [{ instancePath: t + "/body/" + u + "/bullet", schemaPath: "#/definitions/TemplateFillParagraph/properties/bullet/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }], !1;
|
|
361
|
+
var h = w === n;
|
|
362
|
+
} else
|
|
363
|
+
var h = !0;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
} else
|
|
367
|
+
return q.errors = [{ instancePath: t + "/body/" + u, schemaPath: "#/definitions/TemplateFillParagraph/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
368
|
+
var c = v === n;
|
|
369
|
+
if (!c)
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
} else
|
|
373
|
+
return q.errors = [{ instancePath: t + "/body", schemaPath: "#/properties/body/type", keyword: "type", params: { type: "array" }, message: "must be array" }], !1;
|
|
374
|
+
var a = f === n;
|
|
375
|
+
} else
|
|
376
|
+
var a = !0;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
} else
|
|
382
|
+
return q.errors = [{ instancePath: t, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
383
|
+
return q.errors = o, n === 0;
|
|
384
|
+
}
|
|
385
|
+
function j(e, { instancePath: t = "", parentData: r, parentDataProperty: s, rootData: i = e } = {}) {
|
|
386
|
+
let o = null, n = 0;
|
|
387
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
388
|
+
let p;
|
|
389
|
+
if (e.body === void 0 && (p = "body") || e.title === void 0 && (p = "title") || e.type === void 0 && (p = "type"))
|
|
390
|
+
return j.errors = [{ instancePath: t, schemaPath: "#/required", keyword: "required", params: { missingProperty: p }, message: "must have required property '" + p + "'" }], !1;
|
|
391
|
+
for (const l in e)
|
|
392
|
+
if (!(l === "title" || l === "notes" || l === "layoutId" || l === "type" || l === "body"))
|
|
393
|
+
return j.errors = [{ instancePath: t, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: l }, message: "must NOT have additional properties" }], !1;
|
|
394
|
+
{
|
|
395
|
+
if (e.title !== void 0) {
|
|
396
|
+
const l = n;
|
|
397
|
+
if (typeof e.title != "string")
|
|
398
|
+
return j.errors = [{ instancePath: t + "/title", schemaPath: "#/properties/title/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
399
|
+
var a = l === n;
|
|
400
|
+
} else
|
|
401
|
+
var a = !0;
|
|
402
|
+
if (a) {
|
|
403
|
+
if (e.notes !== void 0) {
|
|
404
|
+
const l = n;
|
|
405
|
+
if (typeof e.notes != "string")
|
|
406
|
+
return j.errors = [{ instancePath: t + "/notes", schemaPath: "#/properties/notes/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
407
|
+
var a = l === n;
|
|
408
|
+
} else
|
|
409
|
+
var a = !0;
|
|
410
|
+
if (a) {
|
|
411
|
+
if (e.layoutId !== void 0) {
|
|
412
|
+
const l = n;
|
|
413
|
+
if (typeof e.layoutId != "string")
|
|
414
|
+
return j.errors = [{ instancePath: t + "/layoutId", schemaPath: "#/properties/layoutId/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
415
|
+
var a = l === n;
|
|
416
|
+
} else
|
|
417
|
+
var a = !0;
|
|
418
|
+
if (a) {
|
|
419
|
+
if (e.type !== void 0) {
|
|
420
|
+
let l = e.type;
|
|
421
|
+
const f = n;
|
|
422
|
+
if (typeof l != "string")
|
|
423
|
+
return j.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
424
|
+
if (l !== "content")
|
|
425
|
+
return j.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/const", keyword: "const", params: { allowedValue: "content" }, message: "must be equal to constant" }], !1;
|
|
426
|
+
var a = f === n;
|
|
427
|
+
} else
|
|
428
|
+
var a = !0;
|
|
429
|
+
if (a)
|
|
430
|
+
if (e.body !== void 0) {
|
|
431
|
+
let l = e.body;
|
|
432
|
+
const f = n;
|
|
433
|
+
if (Array.isArray(l)) {
|
|
434
|
+
if (l.length < 1)
|
|
435
|
+
return j.errors = [{ instancePath: t + "/body", schemaPath: "#/properties/body/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" }], !1;
|
|
436
|
+
{
|
|
437
|
+
var c = !0;
|
|
438
|
+
const g = l.length;
|
|
439
|
+
for (let u = 0; u < g; u++) {
|
|
440
|
+
let d = l[u];
|
|
441
|
+
const v = n;
|
|
442
|
+
if (d && typeof d == "object" && !Array.isArray(d)) {
|
|
443
|
+
let x;
|
|
444
|
+
if (d.text === void 0 && (x = "text"))
|
|
445
|
+
return j.errors = [{ instancePath: t + "/body/" + u, schemaPath: "#/definitions/TemplateFillParagraph/required", keyword: "required", params: { missingProperty: x }, message: "must have required property '" + x + "'" }], !1;
|
|
446
|
+
for (const w in d)
|
|
447
|
+
if (!(w === "text" || w === "level" || w === "bullet"))
|
|
448
|
+
return j.errors = [{ instancePath: t + "/body/" + u, schemaPath: "#/definitions/TemplateFillParagraph/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: w }, message: "must NOT have additional properties" }], !1;
|
|
449
|
+
{
|
|
450
|
+
if (d.text !== void 0) {
|
|
451
|
+
const w = n;
|
|
452
|
+
if (typeof d.text != "string")
|
|
453
|
+
return j.errors = [{ instancePath: t + "/body/" + u + "/text", schemaPath: "#/definitions/TemplateFillParagraph/properties/text/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
454
|
+
var h = w === n;
|
|
455
|
+
} else
|
|
456
|
+
var h = !0;
|
|
457
|
+
if (h) {
|
|
458
|
+
if (d.level !== void 0) {
|
|
459
|
+
let w = d.level;
|
|
460
|
+
const k = n;
|
|
461
|
+
if (!(typeof w == "number" && isFinite(w)))
|
|
462
|
+
return j.errors = [{ instancePath: t + "/body/" + u + "/level", schemaPath: "#/definitions/TemplateFillParagraph/properties/level/type", keyword: "type", params: { type: "number" }, message: "must be number" }], !1;
|
|
463
|
+
if (!(w === 0 || w === 1 || w === 2 || w === 3 || w === 4 || w === 5 || w === 6 || w === 7 || w === 8))
|
|
464
|
+
return j.errors = [{ instancePath: t + "/body/" + u + "/level", schemaPath: "#/definitions/TemplateFillParagraph/properties/level/enum", keyword: "enum", params: { allowedValues: Le.properties.level.enum }, message: "must be equal to one of the allowed values" }], !1;
|
|
465
|
+
var h = k === n;
|
|
466
|
+
} else
|
|
467
|
+
var h = !0;
|
|
468
|
+
if (h)
|
|
469
|
+
if (d.bullet !== void 0) {
|
|
470
|
+
const w = n;
|
|
471
|
+
if (typeof d.bullet != "boolean")
|
|
472
|
+
return j.errors = [{ instancePath: t + "/body/" + u + "/bullet", schemaPath: "#/definitions/TemplateFillParagraph/properties/bullet/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }], !1;
|
|
473
|
+
var h = w === n;
|
|
474
|
+
} else
|
|
475
|
+
var h = !0;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
} else
|
|
479
|
+
return j.errors = [{ instancePath: t + "/body/" + u, schemaPath: "#/definitions/TemplateFillParagraph/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
480
|
+
var c = v === n;
|
|
481
|
+
if (!c)
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
} else
|
|
486
|
+
return j.errors = [{ instancePath: t + "/body", schemaPath: "#/properties/body/type", keyword: "type", params: { type: "array" }, message: "must be array" }], !1;
|
|
487
|
+
var a = f === n;
|
|
488
|
+
} else
|
|
489
|
+
var a = !0;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
} else
|
|
495
|
+
return j.errors = [{ instancePath: t, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
496
|
+
return j.errors = o, n === 0;
|
|
497
|
+
}
|
|
498
|
+
function M(e, { instancePath: t = "", parentData: r, parentDataProperty: s, rootData: i = e } = {}) {
|
|
499
|
+
let o = null, n = 0;
|
|
500
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
501
|
+
let l;
|
|
502
|
+
if (e.columns === void 0 && (l = "columns") || e.title === void 0 && (l = "title") || e.type === void 0 && (l = "type"))
|
|
503
|
+
return M.errors = [{ instancePath: t, schemaPath: "#/required", keyword: "required", params: { missingProperty: l }, message: "must have required property '" + l + "'" }], !1;
|
|
504
|
+
for (const f in e)
|
|
505
|
+
if (!(f === "title" || f === "notes" || f === "layoutId" || f === "type" || f === "columns"))
|
|
506
|
+
return M.errors = [{ instancePath: t, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: f }, message: "must NOT have additional properties" }], !1;
|
|
507
|
+
{
|
|
508
|
+
if (e.title !== void 0) {
|
|
509
|
+
const f = n;
|
|
510
|
+
if (typeof e.title != "string")
|
|
511
|
+
return M.errors = [{ instancePath: t + "/title", schemaPath: "#/properties/title/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
512
|
+
var a = f === n;
|
|
513
|
+
} else
|
|
514
|
+
var a = !0;
|
|
515
|
+
if (a) {
|
|
516
|
+
if (e.notes !== void 0) {
|
|
517
|
+
const f = n;
|
|
518
|
+
if (typeof e.notes != "string")
|
|
519
|
+
return M.errors = [{ instancePath: t + "/notes", schemaPath: "#/properties/notes/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
520
|
+
var a = f === n;
|
|
521
|
+
} else
|
|
522
|
+
var a = !0;
|
|
523
|
+
if (a) {
|
|
524
|
+
if (e.layoutId !== void 0) {
|
|
525
|
+
const f = n;
|
|
526
|
+
if (typeof e.layoutId != "string")
|
|
527
|
+
return M.errors = [{ instancePath: t + "/layoutId", schemaPath: "#/properties/layoutId/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
528
|
+
var a = f === n;
|
|
529
|
+
} else
|
|
530
|
+
var a = !0;
|
|
531
|
+
if (a) {
|
|
532
|
+
if (e.type !== void 0) {
|
|
533
|
+
let f = e.type;
|
|
534
|
+
const m = n;
|
|
535
|
+
if (typeof f != "string")
|
|
536
|
+
return M.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
537
|
+
if (f !== "two-column")
|
|
538
|
+
return M.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/const", keyword: "const", params: { allowedValue: "two-column" }, message: "must be equal to constant" }], !1;
|
|
539
|
+
var a = m === n;
|
|
540
|
+
} else
|
|
541
|
+
var a = !0;
|
|
542
|
+
if (a)
|
|
543
|
+
if (e.columns !== void 0) {
|
|
544
|
+
let f = e.columns;
|
|
545
|
+
const m = n;
|
|
546
|
+
if (Array.isArray(f)) {
|
|
547
|
+
if (f.length > 2)
|
|
548
|
+
return M.errors = [{ instancePath: t + "/columns", schemaPath: "#/properties/columns/maxItems", keyword: "maxItems", params: { limit: 2 }, message: "must NOT have more than 2 items" }], !1;
|
|
549
|
+
if (f.length < 2)
|
|
550
|
+
return M.errors = [{ instancePath: t + "/columns", schemaPath: "#/properties/columns/minItems", keyword: "minItems", params: { limit: 2 }, message: "must NOT have fewer than 2 items" }], !1;
|
|
551
|
+
{
|
|
552
|
+
var c = !0;
|
|
553
|
+
const u = f.length;
|
|
554
|
+
for (let d = 0; d < u; d++) {
|
|
555
|
+
let v = f[d];
|
|
556
|
+
const P = n;
|
|
557
|
+
if (Array.isArray(v)) {
|
|
558
|
+
var h = !0;
|
|
559
|
+
const w = v.length;
|
|
560
|
+
for (let k = 0; k < w; k++) {
|
|
561
|
+
let b = v[k];
|
|
562
|
+
const $ = n;
|
|
563
|
+
if (b && typeof b == "object" && !Array.isArray(b)) {
|
|
564
|
+
let C;
|
|
565
|
+
if (b.text === void 0 && (C = "text"))
|
|
566
|
+
return M.errors = [{ instancePath: t + "/columns/" + d + "/" + k, schemaPath: "#/definitions/TemplateFillParagraph/required", keyword: "required", params: { missingProperty: C }, message: "must have required property '" + C + "'" }], !1;
|
|
567
|
+
for (const A in b)
|
|
568
|
+
if (!(A === "text" || A === "level" || A === "bullet"))
|
|
569
|
+
return M.errors = [{ instancePath: t + "/columns/" + d + "/" + k, schemaPath: "#/definitions/TemplateFillParagraph/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: A }, message: "must NOT have additional properties" }], !1;
|
|
570
|
+
{
|
|
571
|
+
if (b.text !== void 0) {
|
|
572
|
+
const A = n;
|
|
573
|
+
if (typeof b.text != "string")
|
|
574
|
+
return M.errors = [{ instancePath: t + "/columns/" + d + "/" + k + "/text", schemaPath: "#/definitions/TemplateFillParagraph/properties/text/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
575
|
+
var p = A === n;
|
|
576
|
+
} else
|
|
577
|
+
var p = !0;
|
|
578
|
+
if (p) {
|
|
579
|
+
if (b.level !== void 0) {
|
|
580
|
+
let A = b.level;
|
|
581
|
+
const Z = n;
|
|
582
|
+
if (!(typeof A == "number" && isFinite(A)))
|
|
583
|
+
return M.errors = [{ instancePath: t + "/columns/" + d + "/" + k + "/level", schemaPath: "#/definitions/TemplateFillParagraph/properties/level/type", keyword: "type", params: { type: "number" }, message: "must be number" }], !1;
|
|
584
|
+
if (!(A === 0 || A === 1 || A === 2 || A === 3 || A === 4 || A === 5 || A === 6 || A === 7 || A === 8))
|
|
585
|
+
return M.errors = [{ instancePath: t + "/columns/" + d + "/" + k + "/level", schemaPath: "#/definitions/TemplateFillParagraph/properties/level/enum", keyword: "enum", params: { allowedValues: Le.properties.level.enum }, message: "must be equal to one of the allowed values" }], !1;
|
|
586
|
+
var p = Z === n;
|
|
587
|
+
} else
|
|
588
|
+
var p = !0;
|
|
589
|
+
if (p)
|
|
590
|
+
if (b.bullet !== void 0) {
|
|
591
|
+
const A = n;
|
|
592
|
+
if (typeof b.bullet != "boolean")
|
|
593
|
+
return M.errors = [{ instancePath: t + "/columns/" + d + "/" + k + "/bullet", schemaPath: "#/definitions/TemplateFillParagraph/properties/bullet/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }], !1;
|
|
594
|
+
var p = A === n;
|
|
595
|
+
} else
|
|
596
|
+
var p = !0;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
} else
|
|
600
|
+
return M.errors = [{ instancePath: t + "/columns/" + d + "/" + k, schemaPath: "#/definitions/TemplateFillParagraph/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
601
|
+
var h = $ === n;
|
|
602
|
+
if (!h)
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
} else
|
|
606
|
+
return M.errors = [{ instancePath: t + "/columns/" + d, schemaPath: "#/properties/columns/items/type", keyword: "type", params: { type: "array" }, message: "must be array" }], !1;
|
|
607
|
+
var c = P === n;
|
|
608
|
+
if (!c)
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
} else
|
|
613
|
+
return M.errors = [{ instancePath: t + "/columns", schemaPath: "#/properties/columns/type", keyword: "type", params: { type: "array" }, message: "must be array" }], !1;
|
|
614
|
+
var a = m === n;
|
|
615
|
+
} else
|
|
616
|
+
var a = !0;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
} else
|
|
622
|
+
return M.errors = [{ instancePath: t, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
623
|
+
return M.errors = o, n === 0;
|
|
624
|
+
}
|
|
625
|
+
const It = { properties: { mime: { enum: ["image/png", "image/jpeg", "image/gif", "image/webp"] }, fit: { enum: ["contain", "cover"] } } };
|
|
626
|
+
function F(e, { instancePath: t = "", parentData: r, parentDataProperty: s, rootData: i = e } = {}) {
|
|
627
|
+
let o = null, n = 0;
|
|
628
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
629
|
+
let l;
|
|
630
|
+
if (e.image === void 0 && (l = "image") || e.title === void 0 && (l = "title") || e.type === void 0 && (l = "type"))
|
|
631
|
+
return F.errors = [{ instancePath: t, schemaPath: "#/required", keyword: "required", params: { missingProperty: l }, message: "must have required property '" + l + "'" }], !1;
|
|
632
|
+
for (const f in e)
|
|
633
|
+
if (!(f === "title" || f === "notes" || f === "layoutId" || f === "type" || f === "image" || f === "body"))
|
|
634
|
+
return F.errors = [{ instancePath: t, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: f }, message: "must NOT have additional properties" }], !1;
|
|
635
|
+
{
|
|
636
|
+
if (e.title !== void 0) {
|
|
637
|
+
const f = n;
|
|
638
|
+
if (typeof e.title != "string")
|
|
639
|
+
return F.errors = [{ instancePath: t + "/title", schemaPath: "#/properties/title/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
640
|
+
var a = f === n;
|
|
641
|
+
} else
|
|
642
|
+
var a = !0;
|
|
643
|
+
if (a) {
|
|
644
|
+
if (e.notes !== void 0) {
|
|
645
|
+
const f = n;
|
|
646
|
+
if (typeof e.notes != "string")
|
|
647
|
+
return F.errors = [{ instancePath: t + "/notes", schemaPath: "#/properties/notes/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
648
|
+
var a = f === n;
|
|
649
|
+
} else
|
|
650
|
+
var a = !0;
|
|
651
|
+
if (a) {
|
|
652
|
+
if (e.layoutId !== void 0) {
|
|
653
|
+
const f = n;
|
|
654
|
+
if (typeof e.layoutId != "string")
|
|
655
|
+
return F.errors = [{ instancePath: t + "/layoutId", schemaPath: "#/properties/layoutId/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
656
|
+
var a = f === n;
|
|
657
|
+
} else
|
|
658
|
+
var a = !0;
|
|
659
|
+
if (a) {
|
|
660
|
+
if (e.type !== void 0) {
|
|
661
|
+
let f = e.type;
|
|
662
|
+
const m = n;
|
|
663
|
+
if (typeof f != "string")
|
|
664
|
+
return F.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
665
|
+
if (f !== "image")
|
|
666
|
+
return F.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/const", keyword: "const", params: { allowedValue: "image" }, message: "must be equal to constant" }], !1;
|
|
667
|
+
var a = m === n;
|
|
668
|
+
} else
|
|
669
|
+
var a = !0;
|
|
670
|
+
if (a) {
|
|
671
|
+
if (e.image !== void 0) {
|
|
672
|
+
let f = e.image;
|
|
673
|
+
const m = n;
|
|
674
|
+
if (f && typeof f == "object" && !Array.isArray(f)) {
|
|
675
|
+
let u;
|
|
676
|
+
if (f.bytes === void 0 && (u = "bytes") || f.mime === void 0 && (u = "mime"))
|
|
677
|
+
return F.errors = [{ instancePath: t + "/image", schemaPath: "#/definitions/TemplateFillImage/required", keyword: "required", params: { missingProperty: u }, message: "must have required property '" + u + "'" }], !1;
|
|
678
|
+
for (const d in f)
|
|
679
|
+
if (!(d === "bytes" || d === "mime" || d === "altText" || d === "fit"))
|
|
680
|
+
return F.errors = [{ instancePath: t + "/image", schemaPath: "#/definitions/TemplateFillImage/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: d }, message: "must NOT have additional properties" }], !1;
|
|
681
|
+
{
|
|
682
|
+
if (f.bytes !== void 0) {
|
|
683
|
+
const d = n;
|
|
684
|
+
if (typeof f.bytes != "string")
|
|
685
|
+
return F.errors = [{ instancePath: t + "/image/bytes", schemaPath: "#/definitions/TemplateFillImage/properties/bytes/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
686
|
+
var c = d === n;
|
|
687
|
+
} else
|
|
688
|
+
var c = !0;
|
|
689
|
+
if (c) {
|
|
690
|
+
if (f.mime !== void 0) {
|
|
691
|
+
let d = f.mime;
|
|
692
|
+
const v = n;
|
|
693
|
+
if (typeof d != "string")
|
|
694
|
+
return F.errors = [{ instancePath: t + "/image/mime", schemaPath: "#/definitions/TemplateFillImage/properties/mime/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
695
|
+
if (!(d === "image/png" || d === "image/jpeg" || d === "image/gif" || d === "image/webp"))
|
|
696
|
+
return F.errors = [{ instancePath: t + "/image/mime", schemaPath: "#/definitions/TemplateFillImage/properties/mime/enum", keyword: "enum", params: { allowedValues: It.properties.mime.enum }, message: "must be equal to one of the allowed values" }], !1;
|
|
697
|
+
var c = v === n;
|
|
698
|
+
} else
|
|
699
|
+
var c = !0;
|
|
700
|
+
if (c) {
|
|
701
|
+
if (f.altText !== void 0) {
|
|
702
|
+
const d = n;
|
|
703
|
+
if (typeof f.altText != "string")
|
|
704
|
+
return F.errors = [{ instancePath: t + "/image/altText", schemaPath: "#/definitions/TemplateFillImage/properties/altText/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
705
|
+
var c = d === n;
|
|
706
|
+
} else
|
|
707
|
+
var c = !0;
|
|
708
|
+
if (c)
|
|
709
|
+
if (f.fit !== void 0) {
|
|
710
|
+
let d = f.fit;
|
|
711
|
+
const v = n;
|
|
712
|
+
if (typeof d != "string")
|
|
713
|
+
return F.errors = [{ instancePath: t + "/image/fit", schemaPath: "#/definitions/TemplateFillImage/properties/fit/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
714
|
+
if (!(d === "contain" || d === "cover"))
|
|
715
|
+
return F.errors = [{ instancePath: t + "/image/fit", schemaPath: "#/definitions/TemplateFillImage/properties/fit/enum", keyword: "enum", params: { allowedValues: It.properties.fit.enum }, message: "must be equal to one of the allowed values" }], !1;
|
|
716
|
+
var c = v === n;
|
|
717
|
+
} else
|
|
718
|
+
var c = !0;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
} else
|
|
723
|
+
return F.errors = [{ instancePath: t + "/image", schemaPath: "#/definitions/TemplateFillImage/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
724
|
+
var a = m === n;
|
|
725
|
+
} else
|
|
726
|
+
var a = !0;
|
|
727
|
+
if (a)
|
|
728
|
+
if (e.body !== void 0) {
|
|
729
|
+
let f = e.body;
|
|
730
|
+
const m = n;
|
|
731
|
+
if (Array.isArray(f)) {
|
|
732
|
+
var h = !0;
|
|
733
|
+
const u = f.length;
|
|
734
|
+
for (let d = 0; d < u; d++) {
|
|
735
|
+
let v = f[d];
|
|
736
|
+
const P = n;
|
|
737
|
+
if (v && typeof v == "object" && !Array.isArray(v)) {
|
|
738
|
+
let w;
|
|
739
|
+
if (v.text === void 0 && (w = "text"))
|
|
740
|
+
return F.errors = [{ instancePath: t + "/body/" + d, schemaPath: "#/definitions/TemplateFillParagraph/required", keyword: "required", params: { missingProperty: w }, message: "must have required property '" + w + "'" }], !1;
|
|
741
|
+
for (const k in v)
|
|
742
|
+
if (!(k === "text" || k === "level" || k === "bullet"))
|
|
743
|
+
return F.errors = [{ instancePath: t + "/body/" + d, schemaPath: "#/definitions/TemplateFillParagraph/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: k }, message: "must NOT have additional properties" }], !1;
|
|
744
|
+
{
|
|
745
|
+
if (v.text !== void 0) {
|
|
746
|
+
const k = n;
|
|
747
|
+
if (typeof v.text != "string")
|
|
748
|
+
return F.errors = [{ instancePath: t + "/body/" + d + "/text", schemaPath: "#/definitions/TemplateFillParagraph/properties/text/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
749
|
+
var p = k === n;
|
|
750
|
+
} else
|
|
751
|
+
var p = !0;
|
|
752
|
+
if (p) {
|
|
753
|
+
if (v.level !== void 0) {
|
|
754
|
+
let k = v.level;
|
|
755
|
+
const b = n;
|
|
756
|
+
if (!(typeof k == "number" && isFinite(k)))
|
|
757
|
+
return F.errors = [{ instancePath: t + "/body/" + d + "/level", schemaPath: "#/definitions/TemplateFillParagraph/properties/level/type", keyword: "type", params: { type: "number" }, message: "must be number" }], !1;
|
|
758
|
+
if (!(k === 0 || k === 1 || k === 2 || k === 3 || k === 4 || k === 5 || k === 6 || k === 7 || k === 8))
|
|
759
|
+
return F.errors = [{ instancePath: t + "/body/" + d + "/level", schemaPath: "#/definitions/TemplateFillParagraph/properties/level/enum", keyword: "enum", params: { allowedValues: Le.properties.level.enum }, message: "must be equal to one of the allowed values" }], !1;
|
|
760
|
+
var p = b === n;
|
|
761
|
+
} else
|
|
762
|
+
var p = !0;
|
|
763
|
+
if (p)
|
|
764
|
+
if (v.bullet !== void 0) {
|
|
765
|
+
const k = n;
|
|
766
|
+
if (typeof v.bullet != "boolean")
|
|
767
|
+
return F.errors = [{ instancePath: t + "/body/" + d + "/bullet", schemaPath: "#/definitions/TemplateFillParagraph/properties/bullet/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }], !1;
|
|
768
|
+
var p = k === n;
|
|
769
|
+
} else
|
|
770
|
+
var p = !0;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
} else
|
|
774
|
+
return F.errors = [{ instancePath: t + "/body/" + d, schemaPath: "#/definitions/TemplateFillParagraph/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
775
|
+
var h = P === n;
|
|
776
|
+
if (!h)
|
|
777
|
+
break;
|
|
778
|
+
}
|
|
779
|
+
} else
|
|
780
|
+
return F.errors = [{ instancePath: t + "/body", schemaPath: "#/properties/body/type", keyword: "type", params: { type: "array" }, message: "must be array" }], !1;
|
|
781
|
+
var a = m === n;
|
|
782
|
+
} else
|
|
783
|
+
var a = !0;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
} else
|
|
790
|
+
return F.errors = [{ instancePath: t, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
791
|
+
return F.errors = o, n === 0;
|
|
792
|
+
}
|
|
793
|
+
const Ps = { properties: { type: { enum: ["bar", "line", "pie", "doughnut", "area", "scatter", "radar", "bubble"] } } }, Be = { properties: { values: { items: { type: ["number", "null"] } }, x: { items: { type: ["number", "null"] } }, sizes: { items: { type: ["number", "null"] } } } };
|
|
794
|
+
function R(e, { instancePath: t = "", parentData: r, parentDataProperty: s, rootData: i = e } = {}) {
|
|
795
|
+
let o = null, n = 0;
|
|
796
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
797
|
+
let g;
|
|
798
|
+
if (e.type === void 0 && (g = "type") || e.categories === void 0 && (g = "categories") || e.series === void 0 && (g = "series"))
|
|
799
|
+
return R.errors = [{ instancePath: t, schemaPath: "#/required", keyword: "required", params: { missingProperty: g }, message: "must have required property '" + g + "'" }], !1;
|
|
800
|
+
for (const u in e)
|
|
801
|
+
if (!(u === "type" || u === "categories" || u === "series" || u === "title"))
|
|
802
|
+
return R.errors = [{ instancePath: t, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: u }, message: "must NOT have additional properties" }], !1;
|
|
803
|
+
{
|
|
804
|
+
if (e.type !== void 0) {
|
|
805
|
+
let u = e.type;
|
|
806
|
+
const d = n;
|
|
807
|
+
if (typeof u != "string")
|
|
808
|
+
return R.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
809
|
+
if (!(u === "bar" || u === "line" || u === "pie" || u === "doughnut" || u === "area" || u === "scatter" || u === "radar" || u === "bubble"))
|
|
810
|
+
return R.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/enum", keyword: "enum", params: { allowedValues: Ps.properties.type.enum }, message: "must be equal to one of the allowed values" }], !1;
|
|
811
|
+
var a = d === n;
|
|
812
|
+
} else
|
|
813
|
+
var a = !0;
|
|
814
|
+
if (a) {
|
|
815
|
+
if (e.categories !== void 0) {
|
|
816
|
+
let u = e.categories;
|
|
817
|
+
const d = n;
|
|
818
|
+
if (Array.isArray(u)) {
|
|
819
|
+
var c = !0;
|
|
820
|
+
const P = u.length;
|
|
821
|
+
for (let x = 0; x < P; x++) {
|
|
822
|
+
const w = n;
|
|
823
|
+
if (typeof u[x] != "string")
|
|
824
|
+
return R.errors = [{ instancePath: t + "/categories/" + x, schemaPath: "#/properties/categories/items/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
825
|
+
var c = w === n;
|
|
826
|
+
if (!c)
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
829
|
+
} else
|
|
830
|
+
return R.errors = [{ instancePath: t + "/categories", schemaPath: "#/properties/categories/type", keyword: "type", params: { type: "array" }, message: "must be array" }], !1;
|
|
831
|
+
var a = d === n;
|
|
832
|
+
} else
|
|
833
|
+
var a = !0;
|
|
834
|
+
if (a) {
|
|
835
|
+
if (e.series !== void 0) {
|
|
836
|
+
let u = e.series;
|
|
837
|
+
const d = n;
|
|
838
|
+
if (Array.isArray(u)) {
|
|
839
|
+
var h = !0;
|
|
840
|
+
const P = u.length;
|
|
841
|
+
for (let x = 0; x < P; x++) {
|
|
842
|
+
let w = u[x];
|
|
843
|
+
const k = n;
|
|
844
|
+
if (w && typeof w == "object" && !Array.isArray(w)) {
|
|
845
|
+
let $;
|
|
846
|
+
if (w.name === void 0 && ($ = "name") || w.values === void 0 && ($ = "values"))
|
|
847
|
+
return R.errors = [{ instancePath: t + "/series/" + x, schemaPath: "#/definitions/TemplateFillChartSeries/required", keyword: "required", params: { missingProperty: $ }, message: "must have required property '" + $ + "'" }], !1;
|
|
848
|
+
for (const I in w)
|
|
849
|
+
if (!(I === "name" || I === "values" || I === "x" || I === "sizes"))
|
|
850
|
+
return R.errors = [{ instancePath: t + "/series/" + x, schemaPath: "#/definitions/TemplateFillChartSeries/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: I }, message: "must NOT have additional properties" }], !1;
|
|
851
|
+
{
|
|
852
|
+
if (w.name !== void 0) {
|
|
853
|
+
const I = n;
|
|
854
|
+
if (typeof w.name != "string")
|
|
855
|
+
return R.errors = [{ instancePath: t + "/series/" + x + "/name", schemaPath: "#/definitions/TemplateFillChartSeries/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
856
|
+
var p = I === n;
|
|
857
|
+
} else
|
|
858
|
+
var p = !0;
|
|
859
|
+
if (p) {
|
|
860
|
+
if (w.values !== void 0) {
|
|
861
|
+
let I = w.values;
|
|
862
|
+
const C = n;
|
|
863
|
+
if (Array.isArray(I)) {
|
|
864
|
+
var l = !0;
|
|
865
|
+
const Z = I.length;
|
|
866
|
+
for (let _ = 0; _ < Z; _++) {
|
|
867
|
+
let L = I[_];
|
|
868
|
+
const T = n;
|
|
869
|
+
if (!(typeof L == "number" && isFinite(L)) && L !== null)
|
|
870
|
+
return R.errors = [{ instancePath: t + "/series/" + x + "/values/" + _, schemaPath: "#/definitions/TemplateFillChartSeries/properties/values/items/type", keyword: "type", params: { type: Be.properties.values.items.type }, message: "must be number,null" }], !1;
|
|
871
|
+
var l = T === n;
|
|
872
|
+
if (!l)
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
} else
|
|
876
|
+
return R.errors = [{ instancePath: t + "/series/" + x + "/values", schemaPath: "#/definitions/TemplateFillChartSeries/properties/values/type", keyword: "type", params: { type: "array" }, message: "must be array" }], !1;
|
|
877
|
+
var p = C === n;
|
|
878
|
+
} else
|
|
879
|
+
var p = !0;
|
|
880
|
+
if (p) {
|
|
881
|
+
if (w.x !== void 0) {
|
|
882
|
+
let I = w.x;
|
|
883
|
+
const C = n;
|
|
884
|
+
if (Array.isArray(I)) {
|
|
885
|
+
var f = !0;
|
|
886
|
+
const Z = I.length;
|
|
887
|
+
for (let _ = 0; _ < Z; _++) {
|
|
888
|
+
let L = I[_];
|
|
889
|
+
const T = n;
|
|
890
|
+
if (!(typeof L == "number" && isFinite(L)) && L !== null)
|
|
891
|
+
return R.errors = [{ instancePath: t + "/series/" + x + "/x/" + _, schemaPath: "#/definitions/TemplateFillChartSeries/properties/x/items/type", keyword: "type", params: { type: Be.properties.x.items.type }, message: "must be number,null" }], !1;
|
|
892
|
+
var f = T === n;
|
|
893
|
+
if (!f)
|
|
894
|
+
break;
|
|
895
|
+
}
|
|
896
|
+
} else
|
|
897
|
+
return R.errors = [{ instancePath: t + "/series/" + x + "/x", schemaPath: "#/definitions/TemplateFillChartSeries/properties/x/type", keyword: "type", params: { type: "array" }, message: "must be array" }], !1;
|
|
898
|
+
var p = C === n;
|
|
899
|
+
} else
|
|
900
|
+
var p = !0;
|
|
901
|
+
if (p)
|
|
902
|
+
if (w.sizes !== void 0) {
|
|
903
|
+
let I = w.sizes;
|
|
904
|
+
const C = n;
|
|
905
|
+
if (Array.isArray(I)) {
|
|
906
|
+
var m = !0;
|
|
907
|
+
const Z = I.length;
|
|
908
|
+
for (let _ = 0; _ < Z; _++) {
|
|
909
|
+
let L = I[_];
|
|
910
|
+
const T = n;
|
|
911
|
+
if (!(typeof L == "number" && isFinite(L)) && L !== null)
|
|
912
|
+
return R.errors = [{ instancePath: t + "/series/" + x + "/sizes/" + _, schemaPath: "#/definitions/TemplateFillChartSeries/properties/sizes/items/type", keyword: "type", params: { type: Be.properties.sizes.items.type }, message: "must be number,null" }], !1;
|
|
913
|
+
var m = T === n;
|
|
914
|
+
if (!m)
|
|
915
|
+
break;
|
|
916
|
+
}
|
|
917
|
+
} else
|
|
918
|
+
return R.errors = [{ instancePath: t + "/series/" + x + "/sizes", schemaPath: "#/definitions/TemplateFillChartSeries/properties/sizes/type", keyword: "type", params: { type: "array" }, message: "must be array" }], !1;
|
|
919
|
+
var p = C === n;
|
|
920
|
+
} else
|
|
921
|
+
var p = !0;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
} else
|
|
926
|
+
return R.errors = [{ instancePath: t + "/series/" + x, schemaPath: "#/definitions/TemplateFillChartSeries/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
927
|
+
var h = k === n;
|
|
928
|
+
if (!h)
|
|
929
|
+
break;
|
|
930
|
+
}
|
|
931
|
+
} else
|
|
932
|
+
return R.errors = [{ instancePath: t + "/series", schemaPath: "#/properties/series/type", keyword: "type", params: { type: "array" }, message: "must be array" }], !1;
|
|
933
|
+
var a = d === n;
|
|
934
|
+
} else
|
|
935
|
+
var a = !0;
|
|
936
|
+
if (a)
|
|
937
|
+
if (e.title !== void 0) {
|
|
938
|
+
const u = n;
|
|
939
|
+
if (typeof e.title != "string")
|
|
940
|
+
return R.errors = [{ instancePath: t + "/title", schemaPath: "#/properties/title/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
941
|
+
var a = u === n;
|
|
942
|
+
} else
|
|
943
|
+
var a = !0;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
} else
|
|
948
|
+
return R.errors = [{ instancePath: t, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
949
|
+
return R.errors = o, n === 0;
|
|
950
|
+
}
|
|
951
|
+
function X(e, { instancePath: t = "", parentData: r, parentDataProperty: s, rootData: i = e } = {}) {
|
|
952
|
+
let o = null, n = 0;
|
|
953
|
+
if (n === 0)
|
|
954
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
955
|
+
let c;
|
|
956
|
+
if (e.chart === void 0 && (c = "chart") || e.title === void 0 && (c = "title") || e.type === void 0 && (c = "type"))
|
|
957
|
+
return X.errors = [{ instancePath: t, schemaPath: "#/required", keyword: "required", params: { missingProperty: c }, message: "must have required property '" + c + "'" }], !1;
|
|
958
|
+
{
|
|
959
|
+
const h = n;
|
|
960
|
+
for (const p in e)
|
|
961
|
+
if (!(p === "title" || p === "notes" || p === "layoutId" || p === "type" || p === "chart"))
|
|
962
|
+
return X.errors = [{ instancePath: t, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: p }, message: "must NOT have additional properties" }], !1;
|
|
963
|
+
if (h === n) {
|
|
964
|
+
if (e.title !== void 0) {
|
|
965
|
+
const p = n;
|
|
966
|
+
if (typeof e.title != "string")
|
|
967
|
+
return X.errors = [{ instancePath: t + "/title", schemaPath: "#/properties/title/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
968
|
+
var a = p === n;
|
|
969
|
+
} else
|
|
970
|
+
var a = !0;
|
|
971
|
+
if (a) {
|
|
972
|
+
if (e.notes !== void 0) {
|
|
973
|
+
const p = n;
|
|
974
|
+
if (typeof e.notes != "string")
|
|
975
|
+
return X.errors = [{ instancePath: t + "/notes", schemaPath: "#/properties/notes/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
976
|
+
var a = p === n;
|
|
977
|
+
} else
|
|
978
|
+
var a = !0;
|
|
979
|
+
if (a) {
|
|
980
|
+
if (e.layoutId !== void 0) {
|
|
981
|
+
const p = n;
|
|
982
|
+
if (typeof e.layoutId != "string")
|
|
983
|
+
return X.errors = [{ instancePath: t + "/layoutId", schemaPath: "#/properties/layoutId/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
984
|
+
var a = p === n;
|
|
985
|
+
} else
|
|
986
|
+
var a = !0;
|
|
987
|
+
if (a) {
|
|
988
|
+
if (e.type !== void 0) {
|
|
989
|
+
let p = e.type;
|
|
990
|
+
const l = n;
|
|
991
|
+
if (typeof p != "string")
|
|
992
|
+
return X.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" }], !1;
|
|
993
|
+
if (p !== "chart")
|
|
994
|
+
return X.errors = [{ instancePath: t + "/type", schemaPath: "#/properties/type/const", keyword: "const", params: { allowedValue: "chart" }, message: "must be equal to constant" }], !1;
|
|
995
|
+
var a = l === n;
|
|
996
|
+
} else
|
|
997
|
+
var a = !0;
|
|
998
|
+
if (a)
|
|
999
|
+
if (e.chart !== void 0) {
|
|
1000
|
+
const p = n;
|
|
1001
|
+
R(e.chart, { instancePath: t + "/chart", parentData: e, parentDataProperty: "chart", rootData: i }) || (o = o === null ? R.errors : o.concat(R.errors), n = o.length);
|
|
1002
|
+
var a = p === n;
|
|
1003
|
+
} else
|
|
1004
|
+
var a = !0;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
} else
|
|
1011
|
+
return X.errors = [{ instancePath: t, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
1012
|
+
return X.errors = o, n === 0;
|
|
1013
|
+
}
|
|
1014
|
+
function Pe(e, { instancePath: t = "", parentData: r, parentDataProperty: s, rootData: i = e } = {}) {
|
|
1015
|
+
let o = null, n = 0;
|
|
1016
|
+
const a = n;
|
|
1017
|
+
let c = !1;
|
|
1018
|
+
const h = n;
|
|
1019
|
+
if (n === n)
|
|
1020
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
1021
|
+
let m;
|
|
1022
|
+
if (e.title === void 0 && (m = "title") || e.type === void 0 && (m = "type")) {
|
|
1023
|
+
const g = { instancePath: t, schemaPath: "#/definitions/TemplateFillTitleSlide/required", keyword: "required", params: { missingProperty: m }, message: "must have required property '" + m + "'" };
|
|
1024
|
+
o === null ? o = [g] : o.push(g), n++;
|
|
1025
|
+
} else {
|
|
1026
|
+
const g = n;
|
|
1027
|
+
for (const u in e)
|
|
1028
|
+
if (!(u === "title" || u === "notes" || u === "layoutId" || u === "type" || u === "subtitle")) {
|
|
1029
|
+
const d = { instancePath: t, schemaPath: "#/definitions/TemplateFillTitleSlide/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: u }, message: "must NOT have additional properties" };
|
|
1030
|
+
o === null ? o = [d] : o.push(d), n++;
|
|
1031
|
+
break;
|
|
1032
|
+
}
|
|
1033
|
+
if (g === n) {
|
|
1034
|
+
if (e.title !== void 0) {
|
|
1035
|
+
const u = n;
|
|
1036
|
+
if (typeof e.title != "string") {
|
|
1037
|
+
const d = { instancePath: t + "/title", schemaPath: "#/definitions/TemplateFillTitleSlide/properties/title/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1038
|
+
o === null ? o = [d] : o.push(d), n++;
|
|
1039
|
+
}
|
|
1040
|
+
var l = u === n;
|
|
1041
|
+
} else
|
|
1042
|
+
var l = !0;
|
|
1043
|
+
if (l) {
|
|
1044
|
+
if (e.notes !== void 0) {
|
|
1045
|
+
const u = n;
|
|
1046
|
+
if (typeof e.notes != "string") {
|
|
1047
|
+
const v = { instancePath: t + "/notes", schemaPath: "#/definitions/TemplateFillTitleSlide/properties/notes/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1048
|
+
o === null ? o = [v] : o.push(v), n++;
|
|
1049
|
+
}
|
|
1050
|
+
var l = u === n;
|
|
1051
|
+
} else
|
|
1052
|
+
var l = !0;
|
|
1053
|
+
if (l) {
|
|
1054
|
+
if (e.layoutId !== void 0) {
|
|
1055
|
+
const u = n;
|
|
1056
|
+
if (typeof e.layoutId != "string") {
|
|
1057
|
+
const v = { instancePath: t + "/layoutId", schemaPath: "#/definitions/TemplateFillTitleSlide/properties/layoutId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1058
|
+
o === null ? o = [v] : o.push(v), n++;
|
|
1059
|
+
}
|
|
1060
|
+
var l = u === n;
|
|
1061
|
+
} else
|
|
1062
|
+
var l = !0;
|
|
1063
|
+
if (l) {
|
|
1064
|
+
if (e.type !== void 0) {
|
|
1065
|
+
let u = e.type;
|
|
1066
|
+
const d = n;
|
|
1067
|
+
if (typeof u != "string") {
|
|
1068
|
+
const P = { instancePath: t + "/type", schemaPath: "#/definitions/TemplateFillTitleSlide/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1069
|
+
o === null ? o = [P] : o.push(P), n++;
|
|
1070
|
+
}
|
|
1071
|
+
if (u !== "title") {
|
|
1072
|
+
const P = { instancePath: t + "/type", schemaPath: "#/definitions/TemplateFillTitleSlide/properties/type/const", keyword: "const", params: { allowedValue: "title" }, message: "must be equal to constant" };
|
|
1073
|
+
o === null ? o = [P] : o.push(P), n++;
|
|
1074
|
+
}
|
|
1075
|
+
var l = d === n;
|
|
1076
|
+
} else
|
|
1077
|
+
var l = !0;
|
|
1078
|
+
if (l)
|
|
1079
|
+
if (e.subtitle !== void 0) {
|
|
1080
|
+
const u = n;
|
|
1081
|
+
if (typeof e.subtitle != "string") {
|
|
1082
|
+
const v = { instancePath: t + "/subtitle", schemaPath: "#/definitions/TemplateFillTitleSlide/properties/subtitle/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1083
|
+
o === null ? o = [v] : o.push(v), n++;
|
|
1084
|
+
}
|
|
1085
|
+
var l = u === n;
|
|
1086
|
+
} else
|
|
1087
|
+
var l = !0;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
} else {
|
|
1094
|
+
const m = { instancePath: t, schemaPath: "#/definitions/TemplateFillTitleSlide/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1095
|
+
o === null ? o = [m] : o.push(m), n++;
|
|
1096
|
+
}
|
|
1097
|
+
var f = h === n;
|
|
1098
|
+
if (c = c || f, !c) {
|
|
1099
|
+
const m = n;
|
|
1100
|
+
q(e, { instancePath: t, parentData: r, parentDataProperty: s, rootData: i }) || (o = o === null ? q.errors : o.concat(q.errors), n = o.length);
|
|
1101
|
+
var f = m === n;
|
|
1102
|
+
if (c = c || f, !c) {
|
|
1103
|
+
const u = n;
|
|
1104
|
+
j(e, { instancePath: t, parentData: r, parentDataProperty: s, rootData: i }) || (o = o === null ? j.errors : o.concat(j.errors), n = o.length);
|
|
1105
|
+
var f = u === n;
|
|
1106
|
+
if (c = c || f, !c) {
|
|
1107
|
+
const v = n;
|
|
1108
|
+
M(e, { instancePath: t, parentData: r, parentDataProperty: s, rootData: i }) || (o = o === null ? M.errors : o.concat(M.errors), n = o.length);
|
|
1109
|
+
var f = v === n;
|
|
1110
|
+
if (c = c || f, !c) {
|
|
1111
|
+
const x = n;
|
|
1112
|
+
F(e, { instancePath: t, parentData: r, parentDataProperty: s, rootData: i }) || (o = o === null ? F.errors : o.concat(F.errors), n = o.length);
|
|
1113
|
+
var f = x === n;
|
|
1114
|
+
if (c = c || f, !c) {
|
|
1115
|
+
const k = n;
|
|
1116
|
+
X(e, { instancePath: t, parentData: r, parentDataProperty: s, rootData: i }) || (o = o === null ? X.errors : o.concat(X.errors), n = o.length);
|
|
1117
|
+
var f = k === n;
|
|
1118
|
+
c = c || f;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
if (c)
|
|
1125
|
+
n = a, o !== null && (a ? o.length = a : o = null);
|
|
1126
|
+
else {
|
|
1127
|
+
const m = { instancePath: t, schemaPath: "#/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
|
|
1128
|
+
return o === null ? o = [m] : o.push(m), n++, Pe.errors = o, !1;
|
|
1129
|
+
}
|
|
1130
|
+
return Pe.errors = o, n === 0;
|
|
1131
|
+
}
|
|
1132
|
+
function V(e, { instancePath: t = "", parentData: r, parentDataProperty: s, rootData: i = e } = {}) {
|
|
1133
|
+
let o = null, n = 0;
|
|
1134
|
+
if (n === 0)
|
|
1135
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
1136
|
+
let h;
|
|
1137
|
+
if (e.version === void 0 && (h = "version") || e.slides === void 0 && (h = "slides"))
|
|
1138
|
+
return V.errors = [{ instancePath: t, schemaPath: "#/required", keyword: "required", params: { missingProperty: h }, message: "must have required property '" + h + "'" }], !1;
|
|
1139
|
+
{
|
|
1140
|
+
const p = n;
|
|
1141
|
+
for (const l in e)
|
|
1142
|
+
if (!(l === "version" || l === "slides"))
|
|
1143
|
+
return V.errors = [{ instancePath: t, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: l }, message: "must NOT have additional properties" }], !1;
|
|
1144
|
+
if (p === n) {
|
|
1145
|
+
if (e.version !== void 0) {
|
|
1146
|
+
let l = e.version;
|
|
1147
|
+
const f = n;
|
|
1148
|
+
if (!(typeof l == "number" && isFinite(l)))
|
|
1149
|
+
return V.errors = [{ instancePath: t + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "number" }, message: "must be number" }], !1;
|
|
1150
|
+
if (l !== 1)
|
|
1151
|
+
return V.errors = [{ instancePath: t + "/version", schemaPath: "#/properties/version/const", keyword: "const", params: { allowedValue: 1 }, message: "must be equal to constant" }], !1;
|
|
1152
|
+
var a = f === n;
|
|
1153
|
+
} else
|
|
1154
|
+
var a = !0;
|
|
1155
|
+
if (a)
|
|
1156
|
+
if (e.slides !== void 0) {
|
|
1157
|
+
let l = e.slides;
|
|
1158
|
+
const f = n;
|
|
1159
|
+
if (n === f)
|
|
1160
|
+
if (Array.isArray(l)) {
|
|
1161
|
+
if (l.length < 1)
|
|
1162
|
+
return V.errors = [{ instancePath: t + "/slides", schemaPath: "#/properties/slides/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" }], !1;
|
|
1163
|
+
{
|
|
1164
|
+
var c = !0;
|
|
1165
|
+
const g = l.length;
|
|
1166
|
+
for (let u = 0; u < g; u++) {
|
|
1167
|
+
const d = n;
|
|
1168
|
+
Pe(l[u], { instancePath: t + "/slides/" + u, parentData: l, parentDataProperty: u, rootData: i }) || (o = o === null ? Pe.errors : o.concat(Pe.errors), n = o.length);
|
|
1169
|
+
var c = d === n;
|
|
1170
|
+
if (!c)
|
|
1171
|
+
break;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
} else
|
|
1175
|
+
return V.errors = [{ instancePath: t + "/slides", schemaPath: "#/properties/slides/type", keyword: "type", params: { type: "array" }, message: "must be array" }], !1;
|
|
1176
|
+
var a = f === n;
|
|
1177
|
+
} else
|
|
1178
|
+
var a = !0;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
} else
|
|
1182
|
+
return V.errors = [{ instancePath: t, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }], !1;
|
|
1183
|
+
return V.errors = o, n === 0;
|
|
1184
|
+
}
|
|
1185
|
+
function rr(e, { instancePath: t = "", parentData: r, parentDataProperty: s, rootData: i = e } = {}) {
|
|
1186
|
+
let o = null, n = 0;
|
|
1187
|
+
return V(e, { instancePath: t, parentData: r, parentDataProperty: s, rootData: i }) || (o = o === null ? V.errors : o.concat(V.errors), n = o.length), rr.errors = o, n === 0;
|
|
1188
|
+
}
|
|
1189
|
+
function ks(e, t, r) {
|
|
1190
|
+
for (const s of e) {
|
|
1191
|
+
const i = s.codePointAt(0);
|
|
1192
|
+
if (!(i === 9 || i === 10 || i === 13 || i >= 32 && i <= 55295 || i >= 57344 && i <= 65533 || i >= 65536 && i <= 1114111))
|
|
1193
|
+
throw new E(
|
|
1194
|
+
"invalid-outline",
|
|
1195
|
+
`${t} 包含 XML 1.0 不允许的字符 U+${i.toString(16).toUpperCase().padStart(4, "0")}`,
|
|
1196
|
+
r,
|
|
1197
|
+
t
|
|
1198
|
+
);
|
|
1199
|
+
}
|
|
1200
|
+
return e.replace(/\r\n?/g, `
|
|
1201
|
+
`);
|
|
1202
|
+
}
|
|
1203
|
+
function Ts(e) {
|
|
1204
|
+
const t = structuredClone(e), r = (s, i, o) => {
|
|
1205
|
+
if (typeof s == "string") return i.endsWith(".image.bytes") || i.endsWith(".layoutId") ? s : ks(s, i, o);
|
|
1206
|
+
if (Array.isArray(s)) return s.map((n, a) => r(n, `${i}[${a}]`, i === "slides" ? a + 1 : o));
|
|
1207
|
+
if (s && typeof s == "object")
|
|
1208
|
+
for (const [n, a] of Object.entries(s))
|
|
1209
|
+
s[n] = r(a, i ? `${i}.${n}` : n, o);
|
|
1210
|
+
return s;
|
|
1211
|
+
};
|
|
1212
|
+
return r(t, "", null);
|
|
1213
|
+
}
|
|
1214
|
+
const $t = rr;
|
|
1215
|
+
function Is(e, t) {
|
|
1216
|
+
const r = (i, o) => {
|
|
1217
|
+
throw new E("invalid-chart-data", `第 ${t} 页图表 ${i}:${o}`, t, `chart.${i}`);
|
|
1218
|
+
}, s = e.type === "scatter" || e.type === "bubble";
|
|
1219
|
+
e.series.length || r("series", "至少需要一个系列"), s && e.categories.length && r("categories", "散点和气泡图使用 x 数组,categories 必须为空"), !s && !e.categories.length && r("categories", "类别图至少需要一个类别"), e.type === "pie" && e.series.length !== 1 && r("series", "饼图必须恰有一个系列"), e.series.forEach((i, o) => {
|
|
1220
|
+
var a;
|
|
1221
|
+
const n = `series[${o}]`;
|
|
1222
|
+
i.values.length || r(`${n}.values`, "至少需要一个数据点"), !s && i.values.length !== e.categories.length && r(`${n}.values`, `实际 ${i.values.length} 个值,预期与 ${e.categories.length} 个类别一致`), s && (!i.x || i.x.length !== i.values.length) && r(`${n}.x`, `x 必须与 ${i.values.length} 个 values 一一对应`), !s && i.x !== void 0 && r(`${n}.x`, "类别图不能带 x 数据"), e.type === "bubble" ? ((!i.sizes || i.sizes.length !== i.values.length) && r(`${n}.sizes`, `sizes 必须与 ${i.values.length} 个 values 一一对应`), (a = i.sizes) != null && a.some((c) => c !== null && c < 0) && r(`${n}.sizes`, "气泡尺寸不能为负")) : i.sizes !== void 0 && r(`${n}.sizes`, "只有气泡图接受 sizes");
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
function $s(e) {
|
|
1226
|
+
var s;
|
|
1227
|
+
if (!$t(e)) {
|
|
1228
|
+
const i = (s = $t.errors) == null ? void 0 : s[0], o = /^\/slides\/(\d+)(?:\/|$)/.exec((i == null ? void 0 : i.instancePath) ?? "");
|
|
1229
|
+
throw new E(
|
|
1230
|
+
"invalid-outline",
|
|
1231
|
+
`大纲不符合 template-fill Schema:${(i == null ? void 0 : i.instancePath) || "/"} ${(i == null ? void 0 : i.message) ?? ""}`,
|
|
1232
|
+
o ? Number(o[1]) + 1 : null,
|
|
1233
|
+
(i == null ? void 0 : i.instancePath) ?? null
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
const t = Ts(e), r = /* @__PURE__ */ new Map();
|
|
1237
|
+
return t.slides.forEach((i, o) => {
|
|
1238
|
+
const n = o + 1;
|
|
1239
|
+
if (i.type === "chart" && Is(i.chart, n), i.type === "image")
|
|
1240
|
+
try {
|
|
1241
|
+
const a = xs(i.image.bytes, o);
|
|
1242
|
+
ws(a, i.image.mime, `第 ${n} 页 image`);
|
|
1243
|
+
const c = jr(a);
|
|
1244
|
+
if (!c || c.width <= 0 || c.height <= 0)
|
|
1245
|
+
throw new Error("图片必须含可读取的正宽高");
|
|
1246
|
+
r.set(o, { bytes: a, metadata: c });
|
|
1247
|
+
} catch (a) {
|
|
1248
|
+
throw new E(
|
|
1249
|
+
"invalid-image",
|
|
1250
|
+
`第 ${n} 页图片无效:${a instanceof Error ? a.message : String(a)}`,
|
|
1251
|
+
n,
|
|
1252
|
+
"image"
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
}), { outline: t, images: r };
|
|
1256
|
+
}
|
|
1257
|
+
const ie = /* @__PURE__ */ new WeakMap(), Ss = /* @__PURE__ */ new WeakMap(), Es = /* @__PURE__ */ new WeakMap(), sr = "http://www.w3.org/XML/1998/namespace", Cs = "http://www.w3.org/2000/xmlns/", Ns = /^[A-Za-z_][A-Za-z0-9_.-]*$/, As = /^[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{N}\p{M}\p{Pc}_.\-\u00B7\u203F-\u2040]*$/u, Ve = (e) => Ns.test(e) || As.test(e);
|
|
1258
|
+
function St(e) {
|
|
1259
|
+
const t = e.indexOf(":");
|
|
1260
|
+
return t < 0 ? Ve(e) : t === e.lastIndexOf(":") && Ve(e.slice(0, t)) && Ve(e.slice(t + 1));
|
|
1261
|
+
}
|
|
1262
|
+
const rt = (e) => {
|
|
1263
|
+
const t = e.indexOf(":");
|
|
1264
|
+
return t < 0 ? { prefix: null, localName: e } : { prefix: e.slice(0, t), localName: e.slice(t + 1) };
|
|
1265
|
+
};
|
|
1266
|
+
function Et(e, t, r) {
|
|
1267
|
+
const s = rt(e);
|
|
1268
|
+
return r && (e === "xmlns" || s.prefix === "xmlns") ? Cs : s.prefix === "xml" ? sr : s.prefix ? t.get(s.prefix) || null : r ? null : t.get("") || null;
|
|
1269
|
+
}
|
|
1270
|
+
const Fs = /* @__PURE__ */ new WeakMap(), Os = {
|
|
1271
|
+
amp: "&",
|
|
1272
|
+
lt: "<",
|
|
1273
|
+
gt: ">",
|
|
1274
|
+
quot: '"',
|
|
1275
|
+
apos: "'"
|
|
1276
|
+
}, ke = (e) => e === " " || e === " " || e === "\r" || e === `
|
|
1277
|
+
`, Ct = (e) => ke(e) || e === "=" || e === "/" || e === ">";
|
|
1278
|
+
function _s(e) {
|
|
1279
|
+
let t = e.length - 2;
|
|
1280
|
+
for (; ke(e[t]); ) t--;
|
|
1281
|
+
return e[t] === "/";
|
|
1282
|
+
}
|
|
1283
|
+
function Ee(e) {
|
|
1284
|
+
return e.includes("&") ? e.replace(/&(#x[0-9a-f]+|#[0-9]+|[A-Za-z][\w.-]*);/gi, (t, r) => {
|
|
1285
|
+
if (r[0] !== "#") return Os[r] ?? t;
|
|
1286
|
+
const s = r[1].toLowerCase() === "x", i = Number.parseInt(r.slice(s ? 2 : 1), s ? 16 : 10);
|
|
1287
|
+
return Number.isFinite(i) && i >= 0 && i <= 1114111 ? String.fromCodePoint(i) : t;
|
|
1288
|
+
}) : e;
|
|
1289
|
+
}
|
|
1290
|
+
function Ms(e) {
|
|
1291
|
+
let t = "utf-8", r = !1, s = 0;
|
|
1292
|
+
return e[0] === 239 && e[1] === 187 && e[2] === 191 ? (r = !0, s = 3) : e[0] === 255 && e[1] === 254 ? (t = "utf-16le", r = !0, s = 2) : e[0] === 254 && e[1] === 255 ? (t = "utf-16be", r = !0, s = 2) : e[0] === 60 && e[1] === 0 ? t = "utf-16le" : e[0] === 0 && e[1] === 60 && (t = "utf-16be"), { text: new TextDecoder(t, { fatal: !0 }).decode(e.subarray(s)), encoding: t, bom: r };
|
|
1293
|
+
}
|
|
1294
|
+
class Nt {
|
|
1295
|
+
constructor(t) {
|
|
1296
|
+
this.source = t, this.offset = 0;
|
|
1297
|
+
}
|
|
1298
|
+
parse() {
|
|
1299
|
+
const t = [], r = { type: "document", children: t, root: null };
|
|
1300
|
+
let s = null;
|
|
1301
|
+
for (; this.offset < this.source.length; ) {
|
|
1302
|
+
const i = this.source[this.offset] === "<" ? this.parseMarkup(r, /* @__PURE__ */ new Map()) : this.parseText(r);
|
|
1303
|
+
t.push(i), i.type === "element" ? (s && this.fail("XML 只能有一个根元素"), s = i) : i.type === "text" && i.value.replace(/^\uFEFF/, "").trim() && this.fail("根元素外不能出现文本");
|
|
1304
|
+
}
|
|
1305
|
+
return s || this.fail("未找到根元素"), Object.defineProperty(r, "root", { value: s, enumerable: !0 }), ie.set(r, { raw: this.source, parent: null, dirty: !1 }), r;
|
|
1306
|
+
}
|
|
1307
|
+
parseText(t) {
|
|
1308
|
+
const r = this.offset, s = this.source.indexOf("<", r);
|
|
1309
|
+
this.offset = s < 0 ? this.source.length : s;
|
|
1310
|
+
const i = this.source.slice(r, this.offset), o = { type: "text", value: Ee(i) };
|
|
1311
|
+
return ie.set(o, { raw: i, parent: t, dirty: !1 }), o;
|
|
1312
|
+
}
|
|
1313
|
+
parseMarkup(t, r) {
|
|
1314
|
+
const s = this.offset;
|
|
1315
|
+
if (this.source.startsWith("<!--", s)) {
|
|
1316
|
+
const i = this.source.indexOf("-->", s + 4);
|
|
1317
|
+
i < 0 && this.fail("注释未闭合"), this.offset = i + 3;
|
|
1318
|
+
const o = this.source.slice(s, this.offset), n = { type: "comment", value: o.slice(4, -3) };
|
|
1319
|
+
return ie.set(n, { raw: o, parent: t, dirty: !1 }), n;
|
|
1320
|
+
}
|
|
1321
|
+
if (this.source.startsWith("<![CDATA[", s)) {
|
|
1322
|
+
const i = this.source.indexOf("]]>", s + 9);
|
|
1323
|
+
i < 0 && this.fail("CDATA 未闭合"), this.offset = i + 3;
|
|
1324
|
+
const o = this.source.slice(s, this.offset), n = { type: "cdata", value: o.slice(9, -3) };
|
|
1325
|
+
return ie.set(n, { raw: o, parent: t, dirty: !1 }), n;
|
|
1326
|
+
}
|
|
1327
|
+
return this.source.startsWith("<?", s) ? this.parseInstruction(t) : this.source.startsWith("<!", s) ? this.parseDeclaration(t) : (this.source.startsWith("</", s) && this.fail("遇到意外的闭合标签"), this.parseElement(t, r));
|
|
1328
|
+
}
|
|
1329
|
+
parseInstruction(t) {
|
|
1330
|
+
const r = this.offset, s = this.source.indexOf("?>", r + 2);
|
|
1331
|
+
s < 0 && this.fail("处理指令未闭合"), this.offset = s + 2;
|
|
1332
|
+
const i = this.source.slice(r, this.offset), o = i.slice(2, -2), n = o.search(/\s/), a = {
|
|
1333
|
+
type: "processing-instruction",
|
|
1334
|
+
target: n < 0 ? o : o.slice(0, n),
|
|
1335
|
+
value: n < 0 ? "" : o.slice(n).trimStart()
|
|
1336
|
+
};
|
|
1337
|
+
return ie.set(a, { raw: i, parent: t, dirty: !1 }), a;
|
|
1338
|
+
}
|
|
1339
|
+
parseDeclaration(t) {
|
|
1340
|
+
const r = this.offset;
|
|
1341
|
+
let s = "", i = 0;
|
|
1342
|
+
for (this.offset += 2; this.offset < this.source.length; ) {
|
|
1343
|
+
const a = this.source[this.offset++];
|
|
1344
|
+
if (s)
|
|
1345
|
+
a === s && (s = "");
|
|
1346
|
+
else if (a === '"' || a === "'") s = a;
|
|
1347
|
+
else if (a === "[") i++;
|
|
1348
|
+
else if (a === "]") i = Math.max(0, i - 1);
|
|
1349
|
+
else if (a === ">" && i === 0) break;
|
|
1350
|
+
}
|
|
1351
|
+
this.source[this.offset - 1] !== ">" && this.fail("声明未闭合");
|
|
1352
|
+
const o = this.source.slice(r, this.offset), n = { type: "declaration", value: o.slice(2, -1) };
|
|
1353
|
+
return ie.set(n, { raw: o, parent: t, dirty: !1 }), n;
|
|
1354
|
+
}
|
|
1355
|
+
parseElement(t, r) {
|
|
1356
|
+
const s = this.offset, i = this.scanOpenEnd(s), o = this.source.slice(s, i + 1), n = this.scanNameEnd(s + 1, i), a = this.source.slice(s + 1, n);
|
|
1357
|
+
St(a) || this.fail(`非法元素名 ${a || "(空)"}`);
|
|
1358
|
+
const c = this.parseAttributes(o, a.length + 1), h = new Map(r);
|
|
1359
|
+
h.set("xml", sr);
|
|
1360
|
+
for (const v of c)
|
|
1361
|
+
v.name === "xmlns" ? h.set("", Ee(v.value)) : v.name.startsWith("xmlns:") && h.set(v.name.slice(6), Ee(v.value));
|
|
1362
|
+
const p = c.map((v) => {
|
|
1363
|
+
const P = rt(v.name), x = {
|
|
1364
|
+
name: v.name,
|
|
1365
|
+
prefix: P.prefix,
|
|
1366
|
+
localName: P.localName,
|
|
1367
|
+
namespaceUri: Et(v.name, h, !0),
|
|
1368
|
+
value: Ee(v.value),
|
|
1369
|
+
quote: v.quote
|
|
1370
|
+
};
|
|
1371
|
+
return Es.set(x, v.state), x;
|
|
1372
|
+
}), l = rt(a), f = _s(o), m = [], g = {
|
|
1373
|
+
type: "element",
|
|
1374
|
+
name: a,
|
|
1375
|
+
prefix: l.prefix,
|
|
1376
|
+
localName: l.localName,
|
|
1377
|
+
namespaceUri: Et(a, h, !1),
|
|
1378
|
+
attributes: p,
|
|
1379
|
+
children: m,
|
|
1380
|
+
selfClosing: f
|
|
1381
|
+
};
|
|
1382
|
+
this.offset = i + 1;
|
|
1383
|
+
let u = "";
|
|
1384
|
+
if (!f) {
|
|
1385
|
+
for (; this.offset < this.source.length && !this.source.startsWith("</", this.offset); ) {
|
|
1386
|
+
const w = this.source[this.offset] === "<" ? this.parseMarkup(g, h) : this.parseText(g);
|
|
1387
|
+
m.push(w);
|
|
1388
|
+
}
|
|
1389
|
+
this.source.startsWith("</", this.offset) || this.fail(`元素 <${a}> 未闭合`);
|
|
1390
|
+
const v = this.offset, P = this.source.indexOf(">", v + 2);
|
|
1391
|
+
P < 0 && this.fail(`元素 <${a}> 未闭合`);
|
|
1392
|
+
const x = this.source.slice(v + 2, P).trim();
|
|
1393
|
+
x !== a && this.fail(`闭合标签 </${x}> 与 <${a}> 不匹配`), this.offset = P + 1, u = this.source.slice(v, this.offset);
|
|
1394
|
+
}
|
|
1395
|
+
const d = {
|
|
1396
|
+
raw: this.source.slice(s, this.offset),
|
|
1397
|
+
parent: t,
|
|
1398
|
+
dirty: !1,
|
|
1399
|
+
openRaw: o,
|
|
1400
|
+
closeRaw: u,
|
|
1401
|
+
sourceSelfClosing: f,
|
|
1402
|
+
// 源属性表必须与公开的当前属性表分离;删除/新增只改当前表,序列化仍靠源表定位原始字节。
|
|
1403
|
+
sourceAttributes: [...p],
|
|
1404
|
+
namespaces: h
|
|
1405
|
+
};
|
|
1406
|
+
return ie.set(g, d), Ss.set(g, d), g;
|
|
1407
|
+
}
|
|
1408
|
+
scanOpenEnd(t) {
|
|
1409
|
+
let r = "";
|
|
1410
|
+
for (let s = t + 1; s < this.source.length; s++) {
|
|
1411
|
+
const i = this.source[s];
|
|
1412
|
+
if (r)
|
|
1413
|
+
i === r && (r = "");
|
|
1414
|
+
else if (i === '"' || i === "'") r = i;
|
|
1415
|
+
else if (i === ">") return s;
|
|
1416
|
+
}
|
|
1417
|
+
this.fail("开始标签未闭合");
|
|
1418
|
+
}
|
|
1419
|
+
scanNameEnd(t, r) {
|
|
1420
|
+
let s = t;
|
|
1421
|
+
for (; s < r && !Ct(this.source[s]); ) s++;
|
|
1422
|
+
return s;
|
|
1423
|
+
}
|
|
1424
|
+
parseAttributes(t, r) {
|
|
1425
|
+
const s = [], i = /* @__PURE__ */ new Set();
|
|
1426
|
+
let o = r;
|
|
1427
|
+
for (; o < t.length - 1; ) {
|
|
1428
|
+
const n = o;
|
|
1429
|
+
for (; ke(t[o]); ) o++;
|
|
1430
|
+
if (t[o] === "/" || t[o] === ">" || o >= t.length - 1) break;
|
|
1431
|
+
o === n && this.fail("属性前缺少空白");
|
|
1432
|
+
const a = o;
|
|
1433
|
+
for (; o < t.length && !Ct(t[o]); ) o++;
|
|
1434
|
+
const c = t.slice(a, o);
|
|
1435
|
+
for (St(c) || this.fail(`非法属性名 ${c || "(空)"}`), i.has(c) && this.fail(`属性 ${c} 重复`), i.add(c); ke(t[o]); ) o++;
|
|
1436
|
+
for (t[o++] !== "=" && this.fail(`属性 ${c} 缺少等号`); ke(t[o]); ) o++;
|
|
1437
|
+
const h = t[o++];
|
|
1438
|
+
h !== '"' && h !== "'" && this.fail(`属性 ${c} 必须使用引号`);
|
|
1439
|
+
const p = o, l = t.indexOf(h, p);
|
|
1440
|
+
l < 0 && this.fail(`属性 ${c} 未闭合`), o = l + 1, s.push({
|
|
1441
|
+
name: c,
|
|
1442
|
+
value: t.slice(p, l),
|
|
1443
|
+
quote: h,
|
|
1444
|
+
state: {
|
|
1445
|
+
source: !0,
|
|
1446
|
+
present: !0,
|
|
1447
|
+
changed: !1,
|
|
1448
|
+
start: n,
|
|
1449
|
+
nameStart: a,
|
|
1450
|
+
valueStart: p,
|
|
1451
|
+
valueEnd: l,
|
|
1452
|
+
end: o
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
return s;
|
|
1457
|
+
}
|
|
1458
|
+
fail(t) {
|
|
1459
|
+
throw new Error(`XML 解析失败(偏移 ${this.offset}):${t}`);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
function Rs(e) {
|
|
1463
|
+
if (typeof e == "string") return new Nt(e).parse();
|
|
1464
|
+
const t = Ms(e), r = new Nt(t.text).parse();
|
|
1465
|
+
return Fs.set(r, { encoding: t.encoding, bom: t.bom, source: e }), r;
|
|
1466
|
+
}
|
|
1467
|
+
const js = (e, t) => e.localName === t.localName && (!Object.prototype.hasOwnProperty.call(t, "namespaceUri") || e.namespaceUri === t.namespaceUri);
|
|
1468
|
+
function Us(e, t) {
|
|
1469
|
+
return e.attributes.find((r) => js(r, t)) ?? null;
|
|
1470
|
+
}
|
|
1471
|
+
function qs(e, t) {
|
|
1472
|
+
return e.layouts[t].children.flatMap((r) => {
|
|
1473
|
+
const i = e.elements[r].meta.ph;
|
|
1474
|
+
if (!i || ["dt", "sldNum", "ftr", "hdr"].includes(i.type)) return [];
|
|
1475
|
+
const o = W(e, r);
|
|
1476
|
+
return o.kind !== "shape" || ![o.x, o.y, o.w, o.h, o.rot].every(Number.isFinite) || o.w <= 0 || o.h <= 0 ? [] : [{
|
|
1477
|
+
id: r,
|
|
1478
|
+
type: i.type,
|
|
1479
|
+
index: i.idx ?? null,
|
|
1480
|
+
rot: o.rot,
|
|
1481
|
+
flipH: o.flipH,
|
|
1482
|
+
flipV: o.flipV,
|
|
1483
|
+
rect: { x: o.x, y: o.y, w: o.w, h: o.h }
|
|
1484
|
+
}];
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
function zs(e, t) {
|
|
1488
|
+
var i, o;
|
|
1489
|
+
const r = e.layouts[t].origin.part, s = (i = e.package) == null ? void 0 : i.parts[r];
|
|
1490
|
+
if (!s) throw new E("invalid-template", `版式 ${t} 缺少可读的来源部件 ${r}`);
|
|
1491
|
+
return ((o = Us(Rs(s).root, { localName: "type", namespaceUri: null })) == null ? void 0 : o.value) ?? null;
|
|
1492
|
+
}
|
|
1493
|
+
function Ds(e, t, r) {
|
|
1494
|
+
var p, l;
|
|
1495
|
+
const s = qs(e, t), o = ((f) => Wt(s, (m) => ({ type: m.type, idx: m.index }), { type: f }))("title");
|
|
1496
|
+
if (!o) return null;
|
|
1497
|
+
const n = s.filter((f) => f.type === "body" || f.type === "obj").sort((f, m) => f.rect.x - m.rect.x || f.rect.y - m.rect.y || (f.id < m.id ? -1 : f.id > m.id ? 1 : 0)), a = zs(e, t);
|
|
1498
|
+
if (r.type === "title") {
|
|
1499
|
+
const f = s.find((m) => m.type === "subTitle");
|
|
1500
|
+
return r.subtitle !== void 0 && !f ? null : {
|
|
1501
|
+
plan: { layoutId: t, title: o, subtitle: f, bodies: [] },
|
|
1502
|
+
score: (a === "title" || o.type === "ctrTitle" ? 0 : 20) + n.length
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
if (r.type === "section")
|
|
1506
|
+
return !r.layoutId && a !== "secHead" || (p = r.body) != null && p.length && !n.length ? null : { plan: { layoutId: t, title: o, bodies: n.slice(0, 1) }, score: n.length };
|
|
1507
|
+
if (r.type === "content" || r.type === "two-column") {
|
|
1508
|
+
const f = r.type === "two-column" ? 2 : 1;
|
|
1509
|
+
return n.length < f || a === "title" || a === "secHead" ? null : { plan: { layoutId: t, title: o, bodies: n.slice(0, f) }, score: n.length - f };
|
|
1510
|
+
}
|
|
1511
|
+
const c = r.type === "image" ? ["pic", "obj", "body"] : ["chart", "obj", "body"], h = r.type === "image" && !!((l = r.body) != null && l.length);
|
|
1512
|
+
for (let f = 0; f < c.length; f++)
|
|
1513
|
+
for (const m of s.filter((g) => g.type === c[f])) {
|
|
1514
|
+
const g = n.filter((u) => u.id !== m.id);
|
|
1515
|
+
if (!(h && !g.length) && !(a === "title" || a === "secHead"))
|
|
1516
|
+
return {
|
|
1517
|
+
plan: { layoutId: t, title: o, object: m, bodies: h ? g.slice(0, 1) : [] },
|
|
1518
|
+
score: f * 10 + Math.max(0, g.length - Number(h))
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
return null;
|
|
1522
|
+
}
|
|
1523
|
+
function Ls(e, t) {
|
|
1524
|
+
return t.map((r, s) => {
|
|
1525
|
+
if (r.layoutId !== void 0 && !e.layouts[r.layoutId])
|
|
1526
|
+
throw new E(
|
|
1527
|
+
"layout-not-found",
|
|
1528
|
+
`第 ${s + 1} 页指定的版式不存在:${r.layoutId}`,
|
|
1529
|
+
s + 1,
|
|
1530
|
+
"layoutId"
|
|
1531
|
+
);
|
|
1532
|
+
const i = (r.layoutId ? [r.layoutId] : e.layoutOrder).flatMap((o, n) => {
|
|
1533
|
+
const a = Ds(e, o, r);
|
|
1534
|
+
return a ? [{ ...a, order: n }] : [];
|
|
1535
|
+
}).sort((o, n) => o.score - n.score || o.order - n.order);
|
|
1536
|
+
if (!i.length)
|
|
1537
|
+
throw new E(
|
|
1538
|
+
"layout-role-mismatch",
|
|
1539
|
+
`第 ${s + 1} 页 ${r.type} 没有匹配的占位符版式;可用版式:${e.layoutOrder.join(", ")}`,
|
|
1540
|
+
s + 1,
|
|
1541
|
+
"type"
|
|
1542
|
+
);
|
|
1543
|
+
return i[0].plan;
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
const nr = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ir = nr.length, or = 8, de = BigInt(ir), ar = de ** BigInt(or), Zs = ar / 4n / de * de;
|
|
1547
|
+
function Ws(e) {
|
|
1548
|
+
if (e < 0n || e >= ar) throw new Error("初始分数序超出容量");
|
|
1549
|
+
let t = e, r = "";
|
|
1550
|
+
for (let s = 0; s < or; s++)
|
|
1551
|
+
r = nr[Number(t % de)] + r, t /= de;
|
|
1552
|
+
return r;
|
|
1553
|
+
}
|
|
1554
|
+
function Ze(e) {
|
|
1555
|
+
if (!Number.isSafeInteger(e) || e < 0) throw new Error("初始分数序下标必须是非负安全整数");
|
|
1556
|
+
return Ws(Zs + BigInt(e) * de + BigInt(Math.floor(ir / 2)));
|
|
1557
|
+
}
|
|
1558
|
+
function st(e) {
|
|
1559
|
+
return `#r${e}`;
|
|
1560
|
+
}
|
|
1561
|
+
function nt(e) {
|
|
1562
|
+
return `#c${e}`;
|
|
1563
|
+
}
|
|
1564
|
+
function ne(e) {
|
|
1565
|
+
if (e.src.kind !== "table") throw new Error(`元素 ${e.id} 不是表格`);
|
|
1566
|
+
return [
|
|
1567
|
+
...e.src.rows.map((t, r) => ({
|
|
1568
|
+
id: st(r),
|
|
1569
|
+
rowRef: r,
|
|
1570
|
+
source: r,
|
|
1571
|
+
order: Ze(r)
|
|
1572
|
+
})),
|
|
1573
|
+
...Object.entries(e.ovr.tableRows ?? {}).map(([t, r]) => ({
|
|
1574
|
+
id: t,
|
|
1575
|
+
rowRef: t,
|
|
1576
|
+
source: null,
|
|
1577
|
+
...r
|
|
1578
|
+
}))
|
|
1579
|
+
].filter((t) => {
|
|
1580
|
+
var r;
|
|
1581
|
+
return !((r = e.ovr.tableRemovedRows) != null && r[t.id]);
|
|
1582
|
+
}).sort((t, r) => t.order < r.order ? -1 : t.order > r.order ? 1 : t.id < r.id ? -1 : 1);
|
|
1583
|
+
}
|
|
1584
|
+
function ye(e) {
|
|
1585
|
+
if (e.src.kind !== "table") throw new Error(`元素 ${e.id} 不是表格`);
|
|
1586
|
+
return [
|
|
1587
|
+
...e.src.colWidths.map((t, r) => ({
|
|
1588
|
+
id: nt(r),
|
|
1589
|
+
columnRef: r,
|
|
1590
|
+
source: r,
|
|
1591
|
+
order: Ze(r)
|
|
1592
|
+
})),
|
|
1593
|
+
...Object.entries(e.ovr.tableColumns ?? {}).map(([t, r]) => ({
|
|
1594
|
+
id: t,
|
|
1595
|
+
columnRef: t,
|
|
1596
|
+
source: null,
|
|
1597
|
+
...r
|
|
1598
|
+
}))
|
|
1599
|
+
].filter((t) => {
|
|
1600
|
+
var r;
|
|
1601
|
+
return !((r = e.ovr.tableRemovedColumns) != null && r[t.id]);
|
|
1602
|
+
}).sort((t, r) => t.order < r.order ? -1 : t.order > r.order ? 1 : t.id < r.id ? -1 : 1);
|
|
1603
|
+
}
|
|
1604
|
+
function Xs(e) {
|
|
1605
|
+
if (e.src.kind !== "table") throw new Error(`元素 ${e.id} 不是表格`);
|
|
1606
|
+
const t = [];
|
|
1607
|
+
return e.src.rows.forEach((r, s) => r.cells.forEach((i, o) => {
|
|
1608
|
+
i.merged || i.rowSpan <= 1 && i.colSpan <= 1 || t.push({
|
|
1609
|
+
from: { row: st(s), column: nt(o) },
|
|
1610
|
+
to: {
|
|
1611
|
+
row: st(s + i.rowSpan - 1),
|
|
1612
|
+
column: nt(o + i.colSpan - 1)
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
})), t;
|
|
1616
|
+
}
|
|
1617
|
+
function lr(e) {
|
|
1618
|
+
return e.ovr.tableMerges ?? Xs(e);
|
|
1619
|
+
}
|
|
1620
|
+
function Bs(e, t) {
|
|
1621
|
+
if (e.src.kind !== "table") return null;
|
|
1622
|
+
const r = {
|
|
1623
|
+
...e,
|
|
1624
|
+
ovr: { ...e.ovr, tableRemovedRows: void 0, tableRemovedColumns: void 0 }
|
|
1625
|
+
}, s = ne(r), i = ye(r), o = {
|
|
1626
|
+
r: s.findIndex((n) => n.id === t.row),
|
|
1627
|
+
c: i.findIndex((n) => n.id === t.column)
|
|
1628
|
+
};
|
|
1629
|
+
if (o.r < 0 || o.c < 0) return null;
|
|
1630
|
+
for (const n of lr(e)) {
|
|
1631
|
+
const a = [
|
|
1632
|
+
s.findIndex((f) => f.id === n.from.row),
|
|
1633
|
+
i.findIndex((f) => f.id === n.from.column),
|
|
1634
|
+
s.findIndex((f) => f.id === n.to.row),
|
|
1635
|
+
i.findIndex((f) => f.id === n.to.column)
|
|
1636
|
+
];
|
|
1637
|
+
if (a.some((f) => f < 0)) continue;
|
|
1638
|
+
const [c, h, p, l] = [
|
|
1639
|
+
Math.min(a[0], a[2]),
|
|
1640
|
+
Math.min(a[1], a[3]),
|
|
1641
|
+
Math.max(a[0], a[2]),
|
|
1642
|
+
Math.max(a[1], a[3])
|
|
1643
|
+
];
|
|
1644
|
+
if (!(o.r < c || o.r > p || o.c < h || o.c > l))
|
|
1645
|
+
return o.r === c && o.c === h ? "anchor" : "placeholder";
|
|
1646
|
+
}
|
|
1647
|
+
return null;
|
|
1648
|
+
}
|
|
1649
|
+
function Vs(e, t, r) {
|
|
1650
|
+
const s = {
|
|
1651
|
+
...e,
|
|
1652
|
+
ovr: { ...e.ovr, tableRemovedRows: void 0, tableRemovedColumns: void 0 }
|
|
1653
|
+
}, i = ne(s), o = ye(s), n = new Set(t.map((c) => c.id)), a = new Set(r.map((c) => c.id));
|
|
1654
|
+
return lr(e).flatMap((c) => {
|
|
1655
|
+
const h = i.findIndex((u) => u.id === c.from.row), p = i.findIndex((u) => u.id === c.to.row), l = o.findIndex((u) => u.id === c.from.column), f = o.findIndex((u) => u.id === c.to.column);
|
|
1656
|
+
if ([h, p, l, f].some((u) => u < 0)) return [];
|
|
1657
|
+
const m = i.slice(Math.min(h, p), Math.max(h, p) + 1).filter((u) => n.has(u.id)), g = o.slice(Math.min(l, f), Math.max(l, f) + 1).filter((u) => a.has(u.id));
|
|
1658
|
+
return m.length * g.length <= 1 ? [] : [{
|
|
1659
|
+
from: { row: m[0].id, column: g[0].id },
|
|
1660
|
+
to: {
|
|
1661
|
+
row: m[m.length - 1].id,
|
|
1662
|
+
column: g[g.length - 1].id
|
|
1663
|
+
}
|
|
1664
|
+
}];
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
function Hs(e, t) {
|
|
1668
|
+
const r = e.elements[t];
|
|
1669
|
+
if (!r || r.src.kind !== "table") throw new Error(`找不到表格:${t}`);
|
|
1670
|
+
const s = r.src, i = ne(r).map((a) => {
|
|
1671
|
+
var c, h;
|
|
1672
|
+
return {
|
|
1673
|
+
id: a.id,
|
|
1674
|
+
source: a.source,
|
|
1675
|
+
height: ((c = r.ovr.tableRowHeights) == null ? void 0 : c[a.id]) ?? (a.source === null ? ((h = s.rows[a.template ?? s.rows.length - 1]) == null ? void 0 : h.height) ?? 0 : s.rows[a.source].height)
|
|
1676
|
+
};
|
|
1677
|
+
}), o = ye(r).map((a) => {
|
|
1678
|
+
var c;
|
|
1679
|
+
return {
|
|
1680
|
+
id: a.id,
|
|
1681
|
+
source: a.source,
|
|
1682
|
+
width: ((c = r.ovr.tableColumnWidths) == null ? void 0 : c[a.id]) ?? (a.source === null ? s.colWidths[a.template ?? s.colWidths.length - 1] ?? 0 : s.colWidths[a.source])
|
|
1683
|
+
};
|
|
1684
|
+
}), n = Vs(r, i, o).map((a) => ({ from: { ...a.from }, to: { ...a.to } }));
|
|
1685
|
+
return { rows: i, columns: o, merges: n };
|
|
1686
|
+
}
|
|
1687
|
+
function Gs(e, t) {
|
|
1688
|
+
if (e.src.kind !== "table") throw new Error(`元素 ${e.id} 不是表格`);
|
|
1689
|
+
const r = t.template ?? e.src.rows.length - 1, s = e.src.rows[r];
|
|
1690
|
+
if (!s) throw new Error(`表格 ${e.id} 的行模板无效:${r}`);
|
|
1691
|
+
return s;
|
|
1692
|
+
}
|
|
1693
|
+
function Ys(e) {
|
|
1694
|
+
return `${e.r}:${e.c}`;
|
|
1695
|
+
}
|
|
1696
|
+
function Ks(e, t) {
|
|
1697
|
+
return `@${e.length}:${e}:${t}`;
|
|
1698
|
+
}
|
|
1699
|
+
function At(e) {
|
|
1700
|
+
return typeof e == "number" ? `#${e}` : e;
|
|
1701
|
+
}
|
|
1702
|
+
function Js(e, t) {
|
|
1703
|
+
const r = At(e), s = At(t);
|
|
1704
|
+
return `!${r.length}:${r}:${s.length}:${s}`;
|
|
1705
|
+
}
|
|
1706
|
+
function fr(e, t) {
|
|
1707
|
+
var r;
|
|
1708
|
+
return e.src.kind !== "table" ? null : ((r = ne(e)[t.r]) == null ? void 0 : r.rowRef) ?? null;
|
|
1709
|
+
}
|
|
1710
|
+
function cr(e, t) {
|
|
1711
|
+
var r;
|
|
1712
|
+
return e.src.kind !== "table" ? null : ((r = ye(e)[t.c]) == null ? void 0 : r.columnRef) ?? null;
|
|
1713
|
+
}
|
|
1714
|
+
function Qs(e, t) {
|
|
1715
|
+
return typeof e == "number" ? Ys({ r: e, c: t }) : Ks(e, t);
|
|
1716
|
+
}
|
|
1717
|
+
function en(e, t) {
|
|
1718
|
+
return typeof t == "number" ? Qs(e, t) : Js(e, t);
|
|
1719
|
+
}
|
|
1720
|
+
function He(e, t) {
|
|
1721
|
+
const r = fr(e, t), s = cr(e, t);
|
|
1722
|
+
if (r === null || s === null) throw new Error(`表格单元格越界:${t.r},${t.c}`);
|
|
1723
|
+
return en(r, s);
|
|
1724
|
+
}
|
|
1725
|
+
function tn(e, t) {
|
|
1726
|
+
Qt(e, ["r", "c"], t);
|
|
1727
|
+
const r = e;
|
|
1728
|
+
if (!Number.isSafeInteger(r.r) || r.r < 0 || !Number.isSafeInteger(r.c) || r.c < 0)
|
|
1729
|
+
throw new Error(`${t} 必须使用非负安全整数行列坐标`);
|
|
1730
|
+
}
|
|
1731
|
+
const it = /* @__PURE__ */ new WeakMap();
|
|
1732
|
+
function rn(e) {
|
|
1733
|
+
return Object.entries(e.ovr.tableRows ?? {}).map(([t, r]) => ({ id: t, ...r })).sort((t, r) => t.order < r.order ? -1 : t.order > r.order ? 1 : 0);
|
|
1734
|
+
}
|
|
1735
|
+
function ur(e) {
|
|
1736
|
+
const t = e.paragraphs[0], r = t == null ? void 0 : t.runs[0];
|
|
1737
|
+
if (!t || !r) throw new Error("表格行模板缺少可继承的段落与字符格式");
|
|
1738
|
+
return {
|
|
1739
|
+
...structuredClone(e),
|
|
1740
|
+
paragraphs: [{
|
|
1741
|
+
...structuredClone(t),
|
|
1742
|
+
runs: [{ ...structuredClone(r), text: "", math: void 0 }]
|
|
1743
|
+
}]
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
function sn(e) {
|
|
1747
|
+
var r;
|
|
1748
|
+
const t = e.text ?? ((r = e.editInfo) == null ? void 0 : r.textTemplate);
|
|
1749
|
+
if (!t) throw new Error("表格单元格模板缺少文本体");
|
|
1750
|
+
return {
|
|
1751
|
+
...structuredClone(e),
|
|
1752
|
+
colSpan: 1,
|
|
1753
|
+
rowSpan: 1,
|
|
1754
|
+
merged: !1,
|
|
1755
|
+
text: null,
|
|
1756
|
+
editInfo: { ...structuredClone(e.editInfo), textTemplate: ur(t) }
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
function nn(e) {
|
|
1760
|
+
let t = 0;
|
|
1761
|
+
return {
|
|
1762
|
+
height: e.height,
|
|
1763
|
+
cells: e.cells.map((r, s) => {
|
|
1764
|
+
var a;
|
|
1765
|
+
const i = s < t;
|
|
1766
|
+
i || (t = Math.max(t, s + Math.max(1, r.colSpan)));
|
|
1767
|
+
const o = r.text ?? ((a = r.editInfo) == null ? void 0 : a.textTemplate);
|
|
1768
|
+
if (!o) throw new Error(`表格行模板第 ${s} 格缺少文本体`);
|
|
1769
|
+
const n = ur(o);
|
|
1770
|
+
return {
|
|
1771
|
+
...structuredClone(r),
|
|
1772
|
+
colSpan: i ? 1 : Math.max(1, r.colSpan),
|
|
1773
|
+
rowSpan: 1,
|
|
1774
|
+
merged: i,
|
|
1775
|
+
text: null,
|
|
1776
|
+
editInfo: { textTemplate: n }
|
|
1777
|
+
};
|
|
1778
|
+
})
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
function on(e, t, r) {
|
|
1782
|
+
var i;
|
|
1783
|
+
const s = (i = it.get(e)) == null ? void 0 : i.get(t);
|
|
1784
|
+
return (s == null ? void 0 : s.template) === r ? s.row : nn(r);
|
|
1785
|
+
}
|
|
1786
|
+
function pr(e) {
|
|
1787
|
+
var h;
|
|
1788
|
+
if (e.src.kind !== "table") throw new Error(`元素 ${e.id} 不是表格`);
|
|
1789
|
+
const t = e.src, r = rn(e);
|
|
1790
|
+
if (!r.length) {
|
|
1791
|
+
it.delete(e);
|
|
1792
|
+
const p = ne(e);
|
|
1793
|
+
return p.length === t.rows.length ? t.rows : p.map((l) => t.rows[l.source]);
|
|
1794
|
+
}
|
|
1795
|
+
const s = (h = t.editInfo) == null ? void 0 : h.tableRowAppend, i = r.every((p) => p.order > Ze(t.rows.length - 1)), o = [...t.rows];
|
|
1796
|
+
s && i && (o[o.length - 1] = s.previousLast ?? s.regular[1]);
|
|
1797
|
+
const n = /* @__PURE__ */ new Map(), a = new Map(r.map((p, l) => [p.id, l])), c = ne(e).map((p) => {
|
|
1798
|
+
if (p.source !== null) return o[p.source];
|
|
1799
|
+
const l = a.get(p.id), m = (i ? l === r.length - 1 ? s == null ? void 0 : s.last[l % 2] : s == null ? void 0 : s.regular[l % 2] : void 0) ?? Gs(e, p), g = on(e, p.id, m);
|
|
1800
|
+
return n.set(p.id, { template: m, row: g }), g;
|
|
1801
|
+
});
|
|
1802
|
+
return it.set(e, n), c;
|
|
1803
|
+
}
|
|
1804
|
+
function an(e) {
|
|
1805
|
+
if (e.src.kind !== "table") return !1;
|
|
1806
|
+
if (e.ovr.tableColumns || e.ovr.tableRemovedRows || e.ovr.tableRemovedColumns || e.ovr.tableRowHeights || e.ovr.tableColumnWidths || e.ovr.tableMerges !== void 0) return !0;
|
|
1807
|
+
const t = Ze(e.src.rows.length - 1);
|
|
1808
|
+
return Object.values(e.ovr.tableRows ?? {}).some((r) => r.order <= t);
|
|
1809
|
+
}
|
|
1810
|
+
function ln(e, t) {
|
|
1811
|
+
return { ...t ? sn(e) : structuredClone(e), colSpan: 1, rowSpan: 1, merged: !1 };
|
|
1812
|
+
}
|
|
1813
|
+
function fn(e, t) {
|
|
1814
|
+
if (e.src.kind !== "table") throw new Error(`元素 ${e.id} 不是表格`);
|
|
1815
|
+
const r = e.src, s = ne(e), i = ye(e), o = pr(e), n = s.map((u, d) => {
|
|
1816
|
+
var w;
|
|
1817
|
+
const v = u.source ?? u.template ?? r.rows.length - 1, P = o[d] ?? r.rows[v], x = i.map((k) => {
|
|
1818
|
+
const b = k.source ?? k.template ?? r.colWidths.length - 1, $ = k.source === null ? P.cells[b] ?? P.cells[P.cells.length - 1] : P.cells[k.source];
|
|
1819
|
+
if (!$) throw new Error(`表格 ${e.id} 缺少单元格模板`);
|
|
1820
|
+
return ln($, u.source === null || k.source === null);
|
|
1821
|
+
});
|
|
1822
|
+
return {
|
|
1823
|
+
height: ((w = e.ovr.tableRowHeights) == null ? void 0 : w[u.id]) ?? P.height,
|
|
1824
|
+
cells: x
|
|
1825
|
+
};
|
|
1826
|
+
}), a = Hs({ elements: { [e.id]: e } }, e.id);
|
|
1827
|
+
for (const u of a.merges) {
|
|
1828
|
+
const d = a.rows.findIndex((I) => I.id === u.from.row), v = a.rows.findIndex((I) => I.id === u.to.row), P = a.columns.findIndex((I) => I.id === u.from.column), x = a.columns.findIndex((I) => I.id === u.to.column);
|
|
1829
|
+
if ([d, v, P, x].some((I) => I < 0)) continue;
|
|
1830
|
+
const w = Math.min(d, v), k = Math.max(d, v), b = Math.min(P, x), $ = Math.max(P, x);
|
|
1831
|
+
n[w].cells[b] = {
|
|
1832
|
+
...n[w].cells[b],
|
|
1833
|
+
rowSpan: k - w + 1,
|
|
1834
|
+
colSpan: $ - b + 1
|
|
1835
|
+
};
|
|
1836
|
+
for (let I = w; I <= k; I++) for (let C = b; C <= $; C++)
|
|
1837
|
+
(I !== w || C !== b) && (n[I].cells[C] = {
|
|
1838
|
+
...n[I].cells[C],
|
|
1839
|
+
merged: !0,
|
|
1840
|
+
rowSpan: 1,
|
|
1841
|
+
colSpan: 1
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
const c = i.map((u) => {
|
|
1845
|
+
var d;
|
|
1846
|
+
return ((d = e.ovr.tableColumnWidths) == null ? void 0 : d[u.id]) ?? (u.source === null ? r.colWidths[u.template ?? r.colWidths.length - 1] : r.colWidths[u.source]);
|
|
1847
|
+
}), h = r.colWidths.reduce((u, d) => u + d, 0), p = r.rows.reduce((u, d) => u + d.height, 0), l = typeof e.ovr.w == "number" ? e.ovr.w : t.w, f = typeof e.ovr.h == "number" ? e.ovr.h : t.h, m = c.reduce((u, d) => u + d, 0), g = n.reduce((u, d) => u + d.height, 0);
|
|
1848
|
+
return {
|
|
1849
|
+
...t,
|
|
1850
|
+
colWidths: c,
|
|
1851
|
+
rows: n,
|
|
1852
|
+
w: h > 0 ? m * l / h : m,
|
|
1853
|
+
h: p > 0 ? g * f / p : g
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
function Ft(e) {
|
|
1857
|
+
const t = e.lastIndexOf("/"), r = t < 0 ? "" : e.slice(0, t + 1), s = t < 0 ? e : e.slice(t + 1);
|
|
1858
|
+
return `${r}_rels/${s}.rels`;
|
|
1859
|
+
}
|
|
1860
|
+
function Ot(e, t) {
|
|
1861
|
+
const r = e.split("/").slice(0, -1), s = t.split("/");
|
|
1862
|
+
let i = 0;
|
|
1863
|
+
for (; i < r.length && i < s.length && r[i] === s[i]; ) i++;
|
|
1864
|
+
return `${"../".repeat(r.length - i)}${s.slice(i).join("/")}`;
|
|
1865
|
+
}
|
|
1866
|
+
function cn(e, t) {
|
|
1867
|
+
var c, h, p, l, f, m, g, u, d, v, P, x, w;
|
|
1868
|
+
if (e.id !== t.id || e.meta.editable !== "full")
|
|
1869
|
+
throw new Error(`找不到可编辑文字的元素:${t.id}`);
|
|
1870
|
+
if (t.cell === void 0) {
|
|
1871
|
+
if (e.src.kind !== "shape" || !e.src.text && !e.meta.textTemplate)
|
|
1872
|
+
throw new Error(`找不到可编辑文字的形状:${t.id}`);
|
|
1873
|
+
return {
|
|
1874
|
+
record: e,
|
|
1875
|
+
body: e.src.text ?? e.meta.textTemplate,
|
|
1876
|
+
levelTemplate: ((c = e.src.editInfo) == null ? void 0 : c.textLevelTemplate) ?? e.meta.textTemplate,
|
|
1877
|
+
before: e.ovr.text,
|
|
1878
|
+
patchTarget: { id: t.id },
|
|
1879
|
+
empty: ((h = e.ovr.text) == null ? void 0 : h.kind) === "empty" || !e.ovr.text && e.src.text === null
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
if (tn(t.cell, "文字命令 cell"), e.src.kind !== "table") throw new Error(`文字命令 cell 必须指向表格:${t.id}`);
|
|
1883
|
+
const s = (p = (an(e) ? fn(e, e.src).rows : pr(e))[t.cell.r]) == null ? void 0 : p.cells[t.cell.c];
|
|
1884
|
+
if (!s) throw new Error(`表格单元格越界:${t.cell.r},${t.cell.c}`);
|
|
1885
|
+
const i = {
|
|
1886
|
+
row: (l = ne(e)[t.cell.r]) == null ? void 0 : l.id,
|
|
1887
|
+
column: (f = ye(e)[t.cell.c]) == null ? void 0 : f.id
|
|
1888
|
+
};
|
|
1889
|
+
if (!i.row || !i.column || s.merged || Bs(e, i) === "placeholder")
|
|
1890
|
+
throw new Error(`合并占位格不可单独编辑:${t.cell.r},${t.cell.c}`);
|
|
1891
|
+
const o = s.text ?? ((m = s.editInfo) == null ? void 0 : m.textTemplate);
|
|
1892
|
+
if (!o) throw new Error(`表格单元格缺少可编辑文本体:${t.cell.r},${t.cell.c}`);
|
|
1893
|
+
const n = fr(e, t.cell), a = cr(e, t.cell);
|
|
1894
|
+
if (n === null || a === null) throw new Error(`表格单元格越界:${t.cell.r},${t.cell.c}`);
|
|
1895
|
+
return {
|
|
1896
|
+
record: e,
|
|
1897
|
+
body: o,
|
|
1898
|
+
before: (u = (g = e.ovr.tableCells) == null ? void 0 : g[He(e, t.cell)]) == null ? void 0 : u.text,
|
|
1899
|
+
patchTarget: { id: t.id, cell: { row: n, column: a } },
|
|
1900
|
+
empty: ((P = (v = (d = e.ovr.tableCells) == null ? void 0 : d[He(e, t.cell)]) == null ? void 0 : v.text) == null ? void 0 : P.kind) === "empty" || !((w = (x = e.ovr.tableCells) == null ? void 0 : x[He(e, t.cell)]) != null && w.text) && s.text === null
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
const mr = (e, t) => {
|
|
1904
|
+
if (typeof e == "number") {
|
|
1905
|
+
if (t === 3)
|
|
1906
|
+
return {
|
|
1907
|
+
mode: "rgb",
|
|
1908
|
+
r: (e >> 8 & 15 | e >> 4 & 240) / 255,
|
|
1909
|
+
g: (e >> 4 & 15 | e & 240) / 255,
|
|
1910
|
+
b: (e & 15 | e << 4 & 240) / 255
|
|
1911
|
+
};
|
|
1912
|
+
if (t === 4)
|
|
1913
|
+
return {
|
|
1914
|
+
mode: "rgb",
|
|
1915
|
+
r: (e >> 12 & 15 | e >> 8 & 240) / 255,
|
|
1916
|
+
g: (e >> 8 & 15 | e >> 4 & 240) / 255,
|
|
1917
|
+
b: (e >> 4 & 15 | e & 240) / 255,
|
|
1918
|
+
alpha: (e & 15 | e << 4 & 240) / 255
|
|
1919
|
+
};
|
|
1920
|
+
if (t === 6)
|
|
1921
|
+
return {
|
|
1922
|
+
mode: "rgb",
|
|
1923
|
+
r: (e >> 16 & 255) / 255,
|
|
1924
|
+
g: (e >> 8 & 255) / 255,
|
|
1925
|
+
b: (e & 255) / 255
|
|
1926
|
+
};
|
|
1927
|
+
if (t === 8)
|
|
1928
|
+
return {
|
|
1929
|
+
mode: "rgb",
|
|
1930
|
+
r: (e >> 24 & 255) / 255,
|
|
1931
|
+
g: (e >> 16 & 255) / 255,
|
|
1932
|
+
b: (e >> 8 & 255) / 255,
|
|
1933
|
+
alpha: (e & 255) / 255
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1936
|
+
}, un = {
|
|
1937
|
+
aliceblue: 15792383,
|
|
1938
|
+
antiquewhite: 16444375,
|
|
1939
|
+
aqua: 65535,
|
|
1940
|
+
aquamarine: 8388564,
|
|
1941
|
+
azure: 15794175,
|
|
1942
|
+
beige: 16119260,
|
|
1943
|
+
bisque: 16770244,
|
|
1944
|
+
black: 0,
|
|
1945
|
+
blanchedalmond: 16772045,
|
|
1946
|
+
blue: 255,
|
|
1947
|
+
blueviolet: 9055202,
|
|
1948
|
+
brown: 10824234,
|
|
1949
|
+
burlywood: 14596231,
|
|
1950
|
+
cadetblue: 6266528,
|
|
1951
|
+
chartreuse: 8388352,
|
|
1952
|
+
chocolate: 13789470,
|
|
1953
|
+
coral: 16744272,
|
|
1954
|
+
cornflowerblue: 6591981,
|
|
1955
|
+
cornsilk: 16775388,
|
|
1956
|
+
crimson: 14423100,
|
|
1957
|
+
cyan: 65535,
|
|
1958
|
+
darkblue: 139,
|
|
1959
|
+
darkcyan: 35723,
|
|
1960
|
+
darkgoldenrod: 12092939,
|
|
1961
|
+
darkgray: 11119017,
|
|
1962
|
+
darkgreen: 25600,
|
|
1963
|
+
darkgrey: 11119017,
|
|
1964
|
+
darkkhaki: 12433259,
|
|
1965
|
+
darkmagenta: 9109643,
|
|
1966
|
+
darkolivegreen: 5597999,
|
|
1967
|
+
darkorange: 16747520,
|
|
1968
|
+
darkorchid: 10040012,
|
|
1969
|
+
darkred: 9109504,
|
|
1970
|
+
darksalmon: 15308410,
|
|
1971
|
+
darkseagreen: 9419919,
|
|
1972
|
+
darkslateblue: 4734347,
|
|
1973
|
+
darkslategray: 3100495,
|
|
1974
|
+
darkslategrey: 3100495,
|
|
1975
|
+
darkturquoise: 52945,
|
|
1976
|
+
darkviolet: 9699539,
|
|
1977
|
+
deeppink: 16716947,
|
|
1978
|
+
deepskyblue: 49151,
|
|
1979
|
+
dimgray: 6908265,
|
|
1980
|
+
dimgrey: 6908265,
|
|
1981
|
+
dodgerblue: 2003199,
|
|
1982
|
+
firebrick: 11674146,
|
|
1983
|
+
floralwhite: 16775920,
|
|
1984
|
+
forestgreen: 2263842,
|
|
1985
|
+
fuchsia: 16711935,
|
|
1986
|
+
gainsboro: 14474460,
|
|
1987
|
+
ghostwhite: 16316671,
|
|
1988
|
+
gold: 16766720,
|
|
1989
|
+
goldenrod: 14329120,
|
|
1990
|
+
gray: 8421504,
|
|
1991
|
+
green: 32768,
|
|
1992
|
+
greenyellow: 11403055,
|
|
1993
|
+
grey: 8421504,
|
|
1994
|
+
honeydew: 15794160,
|
|
1995
|
+
hotpink: 16738740,
|
|
1996
|
+
indianred: 13458524,
|
|
1997
|
+
indigo: 4915330,
|
|
1998
|
+
ivory: 16777200,
|
|
1999
|
+
khaki: 15787660,
|
|
2000
|
+
lavender: 15132410,
|
|
2001
|
+
lavenderblush: 16773365,
|
|
2002
|
+
lawngreen: 8190976,
|
|
2003
|
+
lemonchiffon: 16775885,
|
|
2004
|
+
lightblue: 11393254,
|
|
2005
|
+
lightcoral: 15761536,
|
|
2006
|
+
lightcyan: 14745599,
|
|
2007
|
+
lightgoldenrodyellow: 16448210,
|
|
2008
|
+
lightgray: 13882323,
|
|
2009
|
+
lightgreen: 9498256,
|
|
2010
|
+
lightgrey: 13882323,
|
|
2011
|
+
lightpink: 16758465,
|
|
2012
|
+
lightsalmon: 16752762,
|
|
2013
|
+
lightseagreen: 2142890,
|
|
2014
|
+
lightskyblue: 8900346,
|
|
2015
|
+
lightslategray: 7833753,
|
|
2016
|
+
lightslategrey: 7833753,
|
|
2017
|
+
lightsteelblue: 11584734,
|
|
2018
|
+
lightyellow: 16777184,
|
|
2019
|
+
lime: 65280,
|
|
2020
|
+
limegreen: 3329330,
|
|
2021
|
+
linen: 16445670,
|
|
2022
|
+
magenta: 16711935,
|
|
2023
|
+
maroon: 8388608,
|
|
2024
|
+
mediumaquamarine: 6737322,
|
|
2025
|
+
mediumblue: 205,
|
|
2026
|
+
mediumorchid: 12211667,
|
|
2027
|
+
mediumpurple: 9662683,
|
|
2028
|
+
mediumseagreen: 3978097,
|
|
2029
|
+
mediumslateblue: 8087790,
|
|
2030
|
+
mediumspringgreen: 64154,
|
|
2031
|
+
mediumturquoise: 4772300,
|
|
2032
|
+
mediumvioletred: 13047173,
|
|
2033
|
+
midnightblue: 1644912,
|
|
2034
|
+
mintcream: 16121850,
|
|
2035
|
+
mistyrose: 16770273,
|
|
2036
|
+
moccasin: 16770229,
|
|
2037
|
+
navajowhite: 16768685,
|
|
2038
|
+
navy: 128,
|
|
2039
|
+
oldlace: 16643558,
|
|
2040
|
+
olive: 8421376,
|
|
2041
|
+
olivedrab: 7048739,
|
|
2042
|
+
orange: 16753920,
|
|
2043
|
+
orangered: 16729344,
|
|
2044
|
+
orchid: 14315734,
|
|
2045
|
+
palegoldenrod: 15657130,
|
|
2046
|
+
palegreen: 10025880,
|
|
2047
|
+
paleturquoise: 11529966,
|
|
2048
|
+
palevioletred: 14381203,
|
|
2049
|
+
papayawhip: 16773077,
|
|
2050
|
+
peachpuff: 16767673,
|
|
2051
|
+
peru: 13468991,
|
|
2052
|
+
pink: 16761035,
|
|
2053
|
+
plum: 14524637,
|
|
2054
|
+
powderblue: 11591910,
|
|
2055
|
+
purple: 8388736,
|
|
2056
|
+
// Added in CSS Colors Level 4:
|
|
2057
|
+
// https://drafts.csswg.org/css-color/#changes-from-3
|
|
2058
|
+
rebeccapurple: 6697881,
|
|
2059
|
+
red: 16711680,
|
|
2060
|
+
rosybrown: 12357519,
|
|
2061
|
+
royalblue: 4286945,
|
|
2062
|
+
saddlebrown: 9127187,
|
|
2063
|
+
salmon: 16416882,
|
|
2064
|
+
sandybrown: 16032864,
|
|
2065
|
+
seagreen: 3050327,
|
|
2066
|
+
seashell: 16774638,
|
|
2067
|
+
sienna: 10506797,
|
|
2068
|
+
silver: 12632256,
|
|
2069
|
+
skyblue: 8900331,
|
|
2070
|
+
slateblue: 6970061,
|
|
2071
|
+
slategray: 7372944,
|
|
2072
|
+
slategrey: 7372944,
|
|
2073
|
+
snow: 16775930,
|
|
2074
|
+
springgreen: 65407,
|
|
2075
|
+
steelblue: 4620980,
|
|
2076
|
+
tan: 13808780,
|
|
2077
|
+
teal: 32896,
|
|
2078
|
+
thistle: 14204888,
|
|
2079
|
+
tomato: 16737095,
|
|
2080
|
+
turquoise: 4251856,
|
|
2081
|
+
violet: 15631086,
|
|
2082
|
+
wheat: 16113331,
|
|
2083
|
+
white: 16777215,
|
|
2084
|
+
whitesmoke: 16119285,
|
|
2085
|
+
yellow: 16776960,
|
|
2086
|
+
yellowgreen: 10145074
|
|
2087
|
+
}, pn = (e) => mr(un[e.toLowerCase()], 6), mn = /^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i, dn = (e) => {
|
|
2088
|
+
let t;
|
|
2089
|
+
return (t = e.match(mn)) ? mr(parseInt(t[1], 16), t[1].length) : void 0;
|
|
2090
|
+
}, pe = "([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)", Ge = `${pe}%`, dr = `(?:${pe}%|${pe})`, je = "\\s*,\\s*", hn = new RegExp(
|
|
2091
|
+
`^rgba?\\(\\s*${pe}${je}${pe}${je}${pe}\\s*(?:,\\s*${dr}\\s*)?\\)$`
|
|
2092
|
+
), yn = new RegExp(
|
|
2093
|
+
`^rgba?\\(\\s*${Ge}${je}${Ge}${je}${Ge}\\s*(?:,\\s*${dr}\\s*)?\\)$`
|
|
2094
|
+
), gn = (e) => {
|
|
2095
|
+
let t = { mode: "rgb" }, r;
|
|
2096
|
+
if (r = e.match(hn))
|
|
2097
|
+
r[1] !== void 0 && (t.r = r[1] / 255), r[2] !== void 0 && (t.g = r[2] / 255), r[3] !== void 0 && (t.b = r[3] / 255);
|
|
2098
|
+
else if (r = e.match(yn))
|
|
2099
|
+
r[1] !== void 0 && (t.r = r[1] / 100), r[2] !== void 0 && (t.g = r[2] / 100), r[3] !== void 0 && (t.b = r[3] / 100);
|
|
2100
|
+
else
|
|
2101
|
+
return;
|
|
2102
|
+
return r[4] !== void 0 ? t.alpha = Math.max(0, Math.min(1, r[4] / 100)) : r[5] !== void 0 && (t.alpha = Math.max(0, Math.min(1, +r[5]))), t;
|
|
2103
|
+
}, vn = (e, t) => e === void 0 ? void 0 : typeof e != "object" ? vr(e) : e.mode !== void 0 ? e : t ? { ...e, mode: t } : void 0, wn = (e = "rgb") => (t) => (t = vn(t, e)) !== void 0 ? (
|
|
2104
|
+
// if the color's mode corresponds to our target mode
|
|
2105
|
+
t.mode === e ? (
|
|
2106
|
+
// then just return the color
|
|
2107
|
+
t
|
|
2108
|
+
) : (
|
|
2109
|
+
// otherwise check to see if we have a dedicated
|
|
2110
|
+
// converter for the target mode
|
|
2111
|
+
Y[t.mode][e] ? (
|
|
2112
|
+
// and return its result...
|
|
2113
|
+
Y[t.mode][e](t)
|
|
2114
|
+
) : (
|
|
2115
|
+
// ...otherwise pass through RGB as an intermediary step.
|
|
2116
|
+
// if the target mode is RGB...
|
|
2117
|
+
e === "rgb" ? (
|
|
2118
|
+
// just return the RGB
|
|
2119
|
+
Y[t.mode].rgb(t)
|
|
2120
|
+
) : (
|
|
2121
|
+
// otherwise convert color.mode -> RGB -> target_mode
|
|
2122
|
+
Y.rgb[e](Y[t.mode].rgb(t))
|
|
2123
|
+
)
|
|
2124
|
+
)
|
|
2125
|
+
)
|
|
2126
|
+
) : void 0, Y = {}, hr = {}, Ue = [], yr = {}, bn = (e) => e, xn = (e) => (Y[e.mode] = {
|
|
2127
|
+
...Y[e.mode],
|
|
2128
|
+
...e.toMode
|
|
2129
|
+
}, Object.keys(e.fromMode || {}).forEach((t) => {
|
|
2130
|
+
Y[t] || (Y[t] = {}), Y[t][e.mode] = e.fromMode[t];
|
|
2131
|
+
}), e.ranges || (e.ranges = {}), e.difference || (e.difference = {}), e.channels.forEach((t) => {
|
|
2132
|
+
if (e.ranges[t] === void 0 && (e.ranges[t] = [0, 1]), !e.interpolate[t])
|
|
2133
|
+
throw new Error(`Missing interpolator for: ${t}`);
|
|
2134
|
+
typeof e.interpolate[t] == "function" && (e.interpolate[t] = {
|
|
2135
|
+
use: e.interpolate[t]
|
|
2136
|
+
}), e.interpolate[t].fixup || (e.interpolate[t].fixup = bn);
|
|
2137
|
+
}), hr[e.mode] = e, (e.parse || []).forEach((t) => {
|
|
2138
|
+
kn(t, e.mode);
|
|
2139
|
+
}), wn(e.mode)), Pn = (e) => hr[e], kn = (e, t) => {
|
|
2140
|
+
if (typeof e == "string") {
|
|
2141
|
+
if (!t)
|
|
2142
|
+
throw new Error("'mode' required when 'parser' is a string");
|
|
2143
|
+
yr[e] = t;
|
|
2144
|
+
} else typeof e == "function" && Ue.indexOf(e) < 0 && Ue.push(e);
|
|
2145
|
+
}, ot = /[^\x00-\x7F]|[a-zA-Z_]/, Tn = /[^\x00-\x7F]|[-\w]/, N = {
|
|
2146
|
+
Function: "function",
|
|
2147
|
+
Ident: "ident",
|
|
2148
|
+
Number: "number",
|
|
2149
|
+
Percentage: "percentage",
|
|
2150
|
+
ParenClose: ")",
|
|
2151
|
+
None: "none",
|
|
2152
|
+
Hue: "hue",
|
|
2153
|
+
Alpha: "alpha"
|
|
2154
|
+
};
|
|
2155
|
+
let S = 0;
|
|
2156
|
+
function Ce(e) {
|
|
2157
|
+
let t = e[S], r = e[S + 1];
|
|
2158
|
+
return t === "-" || t === "+" ? /\d/.test(r) || r === "." && /\d/.test(e[S + 2]) : t === "." ? /\d/.test(r) : /\d/.test(t);
|
|
2159
|
+
}
|
|
2160
|
+
function at(e) {
|
|
2161
|
+
if (S >= e.length)
|
|
2162
|
+
return !1;
|
|
2163
|
+
let t = e[S];
|
|
2164
|
+
if (ot.test(t))
|
|
2165
|
+
return !0;
|
|
2166
|
+
if (t === "-") {
|
|
2167
|
+
if (e.length - S < 2)
|
|
2168
|
+
return !1;
|
|
2169
|
+
let r = e[S + 1];
|
|
2170
|
+
return !!(r === "-" || ot.test(r));
|
|
2171
|
+
}
|
|
2172
|
+
return !1;
|
|
2173
|
+
}
|
|
2174
|
+
const In = {
|
|
2175
|
+
deg: 1,
|
|
2176
|
+
rad: 180 / Math.PI,
|
|
2177
|
+
grad: 9 / 10,
|
|
2178
|
+
turn: 360
|
|
2179
|
+
};
|
|
2180
|
+
function ve(e) {
|
|
2181
|
+
let t = "";
|
|
2182
|
+
if ((e[S] === "-" || e[S] === "+") && (t += e[S++]), t += Ne(e), e[S] === "." && /\d/.test(e[S + 1]) && (t += e[S++] + Ne(e)), (e[S] === "e" || e[S] === "E") && ((e[S + 1] === "-" || e[S + 1] === "+") && /\d/.test(e[S + 2]) ? t += e[S++] + e[S++] + Ne(e) : /\d/.test(e[S + 1]) && (t += e[S++] + Ne(e))), at(e)) {
|
|
2183
|
+
let r = qe(e);
|
|
2184
|
+
return r === "deg" || r === "rad" || r === "turn" || r === "grad" ? { type: N.Hue, value: t * In[r] } : void 0;
|
|
2185
|
+
}
|
|
2186
|
+
return e[S] === "%" ? (S++, { type: N.Percentage, value: +t }) : { type: N.Number, value: +t };
|
|
2187
|
+
}
|
|
2188
|
+
function Ne(e) {
|
|
2189
|
+
let t = "";
|
|
2190
|
+
for (; /\d/.test(e[S]); )
|
|
2191
|
+
t += e[S++];
|
|
2192
|
+
return t;
|
|
2193
|
+
}
|
|
2194
|
+
function qe(e) {
|
|
2195
|
+
let t = "";
|
|
2196
|
+
for (; S < e.length && Tn.test(e[S]); )
|
|
2197
|
+
t += e[S++];
|
|
2198
|
+
return t;
|
|
2199
|
+
}
|
|
2200
|
+
function $n(e) {
|
|
2201
|
+
let t = qe(e);
|
|
2202
|
+
return e[S] === "(" ? (S++, { type: N.Function, value: t }) : t === "none" ? { type: N.None, value: void 0 } : { type: N.Ident, value: t };
|
|
2203
|
+
}
|
|
2204
|
+
function Sn(e = "") {
|
|
2205
|
+
let t = e.trim(), r = [], s;
|
|
2206
|
+
for (S = 0; S < t.length; ) {
|
|
2207
|
+
if (s = t[S++], s === `
|
|
2208
|
+
` || s === " " || s === " ") {
|
|
2209
|
+
for (; S < t.length && (t[S] === `
|
|
2210
|
+
` || t[S] === " " || t[S] === " "); )
|
|
2211
|
+
S++;
|
|
2212
|
+
continue;
|
|
2213
|
+
}
|
|
2214
|
+
if (s === ",")
|
|
2215
|
+
return;
|
|
2216
|
+
if (s === ")") {
|
|
2217
|
+
r.push({ type: N.ParenClose });
|
|
2218
|
+
continue;
|
|
2219
|
+
}
|
|
2220
|
+
if (s === "+") {
|
|
2221
|
+
if (S--, Ce(t)) {
|
|
2222
|
+
r.push(ve(t));
|
|
2223
|
+
continue;
|
|
2224
|
+
}
|
|
2225
|
+
return;
|
|
2226
|
+
}
|
|
2227
|
+
if (s === "-") {
|
|
2228
|
+
if (S--, Ce(t)) {
|
|
2229
|
+
r.push(ve(t));
|
|
2230
|
+
continue;
|
|
2231
|
+
}
|
|
2232
|
+
if (at(t)) {
|
|
2233
|
+
r.push({ type: N.Ident, value: qe(t) });
|
|
2234
|
+
continue;
|
|
2235
|
+
}
|
|
2236
|
+
return;
|
|
2237
|
+
}
|
|
2238
|
+
if (s === ".") {
|
|
2239
|
+
if (S--, Ce(t)) {
|
|
2240
|
+
r.push(ve(t));
|
|
2241
|
+
continue;
|
|
2242
|
+
}
|
|
2243
|
+
return;
|
|
2244
|
+
}
|
|
2245
|
+
if (s === "/") {
|
|
2246
|
+
for (; S < t.length && (t[S] === `
|
|
2247
|
+
` || t[S] === " " || t[S] === " "); )
|
|
2248
|
+
S++;
|
|
2249
|
+
let i;
|
|
2250
|
+
if (Ce(t) && (i = ve(t), i.type !== N.Hue)) {
|
|
2251
|
+
r.push({ type: N.Alpha, value: i });
|
|
2252
|
+
continue;
|
|
2253
|
+
}
|
|
2254
|
+
if (at(t) && qe(t) === "none") {
|
|
2255
|
+
r.push({
|
|
2256
|
+
type: N.Alpha,
|
|
2257
|
+
value: { type: N.None, value: void 0 }
|
|
2258
|
+
});
|
|
2259
|
+
continue;
|
|
2260
|
+
}
|
|
2261
|
+
return;
|
|
2262
|
+
}
|
|
2263
|
+
if (/\d/.test(s)) {
|
|
2264
|
+
S--, r.push(ve(t));
|
|
2265
|
+
continue;
|
|
2266
|
+
}
|
|
2267
|
+
if (ot.test(s)) {
|
|
2268
|
+
S--, r.push($n(t));
|
|
2269
|
+
continue;
|
|
2270
|
+
}
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
return r;
|
|
2274
|
+
}
|
|
2275
|
+
function En(e) {
|
|
2276
|
+
e._i = 0;
|
|
2277
|
+
let t = e[e._i++];
|
|
2278
|
+
if (!t || t.type !== N.Function || t.value !== "color" || (t = e[e._i++], t.type !== N.Ident))
|
|
2279
|
+
return;
|
|
2280
|
+
const r = yr[t.value];
|
|
2281
|
+
if (!r)
|
|
2282
|
+
return;
|
|
2283
|
+
const s = { mode: r }, i = gr(e, !1);
|
|
2284
|
+
if (!i)
|
|
2285
|
+
return;
|
|
2286
|
+
const o = Pn(r).channels;
|
|
2287
|
+
for (let n = 0, a, c; n < o.length; n++)
|
|
2288
|
+
a = i[n], c = o[n], a.type !== N.None && (s[c] = a.type === N.Number ? a.value : a.value / 100, c === "alpha" && (s[c] = Math.max(0, Math.min(1, s[c]))));
|
|
2289
|
+
return s;
|
|
2290
|
+
}
|
|
2291
|
+
function gr(e, t) {
|
|
2292
|
+
const r = [];
|
|
2293
|
+
let s;
|
|
2294
|
+
for (; e._i < e.length; ) {
|
|
2295
|
+
if (s = e[e._i++], s.type === N.None || s.type === N.Number || s.type === N.Alpha || s.type === N.Percentage || t && s.type === N.Hue) {
|
|
2296
|
+
r.push(s);
|
|
2297
|
+
continue;
|
|
2298
|
+
}
|
|
2299
|
+
if (s.type === N.ParenClose) {
|
|
2300
|
+
if (e._i < e.length)
|
|
2301
|
+
return;
|
|
2302
|
+
continue;
|
|
2303
|
+
}
|
|
2304
|
+
return;
|
|
2305
|
+
}
|
|
2306
|
+
if (!(r.length < 3 || r.length > 4)) {
|
|
2307
|
+
if (r.length === 4) {
|
|
2308
|
+
if (r[3].type !== N.Alpha)
|
|
2309
|
+
return;
|
|
2310
|
+
r[3] = r[3].value;
|
|
2311
|
+
}
|
|
2312
|
+
return r.length === 3 && r.push({ type: N.None, value: void 0 }), r.every((i) => i.type !== N.Alpha) ? r : void 0;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
function Cn(e, t) {
|
|
2316
|
+
e._i = 0;
|
|
2317
|
+
let r = e[e._i++];
|
|
2318
|
+
if (!r || r.type !== N.Function)
|
|
2319
|
+
return;
|
|
2320
|
+
let s = gr(e, t);
|
|
2321
|
+
if (s)
|
|
2322
|
+
return s.unshift(r.value), s;
|
|
2323
|
+
}
|
|
2324
|
+
const vr = (e) => {
|
|
2325
|
+
if (typeof e != "string")
|
|
2326
|
+
return;
|
|
2327
|
+
const t = Sn(e), r = t ? Cn(t, !0) : void 0;
|
|
2328
|
+
let s, i = 0, o = Ue.length;
|
|
2329
|
+
for (; i < o; )
|
|
2330
|
+
if ((s = Ue[i++](e, r)) !== void 0)
|
|
2331
|
+
return s;
|
|
2332
|
+
return t ? En(t) : void 0;
|
|
2333
|
+
};
|
|
2334
|
+
function Nn(e, t) {
|
|
2335
|
+
if (!t || t[0] !== "rgb" && t[0] !== "rgba")
|
|
2336
|
+
return;
|
|
2337
|
+
const r = { mode: "rgb" }, [, s, i, o, n] = t;
|
|
2338
|
+
if (!(s.type === N.Hue || i.type === N.Hue || o.type === N.Hue))
|
|
2339
|
+
return s.type !== N.None && (r.r = s.type === N.Number ? s.value / 255 : s.value / 100), i.type !== N.None && (r.g = i.type === N.Number ? i.value / 255 : i.value / 100), o.type !== N.None && (r.b = o.type === N.Number ? o.value / 255 : o.value / 100), n.type !== N.None && (r.alpha = Math.min(
|
|
2340
|
+
1,
|
|
2341
|
+
Math.max(
|
|
2342
|
+
0,
|
|
2343
|
+
n.type === N.Number ? n.value : n.value / 100
|
|
2344
|
+
)
|
|
2345
|
+
)), r;
|
|
2346
|
+
}
|
|
2347
|
+
const An = (e) => e === "transparent" ? { mode: "rgb", r: 0, g: 0, b: 0, alpha: 0 } : void 0, Fn = (e, t, r) => e + r * (t - e), On = (e) => {
|
|
2348
|
+
let t = [];
|
|
2349
|
+
for (let r = 0; r < e.length - 1; r++) {
|
|
2350
|
+
let s = e[r], i = e[r + 1];
|
|
2351
|
+
s === void 0 && i === void 0 ? t.push(void 0) : s !== void 0 && i !== void 0 ? t.push([s, i]) : t.push(s !== void 0 ? [s, s] : [i, i]);
|
|
2352
|
+
}
|
|
2353
|
+
return t;
|
|
2354
|
+
}, _n = (e) => (t) => {
|
|
2355
|
+
let r = On(t);
|
|
2356
|
+
return (s) => {
|
|
2357
|
+
let i = s * r.length, o = s >= 1 ? r.length - 1 : Math.max(Math.floor(i), 0), n = r[o];
|
|
2358
|
+
return n === void 0 ? void 0 : e(n[0], n[1], i - o);
|
|
2359
|
+
};
|
|
2360
|
+
}, Ae = _n(Fn), Mn = (e) => {
|
|
2361
|
+
let t = !1, r = e.map((s) => s !== void 0 ? (t = !0, s) : 1);
|
|
2362
|
+
return t ? r : e;
|
|
2363
|
+
}, Rn = {
|
|
2364
|
+
mode: "rgb",
|
|
2365
|
+
channels: ["r", "g", "b", "alpha"],
|
|
2366
|
+
parse: [
|
|
2367
|
+
Nn,
|
|
2368
|
+
dn,
|
|
2369
|
+
gn,
|
|
2370
|
+
pn,
|
|
2371
|
+
An,
|
|
2372
|
+
"srgb"
|
|
2373
|
+
],
|
|
2374
|
+
serialize: "srgb",
|
|
2375
|
+
interpolate: {
|
|
2376
|
+
r: Ae,
|
|
2377
|
+
g: Ae,
|
|
2378
|
+
b: Ae,
|
|
2379
|
+
alpha: { use: Ae, fixup: Mn }
|
|
2380
|
+
},
|
|
2381
|
+
gamut: !0,
|
|
2382
|
+
white: { r: 1, g: 1, b: 1 },
|
|
2383
|
+
black: { r: 0, g: 0, b: 0 }
|
|
2384
|
+
};
|
|
2385
|
+
class jn extends Error {
|
|
2386
|
+
constructor(t, r, s = null, i = null) {
|
|
2387
|
+
super(r), this.reason = t, this.slideNumber = s, this.elementId = i, this.name = "LayoutLintError";
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
xn(Rn);
|
|
2391
|
+
function Un(e) {
|
|
2392
|
+
const t = typeof e == "string" ? vr(e) : void 0;
|
|
2393
|
+
if (!t || t.mode !== "rgb" || ![t.r, t.g, t.b, t.alpha ?? 1].every((r) => typeof r == "number" && Number.isFinite(r))) throw new jn("invalid-color", `无法分析 sRGB 颜色:${String(e)}`);
|
|
2394
|
+
return [t.r, t.g, t.b, t.alpha ?? 1].map((r) => Math.max(0, Math.min(1, r)));
|
|
2395
|
+
}
|
|
2396
|
+
function K(e, t, r) {
|
|
2397
|
+
const s = Wt(
|
|
2398
|
+
e.slides[t].children,
|
|
2399
|
+
(i) => e.elements[i].meta.ph,
|
|
2400
|
+
{ type: r.type, idx: r.index }
|
|
2401
|
+
);
|
|
2402
|
+
if (!s) throw new E("placeholder-not-found", `新页 ${t} 缺少占位符 ${r.type}/${r.index}`);
|
|
2403
|
+
return s;
|
|
2404
|
+
}
|
|
2405
|
+
function we(e, t, r) {
|
|
2406
|
+
if (!cn(e.doc.elements[t], { id: t }).empty) throw new E("invalid-template", `新页占位符 ${t} 应为空,实际含页面直设文字`, null, null, t);
|
|
2407
|
+
const i = r.length ? r.flatMap((o) => o.text.split(`
|
|
2408
|
+
`).map((n) => ({ ...o, text: n }))) : [{ text: "" }];
|
|
2409
|
+
e.exec({ type: "EditText", id: t, ops: [{
|
|
2410
|
+
type: "replaceFragment",
|
|
2411
|
+
from: { p: 0, r: 0, off: 0 },
|
|
2412
|
+
to: { p: 0, r: 0, off: 0 },
|
|
2413
|
+
fragment: { paragraphs: i.map((o) => ({
|
|
2414
|
+
text: o.text,
|
|
2415
|
+
marks: o.text.length ? [{ from: 0, to: o.text.length, props: {} }] : []
|
|
2416
|
+
})) }
|
|
2417
|
+
}] }), i.forEach((o, n) => e.exec({
|
|
2418
|
+
type: "SetParaProps",
|
|
2419
|
+
id: t,
|
|
2420
|
+
range: { from: { p: n, r: 0, off: 0 }, to: { p: n, r: 0, off: o.text.length } },
|
|
2421
|
+
props: { level: o.level ?? 0, ...o.bullet === void 0 ? {} : { bullet: o.bullet ? { kind: "char", char: "•" } : { kind: "none" } } }
|
|
2422
|
+
})), e.exec({ type: "SetBodyProps", id: t, props: { autoFit: "normal" } });
|
|
2423
|
+
}
|
|
2424
|
+
function qn(e, t, r, s, i) {
|
|
2425
|
+
const o = K(e.doc, t, r), n = i.metadata.width / i.metadata.height, a = r.rect.w / r.rect.h;
|
|
2426
|
+
let c = { ...r.rect };
|
|
2427
|
+
if ((s.image.fit ?? "contain") === "contain") {
|
|
2428
|
+
const l = n > a ? c.w : c.h * n, f = n > a ? c.w / n : c.h;
|
|
2429
|
+
c = { x: c.x + (c.w - l) / 2, y: c.y + (c.h - f) / 2, w: l, h: f };
|
|
2430
|
+
}
|
|
2431
|
+
const h = new Set(e.doc.slides[t].children);
|
|
2432
|
+
r.type !== "pic" && e.exec({ type: "RemoveElement", id: o }), e.exec({
|
|
2433
|
+
type: "AddImage",
|
|
2434
|
+
slideId: t,
|
|
2435
|
+
rect: c,
|
|
2436
|
+
bytes: i.bytes,
|
|
2437
|
+
mime: s.image.mime,
|
|
2438
|
+
...r.type === "pic" ? { placeholderId: o } : {}
|
|
2439
|
+
});
|
|
2440
|
+
const p = e.doc.slides[t].children.find((l) => !h.has(l));
|
|
2441
|
+
if (!p) throw new E("invalid-result", `页面 ${t} 新增图片后未取得原生图片身份`);
|
|
2442
|
+
if (r.rot && e.exec({ type: "SetXfrm", id: p, rot: r.rot }), (r.flipH || r.flipV) && e.exec({ type: "SetFlip", id: p, h: r.flipH, v: r.flipV }), s.image.fit === "cover") {
|
|
2443
|
+
const l = n > a, f = Math.round((1 - (l ? a / n : n / a)) * 1e5);
|
|
2444
|
+
if (f >= 1e5)
|
|
2445
|
+
throw new E("image-crop-unrepresentable", "cover 裁剪后的面积小于 OOXML 十万分之一精度,不能无失真表示", null, "image.fit");
|
|
2446
|
+
const m = Math.floor(f / 2) / 1e5, g = (f - Math.floor(f / 2)) / 1e5;
|
|
2447
|
+
e.exec({ type: "SetCrop", id: p, crop: {
|
|
2448
|
+
l: l ? m : 0,
|
|
2449
|
+
r: l ? g : 0,
|
|
2450
|
+
t: l ? 0 : m,
|
|
2451
|
+
b: l ? 0 : g
|
|
2452
|
+
} });
|
|
2453
|
+
}
|
|
2454
|
+
s.image.altText !== void 0 && e.exec({ type: "SetAltText", id: p, title: null, descr: s.image.altText });
|
|
2455
|
+
}
|
|
2456
|
+
function zn(e, t, r, s, i) {
|
|
2457
|
+
const o = [...e.doc.slideOrder], n = [];
|
|
2458
|
+
t.forEach((a, c) => {
|
|
2459
|
+
var g, u;
|
|
2460
|
+
B(i);
|
|
2461
|
+
const h = r[c], l = [...e.exec({
|
|
2462
|
+
type: "AddSlide",
|
|
2463
|
+
layoutId: h.layoutId,
|
|
2464
|
+
at: { after: e.doc.slideOrder[e.doc.slideOrder.length - 1] ?? null }
|
|
2465
|
+
}).createdSlides][0];
|
|
2466
|
+
if (!l) throw new E("invalid-result", `第 ${c + 1} 页未取得新页身份`, c + 1);
|
|
2467
|
+
const f = K(e.doc, l, h.title);
|
|
2468
|
+
we(e, f, [{ text: a.title, bullet: !1 }]), a.type === "title" && h.subtitle && a.subtitle !== void 0 && we(e, K(e.doc, l, h.subtitle), [{ text: a.subtitle, bullet: !1 }]), (a.type === "section" || a.type === "image") && ((g = a.body) != null && g.length) && we(e, K(e.doc, l, h.bodies[0]), a.body), a.type === "content" && we(e, K(e.doc, l, h.bodies[0]), a.body), a.type === "two-column" && a.columns.forEach((d, v) => we(e, K(e.doc, l, h.bodies[v]), d)), a.type === "image" && qn(e, l, h.object, a, s.get(c)), a.type === "chart" && e.exec({ type: "RemoveElement", id: K(e.doc, l, h.object) }), a.notes !== void 0 && e.exec({ type: "SetNotes", id: l, text: a.notes });
|
|
2469
|
+
for (const d of e.doc.slides[l].children) {
|
|
2470
|
+
const v = e.doc.elements[d];
|
|
2471
|
+
v.src.kind === "shape" && v.meta.ph && ["dt", "sldNum", "ftr", "hdr"].includes(v.meta.ph.type) && e.exec({ type: "SetBodyProps", id: d, props: { autoFit: "normal" } });
|
|
2472
|
+
}
|
|
2473
|
+
const m = (u = e.doc.slides[l].origin) == null ? void 0 : u.part;
|
|
2474
|
+
if (!m) throw new E("invalid-result", `第 ${c + 1} 页缺少原生保存锚点`, c + 1);
|
|
2475
|
+
n.push({ slideId: l, slidePart: m, plan: h, type: a.type });
|
|
2476
|
+
});
|
|
2477
|
+
for (const a of o) e.exec({ type: "RemoveSlide", id: a });
|
|
2478
|
+
return n;
|
|
2479
|
+
}
|
|
2480
|
+
function Dn(e, t) {
|
|
2481
|
+
var c;
|
|
2482
|
+
const r = e.elements[t.id], s = W(e, t.id), i = s.kind === "shape" ? s.text ?? r.meta.textTemplate : void 0, o = (c = i == null ? void 0 : i.paragraphs[0]) == null ? void 0 : c.runs[0];
|
|
2483
|
+
return o ? { textColor: Un(o.color).slice(0, 3).map((h) => Math.round(h * 255).toString(16).padStart(2, "0")).join(""), ...o.fonts[0] ? { fontFamily: o.fonts[0] } : {} } : {};
|
|
2484
|
+
}
|
|
2485
|
+
function wr(e, t) {
|
|
2486
|
+
return e.length === t.length && e.every((r, s) => r === t[s]);
|
|
2487
|
+
}
|
|
2488
|
+
const Ln = new Uint8Array(), Zn = Object.freeze(/* @__PURE__ */ Object.create(null)), _t = Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
2489
|
+
function br(e, t, r = _t) {
|
|
2490
|
+
let s = e, i = t, o = r, n = !1;
|
|
2491
|
+
const a = {
|
|
2492
|
+
format: "pptx",
|
|
2493
|
+
get bytes() {
|
|
2494
|
+
return s;
|
|
2495
|
+
},
|
|
2496
|
+
get parts() {
|
|
2497
|
+
return i;
|
|
2498
|
+
},
|
|
2499
|
+
get assets() {
|
|
2500
|
+
return o;
|
|
2501
|
+
},
|
|
2502
|
+
get disposed() {
|
|
2503
|
+
return n;
|
|
2504
|
+
}
|
|
2505
|
+
};
|
|
2506
|
+
return Object.defineProperty(a, "dispose", {
|
|
2507
|
+
value: () => {
|
|
2508
|
+
s = Ln, i = Zn, o = _t, n = !0;
|
|
2509
|
+
}
|
|
2510
|
+
}), Object.freeze(a);
|
|
2511
|
+
}
|
|
2512
|
+
function Wn(e) {
|
|
2513
|
+
var t;
|
|
2514
|
+
(t = e.dispose) == null || t.call(e);
|
|
2515
|
+
}
|
|
2516
|
+
const xr = new Uint32Array(256);
|
|
2517
|
+
for (let e = 0; e < 256; e++) {
|
|
2518
|
+
let t = e;
|
|
2519
|
+
for (let r = 0; r < 8; r++) t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
|
|
2520
|
+
xr[e] = t >>> 0;
|
|
2521
|
+
}
|
|
2522
|
+
function Pr(e) {
|
|
2523
|
+
let t = 4294967295;
|
|
2524
|
+
for (const r of e) t = xr[(t ^ r) & 255] ^ t >>> 8;
|
|
2525
|
+
return (t ^ 4294967295) >>> 0;
|
|
2526
|
+
}
|
|
2527
|
+
const kr = 33639248, ft = 101010256, Tr = 67324752, Xn = 101075792, Bn = 117853008, Mt = 1, Vn = new TextDecoder("utf-8", { fatal: !0 }), Hn = new TextEncoder(), Gn = /* @__PURE__ */ new Set([
|
|
2528
|
+
"7z",
|
|
2529
|
+
"aac",
|
|
2530
|
+
"avi",
|
|
2531
|
+
"eot",
|
|
2532
|
+
"gif",
|
|
2533
|
+
"gz",
|
|
2534
|
+
"jpeg",
|
|
2535
|
+
"jpg",
|
|
2536
|
+
"m4a",
|
|
2537
|
+
"m4v",
|
|
2538
|
+
"mov",
|
|
2539
|
+
"mp3",
|
|
2540
|
+
"mp4",
|
|
2541
|
+
"mpeg",
|
|
2542
|
+
"mpg",
|
|
2543
|
+
"ogg",
|
|
2544
|
+
"otf",
|
|
2545
|
+
"png",
|
|
2546
|
+
"ttf",
|
|
2547
|
+
"webm",
|
|
2548
|
+
"webp",
|
|
2549
|
+
"woff",
|
|
2550
|
+
"woff2",
|
|
2551
|
+
"zip"
|
|
2552
|
+
]), Ir = (e, t) => e < t ? -1 : e > t ? 1 : 0;
|
|
2553
|
+
class D extends Error {
|
|
2554
|
+
constructor(t, r) {
|
|
2555
|
+
super(r), this.reason = t, this.name = "ZipPassthroughUnsupported";
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
const J = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
2559
|
+
function ce(e, t, r, s) {
|
|
2560
|
+
if (!Number.isSafeInteger(t) || !Number.isSafeInteger(r) || t < 0 || r < 0 || t + r > e.length)
|
|
2561
|
+
throw new Error(`ZIP ${s} 超出文件边界`);
|
|
2562
|
+
}
|
|
2563
|
+
function Yn(e) {
|
|
2564
|
+
if (e.length < 22) throw new Error("ZIP 缺少 EOCD");
|
|
2565
|
+
const t = J(e), r = Math.max(0, e.length - 22 - 65535);
|
|
2566
|
+
for (let s = e.length - 22; s >= r; s--) {
|
|
2567
|
+
if (t.getUint32(s, !0) !== ft) continue;
|
|
2568
|
+
const i = t.getUint16(s + 20, !0);
|
|
2569
|
+
if (s + 22 + i === e.length) return s;
|
|
2570
|
+
}
|
|
2571
|
+
throw new Error("ZIP 缺少有效 EOCD");
|
|
2572
|
+
}
|
|
2573
|
+
function Kn(e, t) {
|
|
2574
|
+
if (!(t & 2048) && e.some((r) => r >= 128))
|
|
2575
|
+
throw new D("legacy-filename", "ZIP 使用非 UTF-8 文件名,不能安全映射 OPC part");
|
|
2576
|
+
try {
|
|
2577
|
+
return Vn.decode(e);
|
|
2578
|
+
} catch {
|
|
2579
|
+
throw new Error("ZIP 文件名不是有效 UTF-8");
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
function Rt(e, t, r, s, i) {
|
|
2583
|
+
ce(e, t, r, i);
|
|
2584
|
+
const o = J(e), n = t + r;
|
|
2585
|
+
let a = t;
|
|
2586
|
+
for (; a < n; ) {
|
|
2587
|
+
if (a + 4 > n) throw new Error(`ZIP ${i} 字段头不完整`);
|
|
2588
|
+
const c = o.getUint16(a, !0), h = o.getUint16(a + 2, !0);
|
|
2589
|
+
if (a + 4 + h > n) throw new Error(`ZIP ${i} 字段超出 extra 边界`);
|
|
2590
|
+
if (c === s) return !0;
|
|
2591
|
+
a += 4 + h;
|
|
2592
|
+
}
|
|
2593
|
+
return !1;
|
|
2594
|
+
}
|
|
2595
|
+
function Jn(e) {
|
|
2596
|
+
const t = Yn(e), r = J(e), s = r.getUint16(t + 4, !0), i = r.getUint16(t + 6, !0), o = r.getUint16(t + 8, !0), n = r.getUint16(t + 10, !0), a = r.getUint32(t + 12, !0), c = r.getUint32(t + 16, !0), h = r.getUint16(t + 20, !0);
|
|
2597
|
+
if (t >= 20 && r.getUint32(t - 20, !0) === Bn)
|
|
2598
|
+
throw new D("zip64", "ZIP64 定位器不支持直通");
|
|
2599
|
+
if (s || i || o !== n)
|
|
2600
|
+
throw new D("multi-disk", "ZIP 多磁盘格式不支持直通");
|
|
2601
|
+
if (n === 65535 || a === 4294967295 || c === 4294967295)
|
|
2602
|
+
throw new D("zip64", "ZIP64 不支持直通");
|
|
2603
|
+
if (h)
|
|
2604
|
+
throw new D("archive-comment", "带存档注释的 ZIP 不支持直通");
|
|
2605
|
+
ce(e, c, a, "中央目录");
|
|
2606
|
+
const p = [], l = /* @__PURE__ */ new Set();
|
|
2607
|
+
let f = c;
|
|
2608
|
+
for (let m = 0; m < n; m++) {
|
|
2609
|
+
if (ce(e, f, 46, "中央目录条目"), r.getUint32(f, !0) !== kr) throw new Error("ZIP 中央目录签名错误");
|
|
2610
|
+
const g = r.getUint16(f + 8, !0), u = r.getUint16(f + 10, !0), d = r.getUint32(f + 20, !0), v = r.getUint32(f + 24, !0), P = r.getUint16(f + 28, !0), x = r.getUint16(f + 30, !0), w = r.getUint16(f + 32, !0), k = r.getUint16(f + 34, !0), b = r.getUint32(f + 42, !0), $ = 46 + P + x + w;
|
|
2611
|
+
if (ce(e, f, $, "中央目录条目"), d === 4294967295 || v === 4294967295 || b === 4294967295 || k === 65535)
|
|
2612
|
+
throw new D("zip64", "ZIP64 条目不支持直通");
|
|
2613
|
+
if (k) throw new D("multi-disk", "跨磁盘 ZIP 条目不支持直通");
|
|
2614
|
+
if (g & 1) throw new D("encrypted-entry", "ZIP 加密条目不支持直通");
|
|
2615
|
+
if (g & 8)
|
|
2616
|
+
throw new D("data-descriptor", "ZIP 数据描述符不支持直通");
|
|
2617
|
+
if (u !== 0 && u !== 8)
|
|
2618
|
+
throw new D("unsupported-compression", `ZIP 压缩方法 ${u} 不支持直通`);
|
|
2619
|
+
const I = e.subarray(f + 46, f + 46 + P);
|
|
2620
|
+
if (Rt(
|
|
2621
|
+
e,
|
|
2622
|
+
f + 46 + P,
|
|
2623
|
+
x,
|
|
2624
|
+
Mt,
|
|
2625
|
+
`中央目录 extra ${m + 1}`
|
|
2626
|
+
))
|
|
2627
|
+
throw new D("zip64", "ZIP64 中央目录 extra 不支持直通");
|
|
2628
|
+
const C = Kn(I, g);
|
|
2629
|
+
if (l.has(C)) throw new Error(`ZIP 存在重复条目:${C}`);
|
|
2630
|
+
if (l.add(C), ce(e, b, 30, `本地头 ${C}`), r.getUint32(b, !0) !== Tr) throw new Error(`ZIP 本地头签名错误:${C}`);
|
|
2631
|
+
const A = r.getUint16(b + 6, !0), Z = r.getUint16(b + 8, !0);
|
|
2632
|
+
if (A & 1)
|
|
2633
|
+
throw new D("encrypted-entry", "ZIP 本地头声明加密,不支持直通");
|
|
2634
|
+
if (A & 8)
|
|
2635
|
+
throw new D("data-descriptor", "ZIP 本地头使用数据描述符,不支持直通");
|
|
2636
|
+
if (Z !== 0 && Z !== 8)
|
|
2637
|
+
throw new D(
|
|
2638
|
+
"unsupported-compression",
|
|
2639
|
+
`ZIP 本地头压缩方法 ${Z} 不支持直通`
|
|
2640
|
+
);
|
|
2641
|
+
if (A !== g || Z !== u || r.getUint32(b + 14, !0) !== r.getUint32(f + 16, !0) || r.getUint32(b + 18, !0) !== d || r.getUint32(b + 22, !0) !== v)
|
|
2642
|
+
throw new Error(`ZIP 本地头与中央目录元数据不一致:${C}`);
|
|
2643
|
+
const _ = r.getUint16(b + 26, !0), L = r.getUint16(b + 28, !0);
|
|
2644
|
+
if (Rt(
|
|
2645
|
+
e,
|
|
2646
|
+
b + 30 + _,
|
|
2647
|
+
L,
|
|
2648
|
+
Mt,
|
|
2649
|
+
`本地头 extra ${C}`
|
|
2650
|
+
))
|
|
2651
|
+
throw new D("zip64", "ZIP64 本地头 extra 不支持直通");
|
|
2652
|
+
const T = 30 + _ + L + d;
|
|
2653
|
+
ce(e, b, T, `本地条目 ${C}`);
|
|
2654
|
+
const U = e.subarray(b + 30, b + 30 + _);
|
|
2655
|
+
if (!wr(U, I)) throw new Error(`ZIP 本地头与中央目录名称不一致:${C}`);
|
|
2656
|
+
p.push({
|
|
2657
|
+
name: C,
|
|
2658
|
+
flags: g,
|
|
2659
|
+
method: u,
|
|
2660
|
+
compressedSize: d,
|
|
2661
|
+
uncompressedSize: v,
|
|
2662
|
+
localOffset: b,
|
|
2663
|
+
localRaw: e.subarray(b, b + T),
|
|
2664
|
+
centralRaw: e.subarray(f, f + $)
|
|
2665
|
+
}), f += $;
|
|
2666
|
+
}
|
|
2667
|
+
if (f !== c + a) throw new Error("ZIP 中央目录包含未识别记录");
|
|
2668
|
+
if (f !== t)
|
|
2669
|
+
throw f + 4 <= e.length && r.getUint32(f, !0) === Xn ? new D("zip64", "ZIP64 EOCD 记录不支持直通") : new Error("ZIP 中央目录与 EOCD 之间存在未识别记录");
|
|
2670
|
+
return { entries: p };
|
|
2671
|
+
}
|
|
2672
|
+
function $r(e) {
|
|
2673
|
+
const t = e.reduce((i, o) => i + o.length, 0), r = new Uint8Array(t);
|
|
2674
|
+
let s = 0;
|
|
2675
|
+
for (const i of e)
|
|
2676
|
+
r.set(i, s), s += i.length;
|
|
2677
|
+
return r;
|
|
2678
|
+
}
|
|
2679
|
+
function Qn(e, t) {
|
|
2680
|
+
if (t.length > 4294967295) throw new Error(`OPC part 过大,需要 ZIP64:${e.name}`);
|
|
2681
|
+
const r = e.method === 8 ? Kt(t, { level: 6 }) : t;
|
|
2682
|
+
if (r.length > 4294967295) throw new Error(`OPC part 压缩后过大,需要 ZIP64:${e.name}`);
|
|
2683
|
+
const s = e.localRaw.length - e.compressedSize, i = new Uint8Array(s + r.length);
|
|
2684
|
+
i.set(e.localRaw.subarray(0, s)), i.set(r, s);
|
|
2685
|
+
const o = J(i), n = Pr(t);
|
|
2686
|
+
return o.setUint32(14, n, !0), o.setUint32(18, r.length, !0), o.setUint32(22, t.length, !0), { bytes: i, checksum: n, compressedSize: r.length, uncompressedSize: t.length };
|
|
2687
|
+
}
|
|
2688
|
+
function ei(e, t, r) {
|
|
2689
|
+
const s = new Uint8Array(e.centralRaw), i = J(s);
|
|
2690
|
+
return t && (i.setUint32(16, t.checksum, !0), i.setUint32(20, t.compressedSize, !0), i.setUint32(24, t.uncompressedSize, !0)), i.setUint32(42, r, !0), s;
|
|
2691
|
+
}
|
|
2692
|
+
function ti(e, t) {
|
|
2693
|
+
const r = [], s = [];
|
|
2694
|
+
let i = 0, o = 0, n = 0;
|
|
2695
|
+
const a = new Set(e.entries.map((g) => g.name));
|
|
2696
|
+
for (const g of e.entries) {
|
|
2697
|
+
const u = t.get(g.name);
|
|
2698
|
+
if (u === null) {
|
|
2699
|
+
n++;
|
|
2700
|
+
continue;
|
|
2701
|
+
}
|
|
2702
|
+
const d = u ? Qn(g, u) : null, v = (d == null ? void 0 : d.bytes) ?? g.localRaw;
|
|
2703
|
+
r.push(v), s.push(ei(g, d, i)), i += v.length, u ? n++ : o++;
|
|
2704
|
+
}
|
|
2705
|
+
const c = [...t].filter(([g, u]) => !a.has(g) && u !== null).sort(([g], [u]) => Ir(g, u));
|
|
2706
|
+
for (const [g, u] of c) {
|
|
2707
|
+
const d = Er(g, u, i);
|
|
2708
|
+
r.push(d.local), s.push(d.central), i += d.local.length, n++;
|
|
2709
|
+
}
|
|
2710
|
+
const h = r.length;
|
|
2711
|
+
if (h > 65535) throw new Error("保存结果需要 ZIP64 条目计数,当前不支持");
|
|
2712
|
+
const p = i, l = s.reduce((g, u) => g + u.length, 0);
|
|
2713
|
+
if (p > 4294967295 || l > 4294967295)
|
|
2714
|
+
throw new Error("保存结果需要 ZIP64 偏移,当前不支持");
|
|
2715
|
+
const f = new Uint8Array(22), m = J(f);
|
|
2716
|
+
return m.setUint32(0, ft, !0), m.setUint16(8, h, !0), m.setUint16(10, h, !0), m.setUint32(12, l, !0), m.setUint32(16, p, !0), { bytes: $r([...r, ...s, f]), preservedEntries: o, rewrittenEntries: n };
|
|
2717
|
+
}
|
|
2718
|
+
function Sr(e, t) {
|
|
2719
|
+
const r = Object.keys(e), s = new Set(r), i = r.filter((l) => t.get(l) !== null);
|
|
2720
|
+
if (i.push(...[...t].filter(([l, f]) => !s.has(l) && f !== null).map(([l]) => l).sort(Ir)), i.length > 65535) throw new Error("重压结果需要 ZIP64 条目计数,当前不支持");
|
|
2721
|
+
const o = [], n = [];
|
|
2722
|
+
let a = 0;
|
|
2723
|
+
for (const l of i) {
|
|
2724
|
+
const f = t.get(l) ?? e[l];
|
|
2725
|
+
if (!f) throw new Error(`重压时缺少 OPC part:${l}`);
|
|
2726
|
+
const m = Er(l, f, a);
|
|
2727
|
+
o.push(m.local), n.push(m.central), a += m.local.length;
|
|
2728
|
+
}
|
|
2729
|
+
const c = n.reduce((l, f) => l + f.length, 0);
|
|
2730
|
+
if (a > 4294967295 || c > 4294967295) throw new Error("重压结果需要 ZIP64 偏移,当前不支持");
|
|
2731
|
+
const h = new Uint8Array(22), p = J(h);
|
|
2732
|
+
return p.setUint32(0, ft, !0), p.setUint16(8, i.length, !0), p.setUint16(10, i.length, !0), p.setUint32(12, c, !0), p.setUint32(16, a, !0), {
|
|
2733
|
+
bytes: $r([...o, ...n, h]),
|
|
2734
|
+
preservedEntries: 0,
|
|
2735
|
+
rewrittenEntries: i.length
|
|
2736
|
+
};
|
|
2737
|
+
}
|
|
2738
|
+
function Er(e, t, r) {
|
|
2739
|
+
if (t.length > 4294967295) throw new Error(`OPC part 过大,需要 ZIP64:${e}`);
|
|
2740
|
+
const s = Hn.encode(e);
|
|
2741
|
+
if (s.length > 65535) throw new Error(`OPC part 路径过长:${e.slice(0, 80)}`);
|
|
2742
|
+
const i = e.slice(e.lastIndexOf(".") + 1).toLowerCase(), o = Gn.has(i) ? null : Kt(t, { level: 6 }), n = o !== null && o.length < t.length, a = n ? 8 : 0, c = n ? o : t;
|
|
2743
|
+
if (c.length > 4294967295) throw new Error(`OPC part 压缩后过大,需要 ZIP64:${e}`);
|
|
2744
|
+
const h = Pr(t), p = new Uint8Array(30 + s.length + c.length), l = J(p);
|
|
2745
|
+
l.setUint32(0, Tr, !0), l.setUint16(4, 20, !0), l.setUint16(6, 2048, !0), l.setUint16(8, a, !0), l.setUint16(12, 33, !0), l.setUint32(14, h, !0), l.setUint32(18, c.length, !0), l.setUint32(22, t.length, !0), l.setUint16(26, s.length, !0), p.set(s, 30), p.set(c, 30 + s.length);
|
|
2746
|
+
const f = new Uint8Array(46 + s.length), m = J(f);
|
|
2747
|
+
return m.setUint32(0, kr, !0), m.setUint16(4, 798, !0), m.setUint16(6, 20, !0), m.setUint16(8, 2048, !0), m.setUint16(10, a, !0), m.setUint16(14, 33, !0), m.setUint32(16, h, !0), m.setUint32(20, c.length, !0), m.setUint32(24, t.length, !0), m.setUint16(28, s.length, !0), m.setUint32(42, r, !0), f.set(s, 46), { local: p, central: f };
|
|
2748
|
+
}
|
|
2749
|
+
function ri(e, t) {
|
|
2750
|
+
const r = /* @__PURE__ */ new Map();
|
|
2751
|
+
for (const [s, i] of Object.entries(t)) {
|
|
2752
|
+
Cr(s);
|
|
2753
|
+
const o = e.parts[s];
|
|
2754
|
+
i === null ? o && r.set(s, null) : (!o || !wr(o, i)) && r.set(s, new Uint8Array(i));
|
|
2755
|
+
}
|
|
2756
|
+
return r;
|
|
2757
|
+
}
|
|
2758
|
+
function Cr(e) {
|
|
2759
|
+
const t = e.split("/");
|
|
2760
|
+
if (!e || e.startsWith("/") || e.endsWith("/") || e.includes("\\") || t.some((r) => !r || r === "." || r === ".."))
|
|
2761
|
+
throw new Error(`非法 OPC part 路径:${e}`);
|
|
2762
|
+
}
|
|
2763
|
+
function si(e) {
|
|
2764
|
+
const t = /* @__PURE__ */ Object.create(null), r = /* @__PURE__ */ new Map();
|
|
2765
|
+
for (const [o, n] of Object.entries(e)) {
|
|
2766
|
+
Cr(o);
|
|
2767
|
+
const a = n.slice();
|
|
2768
|
+
t[o] = a, r.set(o, a);
|
|
2769
|
+
}
|
|
2770
|
+
const s = Sr(/* @__PURE__ */ Object.create(null), r), i = Object.freeze(t);
|
|
2771
|
+
return {
|
|
2772
|
+
...s,
|
|
2773
|
+
bytes: s.bytes,
|
|
2774
|
+
package: br(s.bytes, i),
|
|
2775
|
+
mode: "repacked",
|
|
2776
|
+
fallbackReason: null
|
|
2777
|
+
};
|
|
2778
|
+
}
|
|
2779
|
+
function ni(e, t, r) {
|
|
2780
|
+
const s = /* @__PURE__ */ Object.create(null);
|
|
2781
|
+
for (const [o, n] of Object.entries(e.parts))
|
|
2782
|
+
r.get(o) !== null && (s[o] = r.get(o) ?? n);
|
|
2783
|
+
for (const [o, n] of r) n !== null && (s[o] = n);
|
|
2784
|
+
Object.freeze(s);
|
|
2785
|
+
const i = Object.freeze(Object.fromEntries(Object.entries(e.assets ?? {}).filter(([, o]) => !!o.sourcePart && !!s[o.sourcePart] && !r.has(o.sourcePart))));
|
|
2786
|
+
return br(t, s, i);
|
|
2787
|
+
}
|
|
2788
|
+
function Nr(e) {
|
|
2789
|
+
Wn(e);
|
|
2790
|
+
}
|
|
2791
|
+
function ii(e, t) {
|
|
2792
|
+
if (e.disposed) throw new Error("OPC 原包已释放,不能保存");
|
|
2793
|
+
const r = ri(e, t);
|
|
2794
|
+
if (r.size) {
|
|
2795
|
+
let s, i = null;
|
|
2796
|
+
try {
|
|
2797
|
+
s = ti(Jn(e.bytes), r);
|
|
2798
|
+
} catch (o) {
|
|
2799
|
+
if (!(o instanceof D)) throw o;
|
|
2800
|
+
i = o.reason, s = Sr(e.parts, r);
|
|
2801
|
+
}
|
|
2802
|
+
return {
|
|
2803
|
+
...s,
|
|
2804
|
+
package: ni(e, s.bytes, r),
|
|
2805
|
+
mode: i ? "repacked" : "passthrough",
|
|
2806
|
+
fallbackReason: i
|
|
2807
|
+
};
|
|
2808
|
+
}
|
|
2809
|
+
return {
|
|
2810
|
+
bytes: e.bytes,
|
|
2811
|
+
package: e,
|
|
2812
|
+
mode: "identity",
|
|
2813
|
+
fallbackReason: null,
|
|
2814
|
+
preservedEntries: Object.keys(e.parts).length,
|
|
2815
|
+
rewrittenEntries: 0
|
|
2816
|
+
};
|
|
2817
|
+
}
|
|
2818
|
+
const oi = 9525, ai = -2147483648, Ar = 2147483647, Fr = (e) => Math.round(e * oi), jt = (e) => {
|
|
2819
|
+
const t = Fr(e);
|
|
2820
|
+
return Number.isSafeInteger(t) && t >= ai && t <= Ar;
|
|
2821
|
+
}, Ut = (e) => {
|
|
2822
|
+
const t = Fr(e);
|
|
2823
|
+
return Number.isSafeInteger(t) && t > 0 && t <= Ar;
|
|
2824
|
+
};
|
|
2825
|
+
function li(e, t) {
|
|
2826
|
+
Qt(e, ["x", "y", "w", "h"], t);
|
|
2827
|
+
const r = e;
|
|
2828
|
+
if (!Number.isFinite(r.x) || !Number.isFinite(r.y) || !jt(r.x) || !jt(r.y) || !Number.isFinite(r.w) || r.w <= 0 || !Ut(r.w) || !Number.isFinite(r.h) || r.h <= 0 || !Ut(r.h))
|
|
2829
|
+
throw new Error(`${t} 必须是 PowerPoint 可表示的有限坐标与有限正尺寸`);
|
|
2830
|
+
}
|
|
2831
|
+
const fi = 32767, ci = 2e4, ui = 1024, pi = 1e5, mi = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/u;
|
|
2832
|
+
function di(e) {
|
|
2833
|
+
return !mi.test(e);
|
|
2834
|
+
}
|
|
2835
|
+
function Fe(e, t) {
|
|
2836
|
+
if (typeof e != "string" || e.length > fi || !di(e))
|
|
2837
|
+
throw new Error(`${t}无效`);
|
|
2838
|
+
}
|
|
2839
|
+
function hi(e, t) {
|
|
2840
|
+
if (e !== null && (typeof e != "number" || !Number.isFinite(e)))
|
|
2841
|
+
throw new Error(`${t}必须是有限数字或 null`);
|
|
2842
|
+
}
|
|
2843
|
+
const Or = 16384, yi = 1048576;
|
|
2844
|
+
function lt(e) {
|
|
2845
|
+
if (!Number.isInteger(e) || e < 1 || e > Or) throw new Error("工作簿列号越界");
|
|
2846
|
+
let t = "";
|
|
2847
|
+
for (let r = e; r; r = Math.floor((r - 1) / 26))
|
|
2848
|
+
t = String.fromCharCode(65 + (r - 1) % 26) + t;
|
|
2849
|
+
return t;
|
|
2850
|
+
}
|
|
2851
|
+
const gi = (e) => /^[A-Za-z_][A-Za-z0-9_.]*$/.test(e) ? e : `'${e.replace(/'/g, "''")}'`;
|
|
2852
|
+
function vi(e) {
|
|
2853
|
+
if (![e.startColumn, e.endColumn, e.startRow, e.endRow].every(Number.isInteger) || e.startColumn < 1 || e.endColumn > Or || e.startColumn > e.endColumn || e.startRow < 1 || e.endRow > yi || e.startRow > e.endRow)
|
|
2854
|
+
throw new Error("工作簿范围越界");
|
|
2855
|
+
const t = `$${lt(e.startColumn)}$${e.startRow}`, r = `$${lt(e.endColumn)}$${e.endRow}`;
|
|
2856
|
+
return `${gi(e.sheet)}!${t}${t === r ? "" : `:${r}`}`;
|
|
2857
|
+
}
|
|
2858
|
+
const O = {
|
|
2859
|
+
chart: "http://schemas.openxmlformats.org/drawingml/2006/chart",
|
|
2860
|
+
drawing: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
2861
|
+
presentation: "http://schemas.openxmlformats.org/presentationml/2006/main",
|
|
2862
|
+
office: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
2863
|
+
relationships: "http://schemas.openxmlformats.org/package/2006/relationships",
|
|
2864
|
+
types: "http://schemas.openxmlformats.org/package/2006/content-types",
|
|
2865
|
+
spreadsheet: "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
|
2866
|
+
};
|
|
2867
|
+
function y(e, t = {}, r = []) {
|
|
2868
|
+
const s = Vr(e, { attributes: Object.entries(t).map(([i, o]) => [i, String(o)]) });
|
|
2869
|
+
for (const i of r) Ie(s, typeof i == "string" ? Hr(i) : i);
|
|
2870
|
+
return s;
|
|
2871
|
+
}
|
|
2872
|
+
function re(e, t, r) {
|
|
2873
|
+
const s = oe(`<${e}/>`);
|
|
2874
|
+
for (const [i, o] of Object.entries(t)) {
|
|
2875
|
+
const n = i ? `xmlns:${i}` : "xmlns";
|
|
2876
|
+
Yt(s.root, n, o);
|
|
2877
|
+
}
|
|
2878
|
+
for (const i of r) Ie(s.root, i);
|
|
2879
|
+
return s;
|
|
2880
|
+
}
|
|
2881
|
+
function be(e, t, r = 2) {
|
|
2882
|
+
return vi({
|
|
2883
|
+
sheet: "Sheet1",
|
|
2884
|
+
startColumn: e,
|
|
2885
|
+
endColumn: e,
|
|
2886
|
+
startRow: r,
|
|
2887
|
+
endRow: r + t - 1
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
function wi(e) {
|
|
2891
|
+
const t = { r: `${lt(e.column)}${e.row}` };
|
|
2892
|
+
return e.value === null ? y("c", t) : typeof e.value == "number" ? y("c", t, [y("v", {}, [String(e.value)])]) : y("c", { ...t, t: "inlineStr" }, [y("is", {}, [
|
|
2893
|
+
y("t", /^\s|\s$/.test(e.value) ? { "xml:space": "preserve" } : {}, [e.value])
|
|
2894
|
+
])]);
|
|
2895
|
+
}
|
|
2896
|
+
function bi(e) {
|
|
2897
|
+
const t = e.type === "scatter" || e.type === "bubble", r = [], s = (p, l, f) => r.push({ column: p, row: l, value: f }), i = (p, l) => l.forEach((f, m) => s(p, m + 2, f));
|
|
2898
|
+
t || (s(1, 1, "Categories"), i(1, e.categories));
|
|
2899
|
+
const o = e.series.map((p, l) => {
|
|
2900
|
+
const f = t ? l * (e.type === "bubble" ? 3 : 2) + 1 : l + 2, m = t ? f + 1 : f;
|
|
2901
|
+
return s(m, 1, p.name), i(m, p.values), t && (s(f, 1, `${p.name} X`), i(f, p.x)), e.type === "bubble" && (s(f + 2, 1, `${p.name} Size`), i(f + 2, p.sizes)), {
|
|
2902
|
+
name: be(m, 1, 1),
|
|
2903
|
+
values: be(m, p.values.length),
|
|
2904
|
+
...t ? { x: be(f, p.values.length) } : {},
|
|
2905
|
+
...e.type === "bubble" ? { sizes: be(f + 2, p.values.length) } : {}
|
|
2906
|
+
};
|
|
2907
|
+
}), n = /* @__PURE__ */ new Map();
|
|
2908
|
+
for (const p of r) {
|
|
2909
|
+
const l = n.get(p.row) ?? [];
|
|
2910
|
+
l.push(p), n.set(p.row, l);
|
|
2911
|
+
}
|
|
2912
|
+
const a = [...n].sort(([p], [l]) => p - l).map(([p, l]) => y("row", { r: p }, l.sort((f, m) => f.column - m.column).map(wi))), c = {
|
|
2913
|
+
"[Content_Types].xml": G(re("Types", { "": O.types }, [
|
|
2914
|
+
y("Default", { Extension: "rels", ContentType: "application/vnd.openxmlformats-package.relationships+xml" }),
|
|
2915
|
+
y("Default", { Extension: "xml", ContentType: "application/xml" }),
|
|
2916
|
+
y("Override", { PartName: "/xl/workbook.xml", ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" }),
|
|
2917
|
+
y("Override", { PartName: "/xl/worksheets/sheet1.xml", ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" })
|
|
2918
|
+
])),
|
|
2919
|
+
"_rels/.rels": G(re("Relationships", { "": O.relationships }, [
|
|
2920
|
+
y("Relationship", { Id: "rId1", Type: `${O.office}/officeDocument`, Target: "xl/workbook.xml" })
|
|
2921
|
+
])),
|
|
2922
|
+
"xl/workbook.xml": G(re("workbook", { "": O.spreadsheet, r: O.office }, [
|
|
2923
|
+
y("sheets", {}, [y("sheet", { name: "Sheet1", sheetId: 1, "r:id": "rId1" })]),
|
|
2924
|
+
y("calcPr", { calcId: 191029 })
|
|
2925
|
+
])),
|
|
2926
|
+
"xl/_rels/workbook.xml.rels": G(re("Relationships", { "": O.relationships }, [
|
|
2927
|
+
y("Relationship", { Id: "rId1", Type: `${O.office}/worksheet`, Target: "worksheets/sheet1.xml" })
|
|
2928
|
+
])),
|
|
2929
|
+
"xl/worksheets/sheet1.xml": G(re("worksheet", { "": O.spreadsheet }, [
|
|
2930
|
+
y("sheetData", {}, a)
|
|
2931
|
+
]))
|
|
2932
|
+
}, h = si(c);
|
|
2933
|
+
return Nr(h.package), { bytes: h.bytes, categories: t ? "" : be(1, e.categories.length), series: o };
|
|
2934
|
+
}
|
|
2935
|
+
function fe(e, t, r) {
|
|
2936
|
+
const s = y(`c:${e}Cache`, {}, [
|
|
2937
|
+
...e === "num" ? [y("c:formatCode", {}, ["General"])] : [],
|
|
2938
|
+
y("c:ptCount", { val: r.length }),
|
|
2939
|
+
...r.flatMap((i, o) => i === null ? [] : [
|
|
2940
|
+
y("c:pt", { idx: o }, [y("c:v", {}, [String(i)])])
|
|
2941
|
+
])
|
|
2942
|
+
]);
|
|
2943
|
+
return y(`c:${e}Ref`, {}, [y("c:f", {}, [t]), s]);
|
|
2944
|
+
}
|
|
2945
|
+
function _r(e) {
|
|
2946
|
+
return y("a:solidFill", {}, [e.textColor ? y("a:srgbClr", { val: e.textColor }) : y("a:schemeClr", { val: "tx1" })]);
|
|
2947
|
+
}
|
|
2948
|
+
function xi(e) {
|
|
2949
|
+
return y("c:txPr", {}, [y("a:bodyPr"), y("a:lstStyle"), y("a:p", {}, [
|
|
2950
|
+
y("a:pPr", {}, [y("a:defRPr", { sz: 1100 }, [
|
|
2951
|
+
_r(e),
|
|
2952
|
+
y("a:latin", { typeface: e.fontFamily ?? "+mn-lt" }),
|
|
2953
|
+
y("a:ea", { typeface: e.fontFamily ?? "+mn-ea" }),
|
|
2954
|
+
y("a:cs", { typeface: e.fontFamily ?? "+mn-cs" })
|
|
2955
|
+
])]),
|
|
2956
|
+
y("a:endParaRPr", { lang: "zh-CN" })
|
|
2957
|
+
])]);
|
|
2958
|
+
}
|
|
2959
|
+
function qt(e, t, r, s) {
|
|
2960
|
+
return y(`c:${e}Ax`, {}, [
|
|
2961
|
+
y("c:axId", { val: t }),
|
|
2962
|
+
y("c:scaling", {}, [y("c:orientation", { val: "minMax" })]),
|
|
2963
|
+
y("c:delete", { val: 0 }),
|
|
2964
|
+
y("c:axPos", { val: s }),
|
|
2965
|
+
...e === "val" ? [y("c:majorGridlines"), y("c:numFmt", { formatCode: "General", sourceLinked: 0 })] : [],
|
|
2966
|
+
y("c:majorTickMark", { val: "none" }),
|
|
2967
|
+
y("c:minorTickMark", { val: "none" }),
|
|
2968
|
+
y("c:tickLblPos", { val: "nextTo" }),
|
|
2969
|
+
y("c:crossAx", { val: r }),
|
|
2970
|
+
y("c:crosses", { val: "autoZero" }),
|
|
2971
|
+
...e === "cat" ? [
|
|
2972
|
+
y("c:auto", { val: 1 }),
|
|
2973
|
+
y("c:lblAlgn", { val: "ctr" }),
|
|
2974
|
+
y("c:lblOffset", { val: 100 }),
|
|
2975
|
+
y("c:noMultiLvlLbl", { val: 0 })
|
|
2976
|
+
] : [y("c:crossBetween", { val: "between" })]
|
|
2977
|
+
]);
|
|
2978
|
+
}
|
|
2979
|
+
function Pi(e, t, r, s, i) {
|
|
2980
|
+
const o = e.type === "scatter" || e.type === "bubble", n = e.type === "line" || e.type === "scatter" || e.type === "radar", a = () => y("a:solidFill", {}, [y("a:schemeClr", { val: `accent${r % 6 + 1}` })]);
|
|
2981
|
+
return y("c:ser", {}, [
|
|
2982
|
+
y("c:idx", { val: r }),
|
|
2983
|
+
y("c:order", { val: r }),
|
|
2984
|
+
y("c:tx", {}, [fe("str", s.name, [t.name])]),
|
|
2985
|
+
y("c:spPr", {}, [n ? y("a:ln", { w: 19050 }, [a()]) : a()]),
|
|
2986
|
+
...n ? [y("c:marker", {}, [y("c:symbol", { val: "circle" }), y("c:size", { val: 5 })])] : [],
|
|
2987
|
+
...o ? [
|
|
2988
|
+
y("c:xVal", {}, [fe("num", s.x, t.x)]),
|
|
2989
|
+
y("c:yVal", {}, [fe("num", s.values, t.values)])
|
|
2990
|
+
] : [
|
|
2991
|
+
y("c:cat", {}, [fe("str", i, e.categories)]),
|
|
2992
|
+
y("c:val", {}, [fe("num", s.values, t.values)])
|
|
2993
|
+
],
|
|
2994
|
+
...e.type === "bubble" ? [y("c:bubbleSize", {}, [fe("num", s.sizes, t.sizes)])] : e.type === "line" || e.type === "scatter" ? [y("c:smooth", { val: 0 })] : []
|
|
2995
|
+
]);
|
|
2996
|
+
}
|
|
2997
|
+
function ki(e, t, r, s) {
|
|
2998
|
+
const i = e.type === "pie" || e.type === "doughnut", o = e.type === "scatter" || e.type === "bubble", n = 48650001, a = 48650002, c = y(`c:${e.type}Chart`, {}, [
|
|
2999
|
+
...e.type === "bar" ? [y("c:barDir", { val: "col" }), y("c:grouping", { val: "clustered" })] : e.type === "line" || e.type === "area" ? [y("c:grouping", { val: "standard" })] : e.type === "radar" ? [y("c:radarStyle", { val: "marker" })] : e.type === "scatter" ? [y("c:scatterStyle", { val: "lineMarker" })] : [],
|
|
3000
|
+
y("c:varyColors", { val: i ? 1 : 0 }),
|
|
3001
|
+
...e.series.map((l, f) => Pi(e, l, f, t[f], r)),
|
|
3002
|
+
...e.type === "bar" ? [y("c:gapWidth", { val: 150 })] : [],
|
|
3003
|
+
...i ? [y("c:firstSliceAng", { val: 0 })] : [],
|
|
3004
|
+
...e.type === "doughnut" ? [y("c:holeSize", { val: 50 })] : [],
|
|
3005
|
+
...e.type === "bubble" ? [
|
|
3006
|
+
y("c:bubbleScale", { val: 100 }),
|
|
3007
|
+
y("c:showNegBubbles", { val: 0 }),
|
|
3008
|
+
y("c:sizeRepresents", { val: "area" })
|
|
3009
|
+
] : [],
|
|
3010
|
+
...i ? [] : [y("c:axId", { val: n }), y("c:axId", { val: a })]
|
|
3011
|
+
]), h = e.title ? [y("c:title", {}, [y("c:tx", {}, [y("c:rich", {}, [
|
|
3012
|
+
y("a:bodyPr"),
|
|
3013
|
+
y("a:lstStyle"),
|
|
3014
|
+
y("a:p", {}, [
|
|
3015
|
+
y("a:r", {}, [y("a:rPr", { lang: "zh-CN", sz: 1400 }, [
|
|
3016
|
+
_r(s),
|
|
3017
|
+
y("a:latin", { typeface: s.fontFamily ?? "+mn-lt" })
|
|
3018
|
+
]), y("a:t", {}, [e.title])])
|
|
3019
|
+
])
|
|
3020
|
+
])]), y("c:overlay", { val: 0 })])] : [], p = re("c:chartSpace", { c: O.chart, a: O.drawing, r: O.office }, [
|
|
3021
|
+
y("c:date1904", { val: 0 }),
|
|
3022
|
+
y("c:lang", { val: "zh-CN" }),
|
|
3023
|
+
y("c:roundedCorners", { val: 0 }),
|
|
3024
|
+
y("c:chart", {}, [
|
|
3025
|
+
...h,
|
|
3026
|
+
y("c:autoTitleDeleted", { val: e.title ? 0 : 1 }),
|
|
3027
|
+
y("c:plotArea", {}, [
|
|
3028
|
+
y("c:layout"),
|
|
3029
|
+
c,
|
|
3030
|
+
...i ? [] : [qt(o ? "val" : "cat", n, a, "b"), qt("val", a, n, "l")]
|
|
3031
|
+
]),
|
|
3032
|
+
y("c:legend", {}, [y("c:legendPos", { val: "r" }), y("c:layout"), y("c:overlay", { val: 0 })]),
|
|
3033
|
+
y("c:plotVisOnly", { val: 1 }),
|
|
3034
|
+
y("c:dispBlanksAs", { val: "gap" })
|
|
3035
|
+
]),
|
|
3036
|
+
y("c:spPr", {}, [y("a:noFill"), y("a:ln", {}, [y("a:noFill")])]),
|
|
3037
|
+
xi(s),
|
|
3038
|
+
y("c:externalData", { "r:id": "rIdWorkbook" }, [y("c:autoUpdate", { val: 0 })])
|
|
3039
|
+
]);
|
|
3040
|
+
return G(p);
|
|
3041
|
+
}
|
|
3042
|
+
const Ti = /* @__PURE__ */ new Set(["bar", "line", "pie", "doughnut", "area", "scatter", "radar", "bubble"]), Ii = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml", $i = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ct = (e, t) => {
|
|
3043
|
+
var r;
|
|
3044
|
+
return (r = se(e, { localName: t, namespaceUri: null })) == null ? void 0 : r.value;
|
|
3045
|
+
};
|
|
3046
|
+
function te(e) {
|
|
3047
|
+
throw new E("invalid-chart-data", e);
|
|
3048
|
+
}
|
|
3049
|
+
function Si(e) {
|
|
3050
|
+
const { chart: t, rect: r } = e;
|
|
3051
|
+
try {
|
|
3052
|
+
li(r, "图表框架");
|
|
3053
|
+
} catch (o) {
|
|
3054
|
+
te(o instanceof Error ? o.message : String(o));
|
|
3055
|
+
}
|
|
3056
|
+
e.rot !== void 0 && (!Number.isFinite(e.rot) || Math.round(e.rot * 6e4) < -2147483648 || Math.round(e.rot * 6e4) > 2147483647) && te("图表旋转角必须可写入 OOXML 角度"), [e.flipH, e.flipV].some((o) => o !== void 0 && typeof o != "boolean") && te("图表翻转必须是布尔值"), e.textColor !== void 0 && (typeof e.textColor != "string" || !/^[0-9A-Fa-f]{6}$/.test(e.textColor)) && te("图表文字色必须是六位 sRGB 十六进制"), e.fontFamily !== void 0 && Fe(e.fontFamily, "图表字体"), (!t || !Ti.has(t.type) || !Array.isArray(t.categories) || !Array.isArray(t.series) || !t.series.length || t.series.length > ui) && te("图表类型、类别或系列数量无效"), t.title !== void 0 && Fe(t.title, "图表标题");
|
|
3057
|
+
for (const o of t.categories) Fe(o, "图表类别");
|
|
3058
|
+
const s = t.type === "scatter" || t.type === "bubble";
|
|
3059
|
+
let i = 0;
|
|
3060
|
+
for (const o of t.series) {
|
|
3061
|
+
Fe(o.name, "图表系列名称"), (!Array.isArray(o.values) || !o.values.length || o.values.length > ci || !s && o.values.length !== t.categories.length) && te("图表系列数据点数与类别不匹配");
|
|
3062
|
+
const n = [
|
|
3063
|
+
o.values,
|
|
3064
|
+
...s ? [o.x] : [],
|
|
3065
|
+
...t.type === "bubble" ? [o.sizes] : []
|
|
3066
|
+
];
|
|
3067
|
+
n.some((a) => !Array.isArray(a) || a.length !== o.values.length) && te("图表 X/Y/大小的数据形状不匹配");
|
|
3068
|
+
for (const a of n) for (const c of a) hi(c, "图表数值");
|
|
3069
|
+
i += o.values.length;
|
|
3070
|
+
}
|
|
3071
|
+
i > pi && te("图表数据超过现有编辑器的安全容量");
|
|
3072
|
+
}
|
|
3073
|
+
function Ei(e) {
|
|
3074
|
+
const t = [e.root];
|
|
3075
|
+
let r = 1;
|
|
3076
|
+
for (; t.length; ) {
|
|
3077
|
+
const s = t.pop();
|
|
3078
|
+
if (s.localName === "cNvPr" && s.namespaceUri === O.presentation) {
|
|
3079
|
+
const i = Number(ct(s, "id"));
|
|
3080
|
+
if (!Number.isSafeInteger(i) || i < 1 || i >= 4294967295)
|
|
3081
|
+
throw new E("unsupported-template", "图表目标页包含无效或耗尽的 shape id");
|
|
3082
|
+
r = Math.max(r, i);
|
|
3083
|
+
}
|
|
3084
|
+
t.push(...ae(s));
|
|
3085
|
+
}
|
|
3086
|
+
return r + 1;
|
|
3087
|
+
}
|
|
3088
|
+
function Ci(e, t, r) {
|
|
3089
|
+
const { rect: s } = r, i = (o) => Math.round(o * 9525);
|
|
3090
|
+
return y("p:graphicFrame", {
|
|
3091
|
+
"xmlns:p": O.presentation,
|
|
3092
|
+
"xmlns:a": O.drawing,
|
|
3093
|
+
"xmlns:r": O.office,
|
|
3094
|
+
"xmlns:c": O.chart
|
|
3095
|
+
}, [
|
|
3096
|
+
y("p:nvGraphicFramePr", {}, [
|
|
3097
|
+
y("p:cNvPr", { id: e, name: r.chart.title ?? `图表 ${e}` }),
|
|
3098
|
+
y("p:cNvGraphicFramePr", {}, [y("a:graphicFrameLocks", { noGrp: 1 })]),
|
|
3099
|
+
y("p:nvPr")
|
|
3100
|
+
]),
|
|
3101
|
+
y("p:xfrm", {
|
|
3102
|
+
...r.rot ? { rot: Math.round(r.rot * 6e4) } : {},
|
|
3103
|
+
...r.flipH ? { flipH: 1 } : {},
|
|
3104
|
+
...r.flipV ? { flipV: 1 } : {}
|
|
3105
|
+
}, [
|
|
3106
|
+
y("a:off", { x: i(s.x), y: i(s.y) }),
|
|
3107
|
+
y("a:ext", { cx: i(s.w), cy: i(s.h) })
|
|
3108
|
+
]),
|
|
3109
|
+
y("a:graphic", {}, [y("a:graphicData", { uri: O.chart }, [
|
|
3110
|
+
y("c:chart", { "r:id": t })
|
|
3111
|
+
])])
|
|
3112
|
+
]);
|
|
3113
|
+
}
|
|
3114
|
+
function Ni(e, t, r) {
|
|
3115
|
+
if (e.root.namespaceUri !== O.relationships) throw new E("unsupported-template", "目标页关系根命名空间无效");
|
|
3116
|
+
const s = ae(e.root, { localName: "Relationship", namespaceUri: O.relationships }), i = new Set(s.map((a) => ct(a, "Id")));
|
|
3117
|
+
let o = 1;
|
|
3118
|
+
for (; i.has(`rIdTemplateChart${o}`); ) o++;
|
|
3119
|
+
const n = `rIdTemplateChart${o}`;
|
|
3120
|
+
return Ie(e.root, y("Relationship", { Id: n, Type: t, Target: r })), n;
|
|
3121
|
+
}
|
|
3122
|
+
function Ai(e, t) {
|
|
3123
|
+
for (const m of t) Si(m);
|
|
3124
|
+
if (!t.length) return e.slice();
|
|
3125
|
+
let r = 0, s = 0;
|
|
3126
|
+
const i = Qe(e, { filter(m) {
|
|
3127
|
+
if (r += m.originalSize, ++s > 2e4 || m.originalSize > 64 * 1024 * 1024 || r > 512 * 1024 * 1024)
|
|
3128
|
+
throw new E("resource-limit", "图表生成输入包解压规模超过安全上限");
|
|
3129
|
+
return !0;
|
|
3130
|
+
} }), o = i["[Content_Types].xml"] && oe(i["[Content_Types].xml"]);
|
|
3131
|
+
if (!o || o.root.namespaceUri !== O.types) throw new E("unsupported-template", "PPTX 缺少有效内容类型目录");
|
|
3132
|
+
const n = new Set(Object.keys(i));
|
|
3133
|
+
for (const m of ae(o.root, { localName: "Override", namespaceUri: O.types })) {
|
|
3134
|
+
const g = ct(m, "PartName");
|
|
3135
|
+
g != null && g.startsWith("/") && n.add(g.slice(1));
|
|
3136
|
+
}
|
|
3137
|
+
const a = /* @__PURE__ */ Object.create(null), c = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
3138
|
+
let p = 1;
|
|
3139
|
+
for (const m of t) {
|
|
3140
|
+
const g = i[m.slidePart];
|
|
3141
|
+
if (!g) throw new E("target-not-found", `图表目标页不存在:${m.slidePart}`);
|
|
3142
|
+
const u = c.get(m.slidePart) ?? oe(g);
|
|
3143
|
+
if (c.set(m.slidePart, u), u.root.namespaceUri !== O.presentation || u.root.localName !== "sld")
|
|
3144
|
+
throw new E("unsupported-template", `图表目标不是标准 OOXML 页面:${m.slidePart}`);
|
|
3145
|
+
const d = wt(u.root, { localName: "cSld", namespaceUri: O.presentation }), v = d && wt(d, { localName: "spTree", namespaceUri: O.presentation });
|
|
3146
|
+
if (!v) throw new E("unsupported-template", `图表目标页缺少形状树:${m.slidePart}`);
|
|
3147
|
+
let P, x, w;
|
|
3148
|
+
do
|
|
3149
|
+
P = `ppt/charts/template-fill-chart${p}.xml`, x = `ppt/embeddings/template-fill-chart${p}.xlsx`, w = Ft(P), p++;
|
|
3150
|
+
while ([P, x, w].some((C) => n.has(C)));
|
|
3151
|
+
[P, x, w].forEach((C) => n.add(C));
|
|
3152
|
+
const k = bi(m.chart);
|
|
3153
|
+
a[x] = k.bytes, a[P] = ki(m.chart, k.series, k.categories, m), a[w] = G(re("Relationships", { "": O.relationships }, [
|
|
3154
|
+
y("Relationship", { Id: "rIdWorkbook", Type: `${O.office}/package`, Target: Ot(P, x) })
|
|
3155
|
+
]));
|
|
3156
|
+
for (const [C, A] of [[P, Ii], [x, $i]])
|
|
3157
|
+
Ie(o.root, y("Override", { PartName: `/${C}`, ContentType: A }));
|
|
3158
|
+
const b = Ft(m.slidePart), $ = h.get(b) ?? (i[b] ? oe(i[b]) : re("Relationships", { "": O.relationships }, []));
|
|
3159
|
+
h.set(b, $);
|
|
3160
|
+
const I = Ni($, `${O.office}/chart`, Ot(m.slidePart, P));
|
|
3161
|
+
Ie(v, Ci(Ei(u), I, m));
|
|
3162
|
+
}
|
|
3163
|
+
for (const [m, g] of [...c, ...h]) a[m] = G(g);
|
|
3164
|
+
a["[Content_Types].xml"] = G(o);
|
|
3165
|
+
const f = ii({ format: "pptx", bytes: e, parts: i, disposed: !1 }, a);
|
|
3166
|
+
return Nr(f.package), f.bytes;
|
|
3167
|
+
}
|
|
3168
|
+
const zt = /* @__PURE__ */ new Set(["serif", "sans-serif", "monospace", "system-ui"]), he = (e) => e.trim().toLowerCase();
|
|
3169
|
+
function Te(e, t) {
|
|
3170
|
+
let r = t;
|
|
3171
|
+
const s = /* @__PURE__ */ new Set();
|
|
3172
|
+
for (; e.elements[r]; ) {
|
|
3173
|
+
if (s.has(r)) throw new E("layout-repair-failed", `修复目标 ${t} 的父链成环`, null, null, t);
|
|
3174
|
+
s.add(r);
|
|
3175
|
+
const i = e.elements[r].parent;
|
|
3176
|
+
if (e.slides[i]) return { root: r, canvas: { kind: "slide", id: i } };
|
|
3177
|
+
if (e.layouts[i]) return { root: r, canvas: { kind: "layout", id: i } };
|
|
3178
|
+
if (e.masters[i]) return { root: r, canvas: { kind: "master", id: i } };
|
|
3179
|
+
r = i;
|
|
3180
|
+
}
|
|
3181
|
+
throw new E("layout-repair-failed", `修复目标 ${t} 没有有效的画布父链`, null, null, t);
|
|
3182
|
+
}
|
|
3183
|
+
function Q(e, t, r, ...s) {
|
|
3184
|
+
const { canvas: i } = Te(e, r);
|
|
3185
|
+
return i.kind === "slide" ? t.exec(...s) : t.execDesign(i, ...s);
|
|
3186
|
+
}
|
|
3187
|
+
function ee(e, t, r, s, i, o, n = "off-canvas") {
|
|
3188
|
+
var c;
|
|
3189
|
+
const a = t ? (c = e.elements[t]) == null ? void 0 : c.meta.origin : void 0;
|
|
3190
|
+
return {
|
|
3191
|
+
elementId: t,
|
|
3192
|
+
slideNumber: (r == null ? void 0 : r.slideNumber) ?? null,
|
|
3193
|
+
source: a ? { ...a } : null,
|
|
3194
|
+
reason: (r == null ? void 0 : r.reason) ?? n,
|
|
3195
|
+
action: s,
|
|
3196
|
+
before: i,
|
|
3197
|
+
after: o
|
|
3198
|
+
};
|
|
3199
|
+
}
|
|
3200
|
+
function Ye(e, t, r) {
|
|
3201
|
+
const s = ue(e, t);
|
|
3202
|
+
return Math.max(-s.left, -s.top, s.right - e.meta.width, s.bottom - e.meta.height) > r;
|
|
3203
|
+
}
|
|
3204
|
+
function Dt(e, t, r, s, i, o) {
|
|
3205
|
+
if (!Ye(e, r, s)) return !1;
|
|
3206
|
+
const n = Te(e, r).root, a = Ye(e, n, s) ? n : r;
|
|
3207
|
+
let c = W(e, a);
|
|
3208
|
+
const h = { bounds: ue(e, a), x: c.x, y: c.y, w: c.w, h: c.h, rot: c.rot }, p = h.bounds, l = p.right - p.left, f = p.bottom - p.top;
|
|
3209
|
+
if (![l, f, c.w, c.h].every(Number.isFinite) || l < 0 || f < 0 || !l && !f)
|
|
3210
|
+
throw new E("layout-repair-failed", `元素 ${a} 没有可修复的有限正面积`, (i == null ? void 0 : i.slideNumber) ?? null, null, a);
|
|
3211
|
+
const m = Math.min(0.02, e.meta.width / 100, e.meta.height / 100), g = Math.min(1, l ? (e.meta.width - m * 2) / l : 1, f ? (e.meta.height - m * 2) / f : 1);
|
|
3212
|
+
g < 1 && Q(e, t, a, {
|
|
3213
|
+
type: "SetXfrm",
|
|
3214
|
+
id: a,
|
|
3215
|
+
x: c.x + c.w * (1 - g) / 2,
|
|
3216
|
+
y: c.y + c.h * (1 - g) / 2,
|
|
3217
|
+
w: c.w * g,
|
|
3218
|
+
h: c.h * g
|
|
3219
|
+
});
|
|
3220
|
+
const u = ue(e, a), d = u.left < m ? m - u.left : u.right > e.meta.width - m ? e.meta.width - m - u.right : 0, v = u.top < m ? m - u.top : u.bottom > e.meta.height - m ? e.meta.height - m - u.bottom : 0;
|
|
3221
|
+
if (d || v) {
|
|
3222
|
+
const P = Xt(Bt(e, a), { x: d, y: v });
|
|
3223
|
+
c = W(e, a), Q(e, t, a, { type: "SetXfrm", id: a, x: c.x + P.x, y: c.y + P.y });
|
|
3224
|
+
}
|
|
3225
|
+
if (Ye(e, a, s))
|
|
3226
|
+
throw new E("layout-repair-failed", `元素 ${a} 等比缩放和平移后仍越出画布`, (i == null ? void 0 : i.slideNumber) ?? null, null, a);
|
|
3227
|
+
return c = W(e, a), o.push(ee(
|
|
3228
|
+
e,
|
|
3229
|
+
a,
|
|
3230
|
+
i,
|
|
3231
|
+
"fit-geometry",
|
|
3232
|
+
h,
|
|
3233
|
+
{ bounds: ue(e, a), x: c.x, y: c.y, w: c.w, h: c.h, rot: c.rot }
|
|
3234
|
+
)), !0;
|
|
3235
|
+
}
|
|
3236
|
+
function Mr(e) {
|
|
3237
|
+
if (!e.fonts) return null;
|
|
3238
|
+
const t = [...e.fonts.available, ...e.fonts.embedded];
|
|
3239
|
+
if (t.some((s) => typeof s != "string" || !s.trim()))
|
|
3240
|
+
throw new E("invalid-options", "修复使用的真实字体库存必须由非空字体名组成");
|
|
3241
|
+
const r = t.find((s) => !zt.has(he(s)));
|
|
3242
|
+
return r ? { known: /* @__PURE__ */ new Set([...t.map(he), ...zt]), fallback: r } : null;
|
|
3243
|
+
}
|
|
3244
|
+
function Fi(e, t, r, s) {
|
|
3245
|
+
const i = Mr(r);
|
|
3246
|
+
if (i)
|
|
3247
|
+
for (const o of e.themeOrder) {
|
|
3248
|
+
const n = dt(e, o), a = {};
|
|
3249
|
+
for (const c of ["major", "minor"]) {
|
|
3250
|
+
const h = {};
|
|
3251
|
+
for (const l of ["latin", "ea", "cs"]) {
|
|
3252
|
+
const f = n.fonts[c][l];
|
|
3253
|
+
f && !i.known.has(he(f)) && (h[l] = i.fallback);
|
|
3254
|
+
}
|
|
3255
|
+
const p = Object.fromEntries(Object.entries(n.fonts[c].scripts).filter(([, l]) => !!l && !i.known.has(he(l))).map(([l]) => [l, i.fallback]));
|
|
3256
|
+
Object.keys(p).length && (h.scripts = p), Object.keys(h).length && (a[c] = h);
|
|
3257
|
+
}
|
|
3258
|
+
Object.keys(a).length && (t.exec({ type: "SetTheme", id: o, fontScheme: a }), s.push(ee(
|
|
3259
|
+
e,
|
|
3260
|
+
null,
|
|
3261
|
+
null,
|
|
3262
|
+
"replace-theme-fonts",
|
|
3263
|
+
{ themeId: o, fonts: n.fonts },
|
|
3264
|
+
{ themeId: o, fonts: dt(e, o).fonts },
|
|
3265
|
+
"missing-font"
|
|
3266
|
+
)));
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
function ze(e, t) {
|
|
3270
|
+
var s;
|
|
3271
|
+
const r = W(e, t.elementId);
|
|
3272
|
+
if (r.kind === "shape" && r.text) return { body: r.text };
|
|
3273
|
+
if (r.kind === "table" && t.cell) {
|
|
3274
|
+
const i = (s = r.rows[t.cell.row]) == null ? void 0 : s.cells[t.cell.column];
|
|
3275
|
+
if (i != null && i.text) return { body: i.text, cell: { r: t.cell.row, c: t.cell.column } };
|
|
3276
|
+
}
|
|
3277
|
+
return null;
|
|
3278
|
+
}
|
|
3279
|
+
function Oi(e) {
|
|
3280
|
+
var s;
|
|
3281
|
+
if (!e.paragraphs.some((i) => i.runs.some((o) => o.text.length))) return null;
|
|
3282
|
+
const t = e.paragraphs.length - 1, r = Math.max(0, e.paragraphs[t].runs.length - 1);
|
|
3283
|
+
return { from: { p: 0, r: 0, off: 0 }, to: { p: t, r, off: ((s = e.paragraphs[t].runs[r]) == null ? void 0 : s.text.length) ?? 0 } };
|
|
3284
|
+
}
|
|
3285
|
+
function _i(e, t, r, s, i) {
|
|
3286
|
+
const o = Mr(s), n = ze(e, r);
|
|
3287
|
+
if (!o || !n) return !1;
|
|
3288
|
+
const a = n.body.paragraphs.flatMap((c, h) => c.runs.flatMap((p, l) => !p.text.length || !p.fonts.some((f) => !o.known.has(he(f))) ? [] : [{
|
|
3289
|
+
from: ht(n.body, { p: h, r: l, off: 0 }),
|
|
3290
|
+
to: ht(n.body, { p: h, r: l, off: p.text.length }),
|
|
3291
|
+
before: [...p.fonts],
|
|
3292
|
+
font: p.fonts.find((f) => o.known.has(he(f))) ?? o.fallback
|
|
3293
|
+
}]));
|
|
3294
|
+
for (const c of a.reverse()) {
|
|
3295
|
+
const h = ze(e, r);
|
|
3296
|
+
Q(e, t, r.elementId, {
|
|
3297
|
+
type: "SetRunProps",
|
|
3298
|
+
id: r.elementId,
|
|
3299
|
+
cell: h.cell,
|
|
3300
|
+
range: { from: yt(h.body, c.from), to: yt(h.body, c.to) },
|
|
3301
|
+
props: { font: c.font }
|
|
3302
|
+
}), i.push(ee(e, r.elementId, r, "replace-run-font", { fonts: c.before, from: c.from, to: c.to }, { font: c.font }));
|
|
3303
|
+
}
|
|
3304
|
+
return a.length > 0;
|
|
3305
|
+
}
|
|
3306
|
+
function Mi(e, t, r, s) {
|
|
3307
|
+
const i = ze(e, r);
|
|
3308
|
+
if (!i || i.body.autoFitCompute) return !1;
|
|
3309
|
+
const o = i.body.autoFitNormal ? [{ type: "SetBodyProps", id: r.elementId, cell: i.cell, props: { autoFit: "none" } }] : [];
|
|
3310
|
+
return Q(e, t, r.elementId, ...o, {
|
|
3311
|
+
type: "SetBodyProps",
|
|
3312
|
+
id: r.elementId,
|
|
3313
|
+
cell: i.cell,
|
|
3314
|
+
props: { autoFit: "normal" }
|
|
3315
|
+
}).forward.length ? (s.push(ee(
|
|
3316
|
+
e,
|
|
3317
|
+
r.elementId,
|
|
3318
|
+
r,
|
|
3319
|
+
"normal-autofit",
|
|
3320
|
+
{ autoFit: i.body.autoFitNormal ? "normal" : i.body.autoFitShape ? "shape" : "none", fontScale: i.body.fontScale },
|
|
3321
|
+
{ autoFit: "normal", compute: !0 }
|
|
3322
|
+
)), !0) : !1;
|
|
3323
|
+
}
|
|
3324
|
+
async function Ri(e, t, r, s, i) {
|
|
3325
|
+
var f;
|
|
3326
|
+
const o = ze(e, r), n = o && Oi(o.body);
|
|
3327
|
+
if (!o || !n) return !1;
|
|
3328
|
+
const a = r.elementId, c = W(e, a), h = {
|
|
3329
|
+
colors: o.body.paragraphs.flatMap((m) => m.runs.map((g) => g.color)),
|
|
3330
|
+
fillType: c.kind === "shape" ? ((f = c.fill) == null ? void 0 : f.type) ?? "none" : null
|
|
3331
|
+
}, p = async () => !(await me(e, { ...s, checks: ["low-contrast"] })).issues.some((m) => m.elementId === a && JSON.stringify(m.cell) === JSON.stringify(r.cell));
|
|
3332
|
+
for (const m of ["rgb(0,0,0)", "rgb(255,255,255)"]) {
|
|
3333
|
+
const g = Q(e, t, a, { type: "SetRunProps", id: a, cell: o.cell, range: n, props: { color: m } });
|
|
3334
|
+
if (await p())
|
|
3335
|
+
return g.forward.length && i.push(ee(e, a, r, "contrast-text-color", h, { color: m })), !!g.forward.length;
|
|
3336
|
+
if (g.forward.length && !t.undo()) throw new E("layout-repair-failed", `文字 ${a} 的颜色试验无法恢复`, r.slideNumber, null, a);
|
|
3337
|
+
}
|
|
3338
|
+
if (W(e, a).kind !== "shape") return !1;
|
|
3339
|
+
const l = Q(
|
|
3340
|
+
e,
|
|
3341
|
+
t,
|
|
3342
|
+
a,
|
|
3343
|
+
{ type: "SetFill", id: a, fill: { type: "solid", color: "rgb(255,255,255)" } },
|
|
3344
|
+
{ type: "SetRunProps", id: a, range: n, props: { color: "rgb(0,0,0)" } }
|
|
3345
|
+
);
|
|
3346
|
+
if (await p())
|
|
3347
|
+
return l.forward.length && i.push(ee(
|
|
3348
|
+
e,
|
|
3349
|
+
a,
|
|
3350
|
+
r,
|
|
3351
|
+
"contrast-text-background",
|
|
3352
|
+
h,
|
|
3353
|
+
{ color: "rgb(0,0,0)", fill: "rgb(255,255,255)" }
|
|
3354
|
+
)), !!l.forward.length;
|
|
3355
|
+
if (l.forward.length && !t.undo()) throw new E("layout-repair-failed", `文字 ${a} 的背景试验无法恢复`, r.slideNumber, null, a);
|
|
3356
|
+
return !1;
|
|
3357
|
+
}
|
|
3358
|
+
function ji(e, t, r, s) {
|
|
3359
|
+
const i = W(e, r.elementId), o = r.measurements.sourceWidth, n = r.measurements.sourceHeight;
|
|
3360
|
+
if (i.kind !== "image" || i.media || typeof o != "number" || typeof n != "number" || o <= 0 || n <= 0) return !1;
|
|
3361
|
+
const a = o / n, c = i.w / i.h, h = a > c, p = Math.round((1 - (h ? c / a : a / c)) * 1e5);
|
|
3362
|
+
if (p >= 1e5) return !1;
|
|
3363
|
+
const l = Math.floor(p / 2) / 1e5, f = (p - Math.floor(p / 2)) / 1e5, m = { l: h ? l : 0, r: h ? f : 0, t: h ? 0 : l, b: h ? 0 : f };
|
|
3364
|
+
return Q(e, t, r.elementId, { type: "SetCrop", id: r.elementId, crop: m }).forward.length ? (s.push(ee(e, r.elementId, r, "cover-image", { crop: i.crop }, { crop: m })), !0) : !1;
|
|
3365
|
+
}
|
|
3366
|
+
function Ui(e, t, r, s, i, o) {
|
|
3367
|
+
const n = W(e, r);
|
|
3368
|
+
if (n.kind !== "shape" || !n.text || n.text.warp || n.text.vert && n.text.vert !== "horz" || !n.text.paragraphs.some((v) => v.runs.some((P) => P.text.trim()))) return !1;
|
|
3369
|
+
const a = Ur(n.text, n.w, n.h, { measureText: i.measureText, includeCarets: !1 }), c = Math.ceil(qr(
|
|
3370
|
+
n.text,
|
|
3371
|
+
n.w,
|
|
3372
|
+
{ measureText: i.measureText, scale: a.scale, anchor: "top" }
|
|
3373
|
+
) * 9525 + 1) / 9525;
|
|
3374
|
+
if (c >= n.h - (i.tolerancePx ?? 0.01)) return !1;
|
|
3375
|
+
const h = n.text.anchor === "bottom" ? 1 : n.text.anchor === "middle" ? 0.5 : 0, p = n.flipV ? 1 - h : h, l = gt(vt(n), { x: n.w / 2, y: n.h * p }), f = { ...n, h: c }, m = gt(vt(f), { x: f.w / 2, y: c * p }), g = {
|
|
3376
|
+
x: n.x,
|
|
3377
|
+
y: n.y,
|
|
3378
|
+
w: n.w,
|
|
3379
|
+
h: n.h,
|
|
3380
|
+
fontScale: a.scale,
|
|
3381
|
+
lines: a.lines.map((v) => ({ x: v.x, y: v.y, width: v.width, height: v.height }))
|
|
3382
|
+
};
|
|
3383
|
+
if (!Q(
|
|
3384
|
+
e,
|
|
3385
|
+
t,
|
|
3386
|
+
r,
|
|
3387
|
+
{ type: "SetXfrm", id: r, x: n.x + l.x - m.x, y: n.y + l.y - m.y, h: c },
|
|
3388
|
+
{ type: "SetBodyProps", id: r, props: { autoFit: "normal" } }
|
|
3389
|
+
).forward.length) return !1;
|
|
3390
|
+
const d = W(e, r);
|
|
3391
|
+
return o.push(ee(
|
|
3392
|
+
e,
|
|
3393
|
+
r,
|
|
3394
|
+
s,
|
|
3395
|
+
"tighten-text-frame",
|
|
3396
|
+
g,
|
|
3397
|
+
{ x: d.x, y: d.y, w: d.w, h: d.h }
|
|
3398
|
+
)), !0;
|
|
3399
|
+
}
|
|
3400
|
+
function Oe(e, t) {
|
|
3401
|
+
return e.issues.some((r) => r.reason === "element-overlap" && (r.elementId === t || r.measurements.relatedElementId === t));
|
|
3402
|
+
}
|
|
3403
|
+
async function qi(e, t, r, s, i) {
|
|
3404
|
+
const o = r.measurements.relatedElementId;
|
|
3405
|
+
if (typeof o != "string" || !e.elements[o]) return !1;
|
|
3406
|
+
const n = [r.elementId, o];
|
|
3407
|
+
let a = !1;
|
|
3408
|
+
for (const l of n) a = Ui(e, t, l, r, s, i) || a;
|
|
3409
|
+
const c = { ...s, checks: ["element-overlap", "off-canvas", "text-overflow"] };
|
|
3410
|
+
let h = await me(e, c);
|
|
3411
|
+
if (!Oe(h, r.elementId) && !Oe(h, o)) return a;
|
|
3412
|
+
const p = [...n].sort((l, f) => +(Te(e, l).canvas.kind === "slide") - +(Te(e, f).canvas.kind === "slide"));
|
|
3413
|
+
for (const l of p) {
|
|
3414
|
+
if (!Oe(h, l) || Te(e, l).root !== l || W(e, l).kind !== "shape") continue;
|
|
3415
|
+
const f = Ht(e), m = ue(e, l), g = m.right - m.left, u = m.bottom - m.top, d = 4, v = f.slides.filter((b) => b.elements.some(($) => $.id === l)), P = /* @__PURE__ */ new Set([d, e.meta.width - g - d, m.left]), x = /* @__PURE__ */ new Set([d, e.meta.height - u - d, m.top]), w = v.flatMap((b) => b.elements.filter(($) => $.id !== l && !$.hidden && ($.kind === "image" || $.kind === "table" || $.editable === "frame" || $.paragraphs.some((I) => I.text.trim()))));
|
|
3416
|
+
for (const b of w)
|
|
3417
|
+
P.add(b.bounds.x - g - d), P.add(b.bounds.x + b.bounds.width + d), x.add(b.bounds.y - u - d), x.add(b.bounds.y + b.bounds.height + d);
|
|
3418
|
+
const k = [...P].flatMap((b) => [...x].map(($) => ({ left: b, top: $ }))).filter((b) => b.left >= 0 && b.top >= 0 && b.left + g <= e.meta.width && b.top + u <= e.meta.height).filter((b) => !w.some(($) => {
|
|
3419
|
+
const I = Math.min(b.left + g, $.bounds.x + $.bounds.width) - Math.max(b.left, $.bounds.x), C = Math.min(b.top + u, $.bounds.y + $.bounds.height) - Math.max(b.top, $.bounds.y);
|
|
3420
|
+
return I > 0 && C > 0 && I * C / Math.min(g * u, $.bounds.width * $.bounds.height) > (s.overlapRatio ?? 0.25);
|
|
3421
|
+
})).sort((b, $) => Math.hypot(b.left - m.left, b.top - m.top) - Math.hypot($.left - m.left, $.top - m.top) || b.top - $.top || b.left - $.left);
|
|
3422
|
+
for (const b of k) {
|
|
3423
|
+
const $ = W(e, l), I = Xt(Bt(e, l), { x: b.left - m.left, y: b.top - m.top }), C = Q(e, t, l, { type: "SetXfrm", id: l, x: $.x + I.x, y: $.y + I.y });
|
|
3424
|
+
if (h = await me(e, c), C.forward.length && !Oe(h, l) && !h.issues.some((A) => A.elementId === l && (A.reason === "off-canvas" || A.reason === "text-overflow")))
|
|
3425
|
+
return i.push(ee(e, l, r, "move-text-frame", { bounds: m }, { bounds: ue(e, l) })), !0;
|
|
3426
|
+
if (C.forward.length && !t.undo()) throw new E("layout-repair-failed", `文字 ${l} 的移动试验无法恢复`, r.slideNumber, null, l);
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
return a;
|
|
3430
|
+
}
|
|
3431
|
+
async function Lt(e, t, r, s = {}) {
|
|
3432
|
+
const i = [], o = [], n = s.signal ?? r.signal, a = () => B(n);
|
|
3433
|
+
if (a(), s.phase === "design") {
|
|
3434
|
+
Fi(e, t, r, i);
|
|
3435
|
+
for (const u of [...e.masterOrder.flatMap((d) => e.masters[d].children), ...e.layoutOrder.flatMap((d) => e.layouts[d].children)])
|
|
3436
|
+
a(), Dt(e, t, u, r.tolerancePx ?? 0.01, null, i);
|
|
3437
|
+
return { changed: i.length > 0, initialReport: null, report: null, repairs: i, unavailable: o };
|
|
3438
|
+
}
|
|
3439
|
+
const c = { ...r, signal: n };
|
|
3440
|
+
let h = await me(e, c);
|
|
3441
|
+
const p = h, l = /* @__PURE__ */ new Set();
|
|
3442
|
+
let f = 0;
|
|
3443
|
+
const m = (u) => `${u.reason}:${u.elementId}:${JSON.stringify(u.cell)}:${u.measurements.relatedElementId ?? ""}:${u.reason === "low-contrast" ? f : 0}`, g = ["off-canvas", "missing-font", "text-overflow", "image-distorted", "element-overlap", "low-contrast", "placeholder-prompt-left"];
|
|
3444
|
+
for (; ; ) {
|
|
3445
|
+
a();
|
|
3446
|
+
const u = [...h.issues].sort((v, P) => g.indexOf(v.reason) - g.indexOf(P.reason)).find((v) => !l.has(m(v)));
|
|
3447
|
+
if (!u) break;
|
|
3448
|
+
l.add(m(u));
|
|
3449
|
+
let d = !1;
|
|
3450
|
+
try {
|
|
3451
|
+
u.reason === "off-canvas" ? d = Dt(e, t, u.elementId, r.tolerancePx ?? 0.01, u, i) : u.reason === "missing-font" ? d = _i(e, t, u, r, i) : u.reason === "text-overflow" ? d = Mi(e, t, u, i) : u.reason === "image-distorted" ? d = ji(e, t, u, i) : u.reason === "element-overlap" ? d = await qi(e, t, u, c, i) : u.reason === "low-contrast" && (d = await Ri(e, t, u, c, i));
|
|
3452
|
+
} catch (v) {
|
|
3453
|
+
throw v instanceof E || n != null && n.aborted ? v : new E(
|
|
3454
|
+
"layout-repair-failed",
|
|
3455
|
+
`第 ${u.slideNumber} 页 ${u.elementId} 的 ${u.reason} 修复失败:${v instanceof Error ? v.message : String(v)}`,
|
|
3456
|
+
u.slideNumber,
|
|
3457
|
+
null,
|
|
3458
|
+
u.elementId,
|
|
3459
|
+
h
|
|
3460
|
+
);
|
|
3461
|
+
}
|
|
3462
|
+
d && (u.reason === "off-canvas" || u.reason === "element-overlap") && f++, d || o.push({
|
|
3463
|
+
elementId: u.elementId,
|
|
3464
|
+
reason: u.reason,
|
|
3465
|
+
detail: "现有可安全执行的原生命令未能消除此问题,完整诊断仍保留"
|
|
3466
|
+
}), h = await me(e, c);
|
|
3467
|
+
}
|
|
3468
|
+
return {
|
|
3469
|
+
changed: i.length > 0,
|
|
3470
|
+
initialReport: p,
|
|
3471
|
+
report: h,
|
|
3472
|
+
repairs: i,
|
|
3473
|
+
unavailable: o.filter((u) => h.issues.some((d) => d.elementId === u.elementId && d.reason === u.reason))
|
|
3474
|
+
};
|
|
3475
|
+
}
|
|
3476
|
+
const Ke = "[Content_Types].xml", zi = "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml", Zt = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml", Di = "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
3477
|
+
function Li(e) {
|
|
3478
|
+
var h;
|
|
3479
|
+
const r = Qe(e, { filter: (p) => p.name === Ke })[Ke];
|
|
3480
|
+
if (!r) throw new E("invalid-template", "模板包缺少 Content Types");
|
|
3481
|
+
const s = oe(r), i = ae(s.root, { localName: "Override", namespaceUri: Di }).find((p) => {
|
|
3482
|
+
var l;
|
|
3483
|
+
return ((l = se(p, { localName: "PartName", namespaceUri: null })) == null ? void 0 : l.value) === "/ppt/presentation.xml";
|
|
3484
|
+
}), o = i && ((h = se(i, { localName: "ContentType", namespaceUri: null })) == null ? void 0 : h.value);
|
|
3485
|
+
if (o === Zt) return e;
|
|
3486
|
+
if (!i || o !== zi)
|
|
3487
|
+
throw new E("unsupported-template", `模板主部件类型 ${o ?? "(缺失)"} 不属于普通 PPTX/POTX`);
|
|
3488
|
+
Yt(i, "ContentType", Zt);
|
|
3489
|
+
const n = Qe(e), c = Br({ format: "pptx", bytes: e, parts: n, disposed: !1 }, { [Ke]: G(s) });
|
|
3490
|
+
return Gt(c.package), c.bytes;
|
|
3491
|
+
}
|
|
3492
|
+
const Qi = {
|
|
3493
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
3494
|
+
$ref: "#/definitions/TemplateFillOutline",
|
|
3495
|
+
definitions: {
|
|
3496
|
+
TemplateFillOutline: {
|
|
3497
|
+
type: "object",
|
|
3498
|
+
properties: {
|
|
3499
|
+
version: {
|
|
3500
|
+
type: "number",
|
|
3501
|
+
const: 1
|
|
3502
|
+
},
|
|
3503
|
+
slides: {
|
|
3504
|
+
type: "array",
|
|
3505
|
+
items: {
|
|
3506
|
+
$ref: "#/definitions/TemplateFillSlide"
|
|
3507
|
+
},
|
|
3508
|
+
minItems: 1
|
|
3509
|
+
}
|
|
3510
|
+
},
|
|
3511
|
+
required: [
|
|
3512
|
+
"version",
|
|
3513
|
+
"slides"
|
|
3514
|
+
],
|
|
3515
|
+
additionalProperties: !1
|
|
3516
|
+
},
|
|
3517
|
+
TemplateFillSlide: {
|
|
3518
|
+
anyOf: [
|
|
3519
|
+
{
|
|
3520
|
+
$ref: "#/definitions/TemplateFillTitleSlide"
|
|
3521
|
+
},
|
|
3522
|
+
{
|
|
3523
|
+
$ref: "#/definitions/TemplateFillSectionSlide"
|
|
3524
|
+
},
|
|
3525
|
+
{
|
|
3526
|
+
$ref: "#/definitions/TemplateFillContentSlide"
|
|
3527
|
+
},
|
|
3528
|
+
{
|
|
3529
|
+
$ref: "#/definitions/TemplateFillTwoColumnSlide"
|
|
3530
|
+
},
|
|
3531
|
+
{
|
|
3532
|
+
$ref: "#/definitions/TemplateFillImageSlide"
|
|
3533
|
+
},
|
|
3534
|
+
{
|
|
3535
|
+
$ref: "#/definitions/TemplateFillChartSlide"
|
|
3536
|
+
}
|
|
3537
|
+
]
|
|
3538
|
+
},
|
|
3539
|
+
TemplateFillTitleSlide: {
|
|
3540
|
+
type: "object",
|
|
3541
|
+
properties: {
|
|
3542
|
+
title: {
|
|
3543
|
+
type: "string"
|
|
3544
|
+
},
|
|
3545
|
+
notes: {
|
|
3546
|
+
type: "string"
|
|
3547
|
+
},
|
|
3548
|
+
layoutId: {
|
|
3549
|
+
type: "string"
|
|
3550
|
+
},
|
|
3551
|
+
type: {
|
|
3552
|
+
type: "string",
|
|
3553
|
+
const: "title"
|
|
3554
|
+
},
|
|
3555
|
+
subtitle: {
|
|
3556
|
+
type: "string"
|
|
3557
|
+
}
|
|
3558
|
+
},
|
|
3559
|
+
required: [
|
|
3560
|
+
"title",
|
|
3561
|
+
"type"
|
|
3562
|
+
],
|
|
3563
|
+
additionalProperties: !1
|
|
3564
|
+
},
|
|
3565
|
+
TemplateFillSectionSlide: {
|
|
3566
|
+
type: "object",
|
|
3567
|
+
properties: {
|
|
3568
|
+
title: {
|
|
3569
|
+
type: "string"
|
|
3570
|
+
},
|
|
3571
|
+
notes: {
|
|
3572
|
+
type: "string"
|
|
3573
|
+
},
|
|
3574
|
+
layoutId: {
|
|
3575
|
+
type: "string"
|
|
3576
|
+
},
|
|
3577
|
+
type: {
|
|
3578
|
+
type: "string",
|
|
3579
|
+
const: "section"
|
|
3580
|
+
},
|
|
3581
|
+
body: {
|
|
3582
|
+
type: "array",
|
|
3583
|
+
items: {
|
|
3584
|
+
$ref: "#/definitions/TemplateFillParagraph"
|
|
3585
|
+
}
|
|
3586
|
+
}
|
|
3587
|
+
},
|
|
3588
|
+
required: [
|
|
3589
|
+
"title",
|
|
3590
|
+
"type"
|
|
3591
|
+
],
|
|
3592
|
+
additionalProperties: !1
|
|
3593
|
+
},
|
|
3594
|
+
TemplateFillParagraph: {
|
|
3595
|
+
type: "object",
|
|
3596
|
+
properties: {
|
|
3597
|
+
text: {
|
|
3598
|
+
type: "string"
|
|
3599
|
+
},
|
|
3600
|
+
level: {
|
|
3601
|
+
type: "number",
|
|
3602
|
+
enum: [
|
|
3603
|
+
0,
|
|
3604
|
+
1,
|
|
3605
|
+
2,
|
|
3606
|
+
3,
|
|
3607
|
+
4,
|
|
3608
|
+
5,
|
|
3609
|
+
6,
|
|
3610
|
+
7,
|
|
3611
|
+
8
|
|
3612
|
+
]
|
|
3613
|
+
},
|
|
3614
|
+
bullet: {
|
|
3615
|
+
type: "boolean"
|
|
3616
|
+
}
|
|
3617
|
+
},
|
|
3618
|
+
required: [
|
|
3619
|
+
"text"
|
|
3620
|
+
],
|
|
3621
|
+
additionalProperties: !1
|
|
3622
|
+
},
|
|
3623
|
+
TemplateFillContentSlide: {
|
|
3624
|
+
type: "object",
|
|
3625
|
+
properties: {
|
|
3626
|
+
title: {
|
|
3627
|
+
type: "string"
|
|
3628
|
+
},
|
|
3629
|
+
notes: {
|
|
3630
|
+
type: "string"
|
|
3631
|
+
},
|
|
3632
|
+
layoutId: {
|
|
3633
|
+
type: "string"
|
|
3634
|
+
},
|
|
3635
|
+
type: {
|
|
3636
|
+
type: "string",
|
|
3637
|
+
const: "content"
|
|
3638
|
+
},
|
|
3639
|
+
body: {
|
|
3640
|
+
type: "array",
|
|
3641
|
+
items: {
|
|
3642
|
+
$ref: "#/definitions/TemplateFillParagraph"
|
|
3643
|
+
},
|
|
3644
|
+
minItems: 1
|
|
3645
|
+
}
|
|
3646
|
+
},
|
|
3647
|
+
required: [
|
|
3648
|
+
"body",
|
|
3649
|
+
"title",
|
|
3650
|
+
"type"
|
|
3651
|
+
],
|
|
3652
|
+
additionalProperties: !1
|
|
3653
|
+
},
|
|
3654
|
+
TemplateFillTwoColumnSlide: {
|
|
3655
|
+
type: "object",
|
|
3656
|
+
properties: {
|
|
3657
|
+
title: {
|
|
3658
|
+
type: "string"
|
|
3659
|
+
},
|
|
3660
|
+
notes: {
|
|
3661
|
+
type: "string"
|
|
3662
|
+
},
|
|
3663
|
+
layoutId: {
|
|
3664
|
+
type: "string"
|
|
3665
|
+
},
|
|
3666
|
+
type: {
|
|
3667
|
+
type: "string",
|
|
3668
|
+
const: "two-column"
|
|
3669
|
+
},
|
|
3670
|
+
columns: {
|
|
3671
|
+
type: "array",
|
|
3672
|
+
items: {
|
|
3673
|
+
type: "array",
|
|
3674
|
+
items: {
|
|
3675
|
+
$ref: "#/definitions/TemplateFillParagraph"
|
|
3676
|
+
}
|
|
3677
|
+
},
|
|
3678
|
+
minItems: 2,
|
|
3679
|
+
maxItems: 2
|
|
3680
|
+
}
|
|
3681
|
+
},
|
|
3682
|
+
required: [
|
|
3683
|
+
"columns",
|
|
3684
|
+
"title",
|
|
3685
|
+
"type"
|
|
3686
|
+
],
|
|
3687
|
+
additionalProperties: !1
|
|
3688
|
+
},
|
|
3689
|
+
TemplateFillImageSlide: {
|
|
3690
|
+
type: "object",
|
|
3691
|
+
properties: {
|
|
3692
|
+
title: {
|
|
3693
|
+
type: "string"
|
|
3694
|
+
},
|
|
3695
|
+
notes: {
|
|
3696
|
+
type: "string"
|
|
3697
|
+
},
|
|
3698
|
+
layoutId: {
|
|
3699
|
+
type: "string"
|
|
3700
|
+
},
|
|
3701
|
+
type: {
|
|
3702
|
+
type: "string",
|
|
3703
|
+
const: "image"
|
|
3704
|
+
},
|
|
3705
|
+
image: {
|
|
3706
|
+
$ref: "#/definitions/TemplateFillImage"
|
|
3707
|
+
},
|
|
3708
|
+
body: {
|
|
3709
|
+
type: "array",
|
|
3710
|
+
items: {
|
|
3711
|
+
$ref: "#/definitions/TemplateFillParagraph"
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3714
|
+
},
|
|
3715
|
+
required: [
|
|
3716
|
+
"image",
|
|
3717
|
+
"title",
|
|
3718
|
+
"type"
|
|
3719
|
+
],
|
|
3720
|
+
additionalProperties: !1
|
|
3721
|
+
},
|
|
3722
|
+
TemplateFillImage: {
|
|
3723
|
+
type: "object",
|
|
3724
|
+
properties: {
|
|
3725
|
+
bytes: {
|
|
3726
|
+
type: "string"
|
|
3727
|
+
},
|
|
3728
|
+
mime: {
|
|
3729
|
+
type: "string",
|
|
3730
|
+
enum: [
|
|
3731
|
+
"image/png",
|
|
3732
|
+
"image/jpeg",
|
|
3733
|
+
"image/gif",
|
|
3734
|
+
"image/webp"
|
|
3735
|
+
]
|
|
3736
|
+
},
|
|
3737
|
+
altText: {
|
|
3738
|
+
type: "string"
|
|
3739
|
+
},
|
|
3740
|
+
fit: {
|
|
3741
|
+
type: "string",
|
|
3742
|
+
enum: [
|
|
3743
|
+
"contain",
|
|
3744
|
+
"cover"
|
|
3745
|
+
]
|
|
3746
|
+
}
|
|
3747
|
+
},
|
|
3748
|
+
required: [
|
|
3749
|
+
"bytes",
|
|
3750
|
+
"mime"
|
|
3751
|
+
],
|
|
3752
|
+
additionalProperties: !1
|
|
3753
|
+
},
|
|
3754
|
+
TemplateFillChartSlide: {
|
|
3755
|
+
type: "object",
|
|
3756
|
+
properties: {
|
|
3757
|
+
title: {
|
|
3758
|
+
type: "string"
|
|
3759
|
+
},
|
|
3760
|
+
notes: {
|
|
3761
|
+
type: "string"
|
|
3762
|
+
},
|
|
3763
|
+
layoutId: {
|
|
3764
|
+
type: "string"
|
|
3765
|
+
},
|
|
3766
|
+
type: {
|
|
3767
|
+
type: "string",
|
|
3768
|
+
const: "chart"
|
|
3769
|
+
},
|
|
3770
|
+
chart: {
|
|
3771
|
+
$ref: "#/definitions/TemplateFillChart"
|
|
3772
|
+
}
|
|
3773
|
+
},
|
|
3774
|
+
required: [
|
|
3775
|
+
"chart",
|
|
3776
|
+
"title",
|
|
3777
|
+
"type"
|
|
3778
|
+
],
|
|
3779
|
+
additionalProperties: !1
|
|
3780
|
+
},
|
|
3781
|
+
TemplateFillChart: {
|
|
3782
|
+
type: "object",
|
|
3783
|
+
properties: {
|
|
3784
|
+
type: {
|
|
3785
|
+
type: "string",
|
|
3786
|
+
enum: [
|
|
3787
|
+
"bar",
|
|
3788
|
+
"line",
|
|
3789
|
+
"pie",
|
|
3790
|
+
"doughnut",
|
|
3791
|
+
"area",
|
|
3792
|
+
"scatter",
|
|
3793
|
+
"radar",
|
|
3794
|
+
"bubble"
|
|
3795
|
+
]
|
|
3796
|
+
},
|
|
3797
|
+
categories: {
|
|
3798
|
+
type: "array",
|
|
3799
|
+
items: {
|
|
3800
|
+
type: "string"
|
|
3801
|
+
}
|
|
3802
|
+
},
|
|
3803
|
+
series: {
|
|
3804
|
+
type: "array",
|
|
3805
|
+
items: {
|
|
3806
|
+
$ref: "#/definitions/TemplateFillChartSeries"
|
|
3807
|
+
}
|
|
3808
|
+
},
|
|
3809
|
+
title: {
|
|
3810
|
+
type: "string"
|
|
3811
|
+
}
|
|
3812
|
+
},
|
|
3813
|
+
required: [
|
|
3814
|
+
"type",
|
|
3815
|
+
"categories",
|
|
3816
|
+
"series"
|
|
3817
|
+
],
|
|
3818
|
+
additionalProperties: !1
|
|
3819
|
+
},
|
|
3820
|
+
TemplateFillChartSeries: {
|
|
3821
|
+
type: "object",
|
|
3822
|
+
properties: {
|
|
3823
|
+
name: {
|
|
3824
|
+
type: "string"
|
|
3825
|
+
},
|
|
3826
|
+
values: {
|
|
3827
|
+
type: "array",
|
|
3828
|
+
items: {
|
|
3829
|
+
type: [
|
|
3830
|
+
"number",
|
|
3831
|
+
"null"
|
|
3832
|
+
]
|
|
3833
|
+
}
|
|
3834
|
+
},
|
|
3835
|
+
x: {
|
|
3836
|
+
type: "array",
|
|
3837
|
+
items: {
|
|
3838
|
+
type: [
|
|
3839
|
+
"number",
|
|
3840
|
+
"null"
|
|
3841
|
+
]
|
|
3842
|
+
}
|
|
3843
|
+
},
|
|
3844
|
+
sizes: {
|
|
3845
|
+
type: "array",
|
|
3846
|
+
items: {
|
|
3847
|
+
type: [
|
|
3848
|
+
"number",
|
|
3849
|
+
"null"
|
|
3850
|
+
]
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
},
|
|
3854
|
+
required: [
|
|
3855
|
+
"name",
|
|
3856
|
+
"values"
|
|
3857
|
+
],
|
|
3858
|
+
additionalProperties: !1
|
|
3859
|
+
}
|
|
3860
|
+
},
|
|
3861
|
+
$id: "https://web-ppt.dev/schemas/template-fill.schema.json"
|
|
3862
|
+
};
|
|
3863
|
+
function Zi(e) {
|
|
3864
|
+
if (!e || typeof e != "object" || !e.lint || typeof e.lint != "object" || Array.isArray(e.lint) || typeof e.lint.measureText != "function")
|
|
3865
|
+
throw new E("measurement-required", "模板填充必须通过 options.lint.measureText 提供真实文字测量");
|
|
3866
|
+
if (e.idPrefix !== void 0 && (typeof e.idPrefix != "string" || !e.idPrefix))
|
|
3867
|
+
throw new E("invalid-options", "idPrefix 必须是非空字符串");
|
|
3868
|
+
if (e.requireClean !== void 0 && typeof e.requireClean != "boolean")
|
|
3869
|
+
throw new E("invalid-options", "requireClean 必须是布尔值");
|
|
3870
|
+
if (e.repair !== void 0 && typeof e.repair != "boolean")
|
|
3871
|
+
throw new E("invalid-options", "repair 必须是布尔值");
|
|
3872
|
+
if (e.lint.checks !== void 0 && !Array.isArray(e.lint.checks) || e.lint.fonts !== void 0 && (!e.lint.fonts || !Array.isArray(e.lint.fonts.available) || !Array.isArray(e.lint.fonts.embedded)))
|
|
3873
|
+
throw new E("invalid-options", "布局检查的 checks 和字体库存必须使用数组");
|
|
3874
|
+
if (e.lint.fonts && [...e.lint.fonts.available, ...e.lint.fonts.embedded].some((t) => typeof t != "string" || !t.trim()))
|
|
3875
|
+
throw new E("invalid-options", "字体库存必须使用非空字体名");
|
|
3876
|
+
for (const t of [e.signal, e.lint.signal])
|
|
3877
|
+
if (t !== void 0 && (typeof (t == null ? void 0 : t.aborted) != "boolean" || typeof t.addEventListener != "function" || typeof t.removeEventListener != "function"))
|
|
3878
|
+
throw new E("invalid-options", "取消信号必须是 AbortSignal");
|
|
3879
|
+
return { ...e, lint: {
|
|
3880
|
+
...e.lint,
|
|
3881
|
+
...e.lint.checks ? { checks: [...e.lint.checks] } : {},
|
|
3882
|
+
...e.lint.fonts ? { fonts: { available: [...e.lint.fonts.available], embedded: [...e.lint.fonts.embedded] } } : {}
|
|
3883
|
+
} };
|
|
3884
|
+
}
|
|
3885
|
+
async function Wi(e) {
|
|
3886
|
+
if (typeof e == "string") {
|
|
3887
|
+
const { createPptxFromTemplate: t } = await import("./index-2ti1e4_F.js");
|
|
3888
|
+
try {
|
|
3889
|
+
return t(e);
|
|
3890
|
+
} catch (r) {
|
|
3891
|
+
throw new E("template-not-found", String(r), null, "template");
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
try {
|
|
3895
|
+
return tr(e, "模板字节");
|
|
3896
|
+
} catch (t) {
|
|
3897
|
+
throw new E("invalid-template", t instanceof Error ? t.message : String(t));
|
|
3898
|
+
}
|
|
3899
|
+
}
|
|
3900
|
+
async function xe(e, t) {
|
|
3901
|
+
var i;
|
|
3902
|
+
const r = await zr(e, { edit: !0, keepPackage: !0, lazy: !1 });
|
|
3903
|
+
let s;
|
|
3904
|
+
try {
|
|
3905
|
+
if (s = Zr(r, { idPrefix: t }), s.meta.source !== "pptx" || s.meta.readonly || !s.package)
|
|
3906
|
+
throw new E("unsupported-template", "模板必须是可编辑的 OOXML PPTX/POTX 文稿");
|
|
3907
|
+
return { presentation: r, doc: s, editor: new Wr(s) };
|
|
3908
|
+
} catch (o) {
|
|
3909
|
+
throw s ? Vt(s) : (i = r.dispose) == null || i.call(r), o;
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
async function Je(e) {
|
|
3913
|
+
const t = await Xr(e);
|
|
3914
|
+
return t.package !== e.package && Gt(t.package), t.bytes;
|
|
3915
|
+
}
|
|
3916
|
+
async function eo(e, t, r) {
|
|
3917
|
+
var c, h;
|
|
3918
|
+
r = Zi(r);
|
|
3919
|
+
const s = new AbortController(), i = () => s.abort(), o = [r.signal, r.lint.signal].filter((p) => !!p);
|
|
3920
|
+
for (const p of o)
|
|
3921
|
+
p.addEventListener("abort", i, { once: !0 }), p.aborted && i();
|
|
3922
|
+
let n;
|
|
3923
|
+
const a = () => {
|
|
3924
|
+
n && (n.editor.dispose(), Vt(n.doc), n = void 0);
|
|
3925
|
+
};
|
|
3926
|
+
try {
|
|
3927
|
+
B(s.signal);
|
|
3928
|
+
const { outline: p, images: l } = $s(t), f = p, m = await Wi(e);
|
|
3929
|
+
B(s.signal);
|
|
3930
|
+
const g = r.idPrefix ?? "template-fill-";
|
|
3931
|
+
n = await xe(m, g), B(s.signal);
|
|
3932
|
+
const u = Li(m);
|
|
3933
|
+
u !== m && (a(), n = await xe(u, g), B(s.signal));
|
|
3934
|
+
const d = [];
|
|
3935
|
+
if (r.repair !== !1) {
|
|
3936
|
+
const T = await Lt(
|
|
3937
|
+
n.doc,
|
|
3938
|
+
n.editor,
|
|
3939
|
+
r.lint,
|
|
3940
|
+
{ signal: s.signal, phase: "design" }
|
|
3941
|
+
);
|
|
3942
|
+
if (d.push(...T.repairs), T.changed) {
|
|
3943
|
+
const U = await Je(n.doc);
|
|
3944
|
+
a(), n = await xe(U, g);
|
|
3945
|
+
}
|
|
3946
|
+
B(s.signal);
|
|
3947
|
+
}
|
|
3948
|
+
const v = Ls(n.doc, f.slides), P = v.map((T) => T.object ? Dn(n.doc, T.object) : {}), x = [...((c = r.lint.fonts) == null ? void 0 : c.available) ?? [], ...((h = r.lint.fonts) == null ? void 0 : h.embedded) ?? []], w = new Set(x.map((T) => T.trim().toLowerCase())), k = x.find((T) => !["serif", "sans-serif", "monospace", "system-ui"].includes(T.trim().toLowerCase()));
|
|
3949
|
+
P.forEach((T, U) => {
|
|
3950
|
+
r.repair === !1 || f.slides[U].type !== "chart" || !k || !T.fontFamily || w.has(T.fontFamily.trim().toLowerCase()) || (d.push({
|
|
3951
|
+
elementId: null,
|
|
3952
|
+
slideNumber: U + 1,
|
|
3953
|
+
source: null,
|
|
3954
|
+
reason: "missing-font",
|
|
3955
|
+
action: "select-chart-font",
|
|
3956
|
+
before: { font: T.fontFamily },
|
|
3957
|
+
after: { font: k }
|
|
3958
|
+
}), T.fontFamily = k);
|
|
3959
|
+
});
|
|
3960
|
+
const b = zn(n.editor, f.slides, v, l, s.signal), $ = f.slides.flatMap((T, U) => {
|
|
3961
|
+
if (T.type !== "chart") return [];
|
|
3962
|
+
const z = v[U].object;
|
|
3963
|
+
return [{
|
|
3964
|
+
slidePart: b[U].slidePart,
|
|
3965
|
+
rect: z.rect,
|
|
3966
|
+
chart: T.chart,
|
|
3967
|
+
rot: z.rot,
|
|
3968
|
+
flipH: z.flipH,
|
|
3969
|
+
flipV: z.flipV,
|
|
3970
|
+
...P[U]
|
|
3971
|
+
}];
|
|
3972
|
+
}), I = await Je(n.doc);
|
|
3973
|
+
B(s.signal);
|
|
3974
|
+
let C = Ai(I, $);
|
|
3975
|
+
if (a(), n = await xe(C, g), B(s.signal), r.repair !== !1) {
|
|
3976
|
+
const T = await Lt(
|
|
3977
|
+
n.doc,
|
|
3978
|
+
n.editor,
|
|
3979
|
+
r.lint,
|
|
3980
|
+
{ signal: s.signal, phase: "all" }
|
|
3981
|
+
);
|
|
3982
|
+
d.push(...T.repairs), T.changed && (C = await Je(n.doc), a(), n = await xe(C, g)), B(s.signal);
|
|
3983
|
+
}
|
|
3984
|
+
const A = Ht(n.doc), Z = f.slides.map((T, U) => {
|
|
3985
|
+
const z = n.doc.slideOrder[U], le = v[U], We = n.doc.slides[z].children.filter(($e) => {
|
|
3986
|
+
var pt, mt;
|
|
3987
|
+
const ut = n.doc.elements[$e];
|
|
3988
|
+
return ((pt = ut.meta.origin) == null ? void 0 : pt.part) === ((mt = n.doc.slides[z].origin) == null ? void 0 : mt.part) && (T.type === "image" ? ut.src.kind === "image" : T.type === "chart" && !!as(n.doc, $e));
|
|
3989
|
+
});
|
|
3990
|
+
if ((T.type === "image" || T.type === "chart") && We.length !== 1)
|
|
3991
|
+
throw new E("invalid-result", `第 ${U + 1} 页预期一个原生 ${T.type} 对象,实际 ${We.length} 个`, U + 1);
|
|
3992
|
+
return {
|
|
3993
|
+
slideNumber: U + 1,
|
|
3994
|
+
slideId: z,
|
|
3995
|
+
layoutId: le.layoutId,
|
|
3996
|
+
titleId: K(n.doc, z, le.title),
|
|
3997
|
+
bodyIds: le.bodies.map(($e) => K(n.doc, z, $e)),
|
|
3998
|
+
objectId: We[0] ?? null
|
|
3999
|
+
};
|
|
4000
|
+
}), _ = await me(n.doc, { ...r.lint, signal: s.signal });
|
|
4001
|
+
if (B(s.signal), r.requireClean !== !1 && _.issues.length) {
|
|
4002
|
+
const T = _.issues[0];
|
|
4003
|
+
throw new E(
|
|
4004
|
+
"layout-invalid",
|
|
4005
|
+
`生成文稿有 ${_.issues.length} 项布局问题;首项为第 ${T.slideNumber} 页 ${T.elementId} 的 ${T.reason}`,
|
|
4006
|
+
T.slideNumber,
|
|
4007
|
+
null,
|
|
4008
|
+
T.elementId,
|
|
4009
|
+
_
|
|
4010
|
+
);
|
|
4011
|
+
}
|
|
4012
|
+
const L = d.map((T) => {
|
|
4013
|
+
if (!T.source) {
|
|
4014
|
+
if (T.action !== "select-chart-font" || T.slideNumber === null) return T;
|
|
4015
|
+
const z = Z[T.slideNumber - 1].objectId;
|
|
4016
|
+
return { ...T, elementId: z, source: z ? n.doc.elements[z].meta.origin ?? null : null };
|
|
4017
|
+
}
|
|
4018
|
+
const U = Object.values(n.doc.elements).find((z) => {
|
|
4019
|
+
var le;
|
|
4020
|
+
return ((le = z.meta.origin) == null ? void 0 : le.part) === T.source.part && z.meta.origin.spid === T.source.spid;
|
|
4021
|
+
});
|
|
4022
|
+
return { ...T, elementId: (U == null ? void 0 : U.id) ?? null };
|
|
4023
|
+
});
|
|
4024
|
+
return { bytes: C, description: A, lint: _, bindings: Z, repairs: L };
|
|
4025
|
+
} catch (p) {
|
|
4026
|
+
if (p instanceof E) throw p;
|
|
4027
|
+
const l = p, f = typeof (l == null ? void 0 : l.reason) == "string" ? l.reason : "template-fill-failed";
|
|
4028
|
+
throw new E(
|
|
4029
|
+
f,
|
|
4030
|
+
p instanceof Error ? p.message : String(p),
|
|
4031
|
+
typeof (l == null ? void 0 : l.slideNumber) == "number" ? l.slideNumber : null,
|
|
4032
|
+
typeof (l == null ? void 0 : l.field) == "string" ? l.field : null,
|
|
4033
|
+
typeof (l == null ? void 0 : l.elementId) == "string" ? l.elementId : null
|
|
4034
|
+
);
|
|
4035
|
+
} finally {
|
|
4036
|
+
a();
|
|
4037
|
+
for (const p of o) p.removeEventListener("abort", i);
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
export {
|
|
4041
|
+
E as T,
|
|
4042
|
+
si as c,
|
|
4043
|
+
Nr as d,
|
|
4044
|
+
eo as f,
|
|
4045
|
+
Qi as t
|
|
4046
|
+
};
|