@office-open/core 0.10.1 → 0.10.3

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.
@@ -1,7 +1,7 @@
1
- import "./patch-DocIv0Sn.mjs";
1
+ import "./patch-DEPPafeB.mjs";
2
2
  import "./smartart-DCY-Vdv7.mjs";
3
3
  import "./chart-DwE8FCFk.mjs";
4
- import { d as parse$1, f as stringify$1 } from "./descriptor-BdWTH1vv.mjs";
4
+ import { d as stringify$1, u as parse$1 } from "./descriptor-DAER86Rt.mjs";
5
5
  import "./theme-CiNzdl-9.mjs";
6
6
  import { attr, attrMeasure, attrNum, element, escapeXml, findChild, js2xml, stringify, textOf, xml2js } from "@office-open/xml";
7
7
  import { AsyncZipDeflate, Zip, ZipPassThrough, strFromU8, strFromU8 as strFromU8$1, strToU8, unzipSync, unzipSync as unzipSync$1, zip, zipSync } from "fflate";
@@ -40,6 +40,69 @@ var Relationships = class {
40
40
  return p.join("");
41
41
  }
42
42
  };
43
+ /**
44
+ * Serialize a Relationships part only when it carries at least one
45
+ * relationship. Optional parts (fontTable, headers, footers, charts, drawings,
46
+ * worksheets, …) emit no .rels part when empty — Office strips empty rels
47
+ * shells when re-saving, so skipping them keeps generated packages free of
48
+ * redundant empty parts and matches Office's normalized output.
49
+ *
50
+ * Always-on parts (the package `_rels/.rels` and the main
51
+ * document/presentation/workbook parts) carry relationships by construction
52
+ * and must NOT use this gate.
53
+ */
54
+ function optionalRelsPart(rel, xmlDeclaration, path) {
55
+ return rel.relationshipCount > 0 ? {
56
+ data: xmlDeclaration + rel.serialize(),
57
+ path
58
+ } : void 0;
59
+ }
60
+ //#endregion
61
+ //#region src/opc/media.ts
62
+ /**
63
+ * Shared media collection for docx/pptx/xlsx. Generic over the package's entry
64
+ * type so each package keeps its own metadata while sharing the registration +
65
+ * dedup logic.
66
+ */
67
+ var Media = class {
68
+ map = /* @__PURE__ */ new Map();
69
+ counter = 0;
70
+ /**
71
+ * Register media, reusing the existing entry when the bytes already exist.
72
+ * Returns the canonical entry (shared across all identical references) —
73
+ * callers read `entry.fileName` for placeholders/relationship targets or use
74
+ * the whole entry (e.g. drawing XML). The `build` callback constructs the
75
+ * package-specific entry from the allocated file name.
76
+ *
77
+ * Pass `fileName` to pin the name (round-trip scenarios preserving a source
78
+ * file name); omit it to allocate the next sequential `imageN.ext`.
79
+ */
80
+ addMedia(data, type, build, fileName) {
81
+ const existingKey = this.findByContent(data);
82
+ if (existingKey) return this.map.get(existingKey);
83
+ const resolvedName = fileName ?? `image${++this.counter}.${type}`;
84
+ const entry = build(resolvedName);
85
+ this.map.set(resolvedName, entry);
86
+ return entry;
87
+ }
88
+ /** Find the key of an existing entry with byte-identical content. */
89
+ findByContent(data) {
90
+ for (const [key, entry] of this.map) {
91
+ const existing = entry.data;
92
+ if (existing.length !== data.length) continue;
93
+ let match = true;
94
+ for (let i = 0; i < existing.length; i++) if (existing[i] !== data[i]) {
95
+ match = false;
96
+ break;
97
+ }
98
+ if (match) return key;
99
+ }
100
+ }
101
+ /** All registered media entries. */
102
+ get array() {
103
+ return [...this.map.values()];
104
+ }
105
+ };
43
106
  //#endregion
44
107
  //#region src/opc/content-types.ts
45
108
  /**
@@ -2409,9 +2472,10 @@ const DOCX_PARTS = {
2409
2472
  },
2410
2473
  {
2411
2474
  path: "word/theme/theme1.xml",
2475
+ contentType: "application/vnd.openxmlformats-officedocument.theme+xml",
2412
2476
  presence: {
2413
2477
  kind: "conditional",
2414
- flag: "rawParts theme"
2478
+ flag: "freshCompile"
2415
2479
  }
2416
2480
  }
2417
2481
  ]
@@ -4207,7 +4271,7 @@ const extractBlipFillMedia = (fill, nameAllocator) => {
4207
4271
  /**
4208
4272
  * Builds a DrawingML fill XML string from a FillOptions config.
4209
4273
  */
4210
- const buildFill = (options) => {
4274
+ const buildFill = (options, embedPlaceholder) => {
4211
4275
  if (typeof options === "string") return createSolidFill({ value: options.replace("#", "") });
4212
4276
  switch (options.type) {
4213
4277
  case "solid": return createSolidFill(normalizeColor(options.color));
@@ -4227,11 +4291,12 @@ const buildFill = (options) => {
4227
4291
  });
4228
4292
  case "blip": {
4229
4293
  const fileName = `${uniqueId()}.${options.imageType}`;
4294
+ const embed = embedPlaceholder ?? `{${fileName}}`;
4230
4295
  const blipChildren = [];
4231
4296
  if (options.blipEffects) blipChildren.push(...createBlipEffects(options.blipEffects));
4232
4297
  const children = [element("a:blip", {
4233
4298
  cstate: "none",
4234
- "r:embed": `{${fileName}}`
4299
+ "r:embed": embed
4235
4300
  }, blipChildren.length > 0 ? blipChildren : void 0), createSourceRectangle(options.sourceRectangle)];
4236
4301
  if (options.tile) children.push(createTileInfo(options.tile));
4237
4302
  else children.push("<a:stretch><a:fillRect/></a:stretch>");
@@ -6769,14 +6834,17 @@ const scRgbColorDesc = {
6769
6834
  const SYSTEM_COLOR_VALUES = new Set(Object.values(SystemColor));
6770
6835
  const PRESET_COLOR_VALUES = new Set(Object.values(PresetColor));
6771
6836
  const SCHEME_COLOR_VALUES = new Set(Object.values(SchemeColor));
6772
- function getColorDescriptor(color) {
6773
- if ("hue" in color && "saturation" in color && "luminance" in color) return hslColorDesc;
6774
- if ("r" in color && "g" in color && "b" in color) return scRgbColorDesc;
6837
+ /** Stringify an EG_ColorChoice (direct color element, no `a:solidFill` wrapper).
6838
+ * Used for gradient stops, fg/bg clr, and effect colors. Replaces the former
6839
+ * `getColorDescriptor` which returned a polymorphic `CustomDescriptor<any>`. */
6840
+ function stringifyColorChoice(color, ctx) {
6841
+ if ("hue" in color) return stringify$1(hslColorDesc, color, ctx) ?? "";
6842
+ if ("r" in color) return stringify$1(scRgbColorDesc, color, ctx) ?? "";
6775
6843
  const colorValue = color.value;
6776
- if (SYSTEM_COLOR_VALUES.has(colorValue)) return systemColorDesc;
6777
- if (PRESET_COLOR_VALUES.has(colorValue)) return presetColorDesc;
6778
- if (SCHEME_COLOR_VALUES.has(colorValue)) return schemeColorDesc;
6779
- return rgbColorDesc;
6844
+ if (SYSTEM_COLOR_VALUES.has(colorValue)) return stringify$1(systemColorDesc, color, ctx) ?? "";
6845
+ if (PRESET_COLOR_VALUES.has(colorValue)) return stringify$1(presetColorDesc, color, ctx) ?? "";
6846
+ if (SCHEME_COLOR_VALUES.has(colorValue)) return stringify$1(schemeColorDesc, color, ctx) ?? "";
6847
+ return stringify$1(rgbColorDesc, color, ctx) ?? "";
6780
6848
  }
6781
6849
  /**
6782
6850
  * Parse an EG_ColorChoice from an element's direct children. Handles all six
@@ -6799,7 +6867,7 @@ function parseColorChoice(el, ctx) {
6799
6867
  const solidFillDesc = {
6800
6868
  kind: "custom",
6801
6869
  stringify(color, ctx) {
6802
- const inner = stringify$1(getColorDescriptor(color), color, ctx);
6870
+ const inner = stringifyColorChoice(color, ctx);
6803
6871
  if (!inner) return void 0;
6804
6872
  return `<a:solidFill>${inner}</a:solidFill>`;
6805
6873
  },
@@ -6808,1431 +6876,1465 @@ const solidFillDesc = {
6808
6876
  }
6809
6877
  };
6810
6878
  //#endregion
6811
- //#region src/drawingml/fill/fill-descriptors.ts
6879
+ //#region src/drawingml/blip/blip-descriptors.ts
6812
6880
  /**
6813
- * Fill descriptors for DrawingML EG_FillProperties.
6881
+ * Blip descriptor for DrawingML pictures.
6814
6882
  *
6815
6883
  * @module
6816
6884
  */
6817
- function stringifyRelativeRect(tag, rect) {
6818
- const parts = [];
6819
- if (rect.left) parts.push(`l="${escapeXml(rect.left)}"`);
6820
- if (rect.top) parts.push(`t="${escapeXml(rect.top)}"`);
6821
- if (rect.right) parts.push(`r="${escapeXml(rect.right)}"`);
6822
- if (rect.bottom) parts.push(`b="${escapeXml(rect.bottom)}"`);
6823
- return `<${tag}${parts.length ? " " + parts.join(" ") : ""}/>`;
6824
- }
6825
- function readRelativeRect(el) {
6826
- const result = {};
6827
- if (el.attributes?.["l"]) result.left = String(el.attributes["l"]);
6828
- if (el.attributes?.["t"]) result.top = String(el.attributes["t"]);
6829
- if (el.attributes?.["r"]) result.right = String(el.attributes["r"]);
6830
- if (el.attributes?.["b"]) result.bottom = String(el.attributes["b"]);
6831
- return result;
6832
- }
6833
- function stringifyShade(shade) {
6834
- if ("angle" in shade) {
6835
- const parts = [];
6836
- if (shade.angle !== void 0) parts.push(`ang="${shade.angle}"`);
6837
- if (shade.scaled !== void 0) parts.push(`scaled="${shade.scaled ? 1 : 0}"`);
6838
- return `<a:lin${parts.length ? " " + parts.join(" ") : ""}/>`;
6839
- }
6840
- const pathShade = shade;
6841
- const parts = [];
6842
- if (pathShade.path) parts.push(`path="${escapeXml(pathShade.path)}"`);
6843
- const attrStr = parts.length ? " " + parts.join(" ") : "";
6844
- if (pathShade.fillToRectangle) return `<a:path${attrStr}>${stringifyRelativeRect("a:fillToRect", pathShade.fillToRectangle)}</a:path>`;
6845
- return `<a:path${attrStr}/>`;
6846
- }
6847
- const gradientFillDesc = {
6885
+ const tileDesc = {
6848
6886
  kind: "custom",
6849
- stringify(opts, ctx) {
6850
- const parts = [];
6851
- const stopsXml = opts.stops.map((stop) => {
6852
- const colorXml = stringify$1(getColorDescriptor(stop.color), stop.color, ctx);
6853
- if (!colorXml) return `<a:gs pos="${stop.position}"/>`;
6854
- return `<a:gs pos="${stop.position}">${colorXml}</a:gs>`;
6855
- }).join("");
6856
- parts.push(`<a:gsLst>${stopsXml}</a:gsLst>`);
6857
- if (opts.shade) parts.push(stringifyShade(opts.shade));
6858
- if (opts.tileRectangle) parts.push(stringifyRelativeRect("a:tileRect", opts.tileRectangle));
6887
+ stringify(opts, _ctx) {
6859
6888
  const attrParts = [];
6860
- if (opts.flip) attrParts.push(`flip="${escapeXml(opts.flip)}"`);
6861
- if (opts.rotateWithShape !== void 0) attrParts.push(`rotWithShape="${opts.rotateWithShape ? 1 : 0}"`);
6862
- return `<a:gradFill${attrParts.length ? " " + attrParts.join(" ") : ""}>${parts.join("")}</a:gradFill>`;
6889
+ if (opts.tx !== void 0) attrParts.push(`tx="${opts.tx}"`);
6890
+ if (opts.ty !== void 0) attrParts.push(`ty="${opts.ty}"`);
6891
+ if (opts.sx !== void 0) attrParts.push(`sx="${opts.sx}"`);
6892
+ if (opts.sy !== void 0) attrParts.push(`sy="${opts.sy}"`);
6893
+ if (opts.flip !== void 0) attrParts.push(`flip="${escapeXml(opts.flip)}"`);
6894
+ if (opts.align !== void 0) attrParts.push(`algn="${escapeXml(xsdRectAlignment.to(opts.align))}"`);
6895
+ return `<a:tile${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
6863
6896
  },
6864
- parse(el, ctx) {
6897
+ parse(el, _ctx) {
6865
6898
  const result = {};
6866
- const gsLst = findChild(el, "a:gsLst");
6867
- if (gsLst?.elements) result.stops = gsLst.elements.filter((c) => c.name === "a:gs").map((gs) => {
6868
- return {
6869
- position: Number(gs.attributes?.["pos"] ?? 0),
6870
- color: readDirectColor(gs, ctx)
6871
- };
6872
- });
6873
- const lin = findChild(el, "a:lin");
6874
- if (lin) {
6875
- const shade = {};
6876
- if (lin.attributes?.["ang"] !== void 0) shade.angle = Number(lin.attributes["ang"]);
6877
- if (lin.attributes?.["scaled"] !== void 0) shade.scaled = lin.attributes["scaled"] !== "0";
6878
- result.shade = shade;
6879
- } else {
6880
- const path = findChild(el, "a:path");
6881
- if (path) {
6882
- const shade = {};
6883
- if (path.attributes?.["path"] !== void 0) shade.path = String(path.attributes["path"]);
6884
- const fillToRectangle = findChild(path, "a:fillToRect");
6885
- if (fillToRectangle) shade.fillToRectangle = readRelativeRect(fillToRectangle);
6886
- result.shade = shade;
6887
- }
6888
- }
6899
+ if (el.attributes?.["tx"] !== void 0) result.tx = Number(el.attributes["tx"]);
6900
+ if (el.attributes?.["ty"] !== void 0) result.ty = Number(el.attributes["ty"]);
6901
+ if (el.attributes?.["sx"] !== void 0) result.sx = Number(el.attributes["sx"]);
6902
+ if (el.attributes?.["sy"] !== void 0) result.sy = Number(el.attributes["sy"]);
6889
6903
  if (el.attributes?.["flip"] !== void 0) result.flip = String(el.attributes["flip"]);
6890
- if (el.attributes?.["rotWithShape"] !== void 0) result.rotateWithShape = el.attributes["rotWithShape"] !== "0";
6891
- const tileRectangle = findChild(el, "a:tileRect");
6892
- if (tileRectangle) result.tileRectangle = readRelativeRect(tileRectangle);
6904
+ if (el.attributes?.["algn"] !== void 0) result.align = xsdRectAlignment.from(String(el.attributes["algn"]));
6893
6905
  return result;
6894
6906
  }
6895
6907
  };
6896
- const patternFillDesc = {
6908
+ const sourceRectangleDesc = {
6897
6909
  kind: "custom",
6898
- stringify(opts, ctx) {
6899
- const parts = [];
6900
- const prst = xsdPattern.to(opts.pattern);
6901
- if (opts.foregroundColor) {
6902
- const colorXml = stringify$1(getColorDescriptor(opts.foregroundColor), opts.foregroundColor, ctx);
6903
- if (colorXml) parts.push(`<a:fgClr>${colorXml}</a:fgClr>`);
6904
- }
6905
- if (opts.backgroundColor) {
6906
- const colorXml = stringify$1(getColorDescriptor(opts.backgroundColor), opts.backgroundColor, ctx);
6907
- if (colorXml) parts.push(`<a:bgClr>${colorXml}</a:bgClr>`);
6908
- }
6909
- const inner = parts.join("");
6910
- return `<a:pattFill prst="${escapeXml(prst)}">${inner}</a:pattFill>`;
6910
+ stringify(opts, _ctx) {
6911
+ const attrParts = [];
6912
+ if (opts.left !== void 0) attrParts.push(`l="${opts.left}"`);
6913
+ if (opts.top !== void 0) attrParts.push(`t="${opts.top}"`);
6914
+ if (opts.right !== void 0) attrParts.push(`r="${opts.right}"`);
6915
+ if (opts.bottom !== void 0) attrParts.push(`b="${opts.bottom}"`);
6916
+ return `<a:srcRect${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
6911
6917
  },
6912
- parse(el, ctx) {
6918
+ parse(el, _ctx) {
6913
6919
  const result = {};
6914
- const prst = el.attributes?.["prst"];
6915
- if (prst) result.pattern = xsdPattern.from(String(prst));
6916
- const fgClr = findChild(el, "a:fgClr");
6917
- if (fgClr) result.foregroundColor = readDirectColor(fgClr, ctx);
6918
- const bgClr = findChild(el, "a:bgClr");
6919
- if (bgClr) result.backgroundColor = readDirectColor(bgClr, ctx);
6920
+ if (el.attributes?.["l"] !== void 0) result.left = Number(el.attributes["l"]);
6921
+ if (el.attributes?.["t"] !== void 0) result.top = Number(el.attributes["t"]);
6922
+ if (el.attributes?.["r"] !== void 0) result.right = Number(el.attributes["r"]);
6923
+ if (el.attributes?.["b"] !== void 0) result.bottom = Number(el.attributes["b"]);
6920
6924
  return result;
6921
6925
  }
6922
6926
  };
6923
- const fillDesc = {
6927
+ const stretchDesc = {
6924
6928
  kind: "custom",
6925
- stringify(opts, ctx) {
6926
- if (typeof opts === "string") return stringify$1(solidFillDesc, { value: opts.replace("#", "") }, ctx);
6927
- switch (opts.type) {
6928
- case "none": return "<a:noFill/>";
6929
- case "solid": return stringify$1(solidFillDesc, typeof opts.color === "string" ? { value: opts.color.replace("#", "") } : opts.color, ctx);
6930
- case "gradient": {
6931
- if ("options" in opts) return stringify$1(gradientFillDesc, opts.options, ctx);
6932
- const gradOpts = { stops: opts.stops.map((stop) => ({
6933
- position: stop.position * 1e3,
6934
- color: typeof stop.color === "string" ? { value: stop.color.replace("#", "") } : stop.color
6935
- })) };
6936
- if (!opts.path && opts.angle !== void 0) gradOpts.shade = {
6937
- angle: opts.angle * 6e4,
6938
- scaled: opts.scaled ?? true
6939
- };
6940
- if (opts.path) gradOpts.shade = { path: opts.path };
6941
- return stringify$1(gradientFillDesc, gradOpts, ctx);
6942
- }
6943
- case "blip": return;
6944
- case "pattern": return stringify$1(patternFillDesc, {
6945
- pattern: opts.pattern,
6946
- ...opts.foregroundColor && { foregroundColor: typeof opts.foregroundColor === "string" ? { value: opts.foregroundColor.replace("#", "") } : opts.foregroundColor },
6947
- ...opts.backgroundColor && { backgroundColor: typeof opts.backgroundColor === "string" ? { value: opts.backgroundColor.replace("#", "") } : opts.backgroundColor }
6948
- }, ctx);
6949
- case "group": return "<a:grpFill/>";
6950
- }
6929
+ stringify(opts, _ctx) {
6930
+ const attrParts = [];
6931
+ if (opts.left !== void 0) attrParts.push(`l="${opts.left}"`);
6932
+ if (opts.top !== void 0) attrParts.push(`t="${opts.top}"`);
6933
+ if (opts.right !== void 0) attrParts.push(`r="${opts.right}"`);
6934
+ if (opts.bottom !== void 0) attrParts.push(`b="${opts.bottom}"`);
6935
+ return `<a:stretch><a:fillRect${attrParts.length ? " " + attrParts.join(" ") : ""}/></a:stretch>`;
6951
6936
  },
6952
- parse(el, ctx) {
6953
- const resolve = (tag) => el.name === tag ? el : findChild(el, tag);
6954
- if (resolve("a:noFill")) return { type: "none" };
6955
- const solidFill = resolve("a:solidFill");
6956
- if (solidFill) return {
6957
- type: "solid",
6958
- color: parse$1(solidFillDesc, solidFill, ctx)
6959
- };
6960
- const gradFill = resolve("a:gradFill");
6961
- if (gradFill) return {
6962
- type: "gradient",
6963
- options: parse$1(gradientFillDesc, gradFill, ctx)
6964
- };
6965
- const pattFill = resolve("a:pattFill");
6966
- if (pattFill) return {
6967
- type: "pattern",
6968
- ...parse$1(patternFillDesc, pattFill, ctx)
6969
- };
6970
- if (resolve("a:grpFill")) return { type: "group" };
6971
- return { type: "none" };
6937
+ parse(el, _ctx) {
6938
+ const fillRect = findChild(el, "a:fillRect");
6939
+ if (!fillRect) return {};
6940
+ const result = {};
6941
+ if (fillRect.attributes?.["l"] !== void 0) result.left = Number(fillRect.attributes["l"]);
6942
+ if (fillRect.attributes?.["t"] !== void 0) result.top = Number(fillRect.attributes["t"]);
6943
+ if (fillRect.attributes?.["r"] !== void 0) result.right = Number(fillRect.attributes["r"]);
6944
+ if (fillRect.attributes?.["b"] !== void 0) result.bottom = Number(fillRect.attributes["b"]);
6945
+ return result;
6972
6946
  }
6973
6947
  };
6974
- function readDirectColor(el, ctx) {
6975
- const color = parseColorChoice(el, ctx);
6976
- if (Object.keys(color).length > 0) return color;
6977
- const solidFill = findChild(el, "a:solidFill");
6978
- if (solidFill) return parse$1(solidFillDesc, solidFill, ctx);
6979
- return { value: "" };
6980
- }
6981
- //#endregion
6982
- //#region src/drawingml/outline/outline-descriptors.ts
6983
- /**
6984
- * Outline descriptor for DrawingML shapes.
6985
- *
6986
- * @module
6987
- */
6988
- function stringifyLineEnd(tag, opts) {
6948
+ function stringifyBlipEffects(opts, ctx) {
6989
6949
  const parts = [];
6990
- if (opts.type) parts.push(`type="${escapeXml(opts.type)}"`);
6991
- if (opts.width) parts.push(`w="${escapeXml(opts.width)}"`);
6992
- if (opts.length) parts.push(`len="${escapeXml(opts.length)}"`);
6993
- return `<${tag}${parts.length ? " " + parts.join(" ") : ""}/>`;
6994
- }
6995
- function readLineEnd(el) {
6996
- const result = {};
6997
- if (el.attributes?.["type"]) result.type = String(el.attributes["type"]);
6998
- if (el.attributes?.["w"]) result.width = String(el.attributes["w"]);
6999
- if (el.attributes?.["len"]) result.length = String(el.attributes["len"]);
7000
- return result;
7001
- }
7002
- function stringifyCustomDash(stops) {
7003
- return `<a:custDash>${stops.map((s) => `<a:ds d="${escapeXml(s.d)}" sp="${escapeXml(s.sp)}"/>`).join("")}</a:custDash>`;
7004
- }
7005
- const outlineDesc = {
7006
- kind: "custom",
7007
- stringify(opts, ctx) {
7008
- const parts = [];
6950
+ if (opts.grayscale) parts.push("<a:grayscl/>");
6951
+ if (opts.luminance) {
7009
6952
  const attrParts = [];
7010
- if (opts.width !== void 0) attrParts.push(`w="${convertToEmu(opts.width)}"`);
7011
- if (opts.cap !== void 0) attrParts.push(`cap="${escapeXml(opts.cap)}"`);
7012
- if (opts.compoundLine !== void 0) attrParts.push(`cmpd="${escapeXml(opts.compoundLine)}"`);
7013
- if (opts.align !== void 0) attrParts.push(`algn="${escapeXml(opts.align)}"`);
6953
+ if (opts.luminance.bright !== void 0) attrParts.push(`bright="${opts.luminance.bright}"`);
6954
+ if (opts.luminance.contrast !== void 0) attrParts.push(`contrast="${opts.luminance.contrast}"`);
7014
6955
  const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7015
- if (opts.type === "noFill") parts.push("<a:noFill/>");
7016
- else if (opts.type === "solidFill" && opts.color) {
7017
- const fillXml = stringify$1(solidFillDesc, opts.color, ctx);
7018
- if (fillXml) parts.push(fillXml);
7019
- } else if (opts.type === "gradFill" && opts.gradientFill) {
7020
- const gradXml = stringify$1(gradientFillDesc, opts.gradientFill, ctx);
7021
- if (gradXml) parts.push(gradXml);
7022
- }
7023
- if (opts.customDash) parts.push(stringifyCustomDash(opts.customDash));
7024
- else if (opts.dash) parts.push(`<a:prstDash val="${escapeXml(opts.dash)}"/>`);
7025
- if (opts.join) if (opts.join === "miter" && opts.miterLimit !== void 0) parts.push(`<a:miter lim="${opts.miterLimit}"/>`);
7026
- else parts.push(`<a:${opts.join}/>`);
7027
- if (opts.headEnd) parts.push(stringifyLineEnd("a:headEnd", opts.headEnd));
7028
- if (opts.tailEnd) parts.push(stringifyLineEnd("a:tailEnd", opts.tailEnd));
7029
- if (parts.length === 0 && !attrStr) return void 0;
7030
- if (parts.length === 0) return `<a:ln${attrStr}/>`;
7031
- return `<a:ln${attrStr}>${parts.join("")}</a:ln>`;
6956
+ parts.push(`<a:lum${attrStr}/>`);
6957
+ }
6958
+ if (opts.hsl) {
6959
+ const attrParts = [];
6960
+ if (opts.hsl.hue !== void 0) attrParts.push(`hue="${opts.hsl.hue}"`);
6961
+ if (opts.hsl.saturation !== void 0) attrParts.push(`sat="${opts.hsl.saturation}"`);
6962
+ if (opts.hsl.luminance !== void 0) attrParts.push(`lum="${opts.hsl.luminance}"`);
6963
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
6964
+ parts.push(`<a:hsl${attrStr}/>`);
6965
+ }
6966
+ if (opts.tint) {
6967
+ const attrParts = [];
6968
+ if (opts.tint.hue !== void 0) attrParts.push(`hue="${opts.tint.hue}"`);
6969
+ if (opts.tint.amount !== void 0) attrParts.push(`amt="${opts.tint.amount}"`);
6970
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
6971
+ parts.push(`<a:tint${attrStr}/>`);
6972
+ }
6973
+ if (opts.duotone) {
6974
+ const c1 = stringify$1(solidFillDesc, opts.duotone.color1, ctx);
6975
+ const c2 = stringify$1(solidFillDesc, opts.duotone.color2, ctx);
6976
+ parts.push(`<a:duotone>${c1 ?? ""}${c2 ?? ""}</a:duotone>`);
6977
+ }
6978
+ if (opts.biLevel) parts.push(`<a:biLevel thresh="${opts.biLevel.threshold}"/>`);
6979
+ if (opts.alphaCeiling) parts.push("<a:alphaCeiling/>");
6980
+ if (opts.alphaFloor) parts.push("<a:alphaFloor/>");
6981
+ if (opts.alphaInverse !== void 0) if (typeof opts.alphaInverse === "boolean") parts.push("<a:alphaInv/>");
6982
+ else {
6983
+ const colorXml = stringify$1(solidFillDesc, opts.alphaInverse, ctx);
6984
+ parts.push(`<a:alphaInv>${colorXml ?? ""}</a:alphaInv>`);
6985
+ }
6986
+ if (opts.alphaModFix) {
6987
+ const amt = opts.alphaModFix.amount ?? 100;
6988
+ parts.push(`<a:alphaModFix amt="${amt}"/>`);
6989
+ }
6990
+ if (opts.alphaRepl) parts.push(`<a:alphaRepl a="${opts.alphaRepl.amount}"/>`);
6991
+ if (opts.alphaBiLevel) parts.push(`<a:alphaBiLevel thresh="${opts.alphaBiLevel.threshold}"/>`);
6992
+ if (opts.colorChange) {
6993
+ const fromXml = stringify$1(solidFillDesc, opts.colorChange.from, ctx);
6994
+ const toXml = stringify$1(solidFillDesc, opts.colorChange.to, ctx);
6995
+ const attrParts = [];
6996
+ if (opts.colorChange.useAlpha === false) attrParts.push("useA=\"0\"");
6997
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
6998
+ parts.push(`<a:clrChange${attrStr}><a:clrFrom>${fromXml ?? ""}</a:clrFrom><a:clrTo>${toXml ?? ""}</a:clrTo></a:clrChange>`);
6999
+ }
7000
+ if (opts.colorRepl) {
7001
+ const colorXml = stringify$1(solidFillDesc, opts.colorRepl.color, ctx);
7002
+ parts.push(`<a:clrRepl>${colorXml ?? ""}</a:clrRepl>`);
7003
+ }
7004
+ if (opts.blur) {
7005
+ const attrParts = [];
7006
+ if (opts.blur.radius !== void 0) attrParts.push(`rad="${opts.blur.radius}"`);
7007
+ if (opts.blur.grow === false) attrParts.push("grow=\"0\"");
7008
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7009
+ parts.push(`<a:blur${attrStr}/>`);
7010
+ }
7011
+ return parts.join("");
7012
+ }
7013
+ function readBlipEffects(el, ctx) {
7014
+ const result = {};
7015
+ if (findChild(el, "a:grayscl")) result.grayscale = true;
7016
+ const lum = findChild(el, "a:lum");
7017
+ if (lum) {
7018
+ const opts = {};
7019
+ if (lum.attributes?.["bright"] !== void 0) opts.bright = Number(String(lum.attributes["bright"]).replace("%", ""));
7020
+ if (lum.attributes?.["contrast"] !== void 0) opts.contrast = Number(String(lum.attributes["contrast"]).replace("%", ""));
7021
+ result.luminance = opts;
7022
+ }
7023
+ const hsl = findChild(el, "a:hsl");
7024
+ if (hsl) {
7025
+ const opts = {};
7026
+ if (hsl.attributes?.["hue"] !== void 0) opts.hue = Number(hsl.attributes["hue"]);
7027
+ if (hsl.attributes?.["sat"] !== void 0) opts.saturation = Number(String(hsl.attributes["sat"]).replace("%", ""));
7028
+ if (hsl.attributes?.["lum"] !== void 0) opts.luminance = Number(String(hsl.attributes["lum"]).replace("%", ""));
7029
+ result.hsl = opts;
7030
+ }
7031
+ const tint = findChild(el, "a:tint");
7032
+ if (tint) {
7033
+ const opts = {};
7034
+ if (tint.attributes?.["hue"] !== void 0) opts.hue = Number(tint.attributes["hue"]);
7035
+ if (tint.attributes?.["amt"] !== void 0) opts.amount = Number(String(tint.attributes["amt"]).replace("%", ""));
7036
+ result.tint = opts;
7037
+ }
7038
+ const biLevel = findChild(el, "a:biLevel");
7039
+ if (biLevel?.attributes?.["thresh"] !== void 0) result.biLevel = { threshold: Number(String(biLevel.attributes["thresh"]).replace("%", "")) };
7040
+ if (findChild(el, "a:alphaCeiling")) result.alphaCeiling = true;
7041
+ if (findChild(el, "a:alphaFloor")) result.alphaFloor = true;
7042
+ const alphaInv = findChild(el, "a:alphaInv");
7043
+ if (alphaInv) {
7044
+ const solidFill = findChild(alphaInv, "a:solidFill");
7045
+ if (solidFill) result.alphaInverse = parse$1(solidFillDesc, solidFill, ctx);
7046
+ else result.alphaInverse = {};
7047
+ }
7048
+ const alphaModFix = findChild(el, "a:alphaModFix");
7049
+ if (alphaModFix) {
7050
+ const opts = {};
7051
+ if (alphaModFix.attributes?.["amt"] !== void 0) opts.amount = Number(String(alphaModFix.attributes["amt"]).replace("%", ""));
7052
+ result.alphaModFix = opts;
7053
+ }
7054
+ const alphaRepl = findChild(el, "a:alphaRepl");
7055
+ if (alphaRepl?.attributes?.["a"] !== void 0) result.alphaRepl = { amount: Number(String(alphaRepl.attributes["a"]).replace("%", "")) };
7056
+ const alphaBiLevel = findChild(el, "a:alphaBiLevel");
7057
+ if (alphaBiLevel?.attributes?.["thresh"] !== void 0) result.alphaBiLevel = { threshold: Number(String(alphaBiLevel.attributes["thresh"]).replace("%", "")) };
7058
+ const clrChange = findChild(el, "a:clrChange");
7059
+ if (clrChange) {
7060
+ const opts = {};
7061
+ if (clrChange.attributes?.["useA"] !== void 0) opts.useAlpha = clrChange.attributes["useA"] !== "0";
7062
+ const clrFrom = findChild(clrChange, "a:clrFrom");
7063
+ if (clrFrom) {
7064
+ const fromFill = findChild(clrFrom, "a:solidFill");
7065
+ if (fromFill) opts.from = parse$1(solidFillDesc, fromFill, ctx);
7066
+ }
7067
+ const clrTo = findChild(clrChange, "a:clrTo");
7068
+ if (clrTo) {
7069
+ const toFill = findChild(clrTo, "a:solidFill");
7070
+ if (toFill) opts.to = parse$1(solidFillDesc, toFill, ctx);
7071
+ }
7072
+ result.colorChange = opts;
7073
+ }
7074
+ const clrRepl = findChild(el, "a:clrRepl");
7075
+ if (clrRepl) {
7076
+ const solidFill = findChild(clrRepl, "a:solidFill");
7077
+ if (solidFill) result.colorRepl = { color: parse$1(solidFillDesc, solidFill, ctx) };
7078
+ }
7079
+ const blur = findChild(el, "a:blur");
7080
+ if (blur) {
7081
+ const opts = {};
7082
+ if (blur.attributes?.["rad"] !== void 0) opts.radius = Number(blur.attributes["rad"]);
7083
+ if (blur.attributes?.["grow"] !== void 0) opts.grow = blur.attributes["grow"] !== "0";
7084
+ result.blur = opts;
7085
+ }
7086
+ const duotone = findChild(el, "a:duotone");
7087
+ if (duotone?.elements) {
7088
+ const fills = [];
7089
+ for (const child of duotone.elements) {
7090
+ const sf = findChild(child, "a:solidFill");
7091
+ if (sf) fills.push(parse$1(solidFillDesc, sf, ctx));
7092
+ }
7093
+ if (fills.length >= 2) result.duotone = {
7094
+ color1: fills[0],
7095
+ color2: fills[1]
7096
+ };
7097
+ }
7098
+ return Object.keys(result).length > 0 ? result : void 0;
7099
+ }
7100
+ const blipDesc = {
7101
+ kind: "custom",
7102
+ stringify(opts, ctx) {
7103
+ const attrParts = [];
7104
+ const embedValue = `{${opts.referenceId}}`;
7105
+ attrParts.push(`r:embed="${escapeXml(embedValue)}"`);
7106
+ attrParts.push("cstate=\"none\"");
7107
+ const attrStr = " " + attrParts.join(" ");
7108
+ const parts = [];
7109
+ if (opts.blipEffects) parts.push(stringifyBlipEffects(opts.blipEffects, ctx));
7110
+ const content = parts.join("");
7111
+ if (!content) return `<a:blip${attrStr}/>`;
7112
+ return `<a:blip${attrStr}>${content}</a:blip>`;
7032
7113
  },
7033
- parse(el, _ctx) {
7114
+ parse(el, ctx) {
7034
7115
  const result = {};
7035
- if (el.attributes) {
7036
- if (el.attributes["w"] !== void 0) result.width = Number(el.attributes["w"]);
7037
- if (el.attributes["cap"] !== void 0) result.cap = String(el.attributes["cap"]);
7038
- if (el.attributes["cmpd"] !== void 0) result.compoundLine = String(el.attributes["cmpd"]);
7039
- if (el.attributes["algn"] !== void 0) result.align = String(el.attributes["algn"]);
7040
- }
7041
- const solidFill = findChild(el, "a:solidFill");
7042
- if (solidFill) {
7043
- result.type = "solidFill";
7044
- result.color = parse$1(solidFillDesc, solidFill, _ctx);
7116
+ const embed = el.attributes?.["r:embed"];
7117
+ if (embed !== void 0) result.referenceId = String(embed).replace(/^\{(.+)\}$/, "$1");
7118
+ const link = el.attributes?.["r:link"];
7119
+ if (link !== void 0) result.referenceId = String(link).replace(/^\{(.+)\}$/, "$1");
7120
+ const effects = readBlipEffects(el, ctx);
7121
+ if (effects) result.blipEffects = effects;
7122
+ return result;
7123
+ }
7124
+ };
7125
+ const blipFillDesc = {
7126
+ kind: "custom",
7127
+ stringify(opts, ctx) {
7128
+ const attrParts = [];
7129
+ if (opts.dpi !== void 0) attrParts.push(`dpi="${opts.dpi}"`);
7130
+ if (opts.rotWithShape !== void 0) attrParts.push(`rotWithShape="${opts.rotWithShape ? 1 : 0}"`);
7131
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7132
+ const parts = [];
7133
+ if (opts.referenceId) {
7134
+ const blipXml = stringify$1(blipDesc, {
7135
+ referenceId: opts.referenceId,
7136
+ blipEffects: opts.blipEffects
7137
+ }, ctx);
7138
+ if (blipXml) parts.push(blipXml);
7045
7139
  }
7046
- if (findChild(el, "a:noFill")) result.type = "noFill";
7047
- if (findChild(el, "a:gradFill")) {
7048
- result.type = "gradFill";
7049
- result.gradientFill = parse$1(gradientFillDesc, findChild(el, "a:gradFill"), _ctx);
7140
+ if (opts.sourceRectangle) {
7141
+ const srcRectXml = stringify$1(sourceRectangleDesc, opts.sourceRectangle, ctx);
7142
+ if (srcRectXml) parts.push(srcRectXml);
7050
7143
  }
7051
- const prstDash = findChild(el, "a:prstDash");
7052
- if (prstDash?.attributes?.["val"]) result.dash = String(prstDash.attributes["val"]);
7053
- const custDash = findChild(el, "a:custDash");
7054
- if (custDash?.elements) result.customDash = custDash.elements.filter((c) => c.name === "a:ds").map((c) => ({
7055
- d: String(c.attributes?.["d"] ?? ""),
7056
- sp: String(c.attributes?.["sp"] ?? "")
7057
- }));
7058
- if (findChild(el, "a:round")) result.join = "round";
7059
- else if (findChild(el, "a:bevel")) result.join = "bevel";
7060
- else {
7061
- const miter = findChild(el, "a:miter");
7062
- if (miter) {
7063
- result.join = "miter";
7064
- if (miter.attributes?.["lim"]) result.miterLimit = Number(miter.attributes["lim"]);
7065
- }
7144
+ if (opts.tile) {
7145
+ const tileXml = stringify$1(tileDesc, opts.tile, ctx);
7146
+ if (tileXml) parts.push(tileXml);
7147
+ } else parts.push("<a:stretch><a:fillRect/></a:stretch>");
7148
+ const content = parts.join("");
7149
+ if (!attrStr && !content) return void 0;
7150
+ if (!content) return `<pic:blipFill${attrStr}/>`;
7151
+ return `<pic:blipFill${attrStr}>${content}</pic:blipFill>`;
7152
+ },
7153
+ parse(el, ctx) {
7154
+ const result = {};
7155
+ if (el.attributes?.["dpi"] !== void 0) result.dpi = Number(el.attributes["dpi"]);
7156
+ if (el.attributes?.["rotWithShape"] !== void 0) result.rotWithShape = el.attributes["rotWithShape"] !== "0";
7157
+ const blip = findChild(el, "a:blip");
7158
+ if (blip) {
7159
+ const blipResult = parse$1(blipDesc, blip, ctx);
7160
+ if (blipResult.referenceId) result.referenceId = blipResult.referenceId;
7161
+ if (blipResult.blipEffects) result.blipEffects = blipResult.blipEffects;
7066
7162
  }
7067
- const headEnd = findChild(el, "a:headEnd");
7068
- if (headEnd) result.headEnd = readLineEnd(headEnd);
7069
- const tailEnd = findChild(el, "a:tailEnd");
7070
- if (tailEnd) result.tailEnd = readLineEnd(tailEnd);
7163
+ const srcRect = findChild(el, "a:srcRect");
7164
+ if (srcRect) result.sourceRectangle = parse$1(sourceRectangleDesc, srcRect, ctx);
7165
+ const tile = findChild(el, "a:tile");
7166
+ if (tile) result.tile = parse$1(tileDesc, tile, ctx);
7071
7167
  return result;
7072
7168
  }
7073
7169
  };
7074
7170
  //#endregion
7075
- //#region src/drawingml/effects/effect-descriptors.ts
7171
+ //#region src/drawingml/fill/fill-descriptors.ts
7076
7172
  /**
7077
- * Effect list descriptor for DrawingML shapes.
7173
+ * Fill descriptors for DrawingML EG_FillProperties.
7078
7174
  *
7079
7175
  * @module
7080
7176
  */
7081
- function stringifyEffectColor(color, ctx) {
7082
- if (!color) return void 0;
7083
- return stringify$1(getColorDescriptor(color), color, ctx);
7177
+ function stringifyRelativeRect(tag, rect) {
7178
+ const parts = [];
7179
+ if (rect.left) parts.push(`l="${escapeXml(rect.left)}"`);
7180
+ if (rect.top) parts.push(`t="${escapeXml(rect.top)}"`);
7181
+ if (rect.right) parts.push(`r="${escapeXml(rect.right)}"`);
7182
+ if (rect.bottom) parts.push(`b="${escapeXml(rect.bottom)}"`);
7183
+ return `<${tag}${parts.length ? " " + parts.join(" ") : ""}/>`;
7084
7184
  }
7085
- function stringifyColorEffect(tag, attrs, color, ctx) {
7086
- const attrParts = [];
7087
- for (const [key, val] of Object.entries(attrs)) if (val !== void 0) attrParts.push(`${key}="${escapeXml(String(val))}"`);
7088
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7089
- const colorXml = stringifyEffectColor(color, ctx);
7090
- if (!colorXml && !attrStr) return void 0;
7091
- if (!colorXml) return `<${tag}${attrStr}/>`;
7092
- return `<${tag}${attrStr}>${colorXml}</${tag}>`;
7185
+ function readRelativeRect(el) {
7186
+ const result = {};
7187
+ if (el.attributes?.["l"]) result.left = String(el.attributes["l"]);
7188
+ if (el.attributes?.["t"]) result.top = String(el.attributes["t"]);
7189
+ if (el.attributes?.["r"]) result.right = String(el.attributes["r"]);
7190
+ if (el.attributes?.["b"]) result.bottom = String(el.attributes["b"]);
7191
+ return result;
7093
7192
  }
7094
- function readColorFromElement(el, ctx) {
7095
- const color = parseColorChoice(el, ctx);
7096
- if (!color || Object.keys(color).length === 0) return void 0;
7097
- return color;
7193
+ function stringifyShade(shade) {
7194
+ if ("angle" in shade) {
7195
+ const parts = [];
7196
+ if (shade.angle !== void 0) parts.push(`ang="${shade.angle}"`);
7197
+ if (shade.scaled !== void 0) parts.push(`scaled="${shade.scaled ? 1 : 0}"`);
7198
+ return `<a:lin${parts.length ? " " + parts.join(" ") : ""}/>`;
7199
+ }
7200
+ const pathShade = shade;
7201
+ const parts = [];
7202
+ if (pathShade.path) parts.push(`path="${escapeXml(pathShade.path)}"`);
7203
+ const attrStr = parts.length ? " " + parts.join(" ") : "";
7204
+ if (pathShade.fillToRectangle) return `<a:path${attrStr}>${stringifyRelativeRect("a:fillToRect", pathShade.fillToRectangle)}</a:path>`;
7205
+ return `<a:path${attrStr}/>`;
7098
7206
  }
7099
- const effectListDesc = {
7207
+ const gradientFillDesc = {
7100
7208
  kind: "custom",
7101
7209
  stringify(opts, ctx) {
7102
7210
  const parts = [];
7103
- if (opts.blur) {
7104
- const attrParts = [];
7105
- if (opts.blur.radius !== void 0) attrParts.push(`rad="${opts.blur.radius}"`);
7106
- if (opts.blur.grow === false) attrParts.push("grow=\"0\"");
7107
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7108
- parts.push(`<a:blur${attrStr}/>`);
7109
- }
7110
- if (opts.fillOverlay) parts.push(`<a:fillOverlay blend="${escapeXml(opts.fillOverlay.blend)}"/>`);
7111
- if (opts.glow) parts.push(stringifyColorEffect("a:glow", { rad: opts.glow.radius }, opts.glow.color, ctx) ?? "");
7112
- if (opts.innerShadow) parts.push(stringifyColorEffect("a:innerShdw", {
7113
- blurRad: opts.innerShadow.blurRadius,
7114
- dist: opts.innerShadow.distance,
7115
- dir: opts.innerShadow.direction
7116
- }, opts.innerShadow.color, ctx) ?? "");
7117
- if (opts.outerShadow) parts.push(stringifyColorEffect("a:outerShdw", {
7118
- blurRad: opts.outerShadow.blurRadius,
7119
- dist: opts.outerShadow.distance,
7120
- dir: opts.outerShadow.direction,
7121
- sx: opts.outerShadow.scaleX,
7122
- sy: opts.outerShadow.scaleY,
7123
- kx: opts.outerShadow.skewX,
7124
- ky: opts.outerShadow.skewY,
7125
- algn: opts.outerShadow.alignment,
7126
- rotWithShape: opts.outerShadow.rotWithShape === false ? 0 : void 0
7127
- }, opts.outerShadow.color, ctx) ?? "");
7128
- if (opts.presetShadow) parts.push(stringifyColorEffect("a:prstShdw", {
7129
- prst: opts.presetShadow.preset,
7130
- dist: opts.presetShadow.distance,
7131
- dir: opts.presetShadow.direction
7132
- }, opts.presetShadow.color, ctx) ?? "");
7133
- if (opts.reflection) {
7134
- const refOpts = opts.reflection === true ? {} : opts.reflection;
7135
- const attrParts = [];
7136
- if (refOpts.blurRadius !== void 0) attrParts.push(`blurRad="${refOpts.blurRadius}"`);
7137
- if (refOpts.startAlpha !== void 0) attrParts.push(`stA="${refOpts.startAlpha}"`);
7138
- if (refOpts.startPosition !== void 0) attrParts.push(`stPos="${refOpts.startPosition}"`);
7139
- if (refOpts.endAlpha !== void 0) attrParts.push(`endA="${refOpts.endAlpha}"`);
7140
- if (refOpts.endPosition !== void 0) attrParts.push(`endPos="${refOpts.endPosition}"`);
7141
- if (refOpts.distance !== void 0) attrParts.push(`dist="${refOpts.distance}"`);
7142
- if (refOpts.direction !== void 0) attrParts.push(`dir="${refOpts.direction}"`);
7143
- if (refOpts.fadeDirection !== void 0) attrParts.push(`fadeDir="${refOpts.fadeDirection}"`);
7144
- if (refOpts.scaleX !== void 0) attrParts.push(`sx="${refOpts.scaleX}"`);
7145
- if (refOpts.scaleY !== void 0) attrParts.push(`sy="${refOpts.scaleY}"`);
7146
- if (refOpts.skewX !== void 0) attrParts.push(`kx="${refOpts.skewX}"`);
7147
- if (refOpts.skewY !== void 0) attrParts.push(`ky="${refOpts.skewY}"`);
7148
- if (refOpts.alignment !== void 0) attrParts.push(`algn="${refOpts.alignment}"`);
7149
- if (refOpts.rotWithShape !== void 0) attrParts.push(`rotWithShape="${refOpts.rotWithShape ? 1 : 0}"`);
7150
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7151
- parts.push(`<a:reflection${attrStr}/>`);
7152
- }
7153
- if (opts.softEdge !== void 0) parts.push(`<a:softEdge rad="${opts.softEdge}"/>`);
7154
- const content = parts.filter(Boolean).join("");
7155
- if (!content) return void 0;
7156
- return `<a:effectLst>${content}</a:effectLst>`;
7211
+ const stopsXml = opts.stops.map((stop) => {
7212
+ const colorXml = stringifyColorChoice(stop.color, ctx);
7213
+ if (!colorXml) return `<a:gs pos="${stop.position}"/>`;
7214
+ return `<a:gs pos="${stop.position}">${colorXml}</a:gs>`;
7215
+ }).join("");
7216
+ parts.push(`<a:gsLst>${stopsXml}</a:gsLst>`);
7217
+ if (opts.shade) parts.push(stringifyShade(opts.shade));
7218
+ if (opts.tileRectangle) parts.push(stringifyRelativeRect("a:tileRect", opts.tileRectangle));
7219
+ const attrParts = [];
7220
+ if (opts.flip) attrParts.push(`flip="${escapeXml(opts.flip)}"`);
7221
+ if (opts.rotateWithShape !== void 0) attrParts.push(`rotWithShape="${opts.rotateWithShape ? 1 : 0}"`);
7222
+ return `<a:gradFill${attrParts.length ? " " + attrParts.join(" ") : ""}>${parts.join("")}</a:gradFill>`;
7157
7223
  },
7158
7224
  parse(el, ctx) {
7159
7225
  const result = {};
7160
- const blur = findChild(el, "a:blur");
7161
- if (blur) {
7162
- const blurOpts = {};
7163
- if (blur.attributes?.["rad"] !== void 0) blurOpts.radius = Number(blur.attributes["rad"]);
7164
- if (blur.attributes?.["grow"] !== void 0) blurOpts.grow = blur.attributes["grow"] !== "0";
7165
- result.blur = blurOpts;
7166
- }
7167
- const glow = findChild(el, "a:glow");
7168
- if (glow) {
7169
- const glowOpts = {};
7170
- if (glow.attributes?.["rad"] !== void 0) glowOpts.radius = Number(glow.attributes["rad"]);
7171
- const color = readColorFromElement(glow, ctx);
7172
- if (color) glowOpts.color = color;
7173
- result.glow = glowOpts;
7174
- }
7175
- const innerShdw = findChild(el, "a:innerShdw");
7176
- if (innerShdw) {
7177
- const innerOpts = {};
7178
- if (innerShdw.attributes?.["blurRad"] !== void 0) innerOpts.blurRadius = Number(innerShdw.attributes["blurRad"]);
7179
- if (innerShdw.attributes?.["dist"] !== void 0) innerOpts.distance = Number(innerShdw.attributes["dist"]);
7180
- if (innerShdw.attributes?.["dir"] !== void 0) innerOpts.direction = Number(innerShdw.attributes["dir"]);
7181
- const color = readColorFromElement(innerShdw, ctx);
7182
- if (color) innerOpts.color = color;
7183
- result.innerShadow = innerOpts;
7184
- }
7185
- const outerShdw = findChild(el, "a:outerShdw");
7186
- if (outerShdw) {
7187
- const outerOpts = {};
7188
- if (outerShdw.attributes?.["blurRad"] !== void 0) outerOpts.blurRadius = Number(outerShdw.attributes["blurRad"]);
7189
- if (outerShdw.attributes?.["dist"] !== void 0) outerOpts.distance = Number(outerShdw.attributes["dist"]);
7190
- if (outerShdw.attributes?.["dir"] !== void 0) outerOpts.direction = Number(outerShdw.attributes["dir"]);
7191
- if (outerShdw.attributes?.["sx"] !== void 0) outerOpts.scaleX = Number(outerShdw.attributes["sx"]);
7192
- if (outerShdw.attributes?.["sy"] !== void 0) outerOpts.scaleY = Number(outerShdw.attributes["sy"]);
7193
- if (outerShdw.attributes?.["kx"] !== void 0) outerOpts.skewX = Number(outerShdw.attributes["kx"]);
7194
- if (outerShdw.attributes?.["ky"] !== void 0) outerOpts.skewY = Number(outerShdw.attributes["ky"]);
7195
- if (outerShdw.attributes?.["algn"] !== void 0) outerOpts.alignment = String(outerShdw.attributes["algn"]);
7196
- if (outerShdw.attributes?.["rotWithShape"] !== void 0) outerOpts.rotWithShape = outerShdw.attributes["rotWithShape"] !== "0";
7197
- const color = readColorFromElement(outerShdw, ctx);
7198
- if (color) outerOpts.color = color;
7199
- result.outerShadow = outerOpts;
7200
- }
7201
- const fillOverlay = findChild(el, "a:fillOverlay");
7202
- if (fillOverlay) {
7203
- const overlayOpts = {};
7204
- if (fillOverlay.attributes?.["blend"] !== void 0) overlayOpts.blend = String(fillOverlay.attributes["blend"]);
7205
- result.fillOverlay = overlayOpts;
7226
+ const gsLst = findChild(el, "a:gsLst");
7227
+ if (gsLst?.elements) result.stops = gsLst.elements.filter((c) => c.name === "a:gs").map((gs) => {
7228
+ return {
7229
+ position: Number(gs.attributes?.["pos"] ?? 0),
7230
+ color: readDirectColor(gs, ctx)
7231
+ };
7232
+ });
7233
+ const lin = findChild(el, "a:lin");
7234
+ if (lin) {
7235
+ const shade = {};
7236
+ if (lin.attributes?.["ang"] !== void 0) shade.angle = Number(lin.attributes["ang"]);
7237
+ if (lin.attributes?.["scaled"] !== void 0) shade.scaled = lin.attributes["scaled"] !== "0";
7238
+ result.shade = shade;
7239
+ } else {
7240
+ const path = findChild(el, "a:path");
7241
+ if (path) {
7242
+ const shade = {};
7243
+ if (path.attributes?.["path"] !== void 0) shade.path = String(path.attributes["path"]);
7244
+ const fillToRectangle = findChild(path, "a:fillToRect");
7245
+ if (fillToRectangle) shade.fillToRectangle = readRelativeRect(fillToRectangle);
7246
+ result.shade = shade;
7247
+ }
7206
7248
  }
7207
- const prstShdw = findChild(el, "a:prstShdw");
7208
- if (prstShdw) {
7209
- const prstOpts = {};
7210
- if (prstShdw.attributes?.["prst"] !== void 0) prstOpts.preset = String(prstShdw.attributes["prst"]);
7211
- if (prstShdw.attributes?.["dist"] !== void 0) prstOpts.distance = Number(prstShdw.attributes["dist"]);
7212
- if (prstShdw.attributes?.["dir"] !== void 0) prstOpts.direction = Number(prstShdw.attributes["dir"]);
7213
- const color = readColorFromElement(prstShdw, ctx);
7214
- if (color) prstOpts.color = color;
7215
- result.presetShadow = prstOpts;
7249
+ if (el.attributes?.["flip"] !== void 0) result.flip = String(el.attributes["flip"]);
7250
+ if (el.attributes?.["rotWithShape"] !== void 0) result.rotateWithShape = el.attributes["rotWithShape"] !== "0";
7251
+ const tileRectangle = findChild(el, "a:tileRect");
7252
+ if (tileRectangle) result.tileRectangle = readRelativeRect(tileRectangle);
7253
+ return result;
7254
+ }
7255
+ };
7256
+ const patternFillDesc = {
7257
+ kind: "custom",
7258
+ stringify(opts, ctx) {
7259
+ const parts = [];
7260
+ const prst = xsdPattern.to(opts.pattern);
7261
+ if (opts.foregroundColor) {
7262
+ const colorXml = stringifyColorChoice(opts.foregroundColor, ctx);
7263
+ if (colorXml) parts.push(`<a:fgClr>${colorXml}</a:fgClr>`);
7216
7264
  }
7217
- const reflection = findChild(el, "a:reflection");
7218
- if (reflection) {
7219
- const refOpts = {};
7220
- if (reflection.attributes?.["blurRad"] !== void 0) refOpts.blurRadius = Number(reflection.attributes["blurRad"]);
7221
- if (reflection.attributes?.["stA"] !== void 0) refOpts.startAlpha = Number(reflection.attributes["stA"]);
7222
- if (reflection.attributes?.["stPos"] !== void 0) refOpts.startPosition = Number(reflection.attributes["stPos"]);
7223
- if (reflection.attributes?.["endA"] !== void 0) refOpts.endAlpha = Number(reflection.attributes["endA"]);
7224
- if (reflection.attributes?.["endPos"] !== void 0) refOpts.endPosition = Number(reflection.attributes["endPos"]);
7225
- if (reflection.attributes?.["dist"] !== void 0) refOpts.distance = Number(reflection.attributes["dist"]);
7226
- if (reflection.attributes?.["dir"] !== void 0) refOpts.direction = Number(reflection.attributes["dir"]);
7227
- if (reflection.attributes?.["fadeDir"] !== void 0) refOpts.fadeDirection = Number(reflection.attributes["fadeDir"]);
7228
- if (reflection.attributes?.["sx"] !== void 0) refOpts.scaleX = Number(reflection.attributes["sx"]);
7229
- if (reflection.attributes?.["sy"] !== void 0) refOpts.scaleY = Number(reflection.attributes["sy"]);
7230
- if (reflection.attributes?.["kx"] !== void 0) refOpts.skewX = Number(reflection.attributes["kx"]);
7231
- if (reflection.attributes?.["ky"] !== void 0) refOpts.skewY = Number(reflection.attributes["ky"]);
7232
- if (reflection.attributes?.["algn"] !== void 0) refOpts.alignment = String(reflection.attributes["algn"]);
7233
- if (reflection.attributes?.["rotWithShape"] !== void 0) refOpts.rotWithShape = reflection.attributes["rotWithShape"] !== "0";
7234
- result.reflection = refOpts;
7265
+ if (opts.backgroundColor) {
7266
+ const colorXml = stringifyColorChoice(opts.backgroundColor, ctx);
7267
+ if (colorXml) parts.push(`<a:bgClr>${colorXml}</a:bgClr>`);
7235
7268
  }
7236
- const softEdge = findChild(el, "a:softEdge");
7237
- if (softEdge?.attributes?.["rad"] !== void 0) result.softEdge = Number(softEdge.attributes["rad"]);
7269
+ const inner = parts.join("");
7270
+ return `<a:pattFill prst="${escapeXml(prst)}">${inner}</a:pattFill>`;
7271
+ },
7272
+ parse(el, ctx) {
7273
+ const result = {};
7274
+ const prst = el.attributes?.["prst"];
7275
+ if (prst) result.pattern = xsdPattern.from(String(prst));
7276
+ const fgClr = findChild(el, "a:fgClr");
7277
+ if (fgClr) result.foregroundColor = readDirectColor(fgClr, ctx);
7278
+ const bgClr = findChild(el, "a:bgClr");
7279
+ if (bgClr) result.backgroundColor = readDirectColor(bgClr, ctx);
7238
7280
  return result;
7239
7281
  }
7240
7282
  };
7241
- //#endregion
7242
- //#region src/drawingml/locking/locking-descriptors.ts
7243
- const BASE_LOCKING_KEYS = [
7244
- "noGrp",
7245
- "noSelect",
7246
- "noRot",
7247
- "noChangeAspect",
7248
- "noMove",
7249
- "noResize",
7250
- "noEditPoints",
7251
- "noAdjustHandles",
7252
- "noChangeArrowheads",
7253
- "noChangeShapeType"
7254
- ];
7255
- const SHAPE_EXTRA_KEYS = ["noTextEdit"];
7256
- const PICTURE_EXTRA_KEYS = ["noCrop"];
7257
- const GROUP_EXTRA_KEYS = ["noUngrp"];
7258
- const FRAME_EXTRA_KEYS = ["noDrilldown"];
7259
- function stringifyLockingAttrs(opts, keys) {
7260
- const parts = [];
7261
- for (const key of keys) if (opts[key] !== void 0) parts.push(`${key}="${opts[key] ? 1 : 0}"`);
7262
- return parts.length ? " " + parts.join(" ") : "";
7263
- }
7264
- function readLockingAttrs(el, keys) {
7265
- const result = {};
7266
- if (!el.attributes) return result;
7267
- for (const key of keys) {
7268
- const val = el.attributes[key];
7269
- if (val !== void 0) result[key] = val === "1" || val === 1 || val === "true";
7283
+ function imageTypeFromPath(path) {
7284
+ switch (path.split(".").pop()?.toLowerCase() ?? "") {
7285
+ case "png": return "png";
7286
+ case "jpg":
7287
+ case "jpeg": return "jpg";
7288
+ case "gif": return "gif";
7289
+ case "bmp": return "bmp";
7290
+ case "tif":
7291
+ case "tiff": return "tif";
7292
+ case "ico": return "ico";
7293
+ case "emf": return "emf";
7294
+ case "wmf": return "wmf";
7295
+ default: return "png";
7270
7296
  }
7271
- return result;
7272
7297
  }
7273
- const shapeLockingDesc = {
7298
+ const fillDesc = {
7274
7299
  kind: "custom",
7275
- stringify(opts, _ctx) {
7276
- const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...SHAPE_EXTRA_KEYS]);
7277
- if (!attrStr) return void 0;
7278
- return `<a:spLocks${attrStr}/>`;
7279
- },
7280
- parse(el, _ctx) {
7281
- return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...SHAPE_EXTRA_KEYS]);
7282
- }
7283
- };
7284
- const pictureLockingDesc = {
7285
- kind: "custom",
7286
- stringify(opts, _ctx) {
7287
- const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...PICTURE_EXTRA_KEYS]);
7288
- if (!attrStr) return void 0;
7289
- return `<a:picLocks${attrStr}/>`;
7290
- },
7291
- parse(el, _ctx) {
7292
- return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...PICTURE_EXTRA_KEYS]);
7293
- }
7294
- };
7295
- const groupLockingDesc = {
7296
- kind: "custom",
7297
- stringify(opts, _ctx) {
7298
- const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...GROUP_EXTRA_KEYS]);
7299
- if (!attrStr) return void 0;
7300
- return `<a:grpSpLocks${attrStr}/>`;
7301
- },
7302
- parse(el, _ctx) {
7303
- return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...GROUP_EXTRA_KEYS]);
7304
- }
7305
- };
7306
- const graphicFrameLockingDesc = {
7307
- kind: "custom",
7308
- stringify(opts, _ctx) {
7309
- const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...FRAME_EXTRA_KEYS]);
7310
- if (!attrStr) return void 0;
7311
- return `<a:graphicFrameLocks${attrStr}/>`;
7312
- },
7313
- parse(el, _ctx) {
7314
- return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...FRAME_EXTRA_KEYS]);
7315
- }
7316
- };
7317
- //#endregion
7318
- //#region src/drawingml/geometry/geometry-descriptors.ts
7319
- /**
7320
- * Geometry descriptors for DrawingML shapes.
7321
- *
7322
- * @module
7323
- */
7324
- const adjustmentValuesDesc = {
7325
- kind: "custom",
7326
- stringify(guides, _ctx) {
7327
- if (!guides || guides.length === 0) return "<a:avLst/>";
7328
- return `<a:avLst>${guides.map((g) => `<a:gd name="${escapeXml(g.name)}" fmla="${escapeXml(g.formula)}"/>`).join("")}</a:avLst>`;
7329
- },
7330
- parse(el, _ctx) {
7331
- const result = [];
7332
- if (el.elements) {
7333
- for (const child of el.elements) if (child.name === "a:gd" && child.attributes) {
7334
- const name = child.attributes["name"];
7335
- const fmla = child.attributes["fmla"];
7336
- if (name !== void 0 && fmla !== void 0) result.push({
7337
- name: String(name),
7338
- formula: String(fmla)
7339
- });
7300
+ stringify(opts, ctx) {
7301
+ if (typeof opts === "string") return stringify$1(solidFillDesc, { value: opts.replace("#", "") }, ctx);
7302
+ switch (opts.type) {
7303
+ case "none": return "<a:noFill/>";
7304
+ case "solid": return stringify$1(solidFillDesc, typeof opts.color === "string" ? { value: opts.color.replace("#", "") } : opts.color, ctx);
7305
+ case "gradient": {
7306
+ if ("options" in opts) return stringify$1(gradientFillDesc, opts.options, ctx);
7307
+ const gradOpts = { stops: opts.stops.map((stop) => ({
7308
+ position: stop.position * 1e3,
7309
+ color: typeof stop.color === "string" ? { value: stop.color.replace("#", "") } : stop.color
7310
+ })) };
7311
+ if (!opts.path && opts.angle !== void 0) gradOpts.shade = {
7312
+ angle: opts.angle * 6e4,
7313
+ scaled: opts.scaled ?? true
7314
+ };
7315
+ if (opts.path) gradOpts.shade = { path: opts.path };
7316
+ return stringify$1(gradientFillDesc, gradOpts, ctx);
7340
7317
  }
7318
+ case "blip": return buildFill(opts, ctx.addMedia(toUint8Array(opts.data), opts.imageType));
7319
+ case "pattern": return stringify$1(patternFillDesc, {
7320
+ pattern: opts.pattern,
7321
+ ...opts.foregroundColor && { foregroundColor: typeof opts.foregroundColor === "string" ? { value: opts.foregroundColor.replace("#", "") } : opts.foregroundColor },
7322
+ ...opts.backgroundColor && { backgroundColor: typeof opts.backgroundColor === "string" ? { value: opts.backgroundColor.replace("#", "") } : opts.backgroundColor }
7323
+ }, ctx);
7324
+ case "group": return "<a:grpFill/>";
7341
7325
  }
7342
- return result;
7343
- }
7344
- };
7345
- const presetGeometryDesc = {
7346
- kind: "custom",
7347
- stringify(opts, ctx) {
7348
- const prst = opts.preset ?? "rect";
7349
- let avXml = "";
7350
- if (opts.adjustmentValues) avXml = stringify$1(adjustmentValuesDesc, opts.adjustmentValues, ctx) ?? "<a:avLst/>";
7351
- else avXml = "<a:avLst/>";
7352
- return `<a:prstGeom prst="${escapeXml(prst)}">${avXml}</a:prstGeom>`;
7353
7326
  },
7354
7327
  parse(el, ctx) {
7355
- const result = {};
7356
- if (el.attributes?.["prst"] !== void 0) result.preset = String(el.attributes["prst"]);
7357
- const avLst = findChild(el, "a:avLst");
7358
- if (avLst) {
7359
- const guides = parse$1(adjustmentValuesDesc, avLst, ctx);
7360
- if (guides.length > 0) result.adjustmentValues = guides;
7328
+ const resolve = (tag) => el.name === tag ? el : findChild(el, tag);
7329
+ if (resolve("a:noFill")) return { type: "none" };
7330
+ const solidFill = resolve("a:solidFill");
7331
+ if (solidFill) return {
7332
+ type: "solid",
7333
+ color: parse$1(solidFillDesc, solidFill, ctx)
7334
+ };
7335
+ const gradFill = resolve("a:gradFill");
7336
+ if (gradFill) return {
7337
+ type: "gradient",
7338
+ options: parse$1(gradientFillDesc, gradFill, ctx)
7339
+ };
7340
+ const pattFill = resolve("a:pattFill");
7341
+ if (pattFill) return {
7342
+ type: "pattern",
7343
+ ...parse$1(patternFillDesc, pattFill, ctx)
7344
+ };
7345
+ if (resolve("a:grpFill")) return { type: "group" };
7346
+ const blipFill = resolve("a:blipFill");
7347
+ if (blipFill) {
7348
+ const blipOpts = parse$1(blipFillDesc, blipFill, ctx);
7349
+ const mediaPath = blipOpts.referenceId ? ctx.resolveRelationship(blipOpts.referenceId) : void 0;
7350
+ const data = mediaPath ? ctx.getRaw(mediaPath) : void 0;
7351
+ if (mediaPath && data) {
7352
+ const blip = {
7353
+ type: "blip",
7354
+ data,
7355
+ imageType: imageTypeFromPath(mediaPath)
7356
+ };
7357
+ if (blipOpts.dpi !== void 0) blip.dpi = blipOpts.dpi;
7358
+ if (blipOpts.rotWithShape !== void 0) blip.rotWithShape = blipOpts.rotWithShape;
7359
+ if (blipOpts.blipEffects) blip.blipEffects = blipOpts.blipEffects;
7360
+ if (blipOpts.sourceRectangle) blip.sourceRectangle = blipOpts.sourceRectangle;
7361
+ if (blipOpts.tile) blip.tile = blipOpts.tile;
7362
+ return blip;
7363
+ }
7361
7364
  }
7362
- return result;
7365
+ return { type: "none" };
7363
7366
  }
7364
7367
  };
7365
- function stringifyAdjustPoint(pt) {
7366
- return `<a:pt x="${escapeXml(pt.x)}" y="${escapeXml(pt.y)}"/>`;
7368
+ function readDirectColor(el, ctx) {
7369
+ const color = parseColorChoice(el, ctx);
7370
+ if (Object.keys(color).length > 0) return color;
7371
+ const solidFill = findChild(el, "a:solidFill");
7372
+ if (solidFill) return parse$1(solidFillDesc, solidFill, ctx);
7373
+ return { value: "" };
7367
7374
  }
7368
- function stringifyPathCommand(cmd) {
7369
- switch (cmd.command) {
7370
- case "moveTo": return `<a:moveTo>${stringifyAdjustPoint(cmd.point)}</a:moveTo>`;
7371
- case "lineTo": return `<a:lnTo>${stringifyAdjustPoint(cmd.point)}</a:lnTo>`;
7372
- case "arcTo": return `<a:arcTo wR="${escapeXml(cmd.widthRadius)}" hR="${escapeXml(cmd.heightRadius)}" stAng="${escapeXml(cmd.startAngle)}" swAng="${escapeXml(cmd.sweepAngle)}"/>`;
7373
- case "quadBezTo": return `<a:quadBezTo>${cmd.points.map(stringifyAdjustPoint).join("")}</a:quadBezTo>`;
7374
- case "cubicBezTo": return `<a:cubicBezTo>${cmd.points.map(stringifyAdjustPoint).join("")}</a:cubicBezTo>`;
7375
- case "close": return "<a:close/>";
7376
- }
7375
+ //#endregion
7376
+ //#region src/drawingml/outline/outline-descriptors.ts
7377
+ /**
7378
+ * Outline descriptor for DrawingML shapes.
7379
+ *
7380
+ * @module
7381
+ */
7382
+ function stringifyLineEnd(tag, opts) {
7383
+ const parts = [];
7384
+ if (opts.type) parts.push(`type="${escapeXml(opts.type)}"`);
7385
+ if (opts.width) parts.push(`w="${escapeXml(opts.width)}"`);
7386
+ if (opts.length) parts.push(`len="${escapeXml(opts.length)}"`);
7387
+ return `<${tag}${parts.length ? " " + parts.join(" ") : ""}/>`;
7377
7388
  }
7378
- function stringifyPath(path) {
7379
- const attrs = [];
7380
- if (path.w !== void 0) attrs.push(`w="${path.w}"`);
7381
- if (path.h !== void 0) attrs.push(`h="${path.h}"`);
7382
- if (path.fill !== void 0) attrs.push(`fill="${escapeXml(path.fill)}"`);
7383
- if (path.stroke !== void 0) attrs.push(`stroke="${path.stroke}"`);
7384
- if (path.extrusionOk !== void 0) attrs.push(`extrusionOk="${path.extrusionOk}"`);
7385
- const attrStr = attrs.length ? " " + attrs.join(" ") : "";
7386
- const cmds = path.commands.map(stringifyPathCommand).join("");
7387
- if (!cmds && !attrStr) return "<a:path/>";
7388
- return `<a:path${attrStr}>${cmds}</a:path>`;
7389
+ function readLineEnd(el) {
7390
+ const result = {};
7391
+ if (el.attributes?.["type"]) result.type = String(el.attributes["type"]);
7392
+ if (el.attributes?.["w"]) result.width = String(el.attributes["w"]);
7393
+ if (el.attributes?.["len"]) result.length = String(el.attributes["len"]);
7394
+ return result;
7389
7395
  }
7390
- function readAdjustPoint(el) {
7391
- if (!el.attributes) return void 0;
7392
- const x = el.attributes["x"];
7393
- const y = el.attributes["y"];
7394
- if (x === void 0 || y === void 0) return void 0;
7395
- return {
7396
- x: String(x),
7397
- y: String(y)
7398
- };
7396
+ function stringifyCustomDash(stops) {
7397
+ return `<a:custDash>${stops.map((s) => `<a:ds d="${escapeXml(s.d)}" sp="${escapeXml(s.sp)}"/>`).join("")}</a:custDash>`;
7399
7398
  }
7400
- function readPathCommand(tag, el) {
7401
- switch (tag) {
7402
- case "a:moveTo": {
7403
- const pt = el.elements?.find((c) => c.name === "a:pt");
7404
- if (!pt) return void 0;
7405
- const point = readAdjustPoint(pt);
7406
- if (!point) return void 0;
7407
- return {
7408
- command: "moveTo",
7409
- point
7410
- };
7411
- }
7412
- case "a:lnTo": {
7413
- const pt = el.elements?.find((c) => c.name === "a:pt");
7414
- if (!pt) return void 0;
7415
- const point = readAdjustPoint(pt);
7416
- if (!point) return void 0;
7417
- return {
7418
- command: "lineTo",
7419
- point
7420
- };
7421
- }
7422
- case "a:arcTo": {
7423
- const a = el.attributes;
7424
- if (!a) return void 0;
7425
- return {
7426
- command: "arcTo",
7427
- widthRadius: String(a["wR"] ?? ""),
7428
- heightRadius: String(a["hR"] ?? ""),
7429
- startAngle: String(a["stAng"] ?? ""),
7430
- sweepAngle: String(a["swAng"] ?? "")
7431
- };
7399
+ const outlineDesc = {
7400
+ kind: "custom",
7401
+ stringify(opts, ctx) {
7402
+ const parts = [];
7403
+ const attrParts = [];
7404
+ if (opts.width !== void 0) attrParts.push(`w="${convertToEmu(opts.width)}"`);
7405
+ if (opts.cap !== void 0) attrParts.push(`cap="${escapeXml(opts.cap)}"`);
7406
+ if (opts.compoundLine !== void 0) attrParts.push(`cmpd="${escapeXml(opts.compoundLine)}"`);
7407
+ if (opts.align !== void 0) attrParts.push(`algn="${escapeXml(opts.align)}"`);
7408
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7409
+ if (opts.type === "noFill") parts.push("<a:noFill/>");
7410
+ else if (opts.type === "solidFill" && opts.color) {
7411
+ const fillXml = stringify$1(solidFillDesc, opts.color, ctx);
7412
+ if (fillXml) parts.push(fillXml);
7413
+ } else if (opts.type === "gradFill" && opts.gradientFill) {
7414
+ const gradXml = stringify$1(gradientFillDesc, opts.gradientFill, ctx);
7415
+ if (gradXml) parts.push(gradXml);
7432
7416
  }
7433
- case "a:quadBezTo": {
7434
- const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(readAdjustPoint).filter((p) => p !== void 0);
7435
- if (points.length < 2) return void 0;
7436
- return {
7437
- command: "quadBezTo",
7438
- points: [points[0], points[1]]
7439
- };
7417
+ if (opts.customDash) parts.push(stringifyCustomDash(opts.customDash));
7418
+ else if (opts.dash) parts.push(`<a:prstDash val="${escapeXml(opts.dash)}"/>`);
7419
+ if (opts.join) if (opts.join === "miter" && opts.miterLimit !== void 0) parts.push(`<a:miter lim="${opts.miterLimit}"/>`);
7420
+ else parts.push(`<a:${opts.join}/>`);
7421
+ if (opts.headEnd) parts.push(stringifyLineEnd("a:headEnd", opts.headEnd));
7422
+ if (opts.tailEnd) parts.push(stringifyLineEnd("a:tailEnd", opts.tailEnd));
7423
+ if (parts.length === 0 && !attrStr) return void 0;
7424
+ if (parts.length === 0) return `<a:ln${attrStr}/>`;
7425
+ return `<a:ln${attrStr}>${parts.join("")}</a:ln>`;
7426
+ },
7427
+ parse(el, _ctx) {
7428
+ const result = {};
7429
+ if (el.attributes) {
7430
+ if (el.attributes["w"] !== void 0) result.width = Number(el.attributes["w"]);
7431
+ if (el.attributes["cap"] !== void 0) result.cap = String(el.attributes["cap"]);
7432
+ if (el.attributes["cmpd"] !== void 0) result.compoundLine = String(el.attributes["cmpd"]);
7433
+ if (el.attributes["algn"] !== void 0) result.align = String(el.attributes["algn"]);
7440
7434
  }
7441
- case "a:cubicBezTo": {
7442
- const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(readAdjustPoint).filter((p) => p !== void 0);
7443
- if (points.length < 3) return void 0;
7444
- return {
7445
- command: "cubicBezTo",
7446
- points: [
7447
- points[0],
7448
- points[1],
7449
- points[2]
7450
- ]
7451
- };
7435
+ const solidFill = findChild(el, "a:solidFill");
7436
+ if (solidFill) {
7437
+ result.type = "solidFill";
7438
+ result.color = parse$1(solidFillDesc, solidFill, _ctx);
7452
7439
  }
7453
- case "a:close": return { command: "close" };
7454
- default: return;
7455
- }
7456
- }
7457
- function readPath(el) {
7458
- const result = {};
7459
- if (el.attributes) {
7460
- if (el.attributes["w"] !== void 0) result.w = Number(el.attributes["w"]);
7461
- if (el.attributes["h"] !== void 0) result.h = Number(el.attributes["h"]);
7462
- if (el.attributes["fill"] !== void 0) result.fill = String(el.attributes["fill"]);
7463
- if (el.attributes["stroke"] !== void 0) result.stroke = el.attributes["stroke"] !== "0" && el.attributes["stroke"] !== "false";
7464
- if (el.attributes["extrusionOk"] !== void 0) result.extrusionOk = el.attributes["extrusionOk"] !== "0" && el.attributes["extrusionOk"] !== "false";
7465
- }
7466
- const commands = [];
7467
- if (el.elements) {
7468
- for (const child of el.elements) if (child.name) {
7469
- const cmd = readPathCommand(child.name, child);
7470
- if (cmd) commands.push(cmd);
7440
+ if (findChild(el, "a:noFill")) result.type = "noFill";
7441
+ if (findChild(el, "a:gradFill")) {
7442
+ result.type = "gradFill";
7443
+ result.gradientFill = parse$1(gradientFillDesc, findChild(el, "a:gradFill"), _ctx);
7471
7444
  }
7472
- }
7473
- if (commands.length > 0) result.commands = commands;
7474
- return result;
7475
- }
7476
- function stringifyGuideList(tag, guides) {
7477
- if (!guides || guides.length === 0) return `<${tag}/>`;
7478
- return `<${tag}>${guides.map((g) => `<a:gd name="${escapeXml(g.name)}" fmla="${escapeXml(g.formula)}"/>`).join("")}</${tag}>`;
7479
- }
7480
- function readGuideList(el) {
7481
- const result = [];
7482
- if (el.elements) {
7483
- for (const child of el.elements) if (child.name === "a:gd" && child.attributes) {
7484
- const name = child.attributes["name"];
7485
- const fmla = child.attributes["fmla"];
7486
- if (name !== void 0 && fmla !== void 0) result.push({
7487
- name: String(name),
7488
- formula: String(fmla)
7489
- });
7445
+ const prstDash = findChild(el, "a:prstDash");
7446
+ if (prstDash?.attributes?.["val"]) result.dash = String(prstDash.attributes["val"]);
7447
+ const custDash = findChild(el, "a:custDash");
7448
+ if (custDash?.elements) result.customDash = custDash.elements.filter((c) => c.name === "a:ds").map((c) => ({
7449
+ d: String(c.attributes?.["d"] ?? ""),
7450
+ sp: String(c.attributes?.["sp"] ?? "")
7451
+ }));
7452
+ if (findChild(el, "a:round")) result.join = "round";
7453
+ else if (findChild(el, "a:bevel")) result.join = "bevel";
7454
+ else {
7455
+ const miter = findChild(el, "a:miter");
7456
+ if (miter) {
7457
+ result.join = "miter";
7458
+ if (miter.attributes?.["lim"]) result.miterLimit = Number(miter.attributes["lim"]);
7459
+ }
7490
7460
  }
7461
+ const headEnd = findChild(el, "a:headEnd");
7462
+ if (headEnd) result.headEnd = readLineEnd(headEnd);
7463
+ const tailEnd = findChild(el, "a:tailEnd");
7464
+ if (tailEnd) result.tailEnd = readLineEnd(tailEnd);
7465
+ return result;
7491
7466
  }
7492
- return result;
7493
- }
7494
- function stringifyAdjustHandlePos(pos) {
7495
- return `<a:pos x="${escapeXml(pos.x)}" y="${escapeXml(pos.y)}"/>`;
7496
- }
7497
- function stringifyXYAdjustHandle(h) {
7498
- const attrs = [];
7499
- if (h.guideRefX !== void 0) attrs.push(`gdRefX="${escapeXml(h.guideRefX)}"`);
7500
- if (h.minX !== void 0) attrs.push(`minX="${escapeXml(h.minX)}"`);
7501
- if (h.maxX !== void 0) attrs.push(`maxX="${escapeXml(h.maxX)}"`);
7502
- if (h.guideRefY !== void 0) attrs.push(`gdRefY="${escapeXml(h.guideRefY)}"`);
7503
- if (h.minY !== void 0) attrs.push(`minY="${escapeXml(h.minY)}"`);
7504
- if (h.maxY !== void 0) attrs.push(`maxY="${escapeXml(h.maxY)}"`);
7505
- return `<a:ahXY${attrs.length ? " " + attrs.join(" ") : ""}>${stringifyAdjustHandlePos(h.position)}</a:ahXY>`;
7506
- }
7507
- function stringifyPolarAdjustHandle(h) {
7508
- const attrs = [];
7509
- if (h.guideRefRadius !== void 0) attrs.push(`gdRefR="${escapeXml(h.guideRefRadius)}"`);
7510
- if (h.minRadius !== void 0) attrs.push(`minR="${escapeXml(h.minRadius)}"`);
7511
- if (h.maxRadius !== void 0) attrs.push(`maxR="${escapeXml(h.maxRadius)}"`);
7512
- if (h.guideRefAngle !== void 0) attrs.push(`gdRefAng="${escapeXml(h.guideRefAngle)}"`);
7513
- if (h.minAngle !== void 0) attrs.push(`minAng="${escapeXml(h.minAngle)}"`);
7514
- if (h.maxAngle !== void 0) attrs.push(`maxAng="${escapeXml(h.maxAngle)}"`);
7515
- return `<a:ahPolar${attrs.length ? " " + attrs.join(" ") : ""}>${stringifyAdjustHandlePos(h.position)}</a:ahPolar>`;
7516
- }
7517
- function stringifyAdjustHandle(h) {
7518
- return h.type === "xy" ? stringifyXYAdjustHandle(h) : stringifyPolarAdjustHandle(h);
7519
- }
7520
- function readAdjustHandlePos(el) {
7521
- const pos = el.elements?.find((c) => c.name === "a:pos");
7522
- if (!pos?.attributes) return void 0;
7523
- const x = pos.attributes["x"];
7524
- const y = pos.attributes["y"];
7525
- if (x === void 0 || y === void 0) return void 0;
7526
- return {
7527
- x: String(x),
7528
- y: String(y)
7529
- };
7530
- }
7531
- function readXYAdjustHandle(el) {
7532
- const position = readAdjustHandlePos(el);
7533
- if (!position) return void 0;
7534
- const result = {
7535
- type: "xy",
7536
- position
7537
- };
7538
- if (el.attributes?.["gdRefX"] !== void 0) result.guideRefX = String(el.attributes["gdRefX"]);
7539
- if (el.attributes?.["minX"] !== void 0) result.minX = String(el.attributes["minX"]);
7540
- if (el.attributes?.["maxX"] !== void 0) result.maxX = String(el.attributes["maxX"]);
7541
- if (el.attributes?.["gdRefY"] !== void 0) result.guideRefY = String(el.attributes["gdRefY"]);
7542
- if (el.attributes?.["minY"] !== void 0) result.minY = String(el.attributes["minY"]);
7543
- if (el.attributes?.["maxY"] !== void 0) result.maxY = String(el.attributes["maxY"]);
7544
- return result;
7545
- }
7546
- function readPolarAdjustHandle(el) {
7547
- const position = readAdjustHandlePos(el);
7548
- if (!position) return void 0;
7549
- const result = {
7550
- type: "polar",
7551
- position
7552
- };
7553
- if (el.attributes?.["gdRefR"] !== void 0) result.guideRefRadius = String(el.attributes["gdRefR"]);
7554
- if (el.attributes?.["minR"] !== void 0) result.minRadius = String(el.attributes["minR"]);
7555
- if (el.attributes?.["maxR"] !== void 0) result.maxRadius = String(el.attributes["maxR"]);
7556
- if (el.attributes?.["gdRefAng"] !== void 0) result.guideRefAngle = String(el.attributes["gdRefAng"]);
7557
- if (el.attributes?.["minAng"] !== void 0) result.minAngle = String(el.attributes["minAng"]);
7558
- if (el.attributes?.["maxAng"] !== void 0) result.maxAngle = String(el.attributes["maxAng"]);
7559
- return result;
7560
- }
7561
- function stringifyConnectionSite(site) {
7562
- return `<a:cxn ang="${escapeXml(site.angle)}">${stringifyAdjustHandlePos(site.position)}</a:cxn>`;
7563
- }
7564
- function readConnectionSite(el) {
7565
- const ang = el.attributes?.["ang"];
7566
- if (ang === void 0) return void 0;
7567
- const position = readAdjustHandlePos(el);
7568
- if (!position) return void 0;
7569
- return {
7570
- angle: String(ang),
7571
- position
7572
- };
7467
+ };
7468
+ //#endregion
7469
+ //#region src/drawingml/effects/effect-descriptors.ts
7470
+ /**
7471
+ * Effect list descriptor for DrawingML shapes.
7472
+ *
7473
+ * @module
7474
+ */
7475
+ function stringifyEffectColor(color, ctx) {
7476
+ if (!color) return void 0;
7477
+ return stringifyColorChoice(color, ctx);
7573
7478
  }
7574
- function stringifyGeomRect(rect) {
7575
- return `<a:rect l="${escapeXml(rect.left)}" t="${escapeXml(rect.top)}" r="${escapeXml(rect.right)}" b="${escapeXml(rect.bottom)}"/>`;
7479
+ function stringifyColorEffect(tag, attrs, color, ctx) {
7480
+ const attrParts = [];
7481
+ for (const [key, val] of Object.entries(attrs)) if (val !== void 0) attrParts.push(`${key}="${escapeXml(String(val))}"`);
7482
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7483
+ const colorXml = stringifyEffectColor(color, ctx);
7484
+ if (!colorXml && !attrStr) return void 0;
7485
+ if (!colorXml) return `<${tag}${attrStr}/>`;
7486
+ return `<${tag}${attrStr}>${colorXml}</${tag}>`;
7576
7487
  }
7577
- function readGeomRect(el) {
7578
- const a = el.attributes;
7579
- if (!a) return void 0;
7580
- const l = a["l"];
7581
- const t = a["t"];
7582
- const r = a["r"];
7583
- const b = a["b"];
7584
- if (l === void 0 || t === void 0 || r === void 0 || b === void 0) return void 0;
7585
- return {
7586
- left: String(l),
7587
- top: String(t),
7588
- right: String(r),
7589
- bottom: String(b)
7590
- };
7488
+ function readColorFromElement(el, ctx) {
7489
+ const color = parseColorChoice(el, ctx);
7490
+ if (!color || Object.keys(color).length === 0) return void 0;
7491
+ return color;
7591
7492
  }
7592
- const customGeometryDesc = {
7493
+ const effectListDesc = {
7593
7494
  kind: "custom",
7594
- stringify(opts, _ctx) {
7495
+ stringify(opts, ctx) {
7595
7496
  const parts = [];
7596
- if (opts.adjustmentValues && opts.adjustmentValues.length > 0) parts.push(stringifyGuideList("a:avLst", opts.adjustmentValues));
7597
- else parts.push("<a:avLst/>");
7598
- if (opts.guides && opts.guides.length > 0) parts.push(stringifyGuideList("a:gdLst", opts.guides));
7599
- if (opts.adjustHandles && opts.adjustHandles.length > 0) {
7600
- const inner = opts.adjustHandles.map(stringifyAdjustHandle).join("");
7601
- parts.push(`<a:ahLst>${inner}</a:ahLst>`);
7497
+ if (opts.blur) {
7498
+ const attrParts = [];
7499
+ if (opts.blur.radius !== void 0) attrParts.push(`rad="${opts.blur.radius}"`);
7500
+ if (opts.blur.grow === false) attrParts.push("grow=\"0\"");
7501
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7502
+ parts.push(`<a:blur${attrStr}/>`);
7602
7503
  }
7603
- if (opts.connectionSites && opts.connectionSites.length > 0) {
7604
- const inner = opts.connectionSites.map(stringifyConnectionSite).join("");
7605
- parts.push(`<a:cxnLst>${inner}</a:cxnLst>`);
7504
+ if (opts.fillOverlay) parts.push(`<a:fillOverlay blend="${escapeXml(opts.fillOverlay.blend)}"/>`);
7505
+ if (opts.glow) parts.push(stringifyColorEffect("a:glow", { rad: opts.glow.radius }, opts.glow.color, ctx) ?? "");
7506
+ if (opts.innerShadow) parts.push(stringifyColorEffect("a:innerShdw", {
7507
+ blurRad: opts.innerShadow.blurRadius,
7508
+ dist: opts.innerShadow.distance,
7509
+ dir: opts.innerShadow.direction
7510
+ }, opts.innerShadow.color, ctx) ?? "");
7511
+ if (opts.outerShadow) parts.push(stringifyColorEffect("a:outerShdw", {
7512
+ blurRad: opts.outerShadow.blurRadius,
7513
+ dist: opts.outerShadow.distance,
7514
+ dir: opts.outerShadow.direction,
7515
+ sx: opts.outerShadow.scaleX,
7516
+ sy: opts.outerShadow.scaleY,
7517
+ kx: opts.outerShadow.skewX,
7518
+ ky: opts.outerShadow.skewY,
7519
+ algn: opts.outerShadow.alignment,
7520
+ rotWithShape: opts.outerShadow.rotWithShape === false ? 0 : void 0
7521
+ }, opts.outerShadow.color, ctx) ?? "");
7522
+ if (opts.presetShadow) parts.push(stringifyColorEffect("a:prstShdw", {
7523
+ prst: opts.presetShadow.preset,
7524
+ dist: opts.presetShadow.distance,
7525
+ dir: opts.presetShadow.direction
7526
+ }, opts.presetShadow.color, ctx) ?? "");
7527
+ if (opts.reflection) {
7528
+ const refOpts = opts.reflection === true ? {} : opts.reflection;
7529
+ const attrParts = [];
7530
+ if (refOpts.blurRadius !== void 0) attrParts.push(`blurRad="${refOpts.blurRadius}"`);
7531
+ if (refOpts.startAlpha !== void 0) attrParts.push(`stA="${refOpts.startAlpha}"`);
7532
+ if (refOpts.startPosition !== void 0) attrParts.push(`stPos="${refOpts.startPosition}"`);
7533
+ if (refOpts.endAlpha !== void 0) attrParts.push(`endA="${refOpts.endAlpha}"`);
7534
+ if (refOpts.endPosition !== void 0) attrParts.push(`endPos="${refOpts.endPosition}"`);
7535
+ if (refOpts.distance !== void 0) attrParts.push(`dist="${refOpts.distance}"`);
7536
+ if (refOpts.direction !== void 0) attrParts.push(`dir="${refOpts.direction}"`);
7537
+ if (refOpts.fadeDirection !== void 0) attrParts.push(`fadeDir="${refOpts.fadeDirection}"`);
7538
+ if (refOpts.scaleX !== void 0) attrParts.push(`sx="${refOpts.scaleX}"`);
7539
+ if (refOpts.scaleY !== void 0) attrParts.push(`sy="${refOpts.scaleY}"`);
7540
+ if (refOpts.skewX !== void 0) attrParts.push(`kx="${refOpts.skewX}"`);
7541
+ if (refOpts.skewY !== void 0) attrParts.push(`ky="${refOpts.skewY}"`);
7542
+ if (refOpts.alignment !== void 0) attrParts.push(`algn="${refOpts.alignment}"`);
7543
+ if (refOpts.rotWithShape !== void 0) attrParts.push(`rotWithShape="${refOpts.rotWithShape ? 1 : 0}"`);
7544
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7545
+ parts.push(`<a:reflection${attrStr}/>`);
7606
7546
  }
7607
- if (opts.textRectangle) parts.push(stringifyGeomRect(opts.textRectangle));
7608
- const pathsXml = opts.pathList.map(stringifyPath).join("");
7609
- parts.push(`<a:pathLst>${pathsXml}</a:pathLst>`);
7610
- return `<a:custGeom>${parts.join("")}</a:custGeom>`;
7547
+ if (opts.softEdge !== void 0) parts.push(`<a:softEdge rad="${opts.softEdge}"/>`);
7548
+ const content = parts.filter(Boolean).join("");
7549
+ if (!content) return void 0;
7550
+ return `<a:effectLst>${content}</a:effectLst>`;
7611
7551
  },
7612
- parse(el, _ctx) {
7552
+ parse(el, ctx) {
7613
7553
  const result = {};
7614
- const avLst = findChild(el, "a:avLst");
7615
- if (avLst) {
7616
- const guides = readGuideList(avLst);
7617
- if (guides.length > 0) result.adjustmentValues = guides;
7554
+ const blur = findChild(el, "a:blur");
7555
+ if (blur) {
7556
+ const blurOpts = {};
7557
+ if (blur.attributes?.["rad"] !== void 0) blurOpts.radius = Number(blur.attributes["rad"]);
7558
+ if (blur.attributes?.["grow"] !== void 0) blurOpts.grow = blur.attributes["grow"] !== "0";
7559
+ result.blur = blurOpts;
7618
7560
  }
7619
- const gdLst = findChild(el, "a:gdLst");
7620
- if (gdLst) {
7621
- const guides = readGuideList(gdLst);
7622
- if (guides.length > 0) result.guides = guides;
7561
+ const glow = findChild(el, "a:glow");
7562
+ if (glow) {
7563
+ const glowOpts = {};
7564
+ if (glow.attributes?.["rad"] !== void 0) glowOpts.radius = Number(glow.attributes["rad"]);
7565
+ const color = readColorFromElement(glow, ctx);
7566
+ if (color) glowOpts.color = color;
7567
+ result.glow = glowOpts;
7623
7568
  }
7624
- const ahLst = findChild(el, "a:ahLst");
7625
- if (ahLst?.elements) {
7626
- const handles = [];
7627
- for (const child of ahLst.elements) if (child.name === "a:ahXY") {
7628
- const h = readXYAdjustHandle(child);
7629
- if (h) handles.push(h);
7630
- } else if (child.name === "a:ahPolar") {
7631
- const h = readPolarAdjustHandle(child);
7632
- if (h) handles.push(h);
7633
- }
7634
- if (handles.length > 0) result.adjustHandles = handles;
7569
+ const innerShdw = findChild(el, "a:innerShdw");
7570
+ if (innerShdw) {
7571
+ const innerOpts = {};
7572
+ if (innerShdw.attributes?.["blurRad"] !== void 0) innerOpts.blurRadius = Number(innerShdw.attributes["blurRad"]);
7573
+ if (innerShdw.attributes?.["dist"] !== void 0) innerOpts.distance = Number(innerShdw.attributes["dist"]);
7574
+ if (innerShdw.attributes?.["dir"] !== void 0) innerOpts.direction = Number(innerShdw.attributes["dir"]);
7575
+ const color = readColorFromElement(innerShdw, ctx);
7576
+ if (color) innerOpts.color = color;
7577
+ result.innerShadow = innerOpts;
7635
7578
  }
7636
- const cxnLst = findChild(el, "a:cxnLst");
7637
- if (cxnLst?.elements) {
7638
- const sites = [];
7639
- for (const child of cxnLst.elements) if (child.name === "a:cxn") {
7640
- const site = readConnectionSite(child);
7641
- if (site) sites.push(site);
7642
- }
7643
- if (sites.length > 0) result.connectionSites = sites;
7579
+ const outerShdw = findChild(el, "a:outerShdw");
7580
+ if (outerShdw) {
7581
+ const outerOpts = {};
7582
+ if (outerShdw.attributes?.["blurRad"] !== void 0) outerOpts.blurRadius = Number(outerShdw.attributes["blurRad"]);
7583
+ if (outerShdw.attributes?.["dist"] !== void 0) outerOpts.distance = Number(outerShdw.attributes["dist"]);
7584
+ if (outerShdw.attributes?.["dir"] !== void 0) outerOpts.direction = Number(outerShdw.attributes["dir"]);
7585
+ if (outerShdw.attributes?.["sx"] !== void 0) outerOpts.scaleX = Number(outerShdw.attributes["sx"]);
7586
+ if (outerShdw.attributes?.["sy"] !== void 0) outerOpts.scaleY = Number(outerShdw.attributes["sy"]);
7587
+ if (outerShdw.attributes?.["kx"] !== void 0) outerOpts.skewX = Number(outerShdw.attributes["kx"]);
7588
+ if (outerShdw.attributes?.["ky"] !== void 0) outerOpts.skewY = Number(outerShdw.attributes["ky"]);
7589
+ if (outerShdw.attributes?.["algn"] !== void 0) outerOpts.alignment = String(outerShdw.attributes["algn"]);
7590
+ if (outerShdw.attributes?.["rotWithShape"] !== void 0) outerOpts.rotWithShape = outerShdw.attributes["rotWithShape"] !== "0";
7591
+ const color = readColorFromElement(outerShdw, ctx);
7592
+ if (color) outerOpts.color = color;
7593
+ result.outerShadow = outerOpts;
7644
7594
  }
7645
- const rect = findChild(el, "a:rect");
7646
- if (rect) {
7647
- const textRectangle = readGeomRect(rect);
7648
- if (textRectangle) result.textRectangle = textRectangle;
7595
+ const fillOverlay = findChild(el, "a:fillOverlay");
7596
+ if (fillOverlay) {
7597
+ const overlayOpts = {};
7598
+ if (fillOverlay.attributes?.["blend"] !== void 0) overlayOpts.blend = String(fillOverlay.attributes["blend"]);
7599
+ result.fillOverlay = overlayOpts;
7649
7600
  }
7650
- const pathLst = findChild(el, "a:pathLst");
7651
- if (pathLst?.elements) {
7652
- const paths = [];
7653
- for (const child of pathLst.elements) if (child.name === "a:path") {
7654
- const p = readPath(child);
7655
- if (p.commands && p.commands.length > 0) paths.push(p);
7656
- }
7657
- if (paths.length > 0) result.pathList = paths;
7601
+ const prstShdw = findChild(el, "a:prstShdw");
7602
+ if (prstShdw) {
7603
+ const prstOpts = {};
7604
+ if (prstShdw.attributes?.["prst"] !== void 0) prstOpts.preset = String(prstShdw.attributes["prst"]);
7605
+ if (prstShdw.attributes?.["dist"] !== void 0) prstOpts.distance = Number(prstShdw.attributes["dist"]);
7606
+ if (prstShdw.attributes?.["dir"] !== void 0) prstOpts.direction = Number(prstShdw.attributes["dir"]);
7607
+ const color = readColorFromElement(prstShdw, ctx);
7608
+ if (color) prstOpts.color = color;
7609
+ result.presetShadow = prstOpts;
7610
+ }
7611
+ const reflection = findChild(el, "a:reflection");
7612
+ if (reflection) {
7613
+ const refOpts = {};
7614
+ if (reflection.attributes?.["blurRad"] !== void 0) refOpts.blurRadius = Number(reflection.attributes["blurRad"]);
7615
+ if (reflection.attributes?.["stA"] !== void 0) refOpts.startAlpha = Number(reflection.attributes["stA"]);
7616
+ if (reflection.attributes?.["stPos"] !== void 0) refOpts.startPosition = Number(reflection.attributes["stPos"]);
7617
+ if (reflection.attributes?.["endA"] !== void 0) refOpts.endAlpha = Number(reflection.attributes["endA"]);
7618
+ if (reflection.attributes?.["endPos"] !== void 0) refOpts.endPosition = Number(reflection.attributes["endPos"]);
7619
+ if (reflection.attributes?.["dist"] !== void 0) refOpts.distance = Number(reflection.attributes["dist"]);
7620
+ if (reflection.attributes?.["dir"] !== void 0) refOpts.direction = Number(reflection.attributes["dir"]);
7621
+ if (reflection.attributes?.["fadeDir"] !== void 0) refOpts.fadeDirection = Number(reflection.attributes["fadeDir"]);
7622
+ if (reflection.attributes?.["sx"] !== void 0) refOpts.scaleX = Number(reflection.attributes["sx"]);
7623
+ if (reflection.attributes?.["sy"] !== void 0) refOpts.scaleY = Number(reflection.attributes["sy"]);
7624
+ if (reflection.attributes?.["kx"] !== void 0) refOpts.skewX = Number(reflection.attributes["kx"]);
7625
+ if (reflection.attributes?.["ky"] !== void 0) refOpts.skewY = Number(reflection.attributes["ky"]);
7626
+ if (reflection.attributes?.["algn"] !== void 0) refOpts.alignment = String(reflection.attributes["algn"]);
7627
+ if (reflection.attributes?.["rotWithShape"] !== void 0) refOpts.rotWithShape = reflection.attributes["rotWithShape"] !== "0";
7628
+ result.reflection = refOpts;
7658
7629
  }
7630
+ const softEdge = findChild(el, "a:softEdge");
7631
+ if (softEdge?.attributes?.["rad"] !== void 0) result.softEdge = Number(softEdge.attributes["rad"]);
7659
7632
  return result;
7660
7633
  }
7661
7634
  };
7662
7635
  //#endregion
7663
- //#region src/drawingml/transform-descriptors.ts
7664
- /**
7665
- * Transform 2D descriptor for DrawingML shapes.
7666
- *
7667
- * @module
7668
- */
7669
- const transform2DDesc = {
7636
+ //#region src/drawingml/locking/locking-descriptors.ts
7637
+ const BASE_LOCKING_KEYS = [
7638
+ "noGrp",
7639
+ "noSelect",
7640
+ "noRot",
7641
+ "noChangeAspect",
7642
+ "noMove",
7643
+ "noResize",
7644
+ "noEditPoints",
7645
+ "noAdjustHandles",
7646
+ "noChangeArrowheads",
7647
+ "noChangeShapeType"
7648
+ ];
7649
+ const SHAPE_EXTRA_KEYS = ["noTextEdit"];
7650
+ const PICTURE_EXTRA_KEYS = ["noCrop"];
7651
+ const GROUP_EXTRA_KEYS = ["noUngrp"];
7652
+ const FRAME_EXTRA_KEYS = ["noDrilldown"];
7653
+ function stringifyLockingAttrs(opts, keys) {
7654
+ const parts = [];
7655
+ for (const key of keys) if (opts[key] !== void 0) parts.push(`${key}="${opts[key] ? 1 : 0}"`);
7656
+ return parts.length ? " " + parts.join(" ") : "";
7657
+ }
7658
+ function readLockingAttrs(el, keys) {
7659
+ const result = {};
7660
+ if (!el.attributes) return result;
7661
+ for (const key of keys) {
7662
+ const val = el.attributes[key];
7663
+ if (val !== void 0) result[key] = val === "1" || val === 1 || val === "true";
7664
+ }
7665
+ return result;
7666
+ }
7667
+ const shapeLockingDesc = {
7670
7668
  kind: "custom",
7671
7669
  stringify(opts, _ctx) {
7672
- const parts = [];
7673
- const attrParts = [];
7674
- if (opts.flipHorizontal !== void 0) attrParts.push(`flipH="${opts.flipHorizontal ? 1 : 0}"`);
7675
- if (opts.flipVertical !== void 0) attrParts.push(`flipV="${opts.flipVertical ? 1 : 0}"`);
7676
- if (opts.rotation !== void 0) attrParts.push(`rot="${opts.rotation}"`);
7677
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7678
- if (opts.x !== void 0 || opts.y !== void 0) {
7679
- const x = opts.x !== void 0 ? convertToEmu(opts.x) : 0;
7680
- const y = opts.y !== void 0 ? convertToEmu(opts.y) : 0;
7681
- parts.push(`<a:off x="${x}" y="${y}"/>`);
7682
- }
7683
- if (opts.width !== void 0 || opts.height !== void 0) {
7684
- const cx = opts.width !== void 0 ? convertToEmu(opts.width) : 0;
7685
- const cy = opts.height !== void 0 ? convertToEmu(opts.height) : 0;
7686
- parts.push(`<a:ext cx="${cx}" cy="${cy}"/>`);
7687
- }
7688
- if (parts.length === 0 && !attrStr) return void 0;
7689
- if (parts.length === 0) return `<a:xfrm${attrStr}/>`;
7690
- return `<a:xfrm${attrStr}>${parts.join("")}</a:xfrm>`;
7670
+ const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...SHAPE_EXTRA_KEYS]);
7671
+ if (!attrStr) return void 0;
7672
+ return `<a:spLocks${attrStr}/>`;
7673
+ },
7674
+ parse(el, _ctx) {
7675
+ return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...SHAPE_EXTRA_KEYS]);
7676
+ }
7677
+ };
7678
+ const pictureLockingDesc = {
7679
+ kind: "custom",
7680
+ stringify(opts, _ctx) {
7681
+ const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...PICTURE_EXTRA_KEYS]);
7682
+ if (!attrStr) return void 0;
7683
+ return `<a:picLocks${attrStr}/>`;
7691
7684
  },
7692
7685
  parse(el, _ctx) {
7693
- const result = {};
7694
- if (el.attributes) {
7695
- if (el.attributes["flipH"] !== void 0) result.flipHorizontal = el.attributes["flipH"] === 1 || el.attributes["flipH"] === "1";
7696
- if (el.attributes["flipV"] !== void 0) result.flipVertical = el.attributes["flipV"] === 1 || el.attributes["flipV"] === "1";
7697
- if (el.attributes["rot"] !== void 0) result.rotation = Number(el.attributes["rot"]);
7698
- }
7699
- const off = findChild(el, "a:off");
7700
- if (off?.attributes) {
7701
- result.x = attrMeasure(off, "x") ?? 0;
7702
- result.y = attrMeasure(off, "y") ?? 0;
7703
- }
7704
- const ext = findChild(el, "a:ext");
7705
- if (ext?.attributes) {
7706
- result.width = attrMeasure(ext, "cx") ?? 0;
7707
- result.height = attrMeasure(ext, "cy") ?? 0;
7708
- }
7709
- return result;
7686
+ return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...PICTURE_EXTRA_KEYS]);
7710
7687
  }
7711
7688
  };
7712
- const groupTransform2DDesc = {
7689
+ const groupLockingDesc = {
7713
7690
  kind: "custom",
7714
- stringify(opts, ctx) {
7715
- const base = transform2DDesc.stringify(opts, ctx) ?? "<a:xfrm/>";
7716
- const chOff = `<a:chOff x="${opts.childOffsetX ?? 0}" y="${opts.childOffsetY ?? 0}"/>`;
7717
- const chExt = `<a:chExt cx="${opts.childExtentWidth ?? 0}" cy="${opts.childExtentHeight ?? 0}"/>`;
7718
- if (base.endsWith("/>")) return `<a:xfrm>${chOff}${chExt}</a:xfrm>`;
7719
- return base.replace(/<\/a:xfrm>$/, `${chOff}${chExt}</a:xfrm>`);
7691
+ stringify(opts, _ctx) {
7692
+ const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...GROUP_EXTRA_KEYS]);
7693
+ if (!attrStr) return void 0;
7694
+ return `<a:grpSpLocks${attrStr}/>`;
7720
7695
  },
7721
- parse(el, ctx) {
7722
- const result = transform2DDesc.parse(el, ctx);
7723
- const chOff = findChild(el, "a:chOff");
7724
- if (chOff?.attributes) {
7725
- result.childOffsetX = attrMeasure(chOff, "x") ?? 0;
7726
- result.childOffsetY = attrMeasure(chOff, "y") ?? 0;
7727
- }
7728
- const chExt = findChild(el, "a:chExt");
7729
- if (chExt?.attributes) {
7730
- result.childExtentWidth = attrMeasure(chExt, "cx") ?? 0;
7731
- result.childExtentHeight = attrMeasure(chExt, "cy") ?? 0;
7732
- }
7733
- return result;
7696
+ parse(el, _ctx) {
7697
+ return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...GROUP_EXTRA_KEYS]);
7698
+ }
7699
+ };
7700
+ const graphicFrameLockingDesc = {
7701
+ kind: "custom",
7702
+ stringify(opts, _ctx) {
7703
+ const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...FRAME_EXTRA_KEYS]);
7704
+ if (!attrStr) return void 0;
7705
+ return `<a:graphicFrameLocks${attrStr}/>`;
7706
+ },
7707
+ parse(el, _ctx) {
7708
+ return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...FRAME_EXTRA_KEYS]);
7734
7709
  }
7735
7710
  };
7736
7711
  //#endregion
7737
- //#region src/drawingml/three-d/three-d-descriptors.ts
7712
+ //#region src/drawingml/geometry/geometry-descriptors.ts
7738
7713
  /**
7739
- * 3D descriptor for DrawingML shapes.
7714
+ * Geometry descriptors for DrawingML shapes.
7740
7715
  *
7741
7716
  * @module
7742
7717
  */
7743
- function stringifySphereCoords(coords) {
7744
- return `<a:rot lat="${coords.lat}" lon="${coords.lon}" rev="${coords.rev}"/>`;
7745
- }
7746
- function readSphereCoords(el) {
7747
- const lat = el.attributes?.["lat"];
7748
- const lon = el.attributes?.["lon"];
7749
- const rev = el.attributes?.["rev"];
7750
- if (lat === void 0 || lon === void 0 || rev === void 0) return void 0;
7751
- return {
7752
- lat: Number(lat),
7753
- lon: Number(lon),
7754
- rev: Number(rev)
7755
- };
7756
- }
7757
- const bevelDesc = {
7718
+ const adjustmentValuesDesc = {
7758
7719
  kind: "custom",
7759
- stringify(opts, _ctx) {
7760
- const attrParts = [];
7761
- if (opts.w !== void 0) attrParts.push(`w="${opts.w}"`);
7762
- if (opts.h !== void 0) attrParts.push(`h="${opts.h}"`);
7763
- if (opts.prst !== void 0) attrParts.push(`prst="${escapeXml(opts.prst)}"`);
7764
- return `<a:bevel${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
7720
+ stringify(guides, _ctx) {
7721
+ if (!guides || guides.length === 0) return "<a:avLst/>";
7722
+ return `<a:avLst>${guides.map((g) => `<a:gd name="${escapeXml(g.name)}" fmla="${escapeXml(g.formula)}"/>`).join("")}</a:avLst>`;
7765
7723
  },
7766
7724
  parse(el, _ctx) {
7767
- const result = {};
7768
- if (el.attributes?.["w"] !== void 0) result.w = Number(el.attributes["w"]);
7769
- if (el.attributes?.["h"] !== void 0) result.h = Number(el.attributes["h"]);
7770
- if (el.attributes?.["prst"] !== void 0) result.prst = String(el.attributes["prst"]);
7725
+ const result = [];
7726
+ if (el.elements) {
7727
+ for (const child of el.elements) if (child.name === "a:gd" && child.attributes) {
7728
+ const name = child.attributes["name"];
7729
+ const fmla = child.attributes["fmla"];
7730
+ if (name !== void 0 && fmla !== void 0) result.push({
7731
+ name: String(name),
7732
+ formula: String(fmla)
7733
+ });
7734
+ }
7735
+ }
7771
7736
  return result;
7772
7737
  }
7773
7738
  };
7774
- const shape3DDesc = {
7739
+ const presetGeometryDesc = {
7775
7740
  kind: "custom",
7776
7741
  stringify(opts, ctx) {
7777
- const parts = [];
7778
- if (opts.bevelT) {
7779
- const bevelXml = stringify$1(bevelDesc, opts.bevelT, ctx);
7780
- if (bevelXml) parts.push(bevelXml.replace("<a:bevel", "<a:bevelT"));
7781
- }
7782
- if (opts.bevelB) {
7783
- const bevelXml = stringify$1(bevelDesc, opts.bevelB, ctx);
7784
- if (bevelXml) parts.push(bevelXml.replace("<a:bevel", "<a:bevelB"));
7785
- }
7786
- if (opts.extrusionColor) {
7787
- const colorXml = stringify$1(solidFillDesc, opts.extrusionColor, ctx);
7788
- if (colorXml) parts.push(`<a:extrusionClr>${colorXml}</a:extrusionClr>`);
7789
- }
7790
- if (opts.contourColor) {
7791
- const colorXml = stringify$1(solidFillDesc, opts.contourColor, ctx);
7792
- if (colorXml) parts.push(`<a:contourClr>${colorXml}</a:contourClr>`);
7793
- }
7794
- const attrParts = [];
7795
- if (opts.z !== void 0) attrParts.push(`z="${opts.z}"`);
7796
- if (opts.extrusionH !== void 0) attrParts.push(`extrusionH="${opts.extrusionH}"`);
7797
- if (opts.contourW !== void 0) attrParts.push(`contourW="${opts.contourW}"`);
7798
- if (opts.prstMaterial !== void 0) attrParts.push(`prstMaterial="${escapeXml(xsdMaterialType.to(opts.prstMaterial))}"`);
7799
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7800
- const content = parts.join("");
7801
- if (!attrStr && !content) return void 0;
7802
- if (!content) return `<a:sp3d${attrStr}/>`;
7803
- return `<a:sp3d${attrStr}>${content}</a:sp3d>`;
7742
+ const prst = opts.preset ?? "rect";
7743
+ let avXml = "";
7744
+ if (opts.adjustmentValues) avXml = stringify$1(adjustmentValuesDesc, opts.adjustmentValues, ctx) ?? "<a:avLst/>";
7745
+ else avXml = "<a:avLst/>";
7746
+ return `<a:prstGeom prst="${escapeXml(prst)}">${avXml}</a:prstGeom>`;
7804
7747
  },
7805
7748
  parse(el, ctx) {
7806
7749
  const result = {};
7807
- if (el.attributes?.["z"] !== void 0) result.z = Number(el.attributes["z"]);
7808
- if (el.attributes?.["extrusionH"] !== void 0) result.extrusionH = Number(el.attributes["extrusionH"]);
7809
- if (el.attributes?.["contourW"] !== void 0) result.contourW = Number(el.attributes["contourW"]);
7810
- if (el.attributes?.["prstMaterial"] !== void 0) result.prstMaterial = xsdMaterialType.from(String(el.attributes["prstMaterial"]));
7811
- const bevelT = findChild(el, "a:bevelT");
7812
- if (bevelT) result.bevelT = parse$1(bevelDesc, bevelT, ctx);
7813
- const bevelB = findChild(el, "a:bevelB");
7814
- if (bevelB) result.bevelB = parse$1(bevelDesc, bevelB, ctx);
7815
- const extrusionClr = findChild(el, "a:extrusionClr");
7816
- if (extrusionClr) {
7817
- const solidFill = findChild(extrusionClr, "a:solidFill");
7818
- if (solidFill) result.extrusionColor = parse$1(solidFillDesc, solidFill, ctx);
7819
- }
7820
- const contourClr = findChild(el, "a:contourClr");
7821
- if (contourClr) {
7822
- const solidFill = findChild(contourClr, "a:solidFill");
7823
- if (solidFill) result.contourColor = parse$1(solidFillDesc, solidFill, ctx);
7750
+ if (el.attributes?.["prst"] !== void 0) result.preset = String(el.attributes["prst"]);
7751
+ const avLst = findChild(el, "a:avLst");
7752
+ if (avLst) {
7753
+ const guides = parse$1(adjustmentValuesDesc, avLst, ctx);
7754
+ if (guides.length > 0) result.adjustmentValues = guides;
7824
7755
  }
7825
7756
  return result;
7826
7757
  }
7827
7758
  };
7828
- const cameraDesc = {
7829
- kind: "custom",
7830
- stringify(opts, _ctx) {
7831
- const attrParts = [];
7832
- attrParts.push(`prst="${escapeXml(opts.preset)}"`);
7833
- if (opts.fov !== void 0) attrParts.push(`fov="${opts.fov}"`);
7834
- if (opts.zoom !== void 0) attrParts.push(`zoom="${escapeXml(opts.zoom)}"`);
7835
- const attrStr = " " + attrParts.join(" ");
7836
- const parts = [];
7837
- if (opts.rotation) parts.push(stringifySphereCoords(opts.rotation));
7838
- const content = parts.join("");
7839
- if (!content) return `<a:camera${attrStr}/>`;
7840
- return `<a:camera${attrStr}>${content}</a:camera>`;
7841
- },
7842
- parse(el, _ctx) {
7843
- const result = {};
7844
- if (el.attributes?.["prst"] !== void 0) result.preset = String(el.attributes["prst"]);
7845
- if (el.attributes?.["fov"] !== void 0) result.fov = Number(el.attributes["fov"]);
7846
- if (el.attributes?.["zoom"] !== void 0) result.zoom = String(el.attributes["zoom"]);
7847
- const rot = findChild(el, "a:rot");
7848
- if (rot) result.rotation = readSphereCoords(rot);
7849
- return result;
7759
+ function stringifyAdjustPoint(pt) {
7760
+ return `<a:pt x="${escapeXml(pt.x)}" y="${escapeXml(pt.y)}"/>`;
7761
+ }
7762
+ function stringifyPathCommand(cmd) {
7763
+ switch (cmd.command) {
7764
+ case "moveTo": return `<a:moveTo>${stringifyAdjustPoint(cmd.point)}</a:moveTo>`;
7765
+ case "lineTo": return `<a:lnTo>${stringifyAdjustPoint(cmd.point)}</a:lnTo>`;
7766
+ case "arcTo": return `<a:arcTo wR="${escapeXml(cmd.widthRadius)}" hR="${escapeXml(cmd.heightRadius)}" stAng="${escapeXml(cmd.startAngle)}" swAng="${escapeXml(cmd.sweepAngle)}"/>`;
7767
+ case "quadBezTo": return `<a:quadBezTo>${cmd.points.map(stringifyAdjustPoint).join("")}</a:quadBezTo>`;
7768
+ case "cubicBezTo": return `<a:cubicBezTo>${cmd.points.map(stringifyAdjustPoint).join("")}</a:cubicBezTo>`;
7769
+ case "close": return "<a:close/>";
7770
+ }
7771
+ }
7772
+ function stringifyPath(path) {
7773
+ const attrs = [];
7774
+ if (path.w !== void 0) attrs.push(`w="${path.w}"`);
7775
+ if (path.h !== void 0) attrs.push(`h="${path.h}"`);
7776
+ if (path.fill !== void 0) attrs.push(`fill="${escapeXml(path.fill)}"`);
7777
+ if (path.stroke !== void 0) attrs.push(`stroke="${path.stroke}"`);
7778
+ if (path.extrusionOk !== void 0) attrs.push(`extrusionOk="${path.extrusionOk}"`);
7779
+ const attrStr = attrs.length ? " " + attrs.join(" ") : "";
7780
+ const cmds = path.commands.map(stringifyPathCommand).join("");
7781
+ if (!cmds && !attrStr) return "<a:path/>";
7782
+ return `<a:path${attrStr}>${cmds}</a:path>`;
7783
+ }
7784
+ function readAdjustPoint(el) {
7785
+ if (!el.attributes) return void 0;
7786
+ const x = el.attributes["x"];
7787
+ const y = el.attributes["y"];
7788
+ if (x === void 0 || y === void 0) return void 0;
7789
+ return {
7790
+ x: String(x),
7791
+ y: String(y)
7792
+ };
7793
+ }
7794
+ function readPathCommand(tag, el) {
7795
+ switch (tag) {
7796
+ case "a:moveTo": {
7797
+ const pt = el.elements?.find((c) => c.name === "a:pt");
7798
+ if (!pt) return void 0;
7799
+ const point = readAdjustPoint(pt);
7800
+ if (!point) return void 0;
7801
+ return {
7802
+ command: "moveTo",
7803
+ point
7804
+ };
7805
+ }
7806
+ case "a:lnTo": {
7807
+ const pt = el.elements?.find((c) => c.name === "a:pt");
7808
+ if (!pt) return void 0;
7809
+ const point = readAdjustPoint(pt);
7810
+ if (!point) return void 0;
7811
+ return {
7812
+ command: "lineTo",
7813
+ point
7814
+ };
7815
+ }
7816
+ case "a:arcTo": {
7817
+ const a = el.attributes;
7818
+ if (!a) return void 0;
7819
+ return {
7820
+ command: "arcTo",
7821
+ widthRadius: String(a["wR"] ?? ""),
7822
+ heightRadius: String(a["hR"] ?? ""),
7823
+ startAngle: String(a["stAng"] ?? ""),
7824
+ sweepAngle: String(a["swAng"] ?? "")
7825
+ };
7826
+ }
7827
+ case "a:quadBezTo": {
7828
+ const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(readAdjustPoint).filter((p) => p !== void 0);
7829
+ if (points.length < 2) return void 0;
7830
+ return {
7831
+ command: "quadBezTo",
7832
+ points: [points[0], points[1]]
7833
+ };
7834
+ }
7835
+ case "a:cubicBezTo": {
7836
+ const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(readAdjustPoint).filter((p) => p !== void 0);
7837
+ if (points.length < 3) return void 0;
7838
+ return {
7839
+ command: "cubicBezTo",
7840
+ points: [
7841
+ points[0],
7842
+ points[1],
7843
+ points[2]
7844
+ ]
7845
+ };
7846
+ }
7847
+ case "a:close": return { command: "close" };
7848
+ default: return;
7850
7849
  }
7851
- };
7852
- const lightRigDesc = {
7853
- kind: "custom",
7854
- stringify(opts, _ctx) {
7855
- const attrParts = [];
7856
- attrParts.push(`rig="${escapeXml(opts.rig)}"`);
7857
- attrParts.push(`dir="${escapeXml(opts.direction)}"`);
7858
- const attrStr = " " + attrParts.join(" ");
7859
- const parts = [];
7860
- if (opts.rotation) parts.push(stringifySphereCoords(opts.rotation));
7861
- const content = parts.join("");
7862
- if (!content) return `<a:lightRig${attrStr}/>`;
7863
- return `<a:lightRig${attrStr}>${content}</a:lightRig>`;
7864
- },
7865
- parse(el, _ctx) {
7866
- const result = {};
7867
- if (el.attributes?.["rig"] !== void 0) result.rig = String(el.attributes["rig"]);
7868
- if (el.attributes?.["dir"] !== void 0) result.direction = String(el.attributes["dir"]);
7869
- const rot = findChild(el, "a:rot");
7870
- if (rot) result.rotation = readSphereCoords(rot);
7871
- return result;
7850
+ }
7851
+ function readPath(el) {
7852
+ const result = {};
7853
+ if (el.attributes) {
7854
+ if (el.attributes["w"] !== void 0) result.w = Number(el.attributes["w"]);
7855
+ if (el.attributes["h"] !== void 0) result.h = Number(el.attributes["h"]);
7856
+ if (el.attributes["fill"] !== void 0) result.fill = String(el.attributes["fill"]);
7857
+ if (el.attributes["stroke"] !== void 0) result.stroke = el.attributes["stroke"] !== "0" && el.attributes["stroke"] !== "false";
7858
+ if (el.attributes["extrusionOk"] !== void 0) result.extrusionOk = el.attributes["extrusionOk"] !== "0" && el.attributes["extrusionOk"] !== "false";
7872
7859
  }
7873
- };
7874
- const scene3DDesc = {
7875
- kind: "custom",
7876
- stringify(opts, ctx) {
7877
- const parts = [];
7878
- const cameraXml = stringify$1(cameraDesc, opts.camera, ctx);
7879
- if (cameraXml) parts.push(cameraXml);
7880
- const lightRigXml = stringify$1(lightRigDesc, opts.lightRig, ctx);
7881
- if (lightRigXml) parts.push(lightRigXml);
7882
- if (opts.backdrop) parts.push(stringifyBackdrop(opts.backdrop));
7883
- const content = parts.join("");
7884
- if (!content) return void 0;
7885
- return `<a:scene3d>${content}</a:scene3d>`;
7886
- },
7887
- parse(el, ctx) {
7888
- const result = {};
7889
- const camera = findChild(el, "a:camera");
7890
- if (camera) result.camera = parse$1(cameraDesc, camera, ctx);
7891
- const lightRig = findChild(el, "a:lightRig");
7892
- if (lightRig) result.lightRig = parse$1(lightRigDesc, lightRig, ctx);
7893
- const backdrop = findChild(el, "a:backdrop");
7894
- if (backdrop) result.backdrop = readBackdrop(backdrop);
7895
- return result;
7860
+ const commands = [];
7861
+ if (el.elements) {
7862
+ for (const child of el.elements) if (child.name) {
7863
+ const cmd = readPathCommand(child.name, child);
7864
+ if (cmd) commands.push(cmd);
7865
+ }
7896
7866
  }
7897
- };
7898
- function stringifyPoint3D(name, point) {
7899
- return `<${name} x="${point.x}" y="${point.y}" z="${point.z}"/>`;
7867
+ if (commands.length > 0) result.commands = commands;
7868
+ return result;
7900
7869
  }
7901
- function stringifyVector3D(name, vector) {
7902
- return `<${name} dx="${vector.dx}" dy="${vector.dy}" dz="${vector.dz}"/>`;
7870
+ function stringifyGuideList(tag, guides) {
7871
+ if (!guides || guides.length === 0) return `<${tag}/>`;
7872
+ return `<${tag}>${guides.map((g) => `<a:gd name="${escapeXml(g.name)}" fmla="${escapeXml(g.formula)}"/>`).join("")}</${tag}>`;
7903
7873
  }
7904
- function stringifyBackdrop(opts) {
7905
- return `<a:backdrop>${stringifyPoint3D("a:anchor", opts.anchor) + stringifyVector3D("a:norm", opts.normal) + stringifyVector3D("a:up", opts.up)}</a:backdrop>`;
7874
+ function readGuideList(el) {
7875
+ const result = [];
7876
+ if (el.elements) {
7877
+ for (const child of el.elements) if (child.name === "a:gd" && child.attributes) {
7878
+ const name = child.attributes["name"];
7879
+ const fmla = child.attributes["fmla"];
7880
+ if (name !== void 0 && fmla !== void 0) result.push({
7881
+ name: String(name),
7882
+ formula: String(fmla)
7883
+ });
7884
+ }
7885
+ }
7886
+ return result;
7906
7887
  }
7907
- function readPoint3D(el) {
7908
- const x = el.attributes?.["x"];
7909
- const y = el.attributes?.["y"];
7910
- const z = el.attributes?.["z"];
7911
- if (x === void 0 || y === void 0 || z === void 0) return void 0;
7888
+ function stringifyAdjustHandlePos(pos) {
7889
+ return `<a:pos x="${escapeXml(pos.x)}" y="${escapeXml(pos.y)}"/>`;
7890
+ }
7891
+ function stringifyXYAdjustHandle(h) {
7892
+ const attrs = [];
7893
+ if (h.guideRefX !== void 0) attrs.push(`gdRefX="${escapeXml(h.guideRefX)}"`);
7894
+ if (h.minX !== void 0) attrs.push(`minX="${escapeXml(h.minX)}"`);
7895
+ if (h.maxX !== void 0) attrs.push(`maxX="${escapeXml(h.maxX)}"`);
7896
+ if (h.guideRefY !== void 0) attrs.push(`gdRefY="${escapeXml(h.guideRefY)}"`);
7897
+ if (h.minY !== void 0) attrs.push(`minY="${escapeXml(h.minY)}"`);
7898
+ if (h.maxY !== void 0) attrs.push(`maxY="${escapeXml(h.maxY)}"`);
7899
+ return `<a:ahXY${attrs.length ? " " + attrs.join(" ") : ""}>${stringifyAdjustHandlePos(h.position)}</a:ahXY>`;
7900
+ }
7901
+ function stringifyPolarAdjustHandle(h) {
7902
+ const attrs = [];
7903
+ if (h.guideRefRadius !== void 0) attrs.push(`gdRefR="${escapeXml(h.guideRefRadius)}"`);
7904
+ if (h.minRadius !== void 0) attrs.push(`minR="${escapeXml(h.minRadius)}"`);
7905
+ if (h.maxRadius !== void 0) attrs.push(`maxR="${escapeXml(h.maxRadius)}"`);
7906
+ if (h.guideRefAngle !== void 0) attrs.push(`gdRefAng="${escapeXml(h.guideRefAngle)}"`);
7907
+ if (h.minAngle !== void 0) attrs.push(`minAng="${escapeXml(h.minAngle)}"`);
7908
+ if (h.maxAngle !== void 0) attrs.push(`maxAng="${escapeXml(h.maxAngle)}"`);
7909
+ return `<a:ahPolar${attrs.length ? " " + attrs.join(" ") : ""}>${stringifyAdjustHandlePos(h.position)}</a:ahPolar>`;
7910
+ }
7911
+ function stringifyAdjustHandle(h) {
7912
+ return h.type === "xy" ? stringifyXYAdjustHandle(h) : stringifyPolarAdjustHandle(h);
7913
+ }
7914
+ function readAdjustHandlePos(el) {
7915
+ const pos = el.elements?.find((c) => c.name === "a:pos");
7916
+ if (!pos?.attributes) return void 0;
7917
+ const x = pos.attributes["x"];
7918
+ const y = pos.attributes["y"];
7919
+ if (x === void 0 || y === void 0) return void 0;
7912
7920
  return {
7913
- x: Number(x),
7914
- y: Number(y),
7915
- z: Number(z)
7921
+ x: String(x),
7922
+ y: String(y)
7916
7923
  };
7917
7924
  }
7918
- function readVector3D(el) {
7919
- const dx = el.attributes?.["dx"];
7920
- const dy = el.attributes?.["dy"];
7921
- const dz = el.attributes?.["dz"];
7922
- if (dx === void 0 || dy === void 0 || dz === void 0) return void 0;
7925
+ function readXYAdjustHandle(el) {
7926
+ const position = readAdjustHandlePos(el);
7927
+ if (!position) return void 0;
7928
+ const result = {
7929
+ type: "xy",
7930
+ position
7931
+ };
7932
+ if (el.attributes?.["gdRefX"] !== void 0) result.guideRefX = String(el.attributes["gdRefX"]);
7933
+ if (el.attributes?.["minX"] !== void 0) result.minX = String(el.attributes["minX"]);
7934
+ if (el.attributes?.["maxX"] !== void 0) result.maxX = String(el.attributes["maxX"]);
7935
+ if (el.attributes?.["gdRefY"] !== void 0) result.guideRefY = String(el.attributes["gdRefY"]);
7936
+ if (el.attributes?.["minY"] !== void 0) result.minY = String(el.attributes["minY"]);
7937
+ if (el.attributes?.["maxY"] !== void 0) result.maxY = String(el.attributes["maxY"]);
7938
+ return result;
7939
+ }
7940
+ function readPolarAdjustHandle(el) {
7941
+ const position = readAdjustHandlePos(el);
7942
+ if (!position) return void 0;
7943
+ const result = {
7944
+ type: "polar",
7945
+ position
7946
+ };
7947
+ if (el.attributes?.["gdRefR"] !== void 0) result.guideRefRadius = String(el.attributes["gdRefR"]);
7948
+ if (el.attributes?.["minR"] !== void 0) result.minRadius = String(el.attributes["minR"]);
7949
+ if (el.attributes?.["maxR"] !== void 0) result.maxRadius = String(el.attributes["maxR"]);
7950
+ if (el.attributes?.["gdRefAng"] !== void 0) result.guideRefAngle = String(el.attributes["gdRefAng"]);
7951
+ if (el.attributes?.["minAng"] !== void 0) result.minAngle = String(el.attributes["minAng"]);
7952
+ if (el.attributes?.["maxAng"] !== void 0) result.maxAngle = String(el.attributes["maxAng"]);
7953
+ return result;
7954
+ }
7955
+ function stringifyConnectionSite(site) {
7956
+ return `<a:cxn ang="${escapeXml(site.angle)}">${stringifyAdjustHandlePos(site.position)}</a:cxn>`;
7957
+ }
7958
+ function readConnectionSite(el) {
7959
+ const ang = el.attributes?.["ang"];
7960
+ if (ang === void 0) return void 0;
7961
+ const position = readAdjustHandlePos(el);
7962
+ if (!position) return void 0;
7923
7963
  return {
7924
- dx: Number(dx),
7925
- dy: Number(dy),
7926
- dz: Number(dz)
7964
+ angle: String(ang),
7965
+ position
7927
7966
  };
7928
7967
  }
7929
- function readBackdrop(el) {
7930
- const anchor = findChild(el, "a:anchor");
7931
- const norm = findChild(el, "a:norm");
7932
- const up = findChild(el, "a:up");
7933
- if (!anchor || !norm || !up) return void 0;
7934
- const anchorPt = readPoint3D(anchor);
7935
- const normVec = readVector3D(norm);
7936
- const upVec = readVector3D(up);
7937
- if (!anchorPt || !normVec || !upVec) return void 0;
7968
+ function stringifyGeomRect(rect) {
7969
+ return `<a:rect l="${escapeXml(rect.left)}" t="${escapeXml(rect.top)}" r="${escapeXml(rect.right)}" b="${escapeXml(rect.bottom)}"/>`;
7970
+ }
7971
+ function readGeomRect(el) {
7972
+ const a = el.attributes;
7973
+ if (!a) return void 0;
7974
+ const l = a["l"];
7975
+ const t = a["t"];
7976
+ const r = a["r"];
7977
+ const b = a["b"];
7978
+ if (l === void 0 || t === void 0 || r === void 0 || b === void 0) return void 0;
7938
7979
  return {
7939
- anchor: anchorPt,
7940
- normal: normVec,
7941
- up: upVec
7980
+ left: String(l),
7981
+ top: String(t),
7982
+ right: String(r),
7983
+ bottom: String(b)
7942
7984
  };
7943
7985
  }
7986
+ const customGeometryDesc = {
7987
+ kind: "custom",
7988
+ stringify(opts, _ctx) {
7989
+ const parts = [];
7990
+ if (opts.adjustmentValues && opts.adjustmentValues.length > 0) parts.push(stringifyGuideList("a:avLst", opts.adjustmentValues));
7991
+ else parts.push("<a:avLst/>");
7992
+ if (opts.guides && opts.guides.length > 0) parts.push(stringifyGuideList("a:gdLst", opts.guides));
7993
+ if (opts.adjustHandles && opts.adjustHandles.length > 0) {
7994
+ const inner = opts.adjustHandles.map(stringifyAdjustHandle).join("");
7995
+ parts.push(`<a:ahLst>${inner}</a:ahLst>`);
7996
+ }
7997
+ if (opts.connectionSites && opts.connectionSites.length > 0) {
7998
+ const inner = opts.connectionSites.map(stringifyConnectionSite).join("");
7999
+ parts.push(`<a:cxnLst>${inner}</a:cxnLst>`);
8000
+ }
8001
+ if (opts.textRectangle) parts.push(stringifyGeomRect(opts.textRectangle));
8002
+ const pathsXml = opts.pathList.map(stringifyPath).join("");
8003
+ parts.push(`<a:pathLst>${pathsXml}</a:pathLst>`);
8004
+ return `<a:custGeom>${parts.join("")}</a:custGeom>`;
8005
+ },
8006
+ parse(el, _ctx) {
8007
+ const result = {};
8008
+ const avLst = findChild(el, "a:avLst");
8009
+ if (avLst) {
8010
+ const guides = readGuideList(avLst);
8011
+ if (guides.length > 0) result.adjustmentValues = guides;
8012
+ }
8013
+ const gdLst = findChild(el, "a:gdLst");
8014
+ if (gdLst) {
8015
+ const guides = readGuideList(gdLst);
8016
+ if (guides.length > 0) result.guides = guides;
8017
+ }
8018
+ const ahLst = findChild(el, "a:ahLst");
8019
+ if (ahLst?.elements) {
8020
+ const handles = [];
8021
+ for (const child of ahLst.elements) if (child.name === "a:ahXY") {
8022
+ const h = readXYAdjustHandle(child);
8023
+ if (h) handles.push(h);
8024
+ } else if (child.name === "a:ahPolar") {
8025
+ const h = readPolarAdjustHandle(child);
8026
+ if (h) handles.push(h);
8027
+ }
8028
+ if (handles.length > 0) result.adjustHandles = handles;
8029
+ }
8030
+ const cxnLst = findChild(el, "a:cxnLst");
8031
+ if (cxnLst?.elements) {
8032
+ const sites = [];
8033
+ for (const child of cxnLst.elements) if (child.name === "a:cxn") {
8034
+ const site = readConnectionSite(child);
8035
+ if (site) sites.push(site);
8036
+ }
8037
+ if (sites.length > 0) result.connectionSites = sites;
8038
+ }
8039
+ const rect = findChild(el, "a:rect");
8040
+ if (rect) {
8041
+ const textRectangle = readGeomRect(rect);
8042
+ if (textRectangle) result.textRectangle = textRectangle;
8043
+ }
8044
+ const pathLst = findChild(el, "a:pathLst");
8045
+ if (pathLst?.elements) {
8046
+ const paths = [];
8047
+ for (const child of pathLst.elements) if (child.name === "a:path") {
8048
+ const p = readPath(child);
8049
+ if (p.commands && p.commands.length > 0) paths.push(p);
8050
+ }
8051
+ if (paths.length > 0) result.pathList = paths;
8052
+ }
8053
+ return result;
8054
+ }
8055
+ };
7944
8056
  //#endregion
7945
- //#region src/drawingml/blip/blip-descriptors.ts
8057
+ //#region src/drawingml/transform-descriptors.ts
7946
8058
  /**
7947
- * Blip descriptor for DrawingML pictures.
8059
+ * Transform 2D descriptor for DrawingML shapes.
7948
8060
  *
7949
8061
  * @module
7950
8062
  */
7951
- const tileDesc = {
7952
- kind: "custom",
7953
- stringify(opts, _ctx) {
7954
- const attrParts = [];
7955
- if (opts.tx !== void 0) attrParts.push(`tx="${opts.tx}"`);
7956
- if (opts.ty !== void 0) attrParts.push(`ty="${opts.ty}"`);
7957
- if (opts.sx !== void 0) attrParts.push(`sx="${opts.sx}"`);
7958
- if (opts.sy !== void 0) attrParts.push(`sy="${opts.sy}"`);
7959
- if (opts.flip !== void 0) attrParts.push(`flip="${escapeXml(opts.flip)}"`);
7960
- if (opts.align !== void 0) attrParts.push(`algn="${escapeXml(xsdRectAlignment.to(opts.align))}"`);
7961
- return `<a:tile${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
7962
- },
7963
- parse(el, _ctx) {
7964
- const result = {};
7965
- if (el.attributes?.["tx"] !== void 0) result.tx = Number(el.attributes["tx"]);
7966
- if (el.attributes?.["ty"] !== void 0) result.ty = Number(el.attributes["ty"]);
7967
- if (el.attributes?.["sx"] !== void 0) result.sx = Number(el.attributes["sx"]);
7968
- if (el.attributes?.["sy"] !== void 0) result.sy = Number(el.attributes["sy"]);
7969
- if (el.attributes?.["flip"] !== void 0) result.flip = String(el.attributes["flip"]);
7970
- if (el.attributes?.["algn"] !== void 0) result.align = xsdRectAlignment.from(String(el.attributes["algn"]));
7971
- return result;
7972
- }
7973
- };
7974
- const sourceRectangleDesc = {
8063
+ const transform2DDesc = {
7975
8064
  kind: "custom",
7976
8065
  stringify(opts, _ctx) {
8066
+ const parts = [];
7977
8067
  const attrParts = [];
7978
- if (opts.left !== void 0) attrParts.push(`l="${opts.left}"`);
7979
- if (opts.top !== void 0) attrParts.push(`t="${opts.top}"`);
7980
- if (opts.right !== void 0) attrParts.push(`r="${opts.right}"`);
7981
- if (opts.bottom !== void 0) attrParts.push(`b="${opts.bottom}"`);
7982
- return `<a:srcRect${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
8068
+ if (opts.flipHorizontal !== void 0) attrParts.push(`flipH="${opts.flipHorizontal ? 1 : 0}"`);
8069
+ if (opts.flipVertical !== void 0) attrParts.push(`flipV="${opts.flipVertical ? 1 : 0}"`);
8070
+ if (opts.rotation !== void 0) attrParts.push(`rot="${opts.rotation}"`);
8071
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8072
+ if (opts.x !== void 0 || opts.y !== void 0) {
8073
+ const x = opts.x !== void 0 ? convertToEmu(opts.x) : 0;
8074
+ const y = opts.y !== void 0 ? convertToEmu(opts.y) : 0;
8075
+ parts.push(`<a:off x="${x}" y="${y}"/>`);
8076
+ }
8077
+ if (opts.width !== void 0 || opts.height !== void 0) {
8078
+ const cx = opts.width !== void 0 ? convertToEmu(opts.width) : 0;
8079
+ const cy = opts.height !== void 0 ? convertToEmu(opts.height) : 0;
8080
+ parts.push(`<a:ext cx="${cx}" cy="${cy}"/>`);
8081
+ }
8082
+ if (parts.length === 0 && !attrStr) return void 0;
8083
+ if (parts.length === 0) return `<a:xfrm${attrStr}/>`;
8084
+ return `<a:xfrm${attrStr}>${parts.join("")}</a:xfrm>`;
7983
8085
  },
7984
8086
  parse(el, _ctx) {
7985
8087
  const result = {};
7986
- if (el.attributes?.["l"] !== void 0) result.left = Number(el.attributes["l"]);
7987
- if (el.attributes?.["t"] !== void 0) result.top = Number(el.attributes["t"]);
7988
- if (el.attributes?.["r"] !== void 0) result.right = Number(el.attributes["r"]);
7989
- if (el.attributes?.["b"] !== void 0) result.bottom = Number(el.attributes["b"]);
8088
+ if (el.attributes) {
8089
+ if (el.attributes["flipH"] !== void 0) result.flipHorizontal = el.attributes["flipH"] === 1 || el.attributes["flipH"] === "1";
8090
+ if (el.attributes["flipV"] !== void 0) result.flipVertical = el.attributes["flipV"] === 1 || el.attributes["flipV"] === "1";
8091
+ if (el.attributes["rot"] !== void 0) result.rotation = Number(el.attributes["rot"]);
8092
+ }
8093
+ const off = findChild(el, "a:off");
8094
+ if (off?.attributes) {
8095
+ result.x = attrMeasure(off, "x") ?? 0;
8096
+ result.y = attrMeasure(off, "y") ?? 0;
8097
+ }
8098
+ const ext = findChild(el, "a:ext");
8099
+ if (ext?.attributes) {
8100
+ result.width = attrMeasure(ext, "cx") ?? 0;
8101
+ result.height = attrMeasure(ext, "cy") ?? 0;
8102
+ }
7990
8103
  return result;
7991
8104
  }
7992
8105
  };
7993
- const stretchDesc = {
8106
+ const groupTransform2DDesc = {
7994
8107
  kind: "custom",
7995
- stringify(opts, _ctx) {
7996
- const attrParts = [];
7997
- if (opts.left !== void 0) attrParts.push(`l="${opts.left}"`);
7998
- if (opts.top !== void 0) attrParts.push(`t="${opts.top}"`);
7999
- if (opts.right !== void 0) attrParts.push(`r="${opts.right}"`);
8000
- if (opts.bottom !== void 0) attrParts.push(`b="${opts.bottom}"`);
8001
- return `<a:stretch><a:fillRect${attrParts.length ? " " + attrParts.join(" ") : ""}/></a:stretch>`;
8108
+ stringify(opts, ctx) {
8109
+ const base = transform2DDesc.stringify(opts, ctx) ?? "<a:xfrm/>";
8110
+ const chOff = `<a:chOff x="${opts.childOffsetX ?? 0}" y="${opts.childOffsetY ?? 0}"/>`;
8111
+ const chExt = `<a:chExt cx="${opts.childExtentWidth ?? 0}" cy="${opts.childExtentHeight ?? 0}"/>`;
8112
+ if (base.endsWith("/>")) return `<a:xfrm>${chOff}${chExt}</a:xfrm>`;
8113
+ return base.replace(/<\/a:xfrm>$/, `${chOff}${chExt}</a:xfrm>`);
8002
8114
  },
8003
- parse(el, _ctx) {
8004
- const fillRect = findChild(el, "a:fillRect");
8005
- if (!fillRect) return {};
8006
- const result = {};
8007
- if (fillRect.attributes?.["l"] !== void 0) result.left = Number(fillRect.attributes["l"]);
8008
- if (fillRect.attributes?.["t"] !== void 0) result.top = Number(fillRect.attributes["t"]);
8009
- if (fillRect.attributes?.["r"] !== void 0) result.right = Number(fillRect.attributes["r"]);
8010
- if (fillRect.attributes?.["b"] !== void 0) result.bottom = Number(fillRect.attributes["b"]);
8115
+ parse(el, ctx) {
8116
+ const result = transform2DDesc.parse(el, ctx);
8117
+ const chOff = findChild(el, "a:chOff");
8118
+ if (chOff?.attributes) {
8119
+ result.childOffsetX = attrMeasure(chOff, "x") ?? 0;
8120
+ result.childOffsetY = attrMeasure(chOff, "y") ?? 0;
8121
+ }
8122
+ const chExt = findChild(el, "a:chExt");
8123
+ if (chExt?.attributes) {
8124
+ result.childExtentWidth = attrMeasure(chExt, "cx") ?? 0;
8125
+ result.childExtentHeight = attrMeasure(chExt, "cy") ?? 0;
8126
+ }
8011
8127
  return result;
8012
8128
  }
8013
8129
  };
8014
- function stringifyBlipEffects(opts, ctx) {
8015
- const parts = [];
8016
- if (opts.grayscale) parts.push("<a:grayscl/>");
8017
- if (opts.luminance) {
8018
- const attrParts = [];
8019
- if (opts.luminance.bright !== void 0) attrParts.push(`bright="${opts.luminance.bright}"`);
8020
- if (opts.luminance.contrast !== void 0) attrParts.push(`contrast="${opts.luminance.contrast}"`);
8021
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8022
- parts.push(`<a:lum${attrStr}/>`);
8023
- }
8024
- if (opts.hsl) {
8025
- const attrParts = [];
8026
- if (opts.hsl.hue !== void 0) attrParts.push(`hue="${opts.hsl.hue}"`);
8027
- if (opts.hsl.saturation !== void 0) attrParts.push(`sat="${opts.hsl.saturation}"`);
8028
- if (opts.hsl.luminance !== void 0) attrParts.push(`lum="${opts.hsl.luminance}"`);
8029
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8030
- parts.push(`<a:hsl${attrStr}/>`);
8031
- }
8032
- if (opts.tint) {
8033
- const attrParts = [];
8034
- if (opts.tint.hue !== void 0) attrParts.push(`hue="${opts.tint.hue}"`);
8035
- if (opts.tint.amount !== void 0) attrParts.push(`amt="${opts.tint.amount}"`);
8036
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8037
- parts.push(`<a:tint${attrStr}/>`);
8038
- }
8039
- if (opts.duotone) {
8040
- const c1 = stringify$1(solidFillDesc, opts.duotone.color1, ctx);
8041
- const c2 = stringify$1(solidFillDesc, opts.duotone.color2, ctx);
8042
- parts.push(`<a:duotone>${c1 ?? ""}${c2 ?? ""}</a:duotone>`);
8043
- }
8044
- if (opts.biLevel) parts.push(`<a:biLevel thresh="${opts.biLevel.threshold}"/>`);
8045
- if (opts.alphaCeiling) parts.push("<a:alphaCeiling/>");
8046
- if (opts.alphaFloor) parts.push("<a:alphaFloor/>");
8047
- if (opts.alphaInverse !== void 0) if (typeof opts.alphaInverse === "boolean") parts.push("<a:alphaInv/>");
8048
- else {
8049
- const colorXml = stringify$1(solidFillDesc, opts.alphaInverse, ctx);
8050
- parts.push(`<a:alphaInv>${colorXml ?? ""}</a:alphaInv>`);
8051
- }
8052
- if (opts.alphaModFix) {
8053
- const amt = opts.alphaModFix.amount ?? 100;
8054
- parts.push(`<a:alphaModFix amt="${amt}"/>`);
8055
- }
8056
- if (opts.alphaRepl) parts.push(`<a:alphaRepl a="${opts.alphaRepl.amount}"/>`);
8057
- if (opts.alphaBiLevel) parts.push(`<a:alphaBiLevel thresh="${opts.alphaBiLevel.threshold}"/>`);
8058
- if (opts.colorChange) {
8059
- const fromXml = stringify$1(solidFillDesc, opts.colorChange.from, ctx);
8060
- const toXml = stringify$1(solidFillDesc, opts.colorChange.to, ctx);
8061
- const attrParts = [];
8062
- if (opts.colorChange.useAlpha === false) attrParts.push("useA=\"0\"");
8063
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8064
- parts.push(`<a:clrChange${attrStr}><a:clrFrom>${fromXml ?? ""}</a:clrFrom><a:clrTo>${toXml ?? ""}</a:clrTo></a:clrChange>`);
8065
- }
8066
- if (opts.colorRepl) {
8067
- const colorXml = stringify$1(solidFillDesc, opts.colorRepl.color, ctx);
8068
- parts.push(`<a:clrRepl>${colorXml ?? ""}</a:clrRepl>`);
8069
- }
8070
- if (opts.blur) {
8071
- const attrParts = [];
8072
- if (opts.blur.radius !== void 0) attrParts.push(`rad="${opts.blur.radius}"`);
8073
- if (opts.blur.grow === false) attrParts.push("grow=\"0\"");
8074
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8075
- parts.push(`<a:blur${attrStr}/>`);
8076
- }
8077
- return parts.join("");
8130
+ //#endregion
8131
+ //#region src/drawingml/three-d/three-d-descriptors.ts
8132
+ /**
8133
+ * 3D descriptor for DrawingML shapes.
8134
+ *
8135
+ * @module
8136
+ */
8137
+ function stringifySphereCoords(coords) {
8138
+ return `<a:rot lat="${coords.lat}" lon="${coords.lon}" rev="${coords.rev}"/>`;
8078
8139
  }
8079
- function readBlipEffects(el, ctx) {
8080
- const result = {};
8081
- if (findChild(el, "a:grayscl")) result.grayscale = true;
8082
- const lum = findChild(el, "a:lum");
8083
- if (lum) {
8084
- const opts = {};
8085
- if (lum.attributes?.["bright"] !== void 0) opts.bright = Number(String(lum.attributes["bright"]).replace("%", ""));
8086
- if (lum.attributes?.["contrast"] !== void 0) opts.contrast = Number(String(lum.attributes["contrast"]).replace("%", ""));
8087
- result.luminance = opts;
8088
- }
8089
- const hsl = findChild(el, "a:hsl");
8090
- if (hsl) {
8091
- const opts = {};
8092
- if (hsl.attributes?.["hue"] !== void 0) opts.hue = Number(hsl.attributes["hue"]);
8093
- if (hsl.attributes?.["sat"] !== void 0) opts.saturation = Number(String(hsl.attributes["sat"]).replace("%", ""));
8094
- if (hsl.attributes?.["lum"] !== void 0) opts.luminance = Number(String(hsl.attributes["lum"]).replace("%", ""));
8095
- result.hsl = opts;
8096
- }
8097
- const tint = findChild(el, "a:tint");
8098
- if (tint) {
8099
- const opts = {};
8100
- if (tint.attributes?.["hue"] !== void 0) opts.hue = Number(tint.attributes["hue"]);
8101
- if (tint.attributes?.["amt"] !== void 0) opts.amount = Number(String(tint.attributes["amt"]).replace("%", ""));
8102
- result.tint = opts;
8103
- }
8104
- const biLevel = findChild(el, "a:biLevel");
8105
- if (biLevel?.attributes?.["thresh"] !== void 0) result.biLevel = { threshold: Number(String(biLevel.attributes["thresh"]).replace("%", "")) };
8106
- if (findChild(el, "a:alphaCeiling")) result.alphaCeiling = true;
8107
- if (findChild(el, "a:alphaFloor")) result.alphaFloor = true;
8108
- const alphaInv = findChild(el, "a:alphaInv");
8109
- if (alphaInv) {
8110
- const solidFill = findChild(alphaInv, "a:solidFill");
8111
- if (solidFill) result.alphaInverse = parse$1(solidFillDesc, solidFill, ctx);
8112
- else result.alphaInverse = {};
8113
- }
8114
- const alphaModFix = findChild(el, "a:alphaModFix");
8115
- if (alphaModFix) {
8116
- const opts = {};
8117
- if (alphaModFix.attributes?.["amt"] !== void 0) opts.amount = Number(String(alphaModFix.attributes["amt"]).replace("%", ""));
8118
- result.alphaModFix = opts;
8140
+ function readSphereCoords(el) {
8141
+ const lat = el.attributes?.["lat"];
8142
+ const lon = el.attributes?.["lon"];
8143
+ const rev = el.attributes?.["rev"];
8144
+ if (lat === void 0 || lon === void 0 || rev === void 0) return void 0;
8145
+ return {
8146
+ lat: Number(lat),
8147
+ lon: Number(lon),
8148
+ rev: Number(rev)
8149
+ };
8150
+ }
8151
+ const bevelDesc = {
8152
+ kind: "custom",
8153
+ stringify(opts, _ctx) {
8154
+ const attrParts = [];
8155
+ if (opts.w !== void 0) attrParts.push(`w="${opts.w}"`);
8156
+ if (opts.h !== void 0) attrParts.push(`h="${opts.h}"`);
8157
+ if (opts.prst !== void 0) attrParts.push(`prst="${escapeXml(opts.prst)}"`);
8158
+ return `<a:bevel${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
8159
+ },
8160
+ parse(el, _ctx) {
8161
+ const result = {};
8162
+ if (el.attributes?.["w"] !== void 0) result.w = Number(el.attributes["w"]);
8163
+ if (el.attributes?.["h"] !== void 0) result.h = Number(el.attributes["h"]);
8164
+ if (el.attributes?.["prst"] !== void 0) result.prst = String(el.attributes["prst"]);
8165
+ return result;
8119
8166
  }
8120
- const alphaRepl = findChild(el, "a:alphaRepl");
8121
- if (alphaRepl?.attributes?.["a"] !== void 0) result.alphaRepl = { amount: Number(String(alphaRepl.attributes["a"]).replace("%", "")) };
8122
- const alphaBiLevel = findChild(el, "a:alphaBiLevel");
8123
- if (alphaBiLevel?.attributes?.["thresh"] !== void 0) result.alphaBiLevel = { threshold: Number(String(alphaBiLevel.attributes["thresh"]).replace("%", "")) };
8124
- const clrChange = findChild(el, "a:clrChange");
8125
- if (clrChange) {
8126
- const opts = {};
8127
- if (clrChange.attributes?.["useA"] !== void 0) opts.useAlpha = clrChange.attributes["useA"] !== "0";
8128
- const clrFrom = findChild(clrChange, "a:clrFrom");
8129
- if (clrFrom) {
8130
- const fromFill = findChild(clrFrom, "a:solidFill");
8131
- if (fromFill) opts.from = parse$1(solidFillDesc, fromFill, ctx);
8167
+ };
8168
+ const shape3DDesc = {
8169
+ kind: "custom",
8170
+ stringify(opts, ctx) {
8171
+ const parts = [];
8172
+ if (opts.bevelT) {
8173
+ const bevelXml = stringify$1(bevelDesc, opts.bevelT, ctx);
8174
+ if (bevelXml) parts.push(bevelXml.replace("<a:bevel", "<a:bevelT"));
8132
8175
  }
8133
- const clrTo = findChild(clrChange, "a:clrTo");
8134
- if (clrTo) {
8135
- const toFill = findChild(clrTo, "a:solidFill");
8136
- if (toFill) opts.to = parse$1(solidFillDesc, toFill, ctx);
8176
+ if (opts.bevelB) {
8177
+ const bevelXml = stringify$1(bevelDesc, opts.bevelB, ctx);
8178
+ if (bevelXml) parts.push(bevelXml.replace("<a:bevel", "<a:bevelB"));
8137
8179
  }
8138
- result.colorChange = opts;
8139
- }
8140
- const clrRepl = findChild(el, "a:clrRepl");
8141
- if (clrRepl) {
8142
- const solidFill = findChild(clrRepl, "a:solidFill");
8143
- if (solidFill) result.colorRepl = { color: parse$1(solidFillDesc, solidFill, ctx) };
8144
- }
8145
- const blur = findChild(el, "a:blur");
8146
- if (blur) {
8147
- const opts = {};
8148
- if (blur.attributes?.["rad"] !== void 0) opts.radius = Number(blur.attributes["rad"]);
8149
- if (blur.attributes?.["grow"] !== void 0) opts.grow = blur.attributes["grow"] !== "0";
8150
- result.blur = opts;
8151
- }
8152
- const duotone = findChild(el, "a:duotone");
8153
- if (duotone?.elements) {
8154
- const fills = [];
8155
- for (const child of duotone.elements) {
8156
- const sf = findChild(child, "a:solidFill");
8157
- if (sf) fills.push(parse$1(solidFillDesc, sf, ctx));
8180
+ if (opts.extrusionColor) {
8181
+ const colorXml = stringify$1(solidFillDesc, opts.extrusionColor, ctx);
8182
+ if (colorXml) parts.push(`<a:extrusionClr>${colorXml}</a:extrusionClr>`);
8158
8183
  }
8159
- if (fills.length >= 2) result.duotone = {
8160
- color1: fills[0],
8161
- color2: fills[1]
8162
- };
8184
+ if (opts.contourColor) {
8185
+ const colorXml = stringify$1(solidFillDesc, opts.contourColor, ctx);
8186
+ if (colorXml) parts.push(`<a:contourClr>${colorXml}</a:contourClr>`);
8187
+ }
8188
+ const attrParts = [];
8189
+ if (opts.z !== void 0) attrParts.push(`z="${opts.z}"`);
8190
+ if (opts.extrusionH !== void 0) attrParts.push(`extrusionH="${opts.extrusionH}"`);
8191
+ if (opts.contourW !== void 0) attrParts.push(`contourW="${opts.contourW}"`);
8192
+ if (opts.prstMaterial !== void 0) attrParts.push(`prstMaterial="${escapeXml(xsdMaterialType.to(opts.prstMaterial))}"`);
8193
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8194
+ const content = parts.join("");
8195
+ if (!attrStr && !content) return void 0;
8196
+ if (!content) return `<a:sp3d${attrStr}/>`;
8197
+ return `<a:sp3d${attrStr}>${content}</a:sp3d>`;
8198
+ },
8199
+ parse(el, ctx) {
8200
+ const result = {};
8201
+ if (el.attributes?.["z"] !== void 0) result.z = Number(el.attributes["z"]);
8202
+ if (el.attributes?.["extrusionH"] !== void 0) result.extrusionH = Number(el.attributes["extrusionH"]);
8203
+ if (el.attributes?.["contourW"] !== void 0) result.contourW = Number(el.attributes["contourW"]);
8204
+ if (el.attributes?.["prstMaterial"] !== void 0) result.prstMaterial = xsdMaterialType.from(String(el.attributes["prstMaterial"]));
8205
+ const bevelT = findChild(el, "a:bevelT");
8206
+ if (bevelT) result.bevelT = parse$1(bevelDesc, bevelT, ctx);
8207
+ const bevelB = findChild(el, "a:bevelB");
8208
+ if (bevelB) result.bevelB = parse$1(bevelDesc, bevelB, ctx);
8209
+ const extrusionClr = findChild(el, "a:extrusionClr");
8210
+ if (extrusionClr) {
8211
+ const solidFill = findChild(extrusionClr, "a:solidFill");
8212
+ if (solidFill) result.extrusionColor = parse$1(solidFillDesc, solidFill, ctx);
8213
+ }
8214
+ const contourClr = findChild(el, "a:contourClr");
8215
+ if (contourClr) {
8216
+ const solidFill = findChild(contourClr, "a:solidFill");
8217
+ if (solidFill) result.contourColor = parse$1(solidFillDesc, solidFill, ctx);
8218
+ }
8219
+ return result;
8163
8220
  }
8164
- return Object.keys(result).length > 0 ? result : void 0;
8165
- }
8166
- const blipDesc = {
8221
+ };
8222
+ const cameraDesc = {
8167
8223
  kind: "custom",
8168
- stringify(opts, ctx) {
8224
+ stringify(opts, _ctx) {
8169
8225
  const attrParts = [];
8170
- const embedValue = `{${opts.referenceId}}`;
8171
- attrParts.push(`r:embed="${escapeXml(embedValue)}"`);
8172
- attrParts.push("cstate=\"none\"");
8226
+ attrParts.push(`prst="${escapeXml(opts.preset)}"`);
8227
+ if (opts.fov !== void 0) attrParts.push(`fov="${opts.fov}"`);
8228
+ if (opts.zoom !== void 0) attrParts.push(`zoom="${escapeXml(opts.zoom)}"`);
8173
8229
  const attrStr = " " + attrParts.join(" ");
8174
8230
  const parts = [];
8175
- if (opts.blipEffects) parts.push(stringifyBlipEffects(opts.blipEffects, ctx));
8231
+ if (opts.rotation) parts.push(stringifySphereCoords(opts.rotation));
8176
8232
  const content = parts.join("");
8177
- if (!content) return `<a:blip${attrStr}/>`;
8178
- return `<a:blip${attrStr}>${content}</a:blip>`;
8233
+ if (!content) return `<a:camera${attrStr}/>`;
8234
+ return `<a:camera${attrStr}>${content}</a:camera>`;
8179
8235
  },
8180
- parse(el, ctx) {
8236
+ parse(el, _ctx) {
8181
8237
  const result = {};
8182
- const embed = el.attributes?.["r:embed"];
8183
- if (embed !== void 0) result.referenceId = String(embed).replace(/^\{(.+)\}$/, "$1");
8184
- const link = el.attributes?.["r:link"];
8185
- if (link !== void 0) result.referenceId = String(link).replace(/^\{(.+)\}$/, "$1");
8186
- const effects = readBlipEffects(el, ctx);
8187
- if (effects) result.blipEffects = effects;
8238
+ if (el.attributes?.["prst"] !== void 0) result.preset = String(el.attributes["prst"]);
8239
+ if (el.attributes?.["fov"] !== void 0) result.fov = Number(el.attributes["fov"]);
8240
+ if (el.attributes?.["zoom"] !== void 0) result.zoom = String(el.attributes["zoom"]);
8241
+ const rot = findChild(el, "a:rot");
8242
+ if (rot) result.rotation = readSphereCoords(rot);
8188
8243
  return result;
8189
8244
  }
8190
8245
  };
8191
- const blipFillDesc = {
8246
+ const lightRigDesc = {
8192
8247
  kind: "custom",
8193
- stringify(opts, ctx) {
8248
+ stringify(opts, _ctx) {
8194
8249
  const attrParts = [];
8195
- if (opts.dpi !== void 0) attrParts.push(`dpi="${opts.dpi}"`);
8196
- if (opts.rotWithShape !== void 0) attrParts.push(`rotWithShape="${opts.rotWithShape ? 1 : 0}"`);
8197
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8250
+ attrParts.push(`rig="${escapeXml(opts.rig)}"`);
8251
+ attrParts.push(`dir="${escapeXml(opts.direction)}"`);
8252
+ const attrStr = " " + attrParts.join(" ");
8198
8253
  const parts = [];
8199
- if (opts.referenceId) {
8200
- const blipXml = stringify$1(blipDesc, {
8201
- referenceId: opts.referenceId,
8202
- blipEffects: opts.blipEffects
8203
- }, ctx);
8204
- if (blipXml) parts.push(blipXml);
8205
- }
8206
- if (opts.sourceRectangle) {
8207
- const srcRectXml = stringify$1(sourceRectangleDesc, opts.sourceRectangle, ctx);
8208
- if (srcRectXml) parts.push(srcRectXml);
8209
- }
8210
- if (opts.tile) {
8211
- const tileXml = stringify$1(tileDesc, opts.tile, ctx);
8212
- if (tileXml) parts.push(tileXml);
8213
- } else parts.push("<a:stretch><a:fillRect/></a:stretch>");
8254
+ if (opts.rotation) parts.push(stringifySphereCoords(opts.rotation));
8214
8255
  const content = parts.join("");
8215
- if (!attrStr && !content) return void 0;
8216
- if (!content) return `<pic:blipFill${attrStr}/>`;
8217
- return `<pic:blipFill${attrStr}>${content}</pic:blipFill>`;
8256
+ if (!content) return `<a:lightRig${attrStr}/>`;
8257
+ return `<a:lightRig${attrStr}>${content}</a:lightRig>`;
8258
+ },
8259
+ parse(el, _ctx) {
8260
+ const result = {};
8261
+ if (el.attributes?.["rig"] !== void 0) result.rig = String(el.attributes["rig"]);
8262
+ if (el.attributes?.["dir"] !== void 0) result.direction = String(el.attributes["dir"]);
8263
+ const rot = findChild(el, "a:rot");
8264
+ if (rot) result.rotation = readSphereCoords(rot);
8265
+ return result;
8266
+ }
8267
+ };
8268
+ const scene3DDesc = {
8269
+ kind: "custom",
8270
+ stringify(opts, ctx) {
8271
+ const parts = [];
8272
+ const cameraXml = stringify$1(cameraDesc, opts.camera, ctx);
8273
+ if (cameraXml) parts.push(cameraXml);
8274
+ const lightRigXml = stringify$1(lightRigDesc, opts.lightRig, ctx);
8275
+ if (lightRigXml) parts.push(lightRigXml);
8276
+ if (opts.backdrop) parts.push(stringifyBackdrop(opts.backdrop));
8277
+ const content = parts.join("");
8278
+ if (!content) return void 0;
8279
+ return `<a:scene3d>${content}</a:scene3d>`;
8218
8280
  },
8219
8281
  parse(el, ctx) {
8220
8282
  const result = {};
8221
- if (el.attributes?.["dpi"] !== void 0) result.dpi = Number(el.attributes["dpi"]);
8222
- if (el.attributes?.["rotWithShape"] !== void 0) result.rotWithShape = el.attributes["rotWithShape"] !== "0";
8223
- const blip = findChild(el, "a:blip");
8224
- if (blip) {
8225
- const blipResult = parse$1(blipDesc, blip, ctx);
8226
- if (blipResult.referenceId) result.referenceId = blipResult.referenceId;
8227
- if (blipResult.blipEffects) result.blipEffects = blipResult.blipEffects;
8228
- }
8229
- const srcRect = findChild(el, "a:srcRect");
8230
- if (srcRect) result.sourceRectangle = parse$1(sourceRectangleDesc, srcRect, ctx);
8231
- const tile = findChild(el, "a:tile");
8232
- if (tile) result.tile = parse$1(tileDesc, tile, ctx);
8283
+ const camera = findChild(el, "a:camera");
8284
+ if (camera) result.camera = parse$1(cameraDesc, camera, ctx);
8285
+ const lightRig = findChild(el, "a:lightRig");
8286
+ if (lightRig) result.lightRig = parse$1(lightRigDesc, lightRig, ctx);
8287
+ const backdrop = findChild(el, "a:backdrop");
8288
+ if (backdrop) result.backdrop = readBackdrop(backdrop);
8233
8289
  return result;
8234
8290
  }
8235
8291
  };
8292
+ function stringifyPoint3D(name, point) {
8293
+ return `<${name} x="${point.x}" y="${point.y}" z="${point.z}"/>`;
8294
+ }
8295
+ function stringifyVector3D(name, vector) {
8296
+ return `<${name} dx="${vector.dx}" dy="${vector.dy}" dz="${vector.dz}"/>`;
8297
+ }
8298
+ function stringifyBackdrop(opts) {
8299
+ return `<a:backdrop>${stringifyPoint3D("a:anchor", opts.anchor) + stringifyVector3D("a:norm", opts.normal) + stringifyVector3D("a:up", opts.up)}</a:backdrop>`;
8300
+ }
8301
+ function readPoint3D(el) {
8302
+ const x = el.attributes?.["x"];
8303
+ const y = el.attributes?.["y"];
8304
+ const z = el.attributes?.["z"];
8305
+ if (x === void 0 || y === void 0 || z === void 0) return void 0;
8306
+ return {
8307
+ x: Number(x),
8308
+ y: Number(y),
8309
+ z: Number(z)
8310
+ };
8311
+ }
8312
+ function readVector3D(el) {
8313
+ const dx = el.attributes?.["dx"];
8314
+ const dy = el.attributes?.["dy"];
8315
+ const dz = el.attributes?.["dz"];
8316
+ if (dx === void 0 || dy === void 0 || dz === void 0) return void 0;
8317
+ return {
8318
+ dx: Number(dx),
8319
+ dy: Number(dy),
8320
+ dz: Number(dz)
8321
+ };
8322
+ }
8323
+ function readBackdrop(el) {
8324
+ const anchor = findChild(el, "a:anchor");
8325
+ const norm = findChild(el, "a:norm");
8326
+ const up = findChild(el, "a:up");
8327
+ if (!anchor || !norm || !up) return void 0;
8328
+ const anchorPt = readPoint3D(anchor);
8329
+ const normVec = readVector3D(norm);
8330
+ const upVec = readVector3D(up);
8331
+ if (!anchorPt || !normVec || !upVec) return void 0;
8332
+ return {
8333
+ anchor: anchorPt,
8334
+ normal: normVec,
8335
+ up: upVec
8336
+ };
8337
+ }
8236
8338
  //#endregion
8237
8339
  //#region src/drawingml/diagram/diagram-descriptors.ts
8238
8340
  /**
@@ -8590,4 +8692,4 @@ function replaceHyperlinkPlaceholders(xml, hyperlinks, offset) {
8590
8692
  return replacePlaceholders(xml, map);
8591
8693
  }
8592
8694
  //#endregion
8593
- export { solidFillDesc as $, createTileInfo as $n, unzipSync$1 as $r, convertToTwip as $t, bevelDesc as A, createFillOverlayEffect as An, SchemeColor as Ar, createHierBranch as At, shapeLockingDesc as B, createLineEnd as Bn, PART_REGISTRIES as Br, createTableStyleList as Bt, diagramStyleDesc as C, PresetShadowVal as Cn, uniqueUuid as Cr, AnimateOneByOneValue as Ct, sourceRectangleDesc as D, createInnerShadowEffect as Dn, createSolidFill as Dr, createAdjustList as Dt, blipFillDesc as E, createOuterShadowEffect as En, createColorElement as Er, createAdjust as Et, customGeometryDesc as F, PresetDash as Fn, createPresetColor as Fr, createGraphicFrameLocking as Ft, patternFillDesc as G, extractBlipFillMedia as Gn, ParsedArchive as Gr, convertEmuToPoints as Gt, outlineDesc as H, createGroupFill as Hn, XLSX_PARTS as Hr, createTransformation as Ht, presetGeometryDesc as I, createOutline as In, createHslColor as Ir, createGroupLocking as It, parseColorChoice as J, PathShadeType as Jn, ZIP_STORED_LEVEL as Jr, convertMillimetersToTwip as Jt, getColorDescriptor as K, PresetPattern as Kn, parseArchive as Kr, convertInchesToEmu as Kt, graphicFrameLockingDesc as L, LineEndLength as Ln, createColorTransforms as Lr, createPictureLocking as Lt, shape3DDesc as M, LineCap as Mn, createScRgbColor as Mr, createOrgChart as Mt, groupTransform2DDesc as N, LineJoin as Nn, createRgbColor as Nr, createPreferredChildren as Nt, stretchDesc as O, createGlowEffect as On, SystemColor as Or, createAnimateOneByOne as Ot, transform2DDesc as P, PenAlignment as Pn, PresetColor as Pr, createPresentationLayoutVariables as Pt, schemeColorDesc as Q, TileAlignment as Qn, strFromU8$1 as Qr, convertToEmu as Qt, groupLockingDesc as R, LineEndType as Rn, buildContentTypeOverrides as Rr, createShapeLocking as Rt, diagramRelationshipIdsDesc as S, createReflectionEffect as Sn, uniqueNumericIdCreator as Sr, createStyleDefinitionHeaderList as St, blipDesc as T, RectAlignment as Tn, toUint8Array as Tr, HierBranchStyle as Tt, fillDesc as U, createNoFill as Un, summarizeOpcIssues as Ur, convertEmuToInches as Ut, effectListDesc as V, createCustomDash as Vn, PPTX_PARTS as Vr, parseTableStyleList as Vt, gradientFillDesc as W, buildFill as Wn, validateOpcConsistency as Wr, convertEmuToPixels as Wt, rgbColorDesc as X, createGradientFill as Xn, createZipStream as Xr, convertPointsToEmu as Xt, presetColorDesc as Y, TileFlipMode as Yn, createPacker as Yr, convertPixelsToEmu as Yt, scRgbColorDesc as Z, createGradientStop as Zn, levelForMediaName as Zr, convertPositionToEmu as Zt, derivePasswordHash as _, createScene3D as _n, xsdVerticalMergeRev as _r, createColorsDefinitionHeader as _t, getMediaRefs as a, encodeBase64 as ai, stringifyStretch as an, xsdLineEndSize as ar, ColorMethod as at, compileMapping as b, createEffectList as bn, hashedId as br, createLayoutDefinitionHeaderList as bt, hasPlaceholders as c, createDefault as ci, createExtentionList as cn, xsdPattern as cr, StyleMatrixIndex as ct, replaceHyperlinkPlaceholders as d, TargetModeType as di, stringifyAdjustmentValues as dn, xsdRectAlignment as dr, createFillColorList as dt, zipAndConvert as ei, convertUniversalMeasureToEmu as en, invertMap as er, systemColorDesc as et, replaceImagePlaceholders as f, PresetMaterialType as fn, xsdStrikeStyle as fr, createLineColorList as ft, replaceVideoPlaceholders as g, createBottomBevel as gn, xsdUnderlineStyle as gr, createTextLineColorList as gt, replaceSmartArtPlaceholders as h, createBevel as hn, xsdTextCaps as hr, createTextFillColorList as ht, formatId as i, decodeBase64 as ii, createTransform2D as in, xsdLineCap as ir, createDiagramRelationshipIds as it, scene3DDesc as j, CompoundLine as jn, createSchemeColor as jr, createMaxChildren as jt, tileDesc as k, BlendMode as kn, createSystemColor as kr, createAnimationLevel as kt, replaceAllPlaceholders as l, createOverride as li, createCustomGeometry as ln, xsdPenAlignment as lr, createDiagramStyle as lt, replaceNumberingPlaceholders as m, BevelPresetType as mn, xsdTextAnchor as mr, createTextEffectColorList as mt, collectPlaceholderKeys as n, OoxmlMimeType as ni, parseUniversalMeasure as nn, xsdCompoundLine as nr, createDiagramShape3D as nt, getReferencedMedia as o, customPropertiesDesc as oi, createBlipFill as on, xsdMaterialType as or, FontCollectionIndex as ot, replaceMediaPlaceholders as p, createShape3D as pn, xsdTextAlign as pr, createStyleLabel as pt, hslColorDesc as q, createPatternFill as qn, ZIP_DEFLATE_LEVEL as qr, convertInchesToTwip as qt, findAndReplaceImagePlaceholders as r, convertOutput as ri, createGroupTransform2D as rn, xsdEffectContainer as rr, createDiagramTextProperties as rt, getVideoRefs as s, appPropertiesDesc as si, createBlip as sn, xsdPathFillMode as sr, HueDirection as st, addSmartArtRelationships as t, zipSyncAndConvert as ti, convertUniversalMeasureToTwip as tn, xsdBlendMode as tr, createDiagramExtensionList as tt, replaceChartPlaceholders as u, Relationships as ui, stringifyPresetGeometry as un, xsdPresetShadow as ur, createEffectColorList as ut, hashPasswordAgile as v, createEffectDag as vn, createSourceRectangle as vr, createColorsDefinitionHeaderList as vt, presentationLayoutVariablesDesc as w, createPresetShadowEffect as wn, isBase64DataURL as wr, AnimationLevelValue as wt, diagramExtensionListDesc as x, createSoftEdgeEffect as xn, uniqueId as xr, createStyleDefinitionHeader as xt, randomBytes as y, calculateEffectExtent as yn, createBlipEffects as yr, createLayoutDefinitionHeader as yt, pictureLockingDesc as z, LineEndWidth as zn, DOCX_PARTS as zr, createTableStyle as zt };
8695
+ export { stringifyColorChoice as $, createTileInfo as $n, unzipSync$1 as $r, convertToTwip as $t, customGeometryDesc as A, createFillOverlayEffect as An, SchemeColor as Ar, createHierBranch as At, patternFillDesc as B, createLineEnd as Bn, PART_REGISTRIES as Br, createTableStyleList as Bt, diagramStyleDesc as C, PresetShadowVal as Cn, uniqueUuid as Cr, AnimateOneByOneValue as Ct, shape3DDesc as D, createInnerShadowEffect as Dn, createSolidFill as Dr, createAdjustList as Dt, scene3DDesc as E, createOuterShadowEffect as En, createColorElement as Er, createAdjust as Et, shapeLockingDesc as F, PresetDash as Fn, createPresetColor as Fr, createGraphicFrameLocking as Ft, tileDesc as G, extractBlipFillMedia as Gn, ParsedArchive as Gr, convertEmuToPoints as Gt, blipFillDesc as H, createGroupFill as Hn, XLSX_PARTS as Hr, createTransformation as Ht, effectListDesc as I, createOutline as In, createHslColor as Ir, createGroupLocking as It, presetColorDesc as J, PathShadeType as Jn, ZIP_STORED_LEVEL as Jr, convertMillimetersToTwip as Jt, hslColorDesc as K, PresetPattern as Kn, parseArchive as Kr, convertInchesToEmu as Kt, outlineDesc as L, LineEndLength as Ln, createColorTransforms as Lr, createPictureLocking as Lt, graphicFrameLockingDesc as M, LineCap as Mn, createScRgbColor as Mr, createOrgChart as Mt, groupLockingDesc as N, LineJoin as Nn, createRgbColor as Nr, createPreferredChildren as Nt, groupTransform2DDesc as O, createGlowEffect as On, SystemColor as Or, createAnimateOneByOne as Ot, pictureLockingDesc as P, PenAlignment as Pn, PresetColor as Pr, createPresentationLayoutVariables as Pt, solidFillDesc as Q, TileAlignment as Qn, strFromU8$1 as Qr, convertToEmu as Qt, fillDesc as R, LineEndType as Rn, buildContentTypeOverrides as Rr, createShapeLocking as Rt, diagramRelationshipIdsDesc as S, createReflectionEffect as Sn, uniqueNumericIdCreator as Sr, createStyleDefinitionHeaderList as St, bevelDesc as T, RectAlignment as Tn, toUint8Array as Tr, HierBranchStyle as Tt, sourceRectangleDesc as U, createNoFill as Un, summarizeOpcIssues as Ur, convertEmuToInches as Ut, blipDesc as V, createCustomDash as Vn, PPTX_PARTS as Vr, parseTableStyleList as Vt, stretchDesc as W, buildFill as Wn, validateOpcConsistency as Wr, convertEmuToPixels as Wt, scRgbColorDesc as X, createGradientFill as Xn, createZipStream as Xr, convertPointsToEmu as Xt, rgbColorDesc as Y, TileFlipMode as Yn, createPacker as Yr, convertPixelsToEmu as Yt, schemeColorDesc as Z, createGradientStop as Zn, levelForMediaName as Zr, convertPositionToEmu as Zt, derivePasswordHash as _, createScene3D as _n, xsdVerticalMergeRev as _r, createColorsDefinitionHeader as _t, getMediaRefs as a, encodeBase64 as ai, stringifyStretch as an, xsdLineEndSize as ar, ColorMethod as at, compileMapping as b, createEffectList as bn, hashedId as br, createLayoutDefinitionHeaderList as bt, hasPlaceholders as c, createDefault as ci, createExtentionList as cn, xsdPattern as cr, StyleMatrixIndex as ct, replaceHyperlinkPlaceholders as d, Relationships as di, stringifyAdjustmentValues as dn, xsdRectAlignment as dr, createFillColorList as dt, zipAndConvert as ei, convertUniversalMeasureToEmu as en, invertMap as er, systemColorDesc as et, replaceImagePlaceholders as f, TargetModeType as fi, PresetMaterialType as fn, xsdStrikeStyle as fr, createLineColorList as ft, replaceVideoPlaceholders as g, createBottomBevel as gn, xsdUnderlineStyle as gr, createTextLineColorList as gt, replaceSmartArtPlaceholders as h, createBevel as hn, xsdTextCaps as hr, createTextFillColorList as ht, formatId as i, decodeBase64 as ii, createTransform2D as in, xsdLineCap as ir, createDiagramRelationshipIds as it, presetGeometryDesc as j, CompoundLine as jn, createSchemeColor as jr, createMaxChildren as jt, transform2DDesc as k, BlendMode as kn, createSystemColor as kr, createAnimationLevel as kt, replaceAllPlaceholders as l, createOverride as li, createCustomGeometry as ln, xsdPenAlignment as lr, createDiagramStyle as lt, replaceNumberingPlaceholders as m, BevelPresetType as mn, xsdTextAnchor as mr, createTextEffectColorList as mt, collectPlaceholderKeys as n, OoxmlMimeType as ni, parseUniversalMeasure as nn, xsdCompoundLine as nr, createDiagramShape3D as nt, getReferencedMedia as o, customPropertiesDesc as oi, createBlipFill as on, xsdMaterialType as or, FontCollectionIndex as ot, replaceMediaPlaceholders as p, optionalRelsPart as pi, createShape3D as pn, xsdTextAlign as pr, createStyleLabel as pt, parseColorChoice as q, createPatternFill as qn, ZIP_DEFLATE_LEVEL as qr, convertInchesToTwip as qt, findAndReplaceImagePlaceholders as r, convertOutput as ri, createGroupTransform2D as rn, xsdEffectContainer as rr, createDiagramTextProperties as rt, getVideoRefs as s, appPropertiesDesc as si, createBlip as sn, xsdPathFillMode as sr, HueDirection as st, addSmartArtRelationships as t, zipSyncAndConvert as ti, convertUniversalMeasureToTwip as tn, xsdBlendMode as tr, createDiagramExtensionList as tt, replaceChartPlaceholders as u, Media as ui, stringifyPresetGeometry as un, xsdPresetShadow as ur, createEffectColorList as ut, hashPasswordAgile as v, createEffectDag as vn, createSourceRectangle as vr, createColorsDefinitionHeaderList as vt, presentationLayoutVariablesDesc as w, createPresetShadowEffect as wn, isBase64DataURL as wr, AnimationLevelValue as wt, diagramExtensionListDesc as x, createSoftEdgeEffect as xn, uniqueId as xr, createStyleDefinitionHeader as xt, randomBytes as y, calculateEffectExtent as yn, createBlipEffects as yr, createLayoutDefinitionHeader as yt, gradientFillDesc as z, LineEndWidth as zn, DOCX_PARTS as zr, createTableStyle as zt };