@office-kit/pptx-dev 0.9.0 → 0.11.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 +98 -18
- package/dist/animation-player.js +1 -0
- package/dist/build-cpmt-r9Q.mjs +131 -0
- package/dist/build-cpmt-r9Q.mjs.map +1 -0
- package/dist/cli.mjs +1918 -159
- package/dist/cli.mjs.map +1 -1
- package/dist/editor.css +1 -0
- package/dist/editor.js +162 -0
- package/dist/index.d.mts +36 -1
- package/dist/index.mjs +1 -1
- package/dist/media-player.js +1 -0
- package/dist/src-CI73YbYS.mjs +1741 -0
- package/dist/src-CI73YbYS.mjs.map +1 -0
- package/dist/terminal-client.js +18 -18
- package/dist/worker.mjs +1 -65
- package/dist/worker.mjs.map +1 -1
- package/package.json +7 -6
- package/dist/src-YH6kAXbA.mjs +0 -380
- package/dist/src-YH6kAXbA.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-CI73YbYS.mjs","names":["dirname"],"sources":["../src/bundle.ts","../src/build-runner.ts","../../../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/fingerprint.ts","../src/deck-merge.ts","../src/editor-store.ts","../src/init.ts","../src/inspect.ts","../src/index.ts"],"sourcesContent":["import { context, transform } from 'esbuild';\nimport { readFile, writeFile } from 'node:fs/promises';\nimport { resolve, sep } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\nconst resolvePackage = (name: string) => fileURLToPath(import.meta.resolve(name));\n\nexport async function createDeckCompiler(entry: string) {\n const transformedSources = new Map<string, { source: string; code: string }>();\n const compiler = await context({\n entryPoints: [resolve(entry)],\n outfile: 'deck.mjs',\n write: false,\n bundle: true,\n platform: 'node',\n format: 'esm',\n target: 'node22',\n jsx: 'automatic',\n jsxImportSource: '@office-kit/pptx-dsl',\n sourcemap: 'inline',\n sourceRoot: pathToFileURL(process.cwd() + sep).href,\n metafile: true,\n logLevel: 'silent',\n plugins: [\n {\n name: 'source-location',\n setup(builder) {\n // A bundled module lives in a temporary directory. Keep source-relative\n // asset URLs pointing at each original module, including imported files.\n builder.onLoad({ filter: /\\.[cm]?[jt]sx?$/ }, async ({ path }) => {\n const source = await readFile(path, 'utf8');\n const cached = transformedSources.get(path);\n if (cached?.source === source) return { contents: cached.code, loader: 'js' };\n const loader = path.endsWith('.tsx')\n ? 'tsx'\n : path.endsWith('.ts') || path.endsWith('.mts') || path.endsWith('.cts')\n ? 'ts'\n : path.endsWith('.jsx')\n ? 'jsx'\n : 'js';\n const transformed = await transform(source, {\n loader,\n sourcefile: path,\n sourcemap: 'inline',\n jsx: 'automatic',\n jsxDev: true,\n jsxImportSource: '@office-kit/pptx-dsl',\n define: { 'import.meta.url': JSON.stringify(pathToFileURL(path).href) },\n });\n transformedSources.set(path, { source, code: transformed.code });\n return { contents: transformed.code, loader: 'js' };\n });\n },\n },\n {\n name: 'shared-office-kit',\n setup(builder) {\n // Core uses symbol-backed handles; all consumers must share its instance.\n builder.onResolve({ filter: /^@office-kit\\/pptx(?:-dsl)?(?:\\/.*)?$/ }, ({ path }) => ({\n path: resolvePackage(path),\n external: true,\n }));\n },\n },\n ],\n });\n return {\n async build(output: string) {\n const result = await compiler.rebuild();\n await writeFile(output, result.outputFiles[0]!.contents);\n const dependencies = Object.keys(result.metafile!.inputs).map((path) => resolve(path));\n const used = new Set(dependencies);\n for (const path of transformedSources.keys())\n if (!used.has(path)) transformedSources.delete(path);\n return dependencies;\n },\n cancel: () => compiler.cancel(),\n close: () => compiler.dispose(),\n };\n}\n","import { Worker } from 'node:worker_threads';\nimport { join } from 'node:path';\nimport { mkdtempSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport type { BuildResult } from './build.ts';\nimport type { PreviewCache } from './preview-cache.ts';\nimport { createDeckCompiler } from './bundle.ts';\n\nconst BUILD_TIMEOUT_MS = 60_000;\n\nfunction prepareWorker() {\n const directory = mkdtempSync(join(tmpdir(), 'office-pptx-'));\n const worker = new Worker(new URL('./worker.mjs', import.meta.url), {\n workerData: { directory },\n execArgv: ['--enable-source-maps'],\n });\n const result = new Promise<{ result: BuildResult; cache: PreviewCache }>(\n (resolveBuild, reject) => {\n worker.once('message', resolveBuild);\n worker.once('error', reject);\n worker.once('exit', (code) =>\n reject(new Error(`Build worker exited without a result (code ${code}).`)),\n );\n },\n );\n // Startup may fail before the next edit asks to use this worker.\n void result.catch(() => {});\n return { worker, result, directory };\n}\n\n/** Internal watch session. Preload libraries, but never reuse a user module cache. */\nexport function createDeckBuilder(entry: string, keepWarm = true) {\n const compiler = createDeckCompiler(entry);\n void compiler.catch(() => {});\n let prepared: ReturnType<typeof prepareWorker> | undefined = prepareWorker();\n let cache: PreviewCache | undefined;\n let closed = false;\n let active = false;\n return {\n async build(): Promise<BuildResult> {\n if (closed || active) throw new Error('Deck builder is closed or already building.');\n active = true;\n const current = prepared ?? prepareWorker();\n prepared = current;\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n const built = await Promise.race([\n (async () => {\n const dependencies = await (await compiler).build(join(current.directory, 'deck.mjs'));\n current.worker.postMessage({ dependencies, cache });\n return current.result;\n })(),\n new Promise<never>((_, reject) => {\n timer = setTimeout(\n () =>\n reject(\n new Error(\n 'Build exceeded 60 seconds. Check the deck for loops or unresolved promises.',\n ),\n ),\n BUILD_TIMEOUT_MS,\n );\n }),\n ]);\n cache = built.cache;\n return built.result;\n } finally {\n clearTimeout(timer);\n await compiler.then(\n (compiler) => compiler.cancel(),\n () => {},\n );\n await current.worker.terminate();\n await rm(current.directory, { recursive: true, force: true });\n active = false;\n prepared = !closed && keepWarm ? prepareWorker() : undefined;\n }\n },\n async cancel() {\n if (!active) return;\n const current = prepared;\n await compiler.then(\n (compiler) => compiler.cancel(),\n () => {},\n );\n await current?.worker.terminate();\n },\n async close() {\n closed = true;\n const current = prepared;\n await compiler.then(\n (compiler) => compiler.cancel(),\n () => {},\n );\n await current?.worker.terminate();\n await compiler.then(\n (compiler) => compiler.close(),\n () => {},\n );\n if (current) await rm(current.directory, { recursive: true, force: true });\n },\n };\n}\n","// 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. The\n// wrapper is deliberately thin: it just translates between fflate's\n// object-keyed API and an ordered array of entries, plus picks a sensible\n// compression level per entry.\n//\n// What we preserve on round-trip:\n//\n// - Entry order. fflate's `unzipSync` returns a plain object whose key\n// iteration order matches the central directory, so we use `Object.keys`\n// to recover the ordering. JS objects preserve insertion order for string\n// keys, so this is well-defined.\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`). PowerPoint sets these to the current time\n// anyway; preserving the original would be misleading.\n// - ZIP64 extensions. fflate auto-promotes when needed.\n// - Extra fields, file attributes, UTF-8 flags. These are not load-bearing\n// for PPTX as consumed by PowerPoint.\n\nimport { type ZipOptions, unzipSync, 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\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.\n */\nexport const readZip = (input: Uint8Array): ZipReadResult => {\n const obj = unzipSync(input);\n const entries: ZipEntry[] = [];\n for (const name of Object.keys(obj)) {\n const data = obj[name];\n if (data === undefined) continue;\n entries.push({ name, data });\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/**\n * Resolves a relationship Target (which may be relative) against a base part\n * name. 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 = (basePart: PartName, target: string): PartName => {\n if (target === '') throw new Error('relationship target is empty');\n if (target.startsWith('/')) return partName(target);\n\n const baseDir = 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 PowerPoint'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 (Microsoft Open XML Diff).\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// PowerPoint 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 PowerPoint 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 // Office 2007+ 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 // 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 PowerPoint\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.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// PowerPoint 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 — PowerPoint 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.\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 PowerPoint 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';\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\nconst writeElement = (e: XmlElement, parts: string[]): void => {\n const name = rawName(e.name.prefix, e.name.localName);\n parts.push('<');\n parts.push(name);\n for (const [prefix, uri] of e.prefixDecls) {\n const decl = prefix === '' ? 'xmlns' : `xmlns:${prefix}`;\n parts.push(` ${decl}=\"${escapeAttr(uri)}\"`);\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);\n parts.push('</');\n parts.push(name);\n parts.push('>');\n};\n\nconst writeNode = (n: XmlNode, parts: string[]): void => {\n switch (n.kind) {\n case 'element':\n writeElement(n, parts);\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. PowerPoint 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\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 version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>');\n }\n for (const p of doc.prolog) writeNode(p, parts);\n writeElement(doc.root, parts);\n for (const e of doc.epilog) writeNode(e, parts);\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);\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/**\n * Resolves the content type for a given part name.\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 */\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 file = basename(name);\n const dot = file.lastIndexOf('.');\n if (dot < 0) return null;\n const ext = file.slice(dot + 1).toLowerCase();\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 Office's diff comparison.\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 PowerPoint emits it and our\n * authoring code follows suit so output diffs cleanly against PowerPoint.\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 { createHash } from 'node:crypto';\nimport { strFromU8, strToU8, unzipSync } from 'fflate';\n\nconst CORE_PROPERTIES = 'docProps/core.xml';\nconst CORE_TIMESTAMPS = /<(dcterms:(?:created|modified))\\b[^>]*>[\\s\\S]*?<\\/\\1>/g;\n\n/** Every build stamps fresh creation and modification times into the core properties. */\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\n/** ZIP container dates and generated core timestamps are not source edits. */\nexport function sourceFingerprint(bytes: Uint8Array): string {\n const parts = unzipSync(bytes);\n const hash = createHash('sha256');\n for (const name of Object.keys(parts).sort()) {\n const content = comparablePart(name, parts[name]!);\n hash.update(JSON.stringify([name, createHash('sha256').update(content).digest('hex')]));\n }\n return hash.digest('hex');\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';\nimport { comparablePart } from './fingerprint.ts';\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/**\n * Three-way merge of presentation packages: `base` is the source build the\n * editor's copy was made from, `ours` the editor's copy and `theirs` the new\n * source build. Changes on different parts, shapes or relationships combine;\n * the same item changed differently on both sides is 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","import { randomUUID } from 'node:crypto';\nimport { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport { strFromU8, strToU8, unzipSync, zipSync } from 'fflate';\nimport { renderDeck, type BuildResult } from './build.ts';\nimport { describeConflict, mergeDecks } from './deck-merge.ts';\nimport { sourceFingerprint } from './fingerprint.ts';\n\nexport interface SavedEdits {\n sourceHash: string;\n bytes: Uint8Array;\n /**\n * The source build the edits were made against, which lets a later source\n * change merge with them. Version 1 sidecars did not store it.\n */\n base: Uint8Array | null;\n}\n\nconst STORE_VERSION = 2;\n\n/** One atomic sidecar keeps the saved deck and its source basis in agreement. */\nexport function editorStore(entry: string) {\n const path = join(dirname(resolve(entry)), '.office-kit', `${basename(entry)}.editor.zip`);\n return {\n path,\n async read(): Promise<SavedEdits | undefined> {\n let bytes: Uint8Array;\n try {\n bytes = await readFile(path);\n } catch (cause) {\n if (cause instanceof Error && 'code' in cause && cause.code === 'ENOENT') return;\n throw cause;\n }\n const parts = unzipSync(bytes);\n if (!parts['state.json'] || !parts['document.pptx'])\n throw new Error(`Invalid editor file: ${path}`);\n const state: unknown = JSON.parse(strFromU8(parts['state.json']));\n if (\n !state ||\n typeof state !== 'object' ||\n !('version' in state) ||\n (state.version !== 1 && state.version !== STORE_VERSION) ||\n !('sourceHash' in state) ||\n typeof state.sourceHash !== 'string' ||\n !/^[a-f0-9]{64}$/.test(state.sourceHash)\n ) {\n throw new Error(`Invalid editor metadata: ${path}`);\n }\n const base = parts['base.pptx'];\n if (state.version === STORE_VERSION && !base) throw new Error(`Invalid editor file: ${path}`);\n return { sourceHash: state.sourceHash, bytes: parts['document.pptx'], base: base ?? null };\n },\n async write(edits: SavedEdits & { base: Uint8Array }): Promise<void> {\n await mkdir(dirname(path), { recursive: true });\n const temporary = `${path}.${randomUUID()}.tmp`;\n try {\n await writeFile(\n temporary,\n zipSync({\n 'state.json': strToU8(\n JSON.stringify({ version: STORE_VERSION, sourceHash: edits.sourceHash }),\n ),\n 'document.pptx': edits.bytes,\n 'base.pptx': edits.base,\n }),\n { flag: 'wx' },\n );\n await rename(temporary, path);\n } finally {\n await rm(temporary, { force: true });\n }\n },\n async clear(): Promise<void> {\n await rm(path, { force: true });\n },\n };\n}\n\nexport async function applySavedEdits(entry: string, source: BuildResult): Promise<BuildResult> {\n const edits = await editorStore(entry).read();\n if (!edits) return source;\n let bytes = edits.bytes;\n if (edits.sourceHash !== sourceFingerprint(source.bytes)) {\n const merged = edits.base ? mergeDecks(edits.base, edits.bytes, source.bytes) : null;\n if (!merged?.ok) {\n throw new Error(\n [\n 'Source changed since the last editor save. Open office-pptx dev and resolve the editor conflict before exporting.',\n ...(merged?.conflicts.map(describeConflict) ?? []),\n ].join('\\n'),\n );\n }\n bytes = merged.bytes;\n }\n return (await renderDeck(bytes, source.dependencies)).result;\n}\n","import { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\n\nconst starter = `import { Presentation } from '@office-kit/pptx-dsl';\nimport { Cover } from './slides/cover.tsx';\n\nexport default (\n <Presentation>\n <Cover />\n </Presentation>\n);\n`;\n\nconst theme = `export const theme = {\n background: '#15171C',\n accent: '#D6336C',\n text: '#FFFFFF',\n muted: '#B4B9C4',\n} as const;\n`;\n\nconst cover = `import { Slide, Text, Shape } from '@office-kit/pptx-dsl';\nimport { theme } from '../theme.ts';\n\nexport function Cover() {\n return (\n <Slide background={theme.background}>\n <Shape preset=\"rect\" x={0.9} y={2.55} width={0.14} height={1.75} fill={theme.accent} stroke={false} />\n <Text x={1.25} y={2.4} width={10} height={1.1} size={48} bold color={theme.text}>\n Your next presentation\n </Text>\n <Text x={1.25} y={3.55} width={10} height={0.6} size={22} color={theme.muted}>\n Edit this TSX and save to update the preview.\n </Text>\n </Slide>\n );\n}\n`;\n\nconst guide = `# Writing this presentation\n\nUse deck.tsx for slide order, slides/*.tsx for individual slides, and theme.ts\nfor shared design values. The JSX runtime is\n@office-kit/pptx-dsl, with no React or Vue dependency.\n\n- Run npm run dev, then open its local URL to preview. Saving source files\n updates the preview. A failed build retains the last successful output.\n- Select an area in the preview to request a focused AI edit, or use Edit text\n for a direct text save. Changes are persisted in TSX. Use the thumbnails, zoom\n and Present to review slides. After edits, inspect every screenshot supplied\n by the preview and correct clipping, overlap, spacing and contrast.\n- For a local revision, locate the slide through deck.tsx or a text search and\n read only the relevant source and dependencies. Patch the requested text, data\n or props; do not regenerate the deck or reformat unrelated code. Keep descriptive\n filenames stable when reordering slides. Preserve existing project structures.\n- Change shared theme values/components only for changes intended for all their\n consumers; use a local prop override for a one-slide exception.\n- Keep the preview running during revisions and inspect affected slides after\n saving. Review all affected consumers for shared changes. Do not run a separate\n export for every intermediate edit. Before delivery, run npm run check and\n npm run build to export deck.pptx, then review the whole deck.\n- Coordinates and dimensions are inches; font sizes and stroke widths are points.\n The default 16:9 canvas is 13.333 × 7.5 inches.\n- Use native Text, Shape, Image, Table and Chart elements. Use JS functions,\n arrays and map to compose elements; do not import React.\n- Chart takes the core ChartSpec in its spec prop. Text accepts rich ParagraphSpec\n arrays through paragraphs. Raw is an escape hatch for public core APIs.\n- For templates: readFile(new URL('./template.pptx', import.meta.url)), then use\n Presentation source={bytes} mode=\"edit\" and Slide target={{index: 0}}.\n Fill target={{name: 'Title 1'}} changes an existing shape. Indices are zero-based.\n Use office-pptx inspect template.pptx to discover names, layouts and placeholders.\n- Use mode=\"compose\" and Slide from={{index: 0}} to build a new sequence from a\n source deck. This intentionally removes the original slide sequence.\n- Keep assets inside this project so the dev server sees changes. Use source-relative\n new URL('./image.png', import.meta.url) when loading local assets.\n- Preserve existing slides and formatting unless the request calls for changes.\n Never rasterize a chart/table as a shortcut. Raw-only features are not DSL coverage.\n- Preview is a rendering aid, not a guarantee of identical PowerPoint rendering.\n Check the exported file in the target application for final delivery.\n\nVSCode uses tsconfig.json for completion and diagnostics. Start the\n\"Preview presentation\" task, then run \"Simple Browser: Show\" with the printed URL\nand move that editor to a side group. Type errors appear in the Problems panel.\n`;\n\n/** Creates a new directory; existing projects are never overwritten. */\nexport async function initProject(directory: string): Promise<string> {\n const root = resolve(directory);\n const packageLocations = [\n import.meta.resolve('@office-kit/pptx/package.json'),\n import.meta.resolve('@office-kit/pptx-dsl/package.json'),\n new URL('../package.json', import.meta.url),\n ];\n const versions = await Promise.all(\n packageLocations.map(async (location) => {\n const manifest: { version: string } = JSON.parse(await readFile(new URL(location), 'utf8'));\n return `^${manifest.version}`;\n }),\n );\n await mkdir(root);\n const files: Record<string, string> = {\n 'package.json':\n JSON.stringify(\n {\n name: 'my-presentation',\n private: true,\n type: 'module',\n scripts: {\n dev: 'office-pptx dev deck.tsx',\n build: 'office-pptx build deck.tsx --out deck.pptx',\n check: 'tsc --noEmit',\n },\n dependencies: { '@office-kit/pptx': versions[0]!, '@office-kit/pptx-dsl': versions[1]! },\n devDependencies: {\n '@office-kit/pptx-dev': versions[2]!,\n '@types/node': '^24.13.2',\n typescript: '^6.0.3',\n },\n },\n null,\n 2,\n ) + '\\n',\n 'tsconfig.json':\n JSON.stringify(\n {\n compilerOptions: {\n target: 'ES2022',\n module: 'ESNext',\n moduleResolution: 'Bundler',\n jsx: 'react-jsx',\n jsxImportSource: '@office-kit/pptx-dsl',\n strict: true,\n exactOptionalPropertyTypes: true,\n noEmit: true,\n allowImportingTsExtensions: true,\n types: ['node'],\n },\n include: ['**/*.ts', '**/*.tsx'],\n exclude: ['node_modules'],\n },\n null,\n 2,\n ) + '\\n',\n 'deck.tsx': starter,\n 'theme.ts': theme,\n 'slides/cover.tsx': cover,\n // Same text under both names on purpose: Claude Code loads CLAUDE.md,\n // Codex loads AGENTS.md, and an agent that starts without the guide\n // reaches for its own slide tooling instead of editing the TSX.\n 'CLAUDE.md': guide,\n 'AGENTS.md': guide,\n 'README.md':\n '# Your slides\\n\\nInstall once with `npm install`, then run `npm run dev` (or `npx office-pptx dev deck.tsx`). Open the printed URL.\\n\\nEdit `slides/cover.tsx`, select an area for an AI instruction, or choose Edit text in the preview. Start Claude Code in an agent pane before sending instructions. An installed Chrome enables automatic screenshot review.\\n\\nRun `npm run check` and `npm run build` to check and export `deck.pptx`.\\n',\n '.gitignore': 'node_modules/\\ndeck.pptx\\n.office-kit/\\n',\n '.vscode/tasks.json':\n JSON.stringify(\n {\n version: '2.0.0',\n tasks: [\n {\n label: 'Preview presentation',\n type: 'shell',\n command: 'npm run dev',\n isBackground: true,\n problemMatcher: {\n pattern: { regexp: '^NEVER_MATCH$', file: 1, message: 2 },\n background: {\n activeOnStart: true,\n beginsPattern: '^.*office-pptx dev',\n endsPattern: '^Preview: ',\n },\n },\n },\n {\n label: 'Check presentation',\n type: 'shell',\n command: 'npm run check',\n problemMatcher: '$tsc',\n },\n {\n label: 'Export presentation',\n type: 'shell',\n command: 'npm run build',\n problemMatcher: [],\n },\n ],\n },\n null,\n 2,\n ) + '\\n',\n };\n await Promise.all(['.vscode', 'slides'].map((directory) => mkdir(join(root, directory))));\n await Promise.all(\n Object.entries(files).map(([name, content]) =>\n writeFile(join(root, name), content, { flag: 'wx' }),\n ),\n );\n return root;\n}\n","import { readFile } from 'node:fs/promises';\nimport {\n loadPresentation,\n getSlides,\n getSlidePartName,\n getSlideTitle,\n getSlideShapes,\n getShapeName,\n getShapeId,\n getShapeKind,\n getShapePlaceholderType,\n getShapePlaceholderIdx,\n getSlideLayouts,\n getSlideLayoutName,\n getSlideLayoutPartName,\n getSlideLayoutType,\n} from '@office-kit/pptx';\n\n/** Source references usable directly in Slide, Fill and Remove props. */\nexport async function inspectTemplate(file: string) {\n const presentation = await loadPresentation(await readFile(file));\n return {\n slides: getSlides(presentation).map((slide, index) => ({\n index,\n part: getSlidePartName(slide),\n title: getSlideTitle(slide),\n shapes: getSlideShapes(slide).map((shape) => ({\n id: getShapeId(shape),\n name: getShapeName(shape),\n kind: getShapeKind(shape),\n placeholder: { type: getShapePlaceholderType(shape), idx: getShapePlaceholderIdx(shape) },\n })),\n })),\n layouts: getSlideLayouts(presentation).map((layout) => ({\n part: getSlideLayoutPartName(layout),\n name: getSlideLayoutName(layout),\n type: getSlideLayoutType(layout),\n })),\n };\n}\n","import { writeFile } from 'node:fs/promises';\nimport { createDeckBuilder } from './build-runner.ts';\nimport type { BuildResult } from './build.ts';\nimport { applySavedEdits } from './editor-store.ts';\nexport type { BuildResult } from './build.ts';\nexport { initProject } from './init.ts';\nexport { inspectTemplate } from './inspect.ts';\n\n/** Each evaluation gets a fresh module cache and releases it when finished. */\nexport async function buildDeck(entry: string): Promise<BuildResult> {\n const builder = createDeckBuilder(entry, false);\n try {\n return await applySavedEdits(entry, await builder.build());\n } finally {\n await builder.close();\n }\n}\nexport async function exportDeck(entry: string, output: string): Promise<BuildResult> {\n const result = await buildDeck(entry);\n await writeFile(output, result.bytes);\n return result;\n}\n"],"mappings":";;;;;;;;;;;;AAKA,MAAM,kBAAkB,SAAiB,cAAc,OAAO,KAAK,QAAQ,IAAI,CAAC;AAEhF,eAAsB,mBAAmB,OAAe;CACtD,MAAM,qCAAqB,IAAI,IAA8C;CAC7E,MAAM,WAAW,MAAM,QAAQ;EAC7B,aAAa,CAAC,QAAQ,KAAK,CAAC;EAC5B,SAAS;EACT,OAAO;EACP,QAAQ;EACR,UAAU;EACV,QAAQ;EACR,QAAQ;EACR,KAAK;EACL,iBAAiB;EACjB,WAAW;EACX,YAAY,cAAc,QAAQ,IAAI,IAAI,GAAG,CAAC,CAAC;EAC/C,UAAU;EACV,UAAU;EACV,SAAS,CACP;GACE,MAAM;GACN,MAAM,SAAS;IAGb,QAAQ,OAAO,EAAE,QAAQ,kBAAkB,GAAG,OAAO,EAAE,WAAW;KAChE,MAAM,SAAS,MAAM,SAAS,MAAM,MAAM;KAC1C,MAAM,SAAS,mBAAmB,IAAI,IAAI;KAC1C,IAAI,QAAQ,WAAW,QAAQ,OAAO;MAAE,UAAU,OAAO;MAAM,QAAQ;KAAK;KAQ5E,MAAM,cAAc,MAAM,UAAU,QAAQ;MAC1C,QARa,KAAK,SAAS,MAAM,IA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