@office-kit/pptx-editor 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -1
- package/dist/{agent-tools-CEZAOXNe.js → agent-tools-EU7Eb-FV.js} +167 -32
- package/dist/agent-tools-EU7Eb-FV.js.map +1 -0
- package/dist/agent-tools-bDB2Jq41.d.ts +28 -0
- package/dist/{deck-merge-B_Damj97.js → deck-merge-Dj_XHQQM.js} +162 -9
- package/dist/deck-merge-Dj_XHQQM.js.map +1 -0
- package/dist/headless.d.ts +55 -0
- package/dist/headless.js +232 -0
- package/dist/headless.js.map +1 -0
- package/dist/{index-BFQN6sI6.d.ts → index-cdzLrufG.d.ts} +3 -26
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/merge.js +1 -1
- package/dist/shape-ref-B5iNfYWh.js +109 -0
- package/dist/shape-ref-B5iNfYWh.js.map +1 -0
- package/dist/{src-BrBOgen_.js → src-CJWOpCx6.js} +27 -110
- package/dist/src-CJWOpCx6.js.map +1 -0
- package/package.json +7 -3
- package/dist/agent-tools-CEZAOXNe.js.map +0 -1
- package/dist/deck-merge-B_Damj97.js.map +0 -1
- package/dist/src-BrBOgen_.js.map +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PresentationData, SlideShapeData } from "@office-kit/pptx";
|
|
2
|
+
|
|
3
|
+
//#region src/core/agent-tools.d.ts
|
|
4
|
+
/** A JSON value: what a tool takes as input and gives back. */
|
|
5
|
+
type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
6
|
+
readonly [key: string]: JsonValue;
|
|
7
|
+
};
|
|
8
|
+
/** A JSON Schema (draft 2020-12) object. */
|
|
9
|
+
type JsonSchema = {
|
|
10
|
+
readonly [key: string]: JsonValue;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A tool definition in the shape model APIs take: Anthropic's `tools` entries
|
|
14
|
+
* as they are; for OpenAI, `{ type: 'function', function: { name, description,
|
|
15
|
+
* parameters: input_schema } }`.
|
|
16
|
+
*/
|
|
17
|
+
interface EditorTool {
|
|
18
|
+
/** The `@office-kit/pptx` export it calls, or a read tool's name. */
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly description: string;
|
|
21
|
+
/** The input, as a self-contained JSON Schema (draft 2020-12) object. */
|
|
22
|
+
readonly input_schema: JsonSchema & {
|
|
23
|
+
readonly type: "object";
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { JsonSchema as n, JsonValue as r, EditorTool as t };
|
|
28
|
+
//# sourceMappingURL=agent-tools-bDB2Jq41.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { strFromU8, strToU8,
|
|
1
|
+
import { Inflate, inflateSync, strFromU8, strToU8, zipSync } from "fflate";
|
|
2
2
|
//#region ../../src/internal/opc/zip.ts
|
|
3
3
|
const STORE_BY_EXTENSION = new Set([
|
|
4
4
|
"png",
|
|
@@ -36,20 +36,173 @@ const extensionOf = (name) => {
|
|
|
36
36
|
* negligible savings.
|
|
37
37
|
*/
|
|
38
38
|
const shouldStore = (name) => STORE_BY_EXTENSION.has(extensionOf(name));
|
|
39
|
+
const SIG_LOCAL_HEADER = 67324752;
|
|
40
|
+
const SIG_CENTRAL_HEADER = 33639248;
|
|
41
|
+
const SIG_EOCD = 101010256;
|
|
42
|
+
const SIG_ZIP64_EOCD = 101075792;
|
|
43
|
+
const SIG_ZIP64_LOCATOR = 117853008;
|
|
44
|
+
const EOCD_SIZE = 22;
|
|
45
|
+
const MAX_COMMENT_LENGTH = 65535;
|
|
46
|
+
const ZIP64_LOCATOR_SIZE = 20;
|
|
47
|
+
const ZIP64_EOCD_MIN_SIZE = 56;
|
|
48
|
+
const CENTRAL_HEADER_SIZE = 46;
|
|
49
|
+
const LOCAL_HEADER_SIZE = 30;
|
|
50
|
+
const ZIP64_EXTRA_ID = 1;
|
|
51
|
+
const ZIP64_SENTINEL_32 = 4294967295;
|
|
52
|
+
const FLAG_UTF8 = 2048;
|
|
53
|
+
const METHOD_STORE = 0;
|
|
54
|
+
const METHOD_DEFLATE = 8;
|
|
55
|
+
const INFLATE_CHUNK_SIZE = 16 * 1024;
|
|
56
|
+
const MAX_DEFLATE_RATIO = 1032;
|
|
57
|
+
const DEFLATE_RATIO_SLACK = 1024;
|
|
58
|
+
const invalid = (reason) => /* @__PURE__ */ new Error(`invalid ZIP: ${reason}`);
|
|
59
|
+
const u16 = (d, at) => d[at] | d[at + 1] << 8;
|
|
60
|
+
const u32 = (d, at) => (d[at] | d[at + 1] << 8 | d[at + 2] << 16 | d[at + 3] << 24) >>> 0;
|
|
61
|
+
const u64 = (d, at) => {
|
|
62
|
+
const value = u32(d, at) + u32(d, at + 4) * 2 ** 32;
|
|
63
|
+
if (!Number.isSafeInteger(value)) throw invalid("ZIP64 value out of range");
|
|
64
|
+
return value;
|
|
65
|
+
};
|
|
66
|
+
const requireRange = (d, at, length, what) => {
|
|
67
|
+
if (at < 0 || length < 0 || at + length > d.length) throw invalid(`${what} is out of bounds`);
|
|
68
|
+
};
|
|
69
|
+
const findEocd = (d) => {
|
|
70
|
+
const lowest = Math.max(0, d.length - EOCD_SIZE - MAX_COMMENT_LENGTH);
|
|
71
|
+
for (let at = d.length - EOCD_SIZE; at >= lowest; at--) if (u32(d, at) === SIG_EOCD) return at;
|
|
72
|
+
throw invalid("end of central directory not found");
|
|
73
|
+
};
|
|
74
|
+
const readCentralDirectoryLocation = (d) => {
|
|
75
|
+
const eocd = findEocd(d);
|
|
76
|
+
const locator = eocd - ZIP64_LOCATOR_SIZE;
|
|
77
|
+
if (locator >= 0 && u32(d, locator) === SIG_ZIP64_LOCATOR) {
|
|
78
|
+
const zip64Eocd = u32(d, locator + 8) + u32(d, locator + 12) * 2 ** 32;
|
|
79
|
+
if (zip64Eocd + ZIP64_EOCD_MIN_SIZE <= d.length && u32(d, zip64Eocd) === SIG_ZIP64_EOCD) return {
|
|
80
|
+
count: u64(d, zip64Eocd + 32),
|
|
81
|
+
offset: u64(d, zip64Eocd + 48)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
count: u16(d, eocd + 10),
|
|
86
|
+
offset: u32(d, eocd + 16)
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
const resolveZip64Sizes = (d, extraStart, extraEnd, sizes) => {
|
|
90
|
+
const needUncompressed = sizes.uncompressedSize === ZIP64_SENTINEL_32;
|
|
91
|
+
const needCompressed = sizes.compressedSize === ZIP64_SENTINEL_32;
|
|
92
|
+
const needOffset = sizes.localHeaderOffset === ZIP64_SENTINEL_32;
|
|
93
|
+
if (!needUncompressed && !needCompressed && !needOffset) return sizes;
|
|
94
|
+
for (let at = extraStart; at + 4 <= extraEnd; at += 4 + u16(d, at + 2)) {
|
|
95
|
+
if (u16(d, at) !== ZIP64_EXTRA_ID) continue;
|
|
96
|
+
const fieldEnd = at + 4 + u16(d, at + 2);
|
|
97
|
+
if (fieldEnd > extraEnd) break;
|
|
98
|
+
let cursor = at + 4;
|
|
99
|
+
const next = () => {
|
|
100
|
+
if (cursor + 8 > fieldEnd) throw invalid("ZIP64 extra field is truncated");
|
|
101
|
+
const value = u64(d, cursor);
|
|
102
|
+
cursor += 8;
|
|
103
|
+
return value;
|
|
104
|
+
};
|
|
105
|
+
return {
|
|
106
|
+
uncompressedSize: needUncompressed ? next() : sizes.uncompressedSize,
|
|
107
|
+
compressedSize: needCompressed ? next() : sizes.compressedSize,
|
|
108
|
+
localHeaderOffset: needOffset ? next() : sizes.localHeaderOffset
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
throw invalid("ZIP64 sizes without a ZIP64 extra field");
|
|
112
|
+
};
|
|
113
|
+
const overflowError = (name, declaredSize) => invalid(`entry "${name}" inflates beyond its declared size of ${declaredSize} bytes`);
|
|
114
|
+
const corruptError = (name, error) => {
|
|
115
|
+
return invalid(`entry "${name}" is not valid DEFLATE data: ${error instanceof Error ? error.message : String(error)}`);
|
|
116
|
+
};
|
|
117
|
+
const inflateSmallEntry = (compressed, declaredSize, name) => {
|
|
118
|
+
if (compressed.length === 0) return new Uint8Array(0);
|
|
119
|
+
let out;
|
|
120
|
+
try {
|
|
121
|
+
out = inflateSync(compressed, { out: new Uint8Array(declaredSize + 1) });
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (error instanceof RangeError) throw overflowError(name, declaredSize);
|
|
124
|
+
throw corruptError(name, error);
|
|
125
|
+
}
|
|
126
|
+
if (out.length > declaredSize) throw overflowError(name, declaredSize);
|
|
127
|
+
return out;
|
|
128
|
+
};
|
|
129
|
+
const inflateLargeEntry = (compressed, declaredSize, name) => {
|
|
130
|
+
const out = new Uint8Array(declaredSize);
|
|
131
|
+
let overflowed = false;
|
|
132
|
+
let produced = 0;
|
|
133
|
+
const inflater = new Inflate((chunk) => {
|
|
134
|
+
if (produced + chunk.length > declaredSize) {
|
|
135
|
+
overflowed = true;
|
|
136
|
+
throw overflowError(name, declaredSize);
|
|
137
|
+
}
|
|
138
|
+
out.set(chunk, produced);
|
|
139
|
+
produced += chunk.length;
|
|
140
|
+
});
|
|
141
|
+
for (let at = 0; at < compressed.length; at += INFLATE_CHUNK_SIZE) {
|
|
142
|
+
const end = Math.min(at + INFLATE_CHUNK_SIZE, compressed.length);
|
|
143
|
+
try {
|
|
144
|
+
inflater.push(compressed.subarray(at, end), end === compressed.length);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
if (overflowed) throw error;
|
|
147
|
+
throw corruptError(name, error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return out.subarray(0, produced);
|
|
151
|
+
};
|
|
152
|
+
const inflateEntry = (compressed, declaredSize, name) => {
|
|
153
|
+
if (declaredSize > compressed.length * MAX_DEFLATE_RATIO + DEFLATE_RATIO_SLACK) throw invalid(`entry "${name}" declares ${declaredSize} bytes, more than ${compressed.length} compressed bytes can hold`);
|
|
154
|
+
const out = compressed.length <= INFLATE_CHUNK_SIZE ? inflateSmallEntry(compressed, declaredSize, name) : inflateLargeEntry(compressed, declaredSize, name);
|
|
155
|
+
if (out.length !== declaredSize) throw invalid(`entry "${name}" inflates to ${out.length} bytes, not its declared ${declaredSize}`);
|
|
156
|
+
return out;
|
|
157
|
+
};
|
|
39
158
|
/**
|
|
40
159
|
* Reads a ZIP archive (a `.pptx` file is a ZIP) and returns entries in
|
|
41
|
-
* central-directory order. Throws if `input` is not a valid ZIP
|
|
160
|
+
* central-directory order. Throws if `input` is not a valid ZIP, if two
|
|
161
|
+
* entries share a name, or if an entry's data does not match the size its
|
|
162
|
+
* central-directory record declares.
|
|
42
163
|
*/
|
|
43
164
|
const readZip = (input) => {
|
|
44
|
-
const
|
|
165
|
+
const { offset, count } = readCentralDirectoryLocation(input);
|
|
45
166
|
const entries = [];
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
167
|
+
const seen = /* @__PURE__ */ new Set();
|
|
168
|
+
let cursor = offset;
|
|
169
|
+
for (let i = 0; i < count; i++) {
|
|
170
|
+
requireRange(input, cursor, CENTRAL_HEADER_SIZE, "central directory");
|
|
171
|
+
if (u32(input, cursor) !== SIG_CENTRAL_HEADER) throw invalid("bad central directory signature");
|
|
172
|
+
const flags = u16(input, cursor + 8);
|
|
173
|
+
const method = u16(input, cursor + 10);
|
|
174
|
+
const nameLength = u16(input, cursor + 28);
|
|
175
|
+
const extraLength = u16(input, cursor + 30);
|
|
176
|
+
const commentLength = u16(input, cursor + 32);
|
|
177
|
+
const nameStart = cursor + CENTRAL_HEADER_SIZE;
|
|
178
|
+
const extraStart = nameStart + nameLength;
|
|
179
|
+
const recordEnd = extraStart + extraLength + commentLength;
|
|
180
|
+
requireRange(input, cursor, recordEnd - cursor, "central directory");
|
|
181
|
+
const name = strFromU8(input.subarray(nameStart, extraStart), (flags & FLAG_UTF8) === 0);
|
|
182
|
+
const { compressedSize, uncompressedSize, localHeaderOffset } = resolveZip64Sizes(input, extraStart, extraStart + extraLength, {
|
|
183
|
+
compressedSize: u32(input, cursor + 20),
|
|
184
|
+
uncompressedSize: u32(input, cursor + 24),
|
|
185
|
+
localHeaderOffset: u32(input, cursor + 42)
|
|
186
|
+
});
|
|
187
|
+
cursor = recordEnd;
|
|
188
|
+
if (seen.has(name)) throw invalid(`duplicate entry "${name}"`);
|
|
189
|
+
seen.add(name);
|
|
190
|
+
requireRange(input, localHeaderOffset, LOCAL_HEADER_SIZE, `local header of "${name}"`);
|
|
191
|
+
if (u32(input, localHeaderOffset) !== SIG_LOCAL_HEADER) throw invalid(`bad local header signature for "${name}"`);
|
|
192
|
+
const dataStart = localHeaderOffset + LOCAL_HEADER_SIZE + u16(input, localHeaderOffset + 26) + u16(input, localHeaderOffset + 28);
|
|
193
|
+
requireRange(input, dataStart, compressedSize, `data of "${name}"`);
|
|
194
|
+
const compressed = input.subarray(dataStart, dataStart + compressedSize);
|
|
195
|
+
if (method === METHOD_STORE) {
|
|
196
|
+
if (compressedSize !== uncompressedSize) throw invalid(`stored entry "${name}" has mismatched sizes`);
|
|
197
|
+
entries.push({
|
|
198
|
+
name,
|
|
199
|
+
data: compressed.slice()
|
|
200
|
+
});
|
|
201
|
+
} else if (method === METHOD_DEFLATE) entries.push({
|
|
50
202
|
name,
|
|
51
|
-
data
|
|
203
|
+
data: inflateEntry(compressed, uncompressedSize, name)
|
|
52
204
|
});
|
|
205
|
+
else throw invalid(`entry "${name}" uses unsupported compression method ${method}`);
|
|
53
206
|
}
|
|
54
207
|
return { entries };
|
|
55
208
|
};
|
|
@@ -1335,4 +1488,4 @@ function describeConflict(conflict) {
|
|
|
1335
1488
|
//#endregion
|
|
1336
1489
|
export { sameDeck as i, describeConflict as n, mergeDecks as r, comparablePart as t };
|
|
1337
1490
|
|
|
1338
|
-
//# sourceMappingURL=deck-merge-
|
|
1491
|
+
//# sourceMappingURL=deck-merge-Dj_XHQQM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deck-merge-Dj_XHQQM.js","names":[],"sources":["../../../src/internal/opc/zip.ts","../../../src/internal/opc/part-name.ts","../../../src/internal/xml/ast.ts","../../../src/internal/xml/namespaces.ts","../../../src/internal/xml/parse.ts","../../../src/internal/xml/query.ts","../../../src/internal/xml/serialize.ts","../../../src/internal/opc/content-types.ts","../../../src/internal/opc/rels.ts","../src/merge/deck-merge.ts"],"sourcesContent":["// ZIP I/O backing the OPC package layer.\n//\n// Wraps `fflate` because it is the only ZIP library that is small (~30KB),\n// synchronous, and works in both Node and browsers without a polyfill.\n// Writing goes through `zipSync`; reading walks the central directory here and\n// inflates each entry with fflate.\n//\n// Reading treats the archive as untrusted input. `unzipSync` inflates every\n// entry to the end even when the output overflows the size the central\n// directory declares, so a few-KB entry declaring 10 bytes can still burn\n// seconds of synchronous CPU. Here an entry is inflated at most one chunk of\n// input past the point its output exceeds the declared size, which caps the\n// work at the sum of the central directory's declared sizes plus about one\n// chunk of overrun.\n//\n// What we preserve on round-trip:\n//\n// - Entry order. Entries are returned in central-directory order.\n// - Approximate per-entry compression method. Real PPTX files store media\n// (PNG, JPEG, ...) with no compression (STORE) and deflate everything\n// else. We mirror that heuristic on write, using extension to decide.\n// We do NOT round-trip the *exact* DEFLATE level — every PPTX consumer\n// accepts any valid level.\n//\n// What we do NOT preserve:\n//\n// - File timestamps (`mtime`). The reference desktop app sets these to the current time\n// anyway; preserving the original would be misleading.\n// - ZIP64 records. They are read, but never written.\n// - Extra fields, file attributes, UTF-8 flags. These are not load-bearing\n// for PPTX as consumed by the reference desktop app.\n\nimport { Inflate, type ZipOptions, inflateSync, strFromU8, zipSync } from 'fflate';\n\nexport interface ZipEntry {\n /** Path inside the archive, forward-slash separated (`ppt/slides/slide1.xml`). */\n name: string;\n /** Decompressed bytes. */\n data: Uint8Array;\n}\n\nexport interface ZipReadResult {\n /** Entries in the order the central directory listed them. */\n entries: ZipEntry[];\n}\n\nconst STORE_BY_EXTENSION = new Set([\n // images — already compressed\n 'png',\n 'jpg',\n 'jpeg',\n 'gif',\n 'bmp',\n 'tif',\n 'tiff',\n 'webp',\n // media — already compressed\n 'mp3',\n 'mp4',\n 'm4a',\n 'm4v',\n 'wav',\n 'wmv',\n 'mov',\n 'avi',\n 'webm',\n 'ogg',\n 'wma',\n // archives — already compressed\n 'pdf',\n 'zip',\n 'gz',\n '7z',\n 'rar',\n]);\n\nconst extensionOf = (name: string): string => {\n const dot = name.lastIndexOf('.');\n return dot < 0 ? '' : name.slice(dot + 1).toLowerCase();\n};\n\n/**\n * Returns true if the entry should be stored uncompressed. PPTX writers\n * conventionally STORE already-compressed payloads to avoid wasting CPU on\n * negligible savings.\n */\nexport const shouldStore = (name: string): boolean => STORE_BY_EXTENSION.has(extensionOf(name));\n\nconst SIG_LOCAL_HEADER = 0x04034b50;\nconst SIG_CENTRAL_HEADER = 0x02014b50;\nconst SIG_EOCD = 0x06054b50;\nconst SIG_ZIP64_EOCD = 0x06064b50;\nconst SIG_ZIP64_LOCATOR = 0x07064b50;\nconst EOCD_SIZE = 22;\nconst MAX_COMMENT_LENGTH = 0xffff;\nconst ZIP64_LOCATOR_SIZE = 20;\nconst ZIP64_EOCD_MIN_SIZE = 56;\nconst CENTRAL_HEADER_SIZE = 46;\nconst LOCAL_HEADER_SIZE = 30;\nconst ZIP64_EXTRA_ID = 0x0001;\nconst ZIP64_SENTINEL_32 = 0xffffffff;\nconst FLAG_UTF8 = 0x0800;\nconst METHOD_STORE = 0;\nconst METHOD_DEFLATE = 8;\n// A 16KB DEFLATE chunk inflates to at most ~17MB (~30ms), which bounds the\n// work done past an entry's declared size before the overflow is noticed.\nconst INFLATE_CHUNK_SIZE = 16 * 1024;\n// DEFLATE needs at least 2 bits per 258-byte match, so it expands at most\n// ~1032:1; the slack covers block headers and the first literals.\nconst MAX_DEFLATE_RATIO = 1032;\nconst DEFLATE_RATIO_SLACK = 1024;\n\nconst invalid = (reason: string): Error => new Error(`invalid ZIP: ${reason}`);\n\nconst u16 = (d: Uint8Array, at: number): number => d[at]! | (d[at + 1]! << 8);\nconst u32 = (d: Uint8Array, at: number): number =>\n (d[at]! | (d[at + 1]! << 8) | (d[at + 2]! << 16) | (d[at + 3]! << 24)) >>> 0;\nconst u64 = (d: Uint8Array, at: number): number => {\n const value = u32(d, at) + u32(d, at + 4) * 2 ** 32;\n if (!Number.isSafeInteger(value)) throw invalid('ZIP64 value out of range');\n return value;\n};\n\nconst requireRange = (d: Uint8Array, at: number, length: number, what: string): void => {\n if (at < 0 || length < 0 || at + length > d.length) throw invalid(`${what} is out of bounds`);\n};\n\nconst findEocd = (d: Uint8Array): number => {\n const lowest = Math.max(0, d.length - EOCD_SIZE - MAX_COMMENT_LENGTH);\n for (let at = d.length - EOCD_SIZE; at >= lowest; at--) {\n if (u32(d, at) === SIG_EOCD) return at;\n }\n throw invalid('end of central directory not found');\n};\n\ninterface CentralDirectory {\n offset: number;\n count: number;\n}\n\nconst readCentralDirectoryLocation = (d: Uint8Array): CentralDirectory => {\n const eocd = findEocd(d);\n const locator = eocd - ZIP64_LOCATOR_SIZE;\n // A ZIP64 locator overrides the 32-bit count and offset even when they are\n // not sentinels, so honour it; the per-entry size checks below hold either way.\n // One that does not lead to a ZIP64 EOCD is ignored, as fflate did.\n if (locator >= 0 && u32(d, locator) === SIG_ZIP64_LOCATOR) {\n const zip64Eocd = u32(d, locator + 8) + u32(d, locator + 12) * 2 ** 32;\n if (zip64Eocd + ZIP64_EOCD_MIN_SIZE <= d.length && u32(d, zip64Eocd) === SIG_ZIP64_EOCD) {\n return { count: u64(d, zip64Eocd + 32), offset: u64(d, zip64Eocd + 48) };\n }\n }\n return { count: u16(d, eocd + 10), offset: u32(d, eocd + 16) };\n};\n\ninterface EntrySizes {\n compressedSize: number;\n uncompressedSize: number;\n localHeaderOffset: number;\n}\n\n// The ZIP64 extra field lists only the values whose 32-bit slot holds the\n// sentinel, in this fixed order (APPNOTE 4.5.3).\nconst resolveZip64Sizes = (\n d: Uint8Array,\n extraStart: number,\n extraEnd: number,\n sizes: EntrySizes,\n): EntrySizes => {\n const needUncompressed = sizes.uncompressedSize === ZIP64_SENTINEL_32;\n const needCompressed = sizes.compressedSize === ZIP64_SENTINEL_32;\n const needOffset = sizes.localHeaderOffset === ZIP64_SENTINEL_32;\n if (!needUncompressed && !needCompressed && !needOffset) return sizes;\n for (let at = extraStart; at + 4 <= extraEnd; at += 4 + u16(d, at + 2)) {\n if (u16(d, at) !== ZIP64_EXTRA_ID) continue;\n const fieldEnd = at + 4 + u16(d, at + 2);\n if (fieldEnd > extraEnd) break;\n let cursor = at + 4;\n const next = (): number => {\n if (cursor + 8 > fieldEnd) throw invalid('ZIP64 extra field is truncated');\n const value = u64(d, cursor);\n cursor += 8;\n return value;\n };\n return {\n uncompressedSize: needUncompressed ? next() : sizes.uncompressedSize,\n compressedSize: needCompressed ? next() : sizes.compressedSize,\n localHeaderOffset: needOffset ? next() : sizes.localHeaderOffset,\n };\n }\n throw invalid('ZIP64 sizes without a ZIP64 extra field');\n};\n\nconst overflowError = (name: string, declaredSize: number): Error =>\n invalid(`entry \"${name}\" inflates beyond its declared size of ${declaredSize} bytes`);\n\nconst corruptError = (name: string, error: unknown): Error => {\n const reason = error instanceof Error ? error.message : String(error);\n return invalid(`entry \"${name}\" is not valid DEFLATE data: ${reason}`);\n};\n\n// One-shot inflate into a buffer one byte longer than declared: fflate drops\n// writes past a caller's buffer, so a full buffer means overflow. Streaming\n// `Inflate` costs ~70µs per entry, which dominates packages of many tiny parts.\nconst inflateSmallEntry = (\n compressed: Uint8Array,\n declaredSize: number,\n name: string,\n): Uint8Array => {\n // fflate returns the whole buffer for empty input; an empty stream yields nothing.\n if (compressed.length === 0) return new Uint8Array(0);\n let out: Uint8Array;\n try {\n out = inflateSync(compressed, { out: new Uint8Array(declaredSize + 1) });\n } catch (error) {\n // A stored block that overruns the buffer surfaces as a RangeError from `set`.\n if (error instanceof RangeError) throw overflowError(name, declaredSize);\n throw corruptError(name, error);\n }\n if (out.length > declaredSize) throw overflowError(name, declaredSize);\n return out;\n};\n\n// Fills a buffer of the declared size, as `unzipSync` did, so a large entry is\n// held once.\nconst inflateLargeEntry = (\n compressed: Uint8Array,\n declaredSize: number,\n name: string,\n): Uint8Array => {\n const out = new Uint8Array(declaredSize);\n let overflowed = false;\n let produced = 0;\n const inflater = new Inflate((chunk) => {\n if (produced + chunk.length > declaredSize) {\n overflowed = true;\n throw overflowError(name, declaredSize);\n }\n out.set(chunk, produced);\n produced += chunk.length;\n });\n for (let at = 0; at < compressed.length; at += INFLATE_CHUNK_SIZE) {\n const end = Math.min(at + INFLATE_CHUNK_SIZE, compressed.length);\n try {\n inflater.push(compressed.subarray(at, end), end === compressed.length);\n } catch (error) {\n if (overflowed) throw error;\n throw corruptError(name, error);\n }\n }\n return out.subarray(0, produced);\n};\n\nconst inflateEntry = (compressed: Uint8Array, declaredSize: number, name: string): Uint8Array => {\n // Checked before allocating so a tiny entry cannot reserve gigabytes.\n if (declaredSize > compressed.length * MAX_DEFLATE_RATIO + DEFLATE_RATIO_SLACK) {\n throw invalid(\n `entry \"${name}\" declares ${declaredSize} bytes, more than ${compressed.length} compressed bytes can hold`,\n );\n }\n const out =\n compressed.length <= INFLATE_CHUNK_SIZE\n ? inflateSmallEntry(compressed, declaredSize, name)\n : inflateLargeEntry(compressed, declaredSize, name);\n if (out.length !== declaredSize) {\n throw invalid(\n `entry \"${name}\" inflates to ${out.length} bytes, not its declared ${declaredSize}`,\n );\n }\n return out;\n};\n\n/**\n * Reads a ZIP archive (a `.pptx` file is a ZIP) and returns entries in\n * central-directory order. Throws if `input` is not a valid ZIP, if two\n * entries share a name, or if an entry's data does not match the size its\n * central-directory record declares.\n */\nexport const readZip = (input: Uint8Array): ZipReadResult => {\n const { offset, count } = readCentralDirectoryLocation(input);\n const entries: ZipEntry[] = [];\n const seen = new Set<string>();\n let cursor = offset;\n for (let i = 0; i < count; i++) {\n requireRange(input, cursor, CENTRAL_HEADER_SIZE, 'central directory');\n if (u32(input, cursor) !== SIG_CENTRAL_HEADER) throw invalid('bad central directory signature');\n const flags = u16(input, cursor + 8);\n const method = u16(input, cursor + 10);\n const nameLength = u16(input, cursor + 28);\n const extraLength = u16(input, cursor + 30);\n const commentLength = u16(input, cursor + 32);\n const nameStart = cursor + CENTRAL_HEADER_SIZE;\n const extraStart = nameStart + nameLength;\n const recordEnd = extraStart + extraLength + commentLength;\n requireRange(input, cursor, recordEnd - cursor, 'central directory');\n const name = strFromU8(input.subarray(nameStart, extraStart), (flags & FLAG_UTF8) === 0);\n const { compressedSize, uncompressedSize, localHeaderOffset } = resolveZip64Sizes(\n input,\n extraStart,\n extraStart + extraLength,\n {\n compressedSize: u32(input, cursor + 20),\n uncompressedSize: u32(input, cursor + 24),\n localHeaderOffset: u32(input, cursor + 42),\n },\n );\n cursor = recordEnd;\n\n if (seen.has(name)) throw invalid(`duplicate entry \"${name}\"`);\n seen.add(name);\n\n requireRange(input, localHeaderOffset, LOCAL_HEADER_SIZE, `local header of \"${name}\"`);\n if (u32(input, localHeaderOffset) !== SIG_LOCAL_HEADER) {\n throw invalid(`bad local header signature for \"${name}\"`);\n }\n const dataStart =\n localHeaderOffset +\n LOCAL_HEADER_SIZE +\n u16(input, localHeaderOffset + 26) +\n u16(input, localHeaderOffset + 28);\n requireRange(input, dataStart, compressedSize, `data of \"${name}\"`);\n const compressed = input.subarray(dataStart, dataStart + compressedSize);\n\n if (method === METHOD_STORE) {\n if (compressedSize !== uncompressedSize) {\n throw invalid(`stored entry \"${name}\" has mismatched sizes`);\n }\n entries.push({ name, data: compressed.slice() });\n } else if (method === METHOD_DEFLATE) {\n entries.push({ name, data: inflateEntry(compressed, uncompressedSize, name) });\n } else {\n throw invalid(`entry \"${name}\" uses unsupported compression method ${method}`);\n }\n }\n return { entries };\n};\n\n/**\n * Writes a ZIP archive. Entries are written in the order given. Each entry's\n * compression method is chosen from its extension via `shouldStore`. Callers\n * who want a specific compression level can pass `levelOverride`.\n */\n/** DEFLATE compression level. 0 stores uncompressed; 9 is best compression. */\nexport type CompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;\n\nexport const writeZip = (\n entries: ReadonlyArray<ZipEntry>,\n options: { level?: CompressionLevel } = {},\n): Uint8Array => {\n const defaultLevel: CompressionLevel = options.level ?? 6;\n const obj: Record<string, [Uint8Array, ZipOptions]> = {};\n for (const e of entries) {\n const level: CompressionLevel = shouldStore(e.name) ? 0 : defaultLevel;\n obj[e.name] = [e.data, { level }];\n }\n return zipSync(obj);\n};\n","// Part name utilities per OPC (ECMA-376 Part 2 §9.1.1).\n//\n// A part name is a URI path that begins with `/`, uses `/` as segment\n// separator, and has no trailing slash (except the package root which is\n// outside the scope of this module). Within a ZIP, the file name is the part\n// name with the leading `/` removed.\n//\n// Part names are compared case-insensitively. We normalize them to lowercase\n// when comparing but preserve the original casing for serialization, because\n// the casing on disk is significant for compatibility with some tools.\n\nexport type PartName = string & { readonly __brand: 'PartName' };\n\n/**\n * Asserts the given string is a syntactically valid OPC part name and returns\n * it as a branded `PartName`. Throws otherwise.\n *\n * Rules enforced (subset; see ECMA-376 Part 2 §9.1.1.1-9.1.1.6):\n *\n * - Must start with `/`.\n * - Must not end with `/`.\n * - Must not contain `//` (empty segments).\n * - Each segment must be non-empty and must not be `.` or `..`.\n */\nexport const partName = (raw: string): PartName => {\n if (raw === '') throw new Error('part name is empty');\n if (!raw.startsWith('/')) throw new Error(`part name must start with \"/\": ${raw}`);\n if (raw.length > 1 && raw.endsWith('/')) {\n throw new Error(`part name must not end with \"/\": ${raw}`);\n }\n const segments = raw.slice(1).split('/');\n for (const s of segments) {\n if (s === '') throw new Error(`part name contains empty segment: ${raw}`);\n if (s === '.' || s === '..') {\n throw new Error(`part name contains \".\" or \"..\" segment: ${raw}`);\n }\n }\n return raw as PartName;\n};\n\n/** Convert a part name to the corresponding ZIP entry path (no leading slash). */\nexport const toZipPath = (name: PartName): string => name.slice(1);\n\n/** Convert a ZIP entry path to a part name (adds leading slash). */\nexport const fromZipPath = (zipPath: string): PartName => partName(`/${zipPath}`);\n\n/** Case-insensitive part name equality per OPC §9.1.1.7. */\nexport const partNamesEqual = (a: PartName, b: PartName): boolean =>\n a.toLowerCase() === b.toLowerCase();\n\n/**\n * Returns the directory portion of a part name (everything before the final\n * `/`). The result keeps the leading slash but has no trailing slash, except\n * for the root which returns `/`.\n */\nexport const dirname = (name: PartName): string => {\n const idx = name.lastIndexOf('/');\n if (idx <= 0) return '/';\n return name.slice(0, idx);\n};\n\n/** Returns the file portion of a part name (everything after the final `/`). */\nexport const basename = (name: PartName): string => {\n const idx = name.lastIndexOf('/');\n return idx < 0 ? name : name.slice(idx + 1);\n};\n\n/**\n * Computes the part name of the `.rels` file that holds relationships\n * originating from `name`. Per OPC §9.3.2: for a part `/x/y/z.xml` the rels\n * file is `/x/y/_rels/z.xml.rels`. The package-root rels file is `/_rels/.rels`.\n */\nexport const relsPartNameFor = (name: PartName): PartName => {\n const dir = dirname(name);\n const file = basename(name);\n const prefix = dir === '/' ? '/_rels/' : `${dir}/_rels/`;\n return partName(`${prefix}${file}.rels`);\n};\n\n/** The source of the package-root relationships (`/_rels/.rels`). */\nexport const PACKAGE_ROOT = '/';\n\n/**\n * Resolves a relationship Target (which may be relative) against a base part\n * name, or against `PACKAGE_ROOT` for a package-root relationship. Returns the absolute part name (always starts with `/`).\n *\n * `target` is from a Relationship element's `Target` attribute when\n * `TargetMode=\"Internal\"`. External targets must not be passed through here.\n */\nexport const resolveTarget = (\n basePart: PartName | typeof PACKAGE_ROOT,\n target: string,\n): PartName => {\n if (target === '') throw new Error('relationship target is empty');\n if (target.startsWith('/')) return partName(target);\n\n const baseDir = basePart === PACKAGE_ROOT ? PACKAGE_ROOT : dirname(basePart);\n const stack = baseDir === '/' ? [] : baseDir.slice(1).split('/');\n for (const segment of target.split('/')) {\n if (segment === '' || segment === '.') continue;\n if (segment === '..') {\n if (stack.length === 0) {\n throw new Error(`relationship target \"${target}\" escapes the package root`);\n }\n stack.pop();\n continue;\n }\n stack.push(segment);\n }\n return partName(`/${stack.join('/')}`);\n};\n","// XML AST types. Designed for round-trip fidelity on OOXML:\n//\n// - QName carries BOTH the namespace URI (for semantic checks) AND the prefix\n// the input used (so we can serialize back with the same prefix). DOM-style\n// APIs that re-derive prefixes from URIs break the reference desktop app's compatibility\n// tooling.\n// - Attributes are an ordered array, not a map. OOXML attribute order matters\n// for tools that string-compare serialized XML (Open XML diff tools).\n// - Namespace declarations are recorded on the element where they appeared,\n// not flattened. `mc:AlternateContent` and similar nested namespace scopes\n// would otherwise lose their structure.\n// - Text vs CData vs Comment vs PI are distinct node kinds so the serializer\n// doesn't have to guess what to emit.\n\nexport interface QName {\n /** Empty string when no prefix is used (default namespace or unqualified). */\n readonly prefix: string;\n readonly localName: string;\n /** Empty string when the name has no namespace binding. */\n readonly namespaceURI: string;\n}\n\nexport interface XmlAttr {\n readonly name: QName;\n readonly value: string;\n}\n\nexport interface XmlElement {\n readonly kind: 'element';\n name: QName;\n attrs: XmlAttr[];\n /**\n * Prefix → URI declarations that appeared as `xmlns` / `xmlns:foo`\n * attributes on this element. The serializer re-emits them as attributes\n * (NOT inside `attrs`, since that array is for non-namespace attributes\n * only). An empty-string prefix entry is a default-namespace declaration.\n */\n prefixDecls: Map<string, string>;\n children: XmlNode[];\n}\n\nexport interface XmlText {\n readonly kind: 'text';\n data: string;\n}\n\nexport interface XmlCData {\n readonly kind: 'cdata';\n data: string;\n}\n\nexport interface XmlComment {\n readonly kind: 'comment';\n data: string;\n}\n\nexport interface XmlPI {\n readonly kind: 'pi';\n target: string;\n data: string;\n}\n\nexport type XmlNode = XmlElement | XmlText | XmlCData | XmlComment | XmlPI;\n\nexport interface XmlDeclaration {\n readonly version: string;\n readonly encoding?: string;\n readonly standalone?: 'yes' | 'no';\n}\n\nexport interface XmlDocument {\n readonly kind: 'document';\n decl: XmlDeclaration | null;\n /** Comments / processing instructions appearing before the root element. */\n prolog: ReadonlyArray<XmlComment | XmlPI>;\n root: XmlElement;\n /** Comments / processing instructions appearing after the root element. */\n epilog: ReadonlyArray<XmlComment | XmlPI>;\n}\n\n// Constructor helpers — explicit verbs rather than `new` invocations so call\n// sites read naturally.\n\nexport const qname = (prefix: string, localName: string, namespaceURI: string): QName => ({\n prefix,\n localName,\n namespaceURI,\n});\n\nexport const attr = (name: QName, value: string): XmlAttr => ({ name, value });\n\nexport const elem = (\n name: QName,\n init: {\n attrs?: XmlAttr[];\n prefixDecls?: Map<string, string>;\n children?: XmlNode[];\n } = {},\n): XmlElement => ({\n kind: 'element',\n name,\n attrs: init.attrs ?? [],\n prefixDecls: init.prefixDecls ?? new Map(),\n children: init.children ?? [],\n});\n\nexport const text = (data: string): XmlText => ({ kind: 'text', data });\nexport const cdata = (data: string): XmlCData => ({ kind: 'cdata', data });\nexport const comment = (data: string): XmlComment => ({ kind: 'comment', data });\nexport const pi = (target: string, data: string): XmlPI => ({ kind: 'pi', target, data });\n\n// QName comparison — namespace-first. Two QNames are equal iff their URI and\n// localName match. Prefix is irrelevant for equality (it's a serialization\n// detail) but is preserved on the values themselves.\nexport const qnameEquals = (a: QName, b: QName): boolean =>\n a.localName === b.localName && a.namespaceURI === b.namespaceURI;\n\n/**\n * Inserts `element` into `parent.children` at the slot dictated by `rankOf`,\n * keeping element children ordered by ascending rank (stable for equal ranks).\n *\n * Many OOXML complex types are `xsd:sequence`s: a child must appear in a fixed\n * order relative to its siblings or the part fails schema validation. Setters\n * that `push`/`unshift` produce valid output only when the caller happens to\n * invoke them in schema order — fragile across independent mutation calls.\n * Callers should strip any pre-existing same-element first, then use this to\n * drop the new element at its mandated position regardless of call order.\n *\n * `rankOf` returns the sibling's sequence position; return a large number for\n * trailing/unknown children so they sort to the end. Non-element nodes are\n * skipped when scanning, and the new element lands before the first existing\n * element whose rank is strictly greater.\n */\nexport const insertChildByRank = (\n parent: XmlElement,\n element: XmlElement,\n rankOf: (el: XmlElement) => number,\n): void => {\n const rank = rankOf(element);\n let idx = parent.children.length;\n for (let i = 0; i < parent.children.length; i++) {\n const child = parent.children[i];\n if (child?.kind !== 'element') continue;\n if (rankOf(child) > rank) {\n idx = i;\n break;\n }\n }\n parent.children.splice(idx, 0, element);\n};\n\n/**\n * Deep copy of an element, sharing nothing mutable with the original. Editing\n * paths that must either apply a whole change or none of it build into a copy\n * and swap it in once, so a failure part-way leaves the live tree untouched.\n */\nexport const cloneElement = (el: XmlElement): XmlElement =>\n elem(el.name, {\n attrs: el.attrs.map((a) => attr(a.name, a.value)),\n prefixDecls: new Map(el.prefixDecls),\n children: el.children.map(cloneNode),\n });\n\nconst cloneNode = (node: XmlNode): XmlNode =>\n node.kind === 'element' ? cloneElement(node) : { ...node };\n","// Canonical OOXML / PPTX namespace URIs. Keep both the URI and the prefix\n// the reference desktop app emits in the wild — code that re-serializes XML must use the same\n// prefix the input file used (or, for fresh output, the prefix the reference desktop app emits)\n// to maximize compatibility with downstream readers that string-match the prefix\n// rather than resolving by URI.\n\nexport const NS = {\n // Open Packaging Conventions\n contentTypes: 'http://schemas.openxmlformats.org/package/2006/content-types',\n relationships: 'http://schemas.openxmlformats.org/package/2006/relationships',\n // Office Open XML — relationship target type\n officeDocRels: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',\n // PresentationML\n pml: 'http://schemas.openxmlformats.org/presentationml/2006/main',\n // DrawingML\n dml: 'http://schemas.openxmlformats.org/drawingml/2006/main',\n // DrawingML — diagram (SmartArt)\n diagram: 'http://schemas.openxmlformats.org/drawingml/2006/diagram',\n // DrawingML — chart\n chart: 'http://schemas.openxmlformats.org/drawingml/2006/chart',\n // DrawingML — chart drawing\n chartDrawing: 'http://schemas.openxmlformats.org/drawingml/2006/chartDrawing',\n // SpreadsheetML (embedded xlsx for chart data)\n sml: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main',\n // WordprocessingML (embedded in some PPTX parts)\n wml: 'http://schemas.openxmlformats.org/wordprocessingml/2006/main',\n // Markup Compatibility & Extensibility\n mc: 'http://schemas.openxmlformats.org/markup-compatibility/2006',\n // 2007+ vendor extension namespaces (a14, p14, p15, p16, etc.)\n // These appear inside mc:AlternateContent blocks; we list a few here for\n // canonical prefix mapping. Others get auto-prefixed by their declaration.\n a14: 'http://schemas.microsoft.com/office/drawing/2010/main',\n a15: 'http://schemas.microsoft.com/office/drawing/2012/main',\n a16: 'http://schemas.microsoft.com/office/drawing/2014/main',\n p14: 'http://schemas.microsoft.com/office/powerpoint/2010/main',\n p15: 'http://schemas.microsoft.com/office/powerpoint/2012/main',\n p16: 'http://schemas.microsoft.com/office/powerpoint/2015/main',\n // The p159 Morph transition ([MS-PPTX] §2.6).\n p159: 'http://schemas.microsoft.com/office/powerpoint/2015/09/main',\n // Reserved XML namespaces\n xml: 'http://www.w3.org/XML/1998/namespace',\n xmlns: 'http://www.w3.org/2000/xmlns/',\n} as const;\n\n// Suggested prefix for each known namespace URI, mirroring what the reference desktop app\n// emits. Used as a fallback when authoring fresh XML and no prefix has been\n// declared yet. The parser preserves whatever prefix was actually in the input.\nexport const SUGGESTED_PREFIX: Readonly<Record<string, string>> = {\n [NS.contentTypes]: '',\n [NS.relationships]: '',\n [NS.officeDocRels]: 'r',\n [NS.pml]: 'p',\n [NS.dml]: 'a',\n [NS.diagram]: 'dgm',\n [NS.chart]: 'c',\n [NS.chartDrawing]: 'cdr',\n [NS.sml]: '',\n [NS.wml]: 'w',\n [NS.mc]: 'mc',\n [NS.a14]: 'a14',\n [NS.a15]: 'a15',\n [NS.a16]: 'a16',\n [NS.p14]: 'p14',\n [NS.p15]: 'p15',\n [NS.p16]: 'p16',\n [NS.p159]: 'p159',\n [NS.xml]: 'xml',\n};\n","// XML parser tuned for OOXML.\n//\n// Hand-written tokenizer + tree builder. Handles the subset of XML 1.0 that\n// the reference desktop app and the OOXML toolchain actually emit:\n//\n// - The XML declaration `<?xml ... ?>`.\n// - Element start / end / empty tags with attributes.\n// - Namespace prefix declarations (`xmlns`, `xmlns:foo`).\n// - Character data, with the five predefined entities and numeric character\n// references.\n// - CDATA sections, comments, processing instructions.\n//\n// Deliberately NOT supported:\n//\n// - DOCTYPE declarations and DTDs — OOXML doesn't use them. We skip past a\n// leading DOCTYPE if present, but its internal subset is rejected.\n// - General entity references beyond the five predefined names.\n// - XML 1.1 line-end normalization (NEL / LS). XML 1.0 §2.11 end-of-line\n// handling is applied: CR LF and a lone CR read as LF, while ` `\n// still yields a CR.\n//\n// The parser throws `XmlParseError` with a position on the first malformed\n// construct. It is intentionally strict: a silent recovery here would mask\n// data corruption further down the pipeline.\n\nimport {\n type QName,\n type XmlAttr,\n type XmlCData,\n type XmlComment,\n type XmlDeclaration,\n type XmlDocument,\n type XmlElement,\n type XmlPI,\n attr,\n cdata,\n comment,\n elem,\n pi,\n qname,\n text,\n} from './ast.ts';\nimport { NS } from './namespaces.ts';\n\nexport class XmlParseError extends Error {\n constructor(\n message: string,\n public readonly offset: number,\n public readonly line: number,\n public readonly column: number,\n ) {\n super(`${message} at line ${line}:${column} (offset ${offset})`);\n this.name = 'XmlParseError';\n }\n}\n\ninterface Cursor {\n readonly src: string;\n pos: number;\n}\n\nconst isNameStartChar = (c: string): boolean => {\n // XML 1.0 NameStartChar simplified to what OOXML actually emits: ASCII\n // letters, underscore, colon (used in prefixes). The full Unicode predicate\n // is overkill — the reference desktop app never emits non-ASCII element names.\n const code = c.charCodeAt(0);\n return (\n (code >= 65 && code <= 90) || // A-Z\n (code >= 97 && code <= 122) || // a-z\n code === 95 || // _\n code === 58 // :\n );\n};\n\nconst isNameChar = (c: string): boolean => {\n if (isNameStartChar(c)) return true;\n const code = c.charCodeAt(0);\n return (\n (code >= 48 && code <= 57) || // 0-9\n code === 45 || // -\n code === 46 // .\n );\n};\n\nconst isWhitespace = (c: string): boolean => c === ' ' || c === '\\t' || c === '\\n' || c === '\\r';\n\nconst lineColOf = (src: string, pos: number): { line: number; column: number } => {\n let line = 1;\n let column = 1;\n for (let i = 0; i < pos && i < src.length; i++) {\n if (src.charCodeAt(i) === 10) {\n line++;\n column = 1;\n } else {\n column++;\n }\n }\n return { line, column };\n};\n\nconst fail = (cur: Cursor, message: string): never => {\n const { line, column } = lineColOf(cur.src, cur.pos);\n throw new XmlParseError(message, cur.pos, line, column);\n};\n\nconst expect = (cur: Cursor, literal: string): void => {\n if (cur.src.slice(cur.pos, cur.pos + literal.length) !== literal) {\n fail(cur, `expected \"${literal}\"`);\n }\n cur.pos += literal.length;\n};\n\nconst accept = (cur: Cursor, literal: string): boolean => {\n if (cur.src.slice(cur.pos, cur.pos + literal.length) !== literal) return false;\n cur.pos += literal.length;\n return true;\n};\n\nconst skipWhitespace = (cur: Cursor): void => {\n while (cur.pos < cur.src.length && isWhitespace(cur.src[cur.pos] ?? '')) cur.pos++;\n};\n\nconst readName = (cur: Cursor): string => {\n const start = cur.pos;\n if (cur.pos >= cur.src.length || !isNameStartChar(cur.src[cur.pos] ?? '')) {\n fail(cur, 'expected XML name');\n }\n cur.pos++;\n while (cur.pos < cur.src.length && isNameChar(cur.src[cur.pos] ?? '')) cur.pos++;\n return cur.src.slice(start, cur.pos);\n};\n\nconst splitQName = (raw: string): { prefix: string; localName: string } => {\n const idx = raw.indexOf(':');\n if (idx < 0) return { prefix: '', localName: raw };\n return { prefix: raw.slice(0, idx), localName: raw.slice(idx + 1) };\n};\n\n// Character / entity references inside attribute values and text content.\n// XML 1.0 predefined entities + decimal/hex numeric character references.\nconst decodeRefs = (cur: Cursor, raw: string): string => {\n let out = '';\n let i = 0;\n while (i < raw.length) {\n const ch = raw.charCodeAt(i);\n if (ch !== 38 /* & */) {\n out += raw[i];\n i++;\n continue;\n }\n const end = raw.indexOf(';', i + 1);\n if (end < 0) {\n cur.pos -= raw.length - i;\n fail(cur, 'unterminated entity reference');\n }\n const ref = raw.slice(i + 1, end);\n if (ref === 'amp') out += '&';\n else if (ref === 'lt') out += '<';\n else if (ref === 'gt') out += '>';\n else if (ref === 'quot') out += '\"';\n else if (ref === 'apos') out += \"'\";\n else if (ref.startsWith('#x') || ref.startsWith('#X')) {\n const code = Number.parseInt(ref.slice(2), 16);\n if (!Number.isFinite(code)) fail(cur, `invalid hex numeric reference: &${ref};`);\n out += String.fromCodePoint(code);\n } else if (ref.startsWith('#')) {\n const code = Number.parseInt(ref.slice(1), 10);\n if (!Number.isFinite(code)) fail(cur, `invalid decimal numeric reference: &${ref};`);\n out += String.fromCodePoint(code);\n } else {\n fail(cur, `unknown entity reference: &${ref};`);\n }\n i = end + 1;\n }\n return out;\n};\n\nconst readAttrValue = (cur: Cursor): string => {\n const quote = cur.src[cur.pos];\n if (quote !== '\"' && quote !== \"'\") fail(cur, 'expected attribute value');\n cur.pos++;\n const start = cur.pos;\n while (cur.pos < cur.src.length && cur.src[cur.pos] !== quote) {\n if (cur.src.charCodeAt(cur.pos) === 60 /* < */) {\n fail(cur, '\"<\" is not allowed inside an attribute value');\n }\n cur.pos++;\n }\n if (cur.pos >= cur.src.length) fail(cur, 'unterminated attribute value');\n const raw = cur.src.slice(start, cur.pos);\n cur.pos++; // consume closing quote\n return decodeRefs(cur, raw);\n};\n\ninterface NamespaceScope {\n readonly parent: NamespaceScope | null;\n /** prefix → URI; '' key holds the default namespace. */\n readonly bindings: Map<string, string>;\n}\n\nconst xmlScope: NamespaceScope = {\n parent: null,\n bindings: new Map([['xml', NS.xml]]),\n};\n\nconst resolvePrefix = (scope: NamespaceScope, prefix: string): string | null => {\n let cursor: NamespaceScope | null = scope;\n while (cursor) {\n const found = cursor.bindings.get(prefix);\n if (found !== undefined) return found;\n cursor = cursor.parent;\n }\n return null;\n};\n\nconst resolveQName = (\n cur: Cursor,\n scope: NamespaceScope,\n raw: string,\n isAttribute: boolean,\n): QName => {\n const { prefix, localName } = splitQName(raw);\n let namespaceURI = '';\n if (prefix !== '') {\n const found = resolvePrefix(scope, prefix);\n if (found === null) {\n return fail(cur, `unbound namespace prefix \"${prefix}\"`);\n }\n namespaceURI = found;\n } else if (!isAttribute) {\n // Unqualified element names use the default namespace, if any.\n namespaceURI = resolvePrefix(scope, '') ?? '';\n }\n // Per Namespaces in XML 1.0: unqualified attributes have NO namespace, even\n // if a default namespace is declared. We honor that.\n return qname(prefix, localName, namespaceURI);\n};\n\nconst parseDeclaration = (cur: Cursor): XmlDeclaration | null => {\n if (!accept(cur, '<?xml')) return null;\n // Anything until `?>`\n const end = cur.src.indexOf('?>', cur.pos);\n if (end < 0) fail(cur, 'unterminated XML declaration');\n const body = cur.src.slice(cur.pos, end);\n cur.pos = end + 2;\n const get = (key: string): string | undefined => {\n const m = body.match(new RegExp(`\\\\b${key}\\\\s*=\\\\s*(['\"])(.*?)\\\\1`));\n return m?.[2];\n };\n const version = get('version');\n if (version === undefined) {\n return fail(cur, 'XML declaration missing \"version\"');\n }\n const encoding = get('encoding');\n const standaloneRaw = get('standalone');\n let standalone: 'yes' | 'no' | undefined;\n if (standaloneRaw === 'yes' || standaloneRaw === 'no') {\n standalone = standaloneRaw;\n } else if (standaloneRaw !== undefined) {\n return fail(cur, `invalid standalone value \"${standaloneRaw}\"`);\n }\n return {\n version,\n ...(encoding !== undefined ? { encoding } : {}),\n ...(standalone !== undefined ? { standalone } : {}),\n };\n};\n\nconst parseComment = (cur: Cursor): XmlComment => {\n expect(cur, '<!--');\n const end = cur.src.indexOf('-->', cur.pos);\n if (end < 0) fail(cur, 'unterminated comment');\n const data = cur.src.slice(cur.pos, end);\n if (data.includes('--')) fail(cur, '\"--\" is not allowed inside an XML comment');\n cur.pos = end + 3;\n return comment(data);\n};\n\nconst parsePI = (cur: Cursor): XmlPI => {\n expect(cur, '<?');\n const targetStart = cur.pos;\n while (\n cur.pos < cur.src.length &&\n !isWhitespace(cur.src[cur.pos] ?? '') &&\n cur.src.slice(cur.pos, cur.pos + 2) !== '?>'\n ) {\n cur.pos++;\n }\n const target = cur.src.slice(targetStart, cur.pos);\n if (target.toLowerCase() === 'xml') {\n fail(cur, 'PI target may not be \"xml\"');\n }\n skipWhitespace(cur);\n const end = cur.src.indexOf('?>', cur.pos);\n if (end < 0) fail(cur, 'unterminated processing instruction');\n const data = cur.src.slice(cur.pos, end);\n cur.pos = end + 2;\n return pi(target, data);\n};\n\nconst parseCData = (cur: Cursor): XmlCData => {\n expect(cur, '<![CDATA[');\n const end = cur.src.indexOf(']]>', cur.pos);\n if (end < 0) fail(cur, 'unterminated CDATA section');\n const data = cur.src.slice(cur.pos, end);\n cur.pos = end + 3;\n return cdata(data);\n};\n\nconst skipDoctype = (cur: Cursor): void => {\n // OOXML does not use DOCTYPE; if we encounter one we skip it without parsing\n // the internal subset (no `[` allowed).\n expect(cur, '<!DOCTYPE');\n while (cur.pos < cur.src.length) {\n const c = cur.src[cur.pos];\n if (c === '[') fail(cur, 'DOCTYPE internal subset is not supported');\n if (c === '>') {\n cur.pos++;\n return;\n }\n cur.pos++;\n }\n fail(cur, 'unterminated DOCTYPE');\n};\n\nconst parseStartOrEmptyTag = (\n cur: Cursor,\n parentScope: NamespaceScope,\n): { element: XmlElement; scope: NamespaceScope; empty: boolean } => {\n expect(cur, '<');\n const rawName = readName(cur);\n const ownAttrs: { raw: string; rawValue: string }[] = [];\n const prefixDecls = new Map<string, string>();\n let empty = false;\n\n while (true) {\n const wsStart = cur.pos;\n skipWhitespace(cur);\n if (cur.pos === wsStart && cur.src[cur.pos] !== '/' && cur.src[cur.pos] !== '>') {\n fail(cur, 'expected whitespace before next attribute');\n }\n if (accept(cur, '/>')) {\n empty = true;\n break;\n }\n if (accept(cur, '>')) break;\n const attrRawName = readName(cur);\n skipWhitespace(cur);\n expect(cur, '=');\n skipWhitespace(cur);\n const value = readAttrValue(cur);\n if (attrRawName === 'xmlns') {\n prefixDecls.set('', value);\n } else if (attrRawName.startsWith('xmlns:')) {\n const p = attrRawName.slice(6);\n if (p === '') fail(cur, 'empty namespace prefix in xmlns:');\n if (p === 'xmlns') fail(cur, 'prefix \"xmlns\" cannot be redeclared');\n prefixDecls.set(p, value);\n } else {\n ownAttrs.push({ raw: attrRawName, rawValue: value });\n }\n }\n\n const scope: NamespaceScope = {\n parent: parentScope,\n bindings: new Map<string, string>(prefixDecls),\n };\n\n const elemName = resolveQName(cur, scope, rawName, false);\n const attrs: XmlAttr[] = ownAttrs.map(({ raw, rawValue }) =>\n attr(resolveQName(cur, scope, raw, true), rawValue),\n );\n\n return {\n element: elem(elemName, { attrs, prefixDecls, children: [] }),\n scope,\n empty,\n };\n};\n\nconst parseEndTag = (cur: Cursor): string => {\n expect(cur, '</');\n const name = readName(cur);\n skipWhitespace(cur);\n expect(cur, '>');\n return name;\n};\n\nconst parseTextContent = (cur: Cursor): string => {\n const start = cur.pos;\n while (cur.pos < cur.src.length && cur.src.charCodeAt(cur.pos) !== 60 /* < */) {\n cur.pos++;\n }\n return decodeRefs(cur, cur.src.slice(start, cur.pos));\n};\n\nconst parseElement = (cur: Cursor, parentScope: NamespaceScope): XmlElement => {\n const { element, scope, empty } = parseStartOrEmptyTag(cur, parentScope);\n if (empty) return element;\n while (cur.pos < cur.src.length) {\n if (cur.src.charCodeAt(cur.pos) === 60 /* < */) {\n if (cur.src.startsWith('</', cur.pos)) {\n const closingRaw = parseEndTag(cur);\n const expectedRaw =\n element.name.prefix === ''\n ? element.name.localName\n : `${element.name.prefix}:${element.name.localName}`;\n if (closingRaw !== expectedRaw) {\n fail(cur, `mismatched closing tag: expected </${expectedRaw}>, got </${closingRaw}>`);\n }\n return element;\n }\n if (cur.src.startsWith('<![CDATA[', cur.pos)) {\n element.children.push(parseCData(cur));\n } else if (cur.src.startsWith('<!--', cur.pos)) {\n element.children.push(parseComment(cur));\n } else if (cur.src.startsWith('<?', cur.pos)) {\n element.children.push(parsePI(cur));\n } else {\n element.children.push(parseElement(cur, scope));\n }\n } else {\n const t = parseTextContent(cur);\n if (t.length > 0) element.children.push(text(t));\n }\n }\n return fail(cur, `unterminated element <${element.name.localName}>`);\n};\n\nexport const parseXml = (src: string): XmlDocument => {\n // Strip a leading BOM if present — common in OOXML files written by .NET.\n const stripped = src.charCodeAt(0) === 0xfeff ? src.slice(1) : src;\n // XML 1.0 §2.11: normalize line ends before tokenizing so a raw CR LF\n // (pptxgenjs writes one inside <a:t>) reads as the LF a conforming\n // parser hands the application. Character references are decoded later,\n // so ` ` is untouched and still yields a CR.\n const cur: Cursor = { src: stripped.replace(/\\r\\n?/g, '\\n'), pos: 0 };\n const decl = parseDeclaration(cur);\n skipWhitespace(cur);\n\n const prolog: Array<XmlComment | XmlPI> = [];\n // Prolog: comments, PIs, optional DOCTYPE. Stop at the root element.\n while (cur.pos < cur.src.length) {\n skipWhitespace(cur);\n if (cur.src.startsWith('<!--', cur.pos)) prolog.push(parseComment(cur));\n else if (cur.src.startsWith('<!DOCTYPE', cur.pos)) skipDoctype(cur);\n else if (cur.src.startsWith('<?', cur.pos)) prolog.push(parsePI(cur));\n else break;\n }\n skipWhitespace(cur);\n\n if (cur.pos >= cur.src.length || cur.src[cur.pos] !== '<') {\n fail(cur, 'expected root element');\n }\n const root = parseElement(cur, xmlScope);\n\n const epilog: Array<XmlComment | XmlPI> = [];\n while (cur.pos < cur.src.length) {\n skipWhitespace(cur);\n if (cur.pos >= cur.src.length) break;\n if (cur.src.startsWith('<!--', cur.pos)) epilog.push(parseComment(cur));\n else if (cur.src.startsWith('<?', cur.pos)) epilog.push(parsePI(cur));\n else fail(cur, 'unexpected content after root element');\n }\n\n return { kind: 'document', decl, prolog, root, epilog };\n};\n\n// Convenience for parsing an XML fragment (no declaration / prolog), returning\n// just the root element. Used heavily by part-specific tests.\nexport const parseFragment = (src: string): XmlElement => parseXml(src).root;\n\n// Lightweight helper for hand-written test cases: builds a scope chain from\n// inherited prefix declarations and resolves a raw \"prefix:local\" string.\nexport const resolveQNameWithBindings = (\n raw: string,\n bindings: ReadonlyArray<readonly [prefix: string, uri: string]>,\n isAttribute: boolean,\n): QName => {\n const scope: NamespaceScope = {\n parent: null,\n bindings: new Map(bindings),\n };\n return resolveQName({ src: raw, pos: 0 }, scope, raw, isAttribute);\n};\n\nexport const _internalsForTest = { isNameStartChar, isNameChar, splitQName };\n","// Query helpers for the XML AST.\n//\n// These are ergonomic accessors for the read-heavy code in higher layers\n// (PresentationML reads slide.xml looking for `p:cSld/p:spTree`, etc.).\n// They never mutate the AST; mutation goes through the AST constructors and\n// direct field assignment.\n\nimport type { QName, XmlAttr, XmlElement, XmlNode, XmlText } from './ast.ts';\nimport { qnameEquals } from './ast.ts';\n\nexport const isElement = (n: XmlNode): n is XmlElement => n.kind === 'element';\nexport const isText = (n: XmlNode): n is XmlText => n.kind === 'text';\n\nexport const childElements = (e: XmlElement): XmlElement[] => e.children.filter(isElement);\n\nexport const firstChildElement = (e: XmlElement, name: QName): XmlElement | null => {\n for (const c of e.children) {\n if (isElement(c) && qnameEquals(c.name, name)) return c;\n }\n return null;\n};\n\nexport const allChildElements = (e: XmlElement, name: QName): XmlElement[] => {\n const out: XmlElement[] = [];\n for (const c of e.children) {\n if (isElement(c) && qnameEquals(c.name, name)) out.push(c);\n }\n return out;\n};\n\nexport const getAttr = (e: XmlElement, name: QName): XmlAttr | null => {\n for (const a of e.attrs) {\n if (qnameEquals(a.name, name)) return a;\n }\n return null;\n};\n\nexport const getAttrValue = (e: XmlElement, name: QName): string | null =>\n getAttr(e, name)?.value ?? null;\n\n/**\n * Returns the concatenated text content of an element, walking into nested\n * elements. OOXML uses this pattern for `<a:t>Hello</a:t>` (single text\n * child) and for run sequences where multiple text nodes need merging.\n */\nexport const textContent = (e: XmlElement): string => {\n let out = '';\n for (const c of e.children) {\n if (c.kind === 'text') out += c.data;\n else if (c.kind === 'cdata') out += c.data;\n else if (c.kind === 'element') out += textContent(c);\n }\n return out;\n};\n\n/**\n * Walks the element tree depth-first, yielding every element including the\n * root. The visitor returns `false` to skip descending into the current\n * element's children. Returning nothing (or `true`) descends as usual.\n */\nexport const walkElements = (root: XmlElement, visit: (e: XmlElement) => boolean | void): void => {\n const stack: XmlElement[] = [root];\n while (stack.length > 0) {\n const node = stack.pop();\n if (!node) continue;\n const descend = visit(node);\n if (descend === false) continue;\n // Push in reverse so visit order is DFS-natural left-to-right.\n for (let i = node.children.length - 1; i >= 0; i--) {\n const c = node.children[i];\n if (c && isElement(c)) stack.push(c);\n }\n }\n};\n","// XML serializer for the AST in `./ast.ts`.\n//\n// Goals:\n//\n// - Round-trip fidelity. Element/attribute order and prefix choices on the\n// way out match the way in (provided the AST hasn't been mutated to break\n// that). The serializer never reorders attributes, never reallocates\n// namespace prefixes, never re-emits xmlns declarations on a different\n// element than where the parser placed them. It only adds a declaration\n// where an element's or attribute's prefix would otherwise be unbound.\n// - Predictable output for hand-built ASTs. Authoring-time code can assume\n// the same input element produces the same byte sequence.\n// - Escape rules tight enough for the reference desktop app to accept the output: the\n// predefined entities, numeric references for the whitespace controls that\n// attribute-value normalization would otherwise eat (tab / LF / CR), and a\n// hard reject for characters outside the XML 1.0 Char production.\n//\n// Out of scope:\n//\n// - Pretty-printing. OOXML files are usually compact-on-write because most\n// producers don't pretty-print. A future option could add indent if\n// someone really wants it, but the round-trip story is cleaner without.\n\nimport type { XmlAttr, XmlDocument, XmlElement, XmlNode } from './ast.ts';\nimport { NS } from './namespaces.ts';\n\n// XML 1.0 §2.2 excludes C0 controls other than tab / LF / CR, U+FFFE,\n// U+FFFF, and unpaired surrogates. Numeric references cannot rescue them.\n// Iterate by code point so valid surrogate pairs remain legal supplementary\n// characters, while lone surrogates are rejected before UTF-8 replaces them.\nconst rejectForbiddenChar = (c: number): void => {\n const control = c < 0x20 && c !== 0x09 && c !== 0x0a && c !== 0x0d;\n if (control || (c >= 0xd800 && c <= 0xdfff) || c === 0xfffe || c === 0xffff) {\n const hex = c.toString(16).toUpperCase().padStart(4, '0');\n const kind = control ? 'control character' : 'character';\n throw new Error(\n `XML-illegal ${kind} U+${hex} in text; strip ${control ? 'control' : 'illegal'} characters before authoring`,\n );\n }\n};\n\nconst escapeAttr = (s: string): string => {\n // Attribute values: escape <, &, and the quote char we use. We always use\n // double quotes, so single quotes pass through. CR and LF must be encoded\n // numerically because XML parsers normalize whitespace in attribute values.\n let out = '';\n for (const char of s) {\n const c = char.codePointAt(0)!;\n rejectForbiddenChar(c);\n if (c === 38) out += '&';\n else if (c === 60) out += '<';\n else if (c === 62) out += '>';\n else if (c === 34) out += '"';\n else if (c === 9) out += '	';\n else if (c === 10) out += ' ';\n else if (c === 13) out += ' ';\n else out += char;\n }\n return out;\n};\n\nconst escapeText = (s: string): string => {\n let out = '';\n for (const char of s) {\n const c = char.codePointAt(0)!;\n rejectForbiddenChar(c);\n if (c === 38) out += '&';\n else if (c === 60) out += '<';\n else if (c === 62) out += '>';\n else if (c === 13) out += ' ';\n else out += char;\n }\n return out;\n};\n\nconst rawName = (prefix: string, localName: string): string =>\n prefix === '' ? localName : `${prefix}:${localName}`;\n\nconst writeAttr = (a: XmlAttr): string => {\n const name = rawName(a.name.prefix, a.name.localName);\n return ` ${name}=\"${escapeAttr(a.value)}\"`;\n};\n\n// Prefix → URI bindings in scope at the element being written. The root of a\n// document starts with only the reserved `xml` prefix bound.\ntype Scope = ReadonlyMap<string, string>;\n\nconst DOCUMENT_SCOPE: Scope = new Map([['xml', NS.xml]]);\n\n// Parsed elements carry the declarations their input had, but elements built\n// with `elem(...)` carry none and rely on an ancestor declaring their prefixes.\n// Producers may declare a prefix on the element that uses it rather than on\n// the part root, so that ancestor is not guaranteed; declare whatever the\n// element's own name and attributes need that is not already in scope.\nconst missingDecls = (e: XmlElement, scope: Scope): Map<string, string> | null => {\n let added: Map<string, string> | null = null;\n for (let i = -1; i < e.attrs.length; i++) {\n const name = i < 0 ? e.name : e.attrs[i]!.name;\n // Unprefixed attributes are in no namespace whatever the default is.\n if (i >= 0 && name.prefix === '') continue;\n const own = e.prefixDecls.get(name.prefix) ?? added?.get(name.prefix);\n if (own === undefined) {\n if ((scope.get(name.prefix) ?? '') === name.namespaceURI) continue;\n added ??= new Map();\n added.set(name.prefix, name.namespaceURI);\n } else if (own !== name.namespaceURI) {\n throw new Error(\n `prefix \"${name.prefix}\" on <${rawName(e.name.prefix, e.name.localName)}> is bound to both ${own} and ${name.namespaceURI}`,\n );\n }\n }\n return added;\n};\n\nconst writeDecls = (decls: ReadonlyMap<string, string>, parts: string[]): void => {\n for (const [prefix, uri] of decls) {\n const decl = prefix === '' ? 'xmlns' : `xmlns:${prefix}`;\n parts.push(` ${decl}=\"${escapeAttr(uri)}\"`);\n }\n};\n\nconst withDecls = (scope: Scope, decls: ReadonlyMap<string, string>): Scope => {\n if (decls.size === 0) return scope;\n const next = new Map(scope);\n for (const [prefix, uri] of decls) next.set(prefix, uri);\n return next;\n};\n\n// `scope` is null for fragments: their context is unknown, so they are written\n// with exactly the declarations they carry.\nconst writeElement = (e: XmlElement, parts: string[], scope: Scope | null): void => {\n const name = rawName(e.name.prefix, e.name.localName);\n parts.push('<');\n parts.push(name);\n writeDecls(e.prefixDecls, parts);\n let childScope = scope;\n if (scope) {\n const added = missingDecls(e, scope);\n childScope = withDecls(scope, e.prefixDecls);\n if (added) {\n writeDecls(added, parts);\n childScope = withDecls(childScope, added);\n }\n }\n for (const a of e.attrs) parts.push(writeAttr(a));\n if (e.children.length === 0) {\n parts.push('/>');\n return;\n }\n parts.push('>');\n for (const child of e.children) writeNode(child, parts, childScope);\n parts.push('</');\n parts.push(name);\n parts.push('>');\n};\n\nconst writeNode = (n: XmlNode, parts: string[], scope: Scope | null): void => {\n switch (n.kind) {\n case 'element':\n writeElement(n, parts, scope);\n return;\n case 'text':\n parts.push(escapeText(n.data));\n return;\n case 'cdata':\n // CDATA may not contain `]]>`. The canonical workaround is to break the\n // illegal sequence by ending one CDATA section and starting another:\n // replace `]]>` with `]]]]><![CDATA[>` (which re-parses as `]]` followed\n // by `>`). The result is two adjacent CDATA sections whose concatenated\n // content equals the original. The reference desktop app never emits CDATA in PPTX, so\n // this path only ever runs for hand-built ASTs.\n parts.push('<![CDATA[');\n parts.push(n.data.split(']]>').join(']]]]><![CDATA[>'));\n parts.push(']]>');\n return;\n case 'comment':\n parts.push('<!--');\n parts.push(n.data);\n parts.push('-->');\n return;\n case 'pi':\n parts.push('<?');\n parts.push(n.target);\n if (n.data.length > 0) {\n parts.push(' ');\n parts.push(n.data);\n }\n parts.push('?>');\n return;\n }\n};\n\nexport const XML_DECLARATION = '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>';\n\nconst writeDeclaration = (doc: XmlDocument, parts: string[]): void => {\n if (!doc.decl) return;\n parts.push('<?xml version=\"');\n parts.push(escapeAttr(doc.decl.version));\n parts.push('\"');\n if (doc.decl.encoding !== undefined) {\n parts.push(' encoding=\"');\n parts.push(escapeAttr(doc.decl.encoding));\n parts.push('\"');\n }\n if (doc.decl.standalone !== undefined) {\n parts.push(' standalone=\"');\n parts.push(doc.decl.standalone);\n parts.push('\"');\n }\n parts.push('?>');\n};\n\nexport const serializeXml = (\n doc: XmlDocument,\n options: { standaloneDeclaration?: boolean } = {},\n): string => {\n const parts: string[] = [];\n if (doc.decl) {\n writeDeclaration(doc, parts);\n } else if (options.standaloneDeclaration ?? true) {\n // OOXML parts MUST start with an XML declaration. Add a sensible default\n // when the AST doesn't carry one (typical for hand-built trees).\n parts.push(XML_DECLARATION);\n }\n for (const p of doc.prolog) writeNode(p, parts, null);\n writeElement(doc.root, parts, DOCUMENT_SCOPE);\n for (const e of doc.epilog) writeNode(e, parts, null);\n return parts.join('');\n};\n\n// Serialize a single element with no declaration / document wrapper. Useful in\n// tests and when emitting fragments that get inlined into a larger document.\nexport const serializeFragment = (element: XmlElement): string => {\n const parts: string[] = [];\n writeElement(element, parts, null);\n return parts.join('');\n};\n\nexport const _internalsForTest = { escapeAttr, escapeText };\n","// [Content_Types].xml — required per-package map of part-name → content type.\n//\n// ECMA-376 Part 2 §10.1. Structure:\n//\n// <Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\n// <Default Extension=\"xml\" ContentType=\"application/xml\"/>\n// <Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>\n// <Override PartName=\"/ppt/presentation.xml\" ContentType=\"application/vnd....\"/>\n// ...\n// </Types>\n//\n// A part's content type is determined by: first matching Override (by part\n// name, case-insensitive); if none, the Default for the part's extension\n// (case-insensitive). PPTX files always have at least the default for `xml`\n// and `rels`, plus overrides for most parts.\n\nimport { NS, type XmlDocument, elem, parseXml, qname, serializeXml } from '../xml/index.ts';\nimport { type PartName, basename, partName, partNamesEqual } from './part-name.ts';\n\nexport interface ContentTypeDefault {\n /** Lowercase, no leading dot, e.g. `xml`. */\n extension: string;\n contentType: string;\n}\n\nexport interface ContentTypeOverride {\n partName: PartName;\n contentType: string;\n}\n\nexport interface ContentTypes {\n defaults: ContentTypeDefault[];\n overrides: ContentTypeOverride[];\n}\n\nconst CT_NS = NS.contentTypes;\nconst NAME_TYPES = qname('', 'Types', CT_NS);\nconst NAME_DEFAULT = qname('', 'Default', CT_NS);\nconst NAME_OVERRIDE = qname('', 'Override', CT_NS);\nconst ATTR_EXTENSION = qname('', 'Extension', '');\nconst ATTR_CONTENT_TYPE = qname('', 'ContentType', '');\nconst ATTR_PART_NAME = qname('', 'PartName', '');\n\nconst getAttrValueRaw = (\n e: { attrs: ReadonlyArray<{ name: { localName: string }; value: string }> },\n local: string,\n): string | null => {\n for (const a of e.attrs) {\n if (a.name.localName === local) return a.value;\n }\n return null;\n};\n\nexport const parseContentTypes = (xml: string): ContentTypes => {\n const doc = parseXml(xml);\n if (doc.root.name.namespaceURI !== CT_NS || doc.root.name.localName !== 'Types') {\n throw new Error(`expected root <Types xmlns=\"${CT_NS}\">, got <${doc.root.name.localName}>`);\n }\n const defaults: ContentTypeDefault[] = [];\n const overrides: ContentTypeOverride[] = [];\n for (const child of doc.root.children) {\n if (child.kind !== 'element') continue;\n if (child.name.namespaceURI !== CT_NS) continue;\n if (child.name.localName === 'Default') {\n const ext = getAttrValueRaw(child, 'Extension');\n const ct = getAttrValueRaw(child, 'ContentType');\n if (ext === null || ct === null) {\n throw new Error('Content_Types Default missing Extension or ContentType');\n }\n defaults.push({ extension: ext.toLowerCase(), contentType: ct });\n } else if (child.name.localName === 'Override') {\n const pn = getAttrValueRaw(child, 'PartName');\n const ct = getAttrValueRaw(child, 'ContentType');\n if (pn === null || ct === null) {\n throw new Error('Content_Types Override missing PartName or ContentType');\n }\n overrides.push({ partName: partName(pn), contentType: ct });\n }\n }\n return { defaults, overrides };\n};\n\nexport const serializeContentTypes = (ct: ContentTypes): string => {\n const children = [\n ...ct.defaults.map((d) =>\n elem(NAME_DEFAULT, {\n attrs: [\n { name: ATTR_EXTENSION, value: d.extension },\n { name: ATTR_CONTENT_TYPE, value: d.contentType },\n ],\n }),\n ),\n ...ct.overrides.map((o) =>\n elem(NAME_OVERRIDE, {\n attrs: [\n { name: ATTR_PART_NAME, value: o.partName },\n { name: ATTR_CONTENT_TYPE, value: o.contentType },\n ],\n }),\n ),\n ];\n const root = elem(NAME_TYPES, {\n prefixDecls: new Map([['', CT_NS]]),\n children,\n });\n const doc: XmlDocument = {\n kind: 'document',\n decl: { version: '1.0', encoding: 'UTF-8', standalone: 'yes' },\n prolog: [],\n root,\n epilog: [],\n };\n return serializeXml(doc);\n};\n\n// Lowercased extension a Default would match, or null when there is none.\nconst defaultKeyOf = (name: PartName): string | null => {\n const file = basename(name);\n const dot = file.lastIndexOf('.');\n return dot < 0 ? null : file.slice(dot + 1).toLowerCase();\n};\n\n/**\n * Builds a resolver for many part names against one `ContentTypes`.\n *\n * 1. The first Override whose PartName matches case-insensitively wins.\n * 2. Otherwise, the first Default whose Extension matches the part's\n * extension (case-insensitive) wins.\n * 3. Returns `null` if neither rule matches — `[Content_Types].xml` is\n * required to cover every part, so a null here indicates a malformed\n * package.\n *\n * The resolver snapshots `ct`; later edits to it are not reflected.\n */\nexport const contentTypeResolver = (ct: ContentTypes): ((name: PartName) => string | null) => {\n const overrides = new Map<string, string>();\n for (const o of ct.overrides) {\n const key = o.partName.toLowerCase();\n if (!overrides.has(key)) overrides.set(key, o.contentType);\n }\n const defaults = new Map<string, string>();\n for (const d of ct.defaults) {\n const key = d.extension.toLowerCase();\n if (!defaults.has(key)) defaults.set(key, d.contentType);\n }\n return (name) => {\n const override = overrides.get(name.toLowerCase());\n if (override !== undefined) return override;\n const ext = defaultKeyOf(name);\n return ext === null ? null : (defaults.get(ext) ?? null);\n };\n};\n\n/**\n * Resolves the content type of one part name by the rules of\n * `contentTypeResolver`, scanning without building maps.\n */\nexport const lookupContentType = (ct: ContentTypes, name: PartName): string | null => {\n for (const o of ct.overrides) {\n if (partNamesEqual(o.partName, name)) return o.contentType;\n }\n const ext = defaultKeyOf(name);\n if (ext === null) return null;\n for (const d of ct.defaults) {\n if (d.extension.toLowerCase() === ext) return d.contentType;\n }\n return null;\n};\n\n/**\n * Convenience: a fresh ContentTypes seeded with the two defaults every PPTX\n * has (`xml` and `rels`). Authoring code can layer overrides on top.\n */\nexport const emptyContentTypes = (): ContentTypes => ({\n defaults: [\n { extension: 'rels', contentType: 'application/vnd.openxmlformats-package.relationships+xml' },\n { extension: 'xml', contentType: 'application/xml' },\n ],\n overrides: [],\n});\n","// Relationships parts (`*.rels`) per OPC §9.3.\n//\n// Structure:\n//\n// <Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n// <Relationship Id=\"rId1\" Type=\"http://....\" Target=\"slides/slide1.xml\"/>\n// <Relationship Id=\"rId2\" Type=\"http://....\" Target=\"https://x\" TargetMode=\"External\"/>\n// </Relationships>\n//\n// `Id` is unique within the part; PPTX uses `rId<N>` by convention but the\n// schema accepts any xsd:ID-valid string. `Type` is a URI identifying the\n// relationship semantics. `Target` is a URI: relative to the part's location\n// when `TargetMode` is `Internal` (default), or absolute when `External`.\n\nimport { NS, type XmlDocument, elem, parseXml, qname, serializeXml } from '../xml/index.ts';\n\nexport type TargetMode = 'Internal' | 'External';\n\nexport interface Relationship {\n id: string;\n type: string;\n target: string;\n /** Defaults to `'Internal'` when omitted from the XML. */\n targetMode: TargetMode;\n}\n\nexport interface Relationships {\n items: Relationship[];\n}\n\nconst REL_NS = NS.relationships;\nconst NAME_RELATIONSHIPS = qname('', 'Relationships', REL_NS);\nconst NAME_RELATIONSHIP = qname('', 'Relationship', REL_NS);\nconst ATTR_ID = qname('', 'Id', '');\nconst ATTR_TYPE = qname('', 'Type', '');\nconst ATTR_TARGET = qname('', 'Target', '');\nconst ATTR_TARGET_MODE = qname('', 'TargetMode', '');\n\nconst findAttr = (\n e: { attrs: ReadonlyArray<{ name: { localName: string }; value: string }> },\n local: string,\n): string | null => {\n for (const a of e.attrs) {\n if (a.name.localName === local) return a.value;\n }\n return null;\n};\n\nexport const parseRels = (xml: string): Relationships => {\n const doc = parseXml(xml);\n if (doc.root.name.namespaceURI !== REL_NS || doc.root.name.localName !== 'Relationships') {\n throw new Error(\n `expected root <Relationships xmlns=\"${REL_NS}\">, got <${doc.root.name.localName}>`,\n );\n }\n const items: Relationship[] = [];\n for (const child of doc.root.children) {\n if (child.kind !== 'element') continue;\n if (child.name.namespaceURI !== REL_NS || child.name.localName !== 'Relationship') {\n continue;\n }\n const id = findAttr(child, 'Id');\n const type = findAttr(child, 'Type');\n const target = findAttr(child, 'Target');\n if (id === null || type === null || target === null) {\n throw new Error('Relationship missing Id, Type, or Target');\n }\n const modeRaw = findAttr(child, 'TargetMode');\n let targetMode: TargetMode = 'Internal';\n if (modeRaw !== null) {\n if (modeRaw !== 'Internal' && modeRaw !== 'External') {\n throw new Error(`invalid TargetMode \"${modeRaw}\"`);\n }\n targetMode = modeRaw;\n }\n items.push({ id, type, target, targetMode });\n }\n return { items };\n};\n\nexport const serializeRels = (rels: Relationships): string => {\n const children = rels.items.map((r) => {\n const attrs = [\n { name: ATTR_ID, value: r.id },\n { name: ATTR_TYPE, value: r.type },\n { name: ATTR_TARGET, value: r.target },\n ];\n // OOXML convention: only emit TargetMode when External. Tools that\n // do otherwise sometimes get flagged by Open XML diff tools.\n if (r.targetMode === 'External') {\n attrs.push({ name: ATTR_TARGET_MODE, value: 'External' });\n }\n return elem(NAME_RELATIONSHIP, { attrs });\n });\n const root = elem(NAME_RELATIONSHIPS, {\n prefixDecls: new Map([['', REL_NS]]),\n children,\n });\n const doc: XmlDocument = {\n kind: 'document',\n decl: { version: '1.0', encoding: 'UTF-8', standalone: 'yes' },\n prolog: [],\n root,\n epilog: [],\n };\n return serializeXml(doc);\n};\n\n/**\n * Convenience: an empty Relationships value with no items.\n */\nexport const emptyRels = (): Relationships => ({ items: [] });\n\n/**\n * Returns the next free `rId<N>` id given a list of existing ids. The OPC\n * spec doesn't require this naming pattern, but the reference desktop app emits it and our\n * authoring code follows suit so output diffs cleanly against the reference desktop app.\n */\nexport function nextRelId(existing: ReadonlyArray<string>): string;\nexport function nextRelId(existing: ReadonlyArray<string>, count: number): string[];\nexport function nextRelId(existing: ReadonlyArray<string>, count?: number): string | string[] {\n let max = 0;\n for (const id of existing) {\n const m = id.match(/^rId(\\d+)$/);\n if (m?.[1] !== undefined) {\n const n = Number.parseInt(m[1], 10);\n if (Number.isFinite(n) && n > max) max = n;\n }\n }\n return count === undefined\n ? `rId${max + 1}`\n : Array.from({ length: count }, (_, index) => `rId${max + index + 1}`);\n}\n","import { strFromU8, strToU8 } from 'fflate';\n// The core's package and XML layers are bundled into this package's build;\n// they are not part of the `@office-kit/pptx` public API.\nimport {\n emptyRels,\n fromZipPath,\n parseContentTypes,\n parseRels,\n readZip,\n resolveTarget,\n serializeContentTypes,\n serializeRels,\n toZipPath,\n writeZip,\n type ContentTypes,\n type Relationship,\n} from '../../../../src/internal/opc/index.ts';\nimport {\n NS,\n elem,\n parseXml,\n serializeFragment,\n serializeXml,\n walkElements,\n type XmlAttr,\n type XmlElement,\n} from '../../../../src/internal/xml/index.ts';\n\nconst CORE_PROPERTIES = 'docProps/core.xml';\nconst CORE_TIMESTAMPS = /<(dcterms:(?:created|modified))\\b[^>]*>[\\s\\S]*?<\\/\\1>/g;\n\n/**\n * The part as the merge compares it. Every build stamps fresh creation and\n * modification times into the core properties, so those are left out.\n */\nexport function comparablePart(name: string, bytes: Uint8Array): Uint8Array {\n if (name !== CORE_PROPERTIES) return bytes;\n return strToU8(strFromU8(bytes).replace(CORE_TIMESTAMPS, ''));\n}\n\nexport interface DeckConflict {\n /** ZIP part name, e.g. `ppt/slides/slide2.xml`. */\n part: string;\n /** 1-based slide number when the part belongs to a slide, its notes or their relationships. */\n slide: number | null;\n /** The colliding shape when the conflict is inside a shape tree. */\n shape: { id: string; name: string } | null;\n reason: 'both-changed' | 'deleted-and-changed' | 'both-added';\n}\n\nexport type DeckMerge = { ok: true; bytes: Uint8Array } | { ok: false; conflicts: DeckConflict[] };\n\ntype Outcome<T> = { ok: true; value: T } | { ok: false; conflicts: DeckConflict[] };\n\nconst CONTENT_TYPES = '[Content_Types].xml';\nconst PRESENTATION = 'ppt/presentation.xml';\n// Parts whose root is `cSld` + `spTree`, merged shape by shape.\nconst SHAPE_TREE_PART =\n /^ppt\\/(?:slides|slideLayouts|slideMasters|notesSlides|notesMasters|handoutMasters)\\/[^/]+\\.xml$/;\nconst RELATIONSHIPS_PART = /(?:^|\\/)_rels\\/[^/]*\\.rels$/;\nconst SLIDE_RELATIONSHIP = `${NS.officeDocRels}/slide`;\nconst NOTES_RELATIONSHIP = `${NS.officeDocRels}/notesSlide`;\n// Children of `p:spTree` that describe the tree itself rather than a shape.\nconst SHAPE_TREE_PROPERTIES = new Set(['nvGrpSpPr', 'grpSpPr', 'extLst']);\n\nfunction sameBytes(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n for (let index = 0; index < a.length; index++) if (a[index] !== b[index]) return false;\n return true;\n}\n\ninterface Entry<T> {\n key: string;\n /** Comparable form of the item; equal values mean an unchanged item. */\n value: string;\n item: T;\n}\n\ntype Ordering =\n /** Children may appear in any order, e.g. z-order in a shape tree. */\n | 'free'\n /** Children follow an `xsd:sequence`, so two independent insertions at one spot are ambiguous. */\n | 'schema'\n /** Order carries no meaning, so reorderings are ignored. */\n | 'none';\n\ninterface EntryMerge<T> {\n ordering: Ordering;\n /** Merges an item changed on both sides; `null` when the item is atomic. */\n refine?: (key: string, base: T, ours: T, theirs: T) => Outcome<T> | null;\n /** `sample` is absent when the conflict is about the items' order. */\n conflict: (key: string, reason: DeckConflict['reason'], sample?: T) => DeckConflict;\n}\n\n/**\n * Three-way merge of keyed items. An item changed on one side only takes that\n * side; an item changed differently on both sides is a conflict.\n */\nfunction mergeEntries<T>(\n base: Entry<T>[],\n ours: Entry<T>[],\n theirs: Entry<T>[],\n options: EntryMerge<T>,\n): Outcome<T[]> {\n const byKey = (entries: Entry<T>[]) => new Map(entries.map((entry) => [entry.key, entry]));\n const [b, o, t] = [byKey(base), byKey(ours), byKey(theirs)];\n const keys = new Set([...t.keys(), ...o.keys(), ...b.keys()]);\n const chosen = new Map<string, T>();\n const conflicts: DeckConflict[] = [];\n const same = (x: Entry<T> | undefined, y: Entry<T> | undefined) => x?.value === y?.value;\n for (const key of keys) {\n const [be, oe, te] = [b.get(key), o.get(key), t.get(key)];\n let pick: Entry<T> | undefined;\n if (same(oe, be)) pick = te;\n else if (same(te, be) || same(oe, te)) pick = oe;\n else {\n const refined = be && oe && te ? options.refine?.(key, be.item, oe.item, te.item) : null;\n if (refined?.ok) chosen.set(key, refined.value);\n else if (refined) conflicts.push(...refined.conflicts);\n else {\n const reason = !be ? 'both-added' : !oe || !te ? 'deleted-and-changed' : 'both-changed';\n conflicts.push(options.conflict(key, reason, (oe ?? te ?? be)!.item));\n }\n continue;\n }\n if (pick) chosen.set(key, pick.item);\n }\n if (conflicts.length) return { ok: false, conflicts };\n const order = mergeOrder(\n base.map((entry) => entry.key),\n ours.map((entry) => entry.key),\n theirs.map((entry) => entry.key),\n new Set(chosen.keys()),\n options.ordering,\n );\n if (!order) return { ok: false, conflicts: [options.conflict('', 'both-changed')] };\n return { ok: true, value: order.map((key) => chosen.get(key)!) };\n}\n\n/** True when the keys both lists share appear in the same order in each. */\nfunction sameRelativeOrder(a: string[], b: string[]): boolean {\n const [inA, inB] = [new Set(a), new Set(b)];\n const sharedA = a.filter((key) => inB.has(key));\n const sharedB = b.filter((key) => inA.has(key));\n return sharedA.every((key, index) => key === sharedB[index]);\n}\n\n/**\n * Orders the kept keys. The side that reordered (or the source when neither\n * did) gives the order; the other side's additions follow their nearest\n * preceding sibling. `null` means the order cannot be decided.\n */\nfunction mergeOrder(\n base: string[],\n ours: string[],\n theirs: string[],\n keep: Set<string>,\n ordering: Ordering,\n): string[] | null {\n const oursMoved = ordering !== 'none' && !sameRelativeOrder(base, ours);\n const theirsMoved = ordering !== 'none' && !sameRelativeOrder(base, theirs);\n if (oursMoved && theirsMoved && !sameRelativeOrder(ours, theirs)) return null;\n const [primary, secondary] = oursMoved ? [ours, theirs] : [theirs, ours];\n const kept = primary.filter((key) => keep.has(key));\n const placed = new Set(kept);\n const inSecondary = new Set(secondary);\n const next = new Map<string | null, string | undefined>(\n kept.map((key, index) => [index === 0 ? null : kept[index - 1]!, key]),\n );\n if (kept.length) next.set(kept.at(-1)!, undefined);\n // Each anchor gets at most one insertion: the next one chains to the last.\n const after = new Map<string | null, string>();\n let anchor: string | null = null;\n let chained = false;\n for (const key of secondary) {\n if (!keep.has(key)) continue;\n if (placed.has(key)) {\n anchor = key;\n chained = false;\n continue;\n }\n if (!chained) {\n const following = next.get(anchor);\n // Both sides inserted different elements at the same spot.\n if (ordering === 'schema' && following !== undefined && !inSecondary.has(following))\n return null;\n }\n after.set(anchor, key);\n anchor = key;\n chained = true;\n }\n const result: string[] = [];\n const emit = (key: string | null) => {\n for (let at: string | null | undefined = key; at !== undefined; at = after.get(at))\n if (at !== null) result.push(at);\n };\n emit(null);\n for (const key of kept) emit(key);\n return result;\n}\n\ninterface PartContext {\n part: string;\n}\n\nconst partConflict = (\n context: PartContext,\n reason: DeckConflict['reason'],\n shape: DeckConflict['shape'] = null,\n): DeckConflict => ({ part: context.part, slide: null, shape, reason });\n\nfunction shapeIdentity(element: XmlElement): { id: string; name: string } | null {\n let found: XmlElement | undefined;\n walkElements(element, (child) => {\n if (found) return false;\n if (child.name.localName === 'cNvPr') found = child;\n return undefined;\n });\n if (!found) return null;\n const value = (name: string) => found!.attrs.find((item) => item.name.localName === name)?.value;\n const id = value('id');\n return id === undefined ? null : { id, name: value('name') ?? '' };\n}\n\ntype ContainerKind = 'root' | 'cSld' | 'spTree';\n\nconst elementKey = (element: XmlElement) =>\n `${element.name.namespaceURI} ${element.name.localName}`;\n\n/** Keys an element's children, or `null` when they cannot be told apart. */\nfunction childEntries(element: XmlElement, kind: ContainerKind): Entry<XmlElement>[] | null {\n const entries: Entry<XmlElement>[] = [];\n const keys = new Set<string>();\n const occurrences = new Map<string, number>();\n for (const child of element.children) {\n if (child.kind !== 'element') {\n // Whitespace between elements carries no meaning in these parts.\n if (child.kind === 'text' && !child.data.trim()) continue;\n return null;\n }\n let key: string;\n if (\n kind === 'spTree' &&\n !(child.name.namespaceURI === NS.pml && SHAPE_TREE_PROPERTIES.has(child.name.localName))\n ) {\n const identity = shapeIdentity(child);\n if (!identity) return null;\n key = `shape ${identity.id}`;\n } else {\n const name = elementKey(child);\n const occurrence = occurrences.get(name) ?? 0;\n occurrences.set(name, occurrence + 1);\n key = `${name} ${occurrence}`;\n }\n if (keys.has(key)) return null;\n keys.add(key);\n entries.push({ key, value: serializeFragment(child), item: child });\n }\n return entries;\n}\n\nconst attributesValue = (attrs: XmlAttr[]) =>\n JSON.stringify(attrs.map((item) => [item.name.namespaceURI, item.name.localName, item.value]));\n\nconst NESTED: Partial<Record<ContainerKind, { localName: string; kind: ContainerKind }>> = {\n root: { localName: 'cSld', kind: 'cSld' },\n cSld: { localName: 'spTree', kind: 'spTree' },\n};\n\n/** Merges a slide-like element: its attributes as one unit, its children by key. */\nfunction mergeContainer(\n context: PartContext,\n base: XmlElement,\n ours: XmlElement,\n theirs: XmlElement,\n kind: ContainerKind,\n): Outcome<XmlElement> {\n const conflicts: DeckConflict[] = [];\n const [ba, oa, ta] = [base.attrs, ours.attrs, theirs.attrs].map(attributesValue);\n let attrs = theirs.attrs;\n if (oa !== ba && (ta === ba || oa === ta)) attrs = ours.attrs;\n else if (oa !== ba) conflicts.push(partConflict(context, 'both-changed'));\n // Shapes taken from the editor's copy may use prefixes declared on its root.\n const prefixDecls = new Map(theirs.prefixDecls);\n for (const [prefix, uri] of ours.prefixDecls) {\n const existing = prefixDecls.get(prefix);\n if (existing === undefined) prefixDecls.set(prefix, uri);\n else if (existing !== uri) conflicts.push(partConflict(context, 'both-changed'));\n }\n const entries = [base, ours, theirs].map((element) => childEntries(element, kind));\n if (entries.some((list) => !list)) conflicts.push(partConflict(context, 'both-changed'));\n if (conflicts.length) return { ok: false, conflicts };\n const nested = NESTED[kind];\n const children = mergeEntries(entries[0]!, entries[1]!, entries[2]!, {\n ordering: kind === 'spTree' ? 'free' : 'schema',\n refine: (_key, b, o, t) =>\n nested && t.name.namespaceURI === NS.pml && t.name.localName === nested.localName\n ? mergeContainer(context, b, o, t, nested.kind)\n : null,\n conflict: (key, reason, sample) =>\n partConflict(\n context,\n reason,\n sample && key.startsWith('shape ') ? shapeIdentity(sample) : null,\n ),\n });\n if (!children.ok) return children;\n return {\n ok: true,\n value: elem(theirs.name, { attrs, prefixDecls, children: children.value }),\n };\n}\n\nfunction mergeShapeTreePart(\n context: PartContext,\n base: Uint8Array,\n ours: Uint8Array,\n theirs: Uint8Array,\n): Outcome<Uint8Array> {\n const [b, o, t] = [base, ours, theirs].map((bytes) => parseXml(strFromU8(bytes)));\n const root = mergeContainer(context, b!.root, o!.root, t!.root, 'root');\n if (!root.ok) return root;\n return { ok: true, value: strToU8(serializeXml({ ...t!, root: root.value })) };\n}\n\nfunction relationshipEntries(bytes: Uint8Array | undefined): Entry<Relationship>[] {\n const rels = bytes ? parseRels(strFromU8(bytes)) : emptyRels();\n return rels.items.map((item) => ({\n key: item.id,\n value: JSON.stringify([item.type, item.target, item.targetMode]),\n item,\n }));\n}\n\nfunction mergeRelationshipsPart(\n context: PartContext,\n base: Uint8Array | undefined,\n ours: Uint8Array,\n theirs: Uint8Array,\n): Outcome<Uint8Array> {\n const items = mergeEntries(\n relationshipEntries(base),\n relationshipEntries(ours),\n relationshipEntries(theirs),\n { ordering: 'none', conflict: (_key, reason) => partConflict(context, reason) },\n );\n if (!items.ok) return items;\n return { ok: true, value: strToU8(serializeRels({ items: items.value })) };\n}\n\n/**\n * Content types are declarations about parts, so both sides' entries are kept\n * and only overrides for parts the merged package no longer has are dropped.\n */\nfunction mergeContentTypes(\n ours: Uint8Array,\n theirs: Uint8Array,\n parts: Set<string>,\n): Outcome<Uint8Array> {\n const [o, t] = [ours, theirs].map((bytes) => parseContentTypes(strFromU8(bytes)));\n const merged: ContentTypes = { defaults: [], overrides: [] };\n const defaults = new Map<string, string>();\n const overrides = new Map<string, string>();\n const conflicts: DeckConflict[] = [];\n const context = { part: CONTENT_TYPES };\n for (const types of [t!, o!]) {\n for (const item of types.defaults) {\n const existing = defaults.get(item.extension);\n if (existing === undefined) {\n defaults.set(item.extension, item.contentType);\n merged.defaults.push(item);\n } else if (existing !== item.contentType)\n conflicts.push(partConflict(context, 'both-changed'));\n }\n for (const item of types.overrides) {\n const key = item.partName.toLowerCase();\n if (!parts.has(key)) continue;\n const existing = overrides.get(key);\n if (existing === undefined) {\n overrides.set(key, item.contentType);\n merged.overrides.push(item);\n } else if (existing !== item.contentType)\n conflicts.push(partConflict(context, 'both-changed'));\n }\n }\n if (conflicts.length) return { ok: false, conflicts };\n return { ok: true, value: strToU8(serializeContentTypes(merged)) };\n}\n\n/** Maps each slide's parts (the slide, its notes and their relationships) to its number. */\nfunction slideNumbers(parts: Map<string, Uint8Array>): Map<string, number> {\n const numbers = new Map<string, number>();\n const presentation = parts.get(PRESENTATION);\n const presentationRels = parts.get('ppt/_rels/presentation.xml.rels');\n if (!presentation || !presentationRels) return numbers;\n const targets = new Map(\n parseRels(strFromU8(presentationRels))\n .items.filter((item) => item.type === SLIDE_RELATIONSHIP)\n .map((item) => [item.id, toZipPath(resolveTarget(fromZipPath(PRESENTATION), item.target))]),\n );\n let number = 0;\n walkElements(parseXml(strFromU8(presentation)).root, (element) => {\n if (element.name.localName !== 'sldId') return undefined;\n number++;\n const id = element.attrs.find(\n (item) => item.name.namespaceURI === NS.officeDocRels && item.name.localName === 'id',\n )?.value;\n const slide = id === undefined ? undefined : targets.get(id);\n if (!slide) return false;\n const relsPart = relsName(slide);\n numbers.set(slide, number).set(relsPart, number);\n const rels = parts.get(relsPart);\n if (!rels) return false;\n for (const item of parseRels(strFromU8(rels)).items) {\n if (item.type !== NOTES_RELATIONSHIP) continue;\n const notes = toZipPath(resolveTarget(fromZipPath(slide), item.target));\n numbers.set(notes, number).set(relsName(notes), number);\n }\n return false;\n });\n return numbers;\n}\n\nconst relsName = (part: string) => {\n const slash = part.lastIndexOf('/');\n return `${part.slice(0, slash + 1)}_rels/${part.slice(slash + 1)}.rels`;\n};\n\n/**\n * Both sides allocate the next free relationship ID, so a relationship the\n * editor added and a different one the source added often share an ID. IDs\n * are private to a part and its relationships, so the editor's is renamed\n * (in its relationships and in the part referring to it) instead of\n * reporting a conflict.\n */\nfunction renumberAddedRelationships(\n base: Map<string, Uint8Array>,\n ours: Map<string, Uint8Array>,\n theirs: Map<string, Uint8Array>,\n) {\n for (const [name, bytes] of ours) {\n const owner = relationshipsOwner(name);\n const theirsBytes = theirs.get(name);\n const ownerBytes = owner && ours.get(owner);\n if (!ownerBytes || !theirsBytes) continue;\n const parse = (value: Uint8Array | undefined) =>\n value ? parseRels(strFromU8(value)) : emptyRels();\n const [b, o, t] = [parse(base.get(name)), parse(bytes), parse(theirsBytes)];\n const inBase = new Set(b.items.map((item) => item.id));\n const theirsById = new Map(t.items.map((item) => [item.id, item]));\n const used = new Set([...inBase, ...theirsById.keys(), ...o.items.map((item) => item.id)]);\n const renamed = new Map<string, string>();\n let next = 1;\n for (const item of o.items) {\n const other = theirsById.get(item.id);\n if (inBase.has(item.id) || !other || sameRelationship(item, other)) continue;\n while (used.has(`rId${next}`)) next++;\n renamed.set(item.id, `rId${next}`);\n used.add(`rId${next}`);\n item.id = `rId${next}`;\n }\n if (!renamed.size) continue;\n ours.set(name, strToU8(serializeRels(o)));\n const document = parseXml(strFromU8(ownerBytes));\n walkElements(document.root, (element) => {\n element.attrs = element.attrs.map((item) =>\n item.name.namespaceURI === NS.officeDocRels && renamed.has(item.value)\n ? { name: item.name, value: renamed.get(item.value)! }\n : item,\n );\n return undefined;\n });\n ours.set(owner, strToU8(serializeXml(document)));\n }\n}\n\nconst sameRelationship = (a: Relationship, b: Relationship) =>\n a.type === b.type && a.target === b.target && a.targetMode === b.targetMode;\n\n/** The part whose relationships `name` holds; `null` for the package's own. */\nfunction relationshipsOwner(name: string): string | null {\n const match = /^(.*?)_rels\\/([^/]+)\\.rels$/.exec(name);\n return match ? `${match[1]}${match[2]}` : null;\n}\n\nfunction unzip(bytes: Uint8Array): Map<string, Uint8Array> {\n return new Map(readZip(bytes).entries.map((entry) => [entry.name, entry.data]));\n}\n\n/** True when both packages have the same parts with the same content, as the merge compares them. */\nexport function sameDeck(a: Uint8Array, b: Uint8Array): boolean {\n const [x, y] = [unzip(a), unzip(b)];\n if (x.size !== y.size) return false;\n for (const [name, bytes] of x) {\n const other = y.get(name);\n if (!other || !sameBytes(comparablePart(name, bytes), comparablePart(name, other)))\n return false;\n }\n return true;\n}\n\n/**\n * Three-way merge of presentation packages: `base` is the version the other two\n * were both made from, `ours` the editor's copy and `theirs` the other copy (a\n * new source build, an agent's version). Changes on different parts, shapes or\n * relationships combine; the same item changed differently on both sides is\n * reported as a conflict.\n */\nexport function mergeDecks(base: Uint8Array, ours: Uint8Array, theirs: Uint8Array): DeckMerge {\n const [b, o, t] = [unzip(base), unzip(ours), unzip(theirs)] as const;\n renumberAddedRelationships(b, o, t);\n const names = new Set([...t.keys(), ...o.keys(), ...b.keys()]);\n const result = new Map<string, Uint8Array>();\n const conflicts: DeckConflict[] = [];\n const same = (name: string, x: Uint8Array | undefined, y: Uint8Array | undefined) =>\n x === undefined || y === undefined\n ? x === y\n : sameBytes(comparablePart(name, x), comparablePart(name, y));\n for (const name of names) {\n if (name === CONTENT_TYPES) continue;\n const [bp, op, tp] = [b.get(name), o.get(name), t.get(name)];\n let pick: Uint8Array | undefined;\n if (same(name, op, bp)) pick = tp;\n else if (same(name, tp, bp) || same(name, op, tp)) pick = op;\n else {\n const context = { part: name };\n let merged: Outcome<Uint8Array> | null = null;\n if (op && tp && RELATIONSHIPS_PART.test(name))\n merged = mergeRelationshipsPart(context, bp, op, tp);\n else if (bp && op && tp && SHAPE_TREE_PART.test(name))\n merged = mergeShapeTreePart(context, bp, op, tp);\n if (merged?.ok) result.set(name, merged.value);\n else if (merged) conflicts.push(...merged.conflicts);\n else\n conflicts.push(\n partConflict(\n context,\n !bp ? 'both-added' : !op || !tp ? 'deleted-and-changed' : 'both-changed',\n ),\n );\n continue;\n }\n if (pick) result.set(name, pick);\n }\n const [bt, ot, tt] = [b, o, t].map((parts) => parts.get(CONTENT_TYPES)!);\n let contentTypes: Uint8Array | undefined;\n if (same(CONTENT_TYPES, ot, bt)) contentTypes = tt;\n else if (same(CONTENT_TYPES, tt, bt) || same(CONTENT_TYPES, ot, tt)) contentTypes = ot;\n else {\n const merged = mergeContentTypes(\n ot!,\n tt!,\n new Set([...result.keys()].map((name) => `/${name}`.toLowerCase())),\n );\n if (merged.ok) contentTypes = merged.value;\n else conflicts.push(...merged.conflicts);\n }\n if (conflicts.length) {\n const numbers = [b, t, o].reduce(\n (all, parts) => new Map([...all, ...slideNumbers(parts)]),\n new Map<string, number>(),\n );\n return {\n ok: false,\n conflicts: conflicts.map((conflict) => ({\n ...conflict,\n slide: numbers.get(conflict.part) ?? null,\n })),\n };\n }\n return {\n ok: true,\n bytes: writeZip([\n { name: CONTENT_TYPES, data: contentTypes! },\n ...[...result].map(([name, data]) => ({ name, data })),\n ]),\n };\n}\n\n/** One line per conflict, for the CLI and server messages. */\nexport function describeConflict(conflict: DeckConflict): string {\n const where = conflict.slide === null ? conflict.part : `Slide ${conflict.slide}`;\n const what = conflict.shape\n ? `${where}: ${conflict.shape.name || `shape ${conflict.shape.id}`}`\n : where;\n return conflict.reason === 'deleted-and-changed'\n ? `${what} was deleted on one side and changed on the other.`\n : `${what} was changed both in the editor and in the source.`;\n}\n"],"mappings":";;AA8CA,MAAM,qBAAqB,IAAI,IAAI;CAEjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,eAAe,SAAyB;CAC5C,MAAM,MAAM,KAAK,YAAY,GAAG;CAChC,OAAO,MAAM,IAAI,KAAK,KAAK,MAAM,MAAM,CAAC,CAAC,CAAC,YAAY;AACxD;;;;;;AAOA,MAAa,eAAe,SAA0B,mBAAmB,IAAI,YAAY,IAAI,CAAC;AAE9F,MAAM,mBAAmB;AACzB,MAAM,qBAAqB;AAC3B,MAAM,WAAW;AACjB,MAAM,iBAAiB;AACvB,MAAM,oBAAoB;AAC1B,MAAM,YAAY;AAClB,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;AAC5B,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;AACvB,MAAM,oBAAoB;AAC1B,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,iBAAiB;AAGvB,MAAM,qBAAqB,KAAK;AAGhC,MAAM,oBAAoB;AAC1B,MAAM,sBAAsB;AAE5B,MAAM,WAAW,2BAA0B,IAAI,MAAM,gBAAgB,QAAQ;AAE7E,MAAM,OAAO,GAAe,OAAuB,EAAE,MAAQ,EAAE,KAAK,MAAO;AAC3E,MAAM,OAAO,GAAe,QACzB,EAAE,MAAQ,EAAE,KAAK,MAAO,IAAM,EAAE,KAAK,MAAO,KAAO,EAAE,KAAK,MAAO,QAAS;AAC7E,MAAM,OAAO,GAAe,OAAuB;CACjD,MAAM,QAAQ,IAAI,GAAG,EAAE,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,KAAK;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AAE,MAAM;GAAe,MAAM;EAAc,GAC3C,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW;GAAE;GAAM;EAAK,EAAE,CACvD,CAAC;CACH;AACF;;AAGA,SAAgB,iBAAiB,UAAgC;CAC/D,MAAM,QAAQ,SAAS,UAAU,OAAO,SAAS,OAAO,SAAS,SAAS;CAC1E,MAAM,OAAO,SAAS,QAClB,GAAG,MAAM,IAAI,SAAS,MAAM,QAAQ,SAAS,SAAS,MAAM,SAC5D;CACJ,OAAO,SAAS,WAAW,wBACvB,GAAG,KAAK,sDACR,GAAG,KAAK;AACd"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { n as JsonSchema, r as JsonValue } from "./agent-tools-bDB2Jq41.js";
|
|
2
|
+
import { PresentationData } from "@office-kit/pptx";
|
|
3
|
+
|
|
4
|
+
//#region src/core/agent-edits.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The JSON Schema (draft 2020-12) of a batch of edits: `{ edits: [{ tool,
|
|
7
|
+
* input }, …] }`, applied in order. Give it to a model as one tool's input.
|
|
8
|
+
*/
|
|
9
|
+
declare const agentEditSchema: JsonSchema & {
|
|
10
|
+
readonly type: "object";
|
|
11
|
+
};
|
|
12
|
+
/** Why a batch of edits could not be applied. */
|
|
13
|
+
declare class AgentEditError extends Error {
|
|
14
|
+
/** The failing edit's position in the batch; `null` when the batch did not match the schema. */
|
|
15
|
+
readonly index: number | null;
|
|
16
|
+
constructor(index: number | null, message: string, options?: ErrorOptions);
|
|
17
|
+
}
|
|
18
|
+
interface DecodedAgentEdit {
|
|
19
|
+
readonly tool: string;
|
|
20
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
21
|
+
}
|
|
22
|
+
declare const decoded: unique symbol;
|
|
23
|
+
/** Edits `decodeAgentEdits` has checked, ready for `applyAgentEdits`. */
|
|
24
|
+
type DecodedAgentEdits = readonly DecodedAgentEdit[] & {
|
|
25
|
+
readonly [decoded]: true;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Checks a model's `edits` (the `edits` of `agentEditSchema`) without
|
|
29
|
+
* touching a presentation. Throws an `AgentEditError` with `index: null`
|
|
30
|
+
* that lists every problem by its JSON Pointer into `agentEditSchema`'s
|
|
31
|
+
* input (`/edits/0/input/…`). `touchedSlides` are the
|
|
32
|
+
* part names of the slides the edits change, in order, each once.
|
|
33
|
+
*/
|
|
34
|
+
declare function decodeAgentEdits(edits: unknown): {
|
|
35
|
+
edits: DecodedAgentEdits;
|
|
36
|
+
touchedSlides: readonly string[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Applies `edits` to `presentation` in order, each reading references
|
|
40
|
+
* against the presentation as the edits before it left it, and resolves
|
|
41
|
+
* with each edit's result. When edit `i` fails it rejects with an
|
|
42
|
+
* `AgentEditError` of `index: i`; the edits before it have been applied,
|
|
43
|
+
* so discard the presentation.
|
|
44
|
+
*/
|
|
45
|
+
declare function applyAgentEdits(presentation: PresentationData, edits: DecodedAgentEdits): Promise<readonly JsonValue[]>;
|
|
46
|
+
/**
|
|
47
|
+
* What a model reads before editing: for each slide (all of them, or the
|
|
48
|
+
* ones `slides` names by part name, in presentation order) its part name,
|
|
49
|
+
* 0-based index, title, whether it is hidden, its speaker notes and its
|
|
50
|
+
* shapes as the editor's `listShapes` reports them.
|
|
51
|
+
*/
|
|
52
|
+
declare function readForAgent(presentation: PresentationData, slides: readonly string[] | null): JsonValue;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { AgentEditError, type DecodedAgentEdits, type JsonSchema, type JsonValue, agentEditSchema, applyAgentEdits, decodeAgentEdits, readForAgent };
|
|
55
|
+
//# sourceMappingURL=headless.d.ts.map
|