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
  import { JSZip } from "@node-projects/jszip";
4
4
  import { parseXml } from "@rgrove/parse-xml";
@@ -1541,6 +1541,59 @@ const XML_ILLEGAL_CHARS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]|
1541
1541
  const points = Number(pt) || 0;
1542
1542
  return isNaN(points) ? 0 : Math.round(points * (/* inlined export .ONEPT */12700));
1543
1543
  }
1544
+ /**
1545
+ * Round a value into an inclusive integer range.
1546
+ * Non-finite inputs (`NaN`, `Infinity`, `-Infinity`) fall back to `min`.
1547
+ * Prevents out-of-range OOXML attributes (`ST_TextFontSize`, `ST_LineWidth`, `ST_TextSpacing*`,
1548
+ * `ST_GapAmount`, ...) from triggering PowerPoint repair dialogs.
1549
+ * @param {number} val - value to clamp
1550
+ * @param {number} min - inclusive lower bound
1551
+ * @param {number} max - inclusive upper bound
1552
+ * @returns {number} clamped integer
1553
+ */ function clampInt(val, min, max) {
1554
+ if (!Number.isFinite(val)) return min === 0 ? 0 : min;
1555
+ const res = Math.round(Math.min(max, Math.max(min, val)));
1556
+ return res === 0 ? 0 : res;
1557
+ }
1558
+ /**
1559
+ * Clamp an EMU extent to `ST_PositiveCoordinate` (finite non-negative integer `>= 0`).
1560
+ * Zero is legal (e.g. hairline rules); negative or non-finite values clamp to 0.
1561
+ * @param {number} val - extent in EMU
1562
+ * @returns {number} non-negative integer EMU
1563
+ */ function positiveExtent(val) {
1564
+ if (!Number.isFinite(val) || val <= 0) return 0;
1565
+ return Math.round(val);
1566
+ }
1567
+ /**
1568
+ * Convert a font size in points into OOXML `ST_TextFontSize` hundredths of a point (`100..400000`, i.e. 1pt..4000pt).
1569
+ * @param {number} val - font size in points
1570
+ * @returns {number} clamped `sz` attribute value
1571
+ */ function fontSizeToSz(val) {
1572
+ return clampInt(val * 100, 100, 400000);
1573
+ }
1574
+ /**
1575
+ * Clamp an EMU line width to `ST_LineWidth` (`0..20116800`, i.e. 0..1584pt).
1576
+ * @param {number} val - line width in EMU
1577
+ * @returns {number} clamped `w` attribute value in EMU
1578
+ */ function clampLineWidth(val) {
1579
+ return clampInt(val, 0, 20116800);
1580
+ }
1581
+ /**
1582
+ * Convert a line width in points into an EMU `a:ln@w` value clamped to `ST_LineWidth` (`0..20116800`).
1583
+ * @param {number|string|undefined} pt - line width in points
1584
+ * @returns {number} clamped `w` attribute value in EMU
1585
+ */ function valToLineWidth(pt) {
1586
+ return clampLineWidth(valToPts(pt));
1587
+ }
1588
+ /**
1589
+ * Convert a 0..100 transparency percentage into an OOXML `a:alpha@val` (`ST_PositiveFixedPercentage`, `0..100000`).
1590
+ * Non-finite inputs default to opaque (`100000`).
1591
+ * @param {number} transparency - transparency percent (0 = opaque, 100 = fully transparent)
1592
+ * @returns {number} clamped `a:alpha@val` in `0..100000`
1593
+ */ function clampAlphaPct(transparency) {
1594
+ if (!Number.isFinite(transparency)) return 100000;
1595
+ return clampInt((100 - transparency) * 1000, 0, 100000);
1596
+ }
1544
1597
  /**
1545
1598
  * Convert a margin component to EMU (same dual-unit rule as table cells)
1546
1599
  * - `>= 1` → points (`valToPts`)
@@ -1820,9 +1873,9 @@ const FLAG_COLOR_MODIFIERS = [
1820
1873
  }
1821
1874
  function createGlowElement(glow) {
1822
1875
  let strXml = '';
1823
- const size = Math.round(glow.size * (/* inlined export .ONEPT */12700));
1876
+ const size = positiveExtent(Math.round(glow.size * (/* inlined export .ONEPT */12700)));
1824
1877
  const color = glow.color;
1825
- const opacity = Math.round(glow.opacity * 100000);
1878
+ const opacity = clampInt(glow.opacity * 100000, 0, 100000);
1826
1879
  strXml += `<a:glow rad="${size}">`;
1827
1880
  strXml += createColorElement(color, `<a:alpha val="${opacity}"/>`);
1828
1881
  strXml += '</a:glow>';
@@ -1875,7 +1928,7 @@ function createGlowElement(glow) {
1875
1928
  return soleColor ? `<a:solidFill>${createColorElement(soleColor, fallbackInner)}</a:solidFill>` : '';
1876
1929
  }
1877
1930
  const gsLst = stops.map((stop)=>{
1878
- const inner = typeof stop.transparency === 'number' ? `<a:alpha val="${Math.round((100 - Math.min(100, Math.max(0, stop.transparency))) * 1000)}"/>` : '';
1931
+ const inner = typeof stop.transparency === 'number' ? `<a:alpha val="${clampAlphaPct(stop.transparency)}"/>` : '';
1879
1932
  return `<a:gs pos="${stop.pos}">${createColorElement(stop.color, inner)}</a:gs>`;
1880
1933
  }).join('');
1881
1934
  const rotateWithShape = (gradient === null || gradient === void 0 ? void 0 : gradient.rotateWithShape) === false || (gradient === null || gradient === void 0 ? void 0 : gradient.rotWithShape) === false ? 0 : 1;
@@ -1946,8 +1999,8 @@ function createGlowElement(glow) {
1946
1999
  if (props.type) fillType = props.type;
1947
2000
  else if (((_props_image = props.image) === null || _props_image === void 0 ? void 0 : _props_image._rId) || props._rId) fillType = 'image';
1948
2001
  if (props.color) colorVal = props.color;
1949
- if (props.alpha) internalElements += `<a:alpha val="${Math.round((100 - props.alpha) * 1000)}"/>`; // DEPRECATED: @deprecated v3.3.0
1950
- if (props.transparency) internalElements += `<a:alpha val="${Math.round((100 - props.transparency) * 1000)}"/>`;
2002
+ if (props.alpha) internalElements += `<a:alpha val="${clampAlphaPct(props.alpha)}"/>`; // DEPRECATED: @deprecated v3.3.0
2003
+ if (props.transparency) internalElements += `<a:alpha val="${clampAlphaPct(props.transparency)}"/>`;
1951
2004
  }
1952
2005
  const isBareColor = typeof props === 'string' || isModifiedThemeColor(props) || isColorProps(props);
1953
2006
  switch(fillType){
@@ -2899,173 +2952,632 @@ function gen_tables_object_spread(target) {
2899
2952
  });
2900
2953
  }
2901
2954
 
2902
- /**
2903
- * Hyperlinks and mouse-over actions.
2904
- *
2905
- * DrawingML gives the same concept two element names depending on where it appears:
2906
- *
2907
- * | host | click | mouse-over |
2908
- * | :-- | :-- | :-- |
2909
- * | `p:cNvPr` (shapes, pictures) | `a:hlinkClick` (20.1.2.2.22) | `a:hlinkHover` (20.1.2.2.23) |
2910
- * | `a:rPr` (text runs) | `a:hlinkClick` | `a:hlinkMouseOver` (21.1.2.3.6) |
2911
- *
2912
- * Emitting `a:hlinkHover` inside `a:rPr` — or `a:hlinkMouseOver` inside `p:cNvPr` — produces markup
2913
- * PowerPoint cannot parse, so the host decides the element name here rather than at each call site.
2914
- */
2915
- /**
2916
- * Build one `a:hlinkClick` / mouse-over element
2917
- * @param {HyperlinkProps} link - link props
2918
- * @param {'click' | 'hover'} trigger - which interaction this element describes
2919
- * @param {HyperlinkHost} host - the element the link is attached to
2920
- * @param {string} children - child elements (`a:snd`, `a:extLst`); self-closes when empty
2921
- * @returns {string} XML string
2922
- */ function genXmlHyperlink(link, trigger, host, children = '') {
2923
- var _link__rId;
2924
- const tag = trigger === 'click' ? 'a:hlinkClick' : host === 'run' ? 'a:hlinkMouseOver' : 'a:hlinkHover';
2925
- let attrs = `r:id="rId${(_link__rId = link._rId) !== null && _link__rId !== void 0 ? _link__rId : 0}"`;
2926
- if (link.slide) {
2927
- // an internal jump has no URL; the action attribute names the target kind
2928
- attrs += ' action="ppaction://hlinksldjump"';
2929
- } else {
2930
- attrs += ' invalidUrl="" action="" tgtFrame=""';
2955
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2956
+ try {
2957
+ var info = gen[key](arg);
2958
+ var value = info.value;
2959
+ } catch (error) {
2960
+ reject(error);
2961
+ return;
2931
2962
  }
2932
- attrs += ` tooltip="${link.tooltip ? encodeXmlEntities(link.tooltip) : ''}"`;
2933
- if (!link.slide) attrs += ' history="1"';
2934
- // both default to false in the schema, so only write them when turned on
2935
- if (link.highlightClick === true) attrs += ' highlightClick="1"';
2936
- if (link.stopSoundsOnClick === true) attrs += ' endSnd="1"';
2937
- const sound = genXmlHyperlinkSound(link);
2938
- const inner = sound + children;
2939
- return inner ? `<${tag} ${attrs}>${inner}</${tag}>` : `<${tag} ${attrs}/>`;
2940
- }
2941
- /**
2942
- * Build the `a:snd` action sound (ECMA-376 20.1.2.2.32 `CT_EmbeddedWAVAudioFile`)
2943
- * - the relationship is resolved when the object is created, so `_sndRId` is set by then
2944
- * @param {HyperlinkProps} link - link props
2945
- * @returns {string} XML string
2946
- */ function genXmlHyperlinkSound(link) {
2947
- var _link_sound_name;
2948
- var _link_sound;
2949
- if (!((_link_sound = link.sound) === null || _link_sound === void 0 ? void 0 : _link_sound._sndRId)) return '';
2950
- 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')}"/>`;
2963
+ if (info.done) resolve(value);
2964
+ else Promise.resolve(value).then(_next, _throw);
2951
2965
  }
2952
-
2953
- function line_define_property(obj, key, value) {
2954
- if (key in obj) {
2955
- Object.defineProperty(obj, key, {
2956
- value: value,
2957
- enumerable: true,
2958
- configurable: true,
2959
- writable: true
2966
+ function _async_to_generator(fn) {
2967
+ return function() {
2968
+ var self = this, args = arguments;
2969
+ return new Promise(function(resolve, reject) {
2970
+ var gen = fn.apply(self, args);
2971
+ function _next(value) {
2972
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2973
+ }
2974
+ function _throw(err) {
2975
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
2976
+ }
2977
+ _next(undefined);
2960
2978
  });
2961
- } else obj[key] = value;
2962
- return obj;
2979
+ };
2963
2980
  }
2964
- function line_object_spread(target) {
2965
- for(var i = 1; i < arguments.length; i++){
2966
- var source = arguments[i] != null ? arguments[i] : {};
2967
- var ownKeys = Object.keys(source);
2968
- if (typeof Object.getOwnPropertySymbols === "function") {
2969
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
2970
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
2971
- }));
2981
+ /**
2982
+ * PptxGenJS: Media Methods
2983
+ */
2984
+
2985
+ /** Images are measured in pixels; PowerPoint slide dimensions are inches at 96 DPI */ const IMAGE_DPI = 96;
2986
+ /**
2987
+ * Deck-scoped content-hash buckets keyed by `target._allocChartId` (shared across all slides,
2988
+ * layouts, and master in one `PptxGenJS` instance) so identical raster images share one OPC media
2989
+ * part across the entire deck without leaking across presentations.
2990
+ */ const deckImageBuckets = new WeakMap();
2991
+ function getDeckImageBuckets(target) {
2992
+ var _target__allocChartId;
2993
+ const deckKey = (_target__allocChartId = target._allocChartId) !== null && _target__allocChartId !== void 0 ? _target__allocChartId : target;
2994
+ let buckets = deckImageBuckets.get(deckKey);
2995
+ if (!buckets) {
2996
+ buckets = new Map();
2997
+ deckImageBuckets.set(deckKey, buckets);
2998
+ }
2999
+ return buckets;
3000
+ }
3001
+ function isDedupeImageRel(rel) {
3002
+ if (!rel || rel.isLinked || rel.isSvgPng) return false;
3003
+ if (typeof rel.data !== 'string' || !rel.data || rel.data === IMG_BROKEN) return false;
3004
+ const type = typeof rel.type === 'string' ? rel.type.toLowerCase() : '';
3005
+ const extn = typeof rel.extn === 'string' ? rel.extn.toLowerCase() : '';
3006
+ if (extn === 'svg' || type === 'image/svg+xml') return false;
3007
+ return type === 'image' || type.startsWith('image/');
3008
+ }
3009
+ function getRelDataBody(data) {
3010
+ const commaIdx = data.indexOf(',');
3011
+ return commaIdx >= 0 ? data.substring(commaIdx + 1) : data;
3012
+ }
3013
+ function fnv1aHash(str) {
3014
+ let hash = 2166136261;
3015
+ for(let idx = 0; idx < str.length; idx++){
3016
+ hash ^= str.charCodeAt(idx);
3017
+ hash = Math.imul(hash, 16777619);
3018
+ }
3019
+ return (hash >>> 0).toString(16);
3020
+ }
3021
+ /**
3022
+ * Deduplicate one raster image relationship against the deck-scoped content-hash table.
3023
+ * When an identical image payload already exists on any slide/layout in this presentation,
3024
+ * rewrites `rel.Target` to reuse the existing OPC media part and marks `rel.isDuplicate = true`
3025
+ * while keeping `rel.rId` and `rel.data` intact.
3026
+ */ function dedupeImageMediaRel(target, rel) {
3027
+ var _buckets_get;
3028
+ if (!isDedupeImageRel(rel)) return;
3029
+ const body = getRelDataBody(rel.data);
3030
+ if (!body) return;
3031
+ const normExtn = (rel.extn || 'png').toLowerCase() === 'jpg' ? 'jpeg' : (rel.extn || 'png').toLowerCase();
3032
+ const key = `${normExtn}|${body.length}|${fnv1aHash(body)}`;
3033
+ const buckets = getDeckImageBuckets(target);
3034
+ const bucket = (_buckets_get = buckets.get(key)) !== null && _buckets_get !== void 0 ? _buckets_get : [];
3035
+ const existing = bucket.find((entry)=>entry.data === body);
3036
+ if (existing) {
3037
+ if (existing.target !== rel.Target) {
3038
+ rel.isDuplicate = true;
3039
+ rel.Target = existing.target;
2972
3040
  }
2973
- ownKeys.forEach(function(key) {
2974
- line_define_property(target, key, source[key]);
3041
+ } else {
3042
+ bucket.push({
3043
+ data: body,
3044
+ target: rel.Target
2975
3045
  });
3046
+ buckets.set(key, bucket);
2976
3047
  }
2977
- return target;
2978
- }
2979
- function line_ownKeys(object, enumerableOnly) {
2980
- var keys = Object.keys(object);
2981
- if (Object.getOwnPropertySymbols) {
2982
- var symbols = Object.getOwnPropertySymbols(object);
2983
- if (enumerableOnly) {
2984
- symbols = symbols.filter(function(sym) {
2985
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2986
- });
2987
- }
2988
- keys.push.apply(keys, symbols);
2989
- }
2990
- return keys;
2991
3048
  }
2992
- function line_object_spread_props(target, source) {
2993
- source = source != null ? source : {};
2994
- if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2995
- else {
2996
- line_ownKeys(Object(source)).forEach(function(key) {
2997
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2998
- });
2999
- }
3000
- return target;
3049
+ /**
3050
+ * Deduplicate all resolved raster image relationships on a slide/layout deck-wide.
3051
+ * Runs after `encodeSlideMediaRels` resolves so path-loaded images are deduplicated too.
3052
+ */ function dedupeSlideMediaRels(layout) {
3053
+ var _layout__relsMedia;
3054
+ ;
3055
+ ((_layout__relsMedia = layout._relsMedia) !== null && _layout__relsMedia !== void 0 ? _layout__relsMedia : []).forEach((rel)=>dedupeImageMediaRel(layout, rel));
3001
3056
  }
3002
3057
  /**
3003
- * PptxGenJS: Line properties (`a:ln` and its aliases)
3058
+ * Read the natural pixel dimensions of a raster image from its header bytes.
3059
+ * Self-contained replacement for the `image-size` package (PNG/JPEG/GIF/BMP).
3060
+ * Format refs: PNG spec §11.2.2 (IHDR is always the first chunk, width/height big-endian at bytes 16-24);
3061
+ * JPEG (JFIF) SOF0-SOF15 markers carry height then width big-endian; GIF87a/89a logical-screen descriptor
3062
+ * little-endian at bytes 6-10; BMP DIB header little-endian at bytes 18-26. SVG is sized separately (gen-objects).
3004
3063
  *
3005
- * The same `CT_LineProperties` content model is used by shape outlines (`a:ln`), underlines
3006
- * (`a:uLn`), and table cell borders, so the element name is a parameter rather than baked in.
3007
- */
3008
-
3009
- /**
3010
- * Create a line element
3011
- * @param {ShapeLineProps} line - line options
3012
- * @param {string} tag - element name; `a:ln` for a shape outline, `a:uLn` for an underline
3013
- * @return {string} XML
3014
- */ function genXmlLine(line, tag = 'a:ln') {
3015
- // ECMA-376 §5.1.2.1.34: `<a:ln>` carries `w`, `cap`, and `cmpd` attributes
3016
- const cap = line.cap && [
3017
- 'flat',
3018
- 'sq',
3019
- 'rnd'
3020
- ].includes(line.cap) ? ` cap="${line.cap}"` : '';
3021
- const compound = COMPOUND_TYPES.has(String(line.compound)) ? ` cmpd="${String(line.compound)}"` : '';
3022
- if (line.compound && !COMPOUND_TYPES.has(String(line.compound))) {
3023
- console.warn(`[pptxgenjs] line \`compound\` must be one of ${[
3024
- ...COMPOUND_TYPES
3025
- ].join(', ')} - "${String(line.compound)}" ignored`);
3064
+ * Declared dims are header-only (we never decode pixels), so clamp to a sane ceiling: a maliciously crafted
3065
+ * header can claim 0xFFFFFFFF px and emit a ~44-million-inch slide (a corrupt pptx). PowerPoint's max slide is
3066
+ * 56 in (5376 px @ 96 DPI); 100 000 px is generous headroom for legit high-res sources while rejecting bombs.
3067
+ */ const MAX_IMAGE_PX = 100000;
3068
+ function imageDimensions(bytes) {
3069
+ if (bytes.length < 10) return {} // every supported header's dims start at/after byte 6
3070
+ ;
3071
+ const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
3072
+ const sane = (w, h)=>w > 0 && h > 0 && w <= MAX_IMAGE_PX && h <= MAX_IMAGE_PX ? {
3073
+ width: w,
3074
+ height: h
3075
+ } : {};
3076
+ // PNG: 8-byte signature 89 50 4E 47 0D 0A 1A 0A, then IHDR length(4)+type(4)+width(4)+height(4)
3077
+ if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) {
3078
+ if (bytes.length < 24) return {};
3079
+ return sane(dv.getUint32(16, false), dv.getUint32(20, false));
3026
3080
  }
3027
- const attrs = (line.width ? ` w="${valToPts(line.width)}"` : '') + cap + compound;
3028
- let xml = `<${tag}${attrs}>`;
3029
- const hasGrad = !!(line.gradient || line.type === 'gradient' || line.type === 'linearGradient');
3030
- if (line.type !== 'none' && (line.color || hasGrad)) {
3031
- xml += genXmlColorSelection(hasGrad && !line.type ? line_object_spread_props(line_object_spread({}, line), {
3032
- type: 'gradient'
3033
- }) : line);
3081
+ // GIF: 'GIF87a'/'GIF89a', logical screen width/height little-endian at bytes 6-10
3082
+ if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46) {
3083
+ return sane(dv.getUint16(6, true), dv.getUint16(8, true));
3034
3084
  }
3035
- // CT_LineProperties sequence: fill, dash, join, headEnd, tailEnd. A custom pattern replaces
3036
- // the preset one - emitting both would be ambiguous, since `a:custDash` is the same choice.
3037
- xml += genXmlDash(line);
3038
- xml += genXmlJoin(line);
3039
- xml += genXmlArrow('a:headEnd', line.beginArrowType, line.beginArrowSize);
3040
- xml += genXmlArrow('a:tailEnd', line.endArrowType, line.endArrowSize);
3041
- xml += `</${tag}>`;
3042
- return xml;
3043
- }
3044
- /** The dash choice: a custom pattern when given, otherwise the preset */ function genXmlDash(line) {
3045
- var _line_custDash;
3046
- const stops = ((_line_custDash = line.custDash) !== null && _line_custDash !== void 0 ? _line_custDash : []).filter((stop)=>{
3047
- 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;
3048
- if (!ok) console.warn('[pptxgenjs] each `custDash` stop needs a positive `dash` and a non-negative `space` (percent of line width) - stop ignored');
3049
- return ok;
3050
- });
3051
- if (stops.length > 0) {
3052
- const items = stops.map((stop)=>`<a:ds d="${Math.round(stop.dash * 1000)}" sp="${Math.round(stop.space * 1000)}"/>`).join('');
3053
- return `<a:custDash>${items}</a:custDash>`;
3085
+ // BMP: 'BM', DIB width/height little-endian at bytes 18-26 (signed; height may be negative = top-down)
3086
+ if (bytes[0] === 0x42 && bytes[1] === 0x4d) {
3087
+ if (bytes.length < 26) return {};
3088
+ return sane(Math.abs(dv.getInt32(18, true)), Math.abs(dv.getInt32(22, true)));
3054
3089
  }
3055
- return line.dashType ? `<a:prstDash val="${line.dashType}"/>` : '';
3090
+ // JPEG: FF D8, then walk marker segments until a Start-Of-Frame (C0-CF except C4/C8/CC) carries the dims
3091
+ if (bytes[0] === 0xff && bytes[1] === 0xd8) {
3092
+ let off = 2;
3093
+ while(off + 9 <= bytes.length){
3094
+ if (bytes[off] !== 0xff) {
3095
+ off++;
3096
+ continue;
3097
+ }
3098
+ const marker = bytes[off + 1];
3099
+ const isSOF = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
3100
+ if (isSOF) return sane(dv.getUint16(off + 7, false), dv.getUint16(off + 5, false));
3101
+ if (marker === 0xd8 || marker === 0xd9 || marker >= 0xd0 && marker <= 0xd7) {
3102
+ off += 2;
3103
+ continue;
3104
+ } // no length
3105
+ const segLen = dv.getUint16(off + 2, false);
3106
+ off += 2 + segLen;
3107
+ }
3108
+ }
3109
+ return {};
3056
3110
  }
3057
- /** The join choice: `a:round`, `a:bevel`, or `a:miter` with its limit */ function genXmlJoin(line) {
3058
- if (!line.join) return '';
3059
- if (line.join === 'round') return '<a:round/>';
3060
- if (line.join === 'bevel') return '<a:bevel/>';
3061
- if (line.join === 'miter') {
3062
- const lim = typeof line.miterLimit === 'number' && isFinite(line.miterLimit) && line.miterLimit >= 0 ? line.miterLimit : 800;
3063
- return `<a:miter lim="${Math.round(lim * 1000)}"/>`;
3111
+ /**
3112
+ * Natural pixel size from encoded image bytes (PNG/JPEG/GIF/BMP headers).
3113
+ * Returns null when the payload is missing, not a supported raster, or claims 0×0
3114
+ * (`imageDimensions` already rejects zero and bomb-sized headers).
3115
+ *
3116
+ * contain/cover `a:srcRect` (ECMA-376 §5.1.10.55) needs the *blip* aspect, not the
3117
+ * placement box — using w/h as imgSize makes srcRect a no-op whenever they match the sizing box.
3118
+ */ function getImagePixelSize(base64Data) {
3119
+ if (typeof base64Data !== 'string' || !base64Data || base64Data === IMG_BROKEN) return null;
3120
+ try {
3121
+ const dims = imageDimensions(base64ToBytes(base64Data));
3122
+ if (dims.width && dims.height) return {
3123
+ w: dims.width,
3124
+ h: dims.height
3125
+ };
3126
+ } catch (unused) {
3127
+ // unrecognized / truncated payload
3064
3128
  }
3065
- console.warn(`[pptxgenjs] line \`join\` must be 'round' | 'bevel' | 'miter' - "${String(line.join)}" ignored`);
3066
- return '';
3129
+ return null;
3067
3130
  }
3068
- function resolveArrowSize(size) {
3131
+ /**
3132
+ * Size images added without `w`/`h` to their natural dimensions (issue #34)
3133
+ * @note must run after `encodeSlideMediaRels` has resolved - it reads the encoded image bytes
3134
+ * @param {PresSlide | SlideLayout} layout - slide layout
3135
+ */ function applyNaturalImageSizes(layout) {
3136
+ // Media bytes for path-based images are now loaded; deduplicate identical raster payloads deck-wide
3137
+ // before slide/layout `.rels` and zip parts are emitted.
3138
+ dedupeSlideMediaRels(layout);
3139
+ layout._slideObjects.filter((obj)=>{
3140
+ var _obj_options;
3141
+ return obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.image */"image") && ((_obj_options = obj.options) === null || _obj_options === void 0 ? void 0 : _obj_options._sizeFromImage);
3142
+ }).forEach((obj)=>{
3143
+ var _layout__relsMedia_find;
3144
+ 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;
3145
+ if (!obj.options || typeof strData !== 'string' || !strData || strData === IMG_BROKEN) return;
3146
+ // An image bound to a placeholder inherits the placeholder's w/h (slide XML resolves it); sizing it
3147
+ // to its natural pixel dims instead would collapse it to ~px/96 inches (issue #996).
3148
+ if (obj.options.placeholder) return;
3149
+ try {
3150
+ const dims = imageDimensions(base64ToBytes(strData));
3151
+ if (dims.width && dims.height) {
3152
+ obj.options.w = dims.width / IMAGE_DPI;
3153
+ obj.options.h = dims.height / IMAGE_DPI;
3154
+ }
3155
+ } catch (_ex) {
3156
+ // Unreadable/unsupported image: keep the 1x1 inch default
3157
+ }
3158
+ });
3159
+ }
3160
+ /** Select relations that still need their local or remote media encoded. */ function getMediaCandidates(layout) {
3161
+ return layout._relsMedia.filter((rel)=>!rel.isLinked && rel.type !== 'online' && !rel.data && (!rel.path || rel.path && !rel.path.includes('preencoded')));
3162
+ }
3163
+ /**
3164
+ * Mark repeated source paths so only the first relation performs I/O.
3165
+ *
3166
+ * Mutates `isDuplicate`; subsequent helpers copy the first result to every duplicate.
3167
+ */ function markDuplicateMedia(candidates) {
3168
+ const paths = new Set();
3169
+ candidates.forEach((rel)=>{
3170
+ var _rel_path;
3171
+ const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
3172
+ rel.isDuplicate = paths.has(path);
3173
+ paths.add(path);
3174
+ });
3175
+ }
3176
+ /** Copy an encoded or broken source relation's data to every duplicate path. */ function copyMediaToDuplicates(candidates, rel) {
3177
+ candidates.filter((duplicate)=>duplicate.isDuplicate && duplicate.path === rel.path).forEach((duplicate)=>duplicate.data = rel.data);
3178
+ }
3179
+ /** Mark a failed source and all duplicates with the sentinel expected by package generation. */ function markMediaBroken(candidates, rel) {
3180
+ rel.data = IMG_BROKEN;
3181
+ copyMediaToDuplicates(candidates, rel);
3182
+ }
3183
+ function mediaLoadFailed(candidates, rel, message, onError) {
3184
+ markMediaBroken(candidates, rel);
3185
+ if (onError === 'placeholder') {
3186
+ console.warn(`WARN: Unable to load image, using placeholder: ${rel.path}${message ? ` (${message})` : ''}`);
3187
+ return 'done';
3188
+ }
3189
+ throw new Error(message);
3190
+ }
3191
+ /**
3192
+ * Read one Node-local media source and encode it as base64.
3193
+ *
3194
+ * A read failure is recorded before rejection so duplicate references remain consistent.
3195
+ */ function readNodeMediaFile(rel, candidates, fs, onError) {
3196
+ return _async_to_generator(function*() {
3197
+ try {
3198
+ var _rel_path;
3199
+ var _rel_fill;
3200
+ const relPath = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
3201
+ const svgFill = typeof ((_rel_fill = rel.fill) === null || _rel_fill === void 0 ? void 0 : _rel_fill.color) === 'string' ? rel.fill.color : undefined;
3202
+ if (svgFill && (rel.type === 'image/svg+xml' || rel.extn === 'svg')) {
3203
+ const svgText = applySvgFillColor(fs.readFileSync(relPath, 'utf8'), svgFill);
3204
+ rel.data = utf8ToBase64(svgText);
3205
+ } else {
3206
+ const bitmap = fs.readFileSync(relPath);
3207
+ rel.data = bytesToBase64(new Uint8Array(bitmap));
3208
+ if (svgFill && typeof rel.data === 'string') {
3209
+ rel.data = applySvgFillToDataUrl(rel.data, svgFill);
3210
+ }
3211
+ }
3212
+ copyMediaToDuplicates(candidates, rel);
3213
+ return 'done';
3214
+ } catch (ex) {
3215
+ return mediaLoadFailed(candidates, rel, `ERROR: Unable to read media: "${rel.path}"\n${String(ex)}`, onError);
3216
+ }
3217
+ })();
3218
+ }
3219
+ /**
3220
+ * Load one HTTP(S) source in Node, draining error responses and handling both request and response errors.
3221
+ */ function loadNodeMediaUrl(rel, candidates, https, http, onError) {
3222
+ var _rel_path;
3223
+ const httpMod = ((_rel_path = rel.path) === null || _rel_path === void 0 ? void 0 : _rel_path.startsWith('http://')) ? http : https;
3224
+ return new Promise((resolve, reject)=>{
3225
+ const fail = (message)=>{
3226
+ try {
3227
+ resolve(mediaLoadFailed(candidates, rel, message, onError));
3228
+ } catch (ex) {
3229
+ reject(ex);
3230
+ }
3231
+ };
3232
+ try {
3233
+ var _rel_path;
3234
+ const req = httpMod.get((_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '', (res)=>{
3235
+ var _res_statusCode;
3236
+ const status = (_res_statusCode = res.statusCode) !== null && _res_statusCode !== void 0 ? _res_statusCode : 0;
3237
+ if (status < 200 || status > 299) {
3238
+ res.resume(); // drain so the socket is freed
3239
+ fail(`ERROR! Unable to load image (HTTP ${status}): ${rel.path}`);
3240
+ return;
3241
+ }
3242
+ let raw = '';
3243
+ res.setEncoding('binary'); // IMPORTANT: Only binary encoding works
3244
+ res.on('data', (chunk)=>raw += chunk);
3245
+ res.on('end', ()=>{
3246
+ rel.data = binaryStringToBase64(raw);
3247
+ copyMediaToDuplicates(candidates, rel);
3248
+ resolve('done');
3249
+ });
3250
+ res.on('error', ()=>fail(`ERROR! Unable to load image (response): ${rel.path}`));
3251
+ });
3252
+ // NOTE: without this, a DNS/TLS/connection failure emits an unhandled 'error' and kills the process
3253
+ req.on('error', (ex)=>fail(`ERROR! Unable to load image (request): ${rel.path}\n${String(ex)}`));
3254
+ } catch (ex) {
3255
+ fail(`ERROR! Unable to load image (https.get): ${rel.path}\n${String(ex)}`);
3256
+ }
3257
+ });
3258
+ }
3259
+ /**
3260
+ * Fetch one browser media source and convert its Blob response to a data URL.
3261
+ * SVG previews are produced only after the source relation has been populated.
3262
+ */ function loadBrowserMedia(rel, candidates, onError) {
3263
+ return new Promise((resolve, reject)=>{
3264
+ var _rel_path;
3265
+ const fail = (message)=>{
3266
+ try {
3267
+ resolve(mediaLoadFailed(candidates, rel, message, onError));
3268
+ } catch (ex) {
3269
+ reject(ex);
3270
+ }
3271
+ };
3272
+ const xhr = new XMLHttpRequest();
3273
+ xhr.onload = ()=>{
3274
+ // status 0 = non-HTTP schemes (file://); anything outside 2xx is an error page, not image bytes
3275
+ if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {
3276
+ fail(`ERROR! HTTP status ${xhr.status} loading image: ${rel.path}`);
3277
+ return;
3278
+ }
3279
+ const reader = new FileReader();
3280
+ reader.onloadend = ()=>{
3281
+ if (typeof reader.result === 'string') rel.data = reader.result;
3282
+ copyMediaToDuplicates(candidates, rel);
3283
+ if (!rel.isSvgPng) resolve('done');
3284
+ else createSvgPngPreview(rel).then(()=>resolve('done')).catch(reject);
3285
+ };
3286
+ reader.readAsDataURL(xhr.response);
3287
+ };
3288
+ xhr.onerror = ()=>{
3289
+ fail(`ERROR! Unable to load image (xhr.onerror): ${rel.path}`);
3290
+ };
3291
+ xhr.open('GET', (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '');
3292
+ xhr.responseType = 'blob';
3293
+ xhr.send();
3294
+ });
3295
+ }
3296
+ /** Route one source relation to the loader valid for the active runtime. */ function encodeMediaRelation(rel, candidates, isNode, modules, loadNodeModules, onError) {
3297
+ return _async_to_generator(function*() {
3298
+ var _rel_path;
3299
+ if (!modules.https) yield loadNodeModules();
3300
+ const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
3301
+ if (isNode && modules.fs && !path.startsWith('http')) return readNodeMediaFile(rel, candidates, modules.fs, onError);
3302
+ if (isNode && modules.https && modules.http && path.startsWith('http')) return loadNodeMediaUrl(rel, candidates, modules.https, modules.http, onError);
3303
+ return loadBrowserMedia(rel, candidates, onError);
3304
+ })();
3305
+ }
3306
+ /**
3307
+ * Append SVG preview work synchronously because the caller immediately snapshots `promises`.
3308
+ * Node cannot rasterize SVG here, so it keeps the historical broken-preview sentinel behavior.
3309
+ */ function addSvgPreviewPromises(layout, isNode, promises) {
3310
+ layout._relsMedia.filter((rel)=>rel.isSvgPng && rel.data).forEach((rel)=>{
3311
+ // NOTE: must push synchronously - the caller snapshots this array as soon as we return
3312
+ if (isNode) {
3313
+ // SVG is not supported in Node (more info: https://github.com/gitbrent/PptxGenJS/issues/401)
3314
+ rel.data = IMG_BROKEN;
3315
+ promises.push(Promise.resolve('done'));
3316
+ } else {
3317
+ promises.push(createSvgPngPreview(rel));
3318
+ }
3319
+ });
3320
+ }
3321
+ /**
3322
+ * Encode Image/Audio/Video into base64
3323
+ * @param {PresSlide | SlideLayout} layout - slide layout
3324
+ * @return {Promise} promise
3325
+ */ function encodeSlideMediaRels(layout, opts) {
3326
+ // STEP 1: Detect a real Node process. Browser bundles often polyfill `process`
3327
+ // (and even `process.versions.node`), so also require a document-less runtime.
3328
+ const isNode = isNodeRuntime();
3329
+ const modules = {};
3330
+ // STEP 2: Lazy-load Node built-ins if needed. The specifier is built at runtime
3331
+ // so browser bundlers cannot statically resolve `node:https` / `https`.
3332
+ const loadNodeDeps = isNode ? ()=>_async_to_generator(function*() {
3333
+ ;
3334
+ ({ default: modules.fs } = yield importNodeBuiltin('fs'));
3335
+ ({ default: modules.https } = yield importNodeBuiltin('https'));
3336
+ ({ default: modules.http } = yield importNodeBuiltin('http'));
3337
+ })() : ()=>_async_to_generator(function*() {})();
3338
+ // Immediately start it when we know we’re in Node
3339
+ if (isNode) loadNodeDeps();
3340
+ // STEP 3: Prepare promises list
3341
+ const imageProms = [];
3342
+ // A: Capture all audio/image/video candidates for encoding (filtering online/pre-encoded)
3343
+ const candidateRels = getMediaCandidates(layout);
3344
+ // B: PERF: Mark dupes (same `path`) to avoid loading the same media over-and-over!
3345
+ markDuplicateMedia(candidateRels);
3346
+ // STEP 4: Read/Encode each unique media item
3347
+ const onError = (opts === null || opts === void 0 ? void 0 : opts.onError) === 'placeholder' ? 'placeholder' : 'throw';
3348
+ candidateRels.filter((rel)=>!rel.isDuplicate).forEach((rel)=>imageProms.push(encodeMediaRelation(rel, candidateRels, isNode, modules, loadNodeDeps, onError)));
3349
+ // STEP 5: SVG-PNG previews
3350
+ // ......: "SVG:" base64 data still requires a png to be generated
3351
+ // ......: (`isSvgPng` flag this as the preview image, not the SVG itself)
3352
+ addSvgPreviewPromises(layout, isNode, imageProms);
3353
+ return imageProms;
3354
+ }
3355
+ /**
3356
+ * Create SVG preview image
3357
+ * @param {ISlideRelMedia} rel - slide rel
3358
+ * @return {Promise} promise
3359
+ */ function createSvgPngPreview(rel) {
3360
+ return _async_to_generator(function*() {
3361
+ return yield new Promise((resolve, reject)=>{
3362
+ // A: Create
3363
+ const image = new Image();
3364
+ // Shared error handler (also wired to `image.onerror`); the reason string is informational only
3365
+ const handleError = ()=>{
3366
+ rel.data = IMG_BROKEN;
3367
+ reject(new Error(`ERROR! Unable to load image (image.onerror): ${rel.path}`));
3368
+ };
3369
+ // B: Set onload event
3370
+ image.onload = ()=>{
3371
+ // First: Check for any errors: This is the best method (try/catch wont work, etc.)
3372
+ if (image.width + image.height === 0) {
3373
+ handleError();
3374
+ }
3375
+ const canvas = document.createElement('canvas');
3376
+ const ctx = canvas.getContext('2d');
3377
+ if (!ctx) {
3378
+ handleError();
3379
+ return;
3380
+ }
3381
+ canvas.width = image.width;
3382
+ canvas.height = image.height;
3383
+ ctx.drawImage(image, 0, 0);
3384
+ // Users running on local machine will get the following error:
3385
+ // "SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported."
3386
+ // when the canvas.toDataURL call executes below.
3387
+ try {
3388
+ rel.data = canvas.toDataURL(rel.type);
3389
+ resolve('done');
3390
+ } catch (_ex) {
3391
+ handleError();
3392
+ }
3393
+ };
3394
+ image.onerror = handleError;
3395
+ // C: Load image
3396
+ image.src = typeof rel.data === 'string' ? rel.data : IMG_BROKEN;
3397
+ });
3398
+ })();
3399
+ }
3400
+
3401
+ /**
3402
+ * Hyperlinks and mouse-over actions.
3403
+ *
3404
+ * DrawingML gives the same concept two element names depending on where it appears:
3405
+ *
3406
+ * | host | click | mouse-over |
3407
+ * | :-- | :-- | :-- |
3408
+ * | `p:cNvPr` (shapes, pictures) | `a:hlinkClick` (20.1.2.2.22) | `a:hlinkHover` (20.1.2.2.23) |
3409
+ * | `a:rPr` (text runs) | `a:hlinkClick` | `a:hlinkMouseOver` (21.1.2.3.6) |
3410
+ *
3411
+ * Emitting `a:hlinkHover` inside `a:rPr` — or `a:hlinkMouseOver` inside `p:cNvPr` — produces markup
3412
+ * PowerPoint cannot parse, so the host decides the element name here rather than at each call site.
3413
+ */
3414
+ /**
3415
+ * Build one `a:hlinkClick` / mouse-over element
3416
+ * @param {HyperlinkProps} link - link props
3417
+ * @param {'click' | 'hover'} trigger - which interaction this element describes
3418
+ * @param {HyperlinkHost} host - the element the link is attached to
3419
+ * @param {string} children - child elements (`a:snd`, `a:extLst`); self-closes when empty
3420
+ * @returns {string} XML string
3421
+ */ function genXmlHyperlink(link, trigger, host, children = '') {
3422
+ var _link__rId;
3423
+ const tag = trigger === 'click' ? 'a:hlinkClick' : host === 'run' ? 'a:hlinkMouseOver' : 'a:hlinkHover';
3424
+ let attrs = `r:id="rId${(_link__rId = link._rId) !== null && _link__rId !== void 0 ? _link__rId : 0}"`;
3425
+ if (link.slide) {
3426
+ // an internal jump has no URL; the action attribute names the target kind
3427
+ attrs += ' action="ppaction://hlinksldjump"';
3428
+ } else {
3429
+ attrs += ' invalidUrl="" action="" tgtFrame=""';
3430
+ }
3431
+ attrs += ` tooltip="${link.tooltip ? encodeXmlEntities(link.tooltip) : ''}"`;
3432
+ if (!link.slide) attrs += ' history="1"';
3433
+ // both default to false in the schema, so only write them when turned on
3434
+ if (link.highlightClick === true) attrs += ' highlightClick="1"';
3435
+ if (link.stopSoundsOnClick === true) attrs += ' endSnd="1"';
3436
+ const sound = genXmlHyperlinkSound(link);
3437
+ const inner = sound + children;
3438
+ return inner ? `<${tag} ${attrs}>${inner}</${tag}>` : `<${tag} ${attrs}/>`;
3439
+ }
3440
+ /**
3441
+ * Build the `a:snd` action sound (ECMA-376 20.1.2.2.32 `CT_EmbeddedWAVAudioFile`)
3442
+ * - the relationship is resolved when the object is created, so `_sndRId` is set by then
3443
+ * @param {HyperlinkProps} link - link props
3444
+ * @returns {string} XML string
3445
+ */ function genXmlHyperlinkSound(link) {
3446
+ var _link_sound_name;
3447
+ var _link_sound;
3448
+ if (!((_link_sound = link.sound) === null || _link_sound === void 0 ? void 0 : _link_sound._sndRId)) return '';
3449
+ 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')}"/>`;
3450
+ }
3451
+
3452
+ function line_define_property(obj, key, value) {
3453
+ if (key in obj) {
3454
+ Object.defineProperty(obj, key, {
3455
+ value: value,
3456
+ enumerable: true,
3457
+ configurable: true,
3458
+ writable: true
3459
+ });
3460
+ } else obj[key] = value;
3461
+ return obj;
3462
+ }
3463
+ function line_object_spread(target) {
3464
+ for(var i = 1; i < arguments.length; i++){
3465
+ var source = arguments[i] != null ? arguments[i] : {};
3466
+ var ownKeys = Object.keys(source);
3467
+ if (typeof Object.getOwnPropertySymbols === "function") {
3468
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3469
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3470
+ }));
3471
+ }
3472
+ ownKeys.forEach(function(key) {
3473
+ line_define_property(target, key, source[key]);
3474
+ });
3475
+ }
3476
+ return target;
3477
+ }
3478
+ function line_ownKeys(object, enumerableOnly) {
3479
+ var keys = Object.keys(object);
3480
+ if (Object.getOwnPropertySymbols) {
3481
+ var symbols = Object.getOwnPropertySymbols(object);
3482
+ if (enumerableOnly) {
3483
+ symbols = symbols.filter(function(sym) {
3484
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3485
+ });
3486
+ }
3487
+ keys.push.apply(keys, symbols);
3488
+ }
3489
+ return keys;
3490
+ }
3491
+ function line_object_spread_props(target, source) {
3492
+ source = source != null ? source : {};
3493
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3494
+ else {
3495
+ line_ownKeys(Object(source)).forEach(function(key) {
3496
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3497
+ });
3498
+ }
3499
+ return target;
3500
+ }
3501
+ /**
3502
+ * PptxGenJS: Line properties (`a:ln` and its aliases)
3503
+ *
3504
+ * The same `CT_LineProperties` content model is used by shape outlines (`a:ln`), underlines
3505
+ * (`a:uLn`), and table cell borders, so the element name is a parameter rather than baked in.
3506
+ */
3507
+
3508
+ const LINE_ALIGNS = new Set([
3509
+ 'in',
3510
+ 'ctr',
3511
+ 'out'
3512
+ ]);
3513
+ /**
3514
+ * Create a line element
3515
+ * @param {ShapeLineProps} line - line options
3516
+ * @param {string} tag - element name; `a:ln` for a shape outline, `a:uLn` for an underline
3517
+ * @return {string} XML
3518
+ */ function genXmlLine(line, tag = 'a:ln') {
3519
+ // Explicit "no stroke" — emit `<a:noFill/>` so PowerPoint/Slides do not fall back to theme stroke
3520
+ if (line.type === 'none') {
3521
+ return `<${tag}><a:noFill/></${tag}>`;
3522
+ }
3523
+ // ECMA-376 §5.1.2.1.34: `<a:ln>` carries `w`, `cap`, `cmpd`, and `algn` attributes
3524
+ const cap = line.cap && [
3525
+ 'flat',
3526
+ 'sq',
3527
+ 'rnd'
3528
+ ].includes(line.cap) ? ` cap="${line.cap}"` : '';
3529
+ const compound = COMPOUND_TYPES.has(String(line.compound)) ? ` cmpd="${String(line.compound)}"` : '';
3530
+ if (line.compound && !COMPOUND_TYPES.has(String(line.compound))) {
3531
+ console.warn(`[pptxgenjs] line \`compound\` must be one of ${[
3532
+ ...COMPOUND_TYPES
3533
+ ].join(', ')} - "${String(line.compound)}" ignored`);
3534
+ }
3535
+ const align = line.align && LINE_ALIGNS.has(line.align) ? ` algn="${line.align}"` : '';
3536
+ if (line.align && !LINE_ALIGNS.has(line.align)) {
3537
+ console.warn(`[pptxgenjs] line \`align\` must be 'in' | 'ctr' | 'out' - "${String(line.align)}" ignored`);
3538
+ }
3539
+ const attrs = (line.width ? ` w="${valToLineWidth(line.width)}"` : '') + cap + compound + align;
3540
+ let xml = `<${tag}${attrs}>`;
3541
+ const hasGrad = !!(line.gradient || line.type === 'gradient' || line.type === 'linearGradient');
3542
+ if (line.color || hasGrad) {
3543
+ xml += genXmlColorSelection(hasGrad && !line.type ? line_object_spread_props(line_object_spread({}, line), {
3544
+ type: 'gradient'
3545
+ }) : line);
3546
+ }
3547
+ // CT_LineProperties sequence: fill, dash, join, headEnd, tailEnd. A custom pattern replaces
3548
+ // the preset one - emitting both would be ambiguous, since `a:custDash` is the same choice.
3549
+ xml += genXmlDash(line);
3550
+ xml += genXmlJoin(line);
3551
+ xml += genXmlArrow('a:headEnd', line.beginArrowType, line.beginArrowSize);
3552
+ xml += genXmlArrow('a:tailEnd', line.endArrowType, line.endArrowSize);
3553
+ xml += `</${tag}>`;
3554
+ return xml;
3555
+ }
3556
+ /** The dash choice: a custom pattern when given, otherwise the preset */ function genXmlDash(line) {
3557
+ var _line_custDash;
3558
+ const stops = ((_line_custDash = line.custDash) !== null && _line_custDash !== void 0 ? _line_custDash : []).filter((stop)=>{
3559
+ 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;
3560
+ if (!ok) console.warn('[pptxgenjs] each `custDash` stop needs a positive `dash` and a non-negative `space` (percent of line width) - stop ignored');
3561
+ return ok;
3562
+ });
3563
+ if (stops.length > 0) {
3564
+ const items = stops.map((stop)=>`<a:ds d="${Math.round(stop.dash * 1000)}" sp="${Math.round(stop.space * 1000)}"/>`).join('');
3565
+ return `<a:custDash>${items}</a:custDash>`;
3566
+ }
3567
+ return line.dashType ? `<a:prstDash val="${line.dashType}"/>` : '';
3568
+ }
3569
+ /** The join choice: `a:round`, `a:bevel`, or `a:miter` with its limit */ function genXmlJoin(line) {
3570
+ if (!line.join) return '';
3571
+ if (line.join === 'round') return '<a:round/>';
3572
+ if (line.join === 'bevel') return '<a:bevel/>';
3573
+ if (line.join === 'miter') {
3574
+ const lim = typeof line.miterLimit === 'number' && isFinite(line.miterLimit) && line.miterLimit >= 0 ? line.miterLimit : 800;
3575
+ return `<a:miter lim="${Math.round(lim * 1000)}"/>`;
3576
+ }
3577
+ console.warn(`[pptxgenjs] line \`join\` must be 'round' | 'bevel' | 'miter' - "${String(line.join)}" ignored`);
3578
+ return '';
3579
+ }
3580
+ function resolveArrowSize(size) {
3069
3581
  if (!size) return undefined;
3070
3582
  if (typeof size === 'string') return {
3071
3583
  width: size,
@@ -3187,7 +3699,7 @@ function text_object_spread_props(target, source) {
3187
3699
  if (bullet.color) xml += `<a:buClr>${createColorElement(bullet.color)}</a:buClr>`;
3188
3700
  // `a:buSzPct` and `a:buSzPts` are the same choice, so only one may appear
3189
3701
  if (typeof bullet.sizePts === 'number' && isFinite(bullet.sizePts) && bullet.sizePts > 0) {
3190
- xml += `<a:buSzPts val="${Math.round(bullet.sizePts * 100)}"/>`;
3702
+ xml += `<a:buSzPts val="${fontSizeToSz(bullet.sizePts)}"/>`;
3191
3703
  } else {
3192
3704
  const pct = typeof bullet.size === 'number' && isFinite(bullet.size) ? Math.min(400, Math.max(25, bullet.size)) : 100;
3193
3705
  if (typeof bullet.size === 'number' && (bullet.size < 25 || bullet.size > 400)) {
@@ -3198,6 +3710,20 @@ function text_object_spread_props(target, source) {
3198
3710
  if (bullet.fontFace) xml += `<a:buFont typeface="${encodeXmlEntities(bullet.fontFace)}"/>`;
3199
3711
  return xml;
3200
3712
  }
3713
+ /**
3714
+ * Compute `marL` and hanging `indent` attributes for a bulleted paragraph (`a:pPr`).
3715
+ * When `bullet.hangingIndentRatio` is provided, `bullet.indent` acts as the base left margin
3716
+ * (`before text` indent) and the hanging indent is `round(marL * hangingIndentRatio)`.
3717
+ */ function genXmlBulletMarginIndent(options) {
3718
+ const bullet = typeof options.bullet === 'object' ? options.bullet : {};
3719
+ const bulletMarL = valToPts(bullet.indent || (/* inlined export .DEF_BULLET_MARGIN */27));
3720
+ const indentLevel = options.indentLevel && options.indentLevel > 0 ? options.indentLevel : 0;
3721
+ if (typeof bullet.hangingIndentRatio === 'number' && Number.isFinite(bullet.hangingIndentRatio) && bullet.hangingIndentRatio > 0) {
3722
+ const hangingIndent = Math.round(bulletMarL * bullet.hangingIndentRatio);
3723
+ return ` marL="${bulletMarL * (indentLevel || 1)}" indent="-${hangingIndent}"`;
3724
+ }
3725
+ return ` marL="${indentLevel > 0 ? bulletMarL + bulletMarL * indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
3726
+ }
3201
3727
  /**
3202
3728
  * Generate XML Paragraph Properties
3203
3729
  * @param {ISlideObject|TextProps} textObj - text object
@@ -3210,7 +3736,6 @@ function text_object_spread_props(target, source) {
3210
3736
  let strXmlParaSpc = '';
3211
3737
  let strXmlTabStops = '';
3212
3738
  const tag = isDefault ? 'a:lvl1pPr' : 'a:pPr';
3213
- let bulletMarL = valToPts((/* inlined export .DEF_BULLET_MARGIN */27));
3214
3739
  const options = (_textObj_options = textObj.options) !== null && _textObj_options !== void 0 ? _textObj_options : {};
3215
3740
  let paragraphPropXml = `<${tag}${options.rtlMode ? ' rtl="1" ' : ''}`;
3216
3741
  // A: Build paragraphProperties
@@ -3235,10 +3760,12 @@ function text_object_spread_props(target, source) {
3235
3760
  break;
3236
3761
  }
3237
3762
  }
3763
+ // `a:spcPts` is ST_TextSpacingPoint (0..158400, i.e. 0..1584pt) and `a:spcPct` is
3764
+ // ST_TextSpacingPercent (0..13200000) - out-of-range spacing is a schema violation
3238
3765
  if (options.lineSpacing) {
3239
- strXmlLnSpc = `<a:lnSpc><a:spcPts val="${Math.round(options.lineSpacing * 100)}"/></a:lnSpc>`;
3766
+ strXmlLnSpc = `<a:lnSpc><a:spcPts val="${clampInt(options.lineSpacing * 100, 0, 158400)}"/></a:lnSpc>`;
3240
3767
  } else if (options.lineSpacingMultiple) {
3241
- strXmlLnSpc = `<a:lnSpc><a:spcPct val="${Math.round(options.lineSpacingMultiple * 100000)}"/></a:lnSpc>`;
3768
+ strXmlLnSpc = `<a:lnSpc><a:spcPct val="${clampInt(options.lineSpacingMultiple * 100000, 0, 13200000)}"/></a:lnSpc>`;
3242
3769
  }
3243
3770
  // OPTION: indent
3244
3771
  if (options.indentLevel && !isNaN(Number(options.indentLevel)) && options.indentLevel > 0) {
@@ -3261,28 +3788,28 @@ function text_object_spread_props(target, source) {
3261
3788
  if (para.hangingPunct === false) paragraphPropXml += ' hangingPunct="0"';
3262
3789
  // OPTION: Paragraph Spacing: Before/After
3263
3790
  if (options.paraSpaceBefore && !isNaN(Number(options.paraSpaceBefore)) && options.paraSpaceBefore > 0) {
3264
- strXmlParaSpc += `<a:spcBef><a:spcPts val="${Math.round(options.paraSpaceBefore * 100)}"/></a:spcBef>`;
3791
+ strXmlParaSpc += `<a:spcBef><a:spcPts val="${clampInt(options.paraSpaceBefore * 100, 0, 158400)}"/></a:spcBef>`;
3265
3792
  }
3266
3793
  if (options.paraSpaceAfter && !isNaN(Number(options.paraSpaceAfter)) && options.paraSpaceAfter > 0) {
3267
- strXmlParaSpc += `<a:spcAft><a:spcPts val="${Math.round(options.paraSpaceAfter * 100)}"/></a:spcAft>`;
3794
+ strXmlParaSpc += `<a:spcAft><a:spcPts val="${clampInt(options.paraSpaceAfter * 100, 0, 158400)}"/></a:spcAft>`;
3268
3795
  }
3269
3796
  // OPTION: bullet
3270
3797
  // NOTE: OOXML uses the unicode character set for Bullets
3271
3798
  // EX: Unicode Character 'BULLET' (U+2022) ==> '<a:buChar char="&#x2022;"/>'
3272
3799
  if (typeof options.bullet === 'object') {
3273
- var _options_bullet;
3274
- if ((_options_bullet = options.bullet) === null || _options_bullet === void 0 ? void 0 : _options_bullet.indent) bulletMarL = valToPts(options.bullet.indent);
3275
3800
  const buPrefix = genXmlBulletPrefix(options.bullet);
3276
- const buIndent = ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
3801
+ const buIndent = genXmlBulletMarginIndent(options);
3277
3802
  if (options.bullet.image && options.bullet._imageRId) {
3278
3803
  // `a:buBlip` replaces the character or number bullet entirely
3279
3804
  paragraphPropXml += buIndent;
3280
3805
  strXmlBullet = `${buPrefix}<a:buBlip><a:blip r:embed="rId${options.bullet._imageRId}"/></a:buBlip>`;
3281
3806
  } else if (options.bullet.type && options.bullet.type.toString().toLowerCase() === 'number') {
3807
+ var _ref, _options_bullet_numberStartAt;
3282
3808
  // NOTE: only `type: 'number'` is a distinct branch; any other `type` (e.g. 'bullet') falls through to the char-bullet cases below (issue #1432)
3283
3809
  paragraphPropXml += buIndent;
3284
3810
  // auto-numbered bullets fall back to the major latin face when none is given
3285
- 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'}"/>`;
3811
+ 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
3812
+ 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)}"/>`;
3286
3813
  } else if (options.bullet.characterCode) {
3287
3814
  let bulletCode = `&#x${options.bullet.characterCode};`;
3288
3815
  // Check value for hex-ness (s/b 4 char hex)
@@ -3307,7 +3834,7 @@ function text_object_spread_props(target, source) {
3307
3834
  strXmlBullet = `${buPrefix}<a:buChar char="${(/* inlined export .BULLET_TYPES.DEFAULT */"&#x2022;")}"/>`;
3308
3835
  }
3309
3836
  } else if (options.bullet) {
3310
- paragraphPropXml += ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
3837
+ paragraphPropXml += genXmlBulletMarginIndent(options);
3311
3838
  strXmlBullet = `<a:buSzPct val="100000"/><a:buChar char="${(/* inlined export .BULLET_TYPES.DEFAULT */"&#x2022;")}"/>`;
3312
3839
  } else if (!options.bullet) {
3313
3840
  // We only add this when the user explicitely asks for no bullet, otherwise, it can override the master defaults!
@@ -3338,9 +3865,11 @@ function text_object_spread_props(target, source) {
3338
3865
  const runPropsTag = isDefault ? 'a:defRPr' : 'a:rPr';
3339
3866
  // BEGIN runProperties (ex: `<a:rPr lang="en-US" sz="1600" b="1" dirty="0">`)
3340
3867
  runProps += '<' + runPropsTag + ' lang="' + (opts.lang ? opts.lang : 'en-US') + '"' + (opts.lang ? ' altLang="en-US"' : '');
3341
- runProps += opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : ''; // NOTE: Use round so sizes like '7.5' wont cause corrupt presentations
3342
- runProps += (opts === null || opts === void 0 ? void 0 : opts.bold) ? ` b="${opts.bold ? '1' : '0'}"` : '';
3343
- runProps += (opts === null || opts === void 0 ? void 0 : opts.italic) ? ` i="${opts.italic ? '1' : '0'}"` : '';
3868
+ runProps += opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '';
3869
+ if ((opts === null || opts === void 0 ? void 0 : opts.bold) === false) runProps += ' b="0"';
3870
+ else if (opts === null || opts === void 0 ? void 0 : opts.bold) runProps += ' b="1"';
3871
+ if ((opts === null || opts === void 0 ? void 0 : opts.italic) === false) runProps += ' i="0"';
3872
+ else if (opts === null || opts === void 0 ? void 0 : opts.italic) runProps += ' i="1"';
3344
3873
  if ((opts === null || opts === void 0 ? void 0 : opts.strike) === true) warnDeprecatedOnce('strike-boolean', '`strike: true` is deprecated - use `strike: "sngStrike"` (or `"dblStrike"`)');
3345
3874
  runProps += (opts === null || opts === void 0 ? void 0 : opts.strike) ? ` strike="${typeof opts.strike === 'string' ? opts.strike : 'sngStrike'}"` : '';
3346
3875
  if (typeof opts.underline === 'object' && ((_opts_underline = opts.underline) === null || _opts_underline === void 0 ? void 0 : _opts_underline.style)) {
@@ -3374,7 +3903,7 @@ function text_object_spread_props(target, source) {
3374
3903
  // CT_TextCharacterProperties child order: ln, fill, effect, highlight, uLn, uFill, latin, ea, cs, sym
3375
3904
  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) {
3376
3905
  if (opts.outline && typeof opts.outline === 'object') {
3377
- runProps += `<a:ln w="${valToPts(opts.outline.size || 0.75)}">${genXmlColorSelection({
3906
+ runProps += `<a:ln w="${valToLineWidth(opts.outline.size || 0.75)}">${genXmlColorSelection({
3378
3907
  color: opts.outline.color || 'FFFFFF',
3379
3908
  transparency: opts.outline.transparency
3380
3909
  })}</a:ln>`;
@@ -3391,7 +3920,11 @@ function text_object_spread_props(target, source) {
3391
3920
  });
3392
3921
  const resolvedGlow = resolveGlowOptions(opts.glow);
3393
3922
  if (resolvedGlow) runProps += `<a:effectLst>${createGlowElement(resolvedGlow)}</a:effectLst>`;
3394
- if (opts.highlight) runProps += `<a:highlight>${createColorElement(opts.highlight)}</a:highlight>`;
3923
+ if (opts.highlight) {
3924
+ const highlightColor = typeof opts.highlight === 'string' ? opts.highlight : opts.highlight.color;
3925
+ const highlightAlpha = typeof opts.highlight === 'object' && opts.highlight.transparency ? `<a:alpha val="${clampAlphaPct(opts.highlight.transparency)}"/>` : '';
3926
+ runProps += `<a:highlight>${createColorElement(highlightColor, highlightAlpha)}</a:highlight>`;
3927
+ }
3395
3928
  if (run.underlineLine === 'text') runProps += '<a:uLnTx/>';
3396
3929
  else if (run.underlineLine && typeof run.underlineLine === 'object') runProps += genXmlLine(run.underlineLine, 'a:uLn');
3397
3930
  if (typeof opts.underline === 'object' && opts.underline.color) runProps += `<a:uFill>${genXmlColorSelection(opts.underline.color)}</a:uFill>`;
@@ -3799,7 +4332,7 @@ function genXmlTextRun(textObj) {
3799
4332
  // `glow` / softEdge / reflection belong on the shape effectLst (not per-run), unless set on the run itself
3800
4333
  // `omml` is a run-level math payload — inheriting it would replace sibling plain-text runs
3801
4334
  if (key === 'glow' || key === 'softEdge' || key === 'reflection' || key === 'shadow' || key === 'blur' || key === 'fillOverlay' || key === 'effectDag' || key === 'omml') return;
3802
- if (key !== 'bullet' && !textOpts[key]) textOpts[key] = val;
4335
+ if (key !== 'bullet' && textOpts[key] === undefined) textOpts[key] = val;
3803
4336
  });
3804
4337
  // D: Add formatted textrun
3805
4338
  strSlideXml += genXmlTextRun(textObj);
@@ -3816,17 +4349,17 @@ function genXmlTextRun(textObj) {
3816
4349
  const ea = opts.fontFaceEa || opts.fontFace;
3817
4350
  const cs = opts.fontFaceCs || opts.fontFace;
3818
4351
  if (latin || ea || cs) {
3819
- strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : '') + ' dirty="0">';
4352
+ strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0">';
3820
4353
  if (latin) strSlideXml += `<a:latin typeface="${encodeXmlEntities(latin)}" charset="0"/>`;
3821
4354
  if (ea) strSlideXml += `<a:ea typeface="${encodeXmlEntities(ea)}" charset="0"/>`;
3822
4355
  if (cs) strSlideXml += `<a:cs typeface="${encodeXmlEntities(cs)}" charset="0"/>`;
3823
4356
  strSlideXml += '</a:endParaRPr>';
3824
4357
  } else {
3825
- strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : '') + ' dirty="0"/>';
4358
+ strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0"/>';
3826
4359
  }
3827
4360
  } else if (reqsClosingFontSize) {
3828
4361
  // Empty [lineBreak] lines should not contain runProp, however, they need to specify fontSize in `endParaRPr`
3829
- strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : '') + ' dirty="0"/>';
4362
+ strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0"/>';
3830
4363
  } else {
3831
4364
  strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}" dirty="0"/>`; // Added 20180101 to address PPT-2007 issues
3832
4365
  }
@@ -4142,6 +4675,20 @@ function _object_without_properties_loose(source, excluded) {
4142
4675
 
4143
4676
 
4144
4677
 
4678
+
4679
+ function normalizeExtn(extn) {
4680
+ if (!extn || typeof extn !== 'string') return '';
4681
+ return extn.trim().replace(/^\./, '').toLowerCase();
4682
+ }
4683
+ function extractPathExtn(rawPath) {
4684
+ if (!rawPath) return 'png';
4685
+ const cleanPath = rawPath.split('?')[0].split('#')[0];
4686
+ const fileName = cleanPath.substring(Math.max(cleanPath.lastIndexOf('/'), cleanPath.lastIndexOf('\\')) + 1);
4687
+ const dotIdx = fileName.lastIndexOf('.');
4688
+ if (dotIdx <= 0 || dotIdx === fileName.length - 1) return 'png';
4689
+ const candidate = fileName.substring(dotIdx + 1).toLowerCase();
4690
+ return /^[a-z0-9]{1,8}$/.test(candidate) ? candidate : 'png';
4691
+ }
4145
4692
  /** 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));
4146
4693
  /** Type guard: true when `arr` is a flat (1-level) array rather than a nested one. */ function isFlatStringArray(arr) {
4147
4694
  return Array.isArray(arr) && (arr.length === 0 || !Array.isArray(arr[0]));
@@ -4479,10 +5026,11 @@ function _object_without_properties_loose(source, excluded) {
4479
5026
  const v3DPerspective = options.v3DPerspective;
4480
5027
  options.v3DPerspective = v3DPerspective !== undefined && !isNaN(v3DPerspective) && v3DPerspective >= 0 && v3DPerspective <= 240 ? v3DPerspective : 30;
4481
5028
  // D: Options: chart
5029
+ // `c:gapWidth`/`c:gapDepth` are ST_GapAmount (0..500); clamp finite values to 0..500
4482
5030
  const barGapWidthPct = options.barGapWidthPct;
4483
- options.barGapWidthPct = barGapWidthPct !== undefined && !isNaN(barGapWidthPct) && barGapWidthPct >= 0 && barGapWidthPct <= 1000 ? barGapWidthPct : 150;
5031
+ options.barGapWidthPct = typeof barGapWidthPct === 'number' && Number.isFinite(barGapWidthPct) ? clampInt(barGapWidthPct, 0, 500) : 150;
4484
5032
  const barGapDepthPct = options.barGapDepthPct;
4485
- options.barGapDepthPct = barGapDepthPct !== undefined && !isNaN(barGapDepthPct) && barGapDepthPct >= 0 && barGapDepthPct <= 1000 ? barGapDepthPct : 150;
5033
+ options.barGapDepthPct = typeof barGapDepthPct === 'number' && Number.isFinite(barGapDepthPct) ? clampInt(barGapDepthPct, 0, 500) : 150;
4486
5034
  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;
4487
5035
  options.chartColorsOpacity = options.chartColorsOpacity && !isNaN(options.chartColorsOpacity) ? options.chartColorsOpacity : undefined;
4488
5036
  // DEPRECATED: v3.11.0 - use `plotArea.border` vvv
@@ -4694,14 +5242,14 @@ function isSvgFillSource(data, path) {
4694
5242
  });
4695
5243
  return svgRid;
4696
5244
  }
4697
- let extn = (path.split('?')[0].split('#')[0].split('.').pop() || 'png').toLowerCase();
5245
+ let extn = extractPathExtn(path);
4698
5246
  const mime = data ? /image\/([\w+]+);/.exec(data) : null;
4699
- if (mime === null || mime === void 0 ? void 0 : mime[1]) extn = mime[1] === 'svg+xml' ? 'svg' : mime[1];
5247
+ if (mime === null || mime === void 0 ? void 0 : mime[1]) extn = mime[1].toLowerCase() === 'svg+xml' ? 'svg' : mime[1].toLowerCase();
4700
5248
  if (extn === 'jpg') extn = 'jpeg';
4701
5249
  const imgType = 'image/' + extn;
4702
5250
  const dupeItem = target._relsMedia.filter((item)=>item.type === imgType && !item.isDuplicate && !item.isSvgPng && (path && item.path === path || data && item.data && item.data === data))[0];
4703
5251
  const rId = getNewRelId(target);
4704
- target._relsMedia.push({
5252
+ const mediaRel = {
4705
5253
  path: path || 'preencoded.' + extn,
4706
5254
  type: imgType,
4707
5255
  extn,
@@ -4709,7 +5257,9 @@ function isSvgFillSource(data, path) {
4709
5257
  rId,
4710
5258
  isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
4711
5259
  Target: (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/${imageTargetStem(target)}.${extn}`
4712
- });
5260
+ };
5261
+ dedupeImageMediaRel(target, mediaRel);
5262
+ target._relsMedia.push(mediaRel);
4713
5263
  return rId;
4714
5264
  }
4715
5265
  function isStructuredImageFill(fill) {
@@ -4749,7 +5299,7 @@ function resolveObjectImageFills(target, options) {
4749
5299
  if ((_options_fillOverlay = options.fillOverlay) === null || _options_fillOverlay === void 0 ? void 0 : _options_fillOverlay.fill) resolveImageFill(target, options.fillOverlay.fill);
4750
5300
  }
4751
5301
  function addImageDefinition(target, opt) {
4752
- var _opt_fillOverlay, _strImagePath_substring_split__split_pop;
5302
+ var _opt_fillOverlay;
4753
5303
  if ((_opt_fillOverlay = opt.fillOverlay) === null || _opt_fillOverlay === void 0 ? void 0 : _opt_fillOverlay.fill) resolveImageFill(target, opt.fillOverlay.fill);
4754
5304
  const newObject = {
4755
5305
  _type: (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"),
@@ -4785,14 +5335,17 @@ function addImageDefinition(target, opt) {
4785
5335
  return;
4786
5336
  }
4787
5337
  // STEP 1: Set extension
4788
- // NOTE: Split to address URLs with params (eg: `path/brent.jpg?someParam=true`)
4789
- 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();
5338
+ // Honor explicit `opt.extn` (for extensionless signed CDN URLs); otherwise parse from path safely.
5339
+ const explicitExtn = normalizeExtn(opt.extn);
5340
+ let strImgExtn = explicitExtn || extractPathExtn(strImagePath);
4790
5341
  // However, pre-encoded images can be whatever mime-type they want (and good for them!)
4791
- const strImageMimeMatch = strImageData ? /image\/(\w+);/.exec(strImageData) : null;
4792
- if (strImageMimeMatch && strImageMimeMatch.length > 0) {
4793
- strImgExtn = strImageMimeMatch[1];
4794
- } else if (strImageData === null || strImageData === void 0 ? void 0 : strImageData.toLowerCase().includes('image/svg+xml')) {
4795
- strImgExtn = 'svg';
5342
+ if (!explicitExtn) {
5343
+ const strImageMimeMatch = strImageData ? /image\/(\w+);/.exec(strImageData) : null;
5344
+ if (strImageMimeMatch && strImageMimeMatch.length > 0) {
5345
+ strImgExtn = strImageMimeMatch[1].toLowerCase();
5346
+ } else if (strImageData === null || strImageData === void 0 ? void 0 : strImageData.toLowerCase().includes('image/svg+xml')) {
5347
+ strImgExtn = 'svg';
5348
+ }
4796
5349
  }
4797
5350
  // STEP 2: Set type/path
4798
5351
  newObject._type = (/* inlined export .SLIDE_OBJECT_TYPES.image */"image");
@@ -4884,10 +5437,10 @@ function addImageDefinition(target, opt) {
4884
5437
  } else {
4885
5438
  // PERF: Duplicate media should reuse existing `Target` value and not create an additional copy.
4886
5439
  // OPC (ECMA-376 Part 2) lets many relationships point at one part, so identical image bytes are stored once.
4887
- // Match on the source path when given, else on identical base64 `data` (issue #1339) - same content, one media file.
4888
- const imgType = 'image/' + strImgExtn;
5440
+ // Match on the source path within slide, and across the entire deck on identical base64 content hash.
5441
+ const imgType = strImgExtn === 'jpg' ? 'image/jpeg' : 'image/' + strImgExtn;
4889
5442
  const dupeItem = target._relsMedia.filter((item)=>item.type === imgType && !item.isDuplicate && !item.isSvgPng && (strImagePath && item.path === strImagePath || strImageData && item.data && item.data === strImageData))[0];
4890
- target._relsMedia.push({
5443
+ const mediaRel = {
4891
5444
  path: strImagePath || 'preencoded.' + strImgExtn,
4892
5445
  type: imgType,
4893
5446
  extn: strImgExtn,
@@ -4895,7 +5448,9 @@ function addImageDefinition(target, opt) {
4895
5448
  rId: imageRelId,
4896
5449
  isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
4897
5450
  Target: (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/${imageTargetStem(target)}.${strImgExtn}`
4898
- });
5451
+ };
5452
+ dedupeImageMediaRel(target, mediaRel);
5453
+ target._relsMedia.push(mediaRel);
4899
5454
  newObject.imageRid = imageRelId;
4900
5455
  }
4901
5456
  // STEP 5: Hyperlink support
@@ -5430,8 +5985,10 @@ function nextExtPartName(target, prefix, extn) {
5430
5985
  bullet._imageRId = rId;
5431
5986
  }
5432
5987
  function addShapeDefinition(target, shapeName, opts) {
5988
+ var _options_styleRef;
5433
5989
  const options = typeof opts === 'object' ? opts : {};
5434
- options.line = options.line || {
5990
+ // With a theme `lnRef` and no explicit line, omit `<a:ln>` so the stroke inherits from the theme (matches `styleRef.fill` in slide.ts)
5991
+ if (!options.line && !((_options_styleRef = options.styleRef) === null || _options_styleRef === void 0 ? void 0 : _options_styleRef.line)) options.line = {
5435
5992
  type: 'none'
5436
5993
  };
5437
5994
  resolveHyperlinkRels(target, options.hyperlink);
@@ -5452,28 +6009,29 @@ function addShapeDefinition(target, shapeName, opts) {
5452
6009
  throw new Error(`Invalid shape "${shapeName}" - use a \`pptxgen.ShapeType\` value (ex: \`pptxgen.ShapeType.oval\` = 'ellipse')`);
5453
6010
  }
5454
6011
  // 1: ShapeLineProps defaults
5455
- const hasConnectorEnds = options.line.sourceId != null || options.line.targetId != null;
5456
- const newLineOpts = gen_objects_object_spread_props(gen_objects_object_spread({}, options.line), {
5457
- type: options.line.type || (options.line.gradient ? 'gradient' : 'solid'),
5458
- color: options.line.color || (/* inlined export .DEF_SHAPE_LINE_COLOR */"333333"),
5459
- transparency: options.line.transparency || 0,
5460
- gradient: options.line.gradient,
5461
- width: options.line.width || 1,
5462
- dashType: options.line.dashType || 'solid',
5463
- cap: options.line.cap,
5464
- beginArrowType: options.line.beginArrowType || undefined,
5465
- endArrowType: options.line.endArrowType || undefined,
6012
+ const lineSrc = typeof options.line === 'object' && options.line !== null ? options.line : {};
6013
+ const hasConnectorEnds = lineSrc.sourceId != null || lineSrc.targetId != null;
6014
+ const newLineOpts = gen_objects_object_spread_props(gen_objects_object_spread({}, lineSrc), {
6015
+ type: lineSrc.type || (lineSrc.gradient ? 'gradient' : 'solid'),
6016
+ color: lineSrc.color || (/* inlined export .DEF_SHAPE_LINE_COLOR */"333333"),
6017
+ transparency: lineSrc.transparency || 0,
6018
+ gradient: lineSrc.gradient,
6019
+ width: lineSrc.width || 1,
6020
+ dashType: lineSrc.dashType || 'solid',
6021
+ cap: lineSrc.cap,
6022
+ beginArrowType: lineSrc.beginArrowType || undefined,
6023
+ endArrowType: lineSrc.endArrowType || undefined,
5466
6024
  // ZentoSoft connectors
5467
- sourceId: options.line.sourceId,
5468
- targetId: options.line.targetId,
5469
- sourceAnchorPos: options.line.sourceAnchorPos,
5470
- targetAnchorPos: options.line.targetAnchorPos,
5471
- isConnector: options.line.isConnector || hasConnectorEnds,
5472
- curveadjust: options.line.curveadjust,
5473
- _sourceName: options.line._sourceName,
5474
- _targetName: options.line._targetName
6025
+ sourceId: lineSrc.sourceId,
6026
+ targetId: lineSrc.targetId,
6027
+ sourceAnchorPos: lineSrc.sourceAnchorPos,
6028
+ targetAnchorPos: lineSrc.targetAnchorPos,
6029
+ isConnector: lineSrc.isConnector || hasConnectorEnds,
6030
+ curveadjust: lineSrc.curveadjust,
6031
+ _sourceName: lineSrc._sourceName,
6032
+ _targetName: lineSrc._targetName
5475
6033
  });
5476
- if (typeof options.line === 'object' && options.line.type !== 'none') options.line = newLineOpts;
6034
+ if (typeof options.line === 'object' && options.line !== null && options.line.type !== 'none') options.line = newLineOpts;
5477
6035
  // 2: Set options defaults
5478
6036
  const shapeOpts = options;
5479
6037
  shapeOpts._explicitX = options.x !== undefined && options.x !== null;
@@ -5502,11 +6060,35 @@ function addShapeDefinition(target, shapeName, opts) {
5502
6060
  * @param {Function} addSlide - method
5503
6061
  * @param {Function} getSlide - method
5504
6062
  */ function addTableDefinition(target, tableRows, options, slideLayout, presLayout, addSlide, getSlide) {
6063
+ var _ref;
6064
+ var _target__slideLayout;
5505
6065
  const slides = [
5506
6066
  target
5507
6067
  ] // Create array of Slides as more may be added by auto-paging
5508
6068
  ;
5509
- const opt = options && typeof options === 'object' ? gen_objects_object_spread({}, options) : {};
6069
+ let opt = options && typeof options === 'object' ? gen_objects_object_spread({}, options) : {};
6070
+ const explicitX = opt.x !== undefined && opt.x !== null;
6071
+ const explicitY = opt.y !== undefined && opt.y !== null;
6072
+ const explicitW = opt.w !== undefined && opt.w !== null;
6073
+ const explicitH = opt.h !== undefined && opt.h !== null;
6074
+ // PR #1151: resolve layout placeholder defaults under caller options so caller overrides placeholder defaults
6075
+ 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;
6076
+ if (opt.placeholder && layoutObjs) {
6077
+ const placeHold = layoutObjs.find((item)=>{
6078
+ var _item_options;
6079
+ 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;
6080
+ });
6081
+ if (placeHold === null || placeHold === void 0 ? void 0 : placeHold.options) {
6082
+ const _placeHold_options = placeHold.options, { _bodyProp: _bp, line: _ln, objectName: _on, sId: _sId, shape: _sh } = _placeHold_options, placeHoldOpts = _object_without_properties(_placeHold_options, [
6083
+ "_bodyProp",
6084
+ "line",
6085
+ "objectName",
6086
+ "sId",
6087
+ "shape"
6088
+ ]);
6089
+ opt = gen_objects_object_spread({}, placeHoldOpts, opt);
6090
+ }
6091
+ }
5510
6092
  opt.objectName = opt.objectName ? encodeXmlEntities(opt.objectName) : `Table ${target._slideObjects.filter((obj)=>obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.table */"table")).length}`;
5511
6093
  // STEP 1: REALITY-CHECK
5512
6094
  {
@@ -5535,21 +6117,40 @@ function addShapeDefinition(target, shapeName, opts) {
5535
6117
  if (Array.isArray(row)) {
5536
6118
  row.forEach((cell)=>{
5537
6119
  var _newCell_options;
5538
- // A:
6120
+ // A: Clone cell options so caller-supplied objects are never mutated (PR #1553)
5539
6121
  const newCell = {
5540
6122
  _type: (/* inlined export .SLIDE_OBJECT_TYPES.tablecell */"tablecell"),
5541
6123
  text: '',
5542
- options: typeof cell === 'object' && cell.options ? cell.options : {}
6124
+ options: typeof cell === 'object' && cell !== null && cell.options && typeof cell.options === 'object' ? gen_objects_object_spread({}, cell.options) : {}
5543
6125
  };
5544
6126
  // B:
5545
6127
  if (typeof cell === 'string' || typeof cell === 'number') newCell.text = cell.toString();
5546
- else if (cell.text) {
6128
+ else if (cell && typeof cell === 'object' && cell.text !== undefined && cell.text !== null) {
5547
6129
  // Cell can contain complex text type, or string, or number
5548
6130
  if (typeof cell.text === 'string' || typeof cell.text === 'number') newCell.text = cell.text.toString();
5549
- else if (cell.text) newCell.text = cell.text;
5550
- // Capture options
5551
- if (cell.options && typeof cell.options === 'object') newCell.options = cell.options;
6131
+ else if (Array.isArray(cell.text)) {
6132
+ var _newCell_options1;
6133
+ // Clone runs and their options so caller objects are never mutated; inherit lang without overwriting explicit run lang
6134
+ const inheritedLang = ((_newCell_options1 = newCell.options) === null || _newCell_options1 === void 0 ? void 0 : _newCell_options1.lang) || opt.lang;
6135
+ newCell.text = cell.text.map((run)=>{
6136
+ if (!run || typeof run !== 'object') return run;
6137
+ const runOpts = run.options && typeof run.options === 'object' ? gen_objects_object_spread({}, run.options) : undefined;
6138
+ if (inheritedLang && !(runOpts === null || runOpts === void 0 ? void 0 : runOpts.lang)) {
6139
+ return gen_objects_object_spread_props(gen_objects_object_spread({}, run), {
6140
+ options: gen_objects_object_spread_props(gen_objects_object_spread({}, runOpts), {
6141
+ lang: inheritedLang
6142
+ })
6143
+ });
6144
+ }
6145
+ return gen_objects_object_spread_props(gen_objects_object_spread({}, run), {
6146
+ options: runOpts
6147
+ });
6148
+ });
6149
+ } else {
6150
+ newCell.text = cell.text;
6151
+ }
5552
6152
  }
6153
+ if (opt.lang && newCell.options && !newCell.options.lang) newCell.options.lang = opt.lang;
5553
6154
  // C: Set cell borders
5554
6155
  const cellOpts = (_newCell_options = newCell.options) !== null && _newCell_options !== void 0 ? _newCell_options : {};
5555
6156
  newCell.options = cellOpts;
@@ -5568,12 +6169,15 @@ function addShapeDefinition(target, shapeName, opts) {
5568
6169
  }
5569
6170
  ];
5570
6171
  // CASE 1: border interface is: BorderOptions | [BorderOptions, BorderOptions, BorderOptions, BorderOptions]
6172
+ // Defensively shallow-copy caller border arrays so we never mutate them in place (PR #1541)
5571
6173
  const cellBorder = !Array.isArray(initialBorder) && typeof initialBorder === 'object' ? [
5572
6174
  initialBorder,
5573
6175
  initialBorder,
5574
6176
  initialBorder,
5575
6177
  initialBorder
5576
- ] : initialBorder;
6178
+ ] : [
6179
+ ...initialBorder
6180
+ ];
5577
6181
  cellOpts.border = cellBorder;
5578
6182
  // Handle: [null, null, {type:'solid'}, null]
5579
6183
  if (!cellBorder[0]) cellBorder[0] = {
@@ -5622,10 +6226,10 @@ function addShapeDefinition(target, shapeName, opts) {
5622
6226
  });
5623
6227
  // STEP 3: Set options
5624
6228
  const tableOpts = opt;
5625
- tableOpts._explicitX = opt.x !== undefined && opt.x !== null;
5626
- tableOpts._explicitY = opt.y !== undefined && opt.y !== null;
5627
- tableOpts._explicitW = opt.w !== undefined && opt.w !== null;
5628
- tableOpts._explicitH = opt.h !== undefined && opt.h !== null;
6229
+ tableOpts._explicitX = explicitX;
6230
+ tableOpts._explicitY = explicitY;
6231
+ tableOpts._explicitW = explicitW;
6232
+ tableOpts._explicitH = explicitH;
5629
6233
  opt.x = getSmartParseNumber(opt.x || (opt.x === 0 ? 0 : (/* inlined export .EMU */914400) / 2), 'X', presLayout);
5630
6234
  opt.y = getSmartParseNumber(opt.y || (opt.y === 0 ? 0 : (/* inlined export .EMU */914400) / 2), 'Y', presLayout);
5631
6235
  if (opt.h) opt.h = getSmartParseNumber(opt.h, 'Y', presLayout); // NOTE: Dont set default `h` - leaving it null triggers auto-rowH in `makeXMLSlide()`
@@ -5647,7 +6251,9 @@ function addShapeDefinition(target, shapeName, opts) {
5647
6251
  console.warn('addTable `border` option must be an object. Ex: `{border: {type:\'none\'}}`');
5648
6252
  opt.border = undefined;
5649
6253
  } else if (Array.isArray(opt.border)) {
5650
- const optBorder = opt.border;
6254
+ const optBorder = [
6255
+ ...opt.border
6256
+ ];
5651
6257
  [
5652
6258
  0,
5653
6259
  1,
@@ -5664,6 +6270,7 @@ function addShapeDefinition(target, shapeName, opts) {
5664
6270
  type: 'none'
5665
6271
  };
5666
6272
  });
6273
+ opt.border = optBorder;
5667
6274
  }
5668
6275
  opt.autoPage = typeof opt.autoPage === 'boolean' ? opt.autoPage : false;
5669
6276
  opt.autoPageRepeatHeader = typeof opt.autoPageRepeatHeader === 'boolean' ? opt.autoPageRepeatHeader : false;
@@ -6010,21 +6617,29 @@ function addShapeDefinition(target, shapeName, opts) {
6010
6617
  // B: Handle media
6011
6618
  if (props && (props.path || props.data)) {
6012
6619
  // Allow the use of only the data key (`path` isnt reqd)
6013
- props.path = props.path || 'preencoded.png';
6014
- let strImgExtn = (props.path.split('.').pop() || 'png').split('?')[0] // Handle "blah.jpg?width=540" etc.
6015
- ;
6016
- 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
6620
+ const explicitExtn = normalizeExtn(props.extn);
6621
+ props.path = props.path || `preencoded.${explicitExtn || 'png'}`;
6622
+ let strImgExtn = explicitExtn || extractPathExtn(props.path);
6623
+ if (!explicitExtn && props.data) {
6624
+ const bkgdMimeMatch = /image\/([\w+]+);/.exec(props.data);
6625
+ if (bkgdMimeMatch === null || bkgdMimeMatch === void 0 ? void 0 : bkgdMimeMatch[1]) {
6626
+ strImgExtn = bkgdMimeMatch[1].toLowerCase() === 'svg+xml' ? 'svg' : bkgdMimeMatch[1].toLowerCase();
6627
+ }
6628
+ }
6629
+ 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
6017
6630
  target._relsMedia = target._relsMedia || [];
6018
6631
  const intRels = target._relsMedia.length + 1;
6019
6632
  // NOTE: `Target` cannot have spaces (eg:"Slide 1-image-1.jpg") or a "presentation is corrupt" warning comes up
6020
- target._relsMedia.push({
6633
+ const bkgdRel = {
6021
6634
  path: props.path,
6022
6635
  type: (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"),
6023
6636
  extn: strImgExtn,
6024
6637
  data: props.data || undefined,
6025
6638
  rId: intRels,
6026
6639
  Target: `../media/${(target._name || '').replace(/\s+/gi, '-')}-image-${target._relsMedia.length + 1}.${strImgExtn}`
6027
- });
6640
+ };
6641
+ dedupeImageMediaRel(target, bkgdRel);
6642
+ target._relsMedia.push(bkgdRel);
6028
6643
  target._bkgdImgRid = intRels;
6029
6644
  }
6030
6645
  }
@@ -6041,8 +6656,14 @@ function addShapeDefinition(target, shapeName, opts) {
6041
6656
  text
6042
6657
  ];
6043
6658
  textObjs.forEach((text, idx)=>{
6044
- // IMPORTANT: `options` are lost due to recursion/copy!
6045
- if (!Array.isArray(text) && options && options[idx] && options[idx].hyperlink) text.options = gen_objects_object_spread({}, text.options, options[idx]);
6659
+ // IMPORTANT: `options` are lost due to recursion/copy! Preserve explicit run `lang` over cell `lang` (PR #1553).
6660
+ if (!Array.isArray(text) && options && options[idx] && options[idx].hyperlink) {
6661
+ var _text_options;
6662
+ const preservedLang = ((_text_options = text.options) === null || _text_options === void 0 ? void 0 : _text_options.lang) || options[idx].lang;
6663
+ text.options = gen_objects_object_spread({}, text.options, options[idx], preservedLang ? {
6664
+ lang: preservedLang
6665
+ } : {});
6666
+ }
6046
6667
  // NOTE: `text` can be an array of other `text` objects (table cell word-level formatting), continue parsing using recursion
6047
6668
  if (Array.isArray(text)) {
6048
6669
  const cellOpts = [];
@@ -6709,11 +7330,11 @@ function createShadowElement(shadow) {
6709
7330
  }
6710
7331
  let strXml = '<a:effectLst>';
6711
7332
  const type = shadow.type;
6712
- const blur = valToPts(shadow.blur);
6713
- const offset = valToPts(shadow.offset);
7333
+ const blur = Math.max(0, valToPts(shadow.blur));
7334
+ const offset = Math.max(0, valToPts(shadow.offset));
6714
7335
  const angle = Math.round(shadow.angle * 60000);
6715
7336
  const color = shadow.color;
6716
- const opacity = Math.round(shadow.opacity * 100000);
7337
+ const opacity = clampAlphaPct(100 - shadow.opacity * 100);
6717
7338
  const rotShape = shadow.rotateWithShape ? 1 : 0;
6718
7339
  strXml += `<a:${type}Shdw sx="100000" sy="100000" kx="0" ky="0" algn="bl" blurRad="${blur}" rotWithShape="${rotShape}" dist="${offset}" dir="${angle}">`;
6719
7340
  strXml += `<a:srgbClr val="${color}">`;
@@ -6729,7 +7350,7 @@ function createShadowElement(shadow) {
6729
7350
  */ function createGridLineElement(glOpts) {
6730
7351
  let strXml = '<c:majorGridlines>';
6731
7352
  strXml += ' <c:spPr>';
6732
- strXml += ` <a:ln w="${valToPts(glOpts.size || DEF_CHART_GRIDLINE.size)}" cap="${createLineCap(glOpts.cap || DEF_CHART_GRIDLINE.cap)}">`;
7353
+ strXml += ` <a:ln w="${valToLineWidth(glOpts.size || DEF_CHART_GRIDLINE.size)}" cap="${createLineCap(glOpts.cap || DEF_CHART_GRIDLINE.cap)}">`;
6733
7354
  strXml += ` <a:solidFill>${createColorElement(glOpts.color || DEF_CHART_GRIDLINE.color)}</a:solidFill>`;
6734
7355
  strXml += ' <a:prstDash val="' + (glOpts.style || DEF_CHART_GRIDLINE.style) + '"/><a:round/>';
6735
7356
  strXml += ' </a:ln>';
@@ -6767,7 +7388,7 @@ function createLineCap(lineCap) {
6767
7388
  if (chartDash && CHART_LINE_DASH_TYPES.includes(chartDash)) return chartDash;
6768
7389
  return 'solid';
6769
7390
  }
6770
- /** Area charts use `c:grouping` / ST_Grouping (standard|stacked|percentStacked), not ST_BarGrouping. */ const AREA_GROUPING = [
7391
+ /** Area and line charts use `c:grouping` / ST_Grouping (standard|stacked|percentStacked), not ST_BarGrouping. */ const AREA_GROUPING = [
6771
7392
  'standard',
6772
7393
  'stacked',
6773
7394
  'percentStacked'
@@ -6845,7 +7466,7 @@ function firstLabelLevel(data) {
6845
7466
  // `outEnd` is invalid on the layouts that draw labels inside their segments
6846
7467
  const defaultPos = chartType === 'treemap' || chartType === 'sunburst' || chartType === 'funnel' ? 'ctr' : 'outEnd';
6847
7468
  const pos = (_opts_dataLabelPosition = opts.dataLabelPosition) !== null && _opts_dataLabelPosition !== void 0 ? _opts_dataLabelPosition : defaultPos;
6848
- const size = Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100);
7469
+ const size = fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12));
6849
7470
  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>';
6850
7471
  const numFmt = opts.dataLabelFormatCode ? `<cx:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode)}" sourceLinked="0"/>` : '';
6851
7472
  return `<cx:dataLabels pos="${pos}">` + `<cx:visibility seriesName="0" categoryName="${showCategory ? 1 : 0}" value="${showValue ? 1 : 0}"/>` + numFmt + txPr + '</cx:dataLabels>';
@@ -6908,7 +7529,7 @@ function firstLabelLevel(data) {
6908
7529
  }
6909
7530
  function makeTitle(opts) {
6910
7531
  if (!opts.showTitle) return '';
6911
- const size = Math.round((opts.titleFontSize || (/* inlined export .DEF_FONT_TITLE_SIZE */18)) * 100);
7532
+ const size = fontSizeToSz(opts.titleFontSize || (/* inlined export .DEF_FONT_TITLE_SIZE */18));
6912
7533
  const color = opts.titleColor ? `<a:solidFill>${createColorElement(opts.titleColor)}</a:solidFill>` : '';
6913
7534
  const face = opts.titleFontFace ? `<a:latin typeface="${encodeXmlEntities(opts.titleFontFace)}"/>` : '';
6914
7535
  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>';
@@ -7027,7 +7648,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7027
7648
  const align = opts.titleAlign === 'left' || opts.titleAlign === 'right' ? `<a:pPr algn="${opts.titleAlign.substring(0, 1)}">` : '<a:pPr>';
7028
7649
  const rotate = opts.titleRotate ? `<a:bodyPr rot="${convertRotationDegrees(opts.titleRotate)}"/>` : '<a:bodyPr/>' // don't specify rotation to get default (ex. vertical for cat axis)
7029
7650
  ;
7030
- const sizeAttr = opts.fontSize ? `sz="${Math.round(opts.fontSize * 100)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
7651
+ const sizeAttr = opts.fontSize ? `sz="${fontSizeToSz(opts.fontSize)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
7031
7652
  ;
7032
7653
  const titleBold = opts.titleBold ? 1 : 0;
7033
7654
  const titleItalic = opts.titleItalic ? 1 : 0;
@@ -7134,7 +7755,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7134
7755
  strXml += ' <c:tickLblPos val="' + (opts.catAxisLabelPos || (opts.barDir === 'col' ? 'low' : 'nextTo')) + '"/>';
7135
7756
  }
7136
7757
  strXml += ' <c:spPr>';
7137
- strXml += ` <a:ln w="${opts.catAxisLineSize ? valToPts(opts.catAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7758
+ strXml += ` <a:ln w="${opts.catAxisLineSize ? valToLineWidth(opts.catAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7138
7759
  strXml += !opts.catAxisLineShow ? '<a:noFill/>' : '<a:solidFill>' + createColorElement(opts.catAxisLineColor || DEF_CHART_GRIDLINE.color) + '</a:solidFill>';
7139
7760
  strXml += ' <a:prstDash val="' + (opts.catAxisLineStyle || 'solid') + '"/>';
7140
7761
  strXml += ' <a:round/>';
@@ -7150,7 +7771,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7150
7771
  strXml += ' <a:lstStyle/>';
7151
7772
  strXml += ' <a:p>';
7152
7773
  strXml += ' <a:pPr>';
7153
- 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">`;
7774
+ 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">`;
7154
7775
  strXml += ' <a:solidFill>' + createColorElement(opts.catAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
7155
7776
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.catAxisLabelFontFace) || 'Arial') + '"/>';
7156
7777
  strXml += ' <a:ea typeface="' + (encodeXmlEntities(opts.catAxisLabelFontFace) || 'Arial') + '"/>';
@@ -7244,7 +7865,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7244
7865
  strXml += ' <c:tickLblPos val="' + (opts.valAxisLabelPos || (opts.barDir === 'col' ? 'nextTo' : 'low')) + '"/>';
7245
7866
  }
7246
7867
  strXml += ' <c:spPr>';
7247
- strXml += ` <a:ln w="${opts.valAxisLineSize ? valToPts(opts.valAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7868
+ strXml += ` <a:ln w="${opts.valAxisLineSize ? valToLineWidth(opts.valAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7248
7869
  strXml += !opts.valAxisLineShow ? '<a:noFill/>' : '<a:solidFill>' + createColorElement(opts.valAxisLineColor || DEF_CHART_GRIDLINE.color) + '</a:solidFill>';
7249
7870
  strXml += ' <a:prstDash val="' + (opts.valAxisLineStyle || 'solid') + '"/>';
7250
7871
  strXml += ' <a:round/>';
@@ -7255,7 +7876,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7255
7876
  strXml += ' <a:lstStyle/>';
7256
7877
  strXml += ' <a:p>';
7257
7878
  strXml += ' <a:pPr>';
7258
- 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">`;
7879
+ 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">`;
7259
7880
  strXml += ' <a:solidFill>' + createColorElement(opts.valAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
7260
7881
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.valAxisLabelFontFace) || 'Arial') + '"/>';
7261
7882
  strXml += ' <a:ea typeface="' + (encodeXmlEntities(opts.valAxisLabelFontFace) || 'Arial') + '"/>';
@@ -7327,7 +7948,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7327
7948
  strXml += ' <a:lstStyle/>';
7328
7949
  strXml += ' <a:p>';
7329
7950
  strXml += ' <a:pPr>';
7330
- 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">`;
7951
+ 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">`;
7331
7952
  strXml += ` <a:solidFill>${createColorElement(opts.serAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
7332
7953
  strXml += ` <a:latin typeface="${encodeXmlEntities(opts.serAxisLabelFontFace) || 'Arial'}"/>`;
7333
7954
  strXml += ` <a:ea typeface="${encodeXmlEntities(opts.serAxisLabelFontFace) || 'Arial'}"/>`;
@@ -7429,6 +8050,7 @@ function xml_object_spread_props(target, source) {
7429
8050
  * @param {ISlideRelChart} rel - chart object
7430
8051
  * @return {string} XML
7431
8052
  */ function makeXmlCharts(rel) {
8053
+ var _ref;
7432
8054
  var _rel_opts_chartArea, _rel_opts_chartArea1, _rel_opts_chartArea_border, _rel_opts_chartArea2, _rel_opts_chartArea_border1, _rel_opts_chartArea3;
7433
8055
  let strXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
7434
8056
  let usesSecondaryValAxis = false;
@@ -7461,7 +8083,8 @@ function xml_object_spread_props(target, source) {
7461
8083
  /** Add 3D view tag
7462
8084
  * @see: https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_perspective_topic_ID0E6BUQB.html
7463
8085
  */ if (rel.opts._type === core_enums_CHART_TYPE.BAR3D) {
7464
- 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>`;
8086
+ var _rel_opts_v3DRotX, _rel_opts_v3DRotY, _rel_opts_v3DPerspective;
8087
+ 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>`;
7465
8088
  }
7466
8089
  strXml += '<c:plotArea>';
7467
8090
  // IMPORTANT: Dont specify layout to enable auto-fit: PPT does a great job maximizing space with all 4 TRBL locations
@@ -7482,9 +8105,21 @@ function xml_object_spread_props(target, source) {
7482
8105
  }
7483
8106
  }
7484
8107
  // A: Create Chart XML -----------------------------------------------------------
8108
+ const hiddenLegendIndices = [];
7485
8109
  if (Array.isArray(rel.opts._type)) {
8110
+ let seriesIdx = 0;
7486
8111
  rel.opts._type.forEach((type)=>{
7487
8112
  var _options_secondaryValAxis;
8113
+ if (Array.isArray(type.data)) {
8114
+ var _type_options;
8115
+ const hideSubchartLegend = ((_type_options = type.options) === null || _type_options === void 0 ? void 0 : _type_options.showLegend) === false;
8116
+ type.data.forEach((obj)=>{
8117
+ var _obj__dataIndex;
8118
+ const idx = (_obj__dataIndex = obj._dataIndex) !== null && _obj__dataIndex !== void 0 ? _obj__dataIndex : seriesIdx;
8119
+ if (hideSubchartLegend) hiddenLegendIndices.push(idx);
8120
+ seriesIdx++;
8121
+ });
8122
+ }
7488
8123
  const options = xml_object_spread({}, rel.opts, type.options);
7489
8124
  if (options.dataLabelPosition) {
7490
8125
  options.dataLabelPosition = resolveDataLabelPosition(options.dataLabelPosition, type.type, options.barGrouping);
@@ -7541,6 +8176,7 @@ function xml_object_spread_props(target, source) {
7541
8176
  }
7542
8177
  // C: Chart Properties and plotArea Options: Border, Data Table, Fill, Legend
7543
8178
  {
8179
+ var _ref1;
7544
8180
  var _rel_opts_plotArea, _rel_opts_plotArea1, _rel_opts_plotArea_border, _rel_opts_plotArea2, _rel_opts_plotArea_border1, _rel_opts_plotArea3;
7545
8181
  // NOTE: DataTable goes between '</c:valAx>' and '<c:spPr>'
7546
8182
  if (rel.opts.showDataTable) {
@@ -7559,7 +8195,7 @@ function xml_object_spread_props(target, source) {
7559
8195
  strXml += ' <a:lstStyle/>';
7560
8196
  strXml += ' <a:p>';
7561
8197
  strXml += ' <a:pPr rtl="0">';
7562
- 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">`;
8198
+ 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">`;
7563
8199
  strXml += ' <a:solidFill><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></a:solidFill>';
7564
8200
  strXml += ' <a:latin typeface="+mn-lt"/>';
7565
8201
  strXml += ' <a:ea typeface="+mn-ea"/>';
@@ -7575,7 +8211,7 @@ function xml_object_spread_props(target, source) {
7575
8211
  // OPTION: Fill
7576
8212
  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/>';
7577
8213
  // OPTION: Border
7578
- 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>';
8214
+ 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>';
7579
8215
  // Close shapeProp/plotArea before Legend
7580
8216
  strXml += ' <a:effectLst/>';
7581
8217
  strXml += ' </c:spPr>';
@@ -7585,7 +8221,27 @@ function xml_object_spread_props(target, source) {
7585
8221
  if (rel.opts.showLegend) {
7586
8222
  strXml += '<c:legend>';
7587
8223
  strXml += '<c:legendPos val="' + rel.opts.legendPos + '"/>';
7588
- // strXml += '<c:layout/>'
8224
+ // ECMA-376 CT_Legend sequence: legendPos -> legendEntry* -> layout -> overlay -> spPr -> txPr
8225
+ hiddenLegendIndices.forEach((idx)=>{
8226
+ strXml += `<c:legendEntry><c:idx val="${idx}"/><c:delete val="1"/></c:legendEntry>`;
8227
+ });
8228
+ if (rel.opts.legendLayout) {
8229
+ const { x, y, w, h } = rel.opts.legendLayout;
8230
+ const hasX = typeof x === 'number' && Number.isFinite(x);
8231
+ const hasY = typeof y === 'number' && Number.isFinite(y);
8232
+ const hasW = typeof w === 'number' && Number.isFinite(w);
8233
+ const hasH = typeof h === 'number' && Number.isFinite(h);
8234
+ if (hasX || hasY || hasW || hasH) {
8235
+ strXml += '<c:layout><c:manualLayout>';
8236
+ if (hasX) strXml += '<c:xMode val="edge"/>';
8237
+ if (hasY) strXml += '<c:yMode val="edge"/>';
8238
+ if (hasX) strXml += `<c:x val="${x}"/>`;
8239
+ if (hasY) strXml += `<c:y val="${y}"/>`;
8240
+ if (hasW) strXml += `<c:w val="${w}"/>`;
8241
+ if (hasH) strXml += `<c:h val="${h}"/>`;
8242
+ strXml += '</c:manualLayout></c:layout>';
8243
+ }
8244
+ }
7589
8245
  strXml += '<c:overlay val="0"/>';
7590
8246
  if (rel.opts.legendFontFace || rel.opts.legendFontSize || rel.opts.legendColor) {
7591
8247
  strXml += '<c:txPr>';
@@ -7593,7 +8249,7 @@ function xml_object_spread_props(target, source) {
7593
8249
  strXml += ' <a:lstStyle/>';
7594
8250
  strXml += ' <a:p>';
7595
8251
  strXml += ' <a:pPr>';
7596
- strXml += rel.opts.legendFontSize ? `<a:defRPr sz="${Math.round(Number(rel.opts.legendFontSize) * 100)}">` : '<a:defRPr>';
8252
+ strXml += rel.opts.legendFontSize ? `<a:defRPr sz="${fontSizeToSz(Number(rel.opts.legendFontSize))}">` : '<a:defRPr>';
7597
8253
  if (rel.opts.legendColor) strXml += genXmlColorSelection(rel.opts.legendColor);
7598
8254
  if (rel.opts.legendFontFace) strXml += '<a:latin typeface="' + encodeXmlEntities(rel.opts.legendFontFace) + '"/>';
7599
8255
  if (rel.opts.legendFontFace) strXml += '<a:ea typeface="' + encodeXmlEntities(rel.opts.legendFontFace) + '"/>';
@@ -7614,7 +8270,7 @@ function xml_object_spread_props(target, source) {
7614
8270
  // D: CHARTSPACE SHAPE PROPS
7615
8271
  strXml += '<c:spPr>';
7616
8272
  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/>';
7617
- 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>';
8273
+ 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>';
7618
8274
  strXml += ' <a:effectLst/>';
7619
8275
  strXml += '</c:spPr>';
7620
8276
  // E: DATA (Add relID)
@@ -7640,13 +8296,13 @@ function xml_object_spread_props(target, source) {
7640
8296
  * (`standards/ecma/part-23_drawingml-reference-material-drawingml-charts.txt`).
7641
8297
  * An empty `<a:defRPr/>` drops dataLabelFont* on scatter labels (gitbrent #1348).
7642
8298
  */ function genXmlDataLabelDefRPr(opts) {
7643
- 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>';
8299
+ 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>';
7644
8300
  }
7645
8301
  /**
7646
8302
  * Rich-text body for a custom chart data label (`c:tx` / `c:rich`).
7647
8303
  * Escapes text and applies data-label font options.
7648
8304
  */ function genXmlDataLabelRichText(text, opts) {
7649
- const sz = Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100);
8305
+ const sz = fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12));
7650
8306
  const lang = opts.lang || 'en-US';
7651
8307
  let xml = '<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r>';
7652
8308
  xml += `<a:rPr lang="${lang}" dirty="0" sz="${sz}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}">`;
@@ -7716,9 +8372,9 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7716
8372
  case core_enums_CHART_TYPE.RADAR:
7717
8373
  // 1: Start Chart
7718
8374
  strXml += `<c:${chartType}Chart>`;
7719
- // Area charts: `c:grouping` / ST_Grouping (ECMA-376 §5.7.2.76 / §5.7.3.17).
8375
+ // Area and line charts: `c:grouping` / ST_Grouping (ECMA-376 §5.7.2.76 / §5.7.2.97 / §5.7.3.17).
7720
8376
  // `barGrouping` is the public option name; the element is not `c:barGrouping` (that is ST_BarGrouping on bar charts).
7721
- if (chartType === core_enums_CHART_TYPE.AREA) {
8377
+ if (chartType === core_enums_CHART_TYPE.AREA || chartType === core_enums_CHART_TYPE.LINE) {
7722
8378
  strXml += '<c:grouping val="' + resolveAreaGrouping(opts.barGrouping) + '"/>';
7723
8379
  }
7724
8380
  if (chartType === core_enums_CHART_TYPE.BAR || chartType === core_enums_CHART_TYPE.BAR3D) {
@@ -7784,7 +8440,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7784
8440
  if (seriesColor === 'transparent') {
7785
8441
  strXml += '<a:noFill/>';
7786
8442
  } else if (opts.chartColorsOpacity) {
7787
- strXml += '<a:solidFill>' + createColorElement(seriesColor, `<a:alpha val="${Math.round(opts.chartColorsOpacity * 1000)}"/>`) + '</a:solidFill>';
8443
+ strXml += '<a:solidFill>' + createColorElement(seriesColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`) + '</a:solidFill>';
7788
8444
  } else {
7789
8445
  strXml += '<a:solidFill>' + createColorElement(seriesColor) + '</a:solidFill>';
7790
8446
  }
@@ -7792,11 +8448,13 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7792
8448
  if (opts.lineSize === 0) {
7793
8449
  strXml += '<a:ln><a:noFill/></a:ln>';
7794
8450
  } else {
7795
- strXml += `<a:ln w="${valToPts(opts.lineSize)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(seriesColor)}</a:solidFill>`;
8451
+ var _opts_lineSize;
8452
+ 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>`;
7796
8453
  strXml += '<a:prstDash val="' + resolveSeriesLineDash(obj.lineDash, opts.lineDash) + '"/><a:round/></a:ln>';
7797
8454
  }
7798
8455
  } else if (opts.dataBorder) {
7799
- 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>`;
8456
+ var _opts_dataBorder_pt;
8457
+ 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>`;
7800
8458
  }
7801
8459
  strXml += createShadowElement(resolveShadowOptions(opts.shadow));
7802
8460
  strXml += ' </c:spPr>';
@@ -7812,7 +8470,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7812
8470
  strXml += `<c:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode) || 'General'}" sourceLinked="0"/>`;
7813
8471
  if (opts.dataLabelBkgrdColors) strXml += `<c:spPr><a:solidFill>${createColorElement(seriesColor)}</a:solidFill></c:spPr>`;
7814
8472
  strXml += '<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>';
7815
- 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">`;
8473
+ 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">`;
7816
8474
  strXml += `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
7817
8475
  strXml += `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
7818
8476
  strXml += '</a:defRPr></a:pPr></a:p></c:txPr>';
@@ -7827,9 +8485,10 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7827
8485
  }
7828
8486
  // 'c:marker' tag: `lineDataSymbol`
7829
8487
  if (chartType === core_enums_CHART_TYPE.LINE || chartType === core_enums_CHART_TYPE.RADAR) {
8488
+ var _opts_lineDataSymbolLineSize;
7830
8489
  strXml += '<c:marker>';
7831
8490
  strXml += ' <c:symbol val="' + opts.lineDataSymbol + '"/>';
7832
- if (opts.lineDataSymbolSize) strXml += `<c:size val="${opts.lineDataSymbolSize}"/>`; // Defaults to "auto" otherwise (but this is usually too small, so there is a default)
8491
+ 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)
7833
8492
  strXml += ' <c:spPr>';
7834
8493
  // NateRadebaugh/transparent-markers: `'transparent'` → noFill (same as series fill)
7835
8494
  {
@@ -7837,7 +8496,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7837
8496
  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];
7838
8497
  strXml += markerColor === 'transparent' ? ' <a:noFill/>' : ` <a:solidFill>${createColorElement(markerColor)}</a:solidFill>`;
7839
8498
  }
7840
- strXml += ` <a:ln w="${opts.lineDataSymbolLineSize}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || seriesColor)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8499
+ 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>`;
7841
8500
  strXml += ' <a:effectLst/>';
7842
8501
  strXml += ' </c:spPr>';
7843
8502
  strXml += '</c:marker>';
@@ -7948,7 +8607,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7948
8607
  strXml += ' <a:bodyPr/>';
7949
8608
  strXml += ' <a:lstStyle/>';
7950
8609
  strXml += ' <a:p><a:pPr>';
7951
- 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">`;
8610
+ 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">`;
7952
8611
  strXml += ' <a:solidFill>' + createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
7953
8612
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.dataLabelFontFace) || 'Arial') + '"/>';
7954
8613
  strXml += ' </a:defRPr>';
@@ -7966,16 +8625,18 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7966
8625
  }
7967
8626
  // 4: Add more chart options (gapWidth, line Marker, etc.)
7968
8627
  if (chartType === core_enums_CHART_TYPE.BAR) {
7969
- strXml += ` <c:gapWidth val="${opts.barGapWidthPct}"/>`;
8628
+ var _opts_barGapWidthPct;
8629
+ strXml += ` <c:gapWidth val="${clampInt((_opts_barGapWidthPct = opts.barGapWidthPct) !== null && _opts_barGapWidthPct !== void 0 ? _opts_barGapWidthPct : 150, 0, 500)}"/>`;
7970
8630
  // istevkovski/prioritize-overlap: honor barOverlapPct even when grouping is stacked
7971
8631
  // (also treat 0 as explicit — upstream used a truthy check that skipped 0)
7972
8632
  {
7973
- const overlap = typeof opts.barOverlapPct === 'number' ? opts.barOverlapPct : (opts.barGrouping || '').includes('tacked') ? 100 : 0;
8633
+ const overlap = typeof opts.barOverlapPct === 'number' ? clampInt(opts.barOverlapPct, -100, 100) : (opts.barGrouping || '').includes('tacked') ? 100 : 0;
7974
8634
  strXml += ` <c:overlap val="${overlap}"/>`;
7975
8635
  }
7976
8636
  } else if (chartType === core_enums_CHART_TYPE.BAR3D) {
7977
- strXml += ` <c:gapWidth val="${opts.barGapWidthPct}"/>`;
7978
- strXml += ` <c:gapDepth val="${opts.barGapDepthPct}"/>`;
8637
+ var _opts_barGapWidthPct1, _opts_barGapDepthPct;
8638
+ strXml += ` <c:gapWidth val="${clampInt((_opts_barGapWidthPct1 = opts.barGapWidthPct) !== null && _opts_barGapWidthPct1 !== void 0 ? _opts_barGapWidthPct1 : 150, 0, 500)}"/>`;
8639
+ strXml += ` <c:gapDepth val="${clampInt((_opts_barGapDepthPct = opts.barGapDepthPct) !== null && _opts_barGapDepthPct !== void 0 ? _opts_barGapDepthPct : 150, 0, 500)}"/>`;
7979
8640
  strXml += ' <c:shape val="' + opts.bar3DShape + '"/>';
7980
8641
  } else if (chartType === core_enums_CHART_TYPE.LINE) {
7981
8642
  strXml += ' <c:marker val="1"/>';
@@ -8021,14 +8682,15 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8021
8682
  if (tmpSerColor === 'transparent') {
8022
8683
  strXml += '<a:noFill/>';
8023
8684
  } else if (opts.chartColorsOpacity) {
8024
- strXml += '<a:solidFill>' + createColorElement(tmpSerColor, '<a:alpha val="' + Math.round(opts.chartColorsOpacity * 1000).toString() + '"/>') + '</a:solidFill>';
8685
+ strXml += '<a:solidFill>' + createColorElement(tmpSerColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`) + '</a:solidFill>';
8025
8686
  } else {
8026
8687
  strXml += '<a:solidFill>' + createColorElement(tmpSerColor) + '</a:solidFill>';
8027
8688
  }
8028
8689
  if (opts.lineSize === 0) {
8029
8690
  strXml += '<a:ln><a:noFill/></a:ln>';
8030
8691
  } else {
8031
- strXml += `<a:ln w="${valToPts(opts.lineSize)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
8692
+ var _opts_lineSize;
8693
+ 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>`;
8032
8694
  strXml += `<a:prstDash val="${resolveSeriesLineDash(obj.lineDash, opts.lineDash)}"/><a:round/></a:ln>`;
8033
8695
  }
8034
8696
  // Shadow
@@ -8037,11 +8699,12 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8037
8699
  strXml += ' </c:spPr>';
8038
8700
  // 'c:marker' tag: `lineDataSymbol`
8039
8701
  {
8702
+ var _opts_lineDataSymbolLineSize;
8040
8703
  strXml += '<c:marker>';
8041
8704
  strXml += ' <c:symbol val="' + opts.lineDataSymbol + '"/>';
8042
8705
  if (opts.lineDataSymbolSize) {
8043
8706
  // Defaults to "auto" otherwise (but this is usually too small, so there is a default)
8044
- strXml += `<c:size val="${opts.lineDataSymbolSize}"/>`;
8707
+ strXml += `<c:size val="${clampInt(opts.lineDataSymbolSize, 2, 72)}"/>`;
8045
8708
  }
8046
8709
  strXml += '<c:spPr>';
8047
8710
  // NateRadebaugh/transparent-markers: `'transparent'` → noFill (same as series fill)
@@ -8050,7 +8713,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8050
8713
  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];
8051
8714
  strXml += markerColor === 'transparent' ? '<a:noFill/>' : `<a:solidFill>${createColorElement(markerColor)}</a:solidFill>`;
8052
8715
  }
8053
- 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>`;
8716
+ 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>`;
8054
8717
  strXml += '<a:effectLst/>';
8055
8718
  strXml += '</c:spPr>';
8056
8719
  strXml += '</c:marker>';
@@ -8239,7 +8902,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8239
8902
  strXml += ' <a:bodyPr/>';
8240
8903
  strXml += ' <a:lstStyle/>';
8241
8904
  strXml += ' <a:p><a:pPr>';
8242
- 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">`;
8905
+ 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">`;
8243
8906
  strXml += ' <a:solidFill>' + createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
8244
8907
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.dataLabelFontFace) || 'Arial') + '"/>';
8245
8908
  strXml += ' </a:defRPr>';
@@ -8295,16 +8958,18 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8295
8958
  if (tmpSerColor === 'transparent') {
8296
8959
  strXml += '<a:noFill/>';
8297
8960
  } else if (opts.chartColorsOpacity) {
8298
- strXml += `<a:solidFill>${createColorElement(tmpSerColor, '<a:alpha val="' + Math.round(opts.chartColorsOpacity * 1000).toString() + '"/>')}</a:solidFill>`;
8961
+ strXml += `<a:solidFill>${createColorElement(tmpSerColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`)}</a:solidFill>`;
8299
8962
  } else {
8300
8963
  strXml += '<a:solidFill>' + createColorElement(tmpSerColor) + '</a:solidFill>';
8301
8964
  }
8302
8965
  if (opts.lineSize === 0) {
8303
8966
  strXml += '<a:ln><a:noFill/></a:ln>';
8304
8967
  } else if (opts.dataBorder) {
8305
- 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>`;
8968
+ var _opts_dataBorder_pt;
8969
+ 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>`;
8306
8970
  } else {
8307
- strXml += `<a:ln w="${valToPts(opts.lineSize)}" cap="flat"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
8971
+ var _opts_lineSize;
8972
+ 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>`;
8308
8973
  strXml += `<a:prstDash val="${resolveSeriesLineDash(obj.lineDash, opts.lineDash)}"/><a:round/></a:ln>`;
8309
8974
  }
8310
8975
  // Shadow
@@ -8367,7 +9032,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8367
9032
  strXml += '<c:dLbls>';
8368
9033
  strXml += `<c:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode) || 'General'}" sourceLinked="0"/>`;
8369
9034
  strXml += '<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>';
8370
- 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">`;
9035
+ 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">`;
8371
9036
  strXml += `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
8372
9037
  strXml += `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
8373
9038
  strXml += '</a:defRPr></a:pPr></a:p></c:txPr>';
@@ -8394,7 +9059,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8394
9059
  case core_enums_CHART_TYPE.DOUGHNUT:
8395
9060
  case core_enums_CHART_TYPE.PIE:
8396
9061
  {
8397
- var _optsChartData_labels, _optsChartData_values, _opts_dataLabelPosition;
9062
+ var _optsChartData_labels, _optsChartData_values, _opts_dataLabelPosition, _opts_firstSliceAng;
8398
9063
  const optsChartData = data[0];
8399
9064
  // NOTE: chart data arrays are always populated at render time; guarded locals keep this null-safe without changing output
8400
9065
  const chartDataLabels = (_optsChartData_labels = optsChartData.labels) !== null && _optsChartData_labels !== void 0 ? _optsChartData_labels : [];
@@ -8431,7 +9096,9 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8431
9096
  strXml += createShadowElement(resolveShadowOptions(opts.shadow));
8432
9097
  }
8433
9098
  strXml += ' </c:spPr>';
8434
- // strXml += '<c:explosion val="0"/>'
9099
+ if (typeof opts.chartPieExplosion === 'number' && Number.isFinite(opts.chartPieExplosion) && opts.chartPieExplosion > 0) {
9100
+ strXml += `<c:explosion val="${clampInt(opts.chartPieExplosion, 0, 1000)}"/>`;
9101
+ }
8435
9102
  // 2: "Data Point" block for every data row
8436
9103
  chartDataLabels[0].forEach((_label, idx)=>{
8437
9104
  strXml += '<c:dPt>';
@@ -8440,7 +9107,8 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8440
9107
  strXml += ' <c:spPr>';
8441
9108
  strXml += `<a:solidFill>${createColorElement(chartColors[idx + 1 > chartColors.length ? Math.floor(Math.random() * chartColors.length) : idx])}</a:solidFill>`;
8442
9109
  if (opts.dataBorder) {
8443
- 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>`;
9110
+ var _opts_dataBorder_pt;
9111
+ 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>`;
8444
9112
  }
8445
9113
  strXml += createShadowElement(resolveShadowOptions(opts.shadow));
8446
9114
  strXml += ' </c:spPr>';
@@ -8455,7 +9123,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8455
9123
  strXml += ' <a:lstStyle/>';
8456
9124
  strXml += ' <a:p>';
8457
9125
  strXml += ' <a:pPr>';
8458
- 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">`;
9126
+ 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">`;
8459
9127
  strXml += ` <a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill><a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
8460
9128
  strXml += ' </a:defRPr>';
8461
9129
  strXml += ' </a:pPr>';
@@ -8497,8 +9165,8 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8497
9165
  strXml += ' </c:val>';
8498
9166
  // 4: Close "SERIES"
8499
9167
  strXml += ' </c:ser>';
8500
- strXml += ` <c:firstSliceAng val="${opts.firstSliceAng ? Math.round(opts.firstSliceAng) : 0}"/>`;
8501
- if (chartType === core_enums_CHART_TYPE.DOUGHNUT) strXml += `<c:holeSize val="${typeof opts.holeSize === 'number' ? opts.holeSize : '50'}"/>`;
9168
+ strXml += ` <c:firstSliceAng val="${clampInt((_opts_firstSliceAng = opts.firstSliceAng) !== null && _opts_firstSliceAng !== void 0 ? _opts_firstSliceAng : 0, 0, 360)}"/>`;
9169
+ if (chartType === core_enums_CHART_TYPE.DOUGHNUT) strXml += `<c:holeSize val="${clampInt(typeof opts.holeSize === 'number' ? opts.holeSize : 50, 1, 90)}"/>`;
8502
9170
  strXml += '</c:' + chartType + 'Chart>';
8503
9171
  break;
8504
9172
  }
@@ -8509,7 +9177,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8509
9177
  return strXml;
8510
9178
  }
8511
9179
 
8512
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
9180
+ function workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8513
9181
  try {
8514
9182
  var info = gen[key](arg);
8515
9183
  var value = info.value;
@@ -8520,16 +9188,16 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8520
9188
  if (info.done) resolve(value);
8521
9189
  else Promise.resolve(value).then(_next, _throw);
8522
9190
  }
8523
- function _async_to_generator(fn) {
9191
+ function workbook_async_to_generator(fn) {
8524
9192
  return function() {
8525
9193
  var self = this, args = arguments;
8526
9194
  return new Promise(function(resolve, reject) {
8527
9195
  var gen = fn.apply(self, args);
8528
9196
  function _next(value) {
8529
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
9197
+ workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8530
9198
  }
8531
9199
  function _throw(err) {
8532
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
9200
+ workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8533
9201
  }
8534
9202
  _next(undefined);
8535
9203
  });
@@ -8568,7 +9236,7 @@ function makeNumberStyles(formats) {
8568
9236
  * @param {JSZip} zip - file that the resulting XLSX should be added to
8569
9237
  * @return {Promise} promise of generating the XLSX file
8570
9238
  */ function createExcelWorksheet(chartObject, zip) {
8571
- return _async_to_generator(function*() {
9239
+ return workbook_async_to_generator(function*() {
8572
9240
  const zipExcel = new JSZip();
8573
9241
  const dataTableStyles = getDataTableStyles(chartObject);
8574
9242
  addCoreWorkbookFiles(zipExcel, dataTableStyles.customFormats);
@@ -16991,181 +17659,30 @@ function convert_to_eot_object_spread(target) {
16991
17659
  ttfObject = otf2ttfobject(fontBuffer, opts);
16992
17660
  } else if (type === 'woff') {
16993
17661
  if (typeof opts.inflate !== 'function') {
16994
- throw new Error('WOFF conversion requires options.inflate (pako)');
16995
- }
16996
- const ttfBuffer = woff2ttf(fontBuffer, opts);
16997
- ttfObject = new TTFReader(opts).read(ttfBuffer);
16998
- } else {
16999
- throw new Error(`Unsupported font type for EOT conversion: ${String(type)}`);
17000
- }
17001
- const ttfBuffer = new TTFWriter(opts).write(ttfObject);
17002
- return ttf2eot(ttfBuffer, opts);
17003
- }
17004
-
17005
- /**
17006
- * PptxGenJS: Opt-in embedded TrueType fonts (OOXML `ppt/fonts/*.fntdata`)
17007
- *
17008
- * `embedFontsIntoZip` is a no-op when `fonts` is empty — default export never
17009
- * writes Font parts, fntdata content types, or Presentation font relationships.
17010
- * Callers supply their own font bytes via `addFont` and must have a license
17011
- * that permits embedding those files. This library ships no font files.
17012
- *
17013
- * Font-embed orchestration absorbed from MIT `pptx-embed-fonts`
17014
- * (https://github.com/liyao1520/pptx-embed-fonts). TTF/OTF/WOFF→EOT conversion is a
17015
- * vendored subset of MIT `fonteditor-core` under `src/vendor/fonteditor-core`
17016
- * (https://github.com/kekee000/fonteditor-core). WOFF inflate uses pako 3.
17017
- */ function gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17018
- try {
17019
- var info = gen[key](arg);
17020
- var value = info.value;
17021
- } catch (error) {
17022
- reject(error);
17023
- return;
17024
- }
17025
- if (info.done) resolve(value);
17026
- else Promise.resolve(value).then(_next, _throw);
17027
- }
17028
- function gen_fonts_async_to_generator(fn) {
17029
- return function() {
17030
- var self = this, args = arguments;
17031
- return new Promise(function(resolve, reject) {
17032
- var gen = fn.apply(self, args);
17033
- function _next(value) {
17034
- gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
17035
- }
17036
- function _throw(err) {
17037
- gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
17038
- }
17039
- _next(undefined);
17040
- });
17041
- };
17042
- }
17043
-
17044
-
17045
- /** High rId base so font relationships do not collide with slide/master rIds */ const FONT_RID_START = 201314;
17046
- const FONT_REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/font';
17047
- /**
17048
- * Convert TTF / OTF / WOFF bytes to EOT (Office `fntdata` payload).
17049
- * Lazy-loads pako only for WOFF.
17050
- */ function fontToEot(type, fontBuffer) {
17051
- return gen_fonts_async_to_generator(function*() {
17052
- const options = {
17053
- hinting: true
17054
- };
17055
- if (type === 'woff') {
17056
- // pako 3: named exports only; InflateInput is Uint8Array | ArrayBuffer (not number[])
17057
- const { inflate } = yield import("pako");
17058
- options.inflate = (deflatedData)=>Array.from(inflate(Uint8Array.from(deflatedData)));
17059
- }
17060
- return convertToEot(type, fontBuffer, options);
17061
- })();
17062
- }
17063
- function toFntdata(fontType, fontFile) {
17064
- return gen_fonts_async_to_generator(function*() {
17065
- switch(fontType){
17066
- case 'eot':
17067
- // EOT bytes are stored as-is under ppt/fonts/*.fntdata
17068
- return fontFile;
17069
- case 'ttf':
17070
- case 'otf':
17071
- case 'woff':
17072
- return yield fontToEot(fontType, fontFile);
17073
- default:
17074
- throw new Error(`Invalid font type "${String(fontType)}" - use ttf | otf | woff | eot`);
17075
- }
17076
- })();
17077
- }
17078
- function ensureFntdataContentType(contentTypesXml) {
17079
- if (/Extension="fntdata"/i.test(contentTypesXml)) return contentTypesXml;
17080
- const entry = '<Default Extension="fntdata" ContentType="application/x-fontdata"/>';
17081
- // Prefer inserting among other Defaults near the top of <Types>
17082
- if (/<Default\b/i.test(contentTypesXml)) {
17083
- return contentTypesXml.replace(/<Default\b/i, `${entry}<Default`);
17084
- }
17085
- return contentTypesXml.replace(/<Types([^>]*)>/i, `<Types$1>${entry}`);
17086
- }
17087
- function ensurePresentationFontAttrs(presentationXml) {
17088
- let xml = presentationXml;
17089
- if (/embedTrueTypeFonts=/i.test(xml)) {
17090
- xml = xml.replace(/embedTrueTypeFonts="[^"]*"/i, 'embedTrueTypeFonts="true"');
17091
- } else {
17092
- xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 embedTrueTypeFonts="true">');
17093
- }
17094
- if (/saveSubsetFonts=/i.test(xml)) {
17095
- xml = xml.replace(/saveSubsetFonts="[^"]*"/i, 'saveSubsetFonts="true"');
17096
- } else {
17097
- xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 saveSubsetFonts="true">');
17098
- }
17099
- return xml;
17100
- }
17101
- function buildEmbeddedFontLst(fonts) {
17102
- let lst = '<p:embeddedFontLst>';
17103
- for (const font of fonts){
17104
- lst += '<p:embeddedFont>' + `<p:font typeface="${escapeXmlAttr(font.name)}"/>` + `<p:regular r:id="rId${font.rid}"/>` + '</p:embeddedFont>';
17105
- }
17106
- lst += '</p:embeddedFontLst>';
17107
- return lst;
17108
- }
17109
- function escapeXmlAttr(value) {
17110
- return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
17111
- }
17112
- function ensureEmbeddedFontLst(presentationXml, fonts) {
17113
- const lst = buildEmbeddedFontLst(fonts);
17114
- if (/<p:embeddedFontLst[\s>]/i.test(presentationXml)) {
17115
- // Replace existing list wholesale (export always owns the registered set)
17116
- return presentationXml.replace(/<p:embeddedFontLst[\s\S]*?<\/p:embeddedFontLst>/i, lst);
17117
- }
17118
- // ISO 29500: embeddedFontLst precedes defaultTextStyle.
17119
- // Insert after the full opening tag (match consumes `>` or attrs so it's preserved).
17120
- const dtsOpen = presentationXml.match(/<p:defaultTextStyle(?:\s[^>]*)?>/i);
17121
- if (dtsOpen) {
17122
- return presentationXml.replace(dtsOpen[0], `${lst}${dtsOpen[0]}`);
17123
- }
17124
- // Fallback: before closing presentation
17125
- return presentationXml.replace(/<\/p:presentation>/i, `${lst}</p:presentation>`);
17126
- }
17127
- function appendFontRelationships(relsXml, fonts) {
17128
- const nodes = fonts.map((font)=>`<Relationship Id="rId${font.rid}" ` + `Type="${FONT_REL_TYPE}" ` + `Target="fonts/${font.rid}.fntdata"/>`).join('');
17129
- if (!nodes) return relsXml;
17130
- return relsXml.replace(/<\/Relationships>/i, `${nodes}</Relationships>`);
17131
- }
17132
- /**
17133
- * Convert registered fonts into OOXML `ppt/fonts/*.fntdata` + presentation.xml entries.
17134
- * Mutates `zip` in place (before generateAsync).
17135
- */ function embedFontsIntoZip(zip, fonts) {
17136
- return gen_fonts_async_to_generator(function*() {
17137
- if (fonts.length === 0) return;
17138
- const prepared = [];
17139
- let nextRid = FONT_RID_START;
17140
- for (const font of fonts){
17141
- prepared.push({
17142
- name: font.fontFace,
17143
- data: yield toFntdata(font.fontType, font.fontFile),
17144
- rid: nextRid++
17145
- });
17146
- }
17147
- const contentTypesFile = zip.file('[Content_Types].xml');
17148
- if (!contentTypesFile) throw new Error('[Content_Types].xml not found');
17149
- addZipFile(zip, '[Content_Types].xml', ensureFntdataContentType((yield contentTypesFile.async('string'))));
17150
- const presentationFile = zip.file('ppt/presentation.xml');
17151
- if (!presentationFile) throw new Error('ppt/presentation.xml not found');
17152
- let presentationXml = yield presentationFile.async('string');
17153
- presentationXml = ensurePresentationFontAttrs(presentationXml);
17154
- presentationXml = ensureEmbeddedFontLst(presentationXml, prepared);
17155
- addZipFile(zip, 'ppt/presentation.xml', presentationXml);
17156
- const relsFile = zip.file('ppt/_rels/presentation.xml.rels');
17157
- if (!relsFile) throw new Error('ppt/_rels/presentation.xml.rels not found');
17158
- addZipFile(zip, 'ppt/_rels/presentation.xml.rels', appendFontRelationships((yield relsFile.async('string')), prepared));
17159
- for (const font of prepared){
17160
- addZipFile(zip, `ppt/fonts/${font.rid}.fntdata`, font.data, {
17161
- binary: true,
17162
- compression: 'DEFLATE'
17163
- });
17662
+ throw new Error('WOFF conversion requires options.inflate (pako)');
17164
17663
  }
17165
- })();
17664
+ const ttfBuffer = woff2ttf(fontBuffer, opts);
17665
+ ttfObject = new TTFReader(opts).read(ttfBuffer);
17666
+ } else {
17667
+ throw new Error(`Unsupported font type for EOT conversion: ${String(type)}`);
17668
+ }
17669
+ const ttfBuffer = new TTFWriter(opts).write(ttfObject);
17670
+ return ttf2eot(ttfBuffer, opts);
17166
17671
  }
17167
17672
 
17168
- function gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17673
+ /**
17674
+ * PptxGenJS: Opt-in embedded TrueType fonts (OOXML `ppt/fonts/*.fntdata`)
17675
+ *
17676
+ * `embedFontsIntoZip` is a no-op when `fonts` is empty — default export never
17677
+ * writes Font parts, fntdata content types, or Presentation font relationships.
17678
+ * Callers supply their own font bytes via `addFont` and must have a license
17679
+ * that permits embedding those files. This library ships no font files.
17680
+ *
17681
+ * Font-embed orchestration absorbed from MIT `pptx-embed-fonts`
17682
+ * (https://github.com/liyao1520/pptx-embed-fonts). TTF/OTF/WOFF→EOT conversion is a
17683
+ * vendored subset of MIT `fonteditor-core` under `src/vendor/fonteditor-core`
17684
+ * (https://github.com/kekee000/fonteditor-core). WOFF inflate uses pako 3.
17685
+ */ function gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17169
17686
  try {
17170
17687
  var info = gen[key](arg);
17171
17688
  var value = info.value;
@@ -17176,364 +17693,143 @@ function gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key,
17176
17693
  if (info.done) resolve(value);
17177
17694
  else Promise.resolve(value).then(_next, _throw);
17178
17695
  }
17179
- function gen_media_async_to_generator(fn) {
17696
+ function gen_fonts_async_to_generator(fn) {
17180
17697
  return function() {
17181
- var self = this, args = arguments;
17182
- return new Promise(function(resolve, reject) {
17183
- var gen = fn.apply(self, args);
17184
- function _next(value) {
17185
- gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
17186
- }
17187
- function _throw(err) {
17188
- gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
17189
- }
17190
- _next(undefined);
17191
- });
17192
- };
17193
- }
17194
- /**
17195
- * PptxGenJS: Media Methods
17196
- */
17197
-
17198
- /** Images are measured in pixels; PowerPoint slide dimensions are inches at 96 DPI */ const IMAGE_DPI = 96;
17199
- /**
17200
- * Read the natural pixel dimensions of a raster image from its header bytes.
17201
- * Self-contained replacement for the `image-size` package (PNG/JPEG/GIF/BMP).
17202
- * Format refs: PNG spec §11.2.2 (IHDR is always the first chunk, width/height big-endian at bytes 16-24);
17203
- * JPEG (JFIF) SOF0-SOF15 markers carry height then width big-endian; GIF87a/89a logical-screen descriptor
17204
- * little-endian at bytes 6-10; BMP DIB header little-endian at bytes 18-26. SVG is sized separately (gen-objects).
17205
- *
17206
- * Declared dims are header-only (we never decode pixels), so clamp to a sane ceiling: a maliciously crafted
17207
- * header can claim 0xFFFFFFFF px and emit a ~44-million-inch slide (a corrupt pptx). PowerPoint's max slide is
17208
- * 56 in (5376 px @ 96 DPI); 100 000 px is generous headroom for legit high-res sources while rejecting bombs.
17209
- */ const MAX_IMAGE_PX = 100000;
17210
- function imageDimensions(bytes) {
17211
- if (bytes.length < 10) return {} // every supported header's dims start at/after byte 6
17212
- ;
17213
- const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
17214
- const sane = (w, h)=>w > 0 && h > 0 && w <= MAX_IMAGE_PX && h <= MAX_IMAGE_PX ? {
17215
- width: w,
17216
- height: h
17217
- } : {};
17218
- // PNG: 8-byte signature 89 50 4E 47 0D 0A 1A 0A, then IHDR length(4)+type(4)+width(4)+height(4)
17219
- if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) {
17220
- if (bytes.length < 24) return {};
17221
- return sane(dv.getUint32(16, false), dv.getUint32(20, false));
17222
- }
17223
- // GIF: 'GIF87a'/'GIF89a', logical screen width/height little-endian at bytes 6-10
17224
- if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46) {
17225
- return sane(dv.getUint16(6, true), dv.getUint16(8, true));
17226
- }
17227
- // BMP: 'BM', DIB width/height little-endian at bytes 18-26 (signed; height may be negative = top-down)
17228
- if (bytes[0] === 0x42 && bytes[1] === 0x4d) {
17229
- if (bytes.length < 26) return {};
17230
- return sane(Math.abs(dv.getInt32(18, true)), Math.abs(dv.getInt32(22, true)));
17231
- }
17232
- // JPEG: FF D8, then walk marker segments until a Start-Of-Frame (C0-CF except C4/C8/CC) carries the dims
17233
- if (bytes[0] === 0xff && bytes[1] === 0xd8) {
17234
- let off = 2;
17235
- while(off + 9 <= bytes.length){
17236
- if (bytes[off] !== 0xff) {
17237
- off++;
17238
- continue;
17239
- }
17240
- const marker = bytes[off + 1];
17241
- const isSOF = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
17242
- if (isSOF) return sane(dv.getUint16(off + 7, false), dv.getUint16(off + 5, false));
17243
- if (marker === 0xd8 || marker === 0xd9 || marker >= 0xd0 && marker <= 0xd7) {
17244
- off += 2;
17245
- continue;
17246
- } // no length
17247
- const segLen = dv.getUint16(off + 2, false);
17248
- off += 2 + segLen;
17249
- }
17250
- }
17251
- return {};
17252
- }
17253
- /**
17254
- * Natural pixel size from encoded image bytes (PNG/JPEG/GIF/BMP headers).
17255
- * Returns null when the payload is missing, not a supported raster, or claims 0×0
17256
- * (`imageDimensions` already rejects zero and bomb-sized headers).
17257
- *
17258
- * contain/cover `a:srcRect` (ECMA-376 §5.1.10.55) needs the *blip* aspect, not the
17259
- * placement box — using w/h as imgSize makes srcRect a no-op whenever they match the sizing box.
17260
- */ function getImagePixelSize(base64Data) {
17261
- if (typeof base64Data !== 'string' || !base64Data || base64Data === IMG_BROKEN) return null;
17262
- try {
17263
- const dims = imageDimensions(base64ToBytes(base64Data));
17264
- if (dims.width && dims.height) return {
17265
- w: dims.width,
17266
- h: dims.height
17267
- };
17268
- } catch (unused) {
17269
- // unrecognized / truncated payload
17270
- }
17271
- return null;
17272
- }
17273
- /**
17274
- * Size images added without `w`/`h` to their natural dimensions (issue #34)
17275
- * @note must run after `encodeSlideMediaRels` has resolved - it reads the encoded image bytes
17276
- * @param {PresSlide | SlideLayout} layout - slide layout
17277
- */ function applyNaturalImageSizes(layout) {
17278
- layout._slideObjects.filter((obj)=>{
17279
- var _obj_options;
17280
- return obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.image */"image") && ((_obj_options = obj.options) === null || _obj_options === void 0 ? void 0 : _obj_options._sizeFromImage);
17281
- }).forEach((obj)=>{
17282
- var _layout__relsMedia_find;
17283
- 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;
17284
- if (!obj.options || typeof strData !== 'string' || !strData || strData === IMG_BROKEN) return;
17285
- // An image bound to a placeholder inherits the placeholder's w/h (slide XML resolves it); sizing it
17286
- // to its natural pixel dims instead would collapse it to ~px/96 inches (issue #996).
17287
- if (obj.options.placeholder) return;
17288
- try {
17289
- const dims = imageDimensions(base64ToBytes(strData));
17290
- if (dims.width && dims.height) {
17291
- obj.options.w = dims.width / IMAGE_DPI;
17292
- obj.options.h = dims.height / IMAGE_DPI;
17293
- }
17294
- } catch (_ex) {
17295
- // Unreadable/unsupported image: keep the 1x1 inch default
17296
- }
17297
- });
17298
- }
17299
- /** Select relations that still need their local or remote media encoded. */ function getMediaCandidates(layout) {
17300
- return layout._relsMedia.filter((rel)=>!rel.isLinked && rel.type !== 'online' && !rel.data && (!rel.path || rel.path && !rel.path.includes('preencoded')));
17301
- }
17302
- /**
17303
- * Mark repeated source paths so only the first relation performs I/O.
17304
- *
17305
- * Mutates `isDuplicate`; subsequent helpers copy the first result to every duplicate.
17306
- */ function markDuplicateMedia(candidates) {
17307
- const paths = new Set();
17308
- candidates.forEach((rel)=>{
17309
- var _rel_path;
17310
- const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
17311
- rel.isDuplicate = paths.has(path);
17312
- paths.add(path);
17313
- });
17314
- }
17315
- /** Copy an encoded or broken source relation's data to every duplicate path. */ function copyMediaToDuplicates(candidates, rel) {
17316
- candidates.filter((duplicate)=>duplicate.isDuplicate && duplicate.path === rel.path).forEach((duplicate)=>duplicate.data = rel.data);
17317
- }
17318
- /** Mark a failed source and all duplicates with the sentinel expected by package generation. */ function markMediaBroken(candidates, rel) {
17319
- rel.data = IMG_BROKEN;
17320
- copyMediaToDuplicates(candidates, rel);
17321
- }
17322
- function mediaLoadFailed(candidates, rel, message, onError) {
17323
- markMediaBroken(candidates, rel);
17324
- if (onError === 'placeholder') {
17325
- console.warn(`WARN: Unable to load image, using placeholder: ${rel.path}${message ? ` (${message})` : ''}`);
17326
- return 'done';
17327
- }
17328
- throw new Error(message);
17329
- }
17330
- /**
17331
- * Read one Node-local media source and encode it as base64.
17332
- *
17333
- * A read failure is recorded before rejection so duplicate references remain consistent.
17334
- */ function readNodeMediaFile(rel, candidates, fs, onError) {
17335
- return gen_media_async_to_generator(function*() {
17336
- try {
17337
- var _rel_path;
17338
- var _rel_fill;
17339
- const relPath = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
17340
- const svgFill = typeof ((_rel_fill = rel.fill) === null || _rel_fill === void 0 ? void 0 : _rel_fill.color) === 'string' ? rel.fill.color : undefined;
17341
- if (svgFill && (rel.type === 'image/svg+xml' || rel.extn === 'svg')) {
17342
- const svgText = applySvgFillColor(fs.readFileSync(relPath, 'utf8'), svgFill);
17343
- rel.data = utf8ToBase64(svgText);
17344
- } else {
17345
- const bitmap = fs.readFileSync(relPath);
17346
- rel.data = bytesToBase64(new Uint8Array(bitmap));
17347
- if (svgFill && typeof rel.data === 'string') {
17348
- rel.data = applySvgFillToDataUrl(rel.data, svgFill);
17349
- }
17350
- }
17351
- copyMediaToDuplicates(candidates, rel);
17352
- return 'done';
17353
- } catch (ex) {
17354
- return mediaLoadFailed(candidates, rel, `ERROR: Unable to read media: "${rel.path}"\n${String(ex)}`, onError);
17355
- }
17356
- })();
17357
- }
17358
- /**
17359
- * Load one HTTP(S) source in Node, draining error responses and handling both request and response errors.
17360
- */ function loadNodeMediaUrl(rel, candidates, https, http, onError) {
17361
- var _rel_path;
17362
- const httpMod = ((_rel_path = rel.path) === null || _rel_path === void 0 ? void 0 : _rel_path.startsWith('http://')) ? http : https;
17363
- return new Promise((resolve, reject)=>{
17364
- const fail = (message)=>{
17365
- try {
17366
- resolve(mediaLoadFailed(candidates, rel, message, onError));
17367
- } catch (ex) {
17368
- reject(ex);
17369
- }
17370
- };
17371
- try {
17372
- var _rel_path;
17373
- const req = httpMod.get((_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '', (res)=>{
17374
- var _res_statusCode;
17375
- const status = (_res_statusCode = res.statusCode) !== null && _res_statusCode !== void 0 ? _res_statusCode : 0;
17376
- if (status < 200 || status > 299) {
17377
- res.resume(); // drain so the socket is freed
17378
- fail(`ERROR! Unable to load image (HTTP ${status}): ${rel.path}`);
17379
- return;
17380
- }
17381
- let raw = '';
17382
- res.setEncoding('binary'); // IMPORTANT: Only binary encoding works
17383
- res.on('data', (chunk)=>raw += chunk);
17384
- res.on('end', ()=>{
17385
- rel.data = binaryStringToBase64(raw);
17386
- copyMediaToDuplicates(candidates, rel);
17387
- resolve('done');
17388
- });
17389
- res.on('error', ()=>fail(`ERROR! Unable to load image (response): ${rel.path}`));
17390
- });
17391
- // NOTE: without this, a DNS/TLS/connection failure emits an unhandled 'error' and kills the process
17392
- req.on('error', (ex)=>fail(`ERROR! Unable to load image (request): ${rel.path}\n${String(ex)}`));
17393
- } catch (ex) {
17394
- fail(`ERROR! Unable to load image (https.get): ${rel.path}\n${String(ex)}`);
17395
- }
17396
- });
17397
- }
17398
- /**
17399
- * Fetch one browser media source and convert its Blob response to a data URL.
17400
- * SVG previews are produced only after the source relation has been populated.
17401
- */ function loadBrowserMedia(rel, candidates, onError) {
17402
- return new Promise((resolve, reject)=>{
17403
- var _rel_path;
17404
- const fail = (message)=>{
17405
- try {
17406
- resolve(mediaLoadFailed(candidates, rel, message, onError));
17407
- } catch (ex) {
17408
- reject(ex);
17409
- }
17410
- };
17411
- const xhr = new XMLHttpRequest();
17412
- xhr.onload = ()=>{
17413
- // status 0 = non-HTTP schemes (file://); anything outside 2xx is an error page, not image bytes
17414
- if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {
17415
- fail(`ERROR! HTTP status ${xhr.status} loading image: ${rel.path}`);
17416
- return;
17698
+ var self = this, args = arguments;
17699
+ return new Promise(function(resolve, reject) {
17700
+ var gen = fn.apply(self, args);
17701
+ function _next(value) {
17702
+ gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
17417
17703
  }
17418
- const reader = new FileReader();
17419
- reader.onloadend = ()=>{
17420
- if (typeof reader.result === 'string') rel.data = reader.result;
17421
- copyMediaToDuplicates(candidates, rel);
17422
- if (!rel.isSvgPng) resolve('done');
17423
- else createSvgPngPreview(rel).then(()=>resolve('done')).catch(reject);
17424
- };
17425
- reader.readAsDataURL(xhr.response);
17426
- };
17427
- xhr.onerror = ()=>{
17428
- fail(`ERROR! Unable to load image (xhr.onerror): ${rel.path}`);
17429
- };
17430
- xhr.open('GET', (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '');
17431
- xhr.responseType = 'blob';
17432
- xhr.send();
17433
- });
17704
+ function _throw(err) {
17705
+ gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
17706
+ }
17707
+ _next(undefined);
17708
+ });
17709
+ };
17434
17710
  }
17435
- /** Route one source relation to the loader valid for the active runtime. */ function encodeMediaRelation(rel, candidates, isNode, modules, loadNodeModules, onError) {
17436
- return gen_media_async_to_generator(function*() {
17437
- var _rel_path;
17438
- if (!modules.https) yield loadNodeModules();
17439
- const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
17440
- if (isNode && modules.fs && !path.startsWith('http')) return readNodeMediaFile(rel, candidates, modules.fs, onError);
17441
- if (isNode && modules.https && modules.http && path.startsWith('http')) return loadNodeMediaUrl(rel, candidates, modules.https, modules.http, onError);
17442
- return loadBrowserMedia(rel, candidates, onError);
17711
+
17712
+
17713
+ /** High rId base so font relationships do not collide with slide/master rIds */ const FONT_RID_START = 201314;
17714
+ const FONT_REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/font';
17715
+ /**
17716
+ * Convert TTF / OTF / WOFF bytes to EOT (Office `fntdata` payload).
17717
+ * Lazy-loads pako only for WOFF.
17718
+ */ function fontToEot(type, fontBuffer) {
17719
+ return gen_fonts_async_to_generator(function*() {
17720
+ const options = {
17721
+ hinting: true
17722
+ };
17723
+ if (type === 'woff') {
17724
+ // pako 3: named exports only; InflateInput is Uint8Array | ArrayBuffer (not number[])
17725
+ const { inflate } = yield import("pako");
17726
+ options.inflate = (deflatedData)=>Array.from(inflate(Uint8Array.from(deflatedData)));
17727
+ }
17728
+ return convertToEot(type, fontBuffer, options);
17443
17729
  })();
17444
17730
  }
17445
- /**
17446
- * Append SVG preview work synchronously because the caller immediately snapshots `promises`.
17447
- * Node cannot rasterize SVG here, so it keeps the historical broken-preview sentinel behavior.
17448
- */ function addSvgPreviewPromises(layout, isNode, promises) {
17449
- layout._relsMedia.filter((rel)=>rel.isSvgPng && rel.data).forEach((rel)=>{
17450
- // NOTE: must push synchronously - the caller snapshots this array as soon as we return
17451
- if (isNode) {
17452
- // SVG is not supported in Node (more info: https://github.com/gitbrent/PptxGenJS/issues/401)
17453
- rel.data = IMG_BROKEN;
17454
- promises.push(Promise.resolve('done'));
17455
- } else {
17456
- promises.push(createSvgPngPreview(rel));
17731
+ function toFntdata(fontType, fontFile) {
17732
+ return gen_fonts_async_to_generator(function*() {
17733
+ switch(fontType){
17734
+ case 'eot':
17735
+ // EOT bytes are stored as-is under ppt/fonts/*.fntdata
17736
+ return fontFile;
17737
+ case 'ttf':
17738
+ case 'otf':
17739
+ case 'woff':
17740
+ return yield fontToEot(fontType, fontFile);
17741
+ default:
17742
+ throw new Error(`Invalid font type "${String(fontType)}" - use ttf | otf | woff | eot`);
17457
17743
  }
17458
- });
17744
+ })();
17459
17745
  }
17460
- /**
17461
- * Encode Image/Audio/Video into base64
17462
- * @param {PresSlide | SlideLayout} layout - slide layout
17463
- * @return {Promise} promise
17464
- */ function encodeSlideMediaRels(layout, opts) {
17465
- // STEP 1: Detect a real Node process. Browser bundles often polyfill `process`
17466
- // (and even `process.versions.node`), so also require a document-less runtime.
17467
- const isNode = isNodeRuntime();
17468
- const modules = {};
17469
- // STEP 2: Lazy-load Node built-ins if needed. The specifier is built at runtime
17470
- // so browser bundlers cannot statically resolve `node:https` / `https`.
17471
- const loadNodeDeps = isNode ? ()=>gen_media_async_to_generator(function*() {
17472
- ;
17473
- ({ default: modules.fs } = yield importNodeBuiltin('fs'));
17474
- ({ default: modules.https } = yield importNodeBuiltin('https'));
17475
- ({ default: modules.http } = yield importNodeBuiltin('http'));
17476
- })() : ()=>gen_media_async_to_generator(function*() {})();
17477
- // Immediately start it when we know we’re in Node
17478
- if (isNode) loadNodeDeps();
17479
- // STEP 3: Prepare promises list
17480
- const imageProms = [];
17481
- // A: Capture all audio/image/video candidates for encoding (filtering online/pre-encoded)
17482
- const candidateRels = getMediaCandidates(layout);
17483
- // B: PERF: Mark dupes (same `path`) to avoid loading the same media over-and-over!
17484
- markDuplicateMedia(candidateRels);
17485
- // STEP 4: Read/Encode each unique media item
17486
- const onError = (opts === null || opts === void 0 ? void 0 : opts.onError) === 'placeholder' ? 'placeholder' : 'throw';
17487
- candidateRels.filter((rel)=>!rel.isDuplicate).forEach((rel)=>imageProms.push(encodeMediaRelation(rel, candidateRels, isNode, modules, loadNodeDeps, onError)));
17488
- // STEP 5: SVG-PNG previews
17489
- // ......: "SVG:" base64 data still requires a png to be generated
17490
- // ......: (`isSvgPng` flag this as the preview image, not the SVG itself)
17491
- addSvgPreviewPromises(layout, isNode, imageProms);
17492
- return imageProms;
17746
+ function ensureFntdataContentType(contentTypesXml) {
17747
+ if (/Extension="fntdata"/i.test(contentTypesXml)) return contentTypesXml;
17748
+ const entry = '<Default Extension="fntdata" ContentType="application/x-fontdata"/>';
17749
+ // Prefer inserting among other Defaults near the top of <Types>
17750
+ if (/<Default\b/i.test(contentTypesXml)) {
17751
+ return contentTypesXml.replace(/<Default\b/i, `${entry}<Default`);
17752
+ }
17753
+ return contentTypesXml.replace(/<Types([^>]*)>/i, `<Types$1>${entry}`);
17754
+ }
17755
+ function ensurePresentationFontAttrs(presentationXml) {
17756
+ let xml = presentationXml;
17757
+ if (/embedTrueTypeFonts=/i.test(xml)) {
17758
+ xml = xml.replace(/embedTrueTypeFonts="[^"]*"/i, 'embedTrueTypeFonts="true"');
17759
+ } else {
17760
+ xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 embedTrueTypeFonts="true">');
17761
+ }
17762
+ if (/saveSubsetFonts=/i.test(xml)) {
17763
+ xml = xml.replace(/saveSubsetFonts="[^"]*"/i, 'saveSubsetFonts="true"');
17764
+ } else {
17765
+ xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 saveSubsetFonts="true">');
17766
+ }
17767
+ return xml;
17768
+ }
17769
+ function buildEmbeddedFontLst(fonts) {
17770
+ let lst = '<p:embeddedFontLst>';
17771
+ for (const font of fonts){
17772
+ lst += '<p:embeddedFont>' + `<p:font typeface="${escapeXmlAttr(font.name)}"/>` + `<p:regular r:id="rId${font.rid}"/>` + '</p:embeddedFont>';
17773
+ }
17774
+ lst += '</p:embeddedFontLst>';
17775
+ return lst;
17776
+ }
17777
+ function escapeXmlAttr(value) {
17778
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
17779
+ }
17780
+ function ensureEmbeddedFontLst(presentationXml, fonts) {
17781
+ const lst = buildEmbeddedFontLst(fonts);
17782
+ if (/<p:embeddedFontLst[\s>]/i.test(presentationXml)) {
17783
+ // Replace existing list wholesale (export always owns the registered set)
17784
+ return presentationXml.replace(/<p:embeddedFontLst[\s\S]*?<\/p:embeddedFontLst>/i, lst);
17785
+ }
17786
+ // ISO 29500: embeddedFontLst precedes defaultTextStyle.
17787
+ // Insert after the full opening tag (match consumes `>` or attrs so it's preserved).
17788
+ const dtsOpen = presentationXml.match(/<p:defaultTextStyle(?:\s[^>]*)?>/i);
17789
+ if (dtsOpen) {
17790
+ return presentationXml.replace(dtsOpen[0], `${lst}${dtsOpen[0]}`);
17791
+ }
17792
+ // Fallback: before closing presentation
17793
+ return presentationXml.replace(/<\/p:presentation>/i, `${lst}</p:presentation>`);
17794
+ }
17795
+ function appendFontRelationships(relsXml, fonts) {
17796
+ const nodes = fonts.map((font)=>`<Relationship Id="rId${font.rid}" ` + `Type="${FONT_REL_TYPE}" ` + `Target="fonts/${font.rid}.fntdata"/>`).join('');
17797
+ if (!nodes) return relsXml;
17798
+ return relsXml.replace(/<\/Relationships>/i, `${nodes}</Relationships>`);
17493
17799
  }
17494
17800
  /**
17495
- * Create SVG preview image
17496
- * @param {ISlideRelMedia} rel - slide rel
17497
- * @return {Promise} promise
17498
- */ function createSvgPngPreview(rel) {
17499
- return gen_media_async_to_generator(function*() {
17500
- return yield new Promise((resolve, reject)=>{
17501
- // A: Create
17502
- const image = new Image();
17503
- // Shared error handler (also wired to `image.onerror`); the reason string is informational only
17504
- const handleError = ()=>{
17505
- rel.data = IMG_BROKEN;
17506
- reject(new Error(`ERROR! Unable to load image (image.onerror): ${rel.path}`));
17507
- };
17508
- // B: Set onload event
17509
- image.onload = ()=>{
17510
- // First: Check for any errors: This is the best method (try/catch wont work, etc.)
17511
- if (image.width + image.height === 0) {
17512
- handleError();
17513
- }
17514
- const canvas = document.createElement('canvas');
17515
- const ctx = canvas.getContext('2d');
17516
- if (!ctx) {
17517
- handleError();
17518
- return;
17519
- }
17520
- canvas.width = image.width;
17521
- canvas.height = image.height;
17522
- ctx.drawImage(image, 0, 0);
17523
- // Users running on local machine will get the following error:
17524
- // "SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported."
17525
- // when the canvas.toDataURL call executes below.
17526
- try {
17527
- rel.data = canvas.toDataURL(rel.type);
17528
- resolve('done');
17529
- } catch (_ex) {
17530
- handleError();
17531
- }
17532
- };
17533
- image.onerror = handleError;
17534
- // C: Load image
17535
- image.src = typeof rel.data === 'string' ? rel.data : IMG_BROKEN;
17536
- });
17801
+ * Convert registered fonts into OOXML `ppt/fonts/*.fntdata` + presentation.xml entries.
17802
+ * Mutates `zip` in place (before generateAsync).
17803
+ */ function embedFontsIntoZip(zip, fonts) {
17804
+ return gen_fonts_async_to_generator(function*() {
17805
+ if (fonts.length === 0) return;
17806
+ const prepared = [];
17807
+ let nextRid = FONT_RID_START;
17808
+ for (const font of fonts){
17809
+ prepared.push({
17810
+ name: font.fontFace,
17811
+ data: yield toFntdata(font.fontType, font.fontFile),
17812
+ rid: nextRid++
17813
+ });
17814
+ }
17815
+ const contentTypesFile = zip.file('[Content_Types].xml');
17816
+ if (!contentTypesFile) throw new Error('[Content_Types].xml not found');
17817
+ addZipFile(zip, '[Content_Types].xml', ensureFntdataContentType((yield contentTypesFile.async('string'))));
17818
+ const presentationFile = zip.file('ppt/presentation.xml');
17819
+ if (!presentationFile) throw new Error('ppt/presentation.xml not found');
17820
+ let presentationXml = yield presentationFile.async('string');
17821
+ presentationXml = ensurePresentationFontAttrs(presentationXml);
17822
+ presentationXml = ensureEmbeddedFontLst(presentationXml, prepared);
17823
+ addZipFile(zip, 'ppt/presentation.xml', presentationXml);
17824
+ const relsFile = zip.file('ppt/_rels/presentation.xml.rels');
17825
+ if (!relsFile) throw new Error('ppt/_rels/presentation.xml.rels not found');
17826
+ addZipFile(zip, 'ppt/_rels/presentation.xml.rels', appendFontRelationships((yield relsFile.async('string')), prepared));
17827
+ for (const font of prepared){
17828
+ addZipFile(zip, `ppt/fonts/${font.rid}.fntdata`, font.data, {
17829
+ binary: true,
17830
+ compression: 'DEFLATE'
17831
+ });
17832
+ }
17537
17833
  })();
17538
17834
  }
17539
17835
 
@@ -21160,11 +21456,11 @@ const ImageSizingXml = {
21160
21456
  * @returns {string} XML
21161
21457
  */ function genXmlCellBorder(name, border) {
21162
21458
  var _ref, _border_width, _border_color;
21163
- if (border.type === 'none') return `<a:${name} w="0" cap="flat" cmpd="sng" algn="ctr"><a:noFill/></a:${name}>`;
21459
+ if (border.type === 'none') return `<a:${name}><a:noFill/></a:${name}>`;
21164
21460
  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;
21165
21461
  const borderTransparency = border.transparency;
21166
- const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${Math.round((100 - Math.min(100, Math.max(0, borderTransparency))) * 1000)}"/>` : '';
21167
- 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}>`;
21462
+ const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${clampAlphaPct(borderTransparency)}"/>` : '';
21463
+ 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}>`;
21168
21464
  }
21169
21465
  /**
21170
21466
  * One `a:audioCd` endpoint (`a:st` or `a:end`).
@@ -21304,7 +21600,7 @@ const ImageSizingXml = {
21304
21600
  /**
21305
21601
  * Alpha + recolor effects for an image's `a:blip`.
21306
21602
  */ function genXmlBlipEffects(transparency, alpha, recolor) {
21307
- let xml = transparency ? `<a:alphaModFix amt="${Math.round((100 - transparency) * 1000)}"/>` : '';
21603
+ let xml = transparency ? `<a:alphaModFix amt="${clampAlphaPct(transparency)}"/>` : '';
21308
21604
  xml += genXmlBlipRecolor(recolor);
21309
21605
  if (!alpha) return xml;
21310
21606
  if (typeof alpha.replace === 'number' && isFinite(alpha.replace)) xml += `<a:alphaRepl a="${Math.round(Math.min(100, Math.max(0, alpha.replace)) * 1000)}"/>`;
@@ -21466,7 +21762,7 @@ function resolveShapeId(options, idx, usedIds) {
21466
21762
  xml += '<a:rect l="l" t="t" r="r" b="b" />';
21467
21763
  xml += '<a:pathLst>';
21468
21764
  for (const points of pathArrays){
21469
- xml += `<a:path w="${Math.round(pathW)}" h="${Math.round(pathH)}">`;
21765
+ xml += `<a:path w="${positiveExtent(pathW)}" h="${positiveExtent(pathH)}">`;
21470
21766
  points === null || points === void 0 ? void 0 : points.forEach((point, i)=>{
21471
21767
  if ('curve' in point) {
21472
21768
  switch(point.curve.type){
@@ -21635,6 +21931,14 @@ function slideObjectToXml(slide) {
21635
21931
  flipH = line.flipH;
21636
21932
  flipV = line.flipV;
21637
21933
  }
21934
+ // Clamp extents to ST_PositiveCoordinate (>= 0) after line flip so lines keep negative endpoint deltas
21935
+ if (cx < 0 || cy < 0) {
21936
+ console.warn(`[pptxgenjs] negative size on ${slideItemObj._type}${slideItemObj.options.objectName ? ` "${slideItemObj.options.objectName}"` : ''} - w/h cannot be negative, clamped to 0`);
21937
+ }
21938
+ cx = positiveExtent(cx);
21939
+ cy = positiveExtent(cy);
21940
+ imgWidth = positiveExtent(imgWidth);
21941
+ imgHeight = positiveExtent(imgHeight);
21638
21942
  if (flipH) locationAttr += ' flipH="1"';
21639
21943
  if (flipV) locationAttr += ' flipV="1"';
21640
21944
  if (slideItemObj.options.rotate) locationAttr += ` rot="${convertRotationDegrees(slideItemObj.options.rotate)}"`;
@@ -21679,7 +21983,7 @@ function slideObjectToXml(slide) {
21679
21983
  if (w == null || isNaN(w)) {
21680
21984
  w = (typeof slideItemObj.options.w === 'number' ? slideItemObj.options.w : 1) / intColCnt;
21681
21985
  }
21682
- strXml += `<a:gridCol w="${Math.round(w)}"/>`;
21986
+ strXml += `<a:gridCol w="${positiveExtent(w)}"/>`;
21683
21987
  }
21684
21988
  strXml += '</a:tblGrid>';
21685
21989
  } else {
@@ -21687,7 +21991,7 @@ function slideObjectToXml(slide) {
21687
21991
  if (slideItemObj.options.w && !objTabOpts.colW) intColW = Math.round((typeof slideItemObj.options.w === 'number' ? slideItemObj.options.w : 1) / intColCnt);
21688
21992
  strXml += '<a:tblGrid>';
21689
21993
  for(let colw = 0; colw < intColCnt; colw++){
21690
- strXml += `<a:gridCol w="${intColW}"/>`;
21994
+ strXml += `<a:gridCol w="${positiveExtent(intColW)}"/>`;
21691
21995
  }
21692
21996
  strXml += '</a:tblGrid>';
21693
21997
  }
@@ -21765,7 +22069,7 @@ function slideObjectToXml(slide) {
21765
22069
  intRowH = Math.round((itemOpts.h ? inch2Emu(itemOpts.h) : typeof itemOpts.cy === 'number' ? itemOpts.cy : 1) / arrTabRows.length);
21766
22070
  }
21767
22071
  // B: Start row
21768
- strXml += `<a:tr h="${intRowH}">`;
22072
+ strXml += `<a:tr h="${positiveExtent(intRowH)}">`;
21769
22073
  // C: Loop over each CELL
21770
22074
  cells.forEach((cellObj)=>{
21771
22075
  var _ref, _ref1;
@@ -21798,6 +22102,7 @@ function slideObjectToXml(slide) {
21798
22102
  'fill',
21799
22103
  'fontFace',
21800
22104
  'fontSize',
22105
+ 'lang',
21801
22106
  'margin',
21802
22107
  'textDirection',
21803
22108
  'vert',
@@ -21806,7 +22111,7 @@ function slideObjectToXml(slide) {
21806
22111
  ].forEach((name)=>{
21807
22112
  if (objTabOpts[name] && !cellOpts[name] && cellOpts[name] !== 0) cellOpts[name] = objTabOpts[name];
21808
22113
  });
21809
- 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')}"` : '';
22114
+ 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')}"` : '';
21810
22115
  // `vert` = Martin-N alias of `textDirection`
21811
22116
  const cellDir = cellOpts.textDirection || cellOpts.vert;
21812
22117
  const cellTextDir = cellDir && cellDir !== 'horz' ? ` vert="${cellDir}"` : '';
@@ -21955,9 +22260,17 @@ function slideObjectToXml(slide) {
21955
22260
  } else {
21956
22261
  var _slideItemObj_options_line_curveadjust, _slideItemObj_options_line7;
21957
22262
  strSlideXml += '<a:prstGeom prst="' + slideItemObj.shape + '"><a:avLst>';
21958
- // `rectRadius: 0` is a valid sharp-corner adj (ECMA-376 §5.1.11 preset geom `gd name="adj"`).
21959
- if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius) && slideItemObj.options.rectRadius >= 0) {
21960
- strSlideXml += `<a:gd name="adj" fmla="val ${Math.round(slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / Math.min(cx, cy))}"/>`;
22263
+ // `rectRadius` adj is a 0..50000 fraction of the shorter side; clamp out-of-range / zero-extent results.
22264
+ // `round2SameRect` uses two handles (`adj1` top corners, `adj2` bottom corners) — single `adj` is ignored.
22265
+ if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius)) {
22266
+ const minDim = Math.min(cx, cy);
22267
+ const rawAdj = minDim > 0 ? slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / minDim : slideItemObj.options.rectRadius > 0 ? 50000 : 0;
22268
+ const adjVal = clampInt(rawAdj, 0, 50000);
22269
+ if (slideItemObj.shape === core_enums_SHAPE_TYPE.ROUND_2_SAME_RECTANGLE) {
22270
+ strSlideXml += `<a:gd name="adj1" fmla="val ${adjVal}"/><a:gd name="adj2" fmla="val 0"/>`;
22271
+ } else {
22272
+ strSlideXml += `<a:gd name="adj" fmla="val ${adjVal}"/>`;
22273
+ }
21961
22274
  } else if (slideItemObj.options.angleRange) {
21962
22275
  for(let i = 0; i < 2; i++){
21963
22276
  const angle = slideItemObj.options.angleRange[i];
@@ -22070,8 +22383,8 @@ function slideObjectToXml(slide) {
22070
22383
  // the frame must keep the user's w/h container - collapsing it to the crop box (or 0) breaks
22071
22384
  // rendering (issue #1399).
22072
22385
  if (sizing.type !== 'crop') {
22073
- imgWidth = boxW;
22074
- imgHeight = boxH;
22386
+ imgWidth = positiveExtent(boxW);
22387
+ imgHeight = positiveExtent(boxH);
22075
22388
  }
22076
22389
  } else {
22077
22390
  strSlideXml += ' <a:stretch><a:fillRect/></a:stretch>';
@@ -22084,8 +22397,10 @@ function slideObjectToXml(slide) {
22084
22397
  strSlideXml += ' </a:xfrm>';
22085
22398
  // Geometry: rectRadius → roundRect; rounding (legacy) → ellipse; else rect
22086
22399
  // Selective port of niranjan-uma-shankar/feature/html-to-pptx (keeps ellipse back-compat)
22087
- if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius) && slideItemObj.options.rectRadius >= 0) {
22088
- const adjValue = Math.round(slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / Math.min(imgWidth, imgHeight));
22400
+ if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius)) {
22401
+ const minDim = Math.min(imgWidth, imgHeight);
22402
+ const rawAdj = minDim > 0 ? slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / minDim : slideItemObj.options.rectRadius > 0 ? 50000 : 0;
22403
+ const adjValue = clampInt(rawAdj, 0, 50000);
22089
22404
  strSlideXml += ` <a:prstGeom prst="roundRect"><a:avLst><a:gd name="adj" fmla="val ${adjValue}"/></a:avLst></a:prstGeom>`;
22090
22405
  } else {
22091
22406
  strSlideXml += ` <a:prstGeom prst="${rounding ? 'ellipse' : 'rect'}"><a:avLst/></a:prstGeom>`;
@@ -22115,7 +22430,7 @@ function slideObjectToXml(slide) {
22115
22430
  const coverRid = (_slideItemObj__coverRid = slideItemObj._coverRid) !== null && _slideItemObj__coverRid !== void 0 ? _slideItemObj__coverRid : 2;
22116
22431
  strSlideXml += '<p:pic>';
22117
22432
  strSlideXml += ' <p:nvPicPr>';
22118
- strSlideXml += `<p:cNvPr id="${coverRid}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
22433
+ strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
22119
22434
  strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
22120
22435
  if (slideItemObj.mtype === 'audioCd') {
22121
22436
  const cd = slideItemObj.options.audioCd;
@@ -22131,34 +22446,32 @@ function slideObjectToXml(slide) {
22131
22446
  strSlideXml += ' </p:spPr>';
22132
22447
  strSlideXml += '</p:pic>';
22133
22448
  } else if (slideItemObj.mtype === 'online') {
22134
- var _slideItemObj_mediaRid, _slideItemObj_mediaRid1;
22449
+ var _slideItemObj_mediaRid;
22135
22450
  const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
22136
22451
  strSlideXml += '<p:pic>';
22137
22452
  strSlideXml += ' <p:nvPicPr>';
22138
- // IMPORTANT: <p:cNvPr id="" value is critical - if its not the same number as preview image `rId`, PowerPoint throws error!
22139
- strSlideXml += `<p:cNvPr id="${((_slideItemObj_mediaRid = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid !== void 0 ? _slideItemObj_mediaRid : 0) + 2}" name="${slideItemObj.options.objectName}"/>`;
22453
+ strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"/>`;
22140
22454
  strSlideXml += ' <p:cNvPicPr/>';
22141
22455
  strSlideXml += genXmlNvPr(slideItemObj.options, `<a:videoFile r:link="rId${slideItemObj.mediaRid}"${contentType}/>`);
22142
22456
  strSlideXml += ' </p:nvPicPr>';
22143
22457
  // NOTE: `blip` is diferent than videos; also there's no preview "p:extLst" above but exists in videos
22144
- 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!
22458
+ 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!
22145
22459
  strSlideXml += ' <p:spPr>';
22146
22460
  strSlideXml += ` <a:xfrm${locationAttr}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
22147
22461
  strSlideXml += ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>';
22148
22462
  strSlideXml += ' </p:spPr>';
22149
22463
  strSlideXml += '</p:pic>';
22150
22464
  } else {
22151
- var _slideItemObj_mediaRid2, _slideItemObj_mediaRid3, _slideItemObj_mediaRid4, _slideItemObj_mediaRid5;
22465
+ var _slideItemObj_mediaRid1, _slideItemObj_mediaRid2, _slideItemObj_mediaRid3;
22152
22466
  // ECMA-376: audio uses `<a:audioFile>`, video uses `<a:videoFile>` under nvPr.
22153
22467
  const mediaFileTag = slideItemObj.mtype === 'audio' ? 'a:audioFile' : 'a:videoFile';
22154
22468
  const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
22155
22469
  strSlideXml += '<p:pic>';
22156
22470
  strSlideXml += ' <p:nvPicPr>';
22157
- // IMPORTANT: <p:cNvPr id="" value is critical - if not the same number as preiew image rId, PowerPoint throws error!
22158
- 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>`;
22471
+ strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
22159
22472
  strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
22160
22473
  const mediaExtras = genXmlMediaExtras(slideItemObj.options);
22161
- 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>';
22474
+ 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>';
22162
22475
  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>' : '';
22163
22476
  strSlideXml += genXmlNvPr(slideItemObj.options, `<${mediaFileTag} r:link="rId${slideItemObj.mediaRid}"${contentType}/>`, narrationExt ? [
22164
22477
  mediaExt,
@@ -22167,7 +22480,7 @@ function slideObjectToXml(slide) {
22167
22480
  mediaExt
22168
22481
  ]);
22169
22482
  strSlideXml += ' </p:nvPicPr>';
22170
- 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!
22483
+ 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!
22171
22484
  strSlideXml += ' <p:spPr>';
22172
22485
  strSlideXml += ` <a:xfrm${locationAttr}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
22173
22486
  strSlideXml += ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>';
@@ -22350,7 +22663,7 @@ function slideObjectToXml(slide) {
22350
22663
  strSlideXml += ' <p:nvPr><p:ph type="sldNum" sz="quarter" idx="4294967295"/></p:nvPr>';
22351
22664
  strSlideXml += ' </p:nvSpPr>';
22352
22665
  strSlideXml += ' <p:spPr>';
22353
- 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>';
22666
+ 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>';
22354
22667
  strSlideXml += '<p:txBody>';
22355
22668
  strSlideXml += '<a:bodyPr';
22356
22669
  if (slide._slideNumberProps.margin && Array.isArray(slide._slideNumberProps.margin)) {
@@ -22370,7 +22683,7 @@ function slideObjectToXml(slide) {
22370
22683
  strSlideXml += '/>';
22371
22684
  strSlideXml += ' <a:lstStyle><a:lvl1pPr>';
22372
22685
  if (slide._slideNumberProps.fontFace || slide._slideNumberProps.fontSize || slide._slideNumberProps.color) {
22373
- strSlideXml += `<a:defRPr sz="${Math.round((slide._slideNumberProps.fontSize || 12) * 100)}">`;
22686
+ strSlideXml += `<a:defRPr sz="${fontSizeToSz(slide._slideNumberProps.fontSize || 12)}">`;
22374
22687
  if (slide._slideNumberProps.color) strSlideXml += genXmlColorSelection(slide._slideNumberProps.color);
22375
22688
  if (slide._slideNumberProps.fontFace) {
22376
22689
  strSlideXml += `<a:latin typeface="${slide._slideNumberProps.fontFace}"/><a:ea typeface="${slide._slideNumberProps.fontFace}"/><a:cs typeface="${slide._slideNumberProps.fontFace}"/>`;
@@ -22731,20 +23044,21 @@ function slideShowExtLst(slide) {
22731
23044
  * @returns {SlideObjectAnimation[]} array of object animations with their indices
22732
23045
  */ /**
22733
23046
  * Collect media shapes that need a playback entry in the slide timing tree.
22734
- * The shape id targeted by `<p:spTgt spid>` is the media `<p:cNvPr id>`, which the
22735
- * media emitter computes as `mediaRid + 2`. Online (linked) videos are excluded —
23047
+ * The shape id targeted by `<p:spTgt spid>` is the allocated `<p:cNvPr id>` stamped onto
23048
+ * `obj.options.sId` by `slideObjectToXml`. Online (linked) videos are excluded —
22736
23049
  * they don't support the embedded playback timing tree.
22737
23050
  */ function collectMediaPlayback(slide) {
22738
23051
  var _slide__slideObjects;
22739
23052
  const entries = [];
22740
- ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).forEach((obj)=>{
22741
- var _obj_mediaRid;
23053
+ const renderable = ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).filter((obj)=>obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.notes */"notes"));
23054
+ renderable.forEach((obj, idx)=>{
23055
+ var _o_sId;
22742
23056
  if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") || obj.mtype !== 'audio' && obj.mtype !== 'video') return;
22743
23057
  const o = obj.options;
22744
23058
  // Defaults are all false: no timing node unless at least one playback flag is set.
22745
23059
  if (!o || !(o.autoplay || o.loop || o.fullScreen || o.mute)) return;
22746
23060
  entries.push({
22747
- spid: ((_obj_mediaRid = obj.mediaRid) !== null && _obj_mediaRid !== void 0 ? _obj_mediaRid : 0) + 2,
23061
+ spid: (_o_sId = o.sId) !== null && _o_sId !== void 0 ? _o_sId : idx + 2,
22748
23062
  kind: obj.mtype === 'video' ? 'video' : 'audio',
22749
23063
  autoplay: o.autoplay,
22750
23064
  loop: o.loop,
@@ -22758,7 +23072,8 @@ function slideShowExtLst(slide) {
22758
23072
  function collectSlideAnimations(slide) {
22759
23073
  const animations = [];
22760
23074
  if (!slide._slideObjects) return animations;
22761
- slide._slideObjects.forEach((slideObj, index)=>{
23075
+ const renderable = slide._slideObjects.filter((obj)=>obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.notes */"notes"));
23076
+ renderable.forEach((slideObj, index)=>{
22762
23077
  var _ref;
22763
23078
  var _slideObj_options, _slideObj_options1, _slideObj_options2;
22764
23079
  // Warn when animations are incorrectly attached to individual text runs
@@ -22797,8 +23112,8 @@ function collectSlideAnimations(slide) {
22797
23112
  delay: 0
22798
23113
  }, animConfig);
22799
23114
  }
22800
- // Media cNvPr id is mediaRid+2 (not the auto shape index). Charts keep index+2 / sId.
22801
- 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;
23115
+ // `slideObjectToXml` runs first and stamps every object's allocated `p:cNvPr/@id` onto `options.sId`
23116
+ const shapeId = (_ref = (_slideObj_options2 = slideObj.options) === null || _slideObj_options2 === void 0 ? void 0 : _slideObj_options2.sId) !== null && _ref !== void 0 ? _ref : index + 2;
22802
23117
  animations.push({
22803
23118
  objectIndex: index,
22804
23119
  shapeId,
@@ -22820,6 +23135,9 @@ function collectSlideAnimations(slide) {
22820
23135
  if (!s._id) s._id = getUuid('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
22821
23136
  });
22822
23137
  resolveZoomSections(slide, sections);
23138
+ // Render `p:cSld` first so `resolveShapeId` allocates unique `p:cNvPr/@id` values (including media)
23139
+ // and stamps `options.sId` before animations & media playback timing target `<p:spTgt spid="..."/>`.
23140
+ const cSldXml = slideObjectToXml(slide);
22823
23141
  const animations = collectSlideAnimations(slide);
22824
23142
  const mediaPlayback = collectMediaPlayback(slide);
22825
23143
  const timingXml = animations.length > 0 || mediaPlayback.length > 0 ? createTimingXml(animations, mediaPlayback) : '';
@@ -22834,7 +23152,7 @@ function collectSlideAnimations(slide) {
22834
23152
  commentRelExt
22835
23153
  ].filter(Boolean);
22836
23154
  const sldExtXml = sldExtLst.length > 0 ? `<p:extLst>${sldExtLst.join('')}</p:extLst>` : '';
22837
- 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>';
23155
+ 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>';
22838
23156
  }
22839
23157
  /**
22840
23158
  * Get text content of Notes from Slide
@@ -22928,21 +23246,54 @@ function collectSlideAnimations(slide) {
22928
23246
  * Distinct `thm15:themeFamily` ids keep the notes theme from being a byte-identical twin
22929
23247
  * (Office repair creates theme2 when notesMaster shares theme1; Juliussssssss 9bdfe09 / SCV-Soft 1a1998e).
22930
23248
  * @return {string} XML
22931
- */ function makeXmlTheme(pres, variant = 'slide') {
22932
- var _ref, _ref1;
22933
- var _pres_theme, _pres_theme1, _pres_theme2, _pres_theme3, _pres_theme4, _pres_theme5, _pres_theme6;
22934
- 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"/>';
22935
- 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"/>';
22936
- const eaFace = (_ref = (_pres_theme4 = pres.theme) === null || _pres_theme4 === void 0 ? void 0 : _pres_theme4.eaFontFace) !== null && _ref !== void 0 ? _ref : '';
22937
- const csFace = (_ref1 = (_pres_theme5 = pres.theme) === null || _pres_theme5 === void 0 ? void 0 : _pres_theme5.csFontFace) !== null && _ref1 !== void 0 ? _ref1 : '';
23249
+ */ const THEME_COLOR_SLOT_ORDER = [
23250
+ 'dk1',
23251
+ 'lt1',
23252
+ 'dk2',
23253
+ 'lt2',
23254
+ 'accent1',
23255
+ 'accent2',
23256
+ 'accent3',
23257
+ 'accent4',
23258
+ 'accent5',
23259
+ 'accent6',
23260
+ 'hlink',
23261
+ 'folHlink'
23262
+ ];
23263
+ function makeXmlTheme(pres, variant = 'slide') {
23264
+ var _pres_theme, _pres_theme1, _pres_theme2, _pres_theme3, _pres_theme4, _pres_theme5, _pres_theme6, _pres_theme7;
23265
+ const headFace = ((_pres_theme = pres.theme) === null || _pres_theme === void 0 ? void 0 : _pres_theme.headFontFace) ? encodeXmlEntities(pres.theme.headFontFace) : '';
23266
+ const bodyFace = ((_pres_theme1 = pres.theme) === null || _pres_theme1 === void 0 ? void 0 : _pres_theme1.bodyFontFace) ? encodeXmlEntities(pres.theme.bodyFontFace) : '';
23267
+ const explicitEa = ((_pres_theme2 = pres.theme) === null || _pres_theme2 === void 0 ? void 0 : _pres_theme2.eaFontFace) !== undefined ? encodeXmlEntities(pres.theme.eaFontFace) : undefined;
23268
+ const explicitCs = ((_pres_theme3 = pres.theme) === null || _pres_theme3 === void 0 ? void 0 : _pres_theme3.csFontFace) !== undefined ? encodeXmlEntities(pres.theme.csFontFace) : undefined;
23269
+ // Without ea/cs faces, East Asian and complex-script runs inheriting the theme font fall back to app defaults.
23270
+ // When `eaFontFace`/`csFontFace` are unset, mirror `headFontFace`/`bodyFontFace` (pitch-io 3049ea49).
23271
+ 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 : ''}"/>`;
23272
+ 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 : ''}"/>`;
22938
23273
  const themeFamilyId = variant === 'notes' ? '{2E142A2C-CD16-42D6-873A-C26D2A0506FA}' : '{62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F}';
22939
23274
  const themeFamilyVid = variant === 'notes' ? '{1BDDFF52-6CD6-40A5-AB3C-68EB2F1E4D0A}' : '{4A3C46E8-61CC-4603-A589-7422A47A8E4A}';
22940
23275
  // Exactly 12 hex colors required (upstream only checked truthy `.length`, which allowed short arrays → undefined attrs)
22941
- const isCustomColors = Array.isArray((_pres_theme6 = pres.theme) === null || _pres_theme6 === void 0 ? void 0 : _pres_theme6.themeColors) && pres.theme.themeColors.length === 12;
22942
23276
  const c = resolveThemeColors(pres.theme);
22943
- const themeName = isCustomColors ? 'Custom Theme' : 'Office Theme';
22944
- const schemeName = isCustomColors ? 'Custom' : 'Office';
22945
- 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>`;
23277
+ let hasNamedColorOverrides = false;
23278
+ if (((_pres_theme4 = pres.theme) === null || _pres_theme4 === void 0 ? void 0 : _pres_theme4.colors) && typeof pres.theme.colors === 'object') {
23279
+ for (const [slot, raw] of Object.entries(pres.theme.colors)){
23280
+ const idx = THEME_COLOR_SLOT_ORDER.indexOf(slot);
23281
+ if (idx < 0 || typeof raw !== 'string') continue;
23282
+ const hex = raw.replace(/^#/, '').toUpperCase();
23283
+ if (/^[0-9A-F]{6}$/.test(hex)) {
23284
+ c[idx] = hex;
23285
+ hasNamedColorOverrides = true;
23286
+ } else {
23287
+ console.warn(`[pptxgenjs] theme.colors.${slot}="${raw}" is not a valid 6-digit hex; using ${c[idx]}`);
23288
+ }
23289
+ }
23290
+ }
23291
+ const isCustomColors = Array.isArray((_pres_theme5 = pres.theme) === null || _pres_theme5 === void 0 ? void 0 : _pres_theme5.themeColors) && pres.theme.themeColors.length === 12 || hasNamedColorOverrides;
23292
+ const customName = ((_pres_theme6 = pres.theme) === null || _pres_theme6 === void 0 ? void 0 : _pres_theme6.name) ? encodeXmlEntities(pres.theme.name) : '';
23293
+ const themeName = customName || (isCustomColors ? 'Custom Theme' : 'Office Theme');
23294
+ const schemeName = customName || (isCustomColors ? 'Custom' : 'Office');
23295
+ const fontSchemeName = ((_pres_theme7 = pres.theme) === null || _pres_theme7 === void 0 ? void 0 : _pres_theme7.fontSchemeName) ? encodeXmlEntities(pres.theme.fontSchemeName) : customName || 'Office';
23296
+ 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>`;
22946
23297
  }
22947
23298
  const package_P15_NS = 'http://schemas.microsoft.com/office/powerpoint/2012/main';
22948
23299
  const SLD_GUIDE_URI = '{EFAFB233-063F-42B5-8137-9DF3F51BA10A}';
@@ -22996,7 +23347,8 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
22996
23347
  // STEP 4: Add sizes
22997
23348
  // `@type` records which preset the dimensions match; omitted when the caller does not say
22998
23349
  strXml += `<p:sldSz cx="${pres.presLayout.width}" cy="${pres.presLayout.height}"${pres.slideSizeType ? ` type="${pres.slideSizeType}"` : ''}/>`;
22999
- strXml += `<p:notesSz cx="${pres.presLayout.height}" cy="${pres.presLayout.width}"/>`;
23350
+ // Diffit-Inc 15c5bade: fixed 7.5×10in portrait notes page matching standard notesMaster placeholders
23351
+ strXml += '<p:notesSz cx="6858000" cy="9144000"/>';
23000
23352
  // CT_Presentation sequence puts these between `notesSz` and `defaultTextStyle` (photoAlbum, kinsoku)
23001
23353
  if (pres.photoAlbum) {
23002
23354
  const album = pres.photoAlbum;
@@ -23799,7 +24151,7 @@ class PptxGenJS {
23799
24151
  */ pptxgen_define_property(this, "_layout", void 0);
23800
24152
  /**
23801
24153
  * PptxGenJS Library Version
23802
- */ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.3.10"));
24154
+ */ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.4.0"));
23803
24155
  /**
23804
24156
  * @type {string}
23805
24157
  */ pptxgen_define_property(this, "_author", void 0);