ooxml-core 1.35.0 → 1.36.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.
Files changed (49) hide show
  1. package/dist/automation/index.cjs +1290 -825
  2. package/dist/automation/index.mjs +1290 -825
  3. package/dist/visio/bevel-3d.d.ts +31 -4
  4. package/dist/visio/bevel-3d.d.ts.map +1 -1
  5. package/dist/visio/cff-author.d.ts +14 -0
  6. package/dist/visio/cff-author.d.ts.map +1 -0
  7. package/dist/visio/cff-masters.d.ts +11 -0
  8. package/dist/visio/cff-masters.d.ts.map +1 -1
  9. package/dist/visio/edit-commands.d.ts +7 -0
  10. package/dist/visio/edit-commands.d.ts.map +1 -1
  11. package/dist/visio/edit-formatting-commands.d.ts +6 -0
  12. package/dist/visio/edit-formatting-commands.d.ts.map +1 -1
  13. package/dist/visio/edit-formatting-paint.d.ts.map +1 -1
  14. package/dist/visio/edit-instance-geometry.d.ts.map +1 -1
  15. package/dist/visio/edit-instance-recalculate.d.ts +6 -1
  16. package/dist/visio/edit-instance-recalculate.d.ts.map +1 -1
  17. package/dist/visio/edit-shape-create.d.ts.map +1 -1
  18. package/dist/visio/edit-stencil-connector.d.ts.map +1 -1
  19. package/dist/visio/edit-swimlane-stamp.d.ts +22 -0
  20. package/dist/visio/edit-swimlane-stamp.d.ts.map +1 -0
  21. package/dist/visio/edit.d.ts.map +1 -1
  22. package/dist/visio/index.cjs +1338 -568
  23. package/dist/visio/index.d.ts +3 -1
  24. package/dist/visio/index.d.ts.map +1 -1
  25. package/dist/visio/index.mjs +1331 -569
  26. package/dist/visio/model.d.ts +6 -2
  27. package/dist/visio/model.d.ts.map +1 -1
  28. package/dist/visio/path-segments.d.ts +25 -0
  29. package/dist/visio/path-segments.d.ts.map +1 -0
  30. package/dist/visio/shape-sections.d.ts +4 -3
  31. package/dist/visio/shape-sections.d.ts.map +1 -1
  32. package/dist/visio/solid-3d.d.ts +55 -0
  33. package/dist/visio/solid-3d.d.ts.map +1 -0
  34. package/dist/visio/style.d.ts.map +1 -1
  35. package/dist/visio/theme-solid.d.ts +21 -0
  36. package/dist/visio/theme-solid.d.ts.map +1 -0
  37. package/dist/visio/ui/data-visualizer-edits.d.ts +1 -0
  38. package/dist/visio/ui/data-visualizer-edits.d.ts.map +1 -1
  39. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  40. package/dist/visio/ui/index.cjs +1188 -571
  41. package/dist/visio/ui/index.mjs +1188 -572
  42. package/dist/visio/ui/org-chart-belt.d.ts +20 -0
  43. package/dist/visio/ui/org-chart-belt.d.ts.map +1 -0
  44. package/dist/visio/ui/org-chart-edit.d.ts +8 -1
  45. package/dist/visio/ui/org-chart-edit.d.ts.map +1 -1
  46. package/dist/visio/ui/org-chart-import.d.ts.map +1 -1
  47. package/dist/visio/ui/scene-validation.d.ts.map +1 -1
  48. package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
  49. package/package.json +1 -1
@@ -748,8 +748,8 @@ var VisioPackage = class _VisioPackage {
748
748
  this.entries = entries;
749
749
  this.limits = limits;
750
750
  this.deadline = deadline;
751
- for (const entry3 of entries.values())
752
- if (!entry3.directory) this.decodedNames.set(decodePath(entry3.name), entry3.name);
751
+ for (const entry4 of entries.values())
752
+ if (!entry4.directory) this.decodedNames.set(decodePath(entry4.name), entry4.name);
753
753
  }
754
754
  zip;
755
755
  entries;
@@ -809,15 +809,15 @@ var VisioPackage = class _VisioPackage {
809
809
  }
810
810
  /** The declared CRC-32 and size of a part, or an empty string when the package lacks it. */
811
811
  printOf(path3) {
812
- const entry3 = this.entries.get(path3);
813
- return entry3 && !entry3.directory ? `${entry3.crc}:${entry3.size}` : "";
812
+ const entry4 = this.entries.get(path3);
813
+ return entry4 && !entry4.directory ? `${entry4.crc}:${entry4.size}` : "";
814
814
  }
815
815
  has(path3) {
816
816
  this.noted?.add(path3);
817
817
  return this.entries.get(path3)?.directory === false;
818
818
  }
819
819
  paths() {
820
- return [...this.entries.values()].filter((entry3) => !entry3.directory).map((entry3) => entry3.name);
820
+ return [...this.entries.values()].filter((entry4) => !entry4.directory).map((entry4) => entry4.name);
821
821
  }
822
822
  async readXml(path3, expectedRoot) {
823
823
  this.check();
@@ -839,9 +839,9 @@ var VisioPackage = class _VisioPackage {
839
839
  this.check();
840
840
  this.noted?.add(path3);
841
841
  safePath(path3);
842
- const entry3 = this.entries.get(path3);
843
- if (!entry3 || entry3.directory) fail("MISSING_PART", `Missing package part: ${path3}`);
844
- return entry3.size;
842
+ const entry4 = this.entries.get(path3);
843
+ if (!entry4 || entry4.directory) fail("MISSING_PART", `Missing package part: ${path3}`);
844
+ return entry4.size;
845
845
  }
846
846
  /** Shared package-owned bytes. Treat the returned buffer as immutable. */
847
847
  async readBytes(path3) {
@@ -858,8 +858,8 @@ var VisioPackage = class _VisioPackage {
858
858
  return bytes;
859
859
  }
860
860
  async loadBytes(path3) {
861
- const entry3 = this.entries.get(path3), file = this.zip.file(path3);
862
- if (!entry3 || entry3.directory || !file)
861
+ const entry4 = this.entries.get(path3), file = this.zip.file(path3);
862
+ if (!entry4 || entry4.directory || !file)
863
863
  return fail("MISSING_PART", `Missing package part: ${path3}`);
864
864
  return new Promise((resolve, reject2) => {
865
865
  const stream = file.internalStream("uint8array");
@@ -890,9 +890,9 @@ var VisioPackage = class _VisioPackage {
890
890
  fail("LIMIT_ENTRY", `Actual inflated entry exceeds limit: ${path3}`);
891
891
  if (this.totalOutput > this.limits.maxTotalBytes)
892
892
  fail("LIMIT_TOTAL", "Actual inflated ZIP total exceeds limit");
893
- if (size3 > Math.max(1, entry3.compressed) * this.limits.maxCompressionRatio)
893
+ if (size3 > Math.max(1, entry4.compressed) * this.limits.maxCompressionRatio)
894
894
  fail("LIMIT_RATIO", `Actual ZIP compression ratio exceeds limit: ${path3}`);
895
- if (size3 > entry3.size)
895
+ if (size3 > entry4.size)
896
896
  fail("ZIP_MISMATCH", `Actual ZIP entry exceeds declared size: ${path3}`);
897
897
  crc = crc32(chunk, crc);
898
898
  chunks.push(chunk);
@@ -901,7 +901,7 @@ var VisioPackage = class _VisioPackage {
901
901
  }
902
902
  }).on("error", abort).on("end", () => {
903
903
  if (settled) return;
904
- if (size3 !== entry3.size || (crc ^ 4294967295) >>> 0 !== entry3.crc) {
904
+ if (size3 !== entry4.size || (crc ^ 4294967295) >>> 0 !== entry4.crc) {
905
905
  abort(new VisioPackageError("ZIP_MISMATCH", `Inflated size or CRC mismatch: ${path3}`));
906
906
  return;
907
907
  }
@@ -4205,9 +4205,28 @@ function createLine(root2, document, edit) {
4205
4205
  setCell(row2, "Y", 0);
4206
4206
  section3.appendChild(row2);
4207
4207
  }
4208
+ if (edit.text !== void 0) appendLineTextCells(shape, width);
4208
4209
  shape.appendChild(section3);
4210
+ if (edit.text !== void 0) {
4211
+ const text7 = root2.ownerDocument.createElementNS(root2.namespaceURI, "Text");
4212
+ text7.appendChild(root2.ownerDocument.createTextNode(encodeVisioPlainText(edit.text)));
4213
+ shape.appendChild(text7);
4214
+ }
4209
4215
  return shape;
4210
4216
  }
4217
+ function appendLineTextCells(shape, width) {
4218
+ const box5 = Math.max(0.5, Math.min(width, 1.2));
4219
+ const entries = [
4220
+ ["TxtPinX", width / 2, "Width*0.5"],
4221
+ ["TxtPinY", 0, "Height*0.5"],
4222
+ ["TxtWidth", box5],
4223
+ ["TxtHeight", 0.25],
4224
+ ["TxtLocPinX", box5 / 2, "TxtWidth*0.5"],
4225
+ ["TxtLocPinY", 0.125, "TxtHeight*0.5"],
4226
+ ["TxtAngle", 0, "-Angle"]
4227
+ ];
4228
+ for (const [name3, value3, formula2] of entries) setCell(shape, name3, value3, formula2);
4229
+ }
4211
4230
 
4212
4231
  // visio/path-fit.ts
4213
4232
  var finite = (point2) => Number.isFinite(point2.x) && Number.isFinite(point2.y);
@@ -8561,12 +8580,12 @@ function linearToSrgb255(linear) {
8561
8580
  // color/hex-rgb.ts
8562
8581
  function parseArgbHex(hex) {
8563
8582
  const clean5 = hex.replace(/^#/, "");
8564
- const rgb6 = clean5.length === 8 ? clean5.slice(2) : clean5;
8565
- if (!/^[0-9a-fA-F]{6}$/.test(rgb6)) return void 0;
8566
- return [0, 2, 4].map((i) => parseInt(rgb6.slice(i, i + 2), 16));
8583
+ const rgb7 = clean5.length === 8 ? clean5.slice(2) : clean5;
8584
+ if (!/^[0-9a-fA-F]{6}$/.test(rgb7)) return void 0;
8585
+ return [0, 2, 4].map((i) => parseInt(rgb7.slice(i, i + 2), 16));
8567
8586
  }
8568
8587
  var clamp255 = (v) => Math.max(0, Math.min(255, v));
8569
- var rgbToUpperHex = (rgb6) => `#${rgb6.map((v) => clamp255(Math.round(v)).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
8588
+ var rgbToUpperHex = (rgb7) => `#${rgb7.map((v) => clamp255(Math.round(v)).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
8570
8589
 
8571
8590
  // color/theme-palette.ts
8572
8591
  function themePaletteVariantLuminance(variant) {
@@ -8575,9 +8594,9 @@ function themePaletteVariantLuminance(variant) {
8575
8594
  return variant.kind === "lighter" ? { lumMod, lumOff: fraction } : { lumMod };
8576
8595
  }
8577
8596
  function applyThemePaletteVariant(hex, variant) {
8578
- const rgb6 = hexToRgbChannels(hex);
8579
- if (!rgb6) return hex;
8580
- const { h, s, l } = rgbToHsl(rgb6.r, rgb6.g, rgb6.b);
8597
+ const rgb7 = hexToRgbChannels(hex);
8598
+ if (!rgb7) return hex;
8599
+ const { h, s, l } = rgbToHsl(rgb7.r, rgb7.g, rgb7.b);
8581
8600
  const { lumMod, lumOff } = themePaletteVariantLuminance(variant);
8582
8601
  const next = hslToRgb(h, s, l * lumMod + (lumOff ?? 0), (value3) => Math.floor(value3 + 1e-6));
8583
8602
  return `#${toHex(next.r)}${toHex(next.g)}${toHex(next.b)}`.toLowerCase();
@@ -8775,10 +8794,10 @@ var APPLIED = /* @__PURE__ */ new Set([
8775
8794
  ]);
8776
8795
  function resolveDrawingColor(color2, theme2, options2) {
8777
8796
  const base2 = baseHex(color2, theme2);
8778
- const rgb6 = base2 ? hexToRgbChannels(base2) : null;
8779
- if (!rgb6) return void 0;
8797
+ const rgb7 = base2 ? hexToRgbChannels(base2) : null;
8798
+ if (!rgb7) return void 0;
8780
8799
  if (options2?.transformOrder === "document") {
8781
- const value3 = orderedColorTransforms(rgb6, color2.transforms);
8800
+ const value3 = orderedColorTransforms(rgb7, color2.transforms);
8782
8801
  const round3 = options2.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
8783
8802
  return {
8784
8803
  hex: `#${toHex(round3(value3.r))}${toHex(round3(value3.g))}${toHex(round3(value3.b))}`,
@@ -8788,9 +8807,9 @@ function resolveDrawingColor(color2, theme2, options2) {
8788
8807
  )
8789
8808
  };
8790
8809
  }
8791
- let { r, g, b } = rgb6;
8792
- const find = (name3) => color2.transforms.find((entry3) => entry3.name === name3)?.value;
8793
- const has = (name3) => color2.transforms.some((entry3) => entry3.name === name3);
8810
+ let { r, g, b } = rgb7;
8811
+ const find = (name3) => color2.transforms.find((entry4) => entry4.name === name3)?.value;
8812
+ const has = (name3) => color2.transforms.some((entry4) => entry4.name === name3);
8794
8813
  if (has("comp")) {
8795
8814
  const hsl = rgbToHsl(r, g, b);
8796
8815
  ({ r, g, b } = hslToRgb((hsl.h + 180) % 360, hsl.s, hsl.l));
@@ -8841,7 +8860,7 @@ function resolveDrawingColor(color2, theme2, options2) {
8841
8860
  return {
8842
8861
  hex: `#${toHex(r)}${toHex(g)}${toHex(b)}`,
8843
8862
  alpha,
8844
- unapplied: [...new Set(color2.transforms.map((entry3) => entry3.name))].filter(
8863
+ unapplied: [...new Set(color2.transforms.map((entry4) => entry4.name))].filter(
8845
8864
  (name3) => !APPLIED.has(name3)
8846
8865
  )
8847
8866
  };
@@ -10330,8 +10349,8 @@ function sortKeys(value3) {
10330
10349
  if (value3 && typeof value3 === "object") {
10331
10350
  const out = {};
10332
10351
  for (const key3 of Object.keys(value3).sort()) {
10333
- const entry3 = value3[key3];
10334
- if (entry3 !== void 0) out[key3] = sortKeys(entry3);
10352
+ const entry4 = value3[key3];
10353
+ if (entry4 !== void 0) out[key3] = sortKeys(entry4);
10335
10354
  }
10336
10355
  return out;
10337
10356
  }
@@ -10608,7 +10627,7 @@ function compileFraction(tokens3, slash) {
10608
10627
  let denEnd = slash + 1;
10609
10628
  while (isDigit(tokens3[denEnd]) || tokens3[denEnd]?.t === "num") denEnd++;
10610
10629
  const denTokens = tokens3.slice(slash + 1, denEnd);
10611
- const fixed = denTokens.some((t) => t.t === "num") && denTokens.every((t) => t.t === "num" || isDigit(t) && t.c === "0");
10630
+ const fixed2 = denTokens.some((t) => t.t === "num") && denTokens.every((t) => t.t === "num" || isDigit(t) && t.c === "0");
10612
10631
  const plan = {
10613
10632
  tokens: [],
10614
10633
  intDigits: [],
@@ -10616,13 +10635,13 @@ function compileFraction(tokens3, slash) {
10616
10635
  denDigits: [],
10617
10636
  denWidth: denTokens.length
10618
10637
  };
10619
- if (fixed) {
10638
+ if (fixed2) {
10620
10639
  plan.fixedDenominator = Number(denTokens.map((t) => t.t === "num" ? t.v : "0").join(""));
10621
10640
  }
10622
10641
  tokens3.forEach((tok, i) => {
10623
10642
  if (i === slash) plan.tokens.push({ r: "slash" });
10624
10643
  else if (i > slash && i < denEnd) {
10625
- if (fixed) {
10644
+ if (fixed2) {
10626
10645
  if (i === slash + 1) plan.tokens.push({ r: "den", index: 0 });
10627
10646
  } else if (isDigit(tok)) {
10628
10647
  plan.tokens.push({ r: "den", index: plan.denDigits.length });
@@ -11305,9 +11324,9 @@ function generalDigits(v, width) {
11305
11324
  if (r.point > width) return scientific2(v, width).text;
11306
11325
  return plain2(r);
11307
11326
  }
11308
- const fixed = roundDecimals(v, Math.max(0, width - 2));
11327
+ const fixed2 = roundDecimals(v, Math.max(0, width - 2));
11309
11328
  const sci = scientific2(v, width);
11310
- if (fixed.d && fixed.d.length >= sci.sig) return plain2(fixed);
11329
+ if (fixed2.d && fixed2.d.length >= sci.sig) return plain2(fixed2);
11311
11330
  return sci.text;
11312
11331
  }
11313
11332
  function formatGeneral(value3, width = GENERAL_WIDTH) {
@@ -11540,10 +11559,10 @@ function hls240ToRgb({ h, l, s }) {
11540
11559
  var parseHex = parseArgbHex;
11541
11560
  var toHexColor = rgbToUpperHex;
11542
11561
  function applyTint(hex, tint) {
11543
- const rgb6 = parseHex(hex) ?? [0, 0, 0];
11544
- if (!tint) return toHexColor(rgb6);
11562
+ const rgb7 = parseHex(hex) ?? [0, 0, 0];
11563
+ if (!tint) return toHexColor(rgb7);
11545
11564
  const t = Math.max(-1, Math.min(1, tint));
11546
- const hls = rgbToHls240(...rgb6);
11565
+ const hls = rgbToHls240(...rgb7);
11547
11566
  const l = t < 0 ? Math.trunc(hls.l * (1 + t)) : Math.round(hls.l * (1 - t) + HLSMAX * t);
11548
11567
  return toHexColor(hls240ToRgb({ ...hls, l: Math.max(0, Math.min(HLSMAX, l)) }));
11549
11568
  }
@@ -12459,7 +12478,7 @@ function countDerived(pivot) {
12459
12478
  }
12460
12479
  var pivotAxisFieldNames = (pivot) => [
12461
12480
  ...pivot.fields,
12462
- ...derivedDateFields(pivot).filter((entry3) => !pivot.fields.includes(entry3.name)).map((entry3) => entry3.name)
12481
+ ...derivedDateFields(pivot).filter((entry4) => !pivot.fields.includes(entry4.name)).map((entry4) => entry4.name)
12463
12482
  ];
12464
12483
  function resolveDateGroups(pivot) {
12465
12484
  return (pivot.dateGroups ?? []).map((group2) => {
@@ -12470,11 +12489,11 @@ function resolveDateGroups(pivot) {
12470
12489
  });
12471
12490
  }
12472
12491
  function derivedDateLabels(pivot, name3) {
12473
- const entry3 = derivedDateFields(pivot).find((candidate) => candidate.name === name3);
12474
- if (!entry3) return void 0;
12475
- const [group2] = resolveDateGroups({ ...pivot, dateGroups: [entry3.group] });
12492
+ const entry4 = derivedDateFields(pivot).find((candidate) => candidate.name === name3);
12493
+ if (!entry4) return void 0;
12494
+ const [group2] = resolveDateGroups({ ...pivot, dateGroups: [entry4.group] });
12476
12495
  const range2 = { start: group2.start, end: group2.end };
12477
- return dateUnitLabels(entry3.unit, range2, dateGroupDays(group2), pivot.date1904 ?? false, group2);
12496
+ return dateUnitLabels(entry4.unit, range2, dateGroupDays(group2), pivot.date1904 ?? false, group2);
12478
12497
  }
12479
12498
  function validateDateGroups(pivot) {
12480
12499
  const groups = pivot.dateGroups;
@@ -12510,19 +12529,19 @@ function expandDateGroups(pivot) {
12510
12529
  const resolved = { ...pivot, dateGroups: groups };
12511
12530
  const derived = derivedDateFields(resolved);
12512
12531
  const date1904 = pivot.date1904 ?? false;
12513
- const tables = derived.map((entry3) => {
12514
- const range2 = { start: entry3.group.start, end: entry3.group.end };
12515
- const days = dateGroupDays(entry3.group);
12516
- const labels = dateUnitLabels(entry3.unit, range2, days, date1904, entry3.group);
12532
+ const tables = derived.map((entry4) => {
12533
+ const range2 = { start: entry4.group.start, end: entry4.group.end };
12534
+ const days = dateGroupDays(entry4.group);
12535
+ const labels = dateUnitLabels(entry4.unit, range2, days, date1904, entry4.group);
12517
12536
  return {
12518
- base: pivot.fields.indexOf(entry3.group.field),
12537
+ base: pivot.fields.indexOf(entry4.group.field),
12519
12538
  labels,
12520
- index: (serial) => dateUnitIndex(entry3.unit, range2, days, date1904, serial, labels.length)
12539
+ index: (serial) => dateUnitIndex(entry4.unit, range2, days, date1904, serial, labels.length)
12521
12540
  };
12522
12541
  });
12523
12542
  return {
12524
12543
  ...resolved,
12525
- fields: [...pivot.fields, ...derived.map((entry3) => entry3.name)],
12544
+ fields: [...pivot.fields, ...derived.map((entry4) => entry4.name)],
12526
12545
  records: pivot.records.map((record5) => [
12527
12546
  ...record5,
12528
12547
  ...tables.map((table2) => {
@@ -12567,7 +12586,7 @@ function validateFieldGroups(pivot) {
12567
12586
  if (!group2 || typeof group2 !== "object" || index3 < 0 || seen.has(group2.field) || ![group2.start, group2.end, group2.by].every(Number.isInteger) || group2.by < 1 || group2.start >= group2.end || groupBucketCount(group2) > MAX_BUCKETS)
12568
12587
  throw new Error("Choose a valid number group.");
12569
12588
  seen.add(group2.field);
12570
- if (pivot.pageFilter?.field === group2.field || pivot.valueField === group2.field || (pivot.additionalValues ?? []).some((measure3) => measure3.field === group2.field) || (pivot.dateFields ?? []).includes(group2.field) || (pivot.itemFilters ?? []).some((filter) => filter.field === group2.field))
12589
+ if (pivot.pageFilter?.field === group2.field || pivot.valueField === group2.field || (pivot.additionalValues ?? []).some((measure4) => measure4.field === group2.field) || (pivot.dateFields ?? []).includes(group2.field) || (pivot.itemFilters ?? []).some((filter) => filter.field === group2.field))
12571
12590
  throw new Error("A grouped field cannot also be a filter, date field or value field.");
12572
12591
  for (const record5 of pivot.records) {
12573
12592
  const value3 = record5[index3];
@@ -12632,8 +12651,8 @@ var PIVOT_SUBTOTAL_ORDER = [
12632
12651
  "varp"
12633
12652
  ];
12634
12653
  function fieldSubtotalFunctions(pivot, field2) {
12635
- const entry3 = pivot.fieldSubtotals?.find((item2) => item2.field === field2);
12636
- if (entry3) return PIVOT_SUBTOTAL_ORDER.filter((fn) => entry3.functions.includes(fn));
12654
+ const entry4 = pivot.fieldSubtotals?.find((item2) => item2.field === field2);
12655
+ if (entry4) return PIVOT_SUBTOTAL_ORDER.filter((fn) => entry4.functions.includes(fn));
12637
12656
  return field2 === pivot.rowField && pivot.subtotals === false ? [] : "auto";
12638
12657
  }
12639
12658
  function validateFieldSubtotals(pivot, axisFields) {
@@ -12641,22 +12660,22 @@ function validateFieldSubtotals(pivot, axisFields) {
12641
12660
  if (entries === void 0) return;
12642
12661
  if (!Array.isArray(entries)) throw new Error("Choose valid field subtotals.");
12643
12662
  const seen = /* @__PURE__ */ new Set();
12644
- for (const entry3 of entries) {
12645
- if (!entry3 || typeof entry3 !== "object" || !axisFields.includes(entry3.field) || seen.has(entry3.field) || !Array.isArray(entry3.functions) || entry3.functions.some((fn) => !PIVOT_AGGREGATES.includes(fn)) || new Set(entry3.functions).size !== entry3.functions.length)
12663
+ for (const entry4 of entries) {
12664
+ if (!entry4 || typeof entry4 !== "object" || !axisFields.includes(entry4.field) || seen.has(entry4.field) || !Array.isArray(entry4.functions) || entry4.functions.some((fn) => !PIVOT_AGGREGATES.includes(fn)) || new Set(entry4.functions).size !== entry4.functions.length)
12646
12665
  throw new Error("Choose valid field subtotals.");
12647
- seen.add(entry3.field);
12666
+ seen.add(entry4.field);
12648
12667
  }
12649
12668
  }
12650
12669
 
12651
12670
  // xlsx/pivot/item-filters.ts
12652
12671
  function applyPivotItemFilters(pivot) {
12653
- const active = (pivot.itemFilters ?? []).filter((entry3) => entry3.hidden.length);
12672
+ const active = (pivot.itemFilters ?? []).filter((entry4) => entry4.hidden.length);
12654
12673
  const range2 = pivot.dateFilter;
12655
12674
  if (!active.length && !range2) return pivot;
12656
12675
  const dateIndex = range2 ? pivot.fields.indexOf(range2.field) : -1;
12657
- const tests = active.map((entry3) => ({
12658
- index: pivot.fields.indexOf(entry3.field),
12659
- hidden: new Set(entry3.hidden.map(pivotValueKey))
12676
+ const tests = active.map((entry4) => ({
12677
+ index: pivot.fields.indexOf(entry4.field),
12678
+ hidden: new Set(entry4.hidden.map(pivotValueKey))
12660
12679
  }));
12661
12680
  return {
12662
12681
  ...pivot,
@@ -12699,7 +12718,7 @@ function validatePivotItemFilters(pivot) {
12699
12718
  var keyOf = (field2, item2) => `${field2}\0${pivotValueKey(item2)}`;
12700
12719
  function pivotItemLabeler(pivot) {
12701
12720
  const blank = pivotCaptions(pivot).blank;
12702
- const names = pivot.itemNames?.length ? new Map(pivot.itemNames.map((entry3) => [keyOf(entry3.field, entry3.item), entry3.name])) : void 0;
12721
+ const names = pivot.itemNames?.length ? new Map(pivot.itemNames.map((entry4) => [keyOf(entry4.field, entry4.item), entry4.name])) : void 0;
12703
12722
  return (field2, value3) => names?.get(keyOf(field2, value3)) ?? (value3 === null || value3 === "" ? blank : pivotItemLabel(value3));
12704
12723
  }
12705
12724
 
@@ -12867,9 +12886,9 @@ function validatePivotFields(pivot) {
12867
12886
  if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== pivotCaptions(pivot).values)
12868
12887
  throw new Error("This PivotTable uses unsupported Values header captions.");
12869
12888
  if (!Array.isArray(extras) || extras.length > 15 || extras.some(
12870
- (measure3) => !measure3 || !pivot.fields.includes(measure3.field) || !PIVOT_AGGREGATES.includes(measure3.aggregate) || typeof measure3.caption !== "string" || !measure3.caption.trim() || measure3.caption.length > 255 || pivot.fields.some((field2) => field2.toLowerCase() === measure3.caption.toLowerCase())
12889
+ (measure4) => !measure4 || !pivot.fields.includes(measure4.field) || !PIVOT_AGGREGATES.includes(measure4.aggregate) || typeof measure4.caption !== "string" || !measure4.caption.trim() || measure4.caption.length > 255 || pivot.fields.some((field2) => field2.toLowerCase() === measure4.caption.toLowerCase())
12871
12890
  ) || new Set(
12872
- [pivot.valueCaption, ...extras.map((measure3) => measure3.caption)].map(
12891
+ [pivot.valueCaption, ...extras.map((measure4) => measure4.caption)].map(
12873
12892
  (caption) => caption?.toLowerCase()
12874
12893
  )
12875
12894
  ).size !== extras.length + 1)
@@ -12910,7 +12929,7 @@ function aggregateValues(records, field2, type) {
12910
12929
  const sum = numbers.reduce((total, value3) => total + value3, 0);
12911
12930
  return type === "average" ? sum / numbers.length : sum;
12912
12931
  }
12913
- var pivotMeasureNumber = (pivot, records, measure3) => aggregateValues(records, pivot.fields.indexOf(measure3.field), measure3.aggregate);
12932
+ var pivotMeasureNumber = (pivot, records, measure4) => aggregateValues(records, pivot.fields.indexOf(measure4.field), measure4.aggregate);
12914
12933
 
12915
12934
  // xlsx/pivot/columns.ts
12916
12935
  var SEPARATOR = "";
@@ -12947,17 +12966,17 @@ function pivotColumnEntries(pivot) {
12947
12966
  values: [...values, child4[1].value],
12948
12967
  keys: [...keys, child4[0]]
12949
12968
  };
12950
- const entry3 = {
12969
+ const entry4 = {
12951
12970
  path: here.path,
12952
12971
  key: columnKey(here.keys, here.keys.length),
12953
12972
  values: here.values
12954
12973
  };
12955
- if (level3 === names.length - 1) entries.push({ kind: "leaf", ...entry3 });
12974
+ if (level3 === names.length - 1) entries.push({ kind: "leaf", ...entry4 });
12956
12975
  else {
12957
12976
  visit(child4[1], level3 + 1, here.path, here.values, here.keys);
12958
12977
  const own = functions[level3];
12959
- if (own === "auto") entries.push({ kind: "subtotal", ...entry3 });
12960
- else for (const fn of own) entries.push({ kind: "subtotal", ...entry3, fn });
12978
+ if (own === "auto") entries.push({ kind: "subtotal", ...entry4 });
12979
+ else for (const fn of own) entries.push({ kind: "subtotal", ...entry4, fn });
12961
12980
  }
12962
12981
  }
12963
12982
  };
@@ -12980,7 +12999,7 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
12980
12999
  const levels = columns.names.length;
12981
13000
  if (!levels)
12982
13001
  return [
12983
- [...rowLabels, ...valuesOnRows ? [null] : measures2.map((measure3) => measure3.caption)]
13002
+ [...rowLabels, ...valuesOnRows ? [null] : measures2.map((measure4) => measure4.caption)]
12984
13003
  ];
12985
13004
  const compact = pivot.layout === "compact";
12986
13005
  const labelColumns = rowLabels.length;
@@ -12998,22 +13017,22 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
12998
13017
  grid[rows - 1][i] = text7;
12999
13018
  });
13000
13019
  let previous = [];
13001
- columns.entries.forEach((entry3, j) => {
13020
+ columns.entries.forEach((entry4, j) => {
13002
13021
  const at3 = labelColumns + j * count;
13003
- if (entry3.kind === "leaf") {
13004
- entry3.path.forEach((_index, level3) => {
13005
- const continued = entry3.path.slice(0, level3 + 1).every((p, i) => p === previous[i]);
13006
- if (!continued) grid[1 + level3][at3] = labelOf(columns.names[level3], entry3.values[level3]);
13022
+ if (entry4.kind === "leaf") {
13023
+ entry4.path.forEach((_index, level3) => {
13024
+ const continued = entry4.path.slice(0, level3 + 1).every((p, i) => p === previous[i]);
13025
+ if (!continued) grid[1 + level3][at3] = labelOf(columns.names[level3], entry4.values[level3]);
13007
13026
  });
13008
- previous = entry3.path;
13009
- if (count > 1) measures2.forEach((measure3, m) => grid[rows - 1][at3 + m] = measure3.caption);
13027
+ previous = entry4.path;
13028
+ if (count > 1) measures2.forEach((measure4, m) => grid[rows - 1][at3 + m] = measure4.caption);
13010
13029
  return;
13011
13030
  }
13012
- const row2 = entry3.kind === "grand" ? 1 : entry3.path.length;
13013
- const name3 = entry3.kind === "grand" ? "" : String(labelOf(columns.names[entry3.path.length - 1], entry3.values.at(-1)));
13014
- measures2.forEach((measure3, m) => {
13015
- const custom = entry3.fn ? caps.functions[entry3.fn] : void 0;
13016
- grid[row2][at3 + m] = custom ? count === 1 ? `${name3} ${custom}` : `${name3} ${custom} of ${measure3.field}` : count === 1 ? entry3.kind === "grand" ? caps.grandTotal : fillCaption(caps.subtotal, name3) : entry3.kind === "grand" ? fillCaption(caps.measureTotal, measure3.caption) : `${name3} ${measure3.caption}`;
13031
+ const row2 = entry4.kind === "grand" ? 1 : entry4.path.length;
13032
+ const name3 = entry4.kind === "grand" ? "" : String(labelOf(columns.names[entry4.path.length - 1], entry4.values.at(-1)));
13033
+ measures2.forEach((measure4, m) => {
13034
+ const custom = entry4.fn ? caps.functions[entry4.fn] : void 0;
13035
+ grid[row2][at3 + m] = custom ? count === 1 ? `${name3} ${custom}` : `${name3} ${custom} of ${measure4.field}` : count === 1 ? entry4.kind === "grand" ? caps.grandTotal : fillCaption(caps.subtotal, name3) : entry4.kind === "grand" ? fillCaption(caps.measureTotal, measure4.caption) : `${name3} ${measure4.caption}`;
13017
13036
  });
13018
13037
  });
13019
13038
  return grid;
@@ -13085,11 +13104,11 @@ function nestedPivotGrid(pivot) {
13085
13104
  let rowCount = 0;
13086
13105
  const width = dimensions3.width - labelColumns;
13087
13106
  const blanks = () => Array(width).fill(null);
13088
- const cells4 = (group2, rowFn, measure3) => columns.entries.flatMap((entry3) => {
13089
- const records = entry3.kind === "grand" ? group2.records : group2.columns.get(entry3.key) ?? [];
13090
- const picked = measure3 === void 0 ? measures2 : [measures2[measure3]];
13091
- if (rowFn && entry3.fn && rowFn !== entry3.fn) return picked.map(() => null);
13092
- const fn = rowFn ?? entry3.fn;
13107
+ const cells4 = (group2, rowFn, measure4) => columns.entries.flatMap((entry4) => {
13108
+ const records = entry4.kind === "grand" ? group2.records : group2.columns.get(entry4.key) ?? [];
13109
+ const picked = measure4 === void 0 ? measures2 : [measures2[measure4]];
13110
+ if (rowFn && entry4.fn && rowFn !== entry4.fn) return picked.map(() => null);
13111
+ const fn = rowFn ?? entry4.fn;
13093
13112
  return picked.map(
13094
13113
  (one) => fn ? aggregateValues(records, pivot.fields.indexOf(one.field), fn) : pivotMeasureNumber(pivot, records, one)
13095
13114
  );
@@ -13109,17 +13128,17 @@ function nestedPivotGrid(pivot) {
13109
13128
  throw new Error("The PivotTable result is too large.");
13110
13129
  return;
13111
13130
  }
13112
- const [cells5, numbers, entry3] = build2();
13131
+ const [cells5, numbers, entry4] = build2();
13113
13132
  values.push([...cells5, ...numbers]);
13114
- rowEntries.push(entry3);
13133
+ rowEntries.push(entry4);
13115
13134
  indents.push(compact ? indent : 0);
13116
13135
  };
13117
- const entryOf = (indices, measure3, type) => ({
13136
+ const entryOf = (indices, measure4, type) => ({
13118
13137
  indices,
13119
- ...measure3 !== void 0 ? { measure: measure3 } : {},
13138
+ ...measure4 !== void 0 ? { measure: measure4 } : {},
13120
13139
  ...type ? { type } : {}
13121
13140
  });
13122
- const walk = (level3, group2, measure3, path3) => {
13141
+ const walk = (level3, group2, measure4, path3) => {
13123
13142
  const field2 = fieldOf(level3);
13124
13143
  const last = level3 === levels - 1;
13125
13144
  const repeated = Array.from(
@@ -13164,16 +13183,16 @@ function nestedPivotGrid(pivot) {
13164
13183
  if (last)
13165
13184
  return push(level3, () => [
13166
13185
  labelCells(path3, leafShown(here.firsts), level3, text7),
13167
- cells4(child4, void 0, measure3),
13168
- entryOf(here.indices, measure3)
13186
+ cells4(child4, void 0, measure4),
13187
+ entryOf(here.indices, measure4)
13169
13188
  ]);
13170
13189
  if (!tabular)
13171
13190
  push(level3, () => [
13172
13191
  labelCells(path3, repeated, level3, text7),
13173
- showsValue ? cells4(child4, void 0, measure3) : blanks(),
13174
- entryOf(here.indices, measure3)
13192
+ showsValue ? cells4(child4, void 0, measure4) : blanks(),
13193
+ entryOf(here.indices, measure4)
13175
13194
  ]);
13176
- walk(level3 + 1, child4, measure3, here);
13195
+ walk(level3 + 1, child4, measure4, here);
13177
13196
  if (field2 === depth - 1) return;
13178
13197
  const caption = String(text7);
13179
13198
  const subtotal = (title, fn, one) => push(level3, () => [
@@ -13183,21 +13202,21 @@ function nestedPivotGrid(pivot) {
13183
13202
  ]);
13184
13203
  if (own === "auto") {
13185
13204
  if (showsValue) return;
13186
- if (valuesAbove) subtotal(fillCaption(caps.subtotal, caption), void 0, measure3);
13205
+ if (valuesAbove) subtotal(fillCaption(caps.subtotal, caption), void 0, measure4);
13187
13206
  else measures2.forEach((one, m) => subtotal(`${caption} ${one.caption}`, void 0, m));
13188
13207
  } else
13189
13208
  for (const fn of own)
13190
- if (valuesAbove) subtotal(`${caption} ${caps.functions[fn]}`, fn, measure3);
13209
+ if (valuesAbove) subtotal(`${caption} ${caps.functions[fn]}`, fn, measure4);
13191
13210
  else
13192
13211
  measures2.forEach(
13193
13212
  (one, m) => subtotal(`${caption} ${caps.functions[fn]} of ${one.field}`, fn, m)
13194
13213
  );
13195
13214
  });
13196
13215
  };
13197
- const grand = (text7, measure3) => push(0, () => [
13216
+ const grand = (text7, measure4) => push(0, () => [
13198
13217
  compact ? [text7] : [text7, ...Array(levels - 1).fill(null)],
13199
- cells4(root2, void 0, measure3),
13200
- entryOf([0], measure3, "grand")
13218
+ cells4(root2, void 0, measure4),
13219
+ entryOf([0], measure4, "grand")
13201
13220
  ]);
13202
13221
  const build = () => {
13203
13222
  walk(0, root2, void 0, { labels: [], indices: [], firsts: [] });
@@ -13404,8 +13423,8 @@ function isSafePartName(name3) {
13404
13423
  if (body.startsWith("/")) return false;
13405
13424
  return !body.split("/").some((segment) => segment === "..");
13406
13425
  }
13407
- function declaredEntrySize(entry3) {
13408
- const data = entry3._data;
13426
+ function declaredEntrySize(entry4) {
13427
+ const data = entry4._data;
13409
13428
  const size3 = Number(data?.uncompressedSize ?? 0);
13410
13429
  return Number.isFinite(size3) && size3 > 0 ? size3 : 0;
13411
13430
  }
@@ -13419,10 +13438,10 @@ function resolveLimits(limits) {
13419
13438
  fail: (message, limit3, kind, actual) => create3 ? create3(message, { limit: limit3, kind, actual }) : new ZipLimitError(message, { limit: limit3, kind, actual })
13420
13439
  };
13421
13440
  }
13422
- async function inflateEntryGuarded(entry3, alreadyRead, limits) {
13441
+ async function inflateEntryGuarded(entry4, alreadyRead, limits) {
13423
13442
  const chunks = [];
13424
13443
  let size3 = 0;
13425
- for await (const chunk of streamEntryGuarded(entry3, alreadyRead, limits)) {
13444
+ for await (const chunk of streamEntryGuarded(entry4, alreadyRead, limits)) {
13426
13445
  chunks.push(chunk);
13427
13446
  size3 += chunk.byteLength;
13428
13447
  }
@@ -13436,10 +13455,10 @@ async function inflateEntryGuarded(entry3, alreadyRead, limits) {
13436
13455
  return out;
13437
13456
  }
13438
13457
  var AHEAD = 8;
13439
- async function* streamEntryGuarded(entry3, alreadyRead, limits) {
13458
+ async function* streamEntryGuarded(entry4, alreadyRead, limits) {
13440
13459
  const r = resolveLimits(limits);
13441
- const declared = declaredEntrySize(entry3);
13442
- const stream = entry3.internalStream("uint8array");
13460
+ const declared = declaredEntrySize(entry4);
13461
+ const stream = entry4.internalStream("uint8array");
13443
13462
  const queue = [];
13444
13463
  let size3 = 0;
13445
13464
  let ended = false;
@@ -13469,7 +13488,7 @@ async function* streamEntryGuarded(entry3, alreadyRead, limits) {
13469
13488
  if (size3 > declared || size3 > r.maxEntryBytes)
13470
13489
  return fail4(
13471
13490
  r.fail(
13472
- `${r.label} part ${entry3.name} inflates past its declared size`,
13491
+ `${r.label} part ${entry4.name} inflates past its declared size`,
13473
13492
  r.maxEntryBytes,
13474
13493
  size3 > declared ? "declaredSize" : "maxEntryBytes",
13475
13494
  size3
@@ -13532,15 +13551,15 @@ function guardZip(zip, limits = {}) {
13532
13551
  entries.length
13533
13552
  );
13534
13553
  let declared = 0;
13535
- for (const entry3 of entries) {
13536
- const original = entry3.unsafeOriginalName;
13537
- if (!isSafePartName(entry3.name) || original !== void 0 && !isSafePartName(original))
13554
+ for (const entry4 of entries) {
13555
+ const original = entry4.unsafeOriginalName;
13556
+ if (!isSafePartName(entry4.name) || original !== void 0 && !isSafePartName(original))
13538
13557
  throw r.fail(`${r.label} package has an unsafe part name`, r.maxEntries, "partName");
13539
- if (entry3.dir) continue;
13540
- const size3 = declaredEntrySize(entry3);
13558
+ if (entry4.dir) continue;
13559
+ const size3 = declaredEntrySize(entry4);
13541
13560
  if (size3 > r.maxEntryBytes)
13542
13561
  throw r.fail(
13543
- `${r.label} part ${entry3.name} exceeds the uncompressed part size limit`,
13562
+ `${r.label} part ${entry4.name} exceeds the uncompressed part size limit`,
13544
13563
  r.maxEntryBytes,
13545
13564
  "maxEntryBytes",
13546
13565
  size3
@@ -13556,15 +13575,15 @@ function guardZip(zip, limits = {}) {
13556
13575
  );
13557
13576
  const produced = /* @__PURE__ */ new Map();
13558
13577
  let total = 0;
13559
- for (const entry3 of entries) {
13560
- if (entry3.dir) continue;
13561
- const inflateOriginal = entry3.async.bind(entry3);
13562
- entry3.async = async (type, onUpdate) => {
13563
- const previous = produced.get(entry3.name) ?? 0;
13564
- const bytes = await inflateEntryGuarded(entry3, total - previous, limits);
13578
+ for (const entry4 of entries) {
13579
+ if (entry4.dir) continue;
13580
+ const inflateOriginal = entry4.async.bind(entry4);
13581
+ entry4.async = async (type, onUpdate) => {
13582
+ const previous = produced.get(entry4.name) ?? 0;
13583
+ const bytes = await inflateEntryGuarded(entry4, total - previous, limits);
13565
13584
  if (bytes.byteLength > previous) {
13566
13585
  total += bytes.byteLength - previous;
13567
- produced.set(entry3.name, bytes.byteLength);
13586
+ produced.set(entry4.name, bytes.byteLength);
13568
13587
  }
13569
13588
  switch (type) {
13570
13589
  case "uint8array":
@@ -14142,15 +14161,15 @@ function readPivotCaptionAttributes(root2) {
14142
14161
  }
14143
14162
  function aggregateCaptionsOf(pivot) {
14144
14163
  const out = {};
14145
- for (const measure3 of [
14164
+ for (const measure4 of [
14146
14165
  { field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
14147
14166
  ...pivot.additionalValues ?? []
14148
14167
  ]) {
14149
- const at3 = measure3.caption.indexOf(measure3.field);
14150
- if (at3 < 0 || measure3.caption === measure3.field) continue;
14151
- const template = `${measure3.caption.slice(0, at3)}{0}${measure3.caption.slice(at3 + measure3.field.length)}`;
14152
- if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure3.aggregate])
14153
- out[measure3.aggregate] = template;
14168
+ const at3 = measure4.caption.indexOf(measure4.field);
14169
+ if (at3 < 0 || measure4.caption === measure4.field) continue;
14170
+ const template = `${measure4.caption.slice(0, at3)}{0}${measure4.caption.slice(at3 + measure4.field.length)}`;
14171
+ if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure4.aggregate])
14172
+ out[measure4.aggregate] = template;
14154
14173
  }
14155
14174
  return Object.keys(out).length ? out : void 0;
14156
14175
  }
@@ -14533,17 +14552,17 @@ function settleSlicers(workbook, warn) {
14533
14552
  const book = workbook.slicers;
14534
14553
  if (!book) return;
14535
14554
  const pivotAt = (tabId, name3) => {
14536
- const sheet = workbook.sheets.find((entry3) => entry3.sheetId === tabId);
14537
- const pivot = sheet?.pivotTables?.find((entry3) => entry3.name === name3);
14555
+ const sheet = workbook.sheets.find((entry4) => entry4.sheetId === tabId);
14556
+ const pivot = sheet?.pivotTables?.find((entry4) => entry4.name === name3);
14538
14557
  return sheet && pivot ? { sheet, pivot } : void 0;
14539
14558
  };
14540
14559
  const good = (cache2) => {
14541
14560
  if (cache2.source.kind === "table") {
14542
14561
  const { tableId, column } = cache2.source;
14543
14562
  for (const sheet of workbook.sheets) {
14544
- const table2 = sheet.tables.find((entry3) => entry3.id === tableId);
14563
+ const table2 = sheet.tables.find((entry4) => entry4.id === tableId);
14545
14564
  if (table2)
14546
- return table2.headerRow && !table2.filterNotModeled && table2.columns.some((entry3) => entry3.sourceId === column);
14565
+ return table2.headerRow && !table2.filterNotModeled && table2.columns.some((entry4) => entry4.sourceId === column);
14547
14566
  }
14548
14567
  return false;
14549
14568
  }
@@ -14712,13 +14731,13 @@ function readDateGroups(fields, count, names, dateFields, records, date1904) {
14712
14731
  for (const [base2, list2] of members3) {
14713
14732
  const field2 = names[base2] ?? "";
14714
14733
  const parent = first(fields[base2], "fieldGroup", NS.x);
14715
- const units3 = list2.map((entry3) => entry3.unit);
14734
+ const units3 = list2.map((entry4) => entry4.unit);
14716
14735
  if (!dateFields.includes(field2) || Number(att(parent, "par")) !== list2.at(-1).index || units3.some(
14717
14736
  (unit4, i) => i > 0 && PIVOT_DATE_UNITS.indexOf(unit4) <= PIVOT_DATE_UNITS.indexOf(units3[i - 1])
14718
14737
  ))
14719
14738
  throw unsupported3("group parent");
14720
14739
  const ranges = list2.map(
14721
- (entry3) => first(first(entry3.node, "fieldGroup", NS.x), "rangePr", NS.x)
14740
+ (entry4) => first(first(entry4.node, "fieldGroup", NS.x), "rangePr", NS.x)
14722
14741
  );
14723
14742
  const sample = ranges[0];
14724
14743
  const autoStart = att(sample, "autoStart") !== "0";
@@ -14746,15 +14765,15 @@ function readDateGroups(fields, count, names, dateFields, records, date1904) {
14746
14765
  if (!close(expected.start, start) || !close(expected.end, end))
14747
14766
  throw unsupported3("stale range");
14748
14767
  const localized = {};
14749
- for (const entry3 of list2) {
14750
- const labels = englishDateUnitLabels(entry3.unit, expected, dateGroupDays(group2), date1904);
14751
- const node3 = first(first(entry3.node, "fieldGroup", NS.x), "groupItems", NS.x);
14768
+ for (const entry4 of list2) {
14769
+ const labels = englishDateUnitLabels(entry4.unit, expected, dateGroupDays(group2), date1904);
14770
+ const node3 = first(first(entry4.node, "fieldGroup", NS.x), "groupItems", NS.x);
14752
14771
  const actual = children(node3, "s", NS.x).map((item2) => decodeEscapes(att(item2, "v") ?? ""));
14753
- const name3 = decodeEscapes(att(entry3.node, "name") ?? "");
14772
+ const name3 = decodeEscapes(att(entry4.node, "name") ?? "");
14754
14773
  if (!name3 || elements(node3).length !== actual.length || actual.length !== labels.length || actual.some((label) => !label) || new Set(actual).size !== actual.length)
14755
14774
  throw unsupported3("group items");
14756
- if (name3 !== dateGroupFieldName(entry3.unit, field2) || actual.some((l, i) => l !== labels[i]))
14757
- localized[entry3.unit] = { name: name3, labels: actual };
14775
+ if (name3 !== dateGroupFieldName(entry4.unit, field2) || actual.some((l, i) => l !== labels[i]))
14776
+ localized[entry4.unit] = { name: name3, labels: actual };
14758
14777
  }
14759
14778
  groups.push(Object.keys(localized).length ? { ...group2, localized } : group2);
14760
14779
  }
@@ -14831,9 +14850,9 @@ function readItemNames(tableFields, names, shared) {
14831
14850
  // xlsx/pivot/values-axis.ts
14832
14851
  function remapPivotRowEntries(entries, axes) {
14833
14852
  return entries.map(
14834
- (entry3) => entry3.type === "grand" ? entry3 : {
14835
- ...entry3,
14836
- indices: entry3.indices.map((item2, axis) => {
14853
+ (entry4) => entry4.type === "grand" ? entry4 : {
14854
+ ...entry4,
14855
+ indices: entry4.indices.map((item2, axis) => {
14837
14856
  if (axes[axis] === null) return item2;
14838
14857
  const index3 = axes[axis]?.[item2];
14839
14858
  if (index3 === void 0) throw new Error("Invalid report row axis item");
@@ -14969,9 +14988,9 @@ function assertPageAxisItems(root2, pivot, shared, cache2, recordRoot) {
14969
14988
  throw new Error("Invalid page column items");
14970
14989
  let previous = [];
14971
14990
  colItems.forEach((item2, i) => {
14972
- const grand = i >= expected.length, measure3 = grand ? i - expected.length : i % measures2;
14991
+ const grand = i >= expected.length, measure4 = grand ? i - expected.length : i % measures2;
14973
14992
  const xs = children(item2, "x", NS.x).map((x) => integer2(x.getAttribute("v"), 0)), prefix2 = integer2(item2.getAttribute("r"), 0);
14974
- if (integer2(item2.getAttribute("i"), 0) !== measure3 || !Number.isInteger(prefix2) || prefix2 < 0 || prefix2 > Math.max(0, previous.length - 1))
14993
+ if (integer2(item2.getAttribute("i"), 0) !== measure4 || !Number.isInteger(prefix2) || prefix2 < 0 || prefix2 > Math.max(0, previous.length - 1))
14975
14994
  throw new Error("Invalid page column prefix");
14976
14995
  if (grand) {
14977
14996
  if (item2.getAttribute("t") !== "grand" || prefix2 !== 0 || xs.length !== 1 || xs[0] !== 0)
@@ -15013,12 +15032,12 @@ function readOne(workbook, source, part) {
15013
15032
  const cachePart = source.targetOfType(part, RELATIONSHIP_TYPES.pivotCacheDefinition);
15014
15033
  if (!cachePart) throw new Error("Missing pivot cache");
15015
15034
  const bookPart = source.workbookPart();
15016
- const entry3 = children(
15035
+ const entry4 = children(
15017
15036
  first(parseXml(source.text(bookPart)).documentElement, "pivotCaches", NS.x),
15018
15037
  "pivotCache",
15019
15038
  NS.x
15020
15039
  ).find((node3) => Number(att(node3, "cacheId")) === cacheId);
15021
- const relationship2 = entry3 && source.rels(bookPart).get(relAttr(entry3, "id") ?? "");
15040
+ const relationship2 = entry4 && source.rels(bookPart).get(relAttr(entry4, "id") ?? "");
15022
15041
  if (!relationship2 || source.target(bookPart, relationship2) !== cachePart)
15023
15042
  throw new Error("Inconsistent pivot cache identity");
15024
15043
  const cache2 = parseXml(source.text(cachePart)).documentElement;
@@ -15073,7 +15092,7 @@ function readOne(workbook, source, part) {
15073
15092
  if (rowFields.length < 1 || dataFields.length < 1 || dataFields.length > 16 || !supportedPivotAxes(rowFields, colFields, dataFields.length, rowsAxis) || root2.getAttribute("rowGrandTotals") === "0" || root2.getAttribute("colGrandTotals") === "0")
15074
15093
  throw new Error("Unsupported pivot layout");
15075
15094
  const valueIndex = pivotValueIndex(root2, rowsAxis ? rowFields : colFields);
15076
- const measure3 = dataFields[0];
15095
+ const measure4 = dataFields[0];
15077
15096
  const definition = elements(first(root2, "extLst", NS.x) ?? parseXml("<root/>").documentElement).map(
15078
15097
  (extension2) => first(
15079
15098
  extension2,
@@ -15097,8 +15116,8 @@ function readOne(workbook, source, part) {
15097
15116
  throw new Error("Unsupported Values axis item");
15098
15117
  }
15099
15118
  }
15100
- const aggregate = att(measure3, "subtotal") ?? "sum";
15101
- if (!PIVOT_AGGREGATES.includes(aggregate) || att(measure3, "showDataAs") && att(measure3, "showDataAs") !== "normal")
15119
+ const aggregate = att(measure4, "subtotal") ?? "sum";
15120
+ if (!PIVOT_AGGREGATES.includes(aggregate) || att(measure4, "showDataAs") && att(measure4, "showDataAs") !== "normal")
15102
15121
  throw new Error("Unsupported pivot aggregate");
15103
15122
  const names = fields.map((field2) => decodeEscapes(att(field2, "name") ?? ""));
15104
15123
  const axisNames = allFields.map((field2) => decodeEscapes(att(field2, "name") ?? ""));
@@ -15119,7 +15138,7 @@ function readOne(workbook, source, part) {
15119
15138
  const rowDefinitions = realRows.map((field2) => tableFields[Number(att(field2, "x"))]);
15120
15139
  const subtotalSettings = fieldSubtotalsOf(rowDefinitions, [row2, second, ...more]);
15121
15140
  const subtotal = !subtotalSettings.some(
15122
- (entry4) => entry4.field === row2 && entry4.functions.length === 0
15141
+ (entry5) => entry5.field === row2 && entry5.functions.length === 0
15123
15142
  );
15124
15143
  const repeat = realRows.map((field2) => {
15125
15144
  const node3 = tableFields[Number(att(field2, "x"))];
@@ -15133,7 +15152,7 @@ function readOne(workbook, source, part) {
15133
15152
  "fillDownLabels"
15134
15153
  ) === "1";
15135
15154
  });
15136
- if (repeat.some((entry4) => entry4 !== repeat[0])) throw new Error("Mixed field label repetition");
15155
+ if (repeat.some((entry5) => entry5 !== repeat[0])) throw new Error("Mixed field label repetition");
15137
15156
  const columnDefs = dataFields.length > 1 && !rowsAxis ? colFields.slice(0, -1) : colFields;
15138
15157
  const columnNames = columnDefs.map((field2) => axisNames[Number(att(field2, "x"))]);
15139
15158
  const hasColumn = columnDefs.length > 0;
@@ -15142,7 +15161,7 @@ function readOne(workbook, source, part) {
15142
15161
  const columnDefinitions = columnDefs.map((field2) => tableFields[Number(att(field2, "x"))]);
15143
15162
  if (columnNames.some((name3) => !name3)) throw new Error("Invalid pivot column fields");
15144
15163
  const columnSubtotals = fieldSubtotalsOf(columnDefinitions, columnNames);
15145
- const data = names[Number(att(measure3, "fld"))];
15164
+ const data = names[Number(att(measure4, "fld"))];
15146
15165
  const location = parseRange(att(first(root2, "location", NS.x), "ref") ?? "");
15147
15166
  if (!row2 || !data || !location || hasColumn && !col || realRows.length === 2 && !second)
15148
15167
  throw new Error("Invalid pivot fields");
@@ -15184,7 +15203,7 @@ function readOne(workbook, source, part) {
15184
15203
  if (dateFields.some((field2) => onAxis.has(field2)))
15185
15204
  throw new Error("Date fields used as rows, columns or values are preserved");
15186
15205
  const fieldSubtotals = [
15187
- ...subtotalSettings.filter((entry4) => entry4.field !== row2 || entry4.functions.length),
15206
+ ...subtotalSettings.filter((entry5) => entry5.field !== row2 || entry5.functions.length),
15188
15207
  ...columnSubtotals
15189
15208
  ];
15190
15209
  const pivot = {
@@ -15214,14 +15233,14 @@ function readOne(workbook, source, part) {
15214
15233
  },
15215
15234
  valueField: data,
15216
15235
  aggregate,
15217
- valueCaption: decodeEscapes(att(measure3, "name") ?? data),
15236
+ valueCaption: decodeEscapes(att(measure4, "name") ?? data),
15218
15237
  ...dataFields.length > 1 ? {
15219
- additionalValues: dataFields.slice(1).map((measure4) => {
15220
- const field2 = names[Number(att(measure4, "fld"))];
15221
- const aggregate2 = att(measure4, "subtotal") ?? "sum";
15222
- if (!field2 || !PIVOT_AGGREGATES.includes(aggregate2) || att(measure4, "showDataAs") && att(measure4, "showDataAs") !== "normal")
15238
+ additionalValues: dataFields.slice(1).map((measure5) => {
15239
+ const field2 = names[Number(att(measure5, "fld"))];
15240
+ const aggregate2 = att(measure5, "subtotal") ?? "sum";
15241
+ if (!field2 || !PIVOT_AGGREGATES.includes(aggregate2) || att(measure5, "showDataAs") && att(measure5, "showDataAs") !== "normal")
15223
15242
  throw new Error("Unsupported pivot measure");
15224
- return { field: field2, aggregate: aggregate2, caption: decodeEscapes(att(measure4, "name") ?? field2) };
15243
+ return { field: field2, aggregate: aggregate2, caption: decodeEscapes(att(measure5, "name") ?? field2) };
15225
15244
  })
15226
15245
  } : {},
15227
15246
  fields: names,
@@ -15527,9 +15546,9 @@ async function openPackage(input, limits) {
15527
15546
  async function readZipParts(input, limits = {}) {
15528
15547
  const zip = await openPackage(input, resolveLoadLimits(limits));
15529
15548
  const parts = /* @__PURE__ */ new Map();
15530
- for (const entry3 of Object.values(zip.files)) {
15531
- if (entry3.dir) continue;
15532
- parts.set(entry3.name.replace(/^\//, ""), await entry3.async("uint8array"));
15549
+ for (const entry4 of Object.values(zip.files)) {
15550
+ if (entry4.dir) continue;
15551
+ parts.set(entry4.name.replace(/^\//, ""), await entry4.async("uint8array"));
15533
15552
  }
15534
15553
  return parts;
15535
15554
  }
@@ -15653,10 +15672,10 @@ function splitSheetData(xml) {
15653
15672
  function parseColor(element2, palette) {
15654
15673
  if (!element2) return void 0;
15655
15674
  const color2 = {};
15656
- const rgb6 = att(element2, "rgb");
15675
+ const rgb7 = att(element2, "rgb");
15657
15676
  const theme2 = numAttr(element2, "theme");
15658
15677
  const indexed = numAttr(element2, "indexed");
15659
- if (rgb6 && /^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(rgb6)) color2.rgb = rgb6.toUpperCase();
15678
+ if (rgb7 && /^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(rgb7)) color2.rgb = rgb7.toUpperCase();
15660
15679
  else if (theme2 !== void 0) color2.theme = theme2;
15661
15680
  else if (indexed !== void 0) {
15662
15681
  const override = palette?.[indexed];
@@ -15940,15 +15959,15 @@ function parseStyles(xml, warnings) {
15940
15959
  const xfId = numAttr(node3, "xfId") ?? 0;
15941
15960
  const name3 = att(node3, "name") ?? `Style ${xfId}`;
15942
15961
  const style3 = styleXfs[xfId] ?? fallback;
15943
- const entry3 = { name: name3, style: structuredClone(style3) };
15962
+ const entry4 = { name: name3, style: structuredClone(style3) };
15944
15963
  const builtinId = numAttr(node3, "builtinId");
15945
- if (builtinId !== void 0) entry3.builtinId = builtinId;
15964
+ if (builtinId !== void 0) entry4.builtinId = builtinId;
15946
15965
  if (!namesByXf.has(xfId)) namesByXf.set(xfId, name3);
15947
- namedStyles.push(entry3);
15966
+ namedStyles.push(entry4);
15948
15967
  }
15949
- const normalAt = namedStyles.findIndex((entry3) => entry3.builtinId === 0);
15968
+ const normalAt = namedStyles.findIndex((entry4) => entry4.builtinId === 0);
15950
15969
  if (normalAt > 0) namedStyles.unshift(...namedStyles.splice(normalAt, 1));
15951
- if (!namedStyles.some((entry3) => entry3.name === "Normal"))
15970
+ if (!namedStyles.some((entry4) => entry4.name === "Normal"))
15952
15971
  namedStyles.unshift({ name: "Normal", style: styleXfs[0] ?? defaultCellStyle(), builtinId: 0 });
15953
15972
  const styles = [];
15954
15973
  const keys = /* @__PURE__ */ new Map();
@@ -16034,13 +16053,13 @@ function readDateGroup(node3) {
16034
16053
  return item2;
16035
16054
  }
16036
16055
  function readFilterColumn(column, dxfs) {
16037
- const entry3 = { offset: numAttr(column, "colId") ?? 0 };
16056
+ const entry4 = { offset: numAttr(column, "colId") ?? 0 };
16038
16057
  const filters = xFirst(column, "filters");
16039
16058
  if (filters) {
16040
- entry3.values = xChildren(filters, "filter").map((f) => att(f, "val") ?? "");
16041
- if (boolAttr(filters, "blank")) entry3.blank = true;
16059
+ entry4.values = xChildren(filters, "filter").map((f) => att(f, "val") ?? "");
16060
+ if (boolAttr(filters, "blank")) entry4.blank = true;
16042
16061
  const groups = xChildren(filters, "dateGroupItem").map(readDateGroup).filter((g) => g !== void 0);
16043
- if (groups.length) entry3.dateGroups = groups;
16062
+ if (groups.length) entry4.dateGroups = groups;
16044
16063
  }
16045
16064
  const custom = xFirst(column, "customFilters");
16046
16065
  if (custom) {
@@ -16051,12 +16070,12 @@ function readFilterColumn(column, dxfs) {
16051
16070
  value: att(c2, "val") ?? ""
16052
16071
  };
16053
16072
  });
16054
- entry3.custom = { ...boolAttr(custom, "and") ? { and: true } : {}, conditions };
16073
+ entry4.custom = { ...boolAttr(custom, "and") ? { and: true } : {}, conditions };
16055
16074
  }
16056
16075
  const top = xFirst(column, "top10");
16057
16076
  if (top) {
16058
16077
  const filterValue = numAttr(top, "filterVal");
16059
- entry3.top10 = {
16078
+ entry4.top10 = {
16060
16079
  top: boolAttr(top, "top", true),
16061
16080
  percent: boolAttr(top, "percent", false),
16062
16081
  value: numAttr(top, "val") ?? 10,
@@ -16067,7 +16086,7 @@ function readFilterColumn(column, dxfs) {
16067
16086
  if (dynamic2) {
16068
16087
  const value3 = numAttr(dynamic2, "val");
16069
16088
  const maxValue = numAttr(dynamic2, "maxVal");
16070
- entry3.dynamic = {
16089
+ entry4.dynamic = {
16071
16090
  type: att(dynamic2, "type") ?? "null",
16072
16091
  ...value3 !== void 0 ? { value: value3 } : {},
16073
16092
  ...maxValue !== void 0 ? { maxValue } : {}
@@ -16077,7 +16096,7 @@ function readFilterColumn(column, dxfs) {
16077
16096
  if (color2) {
16078
16097
  const dxfId = numAttr(color2, "dxfId");
16079
16098
  const style3 = dxfId === void 0 ? void 0 : dxfs?.[dxfId];
16080
- entry3.color = {
16099
+ entry4.color = {
16081
16100
  cellColor: boolAttr(color2, "cellColor", true),
16082
16101
  ...dxfId !== void 0 ? { dxfId } : {},
16083
16102
  ...style3 ? { style: structuredClone(style3) } : {}
@@ -16087,11 +16106,11 @@ function readFilterColumn(column, dxfs) {
16087
16106
  const iconSet = att(icon, "iconSet");
16088
16107
  if (iconSet) {
16089
16108
  const iconId = numAttr(icon, "iconId");
16090
- entry3.icon = { iconSet, ...iconId !== void 0 ? { iconId } : {} };
16109
+ entry4.icon = { iconSet, ...iconId !== void 0 ? { iconId } : {} };
16091
16110
  }
16092
- if (boolAttr(column, "hiddenButton")) entry3.hiddenButton = true;
16093
- entry3.sourceXml = outerXml(column).replace(MAIN_NS_DECL, "");
16094
- return entry3;
16111
+ if (boolAttr(column, "hiddenButton")) entry4.hiddenButton = true;
16112
+ entry4.sourceXml = outerXml(column).replace(MAIN_NS_DECL, "");
16113
+ return entry4;
16095
16114
  }
16096
16115
 
16097
16116
  // xlsx/read/sort-state.ts
@@ -17480,7 +17499,7 @@ function diagramNodesInTreeOrder(data) {
17480
17499
  nodes.sort(
17481
17500
  (a2, b) => (order.get(a2.node.id) ?? Number.MAX_SAFE_INTEGER) - (order.get(b.node.id) ?? Number.MAX_SAFE_INTEGER) || a2.index - b.index
17482
17501
  );
17483
- return treeOrderDiagramNodes(nodes.map((entry3) => entry3.node));
17502
+ return treeOrderDiagramNodes(nodes.map((entry4) => entry4.node));
17484
17503
  }
17485
17504
 
17486
17505
  // units/constants.ts
@@ -17490,7 +17509,7 @@ var EMU_PER_POINT = 12700;
17490
17509
  // drawingml/drawing-shadow.ts
17491
17510
  function resolveDrawingShadow(effects, theme2) {
17492
17511
  const effect = parseDrawingEffects(effects)?.effects.find(
17493
- (entry3) => entry3.kind === "outerShadow"
17512
+ (entry4) => entry4.kind === "outerShadow"
17494
17513
  );
17495
17514
  return effect?.kind === "outerShadow" ? resolveDrawingOuterShadow(effect, theme2) : void 0;
17496
17515
  }
@@ -18041,12 +18060,12 @@ function captureDiagramPictures(model2, dataXml, dataParts, drawing) {
18041
18060
  id4 = `ooxmlDiagramPicture${index3}`;
18042
18061
  parts[id4] = part;
18043
18062
  }
18044
- const entry3 = { ...source, fill: remapFill(source.fill, id4) };
18063
+ const entry4 = { ...source, fill: remapFill(source.fill, id4) };
18045
18064
  const existing = pictures.findIndex(
18046
- (item2) => item2.nodeId === entry3.nodeId && (item2.role === entry3.role && item2.styleLabel === entry3.styleLabel || !item2.role && !item2.styleLabel && item2.fill.relId === entry3.fill.relId)
18065
+ (item2) => item2.nodeId === entry4.nodeId && (item2.role === entry4.role && item2.styleLabel === entry4.styleLabel || !item2.role && !item2.styleLabel && item2.fill.relId === entry4.fill.relId)
18047
18066
  );
18048
- if (existing < 0) pictures.push(entry3);
18049
- else pictures[existing] = entry3;
18067
+ if (existing < 0) pictures.push(entry4);
18068
+ else pictures[existing] = entry4;
18050
18069
  };
18051
18070
  const root2 = parseXml(dataXml).documentElement;
18052
18071
  const saved2 = root2.getElementsByTagNameNS(DIAGRAM_PICTURE_SOURCE_NS, "picture");
@@ -18122,7 +18141,7 @@ async function resolveDiagramDrawingPart(hostPart, dataRelId, drawingExtensionRe
18122
18141
  const entries = await host.readRelationshipEntries(diagramRelationshipsPart(dataPath));
18123
18142
  if (!entries) return void 0;
18124
18143
  const drawing = entries.find(
18125
- (entry3) => (!drawingExtensionRelId || entry3.id.trim() === drawingExtensionRelId) && entry3.type.endsWith("/diagramDrawing")
18144
+ (entry4) => (!drawingExtensionRelId || entry4.id.trim() === drawingExtensionRelId) && entry4.type.endsWith("/diagramDrawing")
18126
18145
  );
18127
18146
  const id4 = drawing?.id.trim() ?? "";
18128
18147
  const target2 = drawing?.target.trim() ?? "";
@@ -18561,13 +18580,13 @@ async function loadDiagram(hostPart, relationshipIds, host) {
18561
18580
  diagramRelationshipsPart(drawingResolution.path)
18562
18581
  );
18563
18582
  const pictures = (entries ?? []).filter(
18564
- (entry3) => entry3.type.endsWith("/image") && entry3.mode !== "External" && !/^[a-z][a-z0-9+.-]*:/i.test(entry3.target)
18583
+ (entry4) => entry4.type.endsWith("/image") && entry4.mode !== "External" && !/^[a-z][a-z0-9+.-]*:/i.test(entry4.target)
18565
18584
  );
18566
18585
  if (pictures.length)
18567
18586
  drawing.pictureParts = Object.fromEntries(
18568
- pictures.map((entry3) => [
18569
- entry3.id,
18570
- host.resolvePath(drawingResolution.path, entry3.target)
18587
+ pictures.map((entry4) => [
18588
+ entry4.id,
18589
+ host.resolvePath(drawingResolution.path, entry4.target)
18571
18590
  ])
18572
18591
  );
18573
18592
  } catch {
@@ -18591,8 +18610,8 @@ async function loadDiagram(hostPart, relationshipIds, host) {
18591
18610
  const entries = await host.readRelationshipEntries(diagramRelationshipsPart(owner));
18592
18611
  pictureParts = Object.fromEntries(
18593
18612
  (entries ?? []).filter(
18594
- (entry3) => entry3.type.endsWith("/image") && entry3.mode !== "External" && !/^[a-z][a-z0-9+.-]*:/i.test(entry3.target)
18595
- ).map((entry3) => [entry3.id, host.resolvePath(owner, entry3.target)])
18613
+ (entry4) => entry4.type.endsWith("/image") && entry4.mode !== "External" && !/^[a-z][a-z0-9+.-]*:/i.test(entry4.target)
18614
+ ).map((entry4) => [entry4.id, host.resolvePath(owner, entry4.target)])
18596
18615
  );
18597
18616
  } catch {
18598
18617
  issues.push({
@@ -20059,12 +20078,12 @@ var LEGEND = /* @__PURE__ */ new Set(["legendPos", "legendEntry", "layout", "ove
20059
20078
  function parseLegend(context, element2) {
20060
20079
  reportUnmodelled(context, element2, LEGEND);
20061
20080
  const entries = children(element2, "legendEntry", NS.c).map(
20062
- (entry3) => assignDefined(
20081
+ (entry4) => assignDefined(
20063
20082
  {},
20064
20083
  {
20065
- index: cNumber(context, entry3, "idx"),
20066
- deleted: cBool(context, entry3, "delete"),
20067
- txPr: textProperties(entry3)
20084
+ index: cNumber(context, entry4, "idx"),
20085
+ deleted: cBool(context, entry4, "delete"),
20086
+ txPr: textProperties(entry4)
20068
20087
  }
20069
20088
  )
20070
20089
  );
@@ -20548,9 +20567,9 @@ function view3DXml(view2) {
20548
20567
  function legendXml(context, legend) {
20549
20568
  if (!legend) return "";
20550
20569
  const entries = legend.entries.map(
20551
- (entry3) => elementXml(
20570
+ (entry4) => elementXml(
20552
20571
  "legendEntry",
20553
- valXml("idx", entry3.index) + valXml("delete", entry3.deleted) + textBodyXml(context, entry3.txPr)
20572
+ valXml("idx", entry4.index) + valXml("delete", entry4.deleted) + textBodyXml(context, entry4.txPr)
20554
20573
  )
20555
20574
  ).join("");
20556
20575
  return elementXml(
@@ -20701,8 +20720,8 @@ function summaryErrorBars(source) {
20701
20720
  return out;
20702
20721
  }
20703
20722
  function summaryAnalysis(series) {
20704
- const trendlines = (series.trendlines ?? []).map(summaryTrendline).filter((entry3) => entry3 !== void 0);
20705
- const errorBars = (series.errorBars ?? []).map(summaryErrorBars).filter((entry3) => entry3 !== void 0);
20723
+ const trendlines = (series.trendlines ?? []).map(summaryTrendline).filter((entry4) => entry4 !== void 0);
20724
+ const errorBars = (series.errorBars ?? []).map(summaryErrorBars).filter((entry4) => entry4 !== void 0);
20706
20725
  return {
20707
20726
  ...trendlines.length ? { trendlines } : {},
20708
20727
  ...errorBars.length ? { errorBars } : {}
@@ -21112,7 +21131,7 @@ function extraGroups(chartSpace, firstType) {
21112
21131
  const stockOverColumns = group2.kind === "stock" && firstType === "column";
21113
21132
  if (group2.is3D || !(["bar", "line", "area"].includes(group2.kind) || stockOverColumns)) continue;
21114
21133
  const type = group2.kind === "bar" ? "column" : group2.kind;
21115
- const entry3 = {
21134
+ const entry4 = {
21116
21135
  chartType: type,
21117
21136
  series: group2.series.map((source, index3) => ({
21118
21137
  ...chartSummarySeries(
@@ -21126,13 +21145,13 @@ function extraGroups(chartSpace, firstType) {
21126
21145
  secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
21127
21146
  };
21128
21147
  if (group2.grouping && GROUPINGS.has(group2.grouping))
21129
- entry3.grouping = group2.grouping;
21130
- if (type === "stock") entry3.stock = stockStyle(group2);
21148
+ entry4.grouping = group2.grouping;
21149
+ if (type === "stock") entry4.stock = stockStyle(group2);
21131
21150
  if (type === "column") {
21132
- if (group2.gapWidth !== void 0) entry3.barGapWidth = group2.gapWidth;
21133
- if (group2.overlap !== void 0) entry3.barOverlap = group2.overlap;
21151
+ if (group2.gapWidth !== void 0) entry4.barGapWidth = group2.gapWidth;
21152
+ if (group2.overlap !== void 0) entry4.barOverlap = group2.overlap;
21134
21153
  }
21135
- if (entry3.series.length) out.push(entry3);
21154
+ if (entry4.series.length) out.push(entry4);
21136
21155
  }
21137
21156
  return out;
21138
21157
  }
@@ -21836,20 +21855,20 @@ function resolveChartStyleDefinition(style3, resolve) {
21836
21855
  for (const name3 of CHART_STYLE_PARTS) {
21837
21856
  const source = style3.entries[name3];
21838
21857
  if (!source) continue;
21839
- const entry3 = {};
21858
+ const entry4 = {};
21840
21859
  for (const key3 of ["fontSize", "bold", "italic", "underline"]) {
21841
21860
  const value3 = source[key3];
21842
- if (value3 !== void 0) Object.assign(entry3, { [key3]: value3 });
21861
+ if (value3 !== void 0) Object.assign(entry4, { [key3]: value3 });
21843
21862
  }
21844
21863
  const line = fillColor(source.line?.fill) ?? (source.lineRef?.color && resolve(source.lineRef.color));
21845
21864
  const fill = fillColor(source.fill) ?? (source.fillRef?.color && resolve(source.fillRef.color));
21846
21865
  const color2 = (source.textColor && resolve(source.textColor)) ?? (source.fontRef?.color && resolve(source.fontRef.color));
21847
- if (color2 !== void 0) entry3.color = color2;
21848
- if (line !== void 0) entry3.lineColor = line;
21849
- if (fill !== void 0) entry3.fillColor = fill;
21866
+ if (color2 !== void 0) entry4.color = color2;
21867
+ if (line !== void 0) entry4.lineColor = line;
21868
+ if (fill !== void 0) entry4.fillColor = fill;
21850
21869
  if (source.line?.widthEmu !== void 0 && source.line.widthEmu > 0)
21851
- entry3.lineWidth = source.line.widthEmu / 12700;
21852
- if (Object.keys(entry3).length) out[name3] = entry3;
21870
+ entry4.lineWidth = source.line.widthEmu / 12700;
21871
+ if (Object.keys(entry4).length) out[name3] = entry4;
21853
21872
  }
21854
21873
  return Object.keys(out).length ? out : void 0;
21855
21874
  }
@@ -21996,9 +22015,9 @@ var TEXT_PARTS = [
21996
22015
  "legend",
21997
22016
  "dataLabel"
21998
22017
  ];
21999
- function inheritChartText(part, entry3, builtIn, root2) {
22000
- if (!root2 || !TEXT_PARTS.includes(part)) return entry3;
22001
- const out = { ...entry3 };
22018
+ function inheritChartText(part, entry4, builtIn, root2) {
22019
+ if (!root2 || !TEXT_PARTS.includes(part)) return entry4;
22020
+ const out = { ...entry4 };
22002
22021
  for (const key3 of TEXT_KEYS) {
22003
22022
  delete out[key3];
22004
22023
  const value3 = root2[key3] ?? builtIn?.[key3];
@@ -22011,11 +22030,11 @@ function inheritChartText(part, entry3, builtIn, root2) {
22011
22030
 
22012
22031
  // chart/render/chart-appearance.ts
22013
22032
  var chartPointsToPixels = (points) => points * EMU_PER_POINT / EMU_PER_PIXEL;
22014
- function typeface(entry3, theme2) {
22015
- const name3 = entry3.typeface;
22033
+ function typeface(entry4, theme2) {
22034
+ const name3 = entry4.typeface;
22016
22035
  if (name3?.startsWith("+mj-")) return theme2.majorFont;
22017
22036
  if (name3?.startsWith("+mn-")) return theme2.minorFont;
22018
- return name3 ?? (entry3.fontRef?.index === "major" ? theme2.majorFont : entry3.fontRef?.index === "minor" ? theme2.minorFont : void 0);
22037
+ return name3 ?? (entry4.fontRef?.index === "major" ? theme2.majorFont : entry4.fontRef?.index === "minor" ? theme2.minorFont : void 0);
22019
22038
  }
22020
22039
  function chartAppearance(chart, theme2) {
22021
22040
  const defaults = builtInChartTextStyle(effectiveBuiltInChartStyle(chart.formatting));
@@ -22024,7 +22043,7 @@ function chartAppearance(chart, theme2) {
22024
22043
  const base2 = chart.styleDefinition?.entries[part];
22025
22044
  const direct = chart.formatting?.entries[part];
22026
22045
  if (!defaults[part] && !base2 && !direct) continue;
22027
- const entry3 = {
22046
+ const entry4 = {
22028
22047
  ...inheritChartText(
22029
22048
  part,
22030
22049
  { ...defaults[part], ...base2, sourceXml: base2?.sourceXml ?? "" },
@@ -22034,8 +22053,8 @@ function chartAppearance(chart, theme2) {
22034
22053
  ...direct,
22035
22054
  sourceXml: direct?.sourceXml ?? base2?.sourceXml ?? ""
22036
22055
  };
22037
- if (base2?.line || direct?.line) entry3.line = { ...base2?.line, ...direct?.line };
22038
- entries[part] = entry3;
22056
+ if (base2?.line || direct?.line) entry4.line = { ...base2?.line, ...direct?.line };
22057
+ entries[part] = entry4;
22039
22058
  }
22040
22059
  const scheme = chartColorScheme(theme2);
22041
22060
  const resolve = (color2) => resolveDrawingColor(
@@ -22048,19 +22067,19 @@ function chartAppearance(chart, theme2) {
22048
22067
  (color2) => drawingColorCss(resolve(color2))
22049
22068
  ) ?? {};
22050
22069
  for (const part of CHART_STYLE_PARTS) {
22051
- const entry3 = entries[part];
22052
- if (!entry3) continue;
22053
- const family = typeface(entry3, theme2);
22054
- const shadow = resolveDrawingShadowXml(entry3.textEffectsXml, {
22070
+ const entry4 = entries[part];
22071
+ if (!entry4) continue;
22072
+ const family = typeface(entry4, theme2);
22073
+ const shadow = resolveDrawingShadowXml(entry4.textEffectsXml, {
22055
22074
  scheme: (name3) => scheme[name3]
22056
22075
  });
22057
22076
  if (shadow) (out[part] ??= {}).textShadow = shadow;
22058
22077
  if (family) (out[part] ??= {}).typeface = family;
22059
- if (entry3.axisVisible !== void 0) (out[part] ??= {}).axisVisible = entry3.axisVisible;
22060
- if (entry3.labelsVisible !== void 0) (out[part] ??= {}).labelsVisible = entry3.labelsVisible;
22061
- if (entry3.line?.widthEmu === 0) (out[part] ??= {}).lineWidth = 0;
22062
- if (entry3.fill?.kind === "gradient") {
22063
- (out[part] ??= {}).gradient = resolveChartGradient(entry3.fill, resolve);
22078
+ if (entry4.axisVisible !== void 0) (out[part] ??= {}).axisVisible = entry4.axisVisible;
22079
+ if (entry4.labelsVisible !== void 0) (out[part] ??= {}).labelsVisible = entry4.labelsVisible;
22080
+ if (entry4.line?.widthEmu === 0) (out[part] ??= {}).lineWidth = 0;
22081
+ if (entry4.fill?.kind === "gradient") {
22082
+ (out[part] ??= {}).gradient = resolveChartGradient(entry4.fill, resolve);
22064
22083
  }
22065
22084
  }
22066
22085
  return out;
@@ -22079,8 +22098,8 @@ function chartRunStyle(run2) {
22079
22098
  }
22080
22099
  function chartTitleText(chart, theme2) {
22081
22100
  const formatting = chart.formatting;
22082
- const entry3 = formatting?.entries.title;
22083
- const body = entry3?.textBody;
22101
+ const entry4 = formatting?.entries.title;
22102
+ const body = entry4?.textBody;
22084
22103
  if (!formatting || !body || body.text !== chart.title) return void 0;
22085
22104
  if (body.paragraphs.length === 1 && body.paragraphs[0].runs.length <= 1 && !body.text.includes("\n") && !body.paragraphs[0].lineSpacing && !body.paragraphs[0].spaceBefore && !body.paragraphs[0].spaceAfter)
22086
22105
  return void 0;
@@ -22093,7 +22112,7 @@ function chartTitleText(chart, theme2) {
22093
22112
  runs: paragraph2.runs.map((run2) => {
22094
22113
  const direct = {
22095
22114
  sourceXml: "",
22096
- ...entry3.textBodyStyle,
22115
+ ...entry4.textBodyStyle,
22097
22116
  ...chartRunStyle(paragraph2.defaultProperties ?? {}),
22098
22117
  ...chartRunStyle(run2)
22099
22118
  };
@@ -22919,23 +22938,23 @@ function readValue2(ctx, c2, cell) {
22919
22938
  const raw2 = v ? v.textContent ?? "" : void 0;
22920
22939
  switch (type) {
22921
22940
  case "s": {
22922
- const entry3 = ctx.sharedStrings[Number(raw2)];
22923
- if (!entry3) {
22941
+ const entry4 = ctx.sharedStrings[Number(raw2)];
22942
+ if (!entry4) {
22924
22943
  if (raw2 !== void 0) ctx.warn("A cell refers to a missing shared string.");
22925
22944
  return;
22926
22945
  }
22927
- cell.value = entry3.text;
22928
- if (entry3.runs) cell.richText = entry3.runs.map((run2) => ({ ...run2 }));
22929
- if (entry3.phonetic) cell.phonetic = structuredClone(entry3.phonetic);
22946
+ cell.value = entry4.text;
22947
+ if (entry4.runs) cell.richText = entry4.runs.map((run2) => ({ ...run2 }));
22948
+ if (entry4.phonetic) cell.phonetic = structuredClone(entry4.phonetic);
22930
22949
  return;
22931
22950
  }
22932
22951
  case "inlineStr": {
22933
22952
  const is = xFirst(c2, "is");
22934
22953
  if (!is) return;
22935
- const entry3 = parseRichString(is, ctx.palette);
22936
- cell.value = entry3.text;
22937
- if (entry3.runs) cell.richText = entry3.runs;
22938
- if (entry3.phonetic) cell.phonetic = entry3.phonetic;
22954
+ const entry4 = parseRichString(is, ctx.palette);
22955
+ cell.value = entry4.text;
22956
+ if (entry4.runs) cell.richText = entry4.runs;
22957
+ if (entry4.phonetic) cell.phonetic = entry4.phonetic;
22939
22958
  return;
22940
22959
  }
22941
22960
  case "str":
@@ -23428,13 +23447,13 @@ async function loadXlsx(input, options2 = {}) {
23428
23447
  const warn = (message) => {
23429
23448
  if (!warnings.includes(message)) warnings.push(message);
23430
23449
  };
23431
- const partOf = (type) => source.targetOfType(workbookPart, type);
23432
- const stylesPart = partOf(RELATIONSHIP_TYPES.styles);
23450
+ const partOf2 = (type) => source.targetOfType(workbookPart, type);
23451
+ const stylesPart = partOf2(RELATIONSHIP_TYPES.styles);
23433
23452
  const styles = parseStyles(stylesPart ? source.text(stylesPart) : void 0, warnings);
23434
- const themePart = partOf(RELATIONSHIP_TYPES.theme);
23435
- const stringsPart = partOf(RELATIONSHIP_TYPES.sharedStrings);
23436
- const personsPart = partOf(RELATIONSHIP_TYPES.person);
23437
- const metadataPart = partOf(RELATIONSHIP_TYPES.sheetMetadata);
23453
+ const themePart = partOf2(RELATIONSHIP_TYPES.theme);
23454
+ const stringsPart = partOf2(RELATIONSHIP_TYPES.sharedStrings);
23455
+ const personsPart = partOf2(RELATIONSHIP_TYPES.person);
23456
+ const metadataPart = partOf2(RELATIONSHIP_TYPES.sheetMetadata);
23438
23457
  const ctx = {
23439
23458
  source,
23440
23459
  sharedStrings: parseSharedStrings(
@@ -23452,24 +23471,24 @@ async function loadXlsx(input, options2 = {}) {
23452
23471
  maxXmlElements: limits.maxXmlElements
23453
23472
  };
23454
23473
  const rels = source.rels(workbookPart);
23455
- const sheets = book.sheets.map((entry3) => {
23456
- const rel = rels.get(entry3.relId);
23474
+ const sheets = book.sheets.map((entry4) => {
23475
+ const rel = rels.get(entry4.relId);
23457
23476
  const target2 = rel ? source.target(workbookPart, rel) : void 0;
23458
23477
  let sheet;
23459
23478
  if (rel?.type === RELATIONSHIP_TYPES.worksheet && target2) {
23460
- sheet = parseWorksheet(ctx, target2, entry3.name, entry3.sheetId);
23479
+ sheet = parseWorksheet(ctx, target2, entry4.name, entry4.sheetId);
23461
23480
  } else {
23462
- sheet = createWorksheet(entry3.name, entry3.sheetId);
23481
+ sheet = createWorksheet(entry4.name, entry4.sheetId);
23463
23482
  if (target2) sheet.partName = target2;
23464
23483
  const kind = rel?.type.split("/").pop() ?? "sheet";
23465
- warn(`Sheet "${entry3.name}" is a ${kind}; it is kept on save but cannot be shown or edited.`);
23484
+ warn(`Sheet "${entry4.name}" is a ${kind}; it is kept on save but cannot be shown or edited.`);
23466
23485
  }
23467
- sheet.state = entry3.state;
23486
+ sheet.state = entry4.state;
23468
23487
  return sheet;
23469
23488
  });
23470
- if (source.has("xl/vbaProject.bin") || partOf(RELATIONSHIP_TYPES.vbaProject))
23489
+ if (source.has("xl/vbaProject.bin") || partOf2(RELATIONSHIP_TYPES.vbaProject))
23471
23490
  warn("The workbook contains VBA macros; they are kept on save but never run.");
23472
- if (partOf(RELATIONSHIP_TYPES.externalLink))
23491
+ if (partOf2(RELATIONSHIP_TYPES.externalLink))
23473
23492
  warn("External workbook links are kept but not updated.");
23474
23493
  const signatures = detectDigitalSignatures([...parts.keys()]);
23475
23494
  if (signatures.hasSignatures)
@@ -24193,14 +24212,14 @@ function strokeOf(line, fallback, resolve) {
24193
24212
  }
24194
24213
  function analysisView(source, seriesColor, resolve) {
24195
24214
  const plain3 = seriesColor === "none" || seriesColor.startsWith("url(") ? TEXT_COLOR : seriesColor;
24196
- const trendlines = (source.trendlines ?? []).flatMap((entry3) => {
24197
- const { name: _name, line, ...fit3 } = entry3;
24215
+ const trendlines = (source.trendlines ?? []).flatMap((entry4) => {
24216
+ const { name: _name, line, ...fit3 } = entry4;
24198
24217
  const fallback = { color: plain3, width: chartPointsToPixels(1.5), dash: "sysDot" };
24199
24218
  const stroke = strokeOf(line, fallback, resolve);
24200
24219
  return stroke ? [{ fit: fit3, stroke }] : [];
24201
24220
  });
24202
- const errorBars = (source.errorBars ?? []).flatMap((entry3) => {
24203
- const { direction: direction2, barType, noEndCap, line, ...amount } = entry3;
24221
+ const errorBars = (source.errorBars ?? []).flatMap((entry4) => {
24222
+ const { direction: direction2, barType, noEndCap, line, ...amount } = entry4;
24204
24223
  const stroke = strokeOf(line, { color: TEXT_COLOR, width: chartPointsToPixels(0.75) }, resolve);
24205
24224
  return stroke ? [{ direction: direction2, barType, amount, endCap: noEndCap !== true, stroke }] : [];
24206
24225
  });
@@ -25276,13 +25295,13 @@ function cross2(o, a2, b) {
25276
25295
  return (a2.x - o.x) * (b.y - o.y) - (a2.y - o.y) * (b.x - o.x);
25277
25296
  }
25278
25297
  function signedArea(poly) {
25279
- let area2 = 0;
25298
+ let area3 = 0;
25280
25299
  for (let i = 0, n = poly.length; i < n; i++) {
25281
25300
  const j = (i + 1) % n;
25282
- area2 += at(poly, i).x * at(poly, j).y;
25283
- area2 -= at(poly, j).x * at(poly, i).y;
25301
+ area3 += at(poly, i).x * at(poly, j).y;
25302
+ area3 -= at(poly, j).x * at(poly, i).y;
25284
25303
  }
25285
- return area2 / 2;
25304
+ return area3 / 2;
25286
25305
  }
25287
25306
  function ensureCCW(poly) {
25288
25307
  return signedArea(poly) < 0 ? [...poly].reverse() : poly;
@@ -25472,20 +25491,20 @@ function drawingPaint(node3, colors, placeholder3, depth = 0) {
25472
25491
  (transform2) => !SUPPORTED_TRANSFORMS.has(transform2.name) || (integer4(transform2.value) ?? 100001) > 1e5
25473
25492
  ))
25474
25493
  return void 0;
25475
- let rgb6;
25494
+ let rgb7;
25476
25495
  let inherited;
25477
- if (color2.kind === "srgb") rgb6 = color2.value;
25478
- else if (color2.kind === "system") rgb6 = color2.fallback;
25496
+ if (color2.kind === "srgb") rgb7 = color2.value;
25497
+ else if (color2.kind === "system") rgb7 = color2.fallback;
25479
25498
  else if (color2.kind === "scheme") {
25480
- if (color2.value === "phClr") rgb6 = placeholder3;
25499
+ if (color2.value === "phClr") rgb7 = placeholder3;
25481
25500
  else {
25482
25501
  inherited = drawingPaint(colors.get(color2.value), colors, placeholder3, depth + 1);
25483
- rgb6 = inherited?.color;
25502
+ rgb7 = inherited?.color;
25484
25503
  }
25485
25504
  }
25486
- if (!rgb6 || !/^#?[\da-f]{6}$/i.test(rgb6)) return void 0;
25505
+ if (!rgb7 || !/^#?[\da-f]{6}$/i.test(rgb7)) return void 0;
25487
25506
  const resolved = resolveDrawingColor(
25488
- { kind: "srgb", value: rgb6.replace(/^#/, ""), transforms },
25507
+ { kind: "srgb", value: rgb7.replace(/^#/, ""), transforms },
25489
25508
  void 0,
25490
25509
  { transformOrder: "document" }
25491
25510
  );
@@ -26476,7 +26495,7 @@ function shapeShadow(cells4, color2, report, themed) {
26476
26495
  "approximate-shadow-offset",
26477
26496
  "A shadow without a shape offset uses Visio's default 0.125 inch page offset."
26478
26497
  );
26479
- const clamp2 = (value3, limit3) => Math.max(-limit3, Math.min(limit3, value3));
26498
+ const clamp3 = (value3, limit3) => Math.max(-limit3, Math.min(limit3, value3));
26480
26499
  const transparency = number(cells4, "ShdwForegndTrans", 0, report);
26481
26500
  report(
26482
26501
  "unverified-shadow",
@@ -26485,8 +26504,8 @@ function shapeShadow(cells4, color2, report, themed) {
26485
26504
  return {
26486
26505
  color: color2("ShdwForegnd", "#000000"),
26487
26506
  opacity: Math.max(0, Math.min(1, 1 - transparency)),
26488
- offsetX: clamp2(hasOffset ? number(cells4, "ShapeShdwOffsetX", 0.125, report) : 0.125, 1e3),
26489
- offsetY: clamp2(hasOffset ? number(cells4, "ShapeShdwOffsetY", -0.125, report) : -0.125, 1e3),
26507
+ offsetX: clamp3(hasOffset ? number(cells4, "ShapeShdwOffsetX", 0.125, report) : 0.125, 1e3),
26508
+ offsetY: clamp3(hasOffset ? number(cells4, "ShapeShdwOffsetY", -0.125, report) : -0.125, 1e3),
26490
26509
  blur: Math.max(0, Math.min(10, number(cells4, "ShapeShdwBlur", 0, report)))
26491
26510
  };
26492
26511
  }
@@ -26494,30 +26513,30 @@ function shapeShadow(cells4, color2, report, themed) {
26494
26513
  // visio/effects.ts
26495
26514
  function shapeEffects(cells4, color2, report, themed) {
26496
26515
  const explicit = (name3) => cells4.has(name3) && cells4.get(name3)?.value !== "Themed";
26497
- const clamp2 = (value3, maximum) => Math.max(0, Math.min(maximum, value3));
26516
+ const clamp3 = (value3, maximum) => Math.max(0, Math.min(maximum, value3));
26498
26517
  const result2 = {};
26499
- const glow = explicit("GlowSize") ? clamp2(number(cells4, "GlowSize", 0, report), 2.5) : 0;
26518
+ const glow = explicit("GlowSize") ? clamp3(number(cells4, "GlowSize", 0, report), 2.5) : 0;
26500
26519
  if (glow > 0) {
26501
- const opacity2 = 1 - clamp2(number(cells4, "GlowColorTrans", 0, report), 1);
26520
+ const opacity2 = 1 - clamp3(number(cells4, "GlowColorTrans", 0, report), 1);
26502
26521
  if (opacity2 > 0) result2.glow = { color: color2("GlowColor", "#000000"), opacity: opacity2, size: glow };
26503
26522
  }
26504
- const soft = explicit("SoftEdgesSize") ? clamp2(number(cells4, "SoftEdgesSize", 0, report), 2) : 0;
26523
+ const soft = explicit("SoftEdgesSize") ? clamp3(number(cells4, "SoftEdgesSize", 0, report), 2) : 0;
26505
26524
  if (soft > 0) result2.softEdges = soft;
26506
- const size3 = explicit("ReflectionSize") ? clamp2(number(cells4, "ReflectionSize", 0, report), 1) : 0;
26525
+ const size3 = explicit("ReflectionSize") ? clamp3(number(cells4, "ReflectionSize", 0, report), 1) : 0;
26507
26526
  if (size3 > 0) {
26508
- const opacity2 = 1 - clamp2(number(cells4, "ReflectionTrans", 0, report), 1);
26527
+ const opacity2 = 1 - clamp3(number(cells4, "ReflectionTrans", 0, report), 1);
26509
26528
  if (opacity2 > 0)
26510
26529
  result2.reflection = {
26511
26530
  opacity: opacity2,
26512
26531
  size: size3,
26513
- distance: clamp2(number(cells4, "ReflectionDist", 0, report), 2),
26514
- blur: clamp2(number(cells4, "ReflectionBlur", 0, report), 2)
26532
+ distance: clamp3(number(cells4, "ReflectionDist", 0, report), 2),
26533
+ blur: clamp3(number(cells4, "ReflectionBlur", 0, report), 2)
26515
26534
  };
26516
26535
  }
26517
- const themedCell = (...names) => names.some((name3) => cells4.get(name3)?.value === "Themed");
26518
- if (themed?.glow && themedCell("GlowSize")) result2.glow = themed.glow;
26519
- if (themed?.softEdges && themedCell("SoftEdgesSize")) result2.softEdges = themed.softEdges;
26520
- if (themed?.reflection && themedCell("ReflectionSize", "ReflectionTrans"))
26536
+ const themedCell2 = (...names) => names.some((name3) => cells4.get(name3)?.value === "Themed");
26537
+ if (themed?.glow && themedCell2("GlowSize")) result2.glow = themed.glow;
26538
+ if (themed?.softEdges && themedCell2("SoftEdgesSize")) result2.softEdges = themed.softEdges;
26539
+ if (themed?.reflection && themedCell2("ReflectionSize", "ReflectionTrans"))
26521
26540
  result2.reflection = themed.reflection;
26522
26541
  if (result2.glow || result2.softEdges || result2.reflection)
26523
26542
  report(
@@ -26555,7 +26574,11 @@ var VISIO_ROTATION_PRESETS = [
26555
26574
  ["off-axis-right", "Off Axis Right", 30, 20, 0, 0],
26556
26575
  ["perspective-left", "Perspective Left", -35, 0, 0, 60],
26557
26576
  ["perspective-right", "Perspective Right", 35, 0, 0, 60],
26558
- ["perspective-relaxed", "Perspective Relaxed", 20, 10, 0, 60]
26577
+ ["perspective-relaxed", "Perspective Relaxed", 20, 10, 0, 60],
26578
+ ["perspective-above", "Perspective Above", 0, -25, 0, 60],
26579
+ ["perspective-below", "Perspective Below", 0, 25, 0, 60],
26580
+ ["perspective-heroic-left", "Perspective Heroic Left", -45, -20, 0, 90],
26581
+ ["perspective-heroic-right", "Perspective Heroic Right", 45, -20, 0, 90]
26559
26582
  ].map(([id4, label, x, y, z, perspective]) => ({
26560
26583
  id: id4,
26561
26584
  label,
@@ -26580,6 +26603,39 @@ function rotationWrites(id4, add) {
26580
26603
  add("RotationZAngle", radians(preset.z), "FillStyle", "DEG");
26581
26604
  add("Perspective", radians(preset.perspective), "FillStyle", "DEG");
26582
26605
  }
26606
+ var rgb = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
26607
+ function solidWrites(edit, add) {
26608
+ if (edit.extrusionDepth !== void 0)
26609
+ add("BevelDepthSize", edit.extrusionDepth / 72, "FillStyle", "PT");
26610
+ if (edit.extrusionColor !== void 0)
26611
+ add("BevelDepthColor", edit.extrusionColor, "FillStyle", void 0, rgb(edit.extrusionColor));
26612
+ if (edit.contourSize !== void 0)
26613
+ add("BevelContourSize", edit.contourSize / 72, "FillStyle", "PT");
26614
+ if (edit.contourColor !== void 0)
26615
+ add("BevelContourColor", edit.contourColor, "FillStyle", void 0, rgb(edit.contourColor));
26616
+ }
26617
+ function snapshotSolid(edit) {
26618
+ const length = (value3, high, what) => {
26619
+ if (typeof value3 !== "number" || !Number.isFinite(value3) || value3 < 0 || value3 > high)
26620
+ fail("INVALID_EDIT", `${what} must be 0 to ${high} points.`);
26621
+ return Math.round(value3 * 100) / 100;
26622
+ };
26623
+ const color2 = (value3, what) => {
26624
+ if (typeof value3 !== "string" || !/^#[0-9a-f]{6}$/i.test(value3))
26625
+ fail("INVALID_EDIT", `${what} requires six hexadecimal digits.`);
26626
+ return value3.toLowerCase();
26627
+ };
26628
+ const result2 = {};
26629
+ if (edit.extrusionDepth !== void 0)
26630
+ result2.extrusionDepth = length(edit.extrusionDepth, 288, "Extrusion depth");
26631
+ if (edit.extrusionColor !== void 0)
26632
+ result2.extrusionColor = color2(edit.extrusionColor, "The extrusion colour");
26633
+ if (edit.contourSize !== void 0)
26634
+ result2.contourSize = length(edit.contourSize, 72, "Contour size");
26635
+ if (edit.contourColor !== void 0)
26636
+ result2.contourColor = color2(edit.contourColor, "The contour colour");
26637
+ return result2;
26638
+ }
26583
26639
  function snapshotBevel(value3) {
26584
26640
  if (!isVisioBevelPreset(value3)) fail("INVALID_EDIT", "Unknown bevel preset.");
26585
26641
  return value3;
@@ -26588,14 +26644,29 @@ function snapshotRotation(value3) {
26588
26644
  if (!isVisioRotationPreset(value3)) fail("INVALID_EDIT", "Unknown 3-D rotation preset.");
26589
26645
  return value3;
26590
26646
  }
26591
- var saved = (cells4, name3) => cells4.has(name3) && cells4.get(name3)?.value !== "Themed" ? number(cells4, name3, 0) : 0;
26592
- function shapeBevel(cells4) {
26593
- const type = Math.trunc(saved(cells4, "BevelTopType"));
26594
- const width = Math.max(0, Math.min(2, saved(cells4, "BevelTopWidth")));
26595
- const height = Math.max(0, Math.min(2, saved(cells4, "BevelTopHeight")));
26596
- return type >= 1 && type <= 12 && (width > 0 || height > 0) ? { type, width, height } : void 0;
26597
- }
26598
- var hasUndrawnBevel = (cells4) => saved(cells4, "BevelBottomType") > 0 || saved(cells4, "BevelContourSize") > 0;
26647
+ var themedCell = (cells4, name3) => cells4.get(name3)?.value === "Themed";
26648
+ var saved = (cells4, name3) => cells4.has(name3) && !themedCell(cells4, name3) ? number(cells4, name3, 0) : 0;
26649
+ var clamp2 = (value3, high) => Math.max(0, Math.min(high, value3));
26650
+ function shapeBevel(cells4, themed) {
26651
+ const read = (name3, themeValue) => themedCell(cells4, name3) ? themeValue ?? 0 : saved(cells4, name3);
26652
+ const type = Math.trunc(read("BevelTopType", themed?.bevel?.type));
26653
+ const width = clamp2(read("BevelTopWidth", themed?.bevel?.width), 2);
26654
+ const height = clamp2(read("BevelTopHeight", themed?.bevel?.height), 2);
26655
+ return type >= 1 && type <= 12 ? { type, width, height } : void 0;
26656
+ }
26657
+ function shapeExtrusion(cells4, solid2, colorOf) {
26658
+ const depth = clamp2(saved(cells4, "BevelDepthSize"), 4);
26659
+ return solid2 && depth > 0 ? { depth, color: colorOf("BevelDepthColor", "#ffffff") } : void 0;
26660
+ }
26661
+ function shapeContour(cells4, solid2, themed, colorOf) {
26662
+ const size3 = clamp2(
26663
+ themedCell(cells4, "BevelContourSize") ? themed?.contour?.size ?? 0 : saved(cells4, "BevelContourSize"),
26664
+ 1
26665
+ );
26666
+ const color2 = themedCell(cells4, "BevelContourColor") ? themed?.contour?.color ?? colorOf("BevelContourColor", "#000000") : colorOf("BevelContourColor", "#000000");
26667
+ return solid2 && size3 > 0 ? { size: size3, color: color2 } : void 0;
26668
+ }
26669
+ var hasUndrawnBevel = (cells4) => saved(cells4, "BevelBottomType") > 0;
26599
26670
  function shapeRotation3d(cells4) {
26600
26671
  const angle = (name3) => Math.max(-Math.PI, Math.min(Math.PI, saved(cells4, name3)));
26601
26672
  const x = angle("RotationXAngle"), y = angle("RotationYAngle"), z = angle("RotationZAngle");
@@ -26616,6 +26687,52 @@ function visioRotation3dMatrix(rotation) {
26616
26687
  return [cc * ca + sc * sa * sb, sc * ca - cc * sa * sb, -sc * cb, cc * cb];
26617
26688
  }
26618
26689
 
26690
+ // visio/theme-solid.ts
26691
+ var PRESETS = [
26692
+ "circle",
26693
+ "relaxedInset",
26694
+ "cross",
26695
+ "coolSlant",
26696
+ "angle",
26697
+ "softRound",
26698
+ "convex",
26699
+ "slope",
26700
+ "divot",
26701
+ "riblet",
26702
+ "hardEdge",
26703
+ "artDeco"
26704
+ ];
26705
+ var EMU2 = 914400;
26706
+ var measure2 = (node3, name3, fallback) => {
26707
+ const raw2 = node3.getAttribute(name3);
26708
+ return raw2 !== null && /^\d{1,10}$/.test(raw2) ? Number(raw2) / EMU2 : fallback;
26709
+ };
26710
+ function themeSolid(cells4, resources, placeholder3) {
26711
+ const solid2 = themeChild(themeFormat(cells4, "Effects", resources), "sp3d");
26712
+ if (!solid2) return void 0;
26713
+ const result2 = {};
26714
+ const top = themeChild(solid2, "bevelT");
26715
+ if (top) {
26716
+ const type = PRESETS.indexOf(top.getAttribute("prst") ?? "circle") + 1;
26717
+ if (type > 0)
26718
+ result2.bevel = {
26719
+ type,
26720
+ width: measure2(top, "w", 76200 / EMU2),
26721
+ height: measure2(top, "h", 76200 / EMU2)
26722
+ };
26723
+ }
26724
+ const size3 = measure2(solid2, "contourW", 0);
26725
+ if (size3 > 0) {
26726
+ const paint3 = drawingPaint(
26727
+ colorChoice(themeChild(solid2, "contourClr")),
26728
+ /* @__PURE__ */ new Map(),
26729
+ placeholder3
26730
+ );
26731
+ result2.contour = { size: size3, ...paint3 ? { color: paint3.color } : {} };
26732
+ }
26733
+ return result2;
26734
+ }
26735
+
26619
26736
  // visio/text-background.ts
26620
26737
  function textBackground(cells4, resources, report) {
26621
26738
  const raw2 = cells4.get("TextBkgnd")?.value;
@@ -27642,9 +27759,9 @@ function roundedRectanglePath(points, rounding, point2) {
27642
27759
  const sweep = a2[0] * b[1] - a2[1] * b[0] > 0 ? 1 : 0;
27643
27760
  const start = after[0], commands = [`M ${point2(start[0], start[1])}`];
27644
27761
  for (let i = 1; i <= 4; i++) {
27645
- const entry3 = before[i % 4], exit2 = after[i % 4];
27762
+ const entry4 = before[i % 4], exit2 = after[i % 4];
27646
27763
  commands.push(
27647
- `L ${point2(entry3[0], entry3[1])}`,
27764
+ `L ${point2(entry4[0], entry4[1])}`,
27648
27765
  `A ${point2(radius, radius)} 0 0 ${sweep} ${point2(exit2[0], exit2[1])}`
27649
27766
  );
27650
27767
  }
@@ -27690,7 +27807,7 @@ function roundedOrthogonalPath(points, radius, point2) {
27690
27807
  const radius2 = radii[i];
27691
27808
  if (!Number.isFinite(radius2) || radius2 < 1e-9) return void 0;
27692
27809
  const incoming = directions[i - 1], outgoing = directions[i];
27693
- const entry3 = [
27810
+ const entry4 = [
27694
27811
  vertex[0] - incoming[0] * radius2,
27695
27812
  vertex[1] - incoming[1] * radius2
27696
27813
  ];
@@ -27698,11 +27815,11 @@ function roundedOrthogonalPath(points, radius, point2) {
27698
27815
  vertex[0] + outgoing[0] * radius2,
27699
27816
  vertex[1] + outgoing[1] * radius2
27700
27817
  ];
27701
- if (!entry3.every(Number.isFinite) || !exit2.every(Number.isFinite) || point2(...entry3) === point2(...vertex) || point2(...exit2) === point2(...vertex))
27818
+ if (!entry4.every(Number.isFinite) || !exit2.every(Number.isFinite) || point2(...entry4) === point2(...vertex) || point2(...exit2) === point2(...vertex))
27702
27819
  return void 0;
27703
27820
  const sweep = incoming[0] * outgoing[1] - incoming[1] * outgoing[0] > 0 ? 1 : 0;
27704
27821
  commands.push(
27705
- `L ${point2(...entry3)}`,
27822
+ `L ${point2(...entry4)}`,
27706
27823
  `A ${point2(radius2, radius2)} 0 0 ${sweep} ${point2(...exit2)}`
27707
27824
  );
27708
27825
  extraCommands++;
@@ -28009,8 +28126,8 @@ function color(cells4, name3, fallback, resources, report, themeCells = cells4,
28009
28126
  if (value3 === void 0) return fallback;
28010
28127
  if (/^#[0-9a-f]{6}$/i.test(value3)) return value3;
28011
28128
  if (/^\d+$/.test(value3)) {
28012
- const entry3 = resources.colors.get(value3) ?? PALETTE[Number(value3)];
28013
- if (entry3 && /^#[0-9a-f]{6}$/i.test(entry3)) return entry3;
28129
+ const entry4 = resources.colors.get(value3) ?? PALETTE[Number(value3)];
28130
+ if (entry4 && /^#[0-9a-f]{6}$/i.test(entry4)) return entry4;
28014
28131
  }
28015
28132
  if (value3 === "Themed") {
28016
28133
  const resolved = themeColor2(themeCells, name3, resources, report, gradientRendered);
@@ -28078,15 +28195,27 @@ function shapeStyle(sheet, resources, report, width = number(sheet.cells, "Width
28078
28195
  report,
28079
28196
  themedEffects
28080
28197
  );
28081
- const bevel = shapeBevel(cells4);
28198
+ const themedSolid = themeSolid(
28199
+ cells4,
28200
+ resources,
28201
+ color(cells4, "FillForegnd", "#ffffff", resources, () => {
28202
+ })
28203
+ );
28204
+ const bevel = shapeBevel(cells4, themedSolid);
28205
+ const solidColor2 = (name3, fallback) => color(cells4, name3, fallback, resources, report);
28206
+ const extrusion = shapeExtrusion(cells4, !!bevel, solidColor2);
28207
+ const contour = shapeContour(cells4, !!bevel, themedSolid, solidColor2);
28082
28208
  const rotation3d = shapeRotation3d(cells4);
28083
- if (bevel || rotation3d)
28209
+ if (bevel && (bevel.width > 0 || bevel.height > 0) || rotation3d || extrusion || contour)
28084
28210
  report(
28085
28211
  "approximated-3d",
28086
- "Bevel and 3-D rotation are approximated by a lighting overlay and a parallel projection; perspective and extrusion are not drawn."
28212
+ "Bevel, 3-D rotation, perspective, extrusion and contour are approximations: a lighting overlay, a projection and flat-shaded side faces, not Visio's renderer."
28087
28213
  );
28088
28214
  if (hasUndrawnBevel(cells4))
28089
- report("unsupported-bevel", "Bottom bevels and bevel contours are not drawn.");
28215
+ report(
28216
+ "unsupported-bevel",
28217
+ "Bottom bevels are not drawn (Visio 16 shows no change on the front of a shape)."
28218
+ );
28090
28219
  const themedBegin = themeArrow(cells4, resources, "Begin");
28091
28220
  const themedEnd = themeArrow(cells4, resources, "End");
28092
28221
  const cap = lineCap(cells4, resources, report);
@@ -28114,6 +28243,8 @@ function shapeStyle(sheet, resources, report, width = number(sheet.cells, "Width
28114
28243
  ...shadow ? { shadow } : {},
28115
28244
  ...effects,
28116
28245
  ...bevel ? { bevel } : {},
28246
+ ...extrusion ? { extrusion } : {},
28247
+ ...contour ? { contour } : {},
28117
28248
  ...rotation3d ? { rotation3d } : {}
28118
28249
  };
28119
28250
  }
@@ -28427,7 +28558,7 @@ var VISIO_BUILT_IN_THEMES = [
28427
28558
  )
28428
28559
  ];
28429
28560
  function visioBuiltInTheme(id4) {
28430
- return VISIO_BUILT_IN_THEMES.find((entry3) => entry3.id === id4);
28561
+ return VISIO_BUILT_IN_THEMES.find((entry4) => entry4.id === id4);
28431
28562
  }
28432
28563
  function visioThemeVariantColors(source, variant) {
28433
28564
  const accents = source.colors.slice(4, 10);
@@ -28451,7 +28582,7 @@ function visioPageTheme(themes, pageCells) {
28451
28582
  const light = drawingColor(theme2.colors.get("lt1"), theme2.colors);
28452
28583
  const dark = drawingColor(theme2.colors.get("dk1"), theme2.colors);
28453
28584
  const builtIn = VISIO_BUILT_IN_THEMES.find(
28454
- (entry3) => entry3.schemeId === id4 && entry3.name === theme2.name
28585
+ (entry4) => entry4.schemeId === id4 && entry4.name === theme2.name
28455
28586
  );
28456
28587
  return {
28457
28588
  name: theme2.name ?? `Theme ${id4}`,
@@ -28480,7 +28611,7 @@ function visioPageThemeSchemes(themes, pageCells) {
28480
28611
  if (!themes || id4 === void 0 || id4 === 0 || id4 >= 65534) continue;
28481
28612
  const matches2 = themes.filter((theme2) => theme2[field2] === id4);
28482
28613
  const builtIn = matches2.length === 1 ? VISIO_BUILT_IN_THEMES.find(
28483
- (entry3) => entry3.schemeId === id4 && entry3.name === matches2[0].name
28614
+ (entry4) => entry4.schemeId === id4 && entry4.name === matches2[0].name
28484
28615
  ) : void 0;
28485
28616
  if (builtIn) result2[key3] = builtIn.id;
28486
28617
  }
@@ -28816,7 +28947,7 @@ function optionsKey(options2) {
28816
28947
  const { metafileConverter: _converter, pages: _pages, documentCache: _cache, ...rest } = options2;
28817
28948
  return JSON.stringify(rest);
28818
28949
  }
28819
- var cacheMatches = (entry3, pkg, options2) => entry3 !== void 0 && entry3.options === optionsKey(options2) && entry3.converter === options2.metafileConverter && entry3.reads.every(([path3, print]) => pkg.printOf(path3) === print);
28950
+ var cacheMatches = (entry4, pkg, options2) => entry4 !== void 0 && entry4.options === optionsKey(options2) && entry4.converter === options2.metafileConverter && entry4.reads.every(([path3, print]) => pkg.printOf(path3) === print);
28820
28951
  async function readDocumentLevel(pkg, documentPart2, options2, checkTime, forward) {
28821
28952
  const reports = [];
28822
28953
  const report = (...args) => {
@@ -28896,8 +29027,8 @@ var VISIO_COMMENT_LIMIT = 1e4;
28896
29027
  var VISIO_COMMENT_TEXT_LIMIT = 16384;
28897
29028
  var VISIO_COMMENT_AUTHOR_LIMIT = 256;
28898
29029
  var unsigned = (value3) => value3 !== void 0 && /^(0|[1-9]\d{0,9})$/.test(value3) && Number(value3) <= 4294967295 ? value3 : void 0;
28899
- function visioCommentId(entry3, index3) {
28900
- return unsigned(attribute2(entry3, "CommentID")) ?? `n${index3}`;
29030
+ function visioCommentId(entry4, index3) {
29031
+ return unsigned(attribute2(entry4, "CommentID")) ?? `n${index3}`;
28901
29032
  }
28902
29033
  async function readVisioComments(pkg, documentPart2, report) {
28903
29034
  const path3 = await related(pkg, documentPart2, "comments", false);
@@ -28922,10 +29053,10 @@ async function readVisioComments(pkg, documentPart2, report) {
28922
29053
  const comments = [];
28923
29054
  const ids = /* @__PURE__ */ new Set();
28924
29055
  let characters = 0;
28925
- entries.slice(0, VISIO_COMMENT_LIMIT).forEach((entry3, index3) => {
28926
- const pageId2 = unsigned(attribute2(entry3, "PageID"));
28927
- const id4 = visioCommentId(entry3, index3);
28928
- const text7 = entry3.textContent ?? "";
29056
+ entries.slice(0, VISIO_COMMENT_LIMIT).forEach((entry4, index3) => {
29057
+ const pageId2 = unsigned(attribute2(entry4, "PageID"));
29058
+ const id4 = visioCommentId(entry4, index3);
29059
+ const text7 = entry4.textContent ?? "";
28929
29060
  characters += text7.length;
28930
29061
  if (pageId2 === void 0 || ids.has(id4) || characters > 1e6) {
28931
29062
  report(
@@ -28938,10 +29069,10 @@ async function readVisioComments(pkg, documentPart2, report) {
28938
29069
  return;
28939
29070
  }
28940
29071
  ids.add(id4);
28941
- const shapeId2 = unsigned(attribute2(entry3, "ShapeID"));
28942
- const author = authors.get(attribute2(entry3, "AuthorID") ?? "");
28943
- const date2 = attribute2(entry3, "Date");
28944
- const editDate = attribute2(entry3, "EditDate");
29072
+ const shapeId2 = unsigned(attribute2(entry4, "ShapeID"));
29073
+ const author = authors.get(attribute2(entry4, "AuthorID") ?? "");
29074
+ const date2 = attribute2(entry4, "Date");
29075
+ const editDate = attribute2(entry4, "EditDate");
28945
29076
  comments.push({
28946
29077
  id: id4,
28947
29078
  pageId: pageId2,
@@ -28951,7 +29082,7 @@ async function readVisioComments(pkg, documentPart2, report) {
28951
29082
  ...date2 ? { date: date2.slice(0, 64) } : {},
28952
29083
  ...editDate ? { editDate: editDate.slice(0, 64) } : {},
28953
29084
  text: text7.slice(0, VISIO_COMMENT_TEXT_LIMIT),
28954
- ...yes(attribute2(entry3, "Done")) ? { done: true } : {}
29085
+ ...yes(attribute2(entry4, "Done")) ? { done: true } : {}
28955
29086
  });
28956
29087
  });
28957
29088
  return comments;
@@ -31146,18 +31277,18 @@ function normalizePath(path3, rootName) {
31146
31277
  return parts;
31147
31278
  }
31148
31279
  function child3(entries, parentId, name3) {
31149
- const children5 = entries.filter((entry3) => entry3.parentId === parentId && entry3.path !== void 0);
31280
+ const children5 = entries.filter((entry4) => entry4.parentId === parentId && entry4.path !== void 0);
31150
31281
  const pick = (matches2) => matches2.length === 1 ? matches2[0] : void 0;
31151
- const exact = children5.filter((entry3) => entry3.name === name3);
31282
+ const exact = children5.filter((entry4) => entry4.name === name3);
31152
31283
  if (exact.length)
31153
31284
  return pick(exact);
31154
- const folded = children5.filter((entry3) => sameName(entry3.name, name3));
31285
+ const folded = children5.filter((entry4) => sameName(entry4.name, name3));
31155
31286
  if (folded.length)
31156
31287
  return pick(folded);
31157
- return pick(children5.filter((entry3) => sameName(bareName(entry3.name), bareName(name3))));
31288
+ return pick(children5.filter((entry4) => sameName(bareName(entry4.name), bareName(name3))));
31158
31289
  }
31159
31290
  function findDirectoryEntry(entries, path3) {
31160
- const root2 = entries.find((entry3) => entry3.type === ENTRY_TYPE_ROOT);
31291
+ const root2 = entries.find((entry4) => entry4.type === ENTRY_TYPE_ROOT);
31161
31292
  if (!root2)
31162
31293
  return void 0;
31163
31294
  let current = root2;
@@ -31171,11 +31302,11 @@ function findDirectoryEntry(entries, path3) {
31171
31302
  return current;
31172
31303
  }
31173
31304
  function findStreamByName(entries, name3, isReadable) {
31174
- const root2 = entries.find((entry3) => entry3.type === ENTRY_TYPE_ROOT);
31305
+ const root2 = entries.find((entry4) => entry4.type === ENTRY_TYPE_ROOT);
31175
31306
  if (root2 && root2.name === name3)
31176
31307
  return root2;
31177
- const top = entries.filter((entry3) => entry3.parentId === root2?.id && isReadable(entry3));
31178
- return top.find((entry3) => entry3.name === name3) ?? top.find((entry3) => sameName(entry3.name, name3)) ?? entries.find((entry3) => entry3.name === name3 && isReadable(entry3));
31308
+ const top = entries.filter((entry4) => entry4.parentId === root2?.id && isReadable(entry4));
31309
+ return top.find((entry4) => entry4.name === name3) ?? top.find((entry4) => sameName(entry4.name, name3)) ?? entries.find((entry4) => entry4.name === name3 && isReadable(entry4));
31179
31310
  }
31180
31311
 
31181
31312
  // ../../node_modules/.bun/@christophervr+ole2@0.14.0/node_modules/@christophervr/ole2/dist/ole2-parser-read.js
@@ -31330,8 +31461,8 @@ function parseOle2(buffer, options2 = {}) {
31330
31461
  throw new Ole2ParseError("Unexpected directory sector count");
31331
31462
  }
31332
31463
  const entries = readDirectory(directoryBytes, majorVersion, strict, warnings);
31333
- for (const entry3 of entries) {
31334
- if (majorVersion === 4 && (!Number.isSafeInteger(entry3.size) || entry3.size > sectorCount * sectorSize)) {
31464
+ for (const entry4 of entries) {
31465
+ if (majorVersion === 4 && (!Number.isSafeInteger(entry4.size) || entry4.size > sectorCount * sectorSize)) {
31335
31466
  throw new Ole2ParseError("Stream size exceeds supported file bounds");
31336
31467
  }
31337
31468
  }
@@ -31392,27 +31523,27 @@ function parseOle2(buffer, options2 = {}) {
31392
31523
  throw new Ole2ParseError("Truncated mini stream sector chain");
31393
31524
  return result2;
31394
31525
  }
31395
- function readEntry(entry3) {
31396
- if (entry3.size < miniStreamCutoff && entry3.type !== ENTRY_TYPE_ROOT) {
31397
- return readMiniStream(entry3.startSector, entry3.size);
31526
+ function readEntry(entry4) {
31527
+ if (entry4.size < miniStreamCutoff && entry4.type !== ENTRY_TYPE_ROOT) {
31528
+ return readMiniStream(entry4.startSector, entry4.size);
31398
31529
  }
31399
- return readStream(entry3.startSector, entry3.size);
31530
+ return readStream(entry4.startSector, entry4.size);
31400
31531
  }
31401
- const readable = (entry3) => entry3.type === ENTRY_TYPE_STREAM || entry3.type === ENTRY_TYPE_ROOT;
31532
+ const readable = (entry4) => entry4.type === ENTRY_TYPE_STREAM || entry4.type === ENTRY_TYPE_ROOT;
31402
31533
  return {
31403
31534
  entries,
31404
31535
  warnings,
31405
31536
  getStream(name3) {
31406
- const entry3 = findStreamByName(entries, name3, readable);
31407
- return entry3 ? readEntry(entry3) : void 0;
31537
+ const entry4 = findStreamByName(entries, name3, readable);
31538
+ return entry4 ? readEntry(entry4) : void 0;
31408
31539
  },
31409
31540
  getStreamByPath(path3) {
31410
- const entry3 = findDirectoryEntry(entries, path3);
31411
- return entry3 && entry3.type === ENTRY_TYPE_STREAM ? readEntry(entry3) : void 0;
31541
+ const entry4 = findDirectoryEntry(entries, path3);
31542
+ return entry4 && entry4.type === ENTRY_TYPE_STREAM ? readEntry(entry4) : void 0;
31412
31543
  },
31413
31544
  getStreamById(id4) {
31414
- const entry3 = entries.find((candidate) => candidate.id === id4);
31415
- return entry3 && readable(entry3) ? readEntry(entry3) : void 0;
31545
+ const entry4 = entries.find((candidate) => candidate.id === id4);
31546
+ return entry4 && readable(entry4) ? readEntry(entry4) : void 0;
31416
31547
  },
31417
31548
  findEntry(path3) {
31418
31549
  return findDirectoryEntry(entries, path3);
@@ -31422,12 +31553,12 @@ function parseOle2(buffer, options2 = {}) {
31422
31553
 
31423
31554
  // ../../node_modules/.bun/@christophervr+ole2@0.14.0/node_modules/@christophervr/ole2/dist/ole2-document-base.js
31424
31555
  var copyOf = (bytes) => bytes === void 0 ? void 0 : new Uint8Array(bytes);
31425
- var detachEntry = (entry3) => ({
31426
- ...entry3,
31427
- clsid: new Uint8Array(entry3.clsid),
31428
- path: entry3.path && [...entry3.path],
31429
- created: entry3.created && new Date(entry3.created),
31430
- modified: entry3.modified && new Date(entry3.modified)
31556
+ var detachEntry = (entry4) => ({
31557
+ ...entry4,
31558
+ clsid: new Uint8Array(entry4.clsid),
31559
+ path: entry4.path && [...entry4.path],
31560
+ created: entry4.created && new Date(entry4.created),
31561
+ modified: entry4.modified && new Date(entry4.modified)
31431
31562
  });
31432
31563
  var Ole2DocumentError = class extends Error {
31433
31564
  code;
@@ -31470,8 +31601,8 @@ var Ole2DocumentBase = class {
31470
31601
  #getStreamByPath = (path3) => copyOf(this.#container.getStreamByPath(path3));
31471
31602
  #getStreamById = (id4) => copyOf(this.#container.getStreamById(id4));
31472
31603
  #findEntry = (path3) => {
31473
- const entry3 = this.#container.findEntry(path3);
31474
- return entry3 && detachEntry(entry3);
31604
+ const entry4 = this.#container.findEntry(path3);
31605
+ return entry4 && detachEntry(entry4);
31475
31606
  };
31476
31607
  /** Retain the original detachable callback API while observing current state. */
31477
31608
  get getStream() {
@@ -31752,12 +31883,12 @@ function processCompoundFileStream(input, path3, replacement) {
31752
31883
  const reserved = /* @__PURE__ */ new Set([...fatIds, ...difatIds, ...dirSectors, ...miniFatSectors]);
31753
31884
  const regularUsed = new Set(reserved);
31754
31885
  const rootMini = entries.find((e) => e.type === 5);
31755
- for (const entry3 of entries) {
31756
- if (entry3.type !== 2 && entry3.type !== 5 || entry3.size === 0)
31886
+ for (const entry4 of entries) {
31887
+ if (entry4.type !== 2 && entry4.type !== 5 || entry4.size === 0)
31757
31888
  continue;
31758
- if (entry3.type === 2 && entry3.size < miniCutoff)
31889
+ if (entry4.type === 2 && entry4.size < miniCutoff)
31759
31890
  continue;
31760
- for (const id4 of exactChain(fat, entry3.start, entry3.size, sectorSize)) {
31891
+ for (const id4 of exactChain(fat, entry4.start, entry4.size, sectorSize)) {
31761
31892
  sector(id4);
31762
31893
  if (regularUsed.has(id4))
31763
31894
  return reject2();
@@ -31765,10 +31896,10 @@ function processCompoundFileStream(input, path3, replacement) {
31765
31896
  }
31766
31897
  }
31767
31898
  const miniUsed = /* @__PURE__ */ new Set();
31768
- for (const entry3 of entries) {
31769
- if (entry3.type !== 2 || entry3.size === 0 || entry3.size >= miniCutoff)
31899
+ for (const entry4 of entries) {
31900
+ if (entry4.type !== 2 || entry4.size === 0 || entry4.size >= miniCutoff)
31770
31901
  continue;
31771
- const ids = exactChain(miniFat, entry3.start, entry3.size, miniSize);
31902
+ const ids = exactChain(miniFat, entry4.start, entry4.size, miniSize);
31772
31903
  for (const id4 of ids) {
31773
31904
  if ((id4 + 1) * miniSize > rootMini.size || miniUsed.has(id4))
31774
31905
  return reject2();
@@ -31964,8 +32095,8 @@ function resizeCompoundFileStreamV4(input, path3, replacement) {
31964
32095
  if (read(40) !== directoryChain.length)
31965
32096
  return fail4("unsafe-edit");
31966
32097
  for (const [block, sector] of directoryChain.entries()) {
31967
- for (let entry3 = 0; entry3 < DIRECTORY_ENTRIES; entry3++) {
31968
- const offset = (sector + 1) * SECTOR3 + entry3 * 128, type = view2.getUint8(offset + 66);
32098
+ for (let entry4 = 0; entry4 < DIRECTORY_ENTRIES; entry4++) {
32099
+ const offset = (sector + 1) * SECTOR3 + entry4 * 128, type = view2.getUint8(offset + 66);
31969
32100
  if (!type)
31970
32101
  continue;
31971
32102
  const nameLength = view2.getUint16(offset + 64, true);
@@ -31976,7 +32107,7 @@ function resizeCompoundFileStreamV4(input, path3, replacement) {
31976
32107
  name4 += String.fromCharCode(view2.getUint16(offset + i, true));
31977
32108
  if (read(offset + 124) !== 0)
31978
32109
  return fail4("unsafe-edit");
31979
- const id4 = block * DIRECTORY_ENTRIES + entry3;
32110
+ const id4 = block * DIRECTORY_ENTRIES + entry4;
31980
32111
  slots.set(id4, { id: id4, name: name4, type, left: read(offset + 68), right: read(offset + 72), child: read(offset + 76), start: read(offset + 116), size: read(offset + 120), offset });
31981
32112
  }
31982
32113
  }
@@ -32266,8 +32397,8 @@ function resizeCompoundFileStream(input, path3, replacement) {
32266
32397
  return fail4("unsafe-edit");
32267
32398
  const slots = /* @__PURE__ */ new Map();
32268
32399
  for (const [block, sector] of follow2(fat, read(48)).entries()) {
32269
- for (let entry3 = 0; entry3 < 4; entry3++) {
32270
- const offset = (sector + 1) * SECTOR2 + entry3 * 128, type = view2.getUint8(offset + 66);
32400
+ for (let entry4 = 0; entry4 < 4; entry4++) {
32401
+ const offset = (sector + 1) * SECTOR2 + entry4 * 128, type = view2.getUint8(offset + 66);
32271
32402
  if (!type)
32272
32403
  continue;
32273
32404
  const nameLength = view2.getUint16(offset + 64, true);
@@ -32276,7 +32407,7 @@ function resizeCompoundFileStream(input, path3, replacement) {
32276
32407
  let name4 = "";
32277
32408
  for (let i = 0; i < nameLength - 2; i += 2)
32278
32409
  name4 += String.fromCharCode(view2.getUint16(offset + i, true));
32279
- const id4 = block * 4 + entry3;
32410
+ const id4 = block * 4 + entry4;
32280
32411
  slots.set(id4, { id: id4, name: name4, type, left: read(offset + 68), right: read(offset + 72), child: read(offset + 76), start: read(offset + 116), size: read(offset + 120), offset });
32281
32412
  }
32282
32413
  }
@@ -32435,15 +32566,15 @@ function serializeDirectoryEntries(dirEntries, numDirSectors, sectorSize) {
32435
32566
  const dirView = new DataView(dirData.buffer);
32436
32567
  const tree = buildDirectoryTree(dirEntries.length);
32437
32568
  for (let i = 0; i < dirEntries.length; i++) {
32438
- const entry3 = dirEntries[i];
32569
+ const entry4 = dirEntries[i];
32439
32570
  const entryOffset = i * DIR_ENTRY_SIZE;
32440
- const nameBytes = encodeName(entry3.name);
32571
+ const nameBytes = encodeName(entry4.name);
32441
32572
  dirData.set(nameBytes.subarray(0, Math.min(nameBytes.length, 64)), entryOffset);
32442
- dirView.setUint16(entryOffset + 64, Math.min((entry3.name.length + 1) * 2, 64), true);
32443
- dirData[entryOffset + 66] = entry3.type;
32573
+ dirView.setUint16(entryOffset + 64, Math.min((entry4.name.length + 1) * 2, 64), true);
32574
+ dirData[entryOffset + 66] = entry4.type;
32444
32575
  dirData[entryOffset + 67] = i === 0 ? 1 : tree.links.get(i).color;
32445
- if (entry3.clsid) {
32446
- dirData.set(entry3.clsid.subarray(0, 16), entryOffset + 80);
32576
+ if (entry4.clsid) {
32577
+ dirData.set(entry4.clsid.subarray(0, 16), entryOffset + 80);
32447
32578
  }
32448
32579
  if (i === 0) {
32449
32580
  dirView.setUint32(entryOffset + 68, 4294967295, true);
@@ -32454,8 +32585,8 @@ function serializeDirectoryEntries(dirEntries, numDirSectors, sectorSize) {
32454
32585
  dirView.setUint32(entryOffset + 72, tree.links.get(i).right, true);
32455
32586
  dirView.setUint32(entryOffset + 76, 4294967295, true);
32456
32587
  }
32457
- dirView.setUint32(entryOffset + 116, entry3.startSector, true);
32458
- dirView.setUint32(entryOffset + 120, entry3.size, true);
32588
+ dirView.setUint32(entryOffset + 116, entry4.startSector, true);
32589
+ dirView.setUint32(entryOffset + 120, entry4.size, true);
32459
32590
  }
32460
32591
  return dirData;
32461
32592
  }
@@ -32692,29 +32823,29 @@ function buildCompoundFile(nodes, options2 = {}) {
32692
32823
  return out;
32693
32824
  }
32694
32825
  function collect(file, dropUnreadable) {
32695
- const root2 = file.entries.find((entry3) => entry3.type === ENTRY_TYPE_ROOT);
32826
+ const root2 = file.entries.find((entry4) => entry4.type === ENTRY_TYPE_ROOT);
32696
32827
  const nodes = [];
32697
32828
  const dropped = [];
32698
- for (const entry3 of file.entries) {
32699
- if (!entry3.path?.length || entry3.type !== ENTRY_TYPE_STORAGE && entry3.type !== ENTRY_TYPE_STREAM)
32829
+ for (const entry4 of file.entries) {
32830
+ if (!entry4.path?.length || entry4.type !== ENTRY_TYPE_STORAGE && entry4.type !== ENTRY_TYPE_STREAM)
32700
32831
  continue;
32701
32832
  let data;
32702
- if (entry3.type === ENTRY_TYPE_STREAM) {
32833
+ if (entry4.type === ENTRY_TYPE_STREAM) {
32703
32834
  try {
32704
- data = file.getStreamById(entry3.id);
32835
+ data = file.getStreamById(entry4.id);
32705
32836
  } catch (error) {
32706
32837
  throw error;
32707
32838
  }
32708
32839
  }
32709
32840
  nodes.push({
32710
- path: [...entry3.path],
32841
+ path: [...entry4.path],
32711
32842
  data,
32712
- stateBits: entry3.stateBits,
32713
- created: entry3.created,
32714
- modified: entry3.modified,
32715
- createdFileTime: entry3.createdFileTime,
32716
- modifiedFileTime: entry3.modifiedFileTime,
32717
- clsid: entry3.clsid.some((byte) => byte !== 0) ? entry3.clsid : void 0
32843
+ stateBits: entry4.stateBits,
32844
+ created: entry4.created,
32845
+ modified: entry4.modified,
32846
+ createdFileTime: entry4.createdFileTime,
32847
+ modifiedFileTime: entry4.modifiedFileTime,
32848
+ clsid: entry4.clsid.some((byte) => byte !== 0) ? entry4.clsid : void 0
32718
32849
  });
32719
32850
  }
32720
32851
  const options2 = { rootClsid: root2.clsid, rootStateBits: root2.stateBits, rootModified: root2.modified, rootModifiedFileTime: root2.modifiedFileTime };
@@ -32868,7 +32999,7 @@ var CfbDocument = class extends Ole2DocumentBase {
32868
32999
  ...access,
32869
33000
  children: () => {
32870
33001
  const parent = this.#entry(reference2);
32871
- return Object.freeze(this.entries.filter((entry3) => entry3.parentId === parent.id).map((entry3) => this.#handle(entry3.path)));
33002
+ return Object.freeze(this.entries.filter((entry4) => entry4.parentId === parent.id).map((entry4) => this.#handle(entry4.path)));
32872
33003
  },
32873
33004
  storage: (name3) => this.storage(childPath(name3)),
32874
33005
  stream: (name3) => this.stream(childPath(name3)),
@@ -32975,21 +33106,21 @@ var CfbDocument = class extends Ole2DocumentBase {
32975
33106
  return this.findEntry(path3) ?? fail2("entry-not-found");
32976
33107
  }
32977
33108
  #requireStorage(path3) {
32978
- const entry3 = this.#requireEntry(path3);
32979
- if (entry3.type !== 1 && entry3.type !== 5)
33109
+ const entry4 = this.#requireEntry(path3);
33110
+ if (entry4.type !== 1 && entry4.type !== 5)
32980
33111
  fail2("not-a-storage");
32981
- return entry3;
33112
+ return entry4;
32982
33113
  }
32983
33114
  #reference(path3, kind) {
32984
33115
  if (!Array.isArray(path3) || path3.some((name3) => typeof name3 !== "string"))
32985
33116
  fail2("invalid-entry-path");
32986
- const entry3 = this.findEntry(path3) ?? fail2(`${kind}-not-found`);
32987
- if (kind === "stream" ? entry3.type !== 2 : entry3.type !== 1 && entry3.type !== 5)
33117
+ const entry4 = this.findEntry(path3) ?? fail2(`${kind}-not-found`);
33118
+ if (kind === "stream" ? entry4.type !== 2 : entry4.type !== 1 && entry4.type !== 5)
32988
33119
  fail2(`not-a-${kind}`);
32989
- const id4 = key2(entry3.path);
33120
+ const id4 = key2(entry4.path);
32990
33121
  let reference2 = this.#references.get(id4);
32991
33122
  if (!reference2) {
32992
- reference2 = { path: Object.freeze([...entry3.path]), live: true };
33123
+ reference2 = { path: Object.freeze([...entry4.path]), live: true };
32993
33124
  this.#references.set(id4, reference2);
32994
33125
  }
32995
33126
  return reference2;
@@ -34853,7 +34984,7 @@ function unwrapXlsBytes(bytes) {
34853
34984
  if (rootWorkbooks.length !== 1)
34854
34985
  return { workbookBytes: bytes };
34855
34986
  const rootWorkbook = rootWorkbooks[0];
34856
- const streamEntry = rootWorkbook ? workbookEntries.find((entry3) => entry3.name.toLowerCase() === rootWorkbook.name) : void 0;
34987
+ const streamEntry = rootWorkbook ? workbookEntries.find((entry4) => entry4.name.toLowerCase() === rootWorkbook.name) : void 0;
34857
34988
  const workbookBytes = rootWorkbook?.data;
34858
34989
  if (!rootWorkbook || !streamEntry || !workbookBytes) {
34859
34990
  return { workbookBytes: bytes };
@@ -34872,13 +35003,13 @@ function unwrapXlsBytes(bytes) {
34872
35003
  if (!canRebuild)
34873
35004
  return originalBytes;
34874
35005
  const streams = /* @__PURE__ */ new Map();
34875
- for (const entry3 of ole.entries) {
34876
- if (entry3.type !== ENTRY_TYPE_STREAM) {
35006
+ for (const entry4 of ole.entries) {
35007
+ if (entry4.type !== ENTRY_TYPE_STREAM) {
34877
35008
  continue;
34878
35009
  }
34879
- const data = entry3.name.toLowerCase() === streamEntry.name.toLowerCase() ? editedWorkbookBytes : ole.getStream(entry3.name);
35010
+ const data = entry4.name.toLowerCase() === streamEntry.name.toLowerCase() ? editedWorkbookBytes : ole.getStream(entry4.name);
34880
35011
  if (data) {
34881
- streams.set(entry3.name, data);
35012
+ streams.set(entry4.name, data);
34882
35013
  }
34883
35014
  }
34884
35015
  return new Uint8Array(buildOle2(streams, rootClsid));
@@ -34889,11 +35020,11 @@ function unwrapXlsBytes(bytes) {
34889
35020
  }
34890
35021
  }
34891
35022
  function hasFlatUniqueStreamLayout(entries, workbookCount) {
34892
- const rootEntries = entries.filter((entry3) => entry3.type === ENTRY_TYPE_ROOT);
34893
- const streamEntries = entries.filter((entry3) => entry3.type === ENTRY_TYPE_STREAM);
35023
+ const rootEntries = entries.filter((entry4) => entry4.type === ENTRY_TYPE_ROOT);
35024
+ const streamEntries = entries.filter((entry4) => entry4.type === ENTRY_TYPE_STREAM);
34894
35025
  if (rootEntries.length !== 1 || workbookCount !== 1 || entries.length !== rootEntries.length + streamEntries.length)
34895
35026
  return false;
34896
- const names = streamEntries.map((entry3) => entry3.name.toLowerCase());
35027
+ const names = streamEntries.map((entry4) => entry4.name.toLowerCase());
34897
35028
  return new Set(names).size === names.length;
34898
35029
  }
34899
35030
  function equalBytes(left, right2) {
@@ -34905,8 +35036,8 @@ function isCfb(bytes) {
34905
35036
 
34906
35037
  // ../../node_modules/.bun/@christophervr+ole2@0.14.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-functions.js
34907
35038
  var TABLE2 = `0 COUNT -1|1 IF -1|2 ISNA 1|3 ISERROR 1|4 SUM -1|5 AVERAGE -1|6 MIN -1|7 MAX -1|8 ROW -1|9 COLUMN -1|10 NA 0|11 NPV -1|12 STDEV -1|13 DOLLAR -1|14 FIXED -1|15 SIN 1|16 COS 1|17 TAN 1|18 ATAN 1|19 PI 0|20 SQRT 1|21 EXP 1|22 LN 1|23 LOG10 1|24 ABS 1|25 INT 1|26 SIGN 1|27 ROUND 2|28 LOOKUP -1|29 INDEX -1|30 REPT 2|31 MID 3|32 LEN 1|33 VALUE 1|34 TRUE 0|35 FALSE 0|36 AND -1|37 OR -1|38 NOT 1|39 MOD 2|40 DCOUNT 3|41 DSUM 3|42 DAVERAGE 3|43 DMIN 3|44 DMAX 3|45 DSTDEV 3|46 VAR -1|47 DVAR 3|48 TEXT 2|49 LINEST -1|50 TREND -1|51 LOGEST -1|52 GROWTH -1|56 PV -1|57 FV -1|58 NPER -1|59 PMT -1|60 RATE -1|61 MIRR 3|62 IRR -1|63 RAND 0|64 MATCH -1|65 DATE 3|66 TIME 3|67 DAY 1|68 MONTH 1|69 YEAR 1|70 WEEKDAY -1|71 HOUR 1|72 MINUTE 1|73 SECOND 1|74 NOW 0|75 AREAS 1|76 ROWS 1|77 COLUMNS 1|78 OFFSET -1|82 SEARCH -1|83 TRANSPOSE 1|86 TYPE 1|97 ATAN2 2|98 ASIN 1|99 ACOS 1|100 CHOOSE -1|101 HLOOKUP -1|102 VLOOKUP -1|105 ISREF 1|109 LOG -1|111 CHAR 1|112 LOWER 1|113 UPPER 1|114 PROPER 1|115 LEFT -1|116 RIGHT -1|117 EXACT 2|118 TRIM 1|119 REPLACE 4|120 SUBSTITUTE -1|121 CODE 1|124 FIND -1|125 CELL -1|126 ISERR 1|127 ISTEXT 1|128 ISNUMBER 1|129 ISBLANK 1|130 T 1|131 N 1|140 DATEVALUE 1|141 TIMEVALUE 1|142 SLN 3|143 SYD 4|144 DDB -1|148 INDIRECT -1|150 CALL -1|162 CLEAN 1|163 MDETERM 1|164 MINVERSE 1|165 MMULT 2|167 IPMT -1|168 PPMT -1|169 COUNTA -1|183 PRODUCT -1|184 FACT 1|189 DPRODUCT 3|190 ISNONTEXT 1|193 STDEVP -1|194 VARP -1|195 DSTDEVP 3|196 DVARP 3|197 TRUNC -1|198 ISLOGICAL 1|199 DCOUNTA 3|204 USDOLLAR -1|205 FINDB -1|206 SEARCHB -1|207 REPLACEB 4|208 LEFTB -1|209 RIGHTB -1|210 MIDB 3|211 LENB 1|212 ROUNDUP 2|213 ROUNDDOWN 2|214 ASC 1|215 DBCS 1|216 RANK -1|219 ADDRESS -1|220 DAYS360 -1|221 TODAY 0|222 VDB -1|227 MEDIAN -1|228 SUMPRODUCT -1|229 SINH 1|230 COSH 1|231 TANH 1|232 ASINH 1|233 ACOSH 1|234 ATANH 1|235 DGET 3|244 INFO 1|247 DB -1|252 FREQUENCY 2|261 ERROR.TYPE 1|269 AVEDEV -1|270 BETADIST -1|271 GAMMALN 1|272 BETAINV -1|273 BINOMDIST 4|274 CHIDIST 2|275 CHIINV 2|276 COMBIN 2|277 CONFIDENCE 3|278 CRITBINOM 3|279 EVEN 1|280 EXPONDIST 3|281 FDIST 3|282 FINV 3|283 FISHER 1|284 FISHERINV 1|285 FLOOR 2|286 GAMMADIST 4|287 GAMMAINV 3|288 CEILING 2|289 HYPGEOMDIST 4|290 LOGNORMDIST 3|291 LOGINV 3|292 NEGBINOMDIST 3|293 NORMDIST 4|294 NORMSDIST 1|295 NORMINV 3|296 NORMSINV 1|297 STANDARDIZE 3|298 ODD 1|299 PERMUT 2|300 POISSON 3|301 TDIST 3|302 WEIBULL 4|303 SUMXMY2 2|304 SUMX2MY2 2|305 SUMX2PY2 2|306 CHITEST 2|307 CORREL 2|308 COVAR 2|309 FORECAST 3|310 FTEST 2|311 INTERCEPT 2|312 PEARSON 2|313 RSQ 2|314 STEYX 2|315 SLOPE 2|316 TTEST 4|317 PROB -1|318 DEVSQ -1|319 GEOMEAN -1|320 HARMEAN -1|321 SUMSQ -1|322 KURT -1|323 SKEW -1|324 ZTEST -1|325 LARGE 2|326 SMALL 2|327 QUARTILE 2|328 PERCENTILE 2|329 PERCENTRANK -1|330 MODE -1|331 TRIMMEAN 2|332 TINV 2|336 CONCATENATE -1|337 POWER 2|342 RADIANS 1|343 DEGREES 1|344 SUBTOTAL -1|345 SUMIF -1|346 COUNTIF 2|347 COUNTBLANK 1|350 ISPMT 4|351 DATEDIF 3|352 DATESTRING 1|353 NUMBERSTRING 2|354 ROMAN -1|358 GETPIVOTDATA -1|359 HYPERLINK -1|360 PHONETIC 1|361 AVERAGEA -1|362 MAXA -1|363 MINA -1|364 STDEVPA -1|365 VARPA -1|366 STDEVA -1|367 VARA -1|368 BAHTTEXT 1`;
34908
- var XLS_FUNCTIONS = new Map(TABLE2.split("|").map((entry3) => {
34909
- const [id4, name3, argc] = entry3.split(" ");
35039
+ var XLS_FUNCTIONS = new Map(TABLE2.split("|").map((entry4) => {
35040
+ const [id4, name3, argc] = entry4.split(" ");
34910
35041
  return [Number(id4), { name: name3 ?? "", argc: Number(argc) }];
34911
35042
  }));
34912
35043
  var XLS_USER_FUNCTION_ID = 255;
@@ -35461,8 +35592,8 @@ var XLS_BUILTIN_FORMATS = {
35461
35592
  49: "@"
35462
35593
  };
35463
35594
  function paletteColor(index3, palette) {
35464
- const rgb6 = index3 < 64 ? palette[index3] : void 0;
35465
- return rgb6 ? { index: index3, rgb: rgb6 } : { index: index3, auto: true };
35595
+ const rgb7 = index3 < 64 ? palette[index3] : void 0;
35596
+ return rgb7 ? { index: index3, rgb: rgb7 } : { index: index3, auto: true };
35466
35597
  }
35467
35598
  var UNDERLINE = {
35468
35599
  1: "single",
@@ -35507,9 +35638,9 @@ function parsePalette(data) {
35507
35638
  const count = r.u16();
35508
35639
  const palette = [...DEFAULT_XLS_PALETTE];
35509
35640
  for (let i = 0; i < count && i + 8 < 64; i++) {
35510
- const rgb6 = [r.u8(), r.u8(), r.u8()];
35641
+ const rgb7 = [r.u8(), r.u8(), r.u8()];
35511
35642
  r.skip(1);
35512
- palette[i + 8] = rgb6.map((c2) => c2.toString(16).padStart(2, "0").toUpperCase()).join("");
35643
+ palette[i + 8] = rgb7.map((c2) => c2.toString(16).padStart(2, "0").toUpperCase()).join("");
35513
35644
  }
35514
35645
  return palette;
35515
35646
  }
@@ -35626,9 +35757,9 @@ function fullColor(r, palette) {
35626
35757
  if (type === 1)
35627
35758
  return withTint(paletteColor(value3, palette));
35628
35759
  if (type === 2) {
35629
- const rgb6 = [value3 & 255, value3 >>> 8 & 255, value3 >>> 16 & 255];
35760
+ const rgb7 = [value3 & 255, value3 >>> 8 & 255, value3 >>> 16 & 255];
35630
35761
  return withTint({
35631
- rgb: rgb6.map((c2) => c2.toString(16).padStart(2, "0").toUpperCase()).join("")
35762
+ rgb: rgb7.map((c2) => c2.toString(16).padStart(2, "0").toUpperCase()).join("")
35632
35763
  });
35633
35764
  }
35634
35765
  if (type === 3)
@@ -37342,7 +37473,7 @@ function compoundStreamNames(bytes) {
37342
37473
  return [];
37343
37474
  try {
37344
37475
  const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
37345
- return parseOle2(buffer).entries.map((entry3) => entry3.name);
37476
+ return parseOle2(buffer).entries.map((entry4) => entry4.name);
37346
37477
  } catch {
37347
37478
  throw new XlsReadError("corrupt", "The file is not a readable OLE2 compound file.");
37348
37479
  }
@@ -37538,8 +37669,8 @@ function extSst(entries, map) {
37538
37669
  view2.setUint16(2, out.length - 4, true);
37539
37670
  view2.setUint16(4, interval, true);
37540
37671
  for (let i = 0; i < count; i++) {
37541
- const entry3 = entries[i * interval];
37542
- const offset = map(entry3.offset), base2 = map(entry3.recordOffset);
37672
+ const entry4 = entries[i * interval];
37673
+ const offset = map(entry4.offset), base2 = map(entry4.recordOffset);
37543
37674
  if (offset < base2 || offset - base2 > 65535)
37544
37675
  reject("malformed-records");
37545
37676
  view2.setUint32(6 + i * 8, offset, true);
@@ -37583,8 +37714,8 @@ function editXlsStringWorkbookStream(input, edit) {
37583
37714
  if (interval !== Math.max(Math.floor(sst.entries.length / 128) + 1, 8) || ext.length !== 2 + Math.ceil(sst.entries.length / interval) * 8)
37584
37715
  reject("malformed-records");
37585
37716
  for (let i = 0; i < (ext.length - 2) / 8; i++) {
37586
- const entry3 = sst.entries[i * interval];
37587
- if (sourceView.getUint32(ext.dataOffset + 2 + i * 8, true) !== entry3.offset || sourceView.getUint16(ext.dataOffset + 6 + i * 8, true) !== entry3.offset - entry3.recordOffset)
37717
+ const entry4 = sst.entries[i * interval];
37718
+ if (sourceView.getUint32(ext.dataOffset + 2 + i * 8, true) !== entry4.offset || sourceView.getUint16(ext.dataOffset + 6 + i * 8, true) !== entry4.offset - entry4.recordOffset)
37588
37719
  reject("malformed-records");
37589
37720
  }
37590
37721
  if (ext.headerOffset >= m.globalsEnd || ext.depth !== 1 || ext.length < 2 || (ext.length - 2) % 8 !== 0 || m.records[m.records.indexOf(ext) + 1]?.opcode === 60)
@@ -38127,11 +38258,11 @@ function snapshot(value3) {
38127
38258
  if (!item2 || typeof item2 !== "object")
38128
38259
  return;
38129
38260
  if (item2 instanceof Map)
38130
- for (const entry3 of item2.values())
38131
- freeze(entry3);
38261
+ for (const entry4 of item2.values())
38262
+ freeze(entry4);
38132
38263
  else
38133
- for (const entry3 of Object.values(item2))
38134
- freeze(entry3);
38264
+ for (const entry4 of Object.values(item2))
38265
+ freeze(entry4);
38135
38266
  Object.freeze(item2);
38136
38267
  };
38137
38268
  freeze(copy9);
@@ -41865,13 +41996,17 @@ function effectiveNumber(cells4, name3, fallback) {
41865
41996
  fail("UNSUPPORTED_GEOMETRY_EDIT", `${name3} of the stencil shape is out of range.`);
41866
41997
  return value3;
41867
41998
  }
41868
- var sectionRows2 = (shape, name3) => children2(shape, "Section").filter((section3) => attribute2(section3, "N") === name3 && !deleted(section3)).flatMap((section3) => children2(section3, "Row"));
41999
+ var sectionRows2 = (shape, name3) => children2(shape, "Section").filter((section3) => attribute2(section3, "N") === name3 && !deleted(section3)).flatMap(
42000
+ (section3) => children2(section3, "Row").map((row2, position) => ({
42001
+ row: row2,
42002
+ index: attribute2(row2, "IX") === void 0 ? position : Number(attribute2(row2, "IX"))
42003
+ }))
42004
+ );
41869
42005
  function effectiveRows(shape, section3) {
41870
42006
  const rows = /* @__PURE__ */ new Map();
41871
42007
  const gone = /* @__PURE__ */ new Set();
41872
42008
  for (const source of [templates.get(shape), shape])
41873
- for (const row2 of sectionRows2(source, section3)) {
41874
- const index3 = Number(attribute2(row2, "IX") ?? "0");
42009
+ for (const { row: row2, index: index3 } of sectionRows2(source, section3)) {
41875
42010
  if (deleted(row2)) {
41876
42011
  gone.add(index3);
41877
42012
  continue;
@@ -42363,7 +42498,7 @@ var PASSIVE = /* @__PURE__ */ new Set([
42363
42498
  "Reviewer",
42364
42499
  "Annotation"
42365
42500
  ]);
42366
- var LENGTHS = /^(width|height|pinx|piny|locpinx|locpiny|txtpinx|txtpiny|txtwidth|txtheight|txtlocpinx|txtlocpiny|beginx|beginy|endx|endy)$/;
42501
+ var LENGTHS = /^(width|height|pinx|piny|locpinx|locpiny|txtpinx|txtpiny|txtwidth|txtheight|txtlocpinx|txtlocpiny|beginx|beginy|endx|endy|lineweight|imgoffsetx|imgoffsety|imgwidth|imgheight)$/;
42367
42502
  function expectedUnit(cell) {
42368
42503
  const unit4 = attribute2(cell.local, "U") ?? attribute2(cell.inherited, "U");
42369
42504
  if (unit4 === void 0 && cell.section && PASSIVE.has(cell.section.name)) return void 0;
@@ -42381,7 +42516,12 @@ function expectedUnit(cell) {
42381
42516
  return "length";
42382
42517
  return !cell.relative && /^(geometry\d+|connections|controls)\.[xy]\d+$/.test(name3) ? "length" : "scalar";
42383
42518
  }
42384
- function recalculateInstanceCaches(target2, changed, check, pins = /* @__PURE__ */ new Map(), text7) {
42519
+ function untaggedLength(cell) {
42520
+ if (cell.section?.name !== "User") return void 0;
42521
+ const formula2 = effectiveFormula(cell);
42522
+ return formula2 && /^\s*[\d.]+\s*(?:MM|CM|IN|FT|M)/i.test(formula2) ? "length" : void 0;
42523
+ }
42524
+ function recalculateInstanceCaches(target2, changed, check, pins = /* @__PURE__ */ new Map(), text7, keepTextSize = false) {
42385
42525
  const scope = "sheets" in target2 ? target2 : singleScope(target2);
42386
42526
  const overrides = new Map(changed);
42387
42527
  const pinned = /* @__PURE__ */ new Map();
@@ -42403,11 +42543,11 @@ function recalculateInstanceCaches(target2, changed, check, pins = /* @__PURE__
42403
42543
  try {
42404
42544
  const ast = parseVisioFormula(source);
42405
42545
  const analysis = analyzeVisioFormula(ast);
42406
- const sized = text7 && analysis.dynamic ? textSizeFormula(ast) : void 0;
42546
+ const sized = analysis.dynamic && (text7 || keepTextSize) ? textSizeFormula(ast) : void 0;
42407
42547
  result2 = sized ? {
42408
42548
  ast,
42409
42549
  local,
42410
- text: true,
42550
+ ...text7 ? { text: true } : { deferText: true },
42411
42551
  references: sized.references.flatMap((ref) => found(ref.cell, ref.shapeId))
42412
42552
  } : analysis.dynamic ? { local, references: mentioned() } : {
42413
42553
  ast,
@@ -42453,22 +42593,42 @@ function recalculateInstanceCaches(target2, changed, check, pins = /* @__PURE__
42453
42593
  if (!node3 || node3.hasAttribute("E")) throw new Unevaluable();
42454
42594
  try {
42455
42595
  const value3 = visioFormulaCachedValue(attribute2(node3, "V") ?? "", attribute2(node3, "U"));
42456
- const unit4 = expectedUnit(cell);
42596
+ const unit4 = expectedUnit(cell) ?? untaggedLength(cell);
42457
42597
  return value3.unit === "scalar" && unit4 && unit4 !== "scalar" ? { ...value3, unit: unit4 } : value3;
42458
42598
  } catch {
42459
42599
  throw new Unevaluable();
42460
42600
  }
42461
42601
  };
42602
+ const tainted = /* @__PURE__ */ new Set();
42603
+ let sawDeferred = false;
42462
42604
  const evaluate = (cell) => {
42605
+ const outer = sawDeferred;
42606
+ sawDeferred = false;
42607
+ try {
42608
+ const result2 = evaluateCell(cell);
42609
+ if (sawDeferred) tainted.add(cell);
42610
+ return result2;
42611
+ } finally {
42612
+ sawDeferred = sawDeferred || outer;
42613
+ }
42614
+ };
42615
+ const evaluateCell = (cell) => {
42463
42616
  check();
42464
42617
  if (--steps < 0)
42465
42618
  fail("LIMIT_FORMULA_STEPS", "ShapeSheet dependency evaluation limit exceeded.");
42466
42619
  const override = overrides.get(cell);
42467
42620
  if (override !== void 0) return { value: override, unit: expectedUnit(cell) ?? "scalar" };
42468
42621
  const known = values.get(cell);
42469
- if (known) return known;
42622
+ if (known) {
42623
+ if (tainted.has(cell)) sawDeferred = true;
42624
+ return known;
42625
+ }
42470
42626
  if (!isAffected(cell, /* @__PURE__ */ new Set())) return cached5(cell);
42471
42627
  const own = dependenciesOf(cell);
42628
+ if (own?.deferText) {
42629
+ sawDeferred = true;
42630
+ return cached5(cell);
42631
+ }
42472
42632
  const ast = own?.ast;
42473
42633
  if (!ast || evaluating.has(cell)) throw new Unevaluable();
42474
42634
  evaluating.add(cell);
@@ -42512,9 +42672,11 @@ function recalculateInstanceCaches(target2, changed, check, pins = /* @__PURE__
42512
42672
  let value3;
42513
42673
  let length;
42514
42674
  try {
42675
+ sawDeferred = false;
42515
42676
  const result2 = evaluate(cell);
42516
42677
  value3 = result2.value;
42517
42678
  length = result2.unit === "length";
42679
+ if (tainted.has(cell) && cell.section && PASSIVE.has(cell.section.name)) continue;
42518
42680
  } catch (error) {
42519
42681
  if (!(error instanceof Unevaluable)) throw error;
42520
42682
  if (cell.section && PASSIVE.has(cell.section.name)) continue;
@@ -43300,7 +43462,7 @@ function proveLocalLine(shape) {
43300
43462
  );
43301
43463
  }
43302
43464
  function moveLocalLine(shape, pageId2, shapeId2, x, y) {
43303
- const fixed = proveLocalLine(shape);
43465
+ const fixed2 = proveLocalLine(shape);
43304
43466
  const local = cells(shape);
43305
43467
  const value3 = (name3) => numeric(local.get(name3));
43306
43468
  const changed = [];
@@ -43325,11 +43487,11 @@ function moveLocalLine(shape, pageId2, shapeId2, x, y) {
43325
43487
  changed.push({ pageId: pageId2, shapeId: shapeId2, cell: name3 });
43326
43488
  }
43327
43489
  }
43328
- return { changed, fixed };
43490
+ return { changed, fixed: fixed2 };
43329
43491
  }
43330
- function assertLineTranslation(shape, fixed) {
43492
+ function assertLineTranslation(shape, fixed2) {
43331
43493
  const local = cells(shape);
43332
- for (const [name3, expected] of fixed)
43494
+ for (const [name3, expected] of fixed2)
43333
43495
  if (!sameLineCoordinate(numeric(local.get(name3), expected), expected))
43334
43496
  fail(
43335
43497
  "EDIT_UNSUPPORTED_DEPENDENCY",
@@ -43897,12 +44059,12 @@ function pathVertices(sheet, width, height, writes) {
43897
44059
  return refuse();
43898
44060
  }
43899
44061
  }
43900
- const entry3 = rows.get(item2.row) ?? { relative: item2.relative };
43901
- entry3[item2.name === "X" ? "x" : "y"] = number6;
43902
- rows.set(item2.row, entry3);
44062
+ const entry4 = rows.get(item2.row) ?? { relative: item2.relative };
44063
+ entry4[item2.name === "X" ? "x" : "y"] = number6;
44064
+ rows.set(item2.row, entry4);
43903
44065
  }
43904
- return [...rows.values()].filter((entry3) => entry3.x !== void 0 && entry3.y !== void 0).map(
43905
- (entry3) => entry3.relative ? { x: entry3.x * width, y: entry3.y * height } : { x: entry3.x, y: entry3.y }
44066
+ return [...rows.values()].filter((entry4) => entry4.x !== void 0 && entry4.y !== void 0).map(
44067
+ (entry4) => entry4.relative ? { x: entry4.x * width, y: entry4.y * height } : { x: entry4.x, y: entry4.y }
43906
44068
  );
43907
44069
  }
43908
44070
  function layoutStencilLine(root2, pageId2, shape, ends, check) {
@@ -44663,7 +44825,7 @@ var installed;
44663
44825
  function setVisioTextMeasurer(measurer) {
44664
44826
  installed = measurer;
44665
44827
  }
44666
- function measure2(text7, style3) {
44828
+ function measure3(text7, style3) {
44667
44829
  for (const measurer of installed ? [designTextMeasurer, installed] : [designTextMeasurer]) {
44668
44830
  const width = measurer.width(text7, style3);
44669
44831
  if (width !== void 0 && Number.isFinite(width) && width >= 0)
@@ -44707,7 +44869,7 @@ function layoutParagraph(pieces, fallback, paragraph2, available) {
44707
44869
  for (const piece of pieces) {
44708
44870
  for (const token of piece.text.match(/ +|[^ ]+/g) ?? []) {
44709
44871
  if (UNSUPPORTED3.test(token)) return void 0;
44710
- const measured = measure2(token, piece.run);
44872
+ const measured = measure3(token, piece.run);
44711
44873
  if (!measured) return void 0;
44712
44874
  if (token.startsWith(" ")) {
44713
44875
  if (width > 0) pending2 += measured.width;
@@ -44723,7 +44885,7 @@ function layoutParagraph(pieces, fallback, paragraph2, available) {
44723
44885
  pending2 = 0;
44724
44886
  if (start === 0 && Number.isFinite(room()) && measured.width > room()) {
44725
44887
  for (const character of token) {
44726
- const one = measure2(character, piece.run);
44888
+ const one = measure3(character, piece.run);
44727
44889
  if (!one) return void 0;
44728
44890
  const edge2 = room();
44729
44891
  if (width > 0) {
@@ -44775,7 +44937,7 @@ function visioTextExtents(text7) {
44775
44937
  width(maximum) {
44776
44938
  const inner = maximum === void 0 ? Infinity : maximum - text7.margins.left - text7.margins.right;
44777
44939
  const laid = layout(inner);
44778
- const mark = measure2(" ", text7.runs.at(-1) ?? fallback);
44940
+ const mark = measure3(" ", text7.runs.at(-1) ?? fallback);
44779
44941
  if (!laid || !mark) return void 0;
44780
44942
  let widest = 0;
44781
44943
  laid.forEach((lines3, index3) => {
@@ -45536,7 +45698,9 @@ async function applyInstanceGeometryEdit(roots, edit, template, check) {
45536
45698
  scope,
45537
45699
  overrides,
45538
45700
  check,
45539
- new Map(pins.map((item2) => [item2, item2 === cell("Width") ? width : height]))
45701
+ new Map(pins.map((item2) => [item2, item2 === cell("Width") ? width : height])),
45702
+ void 0,
45703
+ true
45540
45704
  );
45541
45705
  for (const [item2, value3] of pinned) {
45542
45706
  assertOverridable(item2, "The size");
@@ -49140,13 +49304,13 @@ function masterMediaParts(media, directory, taken, types, existing) {
49140
49304
  node3.setAttribute("Target", `../media/${part.slice(folder.length)}`);
49141
49305
  rels.appendChild(node3);
49142
49306
  const known = Array.from(types.getElementsByTagNameNS(types.namespaceURI, "Default")).some(
49143
- (entry3) => entry3.getAttribute("Extension")?.toLowerCase() === extension2
49307
+ (entry4) => entry4.getAttribute("Extension")?.toLowerCase() === extension2
49144
49308
  );
49145
49309
  if (!known) {
49146
- const entry3 = types.ownerDocument.createElementNS(types.namespaceURI, "Default");
49147
- entry3.setAttribute("Extension", extension2);
49148
- entry3.setAttribute("ContentType", MEDIA_TYPES[extension2] ?? "application/octet-stream");
49149
- types.insertBefore(entry3, types.firstChild);
49310
+ const entry4 = types.ownerDocument.createElementNS(types.namespaceURI, "Default");
49311
+ entry4.setAttribute("Extension", extension2);
49312
+ entry4.setAttribute("ContentType", MEDIA_TYPES[extension2] ?? "application/octet-stream");
49313
+ types.insertBefore(entry4, types.firstChild);
49150
49314
  }
49151
49315
  }
49152
49316
  return { rels, parts };
@@ -49175,17 +49339,17 @@ async function addMasterToDrawing(source, spec, limits, maxOutput, deadline, che
49175
49339
  if (entries.length >= MAX_MASTERS)
49176
49340
  fail("LIMIT_EDITS", "The drawing holds too many masters to add another.");
49177
49341
  const same8 = (value3, other) => value3?.toLowerCase() === other.toLowerCase();
49178
- const ours = spec.uniqueId && entries.find((entry3) => same8(attribute2(entry3, "UniqueID"), spec.uniqueId));
49342
+ const ours = spec.uniqueId && entries.find((entry4) => same8(attribute2(entry4, "UniqueID"), spec.uniqueId));
49179
49343
  if (ours) return { bytes: source, masterId: attribute2(ours, "ID") ?? "", changedParts: [] };
49180
49344
  const name3 = spec.name;
49181
49345
  const reused = await spec.reuse?.({ pkg, existingPart, entries, check });
49182
49346
  if (reused !== void 0) return { bytes: source, masterId: reused, changedParts: [] };
49183
- const ids = entries.map((entry3) => Number(attribute2(entry3, "ID")));
49347
+ const ids = entries.map((entry4) => Number(attribute2(entry4, "ID")));
49184
49348
  if (ids.some((id5) => !Number.isSafeInteger(id5) || id5 < 0))
49185
49349
  fail("UNSUPPORTED_EDIT_PACKAGE", "The drawing has masters without canonical IDs.");
49186
49350
  const id4 = String(Math.max(1, ...ids.map((value3) => value3 + 1)));
49187
49351
  const names = new Set(
49188
- entries.flatMap((entry3) => [attribute2(entry3, "NameU"), attribute2(entry3, "Name")])
49352
+ entries.flatMap((entry4) => [attribute2(entry4, "NameU"), attribute2(entry4, "Name")])
49189
49353
  );
49190
49354
  const unique2 = names.has(name3) ? `${name3}.${id4}` : name3;
49191
49355
  const relsPart = relationshipsPartFor(mastersPart);
@@ -49225,11 +49389,11 @@ async function addMasterToDrawing(source, spec, limits, maxOutput, deadline, che
49225
49389
  spec.entry(masters, id4, unique2, relId);
49226
49390
  const documentCopy = copy3(document);
49227
49391
  let documentTouched = false;
49228
- const contents = await spec.contents(documentCopy, () => documentTouched = true);
49392
+ const contents2 = await spec.contents(documentCopy, () => documentTouched = true);
49229
49393
  const dirty = /* @__PURE__ */ new Map([
49230
49394
  [mastersPart, masters],
49231
49395
  [relsPart, rels],
49232
- [masterPart, contents],
49396
+ [masterPart, contents2],
49233
49397
  ["[Content_Types].xml", types]
49234
49398
  ]);
49235
49399
  if (documentTouched) dirty.set(documentPart2, documentCopy);
@@ -49544,18 +49708,18 @@ async function ensureStencilMaster(source, master2, limits, maxOutput, deadline,
49544
49708
  uniqueId: builtIn.uniqueId,
49545
49709
  name: name3,
49546
49710
  async reuse({ pkg, existingPart, entries, check: tick }) {
49547
- for (const entry3 of entries) {
49711
+ for (const entry4 of entries) {
49548
49712
  tick();
49549
- if (!existingPart || !same8(attribute2(entry3, "NameU") ?? attribute2(entry3, "Name"), name3))
49713
+ if (!existingPart || !same8(attribute2(entry4, "NameU") ?? attribute2(entry4, "Name"), name3))
49550
49714
  continue;
49551
49715
  try {
49552
- const part = await indexedPart(pkg, existingPart, entry3, "master");
49716
+ const part = await indexedPart(pkg, existingPart, entry4, "master");
49553
49717
  const roots = shapesOf2(await visioXml(pkg, part, "MasterContents")).filter(
49554
49718
  (shape) => attribute2(shape, "Del") !== "1"
49555
49719
  );
49556
49720
  const cells4 = new Set(children2(roots[0], "Cell").map((cell) => attribute2(cell, "N")));
49557
49721
  if (roots.length === 1 && !cells4.has("BeginX") && !roots[0].hasAttribute("Master"))
49558
- return attribute2(entry3, "ID") ?? "";
49722
+ return attribute2(entry4, "ID") ?? "";
49559
49723
  } catch {
49560
49724
  }
49561
49725
  }
@@ -49647,26 +49811,26 @@ async function importStencilMaster(source, stencil, stencilMasterId, limits, max
49647
49811
  const stencilDocument = await visioXml(pkg, documentPart2, "VisioDocument");
49648
49812
  const mastersPart = await related(pkg, documentPart2, "masters", false);
49649
49813
  if (!mastersPart) fail("EDIT_TARGET_NOT_FOUND", "The stencil has no masters.");
49650
- const entry3 = children2(await visioXml(pkg, mastersPart, "Masters"), "Master").find(
49814
+ const entry4 = children2(await visioXml(pkg, mastersPart, "Masters"), "Master").find(
49651
49815
  (node3) => attribute2(node3, "ID") === stencilMasterId
49652
49816
  );
49653
- if (!entry3) fail("EDIT_TARGET_NOT_FOUND", "The stencil has no such master.");
49654
- const part = await indexedPart(pkg, mastersPart, entry3, "master");
49817
+ if (!entry4) fail("EDIT_TARGET_NOT_FOUND", "The stencil has no such master.");
49818
+ const part = await indexedPart(pkg, mastersPart, entry4, "master");
49655
49819
  const media = await masterPictures(pkg, part);
49656
- const contents = await visioXml(pkg, part, "MasterContents");
49657
- const name3 = attribute2(entry3, "NameU") ?? attribute2(entry3, "Name") ?? `Master ${stencilMasterId}`;
49820
+ const contents2 = await visioXml(pkg, part, "MasterContents");
49821
+ const name3 = attribute2(entry4, "NameU") ?? attribute2(entry4, "Name") ?? `Master ${stencilMasterId}`;
49658
49822
  return addMasterToDrawing(
49659
49823
  source,
49660
49824
  {
49661
- uniqueId: attribute2(entry3, "UniqueID") ?? "",
49825
+ uniqueId: attribute2(entry4, "UniqueID") ?? "",
49662
49826
  name: name3,
49663
49827
  entry(masters, id4, unique2, relationshipId) {
49664
- const node3 = masters.ownerDocument.importNode(entry3, true);
49828
+ const node3 = masters.ownerDocument.importNode(entry4, true);
49665
49829
  if (node3.namespaceURI !== masters.namespaceURI)
49666
49830
  fail("UNSUPPORTED_EDIT_PACKAGE", "The stencil uses another Visio namespace.");
49667
49831
  node3.setAttribute("ID", id4);
49668
49832
  node3.setAttribute("NameU", unique2);
49669
- if (node3.hasAttribute("Name") && attribute2(entry3, "Name") === name3)
49833
+ if (node3.hasAttribute("Name") && attribute2(entry4, "Name") === name3)
49670
49834
  node3.setAttribute("Name", unique2);
49671
49835
  for (const sheet of children2(node3, "PageSheet"))
49672
49836
  for (const style3 of STYLE_ATTRIBUTES)
@@ -49677,7 +49841,7 @@ async function importStencilMaster(source, stencil, stencilMasterId, limits, max
49677
49841
  media,
49678
49842
  contents(document, touch) {
49679
49843
  const map = styleMapper(stencilDocument, document, touch);
49680
- const root2 = copy3(contents);
49844
+ const root2 = copy3(contents2);
49681
49845
  if (root2.namespaceURI !== document.namespaceURI)
49682
49846
  fail("UNSUPPORTED_EDIT_PACKAGE", "The stencil uses another Visio namespace.");
49683
49847
  for (const shape of Array.from(root2.getElementsByTagNameNS(root2.namespaceURI, "Shape")))
@@ -51750,7 +51914,7 @@ function visioFallbackQuickStyle(style3) {
51750
51914
  return { fill: mix2(base2, 0, 0.5), line: mix2(base2, 0, 0.5), font: light };
51751
51915
  }
51752
51916
  }
51753
- var rgb = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
51917
+ var rgb2 = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
51754
51918
  function shadowWrites(preset, add) {
51755
51919
  if (preset === "none") {
51756
51920
  add("ShdwPattern", 0, "FillStyle");
@@ -51758,7 +51922,7 @@ function shadowWrites(preset, add) {
51758
51922
  }
51759
51923
  const { x, y, blur } = visioShadowPresetGeometry(preset);
51760
51924
  add("ShdwPattern", 1, "FillStyle");
51761
- add("ShdwForegnd", "#000000", "FillStyle", void 0, rgb("#000000"));
51925
+ add("ShdwForegnd", "#000000", "FillStyle", void 0, rgb2("#000000"));
51762
51926
  add("ShdwForegndTrans", 0.6, "FillStyle");
51763
51927
  add("ShapeShdwType", 1, "FillStyle");
51764
51928
  add("ShapeShdwOffsetX", x / 72, "FillStyle", "PT");
@@ -51787,7 +51951,7 @@ async function quickStyleWrites(pkg, document, shape, pageId2, style3, add, chec
51787
51951
  );
51788
51952
  for (const [name3, value3, category] of selectors2) add(name3, value3, category);
51789
51953
  const fallback = visioFallbackQuickStyle(style3);
51790
- const paint3 = (name3, category, color2) => themed ? add(name3, "Themed", category, void 0, "THEMEVAL()") : add(name3, color2, category, void 0, rgb(color2));
51954
+ const paint3 = (name3, category, color2) => themed ? add(name3, "Themed", category, void 0, "THEMEVAL()") : add(name3, color2, category, void 0, rgb2(color2));
51791
51955
  add("FillPattern", 1, "FillStyle");
51792
51956
  add("FillForegndTrans", 0, "FillStyle");
51793
51957
  add("LinePattern", 1, "LineStyle");
@@ -51855,12 +52019,12 @@ function snapshotReflection(value3) {
51855
52019
  blur: bounded5(value3.blur, 100, "Reflection blur must be 0 to 100 points.")
51856
52020
  };
51857
52021
  }
51858
- var rgb2 = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
52022
+ var rgb3 = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
51859
52023
  function effectWrites(edit, add) {
51860
52024
  if (edit.glow) {
51861
52025
  add("GlowSize", edit.glow.size / 72, "FillStyle", "PT");
51862
52026
  if (edit.glow.size > 0) {
51863
- add("GlowColor", edit.glow.color, "FillStyle", void 0, rgb2(edit.glow.color));
52027
+ add("GlowColor", edit.glow.color, "FillStyle", void 0, rgb3(edit.glow.color));
51864
52028
  add("GlowColorTrans", edit.glow.transparency / 100, "FillStyle");
51865
52029
  }
51866
52030
  }
@@ -52084,7 +52248,11 @@ function snapshotFormatting(edit) {
52084
52248
  "softEdges",
52085
52249
  "reflection",
52086
52250
  "bevel",
52087
- "rotation3d"
52251
+ "rotation3d",
52252
+ "extrusionDepth",
52253
+ "extrusionColor",
52254
+ "contourSize",
52255
+ "contourColor"
52088
52256
  ].includes(key3) && edit[key3] !== void 0
52089
52257
  ))
52090
52258
  fail("INVALID_EDIT", "A Quick Style replaces fill, line and font paint as a whole.");
@@ -52098,6 +52266,7 @@ function snapshotFormatting(edit) {
52098
52266
  if (edit.reflection !== void 0) result2.reflection = snapshotReflection(edit.reflection);
52099
52267
  if (edit.bevel !== void 0) result2.bevel = snapshotBevel(edit.bevel);
52100
52268
  if (edit.rotation3d !== void 0) result2.rotation3d = snapshotRotation(edit.rotation3d);
52269
+ Object.assign(result2, snapshotSolid(edit));
52101
52270
  if (result2.fillColor === "none" && result2.fillPattern !== void 0 && result2.fillPattern !== 0)
52102
52271
  fail("INVALID_EDIT", "No fill conflicts with a visible fill pattern.");
52103
52272
  }
@@ -52270,7 +52439,8 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
52270
52439
  endX,
52271
52440
  endY,
52272
52441
  ...connect ? { connect } : {},
52273
- ...route ? { route } : {}
52442
+ ...route ? { route } : {},
52443
+ ...edit.text !== void 0 ? { text: text7(edit.text) } : {}
52274
52444
  };
52275
52445
  }
52276
52446
  case "create-rectangle":
@@ -52319,7 +52489,7 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
52319
52489
  };
52320
52490
  }
52321
52491
  case "delete-shape":
52322
- return { ...target2, type: edit.type };
52492
+ return { ...target2, type: edit.type, ...edit.deferred ? { deferred: true } : {} };
52323
52493
  default:
52324
52494
  return fail("INVALID_EDIT", "Unsupported edit command.");
52325
52495
  }
@@ -53563,13 +53733,13 @@ function createVisioPagePart(parts, pages, pageId2, check) {
53563
53733
  override.setAttribute("PartName", `/${path3}`);
53564
53734
  override.setAttribute("ContentType", contentType);
53565
53735
  parts.types.appendChild(override);
53566
- const contents = parseXml(`<PageContents xmlns="${pages.namespaceURI}"/>`).documentElement;
53567
- contents.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
53568
- parts.dirty.set(path3, contents);
53736
+ const contents2 = parseXml(`<PageContents xmlns="${pages.namespaceURI}"/>`).documentElement;
53737
+ contents2.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
53738
+ parts.dirty.set(path3, contents2);
53569
53739
  parts.dirty.set(parts.pagesPart, pages);
53570
53740
  parts.dirty.set(parts.relsPart, parts.rels);
53571
53741
  parts.dirty.set("[Content_Types].xml", parts.types);
53572
- return { page, contents };
53742
+ return { page, contents: contents2 };
53573
53743
  }
53574
53744
 
53575
53745
  // visio/edit-page-decoration.ts
@@ -53971,7 +54141,7 @@ function formattingFont(document, family) {
53971
54141
  var hasCharacterExtras = (edit) => textExtraCharacterKeys.some((key3) => edit[key3] !== void 0);
53972
54142
  var hasParagraphExtras = (edit) => textExtraParagraphKeys.some((key3) => edit[key3] !== void 0);
53973
54143
  var quoted = (text7) => `"${text7.replaceAll('"', '""')}"`;
53974
- var rgb3 = (color2) => `RGB(${[1, 3, 5].map((i) => parseInt(color2.slice(i, i + 2), 16)).join(",")})`;
54144
+ var rgb4 = (color2) => `RGB(${[1, 3, 5].map((i) => parseInt(color2.slice(i, i + 2), 16)).join(",")})`;
53975
54145
  var inches = (value3) => Number(value3.toFixed(10));
53976
54146
  function characterExtraWrites(edit, name3, add) {
53977
54147
  if (edit.fontTransparency !== void 0) add(name3("ColorTrans"), edit.fontTransparency / 100);
@@ -54024,7 +54194,7 @@ function textBlockWrites(shape, edit, add) {
54024
54194
  }
54025
54195
  if (edit.textBackground !== void 0) {
54026
54196
  if (edit.textBackground === "none") add("TextBkgnd", 0);
54027
- else add("TextBkgnd", edit.textBackground, void 0, `${rgb3(edit.textBackground)}+1`);
54197
+ else add("TextBkgnd", edit.textBackground, void 0, `${rgb4(edit.textBackground)}+1`);
54028
54198
  }
54029
54199
  if (edit.textBackgroundTransparency !== void 0)
54030
54200
  add("TextBkgndTrans", edit.textBackgroundTransparency / 100);
@@ -54188,7 +54358,7 @@ function shapeFormattingWrites(edit) {
54188
54358
  edit.fillColor,
54189
54359
  "FillStyle",
54190
54360
  void 0,
54191
- edit.fillColorTheme ? visioThemeColorFormula(edit.fillColorTheme) : rgb4(edit.fillColor)
54361
+ edit.fillColorTheme ? visioThemeColorFormula(edit.fillColorTheme) : rgb5(edit.fillColor)
54192
54362
  );
54193
54363
  add("FillForegndTrans", 0, "FillStyle");
54194
54364
  }
@@ -54203,7 +54373,7 @@ function shapeFormattingWrites(edit) {
54203
54373
  edit.fillBackgroundColor,
54204
54374
  "FillStyle",
54205
54375
  void 0,
54206
- rgb4(edit.fillBackgroundColor)
54376
+ rgb5(edit.fillBackgroundColor)
54207
54377
  );
54208
54378
  }
54209
54379
  if (edit.fillTransparency !== void 0) {
@@ -54216,7 +54386,7 @@ function shapeFormattingWrites(edit) {
54216
54386
  edit.lineColor,
54217
54387
  "LineStyle",
54218
54388
  void 0,
54219
- edit.lineColorTheme ? visioThemeColorFormula(edit.lineColorTheme) : rgb4(edit.lineColor)
54389
+ edit.lineColorTheme ? visioThemeColorFormula(edit.lineColorTheme) : rgb5(edit.lineColor)
54220
54390
  );
54221
54391
  add("LineColorTrans", 0, "LineStyle");
54222
54392
  add("LineGradientEnabled", 0, "LineStyle");
@@ -54255,6 +54425,7 @@ async function shapeFormattingPlan(pkg, document, shape, edit, check) {
54255
54425
  effectWrites(edit, add);
54256
54426
  if (edit.bevel !== void 0) bevelWrites(edit.bevel, add);
54257
54427
  if (edit.rotation3d !== void 0) rotationWrites(edit.rotation3d, add);
54428
+ solidWrites(edit, add);
54258
54429
  return { writes: [...writes.values()], ...rows ? { rows } : {} };
54259
54430
  }
54260
54431
  async function assertShapeFormattingPaintScope(pkg, document, shape, edit, changed, check) {
@@ -54264,7 +54435,7 @@ async function assertShapeFormattingPaintScope(pkg, document, shape, edit, chang
54264
54435
  if (edit.lineColor === void 0 && changed.has("LineColorTrans"))
54265
54436
  await assertNonGradientPaint(pkg, document, shape, edit.pageId, "Line", check);
54266
54437
  }
54267
- function rgb4(color2) {
54438
+ function rgb5(color2) {
54268
54439
  return `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
54269
54440
  }
54270
54441
 
@@ -54949,11 +55120,11 @@ async function masterEntry(pkg, masterId) {
54949
55120
  async function masterIdentities(pkg, masterIds) {
54950
55121
  const result2 = [];
54951
55122
  for (const id4 of masterIds) {
54952
- const entry3 = await masterEntry(pkg, id4);
54953
- if (!entry3) fail("UNSUPPORTED_CLIPBOARD", "The master of a stencil shape cannot be resolved.");
55123
+ const entry4 = await masterEntry(pkg, id4);
55124
+ if (!entry4) fail("UNSUPPORTED_CLIPBOARD", "The master of a stencil shape cannot be resolved.");
54954
55125
  result2.push({
54955
55126
  id: id4,
54956
- identity: ["UniqueID", "BaseID", "NameU"].map((name3) => attribute2(entry3.master, name3) ?? "").join("|")
55127
+ identity: ["UniqueID", "BaseID", "NameU"].map((name3) => attribute2(entry4.master, name3) ?? "").join("|")
54957
55128
  });
54958
55129
  }
54959
55130
  return result2;
@@ -54961,11 +55132,11 @@ async function masterIdentities(pkg, masterIds) {
54961
55132
  async function assertClipboardMasters(pkg, pagePath, source, captured) {
54962
55133
  for (const id4 of instanceMasterIds(source)) {
54963
55134
  const known = captured?.find((master2) => master2.id === id4);
54964
- const entry3 = await masterEntry(pkg, id4);
54965
- if (!known || !entry3) fail("CLIPBOARD_RESOURCE_MISMATCH", ELSEWHERE);
55135
+ const entry4 = await masterEntry(pkg, id4);
55136
+ if (!known || !entry4) fail("CLIPBOARD_RESOURCE_MISMATCH", ELSEWHERE);
54966
55137
  const [actual] = await masterIdentities(pkg, [id4]);
54967
55138
  if (actual.identity !== known.identity) fail("CLIPBOARD_RESOURCE_MISMATCH", ELSEWHERE);
54968
- const masterPart = await indexedPart(pkg, entry3.mastersPart, entry3.master, "master");
55139
+ const masterPart = await indexedPart(pkg, entry4.mastersPart, entry4.master, "master");
54969
55140
  const linked = [...(await pkg.relationships(pagePath)).values()].some(
54970
55141
  (rel) => rel.type === MASTER_RELATIONSHIP3 && rel.target === masterPart
54971
55142
  );
@@ -55563,14 +55734,14 @@ async function editVsdxPicture(pkg, parts, pages, edit, limits, maxOutput, deadl
55563
55734
  (node3) => node3.getAttribute("Extension")?.toLowerCase() === format6.extension
55564
55735
  );
55565
55736
  if (!declared || declared.getAttribute("ContentType") !== info.mimeType) {
55566
- const entry3 = types.ownerDocument.createElementNS(
55737
+ const entry4 = types.ownerDocument.createElementNS(
55567
55738
  types.namespaceURI,
55568
55739
  declared ? "Override" : "Default"
55569
55740
  );
55570
- if (declared) entry3.setAttribute("PartName", `/${media}`);
55571
- else entry3.setAttribute("Extension", format6.extension);
55572
- entry3.setAttribute("ContentType", info.mimeType);
55573
- types.insertBefore(entry3, declared ? null : types.firstElementChild ?? null);
55741
+ if (declared) entry4.setAttribute("PartName", `/${media}`);
55742
+ else entry4.setAttribute("Extension", format6.extension);
55743
+ entry4.setAttribute("ContentType", info.mimeType);
55744
+ types.insertBefore(entry4, declared ? null : types.firstElementChild ?? null);
55574
55745
  }
55575
55746
  const dirty = /* @__PURE__ */ new Map([
55576
55747
  [path3, root2],
@@ -55629,14 +55800,14 @@ function declareType(types, extension2, contentType2, partName) {
55629
55800
  (node3) => node3.getAttribute("Extension")?.toLowerCase() === extension2
55630
55801
  );
55631
55802
  if (declared?.getAttribute("ContentType") === contentType2) return;
55632
- const entry3 = types.ownerDocument.createElementNS(
55803
+ const entry4 = types.ownerDocument.createElementNS(
55633
55804
  types.namespaceURI,
55634
55805
  declared ? "Override" : "Default"
55635
55806
  );
55636
- if (declared) entry3.setAttribute("PartName", `/${partName}`);
55637
- else entry3.setAttribute("Extension", extension2);
55638
- entry3.setAttribute("ContentType", contentType2);
55639
- types.insertBefore(entry3, declared ? null : types.firstElementChild ?? null);
55807
+ if (declared) entry4.setAttribute("PartName", `/${partName}`);
55808
+ else entry4.setAttribute("Extension", extension2);
55809
+ entry4.setAttribute("ContentType", contentType2);
55810
+ types.insertBefore(entry4, declared ? null : types.firstElementChild ?? null);
55640
55811
  }
55641
55812
  async function stage(pkg, parts) {
55642
55813
  const types = cloneRoot(await pkg.readXml("[Content_Types].xml", "Types"));
@@ -55823,7 +55994,7 @@ function refreshThemeColorCaches(root2, colors, check) {
55823
55994
  }
55824
55995
 
55825
55996
  // visio/edit-page-theme-recolor.ts
55826
- var rgb5 = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
55997
+ var rgb6 = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
55827
55998
  function formattingCell2(sheet, name3) {
55828
55999
  const matches2 = children2(sheet, "Cell").filter((cell) => attribute2(cell, "N") === name3);
55829
56000
  return matches2.length === 1 ? matches2[0] : void 0;
@@ -55847,14 +56018,14 @@ function style2(shape, kind) {
55847
56018
  function convert(cell, fallback, mode) {
55848
56019
  if (!cell || cell.hasAttribute("E")) return false;
55849
56020
  if (mode === "themed") {
55850
- if (normal2(attribute2(cell, "F")) !== rgb5(fallback)) return false;
56021
+ if (normal2(attribute2(cell, "F")) !== rgb6(fallback)) return false;
55851
56022
  cell.setAttribute("V", "Themed");
55852
56023
  cell.setAttribute("F", "THEMEVAL()");
55853
56024
  } else {
55854
56025
  if (normal2(attribute2(cell, "F")) !== "THEMEVAL()" || attribute2(cell, "V") !== "Themed")
55855
56026
  return false;
55856
56027
  cell.setAttribute("V", fallback);
55857
- cell.setAttribute("F", rgb5(fallback));
56028
+ cell.setAttribute("F", rgb6(fallback));
55858
56029
  }
55859
56030
  cell.removeAttribute("U");
55860
56031
  return true;
@@ -56073,7 +56244,7 @@ async function editVsdxPageTheme(pkg, parts, pages, edit, limits, maxOutput, dea
56073
56244
  });
56074
56245
  const dirty = /* @__PURE__ */ new Map([[pagesPath, pagesRoot]]);
56075
56246
  const created = /* @__PURE__ */ new Map();
56076
- const contents = copy6(await visioXml(pkg, contentsPath, "PageContents"));
56247
+ const contents2 = copy6(await visioXml(pkg, contentsPath, "PageContents"));
56077
56248
  let recolored = false;
56078
56249
  const part = PAGE_THEME_PARTS.find((name3) => edit[name3] !== void 0);
56079
56250
  if (edit.embellishment !== void 0)
@@ -56086,8 +56257,8 @@ async function editVsdxPageTheme(pkg, parts, pages, edit, limits, maxOutput, dea
56086
56257
  (style3) => attribute2(style3, "ID") === "0"
56087
56258
  );
56088
56259
  if (attribute2(root2, "NameU") !== "No Style")
56089
- recolored = recolorQuickStyledShapes(contents, "fallback", check);
56090
- recolored = refreshThemeColorCaches(contents, VISIO_UNTHEMED_COLORS, check) || recolored;
56260
+ recolored = recolorQuickStyledShapes(contents2, "fallback", check);
56261
+ recolored = refreshThemeColorCaches(contents2, VISIO_UNTHEMED_COLORS, check) || recolored;
56091
56262
  } else if (edit.theme || part) {
56092
56263
  const source = visioBuiltInTheme(edit.theme ?? edit[part]);
56093
56264
  await ensureBuiltInThemePart(pkg, parts, documentPath, themes, source, dirty, created, check);
@@ -56096,7 +56267,7 @@ async function editVsdxPageTheme(pkg, parts, pages, edit, limits, maxOutput, dea
56096
56267
  if (!part || part === "colors") {
56097
56268
  for (const name3 of ["VariationColorIndex", "VariationStyleIndex"])
56098
56269
  setCell(sheet, name3, edit.variant ?? 0);
56099
- recolored = recolorQuickStyledShapes(contents, "themed", check);
56270
+ recolored = recolorQuickStyledShapes(contents2, "themed", check);
56100
56271
  }
56101
56272
  const hex = (index3) => `#${source.colors[index3].toLowerCase()}`;
56102
56273
  const variant = visioThemeVariantColors(source, edit.variant ?? 0);
@@ -56105,7 +56276,7 @@ async function editVsdxPageTheme(pkg, parts, pages, edit, limits, maxOutput, dea
56105
56276
  for (let index3 = 1; index3 <= 7; index3++)
56106
56277
  colors[`variant${index3}`] = `#${variant[index3 - 1].toLowerCase()}`;
56107
56278
  if (!part || part === "colors")
56108
- recolored = refreshThemeColorCaches(contents, colors, check) || recolored;
56279
+ recolored = refreshThemeColorCaches(contents2, colors, check) || recolored;
56109
56280
  } else if (edit.variant !== void 0) {
56110
56281
  const current = pageSelectedTheme(themes, sheet);
56111
56282
  if (!current || current.variants.length <= edit.variant)
@@ -56125,9 +56296,9 @@ async function editVsdxPageTheme(pkg, parts, pages, edit, limits, maxOutput, dea
56125
56296
  const color2 = drawingColor(current.colors.get(key3), current.colors);
56126
56297
  if (color2) colors[slot2] = color2;
56127
56298
  }
56128
- recolored = refreshThemeColorCaches(contents, colors, check);
56299
+ recolored = refreshThemeColorCaches(contents2, colors, check);
56129
56300
  }
56130
- if (recolored) dirty.set(contentsPath, contents);
56301
+ if (recolored) dirty.set(contentsPath, contents2);
56131
56302
  if ((/* @__PURE__ */ new Set([...parts.keys(), ...dirty.keys(), ...created.keys()])).size > limits.maxEntries)
56132
56303
  fail("LIMIT_ENTRIES", "The theme exceeds the package entry limit.");
56133
56304
  let total = [...parts.values()].reduce((sum, bytes2) => sum + bytes2.length, 0);
@@ -56218,7 +56389,7 @@ async function editVsdxComments(pkg, parts, pages, edits, limits, maxOutput, dea
56218
56389
  const authors = list(root2, "AuthorList");
56219
56390
  const comments = list(root2, "CommentList");
56220
56391
  const byId = new Map(
56221
- children2(comments, "CommentEntry").map((entry3, index3) => [visioCommentId(entry3, index3), entry3])
56392
+ children2(comments, "CommentEntry").map((entry4, index3) => [visioCommentId(entry4, index3), entry4])
56222
56393
  );
56223
56394
  const removed = /* @__PURE__ */ new Set();
56224
56395
  for (const edit of edits) {
@@ -56241,29 +56412,29 @@ async function editVsdxComments(pkg, parts, pages, edits, limits, maxOutput, dea
56241
56412
  if (edit.initials) author.setAttribute("Initials", edit.initials);
56242
56413
  authors.appendChild(author);
56243
56414
  }
56244
- const entry4 = root2.ownerDocument.createElementNS(root2.namespaceURI, "CommentEntry");
56245
- entry4.setAttribute("AuthorID", attribute2(author, "ID"));
56246
- entry4.setAttribute("PageID", edit.pageId);
56247
- if (edit.shapeId !== void 0) entry4.setAttribute("ShapeID", edit.shapeId);
56248
- entry4.setAttribute("Date", edit.date);
56249
- entry4.setAttribute("CommentID", nextId(children2(comments, "CommentEntry"), "CommentID"));
56250
- entry4.textContent = edit.text;
56251
- comments.appendChild(entry4);
56415
+ const entry5 = root2.ownerDocument.createElementNS(root2.namespaceURI, "CommentEntry");
56416
+ entry5.setAttribute("AuthorID", attribute2(author, "ID"));
56417
+ entry5.setAttribute("PageID", edit.pageId);
56418
+ if (edit.shapeId !== void 0) entry5.setAttribute("ShapeID", edit.shapeId);
56419
+ entry5.setAttribute("Date", edit.date);
56420
+ entry5.setAttribute("CommentID", nextId(children2(comments, "CommentEntry"), "CommentID"));
56421
+ entry5.textContent = edit.text;
56422
+ comments.appendChild(entry5);
56252
56423
  continue;
56253
56424
  }
56254
- const entry3 = byId.get(edit.commentId);
56255
- if (!entry3 || removed.has(entry3) || attribute2(entry3, "PageID") !== edit.pageId)
56425
+ const entry4 = byId.get(edit.commentId);
56426
+ if (!entry4 || removed.has(entry4) || attribute2(entry4, "PageID") !== edit.pageId)
56256
56427
  fail("EDIT_TARGET_NOT_FOUND", "Comment does not exist on the page.");
56257
56428
  if (edit.type === "delete-comment") {
56258
- entry3.parentNode.removeChild(entry3);
56259
- removed.add(entry3);
56429
+ entry4.parentNode.removeChild(entry4);
56430
+ removed.add(entry4);
56260
56431
  continue;
56261
56432
  }
56262
56433
  if (edit.text !== void 0) {
56263
- entry3.textContent = edit.text;
56264
- entry3.setAttribute("EditDate", edit.date);
56434
+ entry4.textContent = edit.text;
56435
+ entry4.setAttribute("EditDate", edit.date);
56265
56436
  }
56266
- if (edit.done !== void 0) entry3.setAttribute("Done", edit.done ? "1" : "0");
56437
+ if (edit.done !== void 0) entry4.setAttribute("Done", edit.done ? "1" : "0");
56267
56438
  }
56268
56439
  const dirty = /* @__PURE__ */ new Map([[path3, root2]]);
56269
56440
  if (created) {
@@ -56726,9 +56897,21 @@ var ROLES = {
56726
56897
  "swimlane list": "swimlane-list",
56727
56898
  "phase list": "phase-list"
56728
56899
  };
56900
+ var CFF_AUTHORED_IDS = {
56901
+ frame: "{0F0C7A10-0001-0000-8E40-00608CF305B2}",
56902
+ "swimlane-list": "{0F0C7A10-0002-0000-8E40-00608CF305B2}",
56903
+ "phase-list": "{0F0C7A10-0003-0000-8E40-00608CF305B2}",
56904
+ lane: "{0F0C7A10-0004-0000-8E40-00608CF305B2}",
56905
+ separator: "{0F0C7A10-0005-0000-8E40-00608CF305B2}"
56906
+ };
56907
+ var AUTHORED_ROLES = new Map(
56908
+ Object.entries(CFF_AUTHORED_IDS).map(([role, id4]) => [id4, role])
56909
+ );
56729
56910
  var noCffMasters = {
56730
56911
  get: () => void 0,
56731
56912
  roleOf: () => void 0,
56913
+ authoredId: () => void 0,
56914
+ authoredPart: () => void 0,
56732
56915
  empty: true
56733
56916
  };
56734
56917
  async function loadCffMasters(pkg) {
@@ -56738,25 +56921,31 @@ async function loadCffMasters(pkg) {
56738
56921
  const list2 = await visioXml(pkg, mastersPart, "Masters");
56739
56922
  const shapes = /* @__PURE__ */ new Map();
56740
56923
  const roles = /* @__PURE__ */ new Map();
56924
+ const authored = /* @__PURE__ */ new Map();
56741
56925
  for (const master2 of children2(list2, "Master")) {
56742
56926
  const id4 = attribute2(master2, "ID");
56743
56927
  const role = ROLES[(attribute2(master2, "NameU") ?? attribute2(master2, "Name") ?? "").toLowerCase()];
56744
- if (!id4 || !role) continue;
56745
- const root2 = await visioXml(
56746
- pkg,
56747
- await indexedPart(pkg, mastersPart, master2, "master"),
56748
- "MasterContents"
56749
- );
56928
+ if (!id4) continue;
56929
+ const own = AUTHORED_ROLES.get((attribute2(master2, "UniqueID") ?? "").toUpperCase());
56930
+ if (!role && !own) continue;
56931
+ const part = await indexedPart(pkg, mastersPart, master2, "master");
56932
+ if (own) {
56933
+ authored.set(own, { id: id4, part });
56934
+ continue;
56935
+ }
56936
+ const root2 = await visioXml(pkg, part, "MasterContents");
56750
56937
  const top = children2(children2(root2, "Shapes")[0], "Shape");
56751
56938
  if (top.length !== 1) continue;
56752
56939
  shapes.set(id4, top[0]);
56753
56940
  roles.set(id4, role);
56754
56941
  }
56755
- if (!shapes.size) return noCffMasters;
56942
+ if (!shapes.size && !authored.size) return noCffMasters;
56756
56943
  return {
56757
56944
  get: (id4) => shapes.get(id4),
56758
56945
  roleOf: (id4) => id4 ? roles.get(id4) : void 0,
56759
- empty: false
56946
+ authoredId: (role) => authored.get(role)?.id,
56947
+ authoredPart: (role) => authored.get(role)?.part,
56948
+ empty: !shapes.size
56760
56949
  };
56761
56950
  }
56762
56951
 
@@ -56779,10 +56968,10 @@ function turnSwimlanes(from, frame, showTitle, lanes) {
56779
56968
  box: horizontal2 ? { minX: 0, maxX: size3, minY: 0, maxY: cross } : { minX: 0, maxX: cross, minY: 0, maxY: size3 }
56780
56969
  }))
56781
56970
  );
56782
- const turned = stacking.lanes.map((entry3, index3) => ({
56783
- id: entry3.id,
56971
+ const turned = stacking.lanes.map((entry4, index3) => ({
56972
+ id: entry4.id,
56784
56973
  from: lanes[index3].box,
56785
- to: entry3.target
56974
+ to: entry4.target
56786
56975
  }));
56787
56976
  return {
56788
56977
  direction: direction2,
@@ -56933,10 +57122,10 @@ function createLaneShape(root2, document, id4, frame, heading, direction2, rotat
56933
57122
  return shape;
56934
57123
  }
56935
57124
  var swimlane_level = (kind) => kind === "swimlane" ? -30080 : -30020;
56936
- function createListShape(root2, document, id4, area2, kind, direction2, style3) {
57125
+ function createListShape(root2, document, id4, area3, kind, direction2, style3) {
56937
57126
  const shape = createShape(root2, id4);
56938
57127
  applyShapeCreationStyles(shape, document);
56939
- placeBox(shape, area2);
57128
+ placeBox(shape, area3);
56940
57129
  setCell(shape, "LinePattern", 0);
56941
57130
  setCell(shape, "FillPattern", 0);
56942
57131
  setCell(shape, "ObjType", 4);
@@ -57384,13 +57573,13 @@ function ensureLists(scope, frame, ids = {}) {
57384
57573
  const options2 = optionsOf(frame);
57385
57574
  const lanes = lanesOf(scope, frame, options2.direction);
57386
57575
  const bars = separatorsOf(scope, frame);
57387
- const area2 = boundsOf(lanes) ?? boundsOf([frame]);
57576
+ const area3 = boundsOf(lanes) ?? boundsOf([frame]);
57388
57577
  const fresh = freeShapeIds(scope.root, 2);
57389
57578
  const box5 = {
57390
- x: (area2.minX + area2.maxX) / 2,
57391
- y: (area2.minY + area2.maxY) / 2,
57392
- width: area2.maxX - area2.minX,
57393
- height: area2.maxY - area2.minY
57579
+ x: (area3.minX + area3.maxX) / 2,
57580
+ y: (area3.minY + area3.maxY) / 2,
57581
+ width: area3.maxX - area3.minX,
57582
+ height: area3.maxY - area3.minY
57394
57583
  };
57395
57584
  const horizontal2 = options2.direction === "horizontal";
57396
57585
  const make = (kind, id4) => {
@@ -57526,13 +57715,13 @@ function relayout(scope, frame, order) {
57526
57715
  const titleSize = native && options2.title && Number.isFinite(laneTop) ? Math.max(0, frameBox.maxY - laneTop) : void 0;
57527
57716
  const stacking = stackSwimlanes(options2.direction, frameBox, options2.title, boxes, titleSize);
57528
57717
  const carried = new Map(
57529
- stacking.lanes.map((entry3, index3) => [index3, [...containerClosure(scope.root, lanes[index3])]])
57718
+ stacking.lanes.map((entry4, index3) => [index3, [...containerClosure(scope.root, lanes[index3])]])
57530
57719
  );
57531
57720
  if (scope.contents === "move") for (const ids of carried.values()) assertMovable(scope.root, ids);
57532
- stacking.lanes.forEach((entry3, index3) => {
57721
+ stacking.lanes.forEach((entry4, index3) => {
57533
57722
  scope.check();
57534
- place(scope, lanes[index3], entry3.target);
57535
- if (scope.contents === "move") shift3(scope, carried.get(index3), entry3.dx, entry3.dy);
57723
+ place(scope, lanes[index3], entry4.target);
57724
+ if (scope.contents === "move") shift3(scope, carried.get(index3), entry4.dx, entry4.dy);
57536
57725
  });
57537
57726
  const bars = separatorsOf(scope, frame);
57538
57727
  for (const shape of bars) {
@@ -57547,13 +57736,13 @@ function relayout(scope, frame, order) {
57547
57736
  place(scope, frame, stacking.frame);
57548
57737
  setUserRow(frame, "numLanes", String(lanes.length), "");
57549
57738
  const { swim, phase } = listsOf(scope, frame);
57550
- const area2 = {
57739
+ const area3 = {
57551
57740
  minX: stacking.frame.minX,
57552
57741
  maxX: stacking.frame.maxX,
57553
57742
  maxY: stacking.top,
57554
57743
  minY: stacking.end
57555
57744
  };
57556
- for (const list2 of [swim, phase]) if (list2) place(scope, list2, area2);
57745
+ for (const list2 of [swim, phase]) if (list2) place(scope, list2, area3);
57557
57746
  if (swim) writeListMembers(scope.root, swim, lanes.map(shapeIdOf));
57558
57747
  if (phase)
57559
57748
  writeListMembers(scope.root, phase, orderSeparators(bars, options2.direction).map(shapeIdOf));
@@ -57627,17 +57816,17 @@ function turnFlowchart(scope, frame, direction2) {
57627
57816
  applyLaneLabel(lane, direction2, before.rotate);
57628
57817
  });
57629
57818
  const t = VISIO_SEPARATOR_THICKNESS;
57630
- const area2 = turn.stacking.frame;
57819
+ const area3 = turn.stacking.frame;
57631
57820
  bars.forEach((bar, index3) => {
57632
57821
  const at3 = turn.separator(barCentres[index3]);
57633
57822
  place(
57634
57823
  scope,
57635
57824
  bar,
57636
- direction2 === "horizontal" ? { minX: at3 - t / 2, maxX: at3 + t / 2, minY: turn.stacking.end, maxY: turn.stacking.top } : { minX: area2.minX, maxX: area2.maxX, minY: at3 - t / 2, maxY: at3 + t / 2 }
57825
+ direction2 === "horizontal" ? { minX: at3 - t / 2, maxX: at3 + t / 2, minY: turn.stacking.end, maxY: turn.stacking.top } : { minX: area3.minX, maxX: area3.maxX, minY: at3 - t / 2, maxY: at3 + t / 2 }
57637
57826
  );
57638
57827
  applySeparatorLabel(bar, direction2, before.separators);
57639
57828
  });
57640
- place(scope, frame, area2);
57829
+ place(scope, frame, area3);
57641
57830
  applyFrameTitle(frame, before.title);
57642
57831
  relayout(scope, frame);
57643
57832
  }
@@ -57798,12 +57987,12 @@ function insertSeparator(scope, edit) {
57798
57987
  const { phase } = ensureLists(scope, frame);
57799
57988
  const options2 = optionsOf(frame);
57800
57989
  const lanes = lanesOf(scope, frame, options2.direction);
57801
- const area2 = boundsOf(lanes);
57802
- if (!area2) fail("UNSUPPORTED_GEOMETRY_EDIT", "The flowchart has no lanes.");
57990
+ const area3 = boundsOf(lanes);
57991
+ if (!area3) fail("UNSUPPORTED_GEOMETRY_EDIT", "The flowchart has no lanes.");
57803
57992
  const horizontal2 = options2.direction === "horizontal";
57804
57993
  const thick = VISIO_SEPARATOR_THICKNESS;
57805
- const low = horizontal2 ? area2.minX : area2.minY;
57806
- const high = horizontal2 ? area2.maxX : area2.maxY;
57994
+ const low = horizontal2 ? area3.minX : area3.minY;
57995
+ const high = horizontal2 ? area3.maxX : area3.maxY;
57807
57996
  const at3 = Math.min(Math.max(edit.at ?? (low + high) / 2, low), high);
57808
57997
  const bar = createSeparatorShape(
57809
57998
  scope.root,
@@ -57811,13 +58000,13 @@ function insertSeparator(scope, edit) {
57811
58000
  edit.shapeId,
57812
58001
  horizontal2 ? {
57813
58002
  x: at3,
57814
- y: (area2.minY + area2.maxY) / 2,
58003
+ y: (area3.minY + area3.maxY) / 2,
57815
58004
  width: thick,
57816
- height: area2.maxY - area2.minY
58005
+ height: area3.maxY - area3.minY
57817
58006
  } : {
57818
- x: (area2.minX + area2.maxX) / 2,
58007
+ x: (area3.minX + area3.maxX) / 2,
57819
58008
  y: at3,
57820
- width: area2.maxX - area2.minX,
58009
+ width: area3.maxX - area3.minX,
57821
58010
  height: thick
57822
58011
  },
57823
58012
  options2.style,
@@ -57885,8 +58074,8 @@ function applySwimlaneEdit(roots, document, edit, check, instances = /* @__PURE_
57885
58074
  check();
57886
58075
  const root2 = roots.get(edit.pageId);
57887
58076
  if (!root2) fail("EDIT_TARGET_NOT_FOUND", "Page does not exist.");
57888
- const contents = "contents" in edit && edit.contents === "leave" ? "leave" : "move";
57889
- const scope = { roots, document, root: root2, pageId: edit.pageId, check, contents, masters };
58077
+ const contents2 = "contents" in edit && edit.contents === "leave" ? "leave" : "move";
58078
+ const scope = { roots, document, root: root2, pageId: edit.pageId, check, contents: contents2, masters };
57890
58079
  refuseBuiltByVisio(scope, edit);
57891
58080
  if (edit.type === "create-swimlanes") createSwimlanes(scope, edit);
57892
58081
  else if (edit.type === "insert-swimlane") insertSwimlane(scope, edit);
@@ -57896,6 +58085,251 @@ function applySwimlaneEdit(roots, document, edit, check, instances = /* @__PURE_
57896
58085
  else setOptions(scope, edit);
57897
58086
  }
57898
58087
 
58088
+ // visio/edit-swimlane-stamp.ts
58089
+ var MASTER_RELATIONSHIP4 = "http://schemas.microsoft.com/visio/2010/relationships/master";
58090
+ var CFF_ROLES = Object.keys(CFF_AUTHORED_IDS);
58091
+ function partOf(shape) {
58092
+ if (userValue(shape, VISIO_SWIMLANE_FRAME_ROW) === "1") return "frame";
58093
+ if (userValue(shape, VISIO_SWIMLANE_LANE_ROW) === "1") return "lane";
58094
+ if (userValue(shape, VISIO_SEPARATOR_ROW) === "1") return "separator";
58095
+ if (userValue(shape, "msvStructureType")?.toLowerCase() !== "list") return void 0;
58096
+ const kind = userValue(shape, "msvSDListRequiredCategories");
58097
+ return kind === "Swimlane" ? "swimlane-list" : kind === "Phase" ? "phase-list" : void 0;
58098
+ }
58099
+ function unstampCffMasters(root2, masters) {
58100
+ const ids = new Set(CFF_ROLES.map((role) => masters.authoredId(role)).filter(Boolean));
58101
+ if (!ids.size) return;
58102
+ for (const shape of topLevelShapes(root2))
58103
+ if (ids.has(attribute2(shape, "Master"))) shape.removeAttribute("Master");
58104
+ }
58105
+ function stampCffMasters(root2, masters) {
58106
+ const used = /* @__PURE__ */ new Set();
58107
+ for (const shape of topLevelShapes(root2)) {
58108
+ const id4 = attribute2(shape, "Master");
58109
+ const role = CFF_ROLES.find((item2) => masters.authoredId(item2) === id4);
58110
+ if (role && id4) used.add(role);
58111
+ }
58112
+ for (const shape of topLevelShapes(root2)) {
58113
+ if (attribute2(shape, "Master") || !shapeIdOf(shape)) continue;
58114
+ const role = partOf(shape);
58115
+ const id4 = role && masters.authoredId(role);
58116
+ if (!id4) continue;
58117
+ shape.setAttribute("Master", id4);
58118
+ used.add(role);
58119
+ }
58120
+ return used;
58121
+ }
58122
+ async function relateCffMasters(pkg, parts, pagePath, roles, masters) {
58123
+ const part = relationshipsPartFor(pagePath);
58124
+ const rels = parts.has(part) ? copy3(await pkg.readXml(part, "Relationships")) : parseXml(`<Relationships xmlns="${NS.rels}"/>`).documentElement;
58125
+ const existing = () => Array.from(rels.getElementsByTagNameNS(rels.namespaceURI, "Relationship"));
58126
+ let changed = false;
58127
+ for (const role of roles) {
58128
+ const target2 = masters.authoredPart(role);
58129
+ if (!target2) continue;
58130
+ const linked = existing().some(
58131
+ (rel) => rel.getAttribute("Type") === MASTER_RELATIONSHIP4 && rel.getAttribute("TargetMode") !== "External" && resolvePartPath(pagePath, rel.getAttribute("Target") ?? "") === target2
58132
+ );
58133
+ if (linked) continue;
58134
+ const ids = new Set(existing().map((rel) => rel.getAttribute("Id") ?? ""));
58135
+ let index3 = 1;
58136
+ while (ids.has(`rId${index3}`)) index3++;
58137
+ const relationship2 = rels.ownerDocument.createElementNS(rels.namespaceURI, "Relationship");
58138
+ relationship2.setAttribute("Id", `rId${index3}`);
58139
+ relationship2.setAttribute("Type", MASTER_RELATIONSHIP4);
58140
+ const from = pagePath.split("/").slice(0, -1);
58141
+ const to = target2.split("/");
58142
+ let shared = 0;
58143
+ while (shared < from.length && shared < to.length - 1 && from[shared] === to[shared]) shared++;
58144
+ relationship2.setAttribute(
58145
+ "Target",
58146
+ [...from.slice(shared).map(() => ".."), ...to.slice(shared)].join("/")
58147
+ );
58148
+ rels.appendChild(relationship2);
58149
+ changed = true;
58150
+ }
58151
+ return changed ? { part, rels } : void 0;
58152
+ }
58153
+
58154
+ // visio/cff-author.ts
58155
+ var MM = 1 / 25.4;
58156
+ var STENCIL = ["visMasterStencil", "xfunc_m.vss"];
58157
+ var VERSION = ["visVersion", "15", ""];
58158
+ var HIDDEN_LAYER = ["msvSDMembersOnHiddenLayer", "1", "BOOL"];
58159
+ var QUIET = [
58160
+ ["msvSDContainerNoHighlight", "1", "BOOL"],
58161
+ ["msvSDContainerNoRibbon", "1", "BOOL"]
58162
+ ];
58163
+ var ALL_PARTS = "CFF Container;CFF List;Swimlane;Phase;NonCFF";
58164
+ var DEFINITIONS = {
58165
+ frame: {
58166
+ name: "CFF Container",
58167
+ size: { width: 150 * MM, height: 100 * MM },
58168
+ rows: [
58169
+ ["msvShapeCategories", "CFF Container;DoNotContain"],
58170
+ ["msvStructureType", "Container"],
58171
+ ...QUIET,
58172
+ ["msvSDContainerRequiredCategories", "CFF List"],
58173
+ ["msvSDContainerExcludedCategories", ""],
58174
+ STENCIL,
58175
+ VERSION
58176
+ ]
58177
+ },
58178
+ "swimlane-list": {
58179
+ name: "Swimlane List",
58180
+ size: { width: 125 * MM, height: 100 * MM },
58181
+ rows: [
58182
+ ["msvStructureType", "List"],
58183
+ ["msvShapeCategories", "CFF List;DoNotContain"],
58184
+ ["msvSDListRequiredCategories", "Swimlane"],
58185
+ ["msvSDContainerExcludedCategories", "CFF Container;CFF List;Phase;NonCFF"],
58186
+ ...QUIET,
58187
+ ["msvSDListDirection", "2", ""],
58188
+ HIDDEN_LAYER,
58189
+ STENCIL,
58190
+ VERSION
58191
+ ]
58192
+ },
58193
+ "phase-list": {
58194
+ name: "Phase List",
58195
+ size: { width: 100 * MM, height: 150 * MM },
58196
+ rows: [
58197
+ ["msvStructureType", "List"],
58198
+ ["msvShapeCategories", "CFF List;DoNotContain"],
58199
+ ["msvSDContainerRequiredCategories", "Phase"],
58200
+ ["msvSDListRequiredCategories", "Phase"],
58201
+ ...QUIET,
58202
+ ["msvSDListDirection", "0", ""],
58203
+ HIDDEN_LAYER,
58204
+ STENCIL,
58205
+ VERSION
58206
+ ]
58207
+ },
58208
+ lane: {
58209
+ name: "Swimlane",
58210
+ size: { width: 125 * MM, height: 30 * MM },
58211
+ rows: [
58212
+ ["msvShapeCategories", "Swimlane;DoNotContain"],
58213
+ ["msvStructureType", "Container"],
58214
+ ["msvSDContainerNoRibbon", "1", "BOOL"],
58215
+ ["msvSDContainerExcludedCategories", ALL_PARTS],
58216
+ HIDDEN_LAYER,
58217
+ STENCIL,
58218
+ VERSION
58219
+ ]
58220
+ },
58221
+ separator: {
58222
+ name: "Separator",
58223
+ size: { width: 0.1, height: 100 * MM },
58224
+ rows: [
58225
+ ["msvStructureType", "Container"],
58226
+ ["msvShapeCategories", "Phase;DoNotContain"],
58227
+ ["msvSDContainerExcludedCategories", ALL_PARTS],
58228
+ ...QUIET,
58229
+ HIDDEN_LAYER,
58230
+ STENCIL,
58231
+ VERSION
58232
+ ]
58233
+ }
58234
+ };
58235
+ var CFF_ROLES2 = [
58236
+ "frame",
58237
+ "swimlane-list",
58238
+ "phase-list",
58239
+ "lane",
58240
+ "separator"
58241
+ ];
58242
+ var baseId = (uniqueId) => uniqueId.replace(/^\{[0-9A-F]{8}/, "{4F0C7A10");
58243
+ function entry3(role) {
58244
+ return (masters, id4, name3, relationshipId) => {
58245
+ const doc = masters.ownerDocument;
58246
+ const node3 = (parent, tag) => parent.appendChild(doc.createElementNS(masters.namespaceURI, tag));
58247
+ const master2 = node3(masters, "Master");
58248
+ const { size: size3 } = DEFINITIONS[role];
58249
+ for (const [attribute4, value3] of [
58250
+ ["ID", id4],
58251
+ ["NameU", name3],
58252
+ ["IsCustomNameU", "1"],
58253
+ ["Name", name3],
58254
+ ["IsCustomName", "1"],
58255
+ ["Prompt", ""],
58256
+ ["IconSize", "1"],
58257
+ ["AlignName", "2"],
58258
+ ["MatchByName", "0"],
58259
+ ["IconUpdate", "1"],
58260
+ ["UniqueID", CFF_AUTHORED_IDS[role]],
58261
+ ["BaseID", baseId(CFF_AUTHORED_IDS[role])],
58262
+ ["PatternFlags", "0"],
58263
+ ["Hidden", "1"],
58264
+ ["MasterType", "34"]
58265
+ ])
58266
+ master2.setAttribute(attribute4, value3);
58267
+ const sheet = node3(master2, "PageSheet");
58268
+ for (const style3 of ["LineStyle", "FillStyle", "TextStyle"]) sheet.setAttribute(style3, "0");
58269
+ for (const [cell, value3] of [
58270
+ ["PageWidth", size3.width],
58271
+ ["PageHeight", size3.height],
58272
+ ["PageScale", 1],
58273
+ ["DrawingScale", 1],
58274
+ ["DrawingSizeType", 4],
58275
+ ["DrawingScaleType", 0]
58276
+ ])
58277
+ setCell(sheet, cell, value3);
58278
+ node3(master2, "Rel").setAttributeNS(NS.r, "r:id", relationshipId);
58279
+ };
58280
+ }
58281
+ function contents(role) {
58282
+ return (document) => {
58283
+ const namespace = document.namespaceURI;
58284
+ const root2 = parseXml(`<MasterContents xmlns="${namespace}"/>`).documentElement;
58285
+ root2.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
58286
+ const doc = root2.ownerDocument;
58287
+ const shapes = root2.appendChild(doc.createElementNS(namespace, "Shapes"));
58288
+ const shape = shapes.appendChild(doc.createElementNS(namespace, "Shape"));
58289
+ shape.setAttribute("ID", "5");
58290
+ shape.setAttribute("Type", "Shape");
58291
+ applyShapeCreationStyles(shape, document);
58292
+ const { width, height } = DEFINITIONS[role].size;
58293
+ for (const [name3, value3, formula2] of [
58294
+ ["PinX", width / 2],
58295
+ ["PinY", height / 2],
58296
+ ["Width", width],
58297
+ ["Height", height],
58298
+ ["LocPinX", width / 2, "Width*0.5"],
58299
+ ["LocPinY", height / 2, "Height*0.5"],
58300
+ ["Angle", 0],
58301
+ ["FlipX", 0],
58302
+ ["FlipY", 0],
58303
+ ["ResizeMode", 0]
58304
+ ])
58305
+ setCell(shape, name3, value3, formula2);
58306
+ shape.appendChild(userSection(shape, DEFINITIONS[role].rows));
58307
+ return root2;
58308
+ };
58309
+ }
58310
+ async function ensureCffMasters(source, limits, maxOutput, deadline, check) {
58311
+ let bytes = source;
58312
+ const changedParts = /* @__PURE__ */ new Set();
58313
+ for (const role of CFF_ROLES2) {
58314
+ const added = await addMasterToDrawing(
58315
+ bytes,
58316
+ {
58317
+ uniqueId: CFF_AUTHORED_IDS[role],
58318
+ name: DEFINITIONS[role].name,
58319
+ entry: entry3(role),
58320
+ contents: contents(role)
58321
+ },
58322
+ limits,
58323
+ maxOutput,
58324
+ deadline,
58325
+ check
58326
+ );
58327
+ bytes = added.bytes;
58328
+ for (const part of added.changedParts) changedParts.add(part);
58329
+ }
58330
+ return { bytes, changedParts: [...changedParts] };
58331
+ }
58332
+
57899
58333
  // visio/edit-layers.ts
57900
58334
  var copy8 = (root2) => root2.ownerDocument.cloneNode(true).documentElement;
57901
58335
  var cellValue2 = (owner, name3) => attribute2(
@@ -58257,11 +58691,33 @@ async function editVsdx(input, edits, options2 = {}) {
58257
58691
  ] : [],
58258
58692
  ...prepared2.templateConverted ? [{ code: "TEMPLATE_SAVED_AS_DRAWING", message: "The template was saved as a drawing." }] : []
58259
58693
  ];
58260
- const final = await editVisioPrepared(prepared2.bytes, snapshot2, options2, clock);
58694
+ const final = await editWithDeletionsLast(prepared2.bytes, snapshot2, options2, clock);
58261
58695
  return notes.length ? { ...final, diagnostics: [...notes, ...final.diagnostics] } : final;
58262
58696
  }
58697
+ async function editWithDeletionsLast(input, edits, options2, clock) {
58698
+ const deferred2 = edits.filter((edit) => edit.type === "delete-shape" && edit.deferred);
58699
+ if (!deferred2.length) return editVisioPrepared(input, edits, options2, clock);
58700
+ const rest = edits.filter((edit) => !deferred2.includes(edit));
58701
+ const first2 = rest.length ? await editVsdx(input, rest, options2) : { bytes: input, changedParts: [], diagnostics: [] };
58702
+ const plain3 = deferred2.map((edit) => ({ ...edit, deferred: false }));
58703
+ const second = await editVsdx(first2.bytes, plain3, options2);
58704
+ return {
58705
+ bytes: second.bytes,
58706
+ changedParts: [.../* @__PURE__ */ new Set([...first2.changedParts, ...second.changedParts])],
58707
+ diagnostics: [...first2.diagnostics, ...second.diagnostics]
58708
+ };
58709
+ }
58263
58710
  async function editVisioPrepared(input, edits, options2, clock) {
58264
- const edited = await editVsdxTransaction(input, edits, options2, clock);
58711
+ const limits = { ...DEFAULTS, ...options2.limits };
58712
+ const cff = edits.some((edit) => edit.type === "create-swimlanes") ? await ensureCffMasters(
58713
+ input,
58714
+ limits,
58715
+ positive2(options2.maxOutputBytes ?? limits.maxInputBytes),
58716
+ Date.now() + limits.maxRuntimeMs,
58717
+ () => void 0
58718
+ ) : void 0;
58719
+ const first2 = await editVsdxTransaction(cff?.bytes ?? input, edits, options2, clock);
58720
+ const edited = cff ? { ...first2, changedParts: [.../* @__PURE__ */ new Set([...cff.changedParts, ...first2.changedParts])] } : first2;
58265
58721
  const resized = await refreshTextSizes(clock.textSizes, edited, options2, clock.deadline);
58266
58722
  const result2 = await refreshLineJumpCaches(
58267
58723
  clock.jumpPages,
@@ -58448,7 +58904,7 @@ async function editVsdxTransaction(input, edits, options2, clock = {
58448
58904
  (command2) => command2.type !== "replace-plain-text" && command2.type !== "replace-text-ranges" && command2.type !== "insert-text-field" && command2.type !== "update-text-field" && command2.type !== "reorder-shape" && command2.type !== "duplicate-shapes" && command2.type !== "paste-shapes" && command2.type !== "change-shape" && command2.type !== "insert-picture" && !isVisioChartObjectEdit(command2) && command2.type !== "set-page-theme" && !isVisioMetadataEdit(command2) && command2.type !== "set-shape-data" && !isVisioControlEdit(command2) && !isVisioActionEdit(command2) && !isVisioGroupEdit(command2) && !isVisioDiagramPartEdit(command2) && !isVisioContainerEdit(command2) && !isVisioPictureEdit(command2) && !isVisioGuideEdit(command2) && !isVisioFormatEdit(command2)
58449
58905
  );
58450
58906
  let document;
58451
- const cffMasters = commands.some(isVisioSwimlaneEdit) ? await loadCffMasters(pkg) : noCffMasters;
58907
+ const cffMasters = await loadCffMasters(pkg);
58452
58908
  let masterMovePins = emptyMasterMoveProof();
58453
58909
  const instanceCommands = /* @__PURE__ */ new Set();
58454
58910
  let instanceDeletes = /* @__PURE__ */ new Set();
@@ -58458,7 +58914,9 @@ async function editVsdxTransaction(input, edits, options2, clock = {
58458
58914
  )) {
58459
58915
  for (const [pageId2, path4] of pages) {
58460
58916
  const sourceRoot = await visioXml(pkg, path4, "PageContents");
58461
- roots.set(pageId2, sourceRoot.ownerDocument.cloneNode(true).documentElement);
58917
+ const root2 = sourceRoot.ownerDocument.cloneNode(true).documentElement;
58918
+ unstampCffMasters(root2, cffMasters);
58919
+ roots.set(pageId2, root2);
58462
58920
  }
58463
58921
  for (const [pageId2, root2] of roots) {
58464
58922
  const ids = new Set(
@@ -58722,12 +59180,18 @@ async function editVsdxTransaction(input, edits, options2, clock = {
58722
59180
  for (const shapeId2 of takeDeferredTextSizes(root2)) clock.textSizes.push({ pageId: pageId2, shapeId: shapeId2 });
58723
59181
  let totalBytes = [...parts.values()].reduce((sum, bytes2) => sum + bytes2.length, 0);
58724
59182
  let nodes = 0;
59183
+ for (const [path3, root2] of [...dirty]) {
59184
+ if (![...pages.values()].includes(path3)) continue;
59185
+ const used = stampCffMasters(root2, cffMasters);
59186
+ const related2 = used.size ? await relateCffMasters(pkg, parts, path3, used, cffMasters) : void 0;
59187
+ if (related2) dirty.set(related2.part, related2.rels);
59188
+ }
58725
59189
  for (const [path3, root2] of dirty) {
58726
59190
  const serialized = serializeEditedXml(root2, limits, check);
58727
59191
  nodes += serialized.nodes;
58728
59192
  if (nodes > limits.maxTotalXmlNodes)
58729
59193
  fail("LIMIT_XML_TOTAL", "Edited XML node total exceeds limit.");
58730
- totalBytes += serialized.bytes.length - parts.get(path3).length;
59194
+ totalBytes += serialized.bytes.length - (parts.get(path3)?.length ?? 0);
58731
59195
  if (totalBytes > limits.maxTotalBytes)
58732
59196
  fail("LIMIT_TOTAL", "Edited package total exceeds limit.");
58733
59197
  parts.set(path3, serialized.bytes);
@@ -58743,7 +59207,8 @@ async function editVsdxTransaction(input, edits, options2, clock = {
58743
59207
  { ...limits, maxInputBytes: maxOutput, maxRuntimeMs: Math.max(1, deadline - Date.now()) },
58744
59208
  check
58745
59209
  );
58746
- for (const path3 of dirty.keys()) await visioXml(verified.pkg, path3, "PageContents");
59210
+ for (const path3 of dirty.keys())
59211
+ if (!path3.endsWith(".rels")) await visioXml(verified.pkg, path3, "PageContents");
58747
59212
  check();
58748
59213
  }
58749
59214
  return {
@@ -59009,6 +59474,303 @@ async function createVsdx(options2 = {}) {
59009
59474
  return writeEditedPackage(parts, DEFAULTS.maxInputBytes, deadline, check);
59010
59475
  }
59011
59476
 
59477
+ // visio/path-segments.ts
59478
+ var MAX_PATH_CHARS = 2e6;
59479
+ var MAX_PATH_SEGMENTS = 2e5;
59480
+ var COUNTS = {
59481
+ m: 2,
59482
+ l: 2,
59483
+ h: 1,
59484
+ v: 1,
59485
+ c: 6,
59486
+ s: 4,
59487
+ q: 4,
59488
+ t: 2,
59489
+ a: 7,
59490
+ z: 0
59491
+ };
59492
+ function parsePath(d) {
59493
+ if (d.length > MAX_PATH_CHARS) return void 0;
59494
+ const tokens3 = d.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/g);
59495
+ if (!tokens3) return [];
59496
+ const out = [];
59497
+ let x = 0, y = 0, startX = 0, startY = 0, lastC, lastQ;
59498
+ let command2 = "";
59499
+ let index3 = 0;
59500
+ const read = () => Number(tokens3[index3++]);
59501
+ while (index3 < tokens3.length) {
59502
+ if (out.length > MAX_PATH_SEGMENTS) return void 0;
59503
+ const token = tokens3[index3];
59504
+ if (/[a-zA-Z]/.test(token)) {
59505
+ command2 = token;
59506
+ index3++;
59507
+ } else if (!command2) return void 0;
59508
+ else if (command2 === "M") command2 = "L";
59509
+ else if (command2 === "m") command2 = "l";
59510
+ const lower3 = command2.toLowerCase();
59511
+ const need = COUNTS[lower3];
59512
+ if (need === void 0) return void 0;
59513
+ if (index3 + need > tokens3.length) return void 0;
59514
+ const relative = command2 === lower3;
59515
+ const ox = relative ? x : 0, oy = relative ? y : 0;
59516
+ let nextC, nextQ;
59517
+ switch (lower3) {
59518
+ case "m":
59519
+ x = ox + read();
59520
+ y = oy + read();
59521
+ startX = x;
59522
+ startY = y;
59523
+ out.push({ t: "M", x, y });
59524
+ break;
59525
+ case "l":
59526
+ x = ox + read();
59527
+ y = oy + read();
59528
+ out.push({ t: "L", x, y });
59529
+ break;
59530
+ case "h":
59531
+ x = (relative ? x : 0) + read();
59532
+ out.push({ t: "L", x, y });
59533
+ break;
59534
+ case "v":
59535
+ y = (relative ? y : 0) + read();
59536
+ out.push({ t: "L", x, y });
59537
+ break;
59538
+ case "c": {
59539
+ const x1 = ox + read(), y1 = oy + read(), x2 = ox + read(), y2 = oy + read();
59540
+ out.push({ t: "C", x1, y1, x2, y2, x: x = ox + read(), y: y = oy + read() });
59541
+ nextC = [x2, y2];
59542
+ break;
59543
+ }
59544
+ case "s": {
59545
+ const x1 = lastC ? 2 * x - lastC[0] : x, y1 = lastC ? 2 * y - lastC[1] : y;
59546
+ const x2 = ox + read(), y2 = oy + read();
59547
+ out.push({ t: "C", x1, y1, x2, y2, x: x = ox + read(), y: y = oy + read() });
59548
+ nextC = [x2, y2];
59549
+ break;
59550
+ }
59551
+ case "q":
59552
+ case "t": {
59553
+ let qx, qy;
59554
+ if (lower3 === "q") {
59555
+ qx = ox + read();
59556
+ qy = oy + read();
59557
+ } else {
59558
+ qx = lastQ ? 2 * x - lastQ[0] : x;
59559
+ qy = lastQ ? 2 * y - lastQ[1] : y;
59560
+ }
59561
+ const ex = ox + read(), ey = oy + read();
59562
+ out.push({
59563
+ t: "C",
59564
+ x1: x + 2 / 3 * (qx - x),
59565
+ y1: y + 2 / 3 * (qy - y),
59566
+ x2: ex + 2 / 3 * (qx - ex),
59567
+ y2: ey + 2 / 3 * (qy - ey),
59568
+ x: ex,
59569
+ y: ey
59570
+ });
59571
+ x = ex;
59572
+ y = ey;
59573
+ nextQ = [qx, qy];
59574
+ break;
59575
+ }
59576
+ case "a": {
59577
+ const rx = read(), ry = read(), rotation = read(), large = read(), sweep = read();
59578
+ const ex = ox + read(), ey = oy + read();
59579
+ arc3(out, x, y, rx, ry, rotation, large !== 0, sweep !== 0, ex, ey);
59580
+ x = ex;
59581
+ y = ey;
59582
+ break;
59583
+ }
59584
+ case "z":
59585
+ out.push({ t: "Z" });
59586
+ x = startX;
59587
+ y = startY;
59588
+ break;
59589
+ }
59590
+ lastC = nextC;
59591
+ lastQ = nextQ;
59592
+ if (lower3 === "z") command2 = "";
59593
+ }
59594
+ return out;
59595
+ }
59596
+ function arc3(out, x0, y0, rxIn, ryIn, degrees, large, sweep, x, y) {
59597
+ let rx = Math.abs(rxIn), ry = Math.abs(ryIn);
59598
+ if (x0 === x && y0 === y || rx === 0 || ry === 0) {
59599
+ out.push({ t: "L", x, y });
59600
+ return;
59601
+ }
59602
+ const phi = degrees * Math.PI / 180, cos = Math.cos(phi), sin = Math.sin(phi);
59603
+ const dx = (x0 - x) / 2, dy = (y0 - y) / 2;
59604
+ const x1 = cos * dx + sin * dy, y1 = -sin * dx + cos * dy;
59605
+ const lambda = x1 * x1 / (rx * rx) + y1 * y1 / (ry * ry);
59606
+ if (lambda > 1) {
59607
+ rx *= Math.sqrt(lambda);
59608
+ ry *= Math.sqrt(lambda);
59609
+ }
59610
+ const numerator = rx * rx * ry * ry - rx * rx * y1 * y1 - ry * ry * x1 * x1;
59611
+ const denominator = rx * rx * y1 * y1 + ry * ry * x1 * x1;
59612
+ const factor = (large === sweep ? -1 : 1) * Math.sqrt(Math.max(0, numerator / (denominator || 1)));
59613
+ const cx1 = factor * rx * y1 / ry, cy1 = -factor * ry * x1 / rx;
59614
+ const cx = cos * cx1 - sin * cy1 + (x0 + x) / 2, cy = sin * cx1 + cos * cy1 + (y0 + y) / 2;
59615
+ const angle = (ux, uy, vx, vy) => Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
59616
+ const start = angle(1, 0, (x1 - cx1) / rx, (y1 - cy1) / ry);
59617
+ let delta = angle((x1 - cx1) / rx, (y1 - cy1) / ry, (-x1 - cx1) / rx, (-y1 - cy1) / ry);
59618
+ if (!sweep && delta > 0) delta -= 2 * Math.PI;
59619
+ else if (sweep && delta < 0) delta += 2 * Math.PI;
59620
+ const pieces = Math.max(1, Math.ceil(Math.abs(delta) / (Math.PI / 2) - 1e-9));
59621
+ const step2 = delta / pieces;
59622
+ const k = 4 / 3 * Math.tan(step2 / 4);
59623
+ const point2 = (t) => {
59624
+ const c2 = Math.cos(t), s = Math.sin(t);
59625
+ return [
59626
+ cx + rx * c2 * cos - ry * s * sin,
59627
+ cy + rx * c2 * sin + ry * s * cos,
59628
+ -rx * s * cos - ry * c2 * sin,
59629
+ -rx * s * sin + ry * c2 * cos
59630
+ ];
59631
+ };
59632
+ for (let piece = 0; piece < pieces; piece++) {
59633
+ const a2 = start + piece * step2, b = a2 + step2;
59634
+ const [px, py, dpx, dpy] = point2(a2);
59635
+ const [qx, qy, dqx, dqy] = point2(b);
59636
+ out.push({
59637
+ t: "C",
59638
+ x1: px + k * dpx,
59639
+ y1: py + k * dpy,
59640
+ x2: qx - k * dqx,
59641
+ y2: qy - k * dqy,
59642
+ x: piece === pieces - 1 ? x : qx,
59643
+ y: piece === pieces - 1 ? y : qy
59644
+ });
59645
+ }
59646
+ }
59647
+
59648
+ // visio/solid-3d.ts
59649
+ var VISIO_PERSPECTIVE_LIMIT = 120 * Math.PI / 180;
59650
+ var VISIO_CAMERA_INCHES = 6.36;
59651
+ var CURVE_STEPS = 12;
59652
+ function createProjection(turn, centre, unit4 = 1) {
59653
+ const [ca, sa] = [Math.cos(turn.x), Math.sin(turn.x)];
59654
+ const [cb, sb] = [Math.cos(turn.y), Math.sin(turn.y)];
59655
+ const [cc, sc] = [Math.cos(turn.z), Math.sin(turn.z)];
59656
+ const fov = Math.min(Math.max(turn.perspective, 0), VISIO_PERSPECTIVE_LIMIT);
59657
+ const camera = fov > 1e-3 ? VISIO_CAMERA_INCHES / Math.tan(fov / 2) / (unit4 || 1) : void 0;
59658
+ const turned = (x, y, z) => {
59659
+ const x1 = x * ca - z * sa;
59660
+ const z1 = x * sa + z * ca;
59661
+ return { x: x1, y: y * cb - z1 * sb, z: y * sb + z1 * cb };
59662
+ };
59663
+ return {
59664
+ point(x, y, z = 0) {
59665
+ const t = turned(x - centre.x, y - centre.y, z);
59666
+ const scale = camera === void 0 ? 1 : camera / Math.max(camera - t.z, camera * 0.05);
59667
+ const [px, py] = [t.x * scale, t.y * scale];
59668
+ return { x: centre.x + cc * px - sc * py, y: centre.y + sc * px + cc * py };
59669
+ },
59670
+ depth: (x, y, z = 0) => turned(x - centre.x, y - centre.y, z).z,
59671
+ direction(x, y) {
59672
+ const t = turned(x, y, 0);
59673
+ return { x: cc * t.x - sc * t.y, y: sc * t.x + cc * t.y, toward: t.z };
59674
+ }
59675
+ };
59676
+ }
59677
+ function flattenPath(d) {
59678
+ const segments = parsePath(d);
59679
+ if (!segments) return void 0;
59680
+ const result2 = [];
59681
+ let current;
59682
+ for (const segment of segments) {
59683
+ if (segment.t === "M") {
59684
+ current = { points: [{ x: segment.x, y: segment.y }], closed: false };
59685
+ result2.push(current);
59686
+ } else if (!current) return void 0;
59687
+ else if (segment.t === "L") current.points.push({ x: segment.x, y: segment.y });
59688
+ else if (segment.t === "Z") {
59689
+ current.closed = true;
59690
+ const first2 = current.points[0];
59691
+ current = { points: [first2], closed: false };
59692
+ result2.push(current);
59693
+ } else {
59694
+ const from = current.points[current.points.length - 1];
59695
+ for (let step2 = 1; step2 <= CURVE_STEPS; step2++) {
59696
+ const t = step2 / CURVE_STEPS;
59697
+ const u = 1 - t;
59698
+ const [a2, b, c2, e] = [u * u * u, 3 * u * u * t, 3 * u * t * t, t * t * t];
59699
+ current.points.push({
59700
+ x: a2 * from.x + b * segment.x1 + c2 * segment.x2 + e * segment.x,
59701
+ y: a2 * from.y + b * segment.y1 + c2 * segment.y2 + e * segment.y
59702
+ });
59703
+ }
59704
+ }
59705
+ }
59706
+ for (const sub of result2) {
59707
+ const [first2, last] = [sub.points[0], sub.points[sub.points.length - 1]];
59708
+ if (sub.points.length > 3 && Math.abs(first2.x - last.x) < 1e-9 && Math.abs(first2.y - last.y) < 1e-9)
59709
+ sub.closed = true;
59710
+ }
59711
+ return result2.filter((sub) => sub.closed || sub.points.length > 1);
59712
+ }
59713
+ var fixed = (value3) => String(Math.round(value3 * 1e5) / 1e5);
59714
+ var polygonData = (points, closed) => `${points.map((p, i) => `${i ? "L" : "M"} ${fixed(p.x)} ${fixed(p.y)}`).join(" ")}${closed ? " Z" : ""}`;
59715
+ function projectPathData(d, projection) {
59716
+ const subpaths = flattenPath(d);
59717
+ if (!subpaths) return void 0;
59718
+ return subpaths.map(
59719
+ (sub) => polygonData(
59720
+ sub.points.map((p) => projection.point(p.x, p.y)),
59721
+ sub.closed
59722
+ )
59723
+ ).join(" ");
59724
+ }
59725
+ var area2 = (points) => {
59726
+ let sum = 0;
59727
+ for (let i = 0; i < points.length; i++) {
59728
+ const [p, q] = [points[i], points[(i + 1) % points.length]];
59729
+ sum += p.x * q.y - q.x * p.y;
59730
+ }
59731
+ return sum / 2;
59732
+ };
59733
+ function extrudePaths(paths, projection, depth) {
59734
+ const back = [];
59735
+ const sides = [];
59736
+ for (const d of paths) {
59737
+ const subpaths = flattenPath(d);
59738
+ if (!subpaths) return void 0;
59739
+ for (const sub of subpaths) {
59740
+ const points = [...sub.points];
59741
+ if (!sub.closed || points.length < 3) continue;
59742
+ const first2 = points[0];
59743
+ const last = points[points.length - 1];
59744
+ if (Math.abs(first2.x - last.x) < 1e-9 && Math.abs(first2.y - last.y) < 1e-9) points.pop();
59745
+ const turnSign = area2(points) >= 0 ? 1 : -1;
59746
+ back.push(points.map((p) => projection.point(p.x, p.y, -depth)));
59747
+ for (let i = 0; i < points.length; i++) {
59748
+ const [p, q] = [points[i], points[(i + 1) % points.length]];
59749
+ const [dx, dy] = [q.x - p.x, q.y - p.y];
59750
+ const length = Math.hypot(dx, dy);
59751
+ if (length < 1e-9) continue;
59752
+ const normal3 = projection.direction(turnSign * dy / length, -turnSign * dx / length);
59753
+ if (normal3.toward <= 1e-6) continue;
59754
+ const screen = Math.hypot(normal3.x, normal3.y) || 1;
59755
+ const shade = 0.9 - 0.18 * (normal3.y / screen) - 0.7 * Math.max(0, normal3.x / screen);
59756
+ sides.push({
59757
+ points: [
59758
+ projection.point(p.x, p.y),
59759
+ projection.point(q.x, q.y),
59760
+ projection.point(q.x, q.y, -depth),
59761
+ projection.point(p.x, p.y, -depth)
59762
+ ],
59763
+ shade: Math.max(0.1, shade),
59764
+ depth: projection.depth((p.x + q.x) / 2, (p.y + q.y) / 2, -depth / 2)
59765
+ });
59766
+ }
59767
+ }
59768
+ }
59769
+ sides.sort((a2, b) => a2.depth - b.depth);
59770
+ return { back, sides };
59771
+ }
59772
+ var extrusionPathData = (polygons) => polygons.map((points) => polygonData(points, true)).join(" ");
59773
+
59012
59774
  // visio/open-arrow.ts
59013
59775
  function visioOpenArrowExtent(size3, lineWidth) {
59014
59776
  const index3 = Number.isFinite(size3) ? Math.max(0, Math.min(6, Math.trunc(size3))) : 2;
@@ -59251,4 +60013,4 @@ function visioTabStarts(segments, tabs = [], origin = 0, start = 0, spacing2 = V
59251
60013
  return starts;
59252
60014
  }
59253
60015
 
59254
- export { EmfBitmapError, VISIO_ARROW_SHAPES, VISIO_BACKGROUND_STYLES, VISIO_BASIC_SHAPES, VISIO_BASIC_STENCIL, VISIO_BEVEL_PRESETS, VISIO_BEVEL_TYPES_INSET, VISIO_BEVEL_TYPES_SHARP, VISIO_BORDER_STYLES, VISIO_BUILT_IN_STENCILS, VISIO_BUILT_IN_THEMES, VISIO_BUILT_IN_THEME_IDS, VISIO_CALLOUT_STYLES, VISIO_CHART_OBJECT_MAX_BYTES, VISIO_CLIPBOARD_MAGIC, VISIO_CLIPBOARD_MAX_CHARS, VISIO_COMMENT_AUTHOR_LIMIT, VISIO_COMMENT_LIMIT, VISIO_COMMENT_TEXT_LIMIT, VISIO_CONNECTOR_ROUTES, VISIO_CONTAINER_HEADING, VISIO_CONTAINER_MARGIN, VISIO_CONTAINER_STYLES, VISIO_DATA_LIMITS, VISIO_DEFAULT_TAB_SPACING, VISIO_EMF_ADMISSION_LIMITS, VISIO_FIELD_FORMATS, VISIO_FIELD_FUNCTIONS, VISIO_FLOWCHART_SHAPES, VISIO_FOREIGN_VECTOR_LIMITS, VISIO_GLOW_SIZES, VISIO_GLOW_TRANSPARENCY, VISIO_GLUE, VISIO_GRID_DENSITIES, VISIO_LAYER_NAME_LIMIT, VISIO_LINE_JUMP_LIMITS, VISIO_LINE_JUMP_WIDTH, VISIO_MANAGED_BACKGROUND, VISIO_METADATA_TEXT_LIMIT, VISIO_PAGE_LAYOUT_DEFAULTS, VISIO_PATH_SEGMENT_LIMIT, VISIO_PICTURE_MAX_BYTES, VISIO_PRINT_COUNT_LIMITS, VISIO_QUICK_STYLE_COLORS, VISIO_QUICK_STYLE_VARIANT_COLORS, VISIO_RASTER_IMAGE_LIMITS, VISIO_REFLECTION_PRESETS, VISIO_ROTATION_PRESETS, VISIO_RULER_DENSITIES, VISIO_SCALE_UNITS, VISIO_SHADOW_PRESETS, VISIO_SHAPE_DATA_TYPES, VISIO_SNAP, VISIO_SNAP_GLUE_DEFAULTS, VISIO_SOFT_EDGE_SIZES, VISIO_STENCILS, VISIO_STENCIL_FILES, VISIO_SWIMLANE_HEADER, VISIO_SWIMLANE_MIN, VISIO_SWIMLANE_STYLES, VISIO_SWIMLANE_TITLE, VISIO_TEXT_CASES, VISIO_TEXT_POSITIONS, VISIO_THEME_COLOR_SLOTS, VISIO_UNTHEMED_COLORS, VISIO_VISIBILITY_LIMITS, VisioForeignVectorError, VisioFormulaError, VisioImageError, VisioPackageError, analyzeVisioFormula, canonicalShapeDataValue, captureVisioClipboard, checkVisioAlternativeText, convertVisioMetafile, createVsdx, deserializeVisioClipboard, designTextMeasurer, editVsdx, encodeBitmapEmf, evaluateVisioFormula, evaluateVisioTextField, formatVisioFieldValue, getVisioPageLayers, inspectVisioEmfAdmission, inspectVisioRasterImage, isVisioBasicShape, isVisioBuiltInThemeId, isVisioChangeShapeTarget, isVisioDiagramPartEdit, isVisioLayerName, isVisioOutlineShape, isVisioQuickStyleColor, isVisioShadowPreset, isVisioStencilShape, isVisioThemeColorRef, layoutVisioFilledArrowLine, loadVisio, matchRefreshedRows, mergeVisioPages, parseLegacyVsd, parseVisioFormula, parseVisioThemeColorFormula, parseVsdx, parseVsdxPages, readVisioStencil, resolveVisioPageVisibility, resolveVisioThemeColor, rewriteControlFormula, sanitizeVisioForeignVectorTree, serializeVisioClipboard, setVisioTextMeasurer, trimVisioArrowLine, validateVisioForeignVector, visioBackgroundShapes, visioBasicShapeOutline, visioBorderShapes, visioBuiltInMaster, visioBuiltInStencil, visioBuiltInTheme, visioCircleThrough, visioCurvedRoute, visioDataConnectionFor, visioDecorationName, visioFallbackQuickStyle, visioFilledArrow, visioFitFreeform, visioFitPencil, visioFontAssumed, visioFormulaCachedValue, visioLineJumpPaths, visioLinkedRowNames, visioOpenArrowExtent, visioOpenArrowPath, visioOrthogonalRoute, visioOutlineShape, visioPageLayout, visioPageThemeColors, visioPathBounds, visioPathSamples, visioPrintTileCount, visioQuarterArc, visioRefreshReport, visioRotation3dMatrix, visioShade, visioShadowPresetGeometry, visioShapeDataRowName, visioShapeStructure, visioSimplifyPath, visioSnapGlue, visioStencilMaster, visioStencilShapeOutline, visioTabStarts, visioTextExtents, visioThemeColorFormula, visioThemeVariantColors, visioThemeXml };
60016
+ export { EmfBitmapError, MAX_PATH_CHARS, MAX_PATH_SEGMENTS, VISIO_ARROW_SHAPES, VISIO_BACKGROUND_STYLES, VISIO_BASIC_SHAPES, VISIO_BASIC_STENCIL, VISIO_BEVEL_PRESETS, VISIO_BEVEL_TYPES_INSET, VISIO_BEVEL_TYPES_SHARP, VISIO_BORDER_STYLES, VISIO_BUILT_IN_STENCILS, VISIO_BUILT_IN_THEMES, VISIO_BUILT_IN_THEME_IDS, VISIO_CALLOUT_STYLES, VISIO_CHART_OBJECT_MAX_BYTES, VISIO_CLIPBOARD_MAGIC, VISIO_CLIPBOARD_MAX_CHARS, VISIO_COMMENT_AUTHOR_LIMIT, VISIO_COMMENT_LIMIT, VISIO_COMMENT_TEXT_LIMIT, VISIO_CONNECTOR_ROUTES, VISIO_CONTAINER_HEADING, VISIO_CONTAINER_MARGIN, VISIO_CONTAINER_STYLES, VISIO_DATA_LIMITS, VISIO_DEFAULT_TAB_SPACING, VISIO_EMF_ADMISSION_LIMITS, VISIO_FIELD_FORMATS, VISIO_FIELD_FUNCTIONS, VISIO_FLOWCHART_SHAPES, VISIO_FOREIGN_VECTOR_LIMITS, VISIO_GLOW_SIZES, VISIO_GLOW_TRANSPARENCY, VISIO_GLUE, VISIO_GRID_DENSITIES, VISIO_LAYER_NAME_LIMIT, VISIO_LINE_JUMP_LIMITS, VISIO_LINE_JUMP_WIDTH, VISIO_MANAGED_BACKGROUND, VISIO_METADATA_TEXT_LIMIT, VISIO_PAGE_LAYOUT_DEFAULTS, VISIO_PATH_SEGMENT_LIMIT, VISIO_PICTURE_MAX_BYTES, VISIO_PRINT_COUNT_LIMITS, VISIO_QUICK_STYLE_COLORS, VISIO_QUICK_STYLE_VARIANT_COLORS, VISIO_RASTER_IMAGE_LIMITS, VISIO_REFLECTION_PRESETS, VISIO_ROTATION_PRESETS, VISIO_RULER_DENSITIES, VISIO_SCALE_UNITS, VISIO_SHADOW_PRESETS, VISIO_SHAPE_DATA_TYPES, VISIO_SNAP, VISIO_SNAP_GLUE_DEFAULTS, VISIO_SOFT_EDGE_SIZES, VISIO_STENCILS, VISIO_STENCIL_FILES, VISIO_SWIMLANE_HEADER, VISIO_SWIMLANE_MIN, VISIO_SWIMLANE_STYLES, VISIO_SWIMLANE_TITLE, VISIO_TEXT_CASES, VISIO_TEXT_POSITIONS, VISIO_THEME_COLOR_SLOTS, VISIO_UNTHEMED_COLORS, VISIO_VISIBILITY_LIMITS, VisioForeignVectorError, VisioFormulaError, VisioImageError, VisioPackageError, analyzeVisioFormula, canonicalShapeDataValue, captureVisioClipboard, checkVisioAlternativeText, convertVisioMetafile, createProjection, createVsdx, deserializeVisioClipboard, designTextMeasurer, editVsdx, encodeBitmapEmf, evaluateVisioFormula, evaluateVisioTextField, extrudePaths, extrusionPathData, flattenPath, formatVisioFieldValue, getVisioPageLayers, inspectVisioEmfAdmission, inspectVisioRasterImage, isVisioBasicShape, isVisioBuiltInThemeId, isVisioChangeShapeTarget, isVisioDiagramPartEdit, isVisioLayerName, isVisioOutlineShape, isVisioQuickStyleColor, isVisioShadowPreset, isVisioStencilShape, isVisioThemeColorRef, layoutVisioFilledArrowLine, loadVisio, matchRefreshedRows, mergeVisioPages, parseLegacyVsd, parsePath, parseVisioFormula, parseVisioThemeColorFormula, parseVsdx, parseVsdxPages, projectPathData, readVisioStencil, resolveVisioPageVisibility, resolveVisioThemeColor, rewriteControlFormula, sanitizeVisioForeignVectorTree, serializeVisioClipboard, setVisioTextMeasurer, trimVisioArrowLine, validateVisioForeignVector, visioBackgroundShapes, visioBasicShapeOutline, visioBorderShapes, visioBuiltInMaster, visioBuiltInStencil, visioBuiltInTheme, visioCircleThrough, visioCurvedRoute, visioDataConnectionFor, visioDecorationName, visioFallbackQuickStyle, visioFilledArrow, visioFitFreeform, visioFitPencil, visioFontAssumed, visioFormulaCachedValue, visioLineJumpPaths, visioLinkedRowNames, visioOpenArrowExtent, visioOpenArrowPath, visioOrthogonalRoute, visioOutlineShape, visioPageLayout, visioPageThemeColors, visioPathBounds, visioPathSamples, visioPrintTileCount, visioQuarterArc, visioRefreshReport, visioRotation3dMatrix, visioShade, visioShadowPresetGeometry, visioShapeDataRowName, visioShapeStructure, visioSimplifyPath, visioSnapGlue, visioStencilMaster, visioStencilShapeOutline, visioTabStarts, visioTextExtents, visioThemeColorFormula, visioThemeVariantColors, visioThemeXml };