pptx-glimpse 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -6110,104 +6110,21 @@ init_warning_logger();
6110
6110
 
6111
6111
  // ../document/dist/index.js
6112
6112
  var import_fast_xml_parser = require("fast-xml-parser");
6113
- var import_fflate = require("fflate");
6114
6113
  var import_fast_xml_parser2 = require("fast-xml-parser");
6114
+ var import_fflate = require("fflate");
6115
6115
  var import_fflate2 = require("fflate");
6116
+ var import_fast_xml_parser3 = require("fast-xml-parser");
6116
6117
  function unsafeOoxmlBoundaryAssertion(value) {
6117
6118
  return value;
6118
6119
  }
6119
6120
  function unsafeBrandAssertion2(value) {
6120
6121
  return value;
6121
6122
  }
6122
- function asPartPath(value) {
6123
- return unsafeBrandAssertion2(value);
6124
- }
6125
- function asRelationshipId(value) {
6126
- return unsafeBrandAssertion2(value);
6127
- }
6128
- function asSourceNodeId(value) {
6129
- return unsafeBrandAssertion2(value);
6130
- }
6131
- function asRawSidecarId(value) {
6132
- return unsafeBrandAssertion2(value);
6133
- }
6134
- var RELS_SUFFIX = ".rels";
6135
- var RELS_MARKER = "_rels/";
6136
- var ABSOLUTE_URI_PATTERN = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
6137
- function isRelationshipPart(path) {
6138
- return path.endsWith(RELS_SUFFIX) && path.includes(RELS_MARKER);
6139
- }
6140
- function relationshipsSourcePartPath(relsPath) {
6141
- const idx = relsPath.lastIndexOf(RELS_MARKER);
6142
- const dir = relsPath.slice(0, idx);
6143
- const file = relsPath.slice(idx + RELS_MARKER.length);
6144
- const base = file.endsWith(RELS_SUFFIX) ? file.slice(0, -RELS_SUFFIX.length) : file;
6145
- return asPartPath(dir + base);
6146
- }
6147
- function resolveRelationshipTarget(sourcePartPath, target) {
6148
- if (ABSOLUTE_URI_PATTERN.test(target)) return target;
6149
- const combined = target.startsWith("/") ? target.slice(1) : joinPackageRelativeTarget(sourcePartPath, target);
6150
- return normalizePackagePath(combined);
6151
- }
6152
- function resolveInternalRelationshipTarget(sourcePartPath, relationship) {
6153
- if (relationship.targetMode === "External") return void 0;
6154
- return asPartPath(resolveRelationshipTarget(sourcePartPath, relationship.target));
6155
- }
6156
- function parseRelationshipTargetMode(value) {
6157
- if (value === "Internal" || value === "External") return value;
6158
- return void 0;
6159
- }
6160
- function joinPackageRelativeTarget(sourcePartPath, target) {
6161
- const slash = sourcePartPath.lastIndexOf("/");
6162
- const baseDir = slash === -1 ? "" : sourcePartPath.slice(0, slash);
6163
- return baseDir === "" ? target : `${baseDir}/${target}`;
6164
- }
6165
- function normalizePackagePath(path) {
6166
- const segments = [];
6167
- for (const segment of path.split("/")) {
6168
- if (segment === "" || segment === ".") continue;
6169
- if (segment === "..") {
6170
- segments.pop();
6171
- continue;
6172
- }
6173
- segments.push(segment);
6174
- }
6175
- return segments.join("/");
6176
- }
6177
- var EDITABLE_TEXT_RUN_PROPERTIES = [
6178
- "bold",
6179
- "italic",
6180
- "underline",
6181
- "fontSize",
6182
- "color",
6183
- "typeface"
6184
- ];
6185
- var EDITABLE_TEXT_RUN_PROPERTY_SET = new Set(EDITABLE_TEXT_RUN_PROPERTIES);
6186
- function asEmu2(value) {
6187
- return unsafeBrandAssertion2(value);
6188
- }
6189
- function asPt(value) {
6190
- return unsafeBrandAssertion2(value);
6191
- }
6192
- function asHundredthPt2(value) {
6193
- return unsafeBrandAssertion2(value);
6194
- }
6195
- function asOoxmlPercent(value) {
6196
- return unsafeBrandAssertion2(value);
6197
- }
6198
- function asOoxmlAngle(value) {
6199
- return unsafeBrandAssertion2(value);
6200
- }
6201
- function parseEnumValue(value, allowed) {
6202
- return value !== void 0 && allowed.has(unsafeOoxmlBoundaryAssertion(value)) ? unsafeOoxmlBoundaryAssertion(value) : void 0;
6203
- }
6204
- function parseEnumValueWithDefault(value, allowed, fallback) {
6205
- return parseEnumValue(value, allowed) ?? fallback;
6206
- }
6207
6123
  var parser = new import_fast_xml_parser.XMLParser({
6208
6124
  ignoreAttributes: false,
6209
6125
  attributeNamePrefix: "@_",
6210
6126
  parseAttributeValue: false,
6127
+ parseTagValue: false,
6211
6128
  // Retain prefix. See the comment at the beginning of the file for the reason.
6212
6129
  removeNSPrefix: false,
6213
6130
  // Do not trim text run (`a:t`) to preserve significant white space at the beginning and end.
@@ -6320,6 +6237,62 @@ function scalarToString(value) {
6320
6237
  if (typeof value === "number" || typeof value === "boolean") return String(value);
6321
6238
  return void 0;
6322
6239
  }
6240
+ function asPartPath(value) {
6241
+ return unsafeBrandAssertion2(value);
6242
+ }
6243
+ function asRelationshipId(value) {
6244
+ return unsafeBrandAssertion2(value);
6245
+ }
6246
+ function asSourceNodeId(value) {
6247
+ return unsafeBrandAssertion2(value);
6248
+ }
6249
+ function asRawSidecarId(value) {
6250
+ return unsafeBrandAssertion2(value);
6251
+ }
6252
+ var RELS_SUFFIX = ".rels";
6253
+ var RELS_MARKER = "_rels/";
6254
+ var ABSOLUTE_URI_PATTERN = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
6255
+ function isRelationshipPart(path) {
6256
+ return path.endsWith(RELS_SUFFIX) && path.includes(RELS_MARKER);
6257
+ }
6258
+ function relationshipsSourcePartPath(relsPath) {
6259
+ const idx = relsPath.lastIndexOf(RELS_MARKER);
6260
+ const dir = relsPath.slice(0, idx);
6261
+ const file = relsPath.slice(idx + RELS_MARKER.length);
6262
+ const base = file.endsWith(RELS_SUFFIX) ? file.slice(0, -RELS_SUFFIX.length) : file;
6263
+ return asPartPath(dir + base);
6264
+ }
6265
+ function resolveRelationshipTarget(sourcePartPath, target) {
6266
+ if (ABSOLUTE_URI_PATTERN.test(target)) return target;
6267
+ const combined = target.startsWith("/") ? target.slice(1) : joinPackageRelativeTarget(sourcePartPath, target);
6268
+ return normalizePackagePath(combined);
6269
+ }
6270
+ function resolveInternalRelationshipTarget(sourcePartPath, relationship) {
6271
+ if (relationship.targetMode === "External") return void 0;
6272
+ return asPartPath(resolveRelationshipTarget(sourcePartPath, relationship.target));
6273
+ }
6274
+ function parseRelationshipTargetMode(value) {
6275
+ if (value === "Internal" || value === "External") return value;
6276
+ return void 0;
6277
+ }
6278
+ function joinPackageRelativeTarget(sourcePartPath, target) {
6279
+ const slash = sourcePartPath.lastIndexOf("/");
6280
+ const baseDir = slash === -1 ? "" : sourcePartPath.slice(0, slash);
6281
+ return baseDir === "" ? target : `${baseDir}/${target}`;
6282
+ }
6283
+ function normalizePackagePath(path) {
6284
+ const segments = [];
6285
+ for (const segment of path.split("/")) {
6286
+ if (segment === "" || segment === ".") continue;
6287
+ if (segment === "..") {
6288
+ segments.pop();
6289
+ continue;
6290
+ }
6291
+ segments.push(segment);
6292
+ }
6293
+ return segments.join("/");
6294
+ }
6295
+ var textDecoder = new TextDecoder();
6323
6296
  var ATTR_PREFIX = "@_";
6324
6297
  var TEXT_KEY = "#text";
6325
6298
  function createSidecarIdFactory(partPath) {
@@ -6389,211 +6362,449 @@ function scalarText(value) {
6389
6362
  if (typeof value === "number" || typeof value === "boolean") return String(value);
6390
6363
  return void 0;
6391
6364
  }
6392
- var RECTANGLE_ALIGNMENT_TOKENS = /* @__PURE__ */ new Set([
6393
- "tl",
6394
- "t",
6395
- "tr",
6396
- "l",
6397
- "ctr",
6398
- "r",
6399
- "bl",
6400
- "b",
6401
- "br"
6402
- ]);
6403
- var COLOR_TRANSFORM_KINDS = /* @__PURE__ */ new Set([
6404
- "lumMod",
6405
- "lumOff",
6406
- "tint",
6407
- "shade",
6408
- "alpha"
6409
- ]);
6410
- var RAW_FILL_LOCAL_NAMES = ["grpFill"];
6411
- var PRESET_COLOR_HEX = {
6412
- black: "000000",
6413
- white: "FFFFFF",
6414
- red: "FF0000",
6415
- green: "008000",
6416
- blue: "0000FF",
6417
- yellow: "FFFF00",
6418
- cyan: "00FFFF",
6419
- magenta: "FF00FF"
6420
- };
6421
- function parseColorElement(parent) {
6422
- if (!parent) return void 0;
6423
- const srgb = getChild(parent, "srgbClr");
6424
- if (srgb) {
6425
- const hex = getAttr(srgb, "val");
6426
- if (hex !== void 0) {
6427
- return withTransforms({ kind: "srgb", hex: hex.toUpperCase() }, srgb);
6428
- }
6429
- }
6430
- const scheme = getChild(parent, "schemeClr");
6431
- if (scheme) {
6432
- const name = getAttr(scheme, "val");
6433
- if (name !== void 0) {
6434
- return withTransforms({ kind: "scheme", scheme: name }, scheme);
6435
- }
6436
- }
6437
- const sys = getChild(parent, "sysClr");
6438
- if (sys) {
6439
- const val = getAttr(sys, "val");
6440
- if (val !== void 0) {
6441
- const lastClr = getAttr(sys, "lastClr");
6442
- return withTransforms(
6443
- {
6444
- kind: "system",
6445
- value: val,
6446
- ...lastClr !== void 0 ? { lastColor: lastClr.toUpperCase() } : {}
6447
- },
6448
- sys
6449
- );
6450
- }
6365
+ function parseCustomGeometry(custGeom, orderedCustGeom) {
6366
+ const pathLst = getChild(custGeom, "pathLst");
6367
+ const paths = getChildArray(pathLst, "path");
6368
+ if (paths.length === 0) return void 0;
6369
+ const avGuides = parseGuideList(getChild(custGeom, "avLst"));
6370
+ const guides = parseGuideList(getChild(custGeom, "gdLst"));
6371
+ const orderedPaths = orderedChildEntries(
6372
+ orderedChildChildren(orderedCustGeom, "pathLst"),
6373
+ "path"
6374
+ );
6375
+ const result = [];
6376
+ for (const [index, path] of paths.entries()) {
6377
+ const width = numericAttr(path, "w") ?? 0;
6378
+ const height = numericAttr(path, "h") ?? 0;
6379
+ if (width === 0 && height === 0) continue;
6380
+ const variables = evaluateGuides(avGuides, guides, width, height);
6381
+ const commands = buildPathCommands(path, variables, orderedNodeChildren(orderedPaths[index]));
6382
+ if (commands !== void 0) result.push({ width, height, commands });
6451
6383
  }
6452
- return void 0;
6453
- }
6454
- function parseEffectList(effectList) {
6455
- if (effectList === void 0) return void 0;
6456
- const outerShadow = parseOuterShadow(getChild(effectList, "outerShdw"));
6457
- const innerShadow = parseInnerShadow(getChild(effectList, "innerShdw"));
6458
- const glow = parseGlow(getChild(effectList, "glow"));
6459
- const softEdge = parseSoftEdge(getChild(effectList, "softEdge"));
6460
- const parsed = {
6461
- ...outerShadow !== void 0 ? { outerShadow } : {},
6462
- ...innerShadow !== void 0 ? { innerShadow } : {},
6463
- ...glow !== void 0 ? { glow } : {},
6464
- ...softEdge !== void 0 ? { softEdge } : {}
6465
- };
6466
- return Object.keys(parsed).length > 0 ? parsed : void 0;
6384
+ return result.length > 0 ? result : void 0;
6467
6385
  }
6468
- function parseBlipEffects(blip) {
6469
- if (blip === void 0) return void 0;
6470
- const grayscale = getChild(blip, "grayscl") !== void 0;
6471
- const biLevel = parseBiLevel(getChild(blip, "biLevel"));
6472
- const blur = parseBlurEffect(getChild(blip, "blur"));
6473
- const lum = parseLumEffect(getChild(blip, "lum"));
6474
- const duotone = parseDuotoneEffect(getChild(blip, "duotone"));
6475
- const clrChange = parseColorChangeEffect(getChild(blip, "clrChange"));
6476
- const parsed = {
6477
- grayscale,
6478
- ...biLevel !== void 0 ? { biLevel } : {},
6479
- ...blur !== void 0 ? { blur } : {},
6480
- ...lum !== void 0 ? { lum } : {},
6481
- ...duotone !== void 0 ? { duotone } : {},
6482
- ...clrChange !== void 0 ? { clrChange } : {}
6483
- };
6484
- return grayscale || biLevel !== void 0 || blur !== void 0 || lum !== void 0 || duotone !== void 0 || clrChange !== void 0 ? parsed : void 0;
6386
+ function parseGuideList(parent) {
6387
+ return getChildArray(parent, "gd").map((guide) => ({
6388
+ name: getAttr(guide, "name") ?? "",
6389
+ formula: getAttr(guide, "fmla") ?? ""
6390
+ })).filter((guide) => guide.name !== "" && guide.formula !== "");
6485
6391
  }
6486
- function parseOuterShadow(node) {
6487
- if (node === void 0) return void 0;
6488
- const color = parseColorElement(node);
6489
- if (color === void 0) return void 0;
6490
- return {
6491
- blurRadius: asEmu2(numericAttr(node, "blurRad") ?? 0),
6492
- distance: asEmu2(numericAttr(node, "dist") ?? 0),
6493
- direction: asOoxmlAngle(numericAttr(node, "dir") ?? 0),
6494
- color,
6495
- alignment: parseRectangleAlignment(getAttr(node, "algn"), "b"),
6496
- rotateWithShape: getAttr(node, "rotWithShape") !== "0"
6497
- };
6392
+ function buildPathCommands(path, variables, orderedCommands) {
6393
+ const parts = [];
6394
+ let currentX = 0;
6395
+ let currentY = 0;
6396
+ let startX = 0;
6397
+ let startY = 0;
6398
+ for (const { local, nodes } of pathCommandNodes(path, orderedCommands)) {
6399
+ for (const node of nodes) {
6400
+ if (local === "moveTo") {
6401
+ const point = firstPoint(node, variables);
6402
+ if (point !== void 0) {
6403
+ parts.push(`M ${point.x} ${point.y}`);
6404
+ currentX = point.x;
6405
+ currentY = point.y;
6406
+ startX = point.x;
6407
+ startY = point.y;
6408
+ }
6409
+ } else if (local === "lnTo") {
6410
+ const point = firstPoint(node, variables);
6411
+ if (point !== void 0) {
6412
+ parts.push(`L ${point.x} ${point.y}`);
6413
+ currentX = point.x;
6414
+ currentY = point.y;
6415
+ }
6416
+ } else if (local === "cubicBezTo") {
6417
+ const points = allPoints(node, variables);
6418
+ if (points.length >= 3) {
6419
+ parts.push(`C ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
6420
+ currentX = points[points.length - 1].x;
6421
+ currentY = points[points.length - 1].y;
6422
+ }
6423
+ } else if (local === "quadBezTo") {
6424
+ const points = allPoints(node, variables);
6425
+ if (points.length >= 2) {
6426
+ parts.push(`Q ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
6427
+ currentX = points[points.length - 1].x;
6428
+ currentY = points[points.length - 1].y;
6429
+ }
6430
+ } else if (local === "arcTo") {
6431
+ const arc = convertArcTo(node, currentX, currentY, variables);
6432
+ if (arc !== void 0) {
6433
+ parts.push(arc.command);
6434
+ currentX = arc.endX;
6435
+ currentY = arc.endY;
6436
+ }
6437
+ } else if (local === "close") {
6438
+ parts.push("Z");
6439
+ currentX = startX;
6440
+ currentY = startY;
6441
+ }
6442
+ }
6443
+ }
6444
+ return parts.length > 0 ? parts.join(" ") : void 0;
6498
6445
  }
6499
- function parseInnerShadow(node) {
6500
- if (node === void 0) return void 0;
6501
- const color = parseColorElement(node);
6502
- if (color === void 0) return void 0;
6503
- return {
6504
- blurRadius: asEmu2(numericAttr(node, "blurRad") ?? 0),
6505
- distance: asEmu2(numericAttr(node, "dist") ?? 0),
6506
- direction: asOoxmlAngle(numericAttr(node, "dir") ?? 0),
6507
- color
6508
- };
6446
+ function pathCommandNodes(path, orderedCommands) {
6447
+ if (orderedCommands === void 0) {
6448
+ return Object.keys(path).filter((key) => !key.startsWith("@_")).map((key) => ({ local: localName(key), nodes: getChildArray(path, localName(key)) }));
6449
+ }
6450
+ const counters = {};
6451
+ const result = [];
6452
+ for (const command of orderedCommands) {
6453
+ const key = orderedNodeKey(command);
6454
+ if (key === void 0) continue;
6455
+ const local = localName(key);
6456
+ const index = counters[local] ?? 0;
6457
+ counters[local] = index + 1;
6458
+ const node = getChildArray(path, local)[index];
6459
+ if (node !== void 0) result.push({ local, nodes: [node] });
6460
+ }
6461
+ return result;
6509
6462
  }
6510
- function parseGlow(node) {
6511
- if (node === void 0) return void 0;
6512
- const color = parseColorElement(node);
6513
- if (color === void 0) return void 0;
6514
- return {
6515
- radius: asEmu2(numericAttr(node, "rad") ?? 0),
6516
- color
6517
- };
6463
+ function firstPoint(node, variables) {
6464
+ return allPoints(node, variables)[0];
6518
6465
  }
6519
- function parseSoftEdge(node) {
6520
- if (node === void 0) return void 0;
6521
- return {
6522
- radius: asEmu2(numericAttr(node, "rad") ?? 0)
6523
- };
6466
+ function allPoints(node, variables) {
6467
+ return getChildArray(node, "pt").map((point) => ({
6468
+ x: resolveValue(getAttr(point, "x") ?? "0", variables),
6469
+ y: resolveValue(getAttr(point, "y") ?? "0", variables)
6470
+ }));
6524
6471
  }
6525
- function parseBiLevel(node) {
6526
- if (node === void 0) return void 0;
6472
+ function convertArcTo(arc, currentX, currentY, variables) {
6473
+ const widthRadius = resolveValue(getAttr(arc, "wR") ?? "0", variables);
6474
+ const heightRadius = resolveValue(getAttr(arc, "hR") ?? "0", variables);
6475
+ const startAngle = resolveValue(getAttr(arc, "stAng") ?? "0", variables);
6476
+ const sweepAngle = resolveValue(getAttr(arc, "swAng") ?? "0", variables);
6477
+ if (widthRadius === 0 && heightRadius === 0 || sweepAngle === 0) return void 0;
6478
+ const startRadians = startAngle / 6e4 * (Math.PI / 180);
6479
+ const endRadians = (startAngle + sweepAngle) / 6e4 * (Math.PI / 180);
6480
+ const centerX = currentX - widthRadius * Math.cos(startRadians);
6481
+ const centerY = currentY - heightRadius * Math.sin(startRadians);
6482
+ const endX = centerX + widthRadius * Math.cos(endRadians);
6483
+ const endY = centerY + heightRadius * Math.sin(endRadians);
6484
+ const largeArcFlag = Math.abs(sweepAngle / 6e4) > 180 ? 1 : 0;
6485
+ const sweepFlag = sweepAngle > 0 ? 1 : 0;
6527
6486
  return {
6528
- threshold: (numericAttr(node, "thresh") ?? 5e4) / 1e5
6487
+ command: `A ${round4(widthRadius)} ${round4(heightRadius)} 0 ${largeArcFlag} ${sweepFlag} ${round4(endX)} ${round4(endY)}`,
6488
+ endX,
6489
+ endY
6529
6490
  };
6530
6491
  }
6531
- function parseBlurEffect(node) {
6532
- if (node === void 0) return void 0;
6492
+ function evaluateGuides(avGuides, guides, width, height) {
6493
+ const variables = createBuiltinVariables(width, height);
6494
+ for (const guide of avGuides) variables[guide.name] = evaluateFormula(guide.formula, variables);
6495
+ for (const guide of guides) variables[guide.name] = evaluateFormula(guide.formula, variables);
6496
+ return variables;
6497
+ }
6498
+ function createBuiltinVariables(width, height) {
6533
6499
  return {
6534
- radius: asEmu2(numericAttr(node, "rad") ?? 0),
6535
- grow: getAttr(node, "grow") !== "0"
6500
+ w: width,
6501
+ h: height,
6502
+ l: 0,
6503
+ t: 0,
6504
+ r: width,
6505
+ b: height,
6506
+ wd2: width / 2,
6507
+ hd2: height / 2,
6508
+ wd4: width / 4,
6509
+ hd4: height / 4,
6510
+ ss: Math.min(width, height),
6511
+ ls: Math.max(width, height),
6512
+ cd2: 108e5,
6513
+ cd4: 54e5,
6514
+ cd8: 27e5,
6515
+ "3cd4": 162e5
6536
6516
  };
6537
6517
  }
6538
- function parseLumEffect(node) {
6539
- if (node === void 0) return void 0;
6540
- return {
6541
- brightness: (numericAttr(node, "bright") ?? 0) / 1e5,
6542
- contrast: (numericAttr(node, "contrast") ?? 0) / 1e5
6518
+ function evaluateFormula(formula, variables) {
6519
+ const tokens = formula.trim().split(/\s+/);
6520
+ const op = tokens[0];
6521
+ const resolve2 = (token) => {
6522
+ if (token === void 0) return 0;
6523
+ const value = Number(token);
6524
+ return Number.isNaN(value) ? variables[token] ?? 0 : value;
6543
6525
  };
6526
+ if (op === "val") return resolve2(tokens[1]);
6527
+ if (op === "+-") return resolve2(tokens[1]) + resolve2(tokens[2]) - resolve2(tokens[3]);
6528
+ if (op === "*/")
6529
+ return Math.round(resolve2(tokens[1]) * resolve2(tokens[2]) / (resolve2(tokens[3]) || 1));
6530
+ if (op === "+/")
6531
+ return Math.round((resolve2(tokens[1]) + resolve2(tokens[2])) / (resolve2(tokens[3]) || 1));
6532
+ if (op === "pin")
6533
+ return Math.max(resolve2(tokens[1]), Math.min(resolve2(tokens[2]), resolve2(tokens[3])));
6534
+ if (op === "min") return Math.min(resolve2(tokens[1]), resolve2(tokens[2]));
6535
+ if (op === "max") return Math.max(resolve2(tokens[1]), resolve2(tokens[2]));
6536
+ if (op === "abs") return Math.abs(resolve2(tokens[1]));
6537
+ if (op === "sqrt") return Math.round(Math.sqrt(resolve2(tokens[1])));
6538
+ if (op === "sin") return Math.round(resolve2(tokens[1]) * Math.sin(toRadians(resolve2(tokens[2]))));
6539
+ if (op === "cos") return Math.round(resolve2(tokens[1]) * Math.cos(toRadians(resolve2(tokens[2]))));
6540
+ if (op === "tan") return Math.round(resolve2(tokens[1]) * Math.tan(toRadians(resolve2(tokens[2]))));
6541
+ if (op === "at2")
6542
+ return Math.round(Math.atan2(resolve2(tokens[2]), resolve2(tokens[1])) * (180 / Math.PI) * 6e4);
6543
+ if (op === "mod") {
6544
+ const a = resolve2(tokens[1]);
6545
+ const b = resolve2(tokens[2]);
6546
+ const c = resolve2(tokens[3]);
6547
+ return Math.round(Math.sqrt(a * a + b * b + c * c));
6548
+ }
6549
+ if (op === "cat2") {
6550
+ return Math.round(
6551
+ resolve2(tokens[1]) * Math.cos(Math.atan2(resolve2(tokens[3]), resolve2(tokens[2])))
6552
+ );
6553
+ }
6554
+ if (op === "sat2") {
6555
+ return Math.round(
6556
+ resolve2(tokens[1]) * Math.sin(Math.atan2(resolve2(tokens[3]), resolve2(tokens[2])))
6557
+ );
6558
+ }
6559
+ if (op === "?:") return resolve2(tokens[1]) > 0 ? resolve2(tokens[2]) : resolve2(tokens[3]);
6560
+ return 0;
6544
6561
  }
6545
- function parseDuotoneEffect(node) {
6546
- if (node === void 0) return void 0;
6547
- const colors = collectColorChildren(node);
6548
- if (colors.length < 2) return void 0;
6549
- return { color1: colors[0], color2: colors[1] };
6562
+ function resolveValue(value, variables) {
6563
+ const numeric = Number(value);
6564
+ return Number.isNaN(numeric) ? variables[value] ?? 0 : numeric;
6550
6565
  }
6551
- function parseColorChangeEffect(node) {
6552
- if (node === void 0) return void 0;
6553
- const from = firstColorChild(getChild(node, "clrFrom"));
6554
- const to = firstColorChild(getChild(node, "clrTo"));
6555
- return from !== void 0 && to !== void 0 ? { from, to } : void 0;
6566
+ function numericAttr(node, name) {
6567
+ const raw = getAttr(node, name);
6568
+ if (raw === void 0) return void 0;
6569
+ const value = Number(raw);
6570
+ return Number.isFinite(value) ? value : void 0;
6556
6571
  }
6557
- function collectColorChildren(parent) {
6558
- const colors = [];
6559
- for (const [key, value] of Object.entries(parent)) {
6560
- if (key.startsWith("@_")) continue;
6561
- const nodes = Array.isArray(value) ? value : [value];
6562
- for (const node of nodes) {
6563
- if (!isXmlNode(node)) continue;
6564
- const color = parseColorChild(key, node);
6565
- if (color !== void 0) colors.push(color);
6566
- }
6567
- }
6568
- return colors;
6572
+ function round4(value) {
6573
+ return Math.round(value * 1e3) / 1e3;
6569
6574
  }
6570
- function firstColorChild(parent) {
6571
- return parent !== void 0 ? collectColorChildren(parent)[0] : void 0;
6575
+ function toRadians(ooxmlAngle) {
6576
+ return ooxmlAngle / 6e4 * (Math.PI / 180);
6572
6577
  }
6573
- function parseColorChild(key, node) {
6574
- const name = localName(key);
6575
- return name === "prstClr" ? parsePresetColor(node) : parseColorElement({ [name]: node });
6578
+ function orderedChildChildren(parent, childLocalName) {
6579
+ const child = orderedChildEntries(parent, childLocalName)[0];
6580
+ return orderedNodeChildren(child);
6576
6581
  }
6577
- function isXmlNode(value) {
6578
- return typeof value === "object" && value !== null;
6582
+ function orderedChildEntries(parent, childLocalName) {
6583
+ if (parent === void 0) return [];
6584
+ return parent.filter((child) => {
6585
+ const key = orderedNodeKey(child);
6586
+ return key !== void 0 && localName(key) === childLocalName;
6587
+ });
6579
6588
  }
6580
- function parsePresetColor(node) {
6581
- const value = getAttr(node, "val");
6582
- const hex = value !== void 0 ? PRESET_COLOR_HEX[value] : void 0;
6583
- return hex !== void 0 ? withTransforms({ kind: "srgb", hex }, node) : void 0;
6589
+ function orderedNodeChildren(node) {
6590
+ const key = node !== void 0 ? orderedNodeKey(node) : void 0;
6591
+ const value = key !== void 0 ? node?.[key] : void 0;
6592
+ return Array.isArray(value) ? value : void 0;
6584
6593
  }
6585
- function parseFill(parent, nextId) {
6586
- if (!parent) return void 0;
6587
- const solid = getChild(parent, "solidFill");
6588
- if (solid) {
6589
- const color = parseColorElement(solid);
6590
- if (color) return { kind: "solid", color };
6591
- return { kind: "raw", raw: makeSidecar("a:solidFill", solid, nextId) };
6592
- }
6593
- if (hasChild(parent, "noFill")) return { kind: "none" };
6594
- const grad = getChild(parent, "gradFill");
6595
- if (grad) {
6596
- const fill = parseGradientFill(grad);
6594
+ function orderedNodeKey(node) {
6595
+ return Object.keys(node).find((key) => key !== ":@");
6596
+ }
6597
+ function parseEnumValue(value, allowed) {
6598
+ return value !== void 0 && allowed.has(unsafeOoxmlBoundaryAssertion(value)) ? unsafeOoxmlBoundaryAssertion(value) : void 0;
6599
+ }
6600
+ function parseEnumValueWithDefault(value, allowed, fallback) {
6601
+ return parseEnumValue(value, allowed) ?? fallback;
6602
+ }
6603
+ var RECTANGLE_ALIGNMENT_TOKENS = /* @__PURE__ */ new Set([
6604
+ "tl",
6605
+ "t",
6606
+ "tr",
6607
+ "l",
6608
+ "ctr",
6609
+ "r",
6610
+ "bl",
6611
+ "b",
6612
+ "br"
6613
+ ]);
6614
+ var COLOR_TRANSFORM_KINDS = /* @__PURE__ */ new Set([
6615
+ "lumMod",
6616
+ "lumOff",
6617
+ "tint",
6618
+ "shade",
6619
+ "alpha"
6620
+ ]);
6621
+ var RAW_FILL_LOCAL_NAMES = ["grpFill"];
6622
+ var PRESET_COLOR_HEX = {
6623
+ black: "000000",
6624
+ white: "FFFFFF",
6625
+ red: "FF0000",
6626
+ green: "008000",
6627
+ blue: "0000FF",
6628
+ yellow: "FFFF00",
6629
+ cyan: "00FFFF",
6630
+ magenta: "FF00FF"
6631
+ };
6632
+ function parseColorElement(parent) {
6633
+ if (!parent) return void 0;
6634
+ const srgb = getChild(parent, "srgbClr");
6635
+ if (srgb) {
6636
+ const hex = getAttr(srgb, "val");
6637
+ if (hex !== void 0) {
6638
+ return withTransforms({ kind: "srgb", hex: hex.toUpperCase() }, srgb);
6639
+ }
6640
+ }
6641
+ const scheme = getChild(parent, "schemeClr");
6642
+ if (scheme) {
6643
+ const name = getAttr(scheme, "val");
6644
+ if (name !== void 0) {
6645
+ return withTransforms({ kind: "scheme", scheme: name }, scheme);
6646
+ }
6647
+ }
6648
+ const sys = getChild(parent, "sysClr");
6649
+ if (sys) {
6650
+ const val = getAttr(sys, "val");
6651
+ if (val !== void 0) {
6652
+ const lastClr = getAttr(sys, "lastClr");
6653
+ return withTransforms(
6654
+ {
6655
+ kind: "system",
6656
+ value: val,
6657
+ ...lastClr !== void 0 ? { lastColor: lastClr.toUpperCase() } : {}
6658
+ },
6659
+ sys
6660
+ );
6661
+ }
6662
+ }
6663
+ return void 0;
6664
+ }
6665
+ function parseEffectList(effectList) {
6666
+ if (effectList === void 0) return void 0;
6667
+ const outerShadow = parseOuterShadow(getChild(effectList, "outerShdw"));
6668
+ const innerShadow = parseInnerShadow(getChild(effectList, "innerShdw"));
6669
+ const glow = parseGlow(getChild(effectList, "glow"));
6670
+ const softEdge = parseSoftEdge(getChild(effectList, "softEdge"));
6671
+ const parsed = {
6672
+ ...outerShadow !== void 0 ? { outerShadow } : {},
6673
+ ...innerShadow !== void 0 ? { innerShadow } : {},
6674
+ ...glow !== void 0 ? { glow } : {},
6675
+ ...softEdge !== void 0 ? { softEdge } : {}
6676
+ };
6677
+ return Object.keys(parsed).length > 0 ? parsed : void 0;
6678
+ }
6679
+ function parseBlipEffects(blip) {
6680
+ if (blip === void 0) return void 0;
6681
+ const grayscale = getChild(blip, "grayscl") !== void 0;
6682
+ const biLevel = parseBiLevel(getChild(blip, "biLevel"));
6683
+ const blur = parseBlurEffect(getChild(blip, "blur"));
6684
+ const lum = parseLumEffect(getChild(blip, "lum"));
6685
+ const duotone = parseDuotoneEffect(getChild(blip, "duotone"));
6686
+ const clrChange = parseColorChangeEffect(getChild(blip, "clrChange"));
6687
+ const parsed = {
6688
+ grayscale,
6689
+ ...biLevel !== void 0 ? { biLevel } : {},
6690
+ ...blur !== void 0 ? { blur } : {},
6691
+ ...lum !== void 0 ? { lum } : {},
6692
+ ...duotone !== void 0 ? { duotone } : {},
6693
+ ...clrChange !== void 0 ? { clrChange } : {}
6694
+ };
6695
+ return grayscale || biLevel !== void 0 || blur !== void 0 || lum !== void 0 || duotone !== void 0 || clrChange !== void 0 ? parsed : void 0;
6696
+ }
6697
+ function parseOuterShadow(node) {
6698
+ if (node === void 0) return void 0;
6699
+ const color = parseColorElement(node);
6700
+ if (color === void 0) return void 0;
6701
+ return {
6702
+ blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
6703
+ distance: asEmu2(numericAttr2(node, "dist") ?? 0),
6704
+ direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
6705
+ color,
6706
+ alignment: parseRectangleAlignment(getAttr(node, "algn"), "b"),
6707
+ rotateWithShape: getAttr(node, "rotWithShape") !== "0"
6708
+ };
6709
+ }
6710
+ function parseInnerShadow(node) {
6711
+ if (node === void 0) return void 0;
6712
+ const color = parseColorElement(node);
6713
+ if (color === void 0) return void 0;
6714
+ return {
6715
+ blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
6716
+ distance: asEmu2(numericAttr2(node, "dist") ?? 0),
6717
+ direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
6718
+ color
6719
+ };
6720
+ }
6721
+ function parseGlow(node) {
6722
+ if (node === void 0) return void 0;
6723
+ const color = parseColorElement(node);
6724
+ if (color === void 0) return void 0;
6725
+ return {
6726
+ radius: asEmu2(numericAttr2(node, "rad") ?? 0),
6727
+ color
6728
+ };
6729
+ }
6730
+ function parseSoftEdge(node) {
6731
+ if (node === void 0) return void 0;
6732
+ return {
6733
+ radius: asEmu2(numericAttr2(node, "rad") ?? 0)
6734
+ };
6735
+ }
6736
+ function parseBiLevel(node) {
6737
+ if (node === void 0) return void 0;
6738
+ return {
6739
+ threshold: (numericAttr2(node, "thresh") ?? 5e4) / 1e5
6740
+ };
6741
+ }
6742
+ function parseBlurEffect(node) {
6743
+ if (node === void 0) return void 0;
6744
+ return {
6745
+ radius: asEmu2(numericAttr2(node, "rad") ?? 0),
6746
+ grow: getAttr(node, "grow") !== "0"
6747
+ };
6748
+ }
6749
+ function parseLumEffect(node) {
6750
+ if (node === void 0) return void 0;
6751
+ return {
6752
+ brightness: (numericAttr2(node, "bright") ?? 0) / 1e5,
6753
+ contrast: (numericAttr2(node, "contrast") ?? 0) / 1e5
6754
+ };
6755
+ }
6756
+ function parseDuotoneEffect(node) {
6757
+ if (node === void 0) return void 0;
6758
+ const colors = collectColorChildren(node);
6759
+ if (colors.length < 2) return void 0;
6760
+ return { color1: colors[0], color2: colors[1] };
6761
+ }
6762
+ function parseColorChangeEffect(node) {
6763
+ if (node === void 0) return void 0;
6764
+ const from = firstColorChild(getChild(node, "clrFrom"));
6765
+ const to = firstColorChild(getChild(node, "clrTo"));
6766
+ return from !== void 0 && to !== void 0 ? { from, to } : void 0;
6767
+ }
6768
+ function collectColorChildren(parent) {
6769
+ const colors = [];
6770
+ for (const [key, value] of Object.entries(parent)) {
6771
+ if (key.startsWith("@_")) continue;
6772
+ const nodes = Array.isArray(value) ? value : [value];
6773
+ for (const node of nodes) {
6774
+ if (!isXmlNode(node)) continue;
6775
+ const color = parseColorChild(key, node);
6776
+ if (color !== void 0) colors.push(color);
6777
+ }
6778
+ }
6779
+ return colors;
6780
+ }
6781
+ function firstColorChild(parent) {
6782
+ return parent !== void 0 ? collectColorChildren(parent)[0] : void 0;
6783
+ }
6784
+ function parseColorChild(key, node) {
6785
+ const name = localName(key);
6786
+ return name === "prstClr" ? parsePresetColor(node) : parseColorElement({ [name]: node });
6787
+ }
6788
+ function isXmlNode(value) {
6789
+ return typeof value === "object" && value !== null;
6790
+ }
6791
+ function parsePresetColor(node) {
6792
+ const value = getAttr(node, "val");
6793
+ const hex = value !== void 0 ? PRESET_COLOR_HEX[value] : void 0;
6794
+ return hex !== void 0 ? withTransforms({ kind: "srgb", hex }, node) : void 0;
6795
+ }
6796
+ function parseFill(parent, nextId) {
6797
+ if (!parent) return void 0;
6798
+ const solid = getChild(parent, "solidFill");
6799
+ if (solid) {
6800
+ const color = parseColorElement(solid);
6801
+ if (color) return { kind: "solid", color };
6802
+ return { kind: "raw", raw: makeSidecar("a:solidFill", solid, nextId) };
6803
+ }
6804
+ if (hasChild(parent, "noFill")) return { kind: "none" };
6805
+ const grad = getChild(parent, "gradFill");
6806
+ if (grad) {
6807
+ const fill = parseGradientFill(grad);
6597
6808
  return fill ?? { kind: "raw", raw: makeSidecar("a:gradFill", grad, nextId) };
6598
6809
  }
6599
6810
  const blip = getChild(parent, "blipFill");
@@ -6618,7 +6829,7 @@ function parseGradientFill(grad) {
6618
6829
  const color = parseColorElement(gs);
6619
6830
  if (color === void 0) continue;
6620
6831
  stops.push({
6621
- position: (numericAttr(gs, "pos") ?? 0) / 1e5,
6832
+ position: (numericAttr2(gs, "pos") ?? 0) / 1e5,
6622
6833
  color
6623
6834
  });
6624
6835
  }
@@ -6626,10 +6837,10 @@ function parseGradientFill(grad) {
6626
6837
  const path = getChild(grad, "path");
6627
6838
  if (path !== void 0) {
6628
6839
  const fillToRect = getChild(path, "fillToRect");
6629
- const l = numericAttr(fillToRect, "l") ?? 0;
6630
- const t = numericAttr(fillToRect, "t") ?? 0;
6631
- const r = numericAttr(fillToRect, "r") ?? 0;
6632
- const b = numericAttr(fillToRect, "b") ?? 0;
6840
+ const l = numericAttr2(fillToRect, "l") ?? 0;
6841
+ const t = numericAttr2(fillToRect, "t") ?? 0;
6842
+ const r = numericAttr2(fillToRect, "r") ?? 0;
6843
+ const b = numericAttr2(fillToRect, "b") ?? 0;
6633
6844
  return {
6634
6845
  kind: "gradient",
6635
6846
  gradientType: "radial",
@@ -6642,7 +6853,7 @@ function parseGradientFill(grad) {
6642
6853
  kind: "gradient",
6643
6854
  gradientType: "linear",
6644
6855
  stops,
6645
- angle: asOoxmlAngle(numericAttr(getChild(grad, "lin"), "ang") ?? 0)
6856
+ angle: asOoxmlAngle(numericAttr2(getChild(grad, "lin"), "ang") ?? 0)
6646
6857
  };
6647
6858
  }
6648
6859
  function parseBlipFill(blipFill) {
@@ -6658,368 +6869,101 @@ function parseBlipFill(blipFill) {
6658
6869
  }
6659
6870
  function parseImageFillTile(tile) {
6660
6871
  if (tile === void 0) return void 0;
6661
- const flip = getAttr(tile, "flip") ?? "none";
6662
- return {
6663
- tx: asEmu2(numericAttr(tile, "tx") ?? 0),
6664
- ty: asEmu2(numericAttr(tile, "ty") ?? 0),
6665
- sx: (numericAttr(tile, "sx") ?? 1e5) / 1e5,
6666
- sy: (numericAttr(tile, "sy") ?? 1e5) / 1e5,
6667
- flip: flip === "x" || flip === "y" || flip === "xy" ? flip : "none",
6668
- align: parseRectangleAlignment(getAttr(tile, "algn"), "tl")
6669
- };
6670
- }
6671
- function parseRectangleAlignment(value, fallback) {
6672
- return parseEnumValueWithDefault(value, RECTANGLE_ALIGNMENT_TOKENS, fallback);
6673
- }
6674
- function parsePatternFill(pattern) {
6675
- const foregroundColor = parseColorElement(getChild(pattern, "fgClr"));
6676
- const backgroundColor = parseColorElement(getChild(pattern, "bgClr"));
6677
- if (foregroundColor === void 0 || backgroundColor === void 0) return void 0;
6678
- return {
6679
- kind: "pattern",
6680
- preset: getAttr(pattern, "prst") ?? "ltDnDiag",
6681
- foregroundColor,
6682
- backgroundColor
6683
- };
6684
- }
6685
- function parseOutline(spPr, nextId) {
6686
- const ln = getChild(spPr, "ln");
6687
- return parseLine(ln, nextId);
6688
- }
6689
- function parseLine(ln, nextId) {
6690
- if (!ln) return void 0;
6691
- const width = numericAttr(ln, "w");
6692
- const fill = parseFill(ln, nextId);
6693
- const dashStyle = parseDashStyle(getChild(ln, "prstDash"));
6694
- const customDash = parseCustomDash(ln);
6695
- const lineCap = parseLineCap(getAttr(ln, "cap"));
6696
- const lineJoin = parseLineJoin(ln);
6697
- const headEnd = parseArrowEndpoint(getChild(ln, "headEnd"));
6698
- const tailEnd = parseArrowEndpoint(getChild(ln, "tailEnd"));
6699
- return {
6700
- ...width !== void 0 ? { width: asEmu2(width) } : {},
6701
- ...fill !== void 0 ? { fill } : {},
6702
- ...dashStyle !== void 0 ? { dashStyle } : {},
6703
- ...customDash !== void 0 ? { customDash } : {},
6704
- ...lineCap !== void 0 ? { lineCap } : {},
6705
- ...lineJoin !== void 0 ? { lineJoin } : {},
6706
- ...headEnd !== void 0 ? { headEnd } : {},
6707
- ...tailEnd !== void 0 ? { tailEnd } : {}
6708
- };
6709
- }
6710
- function parseTransform(spPr) {
6711
- const xfrm = getChild(spPr, "xfrm");
6712
- if (!xfrm) return void 0;
6713
- const off = getChild(xfrm, "off");
6714
- const ext = getChild(xfrm, "ext");
6715
- const offsetX = numericAttr(off, "x");
6716
- const offsetY = numericAttr(off, "y");
6717
- const width = numericAttr(ext, "cx");
6718
- const height = numericAttr(ext, "cy");
6719
- if (offsetX === void 0 || offsetY === void 0 || width === void 0 || height === void 0) {
6720
- return void 0;
6721
- }
6722
- const rotation = numericAttr(xfrm, "rot");
6723
- const flipH = getAttr(xfrm, "flipH");
6724
- const flipV = getAttr(xfrm, "flipV");
6725
- return {
6726
- offsetX: asEmu2(offsetX),
6727
- offsetY: asEmu2(offsetY),
6728
- width: asEmu2(width),
6729
- height: asEmu2(height),
6730
- ...rotation !== void 0 ? { rotation: asOoxmlAngle(rotation) } : {},
6731
- ...isTrue(flipH) ? { flipHorizontal: true } : {},
6732
- ...isTrue(flipV) ? { flipVertical: true } : {}
6733
- };
6734
- }
6735
- function withTransforms(base, colorNode) {
6736
- const transforms = [];
6737
- for (const key of Object.keys(colorNode)) {
6738
- if (key.startsWith("@_")) continue;
6739
- const kind = localName(key);
6740
- const transformKind = parseEnumValue(kind, COLOR_TRANSFORM_KINDS);
6741
- if (transformKind === void 0) continue;
6742
- const value = colorNode[key];
6743
- const items = Array.isArray(value) ? value : [value];
6744
- for (const item of items) {
6745
- const raw = getAttr(unsafeOoxmlBoundaryAssertion(item), "val");
6746
- if (raw === void 0) continue;
6747
- const numeric = Number(raw);
6748
- if (!Number.isFinite(numeric)) continue;
6749
- transforms.push({
6750
- kind: transformKind,
6751
- value: asOoxmlPercent(numeric)
6752
- });
6753
- }
6754
- }
6755
- return transforms.length > 0 ? { ...base, transforms } : base;
6756
- }
6757
- function numericAttr(node, name) {
6758
- const raw = getAttr(node, name);
6759
- if (raw === void 0) return void 0;
6760
- const value = Number(raw);
6761
- return Number.isFinite(value) ? value : void 0;
6762
- }
6763
- function isTrue(value) {
6764
- return value === "1" || value === "true";
6765
- }
6766
- function parseDashStyle(prstDash) {
6767
- const value = getAttr(prstDash, "val");
6768
- return parseEnumValue(value, DASH_STYLES);
6769
- }
6770
- function parseCustomDash(ln) {
6771
- const custDash = getChild(ln, "custDash");
6772
- const segments = getChildArray(custDash, "ds");
6773
- if (segments.length === 0) return void 0;
6774
- return segments.flatMap((segment) => [
6775
- (numericAttr(segment, "d") ?? 1e5) / 1e5,
6776
- (numericAttr(segment, "sp") ?? 1e5) / 1e5
6777
- ]);
6778
- }
6779
- var LINE_CAP_MAP = {
6780
- flat: "butt",
6781
- sq: "square",
6782
- rnd: "round"
6783
- };
6784
- function parseLineCap(value) {
6785
- return value !== void 0 ? LINE_CAP_MAP[value] : void 0;
6786
- }
6787
- function parseLineJoin(ln) {
6788
- if (hasChild(ln, "round")) return "round";
6789
- if (hasChild(ln, "bevel")) return "bevel";
6790
- if (hasChild(ln, "miter")) return "miter";
6791
- return void 0;
6792
- }
6793
- function parseArrowEndpoint(node) {
6794
- if (!node) return void 0;
6795
- const type = parseEnumValue(getAttr(node, "type"), ARROW_TYPES2);
6796
- if (type === void 0) return void 0;
6797
- const width = getAttr(node, "w") ?? "med";
6798
- const length = getAttr(node, "len") ?? "med";
6799
- return {
6800
- type,
6801
- width: parseEnumValueWithDefault(width, ARROW_SIZES2, "med"),
6802
- length: parseEnumValueWithDefault(length, ARROW_SIZES2, "med")
6803
- };
6804
- }
6805
- var DASH_STYLES = /* @__PURE__ */ new Set([
6806
- "solid",
6807
- "dash",
6808
- "dot",
6809
- "dashDot",
6810
- "lgDash",
6811
- "lgDashDot",
6812
- "sysDash",
6813
- "sysDot"
6814
- ]);
6815
- var ARROW_TYPES2 = /* @__PURE__ */ new Set([
6816
- "triangle",
6817
- "stealth",
6818
- "diamond",
6819
- "oval",
6820
- "arrow"
6821
- ]);
6822
- var ARROW_SIZES2 = /* @__PURE__ */ new Set(["sm", "med", "lg"]);
6823
- function parseCustomGeometry(custGeom, orderedCustGeom) {
6824
- const pathLst = getChild(custGeom, "pathLst");
6825
- const paths = getChildArray(pathLst, "path");
6826
- if (paths.length === 0) return void 0;
6827
- const avGuides = parseGuideList(getChild(custGeom, "avLst"));
6828
- const guides = parseGuideList(getChild(custGeom, "gdLst"));
6829
- const orderedPaths = orderedChildEntries(
6830
- orderedChildChildren(orderedCustGeom, "pathLst"),
6831
- "path"
6832
- );
6833
- const result = [];
6834
- for (const [index, path] of paths.entries()) {
6835
- const width = numericAttr2(path, "w") ?? 0;
6836
- const height = numericAttr2(path, "h") ?? 0;
6837
- if (width === 0 && height === 0) continue;
6838
- const variables = evaluateGuides(avGuides, guides, width, height);
6839
- const commands = buildPathCommands(path, variables, orderedNodeChildren(orderedPaths[index]));
6840
- if (commands !== void 0) result.push({ width, height, commands });
6841
- }
6842
- return result.length > 0 ? result : void 0;
6843
- }
6844
- function parseGuideList(parent) {
6845
- return getChildArray(parent, "gd").map((guide) => ({
6846
- name: getAttr(guide, "name") ?? "",
6847
- formula: getAttr(guide, "fmla") ?? ""
6848
- })).filter((guide) => guide.name !== "" && guide.formula !== "");
6849
- }
6850
- function buildPathCommands(path, variables, orderedCommands) {
6851
- const parts = [];
6852
- let currentX = 0;
6853
- let currentY = 0;
6854
- let startX = 0;
6855
- let startY = 0;
6856
- for (const { local, nodes } of pathCommandNodes(path, orderedCommands)) {
6857
- for (const node of nodes) {
6858
- if (local === "moveTo") {
6859
- const point = firstPoint(node, variables);
6860
- if (point !== void 0) {
6861
- parts.push(`M ${point.x} ${point.y}`);
6862
- currentX = point.x;
6863
- currentY = point.y;
6864
- startX = point.x;
6865
- startY = point.y;
6866
- }
6867
- } else if (local === "lnTo") {
6868
- const point = firstPoint(node, variables);
6869
- if (point !== void 0) {
6870
- parts.push(`L ${point.x} ${point.y}`);
6871
- currentX = point.x;
6872
- currentY = point.y;
6873
- }
6874
- } else if (local === "cubicBezTo") {
6875
- const points = allPoints(node, variables);
6876
- if (points.length >= 3) {
6877
- parts.push(`C ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
6878
- currentX = points[points.length - 1].x;
6879
- currentY = points[points.length - 1].y;
6880
- }
6881
- } else if (local === "quadBezTo") {
6882
- const points = allPoints(node, variables);
6883
- if (points.length >= 2) {
6884
- parts.push(`Q ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
6885
- currentX = points[points.length - 1].x;
6886
- currentY = points[points.length - 1].y;
6887
- }
6888
- } else if (local === "arcTo") {
6889
- const arc = convertArcTo(node, currentX, currentY, variables);
6890
- if (arc !== void 0) {
6891
- parts.push(arc.command);
6892
- currentX = arc.endX;
6893
- currentY = arc.endY;
6894
- }
6895
- } else if (local === "close") {
6896
- parts.push("Z");
6897
- currentX = startX;
6898
- currentY = startY;
6899
- }
6900
- }
6901
- }
6902
- return parts.length > 0 ? parts.join(" ") : void 0;
6903
- }
6904
- function pathCommandNodes(path, orderedCommands) {
6905
- if (orderedCommands === void 0) {
6906
- return Object.keys(path).filter((key) => !key.startsWith("@_")).map((key) => ({ local: localName(key), nodes: getChildArray(path, localName(key)) }));
6907
- }
6908
- const counters = {};
6909
- const result = [];
6910
- for (const command of orderedCommands) {
6911
- const key = orderedNodeKey(command);
6912
- if (key === void 0) continue;
6913
- const local = localName(key);
6914
- const index = counters[local] ?? 0;
6915
- counters[local] = index + 1;
6916
- const node = getChildArray(path, local)[index];
6917
- if (node !== void 0) result.push({ local, nodes: [node] });
6918
- }
6919
- return result;
6920
- }
6921
- function firstPoint(node, variables) {
6922
- return allPoints(node, variables)[0];
6923
- }
6924
- function allPoints(node, variables) {
6925
- return getChildArray(node, "pt").map((point) => ({
6926
- x: resolveValue(getAttr(point, "x") ?? "0", variables),
6927
- y: resolveValue(getAttr(point, "y") ?? "0", variables)
6928
- }));
6929
- }
6930
- function convertArcTo(arc, currentX, currentY, variables) {
6931
- const widthRadius = resolveValue(getAttr(arc, "wR") ?? "0", variables);
6932
- const heightRadius = resolveValue(getAttr(arc, "hR") ?? "0", variables);
6933
- const startAngle = resolveValue(getAttr(arc, "stAng") ?? "0", variables);
6934
- const sweepAngle = resolveValue(getAttr(arc, "swAng") ?? "0", variables);
6935
- if (widthRadius === 0 && heightRadius === 0 || sweepAngle === 0) return void 0;
6936
- const startRadians = startAngle / 6e4 * (Math.PI / 180);
6937
- const endRadians = (startAngle + sweepAngle) / 6e4 * (Math.PI / 180);
6938
- const centerX = currentX - widthRadius * Math.cos(startRadians);
6939
- const centerY = currentY - heightRadius * Math.sin(startRadians);
6940
- const endX = centerX + widthRadius * Math.cos(endRadians);
6941
- const endY = centerY + heightRadius * Math.sin(endRadians);
6942
- const largeArcFlag = Math.abs(sweepAngle / 6e4) > 180 ? 1 : 0;
6943
- const sweepFlag = sweepAngle > 0 ? 1 : 0;
6872
+ const flip = getAttr(tile, "flip") ?? "none";
6944
6873
  return {
6945
- command: `A ${round4(widthRadius)} ${round4(heightRadius)} 0 ${largeArcFlag} ${sweepFlag} ${round4(endX)} ${round4(endY)}`,
6946
- endX,
6947
- endY
6874
+ tx: asEmu2(numericAttr2(tile, "tx") ?? 0),
6875
+ ty: asEmu2(numericAttr2(tile, "ty") ?? 0),
6876
+ sx: (numericAttr2(tile, "sx") ?? 1e5) / 1e5,
6877
+ sy: (numericAttr2(tile, "sy") ?? 1e5) / 1e5,
6878
+ flip: flip === "x" || flip === "y" || flip === "xy" ? flip : "none",
6879
+ align: parseRectangleAlignment(getAttr(tile, "algn"), "tl")
6948
6880
  };
6949
6881
  }
6950
- function evaluateGuides(avGuides, guides, width, height) {
6951
- const variables = createBuiltinVariables(width, height);
6952
- for (const guide of avGuides) variables[guide.name] = evaluateFormula(guide.formula, variables);
6953
- for (const guide of guides) variables[guide.name] = evaluateFormula(guide.formula, variables);
6954
- return variables;
6882
+ function parseRectangleAlignment(value, fallback) {
6883
+ return parseEnumValueWithDefault(value, RECTANGLE_ALIGNMENT_TOKENS, fallback);
6955
6884
  }
6956
- function createBuiltinVariables(width, height) {
6885
+ function parsePatternFill(pattern) {
6886
+ const foregroundColor = parseColorElement(getChild(pattern, "fgClr"));
6887
+ const backgroundColor = parseColorElement(getChild(pattern, "bgClr"));
6888
+ if (foregroundColor === void 0 || backgroundColor === void 0) return void 0;
6957
6889
  return {
6958
- w: width,
6959
- h: height,
6960
- l: 0,
6961
- t: 0,
6962
- r: width,
6963
- b: height,
6964
- wd2: width / 2,
6965
- hd2: height / 2,
6966
- wd4: width / 4,
6967
- hd4: height / 4,
6968
- ss: Math.min(width, height),
6969
- ls: Math.max(width, height),
6970
- cd2: 108e5,
6971
- cd4: 54e5,
6972
- cd8: 27e5,
6973
- "3cd4": 162e5
6890
+ kind: "pattern",
6891
+ preset: getAttr(pattern, "prst") ?? "ltDnDiag",
6892
+ foregroundColor,
6893
+ backgroundColor
6974
6894
  };
6975
6895
  }
6976
- function evaluateFormula(formula, variables) {
6977
- const tokens = formula.trim().split(/\s+/);
6978
- const op = tokens[0];
6979
- const resolve2 = (token) => {
6980
- if (token === void 0) return 0;
6981
- const value = Number(token);
6982
- return Number.isNaN(value) ? variables[token] ?? 0 : value;
6896
+ function parseOutline(spPr, nextId) {
6897
+ const ln = getChild(spPr, "ln");
6898
+ return parseLine(ln, nextId);
6899
+ }
6900
+ function parseLine(ln, nextId) {
6901
+ if (!ln) return void 0;
6902
+ const width = numericAttr2(ln, "w");
6903
+ const fill = parseFill(ln, nextId);
6904
+ const dashStyle = parseDashStyle(getChild(ln, "prstDash"));
6905
+ const customDash = parseCustomDash(ln);
6906
+ const lineCap = parseLineCap(getAttr(ln, "cap"));
6907
+ const lineJoin = parseLineJoin(ln);
6908
+ const headEnd = parseArrowEndpoint(getChild(ln, "headEnd"));
6909
+ const tailEnd = parseArrowEndpoint(getChild(ln, "tailEnd"));
6910
+ return {
6911
+ ...width !== void 0 ? { width: asEmu2(width) } : {},
6912
+ ...fill !== void 0 ? { fill } : {},
6913
+ ...dashStyle !== void 0 ? { dashStyle } : {},
6914
+ ...customDash !== void 0 ? { customDash } : {},
6915
+ ...lineCap !== void 0 ? { lineCap } : {},
6916
+ ...lineJoin !== void 0 ? { lineJoin } : {},
6917
+ ...headEnd !== void 0 ? { headEnd } : {},
6918
+ ...tailEnd !== void 0 ? { tailEnd } : {}
6983
6919
  };
6984
- if (op === "val") return resolve2(tokens[1]);
6985
- if (op === "+-") return resolve2(tokens[1]) + resolve2(tokens[2]) - resolve2(tokens[3]);
6986
- if (op === "*/")
6987
- return Math.round(resolve2(tokens[1]) * resolve2(tokens[2]) / (resolve2(tokens[3]) || 1));
6988
- if (op === "+/")
6989
- return Math.round((resolve2(tokens[1]) + resolve2(tokens[2])) / (resolve2(tokens[3]) || 1));
6990
- if (op === "pin")
6991
- return Math.max(resolve2(tokens[1]), Math.min(resolve2(tokens[2]), resolve2(tokens[3])));
6992
- if (op === "min") return Math.min(resolve2(tokens[1]), resolve2(tokens[2]));
6993
- if (op === "max") return Math.max(resolve2(tokens[1]), resolve2(tokens[2]));
6994
- if (op === "abs") return Math.abs(resolve2(tokens[1]));
6995
- if (op === "sqrt") return Math.round(Math.sqrt(resolve2(tokens[1])));
6996
- if (op === "sin") return Math.round(resolve2(tokens[1]) * Math.sin(toRadians(resolve2(tokens[2]))));
6997
- if (op === "cos") return Math.round(resolve2(tokens[1]) * Math.cos(toRadians(resolve2(tokens[2]))));
6998
- if (op === "tan") return Math.round(resolve2(tokens[1]) * Math.tan(toRadians(resolve2(tokens[2]))));
6999
- if (op === "at2")
7000
- return Math.round(Math.atan2(resolve2(tokens[2]), resolve2(tokens[1])) * (180 / Math.PI) * 6e4);
7001
- if (op === "mod") {
7002
- const a = resolve2(tokens[1]);
7003
- const b = resolve2(tokens[2]);
7004
- const c = resolve2(tokens[3]);
7005
- return Math.round(Math.sqrt(a * a + b * b + c * c));
7006
- }
7007
- if (op === "cat2") {
7008
- return Math.round(
7009
- resolve2(tokens[1]) * Math.cos(Math.atan2(resolve2(tokens[3]), resolve2(tokens[2])))
7010
- );
7011
- }
7012
- if (op === "sat2") {
7013
- return Math.round(
7014
- resolve2(tokens[1]) * Math.sin(Math.atan2(resolve2(tokens[3]), resolve2(tokens[2])))
7015
- );
6920
+ }
6921
+ function parseTransform(spPr) {
6922
+ const xfrm = getChild(spPr, "xfrm");
6923
+ if (!xfrm) return void 0;
6924
+ const off = getChild(xfrm, "off");
6925
+ const ext = getChild(xfrm, "ext");
6926
+ const offsetX = numericAttr2(off, "x");
6927
+ const offsetY = numericAttr2(off, "y");
6928
+ const width = numericAttr2(ext, "cx");
6929
+ const height = numericAttr2(ext, "cy");
6930
+ if (offsetX === void 0 || offsetY === void 0 || width === void 0 || height === void 0) {
6931
+ return void 0;
7016
6932
  }
7017
- if (op === "?:") return resolve2(tokens[1]) > 0 ? resolve2(tokens[2]) : resolve2(tokens[3]);
7018
- return 0;
6933
+ const rotation = numericAttr2(xfrm, "rot");
6934
+ const flipH = getAttr(xfrm, "flipH");
6935
+ const flipV = getAttr(xfrm, "flipV");
6936
+ return {
6937
+ offsetX: asEmu2(offsetX),
6938
+ offsetY: asEmu2(offsetY),
6939
+ width: asEmu2(width),
6940
+ height: asEmu2(height),
6941
+ ...rotation !== void 0 ? { rotation: asOoxmlAngle(rotation) } : {},
6942
+ ...isTrue(flipH) ? { flipHorizontal: true } : {},
6943
+ ...isTrue(flipV) ? { flipVertical: true } : {}
6944
+ };
7019
6945
  }
7020
- function resolveValue(value, variables) {
7021
- const numeric = Number(value);
7022
- return Number.isNaN(numeric) ? variables[value] ?? 0 : numeric;
6946
+ function withTransforms(base, colorNode) {
6947
+ const transforms = [];
6948
+ for (const key of Object.keys(colorNode)) {
6949
+ if (key.startsWith("@_")) continue;
6950
+ const kind = localName(key);
6951
+ const transformKind = parseEnumValue(kind, COLOR_TRANSFORM_KINDS);
6952
+ if (transformKind === void 0) continue;
6953
+ const value = colorNode[key];
6954
+ const items = Array.isArray(value) ? value : [value];
6955
+ for (const item of items) {
6956
+ const raw = getAttr(unsafeOoxmlBoundaryAssertion(item), "val");
6957
+ if (raw === void 0) continue;
6958
+ const numeric = Number(raw);
6959
+ if (!Number.isFinite(numeric)) continue;
6960
+ transforms.push({
6961
+ kind: transformKind,
6962
+ value: asOoxmlPercent(numeric)
6963
+ });
6964
+ }
6965
+ }
6966
+ return transforms.length > 0 ? { ...base, transforms } : base;
7023
6967
  }
7024
6968
  function numericAttr2(node, name) {
7025
6969
  const raw = getAttr(node, name);
@@ -7027,31 +6971,66 @@ function numericAttr2(node, name) {
7027
6971
  const value = Number(raw);
7028
6972
  return Number.isFinite(value) ? value : void 0;
7029
6973
  }
7030
- function round4(value) {
7031
- return Math.round(value * 1e3) / 1e3;
6974
+ function isTrue(value) {
6975
+ return value === "1" || value === "true";
7032
6976
  }
7033
- function toRadians(ooxmlAngle) {
7034
- return ooxmlAngle / 6e4 * (Math.PI / 180);
6977
+ function parseDashStyle(prstDash) {
6978
+ const value = getAttr(prstDash, "val");
6979
+ return parseEnumValue(value, DASH_STYLES);
7035
6980
  }
7036
- function orderedChildChildren(parent, childLocalName) {
7037
- const child = orderedChildEntries(parent, childLocalName)[0];
7038
- return orderedNodeChildren(child);
6981
+ function parseCustomDash(ln) {
6982
+ const custDash = getChild(ln, "custDash");
6983
+ const segments = getChildArray(custDash, "ds");
6984
+ if (segments.length === 0) return void 0;
6985
+ return segments.flatMap((segment) => [
6986
+ (numericAttr2(segment, "d") ?? 1e5) / 1e5,
6987
+ (numericAttr2(segment, "sp") ?? 1e5) / 1e5
6988
+ ]);
7039
6989
  }
7040
- function orderedChildEntries(parent, childLocalName) {
7041
- if (parent === void 0) return [];
7042
- return parent.filter((child) => {
7043
- const key = orderedNodeKey(child);
7044
- return key !== void 0 && localName(key) === childLocalName;
7045
- });
6990
+ var LINE_CAP_MAP = {
6991
+ flat: "butt",
6992
+ sq: "square",
6993
+ rnd: "round"
6994
+ };
6995
+ function parseLineCap(value) {
6996
+ return value !== void 0 ? LINE_CAP_MAP[value] : void 0;
7046
6997
  }
7047
- function orderedNodeChildren(node) {
7048
- const key = node !== void 0 ? orderedNodeKey(node) : void 0;
7049
- const value = key !== void 0 ? node?.[key] : void 0;
7050
- return Array.isArray(value) ? value : void 0;
6998
+ function parseLineJoin(ln) {
6999
+ if (hasChild(ln, "round")) return "round";
7000
+ if (hasChild(ln, "bevel")) return "bevel";
7001
+ if (hasChild(ln, "miter")) return "miter";
7002
+ return void 0;
7051
7003
  }
7052
- function orderedNodeKey(node) {
7053
- return Object.keys(node).find((key) => key !== ":@");
7004
+ function parseArrowEndpoint(node) {
7005
+ if (!node) return void 0;
7006
+ const type = parseEnumValue(getAttr(node, "type"), ARROW_TYPES);
7007
+ if (type === void 0) return void 0;
7008
+ const width = getAttr(node, "w") ?? "med";
7009
+ const length = getAttr(node, "len") ?? "med";
7010
+ return {
7011
+ type,
7012
+ width: parseEnumValueWithDefault(width, ARROW_SIZES, "med"),
7013
+ length: parseEnumValueWithDefault(length, ARROW_SIZES, "med")
7014
+ };
7054
7015
  }
7016
+ var DASH_STYLES = /* @__PURE__ */ new Set([
7017
+ "solid",
7018
+ "dash",
7019
+ "dot",
7020
+ "dashDot",
7021
+ "lgDash",
7022
+ "lgDashDot",
7023
+ "sysDash",
7024
+ "sysDot"
7025
+ ]);
7026
+ var ARROW_TYPES = /* @__PURE__ */ new Set([
7027
+ "triangle",
7028
+ "stealth",
7029
+ "diamond",
7030
+ "oval",
7031
+ "arrow"
7032
+ ]);
7033
+ var ARROW_SIZES = /* @__PURE__ */ new Set(["sm", "med", "lg"]);
7055
7034
  var KNOWN_TXBODY_CHILDREN = /* @__PURE__ */ new Set(["bodyPr", "lstStyle", "p"]);
7056
7035
  var KNOWN_PARAGRAPH_CHILDREN = /* @__PURE__ */ new Set([
7057
7036
  "pPr",
@@ -7273,20 +7252,20 @@ function splitInterleavedParagraph(p, orderedChildren, partPath, nextId, ownerNo
7273
7252
  }
7274
7253
  function parseBodyProperties(bodyPr) {
7275
7254
  if (!bodyPr) return void 0;
7276
- const marginLeft = numericAttr(bodyPr, "lIns");
7277
- const marginRight = numericAttr(bodyPr, "rIns");
7278
- const marginTop = numericAttr(bodyPr, "tIns");
7279
- const marginBottom = numericAttr(bodyPr, "bIns");
7255
+ const marginLeft = numericAttr2(bodyPr, "lIns");
7256
+ const marginRight = numericAttr2(bodyPr, "rIns");
7257
+ const marginTop = numericAttr2(bodyPr, "tIns");
7258
+ const marginBottom = numericAttr2(bodyPr, "bIns");
7280
7259
  const anchorToken = getAttr(bodyPr, "anchor");
7281
7260
  const anchor = anchorToken !== void 0 ? ANCHOR_MAP[anchorToken] : void 0;
7282
7261
  const wrap = parseWrap(getAttr(bodyPr, "wrap"));
7283
7262
  const vert = parseVerticalType(getAttr(bodyPr, "vert"));
7284
- const numCol = numericAttr(bodyPr, "numCol");
7263
+ const numCol = numericAttr2(bodyPr, "numCol");
7285
7264
  const normAutofit = getChild(bodyPr, "normAutofit");
7286
7265
  const hasSpAutofit = getChild(bodyPr, "spAutoFit") !== void 0;
7287
7266
  const hasNoAutofit = getChild(bodyPr, "noAutofit") !== void 0;
7288
- const fontScale = numericAttr(normAutofit, "fontScale");
7289
- const lnSpcReduction = numericAttr(normAutofit, "lnSpcReduction");
7267
+ const fontScale = numericAttr2(normAutofit, "fontScale");
7268
+ const lnSpcReduction = numericAttr2(normAutofit, "lnSpcReduction");
7290
7269
  const properties = {
7291
7270
  ...marginLeft !== void 0 ? { marginLeft: emu(marginLeft) } : {},
7292
7271
  ...marginRight !== void 0 ? { marginRight: emu(marginRight) } : {},
@@ -7418,16 +7397,16 @@ function parseParagraphProperties(pPr) {
7418
7397
  if (!pPr) return void 0;
7419
7398
  const alignToken = getAttr(pPr, "algn");
7420
7399
  const align = alignToken !== void 0 ? ALIGN_MAP[alignToken] : void 0;
7421
- const level = numericAttr(pPr, "lvl");
7400
+ const level = numericAttr2(pPr, "lvl");
7422
7401
  const lineSpacing = parseSpacing(getChild(pPr, "lnSpc"));
7423
7402
  const spaceBefore = parseSpacing(getChild(pPr, "spcBef"));
7424
7403
  const spaceAfter = parseSpacing(getChild(pPr, "spcAft"));
7425
- const marginLeft = numericAttr(pPr, "marL");
7426
- const indent = numericAttr(pPr, "indent");
7404
+ const marginLeft = numericAttr2(pPr, "marL");
7405
+ const indent = numericAttr2(pPr, "indent");
7427
7406
  const bullet = parseBullet(pPr);
7428
7407
  const bulletFont = getAttr(getChild(pPr, "buFont"), "typeface");
7429
7408
  const bulletColor = parseColorElement(getChild(pPr, "buClr"));
7430
- const bulletSizePct = numericAttr(getChild(pPr, "buSzPct"), "val");
7409
+ const bulletSizePct = numericAttr2(getChild(pPr, "buSzPct"), "val");
7431
7410
  const tabStops = parseTabStops(pPr);
7432
7411
  const defaultRunProperties = parseRunProperties(getChild(pPr, "defRPr"));
7433
7412
  const properties = {
@@ -7449,14 +7428,14 @@ function parseParagraphProperties(pPr) {
7449
7428
  }
7450
7429
  function parseTabStops(pPr) {
7451
7430
  return getChildArray(getChild(pPr, "tabLst"), "tab").map((tab) => ({
7452
- position: emu(numericAttr(tab, "pos") ?? 0),
7431
+ position: emu(numericAttr2(tab, "pos") ?? 0),
7453
7432
  alignment: unsafeOoxmlBoundaryAssertion(getAttr(tab, "algn")) ?? "l"
7454
7433
  }));
7455
7434
  }
7456
7435
  function parseSpacing(node) {
7457
- const points = numericAttr(getChild(node, "spcPts"), "val");
7436
+ const points = numericAttr2(getChild(node, "spcPts"), "val");
7458
7437
  if (points !== void 0) return { type: "pts", value: asHundredthPt2(points) };
7459
- const percent = numericAttr(getChild(node, "spcPct"), "val");
7438
+ const percent = numericAttr2(getChild(node, "spcPct"), "val");
7460
7439
  if (percent !== void 0) return { type: "pct", value: percent };
7461
7440
  return void 0;
7462
7441
  }
@@ -7473,7 +7452,7 @@ function parseBullet(pPr) {
7473
7452
  return {
7474
7453
  type: "autoNum",
7475
7454
  scheme: parseEnumValueWithDefault(scheme, VALID_AUTO_NUM_SCHEMES, "arabicPeriod"),
7476
- startAt: numericAttr(buAutoNum, "startAt") ?? 1
7455
+ startAt: numericAttr2(buAutoNum, "startAt") ?? 1
7477
7456
  };
7478
7457
  }
7479
7458
  return void 0;
@@ -7518,8 +7497,8 @@ function parseRunProperties(rPr) {
7518
7497
  const italic = getAttr(rPr, "i");
7519
7498
  const underline = getAttr(rPr, "u");
7520
7499
  const strike = getAttr(rPr, "strike");
7521
- const baseline = numericAttr(rPr, "baseline");
7522
- const size = numericAttr(rPr, "sz");
7500
+ const baseline = numericAttr2(rPr, "baseline");
7501
+ const size = numericAttr2(rPr, "sz");
7523
7502
  const typeface = getAttr(getChild(rPr, "latin"), "typeface");
7524
7503
  const typefaceEa = getAttr(getChild(rPr, "ea"), "typeface");
7525
7504
  const typefaceCs = getAttr(getChild(rPr, "cs"), "typeface");
@@ -7797,7 +7776,7 @@ function parseConnectorConnection(cNvCxnSpPr) {
7797
7776
  }
7798
7777
  function parseConnectorConnectionEndpoint(node) {
7799
7778
  const shapeId = getAttr(node, "id");
7800
- const connectionSiteIndex = numericAttr(node, "idx");
7779
+ const connectionSiteIndex = numericAttr2(node, "idx");
7801
7780
  if (shapeId === void 0 || connectionSiteIndex === void 0) return void 0;
7802
7781
  return {
7803
7782
  shapeId: asSourceNodeId(shapeId),
@@ -7818,7 +7797,7 @@ function parseShapeStyle(style) {
7818
7797
  }
7819
7798
  function parseStyleReference(ref) {
7820
7799
  if (ref === void 0) return void 0;
7821
- const index = numericAttr(ref, "idx") ?? 0;
7800
+ const index = numericAttr2(ref, "idx") ?? 0;
7822
7801
  const color = parseColorElement(ref);
7823
7802
  return {
7824
7803
  index,
@@ -8153,8 +8132,8 @@ function parseTableCell(tc, partPath, nextId, tableNodeId, tableOrderingSlot, ro
8153
8132
  ...textBody !== void 0 ? { textBody } : {},
8154
8133
  ...fill !== void 0 ? { fill } : {},
8155
8134
  ...borders !== void 0 ? { borders } : {},
8156
- gridSpan: numericAttr(tc, "gridSpan") ?? 1,
8157
- rowSpan: numericAttr(tc, "rowSpan") ?? 1,
8135
+ gridSpan: numericAttr2(tc, "gridSpan") ?? 1,
8136
+ rowSpan: numericAttr2(tc, "rowSpan") ?? 1,
8158
8137
  hMerge: isTrue(getAttr(tc, "hMerge") ?? getAttr(tcPr, "hMerge")),
8159
8138
  vMerge: isTrue(getAttr(tc, "vMerge") ?? getAttr(tcPr, "vMerge")),
8160
8139
  ...rawSidecars.length > 0 ? { rawSidecars } : {}
@@ -8187,7 +8166,7 @@ function parseRawShapeNode(key, node, partPath, nextId, orderingSlot) {
8187
8166
  function parsePlaceholder(ph) {
8188
8167
  if (!ph) return void 0;
8189
8168
  const type = getAttr(ph, "type");
8190
- const index = numericAttr(ph, "idx");
8169
+ const index = numericAttr2(ph, "idx");
8191
8170
  if (type === void 0 && index === void 0) return void 0;
8192
8171
  return {
8193
8172
  ...type !== void 0 ? { type } : {},
@@ -8227,10 +8206,10 @@ function parseChildTransform(grpSpPr, fallback) {
8227
8206
  const xfrm = getChild(grpSpPr, "xfrm");
8228
8207
  const childOff = getChild(xfrm, "chOff");
8229
8208
  const childExt = getChild(xfrm, "chExt");
8230
- const offsetX = numericAttr(childOff, "x") ?? 0;
8231
- const offsetY = numericAttr(childOff, "y") ?? 0;
8232
- const width = numericAttr(childExt, "cx") ?? fallback?.width;
8233
- const height = numericAttr(childExt, "cy") ?? fallback?.height;
8209
+ const offsetX = numericAttr2(childOff, "x") ?? 0;
8210
+ const offsetY = numericAttr2(childOff, "y") ?? 0;
8211
+ const width = numericAttr2(childExt, "cx") ?? fallback?.width;
8212
+ const height = numericAttr2(childExt, "cy") ?? fallback?.height;
8234
8213
  if (width === void 0 || height === void 0) return void 0;
8235
8214
  return {
8236
8215
  offsetX: asEmu2(offsetX),
@@ -8241,10 +8220,10 @@ function parseChildTransform(grpSpPr, fallback) {
8241
8220
  }
8242
8221
  function parseCrop(srcRect) {
8243
8222
  if (!srcRect) return void 0;
8244
- const left = numericAttr(srcRect, "l");
8245
- const top = numericAttr(srcRect, "t");
8246
- const right = numericAttr(srcRect, "r");
8247
- const bottom = numericAttr(srcRect, "b");
8223
+ const left = numericAttr2(srcRect, "l");
8224
+ const top = numericAttr2(srcRect, "t");
8225
+ const right = numericAttr2(srcRect, "r");
8226
+ const bottom = numericAttr2(srcRect, "b");
8248
8227
  const crop = {
8249
8228
  ...left !== void 0 ? { left: asOoxmlPercent(left) } : {},
8250
8229
  ...top !== void 0 ? { top: asOoxmlPercent(top) } : {},
@@ -8256,10 +8235,10 @@ function parseCrop(srcRect) {
8256
8235
  function parseStretch(stretch) {
8257
8236
  const fillRect = getChild(stretch, "fillRect");
8258
8237
  if (fillRect === void 0) return void 0;
8259
- const left = (numericAttr(fillRect, "l") ?? 0) / 1e5;
8260
- const top = (numericAttr(fillRect, "t") ?? 0) / 1e5;
8261
- const right = (numericAttr(fillRect, "r") ?? 0) / 1e5;
8262
- const bottom = (numericAttr(fillRect, "b") ?? 0) / 1e5;
8238
+ const left = (numericAttr2(fillRect, "l") ?? 0) / 1e5;
8239
+ const top = (numericAttr2(fillRect, "t") ?? 0) / 1e5;
8240
+ const right = (numericAttr2(fillRect, "r") ?? 0) / 1e5;
8241
+ const bottom = (numericAttr2(fillRect, "b") ?? 0) / 1e5;
8263
8242
  if (left === 0 && top === 0 && right === 0 && bottom === 0) return void 0;
8264
8243
  return { left, top, right, bottom };
8265
8244
  }
@@ -8268,7 +8247,7 @@ function sourceNodeId(cNvPr) {
8268
8247
  return id !== void 0 ? asSourceNodeId(id) : void 0;
8269
8248
  }
8270
8249
  function emuAttr(node, attrName) {
8271
- return asEmu2(numericAttr(node, attrName) ?? 0);
8250
+ return asEmu2(numericAttr2(node, attrName) ?? 0);
8272
8251
  }
8273
8252
  var EMPTY_KNOWN = /* @__PURE__ */ new Set();
8274
8253
  function orderedChildChildren2(parent, childLocalName) {
@@ -8300,6 +8279,75 @@ function orderedNestedChildChildren(node, parentLocalName, childLocalName) {
8300
8279
  childLocalName
8301
8280
  );
8302
8281
  }
8282
+ var xmlBuilder = new import_fast_xml_parser2.XMLBuilder({
8283
+ ignoreAttributes: false,
8284
+ attributeNamePrefix: "@_",
8285
+ format: false,
8286
+ suppressEmptyNode: true
8287
+ });
8288
+ var EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS = {
8289
+ bold: (value) => requireBooleanOrUndefined(value, "bold"),
8290
+ italic: (value) => requireBooleanOrUndefined(value, "italic"),
8291
+ underline: (value) => requireBooleanOrUndefined(value, "underline"),
8292
+ fontSize: (value) => {
8293
+ if (value !== void 0 && (!Number.isFinite(value) || value <= 0)) {
8294
+ throw new Error("updateTextRunProperties: fontSize must be a finite positive pt value");
8295
+ }
8296
+ },
8297
+ color: (value) => {
8298
+ if (value === void 0) return;
8299
+ if (value.kind !== "srgb") {
8300
+ throw new Error("updateTextRunProperties: only srgb text run color is supported");
8301
+ }
8302
+ if (!/^[0-9A-Fa-f]{6}$/.test(value.hex)) {
8303
+ throw new Error("updateTextRunProperties: srgb text run color must be a 6-digit hex value");
8304
+ }
8305
+ },
8306
+ typeface: (value) => {
8307
+ if (value !== void 0 && value.trim() === "") {
8308
+ throw new Error("updateTextRunProperties: typeface must be a non-empty string");
8309
+ }
8310
+ }
8311
+ };
8312
+ var EDITABLE_TEXT_RUN_PROPERTIES = Object.keys(EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS).filter(
8313
+ (property) => property in EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS
8314
+ );
8315
+ var EDITABLE_TEXT_RUN_PROPERTY_SET = new Set(EDITABLE_TEXT_RUN_PROPERTIES);
8316
+ var EDITABLE_PARAGRAPH_PROPERTIES = [
8317
+ "align",
8318
+ "level",
8319
+ "bullet"
8320
+ ];
8321
+ var EDITABLE_PARAGRAPH_PROPERTY_SET = new Set(EDITABLE_PARAGRAPH_PROPERTIES);
8322
+ function requireBooleanOrUndefined(value, fieldName) {
8323
+ if (value !== void 0 && typeof value !== "boolean") {
8324
+ throw new Error(`updateTextRunProperties: ${fieldName} must be a boolean value`);
8325
+ }
8326
+ }
8327
+ function asEmu2(value) {
8328
+ return unsafeBrandAssertion2(value);
8329
+ }
8330
+ function asPt(value) {
8331
+ return unsafeBrandAssertion2(value);
8332
+ }
8333
+ function asHundredthPt2(value) {
8334
+ return unsafeBrandAssertion2(value);
8335
+ }
8336
+ function asOoxmlPercent(value) {
8337
+ return unsafeBrandAssertion2(value);
8338
+ }
8339
+ function asOoxmlAngle(value) {
8340
+ return unsafeBrandAssertion2(value);
8341
+ }
8342
+ var textEncoder = new TextEncoder();
8343
+ var ROOT_PART = asPartPath("");
8344
+ var PRESENTATION_PART = asPartPath("ppt/presentation.xml");
8345
+ var SLIDE_PART = asPartPath("ppt/slides/slide1.xml");
8346
+ var SLIDE_LAYOUT_PART = asPartPath("ppt/slideLayouts/slideLayout1.xml");
8347
+ var SLIDE_MASTER_PART = asPartPath("ppt/slideMasters/slideMaster1.xml");
8348
+ var THEME_PART = asPartPath("ppt/theme/theme1.xml");
8349
+ var APP_PROPS_PART = asPartPath("docProps/app.xml");
8350
+ var CORE_PROPS_PART = asPartPath("docProps/core.xml");
8303
8351
  var DEFAULT_COLOR_MAP = {
8304
8352
  bg1: "lt1",
8305
8353
  tx1: "dk1",
@@ -8718,7 +8766,7 @@ var DIAGRAM_DRAWING_REL_TYPES = /* @__PURE__ */ new Set([
8718
8766
  "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing",
8719
8767
  "http://purl.oclc.org/ooxml/officeDocument/relationships/diagramDrawing"
8720
8768
  ]);
8721
- var textDecoder = new TextDecoder();
8769
+ var textDecoder2 = new TextDecoder();
8722
8770
  var DEFAULT_TABLE_STYLE_BORDERS = {
8723
8771
  top: {
8724
8772
  width: asEmu2(12700),
@@ -8863,7 +8911,7 @@ function computeConnectorElement(context, connector, layer, partPath) {
8863
8911
  sourceNode: connector,
8864
8912
  ...connector.transform !== void 0 ? { transform: connector.transform } : {},
8865
8913
  ...connector.geometry !== void 0 ? { geometry: connector.geometry } : {},
8866
- ...connector.outline !== void 0 ? { outline: computeOutline(context, connector.outline, partPath) } : connector.style?.lineRef !== void 0 ? { outline: resolveLineReference(context, connector.style.lineRef, partPath) } : {},
8914
+ ...computedOutlineProperty(context, connector.outline, connector.style?.lineRef, partPath),
8867
8915
  ...effects !== void 0 ? { effects } : {}
8868
8916
  };
8869
8917
  }
@@ -8907,7 +8955,7 @@ function computeShapeElement(context, shape, layer, partPath) {
8907
8955
  ...transform !== void 0 ? { transform } : {},
8908
8956
  ...geometry !== void 0 ? { geometry } : {},
8909
8957
  ...shape.fill !== void 0 ? { fill: computeFill(context, shape.fill, partPath) } : shape.style?.fillRef !== void 0 ? { fill: resolveFillReference(context, shape.style.fillRef, partPath) } : {},
8910
- ...shape.outline !== void 0 ? { outline: computeOutline(context, shape.outline, partPath) } : shape.style?.lineRef !== void 0 ? { outline: resolveLineReference(context, shape.style.lineRef, partPath) } : {},
8958
+ ...computedOutlineProperty(context, shape.outline, shape.style?.lineRef, partPath),
8911
8959
  ...effects !== void 0 ? { effects } : {},
8912
8960
  ...shape.textBody !== void 0 ? {
8913
8961
  textBody: computeTextBody(
@@ -8922,7 +8970,7 @@ function computeShapeElement(context, shape, layer, partPath) {
8922
8970
  }
8923
8971
  function computeImageElement(context, image, layer, partPath) {
8924
8972
  const relationship = resolveComputedRelationships(context.source, partPath).find(
8925
- (rel) => rel.id === image.blipRelationshipId && rel.type === IMAGE_REL_TYPE2
8973
+ (rel2) => rel2.id === image.blipRelationshipId && rel2.type === IMAGE_REL_TYPE2
8926
8974
  );
8927
8975
  const effects = image.effects !== void 0 ? computeEffectList(context, image.effects) : void 0;
8928
8976
  const blipEffects = image.blipEffects !== void 0 ? computeBlipEffects(context, image.blipEffects) : void 0;
@@ -8953,7 +9001,7 @@ function computeTableElement(context, table, layer, partPath) {
8953
9001
  }
8954
9002
  function computeChartElement(context, chart, layer, partPath) {
8955
9003
  const relationship = context.relationships.find(
8956
- (rel) => rel.id === chart.chartRelationshipId && CHART_REL_TYPES.has(rel.type)
9004
+ (rel2) => rel2.id === chart.chartRelationshipId && CHART_REL_TYPES.has(rel2.type)
8957
9005
  );
8958
9006
  const chartXml = relationship?.targetPartPath !== void 0 ? readRawPackageText(context.source, relationship.targetPartPath) : void 0;
8959
9007
  const chartData = chartXml !== void 0 ? parseComputedChartData(chartXml, context) : void 0;
@@ -8970,11 +9018,11 @@ function computeChartElement(context, chart, layer, partPath) {
8970
9018
  }
8971
9019
  function computeSmartArtElement(context, smartArt, layer, partPath) {
8972
9020
  const dataRelationship = context.relationships.find(
8973
- (rel) => rel.id === smartArt.dataRelationshipId && DIAGRAM_DATA_REL_TYPES.has(rel.type)
9021
+ (rel2) => rel2.id === smartArt.dataRelationshipId && DIAGRAM_DATA_REL_TYPES.has(rel2.type)
8974
9022
  );
8975
9023
  const dataRelationships = dataRelationship?.targetPartPath !== void 0 ? resolveComputedRelationships(context.source, dataRelationship.targetPartPath) : [];
8976
9024
  const drawingRelationship = dataRelationships.find(
8977
- (rel) => DIAGRAM_DRAWING_REL_TYPES.has(rel.type)
9025
+ (rel2) => DIAGRAM_DRAWING_REL_TYPES.has(rel2.type)
8978
9026
  );
8979
9027
  const drawingPartPath = drawingRelationship?.targetPartPath;
8980
9028
  const drawingXml = drawingPartPath !== void 0 ? readRawPackageText(context.source, drawingPartPath) : void 0;
@@ -9120,7 +9168,7 @@ function computeFill(context, fill, partPath) {
9120
9168
  };
9121
9169
  case "image": {
9122
9170
  const relationship = resolveComputedRelationships(context.source, partPath).find(
9123
- (rel) => rel.id === fill.blipRelationshipId && rel.type === IMAGE_REL_TYPE2
9171
+ (rel2) => rel2.id === fill.blipRelationshipId && rel2.type === IMAGE_REL_TYPE2
9124
9172
  );
9125
9173
  return {
9126
9174
  kind: "image",
@@ -9145,6 +9193,24 @@ function computeOutline(context, outline, partPath) {
9145
9193
  ...outline.fill !== void 0 ? { fill: computeFill(context, outline.fill, partPath) } : {}
9146
9194
  };
9147
9195
  }
9196
+ function computedOutlineProperty(context, outline, lineRef, partPath) {
9197
+ const styleOutline = lineRef !== void 0 ? resolveLineReference(context, lineRef, partPath) : void 0;
9198
+ if (outline === void 0) {
9199
+ return styleOutline !== void 0 ? { outline: styleOutline } : {};
9200
+ }
9201
+ const computed = mergeComputedOutline(styleOutline, computeOutline(context, outline, partPath));
9202
+ return { outline: computed };
9203
+ }
9204
+ function mergeComputedOutline(base, override) {
9205
+ if (base === void 0) return override;
9206
+ const width = override.width ?? base.width;
9207
+ const fill = override.fill ?? base.fill;
9208
+ return {
9209
+ source: { ...base.source, ...override.source },
9210
+ ...width !== void 0 ? { width } : {},
9211
+ ...fill !== void 0 ? { fill } : {}
9212
+ };
9213
+ }
9148
9214
  function resolveFillReference(context, ref, partPath) {
9149
9215
  if (ref.index === 0) return void 0;
9150
9216
  const list = ref.index >= 1e3 ? context.theme?.formatScheme?.backgroundFillStyles : context.theme?.formatScheme?.fillStyles;
@@ -9429,7 +9495,7 @@ function isEmptyPlaceholder(shape) {
9429
9495
  }
9430
9496
  function readRawPackageText(source, partPath) {
9431
9497
  const rawPart = source.packageGraph.rawParts?.find((part) => part.partPath === partPath);
9432
- if (rawPart?.kind === "binary") return textDecoder.decode(rawPart.bytes);
9498
+ if (rawPart?.kind === "binary") return textDecoder2.decode(rawPart.bytes);
9433
9499
  return void 0;
9434
9500
  }
9435
9501
  function numericAttr3(node, attrName) {
@@ -9556,7 +9622,7 @@ function parseBackground(bg, nextId) {
9556
9622
  const bgRef = getChild(bg, "bgRef");
9557
9623
  if (bgRef) {
9558
9624
  const color = parseColorElement(bgRef);
9559
- const index = numericAttr(bgRef, "idx");
9625
+ const index = numericAttr2(bgRef, "idx");
9560
9626
  if (color !== void 0) {
9561
9627
  return { kind: "styleReference", index: index ?? 0, color };
9562
9628
  }
@@ -9686,9 +9752,9 @@ function parseOuterShadow2(node) {
9686
9752
  const color = parseColorElement(node);
9687
9753
  if (node === void 0 || color === void 0) return void 0;
9688
9754
  return {
9689
- blurRadius: asEmu2(numericAttr(node, "blurRad") ?? 0),
9690
- distance: asEmu2(numericAttr(node, "dist") ?? 0),
9691
- direction: asOoxmlAngle(numericAttr(node, "dir") ?? 0),
9755
+ blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
9756
+ distance: asEmu2(numericAttr2(node, "dist") ?? 0),
9757
+ direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
9692
9758
  color,
9693
9759
  alignment: parseRectangleAlignment(getAttr(node, "algn"), "b"),
9694
9760
  rotateWithShape: getAttr(node, "rotWithShape") !== "0"
@@ -9698,9 +9764,9 @@ function parseInnerShadow2(node) {
9698
9764
  const color = parseColorElement(node);
9699
9765
  if (node === void 0 || color === void 0) return void 0;
9700
9766
  return {
9701
- blurRadius: asEmu2(numericAttr(node, "blurRad") ?? 0),
9702
- distance: asEmu2(numericAttr(node, "dist") ?? 0),
9703
- direction: asOoxmlAngle(numericAttr(node, "dir") ?? 0),
9767
+ blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
9768
+ distance: asEmu2(numericAttr2(node, "dist") ?? 0),
9769
+ direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
9704
9770
  color
9705
9771
  };
9706
9772
  }
@@ -9708,14 +9774,14 @@ function parseGlow2(node) {
9708
9774
  const color = parseColorElement(node);
9709
9775
  if (node === void 0 || color === void 0) return void 0;
9710
9776
  return {
9711
- radius: asEmu2(numericAttr(node, "rad") ?? 0),
9777
+ radius: asEmu2(numericAttr2(node, "rad") ?? 0),
9712
9778
  color
9713
9779
  };
9714
9780
  }
9715
9781
  function parseSoftEdge2(node) {
9716
9782
  if (node === void 0) return void 0;
9717
9783
  return {
9718
- radius: asEmu2(numericAttr(node, "rad") ?? 0)
9784
+ radius: asEmu2(numericAttr2(node, "rad") ?? 0)
9719
9785
  };
9720
9786
  }
9721
9787
  function booleanAttr(node, name) {
@@ -9733,8 +9799,8 @@ var SLIDE_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/rel
9733
9799
  var SLIDE_LAYOUT_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
9734
9800
  var SLIDE_MASTER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
9735
9801
  var THEME_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
9736
- var PRESENTATION_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
9737
- var textDecoder2 = new TextDecoder();
9802
+ var PRESENTATION_CONTENT_TYPE2 = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
9803
+ var textDecoder3 = new TextDecoder();
9738
9804
  function readPptx(input) {
9739
9805
  const entries = unzipPackage(input);
9740
9806
  const diagnostics = [];
@@ -9885,7 +9951,7 @@ function parsePartRoot(entries, partPath, rootLocalName, diagnostics, includeOrd
9885
9951
  });
9886
9952
  return void 0;
9887
9953
  }
9888
- const xml = textDecoder2.decode(bytes);
9954
+ const xml = textDecoder3.decode(bytes);
9889
9955
  const root = getChild(parseXml(xml), rootLocalName);
9890
9956
  if (root === void 0) {
9891
9957
  diagnostics.push({
@@ -9900,15 +9966,15 @@ function parsePartRoot(entries, partPath, rootLocalName, diagnostics, includeOrd
9900
9966
  return { root, orderedRoot };
9901
9967
  }
9902
9968
  function resolveSingleRel(relationships, sourcePart, relType) {
9903
- const rels = relationships.find((rel) => rel.sourcePartPath === sourcePart)?.relationships;
9904
- const match = rels?.find((rel) => rel.type === relType && rel.targetMode !== "External");
9969
+ const rels = relationships.find((rel2) => rel2.sourcePartPath === sourcePart)?.relationships;
9970
+ const match = rels?.find((rel2) => rel2.type === relType && rel2.targetMode !== "External");
9905
9971
  if (match === void 0) return void 0;
9906
9972
  return resolveInternalRelationshipTarget(sourcePart, match);
9907
9973
  }
9908
9974
  function resolveAllRels(relationships, sourcePart, relType) {
9909
- const rels = relationships.find((rel) => rel.sourcePartPath === sourcePart)?.relationships ?? [];
9910
- return rels.filter((rel) => rel.type === relType && rel.targetMode !== "External").flatMap((rel) => {
9911
- const target = resolveInternalRelationshipTarget(sourcePart, rel);
9975
+ const rels = relationships.find((rel2) => rel2.sourcePartPath === sourcePart)?.relationships ?? [];
9976
+ return rels.filter((rel2) => rel2.type === relType && rel2.targetMode !== "External").flatMap((rel2) => {
9977
+ const target = resolveInternalRelationshipTarget(sourcePart, rel2);
9912
9978
  return target === void 0 ? [] : [target];
9913
9979
  });
9914
9980
  }
@@ -9936,7 +10002,7 @@ function unzipPackage(input) {
9936
10002
  function readContentTypes(entries) {
9937
10003
  const bytes = entries.get(CONTENT_TYPES_PART);
9938
10004
  if (!bytes) return { defaults: [], overrides: [] };
9939
- const root = getChild(parseXml(textDecoder2.decode(bytes)), "Types");
10005
+ const root = getChild(parseXml(textDecoder3.decode(bytes)), "Types");
9940
10006
  const defaults = [];
9941
10007
  for (const node of getChildArray(root, "Default")) {
9942
10008
  const extension = getAttr(node, "Extension");
@@ -9957,7 +10023,7 @@ function readRelationships(entries) {
9957
10023
  const result = [];
9958
10024
  for (const [path, bytes] of entries) {
9959
10025
  if (!isRelationshipPart(path)) continue;
9960
- const root = getChild(parseXml(textDecoder2.decode(bytes)), "Relationships");
10026
+ const root = getChild(parseXml(textDecoder3.decode(bytes)), "Relationships");
9961
10027
  const relationships = [];
9962
10028
  for (const node of getChildArray(root, "Relationship")) {
9963
10029
  const id = getAttr(node, "Id");
@@ -9988,7 +10054,7 @@ function readPresentation(entries, relationships, overrides, diagnostics) {
9988
10054
  );
9989
10055
  }
9990
10056
  const presentationPartPath = asPartPath(presentationPath);
9991
- const root = getChild(parseXml(textDecoder2.decode(bytes)), "presentation");
10057
+ const root = getChild(parseXml(textDecoder3.decode(bytes)), "presentation");
9992
10058
  if (root === void 0) {
9993
10059
  throw new Error(
9994
10060
  `readPptx: part '${presentationPath}' is not a presentation part (missing p:presentation root)`
@@ -9997,7 +10063,7 @@ function readPresentation(entries, relationships, overrides, diagnostics) {
9997
10063
  const slideSize = readSlideSize(root);
9998
10064
  const defaultTextStyle = parseTextStyle(getChild(root, "defaultTextStyle"));
9999
10065
  const presentationRels = relationships.find(
10000
- (rel) => rel.sourcePartPath === presentationPath
10066
+ (rel2) => rel2.sourcePartPath === presentationPath
10001
10067
  )?.relationships;
10002
10068
  const slidePartPaths = [];
10003
10069
  const sldIdLst = getChild(root, "sldIdLst");
@@ -10005,7 +10071,7 @@ function readPresentation(entries, relationships, overrides, diagnostics) {
10005
10071
  const relId = getNamespacedAttr(sldId, "id");
10006
10072
  if (relId === void 0) continue;
10007
10073
  const handle = { partPath: presentationPartPath, relationshipId: asRelationshipId(relId) };
10008
- const relationship = presentationRels?.find((rel) => rel.id === relId);
10074
+ const relationship = presentationRels?.find((rel2) => rel2.id === relId);
10009
10075
  if (relationship === void 0) {
10010
10076
  diagnostics.push({
10011
10077
  severity: "warning",
@@ -10048,15 +10114,15 @@ function readSlideSize(presentationRoot) {
10048
10114
  }
10049
10115
  function locatePresentationPart(relationships, overrides) {
10050
10116
  const rootRels = relationships.find(
10051
- (rel) => rel.sourcePartPath === PACKAGE_ROOT_PART
10117
+ (rel2) => rel2.sourcePartPath === PACKAGE_ROOT_PART
10052
10118
  )?.relationships;
10053
10119
  const officeDocumentRel = rootRels?.find(
10054
- (rel) => rel.type === OFFICE_DOCUMENT_REL_TYPE && rel.targetMode !== "External"
10120
+ (rel2) => rel2.type === OFFICE_DOCUMENT_REL_TYPE && rel2.targetMode !== "External"
10055
10121
  );
10056
10122
  if (officeDocumentRel !== void 0) {
10057
10123
  return resolveRelationshipTarget(PACKAGE_ROOT_PART, officeDocumentRel.target);
10058
10124
  }
10059
- const override = overrides.find((entry) => entry.contentType === PRESENTATION_CONTENT_TYPE);
10125
+ const override = overrides.find((entry) => entry.contentType === PRESENTATION_CONTENT_TYPE2);
10060
10126
  return override?.partName;
10061
10127
  }
10062
10128
  var MEDIA_CONTENT_TYPE_PREFIXES = ["image/", "audio/", "video/"];
@@ -10084,9 +10150,9 @@ function extensionOf(path) {
10084
10150
  function stripLeadingSlash(path) {
10085
10151
  return path.startsWith("/") ? path.slice(1) : path;
10086
10152
  }
10087
- var textEncoder = new TextEncoder();
10088
- var textDecoder3 = new TextDecoder();
10089
- var xmlBuilder = new import_fast_xml_parser2.XMLBuilder({
10153
+ var textEncoder2 = new TextEncoder();
10154
+ var textDecoder4 = new TextDecoder();
10155
+ var xmlBuilder2 = new import_fast_xml_parser3.XMLBuilder({
10090
10156
  ignoreAttributes: false,
10091
10157
  attributeNamePrefix: "@_",
10092
10158
  format: false,