@aixa-transformation/pptx-viewer 2.0.3 → 2.0.24

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.
@@ -17151,6 +17151,11 @@ var PptxSlideLoaderService = class {
17151
17151
  id: path,
17152
17152
  rId,
17153
17153
  slideNumber: slideIndex + 1,
17154
+ // Preserve the authoritative slide -> slideLayout relationship on the
17155
+ // loaded model. The editor uses this identity to mark the current
17156
+ // layout in the gallery and to scope layout choices to the slide's
17157
+ // master. Without it, the gallery cannot reliably reflect PowerPoint.
17158
+ layoutPath: layoutPathForOverride,
17154
17159
  hidden,
17155
17160
  sectionId: sectionMeta?.sectionId,
17156
17161
  sectionName: sectionMeta?.sectionName,
@@ -42208,6 +42213,11 @@ function getSectionSlideRange(zoomElement, slides) {
42208
42213
  }
42209
42214
  var FONT_SUBSTITUTION_MAP = {
42210
42215
  // Microsoft Office default fonts
42216
+ // Aptos replaced Calibri as Office's default and is intentionally close in
42217
+ // metrics. Calibri/Calibri Light are better fidelity fallbacks than Segoe UI
42218
+ // (which is wider and makes authored one-line titles wrap).
42219
+ Aptos: ["Calibri", "Arial", "sans-serif"],
42220
+ "Aptos Display": ["Calibri Light", "Calibri", "Arial", "sans-serif"],
42211
42221
  Calibri: ["Carlito", "Liberation Sans", "Arial", "sans-serif"],
42212
42222
  "Calibri Light": ["Carlito", "Liberation Sans", "Arial", "sans-serif"],
42213
42223
  Cambria: ["Caladea", "Liberation Serif", "Times New Roman", "serif"],
@@ -52736,6 +52746,37 @@ function parseShowProperties(showPr) {
52736
52746
  }
52737
52747
  return props;
52738
52748
  }
52749
+ function asArray2(value) {
52750
+ if (value === void 0 || value === null) return [];
52751
+ return Array.isArray(value) ? value : [value];
52752
+ }
52753
+ function resolveSlideLayoutOrder(sldMaster, relationships, resolveTarget) {
52754
+ const layoutRelationships = relationships.filter(
52755
+ (relationship) => String(relationship["@_Type"] ?? "").includes("/slideLayout")
52756
+ );
52757
+ const targetById = new Map(
52758
+ layoutRelationships.map((relationship) => [
52759
+ String(relationship["@_Id"] ?? ""),
52760
+ String(relationship["@_Target"] ?? "")
52761
+ ])
52762
+ );
52763
+ const orderedIds = asArray2(xmlChild(sldMaster, "p:sldLayoutIdLst")?.["p:sldLayoutId"]).map((layoutId) => xmlAttr(layoutId, "r:id")).filter((id) => Boolean(id));
52764
+ const orderedTargets = [];
52765
+ const usedIds = /* @__PURE__ */ new Set();
52766
+ for (const id of orderedIds) {
52767
+ const target = targetById.get(id);
52768
+ if (target) {
52769
+ orderedTargets.push(resolveTarget(target));
52770
+ usedIds.add(id);
52771
+ }
52772
+ }
52773
+ for (const relationship of layoutRelationships) {
52774
+ const id = String(relationship["@_Id"] ?? "");
52775
+ const target = String(relationship["@_Target"] ?? "");
52776
+ if (target && !usedIds.has(id)) orderedTargets.push(resolveTarget(target));
52777
+ }
52778
+ return orderedTargets;
52779
+ }
52739
52780
  function parseMasterColorMap(node) {
52740
52781
  if (!node) {
52741
52782
  return void 0;
@@ -55001,7 +55042,22 @@ var PptxHandlerRuntime9 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
55001
55042
  }
55002
55043
  const type = (xmlAttr(ph, "type") ?? "body").trim();
55003
55044
  const idx = xmlAttr(ph, "idx");
55004
- result.push({ type, idx });
55045
+ const xfrm = xmlPath(sp, "p:spPr", "a:xfrm");
55046
+ const off = xmlChild(xfrm, "a:off");
55047
+ const ext = xmlChild(xfrm, "a:ext");
55048
+ const emu = _PptxHandlerRuntime.EMU_PER_PX;
55049
+ const x = off ? Number(xmlAttr(off, "x")) / emu : void 0;
55050
+ const y = off ? Number(xmlAttr(off, "y")) / emu : void 0;
55051
+ const width = ext ? Number(xmlAttr(ext, "cx")) / emu : void 0;
55052
+ const height = ext ? Number(xmlAttr(ext, "cy")) / emu : void 0;
55053
+ result.push({
55054
+ type,
55055
+ idx,
55056
+ ...Number.isFinite(x) ? { x } : {},
55057
+ ...Number.isFinite(y) ? { y } : {},
55058
+ ...Number.isFinite(width) ? { width } : {},
55059
+ ...Number.isFinite(height) ? { height } : {}
55060
+ });
55005
55061
  }
55006
55062
  return result;
55007
55063
  }
@@ -55108,12 +55164,13 @@ var PptxHandlerRuntime9 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
55108
55164
  const rels = this.ensureArray(
55109
55165
  xmlChild(relsData, "Relationships")?.["Relationship"]
55110
55166
  );
55111
- for (const rel of rels) {
55112
- const relType = String(rel["@_Type"] || "");
55113
- if (relType.includes("/slideLayout")) {
55114
- layoutPaths.push(this.resolveImagePath(path, String(rel["@_Target"] || "")));
55115
- }
55116
- }
55167
+ layoutPaths.push(
55168
+ ...resolveSlideLayoutOrder(
55169
+ sldMaster,
55170
+ rels,
55171
+ (target) => this.resolveImagePath(path, target)
55172
+ )
55173
+ );
55117
55174
  }
55118
55175
  const layouts = [];
55119
55176
  for (const lp of layoutPaths) {
@@ -55218,6 +55275,28 @@ var PptxHandlerRuntime9 = class _PptxHandlerRuntime extends PptxHandlerRuntime8
55218
55275
  if (!this.layoutXmlMap.has(layoutPath)) {
55219
55276
  this.layoutXmlMap.set(layoutPath, data);
55220
55277
  }
55278
+ if (!this.slideRelsMap.has(layoutPath)) {
55279
+ const layoutRelsPath = `${layoutPath.replace(
55280
+ "slideLayouts/",
55281
+ "slideLayouts/_rels/"
55282
+ )}.rels`;
55283
+ const layoutRelsXml2 = await this.zip.file(layoutRelsPath)?.async("string");
55284
+ if (layoutRelsXml2) {
55285
+ const layoutRelsData = this.parser.parse(layoutRelsXml2);
55286
+ const relationships = this.ensureArray(
55287
+ xmlChild(layoutRelsData, "Relationships")?.["Relationship"]
55288
+ );
55289
+ const relationshipMap = /* @__PURE__ */ new Map();
55290
+ for (const relationship of relationships) {
55291
+ const id = String(relationship["@_Id"] || "").trim();
55292
+ const target = String(relationship["@_Target"] || "").trim();
55293
+ if (id && target) {
55294
+ relationshipMap.set(id, target);
55295
+ }
55296
+ }
55297
+ this.slideRelsMap.set(layoutPath, relationshipMap);
55298
+ }
55299
+ }
55221
55300
  const layout = { path: layoutPath };
55222
55301
  const cSldName = (xmlAttr(xmlChild(sldLayout, "p:cSld"), "name") ?? "").trim();
55223
55302
  if (cSldName) {
@@ -58093,9 +58172,13 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58093
58172
  return [];
58094
58173
  }
58095
58174
  const result = [];
58096
- const shapes = this.ensureArray(spTree["p:sp"]);
58175
+ const shapes = [
58176
+ ...this.ensureArray(spTree["p:sp"]),
58177
+ ...this.ensureArray(spTree["p:pic"]),
58178
+ ...this.ensureArray(spTree["p:graphicFrame"])
58179
+ ];
58097
58180
  for (const shape of shapes) {
58098
- const nvPr = xmlPath(shape, "p:nvSpPr", "p:nvPr");
58181
+ const nvPr = xmlPath(shape, "p:nvSpPr", "p:nvPr") ?? xmlPath(shape, "p:nvPicPr", "p:nvPr") ?? xmlPath(shape, "p:nvGraphicFramePr", "p:nvPr");
58099
58182
  const phInfo = this.readPlaceholderInfoFromNvPr(nvPr);
58100
58183
  if (!phInfo) {
58101
58184
  continue;
@@ -58124,13 +58207,54 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58124
58207
  }
58125
58208
  return type;
58126
58209
  }
58210
+ placeholderRole(phInfo) {
58211
+ const type = phInfo.type || "body";
58212
+ if (type === "title" || type === "ctrtitle") {
58213
+ return "title";
58214
+ }
58215
+ if (type === "body" || type === "obj" || type === "subtitle" || type === "pic" || type === "chart" || type === "tbl" || type === "media") {
58216
+ return "content";
58217
+ }
58218
+ return type;
58219
+ }
58220
+ preferredPlaceholderTypes(element) {
58221
+ switch (element.type) {
58222
+ case "image":
58223
+ return ["pic", "obj"];
58224
+ case "chart":
58225
+ return ["chart", "obj"];
58226
+ case "table":
58227
+ return ["tbl", "obj"];
58228
+ case "video":
58229
+ case "audio":
58230
+ return ["media", "obj"];
58231
+ case "text":
58232
+ return ["body", "subtitle", "obj"];
58233
+ default:
58234
+ return ["obj", "body"];
58235
+ }
58236
+ }
58237
+ placeholderMatchScore(element, source, target) {
58238
+ const sourceType = source.type || "body";
58239
+ const targetType = target.type || "body";
58240
+ const sourceRole = this.placeholderRole(source);
58241
+ const targetRole = this.placeholderRole(target);
58242
+ if (sourceRole !== targetRole) return -1;
58243
+ let score = 0;
58244
+ if (source.idx !== void 0 && target.idx === source.idx) score += 100;
58245
+ if (targetType === sourceType) score += 50;
58246
+ const preferredIndex = this.preferredPlaceholderTypes(element).indexOf(targetType);
58247
+ if (preferredIndex >= 0) score += 30 - preferredIndex * 5;
58248
+ if (targetType === "obj") score += 10;
58249
+ return score;
58250
+ }
58127
58251
  // ── Core layout switching logic ─────────────────────────────────────
58128
58252
  /**
58129
58253
  * Re-map slide elements to a new layout's placeholders.
58130
58254
  *
58131
58255
  * - Placeholder elements whose type matches a new-layout placeholder
58132
58256
  * get their position/size updated to the new layout's values.
58133
- * - Placeholder elements with no match in the new layout are removed.
58257
+ * - Placeholder elements with no match in the new layout are preserved.
58134
58258
  * - New-layout placeholders with no matching slide element produce
58135
58259
  * empty text elements that are appended to the slide.
58136
58260
  * - Non-placeholder elements are left untouched.
@@ -58139,10 +58263,9 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58139
58263
  */
58140
58264
  remapElementsToNewLayout(elements2, newLayoutXml, newLayoutPath) {
58141
58265
  const layoutPlaceholders = this.extractLayoutPlaceholders(newLayoutXml);
58142
- const layoutPhMap = /* @__PURE__ */ new Map();
58266
+ const targetPlaceholders = [];
58143
58267
  for (const lp of layoutPlaceholders) {
58144
- const key = this.buildPlaceholderMatchKey(lp.phInfo);
58145
- layoutPhMap.set(key, { ...lp, matched: false });
58268
+ targetPlaceholders.push({ ...lp, matched: false });
58146
58269
  }
58147
58270
  const resultElements = [];
58148
58271
  for (const element of elements2) {
@@ -58151,20 +58274,22 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58151
58274
  resultElements.push(element);
58152
58275
  continue;
58153
58276
  }
58154
- const matchKey = this.buildPlaceholderMatchKey(phInfo);
58155
- const layoutPh = layoutPhMap.get(matchKey);
58156
- let resolvedLayoutPh = layoutPh;
58157
- if (!resolvedLayoutPh && phInfo.type) {
58158
- for (const [, lp] of layoutPhMap.entries()) {
58159
- if (!lp.matched && lp.phInfo.type === phInfo.type) {
58160
- resolvedLayoutPh = lp;
58161
- break;
58162
- }
58277
+ let resolvedLayoutPh;
58278
+ let bestScore = -1;
58279
+ for (const candidate of targetPlaceholders) {
58280
+ if (candidate.matched) continue;
58281
+ const score = this.placeholderMatchScore(element, phInfo, candidate.phInfo);
58282
+ if (score > bestScore) {
58283
+ bestScore = score;
58284
+ resolvedLayoutPh = candidate;
58163
58285
  }
58164
58286
  }
58165
58287
  if (resolvedLayoutPh) {
58166
58288
  resolvedLayoutPh.matched = true;
58167
- const updatedElement = { ...element };
58289
+ const updatedElement = {
58290
+ ...element,
58291
+ rawXml: element.rawXml ? cloneXmlObject(element.rawXml) : element.rawXml
58292
+ };
58168
58293
  if (resolvedLayoutPh.cxEmu > 0 && resolvedLayoutPh.cyEmu > 0) {
58169
58294
  updatedElement.x = Math.round(resolvedLayoutPh.xEmu / EMU_PER_PX);
58170
58295
  updatedElement.y = Math.round(resolvedLayoutPh.yEmu / EMU_PER_PX);
@@ -58180,10 +58305,15 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58180
58305
  resolvedLayoutPh.cyEmu
58181
58306
  );
58182
58307
  }
58308
+ if (updatedElement.rawXml) {
58309
+ this.updateElementRawXmlPlaceholder(updatedElement.rawXml, resolvedLayoutPh.phInfo);
58310
+ }
58183
58311
  resultElements.push(updatedElement);
58312
+ } else {
58313
+ resultElements.push(element);
58184
58314
  }
58185
58315
  }
58186
- for (const [, lp] of layoutPhMap) {
58316
+ for (const lp of targetPlaceholders) {
58187
58317
  if (lp.matched) {
58188
58318
  continue;
58189
58319
  }
@@ -58205,6 +58335,24 @@ var PptxHandlerRuntime21 = class extends PptxHandlerRuntime20 {
58205
58335
  }
58206
58336
  return resultElements;
58207
58337
  }
58338
+ updateElementRawXmlPlaceholder(rawXml, phInfo) {
58339
+ const nvPr = xmlPath(rawXml, "p:nvSpPr", "p:nvPr") ?? xmlPath(rawXml, "p:nvPicPr", "p:nvPr") ?? xmlPath(rawXml, "p:nvGraphicFramePr", "p:nvPr");
58340
+ if (!nvPr) {
58341
+ return;
58342
+ }
58343
+ const ph = nvPr["p:ph"] ?? {};
58344
+ nvPr["p:ph"] = ph;
58345
+ if (phInfo.type) {
58346
+ ph["@_type"] = phInfo.type;
58347
+ } else {
58348
+ delete ph["@_type"];
58349
+ }
58350
+ if (phInfo.idx !== void 0) {
58351
+ ph["@_idx"] = phInfo.idx;
58352
+ } else {
58353
+ delete ph["@_idx"];
58354
+ }
58355
+ }
58208
58356
  // ── rawXml transform update ─────────────────────────────────────────
58209
58357
  /**
58210
58358
  * Update the transform (`a:xfrm`) inside an element's rawXml to
@@ -66444,7 +66592,7 @@ function ensureChild2(parent, key) {
66444
66592
  return created;
66445
66593
  }
66446
66594
  var NOTES_MASTER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml";
66447
- function asArray2(value) {
66595
+ function asArray3(value) {
66448
66596
  return Array.isArray(value) ? value : value ? [value] : [];
66449
66597
  }
66450
66598
  function relationshipBase(strict) {
@@ -66491,7 +66639,7 @@ var PptxHandlerRuntime49 = class extends PptxHandlerRuntime48 {
66491
66639
  }
66492
66640
  const relsData = this.parser.parse(relsXml);
66493
66641
  const relsRoot = relsData["Relationships"] ?? {};
66494
- const relationships = asArray2(relsRoot["Relationship"]);
66642
+ const relationships = asArray3(relsRoot["Relationship"]);
66495
66643
  const usedIds = new Set(relationships.map((rel) => String(rel["@_Id"] ?? "")));
66496
66644
  let index = 1;
66497
66645
  while (usedIds.has(`rId${index}`)) {
@@ -66575,7 +66723,7 @@ var PptxHandlerRuntime49 = class extends PptxHandlerRuntime48 {
66575
66723
  }
66576
66724
  const data = this.parser.parse(xml);
66577
66725
  const root = data["Types"] ?? {};
66578
- const overrides10 = asArray2(root["Override"]);
66726
+ const overrides10 = asArray3(root["Override"]);
66579
66727
  if (!overrides10.some((entry) => entry["@_PartName"] === partName)) {
66580
66728
  overrides10.push({ "@_PartName": partName, "@_ContentType": contentType });
66581
66729
  }
@@ -66585,7 +66733,7 @@ var PptxHandlerRuntime49 = class extends PptxHandlerRuntime48 {
66585
66733
  }
66586
66734
  };
66587
66735
  var HANDOUT_MASTER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml";
66588
- function asArray3(value) {
66736
+ function asArray4(value) {
66589
66737
  return Array.isArray(value) ? value : value ? [value] : [];
66590
66738
  }
66591
66739
  function relationshipBase2(strict) {
@@ -66616,7 +66764,7 @@ var PptxHandlerRuntime50 = class extends PptxHandlerRuntime49 {
66616
66764
  }
66617
66765
  const relsData = this.parser.parse(relsXml);
66618
66766
  const relsRoot = relsData["Relationships"] ?? {};
66619
- const relationships = asArray3(relsRoot["Relationship"]);
66767
+ const relationships = asArray4(relsRoot["Relationship"]);
66620
66768
  const target = masterPath.startsWith("ppt/") ? masterPath.slice(4) : masterPath;
66621
66769
  let relationship = relationships.find(
66622
66770
  (rel) => String(rel["@_Type"] ?? "").endsWith("/handoutMaster") && String(rel["@_Target"] ?? "").replace(/^\.\//u, "") === target
@@ -66649,7 +66797,7 @@ var PptxHandlerRuntime50 = class extends PptxHandlerRuntime49 {
66649
66797
  if (existingXml) {
66650
66798
  const data = this.parser.parse(existingXml);
66651
66799
  const root = data["Relationships"] ?? {};
66652
- const relationships = asArray3(root["Relationship"]);
66800
+ const relationships = asArray4(root["Relationship"]);
66653
66801
  if (relationships.some((rel) => String(rel["@_Type"] ?? "").endsWith("/theme"))) {
66654
66802
  return;
66655
66803
  }
@@ -66760,7 +66908,7 @@ var PptxHandlerRuntime50 = class extends PptxHandlerRuntime49 {
66760
66908
  }
66761
66909
  const data = this.parser.parse(xml);
66762
66910
  const root = data["Types"] ?? {};
66763
- const overrides10 = asArray3(root["Override"]);
66911
+ const overrides10 = asArray4(root["Override"]);
66764
66912
  const partName = `/${masterPath}`;
66765
66913
  if (!overrides10.some((entry) => entry["@_PartName"] === partName)) {
66766
66914
  overrides10.push({ "@_PartName": partName, "@_ContentType": HANDOUT_MASTER_CONTENT_TYPE });
@@ -67551,12 +67699,20 @@ var PptxHandlerRuntime56 = class extends PptxHandlerRuntime55 {
67551
67699
  }
67552
67700
  const phKey = this.buildPlaceholderDefaultsKey(phInfo);
67553
67701
  const layoutMap = this.layoutPlaceholderDefaultsCache.get(layoutPath);
67554
- const layoutDefaults = layoutMap?.get(phKey);
67702
+ const lookupDefaults = (map) => {
67703
+ const exact = map?.get(phKey);
67704
+ if (exact || phInfo.type !== void 0 || phInfo.idx === void 0) {
67705
+ return exact;
67706
+ }
67707
+ return map?.get(`obj_${phInfo.idx}`) ?? map?.get(`body_${phInfo.idx}`);
67708
+ };
67709
+ const layoutDefaults = lookupDefaults(layoutMap);
67555
67710
  const masterPath = this.resolveMasterPathForLayout(layoutPath);
67556
67711
  const masterMap = masterPath ? this.masterPlaceholderDefaultsCache.get(masterPath) : void 0;
67557
- const masterDefaults = masterMap?.get(phKey);
67712
+ const masterDefaults = lookupDefaults(masterMap);
67558
67713
  const normalizedType = this.buildPlaceholderDefaultsKey(phInfo).split("_")[0];
67559
- const masterTextStyleType = phInfo.type === "title" || phInfo.type === "ctrtitle" ? "title" : phInfo.type === "body" || phInfo.type === "obj" || phInfo.type === "subtitle" ? "body" : "other";
67714
+ const effectivePlaceholderType = phInfo.type ?? "obj";
67715
+ const masterTextStyleType = effectivePlaceholderType === "title" || effectivePlaceholderType === "ctrtitle" ? "title" : effectivePlaceholderType === "body" || effectivePlaceholderType === "obj" || effectivePlaceholderType === "subtitle" ? "body" : "other";
67560
67716
  const masterTextStyles = masterPath ? this.masterTxStylesCache.get(masterPath) : void 0;
67561
67717
  const masterTextLevels = masterTextStyleType === "title" ? masterTextStyles?.titleStyle : masterTextStyleType === "body" ? masterTextStyles?.bodyStyle : masterTextStyles?.otherStyle;
67562
67718
  const resolvedMasterDefaults = masterTextLevels ? {
@@ -68240,6 +68396,17 @@ var PptxHandlerRuntime58 = class _PptxHandlerRuntime24 extends PptxHandlerRuntim
68240
68396
  return void 0;
68241
68397
  }
68242
68398
  };
68399
+ function parseOoxmlPercentage(value) {
68400
+ const raw = String(value ?? "").trim();
68401
+ if (!raw) {
68402
+ return void 0;
68403
+ }
68404
+ const numeric = Number.parseFloat(raw.endsWith("%") ? raw.slice(0, -1) : raw);
68405
+ if (!Number.isFinite(numeric)) {
68406
+ return void 0;
68407
+ }
68408
+ return raw.endsWith("%") ? numeric / 100 : numeric / 1e5;
68409
+ }
68243
68410
  var PptxHandlerRuntime59 = class extends PptxHandlerRuntime58 {
68244
68411
  /**
68245
68412
  * Apply {@link PlaceholderDefaults} body-level properties to a
@@ -68286,12 +68453,11 @@ var PptxHandlerRuntime59 = class extends PptxHandlerRuntime58 {
68286
68453
  if (Number.isFinite(spacingPointsRaw)) {
68287
68454
  return this.pointsToPixels(spacingPointsRaw / 100);
68288
68455
  }
68289
- const spacingPercentRaw = Number.parseInt(
68290
- String(spacingNode["a:spcPct"]?.["@_val"] || ""),
68291
- 10
68456
+ const spacingPercent = parseOoxmlPercentage(
68457
+ spacingNode["a:spcPct"]?.["@_val"]
68292
68458
  );
68293
- if (Number.isFinite(spacingPercentRaw) && typeof basisFontSizePx === "number" && basisFontSizePx > 0) {
68294
- return spacingPercentRaw / 1e5 * basisFontSizePx;
68459
+ if (spacingPercent !== void 0 && typeof basisFontSizePx === "number" && basisFontSizePx > 0) {
68460
+ return spacingPercent * basisFontSizePx;
68295
68461
  }
68296
68462
  return void 0;
68297
68463
  }
@@ -68299,12 +68465,11 @@ var PptxHandlerRuntime59 = class extends PptxHandlerRuntime58 {
68299
68465
  if (!lineSpacingNode) {
68300
68466
  return void 0;
68301
68467
  }
68302
- const spacingPercentRaw = Number.parseInt(
68303
- String(lineSpacingNode["a:spcPct"]?.["@_val"] || ""),
68304
- 10
68468
+ const spacingPercent = parseOoxmlPercentage(
68469
+ lineSpacingNode["a:spcPct"]?.["@_val"]
68305
68470
  );
68306
- if (Number.isFinite(spacingPercentRaw)) {
68307
- return Math.max(0.1, Math.min(5, spacingPercentRaw / 1e5));
68471
+ if (spacingPercent !== void 0) {
68472
+ return Math.max(0.1, Math.min(5, spacingPercent));
68308
68473
  }
68309
68474
  return void 0;
68310
68475
  }
@@ -68342,8 +68507,13 @@ var PptxHandlerRuntime59 = class extends PptxHandlerRuntime58 {
68342
68507
  if (textStyle.italic === void 0 && levelStyle.italic !== void 0) {
68343
68508
  textStyle.italic = levelStyle.italic;
68344
68509
  }
68345
- if (textStyle.color === void 0 && levelStyle.color !== void 0) {
68346
- textStyle.color = levelStyle.color;
68510
+ if (textStyle.color === void 0) {
68511
+ const currentSlideColor = levelStyle.colorXml ? this.parseColor(levelStyle.colorXml) : void 0;
68512
+ if (currentSlideColor !== void 0) {
68513
+ textStyle.color = currentSlideColor;
68514
+ } else if (levelStyle.color !== void 0) {
68515
+ textStyle.color = levelStyle.color;
68516
+ }
68347
68517
  }
68348
68518
  if (textStyle.paragraphMarginLeft === void 0 && levelStyle.marginLeft !== void 0) {
68349
68519
  textStyle.paragraphMarginLeft = levelStyle.marginLeft;
@@ -69308,25 +69478,31 @@ var PptxHandlerRuntime63 = class extends PptxHandlerRuntime62 {
69308
69478
  "mc:AlternateContent",
69309
69479
  "a:br"
69310
69480
  ]);
69481
+ const paragraphRuns = this.ensureArray(p["a:r"]);
69482
+ const paragraphBreaks = this.ensureArray(p["a:br"]);
69483
+ const hasCollapsedRunBreakOrder = paragraphRuns.length > 1 && paragraphBreaks.length > 0;
69311
69484
  for (const key of Object.keys(p)) {
69312
69485
  if (!contentTagSet.has(key)) {
69313
69486
  continue;
69314
69487
  }
69315
69488
  const items = this.ensureArray(p[key]);
69316
- const rawBreaks = p["a:br"];
69317
- const breakCount = Array.isArray(rawBreaks) ? rawBreaks.length : rawBreaks === void 0 ? 0 : 1;
69318
- const insertCollapsedBreaks = key === "a:r" && items.length > 1 && breakCount > 0;
69489
+ const breakCount = paragraphBreaks.length;
69490
+ const insertCollapsedBreaks = key === "a:r" && hasCollapsedRunBreakOrder;
69319
69491
  for (const [itemIndex, item] of items.entries()) {
69320
69492
  switch (key) {
69321
69493
  case "a:r": {
69322
69494
  processRun(item);
69323
- if (insertCollapsedBreaks && itemIndex < Math.min(items.length - 1, breakCount)) {
69324
- parts.push("\n");
69325
- segments.push({
69326
- text: "\n",
69327
- style: { ...mergedDefaultRunStyle },
69328
- isLineBreak: true
69329
- });
69495
+ if (insertCollapsedBreaks && itemIndex < items.length - 1) {
69496
+ const gapCount = items.length - 1;
69497
+ const breaksHere = Math.floor(breakCount / gapCount) + (itemIndex < breakCount % gapCount ? 1 : 0);
69498
+ for (let breakIndex = 0; breakIndex < breaksHere; breakIndex++) {
69499
+ parts.push("\n");
69500
+ segments.push({
69501
+ text: "\n",
69502
+ style: { ...mergedDefaultRunStyle },
69503
+ isLineBreak: true
69504
+ });
69505
+ }
69330
69506
  }
69331
69507
  break;
69332
69508
  }
@@ -69347,7 +69523,7 @@ var PptxHandlerRuntime63 = class extends PptxHandlerRuntime62 {
69347
69523
  processAlternateContent(item);
69348
69524
  break;
69349
69525
  case "a:br": {
69350
- if (insertCollapsedBreaks) {
69526
+ if (hasCollapsedRunBreakOrder) {
69351
69527
  break;
69352
69528
  }
69353
69529
  const brNode = item ?? {};
@@ -69371,6 +69547,14 @@ var PptxHandlerRuntime63 = class extends PptxHandlerRuntime62 {
69371
69547
  }
69372
69548
  }
69373
69549
  }
69550
+ const markerSegment = segments.find((segment) => segment.bulletInfo);
69551
+ const firstVisibleRun = segments.find(
69552
+ (segment) => !segment.bulletInfo && segment.text !== "\n" && segment.text.length > 0
69553
+ );
69554
+ if (markerSegment && firstVisibleRun) {
69555
+ markerSegment.style = { ...firstVisibleRun.style };
69556
+ seedStyle = { ...firstVisibleRun.style };
69557
+ }
69374
69558
  if (pIdx < paraCount - 1) {
69375
69559
  parts.push("\n");
69376
69560
  segments.push({ text: "\n", style: { ...mergedDefaultRunStyle } });
@@ -71670,10 +71854,14 @@ var PptxHandlerRuntime72 = class _PptxHandlerRuntime31 extends PptxHandlerRuntim
71670
71854
  if (defRPr["@_i"] !== void 0) {
71671
71855
  style.italic = defRPr["@_i"] === "1";
71672
71856
  }
71673
- const color2 = this.parseColor(defRPr["a:solidFill"]);
71857
+ const colorXml2 = defRPr["a:solidFill"];
71858
+ const color2 = this.parseColor(colorXml2);
71674
71859
  if (color2) {
71675
71860
  style.color = color2;
71676
71861
  }
71862
+ if (colorXml2) {
71863
+ style.colorXml = colorXml2;
71864
+ }
71677
71865
  const latin = defRPr["a:latin"];
71678
71866
  if (latin?.["@_typeface"]) {
71679
71867
  const typeface = String(latin["@_typeface"]);
@@ -76617,12 +76805,47 @@ var PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
76617
76805
  const kinsoku = this.extractKinsoku();
76618
76806
  const customerData = await this.parsePresentationCustomerData();
76619
76807
  this.thumbnailData = await this.parseThumbnail() ?? null;
76808
+ const previousEagerDecodeImages = this.eagerDecodeImages;
76809
+ this.eagerDecodeImages = true;
76810
+ try {
76811
+ for (const master of slideMasters) {
76812
+ for (const layout of master.layouts ?? []) {
76813
+ const previewSlidePath = `ppt/slides/__layout_preview_${layout.path.split("/").pop()}`;
76814
+ this.slideRelsMap.set(
76815
+ previewSlidePath,
76816
+ /* @__PURE__ */ new Map([["rIdLayoutPreview", `/${layout.path}`]])
76817
+ );
76818
+ this.layoutCache.delete(layout.path);
76819
+ layout.elements = await this.getLayoutElements(previewSlidePath);
76820
+ this.slideRelsMap.delete(previewSlidePath);
76821
+ layout.backgroundColor ??= master.backgroundColor;
76822
+ }
76823
+ }
76824
+ } finally {
76825
+ this.eagerDecodeImages = previousEagerDecodeImages;
76826
+ }
76827
+ const layoutPreviewMap = new Map(
76828
+ slideMasters.flatMap(
76829
+ (master) => (master.layouts ?? []).map((layout) => [layout.path, layout])
76830
+ )
76831
+ );
76832
+ const layoutOptions = this.getLayoutOptions().map((option) => {
76833
+ const preview = layoutPreviewMap.get(option.path);
76834
+ return preview ? {
76835
+ ...option,
76836
+ previewElements: preview.elements,
76837
+ previewBackgroundColor: preview.backgroundColor,
76838
+ previewWidth: presentationState.width,
76839
+ previewHeight: presentationState.height,
76840
+ previewPlaceholders: preview.placeholders
76841
+ } : option;
76842
+ });
76620
76843
  return new PptxLoadDataBuilder().withDimensions(
76621
76844
  presentationState.width,
76622
76845
  presentationState.height,
76623
76846
  this.rawSlideWidthEmu,
76624
76847
  this.rawSlideHeightEmu
76625
- ).withNotesDimensions(presentationState.notesWidthEmu, presentationState.notesHeightEmu).withSlides(slidesWithWarnings).withLayoutOptions(this.getLayoutOptions()).withHeaderFooter(headerFooter).withPresentationProperties(presentationProperties).withViewProperties(viewProperties).withCustomShows(customShows).withSections(
76848
+ ).withNotesDimensions(presentationState.notesWidthEmu, presentationState.notesHeightEmu).withSlides(slidesWithWarnings).withLayoutOptions(layoutOptions).withHeaderFooter(headerFooter).withPresentationProperties(presentationProperties).withViewProperties(viewProperties).withCustomShows(customShows).withSections(
76626
76849
  presentationState.orderedSections.length > 0 ? presentationState.orderedSections : void 0
76627
76850
  ).withWarnings(this.compatibilityService.getWarnings()).withThemeColorMap({ ...this.themeColorMap }).withTheme(this.buildThemeObject()).withThemeOptions(themeOptions.length > 0 ? themeOptions : void 0).withTableStyleMap(tableStyleMap).withEmbeddedFonts(embeddedFonts.length > 0 ? embeddedFonts : void 0).withEmbeddedFontList(embeddedFontList).withMruColors(presentationProperties?.mruColors).withNotesMaster(notesMaster).withHandoutMaster(handoutMaster).withSlideMasters(slideMasters.length > 0 ? slideMasters : void 0).withTags(tags.length > 0 ? tags : void 0).withCustomProperties(customProperties.length > 0 ? customProperties : void 0).withCoreProperties(coreProperties).withAppProperties(appProperties).withHasMacros(this.vbaProjectBin !== null ? true : void 0).withHasDigitalSignatures(this.signatureDetection?.hasSignatures || void 0).withDigitalSignatureCount(
76628
76851
  this.signatureDetection?.signatureCount && this.signatureDetection.signatureCount > 0 ? this.signatureDetection.signatureCount : void 0