pptxgenjs-plus 4.3.10 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /* PptxGenJS 4.3.10 @ 2026-12-04T13:41:11.342Z */
1
+ /* PptxGenJS 4.4.0 @ 2026-12-05T02:10:07.387Z */
2
2
 
3
3
  "use strict";
4
4
  const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
@@ -1579,6 +1579,59 @@ const XML_ILLEGAL_CHARS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]|
1579
1579
  const points = Number(pt) || 0;
1580
1580
  return isNaN(points) ? 0 : Math.round(points * (/* inlined export .ONEPT */12700));
1581
1581
  }
1582
+ /**
1583
+ * Round a value into an inclusive integer range.
1584
+ * Non-finite inputs (`NaN`, `Infinity`, `-Infinity`) fall back to `min`.
1585
+ * Prevents out-of-range OOXML attributes (`ST_TextFontSize`, `ST_LineWidth`, `ST_TextSpacing*`,
1586
+ * `ST_GapAmount`, ...) from triggering PowerPoint repair dialogs.
1587
+ * @param {number} val - value to clamp
1588
+ * @param {number} min - inclusive lower bound
1589
+ * @param {number} max - inclusive upper bound
1590
+ * @returns {number} clamped integer
1591
+ */ function clampInt(val, min, max) {
1592
+ if (!Number.isFinite(val)) return min === 0 ? 0 : min;
1593
+ const res = Math.round(Math.min(max, Math.max(min, val)));
1594
+ return res === 0 ? 0 : res;
1595
+ }
1596
+ /**
1597
+ * Clamp an EMU extent to `ST_PositiveCoordinate` (finite non-negative integer `>= 0`).
1598
+ * Zero is legal (e.g. hairline rules); negative or non-finite values clamp to 0.
1599
+ * @param {number} val - extent in EMU
1600
+ * @returns {number} non-negative integer EMU
1601
+ */ function positiveExtent(val) {
1602
+ if (!Number.isFinite(val) || val <= 0) return 0;
1603
+ return Math.round(val);
1604
+ }
1605
+ /**
1606
+ * Convert a font size in points into OOXML `ST_TextFontSize` hundredths of a point (`100..400000`, i.e. 1pt..4000pt).
1607
+ * @param {number} val - font size in points
1608
+ * @returns {number} clamped `sz` attribute value
1609
+ */ function fontSizeToSz(val) {
1610
+ return clampInt(val * 100, 100, 400000);
1611
+ }
1612
+ /**
1613
+ * Clamp an EMU line width to `ST_LineWidth` (`0..20116800`, i.e. 0..1584pt).
1614
+ * @param {number} val - line width in EMU
1615
+ * @returns {number} clamped `w` attribute value in EMU
1616
+ */ function clampLineWidth(val) {
1617
+ return clampInt(val, 0, 20116800);
1618
+ }
1619
+ /**
1620
+ * Convert a line width in points into an EMU `a:ln@w` value clamped to `ST_LineWidth` (`0..20116800`).
1621
+ * @param {number|string|undefined} pt - line width in points
1622
+ * @returns {number} clamped `w` attribute value in EMU
1623
+ */ function valToLineWidth(pt) {
1624
+ return clampLineWidth(valToPts(pt));
1625
+ }
1626
+ /**
1627
+ * Convert a 0..100 transparency percentage into an OOXML `a:alpha@val` (`ST_PositiveFixedPercentage`, `0..100000`).
1628
+ * Non-finite inputs default to opaque (`100000`).
1629
+ * @param {number} transparency - transparency percent (0 = opaque, 100 = fully transparent)
1630
+ * @returns {number} clamped `a:alpha@val` in `0..100000`
1631
+ */ function clampAlphaPct(transparency) {
1632
+ if (!Number.isFinite(transparency)) return 100000;
1633
+ return clampInt((100 - transparency) * 1000, 0, 100000);
1634
+ }
1582
1635
  /**
1583
1636
  * Convert a margin component to EMU (same dual-unit rule as table cells)
1584
1637
  * - `>= 1` → points (`valToPts`)
@@ -1858,9 +1911,9 @@ const FLAG_COLOR_MODIFIERS = [
1858
1911
  }
1859
1912
  function createGlowElement(glow) {
1860
1913
  let strXml = '';
1861
- const size = Math.round(glow.size * (/* inlined export .ONEPT */12700));
1914
+ const size = positiveExtent(Math.round(glow.size * (/* inlined export .ONEPT */12700)));
1862
1915
  const color = glow.color;
1863
- const opacity = Math.round(glow.opacity * 100000);
1916
+ const opacity = clampInt(glow.opacity * 100000, 0, 100000);
1864
1917
  strXml += `<a:glow rad="${size}">`;
1865
1918
  strXml += createColorElement(color, `<a:alpha val="${opacity}"/>`);
1866
1919
  strXml += '</a:glow>';
@@ -1913,7 +1966,7 @@ function createGlowElement(glow) {
1913
1966
  return soleColor ? `<a:solidFill>${createColorElement(soleColor, fallbackInner)}</a:solidFill>` : '';
1914
1967
  }
1915
1968
  const gsLst = stops.map((stop)=>{
1916
- const inner = typeof stop.transparency === 'number' ? `<a:alpha val="${Math.round((100 - Math.min(100, Math.max(0, stop.transparency))) * 1000)}"/>` : '';
1969
+ const inner = typeof stop.transparency === 'number' ? `<a:alpha val="${clampAlphaPct(stop.transparency)}"/>` : '';
1917
1970
  return `<a:gs pos="${stop.pos}">${createColorElement(stop.color, inner)}</a:gs>`;
1918
1971
  }).join('');
1919
1972
  const rotateWithShape = (gradient === null || gradient === void 0 ? void 0 : gradient.rotateWithShape) === false || (gradient === null || gradient === void 0 ? void 0 : gradient.rotWithShape) === false ? 0 : 1;
@@ -1984,8 +2037,8 @@ function createGlowElement(glow) {
1984
2037
  if (props.type) fillType = props.type;
1985
2038
  else if (((_props_image = props.image) === null || _props_image === void 0 ? void 0 : _props_image._rId) || props._rId) fillType = 'image';
1986
2039
  if (props.color) colorVal = props.color;
1987
- if (props.alpha) internalElements += `<a:alpha val="${Math.round((100 - props.alpha) * 1000)}"/>`; // DEPRECATED: @deprecated v3.3.0
1988
- if (props.transparency) internalElements += `<a:alpha val="${Math.round((100 - props.transparency) * 1000)}"/>`;
2040
+ if (props.alpha) internalElements += `<a:alpha val="${clampAlphaPct(props.alpha)}"/>`; // DEPRECATED: @deprecated v3.3.0
2041
+ if (props.transparency) internalElements += `<a:alpha val="${clampAlphaPct(props.transparency)}"/>`;
1989
2042
  }
1990
2043
  const isBareColor = typeof props === 'string' || isModifiedThemeColor(props) || isColorProps(props);
1991
2044
  switch(fillType){
@@ -2938,190 +2991,650 @@ function gen_tables_object_spread(target) {
2938
2991
  });
2939
2992
  }
2940
2993
 
2941
- ;// CONCATENATED MODULE: ./src/xml/hyperlink.ts
2942
- /**
2943
- * Hyperlinks and mouse-over actions.
2944
- *
2945
- * DrawingML gives the same concept two element names depending on where it appears:
2946
- *
2947
- * | host | click | mouse-over |
2948
- * | :-- | :-- | :-- |
2949
- * | `p:cNvPr` (shapes, pictures) | `a:hlinkClick` (20.1.2.2.22) | `a:hlinkHover` (20.1.2.2.23) |
2950
- * | `a:rPr` (text runs) | `a:hlinkClick` | `a:hlinkMouseOver` (21.1.2.3.6) |
2951
- *
2952
- * Emitting `a:hlinkHover` inside `a:rPr` — or `a:hlinkMouseOver` inside `p:cNvPr` — produces markup
2953
- * PowerPoint cannot parse, so the host decides the element name here rather than at each call site.
2954
- */
2955
- /**
2956
- * Build one `a:hlinkClick` / mouse-over element
2957
- * @param {HyperlinkProps} link - link props
2958
- * @param {'click' | 'hover'} trigger - which interaction this element describes
2959
- * @param {HyperlinkHost} host - the element the link is attached to
2960
- * @param {string} children - child elements (`a:snd`, `a:extLst`); self-closes when empty
2961
- * @returns {string} XML string
2962
- */ function genXmlHyperlink(link, trigger, host, children = '') {
2963
- var _link__rId;
2964
- const tag = trigger === 'click' ? 'a:hlinkClick' : host === 'run' ? 'a:hlinkMouseOver' : 'a:hlinkHover';
2965
- let attrs = `r:id="rId${(_link__rId = link._rId) !== null && _link__rId !== void 0 ? _link__rId : 0}"`;
2966
- if (link.slide) {
2967
- // an internal jump has no URL; the action attribute names the target kind
2968
- attrs += ' action="ppaction://hlinksldjump"';
2969
- } else {
2970
- attrs += ' invalidUrl="" action="" tgtFrame=""';
2994
+ ;// CONCATENATED MODULE: ./src/gen-media.ts
2995
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2996
+ try {
2997
+ var info = gen[key](arg);
2998
+ var value = info.value;
2999
+ } catch (error) {
3000
+ reject(error);
3001
+ return;
2971
3002
  }
2972
- attrs += ` tooltip="${link.tooltip ? encodeXmlEntities(link.tooltip) : ''}"`;
2973
- if (!link.slide) attrs += ' history="1"';
2974
- // both default to false in the schema, so only write them when turned on
2975
- if (link.highlightClick === true) attrs += ' highlightClick="1"';
2976
- if (link.stopSoundsOnClick === true) attrs += ' endSnd="1"';
2977
- const sound = genXmlHyperlinkSound(link);
2978
- const inner = sound + children;
2979
- return inner ? `<${tag} ${attrs}>${inner}</${tag}>` : `<${tag} ${attrs}/>`;
2980
- }
2981
- /**
2982
- * Build the `a:snd` action sound (ECMA-376 20.1.2.2.32 `CT_EmbeddedWAVAudioFile`)
2983
- * - the relationship is resolved when the object is created, so `_sndRId` is set by then
2984
- * @param {HyperlinkProps} link - link props
2985
- * @returns {string} XML string
2986
- */ function genXmlHyperlinkSound(link) {
2987
- var _link_sound_name;
2988
- var _link_sound;
2989
- if (!((_link_sound = link.sound) === null || _link_sound === void 0 ? void 0 : _link_sound._sndRId)) return '';
2990
- return `<a:snd r:embed="rId${link.sound._sndRId}" name="${encodeXmlEntities((_link_sound_name = link.sound.name) !== null && _link_sound_name !== void 0 ? _link_sound_name : 'sound.wav')}"/>`;
3003
+ if (info.done) resolve(value);
3004
+ else Promise.resolve(value).then(_next, _throw);
2991
3005
  }
2992
-
2993
- ;// CONCATENATED MODULE: ./src/xml/line.ts
2994
- function line_define_property(obj, key, value) {
2995
- if (key in obj) {
2996
- Object.defineProperty(obj, key, {
2997
- value: value,
2998
- enumerable: true,
2999
- configurable: true,
3000
- writable: true
3006
+ function _async_to_generator(fn) {
3007
+ return function() {
3008
+ var self = this, args = arguments;
3009
+ return new Promise(function(resolve, reject) {
3010
+ var gen = fn.apply(self, args);
3011
+ function _next(value) {
3012
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
3013
+ }
3014
+ function _throw(err) {
3015
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
3016
+ }
3017
+ _next(undefined);
3001
3018
  });
3002
- } else obj[key] = value;
3003
- return obj;
3019
+ };
3004
3020
  }
3005
- function line_object_spread(target) {
3006
- for(var i = 1; i < arguments.length; i++){
3007
- var source = arguments[i] != null ? arguments[i] : {};
3008
- var ownKeys = Object.keys(source);
3009
- if (typeof Object.getOwnPropertySymbols === "function") {
3010
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3011
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3012
- }));
3021
+ /**
3022
+ * PptxGenJS: Media Methods
3023
+ */
3024
+
3025
+ /** Images are measured in pixels; PowerPoint slide dimensions are inches at 96 DPI */ const IMAGE_DPI = 96;
3026
+ /**
3027
+ * Deck-scoped content-hash buckets keyed by `target._allocChartId` (shared across all slides,
3028
+ * layouts, and master in one `PptxGenJS` instance) so identical raster images share one OPC media
3029
+ * part across the entire deck without leaking across presentations.
3030
+ */ const deckImageBuckets = new WeakMap();
3031
+ function getDeckImageBuckets(target) {
3032
+ var _target__allocChartId;
3033
+ const deckKey = (_target__allocChartId = target._allocChartId) !== null && _target__allocChartId !== void 0 ? _target__allocChartId : target;
3034
+ let buckets = deckImageBuckets.get(deckKey);
3035
+ if (!buckets) {
3036
+ buckets = new Map();
3037
+ deckImageBuckets.set(deckKey, buckets);
3038
+ }
3039
+ return buckets;
3040
+ }
3041
+ function isDedupeImageRel(rel) {
3042
+ if (!rel || rel.isLinked || rel.isSvgPng) return false;
3043
+ if (typeof rel.data !== 'string' || !rel.data || rel.data === IMG_BROKEN) return false;
3044
+ const type = typeof rel.type === 'string' ? rel.type.toLowerCase() : '';
3045
+ const extn = typeof rel.extn === 'string' ? rel.extn.toLowerCase() : '';
3046
+ if (extn === 'svg' || type === 'image/svg+xml') return false;
3047
+ return type === 'image' || type.startsWith('image/');
3048
+ }
3049
+ function getRelDataBody(data) {
3050
+ const commaIdx = data.indexOf(',');
3051
+ return commaIdx >= 0 ? data.substring(commaIdx + 1) : data;
3052
+ }
3053
+ function fnv1aHash(str) {
3054
+ let hash = 2166136261;
3055
+ for(let idx = 0; idx < str.length; idx++){
3056
+ hash ^= str.charCodeAt(idx);
3057
+ hash = Math.imul(hash, 16777619);
3058
+ }
3059
+ return (hash >>> 0).toString(16);
3060
+ }
3061
+ /**
3062
+ * Deduplicate one raster image relationship against the deck-scoped content-hash table.
3063
+ * When an identical image payload already exists on any slide/layout in this presentation,
3064
+ * rewrites `rel.Target` to reuse the existing OPC media part and marks `rel.isDuplicate = true`
3065
+ * while keeping `rel.rId` and `rel.data` intact.
3066
+ */ function dedupeImageMediaRel(target, rel) {
3067
+ var _buckets_get;
3068
+ if (!isDedupeImageRel(rel)) return;
3069
+ const body = getRelDataBody(rel.data);
3070
+ if (!body) return;
3071
+ const normExtn = (rel.extn || 'png').toLowerCase() === 'jpg' ? 'jpeg' : (rel.extn || 'png').toLowerCase();
3072
+ const key = `${normExtn}|${body.length}|${fnv1aHash(body)}`;
3073
+ const buckets = getDeckImageBuckets(target);
3074
+ const bucket = (_buckets_get = buckets.get(key)) !== null && _buckets_get !== void 0 ? _buckets_get : [];
3075
+ const existing = bucket.find((entry)=>entry.data === body);
3076
+ if (existing) {
3077
+ if (existing.target !== rel.Target) {
3078
+ rel.isDuplicate = true;
3079
+ rel.Target = existing.target;
3013
3080
  }
3014
- ownKeys.forEach(function(key) {
3015
- line_define_property(target, key, source[key]);
3081
+ } else {
3082
+ bucket.push({
3083
+ data: body,
3084
+ target: rel.Target
3016
3085
  });
3086
+ buckets.set(key, bucket);
3017
3087
  }
3018
- return target;
3019
- }
3020
- function line_ownKeys(object, enumerableOnly) {
3021
- var keys = Object.keys(object);
3022
- if (Object.getOwnPropertySymbols) {
3023
- var symbols = Object.getOwnPropertySymbols(object);
3024
- if (enumerableOnly) {
3025
- symbols = symbols.filter(function(sym) {
3026
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3027
- });
3028
- }
3029
- keys.push.apply(keys, symbols);
3030
- }
3031
- return keys;
3032
3088
  }
3033
- function line_object_spread_props(target, source) {
3034
- source = source != null ? source : {};
3035
- if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3036
- else {
3037
- line_ownKeys(Object(source)).forEach(function(key) {
3038
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3039
- });
3040
- }
3041
- return target;
3089
+ /**
3090
+ * Deduplicate all resolved raster image relationships on a slide/layout deck-wide.
3091
+ * Runs after `encodeSlideMediaRels` resolves so path-loaded images are deduplicated too.
3092
+ */ function dedupeSlideMediaRels(layout) {
3093
+ var _layout__relsMedia;
3094
+ ;
3095
+ ((_layout__relsMedia = layout._relsMedia) !== null && _layout__relsMedia !== void 0 ? _layout__relsMedia : []).forEach((rel)=>dedupeImageMediaRel(layout, rel));
3042
3096
  }
3043
3097
  /**
3044
- * PptxGenJS: Line properties (`a:ln` and its aliases)
3098
+ * Read the natural pixel dimensions of a raster image from its header bytes.
3099
+ * Self-contained replacement for the `image-size` package (PNG/JPEG/GIF/BMP).
3100
+ * Format refs: PNG spec §11.2.2 (IHDR is always the first chunk, width/height big-endian at bytes 16-24);
3101
+ * JPEG (JFIF) SOF0-SOF15 markers carry height then width big-endian; GIF87a/89a logical-screen descriptor
3102
+ * little-endian at bytes 6-10; BMP DIB header little-endian at bytes 18-26. SVG is sized separately (gen-objects).
3045
3103
  *
3046
- * The same `CT_LineProperties` content model is used by shape outlines (`a:ln`), underlines
3047
- * (`a:uLn`), and table cell borders, so the element name is a parameter rather than baked in.
3048
- */
3049
-
3050
- /**
3051
- * Create a line element
3052
- * @param {ShapeLineProps} line - line options
3053
- * @param {string} tag - element name; `a:ln` for a shape outline, `a:uLn` for an underline
3054
- * @return {string} XML
3055
- */ function genXmlLine(line, tag = 'a:ln') {
3056
- // ECMA-376 §5.1.2.1.34: `<a:ln>` carries `w`, `cap`, and `cmpd` attributes
3057
- const cap = line.cap && [
3058
- 'flat',
3059
- 'sq',
3060
- 'rnd'
3061
- ].includes(line.cap) ? ` cap="${line.cap}"` : '';
3062
- const compound = COMPOUND_TYPES.has(String(line.compound)) ? ` cmpd="${String(line.compound)}"` : '';
3063
- if (line.compound && !COMPOUND_TYPES.has(String(line.compound))) {
3064
- console.warn(`[pptxgenjs] line \`compound\` must be one of ${[
3065
- ...COMPOUND_TYPES
3066
- ].join(', ')} - "${String(line.compound)}" ignored`);
3104
+ * Declared dims are header-only (we never decode pixels), so clamp to a sane ceiling: a maliciously crafted
3105
+ * header can claim 0xFFFFFFFF px and emit a ~44-million-inch slide (a corrupt pptx). PowerPoint's max slide is
3106
+ * 56 in (5376 px @ 96 DPI); 100 000 px is generous headroom for legit high-res sources while rejecting bombs.
3107
+ */ const MAX_IMAGE_PX = 100000;
3108
+ function imageDimensions(bytes) {
3109
+ if (bytes.length < 10) return {} // every supported header's dims start at/after byte 6
3110
+ ;
3111
+ const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
3112
+ const sane = (w, h)=>w > 0 && h > 0 && w <= MAX_IMAGE_PX && h <= MAX_IMAGE_PX ? {
3113
+ width: w,
3114
+ height: h
3115
+ } : {};
3116
+ // PNG: 8-byte signature 89 50 4E 47 0D 0A 1A 0A, then IHDR length(4)+type(4)+width(4)+height(4)
3117
+ if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) {
3118
+ if (bytes.length < 24) return {};
3119
+ return sane(dv.getUint32(16, false), dv.getUint32(20, false));
3067
3120
  }
3068
- const attrs = (line.width ? ` w="${valToPts(line.width)}"` : '') + cap + compound;
3069
- let xml = `<${tag}${attrs}>`;
3070
- const hasGrad = !!(line.gradient || line.type === 'gradient' || line.type === 'linearGradient');
3071
- if (line.type !== 'none' && (line.color || hasGrad)) {
3072
- xml += genXmlColorSelection(hasGrad && !line.type ? line_object_spread_props(line_object_spread({}, line), {
3073
- type: 'gradient'
3074
- }) : line);
3121
+ // GIF: 'GIF87a'/'GIF89a', logical screen width/height little-endian at bytes 6-10
3122
+ if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46) {
3123
+ return sane(dv.getUint16(6, true), dv.getUint16(8, true));
3075
3124
  }
3076
- // CT_LineProperties sequence: fill, dash, join, headEnd, tailEnd. A custom pattern replaces
3077
- // the preset one - emitting both would be ambiguous, since `a:custDash` is the same choice.
3078
- xml += genXmlDash(line);
3079
- xml += genXmlJoin(line);
3080
- xml += genXmlArrow('a:headEnd', line.beginArrowType, line.beginArrowSize);
3081
- xml += genXmlArrow('a:tailEnd', line.endArrowType, line.endArrowSize);
3082
- xml += `</${tag}>`;
3083
- return xml;
3084
- }
3085
- /** The dash choice: a custom pattern when given, otherwise the preset */ function genXmlDash(line) {
3086
- var _line_custDash;
3087
- const stops = ((_line_custDash = line.custDash) !== null && _line_custDash !== void 0 ? _line_custDash : []).filter((stop)=>{
3088
- const ok = typeof (stop === null || stop === void 0 ? void 0 : stop.dash) === 'number' && isFinite(stop.dash) && stop.dash > 0 && typeof stop.space === 'number' && isFinite(stop.space) && stop.space >= 0;
3089
- if (!ok) console.warn('[pptxgenjs] each `custDash` stop needs a positive `dash` and a non-negative `space` (percent of line width) - stop ignored');
3090
- return ok;
3091
- });
3092
- if (stops.length > 0) {
3093
- const items = stops.map((stop)=>`<a:ds d="${Math.round(stop.dash * 1000)}" sp="${Math.round(stop.space * 1000)}"/>`).join('');
3094
- return `<a:custDash>${items}</a:custDash>`;
3125
+ // BMP: 'BM', DIB width/height little-endian at bytes 18-26 (signed; height may be negative = top-down)
3126
+ if (bytes[0] === 0x42 && bytes[1] === 0x4d) {
3127
+ if (bytes.length < 26) return {};
3128
+ return sane(Math.abs(dv.getInt32(18, true)), Math.abs(dv.getInt32(22, true)));
3095
3129
  }
3096
- return line.dashType ? `<a:prstDash val="${line.dashType}"/>` : '';
3097
- }
3098
- /** The join choice: `a:round`, `a:bevel`, or `a:miter` with its limit */ function genXmlJoin(line) {
3099
- if (!line.join) return '';
3100
- if (line.join === 'round') return '<a:round/>';
3101
- if (line.join === 'bevel') return '<a:bevel/>';
3102
- if (line.join === 'miter') {
3103
- const lim = typeof line.miterLimit === 'number' && isFinite(line.miterLimit) && line.miterLimit >= 0 ? line.miterLimit : 800;
3104
- return `<a:miter lim="${Math.round(lim * 1000)}"/>`;
3130
+ // JPEG: FF D8, then walk marker segments until a Start-Of-Frame (C0-CF except C4/C8/CC) carries the dims
3131
+ if (bytes[0] === 0xff && bytes[1] === 0xd8) {
3132
+ let off = 2;
3133
+ while(off + 9 <= bytes.length){
3134
+ if (bytes[off] !== 0xff) {
3135
+ off++;
3136
+ continue;
3137
+ }
3138
+ const marker = bytes[off + 1];
3139
+ const isSOF = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
3140
+ if (isSOF) return sane(dv.getUint16(off + 7, false), dv.getUint16(off + 5, false));
3141
+ if (marker === 0xd8 || marker === 0xd9 || marker >= 0xd0 && marker <= 0xd7) {
3142
+ off += 2;
3143
+ continue;
3144
+ } // no length
3145
+ const segLen = dv.getUint16(off + 2, false);
3146
+ off += 2 + segLen;
3147
+ }
3105
3148
  }
3106
- console.warn(`[pptxgenjs] line \`join\` must be 'round' | 'bevel' | 'miter' - "${String(line.join)}" ignored`);
3107
- return '';
3108
- }
3109
- function resolveArrowSize(size) {
3110
- if (!size) return undefined;
3111
- if (typeof size === 'string') return {
3112
- width: size,
3113
- length: size
3114
- };
3115
- return size;
3116
- }
3117
- /** An arrow end with its optional sizing */ function genXmlArrow(tag, type, size) {
3118
- if (!type) return '';
3119
- const resolved = resolveArrowSize(size);
3120
- const w = ARROW_SIZES.has(String(resolved === null || resolved === void 0 ? void 0 : resolved.width)) ? ` w="${String(resolved === null || resolved === void 0 ? void 0 : resolved.width)}"` : '';
3121
- const len = ARROW_SIZES.has(String(resolved === null || resolved === void 0 ? void 0 : resolved.length)) ? ` len="${String(resolved === null || resolved === void 0 ? void 0 : resolved.length)}"` : '';
3122
- return `<${tag} type="${type}"${w}${len}/>`;
3149
+ return {};
3123
3150
  }
3124
-
3151
+ /**
3152
+ * Natural pixel size from encoded image bytes (PNG/JPEG/GIF/BMP headers).
3153
+ * Returns null when the payload is missing, not a supported raster, or claims 0×0
3154
+ * (`imageDimensions` already rejects zero and bomb-sized headers).
3155
+ *
3156
+ * contain/cover `a:srcRect` (ECMA-376 §5.1.10.55) needs the *blip* aspect, not the
3157
+ * placement box — using w/h as imgSize makes srcRect a no-op whenever they match the sizing box.
3158
+ */ function getImagePixelSize(base64Data) {
3159
+ if (typeof base64Data !== 'string' || !base64Data || base64Data === IMG_BROKEN) return null;
3160
+ try {
3161
+ const dims = imageDimensions(base64ToBytes(base64Data));
3162
+ if (dims.width && dims.height) return {
3163
+ w: dims.width,
3164
+ h: dims.height
3165
+ };
3166
+ } catch (unused) {
3167
+ // unrecognized / truncated payload
3168
+ }
3169
+ return null;
3170
+ }
3171
+ /**
3172
+ * Size images added without `w`/`h` to their natural dimensions (issue #34)
3173
+ * @note must run after `encodeSlideMediaRels` has resolved - it reads the encoded image bytes
3174
+ * @param {PresSlide | SlideLayout} layout - slide layout
3175
+ */ function applyNaturalImageSizes(layout) {
3176
+ // Media bytes for path-based images are now loaded; deduplicate identical raster payloads deck-wide
3177
+ // before slide/layout `.rels` and zip parts are emitted.
3178
+ dedupeSlideMediaRels(layout);
3179
+ layout._slideObjects.filter((obj)=>{
3180
+ var _obj_options;
3181
+ return obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.image */"image") && ((_obj_options = obj.options) === null || _obj_options === void 0 ? void 0 : _obj_options._sizeFromImage);
3182
+ }).forEach((obj)=>{
3183
+ var _layout__relsMedia_find;
3184
+ const strData = (_layout__relsMedia_find = layout._relsMedia.find((rel)=>rel.rId === obj.imageRid)) === null || _layout__relsMedia_find === void 0 ? void 0 : _layout__relsMedia_find.data;
3185
+ if (!obj.options || typeof strData !== 'string' || !strData || strData === IMG_BROKEN) return;
3186
+ // An image bound to a placeholder inherits the placeholder's w/h (slide XML resolves it); sizing it
3187
+ // to its natural pixel dims instead would collapse it to ~px/96 inches (issue #996).
3188
+ if (obj.options.placeholder) return;
3189
+ try {
3190
+ const dims = imageDimensions(base64ToBytes(strData));
3191
+ if (dims.width && dims.height) {
3192
+ obj.options.w = dims.width / IMAGE_DPI;
3193
+ obj.options.h = dims.height / IMAGE_DPI;
3194
+ }
3195
+ } catch (_ex) {
3196
+ // Unreadable/unsupported image: keep the 1x1 inch default
3197
+ }
3198
+ });
3199
+ }
3200
+ /** Select relations that still need their local or remote media encoded. */ function getMediaCandidates(layout) {
3201
+ return layout._relsMedia.filter((rel)=>!rel.isLinked && rel.type !== 'online' && !rel.data && (!rel.path || rel.path && !rel.path.includes('preencoded')));
3202
+ }
3203
+ /**
3204
+ * Mark repeated source paths so only the first relation performs I/O.
3205
+ *
3206
+ * Mutates `isDuplicate`; subsequent helpers copy the first result to every duplicate.
3207
+ */ function markDuplicateMedia(candidates) {
3208
+ const paths = new Set();
3209
+ candidates.forEach((rel)=>{
3210
+ var _rel_path;
3211
+ const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
3212
+ rel.isDuplicate = paths.has(path);
3213
+ paths.add(path);
3214
+ });
3215
+ }
3216
+ /** Copy an encoded or broken source relation's data to every duplicate path. */ function copyMediaToDuplicates(candidates, rel) {
3217
+ candidates.filter((duplicate)=>duplicate.isDuplicate && duplicate.path === rel.path).forEach((duplicate)=>duplicate.data = rel.data);
3218
+ }
3219
+ /** Mark a failed source and all duplicates with the sentinel expected by package generation. */ function markMediaBroken(candidates, rel) {
3220
+ rel.data = IMG_BROKEN;
3221
+ copyMediaToDuplicates(candidates, rel);
3222
+ }
3223
+ function mediaLoadFailed(candidates, rel, message, onError) {
3224
+ markMediaBroken(candidates, rel);
3225
+ if (onError === 'placeholder') {
3226
+ console.warn(`WARN: Unable to load image, using placeholder: ${rel.path}${message ? ` (${message})` : ''}`);
3227
+ return 'done';
3228
+ }
3229
+ throw new Error(message);
3230
+ }
3231
+ /**
3232
+ * Read one Node-local media source and encode it as base64.
3233
+ *
3234
+ * A read failure is recorded before rejection so duplicate references remain consistent.
3235
+ */ function readNodeMediaFile(rel, candidates, fs, onError) {
3236
+ return _async_to_generator(function*() {
3237
+ try {
3238
+ var _rel_path;
3239
+ var _rel_fill;
3240
+ const relPath = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
3241
+ const svgFill = typeof ((_rel_fill = rel.fill) === null || _rel_fill === void 0 ? void 0 : _rel_fill.color) === 'string' ? rel.fill.color : undefined;
3242
+ if (svgFill && (rel.type === 'image/svg+xml' || rel.extn === 'svg')) {
3243
+ const svgText = applySvgFillColor(fs.readFileSync(relPath, 'utf8'), svgFill);
3244
+ rel.data = utf8ToBase64(svgText);
3245
+ } else {
3246
+ const bitmap = fs.readFileSync(relPath);
3247
+ rel.data = bytesToBase64(new Uint8Array(bitmap));
3248
+ if (svgFill && typeof rel.data === 'string') {
3249
+ rel.data = applySvgFillToDataUrl(rel.data, svgFill);
3250
+ }
3251
+ }
3252
+ copyMediaToDuplicates(candidates, rel);
3253
+ return 'done';
3254
+ } catch (ex) {
3255
+ return mediaLoadFailed(candidates, rel, `ERROR: Unable to read media: "${rel.path}"\n${String(ex)}`, onError);
3256
+ }
3257
+ })();
3258
+ }
3259
+ /**
3260
+ * Load one HTTP(S) source in Node, draining error responses and handling both request and response errors.
3261
+ */ function loadNodeMediaUrl(rel, candidates, https, http, onError) {
3262
+ var _rel_path;
3263
+ const httpMod = ((_rel_path = rel.path) === null || _rel_path === void 0 ? void 0 : _rel_path.startsWith('http://')) ? http : https;
3264
+ return new Promise((resolve, reject)=>{
3265
+ const fail = (message)=>{
3266
+ try {
3267
+ resolve(mediaLoadFailed(candidates, rel, message, onError));
3268
+ } catch (ex) {
3269
+ reject(ex);
3270
+ }
3271
+ };
3272
+ try {
3273
+ var _rel_path;
3274
+ const req = httpMod.get((_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '', (res)=>{
3275
+ var _res_statusCode;
3276
+ const status = (_res_statusCode = res.statusCode) !== null && _res_statusCode !== void 0 ? _res_statusCode : 0;
3277
+ if (status < 200 || status > 299) {
3278
+ res.resume(); // drain so the socket is freed
3279
+ fail(`ERROR! Unable to load image (HTTP ${status}): ${rel.path}`);
3280
+ return;
3281
+ }
3282
+ let raw = '';
3283
+ res.setEncoding('binary'); // IMPORTANT: Only binary encoding works
3284
+ res.on('data', (chunk)=>raw += chunk);
3285
+ res.on('end', ()=>{
3286
+ rel.data = binaryStringToBase64(raw);
3287
+ copyMediaToDuplicates(candidates, rel);
3288
+ resolve('done');
3289
+ });
3290
+ res.on('error', ()=>fail(`ERROR! Unable to load image (response): ${rel.path}`));
3291
+ });
3292
+ // NOTE: without this, a DNS/TLS/connection failure emits an unhandled 'error' and kills the process
3293
+ req.on('error', (ex)=>fail(`ERROR! Unable to load image (request): ${rel.path}\n${String(ex)}`));
3294
+ } catch (ex) {
3295
+ fail(`ERROR! Unable to load image (https.get): ${rel.path}\n${String(ex)}`);
3296
+ }
3297
+ });
3298
+ }
3299
+ /**
3300
+ * Fetch one browser media source and convert its Blob response to a data URL.
3301
+ * SVG previews are produced only after the source relation has been populated.
3302
+ */ function loadBrowserMedia(rel, candidates, onError) {
3303
+ return new Promise((resolve, reject)=>{
3304
+ var _rel_path;
3305
+ const fail = (message)=>{
3306
+ try {
3307
+ resolve(mediaLoadFailed(candidates, rel, message, onError));
3308
+ } catch (ex) {
3309
+ reject(ex);
3310
+ }
3311
+ };
3312
+ const xhr = new XMLHttpRequest();
3313
+ xhr.onload = ()=>{
3314
+ // status 0 = non-HTTP schemes (file://); anything outside 2xx is an error page, not image bytes
3315
+ if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {
3316
+ fail(`ERROR! HTTP status ${xhr.status} loading image: ${rel.path}`);
3317
+ return;
3318
+ }
3319
+ const reader = new FileReader();
3320
+ reader.onloadend = ()=>{
3321
+ if (typeof reader.result === 'string') rel.data = reader.result;
3322
+ copyMediaToDuplicates(candidates, rel);
3323
+ if (!rel.isSvgPng) resolve('done');
3324
+ else createSvgPngPreview(rel).then(()=>resolve('done')).catch(reject);
3325
+ };
3326
+ reader.readAsDataURL(xhr.response);
3327
+ };
3328
+ xhr.onerror = ()=>{
3329
+ fail(`ERROR! Unable to load image (xhr.onerror): ${rel.path}`);
3330
+ };
3331
+ xhr.open('GET', (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '');
3332
+ xhr.responseType = 'blob';
3333
+ xhr.send();
3334
+ });
3335
+ }
3336
+ /** Route one source relation to the loader valid for the active runtime. */ function encodeMediaRelation(rel, candidates, isNode, modules, loadNodeModules, onError) {
3337
+ return _async_to_generator(function*() {
3338
+ var _rel_path;
3339
+ if (!modules.https) yield loadNodeModules();
3340
+ const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
3341
+ if (isNode && modules.fs && !path.startsWith('http')) return readNodeMediaFile(rel, candidates, modules.fs, onError);
3342
+ if (isNode && modules.https && modules.http && path.startsWith('http')) return loadNodeMediaUrl(rel, candidates, modules.https, modules.http, onError);
3343
+ return loadBrowserMedia(rel, candidates, onError);
3344
+ })();
3345
+ }
3346
+ /**
3347
+ * Append SVG preview work synchronously because the caller immediately snapshots `promises`.
3348
+ * Node cannot rasterize SVG here, so it keeps the historical broken-preview sentinel behavior.
3349
+ */ function addSvgPreviewPromises(layout, isNode, promises) {
3350
+ layout._relsMedia.filter((rel)=>rel.isSvgPng && rel.data).forEach((rel)=>{
3351
+ // NOTE: must push synchronously - the caller snapshots this array as soon as we return
3352
+ if (isNode) {
3353
+ // SVG is not supported in Node (more info: https://github.com/gitbrent/PptxGenJS/issues/401)
3354
+ rel.data = IMG_BROKEN;
3355
+ promises.push(Promise.resolve('done'));
3356
+ } else {
3357
+ promises.push(createSvgPngPreview(rel));
3358
+ }
3359
+ });
3360
+ }
3361
+ /**
3362
+ * Encode Image/Audio/Video into base64
3363
+ * @param {PresSlide | SlideLayout} layout - slide layout
3364
+ * @return {Promise} promise
3365
+ */ function encodeSlideMediaRels(layout, opts) {
3366
+ // STEP 1: Detect a real Node process. Browser bundles often polyfill `process`
3367
+ // (and even `process.versions.node`), so also require a document-less runtime.
3368
+ const isNode = isNodeRuntime();
3369
+ const modules = {};
3370
+ // STEP 2: Lazy-load Node built-ins if needed. The specifier is built at runtime
3371
+ // so browser bundlers cannot statically resolve `node:https` / `https`.
3372
+ const loadNodeDeps = isNode ? ()=>_async_to_generator(function*() {
3373
+ ;
3374
+ ({ default: modules.fs } = yield importNodeBuiltin('fs'));
3375
+ ({ default: modules.https } = yield importNodeBuiltin('https'));
3376
+ ({ default: modules.http } = yield importNodeBuiltin('http'));
3377
+ })() : ()=>_async_to_generator(function*() {})();
3378
+ // Immediately start it when we know we’re in Node
3379
+ if (isNode) loadNodeDeps();
3380
+ // STEP 3: Prepare promises list
3381
+ const imageProms = [];
3382
+ // A: Capture all audio/image/video candidates for encoding (filtering online/pre-encoded)
3383
+ const candidateRels = getMediaCandidates(layout);
3384
+ // B: PERF: Mark dupes (same `path`) to avoid loading the same media over-and-over!
3385
+ markDuplicateMedia(candidateRels);
3386
+ // STEP 4: Read/Encode each unique media item
3387
+ const onError = (opts === null || opts === void 0 ? void 0 : opts.onError) === 'placeholder' ? 'placeholder' : 'throw';
3388
+ candidateRels.filter((rel)=>!rel.isDuplicate).forEach((rel)=>imageProms.push(encodeMediaRelation(rel, candidateRels, isNode, modules, loadNodeDeps, onError)));
3389
+ // STEP 5: SVG-PNG previews
3390
+ // ......: "SVG:" base64 data still requires a png to be generated
3391
+ // ......: (`isSvgPng` flag this as the preview image, not the SVG itself)
3392
+ addSvgPreviewPromises(layout, isNode, imageProms);
3393
+ return imageProms;
3394
+ }
3395
+ /**
3396
+ * Create SVG preview image
3397
+ * @param {ISlideRelMedia} rel - slide rel
3398
+ * @return {Promise} promise
3399
+ */ function createSvgPngPreview(rel) {
3400
+ return _async_to_generator(function*() {
3401
+ return yield new Promise((resolve, reject)=>{
3402
+ // A: Create
3403
+ const image = new Image();
3404
+ // Shared error handler (also wired to `image.onerror`); the reason string is informational only
3405
+ const handleError = ()=>{
3406
+ rel.data = IMG_BROKEN;
3407
+ reject(new Error(`ERROR! Unable to load image (image.onerror): ${rel.path}`));
3408
+ };
3409
+ // B: Set onload event
3410
+ image.onload = ()=>{
3411
+ // First: Check for any errors: This is the best method (try/catch wont work, etc.)
3412
+ if (image.width + image.height === 0) {
3413
+ handleError();
3414
+ }
3415
+ const canvas = document.createElement('canvas');
3416
+ const ctx = canvas.getContext('2d');
3417
+ if (!ctx) {
3418
+ handleError();
3419
+ return;
3420
+ }
3421
+ canvas.width = image.width;
3422
+ canvas.height = image.height;
3423
+ ctx.drawImage(image, 0, 0);
3424
+ // Users running on local machine will get the following error:
3425
+ // "SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported."
3426
+ // when the canvas.toDataURL call executes below.
3427
+ try {
3428
+ rel.data = canvas.toDataURL(rel.type);
3429
+ resolve('done');
3430
+ } catch (_ex) {
3431
+ handleError();
3432
+ }
3433
+ };
3434
+ image.onerror = handleError;
3435
+ // C: Load image
3436
+ image.src = typeof rel.data === 'string' ? rel.data : IMG_BROKEN;
3437
+ });
3438
+ })();
3439
+ }
3440
+
3441
+ ;// CONCATENATED MODULE: ./src/xml/hyperlink.ts
3442
+ /**
3443
+ * Hyperlinks and mouse-over actions.
3444
+ *
3445
+ * DrawingML gives the same concept two element names depending on where it appears:
3446
+ *
3447
+ * | host | click | mouse-over |
3448
+ * | :-- | :-- | :-- |
3449
+ * | `p:cNvPr` (shapes, pictures) | `a:hlinkClick` (20.1.2.2.22) | `a:hlinkHover` (20.1.2.2.23) |
3450
+ * | `a:rPr` (text runs) | `a:hlinkClick` | `a:hlinkMouseOver` (21.1.2.3.6) |
3451
+ *
3452
+ * Emitting `a:hlinkHover` inside `a:rPr` — or `a:hlinkMouseOver` inside `p:cNvPr` — produces markup
3453
+ * PowerPoint cannot parse, so the host decides the element name here rather than at each call site.
3454
+ */
3455
+ /**
3456
+ * Build one `a:hlinkClick` / mouse-over element
3457
+ * @param {HyperlinkProps} link - link props
3458
+ * @param {'click' | 'hover'} trigger - which interaction this element describes
3459
+ * @param {HyperlinkHost} host - the element the link is attached to
3460
+ * @param {string} children - child elements (`a:snd`, `a:extLst`); self-closes when empty
3461
+ * @returns {string} XML string
3462
+ */ function genXmlHyperlink(link, trigger, host, children = '') {
3463
+ var _link__rId;
3464
+ const tag = trigger === 'click' ? 'a:hlinkClick' : host === 'run' ? 'a:hlinkMouseOver' : 'a:hlinkHover';
3465
+ let attrs = `r:id="rId${(_link__rId = link._rId) !== null && _link__rId !== void 0 ? _link__rId : 0}"`;
3466
+ if (link.slide) {
3467
+ // an internal jump has no URL; the action attribute names the target kind
3468
+ attrs += ' action="ppaction://hlinksldjump"';
3469
+ } else {
3470
+ attrs += ' invalidUrl="" action="" tgtFrame=""';
3471
+ }
3472
+ attrs += ` tooltip="${link.tooltip ? encodeXmlEntities(link.tooltip) : ''}"`;
3473
+ if (!link.slide) attrs += ' history="1"';
3474
+ // both default to false in the schema, so only write them when turned on
3475
+ if (link.highlightClick === true) attrs += ' highlightClick="1"';
3476
+ if (link.stopSoundsOnClick === true) attrs += ' endSnd="1"';
3477
+ const sound = genXmlHyperlinkSound(link);
3478
+ const inner = sound + children;
3479
+ return inner ? `<${tag} ${attrs}>${inner}</${tag}>` : `<${tag} ${attrs}/>`;
3480
+ }
3481
+ /**
3482
+ * Build the `a:snd` action sound (ECMA-376 20.1.2.2.32 `CT_EmbeddedWAVAudioFile`)
3483
+ * - the relationship is resolved when the object is created, so `_sndRId` is set by then
3484
+ * @param {HyperlinkProps} link - link props
3485
+ * @returns {string} XML string
3486
+ */ function genXmlHyperlinkSound(link) {
3487
+ var _link_sound_name;
3488
+ var _link_sound;
3489
+ if (!((_link_sound = link.sound) === null || _link_sound === void 0 ? void 0 : _link_sound._sndRId)) return '';
3490
+ return `<a:snd r:embed="rId${link.sound._sndRId}" name="${encodeXmlEntities((_link_sound_name = link.sound.name) !== null && _link_sound_name !== void 0 ? _link_sound_name : 'sound.wav')}"/>`;
3491
+ }
3492
+
3493
+ ;// CONCATENATED MODULE: ./src/xml/line.ts
3494
+ function line_define_property(obj, key, value) {
3495
+ if (key in obj) {
3496
+ Object.defineProperty(obj, key, {
3497
+ value: value,
3498
+ enumerable: true,
3499
+ configurable: true,
3500
+ writable: true
3501
+ });
3502
+ } else obj[key] = value;
3503
+ return obj;
3504
+ }
3505
+ function line_object_spread(target) {
3506
+ for(var i = 1; i < arguments.length; i++){
3507
+ var source = arguments[i] != null ? arguments[i] : {};
3508
+ var ownKeys = Object.keys(source);
3509
+ if (typeof Object.getOwnPropertySymbols === "function") {
3510
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3511
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3512
+ }));
3513
+ }
3514
+ ownKeys.forEach(function(key) {
3515
+ line_define_property(target, key, source[key]);
3516
+ });
3517
+ }
3518
+ return target;
3519
+ }
3520
+ function line_ownKeys(object, enumerableOnly) {
3521
+ var keys = Object.keys(object);
3522
+ if (Object.getOwnPropertySymbols) {
3523
+ var symbols = Object.getOwnPropertySymbols(object);
3524
+ if (enumerableOnly) {
3525
+ symbols = symbols.filter(function(sym) {
3526
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3527
+ });
3528
+ }
3529
+ keys.push.apply(keys, symbols);
3530
+ }
3531
+ return keys;
3532
+ }
3533
+ function line_object_spread_props(target, source) {
3534
+ source = source != null ? source : {};
3535
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3536
+ else {
3537
+ line_ownKeys(Object(source)).forEach(function(key) {
3538
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3539
+ });
3540
+ }
3541
+ return target;
3542
+ }
3543
+ /**
3544
+ * PptxGenJS: Line properties (`a:ln` and its aliases)
3545
+ *
3546
+ * The same `CT_LineProperties` content model is used by shape outlines (`a:ln`), underlines
3547
+ * (`a:uLn`), and table cell borders, so the element name is a parameter rather than baked in.
3548
+ */
3549
+
3550
+ const LINE_ALIGNS = new Set([
3551
+ 'in',
3552
+ 'ctr',
3553
+ 'out'
3554
+ ]);
3555
+ /**
3556
+ * Create a line element
3557
+ * @param {ShapeLineProps} line - line options
3558
+ * @param {string} tag - element name; `a:ln` for a shape outline, `a:uLn` for an underline
3559
+ * @return {string} XML
3560
+ */ function genXmlLine(line, tag = 'a:ln') {
3561
+ // Explicit "no stroke" — emit `<a:noFill/>` so PowerPoint/Slides do not fall back to theme stroke
3562
+ if (line.type === 'none') {
3563
+ return `<${tag}><a:noFill/></${tag}>`;
3564
+ }
3565
+ // ECMA-376 §5.1.2.1.34: `<a:ln>` carries `w`, `cap`, `cmpd`, and `algn` attributes
3566
+ const cap = line.cap && [
3567
+ 'flat',
3568
+ 'sq',
3569
+ 'rnd'
3570
+ ].includes(line.cap) ? ` cap="${line.cap}"` : '';
3571
+ const compound = COMPOUND_TYPES.has(String(line.compound)) ? ` cmpd="${String(line.compound)}"` : '';
3572
+ if (line.compound && !COMPOUND_TYPES.has(String(line.compound))) {
3573
+ console.warn(`[pptxgenjs] line \`compound\` must be one of ${[
3574
+ ...COMPOUND_TYPES
3575
+ ].join(', ')} - "${String(line.compound)}" ignored`);
3576
+ }
3577
+ const align = line.align && LINE_ALIGNS.has(line.align) ? ` algn="${line.align}"` : '';
3578
+ if (line.align && !LINE_ALIGNS.has(line.align)) {
3579
+ console.warn(`[pptxgenjs] line \`align\` must be 'in' | 'ctr' | 'out' - "${String(line.align)}" ignored`);
3580
+ }
3581
+ const attrs = (line.width ? ` w="${valToLineWidth(line.width)}"` : '') + cap + compound + align;
3582
+ let xml = `<${tag}${attrs}>`;
3583
+ const hasGrad = !!(line.gradient || line.type === 'gradient' || line.type === 'linearGradient');
3584
+ if (line.color || hasGrad) {
3585
+ xml += genXmlColorSelection(hasGrad && !line.type ? line_object_spread_props(line_object_spread({}, line), {
3586
+ type: 'gradient'
3587
+ }) : line);
3588
+ }
3589
+ // CT_LineProperties sequence: fill, dash, join, headEnd, tailEnd. A custom pattern replaces
3590
+ // the preset one - emitting both would be ambiguous, since `a:custDash` is the same choice.
3591
+ xml += genXmlDash(line);
3592
+ xml += genXmlJoin(line);
3593
+ xml += genXmlArrow('a:headEnd', line.beginArrowType, line.beginArrowSize);
3594
+ xml += genXmlArrow('a:tailEnd', line.endArrowType, line.endArrowSize);
3595
+ xml += `</${tag}>`;
3596
+ return xml;
3597
+ }
3598
+ /** The dash choice: a custom pattern when given, otherwise the preset */ function genXmlDash(line) {
3599
+ var _line_custDash;
3600
+ const stops = ((_line_custDash = line.custDash) !== null && _line_custDash !== void 0 ? _line_custDash : []).filter((stop)=>{
3601
+ const ok = typeof (stop === null || stop === void 0 ? void 0 : stop.dash) === 'number' && isFinite(stop.dash) && stop.dash > 0 && typeof stop.space === 'number' && isFinite(stop.space) && stop.space >= 0;
3602
+ if (!ok) console.warn('[pptxgenjs] each `custDash` stop needs a positive `dash` and a non-negative `space` (percent of line width) - stop ignored');
3603
+ return ok;
3604
+ });
3605
+ if (stops.length > 0) {
3606
+ const items = stops.map((stop)=>`<a:ds d="${Math.round(stop.dash * 1000)}" sp="${Math.round(stop.space * 1000)}"/>`).join('');
3607
+ return `<a:custDash>${items}</a:custDash>`;
3608
+ }
3609
+ return line.dashType ? `<a:prstDash val="${line.dashType}"/>` : '';
3610
+ }
3611
+ /** The join choice: `a:round`, `a:bevel`, or `a:miter` with its limit */ function genXmlJoin(line) {
3612
+ if (!line.join) return '';
3613
+ if (line.join === 'round') return '<a:round/>';
3614
+ if (line.join === 'bevel') return '<a:bevel/>';
3615
+ if (line.join === 'miter') {
3616
+ const lim = typeof line.miterLimit === 'number' && isFinite(line.miterLimit) && line.miterLimit >= 0 ? line.miterLimit : 800;
3617
+ return `<a:miter lim="${Math.round(lim * 1000)}"/>`;
3618
+ }
3619
+ console.warn(`[pptxgenjs] line \`join\` must be 'round' | 'bevel' | 'miter' - "${String(line.join)}" ignored`);
3620
+ return '';
3621
+ }
3622
+ function resolveArrowSize(size) {
3623
+ if (!size) return undefined;
3624
+ if (typeof size === 'string') return {
3625
+ width: size,
3626
+ length: size
3627
+ };
3628
+ return size;
3629
+ }
3630
+ /** An arrow end with its optional sizing */ function genXmlArrow(tag, type, size) {
3631
+ if (!type) return '';
3632
+ const resolved = resolveArrowSize(size);
3633
+ const w = ARROW_SIZES.has(String(resolved === null || resolved === void 0 ? void 0 : resolved.width)) ? ` w="${String(resolved === null || resolved === void 0 ? void 0 : resolved.width)}"` : '';
3634
+ const len = ARROW_SIZES.has(String(resolved === null || resolved === void 0 ? void 0 : resolved.length)) ? ` len="${String(resolved === null || resolved === void 0 ? void 0 : resolved.length)}"` : '';
3635
+ return `<${tag} type="${type}"${w}${len}/>`;
3636
+ }
3637
+
3125
3638
  ;// CONCATENATED MODULE: ./src/xml/text.ts
3126
3639
  function text_define_property(obj, key, value) {
3127
3640
  if (key in obj) {
@@ -3229,7 +3742,7 @@ function text_object_spread_props(target, source) {
3229
3742
  if (bullet.color) xml += `<a:buClr>${createColorElement(bullet.color)}</a:buClr>`;
3230
3743
  // `a:buSzPct` and `a:buSzPts` are the same choice, so only one may appear
3231
3744
  if (typeof bullet.sizePts === 'number' && isFinite(bullet.sizePts) && bullet.sizePts > 0) {
3232
- xml += `<a:buSzPts val="${Math.round(bullet.sizePts * 100)}"/>`;
3745
+ xml += `<a:buSzPts val="${fontSizeToSz(bullet.sizePts)}"/>`;
3233
3746
  } else {
3234
3747
  const pct = typeof bullet.size === 'number' && isFinite(bullet.size) ? Math.min(400, Math.max(25, bullet.size)) : 100;
3235
3748
  if (typeof bullet.size === 'number' && (bullet.size < 25 || bullet.size > 400)) {
@@ -3240,6 +3753,20 @@ function text_object_spread_props(target, source) {
3240
3753
  if (bullet.fontFace) xml += `<a:buFont typeface="${encodeXmlEntities(bullet.fontFace)}"/>`;
3241
3754
  return xml;
3242
3755
  }
3756
+ /**
3757
+ * Compute `marL` and hanging `indent` attributes for a bulleted paragraph (`a:pPr`).
3758
+ * When `bullet.hangingIndentRatio` is provided, `bullet.indent` acts as the base left margin
3759
+ * (`before text` indent) and the hanging indent is `round(marL * hangingIndentRatio)`.
3760
+ */ function genXmlBulletMarginIndent(options) {
3761
+ const bullet = typeof options.bullet === 'object' ? options.bullet : {};
3762
+ const bulletMarL = valToPts(bullet.indent || (/* inlined export .DEF_BULLET_MARGIN */27));
3763
+ const indentLevel = options.indentLevel && options.indentLevel > 0 ? options.indentLevel : 0;
3764
+ if (typeof bullet.hangingIndentRatio === 'number' && Number.isFinite(bullet.hangingIndentRatio) && bullet.hangingIndentRatio > 0) {
3765
+ const hangingIndent = Math.round(bulletMarL * bullet.hangingIndentRatio);
3766
+ return ` marL="${bulletMarL * (indentLevel || 1)}" indent="-${hangingIndent}"`;
3767
+ }
3768
+ return ` marL="${indentLevel > 0 ? bulletMarL + bulletMarL * indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
3769
+ }
3243
3770
  /**
3244
3771
  * Generate XML Paragraph Properties
3245
3772
  * @param {ISlideObject|TextProps} textObj - text object
@@ -3252,7 +3779,6 @@ function text_object_spread_props(target, source) {
3252
3779
  let strXmlParaSpc = '';
3253
3780
  let strXmlTabStops = '';
3254
3781
  const tag = isDefault ? 'a:lvl1pPr' : 'a:pPr';
3255
- let bulletMarL = valToPts((/* inlined export .DEF_BULLET_MARGIN */27));
3256
3782
  const options = (_textObj_options = textObj.options) !== null && _textObj_options !== void 0 ? _textObj_options : {};
3257
3783
  let paragraphPropXml = `<${tag}${options.rtlMode ? ' rtl="1" ' : ''}`;
3258
3784
  // A: Build paragraphProperties
@@ -3277,10 +3803,12 @@ function text_object_spread_props(target, source) {
3277
3803
  break;
3278
3804
  }
3279
3805
  }
3806
+ // `a:spcPts` is ST_TextSpacingPoint (0..158400, i.e. 0..1584pt) and `a:spcPct` is
3807
+ // ST_TextSpacingPercent (0..13200000) - out-of-range spacing is a schema violation
3280
3808
  if (options.lineSpacing) {
3281
- strXmlLnSpc = `<a:lnSpc><a:spcPts val="${Math.round(options.lineSpacing * 100)}"/></a:lnSpc>`;
3809
+ strXmlLnSpc = `<a:lnSpc><a:spcPts val="${clampInt(options.lineSpacing * 100, 0, 158400)}"/></a:lnSpc>`;
3282
3810
  } else if (options.lineSpacingMultiple) {
3283
- strXmlLnSpc = `<a:lnSpc><a:spcPct val="${Math.round(options.lineSpacingMultiple * 100000)}"/></a:lnSpc>`;
3811
+ strXmlLnSpc = `<a:lnSpc><a:spcPct val="${clampInt(options.lineSpacingMultiple * 100000, 0, 13200000)}"/></a:lnSpc>`;
3284
3812
  }
3285
3813
  // OPTION: indent
3286
3814
  if (options.indentLevel && !isNaN(Number(options.indentLevel)) && options.indentLevel > 0) {
@@ -3303,28 +3831,28 @@ function text_object_spread_props(target, source) {
3303
3831
  if (para.hangingPunct === false) paragraphPropXml += ' hangingPunct="0"';
3304
3832
  // OPTION: Paragraph Spacing: Before/After
3305
3833
  if (options.paraSpaceBefore && !isNaN(Number(options.paraSpaceBefore)) && options.paraSpaceBefore > 0) {
3306
- strXmlParaSpc += `<a:spcBef><a:spcPts val="${Math.round(options.paraSpaceBefore * 100)}"/></a:spcBef>`;
3834
+ strXmlParaSpc += `<a:spcBef><a:spcPts val="${clampInt(options.paraSpaceBefore * 100, 0, 158400)}"/></a:spcBef>`;
3307
3835
  }
3308
3836
  if (options.paraSpaceAfter && !isNaN(Number(options.paraSpaceAfter)) && options.paraSpaceAfter > 0) {
3309
- strXmlParaSpc += `<a:spcAft><a:spcPts val="${Math.round(options.paraSpaceAfter * 100)}"/></a:spcAft>`;
3837
+ strXmlParaSpc += `<a:spcAft><a:spcPts val="${clampInt(options.paraSpaceAfter * 100, 0, 158400)}"/></a:spcAft>`;
3310
3838
  }
3311
3839
  // OPTION: bullet
3312
3840
  // NOTE: OOXML uses the unicode character set for Bullets
3313
3841
  // EX: Unicode Character 'BULLET' (U+2022) ==> '<a:buChar char="&#x2022;"/>'
3314
3842
  if (typeof options.bullet === 'object') {
3315
- var _options_bullet;
3316
- if ((_options_bullet = options.bullet) === null || _options_bullet === void 0 ? void 0 : _options_bullet.indent) bulletMarL = valToPts(options.bullet.indent);
3317
3843
  const buPrefix = genXmlBulletPrefix(options.bullet);
3318
- const buIndent = ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
3844
+ const buIndent = genXmlBulletMarginIndent(options);
3319
3845
  if (options.bullet.image && options.bullet._imageRId) {
3320
3846
  // `a:buBlip` replaces the character or number bullet entirely
3321
3847
  paragraphPropXml += buIndent;
3322
3848
  strXmlBullet = `${buPrefix}<a:buBlip><a:blip r:embed="rId${options.bullet._imageRId}"/></a:buBlip>`;
3323
3849
  } else if (options.bullet.type && options.bullet.type.toString().toLowerCase() === 'number') {
3850
+ var _ref, _options_bullet_numberStartAt;
3324
3851
  // NOTE: only `type: 'number'` is a distinct branch; any other `type` (e.g. 'bullet') falls through to the char-bullet cases below (issue #1432)
3325
3852
  paragraphPropXml += buIndent;
3326
3853
  // auto-numbered bullets fall back to the major latin face when none is given
3327
- strXmlBullet = `${buPrefix}${options.bullet.fontFace ? '' : '<a:buFont typeface="+mj-lt"/>'}<a:buAutoNum type="${options.bullet.numberType || options.bullet.style || 'arabicPeriod'}" startAt="${options.bullet.numberStartAt || options.bullet.startAt || '1'}"/>`;
3854
+ strXmlBullet = `${buPrefix}${options.bullet.fontFace ? '' : '<a:buFont typeface="+mj-lt"/>'}<a:buAutoNum type="${options.bullet.numberType || options.bullet.style || 'arabicPeriod'}" startAt="${// ST_TextBulletStartAtNum is 1..32767
3855
+ clampInt(Number((_ref = (_options_bullet_numberStartAt = options.bullet.numberStartAt) !== null && _options_bullet_numberStartAt !== void 0 ? _options_bullet_numberStartAt : options.bullet.startAt) !== null && _ref !== void 0 ? _ref : 1), 1, 32767)}"/>`;
3328
3856
  } else if (options.bullet.characterCode) {
3329
3857
  let bulletCode = `&#x${options.bullet.characterCode};`;
3330
3858
  // Check value for hex-ness (s/b 4 char hex)
@@ -3349,7 +3877,7 @@ function text_object_spread_props(target, source) {
3349
3877
  strXmlBullet = `${buPrefix}<a:buChar char="${(/* inlined export .BULLET_TYPES.DEFAULT */"&#x2022;")}"/>`;
3350
3878
  }
3351
3879
  } else if (options.bullet) {
3352
- paragraphPropXml += ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
3880
+ paragraphPropXml += genXmlBulletMarginIndent(options);
3353
3881
  strXmlBullet = `<a:buSzPct val="100000"/><a:buChar char="${(/* inlined export .BULLET_TYPES.DEFAULT */"&#x2022;")}"/>`;
3354
3882
  } else if (!options.bullet) {
3355
3883
  // We only add this when the user explicitely asks for no bullet, otherwise, it can override the master defaults!
@@ -3380,9 +3908,11 @@ function text_object_spread_props(target, source) {
3380
3908
  const runPropsTag = isDefault ? 'a:defRPr' : 'a:rPr';
3381
3909
  // BEGIN runProperties (ex: `<a:rPr lang="en-US" sz="1600" b="1" dirty="0">`)
3382
3910
  runProps += '<' + runPropsTag + ' lang="' + (opts.lang ? opts.lang : 'en-US') + '"' + (opts.lang ? ' altLang="en-US"' : '');
3383
- runProps += opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : ''; // NOTE: Use round so sizes like '7.5' wont cause corrupt presentations
3384
- runProps += (opts === null || opts === void 0 ? void 0 : opts.bold) ? ` b="${opts.bold ? '1' : '0'}"` : '';
3385
- runProps += (opts === null || opts === void 0 ? void 0 : opts.italic) ? ` i="${opts.italic ? '1' : '0'}"` : '';
3911
+ runProps += opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '';
3912
+ if ((opts === null || opts === void 0 ? void 0 : opts.bold) === false) runProps += ' b="0"';
3913
+ else if (opts === null || opts === void 0 ? void 0 : opts.bold) runProps += ' b="1"';
3914
+ if ((opts === null || opts === void 0 ? void 0 : opts.italic) === false) runProps += ' i="0"';
3915
+ else if (opts === null || opts === void 0 ? void 0 : opts.italic) runProps += ' i="1"';
3386
3916
  if ((opts === null || opts === void 0 ? void 0 : opts.strike) === true) warnDeprecatedOnce('strike-boolean', '`strike: true` is deprecated - use `strike: "sngStrike"` (or `"dblStrike"`)');
3387
3917
  runProps += (opts === null || opts === void 0 ? void 0 : opts.strike) ? ` strike="${typeof opts.strike === 'string' ? opts.strike : 'sngStrike'}"` : '';
3388
3918
  if (typeof opts.underline === 'object' && ((_opts_underline = opts.underline) === null || _opts_underline === void 0 ? void 0 : _opts_underline.style)) {
@@ -3416,7 +3946,7 @@ function text_object_spread_props(target, source) {
3416
3946
  // CT_TextCharacterProperties child order: ln, fill, effect, highlight, uLn, uFill, latin, ea, cs, sym
3417
3947
  if (opts.color || opts.gradient || opts.fontFace || opts.fontFaceEa || opts.fontFaceCs || opts.fontFaceSym || opts.outline || opts.glow || opts.highlight || run.underlineLine || typeof opts.underline === 'object' && opts.underline.color) {
3418
3948
  if (opts.outline && typeof opts.outline === 'object') {
3419
- runProps += `<a:ln w="${valToPts(opts.outline.size || 0.75)}">${genXmlColorSelection({
3949
+ runProps += `<a:ln w="${valToLineWidth(opts.outline.size || 0.75)}">${genXmlColorSelection({
3420
3950
  color: opts.outline.color || 'FFFFFF',
3421
3951
  transparency: opts.outline.transparency
3422
3952
  })}</a:ln>`;
@@ -3433,7 +3963,11 @@ function text_object_spread_props(target, source) {
3433
3963
  });
3434
3964
  const resolvedGlow = resolveGlowOptions(opts.glow);
3435
3965
  if (resolvedGlow) runProps += `<a:effectLst>${createGlowElement(resolvedGlow)}</a:effectLst>`;
3436
- if (opts.highlight) runProps += `<a:highlight>${createColorElement(opts.highlight)}</a:highlight>`;
3966
+ if (opts.highlight) {
3967
+ const highlightColor = typeof opts.highlight === 'string' ? opts.highlight : opts.highlight.color;
3968
+ const highlightAlpha = typeof opts.highlight === 'object' && opts.highlight.transparency ? `<a:alpha val="${clampAlphaPct(opts.highlight.transparency)}"/>` : '';
3969
+ runProps += `<a:highlight>${createColorElement(highlightColor, highlightAlpha)}</a:highlight>`;
3970
+ }
3437
3971
  if (run.underlineLine === 'text') runProps += '<a:uLnTx/>';
3438
3972
  else if (run.underlineLine && typeof run.underlineLine === 'object') runProps += genXmlLine(run.underlineLine, 'a:uLn');
3439
3973
  if (typeof opts.underline === 'object' && opts.underline.color) runProps += `<a:uFill>${genXmlColorSelection(opts.underline.color)}</a:uFill>`;
@@ -3841,7 +4375,7 @@ function genXmlTextRun(textObj) {
3841
4375
  // `glow` / softEdge / reflection belong on the shape effectLst (not per-run), unless set on the run itself
3842
4376
  // `omml` is a run-level math payload — inheriting it would replace sibling plain-text runs
3843
4377
  if (key === 'glow' || key === 'softEdge' || key === 'reflection' || key === 'shadow' || key === 'blur' || key === 'fillOverlay' || key === 'effectDag' || key === 'omml') return;
3844
- if (key !== 'bullet' && !textOpts[key]) textOpts[key] = val;
4378
+ if (key !== 'bullet' && textOpts[key] === undefined) textOpts[key] = val;
3845
4379
  });
3846
4380
  // D: Add formatted textrun
3847
4381
  strSlideXml += genXmlTextRun(textObj);
@@ -3858,17 +4392,17 @@ function genXmlTextRun(textObj) {
3858
4392
  const ea = opts.fontFaceEa || opts.fontFace;
3859
4393
  const cs = opts.fontFaceCs || opts.fontFace;
3860
4394
  if (latin || ea || cs) {
3861
- strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : '') + ' dirty="0">';
4395
+ strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0">';
3862
4396
  if (latin) strSlideXml += `<a:latin typeface="${encodeXmlEntities(latin)}" charset="0"/>`;
3863
4397
  if (ea) strSlideXml += `<a:ea typeface="${encodeXmlEntities(ea)}" charset="0"/>`;
3864
4398
  if (cs) strSlideXml += `<a:cs typeface="${encodeXmlEntities(cs)}" charset="0"/>`;
3865
4399
  strSlideXml += '</a:endParaRPr>';
3866
4400
  } else {
3867
- strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : '') + ' dirty="0"/>';
4401
+ strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0"/>';
3868
4402
  }
3869
4403
  } else if (reqsClosingFontSize) {
3870
4404
  // Empty [lineBreak] lines should not contain runProp, however, they need to specify fontSize in `endParaRPr`
3871
- strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : '') + ' dirty="0"/>';
4405
+ strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0"/>';
3872
4406
  } else {
3873
4407
  strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}" dirty="0"/>`; // Added 20180101 to address PPT-2007 issues
3874
4408
  }
@@ -4186,6 +4720,20 @@ function _object_without_properties_loose(source, excluded) {
4186
4720
 
4187
4721
 
4188
4722
 
4723
+
4724
+ function normalizeExtn(extn) {
4725
+ if (!extn || typeof extn !== 'string') return '';
4726
+ return extn.trim().replace(/^\./, '').toLowerCase();
4727
+ }
4728
+ function extractPathExtn(rawPath) {
4729
+ if (!rawPath) return 'png';
4730
+ const cleanPath = rawPath.split('?')[0].split('#')[0];
4731
+ const fileName = cleanPath.substring(Math.max(cleanPath.lastIndexOf('/'), cleanPath.lastIndexOf('\\')) + 1);
4732
+ const dotIdx = fileName.lastIndexOf('.');
4733
+ if (dotIdx <= 0 || dotIdx === fileName.length - 1) return 'png';
4734
+ const candidate = fileName.substring(dotIdx + 1).toLowerCase();
4735
+ return /^[a-z0-9]{1,8}$/.test(candidate) ? candidate : 'png';
4736
+ }
4189
4737
  /** Valid OOXML preset-geometry strings (the values of `SHAPE_TYPE`) - anything else corrupts the file. */ const VALID_SHAPE_PRESETS = new Set(Object.values(core_enums_SHAPE_TYPE));
4190
4738
  /** Type guard: true when `arr` is a flat (1-level) array rather than a nested one. */ function isFlatStringArray(arr) {
4191
4739
  return Array.isArray(arr) && (arr.length === 0 || !Array.isArray(arr[0]));
@@ -4523,10 +5071,11 @@ function _object_without_properties_loose(source, excluded) {
4523
5071
  const v3DPerspective = options.v3DPerspective;
4524
5072
  options.v3DPerspective = v3DPerspective !== undefined && !isNaN(v3DPerspective) && v3DPerspective >= 0 && v3DPerspective <= 240 ? v3DPerspective : 30;
4525
5073
  // D: Options: chart
5074
+ // `c:gapWidth`/`c:gapDepth` are ST_GapAmount (0..500); clamp finite values to 0..500
4526
5075
  const barGapWidthPct = options.barGapWidthPct;
4527
- options.barGapWidthPct = barGapWidthPct !== undefined && !isNaN(barGapWidthPct) && barGapWidthPct >= 0 && barGapWidthPct <= 1000 ? barGapWidthPct : 150;
5076
+ options.barGapWidthPct = typeof barGapWidthPct === 'number' && Number.isFinite(barGapWidthPct) ? clampInt(barGapWidthPct, 0, 500) : 150;
4528
5077
  const barGapDepthPct = options.barGapDepthPct;
4529
- options.barGapDepthPct = barGapDepthPct !== undefined && !isNaN(barGapDepthPct) && barGapDepthPct >= 0 && barGapDepthPct <= 1000 ? barGapDepthPct : 150;
5078
+ options.barGapDepthPct = typeof barGapDepthPct === 'number' && Number.isFinite(barGapDepthPct) ? clampInt(barGapDepthPct, 0, 500) : 150;
4530
5079
  options.chartColors = Array.isArray(options.chartColors) ? options.chartColors : options._type === core_enums_CHART_TYPE.PIE || options._type === core_enums_CHART_TYPE.DOUGHNUT ? PIECHART_COLORS : BARCHART_COLORS;
4531
5080
  options.chartColorsOpacity = options.chartColorsOpacity && !isNaN(options.chartColorsOpacity) ? options.chartColorsOpacity : undefined;
4532
5081
  // DEPRECATED: v3.11.0 - use `plotArea.border` vvv
@@ -4738,14 +5287,14 @@ function isSvgFillSource(data, path) {
4738
5287
  });
4739
5288
  return svgRid;
4740
5289
  }
4741
- let extn = (path.split('?')[0].split('#')[0].split('.').pop() || 'png').toLowerCase();
5290
+ let extn = extractPathExtn(path);
4742
5291
  const mime = data ? /image\/([\w+]+);/.exec(data) : null;
4743
- if (mime === null || mime === void 0 ? void 0 : mime[1]) extn = mime[1] === 'svg+xml' ? 'svg' : mime[1];
5292
+ if (mime === null || mime === void 0 ? void 0 : mime[1]) extn = mime[1].toLowerCase() === 'svg+xml' ? 'svg' : mime[1].toLowerCase();
4744
5293
  if (extn === 'jpg') extn = 'jpeg';
4745
5294
  const imgType = 'image/' + extn;
4746
5295
  const dupeItem = target._relsMedia.filter((item)=>item.type === imgType && !item.isDuplicate && !item.isSvgPng && (path && item.path === path || data && item.data && item.data === data))[0];
4747
5296
  const rId = getNewRelId(target);
4748
- target._relsMedia.push({
5297
+ const mediaRel = {
4749
5298
  path: path || 'preencoded.' + extn,
4750
5299
  type: imgType,
4751
5300
  extn,
@@ -4753,7 +5302,9 @@ function isSvgFillSource(data, path) {
4753
5302
  rId,
4754
5303
  isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
4755
5304
  Target: (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/${imageTargetStem(target)}.${extn}`
4756
- });
5305
+ };
5306
+ dedupeImageMediaRel(target, mediaRel);
5307
+ target._relsMedia.push(mediaRel);
4757
5308
  return rId;
4758
5309
  }
4759
5310
  function isStructuredImageFill(fill) {
@@ -4793,7 +5344,7 @@ function resolveObjectImageFills(target, options) {
4793
5344
  if ((_options_fillOverlay = options.fillOverlay) === null || _options_fillOverlay === void 0 ? void 0 : _options_fillOverlay.fill) resolveImageFill(target, options.fillOverlay.fill);
4794
5345
  }
4795
5346
  function addImageDefinition(target, opt) {
4796
- var _opt_fillOverlay, _strImagePath_substring_split__split_pop;
5347
+ var _opt_fillOverlay;
4797
5348
  if ((_opt_fillOverlay = opt.fillOverlay) === null || _opt_fillOverlay === void 0 ? void 0 : _opt_fillOverlay.fill) resolveImageFill(target, opt.fillOverlay.fill);
4798
5349
  const newObject = {
4799
5350
  _type: (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"),
@@ -4829,14 +5380,17 @@ function addImageDefinition(target, opt) {
4829
5380
  return;
4830
5381
  }
4831
5382
  // STEP 1: Set extension
4832
- // NOTE: Split to address URLs with params (eg: `path/brent.jpg?someParam=true`)
4833
- let strImgExtn = (((_strImagePath_substring_split__split_pop = strImagePath.substring(strImagePath.lastIndexOf('/') + 1).split('?')[0].split('.').pop()) === null || _strImagePath_substring_split__split_pop === void 0 ? void 0 : _strImagePath_substring_split__split_pop.split('#')[0]) || 'png').toLowerCase();
5383
+ // Honor explicit `opt.extn` (for extensionless signed CDN URLs); otherwise parse from path safely.
5384
+ const explicitExtn = normalizeExtn(opt.extn);
5385
+ let strImgExtn = explicitExtn || extractPathExtn(strImagePath);
4834
5386
  // However, pre-encoded images can be whatever mime-type they want (and good for them!)
4835
- const strImageMimeMatch = strImageData ? /image\/(\w+);/.exec(strImageData) : null;
4836
- if (strImageMimeMatch && strImageMimeMatch.length > 0) {
4837
- strImgExtn = strImageMimeMatch[1];
4838
- } else if (strImageData === null || strImageData === void 0 ? void 0 : strImageData.toLowerCase().includes('image/svg+xml')) {
4839
- strImgExtn = 'svg';
5387
+ if (!explicitExtn) {
5388
+ const strImageMimeMatch = strImageData ? /image\/(\w+);/.exec(strImageData) : null;
5389
+ if (strImageMimeMatch && strImageMimeMatch.length > 0) {
5390
+ strImgExtn = strImageMimeMatch[1].toLowerCase();
5391
+ } else if (strImageData === null || strImageData === void 0 ? void 0 : strImageData.toLowerCase().includes('image/svg+xml')) {
5392
+ strImgExtn = 'svg';
5393
+ }
4840
5394
  }
4841
5395
  // STEP 2: Set type/path
4842
5396
  newObject._type = (/* inlined export .SLIDE_OBJECT_TYPES.image */"image");
@@ -4928,10 +5482,10 @@ function addImageDefinition(target, opt) {
4928
5482
  } else {
4929
5483
  // PERF: Duplicate media should reuse existing `Target` value and not create an additional copy.
4930
5484
  // OPC (ECMA-376 Part 2) lets many relationships point at one part, so identical image bytes are stored once.
4931
- // Match on the source path when given, else on identical base64 `data` (issue #1339) - same content, one media file.
4932
- const imgType = 'image/' + strImgExtn;
5485
+ // Match on the source path within slide, and across the entire deck on identical base64 content hash.
5486
+ const imgType = strImgExtn === 'jpg' ? 'image/jpeg' : 'image/' + strImgExtn;
4933
5487
  const dupeItem = target._relsMedia.filter((item)=>item.type === imgType && !item.isDuplicate && !item.isSvgPng && (strImagePath && item.path === strImagePath || strImageData && item.data && item.data === strImageData))[0];
4934
- target._relsMedia.push({
5488
+ const mediaRel = {
4935
5489
  path: strImagePath || 'preencoded.' + strImgExtn,
4936
5490
  type: imgType,
4937
5491
  extn: strImgExtn,
@@ -4939,7 +5493,9 @@ function addImageDefinition(target, opt) {
4939
5493
  rId: imageRelId,
4940
5494
  isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
4941
5495
  Target: (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/${imageTargetStem(target)}.${strImgExtn}`
4942
- });
5496
+ };
5497
+ dedupeImageMediaRel(target, mediaRel);
5498
+ target._relsMedia.push(mediaRel);
4943
5499
  newObject.imageRid = imageRelId;
4944
5500
  }
4945
5501
  // STEP 5: Hyperlink support
@@ -5474,8 +6030,10 @@ function nextExtPartName(target, prefix, extn) {
5474
6030
  bullet._imageRId = rId;
5475
6031
  }
5476
6032
  function addShapeDefinition(target, shapeName, opts) {
6033
+ var _options_styleRef;
5477
6034
  const options = typeof opts === 'object' ? opts : {};
5478
- options.line = options.line || {
6035
+ // With a theme `lnRef` and no explicit line, omit `<a:ln>` so the stroke inherits from the theme (matches `styleRef.fill` in slide.ts)
6036
+ if (!options.line && !((_options_styleRef = options.styleRef) === null || _options_styleRef === void 0 ? void 0 : _options_styleRef.line)) options.line = {
5479
6037
  type: 'none'
5480
6038
  };
5481
6039
  resolveHyperlinkRels(target, options.hyperlink);
@@ -5496,28 +6054,29 @@ function addShapeDefinition(target, shapeName, opts) {
5496
6054
  throw new Error(`Invalid shape "${shapeName}" - use a \`pptxgen.ShapeType\` value (ex: \`pptxgen.ShapeType.oval\` = 'ellipse')`);
5497
6055
  }
5498
6056
  // 1: ShapeLineProps defaults
5499
- const hasConnectorEnds = options.line.sourceId != null || options.line.targetId != null;
5500
- const newLineOpts = gen_objects_object_spread_props(gen_objects_object_spread({}, options.line), {
5501
- type: options.line.type || (options.line.gradient ? 'gradient' : 'solid'),
5502
- color: options.line.color || (/* inlined export .DEF_SHAPE_LINE_COLOR */"333333"),
5503
- transparency: options.line.transparency || 0,
5504
- gradient: options.line.gradient,
5505
- width: options.line.width || 1,
5506
- dashType: options.line.dashType || 'solid',
5507
- cap: options.line.cap,
5508
- beginArrowType: options.line.beginArrowType || undefined,
5509
- endArrowType: options.line.endArrowType || undefined,
6057
+ const lineSrc = typeof options.line === 'object' && options.line !== null ? options.line : {};
6058
+ const hasConnectorEnds = lineSrc.sourceId != null || lineSrc.targetId != null;
6059
+ const newLineOpts = gen_objects_object_spread_props(gen_objects_object_spread({}, lineSrc), {
6060
+ type: lineSrc.type || (lineSrc.gradient ? 'gradient' : 'solid'),
6061
+ color: lineSrc.color || (/* inlined export .DEF_SHAPE_LINE_COLOR */"333333"),
6062
+ transparency: lineSrc.transparency || 0,
6063
+ gradient: lineSrc.gradient,
6064
+ width: lineSrc.width || 1,
6065
+ dashType: lineSrc.dashType || 'solid',
6066
+ cap: lineSrc.cap,
6067
+ beginArrowType: lineSrc.beginArrowType || undefined,
6068
+ endArrowType: lineSrc.endArrowType || undefined,
5510
6069
  // ZentoSoft connectors
5511
- sourceId: options.line.sourceId,
5512
- targetId: options.line.targetId,
5513
- sourceAnchorPos: options.line.sourceAnchorPos,
5514
- targetAnchorPos: options.line.targetAnchorPos,
5515
- isConnector: options.line.isConnector || hasConnectorEnds,
5516
- curveadjust: options.line.curveadjust,
5517
- _sourceName: options.line._sourceName,
5518
- _targetName: options.line._targetName
6070
+ sourceId: lineSrc.sourceId,
6071
+ targetId: lineSrc.targetId,
6072
+ sourceAnchorPos: lineSrc.sourceAnchorPos,
6073
+ targetAnchorPos: lineSrc.targetAnchorPos,
6074
+ isConnector: lineSrc.isConnector || hasConnectorEnds,
6075
+ curveadjust: lineSrc.curveadjust,
6076
+ _sourceName: lineSrc._sourceName,
6077
+ _targetName: lineSrc._targetName
5519
6078
  });
5520
- if (typeof options.line === 'object' && options.line.type !== 'none') options.line = newLineOpts;
6079
+ if (typeof options.line === 'object' && options.line !== null && options.line.type !== 'none') options.line = newLineOpts;
5521
6080
  // 2: Set options defaults
5522
6081
  const shapeOpts = options;
5523
6082
  shapeOpts._explicitX = options.x !== undefined && options.x !== null;
@@ -5546,11 +6105,35 @@ function addShapeDefinition(target, shapeName, opts) {
5546
6105
  * @param {Function} addSlide - method
5547
6106
  * @param {Function} getSlide - method
5548
6107
  */ function addTableDefinition(target, tableRows, options, slideLayout, presLayout, addSlide, getSlide) {
6108
+ var _ref;
6109
+ var _target__slideLayout;
5549
6110
  const slides = [
5550
6111
  target
5551
6112
  ] // Create array of Slides as more may be added by auto-paging
5552
6113
  ;
5553
- const opt = options && typeof options === 'object' ? gen_objects_object_spread({}, options) : {};
6114
+ let opt = options && typeof options === 'object' ? gen_objects_object_spread({}, options) : {};
6115
+ const explicitX = opt.x !== undefined && opt.x !== null;
6116
+ const explicitY = opt.y !== undefined && opt.y !== null;
6117
+ const explicitW = opt.w !== undefined && opt.w !== null;
6118
+ const explicitH = opt.h !== undefined && opt.h !== null;
6119
+ // PR #1151: resolve layout placeholder defaults under caller options so caller overrides placeholder defaults
6120
+ const layoutObjs = (_ref = (_target__slideLayout = target._slideLayout) === null || _target__slideLayout === void 0 ? void 0 : _target__slideLayout._slideObjects) !== null && _ref !== void 0 ? _ref : slideLayout === null || slideLayout === void 0 ? void 0 : slideLayout._slideObjects;
6121
+ if (opt.placeholder && layoutObjs) {
6122
+ const placeHold = layoutObjs.find((item)=>{
6123
+ var _item_options;
6124
+ return item._type === (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder") && ((_item_options = item.options) === null || _item_options === void 0 ? void 0 : _item_options.placeholder) === opt.placeholder;
6125
+ });
6126
+ if (placeHold === null || placeHold === void 0 ? void 0 : placeHold.options) {
6127
+ const _placeHold_options = placeHold.options, { _bodyProp: _bp, line: _ln, objectName: _on, sId: _sId, shape: _sh } = _placeHold_options, placeHoldOpts = _object_without_properties(_placeHold_options, [
6128
+ "_bodyProp",
6129
+ "line",
6130
+ "objectName",
6131
+ "sId",
6132
+ "shape"
6133
+ ]);
6134
+ opt = gen_objects_object_spread({}, placeHoldOpts, opt);
6135
+ }
6136
+ }
5554
6137
  opt.objectName = opt.objectName ? encodeXmlEntities(opt.objectName) : `Table ${target._slideObjects.filter((obj)=>obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.table */"table")).length}`;
5555
6138
  // STEP 1: REALITY-CHECK
5556
6139
  {
@@ -5579,21 +6162,40 @@ function addShapeDefinition(target, shapeName, opts) {
5579
6162
  if (Array.isArray(row)) {
5580
6163
  row.forEach((cell)=>{
5581
6164
  var _newCell_options;
5582
- // A:
6165
+ // A: Clone cell options so caller-supplied objects are never mutated (PR #1553)
5583
6166
  const newCell = {
5584
6167
  _type: (/* inlined export .SLIDE_OBJECT_TYPES.tablecell */"tablecell"),
5585
6168
  text: '',
5586
- options: typeof cell === 'object' && cell.options ? cell.options : {}
6169
+ options: typeof cell === 'object' && cell !== null && cell.options && typeof cell.options === 'object' ? gen_objects_object_spread({}, cell.options) : {}
5587
6170
  };
5588
6171
  // B:
5589
6172
  if (typeof cell === 'string' || typeof cell === 'number') newCell.text = cell.toString();
5590
- else if (cell.text) {
6173
+ else if (cell && typeof cell === 'object' && cell.text !== undefined && cell.text !== null) {
5591
6174
  // Cell can contain complex text type, or string, or number
5592
6175
  if (typeof cell.text === 'string' || typeof cell.text === 'number') newCell.text = cell.text.toString();
5593
- else if (cell.text) newCell.text = cell.text;
5594
- // Capture options
5595
- if (cell.options && typeof cell.options === 'object') newCell.options = cell.options;
6176
+ else if (Array.isArray(cell.text)) {
6177
+ var _newCell_options1;
6178
+ // Clone runs and their options so caller objects are never mutated; inherit lang without overwriting explicit run lang
6179
+ const inheritedLang = ((_newCell_options1 = newCell.options) === null || _newCell_options1 === void 0 ? void 0 : _newCell_options1.lang) || opt.lang;
6180
+ newCell.text = cell.text.map((run)=>{
6181
+ if (!run || typeof run !== 'object') return run;
6182
+ const runOpts = run.options && typeof run.options === 'object' ? gen_objects_object_spread({}, run.options) : undefined;
6183
+ if (inheritedLang && !(runOpts === null || runOpts === void 0 ? void 0 : runOpts.lang)) {
6184
+ return gen_objects_object_spread_props(gen_objects_object_spread({}, run), {
6185
+ options: gen_objects_object_spread_props(gen_objects_object_spread({}, runOpts), {
6186
+ lang: inheritedLang
6187
+ })
6188
+ });
6189
+ }
6190
+ return gen_objects_object_spread_props(gen_objects_object_spread({}, run), {
6191
+ options: runOpts
6192
+ });
6193
+ });
6194
+ } else {
6195
+ newCell.text = cell.text;
6196
+ }
5596
6197
  }
6198
+ if (opt.lang && newCell.options && !newCell.options.lang) newCell.options.lang = opt.lang;
5597
6199
  // C: Set cell borders
5598
6200
  const cellOpts = (_newCell_options = newCell.options) !== null && _newCell_options !== void 0 ? _newCell_options : {};
5599
6201
  newCell.options = cellOpts;
@@ -5612,12 +6214,15 @@ function addShapeDefinition(target, shapeName, opts) {
5612
6214
  }
5613
6215
  ];
5614
6216
  // CASE 1: border interface is: BorderOptions | [BorderOptions, BorderOptions, BorderOptions, BorderOptions]
6217
+ // Defensively shallow-copy caller border arrays so we never mutate them in place (PR #1541)
5615
6218
  const cellBorder = !Array.isArray(initialBorder) && typeof initialBorder === 'object' ? [
5616
6219
  initialBorder,
5617
6220
  initialBorder,
5618
6221
  initialBorder,
5619
6222
  initialBorder
5620
- ] : initialBorder;
6223
+ ] : [
6224
+ ...initialBorder
6225
+ ];
5621
6226
  cellOpts.border = cellBorder;
5622
6227
  // Handle: [null, null, {type:'solid'}, null]
5623
6228
  if (!cellBorder[0]) cellBorder[0] = {
@@ -5666,10 +6271,10 @@ function addShapeDefinition(target, shapeName, opts) {
5666
6271
  });
5667
6272
  // STEP 3: Set options
5668
6273
  const tableOpts = opt;
5669
- tableOpts._explicitX = opt.x !== undefined && opt.x !== null;
5670
- tableOpts._explicitY = opt.y !== undefined && opt.y !== null;
5671
- tableOpts._explicitW = opt.w !== undefined && opt.w !== null;
5672
- tableOpts._explicitH = opt.h !== undefined && opt.h !== null;
6274
+ tableOpts._explicitX = explicitX;
6275
+ tableOpts._explicitY = explicitY;
6276
+ tableOpts._explicitW = explicitW;
6277
+ tableOpts._explicitH = explicitH;
5673
6278
  opt.x = getSmartParseNumber(opt.x || (opt.x === 0 ? 0 : (/* inlined export .EMU */914400) / 2), 'X', presLayout);
5674
6279
  opt.y = getSmartParseNumber(opt.y || (opt.y === 0 ? 0 : (/* inlined export .EMU */914400) / 2), 'Y', presLayout);
5675
6280
  if (opt.h) opt.h = getSmartParseNumber(opt.h, 'Y', presLayout); // NOTE: Dont set default `h` - leaving it null triggers auto-rowH in `makeXMLSlide()`
@@ -5691,7 +6296,9 @@ function addShapeDefinition(target, shapeName, opts) {
5691
6296
  console.warn('addTable `border` option must be an object. Ex: `{border: {type:\'none\'}}`');
5692
6297
  opt.border = undefined;
5693
6298
  } else if (Array.isArray(opt.border)) {
5694
- const optBorder = opt.border;
6299
+ const optBorder = [
6300
+ ...opt.border
6301
+ ];
5695
6302
  [
5696
6303
  0,
5697
6304
  1,
@@ -5708,6 +6315,7 @@ function addShapeDefinition(target, shapeName, opts) {
5708
6315
  type: 'none'
5709
6316
  };
5710
6317
  });
6318
+ opt.border = optBorder;
5711
6319
  }
5712
6320
  opt.autoPage = typeof opt.autoPage === 'boolean' ? opt.autoPage : false;
5713
6321
  opt.autoPageRepeatHeader = typeof opt.autoPageRepeatHeader === 'boolean' ? opt.autoPageRepeatHeader : false;
@@ -6054,21 +6662,29 @@ function addShapeDefinition(target, shapeName, opts) {
6054
6662
  // B: Handle media
6055
6663
  if (props && (props.path || props.data)) {
6056
6664
  // Allow the use of only the data key (`path` isnt reqd)
6057
- props.path = props.path || 'preencoded.png';
6058
- let strImgExtn = (props.path.split('.').pop() || 'png').split('?')[0] // Handle "blah.jpg?width=540" etc.
6059
- ;
6060
- if (strImgExtn === 'jpg') strImgExtn = 'jpeg'; // base64-encoded jpg's come out as "data:image/jpeg;base64,/9j/[...]", so correct exttnesion to avoid content warnings at PPT startup
6665
+ const explicitExtn = normalizeExtn(props.extn);
6666
+ props.path = props.path || `preencoded.${explicitExtn || 'png'}`;
6667
+ let strImgExtn = explicitExtn || extractPathExtn(props.path);
6668
+ if (!explicitExtn && props.data) {
6669
+ const bkgdMimeMatch = /image\/([\w+]+);/.exec(props.data);
6670
+ if (bkgdMimeMatch === null || bkgdMimeMatch === void 0 ? void 0 : bkgdMimeMatch[1]) {
6671
+ strImgExtn = bkgdMimeMatch[1].toLowerCase() === 'svg+xml' ? 'svg' : bkgdMimeMatch[1].toLowerCase();
6672
+ }
6673
+ }
6674
+ if (strImgExtn === 'jpg') strImgExtn = 'jpeg'; // base64-encoded jpg's come out as "data:image/jpeg;base64,/9j/[...]", so correct extension to avoid content warnings at PPT startup
6061
6675
  target._relsMedia = target._relsMedia || [];
6062
6676
  const intRels = target._relsMedia.length + 1;
6063
6677
  // NOTE: `Target` cannot have spaces (eg:"Slide 1-image-1.jpg") or a "presentation is corrupt" warning comes up
6064
- target._relsMedia.push({
6678
+ const bkgdRel = {
6065
6679
  path: props.path,
6066
6680
  type: (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"),
6067
6681
  extn: strImgExtn,
6068
6682
  data: props.data || undefined,
6069
6683
  rId: intRels,
6070
6684
  Target: `../media/${(target._name || '').replace(/\s+/gi, '-')}-image-${target._relsMedia.length + 1}.${strImgExtn}`
6071
- });
6685
+ };
6686
+ dedupeImageMediaRel(target, bkgdRel);
6687
+ target._relsMedia.push(bkgdRel);
6072
6688
  target._bkgdImgRid = intRels;
6073
6689
  }
6074
6690
  }
@@ -6085,8 +6701,14 @@ function addShapeDefinition(target, shapeName, opts) {
6085
6701
  text
6086
6702
  ];
6087
6703
  textObjs.forEach((text, idx)=>{
6088
- // IMPORTANT: `options` are lost due to recursion/copy!
6089
- if (!Array.isArray(text) && options && options[idx] && options[idx].hyperlink) text.options = gen_objects_object_spread({}, text.options, options[idx]);
6704
+ // IMPORTANT: `options` are lost due to recursion/copy! Preserve explicit run `lang` over cell `lang` (PR #1553).
6705
+ if (!Array.isArray(text) && options && options[idx] && options[idx].hyperlink) {
6706
+ var _text_options;
6707
+ const preservedLang = ((_text_options = text.options) === null || _text_options === void 0 ? void 0 : _text_options.lang) || options[idx].lang;
6708
+ text.options = gen_objects_object_spread({}, text.options, options[idx], preservedLang ? {
6709
+ lang: preservedLang
6710
+ } : {});
6711
+ }
6090
6712
  // NOTE: `text` can be an array of other `text` objects (table cell word-level formatting), continue parsing using recursion
6091
6713
  if (Array.isArray(text)) {
6092
6714
  const cellOpts = [];
@@ -6754,11 +7376,11 @@ function createShadowElement(shadow) {
6754
7376
  }
6755
7377
  let strXml = '<a:effectLst>';
6756
7378
  const type = shadow.type;
6757
- const blur = valToPts(shadow.blur);
6758
- const offset = valToPts(shadow.offset);
7379
+ const blur = Math.max(0, valToPts(shadow.blur));
7380
+ const offset = Math.max(0, valToPts(shadow.offset));
6759
7381
  const angle = Math.round(shadow.angle * 60000);
6760
7382
  const color = shadow.color;
6761
- const opacity = Math.round(shadow.opacity * 100000);
7383
+ const opacity = clampAlphaPct(100 - shadow.opacity * 100);
6762
7384
  const rotShape = shadow.rotateWithShape ? 1 : 0;
6763
7385
  strXml += `<a:${type}Shdw sx="100000" sy="100000" kx="0" ky="0" algn="bl" blurRad="${blur}" rotWithShape="${rotShape}" dist="${offset}" dir="${angle}">`;
6764
7386
  strXml += `<a:srgbClr val="${color}">`;
@@ -6774,7 +7396,7 @@ function createShadowElement(shadow) {
6774
7396
  */ function createGridLineElement(glOpts) {
6775
7397
  let strXml = '<c:majorGridlines>';
6776
7398
  strXml += ' <c:spPr>';
6777
- strXml += ` <a:ln w="${valToPts(glOpts.size || DEF_CHART_GRIDLINE.size)}" cap="${createLineCap(glOpts.cap || DEF_CHART_GRIDLINE.cap)}">`;
7399
+ strXml += ` <a:ln w="${valToLineWidth(glOpts.size || DEF_CHART_GRIDLINE.size)}" cap="${createLineCap(glOpts.cap || DEF_CHART_GRIDLINE.cap)}">`;
6778
7400
  strXml += ` <a:solidFill>${createColorElement(glOpts.color || DEF_CHART_GRIDLINE.color)}</a:solidFill>`;
6779
7401
  strXml += ' <a:prstDash val="' + (glOpts.style || DEF_CHART_GRIDLINE.style) + '"/><a:round/>';
6780
7402
  strXml += ' </a:ln>';
@@ -6812,7 +7434,7 @@ function createLineCap(lineCap) {
6812
7434
  if (chartDash && CHART_LINE_DASH_TYPES.includes(chartDash)) return chartDash;
6813
7435
  return 'solid';
6814
7436
  }
6815
- /** Area charts use `c:grouping` / ST_Grouping (standard|stacked|percentStacked), not ST_BarGrouping. */ const AREA_GROUPING = [
7437
+ /** Area and line charts use `c:grouping` / ST_Grouping (standard|stacked|percentStacked), not ST_BarGrouping. */ const AREA_GROUPING = [
6816
7438
  'standard',
6817
7439
  'stacked',
6818
7440
  'percentStacked'
@@ -6891,7 +7513,7 @@ function firstLabelLevel(data) {
6891
7513
  // `outEnd` is invalid on the layouts that draw labels inside their segments
6892
7514
  const defaultPos = chartType === 'treemap' || chartType === 'sunburst' || chartType === 'funnel' ? 'ctr' : 'outEnd';
6893
7515
  const pos = (_opts_dataLabelPosition = opts.dataLabelPosition) !== null && _opts_dataLabelPosition !== void 0 ? _opts_dataLabelPosition : defaultPos;
6894
- const size = Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100);
7516
+ const size = fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12));
6895
7517
  const txPr = '<cx:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>' + `<a:defRPr sz="${size}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}">` + `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>` + `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace || 'Arial')}"/>` + '</a:defRPr></a:pPr></a:p></cx:txPr>';
6896
7518
  const numFmt = opts.dataLabelFormatCode ? `<cx:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode)}" sourceLinked="0"/>` : '';
6897
7519
  return `<cx:dataLabels pos="${pos}">` + `<cx:visibility seriesName="0" categoryName="${showCategory ? 1 : 0}" value="${showValue ? 1 : 0}"/>` + numFmt + txPr + '</cx:dataLabels>';
@@ -6954,7 +7576,7 @@ function firstLabelLevel(data) {
6954
7576
  }
6955
7577
  function makeTitle(opts) {
6956
7578
  if (!opts.showTitle) return '';
6957
- const size = Math.round((opts.titleFontSize || (/* inlined export .DEF_FONT_TITLE_SIZE */18)) * 100);
7579
+ const size = fontSizeToSz(opts.titleFontSize || (/* inlined export .DEF_FONT_TITLE_SIZE */18));
6958
7580
  const color = opts.titleColor ? `<a:solidFill>${createColorElement(opts.titleColor)}</a:solidFill>` : '';
6959
7581
  const face = opts.titleFontFace ? `<a:latin typeface="${encodeXmlEntities(opts.titleFontFace)}"/>` : '';
6960
7582
  return '<cx:title pos="t" align="ctr" overlay="0"><cx:tx><cx:rich><a:bodyPr/><a:lstStyle/><a:p><a:pPr algn="ctr"/><a:r>' + `<a:rPr lang="${opts.lang || 'en-US'}" sz="${size}" b="${opts.titleBold ? 1 : 0}">${color}${face}</a:rPr>` + `<a:t>${encodeXmlEntities(opts.title || 'Chart Title')}</a:t>` + '</a:r></a:p></cx:rich></cx:tx></cx:title>';
@@ -7075,7 +7697,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7075
7697
  const align = opts.titleAlign === 'left' || opts.titleAlign === 'right' ? `<a:pPr algn="${opts.titleAlign.substring(0, 1)}">` : '<a:pPr>';
7076
7698
  const rotate = opts.titleRotate ? `<a:bodyPr rot="${convertRotationDegrees(opts.titleRotate)}"/>` : '<a:bodyPr/>' // don't specify rotation to get default (ex. vertical for cat axis)
7077
7699
  ;
7078
- const sizeAttr = opts.fontSize ? `sz="${Math.round(opts.fontSize * 100)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
7700
+ const sizeAttr = opts.fontSize ? `sz="${fontSizeToSz(opts.fontSize)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
7079
7701
  ;
7080
7702
  const titleBold = opts.titleBold ? 1 : 0;
7081
7703
  const titleItalic = opts.titleItalic ? 1 : 0;
@@ -7183,7 +7805,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7183
7805
  strXml += ' <c:tickLblPos val="' + (opts.catAxisLabelPos || (opts.barDir === 'col' ? 'low' : 'nextTo')) + '"/>';
7184
7806
  }
7185
7807
  strXml += ' <c:spPr>';
7186
- strXml += ` <a:ln w="${opts.catAxisLineSize ? valToPts(opts.catAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7808
+ strXml += ` <a:ln w="${opts.catAxisLineSize ? valToLineWidth(opts.catAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7187
7809
  strXml += !opts.catAxisLineShow ? '<a:noFill/>' : '<a:solidFill>' + createColorElement(opts.catAxisLineColor || DEF_CHART_GRIDLINE.color) + '</a:solidFill>';
7188
7810
  strXml += ' <a:prstDash val="' + (opts.catAxisLineStyle || 'solid') + '"/>';
7189
7811
  strXml += ' <a:round/>';
@@ -7199,7 +7821,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7199
7821
  strXml += ' <a:lstStyle/>';
7200
7822
  strXml += ' <a:p>';
7201
7823
  strXml += ' <a:pPr>';
7202
- strXml += ` <a:defRPr sz="${Math.round((opts.catAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="${opts.catAxisLabelFontBold ? 1 : 0}" i="${opts.catAxisLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">`;
7824
+ strXml += ` <a:defRPr sz="${fontSizeToSz(opts.catAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.catAxisLabelFontBold ? 1 : 0}" i="${opts.catAxisLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">`;
7203
7825
  strXml += ' <a:solidFill>' + createColorElement(opts.catAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
7204
7826
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.catAxisLabelFontFace) || 'Arial') + '"/>';
7205
7827
  strXml += ' <a:ea typeface="' + (encodeXmlEntities(opts.catAxisLabelFontFace) || 'Arial') + '"/>';
@@ -7293,7 +7915,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7293
7915
  strXml += ' <c:tickLblPos val="' + (opts.valAxisLabelPos || (opts.barDir === 'col' ? 'nextTo' : 'low')) + '"/>';
7294
7916
  }
7295
7917
  strXml += ' <c:spPr>';
7296
- strXml += ` <a:ln w="${opts.valAxisLineSize ? valToPts(opts.valAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7918
+ strXml += ` <a:ln w="${opts.valAxisLineSize ? valToLineWidth(opts.valAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7297
7919
  strXml += !opts.valAxisLineShow ? '<a:noFill/>' : '<a:solidFill>' + createColorElement(opts.valAxisLineColor || DEF_CHART_GRIDLINE.color) + '</a:solidFill>';
7298
7920
  strXml += ' <a:prstDash val="' + (opts.valAxisLineStyle || 'solid') + '"/>';
7299
7921
  strXml += ' <a:round/>';
@@ -7304,7 +7926,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7304
7926
  strXml += ' <a:lstStyle/>';
7305
7927
  strXml += ' <a:p>';
7306
7928
  strXml += ' <a:pPr>';
7307
- strXml += ` <a:defRPr sz="${Math.round((opts.valAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="${opts.valAxisLabelFontBold ? 1 : 0}" i="${opts.valAxisLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">`;
7929
+ strXml += ` <a:defRPr sz="${fontSizeToSz(opts.valAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.valAxisLabelFontBold ? 1 : 0}" i="${opts.valAxisLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">`;
7308
7930
  strXml += ' <a:solidFill>' + createColorElement(opts.valAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
7309
7931
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.valAxisLabelFontFace) || 'Arial') + '"/>';
7310
7932
  strXml += ' <a:ea typeface="' + (encodeXmlEntities(opts.valAxisLabelFontFace) || 'Arial') + '"/>';
@@ -7376,7 +7998,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7376
7998
  strXml += ' <a:lstStyle/>';
7377
7999
  strXml += ' <a:p>';
7378
8000
  strXml += ' <a:pPr>';
7379
- strXml += ` <a:defRPr sz="${Math.round((opts.serAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="${opts.serAxisLabelFontBold ? '1' : '0'}" i="${opts.serAxisLabelFontItalic ? '1' : '0'}" u="none" strike="noStrike">`;
8001
+ strXml += ` <a:defRPr sz="${fontSizeToSz(opts.serAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.serAxisLabelFontBold ? '1' : '0'}" i="${opts.serAxisLabelFontItalic ? '1' : '0'}" u="none" strike="noStrike">`;
7380
8002
  strXml += ` <a:solidFill>${createColorElement(opts.serAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
7381
8003
  strXml += ` <a:latin typeface="${encodeXmlEntities(opts.serAxisLabelFontFace) || 'Arial'}"/>`;
7382
8004
  strXml += ` <a:ea typeface="${encodeXmlEntities(opts.serAxisLabelFontFace) || 'Arial'}"/>`;
@@ -7479,6 +8101,7 @@ function xml_object_spread_props(target, source) {
7479
8101
  * @param {ISlideRelChart} rel - chart object
7480
8102
  * @return {string} XML
7481
8103
  */ function makeXmlCharts(rel) {
8104
+ var _ref;
7482
8105
  var _rel_opts_chartArea, _rel_opts_chartArea1, _rel_opts_chartArea_border, _rel_opts_chartArea2, _rel_opts_chartArea_border1, _rel_opts_chartArea3;
7483
8106
  let strXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
7484
8107
  let usesSecondaryValAxis = false;
@@ -7511,7 +8134,8 @@ function xml_object_spread_props(target, source) {
7511
8134
  /** Add 3D view tag
7512
8135
  * @see: https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_perspective_topic_ID0E6BUQB.html
7513
8136
  */ if (rel.opts._type === core_enums_CHART_TYPE.BAR3D) {
7514
- strXml += `<c:view3D><c:rotX val="${rel.opts.v3DRotX}"/><c:rotY val="${rel.opts.v3DRotY}"/><c:rAngAx val="${!rel.opts.v3DRAngAx ? 0 : 1}"/><c:perspective val="${rel.opts.v3DPerspective}"/></c:view3D>`;
8137
+ var _rel_opts_v3DRotX, _rel_opts_v3DRotY, _rel_opts_v3DPerspective;
8138
+ strXml += `<c:view3D><c:rotX val="${clampInt((_rel_opts_v3DRotX = rel.opts.v3DRotX) !== null && _rel_opts_v3DRotX !== void 0 ? _rel_opts_v3DRotX : 30, -90, 90)}"/><c:rotY val="${clampInt((_rel_opts_v3DRotY = rel.opts.v3DRotY) !== null && _rel_opts_v3DRotY !== void 0 ? _rel_opts_v3DRotY : 30, 0, 360)}"/><c:rAngAx val="${!rel.opts.v3DRAngAx ? 0 : 1}"/><c:perspective val="${clampInt((_rel_opts_v3DPerspective = rel.opts.v3DPerspective) !== null && _rel_opts_v3DPerspective !== void 0 ? _rel_opts_v3DPerspective : 30, 0, 240)}"/></c:view3D>`;
7515
8139
  }
7516
8140
  strXml += '<c:plotArea>';
7517
8141
  // IMPORTANT: Dont specify layout to enable auto-fit: PPT does a great job maximizing space with all 4 TRBL locations
@@ -7532,9 +8156,21 @@ function xml_object_spread_props(target, source) {
7532
8156
  }
7533
8157
  }
7534
8158
  // A: Create Chart XML -----------------------------------------------------------
8159
+ const hiddenLegendIndices = [];
7535
8160
  if (Array.isArray(rel.opts._type)) {
8161
+ let seriesIdx = 0;
7536
8162
  rel.opts._type.forEach((type)=>{
7537
8163
  var _options_secondaryValAxis;
8164
+ if (Array.isArray(type.data)) {
8165
+ var _type_options;
8166
+ const hideSubchartLegend = ((_type_options = type.options) === null || _type_options === void 0 ? void 0 : _type_options.showLegend) === false;
8167
+ type.data.forEach((obj)=>{
8168
+ var _obj__dataIndex;
8169
+ const idx = (_obj__dataIndex = obj._dataIndex) !== null && _obj__dataIndex !== void 0 ? _obj__dataIndex : seriesIdx;
8170
+ if (hideSubchartLegend) hiddenLegendIndices.push(idx);
8171
+ seriesIdx++;
8172
+ });
8173
+ }
7538
8174
  const options = xml_object_spread({}, rel.opts, type.options);
7539
8175
  if (options.dataLabelPosition) {
7540
8176
  options.dataLabelPosition = resolveDataLabelPosition(options.dataLabelPosition, type.type, options.barGrouping);
@@ -7591,6 +8227,7 @@ function xml_object_spread_props(target, source) {
7591
8227
  }
7592
8228
  // C: Chart Properties and plotArea Options: Border, Data Table, Fill, Legend
7593
8229
  {
8230
+ var _ref1;
7594
8231
  var _rel_opts_plotArea, _rel_opts_plotArea1, _rel_opts_plotArea_border, _rel_opts_plotArea2, _rel_opts_plotArea_border1, _rel_opts_plotArea3;
7595
8232
  // NOTE: DataTable goes between '</c:valAx>' and '<c:spPr>'
7596
8233
  if (rel.opts.showDataTable) {
@@ -7609,7 +8246,7 @@ function xml_object_spread_props(target, source) {
7609
8246
  strXml += ' <a:lstStyle/>';
7610
8247
  strXml += ' <a:p>';
7611
8248
  strXml += ' <a:pPr rtl="0">';
7612
- strXml += ` <a:defRPr sz="${Math.round((rel.opts.dataTableFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="0" i="0" u="none" strike="noStrike" kern="1200" baseline="0">`;
8249
+ strXml += ` <a:defRPr sz="${fontSizeToSz(rel.opts.dataTableFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="0" i="0" u="none" strike="noStrike" kern="1200" baseline="0">`;
7613
8250
  strXml += ' <a:solidFill><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></a:solidFill>';
7614
8251
  strXml += ' <a:latin typeface="+mn-lt"/>';
7615
8252
  strXml += ' <a:ea typeface="+mn-ea"/>';
@@ -7625,7 +8262,7 @@ function xml_object_spread_props(target, source) {
7625
8262
  // OPTION: Fill
7626
8263
  strXml += ((_rel_opts_plotArea = rel.opts.plotArea) === null || _rel_opts_plotArea === void 0 ? void 0 : _rel_opts_plotArea.fill) && (rel.opts.plotArea.fill.type === 'gradient' || rel.opts.plotArea.fill.type === 'linearGradient' || rel.opts.plotArea.fill.type === 'pattern' || rel.opts.plotArea.fill.color) ? genXmlColorSelection(rel.opts.plotArea.fill) : '<a:noFill/>';
7627
8264
  // OPTION: Border
7628
- strXml += ((_rel_opts_plotArea1 = rel.opts.plotArea) === null || _rel_opts_plotArea1 === void 0 ? void 0 : _rel_opts_plotArea1.border) ? `<a:ln w="${valToPts((_rel_opts_plotArea2 = rel.opts.plotArea) === null || _rel_opts_plotArea2 === void 0 ? void 0 : (_rel_opts_plotArea_border = _rel_opts_plotArea2.border) === null || _rel_opts_plotArea_border === void 0 ? void 0 : _rel_opts_plotArea_border.pt)}" cap="flat">${genXmlColorSelection((_rel_opts_plotArea3 = rel.opts.plotArea) === null || _rel_opts_plotArea3 === void 0 ? void 0 : (_rel_opts_plotArea_border1 = _rel_opts_plotArea3.border) === null || _rel_opts_plotArea_border1 === void 0 ? void 0 : _rel_opts_plotArea_border1.color)}</a:ln>` : '<a:ln><a:noFill/></a:ln>';
8265
+ strXml += ((_rel_opts_plotArea1 = rel.opts.plotArea) === null || _rel_opts_plotArea1 === void 0 ? void 0 : _rel_opts_plotArea1.border) ? `<a:ln w="${valToLineWidth((_ref1 = (_rel_opts_plotArea2 = rel.opts.plotArea) === null || _rel_opts_plotArea2 === void 0 ? void 0 : (_rel_opts_plotArea_border = _rel_opts_plotArea2.border) === null || _rel_opts_plotArea_border === void 0 ? void 0 : _rel_opts_plotArea_border.pt) !== null && _ref1 !== void 0 ? _ref1 : 0)}" cap="flat">${genXmlColorSelection((_rel_opts_plotArea3 = rel.opts.plotArea) === null || _rel_opts_plotArea3 === void 0 ? void 0 : (_rel_opts_plotArea_border1 = _rel_opts_plotArea3.border) === null || _rel_opts_plotArea_border1 === void 0 ? void 0 : _rel_opts_plotArea_border1.color)}</a:ln>` : '<a:ln><a:noFill/></a:ln>';
7629
8266
  // Close shapeProp/plotArea before Legend
7630
8267
  strXml += ' <a:effectLst/>';
7631
8268
  strXml += ' </c:spPr>';
@@ -7635,7 +8272,27 @@ function xml_object_spread_props(target, source) {
7635
8272
  if (rel.opts.showLegend) {
7636
8273
  strXml += '<c:legend>';
7637
8274
  strXml += '<c:legendPos val="' + rel.opts.legendPos + '"/>';
7638
- // strXml += '<c:layout/>'
8275
+ // ECMA-376 CT_Legend sequence: legendPos -> legendEntry* -> layout -> overlay -> spPr -> txPr
8276
+ hiddenLegendIndices.forEach((idx)=>{
8277
+ strXml += `<c:legendEntry><c:idx val="${idx}"/><c:delete val="1"/></c:legendEntry>`;
8278
+ });
8279
+ if (rel.opts.legendLayout) {
8280
+ const { x, y, w, h } = rel.opts.legendLayout;
8281
+ const hasX = typeof x === 'number' && Number.isFinite(x);
8282
+ const hasY = typeof y === 'number' && Number.isFinite(y);
8283
+ const hasW = typeof w === 'number' && Number.isFinite(w);
8284
+ const hasH = typeof h === 'number' && Number.isFinite(h);
8285
+ if (hasX || hasY || hasW || hasH) {
8286
+ strXml += '<c:layout><c:manualLayout>';
8287
+ if (hasX) strXml += '<c:xMode val="edge"/>';
8288
+ if (hasY) strXml += '<c:yMode val="edge"/>';
8289
+ if (hasX) strXml += `<c:x val="${x}"/>`;
8290
+ if (hasY) strXml += `<c:y val="${y}"/>`;
8291
+ if (hasW) strXml += `<c:w val="${w}"/>`;
8292
+ if (hasH) strXml += `<c:h val="${h}"/>`;
8293
+ strXml += '</c:manualLayout></c:layout>';
8294
+ }
8295
+ }
7639
8296
  strXml += '<c:overlay val="0"/>';
7640
8297
  if (rel.opts.legendFontFace || rel.opts.legendFontSize || rel.opts.legendColor) {
7641
8298
  strXml += '<c:txPr>';
@@ -7643,7 +8300,7 @@ function xml_object_spread_props(target, source) {
7643
8300
  strXml += ' <a:lstStyle/>';
7644
8301
  strXml += ' <a:p>';
7645
8302
  strXml += ' <a:pPr>';
7646
- strXml += rel.opts.legendFontSize ? `<a:defRPr sz="${Math.round(Number(rel.opts.legendFontSize) * 100)}">` : '<a:defRPr>';
8303
+ strXml += rel.opts.legendFontSize ? `<a:defRPr sz="${fontSizeToSz(Number(rel.opts.legendFontSize))}">` : '<a:defRPr>';
7647
8304
  if (rel.opts.legendColor) strXml += genXmlColorSelection(rel.opts.legendColor);
7648
8305
  if (rel.opts.legendFontFace) strXml += '<a:latin typeface="' + encodeXmlEntities(rel.opts.legendFontFace) + '"/>';
7649
8306
  if (rel.opts.legendFontFace) strXml += '<a:ea typeface="' + encodeXmlEntities(rel.opts.legendFontFace) + '"/>';
@@ -7664,7 +8321,7 @@ function xml_object_spread_props(target, source) {
7664
8321
  // D: CHARTSPACE SHAPE PROPS
7665
8322
  strXml += '<c:spPr>';
7666
8323
  strXml += ((_rel_opts_chartArea = rel.opts.chartArea) === null || _rel_opts_chartArea === void 0 ? void 0 : _rel_opts_chartArea.fill) && (rel.opts.chartArea.fill.type === 'gradient' || rel.opts.chartArea.fill.type === 'linearGradient' || rel.opts.chartArea.fill.type === 'pattern' || rel.opts.chartArea.fill.color) ? genXmlColorSelection(rel.opts.chartArea.fill) : '<a:noFill/>';
7667
- strXml += ((_rel_opts_chartArea1 = rel.opts.chartArea) === null || _rel_opts_chartArea1 === void 0 ? void 0 : _rel_opts_chartArea1.border) ? `<a:ln w="${valToPts((_rel_opts_chartArea2 = rel.opts.chartArea) === null || _rel_opts_chartArea2 === void 0 ? void 0 : (_rel_opts_chartArea_border = _rel_opts_chartArea2.border) === null || _rel_opts_chartArea_border === void 0 ? void 0 : _rel_opts_chartArea_border.pt)}" cap="flat">${genXmlColorSelection((_rel_opts_chartArea3 = rel.opts.chartArea) === null || _rel_opts_chartArea3 === void 0 ? void 0 : (_rel_opts_chartArea_border1 = _rel_opts_chartArea3.border) === null || _rel_opts_chartArea_border1 === void 0 ? void 0 : _rel_opts_chartArea_border1.color)}</a:ln>` : '<a:ln><a:noFill/></a:ln>';
8324
+ strXml += ((_rel_opts_chartArea1 = rel.opts.chartArea) === null || _rel_opts_chartArea1 === void 0 ? void 0 : _rel_opts_chartArea1.border) ? `<a:ln w="${valToLineWidth((_ref = (_rel_opts_chartArea2 = rel.opts.chartArea) === null || _rel_opts_chartArea2 === void 0 ? void 0 : (_rel_opts_chartArea_border = _rel_opts_chartArea2.border) === null || _rel_opts_chartArea_border === void 0 ? void 0 : _rel_opts_chartArea_border.pt) !== null && _ref !== void 0 ? _ref : 0)}" cap="flat">${genXmlColorSelection((_rel_opts_chartArea3 = rel.opts.chartArea) === null || _rel_opts_chartArea3 === void 0 ? void 0 : (_rel_opts_chartArea_border1 = _rel_opts_chartArea3.border) === null || _rel_opts_chartArea_border1 === void 0 ? void 0 : _rel_opts_chartArea_border1.color)}</a:ln>` : '<a:ln><a:noFill/></a:ln>';
7668
8325
  strXml += ' <a:effectLst/>';
7669
8326
  strXml += '</c:spPr>';
7670
8327
  // E: DATA (Add relID)
@@ -7690,13 +8347,13 @@ function xml_object_spread_props(target, source) {
7690
8347
  * (`standards/ecma/part-23_drawingml-reference-material-drawingml-charts.txt`).
7691
8348
  * An empty `<a:defRPr/>` drops dataLabelFont* on scatter labels (gitbrent #1348).
7692
8349
  */ function genXmlDataLabelDefRPr(opts) {
7693
- return `<a:defRPr sz="${Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">` + `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>` + `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>` + '</a:defRPr>';
8350
+ return `<a:defRPr sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">` + `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>` + `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>` + '</a:defRPr>';
7694
8351
  }
7695
8352
  /**
7696
8353
  * Rich-text body for a custom chart data label (`c:tx` / `c:rich`).
7697
8354
  * Escapes text and applies data-label font options.
7698
8355
  */ function genXmlDataLabelRichText(text, opts) {
7699
- const sz = Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100);
8356
+ const sz = fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12));
7700
8357
  const lang = opts.lang || 'en-US';
7701
8358
  let xml = '<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r>';
7702
8359
  xml += `<a:rPr lang="${lang}" dirty="0" sz="${sz}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}">`;
@@ -7766,9 +8423,9 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7766
8423
  case core_enums_CHART_TYPE.RADAR:
7767
8424
  // 1: Start Chart
7768
8425
  strXml += `<c:${chartType}Chart>`;
7769
- // Area charts: `c:grouping` / ST_Grouping (ECMA-376 §5.7.2.76 / §5.7.3.17).
8426
+ // Area and line charts: `c:grouping` / ST_Grouping (ECMA-376 §5.7.2.76 / §5.7.2.97 / §5.7.3.17).
7770
8427
  // `barGrouping` is the public option name; the element is not `c:barGrouping` (that is ST_BarGrouping on bar charts).
7771
- if (chartType === core_enums_CHART_TYPE.AREA) {
8428
+ if (chartType === core_enums_CHART_TYPE.AREA || chartType === core_enums_CHART_TYPE.LINE) {
7772
8429
  strXml += '<c:grouping val="' + resolveAreaGrouping(opts.barGrouping) + '"/>';
7773
8430
  }
7774
8431
  if (chartType === core_enums_CHART_TYPE.BAR || chartType === core_enums_CHART_TYPE.BAR3D) {
@@ -7834,7 +8491,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7834
8491
  if (seriesColor === 'transparent') {
7835
8492
  strXml += '<a:noFill/>';
7836
8493
  } else if (opts.chartColorsOpacity) {
7837
- strXml += '<a:solidFill>' + createColorElement(seriesColor, `<a:alpha val="${Math.round(opts.chartColorsOpacity * 1000)}"/>`) + '</a:solidFill>';
8494
+ strXml += '<a:solidFill>' + createColorElement(seriesColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`) + '</a:solidFill>';
7838
8495
  } else {
7839
8496
  strXml += '<a:solidFill>' + createColorElement(seriesColor) + '</a:solidFill>';
7840
8497
  }
@@ -7842,11 +8499,13 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7842
8499
  if (opts.lineSize === 0) {
7843
8500
  strXml += '<a:ln><a:noFill/></a:ln>';
7844
8501
  } else {
7845
- strXml += `<a:ln w="${valToPts(opts.lineSize)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(seriesColor)}</a:solidFill>`;
8502
+ var _opts_lineSize;
8503
+ strXml += `<a:ln w="${valToLineWidth((_opts_lineSize = opts.lineSize) !== null && _opts_lineSize !== void 0 ? _opts_lineSize : 0)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(seriesColor)}</a:solidFill>`;
7846
8504
  strXml += '<a:prstDash val="' + resolveSeriesLineDash(obj.lineDash, opts.lineDash) + '"/><a:round/></a:ln>';
7847
8505
  }
7848
8506
  } else if (opts.dataBorder) {
7849
- strXml += `<a:ln w="${valToPts(opts.dataBorder.pt)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8507
+ var _opts_dataBorder_pt;
8508
+ strXml += `<a:ln w="${valToLineWidth((_opts_dataBorder_pt = opts.dataBorder.pt) !== null && _opts_dataBorder_pt !== void 0 ? _opts_dataBorder_pt : 0)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
7850
8509
  }
7851
8510
  strXml += createShadowElement(resolveShadowOptions(opts.shadow));
7852
8511
  strXml += ' </c:spPr>';
@@ -7862,7 +8521,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7862
8521
  strXml += `<c:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode) || 'General'}" sourceLinked="0"/>`;
7863
8522
  if (opts.dataLabelBkgrdColors) strXml += `<c:spPr><a:solidFill>${createColorElement(seriesColor)}</a:solidFill></c:spPr>`;
7864
8523
  strXml += '<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>';
7865
- strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" u="none">`;
8524
+ strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
7866
8525
  strXml += `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
7867
8526
  strXml += `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
7868
8527
  strXml += '</a:defRPr></a:pPr></a:p></c:txPr>';
@@ -7877,9 +8536,10 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7877
8536
  }
7878
8537
  // 'c:marker' tag: `lineDataSymbol`
7879
8538
  if (chartType === core_enums_CHART_TYPE.LINE || chartType === core_enums_CHART_TYPE.RADAR) {
8539
+ var _opts_lineDataSymbolLineSize;
7880
8540
  strXml += '<c:marker>';
7881
8541
  strXml += ' <c:symbol val="' + opts.lineDataSymbol + '"/>';
7882
- if (opts.lineDataSymbolSize) strXml += `<c:size val="${opts.lineDataSymbolSize}"/>`; // Defaults to "auto" otherwise (but this is usually too small, so there is a default)
8542
+ if (opts.lineDataSymbolSize) strXml += `<c:size val="${clampInt(opts.lineDataSymbolSize, 2, 72)}"/>`; // Defaults to "auto" otherwise (but this is usually too small, so there is a default)
7883
8543
  strXml += ' <c:spPr>';
7884
8544
  // NateRadebaugh/transparent-markers: `'transparent'` → noFill (same as series fill)
7885
8545
  {
@@ -7887,7 +8547,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7887
8547
  const markerColor = (_obj_color1 = obj.color) !== null && _obj_color1 !== void 0 ? _obj_color1 : chartColors[dataIndex + 1 > chartColors.length ? Math.floor(Math.random() * chartColors.length) : dataIndex];
7888
8548
  strXml += markerColor === 'transparent' ? ' <a:noFill/>' : ` <a:solidFill>${createColorElement(markerColor)}</a:solidFill>`;
7889
8549
  }
7890
- strXml += ` <a:ln w="${opts.lineDataSymbolLineSize}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || seriesColor)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8550
+ strXml += ` <a:ln w="${clampLineWidth((_opts_lineDataSymbolLineSize = opts.lineDataSymbolLineSize) !== null && _opts_lineDataSymbolLineSize !== void 0 ? _opts_lineDataSymbolLineSize : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || seriesColor)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
7891
8551
  strXml += ' <a:effectLst/>';
7892
8552
  strXml += ' </c:spPr>';
7893
8553
  strXml += '</c:marker>';
@@ -7998,7 +8658,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7998
8658
  strXml += ' <a:bodyPr/>';
7999
8659
  strXml += ' <a:lstStyle/>';
8000
8660
  strXml += ' <a:p><a:pPr>';
8001
- strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" u="none">`;
8661
+ strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
8002
8662
  strXml += ' <a:solidFill>' + createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
8003
8663
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.dataLabelFontFace) || 'Arial') + '"/>';
8004
8664
  strXml += ' </a:defRPr>';
@@ -8016,16 +8676,18 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8016
8676
  }
8017
8677
  // 4: Add more chart options (gapWidth, line Marker, etc.)
8018
8678
  if (chartType === core_enums_CHART_TYPE.BAR) {
8019
- strXml += ` <c:gapWidth val="${opts.barGapWidthPct}"/>`;
8679
+ var _opts_barGapWidthPct;
8680
+ strXml += ` <c:gapWidth val="${clampInt((_opts_barGapWidthPct = opts.barGapWidthPct) !== null && _opts_barGapWidthPct !== void 0 ? _opts_barGapWidthPct : 150, 0, 500)}"/>`;
8020
8681
  // istevkovski/prioritize-overlap: honor barOverlapPct even when grouping is stacked
8021
8682
  // (also treat 0 as explicit — upstream used a truthy check that skipped 0)
8022
8683
  {
8023
- const overlap = typeof opts.barOverlapPct === 'number' ? opts.barOverlapPct : (opts.barGrouping || '').includes('tacked') ? 100 : 0;
8684
+ const overlap = typeof opts.barOverlapPct === 'number' ? clampInt(opts.barOverlapPct, -100, 100) : (opts.barGrouping || '').includes('tacked') ? 100 : 0;
8024
8685
  strXml += ` <c:overlap val="${overlap}"/>`;
8025
8686
  }
8026
8687
  } else if (chartType === core_enums_CHART_TYPE.BAR3D) {
8027
- strXml += ` <c:gapWidth val="${opts.barGapWidthPct}"/>`;
8028
- strXml += ` <c:gapDepth val="${opts.barGapDepthPct}"/>`;
8688
+ var _opts_barGapWidthPct1, _opts_barGapDepthPct;
8689
+ strXml += ` <c:gapWidth val="${clampInt((_opts_barGapWidthPct1 = opts.barGapWidthPct) !== null && _opts_barGapWidthPct1 !== void 0 ? _opts_barGapWidthPct1 : 150, 0, 500)}"/>`;
8690
+ strXml += ` <c:gapDepth val="${clampInt((_opts_barGapDepthPct = opts.barGapDepthPct) !== null && _opts_barGapDepthPct !== void 0 ? _opts_barGapDepthPct : 150, 0, 500)}"/>`;
8029
8691
  strXml += ' <c:shape val="' + opts.bar3DShape + '"/>';
8030
8692
  } else if (chartType === core_enums_CHART_TYPE.LINE) {
8031
8693
  strXml += ' <c:marker val="1"/>';
@@ -8071,14 +8733,15 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8071
8733
  if (tmpSerColor === 'transparent') {
8072
8734
  strXml += '<a:noFill/>';
8073
8735
  } else if (opts.chartColorsOpacity) {
8074
- strXml += '<a:solidFill>' + createColorElement(tmpSerColor, '<a:alpha val="' + Math.round(opts.chartColorsOpacity * 1000).toString() + '"/>') + '</a:solidFill>';
8736
+ strXml += '<a:solidFill>' + createColorElement(tmpSerColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`) + '</a:solidFill>';
8075
8737
  } else {
8076
8738
  strXml += '<a:solidFill>' + createColorElement(tmpSerColor) + '</a:solidFill>';
8077
8739
  }
8078
8740
  if (opts.lineSize === 0) {
8079
8741
  strXml += '<a:ln><a:noFill/></a:ln>';
8080
8742
  } else {
8081
- strXml += `<a:ln w="${valToPts(opts.lineSize)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
8743
+ var _opts_lineSize;
8744
+ strXml += `<a:ln w="${valToLineWidth((_opts_lineSize = opts.lineSize) !== null && _opts_lineSize !== void 0 ? _opts_lineSize : 0)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
8082
8745
  strXml += `<a:prstDash val="${resolveSeriesLineDash(obj.lineDash, opts.lineDash)}"/><a:round/></a:ln>`;
8083
8746
  }
8084
8747
  // Shadow
@@ -8087,11 +8750,12 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8087
8750
  strXml += ' </c:spPr>';
8088
8751
  // 'c:marker' tag: `lineDataSymbol`
8089
8752
  {
8753
+ var _opts_lineDataSymbolLineSize;
8090
8754
  strXml += '<c:marker>';
8091
8755
  strXml += ' <c:symbol val="' + opts.lineDataSymbol + '"/>';
8092
8756
  if (opts.lineDataSymbolSize) {
8093
8757
  // Defaults to "auto" otherwise (but this is usually too small, so there is a default)
8094
- strXml += `<c:size val="${opts.lineDataSymbolSize}"/>`;
8758
+ strXml += `<c:size val="${clampInt(opts.lineDataSymbolSize, 2, 72)}"/>`;
8095
8759
  }
8096
8760
  strXml += '<c:spPr>';
8097
8761
  // NateRadebaugh/transparent-markers: `'transparent'` → noFill (same as series fill)
@@ -8100,7 +8764,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8100
8764
  const markerColor = (_obj_color1 = obj.color) !== null && _obj_color1 !== void 0 ? _obj_color1 : chartColors[idx + 1 > chartColors.length ? Math.floor(Math.random() * chartColors.length) : idx];
8101
8765
  strXml += markerColor === 'transparent' ? '<a:noFill/>' : `<a:solidFill>${createColorElement(markerColor)}</a:solidFill>`;
8102
8766
  }
8103
- strXml += `<a:ln w="${opts.lineDataSymbolLineSize}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || obj.color || chartColors[colorIndex % chartColors.length])}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8767
+ strXml += `<a:ln w="${clampLineWidth((_opts_lineDataSymbolLineSize = opts.lineDataSymbolLineSize) !== null && _opts_lineDataSymbolLineSize !== void 0 ? _opts_lineDataSymbolLineSize : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || obj.color || chartColors[colorIndex % chartColors.length])}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8104
8768
  strXml += '<a:effectLst/>';
8105
8769
  strXml += '</c:spPr>';
8106
8770
  strXml += '</c:marker>';
@@ -8289,7 +8953,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8289
8953
  strXml += ' <a:bodyPr/>';
8290
8954
  strXml += ' <a:lstStyle/>';
8291
8955
  strXml += ' <a:p><a:pPr>';
8292
- strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? '1' : '0'}" i="${opts.dataLabelFontItalic ? '1' : '0'}" strike="noStrike" sz="${Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" u="none">`;
8956
+ strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? '1' : '0'}" i="${opts.dataLabelFontItalic ? '1' : '0'}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
8293
8957
  strXml += ' <a:solidFill>' + createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
8294
8958
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.dataLabelFontFace) || 'Arial') + '"/>';
8295
8959
  strXml += ' </a:defRPr>';
@@ -8345,16 +9009,18 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8345
9009
  if (tmpSerColor === 'transparent') {
8346
9010
  strXml += '<a:noFill/>';
8347
9011
  } else if (opts.chartColorsOpacity) {
8348
- strXml += `<a:solidFill>${createColorElement(tmpSerColor, '<a:alpha val="' + Math.round(opts.chartColorsOpacity * 1000).toString() + '"/>')}</a:solidFill>`;
9012
+ strXml += `<a:solidFill>${createColorElement(tmpSerColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`)}</a:solidFill>`;
8349
9013
  } else {
8350
9014
  strXml += '<a:solidFill>' + createColorElement(tmpSerColor) + '</a:solidFill>';
8351
9015
  }
8352
9016
  if (opts.lineSize === 0) {
8353
9017
  strXml += '<a:ln><a:noFill/></a:ln>';
8354
9018
  } else if (opts.dataBorder) {
8355
- strXml += `<a:ln w="${valToPts(opts.dataBorder.pt)}" cap="flat"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
9019
+ var _opts_dataBorder_pt;
9020
+ strXml += `<a:ln w="${valToLineWidth((_opts_dataBorder_pt = opts.dataBorder.pt) !== null && _opts_dataBorder_pt !== void 0 ? _opts_dataBorder_pt : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8356
9021
  } else {
8357
- strXml += `<a:ln w="${valToPts(opts.lineSize)}" cap="flat"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
9022
+ var _opts_lineSize;
9023
+ strXml += `<a:ln w="${valToLineWidth((_opts_lineSize = opts.lineSize) !== null && _opts_lineSize !== void 0 ? _opts_lineSize : 0)}" cap="flat"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
8358
9024
  strXml += `<a:prstDash val="${resolveSeriesLineDash(obj.lineDash, opts.lineDash)}"/><a:round/></a:ln>`;
8359
9025
  }
8360
9026
  // Shadow
@@ -8417,7 +9083,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8417
9083
  strXml += '<c:dLbls>';
8418
9084
  strXml += `<c:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode) || 'General'}" sourceLinked="0"/>`;
8419
9085
  strXml += '<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>';
8420
- strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${Math.round(Math.round(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" u="none">`;
9086
+ strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
8421
9087
  strXml += `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
8422
9088
  strXml += `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
8423
9089
  strXml += '</a:defRPr></a:pPr></a:p></c:txPr>';
@@ -8444,7 +9110,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8444
9110
  case core_enums_CHART_TYPE.DOUGHNUT:
8445
9111
  case core_enums_CHART_TYPE.PIE:
8446
9112
  {
8447
- var _optsChartData_labels, _optsChartData_values, _opts_dataLabelPosition;
9113
+ var _optsChartData_labels, _optsChartData_values, _opts_dataLabelPosition, _opts_firstSliceAng;
8448
9114
  const optsChartData = data[0];
8449
9115
  // NOTE: chart data arrays are always populated at render time; guarded locals keep this null-safe without changing output
8450
9116
  const chartDataLabels = (_optsChartData_labels = optsChartData.labels) !== null && _optsChartData_labels !== void 0 ? _optsChartData_labels : [];
@@ -8481,7 +9147,9 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8481
9147
  strXml += createShadowElement(resolveShadowOptions(opts.shadow));
8482
9148
  }
8483
9149
  strXml += ' </c:spPr>';
8484
- // strXml += '<c:explosion val="0"/>'
9150
+ if (typeof opts.chartPieExplosion === 'number' && Number.isFinite(opts.chartPieExplosion) && opts.chartPieExplosion > 0) {
9151
+ strXml += `<c:explosion val="${clampInt(opts.chartPieExplosion, 0, 1000)}"/>`;
9152
+ }
8485
9153
  // 2: "Data Point" block for every data row
8486
9154
  chartDataLabels[0].forEach((_label, idx)=>{
8487
9155
  strXml += '<c:dPt>';
@@ -8490,7 +9158,8 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8490
9158
  strXml += ' <c:spPr>';
8491
9159
  strXml += `<a:solidFill>${createColorElement(chartColors[idx + 1 > chartColors.length ? Math.floor(Math.random() * chartColors.length) : idx])}</a:solidFill>`;
8492
9160
  if (opts.dataBorder) {
8493
- strXml += `<a:ln w="${valToPts(opts.dataBorder.pt)}" cap="flat"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
9161
+ var _opts_dataBorder_pt;
9162
+ strXml += `<a:ln w="${valToLineWidth((_opts_dataBorder_pt = opts.dataBorder.pt) !== null && _opts_dataBorder_pt !== void 0 ? _opts_dataBorder_pt : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8494
9163
  }
8495
9164
  strXml += createShadowElement(resolveShadowOptions(opts.shadow));
8496
9165
  strXml += ' </c:spPr>';
@@ -8505,7 +9174,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8505
9174
  strXml += ' <a:lstStyle/>';
8506
9175
  strXml += ' <a:p>';
8507
9176
  strXml += ' <a:pPr>';
8508
- strXml += ` <a:defRPr sz="${Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="${opts.dataLabelFontBold ? '1' : '0'}" i="${opts.dataLabelFontItalic ? '1' : '0'}" u="none" strike="noStrike">`;
9177
+ strXml += ` <a:defRPr sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.dataLabelFontBold ? '1' : '0'}" i="${opts.dataLabelFontItalic ? '1' : '0'}" u="none" strike="noStrike">`;
8509
9178
  strXml += ` <a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill><a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
8510
9179
  strXml += ' </a:defRPr>';
8511
9180
  strXml += ' </a:pPr>';
@@ -8547,8 +9216,8 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8547
9216
  strXml += ' </c:val>';
8548
9217
  // 4: Close "SERIES"
8549
9218
  strXml += ' </c:ser>';
8550
- strXml += ` <c:firstSliceAng val="${opts.firstSliceAng ? Math.round(opts.firstSliceAng) : 0}"/>`;
8551
- if (chartType === core_enums_CHART_TYPE.DOUGHNUT) strXml += `<c:holeSize val="${typeof opts.holeSize === 'number' ? opts.holeSize : '50'}"/>`;
9219
+ strXml += ` <c:firstSliceAng val="${clampInt((_opts_firstSliceAng = opts.firstSliceAng) !== null && _opts_firstSliceAng !== void 0 ? _opts_firstSliceAng : 0, 0, 360)}"/>`;
9220
+ if (chartType === core_enums_CHART_TYPE.DOUGHNUT) strXml += `<c:holeSize val="${clampInt(typeof opts.holeSize === 'number' ? opts.holeSize : 50, 1, 90)}"/>`;
8552
9221
  strXml += '</c:' + chartType + 'Chart>';
8553
9222
  break;
8554
9223
  }
@@ -8560,7 +9229,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8560
9229
  }
8561
9230
 
8562
9231
  ;// CONCATENATED MODULE: ./src/charts/workbook.ts
8563
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
9232
+ function workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8564
9233
  try {
8565
9234
  var info = gen[key](arg);
8566
9235
  var value = info.value;
@@ -8571,16 +9240,16 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8571
9240
  if (info.done) resolve(value);
8572
9241
  else Promise.resolve(value).then(_next, _throw);
8573
9242
  }
8574
- function _async_to_generator(fn) {
9243
+ function workbook_async_to_generator(fn) {
8575
9244
  return function() {
8576
9245
  var self = this, args = arguments;
8577
9246
  return new Promise(function(resolve, reject) {
8578
9247
  var gen = fn.apply(self, args);
8579
9248
  function _next(value) {
8580
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
9249
+ workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8581
9250
  }
8582
9251
  function _throw(err) {
8583
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
9252
+ workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8584
9253
  }
8585
9254
  _next(undefined);
8586
9255
  });
@@ -8619,7 +9288,7 @@ function makeNumberStyles(formats) {
8619
9288
  * @param {JSZip} zip - file that the resulting XLSX should be added to
8620
9289
  * @return {Promise} promise of generating the XLSX file
8621
9290
  */ function createExcelWorksheet(chartObject, zip) {
8622
- return _async_to_generator(function*() {
9291
+ return workbook_async_to_generator(function*() {
8623
9292
  const zipExcel = new jszip_namespaceObject.JSZip();
8624
9293
  const dataTableStyles = getDataTableStyles(chartObject);
8625
9294
  addCoreWorkbookFiles(zipExcel, dataTableStyles.customFormats);
@@ -17113,181 +17782,29 @@ function convert_to_eot_object_spread(target) {
17113
17782
  if (typeof opts.inflate !== 'function') {
17114
17783
  throw new Error('WOFF conversion requires options.inflate (pako)');
17115
17784
  }
17116
- const ttfBuffer = woff2ttf(fontBuffer, opts);
17117
- ttfObject = new TTFReader(opts).read(ttfBuffer);
17118
- } else {
17119
- throw new Error(`Unsupported font type for EOT conversion: ${String(type)}`);
17120
- }
17121
- const ttfBuffer = new TTFWriter(opts).write(ttfObject);
17122
- return ttf2eot(ttfBuffer, opts);
17123
- }
17124
-
17125
- ;// CONCATENATED MODULE: ./src/gen-fonts.ts
17126
- /**
17127
- * PptxGenJS: Opt-in embedded TrueType fonts (OOXML `ppt/fonts/*.fntdata`)
17128
- *
17129
- * `embedFontsIntoZip` is a no-op when `fonts` is empty — default export never
17130
- * writes Font parts, fntdata content types, or Presentation font relationships.
17131
- * Callers supply their own font bytes via `addFont` and must have a license
17132
- * that permits embedding those files. This library ships no font files.
17133
- *
17134
- * Font-embed orchestration absorbed from MIT `pptx-embed-fonts`
17135
- * (https://github.com/liyao1520/pptx-embed-fonts). TTF/OTF/WOFF→EOT conversion is a
17136
- * vendored subset of MIT `fonteditor-core` under `src/vendor/fonteditor-core`
17137
- * (https://github.com/kekee000/fonteditor-core). WOFF inflate uses pako 3.
17138
- */ function gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17139
- try {
17140
- var info = gen[key](arg);
17141
- var value = info.value;
17142
- } catch (error) {
17143
- reject(error);
17144
- return;
17145
- }
17146
- if (info.done) resolve(value);
17147
- else Promise.resolve(value).then(_next, _throw);
17148
- }
17149
- function gen_fonts_async_to_generator(fn) {
17150
- return function() {
17151
- var self = this, args = arguments;
17152
- return new Promise(function(resolve, reject) {
17153
- var gen = fn.apply(self, args);
17154
- function _next(value) {
17155
- gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
17156
- }
17157
- function _throw(err) {
17158
- gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
17159
- }
17160
- _next(undefined);
17161
- });
17162
- };
17163
- }
17164
-
17165
-
17166
- /** High rId base so font relationships do not collide with slide/master rIds */ const FONT_RID_START = 201314;
17167
- const FONT_REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/font';
17168
- /**
17169
- * Convert TTF / OTF / WOFF bytes to EOT (Office `fntdata` payload).
17170
- * Lazy-loads pako only for WOFF.
17171
- */ function fontToEot(type, fontBuffer) {
17172
- return gen_fonts_async_to_generator(function*() {
17173
- const options = {
17174
- hinting: true
17175
- };
17176
- if (type === 'woff') {
17177
- // pako 3: named exports only; InflateInput is Uint8Array | ArrayBuffer (not number[])
17178
- const { inflate } = yield import("pako");
17179
- options.inflate = (deflatedData)=>Array.from(inflate(Uint8Array.from(deflatedData)));
17180
- }
17181
- return convertToEot(type, fontBuffer, options);
17182
- })();
17183
- }
17184
- function toFntdata(fontType, fontFile) {
17185
- return gen_fonts_async_to_generator(function*() {
17186
- switch(fontType){
17187
- case 'eot':
17188
- // EOT bytes are stored as-is under ppt/fonts/*.fntdata
17189
- return fontFile;
17190
- case 'ttf':
17191
- case 'otf':
17192
- case 'woff':
17193
- return yield fontToEot(fontType, fontFile);
17194
- default:
17195
- throw new Error(`Invalid font type "${String(fontType)}" - use ttf | otf | woff | eot`);
17196
- }
17197
- })();
17198
- }
17199
- function ensureFntdataContentType(contentTypesXml) {
17200
- if (/Extension="fntdata"/i.test(contentTypesXml)) return contentTypesXml;
17201
- const entry = '<Default Extension="fntdata" ContentType="application/x-fontdata"/>';
17202
- // Prefer inserting among other Defaults near the top of <Types>
17203
- if (/<Default\b/i.test(contentTypesXml)) {
17204
- return contentTypesXml.replace(/<Default\b/i, `${entry}<Default`);
17205
- }
17206
- return contentTypesXml.replace(/<Types([^>]*)>/i, `<Types$1>${entry}`);
17207
- }
17208
- function ensurePresentationFontAttrs(presentationXml) {
17209
- let xml = presentationXml;
17210
- if (/embedTrueTypeFonts=/i.test(xml)) {
17211
- xml = xml.replace(/embedTrueTypeFonts="[^"]*"/i, 'embedTrueTypeFonts="true"');
17212
- } else {
17213
- xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 embedTrueTypeFonts="true">');
17214
- }
17215
- if (/saveSubsetFonts=/i.test(xml)) {
17216
- xml = xml.replace(/saveSubsetFonts="[^"]*"/i, 'saveSubsetFonts="true"');
17217
- } else {
17218
- xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 saveSubsetFonts="true">');
17219
- }
17220
- return xml;
17221
- }
17222
- function buildEmbeddedFontLst(fonts) {
17223
- let lst = '<p:embeddedFontLst>';
17224
- for (const font of fonts){
17225
- lst += '<p:embeddedFont>' + `<p:font typeface="${escapeXmlAttr(font.name)}"/>` + `<p:regular r:id="rId${font.rid}"/>` + '</p:embeddedFont>';
17226
- }
17227
- lst += '</p:embeddedFontLst>';
17228
- return lst;
17229
- }
17230
- function escapeXmlAttr(value) {
17231
- return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
17232
- }
17233
- function ensureEmbeddedFontLst(presentationXml, fonts) {
17234
- const lst = buildEmbeddedFontLst(fonts);
17235
- if (/<p:embeddedFontLst[\s>]/i.test(presentationXml)) {
17236
- // Replace existing list wholesale (export always owns the registered set)
17237
- return presentationXml.replace(/<p:embeddedFontLst[\s\S]*?<\/p:embeddedFontLst>/i, lst);
17238
- }
17239
- // ISO 29500: embeddedFontLst precedes defaultTextStyle.
17240
- // Insert after the full opening tag (match consumes `>` or attrs so it's preserved).
17241
- const dtsOpen = presentationXml.match(/<p:defaultTextStyle(?:\s[^>]*)?>/i);
17242
- if (dtsOpen) {
17243
- return presentationXml.replace(dtsOpen[0], `${lst}${dtsOpen[0]}`);
17244
- }
17245
- // Fallback: before closing presentation
17246
- return presentationXml.replace(/<\/p:presentation>/i, `${lst}</p:presentation>`);
17247
- }
17248
- function appendFontRelationships(relsXml, fonts) {
17249
- const nodes = fonts.map((font)=>`<Relationship Id="rId${font.rid}" ` + `Type="${FONT_REL_TYPE}" ` + `Target="fonts/${font.rid}.fntdata"/>`).join('');
17250
- if (!nodes) return relsXml;
17251
- return relsXml.replace(/<\/Relationships>/i, `${nodes}</Relationships>`);
17252
- }
17253
- /**
17254
- * Convert registered fonts into OOXML `ppt/fonts/*.fntdata` + presentation.xml entries.
17255
- * Mutates `zip` in place (before generateAsync).
17256
- */ function embedFontsIntoZip(zip, fonts) {
17257
- return gen_fonts_async_to_generator(function*() {
17258
- if (fonts.length === 0) return;
17259
- const prepared = [];
17260
- let nextRid = FONT_RID_START;
17261
- for (const font of fonts){
17262
- prepared.push({
17263
- name: font.fontFace,
17264
- data: yield toFntdata(font.fontType, font.fontFile),
17265
- rid: nextRid++
17266
- });
17267
- }
17268
- const contentTypesFile = zip.file('[Content_Types].xml');
17269
- if (!contentTypesFile) throw new Error('[Content_Types].xml not found');
17270
- addZipFile(zip, '[Content_Types].xml', ensureFntdataContentType((yield contentTypesFile.async('string'))));
17271
- const presentationFile = zip.file('ppt/presentation.xml');
17272
- if (!presentationFile) throw new Error('ppt/presentation.xml not found');
17273
- let presentationXml = yield presentationFile.async('string');
17274
- presentationXml = ensurePresentationFontAttrs(presentationXml);
17275
- presentationXml = ensureEmbeddedFontLst(presentationXml, prepared);
17276
- addZipFile(zip, 'ppt/presentation.xml', presentationXml);
17277
- const relsFile = zip.file('ppt/_rels/presentation.xml.rels');
17278
- if (!relsFile) throw new Error('ppt/_rels/presentation.xml.rels not found');
17279
- addZipFile(zip, 'ppt/_rels/presentation.xml.rels', appendFontRelationships((yield relsFile.async('string')), prepared));
17280
- for (const font of prepared){
17281
- addZipFile(zip, `ppt/fonts/${font.rid}.fntdata`, font.data, {
17282
- binary: true,
17283
- compression: 'DEFLATE'
17284
- });
17285
- }
17286
- })();
17785
+ const ttfBuffer = woff2ttf(fontBuffer, opts);
17786
+ ttfObject = new TTFReader(opts).read(ttfBuffer);
17787
+ } else {
17788
+ throw new Error(`Unsupported font type for EOT conversion: ${String(type)}`);
17789
+ }
17790
+ const ttfBuffer = new TTFWriter(opts).write(ttfObject);
17791
+ return ttf2eot(ttfBuffer, opts);
17287
17792
  }
17288
17793
 
17289
- ;// CONCATENATED MODULE: ./src/gen-media.ts
17290
- function gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17794
+ ;// CONCATENATED MODULE: ./src/gen-fonts.ts
17795
+ /**
17796
+ * PptxGenJS: Opt-in embedded TrueType fonts (OOXML `ppt/fonts/*.fntdata`)
17797
+ *
17798
+ * `embedFontsIntoZip` is a no-op when `fonts` is empty — default export never
17799
+ * writes Font parts, fntdata content types, or Presentation font relationships.
17800
+ * Callers supply their own font bytes via `addFont` and must have a license
17801
+ * that permits embedding those files. This library ships no font files.
17802
+ *
17803
+ * Font-embed orchestration absorbed from MIT `pptx-embed-fonts`
17804
+ * (https://github.com/liyao1520/pptx-embed-fonts). TTF/OTF/WOFF→EOT conversion is a
17805
+ * vendored subset of MIT `fonteditor-core` under `src/vendor/fonteditor-core`
17806
+ * (https://github.com/kekee000/fonteditor-core). WOFF inflate uses pako 3.
17807
+ */ function gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17291
17808
  try {
17292
17809
  var info = gen[key](arg);
17293
17810
  var value = info.value;
@@ -17298,364 +17815,143 @@ function gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key,
17298
17815
  if (info.done) resolve(value);
17299
17816
  else Promise.resolve(value).then(_next, _throw);
17300
17817
  }
17301
- function gen_media_async_to_generator(fn) {
17818
+ function gen_fonts_async_to_generator(fn) {
17302
17819
  return function() {
17303
- var self = this, args = arguments;
17304
- return new Promise(function(resolve, reject) {
17305
- var gen = fn.apply(self, args);
17306
- function _next(value) {
17307
- gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
17308
- }
17309
- function _throw(err) {
17310
- gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
17311
- }
17312
- _next(undefined);
17313
- });
17314
- };
17315
- }
17316
- /**
17317
- * PptxGenJS: Media Methods
17318
- */
17319
-
17320
- /** Images are measured in pixels; PowerPoint slide dimensions are inches at 96 DPI */ const IMAGE_DPI = 96;
17321
- /**
17322
- * Read the natural pixel dimensions of a raster image from its header bytes.
17323
- * Self-contained replacement for the `image-size` package (PNG/JPEG/GIF/BMP).
17324
- * Format refs: PNG spec §11.2.2 (IHDR is always the first chunk, width/height big-endian at bytes 16-24);
17325
- * JPEG (JFIF) SOF0-SOF15 markers carry height then width big-endian; GIF87a/89a logical-screen descriptor
17326
- * little-endian at bytes 6-10; BMP DIB header little-endian at bytes 18-26. SVG is sized separately (gen-objects).
17327
- *
17328
- * Declared dims are header-only (we never decode pixels), so clamp to a sane ceiling: a maliciously crafted
17329
- * header can claim 0xFFFFFFFF px and emit a ~44-million-inch slide (a corrupt pptx). PowerPoint's max slide is
17330
- * 56 in (5376 px @ 96 DPI); 100 000 px is generous headroom for legit high-res sources while rejecting bombs.
17331
- */ const MAX_IMAGE_PX = 100000;
17332
- function imageDimensions(bytes) {
17333
- if (bytes.length < 10) return {} // every supported header's dims start at/after byte 6
17334
- ;
17335
- const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
17336
- const sane = (w, h)=>w > 0 && h > 0 && w <= MAX_IMAGE_PX && h <= MAX_IMAGE_PX ? {
17337
- width: w,
17338
- height: h
17339
- } : {};
17340
- // PNG: 8-byte signature 89 50 4E 47 0D 0A 1A 0A, then IHDR length(4)+type(4)+width(4)+height(4)
17341
- if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) {
17342
- if (bytes.length < 24) return {};
17343
- return sane(dv.getUint32(16, false), dv.getUint32(20, false));
17344
- }
17345
- // GIF: 'GIF87a'/'GIF89a', logical screen width/height little-endian at bytes 6-10
17346
- if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46) {
17347
- return sane(dv.getUint16(6, true), dv.getUint16(8, true));
17348
- }
17349
- // BMP: 'BM', DIB width/height little-endian at bytes 18-26 (signed; height may be negative = top-down)
17350
- if (bytes[0] === 0x42 && bytes[1] === 0x4d) {
17351
- if (bytes.length < 26) return {};
17352
- return sane(Math.abs(dv.getInt32(18, true)), Math.abs(dv.getInt32(22, true)));
17353
- }
17354
- // JPEG: FF D8, then walk marker segments until a Start-Of-Frame (C0-CF except C4/C8/CC) carries the dims
17355
- if (bytes[0] === 0xff && bytes[1] === 0xd8) {
17356
- let off = 2;
17357
- while(off + 9 <= bytes.length){
17358
- if (bytes[off] !== 0xff) {
17359
- off++;
17360
- continue;
17361
- }
17362
- const marker = bytes[off + 1];
17363
- const isSOF = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
17364
- if (isSOF) return sane(dv.getUint16(off + 7, false), dv.getUint16(off + 5, false));
17365
- if (marker === 0xd8 || marker === 0xd9 || marker >= 0xd0 && marker <= 0xd7) {
17366
- off += 2;
17367
- continue;
17368
- } // no length
17369
- const segLen = dv.getUint16(off + 2, false);
17370
- off += 2 + segLen;
17371
- }
17372
- }
17373
- return {};
17374
- }
17375
- /**
17376
- * Natural pixel size from encoded image bytes (PNG/JPEG/GIF/BMP headers).
17377
- * Returns null when the payload is missing, not a supported raster, or claims 0×0
17378
- * (`imageDimensions` already rejects zero and bomb-sized headers).
17379
- *
17380
- * contain/cover `a:srcRect` (ECMA-376 §5.1.10.55) needs the *blip* aspect, not the
17381
- * placement box — using w/h as imgSize makes srcRect a no-op whenever they match the sizing box.
17382
- */ function getImagePixelSize(base64Data) {
17383
- if (typeof base64Data !== 'string' || !base64Data || base64Data === IMG_BROKEN) return null;
17384
- try {
17385
- const dims = imageDimensions(base64ToBytes(base64Data));
17386
- if (dims.width && dims.height) return {
17387
- w: dims.width,
17388
- h: dims.height
17389
- };
17390
- } catch (unused) {
17391
- // unrecognized / truncated payload
17392
- }
17393
- return null;
17394
- }
17395
- /**
17396
- * Size images added without `w`/`h` to their natural dimensions (issue #34)
17397
- * @note must run after `encodeSlideMediaRels` has resolved - it reads the encoded image bytes
17398
- * @param {PresSlide | SlideLayout} layout - slide layout
17399
- */ function applyNaturalImageSizes(layout) {
17400
- layout._slideObjects.filter((obj)=>{
17401
- var _obj_options;
17402
- return obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.image */"image") && ((_obj_options = obj.options) === null || _obj_options === void 0 ? void 0 : _obj_options._sizeFromImage);
17403
- }).forEach((obj)=>{
17404
- var _layout__relsMedia_find;
17405
- const strData = (_layout__relsMedia_find = layout._relsMedia.find((rel)=>rel.rId === obj.imageRid)) === null || _layout__relsMedia_find === void 0 ? void 0 : _layout__relsMedia_find.data;
17406
- if (!obj.options || typeof strData !== 'string' || !strData || strData === IMG_BROKEN) return;
17407
- // An image bound to a placeholder inherits the placeholder's w/h (slide XML resolves it); sizing it
17408
- // to its natural pixel dims instead would collapse it to ~px/96 inches (issue #996).
17409
- if (obj.options.placeholder) return;
17410
- try {
17411
- const dims = imageDimensions(base64ToBytes(strData));
17412
- if (dims.width && dims.height) {
17413
- obj.options.w = dims.width / IMAGE_DPI;
17414
- obj.options.h = dims.height / IMAGE_DPI;
17415
- }
17416
- } catch (_ex) {
17417
- // Unreadable/unsupported image: keep the 1x1 inch default
17418
- }
17419
- });
17420
- }
17421
- /** Select relations that still need their local or remote media encoded. */ function getMediaCandidates(layout) {
17422
- return layout._relsMedia.filter((rel)=>!rel.isLinked && rel.type !== 'online' && !rel.data && (!rel.path || rel.path && !rel.path.includes('preencoded')));
17423
- }
17424
- /**
17425
- * Mark repeated source paths so only the first relation performs I/O.
17426
- *
17427
- * Mutates `isDuplicate`; subsequent helpers copy the first result to every duplicate.
17428
- */ function markDuplicateMedia(candidates) {
17429
- const paths = new Set();
17430
- candidates.forEach((rel)=>{
17431
- var _rel_path;
17432
- const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
17433
- rel.isDuplicate = paths.has(path);
17434
- paths.add(path);
17435
- });
17436
- }
17437
- /** Copy an encoded or broken source relation's data to every duplicate path. */ function copyMediaToDuplicates(candidates, rel) {
17438
- candidates.filter((duplicate)=>duplicate.isDuplicate && duplicate.path === rel.path).forEach((duplicate)=>duplicate.data = rel.data);
17439
- }
17440
- /** Mark a failed source and all duplicates with the sentinel expected by package generation. */ function markMediaBroken(candidates, rel) {
17441
- rel.data = IMG_BROKEN;
17442
- copyMediaToDuplicates(candidates, rel);
17443
- }
17444
- function mediaLoadFailed(candidates, rel, message, onError) {
17445
- markMediaBroken(candidates, rel);
17446
- if (onError === 'placeholder') {
17447
- console.warn(`WARN: Unable to load image, using placeholder: ${rel.path}${message ? ` (${message})` : ''}`);
17448
- return 'done';
17449
- }
17450
- throw new Error(message);
17451
- }
17452
- /**
17453
- * Read one Node-local media source and encode it as base64.
17454
- *
17455
- * A read failure is recorded before rejection so duplicate references remain consistent.
17456
- */ function readNodeMediaFile(rel, candidates, fs, onError) {
17457
- return gen_media_async_to_generator(function*() {
17458
- try {
17459
- var _rel_path;
17460
- var _rel_fill;
17461
- const relPath = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
17462
- const svgFill = typeof ((_rel_fill = rel.fill) === null || _rel_fill === void 0 ? void 0 : _rel_fill.color) === 'string' ? rel.fill.color : undefined;
17463
- if (svgFill && (rel.type === 'image/svg+xml' || rel.extn === 'svg')) {
17464
- const svgText = applySvgFillColor(fs.readFileSync(relPath, 'utf8'), svgFill);
17465
- rel.data = utf8ToBase64(svgText);
17466
- } else {
17467
- const bitmap = fs.readFileSync(relPath);
17468
- rel.data = bytesToBase64(new Uint8Array(bitmap));
17469
- if (svgFill && typeof rel.data === 'string') {
17470
- rel.data = applySvgFillToDataUrl(rel.data, svgFill);
17471
- }
17472
- }
17473
- copyMediaToDuplicates(candidates, rel);
17474
- return 'done';
17475
- } catch (ex) {
17476
- return mediaLoadFailed(candidates, rel, `ERROR: Unable to read media: "${rel.path}"\n${String(ex)}`, onError);
17477
- }
17478
- })();
17479
- }
17480
- /**
17481
- * Load one HTTP(S) source in Node, draining error responses and handling both request and response errors.
17482
- */ function loadNodeMediaUrl(rel, candidates, https, http, onError) {
17483
- var _rel_path;
17484
- const httpMod = ((_rel_path = rel.path) === null || _rel_path === void 0 ? void 0 : _rel_path.startsWith('http://')) ? http : https;
17485
- return new Promise((resolve, reject)=>{
17486
- const fail = (message)=>{
17487
- try {
17488
- resolve(mediaLoadFailed(candidates, rel, message, onError));
17489
- } catch (ex) {
17490
- reject(ex);
17491
- }
17492
- };
17493
- try {
17494
- var _rel_path;
17495
- const req = httpMod.get((_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '', (res)=>{
17496
- var _res_statusCode;
17497
- const status = (_res_statusCode = res.statusCode) !== null && _res_statusCode !== void 0 ? _res_statusCode : 0;
17498
- if (status < 200 || status > 299) {
17499
- res.resume(); // drain so the socket is freed
17500
- fail(`ERROR! Unable to load image (HTTP ${status}): ${rel.path}`);
17501
- return;
17502
- }
17503
- let raw = '';
17504
- res.setEncoding('binary'); // IMPORTANT: Only binary encoding works
17505
- res.on('data', (chunk)=>raw += chunk);
17506
- res.on('end', ()=>{
17507
- rel.data = binaryStringToBase64(raw);
17508
- copyMediaToDuplicates(candidates, rel);
17509
- resolve('done');
17510
- });
17511
- res.on('error', ()=>fail(`ERROR! Unable to load image (response): ${rel.path}`));
17512
- });
17513
- // NOTE: without this, a DNS/TLS/connection failure emits an unhandled 'error' and kills the process
17514
- req.on('error', (ex)=>fail(`ERROR! Unable to load image (request): ${rel.path}\n${String(ex)}`));
17515
- } catch (ex) {
17516
- fail(`ERROR! Unable to load image (https.get): ${rel.path}\n${String(ex)}`);
17517
- }
17518
- });
17519
- }
17520
- /**
17521
- * Fetch one browser media source and convert its Blob response to a data URL.
17522
- * SVG previews are produced only after the source relation has been populated.
17523
- */ function loadBrowserMedia(rel, candidates, onError) {
17524
- return new Promise((resolve, reject)=>{
17525
- var _rel_path;
17526
- const fail = (message)=>{
17527
- try {
17528
- resolve(mediaLoadFailed(candidates, rel, message, onError));
17529
- } catch (ex) {
17530
- reject(ex);
17531
- }
17532
- };
17533
- const xhr = new XMLHttpRequest();
17534
- xhr.onload = ()=>{
17535
- // status 0 = non-HTTP schemes (file://); anything outside 2xx is an error page, not image bytes
17536
- if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {
17537
- fail(`ERROR! HTTP status ${xhr.status} loading image: ${rel.path}`);
17538
- return;
17820
+ var self = this, args = arguments;
17821
+ return new Promise(function(resolve, reject) {
17822
+ var gen = fn.apply(self, args);
17823
+ function _next(value) {
17824
+ gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
17539
17825
  }
17540
- const reader = new FileReader();
17541
- reader.onloadend = ()=>{
17542
- if (typeof reader.result === 'string') rel.data = reader.result;
17543
- copyMediaToDuplicates(candidates, rel);
17544
- if (!rel.isSvgPng) resolve('done');
17545
- else createSvgPngPreview(rel).then(()=>resolve('done')).catch(reject);
17546
- };
17547
- reader.readAsDataURL(xhr.response);
17548
- };
17549
- xhr.onerror = ()=>{
17550
- fail(`ERROR! Unable to load image (xhr.onerror): ${rel.path}`);
17551
- };
17552
- xhr.open('GET', (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '');
17553
- xhr.responseType = 'blob';
17554
- xhr.send();
17555
- });
17826
+ function _throw(err) {
17827
+ gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
17828
+ }
17829
+ _next(undefined);
17830
+ });
17831
+ };
17556
17832
  }
17557
- /** Route one source relation to the loader valid for the active runtime. */ function encodeMediaRelation(rel, candidates, isNode, modules, loadNodeModules, onError) {
17558
- return gen_media_async_to_generator(function*() {
17559
- var _rel_path;
17560
- if (!modules.https) yield loadNodeModules();
17561
- const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
17562
- if (isNode && modules.fs && !path.startsWith('http')) return readNodeMediaFile(rel, candidates, modules.fs, onError);
17563
- if (isNode && modules.https && modules.http && path.startsWith('http')) return loadNodeMediaUrl(rel, candidates, modules.https, modules.http, onError);
17564
- return loadBrowserMedia(rel, candidates, onError);
17833
+
17834
+
17835
+ /** High rId base so font relationships do not collide with slide/master rIds */ const FONT_RID_START = 201314;
17836
+ const FONT_REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/font';
17837
+ /**
17838
+ * Convert TTF / OTF / WOFF bytes to EOT (Office `fntdata` payload).
17839
+ * Lazy-loads pako only for WOFF.
17840
+ */ function fontToEot(type, fontBuffer) {
17841
+ return gen_fonts_async_to_generator(function*() {
17842
+ const options = {
17843
+ hinting: true
17844
+ };
17845
+ if (type === 'woff') {
17846
+ // pako 3: named exports only; InflateInput is Uint8Array | ArrayBuffer (not number[])
17847
+ const { inflate } = yield import("pako");
17848
+ options.inflate = (deflatedData)=>Array.from(inflate(Uint8Array.from(deflatedData)));
17849
+ }
17850
+ return convertToEot(type, fontBuffer, options);
17565
17851
  })();
17566
17852
  }
17567
- /**
17568
- * Append SVG preview work synchronously because the caller immediately snapshots `promises`.
17569
- * Node cannot rasterize SVG here, so it keeps the historical broken-preview sentinel behavior.
17570
- */ function addSvgPreviewPromises(layout, isNode, promises) {
17571
- layout._relsMedia.filter((rel)=>rel.isSvgPng && rel.data).forEach((rel)=>{
17572
- // NOTE: must push synchronously - the caller snapshots this array as soon as we return
17573
- if (isNode) {
17574
- // SVG is not supported in Node (more info: https://github.com/gitbrent/PptxGenJS/issues/401)
17575
- rel.data = IMG_BROKEN;
17576
- promises.push(Promise.resolve('done'));
17577
- } else {
17578
- promises.push(createSvgPngPreview(rel));
17853
+ function toFntdata(fontType, fontFile) {
17854
+ return gen_fonts_async_to_generator(function*() {
17855
+ switch(fontType){
17856
+ case 'eot':
17857
+ // EOT bytes are stored as-is under ppt/fonts/*.fntdata
17858
+ return fontFile;
17859
+ case 'ttf':
17860
+ case 'otf':
17861
+ case 'woff':
17862
+ return yield fontToEot(fontType, fontFile);
17863
+ default:
17864
+ throw new Error(`Invalid font type "${String(fontType)}" - use ttf | otf | woff | eot`);
17579
17865
  }
17580
- });
17866
+ })();
17581
17867
  }
17582
- /**
17583
- * Encode Image/Audio/Video into base64
17584
- * @param {PresSlide | SlideLayout} layout - slide layout
17585
- * @return {Promise} promise
17586
- */ function encodeSlideMediaRels(layout, opts) {
17587
- // STEP 1: Detect a real Node process. Browser bundles often polyfill `process`
17588
- // (and even `process.versions.node`), so also require a document-less runtime.
17589
- const isNode = isNodeRuntime();
17590
- const modules = {};
17591
- // STEP 2: Lazy-load Node built-ins if needed. The specifier is built at runtime
17592
- // so browser bundlers cannot statically resolve `node:https` / `https`.
17593
- const loadNodeDeps = isNode ? ()=>gen_media_async_to_generator(function*() {
17594
- ;
17595
- ({ default: modules.fs } = yield importNodeBuiltin('fs'));
17596
- ({ default: modules.https } = yield importNodeBuiltin('https'));
17597
- ({ default: modules.http } = yield importNodeBuiltin('http'));
17598
- })() : ()=>gen_media_async_to_generator(function*() {})();
17599
- // Immediately start it when we know we’re in Node
17600
- if (isNode) loadNodeDeps();
17601
- // STEP 3: Prepare promises list
17602
- const imageProms = [];
17603
- // A: Capture all audio/image/video candidates for encoding (filtering online/pre-encoded)
17604
- const candidateRels = getMediaCandidates(layout);
17605
- // B: PERF: Mark dupes (same `path`) to avoid loading the same media over-and-over!
17606
- markDuplicateMedia(candidateRels);
17607
- // STEP 4: Read/Encode each unique media item
17608
- const onError = (opts === null || opts === void 0 ? void 0 : opts.onError) === 'placeholder' ? 'placeholder' : 'throw';
17609
- candidateRels.filter((rel)=>!rel.isDuplicate).forEach((rel)=>imageProms.push(encodeMediaRelation(rel, candidateRels, isNode, modules, loadNodeDeps, onError)));
17610
- // STEP 5: SVG-PNG previews
17611
- // ......: "SVG:" base64 data still requires a png to be generated
17612
- // ......: (`isSvgPng` flag this as the preview image, not the SVG itself)
17613
- addSvgPreviewPromises(layout, isNode, imageProms);
17614
- return imageProms;
17868
+ function ensureFntdataContentType(contentTypesXml) {
17869
+ if (/Extension="fntdata"/i.test(contentTypesXml)) return contentTypesXml;
17870
+ const entry = '<Default Extension="fntdata" ContentType="application/x-fontdata"/>';
17871
+ // Prefer inserting among other Defaults near the top of <Types>
17872
+ if (/<Default\b/i.test(contentTypesXml)) {
17873
+ return contentTypesXml.replace(/<Default\b/i, `${entry}<Default`);
17874
+ }
17875
+ return contentTypesXml.replace(/<Types([^>]*)>/i, `<Types$1>${entry}`);
17876
+ }
17877
+ function ensurePresentationFontAttrs(presentationXml) {
17878
+ let xml = presentationXml;
17879
+ if (/embedTrueTypeFonts=/i.test(xml)) {
17880
+ xml = xml.replace(/embedTrueTypeFonts="[^"]*"/i, 'embedTrueTypeFonts="true"');
17881
+ } else {
17882
+ xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 embedTrueTypeFonts="true">');
17883
+ }
17884
+ if (/saveSubsetFonts=/i.test(xml)) {
17885
+ xml = xml.replace(/saveSubsetFonts="[^"]*"/i, 'saveSubsetFonts="true"');
17886
+ } else {
17887
+ xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 saveSubsetFonts="true">');
17888
+ }
17889
+ return xml;
17890
+ }
17891
+ function buildEmbeddedFontLst(fonts) {
17892
+ let lst = '<p:embeddedFontLst>';
17893
+ for (const font of fonts){
17894
+ lst += '<p:embeddedFont>' + `<p:font typeface="${escapeXmlAttr(font.name)}"/>` + `<p:regular r:id="rId${font.rid}"/>` + '</p:embeddedFont>';
17895
+ }
17896
+ lst += '</p:embeddedFontLst>';
17897
+ return lst;
17898
+ }
17899
+ function escapeXmlAttr(value) {
17900
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
17901
+ }
17902
+ function ensureEmbeddedFontLst(presentationXml, fonts) {
17903
+ const lst = buildEmbeddedFontLst(fonts);
17904
+ if (/<p:embeddedFontLst[\s>]/i.test(presentationXml)) {
17905
+ // Replace existing list wholesale (export always owns the registered set)
17906
+ return presentationXml.replace(/<p:embeddedFontLst[\s\S]*?<\/p:embeddedFontLst>/i, lst);
17907
+ }
17908
+ // ISO 29500: embeddedFontLst precedes defaultTextStyle.
17909
+ // Insert after the full opening tag (match consumes `>` or attrs so it's preserved).
17910
+ const dtsOpen = presentationXml.match(/<p:defaultTextStyle(?:\s[^>]*)?>/i);
17911
+ if (dtsOpen) {
17912
+ return presentationXml.replace(dtsOpen[0], `${lst}${dtsOpen[0]}`);
17913
+ }
17914
+ // Fallback: before closing presentation
17915
+ return presentationXml.replace(/<\/p:presentation>/i, `${lst}</p:presentation>`);
17916
+ }
17917
+ function appendFontRelationships(relsXml, fonts) {
17918
+ const nodes = fonts.map((font)=>`<Relationship Id="rId${font.rid}" ` + `Type="${FONT_REL_TYPE}" ` + `Target="fonts/${font.rid}.fntdata"/>`).join('');
17919
+ if (!nodes) return relsXml;
17920
+ return relsXml.replace(/<\/Relationships>/i, `${nodes}</Relationships>`);
17615
17921
  }
17616
17922
  /**
17617
- * Create SVG preview image
17618
- * @param {ISlideRelMedia} rel - slide rel
17619
- * @return {Promise} promise
17620
- */ function createSvgPngPreview(rel) {
17621
- return gen_media_async_to_generator(function*() {
17622
- return yield new Promise((resolve, reject)=>{
17623
- // A: Create
17624
- const image = new Image();
17625
- // Shared error handler (also wired to `image.onerror`); the reason string is informational only
17626
- const handleError = ()=>{
17627
- rel.data = IMG_BROKEN;
17628
- reject(new Error(`ERROR! Unable to load image (image.onerror): ${rel.path}`));
17629
- };
17630
- // B: Set onload event
17631
- image.onload = ()=>{
17632
- // First: Check for any errors: This is the best method (try/catch wont work, etc.)
17633
- if (image.width + image.height === 0) {
17634
- handleError();
17635
- }
17636
- const canvas = document.createElement('canvas');
17637
- const ctx = canvas.getContext('2d');
17638
- if (!ctx) {
17639
- handleError();
17640
- return;
17641
- }
17642
- canvas.width = image.width;
17643
- canvas.height = image.height;
17644
- ctx.drawImage(image, 0, 0);
17645
- // Users running on local machine will get the following error:
17646
- // "SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported."
17647
- // when the canvas.toDataURL call executes below.
17648
- try {
17649
- rel.data = canvas.toDataURL(rel.type);
17650
- resolve('done');
17651
- } catch (_ex) {
17652
- handleError();
17653
- }
17654
- };
17655
- image.onerror = handleError;
17656
- // C: Load image
17657
- image.src = typeof rel.data === 'string' ? rel.data : IMG_BROKEN;
17658
- });
17923
+ * Convert registered fonts into OOXML `ppt/fonts/*.fntdata` + presentation.xml entries.
17924
+ * Mutates `zip` in place (before generateAsync).
17925
+ */ function embedFontsIntoZip(zip, fonts) {
17926
+ return gen_fonts_async_to_generator(function*() {
17927
+ if (fonts.length === 0) return;
17928
+ const prepared = [];
17929
+ let nextRid = FONT_RID_START;
17930
+ for (const font of fonts){
17931
+ prepared.push({
17932
+ name: font.fontFace,
17933
+ data: yield toFntdata(font.fontType, font.fontFile),
17934
+ rid: nextRid++
17935
+ });
17936
+ }
17937
+ const contentTypesFile = zip.file('[Content_Types].xml');
17938
+ if (!contentTypesFile) throw new Error('[Content_Types].xml not found');
17939
+ addZipFile(zip, '[Content_Types].xml', ensureFntdataContentType((yield contentTypesFile.async('string'))));
17940
+ const presentationFile = zip.file('ppt/presentation.xml');
17941
+ if (!presentationFile) throw new Error('ppt/presentation.xml not found');
17942
+ let presentationXml = yield presentationFile.async('string');
17943
+ presentationXml = ensurePresentationFontAttrs(presentationXml);
17944
+ presentationXml = ensureEmbeddedFontLst(presentationXml, prepared);
17945
+ addZipFile(zip, 'ppt/presentation.xml', presentationXml);
17946
+ const relsFile = zip.file('ppt/_rels/presentation.xml.rels');
17947
+ if (!relsFile) throw new Error('ppt/_rels/presentation.xml.rels not found');
17948
+ addZipFile(zip, 'ppt/_rels/presentation.xml.rels', appendFontRelationships((yield relsFile.async('string')), prepared));
17949
+ for (const font of prepared){
17950
+ addZipFile(zip, `ppt/fonts/${font.rid}.fntdata`, font.data, {
17951
+ binary: true,
17952
+ compression: 'DEFLATE'
17953
+ });
17954
+ }
17659
17955
  })();
17660
17956
  }
17661
17957
 
@@ -21289,11 +21585,11 @@ const ImageSizingXml = {
21289
21585
  * @returns {string} XML
21290
21586
  */ function genXmlCellBorder(name, border) {
21291
21587
  var _ref, _border_width, _border_color;
21292
- if (border.type === 'none') return `<a:${name} w="0" cap="flat" cmpd="sng" algn="ctr"><a:noFill/></a:${name}>`;
21588
+ if (border.type === 'none') return `<a:${name}><a:noFill/></a:${name}>`;
21293
21589
  const width = (_ref = (_border_width = border.width) !== null && _border_width !== void 0 ? _border_width : border.pt) !== null && _ref !== void 0 ? _ref : DEF_CELL_BORDER.pt;
21294
21590
  const borderTransparency = border.transparency;
21295
- const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${Math.round((100 - Math.min(100, Math.max(0, borderTransparency))) * 1000)}"/>` : '';
21296
- return `<a:${name} w="${valToPts(width)}" cap="flat" cmpd="sng" algn="ctr">` + `<a:solidFill>${createColorElement((_border_color = border.color) !== null && _border_color !== void 0 ? _border_color : DEF_CELL_BORDER.color, borderAlpha)}</a:solidFill>` + `<a:prstDash val="${border.type === 'dash' ? 'sysDash' : 'solid'}"/><a:round/>` + '<a:headEnd type="none" w="med" len="med"/><a:tailEnd type="none" w="med" len="med"/>' + `</a:${name}>`;
21591
+ const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${clampAlphaPct(borderTransparency)}"/>` : '';
21592
+ return `<a:${name} w="${valToLineWidth(width)}" cap="flat" cmpd="sng" algn="ctr">` + `<a:solidFill>${createColorElement((_border_color = border.color) !== null && _border_color !== void 0 ? _border_color : DEF_CELL_BORDER.color, borderAlpha)}</a:solidFill>` + `<a:prstDash val="${border.type === 'dash' ? 'sysDash' : 'solid'}"/><a:round/>` + '<a:headEnd type="none" w="med" len="med"/><a:tailEnd type="none" w="med" len="med"/>' + `</a:${name}>`;
21297
21593
  }
21298
21594
  /**
21299
21595
  * One `a:audioCd` endpoint (`a:st` or `a:end`).
@@ -21433,7 +21729,7 @@ const ImageSizingXml = {
21433
21729
  /**
21434
21730
  * Alpha + recolor effects for an image's `a:blip`.
21435
21731
  */ function genXmlBlipEffects(transparency, alpha, recolor) {
21436
- let xml = transparency ? `<a:alphaModFix amt="${Math.round((100 - transparency) * 1000)}"/>` : '';
21732
+ let xml = transparency ? `<a:alphaModFix amt="${clampAlphaPct(transparency)}"/>` : '';
21437
21733
  xml += genXmlBlipRecolor(recolor);
21438
21734
  if (!alpha) return xml;
21439
21735
  if (typeof alpha.replace === 'number' && isFinite(alpha.replace)) xml += `<a:alphaRepl a="${Math.round(Math.min(100, Math.max(0, alpha.replace)) * 1000)}"/>`;
@@ -21595,7 +21891,7 @@ function resolveShapeId(options, idx, usedIds) {
21595
21891
  xml += '<a:rect l="l" t="t" r="r" b="b" />';
21596
21892
  xml += '<a:pathLst>';
21597
21893
  for (const points of pathArrays){
21598
- xml += `<a:path w="${Math.round(pathW)}" h="${Math.round(pathH)}">`;
21894
+ xml += `<a:path w="${positiveExtent(pathW)}" h="${positiveExtent(pathH)}">`;
21599
21895
  points === null || points === void 0 ? void 0 : points.forEach((point, i)=>{
21600
21896
  if ('curve' in point) {
21601
21897
  switch(point.curve.type){
@@ -21764,6 +22060,14 @@ function slideObjectToXml(slide) {
21764
22060
  flipH = line.flipH;
21765
22061
  flipV = line.flipV;
21766
22062
  }
22063
+ // Clamp extents to ST_PositiveCoordinate (>= 0) after line flip so lines keep negative endpoint deltas
22064
+ if (cx < 0 || cy < 0) {
22065
+ console.warn(`[pptxgenjs] negative size on ${slideItemObj._type}${slideItemObj.options.objectName ? ` "${slideItemObj.options.objectName}"` : ''} - w/h cannot be negative, clamped to 0`);
22066
+ }
22067
+ cx = positiveExtent(cx);
22068
+ cy = positiveExtent(cy);
22069
+ imgWidth = positiveExtent(imgWidth);
22070
+ imgHeight = positiveExtent(imgHeight);
21767
22071
  if (flipH) locationAttr += ' flipH="1"';
21768
22072
  if (flipV) locationAttr += ' flipV="1"';
21769
22073
  if (slideItemObj.options.rotate) locationAttr += ` rot="${convertRotationDegrees(slideItemObj.options.rotate)}"`;
@@ -21808,7 +22112,7 @@ function slideObjectToXml(slide) {
21808
22112
  if (w == null || isNaN(w)) {
21809
22113
  w = (typeof slideItemObj.options.w === 'number' ? slideItemObj.options.w : 1) / intColCnt;
21810
22114
  }
21811
- strXml += `<a:gridCol w="${Math.round(w)}"/>`;
22115
+ strXml += `<a:gridCol w="${positiveExtent(w)}"/>`;
21812
22116
  }
21813
22117
  strXml += '</a:tblGrid>';
21814
22118
  } else {
@@ -21816,7 +22120,7 @@ function slideObjectToXml(slide) {
21816
22120
  if (slideItemObj.options.w && !objTabOpts.colW) intColW = Math.round((typeof slideItemObj.options.w === 'number' ? slideItemObj.options.w : 1) / intColCnt);
21817
22121
  strXml += '<a:tblGrid>';
21818
22122
  for(let colw = 0; colw < intColCnt; colw++){
21819
- strXml += `<a:gridCol w="${intColW}"/>`;
22123
+ strXml += `<a:gridCol w="${positiveExtent(intColW)}"/>`;
21820
22124
  }
21821
22125
  strXml += '</a:tblGrid>';
21822
22126
  }
@@ -21894,7 +22198,7 @@ function slideObjectToXml(slide) {
21894
22198
  intRowH = Math.round((itemOpts.h ? inch2Emu(itemOpts.h) : typeof itemOpts.cy === 'number' ? itemOpts.cy : 1) / arrTabRows.length);
21895
22199
  }
21896
22200
  // B: Start row
21897
- strXml += `<a:tr h="${intRowH}">`;
22201
+ strXml += `<a:tr h="${positiveExtent(intRowH)}">`;
21898
22202
  // C: Loop over each CELL
21899
22203
  cells.forEach((cellObj)=>{
21900
22204
  var _ref, _ref1;
@@ -21927,6 +22231,7 @@ function slideObjectToXml(slide) {
21927
22231
  'fill',
21928
22232
  'fontFace',
21929
22233
  'fontSize',
22234
+ 'lang',
21930
22235
  'margin',
21931
22236
  'textDirection',
21932
22237
  'vert',
@@ -21935,7 +22240,7 @@ function slideObjectToXml(slide) {
21935
22240
  ].forEach((name)=>{
21936
22241
  if (objTabOpts[name] && !cellOpts[name] && cellOpts[name] !== 0) cellOpts[name] = objTabOpts[name];
21937
22242
  });
21938
- const cellValign = cellOpts.valign ? ` anchor="${cellOpts.valign.replace(/^c$/i, 'ctr').replace(/^m$/i, 'ctr').replace('center', 'ctr').replace('middle', 'ctr').replace('top', 't').replace('btm', 'b').replace('bottom', 'b')}"` : '';
22243
+ const cellValign = cellOpts.valign ? ` anchor="${cellOpts.valign.replace(/^c$/i, 'ctr').replace(/^m(id(dle)?)?$/i, 'ctr').replace(/^center$/i, 'ctr').replace(/^top$/i, 't').replace(/^b(tm|ottom)$/i, 'b')}"` : '';
21939
22244
  // `vert` = Martin-N alias of `textDirection`
21940
22245
  const cellDir = cellOpts.textDirection || cellOpts.vert;
21941
22246
  const cellTextDir = cellDir && cellDir !== 'horz' ? ` vert="${cellDir}"` : '';
@@ -22084,9 +22389,17 @@ function slideObjectToXml(slide) {
22084
22389
  } else {
22085
22390
  var _slideItemObj_options_line_curveadjust, _slideItemObj_options_line7;
22086
22391
  strSlideXml += '<a:prstGeom prst="' + slideItemObj.shape + '"><a:avLst>';
22087
- // `rectRadius: 0` is a valid sharp-corner adj (ECMA-376 §5.1.11 preset geom `gd name="adj"`).
22088
- if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius) && slideItemObj.options.rectRadius >= 0) {
22089
- strSlideXml += `<a:gd name="adj" fmla="val ${Math.round(slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / Math.min(cx, cy))}"/>`;
22392
+ // `rectRadius` adj is a 0..50000 fraction of the shorter side; clamp out-of-range / zero-extent results.
22393
+ // `round2SameRect` uses two handles (`adj1` top corners, `adj2` bottom corners) — single `adj` is ignored.
22394
+ if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius)) {
22395
+ const minDim = Math.min(cx, cy);
22396
+ const rawAdj = minDim > 0 ? slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / minDim : slideItemObj.options.rectRadius > 0 ? 50000 : 0;
22397
+ const adjVal = clampInt(rawAdj, 0, 50000);
22398
+ if (slideItemObj.shape === core_enums_SHAPE_TYPE.ROUND_2_SAME_RECTANGLE) {
22399
+ strSlideXml += `<a:gd name="adj1" fmla="val ${adjVal}"/><a:gd name="adj2" fmla="val 0"/>`;
22400
+ } else {
22401
+ strSlideXml += `<a:gd name="adj" fmla="val ${adjVal}"/>`;
22402
+ }
22090
22403
  } else if (slideItemObj.options.angleRange) {
22091
22404
  for(let i = 0; i < 2; i++){
22092
22405
  const angle = slideItemObj.options.angleRange[i];
@@ -22199,8 +22512,8 @@ function slideObjectToXml(slide) {
22199
22512
  // the frame must keep the user's w/h container - collapsing it to the crop box (or 0) breaks
22200
22513
  // rendering (issue #1399).
22201
22514
  if (sizing.type !== 'crop') {
22202
- imgWidth = boxW;
22203
- imgHeight = boxH;
22515
+ imgWidth = positiveExtent(boxW);
22516
+ imgHeight = positiveExtent(boxH);
22204
22517
  }
22205
22518
  } else {
22206
22519
  strSlideXml += ' <a:stretch><a:fillRect/></a:stretch>';
@@ -22213,8 +22526,10 @@ function slideObjectToXml(slide) {
22213
22526
  strSlideXml += ' </a:xfrm>';
22214
22527
  // Geometry: rectRadius → roundRect; rounding (legacy) → ellipse; else rect
22215
22528
  // Selective port of niranjan-uma-shankar/feature/html-to-pptx (keeps ellipse back-compat)
22216
- if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius) && slideItemObj.options.rectRadius >= 0) {
22217
- const adjValue = Math.round(slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / Math.min(imgWidth, imgHeight));
22529
+ if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius)) {
22530
+ const minDim = Math.min(imgWidth, imgHeight);
22531
+ const rawAdj = minDim > 0 ? slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / minDim : slideItemObj.options.rectRadius > 0 ? 50000 : 0;
22532
+ const adjValue = clampInt(rawAdj, 0, 50000);
22218
22533
  strSlideXml += ` <a:prstGeom prst="roundRect"><a:avLst><a:gd name="adj" fmla="val ${adjValue}"/></a:avLst></a:prstGeom>`;
22219
22534
  } else {
22220
22535
  strSlideXml += ` <a:prstGeom prst="${rounding ? 'ellipse' : 'rect'}"><a:avLst/></a:prstGeom>`;
@@ -22244,7 +22559,7 @@ function slideObjectToXml(slide) {
22244
22559
  const coverRid = (_slideItemObj__coverRid = slideItemObj._coverRid) !== null && _slideItemObj__coverRid !== void 0 ? _slideItemObj__coverRid : 2;
22245
22560
  strSlideXml += '<p:pic>';
22246
22561
  strSlideXml += ' <p:nvPicPr>';
22247
- strSlideXml += `<p:cNvPr id="${coverRid}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
22562
+ strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
22248
22563
  strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
22249
22564
  if (slideItemObj.mtype === 'audioCd') {
22250
22565
  const cd = slideItemObj.options.audioCd;
@@ -22260,34 +22575,32 @@ function slideObjectToXml(slide) {
22260
22575
  strSlideXml += ' </p:spPr>';
22261
22576
  strSlideXml += '</p:pic>';
22262
22577
  } else if (slideItemObj.mtype === 'online') {
22263
- var _slideItemObj_mediaRid, _slideItemObj_mediaRid1;
22578
+ var _slideItemObj_mediaRid;
22264
22579
  const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
22265
22580
  strSlideXml += '<p:pic>';
22266
22581
  strSlideXml += ' <p:nvPicPr>';
22267
- // IMPORTANT: <p:cNvPr id="" value is critical - if its not the same number as preview image `rId`, PowerPoint throws error!
22268
- strSlideXml += `<p:cNvPr id="${((_slideItemObj_mediaRid = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid !== void 0 ? _slideItemObj_mediaRid : 0) + 2}" name="${slideItemObj.options.objectName}"/>`;
22582
+ strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"/>`;
22269
22583
  strSlideXml += ' <p:cNvPicPr/>';
22270
22584
  strSlideXml += genXmlNvPr(slideItemObj.options, `<a:videoFile r:link="rId${slideItemObj.mediaRid}"${contentType}/>`);
22271
22585
  strSlideXml += ' </p:nvPicPr>';
22272
22586
  // NOTE: `blip` is diferent than videos; also there's no preview "p:extLst" above but exists in videos
22273
- strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((_slideItemObj_mediaRid1 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid1 !== void 0 ? _slideItemObj_mediaRid1 : 0) + 1}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`; // NOTE: Preview image is required!
22587
+ strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((_slideItemObj_mediaRid = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid !== void 0 ? _slideItemObj_mediaRid : 0) + 1}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`; // NOTE: Preview image is required!
22274
22588
  strSlideXml += ' <p:spPr>';
22275
22589
  strSlideXml += ` <a:xfrm${locationAttr}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
22276
22590
  strSlideXml += ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>';
22277
22591
  strSlideXml += ' </p:spPr>';
22278
22592
  strSlideXml += '</p:pic>';
22279
22593
  } else {
22280
- var _slideItemObj_mediaRid2, _slideItemObj_mediaRid3, _slideItemObj_mediaRid4, _slideItemObj_mediaRid5;
22594
+ var _slideItemObj_mediaRid1, _slideItemObj_mediaRid2, _slideItemObj_mediaRid3;
22281
22595
  // ECMA-376: audio uses `<a:audioFile>`, video uses `<a:videoFile>` under nvPr.
22282
22596
  const mediaFileTag = slideItemObj.mtype === 'audio' ? 'a:audioFile' : 'a:videoFile';
22283
22597
  const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
22284
22598
  strSlideXml += '<p:pic>';
22285
22599
  strSlideXml += ' <p:nvPicPr>';
22286
- // IMPORTANT: <p:cNvPr id="" value is critical - if not the same number as preiew image rId, PowerPoint throws error!
22287
- strSlideXml += `<p:cNvPr id="${((_slideItemObj_mediaRid2 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid2 !== void 0 ? _slideItemObj_mediaRid2 : 0) + 2}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
22600
+ strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
22288
22601
  strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
22289
22602
  const mediaExtras = genXmlMediaExtras(slideItemObj.options);
22290
- const mediaExt = '<p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}">' + (mediaExtras ? ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid3 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid3 !== void 0 ? _slideItemObj_mediaRid3 : 0) + 1}">${mediaExtras} </p14:media>` : ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid4 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid4 !== void 0 ? _slideItemObj_mediaRid4 : 0) + 1}"/>`) + '</p:ext>';
22603
+ const mediaExt = '<p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}">' + (mediaExtras ? ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid1 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid1 !== void 0 ? _slideItemObj_mediaRid1 : 0) + 1}">${mediaExtras} </p14:media>` : ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid2 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid2 !== void 0 ? _slideItemObj_mediaRid2 : 0) + 1}"/>`) + '</p:ext>';
22291
22604
  const narrationExt = slideItemObj.options.isNarration ? '<p:ext uri="{42D2F446-02D8-4167-A562-619A0277C38B}"><p15:isNarration xmlns:p15="http://schemas.microsoft.com/office/powerpoint/2012/main" val="1"/></p:ext>' : '';
22292
22605
  strSlideXml += genXmlNvPr(slideItemObj.options, `<${mediaFileTag} r:link="rId${slideItemObj.mediaRid}"${contentType}/>`, narrationExt ? [
22293
22606
  mediaExt,
@@ -22296,7 +22609,7 @@ function slideObjectToXml(slide) {
22296
22609
  mediaExt
22297
22610
  ]);
22298
22611
  strSlideXml += ' </p:nvPicPr>';
22299
- strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((_slideItemObj_mediaRid5 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid5 !== void 0 ? _slideItemObj_mediaRid5 : 0) + 2}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`; // NOTE: Preview image is required!
22612
+ strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((_slideItemObj_mediaRid3 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid3 !== void 0 ? _slideItemObj_mediaRid3 : 0) + 2}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`; // NOTE: Preview image is required!
22300
22613
  strSlideXml += ' <p:spPr>';
22301
22614
  strSlideXml += ` <a:xfrm${locationAttr}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
22302
22615
  strSlideXml += ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>';
@@ -22479,7 +22792,7 @@ function slideObjectToXml(slide) {
22479
22792
  strSlideXml += ' <p:nvPr><p:ph type="sldNum" sz="quarter" idx="4294967295"/></p:nvPr>';
22480
22793
  strSlideXml += ' </p:nvSpPr>';
22481
22794
  strSlideXml += ' <p:spPr>';
22482
- strSlideXml += '<a:xfrm>' + `<a:off x="${getSmartParseNumber(slide._slideNumberProps.x, 'X', slide._presLayout)}" y="${getSmartParseNumber(slide._slideNumberProps.y, 'Y', slide._presLayout)}"/>` + `<a:ext cx="${slide._slideNumberProps.w ? getSmartParseNumber(slide._slideNumberProps.w, 'X', slide._presLayout) : '800000'}" cy="${slide._slideNumberProps.h ? getSmartParseNumber(slide._slideNumberProps.h, 'Y', slide._presLayout) : '300000'}"/>` + '</a:xfrm>' + ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>' + ' <a:extLst><a:ext uri="{C572A759-6A51-4108-AA02-DFA0A04FC94B}"><ma14:wrappingTextBoxFlag val="0" xmlns:ma14="http://schemas.microsoft.com/office/mac/drawingml/2011/main"/></a:ext></a:extLst>' + '</p:spPr>';
22795
+ strSlideXml += '<a:xfrm>' + `<a:off x="${getSmartParseNumber(slide._slideNumberProps.x, 'X', slide._presLayout)}" y="${getSmartParseNumber(slide._slideNumberProps.y, 'Y', slide._presLayout)}"/>` + `<a:ext cx="${slide._slideNumberProps.w ? positiveExtent(getSmartParseNumber(slide._slideNumberProps.w, 'X', slide._presLayout)) : '800000'}" cy="${slide._slideNumberProps.h ? positiveExtent(getSmartParseNumber(slide._slideNumberProps.h, 'Y', slide._presLayout)) : '300000'}"/>` + '</a:xfrm>' + ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>' + ' <a:extLst><a:ext uri="{C572A759-6A51-4108-AA02-DFA0A04FC94B}"><ma14:wrappingTextBoxFlag val="0" xmlns:ma14="http://schemas.microsoft.com/office/mac/drawingml/2011/main"/></a:ext></a:extLst>' + '</p:spPr>';
22483
22796
  strSlideXml += '<p:txBody>';
22484
22797
  strSlideXml += '<a:bodyPr';
22485
22798
  if (slide._slideNumberProps.margin && Array.isArray(slide._slideNumberProps.margin)) {
@@ -22499,7 +22812,7 @@ function slideObjectToXml(slide) {
22499
22812
  strSlideXml += '/>';
22500
22813
  strSlideXml += ' <a:lstStyle><a:lvl1pPr>';
22501
22814
  if (slide._slideNumberProps.fontFace || slide._slideNumberProps.fontSize || slide._slideNumberProps.color) {
22502
- strSlideXml += `<a:defRPr sz="${Math.round((slide._slideNumberProps.fontSize || 12) * 100)}">`;
22815
+ strSlideXml += `<a:defRPr sz="${fontSizeToSz(slide._slideNumberProps.fontSize || 12)}">`;
22503
22816
  if (slide._slideNumberProps.color) strSlideXml += genXmlColorSelection(slide._slideNumberProps.color);
22504
22817
  if (slide._slideNumberProps.fontFace) {
22505
22818
  strSlideXml += `<a:latin typeface="${slide._slideNumberProps.fontFace}"/><a:ea typeface="${slide._slideNumberProps.fontFace}"/><a:cs typeface="${slide._slideNumberProps.fontFace}"/>`;
@@ -22861,20 +23174,21 @@ function slideShowExtLst(slide) {
22861
23174
  * @returns {SlideObjectAnimation[]} array of object animations with their indices
22862
23175
  */ /**
22863
23176
  * Collect media shapes that need a playback entry in the slide timing tree.
22864
- * The shape id targeted by `<p:spTgt spid>` is the media `<p:cNvPr id>`, which the
22865
- * media emitter computes as `mediaRid + 2`. Online (linked) videos are excluded —
23177
+ * The shape id targeted by `<p:spTgt spid>` is the allocated `<p:cNvPr id>` stamped onto
23178
+ * `obj.options.sId` by `slideObjectToXml`. Online (linked) videos are excluded —
22866
23179
  * they don't support the embedded playback timing tree.
22867
23180
  */ function collectMediaPlayback(slide) {
22868
23181
  var _slide__slideObjects;
22869
23182
  const entries = [];
22870
- ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).forEach((obj)=>{
22871
- var _obj_mediaRid;
23183
+ const renderable = ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).filter((obj)=>obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.notes */"notes"));
23184
+ renderable.forEach((obj, idx)=>{
23185
+ var _o_sId;
22872
23186
  if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") || obj.mtype !== 'audio' && obj.mtype !== 'video') return;
22873
23187
  const o = obj.options;
22874
23188
  // Defaults are all false: no timing node unless at least one playback flag is set.
22875
23189
  if (!o || !(o.autoplay || o.loop || o.fullScreen || o.mute)) return;
22876
23190
  entries.push({
22877
- spid: ((_obj_mediaRid = obj.mediaRid) !== null && _obj_mediaRid !== void 0 ? _obj_mediaRid : 0) + 2,
23191
+ spid: (_o_sId = o.sId) !== null && _o_sId !== void 0 ? _o_sId : idx + 2,
22878
23192
  kind: obj.mtype === 'video' ? 'video' : 'audio',
22879
23193
  autoplay: o.autoplay,
22880
23194
  loop: o.loop,
@@ -22888,7 +23202,8 @@ function slideShowExtLst(slide) {
22888
23202
  function collectSlideAnimations(slide) {
22889
23203
  const animations = [];
22890
23204
  if (!slide._slideObjects) return animations;
22891
- slide._slideObjects.forEach((slideObj, index)=>{
23205
+ const renderable = slide._slideObjects.filter((obj)=>obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.notes */"notes"));
23206
+ renderable.forEach((slideObj, index)=>{
22892
23207
  var _ref;
22893
23208
  var _slideObj_options, _slideObj_options1, _slideObj_options2;
22894
23209
  // Warn when animations are incorrectly attached to individual text runs
@@ -22927,8 +23242,8 @@ function collectSlideAnimations(slide) {
22927
23242
  delay: 0
22928
23243
  }, animConfig);
22929
23244
  }
22930
- // Media cNvPr id is mediaRid+2 (not the auto shape index). Charts keep index+2 / sId.
22931
- const shapeId = slideObj._type === (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") && slideObj.mediaRid != null ? slideObj.mediaRid + 2 : (_ref = (_slideObj_options2 = slideObj.options) === null || _slideObj_options2 === void 0 ? void 0 : _slideObj_options2.sId) !== null && _ref !== void 0 ? _ref : index + 2;
23245
+ // `slideObjectToXml` runs first and stamps every object's allocated `p:cNvPr/@id` onto `options.sId`
23246
+ const shapeId = (_ref = (_slideObj_options2 = slideObj.options) === null || _slideObj_options2 === void 0 ? void 0 : _slideObj_options2.sId) !== null && _ref !== void 0 ? _ref : index + 2;
22932
23247
  animations.push({
22933
23248
  objectIndex: index,
22934
23249
  shapeId,
@@ -22950,6 +23265,9 @@ function collectSlideAnimations(slide) {
22950
23265
  if (!s._id) s._id = getUuid('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
22951
23266
  });
22952
23267
  resolveZoomSections(slide, sections);
23268
+ // Render `p:cSld` first so `resolveShapeId` allocates unique `p:cNvPr/@id` values (including media)
23269
+ // and stamps `options.sId` before animations & media playback timing target `<p:spTgt spid="..."/>`.
23270
+ const cSldXml = slideObjectToXml(slide);
22953
23271
  const animations = collectSlideAnimations(slide);
22954
23272
  const mediaPlayback = collectMediaPlayback(slide);
22955
23273
  const timingXml = animations.length > 0 || mediaPlayback.length > 0 ? createTimingXml(animations, mediaPlayback) : '';
@@ -22964,7 +23282,7 @@ function collectSlideAnimations(slide) {
22964
23282
  commentRelExt
22965
23283
  ].filter(Boolean);
22966
23284
  const sldExtXml = sldExtLst.length > 0 ? `<p:extLst>${sldExtLst.join('')}</p:extLst>` : '';
22967
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}` + '<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" ' + 'xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" ' + `xmlns:m="${MATH_NS}" ` + `xmlns:a14="${A14_NS}" ` + (hasP14 ? `xmlns:p14="${P14_NS}" ` : '') + `xmlns:mc="${MC_NS}" mc:Ignorable="a14${hasP14 ? ' p14' : ''}"` + `${(slide === null || slide === void 0 ? void 0 : slide.hidden) ? ' show="0"' : ''}>` + `${slideObjectToXml(slide)}` + '<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>' + `${transitionXml}` + `${timingXml}` + `${sldExtXml}` + '</p:sld>';
23285
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}` + '<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" ' + 'xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" ' + `xmlns:m="${MATH_NS}" ` + `xmlns:a14="${A14_NS}" ` + (hasP14 ? `xmlns:p14="${P14_NS}" ` : '') + `xmlns:mc="${MC_NS}" mc:Ignorable="a14${hasP14 ? ' p14' : ''}"` + `${(slide === null || slide === void 0 ? void 0 : slide.hidden) ? ' show="0"' : ''}>` + `${cSldXml}` + '<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>' + `${transitionXml}` + `${timingXml}` + `${sldExtXml}` + '</p:sld>';
22968
23286
  }
22969
23287
  /**
22970
23288
  * Get text content of Notes from Slide
@@ -23058,21 +23376,54 @@ function collectSlideAnimations(slide) {
23058
23376
  * Distinct `thm15:themeFamily` ids keep the notes theme from being a byte-identical twin
23059
23377
  * (Office repair creates theme2 when notesMaster shares theme1; Juliussssssss 9bdfe09 / SCV-Soft 1a1998e).
23060
23378
  * @return {string} XML
23061
- */ function makeXmlTheme(pres, variant = 'slide') {
23062
- var _ref, _ref1;
23063
- var _pres_theme, _pres_theme1, _pres_theme2, _pres_theme3, _pres_theme4, _pres_theme5, _pres_theme6;
23064
- const majorFont = ((_pres_theme = pres.theme) === null || _pres_theme === void 0 ? void 0 : _pres_theme.headFontFace) ? `<a:latin typeface="${(_pres_theme1 = pres.theme) === null || _pres_theme1 === void 0 ? void 0 : _pres_theme1.headFontFace}"/>` : '<a:latin typeface="Calibri Light" panose="020F0302020204030204"/>';
23065
- const minorFont = ((_pres_theme2 = pres.theme) === null || _pres_theme2 === void 0 ? void 0 : _pres_theme2.bodyFontFace) ? `<a:latin typeface="${(_pres_theme3 = pres.theme) === null || _pres_theme3 === void 0 ? void 0 : _pres_theme3.bodyFontFace}"/>` : '<a:latin typeface="Calibri" panose="020F0502020204030204"/>';
23066
- const eaFace = (_ref = (_pres_theme4 = pres.theme) === null || _pres_theme4 === void 0 ? void 0 : _pres_theme4.eaFontFace) !== null && _ref !== void 0 ? _ref : '';
23067
- const csFace = (_ref1 = (_pres_theme5 = pres.theme) === null || _pres_theme5 === void 0 ? void 0 : _pres_theme5.csFontFace) !== null && _ref1 !== void 0 ? _ref1 : '';
23379
+ */ const THEME_COLOR_SLOT_ORDER = [
23380
+ 'dk1',
23381
+ 'lt1',
23382
+ 'dk2',
23383
+ 'lt2',
23384
+ 'accent1',
23385
+ 'accent2',
23386
+ 'accent3',
23387
+ 'accent4',
23388
+ 'accent5',
23389
+ 'accent6',
23390
+ 'hlink',
23391
+ 'folHlink'
23392
+ ];
23393
+ function makeXmlTheme(pres, variant = 'slide') {
23394
+ var _pres_theme, _pres_theme1, _pres_theme2, _pres_theme3, _pres_theme4, _pres_theme5, _pres_theme6, _pres_theme7;
23395
+ const headFace = ((_pres_theme = pres.theme) === null || _pres_theme === void 0 ? void 0 : _pres_theme.headFontFace) ? encodeXmlEntities(pres.theme.headFontFace) : '';
23396
+ const bodyFace = ((_pres_theme1 = pres.theme) === null || _pres_theme1 === void 0 ? void 0 : _pres_theme1.bodyFontFace) ? encodeXmlEntities(pres.theme.bodyFontFace) : '';
23397
+ const explicitEa = ((_pres_theme2 = pres.theme) === null || _pres_theme2 === void 0 ? void 0 : _pres_theme2.eaFontFace) !== undefined ? encodeXmlEntities(pres.theme.eaFontFace) : undefined;
23398
+ const explicitCs = ((_pres_theme3 = pres.theme) === null || _pres_theme3 === void 0 ? void 0 : _pres_theme3.csFontFace) !== undefined ? encodeXmlEntities(pres.theme.csFontFace) : undefined;
23399
+ // Without ea/cs faces, East Asian and complex-script runs inheriting the theme font fall back to app defaults.
23400
+ // When `eaFontFace`/`csFontFace` are unset, mirror `headFontFace`/`bodyFontFace` (pitch-io 3049ea49).
23401
+ const majorFont = headFace ? `<a:latin typeface="${headFace}"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : headFace}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : headFace}"/>` : `<a:latin typeface="Calibri Light" panose="020F0302020204030204"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : ''}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : ''}"/>`;
23402
+ const minorFont = bodyFace ? `<a:latin typeface="${bodyFace}"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : bodyFace}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : bodyFace}"/>` : `<a:latin typeface="Calibri" panose="020F0502020204030204"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : ''}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : ''}"/>`;
23068
23403
  const themeFamilyId = variant === 'notes' ? '{2E142A2C-CD16-42D6-873A-C26D2A0506FA}' : '{62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F}';
23069
23404
  const themeFamilyVid = variant === 'notes' ? '{1BDDFF52-6CD6-40A5-AB3C-68EB2F1E4D0A}' : '{4A3C46E8-61CC-4603-A589-7422A47A8E4A}';
23070
23405
  // Exactly 12 hex colors required (upstream only checked truthy `.length`, which allowed short arrays → undefined attrs)
23071
- const isCustomColors = Array.isArray((_pres_theme6 = pres.theme) === null || _pres_theme6 === void 0 ? void 0 : _pres_theme6.themeColors) && pres.theme.themeColors.length === 12;
23072
23406
  const c = resolveThemeColors(pres.theme);
23073
- const themeName = isCustomColors ? 'Custom Theme' : 'Office Theme';
23074
- const schemeName = isCustomColors ? 'Custom' : 'Office';
23075
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="${themeName}"><a:themeElements><a:clrScheme name="${schemeName}"><a:dk1><a:sysClr val="windowText" lastClr="${c[0]}"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="${c[1]}"/></a:lt1><a:dk2><a:srgbClr val="${c[2]}"/></a:dk2><a:lt2><a:srgbClr val="${c[3]}"/></a:lt2><a:accent1><a:srgbClr val="${c[4]}"/></a:accent1><a:accent2><a:srgbClr val="${c[5]}"/></a:accent2><a:accent3><a:srgbClr val="${c[6]}"/></a:accent3><a:accent4><a:srgbClr val="${c[7]}"/></a:accent4><a:accent5><a:srgbClr val="${c[8]}"/></a:accent5><a:accent6><a:srgbClr val="${c[9]}"/></a:accent6><a:hlink><a:srgbClr val="${c[10]}"/></a:hlink><a:folHlink><a:srgbClr val="${c[11]}"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont>${majorFont}<a:ea typeface="${eaFace}"/><a:cs typeface="${csFace}"/><a:font script="Jpan" typeface="游ゴシック Light"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线 Light"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Angsana New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:majorFont><a:minorFont>${minorFont}<a:ea typeface="${eaFace}"/><a:cs typeface="${csFace}"/><a:font script="Jpan" typeface="游ゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Cordia New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="110000"/><a:satMod val="105000"/><a:tint val="67000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="103000"/><a:tint val="73000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="109000"/><a:tint val="81000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:satMod val="103000"/><a:lumMod val="102000"/><a:tint val="94000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:satMod val="110000"/><a:lumMod val="100000"/><a:shade val="100000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="99000"/><a:satMod val="120000"/><a:shade val="78000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="12700" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="19050" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="63000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"><a:tint val="95000"/><a:satMod val="170000"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="93000"/><a:satMod val="150000"/><a:shade val="98000"/><a:lumMod val="102000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:tint val="98000"/><a:satMod val="130000"/><a:shade val="90000"/><a:lumMod val="103000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="63000"/><a:satMod val="120000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/><a:extLst><a:ext uri="{05A4C25C-085E-4340-85A3-A5531E510DB2}"><thm15:themeFamily xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main" name="Office Theme" id="${themeFamilyId}" vid="${themeFamilyVid}"/></a:ext></a:extLst></a:theme>`;
23407
+ let hasNamedColorOverrides = false;
23408
+ if (((_pres_theme4 = pres.theme) === null || _pres_theme4 === void 0 ? void 0 : _pres_theme4.colors) && typeof pres.theme.colors === 'object') {
23409
+ for (const [slot, raw] of Object.entries(pres.theme.colors)){
23410
+ const idx = THEME_COLOR_SLOT_ORDER.indexOf(slot);
23411
+ if (idx < 0 || typeof raw !== 'string') continue;
23412
+ const hex = raw.replace(/^#/, '').toUpperCase();
23413
+ if (/^[0-9A-F]{6}$/.test(hex)) {
23414
+ c[idx] = hex;
23415
+ hasNamedColorOverrides = true;
23416
+ } else {
23417
+ console.warn(`[pptxgenjs] theme.colors.${slot}="${raw}" is not a valid 6-digit hex; using ${c[idx]}`);
23418
+ }
23419
+ }
23420
+ }
23421
+ const isCustomColors = Array.isArray((_pres_theme5 = pres.theme) === null || _pres_theme5 === void 0 ? void 0 : _pres_theme5.themeColors) && pres.theme.themeColors.length === 12 || hasNamedColorOverrides;
23422
+ const customName = ((_pres_theme6 = pres.theme) === null || _pres_theme6 === void 0 ? void 0 : _pres_theme6.name) ? encodeXmlEntities(pres.theme.name) : '';
23423
+ const themeName = customName || (isCustomColors ? 'Custom Theme' : 'Office Theme');
23424
+ const schemeName = customName || (isCustomColors ? 'Custom' : 'Office');
23425
+ const fontSchemeName = ((_pres_theme7 = pres.theme) === null || _pres_theme7 === void 0 ? void 0 : _pres_theme7.fontSchemeName) ? encodeXmlEntities(pres.theme.fontSchemeName) : customName || 'Office';
23426
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="${themeName}"><a:themeElements><a:clrScheme name="${schemeName}"><a:dk1><a:sysClr val="windowText" lastClr="${c[0]}"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="${c[1]}"/></a:lt1><a:dk2><a:srgbClr val="${c[2]}"/></a:dk2><a:lt2><a:srgbClr val="${c[3]}"/></a:lt2><a:accent1><a:srgbClr val="${c[4]}"/></a:accent1><a:accent2><a:srgbClr val="${c[5]}"/></a:accent2><a:accent3><a:srgbClr val="${c[6]}"/></a:accent3><a:accent4><a:srgbClr val="${c[7]}"/></a:accent4><a:accent5><a:srgbClr val="${c[8]}"/></a:accent5><a:accent6><a:srgbClr val="${c[9]}"/></a:accent6><a:hlink><a:srgbClr val="${c[10]}"/></a:hlink><a:folHlink><a:srgbClr val="${c[11]}"/></a:folHlink></a:clrScheme><a:fontScheme name="${fontSchemeName}"><a:majorFont>${majorFont}<a:font script="Jpan" typeface="游ゴシック Light"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线 Light"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Angsana New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:majorFont><a:minorFont>${minorFont}<a:font script="Jpan" typeface="游ゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Cordia New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="110000"/><a:satMod val="105000"/><a:tint val="67000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="103000"/><a:tint val="73000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="109000"/><a:tint val="81000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:satMod val="103000"/><a:lumMod val="102000"/><a:tint val="94000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:satMod val="110000"/><a:lumMod val="100000"/><a:shade val="100000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="99000"/><a:satMod val="120000"/><a:shade val="78000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="12700" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="19050" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="63000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"><a:tint val="95000"/><a:satMod val="170000"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="93000"/><a:satMod val="150000"/><a:shade val="98000"/><a:lumMod val="102000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:tint val="98000"/><a:satMod val="130000"/><a:shade val="90000"/><a:lumMod val="103000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="63000"/><a:satMod val="120000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/><a:extLst><a:ext uri="{05A4C25C-085E-4340-85A3-A5531E510DB2}"><thm15:themeFamily xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main" name="Office Theme" id="${themeFamilyId}" vid="${themeFamilyVid}"/></a:ext></a:extLst></a:theme>`;
23076
23427
  }
23077
23428
  const package_P15_NS = 'http://schemas.microsoft.com/office/powerpoint/2012/main';
23078
23429
  const SLD_GUIDE_URI = '{EFAFB233-063F-42B5-8137-9DF3F51BA10A}';
@@ -23126,7 +23477,8 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
23126
23477
  // STEP 4: Add sizes
23127
23478
  // `@type` records which preset the dimensions match; omitted when the caller does not say
23128
23479
  strXml += `<p:sldSz cx="${pres.presLayout.width}" cy="${pres.presLayout.height}"${pres.slideSizeType ? ` type="${pres.slideSizeType}"` : ''}/>`;
23129
- strXml += `<p:notesSz cx="${pres.presLayout.height}" cy="${pres.presLayout.width}"/>`;
23480
+ // Diffit-Inc 15c5bade: fixed 7.5×10in portrait notes page matching standard notesMaster placeholders
23481
+ strXml += '<p:notesSz cx="6858000" cy="9144000"/>';
23130
23482
  // CT_Presentation sequence puts these between `notesSz` and `defaultTextStyle` (photoAlbum, kinsoku)
23131
23483
  if (pres.photoAlbum) {
23132
23484
  const album = pres.photoAlbum;
@@ -23931,7 +24283,7 @@ class PptxGenJS {
23931
24283
  */ pptxgen_define_property(this, "_layout", void 0);
23932
24284
  /**
23933
24285
  * PptxGenJS Library Version
23934
- */ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.3.10"));
24286
+ */ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.4.0"));
23935
24287
  /**
23936
24288
  * @type {string}
23937
24289
  */ pptxgen_define_property(this, "_author", void 0);