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/index.cjs CHANGED
@@ -6139,104 +6139,21 @@ init_warning_logger();
6139
6139
 
6140
6140
  // ../document/dist/index.js
6141
6141
  var import_fast_xml_parser = require("fast-xml-parser");
6142
- var import_fflate = require("fflate");
6143
6142
  var import_fast_xml_parser2 = require("fast-xml-parser");
6143
+ var import_fflate = require("fflate");
6144
6144
  var import_fflate2 = require("fflate");
6145
+ var import_fast_xml_parser3 = require("fast-xml-parser");
6145
6146
  function unsafeOoxmlBoundaryAssertion(value) {
6146
6147
  return value;
6147
6148
  }
6148
6149
  function unsafeBrandAssertion2(value) {
6149
6150
  return value;
6150
6151
  }
6151
- function asPartPath(value) {
6152
- return unsafeBrandAssertion2(value);
6153
- }
6154
- function asRelationshipId(value) {
6155
- return unsafeBrandAssertion2(value);
6156
- }
6157
- function asSourceNodeId(value) {
6158
- return unsafeBrandAssertion2(value);
6159
- }
6160
- function asRawSidecarId(value) {
6161
- return unsafeBrandAssertion2(value);
6162
- }
6163
- var RELS_SUFFIX = ".rels";
6164
- var RELS_MARKER = "_rels/";
6165
- var ABSOLUTE_URI_PATTERN = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
6166
- function isRelationshipPart(path) {
6167
- return path.endsWith(RELS_SUFFIX) && path.includes(RELS_MARKER);
6168
- }
6169
- function relationshipsSourcePartPath(relsPath) {
6170
- const idx = relsPath.lastIndexOf(RELS_MARKER);
6171
- const dir = relsPath.slice(0, idx);
6172
- const file = relsPath.slice(idx + RELS_MARKER.length);
6173
- const base = file.endsWith(RELS_SUFFIX) ? file.slice(0, -RELS_SUFFIX.length) : file;
6174
- return asPartPath(dir + base);
6175
- }
6176
- function resolveRelationshipTarget(sourcePartPath, target) {
6177
- if (ABSOLUTE_URI_PATTERN.test(target)) return target;
6178
- const combined = target.startsWith("/") ? target.slice(1) : joinPackageRelativeTarget(sourcePartPath, target);
6179
- return normalizePackagePath(combined);
6180
- }
6181
- function resolveInternalRelationshipTarget(sourcePartPath, relationship) {
6182
- if (relationship.targetMode === "External") return void 0;
6183
- return asPartPath(resolveRelationshipTarget(sourcePartPath, relationship.target));
6184
- }
6185
- function parseRelationshipTargetMode(value) {
6186
- if (value === "Internal" || value === "External") return value;
6187
- return void 0;
6188
- }
6189
- function joinPackageRelativeTarget(sourcePartPath, target) {
6190
- const slash = sourcePartPath.lastIndexOf("/");
6191
- const baseDir = slash === -1 ? "" : sourcePartPath.slice(0, slash);
6192
- return baseDir === "" ? target : `${baseDir}/${target}`;
6193
- }
6194
- function normalizePackagePath(path) {
6195
- const segments = [];
6196
- for (const segment of path.split("/")) {
6197
- if (segment === "" || segment === ".") continue;
6198
- if (segment === "..") {
6199
- segments.pop();
6200
- continue;
6201
- }
6202
- segments.push(segment);
6203
- }
6204
- return segments.join("/");
6205
- }
6206
- var EDITABLE_TEXT_RUN_PROPERTIES = [
6207
- "bold",
6208
- "italic",
6209
- "underline",
6210
- "fontSize",
6211
- "color",
6212
- "typeface"
6213
- ];
6214
- var EDITABLE_TEXT_RUN_PROPERTY_SET = new Set(EDITABLE_TEXT_RUN_PROPERTIES);
6215
- function asEmu2(value) {
6216
- return unsafeBrandAssertion2(value);
6217
- }
6218
- function asPt(value) {
6219
- return unsafeBrandAssertion2(value);
6220
- }
6221
- function asHundredthPt2(value) {
6222
- return unsafeBrandAssertion2(value);
6223
- }
6224
- function asOoxmlPercent(value) {
6225
- return unsafeBrandAssertion2(value);
6226
- }
6227
- function asOoxmlAngle(value) {
6228
- return unsafeBrandAssertion2(value);
6229
- }
6230
- function parseEnumValue(value, allowed) {
6231
- return value !== void 0 && allowed.has(unsafeOoxmlBoundaryAssertion(value)) ? unsafeOoxmlBoundaryAssertion(value) : void 0;
6232
- }
6233
- function parseEnumValueWithDefault(value, allowed, fallback) {
6234
- return parseEnumValue(value, allowed) ?? fallback;
6235
- }
6236
6152
  var parser = new import_fast_xml_parser.XMLParser({
6237
6153
  ignoreAttributes: false,
6238
6154
  attributeNamePrefix: "@_",
6239
6155
  parseAttributeValue: false,
6156
+ parseTagValue: false,
6240
6157
  // Retain prefix. See the comment at the beginning of the file for the reason.
6241
6158
  removeNSPrefix: false,
6242
6159
  // Do not trim text run (`a:t`) to preserve significant white space at the beginning and end.
@@ -6349,6 +6266,62 @@ function scalarToString(value) {
6349
6266
  if (typeof value === "number" || typeof value === "boolean") return String(value);
6350
6267
  return void 0;
6351
6268
  }
6269
+ function asPartPath(value) {
6270
+ return unsafeBrandAssertion2(value);
6271
+ }
6272
+ function asRelationshipId(value) {
6273
+ return unsafeBrandAssertion2(value);
6274
+ }
6275
+ function asSourceNodeId(value) {
6276
+ return unsafeBrandAssertion2(value);
6277
+ }
6278
+ function asRawSidecarId(value) {
6279
+ return unsafeBrandAssertion2(value);
6280
+ }
6281
+ var RELS_SUFFIX = ".rels";
6282
+ var RELS_MARKER = "_rels/";
6283
+ var ABSOLUTE_URI_PATTERN = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
6284
+ function isRelationshipPart(path) {
6285
+ return path.endsWith(RELS_SUFFIX) && path.includes(RELS_MARKER);
6286
+ }
6287
+ function relationshipsSourcePartPath(relsPath) {
6288
+ const idx = relsPath.lastIndexOf(RELS_MARKER);
6289
+ const dir = relsPath.slice(0, idx);
6290
+ const file = relsPath.slice(idx + RELS_MARKER.length);
6291
+ const base = file.endsWith(RELS_SUFFIX) ? file.slice(0, -RELS_SUFFIX.length) : file;
6292
+ return asPartPath(dir + base);
6293
+ }
6294
+ function resolveRelationshipTarget(sourcePartPath, target) {
6295
+ if (ABSOLUTE_URI_PATTERN.test(target)) return target;
6296
+ const combined = target.startsWith("/") ? target.slice(1) : joinPackageRelativeTarget(sourcePartPath, target);
6297
+ return normalizePackagePath(combined);
6298
+ }
6299
+ function resolveInternalRelationshipTarget(sourcePartPath, relationship) {
6300
+ if (relationship.targetMode === "External") return void 0;
6301
+ return asPartPath(resolveRelationshipTarget(sourcePartPath, relationship.target));
6302
+ }
6303
+ function parseRelationshipTargetMode(value) {
6304
+ if (value === "Internal" || value === "External") return value;
6305
+ return void 0;
6306
+ }
6307
+ function joinPackageRelativeTarget(sourcePartPath, target) {
6308
+ const slash = sourcePartPath.lastIndexOf("/");
6309
+ const baseDir = slash === -1 ? "" : sourcePartPath.slice(0, slash);
6310
+ return baseDir === "" ? target : `${baseDir}/${target}`;
6311
+ }
6312
+ function normalizePackagePath(path) {
6313
+ const segments = [];
6314
+ for (const segment of path.split("/")) {
6315
+ if (segment === "" || segment === ".") continue;
6316
+ if (segment === "..") {
6317
+ segments.pop();
6318
+ continue;
6319
+ }
6320
+ segments.push(segment);
6321
+ }
6322
+ return segments.join("/");
6323
+ }
6324
+ var textDecoder = new TextDecoder();
6352
6325
  var ATTR_PREFIX = "@_";
6353
6326
  var TEXT_KEY = "#text";
6354
6327
  function createSidecarIdFactory(partPath) {
@@ -6418,211 +6391,449 @@ function scalarText(value) {
6418
6391
  if (typeof value === "number" || typeof value === "boolean") return String(value);
6419
6392
  return void 0;
6420
6393
  }
6421
- var RECTANGLE_ALIGNMENT_TOKENS = /* @__PURE__ */ new Set([
6422
- "tl",
6423
- "t",
6424
- "tr",
6425
- "l",
6426
- "ctr",
6427
- "r",
6428
- "bl",
6429
- "b",
6430
- "br"
6431
- ]);
6432
- var COLOR_TRANSFORM_KINDS = /* @__PURE__ */ new Set([
6433
- "lumMod",
6434
- "lumOff",
6435
- "tint",
6436
- "shade",
6437
- "alpha"
6438
- ]);
6439
- var RAW_FILL_LOCAL_NAMES = ["grpFill"];
6440
- var PRESET_COLOR_HEX = {
6441
- black: "000000",
6442
- white: "FFFFFF",
6443
- red: "FF0000",
6444
- green: "008000",
6445
- blue: "0000FF",
6446
- yellow: "FFFF00",
6447
- cyan: "00FFFF",
6448
- magenta: "FF00FF"
6449
- };
6450
- function parseColorElement(parent) {
6451
- if (!parent) return void 0;
6452
- const srgb = getChild(parent, "srgbClr");
6453
- if (srgb) {
6454
- const hex = getAttr(srgb, "val");
6455
- if (hex !== void 0) {
6456
- return withTransforms({ kind: "srgb", hex: hex.toUpperCase() }, srgb);
6457
- }
6458
- }
6459
- const scheme = getChild(parent, "schemeClr");
6460
- if (scheme) {
6461
- const name = getAttr(scheme, "val");
6462
- if (name !== void 0) {
6463
- return withTransforms({ kind: "scheme", scheme: name }, scheme);
6464
- }
6465
- }
6466
- const sys = getChild(parent, "sysClr");
6467
- if (sys) {
6468
- const val = getAttr(sys, "val");
6469
- if (val !== void 0) {
6470
- const lastClr = getAttr(sys, "lastClr");
6471
- return withTransforms(
6472
- {
6473
- kind: "system",
6474
- value: val,
6475
- ...lastClr !== void 0 ? { lastColor: lastClr.toUpperCase() } : {}
6476
- },
6477
- sys
6478
- );
6479
- }
6394
+ function parseCustomGeometry(custGeom, orderedCustGeom) {
6395
+ const pathLst = getChild(custGeom, "pathLst");
6396
+ const paths = getChildArray(pathLst, "path");
6397
+ if (paths.length === 0) return void 0;
6398
+ const avGuides = parseGuideList(getChild(custGeom, "avLst"));
6399
+ const guides = parseGuideList(getChild(custGeom, "gdLst"));
6400
+ const orderedPaths = orderedChildEntries(
6401
+ orderedChildChildren(orderedCustGeom, "pathLst"),
6402
+ "path"
6403
+ );
6404
+ const result = [];
6405
+ for (const [index, path] of paths.entries()) {
6406
+ const width = numericAttr(path, "w") ?? 0;
6407
+ const height = numericAttr(path, "h") ?? 0;
6408
+ if (width === 0 && height === 0) continue;
6409
+ const variables = evaluateGuides(avGuides, guides, width, height);
6410
+ const commands = buildPathCommands(path, variables, orderedNodeChildren(orderedPaths[index]));
6411
+ if (commands !== void 0) result.push({ width, height, commands });
6480
6412
  }
6481
- return void 0;
6482
- }
6483
- function parseEffectList(effectList) {
6484
- if (effectList === void 0) return void 0;
6485
- const outerShadow = parseOuterShadow(getChild(effectList, "outerShdw"));
6486
- const innerShadow = parseInnerShadow(getChild(effectList, "innerShdw"));
6487
- const glow = parseGlow(getChild(effectList, "glow"));
6488
- const softEdge = parseSoftEdge(getChild(effectList, "softEdge"));
6489
- const parsed = {
6490
- ...outerShadow !== void 0 ? { outerShadow } : {},
6491
- ...innerShadow !== void 0 ? { innerShadow } : {},
6492
- ...glow !== void 0 ? { glow } : {},
6493
- ...softEdge !== void 0 ? { softEdge } : {}
6494
- };
6495
- return Object.keys(parsed).length > 0 ? parsed : void 0;
6413
+ return result.length > 0 ? result : void 0;
6496
6414
  }
6497
- function parseBlipEffects(blip) {
6498
- if (blip === void 0) return void 0;
6499
- const grayscale = getChild(blip, "grayscl") !== void 0;
6500
- const biLevel = parseBiLevel(getChild(blip, "biLevel"));
6501
- const blur = parseBlurEffect(getChild(blip, "blur"));
6502
- const lum = parseLumEffect(getChild(blip, "lum"));
6503
- const duotone = parseDuotoneEffect(getChild(blip, "duotone"));
6504
- const clrChange = parseColorChangeEffect(getChild(blip, "clrChange"));
6505
- const parsed = {
6506
- grayscale,
6507
- ...biLevel !== void 0 ? { biLevel } : {},
6508
- ...blur !== void 0 ? { blur } : {},
6509
- ...lum !== void 0 ? { lum } : {},
6510
- ...duotone !== void 0 ? { duotone } : {},
6511
- ...clrChange !== void 0 ? { clrChange } : {}
6512
- };
6513
- return grayscale || biLevel !== void 0 || blur !== void 0 || lum !== void 0 || duotone !== void 0 || clrChange !== void 0 ? parsed : void 0;
6415
+ function parseGuideList(parent) {
6416
+ return getChildArray(parent, "gd").map((guide) => ({
6417
+ name: getAttr(guide, "name") ?? "",
6418
+ formula: getAttr(guide, "fmla") ?? ""
6419
+ })).filter((guide) => guide.name !== "" && guide.formula !== "");
6514
6420
  }
6515
- function parseOuterShadow(node) {
6516
- if (node === void 0) return void 0;
6517
- const color = parseColorElement(node);
6518
- if (color === void 0) return void 0;
6519
- return {
6520
- blurRadius: asEmu2(numericAttr(node, "blurRad") ?? 0),
6521
- distance: asEmu2(numericAttr(node, "dist") ?? 0),
6522
- direction: asOoxmlAngle(numericAttr(node, "dir") ?? 0),
6523
- color,
6524
- alignment: parseRectangleAlignment(getAttr(node, "algn"), "b"),
6525
- rotateWithShape: getAttr(node, "rotWithShape") !== "0"
6526
- };
6421
+ function buildPathCommands(path, variables, orderedCommands) {
6422
+ const parts = [];
6423
+ let currentX = 0;
6424
+ let currentY = 0;
6425
+ let startX = 0;
6426
+ let startY = 0;
6427
+ for (const { local, nodes } of pathCommandNodes(path, orderedCommands)) {
6428
+ for (const node of nodes) {
6429
+ if (local === "moveTo") {
6430
+ const point = firstPoint(node, variables);
6431
+ if (point !== void 0) {
6432
+ parts.push(`M ${point.x} ${point.y}`);
6433
+ currentX = point.x;
6434
+ currentY = point.y;
6435
+ startX = point.x;
6436
+ startY = point.y;
6437
+ }
6438
+ } else if (local === "lnTo") {
6439
+ const point = firstPoint(node, variables);
6440
+ if (point !== void 0) {
6441
+ parts.push(`L ${point.x} ${point.y}`);
6442
+ currentX = point.x;
6443
+ currentY = point.y;
6444
+ }
6445
+ } else if (local === "cubicBezTo") {
6446
+ const points = allPoints(node, variables);
6447
+ if (points.length >= 3) {
6448
+ parts.push(`C ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
6449
+ currentX = points[points.length - 1].x;
6450
+ currentY = points[points.length - 1].y;
6451
+ }
6452
+ } else if (local === "quadBezTo") {
6453
+ const points = allPoints(node, variables);
6454
+ if (points.length >= 2) {
6455
+ parts.push(`Q ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
6456
+ currentX = points[points.length - 1].x;
6457
+ currentY = points[points.length - 1].y;
6458
+ }
6459
+ } else if (local === "arcTo") {
6460
+ const arc = convertArcTo(node, currentX, currentY, variables);
6461
+ if (arc !== void 0) {
6462
+ parts.push(arc.command);
6463
+ currentX = arc.endX;
6464
+ currentY = arc.endY;
6465
+ }
6466
+ } else if (local === "close") {
6467
+ parts.push("Z");
6468
+ currentX = startX;
6469
+ currentY = startY;
6470
+ }
6471
+ }
6472
+ }
6473
+ return parts.length > 0 ? parts.join(" ") : void 0;
6527
6474
  }
6528
- function parseInnerShadow(node) {
6529
- if (node === void 0) return void 0;
6530
- const color = parseColorElement(node);
6531
- if (color === void 0) return void 0;
6532
- return {
6533
- blurRadius: asEmu2(numericAttr(node, "blurRad") ?? 0),
6534
- distance: asEmu2(numericAttr(node, "dist") ?? 0),
6535
- direction: asOoxmlAngle(numericAttr(node, "dir") ?? 0),
6536
- color
6537
- };
6475
+ function pathCommandNodes(path, orderedCommands) {
6476
+ if (orderedCommands === void 0) {
6477
+ return Object.keys(path).filter((key) => !key.startsWith("@_")).map((key) => ({ local: localName(key), nodes: getChildArray(path, localName(key)) }));
6478
+ }
6479
+ const counters = {};
6480
+ const result = [];
6481
+ for (const command of orderedCommands) {
6482
+ const key = orderedNodeKey(command);
6483
+ if (key === void 0) continue;
6484
+ const local = localName(key);
6485
+ const index = counters[local] ?? 0;
6486
+ counters[local] = index + 1;
6487
+ const node = getChildArray(path, local)[index];
6488
+ if (node !== void 0) result.push({ local, nodes: [node] });
6489
+ }
6490
+ return result;
6538
6491
  }
6539
- function parseGlow(node) {
6540
- if (node === void 0) return void 0;
6541
- const color = parseColorElement(node);
6542
- if (color === void 0) return void 0;
6543
- return {
6544
- radius: asEmu2(numericAttr(node, "rad") ?? 0),
6545
- color
6546
- };
6492
+ function firstPoint(node, variables) {
6493
+ return allPoints(node, variables)[0];
6547
6494
  }
6548
- function parseSoftEdge(node) {
6549
- if (node === void 0) return void 0;
6550
- return {
6551
- radius: asEmu2(numericAttr(node, "rad") ?? 0)
6552
- };
6495
+ function allPoints(node, variables) {
6496
+ return getChildArray(node, "pt").map((point) => ({
6497
+ x: resolveValue(getAttr(point, "x") ?? "0", variables),
6498
+ y: resolveValue(getAttr(point, "y") ?? "0", variables)
6499
+ }));
6553
6500
  }
6554
- function parseBiLevel(node) {
6555
- if (node === void 0) return void 0;
6501
+ function convertArcTo(arc, currentX, currentY, variables) {
6502
+ const widthRadius = resolveValue(getAttr(arc, "wR") ?? "0", variables);
6503
+ const heightRadius = resolveValue(getAttr(arc, "hR") ?? "0", variables);
6504
+ const startAngle = resolveValue(getAttr(arc, "stAng") ?? "0", variables);
6505
+ const sweepAngle = resolveValue(getAttr(arc, "swAng") ?? "0", variables);
6506
+ if (widthRadius === 0 && heightRadius === 0 || sweepAngle === 0) return void 0;
6507
+ const startRadians = startAngle / 6e4 * (Math.PI / 180);
6508
+ const endRadians = (startAngle + sweepAngle) / 6e4 * (Math.PI / 180);
6509
+ const centerX = currentX - widthRadius * Math.cos(startRadians);
6510
+ const centerY = currentY - heightRadius * Math.sin(startRadians);
6511
+ const endX = centerX + widthRadius * Math.cos(endRadians);
6512
+ const endY = centerY + heightRadius * Math.sin(endRadians);
6513
+ const largeArcFlag = Math.abs(sweepAngle / 6e4) > 180 ? 1 : 0;
6514
+ const sweepFlag = sweepAngle > 0 ? 1 : 0;
6556
6515
  return {
6557
- threshold: (numericAttr(node, "thresh") ?? 5e4) / 1e5
6516
+ command: `A ${round4(widthRadius)} ${round4(heightRadius)} 0 ${largeArcFlag} ${sweepFlag} ${round4(endX)} ${round4(endY)}`,
6517
+ endX,
6518
+ endY
6558
6519
  };
6559
6520
  }
6560
- function parseBlurEffect(node) {
6561
- if (node === void 0) return void 0;
6521
+ function evaluateGuides(avGuides, guides, width, height) {
6522
+ const variables = createBuiltinVariables(width, height);
6523
+ for (const guide of avGuides) variables[guide.name] = evaluateFormula(guide.formula, variables);
6524
+ for (const guide of guides) variables[guide.name] = evaluateFormula(guide.formula, variables);
6525
+ return variables;
6526
+ }
6527
+ function createBuiltinVariables(width, height) {
6562
6528
  return {
6563
- radius: asEmu2(numericAttr(node, "rad") ?? 0),
6564
- grow: getAttr(node, "grow") !== "0"
6529
+ w: width,
6530
+ h: height,
6531
+ l: 0,
6532
+ t: 0,
6533
+ r: width,
6534
+ b: height,
6535
+ wd2: width / 2,
6536
+ hd2: height / 2,
6537
+ wd4: width / 4,
6538
+ hd4: height / 4,
6539
+ ss: Math.min(width, height),
6540
+ ls: Math.max(width, height),
6541
+ cd2: 108e5,
6542
+ cd4: 54e5,
6543
+ cd8: 27e5,
6544
+ "3cd4": 162e5
6565
6545
  };
6566
6546
  }
6567
- function parseLumEffect(node) {
6568
- if (node === void 0) return void 0;
6569
- return {
6570
- brightness: (numericAttr(node, "bright") ?? 0) / 1e5,
6571
- contrast: (numericAttr(node, "contrast") ?? 0) / 1e5
6547
+ function evaluateFormula(formula, variables) {
6548
+ const tokens = formula.trim().split(/\s+/);
6549
+ const op = tokens[0];
6550
+ const resolve = (token) => {
6551
+ if (token === void 0) return 0;
6552
+ const value = Number(token);
6553
+ return Number.isNaN(value) ? variables[token] ?? 0 : value;
6572
6554
  };
6555
+ if (op === "val") return resolve(tokens[1]);
6556
+ if (op === "+-") return resolve(tokens[1]) + resolve(tokens[2]) - resolve(tokens[3]);
6557
+ if (op === "*/")
6558
+ return Math.round(resolve(tokens[1]) * resolve(tokens[2]) / (resolve(tokens[3]) || 1));
6559
+ if (op === "+/")
6560
+ return Math.round((resolve(tokens[1]) + resolve(tokens[2])) / (resolve(tokens[3]) || 1));
6561
+ if (op === "pin")
6562
+ return Math.max(resolve(tokens[1]), Math.min(resolve(tokens[2]), resolve(tokens[3])));
6563
+ if (op === "min") return Math.min(resolve(tokens[1]), resolve(tokens[2]));
6564
+ if (op === "max") return Math.max(resolve(tokens[1]), resolve(tokens[2]));
6565
+ if (op === "abs") return Math.abs(resolve(tokens[1]));
6566
+ if (op === "sqrt") return Math.round(Math.sqrt(resolve(tokens[1])));
6567
+ if (op === "sin") return Math.round(resolve(tokens[1]) * Math.sin(toRadians(resolve(tokens[2]))));
6568
+ if (op === "cos") return Math.round(resolve(tokens[1]) * Math.cos(toRadians(resolve(tokens[2]))));
6569
+ if (op === "tan") return Math.round(resolve(tokens[1]) * Math.tan(toRadians(resolve(tokens[2]))));
6570
+ if (op === "at2")
6571
+ return Math.round(Math.atan2(resolve(tokens[2]), resolve(tokens[1])) * (180 / Math.PI) * 6e4);
6572
+ if (op === "mod") {
6573
+ const a = resolve(tokens[1]);
6574
+ const b = resolve(tokens[2]);
6575
+ const c = resolve(tokens[3]);
6576
+ return Math.round(Math.sqrt(a * a + b * b + c * c));
6577
+ }
6578
+ if (op === "cat2") {
6579
+ return Math.round(
6580
+ resolve(tokens[1]) * Math.cos(Math.atan2(resolve(tokens[3]), resolve(tokens[2])))
6581
+ );
6582
+ }
6583
+ if (op === "sat2") {
6584
+ return Math.round(
6585
+ resolve(tokens[1]) * Math.sin(Math.atan2(resolve(tokens[3]), resolve(tokens[2])))
6586
+ );
6587
+ }
6588
+ if (op === "?:") return resolve(tokens[1]) > 0 ? resolve(tokens[2]) : resolve(tokens[3]);
6589
+ return 0;
6573
6590
  }
6574
- function parseDuotoneEffect(node) {
6575
- if (node === void 0) return void 0;
6576
- const colors = collectColorChildren(node);
6577
- if (colors.length < 2) return void 0;
6578
- return { color1: colors[0], color2: colors[1] };
6591
+ function resolveValue(value, variables) {
6592
+ const numeric = Number(value);
6593
+ return Number.isNaN(numeric) ? variables[value] ?? 0 : numeric;
6579
6594
  }
6580
- function parseColorChangeEffect(node) {
6581
- if (node === void 0) return void 0;
6582
- const from = firstColorChild(getChild(node, "clrFrom"));
6583
- const to = firstColorChild(getChild(node, "clrTo"));
6584
- return from !== void 0 && to !== void 0 ? { from, to } : void 0;
6595
+ function numericAttr(node, name) {
6596
+ const raw = getAttr(node, name);
6597
+ if (raw === void 0) return void 0;
6598
+ const value = Number(raw);
6599
+ return Number.isFinite(value) ? value : void 0;
6585
6600
  }
6586
- function collectColorChildren(parent) {
6587
- const colors = [];
6588
- for (const [key, value] of Object.entries(parent)) {
6589
- if (key.startsWith("@_")) continue;
6590
- const nodes = Array.isArray(value) ? value : [value];
6591
- for (const node of nodes) {
6592
- if (!isXmlNode(node)) continue;
6593
- const color = parseColorChild(key, node);
6594
- if (color !== void 0) colors.push(color);
6595
- }
6596
- }
6597
- return colors;
6601
+ function round4(value) {
6602
+ return Math.round(value * 1e3) / 1e3;
6598
6603
  }
6599
- function firstColorChild(parent) {
6600
- return parent !== void 0 ? collectColorChildren(parent)[0] : void 0;
6604
+ function toRadians(ooxmlAngle) {
6605
+ return ooxmlAngle / 6e4 * (Math.PI / 180);
6601
6606
  }
6602
- function parseColorChild(key, node) {
6603
- const name = localName(key);
6604
- return name === "prstClr" ? parsePresetColor(node) : parseColorElement({ [name]: node });
6607
+ function orderedChildChildren(parent, childLocalName) {
6608
+ const child = orderedChildEntries(parent, childLocalName)[0];
6609
+ return orderedNodeChildren(child);
6605
6610
  }
6606
- function isXmlNode(value) {
6607
- return typeof value === "object" && value !== null;
6611
+ function orderedChildEntries(parent, childLocalName) {
6612
+ if (parent === void 0) return [];
6613
+ return parent.filter((child) => {
6614
+ const key = orderedNodeKey(child);
6615
+ return key !== void 0 && localName(key) === childLocalName;
6616
+ });
6608
6617
  }
6609
- function parsePresetColor(node) {
6610
- const value = getAttr(node, "val");
6611
- const hex = value !== void 0 ? PRESET_COLOR_HEX[value] : void 0;
6612
- return hex !== void 0 ? withTransforms({ kind: "srgb", hex }, node) : void 0;
6618
+ function orderedNodeChildren(node) {
6619
+ const key = node !== void 0 ? orderedNodeKey(node) : void 0;
6620
+ const value = key !== void 0 ? node?.[key] : void 0;
6621
+ return Array.isArray(value) ? value : void 0;
6613
6622
  }
6614
- function parseFill(parent, nextId) {
6615
- if (!parent) return void 0;
6616
- const solid = getChild(parent, "solidFill");
6617
- if (solid) {
6618
- const color = parseColorElement(solid);
6619
- if (color) return { kind: "solid", color };
6620
- return { kind: "raw", raw: makeSidecar("a:solidFill", solid, nextId) };
6621
- }
6622
- if (hasChild(parent, "noFill")) return { kind: "none" };
6623
- const grad = getChild(parent, "gradFill");
6624
- if (grad) {
6625
- const fill = parseGradientFill(grad);
6623
+ function orderedNodeKey(node) {
6624
+ return Object.keys(node).find((key) => key !== ":@");
6625
+ }
6626
+ function parseEnumValue(value, allowed) {
6627
+ return value !== void 0 && allowed.has(unsafeOoxmlBoundaryAssertion(value)) ? unsafeOoxmlBoundaryAssertion(value) : void 0;
6628
+ }
6629
+ function parseEnumValueWithDefault(value, allowed, fallback) {
6630
+ return parseEnumValue(value, allowed) ?? fallback;
6631
+ }
6632
+ var RECTANGLE_ALIGNMENT_TOKENS = /* @__PURE__ */ new Set([
6633
+ "tl",
6634
+ "t",
6635
+ "tr",
6636
+ "l",
6637
+ "ctr",
6638
+ "r",
6639
+ "bl",
6640
+ "b",
6641
+ "br"
6642
+ ]);
6643
+ var COLOR_TRANSFORM_KINDS = /* @__PURE__ */ new Set([
6644
+ "lumMod",
6645
+ "lumOff",
6646
+ "tint",
6647
+ "shade",
6648
+ "alpha"
6649
+ ]);
6650
+ var RAW_FILL_LOCAL_NAMES = ["grpFill"];
6651
+ var PRESET_COLOR_HEX = {
6652
+ black: "000000",
6653
+ white: "FFFFFF",
6654
+ red: "FF0000",
6655
+ green: "008000",
6656
+ blue: "0000FF",
6657
+ yellow: "FFFF00",
6658
+ cyan: "00FFFF",
6659
+ magenta: "FF00FF"
6660
+ };
6661
+ function parseColorElement(parent) {
6662
+ if (!parent) return void 0;
6663
+ const srgb = getChild(parent, "srgbClr");
6664
+ if (srgb) {
6665
+ const hex = getAttr(srgb, "val");
6666
+ if (hex !== void 0) {
6667
+ return withTransforms({ kind: "srgb", hex: hex.toUpperCase() }, srgb);
6668
+ }
6669
+ }
6670
+ const scheme = getChild(parent, "schemeClr");
6671
+ if (scheme) {
6672
+ const name = getAttr(scheme, "val");
6673
+ if (name !== void 0) {
6674
+ return withTransforms({ kind: "scheme", scheme: name }, scheme);
6675
+ }
6676
+ }
6677
+ const sys = getChild(parent, "sysClr");
6678
+ if (sys) {
6679
+ const val = getAttr(sys, "val");
6680
+ if (val !== void 0) {
6681
+ const lastClr = getAttr(sys, "lastClr");
6682
+ return withTransforms(
6683
+ {
6684
+ kind: "system",
6685
+ value: val,
6686
+ ...lastClr !== void 0 ? { lastColor: lastClr.toUpperCase() } : {}
6687
+ },
6688
+ sys
6689
+ );
6690
+ }
6691
+ }
6692
+ return void 0;
6693
+ }
6694
+ function parseEffectList(effectList) {
6695
+ if (effectList === void 0) return void 0;
6696
+ const outerShadow = parseOuterShadow(getChild(effectList, "outerShdw"));
6697
+ const innerShadow = parseInnerShadow(getChild(effectList, "innerShdw"));
6698
+ const glow = parseGlow(getChild(effectList, "glow"));
6699
+ const softEdge = parseSoftEdge(getChild(effectList, "softEdge"));
6700
+ const parsed = {
6701
+ ...outerShadow !== void 0 ? { outerShadow } : {},
6702
+ ...innerShadow !== void 0 ? { innerShadow } : {},
6703
+ ...glow !== void 0 ? { glow } : {},
6704
+ ...softEdge !== void 0 ? { softEdge } : {}
6705
+ };
6706
+ return Object.keys(parsed).length > 0 ? parsed : void 0;
6707
+ }
6708
+ function parseBlipEffects(blip) {
6709
+ if (blip === void 0) return void 0;
6710
+ const grayscale = getChild(blip, "grayscl") !== void 0;
6711
+ const biLevel = parseBiLevel(getChild(blip, "biLevel"));
6712
+ const blur = parseBlurEffect(getChild(blip, "blur"));
6713
+ const lum = parseLumEffect(getChild(blip, "lum"));
6714
+ const duotone = parseDuotoneEffect(getChild(blip, "duotone"));
6715
+ const clrChange = parseColorChangeEffect(getChild(blip, "clrChange"));
6716
+ const parsed = {
6717
+ grayscale,
6718
+ ...biLevel !== void 0 ? { biLevel } : {},
6719
+ ...blur !== void 0 ? { blur } : {},
6720
+ ...lum !== void 0 ? { lum } : {},
6721
+ ...duotone !== void 0 ? { duotone } : {},
6722
+ ...clrChange !== void 0 ? { clrChange } : {}
6723
+ };
6724
+ return grayscale || biLevel !== void 0 || blur !== void 0 || lum !== void 0 || duotone !== void 0 || clrChange !== void 0 ? parsed : void 0;
6725
+ }
6726
+ function parseOuterShadow(node) {
6727
+ if (node === void 0) return void 0;
6728
+ const color = parseColorElement(node);
6729
+ if (color === void 0) return void 0;
6730
+ return {
6731
+ blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
6732
+ distance: asEmu2(numericAttr2(node, "dist") ?? 0),
6733
+ direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
6734
+ color,
6735
+ alignment: parseRectangleAlignment(getAttr(node, "algn"), "b"),
6736
+ rotateWithShape: getAttr(node, "rotWithShape") !== "0"
6737
+ };
6738
+ }
6739
+ function parseInnerShadow(node) {
6740
+ if (node === void 0) return void 0;
6741
+ const color = parseColorElement(node);
6742
+ if (color === void 0) return void 0;
6743
+ return {
6744
+ blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
6745
+ distance: asEmu2(numericAttr2(node, "dist") ?? 0),
6746
+ direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
6747
+ color
6748
+ };
6749
+ }
6750
+ function parseGlow(node) {
6751
+ if (node === void 0) return void 0;
6752
+ const color = parseColorElement(node);
6753
+ if (color === void 0) return void 0;
6754
+ return {
6755
+ radius: asEmu2(numericAttr2(node, "rad") ?? 0),
6756
+ color
6757
+ };
6758
+ }
6759
+ function parseSoftEdge(node) {
6760
+ if (node === void 0) return void 0;
6761
+ return {
6762
+ radius: asEmu2(numericAttr2(node, "rad") ?? 0)
6763
+ };
6764
+ }
6765
+ function parseBiLevel(node) {
6766
+ if (node === void 0) return void 0;
6767
+ return {
6768
+ threshold: (numericAttr2(node, "thresh") ?? 5e4) / 1e5
6769
+ };
6770
+ }
6771
+ function parseBlurEffect(node) {
6772
+ if (node === void 0) return void 0;
6773
+ return {
6774
+ radius: asEmu2(numericAttr2(node, "rad") ?? 0),
6775
+ grow: getAttr(node, "grow") !== "0"
6776
+ };
6777
+ }
6778
+ function parseLumEffect(node) {
6779
+ if (node === void 0) return void 0;
6780
+ return {
6781
+ brightness: (numericAttr2(node, "bright") ?? 0) / 1e5,
6782
+ contrast: (numericAttr2(node, "contrast") ?? 0) / 1e5
6783
+ };
6784
+ }
6785
+ function parseDuotoneEffect(node) {
6786
+ if (node === void 0) return void 0;
6787
+ const colors = collectColorChildren(node);
6788
+ if (colors.length < 2) return void 0;
6789
+ return { color1: colors[0], color2: colors[1] };
6790
+ }
6791
+ function parseColorChangeEffect(node) {
6792
+ if (node === void 0) return void 0;
6793
+ const from = firstColorChild(getChild(node, "clrFrom"));
6794
+ const to = firstColorChild(getChild(node, "clrTo"));
6795
+ return from !== void 0 && to !== void 0 ? { from, to } : void 0;
6796
+ }
6797
+ function collectColorChildren(parent) {
6798
+ const colors = [];
6799
+ for (const [key, value] of Object.entries(parent)) {
6800
+ if (key.startsWith("@_")) continue;
6801
+ const nodes = Array.isArray(value) ? value : [value];
6802
+ for (const node of nodes) {
6803
+ if (!isXmlNode(node)) continue;
6804
+ const color = parseColorChild(key, node);
6805
+ if (color !== void 0) colors.push(color);
6806
+ }
6807
+ }
6808
+ return colors;
6809
+ }
6810
+ function firstColorChild(parent) {
6811
+ return parent !== void 0 ? collectColorChildren(parent)[0] : void 0;
6812
+ }
6813
+ function parseColorChild(key, node) {
6814
+ const name = localName(key);
6815
+ return name === "prstClr" ? parsePresetColor(node) : parseColorElement({ [name]: node });
6816
+ }
6817
+ function isXmlNode(value) {
6818
+ return typeof value === "object" && value !== null;
6819
+ }
6820
+ function parsePresetColor(node) {
6821
+ const value = getAttr(node, "val");
6822
+ const hex = value !== void 0 ? PRESET_COLOR_HEX[value] : void 0;
6823
+ return hex !== void 0 ? withTransforms({ kind: "srgb", hex }, node) : void 0;
6824
+ }
6825
+ function parseFill(parent, nextId) {
6826
+ if (!parent) return void 0;
6827
+ const solid = getChild(parent, "solidFill");
6828
+ if (solid) {
6829
+ const color = parseColorElement(solid);
6830
+ if (color) return { kind: "solid", color };
6831
+ return { kind: "raw", raw: makeSidecar("a:solidFill", solid, nextId) };
6832
+ }
6833
+ if (hasChild(parent, "noFill")) return { kind: "none" };
6834
+ const grad = getChild(parent, "gradFill");
6835
+ if (grad) {
6836
+ const fill = parseGradientFill(grad);
6626
6837
  return fill ?? { kind: "raw", raw: makeSidecar("a:gradFill", grad, nextId) };
6627
6838
  }
6628
6839
  const blip = getChild(parent, "blipFill");
@@ -6647,7 +6858,7 @@ function parseGradientFill(grad) {
6647
6858
  const color = parseColorElement(gs);
6648
6859
  if (color === void 0) continue;
6649
6860
  stops.push({
6650
- position: (numericAttr(gs, "pos") ?? 0) / 1e5,
6861
+ position: (numericAttr2(gs, "pos") ?? 0) / 1e5,
6651
6862
  color
6652
6863
  });
6653
6864
  }
@@ -6655,10 +6866,10 @@ function parseGradientFill(grad) {
6655
6866
  const path = getChild(grad, "path");
6656
6867
  if (path !== void 0) {
6657
6868
  const fillToRect = getChild(path, "fillToRect");
6658
- const l = numericAttr(fillToRect, "l") ?? 0;
6659
- const t = numericAttr(fillToRect, "t") ?? 0;
6660
- const r = numericAttr(fillToRect, "r") ?? 0;
6661
- const b = numericAttr(fillToRect, "b") ?? 0;
6869
+ const l = numericAttr2(fillToRect, "l") ?? 0;
6870
+ const t = numericAttr2(fillToRect, "t") ?? 0;
6871
+ const r = numericAttr2(fillToRect, "r") ?? 0;
6872
+ const b = numericAttr2(fillToRect, "b") ?? 0;
6662
6873
  return {
6663
6874
  kind: "gradient",
6664
6875
  gradientType: "radial",
@@ -6671,7 +6882,7 @@ function parseGradientFill(grad) {
6671
6882
  kind: "gradient",
6672
6883
  gradientType: "linear",
6673
6884
  stops,
6674
- angle: asOoxmlAngle(numericAttr(getChild(grad, "lin"), "ang") ?? 0)
6885
+ angle: asOoxmlAngle(numericAttr2(getChild(grad, "lin"), "ang") ?? 0)
6675
6886
  };
6676
6887
  }
6677
6888
  function parseBlipFill(blipFill) {
@@ -6687,368 +6898,101 @@ function parseBlipFill(blipFill) {
6687
6898
  }
6688
6899
  function parseImageFillTile(tile) {
6689
6900
  if (tile === void 0) return void 0;
6690
- const flip = getAttr(tile, "flip") ?? "none";
6691
- return {
6692
- tx: asEmu2(numericAttr(tile, "tx") ?? 0),
6693
- ty: asEmu2(numericAttr(tile, "ty") ?? 0),
6694
- sx: (numericAttr(tile, "sx") ?? 1e5) / 1e5,
6695
- sy: (numericAttr(tile, "sy") ?? 1e5) / 1e5,
6696
- flip: flip === "x" || flip === "y" || flip === "xy" ? flip : "none",
6697
- align: parseRectangleAlignment(getAttr(tile, "algn"), "tl")
6698
- };
6699
- }
6700
- function parseRectangleAlignment(value, fallback) {
6701
- return parseEnumValueWithDefault(value, RECTANGLE_ALIGNMENT_TOKENS, fallback);
6702
- }
6703
- function parsePatternFill(pattern) {
6704
- const foregroundColor = parseColorElement(getChild(pattern, "fgClr"));
6705
- const backgroundColor = parseColorElement(getChild(pattern, "bgClr"));
6706
- if (foregroundColor === void 0 || backgroundColor === void 0) return void 0;
6707
- return {
6708
- kind: "pattern",
6709
- preset: getAttr(pattern, "prst") ?? "ltDnDiag",
6710
- foregroundColor,
6711
- backgroundColor
6712
- };
6713
- }
6714
- function parseOutline(spPr, nextId) {
6715
- const ln = getChild(spPr, "ln");
6716
- return parseLine(ln, nextId);
6717
- }
6718
- function parseLine(ln, nextId) {
6719
- if (!ln) return void 0;
6720
- const width = numericAttr(ln, "w");
6721
- const fill = parseFill(ln, nextId);
6722
- const dashStyle = parseDashStyle(getChild(ln, "prstDash"));
6723
- const customDash = parseCustomDash(ln);
6724
- const lineCap = parseLineCap(getAttr(ln, "cap"));
6725
- const lineJoin = parseLineJoin(ln);
6726
- const headEnd = parseArrowEndpoint(getChild(ln, "headEnd"));
6727
- const tailEnd = parseArrowEndpoint(getChild(ln, "tailEnd"));
6728
- return {
6729
- ...width !== void 0 ? { width: asEmu2(width) } : {},
6730
- ...fill !== void 0 ? { fill } : {},
6731
- ...dashStyle !== void 0 ? { dashStyle } : {},
6732
- ...customDash !== void 0 ? { customDash } : {},
6733
- ...lineCap !== void 0 ? { lineCap } : {},
6734
- ...lineJoin !== void 0 ? { lineJoin } : {},
6735
- ...headEnd !== void 0 ? { headEnd } : {},
6736
- ...tailEnd !== void 0 ? { tailEnd } : {}
6737
- };
6738
- }
6739
- function parseTransform(spPr) {
6740
- const xfrm = getChild(spPr, "xfrm");
6741
- if (!xfrm) return void 0;
6742
- const off = getChild(xfrm, "off");
6743
- const ext = getChild(xfrm, "ext");
6744
- const offsetX = numericAttr(off, "x");
6745
- const offsetY = numericAttr(off, "y");
6746
- const width = numericAttr(ext, "cx");
6747
- const height = numericAttr(ext, "cy");
6748
- if (offsetX === void 0 || offsetY === void 0 || width === void 0 || height === void 0) {
6749
- return void 0;
6750
- }
6751
- const rotation = numericAttr(xfrm, "rot");
6752
- const flipH = getAttr(xfrm, "flipH");
6753
- const flipV = getAttr(xfrm, "flipV");
6754
- return {
6755
- offsetX: asEmu2(offsetX),
6756
- offsetY: asEmu2(offsetY),
6757
- width: asEmu2(width),
6758
- height: asEmu2(height),
6759
- ...rotation !== void 0 ? { rotation: asOoxmlAngle(rotation) } : {},
6760
- ...isTrue(flipH) ? { flipHorizontal: true } : {},
6761
- ...isTrue(flipV) ? { flipVertical: true } : {}
6762
- };
6763
- }
6764
- function withTransforms(base, colorNode) {
6765
- const transforms = [];
6766
- for (const key of Object.keys(colorNode)) {
6767
- if (key.startsWith("@_")) continue;
6768
- const kind = localName(key);
6769
- const transformKind = parseEnumValue(kind, COLOR_TRANSFORM_KINDS);
6770
- if (transformKind === void 0) continue;
6771
- const value = colorNode[key];
6772
- const items = Array.isArray(value) ? value : [value];
6773
- for (const item of items) {
6774
- const raw = getAttr(unsafeOoxmlBoundaryAssertion(item), "val");
6775
- if (raw === void 0) continue;
6776
- const numeric = Number(raw);
6777
- if (!Number.isFinite(numeric)) continue;
6778
- transforms.push({
6779
- kind: transformKind,
6780
- value: asOoxmlPercent(numeric)
6781
- });
6782
- }
6783
- }
6784
- return transforms.length > 0 ? { ...base, transforms } : base;
6785
- }
6786
- function numericAttr(node, name) {
6787
- const raw = getAttr(node, name);
6788
- if (raw === void 0) return void 0;
6789
- const value = Number(raw);
6790
- return Number.isFinite(value) ? value : void 0;
6791
- }
6792
- function isTrue(value) {
6793
- return value === "1" || value === "true";
6794
- }
6795
- function parseDashStyle(prstDash) {
6796
- const value = getAttr(prstDash, "val");
6797
- return parseEnumValue(value, DASH_STYLES);
6798
- }
6799
- function parseCustomDash(ln) {
6800
- const custDash = getChild(ln, "custDash");
6801
- const segments = getChildArray(custDash, "ds");
6802
- if (segments.length === 0) return void 0;
6803
- return segments.flatMap((segment) => [
6804
- (numericAttr(segment, "d") ?? 1e5) / 1e5,
6805
- (numericAttr(segment, "sp") ?? 1e5) / 1e5
6806
- ]);
6807
- }
6808
- var LINE_CAP_MAP = {
6809
- flat: "butt",
6810
- sq: "square",
6811
- rnd: "round"
6812
- };
6813
- function parseLineCap(value) {
6814
- return value !== void 0 ? LINE_CAP_MAP[value] : void 0;
6815
- }
6816
- function parseLineJoin(ln) {
6817
- if (hasChild(ln, "round")) return "round";
6818
- if (hasChild(ln, "bevel")) return "bevel";
6819
- if (hasChild(ln, "miter")) return "miter";
6820
- return void 0;
6821
- }
6822
- function parseArrowEndpoint(node) {
6823
- if (!node) return void 0;
6824
- const type = parseEnumValue(getAttr(node, "type"), ARROW_TYPES2);
6825
- if (type === void 0) return void 0;
6826
- const width = getAttr(node, "w") ?? "med";
6827
- const length = getAttr(node, "len") ?? "med";
6828
- return {
6829
- type,
6830
- width: parseEnumValueWithDefault(width, ARROW_SIZES2, "med"),
6831
- length: parseEnumValueWithDefault(length, ARROW_SIZES2, "med")
6832
- };
6833
- }
6834
- var DASH_STYLES = /* @__PURE__ */ new Set([
6835
- "solid",
6836
- "dash",
6837
- "dot",
6838
- "dashDot",
6839
- "lgDash",
6840
- "lgDashDot",
6841
- "sysDash",
6842
- "sysDot"
6843
- ]);
6844
- var ARROW_TYPES2 = /* @__PURE__ */ new Set([
6845
- "triangle",
6846
- "stealth",
6847
- "diamond",
6848
- "oval",
6849
- "arrow"
6850
- ]);
6851
- var ARROW_SIZES2 = /* @__PURE__ */ new Set(["sm", "med", "lg"]);
6852
- function parseCustomGeometry(custGeom, orderedCustGeom) {
6853
- const pathLst = getChild(custGeom, "pathLst");
6854
- const paths = getChildArray(pathLst, "path");
6855
- if (paths.length === 0) return void 0;
6856
- const avGuides = parseGuideList(getChild(custGeom, "avLst"));
6857
- const guides = parseGuideList(getChild(custGeom, "gdLst"));
6858
- const orderedPaths = orderedChildEntries(
6859
- orderedChildChildren(orderedCustGeom, "pathLst"),
6860
- "path"
6861
- );
6862
- const result = [];
6863
- for (const [index, path] of paths.entries()) {
6864
- const width = numericAttr2(path, "w") ?? 0;
6865
- const height = numericAttr2(path, "h") ?? 0;
6866
- if (width === 0 && height === 0) continue;
6867
- const variables = evaluateGuides(avGuides, guides, width, height);
6868
- const commands = buildPathCommands(path, variables, orderedNodeChildren(orderedPaths[index]));
6869
- if (commands !== void 0) result.push({ width, height, commands });
6870
- }
6871
- return result.length > 0 ? result : void 0;
6872
- }
6873
- function parseGuideList(parent) {
6874
- return getChildArray(parent, "gd").map((guide) => ({
6875
- name: getAttr(guide, "name") ?? "",
6876
- formula: getAttr(guide, "fmla") ?? ""
6877
- })).filter((guide) => guide.name !== "" && guide.formula !== "");
6878
- }
6879
- function buildPathCommands(path, variables, orderedCommands) {
6880
- const parts = [];
6881
- let currentX = 0;
6882
- let currentY = 0;
6883
- let startX = 0;
6884
- let startY = 0;
6885
- for (const { local, nodes } of pathCommandNodes(path, orderedCommands)) {
6886
- for (const node of nodes) {
6887
- if (local === "moveTo") {
6888
- const point = firstPoint(node, variables);
6889
- if (point !== void 0) {
6890
- parts.push(`M ${point.x} ${point.y}`);
6891
- currentX = point.x;
6892
- currentY = point.y;
6893
- startX = point.x;
6894
- startY = point.y;
6895
- }
6896
- } else if (local === "lnTo") {
6897
- const point = firstPoint(node, variables);
6898
- if (point !== void 0) {
6899
- parts.push(`L ${point.x} ${point.y}`);
6900
- currentX = point.x;
6901
- currentY = point.y;
6902
- }
6903
- } else if (local === "cubicBezTo") {
6904
- const points = allPoints(node, variables);
6905
- if (points.length >= 3) {
6906
- parts.push(`C ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
6907
- currentX = points[points.length - 1].x;
6908
- currentY = points[points.length - 1].y;
6909
- }
6910
- } else if (local === "quadBezTo") {
6911
- const points = allPoints(node, variables);
6912
- if (points.length >= 2) {
6913
- parts.push(`Q ${points.map((point) => `${point.x} ${point.y}`).join(", ")}`);
6914
- currentX = points[points.length - 1].x;
6915
- currentY = points[points.length - 1].y;
6916
- }
6917
- } else if (local === "arcTo") {
6918
- const arc = convertArcTo(node, currentX, currentY, variables);
6919
- if (arc !== void 0) {
6920
- parts.push(arc.command);
6921
- currentX = arc.endX;
6922
- currentY = arc.endY;
6923
- }
6924
- } else if (local === "close") {
6925
- parts.push("Z");
6926
- currentX = startX;
6927
- currentY = startY;
6928
- }
6929
- }
6930
- }
6931
- return parts.length > 0 ? parts.join(" ") : void 0;
6932
- }
6933
- function pathCommandNodes(path, orderedCommands) {
6934
- if (orderedCommands === void 0) {
6935
- return Object.keys(path).filter((key) => !key.startsWith("@_")).map((key) => ({ local: localName(key), nodes: getChildArray(path, localName(key)) }));
6936
- }
6937
- const counters = {};
6938
- const result = [];
6939
- for (const command of orderedCommands) {
6940
- const key = orderedNodeKey(command);
6941
- if (key === void 0) continue;
6942
- const local = localName(key);
6943
- const index = counters[local] ?? 0;
6944
- counters[local] = index + 1;
6945
- const node = getChildArray(path, local)[index];
6946
- if (node !== void 0) result.push({ local, nodes: [node] });
6947
- }
6948
- return result;
6949
- }
6950
- function firstPoint(node, variables) {
6951
- return allPoints(node, variables)[0];
6952
- }
6953
- function allPoints(node, variables) {
6954
- return getChildArray(node, "pt").map((point) => ({
6955
- x: resolveValue(getAttr(point, "x") ?? "0", variables),
6956
- y: resolveValue(getAttr(point, "y") ?? "0", variables)
6957
- }));
6958
- }
6959
- function convertArcTo(arc, currentX, currentY, variables) {
6960
- const widthRadius = resolveValue(getAttr(arc, "wR") ?? "0", variables);
6961
- const heightRadius = resolveValue(getAttr(arc, "hR") ?? "0", variables);
6962
- const startAngle = resolveValue(getAttr(arc, "stAng") ?? "0", variables);
6963
- const sweepAngle = resolveValue(getAttr(arc, "swAng") ?? "0", variables);
6964
- if (widthRadius === 0 && heightRadius === 0 || sweepAngle === 0) return void 0;
6965
- const startRadians = startAngle / 6e4 * (Math.PI / 180);
6966
- const endRadians = (startAngle + sweepAngle) / 6e4 * (Math.PI / 180);
6967
- const centerX = currentX - widthRadius * Math.cos(startRadians);
6968
- const centerY = currentY - heightRadius * Math.sin(startRadians);
6969
- const endX = centerX + widthRadius * Math.cos(endRadians);
6970
- const endY = centerY + heightRadius * Math.sin(endRadians);
6971
- const largeArcFlag = Math.abs(sweepAngle / 6e4) > 180 ? 1 : 0;
6972
- const sweepFlag = sweepAngle > 0 ? 1 : 0;
6901
+ const flip = getAttr(tile, "flip") ?? "none";
6973
6902
  return {
6974
- command: `A ${round4(widthRadius)} ${round4(heightRadius)} 0 ${largeArcFlag} ${sweepFlag} ${round4(endX)} ${round4(endY)}`,
6975
- endX,
6976
- endY
6903
+ tx: asEmu2(numericAttr2(tile, "tx") ?? 0),
6904
+ ty: asEmu2(numericAttr2(tile, "ty") ?? 0),
6905
+ sx: (numericAttr2(tile, "sx") ?? 1e5) / 1e5,
6906
+ sy: (numericAttr2(tile, "sy") ?? 1e5) / 1e5,
6907
+ flip: flip === "x" || flip === "y" || flip === "xy" ? flip : "none",
6908
+ align: parseRectangleAlignment(getAttr(tile, "algn"), "tl")
6977
6909
  };
6978
6910
  }
6979
- function evaluateGuides(avGuides, guides, width, height) {
6980
- const variables = createBuiltinVariables(width, height);
6981
- for (const guide of avGuides) variables[guide.name] = evaluateFormula(guide.formula, variables);
6982
- for (const guide of guides) variables[guide.name] = evaluateFormula(guide.formula, variables);
6983
- return variables;
6911
+ function parseRectangleAlignment(value, fallback) {
6912
+ return parseEnumValueWithDefault(value, RECTANGLE_ALIGNMENT_TOKENS, fallback);
6984
6913
  }
6985
- function createBuiltinVariables(width, height) {
6914
+ function parsePatternFill(pattern) {
6915
+ const foregroundColor = parseColorElement(getChild(pattern, "fgClr"));
6916
+ const backgroundColor = parseColorElement(getChild(pattern, "bgClr"));
6917
+ if (foregroundColor === void 0 || backgroundColor === void 0) return void 0;
6986
6918
  return {
6987
- w: width,
6988
- h: height,
6989
- l: 0,
6990
- t: 0,
6991
- r: width,
6992
- b: height,
6993
- wd2: width / 2,
6994
- hd2: height / 2,
6995
- wd4: width / 4,
6996
- hd4: height / 4,
6997
- ss: Math.min(width, height),
6998
- ls: Math.max(width, height),
6999
- cd2: 108e5,
7000
- cd4: 54e5,
7001
- cd8: 27e5,
7002
- "3cd4": 162e5
6919
+ kind: "pattern",
6920
+ preset: getAttr(pattern, "prst") ?? "ltDnDiag",
6921
+ foregroundColor,
6922
+ backgroundColor
7003
6923
  };
7004
6924
  }
7005
- function evaluateFormula(formula, variables) {
7006
- const tokens = formula.trim().split(/\s+/);
7007
- const op = tokens[0];
7008
- const resolve = (token) => {
7009
- if (token === void 0) return 0;
7010
- const value = Number(token);
7011
- return Number.isNaN(value) ? variables[token] ?? 0 : value;
6925
+ function parseOutline(spPr, nextId) {
6926
+ const ln = getChild(spPr, "ln");
6927
+ return parseLine(ln, nextId);
6928
+ }
6929
+ function parseLine(ln, nextId) {
6930
+ if (!ln) return void 0;
6931
+ const width = numericAttr2(ln, "w");
6932
+ const fill = parseFill(ln, nextId);
6933
+ const dashStyle = parseDashStyle(getChild(ln, "prstDash"));
6934
+ const customDash = parseCustomDash(ln);
6935
+ const lineCap = parseLineCap(getAttr(ln, "cap"));
6936
+ const lineJoin = parseLineJoin(ln);
6937
+ const headEnd = parseArrowEndpoint(getChild(ln, "headEnd"));
6938
+ const tailEnd = parseArrowEndpoint(getChild(ln, "tailEnd"));
6939
+ return {
6940
+ ...width !== void 0 ? { width: asEmu2(width) } : {},
6941
+ ...fill !== void 0 ? { fill } : {},
6942
+ ...dashStyle !== void 0 ? { dashStyle } : {},
6943
+ ...customDash !== void 0 ? { customDash } : {},
6944
+ ...lineCap !== void 0 ? { lineCap } : {},
6945
+ ...lineJoin !== void 0 ? { lineJoin } : {},
6946
+ ...headEnd !== void 0 ? { headEnd } : {},
6947
+ ...tailEnd !== void 0 ? { tailEnd } : {}
7012
6948
  };
7013
- if (op === "val") return resolve(tokens[1]);
7014
- if (op === "+-") return resolve(tokens[1]) + resolve(tokens[2]) - resolve(tokens[3]);
7015
- if (op === "*/")
7016
- return Math.round(resolve(tokens[1]) * resolve(tokens[2]) / (resolve(tokens[3]) || 1));
7017
- if (op === "+/")
7018
- return Math.round((resolve(tokens[1]) + resolve(tokens[2])) / (resolve(tokens[3]) || 1));
7019
- if (op === "pin")
7020
- return Math.max(resolve(tokens[1]), Math.min(resolve(tokens[2]), resolve(tokens[3])));
7021
- if (op === "min") return Math.min(resolve(tokens[1]), resolve(tokens[2]));
7022
- if (op === "max") return Math.max(resolve(tokens[1]), resolve(tokens[2]));
7023
- if (op === "abs") return Math.abs(resolve(tokens[1]));
7024
- if (op === "sqrt") return Math.round(Math.sqrt(resolve(tokens[1])));
7025
- if (op === "sin") return Math.round(resolve(tokens[1]) * Math.sin(toRadians(resolve(tokens[2]))));
7026
- if (op === "cos") return Math.round(resolve(tokens[1]) * Math.cos(toRadians(resolve(tokens[2]))));
7027
- if (op === "tan") return Math.round(resolve(tokens[1]) * Math.tan(toRadians(resolve(tokens[2]))));
7028
- if (op === "at2")
7029
- return Math.round(Math.atan2(resolve(tokens[2]), resolve(tokens[1])) * (180 / Math.PI) * 6e4);
7030
- if (op === "mod") {
7031
- const a = resolve(tokens[1]);
7032
- const b = resolve(tokens[2]);
7033
- const c = resolve(tokens[3]);
7034
- return Math.round(Math.sqrt(a * a + b * b + c * c));
7035
- }
7036
- if (op === "cat2") {
7037
- return Math.round(
7038
- resolve(tokens[1]) * Math.cos(Math.atan2(resolve(tokens[3]), resolve(tokens[2])))
7039
- );
7040
- }
7041
- if (op === "sat2") {
7042
- return Math.round(
7043
- resolve(tokens[1]) * Math.sin(Math.atan2(resolve(tokens[3]), resolve(tokens[2])))
7044
- );
6949
+ }
6950
+ function parseTransform(spPr) {
6951
+ const xfrm = getChild(spPr, "xfrm");
6952
+ if (!xfrm) return void 0;
6953
+ const off = getChild(xfrm, "off");
6954
+ const ext = getChild(xfrm, "ext");
6955
+ const offsetX = numericAttr2(off, "x");
6956
+ const offsetY = numericAttr2(off, "y");
6957
+ const width = numericAttr2(ext, "cx");
6958
+ const height = numericAttr2(ext, "cy");
6959
+ if (offsetX === void 0 || offsetY === void 0 || width === void 0 || height === void 0) {
6960
+ return void 0;
7045
6961
  }
7046
- if (op === "?:") return resolve(tokens[1]) > 0 ? resolve(tokens[2]) : resolve(tokens[3]);
7047
- return 0;
6962
+ const rotation = numericAttr2(xfrm, "rot");
6963
+ const flipH = getAttr(xfrm, "flipH");
6964
+ const flipV = getAttr(xfrm, "flipV");
6965
+ return {
6966
+ offsetX: asEmu2(offsetX),
6967
+ offsetY: asEmu2(offsetY),
6968
+ width: asEmu2(width),
6969
+ height: asEmu2(height),
6970
+ ...rotation !== void 0 ? { rotation: asOoxmlAngle(rotation) } : {},
6971
+ ...isTrue(flipH) ? { flipHorizontal: true } : {},
6972
+ ...isTrue(flipV) ? { flipVertical: true } : {}
6973
+ };
7048
6974
  }
7049
- function resolveValue(value, variables) {
7050
- const numeric = Number(value);
7051
- return Number.isNaN(numeric) ? variables[value] ?? 0 : numeric;
6975
+ function withTransforms(base, colorNode) {
6976
+ const transforms = [];
6977
+ for (const key of Object.keys(colorNode)) {
6978
+ if (key.startsWith("@_")) continue;
6979
+ const kind = localName(key);
6980
+ const transformKind = parseEnumValue(kind, COLOR_TRANSFORM_KINDS);
6981
+ if (transformKind === void 0) continue;
6982
+ const value = colorNode[key];
6983
+ const items = Array.isArray(value) ? value : [value];
6984
+ for (const item of items) {
6985
+ const raw = getAttr(unsafeOoxmlBoundaryAssertion(item), "val");
6986
+ if (raw === void 0) continue;
6987
+ const numeric = Number(raw);
6988
+ if (!Number.isFinite(numeric)) continue;
6989
+ transforms.push({
6990
+ kind: transformKind,
6991
+ value: asOoxmlPercent(numeric)
6992
+ });
6993
+ }
6994
+ }
6995
+ return transforms.length > 0 ? { ...base, transforms } : base;
7052
6996
  }
7053
6997
  function numericAttr2(node, name) {
7054
6998
  const raw = getAttr(node, name);
@@ -7056,31 +7000,66 @@ function numericAttr2(node, name) {
7056
7000
  const value = Number(raw);
7057
7001
  return Number.isFinite(value) ? value : void 0;
7058
7002
  }
7059
- function round4(value) {
7060
- return Math.round(value * 1e3) / 1e3;
7003
+ function isTrue(value) {
7004
+ return value === "1" || value === "true";
7061
7005
  }
7062
- function toRadians(ooxmlAngle) {
7063
- return ooxmlAngle / 6e4 * (Math.PI / 180);
7006
+ function parseDashStyle(prstDash) {
7007
+ const value = getAttr(prstDash, "val");
7008
+ return parseEnumValue(value, DASH_STYLES);
7064
7009
  }
7065
- function orderedChildChildren(parent, childLocalName) {
7066
- const child = orderedChildEntries(parent, childLocalName)[0];
7067
- return orderedNodeChildren(child);
7010
+ function parseCustomDash(ln) {
7011
+ const custDash = getChild(ln, "custDash");
7012
+ const segments = getChildArray(custDash, "ds");
7013
+ if (segments.length === 0) return void 0;
7014
+ return segments.flatMap((segment) => [
7015
+ (numericAttr2(segment, "d") ?? 1e5) / 1e5,
7016
+ (numericAttr2(segment, "sp") ?? 1e5) / 1e5
7017
+ ]);
7068
7018
  }
7069
- function orderedChildEntries(parent, childLocalName) {
7070
- if (parent === void 0) return [];
7071
- return parent.filter((child) => {
7072
- const key = orderedNodeKey(child);
7073
- return key !== void 0 && localName(key) === childLocalName;
7074
- });
7019
+ var LINE_CAP_MAP = {
7020
+ flat: "butt",
7021
+ sq: "square",
7022
+ rnd: "round"
7023
+ };
7024
+ function parseLineCap(value) {
7025
+ return value !== void 0 ? LINE_CAP_MAP[value] : void 0;
7075
7026
  }
7076
- function orderedNodeChildren(node) {
7077
- const key = node !== void 0 ? orderedNodeKey(node) : void 0;
7078
- const value = key !== void 0 ? node?.[key] : void 0;
7079
- return Array.isArray(value) ? value : void 0;
7027
+ function parseLineJoin(ln) {
7028
+ if (hasChild(ln, "round")) return "round";
7029
+ if (hasChild(ln, "bevel")) return "bevel";
7030
+ if (hasChild(ln, "miter")) return "miter";
7031
+ return void 0;
7080
7032
  }
7081
- function orderedNodeKey(node) {
7082
- return Object.keys(node).find((key) => key !== ":@");
7033
+ function parseArrowEndpoint(node) {
7034
+ if (!node) return void 0;
7035
+ const type = parseEnumValue(getAttr(node, "type"), ARROW_TYPES);
7036
+ if (type === void 0) return void 0;
7037
+ const width = getAttr(node, "w") ?? "med";
7038
+ const length = getAttr(node, "len") ?? "med";
7039
+ return {
7040
+ type,
7041
+ width: parseEnumValueWithDefault(width, ARROW_SIZES, "med"),
7042
+ length: parseEnumValueWithDefault(length, ARROW_SIZES, "med")
7043
+ };
7083
7044
  }
7045
+ var DASH_STYLES = /* @__PURE__ */ new Set([
7046
+ "solid",
7047
+ "dash",
7048
+ "dot",
7049
+ "dashDot",
7050
+ "lgDash",
7051
+ "lgDashDot",
7052
+ "sysDash",
7053
+ "sysDot"
7054
+ ]);
7055
+ var ARROW_TYPES = /* @__PURE__ */ new Set([
7056
+ "triangle",
7057
+ "stealth",
7058
+ "diamond",
7059
+ "oval",
7060
+ "arrow"
7061
+ ]);
7062
+ var ARROW_SIZES = /* @__PURE__ */ new Set(["sm", "med", "lg"]);
7084
7063
  var KNOWN_TXBODY_CHILDREN = /* @__PURE__ */ new Set(["bodyPr", "lstStyle", "p"]);
7085
7064
  var KNOWN_PARAGRAPH_CHILDREN = /* @__PURE__ */ new Set([
7086
7065
  "pPr",
@@ -7302,20 +7281,20 @@ function splitInterleavedParagraph(p, orderedChildren, partPath, nextId, ownerNo
7302
7281
  }
7303
7282
  function parseBodyProperties(bodyPr) {
7304
7283
  if (!bodyPr) return void 0;
7305
- const marginLeft = numericAttr(bodyPr, "lIns");
7306
- const marginRight = numericAttr(bodyPr, "rIns");
7307
- const marginTop = numericAttr(bodyPr, "tIns");
7308
- const marginBottom = numericAttr(bodyPr, "bIns");
7284
+ const marginLeft = numericAttr2(bodyPr, "lIns");
7285
+ const marginRight = numericAttr2(bodyPr, "rIns");
7286
+ const marginTop = numericAttr2(bodyPr, "tIns");
7287
+ const marginBottom = numericAttr2(bodyPr, "bIns");
7309
7288
  const anchorToken = getAttr(bodyPr, "anchor");
7310
7289
  const anchor = anchorToken !== void 0 ? ANCHOR_MAP[anchorToken] : void 0;
7311
7290
  const wrap = parseWrap(getAttr(bodyPr, "wrap"));
7312
7291
  const vert = parseVerticalType(getAttr(bodyPr, "vert"));
7313
- const numCol = numericAttr(bodyPr, "numCol");
7292
+ const numCol = numericAttr2(bodyPr, "numCol");
7314
7293
  const normAutofit = getChild(bodyPr, "normAutofit");
7315
7294
  const hasSpAutofit = getChild(bodyPr, "spAutoFit") !== void 0;
7316
7295
  const hasNoAutofit = getChild(bodyPr, "noAutofit") !== void 0;
7317
- const fontScale = numericAttr(normAutofit, "fontScale");
7318
- const lnSpcReduction = numericAttr(normAutofit, "lnSpcReduction");
7296
+ const fontScale = numericAttr2(normAutofit, "fontScale");
7297
+ const lnSpcReduction = numericAttr2(normAutofit, "lnSpcReduction");
7319
7298
  const properties = {
7320
7299
  ...marginLeft !== void 0 ? { marginLeft: emu(marginLeft) } : {},
7321
7300
  ...marginRight !== void 0 ? { marginRight: emu(marginRight) } : {},
@@ -7447,16 +7426,16 @@ function parseParagraphProperties(pPr) {
7447
7426
  if (!pPr) return void 0;
7448
7427
  const alignToken = getAttr(pPr, "algn");
7449
7428
  const align = alignToken !== void 0 ? ALIGN_MAP[alignToken] : void 0;
7450
- const level = numericAttr(pPr, "lvl");
7429
+ const level = numericAttr2(pPr, "lvl");
7451
7430
  const lineSpacing = parseSpacing(getChild(pPr, "lnSpc"));
7452
7431
  const spaceBefore = parseSpacing(getChild(pPr, "spcBef"));
7453
7432
  const spaceAfter = parseSpacing(getChild(pPr, "spcAft"));
7454
- const marginLeft = numericAttr(pPr, "marL");
7455
- const indent = numericAttr(pPr, "indent");
7433
+ const marginLeft = numericAttr2(pPr, "marL");
7434
+ const indent = numericAttr2(pPr, "indent");
7456
7435
  const bullet = parseBullet(pPr);
7457
7436
  const bulletFont = getAttr(getChild(pPr, "buFont"), "typeface");
7458
7437
  const bulletColor = parseColorElement(getChild(pPr, "buClr"));
7459
- const bulletSizePct = numericAttr(getChild(pPr, "buSzPct"), "val");
7438
+ const bulletSizePct = numericAttr2(getChild(pPr, "buSzPct"), "val");
7460
7439
  const tabStops = parseTabStops(pPr);
7461
7440
  const defaultRunProperties = parseRunProperties(getChild(pPr, "defRPr"));
7462
7441
  const properties = {
@@ -7478,14 +7457,14 @@ function parseParagraphProperties(pPr) {
7478
7457
  }
7479
7458
  function parseTabStops(pPr) {
7480
7459
  return getChildArray(getChild(pPr, "tabLst"), "tab").map((tab) => ({
7481
- position: emu(numericAttr(tab, "pos") ?? 0),
7460
+ position: emu(numericAttr2(tab, "pos") ?? 0),
7482
7461
  alignment: unsafeOoxmlBoundaryAssertion(getAttr(tab, "algn")) ?? "l"
7483
7462
  }));
7484
7463
  }
7485
7464
  function parseSpacing(node) {
7486
- const points = numericAttr(getChild(node, "spcPts"), "val");
7465
+ const points = numericAttr2(getChild(node, "spcPts"), "val");
7487
7466
  if (points !== void 0) return { type: "pts", value: asHundredthPt2(points) };
7488
- const percent = numericAttr(getChild(node, "spcPct"), "val");
7467
+ const percent = numericAttr2(getChild(node, "spcPct"), "val");
7489
7468
  if (percent !== void 0) return { type: "pct", value: percent };
7490
7469
  return void 0;
7491
7470
  }
@@ -7502,7 +7481,7 @@ function parseBullet(pPr) {
7502
7481
  return {
7503
7482
  type: "autoNum",
7504
7483
  scheme: parseEnumValueWithDefault(scheme, VALID_AUTO_NUM_SCHEMES, "arabicPeriod"),
7505
- startAt: numericAttr(buAutoNum, "startAt") ?? 1
7484
+ startAt: numericAttr2(buAutoNum, "startAt") ?? 1
7506
7485
  };
7507
7486
  }
7508
7487
  return void 0;
@@ -7547,8 +7526,8 @@ function parseRunProperties(rPr) {
7547
7526
  const italic = getAttr(rPr, "i");
7548
7527
  const underline = getAttr(rPr, "u");
7549
7528
  const strike = getAttr(rPr, "strike");
7550
- const baseline = numericAttr(rPr, "baseline");
7551
- const size = numericAttr(rPr, "sz");
7529
+ const baseline = numericAttr2(rPr, "baseline");
7530
+ const size = numericAttr2(rPr, "sz");
7552
7531
  const typeface = getAttr(getChild(rPr, "latin"), "typeface");
7553
7532
  const typefaceEa = getAttr(getChild(rPr, "ea"), "typeface");
7554
7533
  const typefaceCs = getAttr(getChild(rPr, "cs"), "typeface");
@@ -7826,7 +7805,7 @@ function parseConnectorConnection(cNvCxnSpPr) {
7826
7805
  }
7827
7806
  function parseConnectorConnectionEndpoint(node) {
7828
7807
  const shapeId = getAttr(node, "id");
7829
- const connectionSiteIndex = numericAttr(node, "idx");
7808
+ const connectionSiteIndex = numericAttr2(node, "idx");
7830
7809
  if (shapeId === void 0 || connectionSiteIndex === void 0) return void 0;
7831
7810
  return {
7832
7811
  shapeId: asSourceNodeId(shapeId),
@@ -7847,7 +7826,7 @@ function parseShapeStyle(style) {
7847
7826
  }
7848
7827
  function parseStyleReference(ref) {
7849
7828
  if (ref === void 0) return void 0;
7850
- const index = numericAttr(ref, "idx") ?? 0;
7829
+ const index = numericAttr2(ref, "idx") ?? 0;
7851
7830
  const color = parseColorElement(ref);
7852
7831
  return {
7853
7832
  index,
@@ -8182,8 +8161,8 @@ function parseTableCell(tc, partPath, nextId, tableNodeId, tableOrderingSlot, ro
8182
8161
  ...textBody !== void 0 ? { textBody } : {},
8183
8162
  ...fill !== void 0 ? { fill } : {},
8184
8163
  ...borders !== void 0 ? { borders } : {},
8185
- gridSpan: numericAttr(tc, "gridSpan") ?? 1,
8186
- rowSpan: numericAttr(tc, "rowSpan") ?? 1,
8164
+ gridSpan: numericAttr2(tc, "gridSpan") ?? 1,
8165
+ rowSpan: numericAttr2(tc, "rowSpan") ?? 1,
8187
8166
  hMerge: isTrue(getAttr(tc, "hMerge") ?? getAttr(tcPr, "hMerge")),
8188
8167
  vMerge: isTrue(getAttr(tc, "vMerge") ?? getAttr(tcPr, "vMerge")),
8189
8168
  ...rawSidecars.length > 0 ? { rawSidecars } : {}
@@ -8216,7 +8195,7 @@ function parseRawShapeNode(key, node, partPath, nextId, orderingSlot) {
8216
8195
  function parsePlaceholder(ph) {
8217
8196
  if (!ph) return void 0;
8218
8197
  const type = getAttr(ph, "type");
8219
- const index = numericAttr(ph, "idx");
8198
+ const index = numericAttr2(ph, "idx");
8220
8199
  if (type === void 0 && index === void 0) return void 0;
8221
8200
  return {
8222
8201
  ...type !== void 0 ? { type } : {},
@@ -8256,10 +8235,10 @@ function parseChildTransform(grpSpPr, fallback) {
8256
8235
  const xfrm = getChild(grpSpPr, "xfrm");
8257
8236
  const childOff = getChild(xfrm, "chOff");
8258
8237
  const childExt = getChild(xfrm, "chExt");
8259
- const offsetX = numericAttr(childOff, "x") ?? 0;
8260
- const offsetY = numericAttr(childOff, "y") ?? 0;
8261
- const width = numericAttr(childExt, "cx") ?? fallback?.width;
8262
- const height = numericAttr(childExt, "cy") ?? fallback?.height;
8238
+ const offsetX = numericAttr2(childOff, "x") ?? 0;
8239
+ const offsetY = numericAttr2(childOff, "y") ?? 0;
8240
+ const width = numericAttr2(childExt, "cx") ?? fallback?.width;
8241
+ const height = numericAttr2(childExt, "cy") ?? fallback?.height;
8263
8242
  if (width === void 0 || height === void 0) return void 0;
8264
8243
  return {
8265
8244
  offsetX: asEmu2(offsetX),
@@ -8270,10 +8249,10 @@ function parseChildTransform(grpSpPr, fallback) {
8270
8249
  }
8271
8250
  function parseCrop(srcRect) {
8272
8251
  if (!srcRect) return void 0;
8273
- const left = numericAttr(srcRect, "l");
8274
- const top = numericAttr(srcRect, "t");
8275
- const right = numericAttr(srcRect, "r");
8276
- const bottom = numericAttr(srcRect, "b");
8252
+ const left = numericAttr2(srcRect, "l");
8253
+ const top = numericAttr2(srcRect, "t");
8254
+ const right = numericAttr2(srcRect, "r");
8255
+ const bottom = numericAttr2(srcRect, "b");
8277
8256
  const crop = {
8278
8257
  ...left !== void 0 ? { left: asOoxmlPercent(left) } : {},
8279
8258
  ...top !== void 0 ? { top: asOoxmlPercent(top) } : {},
@@ -8285,10 +8264,10 @@ function parseCrop(srcRect) {
8285
8264
  function parseStretch(stretch) {
8286
8265
  const fillRect = getChild(stretch, "fillRect");
8287
8266
  if (fillRect === void 0) return void 0;
8288
- const left = (numericAttr(fillRect, "l") ?? 0) / 1e5;
8289
- const top = (numericAttr(fillRect, "t") ?? 0) / 1e5;
8290
- const right = (numericAttr(fillRect, "r") ?? 0) / 1e5;
8291
- const bottom = (numericAttr(fillRect, "b") ?? 0) / 1e5;
8267
+ const left = (numericAttr2(fillRect, "l") ?? 0) / 1e5;
8268
+ const top = (numericAttr2(fillRect, "t") ?? 0) / 1e5;
8269
+ const right = (numericAttr2(fillRect, "r") ?? 0) / 1e5;
8270
+ const bottom = (numericAttr2(fillRect, "b") ?? 0) / 1e5;
8292
8271
  if (left === 0 && top === 0 && right === 0 && bottom === 0) return void 0;
8293
8272
  return { left, top, right, bottom };
8294
8273
  }
@@ -8297,7 +8276,7 @@ function sourceNodeId(cNvPr) {
8297
8276
  return id !== void 0 ? asSourceNodeId(id) : void 0;
8298
8277
  }
8299
8278
  function emuAttr(node, attrName) {
8300
- return asEmu2(numericAttr(node, attrName) ?? 0);
8279
+ return asEmu2(numericAttr2(node, attrName) ?? 0);
8301
8280
  }
8302
8281
  var EMPTY_KNOWN = /* @__PURE__ */ new Set();
8303
8282
  function orderedChildChildren2(parent, childLocalName) {
@@ -8329,6 +8308,75 @@ function orderedNestedChildChildren(node, parentLocalName, childLocalName) {
8329
8308
  childLocalName
8330
8309
  );
8331
8310
  }
8311
+ var xmlBuilder = new import_fast_xml_parser2.XMLBuilder({
8312
+ ignoreAttributes: false,
8313
+ attributeNamePrefix: "@_",
8314
+ format: false,
8315
+ suppressEmptyNode: true
8316
+ });
8317
+ var EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS = {
8318
+ bold: (value) => requireBooleanOrUndefined(value, "bold"),
8319
+ italic: (value) => requireBooleanOrUndefined(value, "italic"),
8320
+ underline: (value) => requireBooleanOrUndefined(value, "underline"),
8321
+ fontSize: (value) => {
8322
+ if (value !== void 0 && (!Number.isFinite(value) || value <= 0)) {
8323
+ throw new Error("updateTextRunProperties: fontSize must be a finite positive pt value");
8324
+ }
8325
+ },
8326
+ color: (value) => {
8327
+ if (value === void 0) return;
8328
+ if (value.kind !== "srgb") {
8329
+ throw new Error("updateTextRunProperties: only srgb text run color is supported");
8330
+ }
8331
+ if (!/^[0-9A-Fa-f]{6}$/.test(value.hex)) {
8332
+ throw new Error("updateTextRunProperties: srgb text run color must be a 6-digit hex value");
8333
+ }
8334
+ },
8335
+ typeface: (value) => {
8336
+ if (value !== void 0 && value.trim() === "") {
8337
+ throw new Error("updateTextRunProperties: typeface must be a non-empty string");
8338
+ }
8339
+ }
8340
+ };
8341
+ var EDITABLE_TEXT_RUN_PROPERTIES = Object.keys(EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS).filter(
8342
+ (property) => property in EDITABLE_TEXT_RUN_PROPERTY_VALIDATORS
8343
+ );
8344
+ var EDITABLE_TEXT_RUN_PROPERTY_SET = new Set(EDITABLE_TEXT_RUN_PROPERTIES);
8345
+ var EDITABLE_PARAGRAPH_PROPERTIES = [
8346
+ "align",
8347
+ "level",
8348
+ "bullet"
8349
+ ];
8350
+ var EDITABLE_PARAGRAPH_PROPERTY_SET = new Set(EDITABLE_PARAGRAPH_PROPERTIES);
8351
+ function requireBooleanOrUndefined(value, fieldName) {
8352
+ if (value !== void 0 && typeof value !== "boolean") {
8353
+ throw new Error(`updateTextRunProperties: ${fieldName} must be a boolean value`);
8354
+ }
8355
+ }
8356
+ function asEmu2(value) {
8357
+ return unsafeBrandAssertion2(value);
8358
+ }
8359
+ function asPt(value) {
8360
+ return unsafeBrandAssertion2(value);
8361
+ }
8362
+ function asHundredthPt2(value) {
8363
+ return unsafeBrandAssertion2(value);
8364
+ }
8365
+ function asOoxmlPercent(value) {
8366
+ return unsafeBrandAssertion2(value);
8367
+ }
8368
+ function asOoxmlAngle(value) {
8369
+ return unsafeBrandAssertion2(value);
8370
+ }
8371
+ var textEncoder = new TextEncoder();
8372
+ var ROOT_PART = asPartPath("");
8373
+ var PRESENTATION_PART = asPartPath("ppt/presentation.xml");
8374
+ var SLIDE_PART = asPartPath("ppt/slides/slide1.xml");
8375
+ var SLIDE_LAYOUT_PART = asPartPath("ppt/slideLayouts/slideLayout1.xml");
8376
+ var SLIDE_MASTER_PART = asPartPath("ppt/slideMasters/slideMaster1.xml");
8377
+ var THEME_PART = asPartPath("ppt/theme/theme1.xml");
8378
+ var APP_PROPS_PART = asPartPath("docProps/app.xml");
8379
+ var CORE_PROPS_PART = asPartPath("docProps/core.xml");
8332
8380
  var DEFAULT_COLOR_MAP = {
8333
8381
  bg1: "lt1",
8334
8382
  tx1: "dk1",
@@ -8747,7 +8795,7 @@ var DIAGRAM_DRAWING_REL_TYPES = /* @__PURE__ */ new Set([
8747
8795
  "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing",
8748
8796
  "http://purl.oclc.org/ooxml/officeDocument/relationships/diagramDrawing"
8749
8797
  ]);
8750
- var textDecoder = new TextDecoder();
8798
+ var textDecoder2 = new TextDecoder();
8751
8799
  var DEFAULT_TABLE_STYLE_BORDERS = {
8752
8800
  top: {
8753
8801
  width: asEmu2(12700),
@@ -8892,7 +8940,7 @@ function computeConnectorElement(context, connector, layer, partPath) {
8892
8940
  sourceNode: connector,
8893
8941
  ...connector.transform !== void 0 ? { transform: connector.transform } : {},
8894
8942
  ...connector.geometry !== void 0 ? { geometry: connector.geometry } : {},
8895
- ...connector.outline !== void 0 ? { outline: computeOutline(context, connector.outline, partPath) } : connector.style?.lineRef !== void 0 ? { outline: resolveLineReference(context, connector.style.lineRef, partPath) } : {},
8943
+ ...computedOutlineProperty(context, connector.outline, connector.style?.lineRef, partPath),
8896
8944
  ...effects !== void 0 ? { effects } : {}
8897
8945
  };
8898
8946
  }
@@ -8936,7 +8984,7 @@ function computeShapeElement(context, shape, layer, partPath) {
8936
8984
  ...transform !== void 0 ? { transform } : {},
8937
8985
  ...geometry !== void 0 ? { geometry } : {},
8938
8986
  ...shape.fill !== void 0 ? { fill: computeFill(context, shape.fill, partPath) } : shape.style?.fillRef !== void 0 ? { fill: resolveFillReference(context, shape.style.fillRef, partPath) } : {},
8939
- ...shape.outline !== void 0 ? { outline: computeOutline(context, shape.outline, partPath) } : shape.style?.lineRef !== void 0 ? { outline: resolveLineReference(context, shape.style.lineRef, partPath) } : {},
8987
+ ...computedOutlineProperty(context, shape.outline, shape.style?.lineRef, partPath),
8940
8988
  ...effects !== void 0 ? { effects } : {},
8941
8989
  ...shape.textBody !== void 0 ? {
8942
8990
  textBody: computeTextBody(
@@ -8951,7 +8999,7 @@ function computeShapeElement(context, shape, layer, partPath) {
8951
8999
  }
8952
9000
  function computeImageElement(context, image, layer, partPath) {
8953
9001
  const relationship = resolveComputedRelationships(context.source, partPath).find(
8954
- (rel) => rel.id === image.blipRelationshipId && rel.type === IMAGE_REL_TYPE2
9002
+ (rel2) => rel2.id === image.blipRelationshipId && rel2.type === IMAGE_REL_TYPE2
8955
9003
  );
8956
9004
  const effects = image.effects !== void 0 ? computeEffectList(context, image.effects) : void 0;
8957
9005
  const blipEffects = image.blipEffects !== void 0 ? computeBlipEffects(context, image.blipEffects) : void 0;
@@ -8982,7 +9030,7 @@ function computeTableElement(context, table, layer, partPath) {
8982
9030
  }
8983
9031
  function computeChartElement(context, chart, layer, partPath) {
8984
9032
  const relationship = context.relationships.find(
8985
- (rel) => rel.id === chart.chartRelationshipId && CHART_REL_TYPES.has(rel.type)
9033
+ (rel2) => rel2.id === chart.chartRelationshipId && CHART_REL_TYPES.has(rel2.type)
8986
9034
  );
8987
9035
  const chartXml = relationship?.targetPartPath !== void 0 ? readRawPackageText(context.source, relationship.targetPartPath) : void 0;
8988
9036
  const chartData = chartXml !== void 0 ? parseComputedChartData(chartXml, context) : void 0;
@@ -8999,11 +9047,11 @@ function computeChartElement(context, chart, layer, partPath) {
8999
9047
  }
9000
9048
  function computeSmartArtElement(context, smartArt, layer, partPath) {
9001
9049
  const dataRelationship = context.relationships.find(
9002
- (rel) => rel.id === smartArt.dataRelationshipId && DIAGRAM_DATA_REL_TYPES.has(rel.type)
9050
+ (rel2) => rel2.id === smartArt.dataRelationshipId && DIAGRAM_DATA_REL_TYPES.has(rel2.type)
9003
9051
  );
9004
9052
  const dataRelationships = dataRelationship?.targetPartPath !== void 0 ? resolveComputedRelationships(context.source, dataRelationship.targetPartPath) : [];
9005
9053
  const drawingRelationship = dataRelationships.find(
9006
- (rel) => DIAGRAM_DRAWING_REL_TYPES.has(rel.type)
9054
+ (rel2) => DIAGRAM_DRAWING_REL_TYPES.has(rel2.type)
9007
9055
  );
9008
9056
  const drawingPartPath = drawingRelationship?.targetPartPath;
9009
9057
  const drawingXml = drawingPartPath !== void 0 ? readRawPackageText(context.source, drawingPartPath) : void 0;
@@ -9149,7 +9197,7 @@ function computeFill(context, fill, partPath) {
9149
9197
  };
9150
9198
  case "image": {
9151
9199
  const relationship = resolveComputedRelationships(context.source, partPath).find(
9152
- (rel) => rel.id === fill.blipRelationshipId && rel.type === IMAGE_REL_TYPE2
9200
+ (rel2) => rel2.id === fill.blipRelationshipId && rel2.type === IMAGE_REL_TYPE2
9153
9201
  );
9154
9202
  return {
9155
9203
  kind: "image",
@@ -9174,6 +9222,24 @@ function computeOutline(context, outline, partPath) {
9174
9222
  ...outline.fill !== void 0 ? { fill: computeFill(context, outline.fill, partPath) } : {}
9175
9223
  };
9176
9224
  }
9225
+ function computedOutlineProperty(context, outline, lineRef, partPath) {
9226
+ const styleOutline = lineRef !== void 0 ? resolveLineReference(context, lineRef, partPath) : void 0;
9227
+ if (outline === void 0) {
9228
+ return styleOutline !== void 0 ? { outline: styleOutline } : {};
9229
+ }
9230
+ const computed = mergeComputedOutline(styleOutline, computeOutline(context, outline, partPath));
9231
+ return { outline: computed };
9232
+ }
9233
+ function mergeComputedOutline(base, override) {
9234
+ if (base === void 0) return override;
9235
+ const width = override.width ?? base.width;
9236
+ const fill = override.fill ?? base.fill;
9237
+ return {
9238
+ source: { ...base.source, ...override.source },
9239
+ ...width !== void 0 ? { width } : {},
9240
+ ...fill !== void 0 ? { fill } : {}
9241
+ };
9242
+ }
9177
9243
  function resolveFillReference(context, ref, partPath) {
9178
9244
  if (ref.index === 0) return void 0;
9179
9245
  const list = ref.index >= 1e3 ? context.theme?.formatScheme?.backgroundFillStyles : context.theme?.formatScheme?.fillStyles;
@@ -9458,7 +9524,7 @@ function isEmptyPlaceholder(shape) {
9458
9524
  }
9459
9525
  function readRawPackageText(source, partPath) {
9460
9526
  const rawPart = source.packageGraph.rawParts?.find((part) => part.partPath === partPath);
9461
- if (rawPart?.kind === "binary") return textDecoder.decode(rawPart.bytes);
9527
+ if (rawPart?.kind === "binary") return textDecoder2.decode(rawPart.bytes);
9462
9528
  return void 0;
9463
9529
  }
9464
9530
  function numericAttr3(node, attrName) {
@@ -9585,7 +9651,7 @@ function parseBackground(bg, nextId) {
9585
9651
  const bgRef = getChild(bg, "bgRef");
9586
9652
  if (bgRef) {
9587
9653
  const color = parseColorElement(bgRef);
9588
- const index = numericAttr(bgRef, "idx");
9654
+ const index = numericAttr2(bgRef, "idx");
9589
9655
  if (color !== void 0) {
9590
9656
  return { kind: "styleReference", index: index ?? 0, color };
9591
9657
  }
@@ -9715,9 +9781,9 @@ function parseOuterShadow2(node) {
9715
9781
  const color = parseColorElement(node);
9716
9782
  if (node === void 0 || color === void 0) return void 0;
9717
9783
  return {
9718
- blurRadius: asEmu2(numericAttr(node, "blurRad") ?? 0),
9719
- distance: asEmu2(numericAttr(node, "dist") ?? 0),
9720
- direction: asOoxmlAngle(numericAttr(node, "dir") ?? 0),
9784
+ blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
9785
+ distance: asEmu2(numericAttr2(node, "dist") ?? 0),
9786
+ direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
9721
9787
  color,
9722
9788
  alignment: parseRectangleAlignment(getAttr(node, "algn"), "b"),
9723
9789
  rotateWithShape: getAttr(node, "rotWithShape") !== "0"
@@ -9727,9 +9793,9 @@ function parseInnerShadow2(node) {
9727
9793
  const color = parseColorElement(node);
9728
9794
  if (node === void 0 || color === void 0) return void 0;
9729
9795
  return {
9730
- blurRadius: asEmu2(numericAttr(node, "blurRad") ?? 0),
9731
- distance: asEmu2(numericAttr(node, "dist") ?? 0),
9732
- direction: asOoxmlAngle(numericAttr(node, "dir") ?? 0),
9796
+ blurRadius: asEmu2(numericAttr2(node, "blurRad") ?? 0),
9797
+ distance: asEmu2(numericAttr2(node, "dist") ?? 0),
9798
+ direction: asOoxmlAngle(numericAttr2(node, "dir") ?? 0),
9733
9799
  color
9734
9800
  };
9735
9801
  }
@@ -9737,14 +9803,14 @@ function parseGlow2(node) {
9737
9803
  const color = parseColorElement(node);
9738
9804
  if (node === void 0 || color === void 0) return void 0;
9739
9805
  return {
9740
- radius: asEmu2(numericAttr(node, "rad") ?? 0),
9806
+ radius: asEmu2(numericAttr2(node, "rad") ?? 0),
9741
9807
  color
9742
9808
  };
9743
9809
  }
9744
9810
  function parseSoftEdge2(node) {
9745
9811
  if (node === void 0) return void 0;
9746
9812
  return {
9747
- radius: asEmu2(numericAttr(node, "rad") ?? 0)
9813
+ radius: asEmu2(numericAttr2(node, "rad") ?? 0)
9748
9814
  };
9749
9815
  }
9750
9816
  function booleanAttr(node, name) {
@@ -9762,8 +9828,8 @@ var SLIDE_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/rel
9762
9828
  var SLIDE_LAYOUT_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
9763
9829
  var SLIDE_MASTER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
9764
9830
  var THEME_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
9765
- var PRESENTATION_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
9766
- var textDecoder2 = new TextDecoder();
9831
+ var PRESENTATION_CONTENT_TYPE2 = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
9832
+ var textDecoder3 = new TextDecoder();
9767
9833
  function readPptx(input) {
9768
9834
  const entries = unzipPackage(input);
9769
9835
  const diagnostics = [];
@@ -9914,7 +9980,7 @@ function parsePartRoot(entries, partPath, rootLocalName, diagnostics, includeOrd
9914
9980
  });
9915
9981
  return void 0;
9916
9982
  }
9917
- const xml = textDecoder2.decode(bytes);
9983
+ const xml = textDecoder3.decode(bytes);
9918
9984
  const root = getChild(parseXml(xml), rootLocalName);
9919
9985
  if (root === void 0) {
9920
9986
  diagnostics.push({
@@ -9929,15 +9995,15 @@ function parsePartRoot(entries, partPath, rootLocalName, diagnostics, includeOrd
9929
9995
  return { root, orderedRoot };
9930
9996
  }
9931
9997
  function resolveSingleRel(relationships, sourcePart, relType) {
9932
- const rels = relationships.find((rel) => rel.sourcePartPath === sourcePart)?.relationships;
9933
- const match = rels?.find((rel) => rel.type === relType && rel.targetMode !== "External");
9998
+ const rels = relationships.find((rel2) => rel2.sourcePartPath === sourcePart)?.relationships;
9999
+ const match = rels?.find((rel2) => rel2.type === relType && rel2.targetMode !== "External");
9934
10000
  if (match === void 0) return void 0;
9935
10001
  return resolveInternalRelationshipTarget(sourcePart, match);
9936
10002
  }
9937
10003
  function resolveAllRels(relationships, sourcePart, relType) {
9938
- const rels = relationships.find((rel) => rel.sourcePartPath === sourcePart)?.relationships ?? [];
9939
- return rels.filter((rel) => rel.type === relType && rel.targetMode !== "External").flatMap((rel) => {
9940
- const target = resolveInternalRelationshipTarget(sourcePart, rel);
10004
+ const rels = relationships.find((rel2) => rel2.sourcePartPath === sourcePart)?.relationships ?? [];
10005
+ return rels.filter((rel2) => rel2.type === relType && rel2.targetMode !== "External").flatMap((rel2) => {
10006
+ const target = resolveInternalRelationshipTarget(sourcePart, rel2);
9941
10007
  return target === void 0 ? [] : [target];
9942
10008
  });
9943
10009
  }
@@ -9965,7 +10031,7 @@ function unzipPackage(input) {
9965
10031
  function readContentTypes(entries) {
9966
10032
  const bytes = entries.get(CONTENT_TYPES_PART);
9967
10033
  if (!bytes) return { defaults: [], overrides: [] };
9968
- const root = getChild(parseXml(textDecoder2.decode(bytes)), "Types");
10034
+ const root = getChild(parseXml(textDecoder3.decode(bytes)), "Types");
9969
10035
  const defaults = [];
9970
10036
  for (const node of getChildArray(root, "Default")) {
9971
10037
  const extension = getAttr(node, "Extension");
@@ -9986,7 +10052,7 @@ function readRelationships(entries) {
9986
10052
  const result = [];
9987
10053
  for (const [path, bytes] of entries) {
9988
10054
  if (!isRelationshipPart(path)) continue;
9989
- const root = getChild(parseXml(textDecoder2.decode(bytes)), "Relationships");
10055
+ const root = getChild(parseXml(textDecoder3.decode(bytes)), "Relationships");
9990
10056
  const relationships = [];
9991
10057
  for (const node of getChildArray(root, "Relationship")) {
9992
10058
  const id = getAttr(node, "Id");
@@ -10017,7 +10083,7 @@ function readPresentation(entries, relationships, overrides, diagnostics) {
10017
10083
  );
10018
10084
  }
10019
10085
  const presentationPartPath = asPartPath(presentationPath);
10020
- const root = getChild(parseXml(textDecoder2.decode(bytes)), "presentation");
10086
+ const root = getChild(parseXml(textDecoder3.decode(bytes)), "presentation");
10021
10087
  if (root === void 0) {
10022
10088
  throw new Error(
10023
10089
  `readPptx: part '${presentationPath}' is not a presentation part (missing p:presentation root)`
@@ -10026,7 +10092,7 @@ function readPresentation(entries, relationships, overrides, diagnostics) {
10026
10092
  const slideSize = readSlideSize(root);
10027
10093
  const defaultTextStyle = parseTextStyle(getChild(root, "defaultTextStyle"));
10028
10094
  const presentationRels = relationships.find(
10029
- (rel) => rel.sourcePartPath === presentationPath
10095
+ (rel2) => rel2.sourcePartPath === presentationPath
10030
10096
  )?.relationships;
10031
10097
  const slidePartPaths = [];
10032
10098
  const sldIdLst = getChild(root, "sldIdLst");
@@ -10034,7 +10100,7 @@ function readPresentation(entries, relationships, overrides, diagnostics) {
10034
10100
  const relId = getNamespacedAttr(sldId, "id");
10035
10101
  if (relId === void 0) continue;
10036
10102
  const handle = { partPath: presentationPartPath, relationshipId: asRelationshipId(relId) };
10037
- const relationship = presentationRels?.find((rel) => rel.id === relId);
10103
+ const relationship = presentationRels?.find((rel2) => rel2.id === relId);
10038
10104
  if (relationship === void 0) {
10039
10105
  diagnostics.push({
10040
10106
  severity: "warning",
@@ -10077,15 +10143,15 @@ function readSlideSize(presentationRoot) {
10077
10143
  }
10078
10144
  function locatePresentationPart(relationships, overrides) {
10079
10145
  const rootRels = relationships.find(
10080
- (rel) => rel.sourcePartPath === PACKAGE_ROOT_PART
10146
+ (rel2) => rel2.sourcePartPath === PACKAGE_ROOT_PART
10081
10147
  )?.relationships;
10082
10148
  const officeDocumentRel = rootRels?.find(
10083
- (rel) => rel.type === OFFICE_DOCUMENT_REL_TYPE && rel.targetMode !== "External"
10149
+ (rel2) => rel2.type === OFFICE_DOCUMENT_REL_TYPE && rel2.targetMode !== "External"
10084
10150
  );
10085
10151
  if (officeDocumentRel !== void 0) {
10086
10152
  return resolveRelationshipTarget(PACKAGE_ROOT_PART, officeDocumentRel.target);
10087
10153
  }
10088
- const override = overrides.find((entry) => entry.contentType === PRESENTATION_CONTENT_TYPE);
10154
+ const override = overrides.find((entry) => entry.contentType === PRESENTATION_CONTENT_TYPE2);
10089
10155
  return override?.partName;
10090
10156
  }
10091
10157
  var MEDIA_CONTENT_TYPE_PREFIXES = ["image/", "audio/", "video/"];
@@ -10113,9 +10179,9 @@ function extensionOf(path) {
10113
10179
  function stripLeadingSlash(path) {
10114
10180
  return path.startsWith("/") ? path.slice(1) : path;
10115
10181
  }
10116
- var textEncoder = new TextEncoder();
10117
- var textDecoder3 = new TextDecoder();
10118
- var xmlBuilder = new import_fast_xml_parser2.XMLBuilder({
10182
+ var textEncoder2 = new TextEncoder();
10183
+ var textDecoder4 = new TextDecoder();
10184
+ var xmlBuilder2 = new import_fast_xml_parser3.XMLBuilder({
10119
10185
  ignoreAttributes: false,
10120
10186
  attributeNamePrefix: "@_",
10121
10187
  format: false,