@officedk/pptxdk 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/build.d.ts +94 -0
  4. package/dist/build.js +148 -0
  5. package/dist/capabilities/dist/all.js +32 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +51 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +31 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +138 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +77 -0
  11. package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
  12. package/dist/capabilities/dist/chart/chart-elements.js +12 -0
  13. package/dist/capabilities/dist/chart/chart-import.js +2272 -0
  14. package/dist/capabilities/dist/chart/chart-labels.js +86 -0
  15. package/dist/capabilities/dist/chart/chart-model.js +9 -0
  16. package/dist/capabilities/dist/chart/chart-schemas.js +1078 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1124 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -0
  20. package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
  21. package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
  22. package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
  23. package/dist/capabilities/dist/chart/preview/index.js +190 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +519 -0
  25. package/dist/capabilities/dist/chart/preview/legend.js +273 -0
  26. package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
  27. package/dist/capabilities/dist/chart/preview/markers.js +100 -0
  28. package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
  29. package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
  30. package/dist/capabilities/dist/chart/preview/scales.js +365 -0
  31. package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
  32. package/dist/capabilities/dist/chart/preview/style.js +48 -0
  33. package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
  34. package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
  35. package/dist/capabilities/dist/chart/preview/types.js +5 -0
  36. package/dist/capabilities/dist/document.js +148 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +289 -0
  38. package/dist/capabilities/dist/font/font-family.js +10 -0
  39. package/dist/capabilities/dist/font/font-import.js +302 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +25 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +51 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +42 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +319 -0
  46. package/dist/capabilities/dist/group/group-xml.js +7 -0
  47. package/dist/capabilities/dist/group/group.js +211 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +94 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +221 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +778 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +149 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +472 -0
  57. package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
  58. package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
  59. package/dist/capabilities/dist/masters/masters.js +250 -0
  60. package/dist/capabilities/dist/motion/motion-api.js +527 -0
  61. package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
  62. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  63. package/dist/capabilities/dist/motion/motion-import.js +1033 -0
  64. package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
  65. package/dist/capabilities/dist/motion/motion-query.js +420 -0
  66. package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
  67. package/dist/capabilities/dist/motion/motion.js +1372 -0
  68. package/dist/capabilities/dist/notes/notes-codegen.js +20 -0
  69. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  70. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  71. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  72. package/dist/capabilities/dist/notes/notes-schemas.js +35 -0
  73. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  74. package/dist/capabilities/dist/notes/notes.js +191 -0
  75. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
  76. package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
  77. package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
  78. package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
  79. package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
  80. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  81. package/dist/capabilities/dist/shape/shape-import.js +579 -0
  82. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  83. package/dist/capabilities/dist/shape/shape.js +337 -0
  84. package/dist/capabilities/dist/shared/geometry.js +1423 -0
  85. package/dist/capabilities/dist/shared/identity.js +205 -0
  86. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  87. package/dist/capabilities/dist/shared/placeholder-import.js +113 -0
  88. package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
  89. package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
  90. package/dist/capabilities/dist/shared/style-parse.js +11 -0
  91. package/dist/capabilities/dist/shared/text-schemas.js +216 -0
  92. package/dist/capabilities/dist/shared/text-service.js +1883 -0
  93. package/dist/capabilities/dist/shared/visual.js +918 -0
  94. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  95. package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
  96. package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
  97. package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
  98. package/dist/capabilities/dist/table/table-codegen.js +81 -0
  99. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  100. package/dist/capabilities/dist/table/table-elements.js +27 -0
  101. package/dist/capabilities/dist/table/table-import.js +539 -0
  102. package/dist/capabilities/dist/table/table-schemas.js +279 -0
  103. package/dist/capabilities/dist/table/table-xml.js +37 -0
  104. package/dist/capabilities/dist/table/table.js +662 -0
  105. package/dist/capabilities/dist/text/text-codegen.js +129 -0
  106. package/dist/capabilities/dist/text/text-declaration.js +19 -0
  107. package/dist/capabilities/dist/text/text-elements.js +38 -0
  108. package/dist/capabilities/dist/text/text-import.js +1077 -0
  109. package/dist/capabilities/dist/text/text-xml.js +9 -0
  110. package/dist/capabilities/dist/text/text.js +335 -0
  111. package/dist/capabilities/dist/transition/transition-api.js +139 -0
  112. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  113. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  114. package/dist/capabilities/dist/transition/transition.js +260 -0
  115. package/dist/capability-D_xeNVIw.d.ts +29496 -0
  116. package/dist/cli.js +20 -0
  117. package/dist/codegen/dist/assets.js +78 -0
  118. package/dist/codegen/dist/codegen.js +611 -0
  119. package/dist/codegen/dist/identifiers.js +193 -0
  120. package/dist/codegen/dist/index.js +3 -0
  121. package/dist/codegen/dist/printer.js +143 -0
  122. package/dist/codegen/dist/types.js +49 -0
  123. package/dist/core/dist/author-ids.js +48 -0
  124. package/dist/core/dist/author-schemas.js +313 -0
  125. package/dist/core/dist/block-flex-layout.js +749 -0
  126. package/dist/core/dist/build.js +4 -0
  127. package/dist/core/dist/capability.js +13 -0
  128. package/dist/core/dist/declaration.js +15 -0
  129. package/dist/core/dist/diagnostics.js +21 -0
  130. package/dist/core/dist/document-internals.js +13 -0
  131. package/dist/core/dist/document.js +408 -0
  132. package/dist/core/dist/geometry-schemas.js +249 -0
  133. package/dist/core/dist/grid-layout.js +445 -0
  134. package/dist/core/dist/host.js +40 -0
  135. package/dist/core/dist/index.js +15 -0
  136. package/dist/core/dist/input-values.js +45 -0
  137. package/dist/core/dist/layout-protocol.js +66 -0
  138. package/dist/core/dist/layout-schemas.js +208 -0
  139. package/dist/core/dist/layout.js +299 -0
  140. package/dist/core/dist/masters.js +169 -0
  141. package/dist/core/dist/morph.js +30 -0
  142. package/dist/core/dist/placeholders.js +213 -0
  143. package/dist/core/dist/query.js +155 -0
  144. package/dist/core/dist/resolution.js +11 -0
  145. package/dist/core/dist/resolve.js +1827 -0
  146. package/dist/core/dist/stage-options.js +67 -0
  147. package/dist/core/dist/theme.js +931 -0
  148. package/dist/document-BHPUODPP.d.ts +27759 -0
  149. package/dist/emit/dist/emit.js +936 -0
  150. package/dist/emit/dist/index.js +5 -0
  151. package/dist/emit/dist/ooxml.js +606 -0
  152. package/dist/emit/dist/shape-tree.js +12 -0
  153. package/dist/import/dist/alternate-content.js +54 -0
  154. package/dist/import/dist/diagnostics.js +153 -0
  155. package/dist/import/dist/fonts.js +250 -0
  156. package/dist/import/dist/import.js +504 -0
  157. package/dist/import/dist/index.js +16 -0
  158. package/dist/import/dist/masters.js +1153 -0
  159. package/dist/import/dist/mechanism.js +10 -0
  160. package/dist/import/dist/namespaces.js +60 -0
  161. package/dist/import/dist/notes-masters.js +300 -0
  162. package/dist/import/dist/opc.js +233 -0
  163. package/dist/import/dist/resources.js +166 -0
  164. package/dist/import/dist/sections.js +139 -0
  165. package/dist/import/dist/themes.js +671 -0
  166. package/dist/import/dist/visual.js +761 -0
  167. package/dist/import/dist/xml-fragments.js +36 -0
  168. package/dist/import/dist/xml-reader.js +267 -0
  169. package/dist/index-B5m3hqjC.d.ts +7 -0
  170. package/dist/index-CCy-Yo8G.d.ts +1208 -0
  171. package/dist/index-DpxcZ4Gs.d.ts +725 -0
  172. package/dist/index.d.ts +7 -0
  173. package/dist/index.js +70 -0
  174. package/dist/node.d.ts +53 -0
  175. package/dist/node.js +194 -0
  176. package/dist/pptxdk/src/cli-commands.js +913 -0
  177. package/dist/pptxdk/src/compose.js +44 -0
  178. package/dist/pptxdk/src/slide.js +9 -0
  179. package/dist/preview/dist/index.js +240 -0
  180. package/dist/preview/dist/options.js +53 -0
  181. package/dist/preview-Cfw0QdMM.d.ts +86 -0
  182. package/dist/preview.d.ts +3 -0
  183. package/dist/preview.js +27 -0
  184. package/dist/react/dist/append.js +66 -0
  185. package/dist/react/dist/document-adapter.js +65 -0
  186. package/dist/react/dist/elements.js +59 -0
  187. package/dist/react/dist/index.js +68 -0
  188. package/dist/react/dist/reconciler.js +290 -0
  189. package/dist/react.d.ts +145 -0
  190. package/dist/react.js +27 -0
  191. package/dist/transition-Cips9wma.d.ts +82 -0
  192. package/dist/vanilla.d.ts +4 -0
  193. package/dist/vanilla.js +14 -0
  194. package/package.json +78 -3
@@ -0,0 +1,2272 @@
1
+ import { bcp47LangSchema, schemeColorNameSchema } from "../../../core/dist/theme.js";
2
+ import { matchLayoutPlaceholderKey } from "../../../core/dist/placeholders.js";
3
+ import "../../../core/dist/capability.js";
4
+ import { A_NS, C_NS, MC_NS, P_NS, R_NS, emuToPx } from "../../../import/dist/namespaces.js";
5
+ import { XmlElementCursor, parseXmlPart } from "../../../import/dist/xml-reader.js";
6
+ import { resolvePartPath } from "../../../import/dist/opc.js";
7
+ import { extentEmuFragmentSchema, hexRgb6Schema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlNonNegativeIntSchema, transformAttributesFragmentSchema } from "../../../import/dist/xml-fragments.js";
8
+ import "../../../import/dist/index.js";
9
+ import { attachDeferredSlideLink, readClickLink } from "../shared/identity.js";
10
+ import { isPlaceholderGraphicFrameElement, readNvPrPlaceholder } from "../shared/placeholder-import.js";
11
+ import { createChartNode } from "./chart-declaration.js";
12
+ import { chartAxisPositionFromNative, chartDataLabelPositionFromNative, chartErrorBarValueTypeFromNative, chartLegendPositionFromNative, chartLineDashFromNative, chartTrendlineTypeFromNative } from "./chart-labels.js";
13
+ import { z } from "zod";
14
+ // ../capabilities/dist/chart/chart-import.js
15
+ const C14_NS = "http://schemas.microsoft.com/office/drawing/2007/8/2/chart";
16
+ const C15_NS = "http://schemas.microsoft.com/office/drawing/2012/chart";
17
+ const WPS_ET_NS = "https://web.wps.cn/et/2018/main";
18
+ const C15_CAT_RANGE_EXT_URI = "{02D57815-91ED-43cb-92C2-25804820EDAC}";
19
+ const C15_DLBL_RANGE_FLAG_EXT_URI = "{CE6537A1-D6FC-4f65-9D91-7224C49458BB}";
20
+ const C16_UNIQUE_ID_EXT_URI = "{C3380CC4-5D6E-409C-BE32-E72D297353CC}";
21
+ const WPS_CHART_PROPS_EXT_URI = "{0b15fc19-7d7d-44ad-8c2d-2c3a37ce22c3}";
22
+ const NonVisualIdSchema = z.object({
23
+ id: ooxmlNonNegativeIntSchema,
24
+ name: z.string().optional()
25
+ });
26
+ const GraphicDataAttrSchema = z.object({ uri: z.string().min(1) });
27
+ const OoxmlFloatSchema = z.string().transform((value) => Number(value.trim())).refine((value) => Number.isFinite(value));
28
+ const SchemeColorSchema = z.object({ val: schemeColorNameSchema });
29
+ const BarDirSchema = z.object({ val: z.enum(["col", "bar"]) });
30
+ const GroupingSchema = z.object({ val: z.enum([
31
+ "clustered",
32
+ "stacked",
33
+ "percentStacked",
34
+ "standard"
35
+ ]) });
36
+ const ScatterStyleSchema = z.object({ val: z.enum([
37
+ "none",
38
+ "line",
39
+ "lineMarker",
40
+ "marker",
41
+ "smooth",
42
+ "smoothMarker"
43
+ ]) });
44
+ const CrossesSchema = z.object({ val: z.enum([
45
+ "autoZero",
46
+ "max",
47
+ "min"
48
+ ]) });
49
+ const TickMarkSchema = z.object({ val: z.enum([
50
+ "none",
51
+ "in",
52
+ "out",
53
+ "cross"
54
+ ]) });
55
+ const TickLblPosSchema = z.object({ val: z.enum([
56
+ "nextTo",
57
+ "high",
58
+ "low",
59
+ "none"
60
+ ]) });
61
+ const DispBlanksAsSchema = z.object({ val: z.enum([
62
+ "gap",
63
+ "zero",
64
+ "span"
65
+ ]) });
66
+ const DLblPosSchema = z.object({ val: z.enum([
67
+ "ctr",
68
+ "inEnd",
69
+ "inBase",
70
+ "outEnd",
71
+ "bestFit",
72
+ "l",
73
+ "r",
74
+ "b",
75
+ "t"
76
+ ]) });
77
+ const MarkerSymbolSchema = z.object({ val: z.enum([
78
+ "auto",
79
+ "circle",
80
+ "dash",
81
+ "diamond",
82
+ "dot",
83
+ "none",
84
+ "plus",
85
+ "square",
86
+ "star",
87
+ "triangle",
88
+ "x"
89
+ ]) });
90
+ const ErrBarTypeSchema = z.object({ val: z.enum([
91
+ "both",
92
+ "plus",
93
+ "minus"
94
+ ]) });
95
+ function directElementChild(parent, namespaceUri, localName) {
96
+ for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
97
+ if (child.nodeType !== 1) continue;
98
+ const el = child;
99
+ if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
100
+ }
101
+ }
102
+ /** Side-effect-free predicate matching `<p:graphicFrame>` elements containing DrawingML charts. */
103
+ function isChartGraphicFrame(cursor) {
104
+ const graphic = directElementChild(cursor.element, A_NS, "graphic");
105
+ if (graphic === void 0) return false;
106
+ const graphicData = directElementChild(graphic, A_NS, "graphicData");
107
+ if (graphicData === void 0) return false;
108
+ return graphicData.getAttribute("uri") === C_NS;
109
+ }
110
+ function consumeAllAttributes(cursor) {
111
+ const attrs = cursor.element.attributes;
112
+ for (let i = 0; i < attrs.length; i += 1) {
113
+ const attr = attrs.item(i);
114
+ if (attr === null) continue;
115
+ const ns = attr.namespaceURI ?? "";
116
+ const local = attr.localName ?? attr.name;
117
+ if (ns === "http://www.w3.org/2000/xmlns/" || attr.name === "xmlns" || attr.prefix === "xmlns") continue;
118
+ cursor.consumeAttr(local, ns);
119
+ }
120
+ }
121
+ /** Recursively consumes a known benign Office/WPS boilerplate element and its descendants. */
122
+ function consumeSubtree(cursor) {
123
+ consumeAllAttributes(cursor);
124
+ for (const child of cursor.remainingElementChildren()) consumeSubtree(child);
125
+ }
126
+ function readValAttr(cursor) {
127
+ return cursor?.attr("val");
128
+ }
129
+ function readBoolVal(cursor) {
130
+ const raw = readValAttr(cursor);
131
+ if (raw === void 0) return void 0;
132
+ const parsed = ooxmlBoolSchema.safeParse(raw);
133
+ return parsed.success ? parsed.data : void 0;
134
+ }
135
+ function readIntVal(cursor) {
136
+ const raw = readValAttr(cursor);
137
+ if (raw === void 0) return void 0;
138
+ const parsed = ooxmlIntSchema.safeParse(raw);
139
+ return parsed.success ? parsed.data : void 0;
140
+ }
141
+ function readFloatVal(cursor) {
142
+ const raw = readValAttr(cursor);
143
+ if (raw === void 0) return void 0;
144
+ const parsed = OoxmlFloatSchema.safeParse(raw);
145
+ return parsed.success ? parsed.data : void 0;
146
+ }
147
+ function readColorModifier(colorCursor, localName) {
148
+ const mod = colorCursor.child(A_NS, localName);
149
+ if (mod === void 0) return void 0;
150
+ const val = readIntVal(mod);
151
+ if (val === void 0 || val < 0 || val > 1e5) return void 0;
152
+ return val / 1e5;
153
+ }
154
+ function readSolidFillColor(fillCursor) {
155
+ const srgb = fillCursor.child(A_NS, "srgbClr");
156
+ const scheme = srgb === void 0 ? fillCursor.child(A_NS, "schemeClr") : void 0;
157
+ const colorCursor = srgb ?? scheme;
158
+ if (colorCursor === void 0) {
159
+ consumeSubtree(fillCursor);
160
+ return;
161
+ }
162
+ let baseString;
163
+ let schemeSlot;
164
+ if (srgb !== void 0) {
165
+ const raw = srgb.attrsObject(["val"]);
166
+ const parsed = hexRgb6Schema.safeParse(raw["val"]);
167
+ if (parsed.success) baseString = `#${parsed.data.toUpperCase()}`;
168
+ } else if (scheme !== void 0) {
169
+ const raw = scheme.attrsObject(["val"]);
170
+ const parsed = SchemeColorSchema.safeParse(raw);
171
+ if (parsed.success) schemeSlot = parsed.data.val;
172
+ }
173
+ const lumMod = readColorModifier(colorCursor, "lumMod");
174
+ const lumOff = readColorModifier(colorCursor, "lumOff");
175
+ const alpha = readColorModifier(colorCursor, "alpha");
176
+ consumeSubtree(colorCursor);
177
+ const baseColor = schemeSlot !== void 0 && lumMod !== void 0 ? {
178
+ slot: schemeSlot,
179
+ lumMod: Math.min(1, lumMod),
180
+ ...lumOff === void 0 ? {} : { lumOff: Math.min(1, lumOff) }
181
+ } : schemeSlot ?? baseString;
182
+ if (baseColor === void 0) return void 0;
183
+ return alpha === void 0 ? baseColor : {
184
+ color: baseColor,
185
+ alpha
186
+ };
187
+ }
188
+ function isEmptyXmlElement(el) {
189
+ return el.children.length === 0 && el.attributes.length === 0;
190
+ }
191
+ function consumeBenignLineElement(spPr) {
192
+ const lnEl = directElementChild(spPr.element, A_NS, "ln");
193
+ if (lnEl === void 0) return false;
194
+ const lnChildren = Array.from(lnEl.children);
195
+ if (!lnChildren.some((c) => c.namespaceURI === "http://schemas.openxmlformats.org/drawingml/2006/main" && c.localName === "noFill") && lnChildren.length > 0) return false;
196
+ if (!lnChildren.every((c) => c.namespaceURI === "http://schemas.openxmlformats.org/drawingml/2006/main" && (c.localName === "noFill" || c.localName === "round") && isEmptyXmlElement(c))) return false;
197
+ const ln = spPr.child(A_NS, "ln");
198
+ ln.consumeAttr("w");
199
+ ln.consumeAttr("cap");
200
+ for (const child of ln.remainingElementChildren()) consumeSubtree(child);
201
+ return true;
202
+ }
203
+ function consumeBenignChartSpPr(spPr) {
204
+ const noFillEl = directElementChild(spPr.element, A_NS, "noFill");
205
+ if (noFillEl !== void 0 && isEmptyXmlElement(noFillEl)) spPr.child(A_NS, "noFill");
206
+ consumeBenignLineElement(spPr);
207
+ const effectEl = directElementChild(spPr.element, A_NS, "effectLst");
208
+ if (effectEl !== void 0 && isEmptyXmlElement(effectEl)) spPr.child(A_NS, "effectLst");
209
+ const extEl = directElementChild(spPr.element, A_NS, "extLst");
210
+ if (extEl !== void 0 && isEmptyXmlElement(extEl)) spPr.child(A_NS, "extLst");
211
+ }
212
+ function readLineFromSpPr(spPr) {
213
+ const lnEl = directElementChild(spPr.element, A_NS, "ln");
214
+ if (lnEl === void 0) return { noLine: false };
215
+ if (directElementChild(lnEl, "http://schemas.openxmlformats.org/drawingml/2006/main", "noFill") !== void 0 && consumeBenignLineElement(spPr)) return { noLine: true };
216
+ const ln = spPr.child(A_NS, "ln");
217
+ const rawW = ln.attr("w");
218
+ ln.consumeAttr("cap");
219
+ const solidFill = ln.child(A_NS, "solidFill");
220
+ const color = solidFill === void 0 ? void 0 : readSolidFillColor(solidFill);
221
+ const prstDash = ln.child(A_NS, "prstDash");
222
+ let dash;
223
+ if (prstDash !== void 0) {
224
+ const rawDash = prstDash.attrsObject(["val"])["val"];
225
+ if (rawDash !== void 0) dash = chartLineDashFromNative[rawDash];
226
+ }
227
+ const roundEl = directElementChild(ln.element, A_NS, "round");
228
+ if (roundEl !== void 0 && isEmptyXmlElement(roundEl)) ln.child(A_NS, "round");
229
+ let width;
230
+ if (rawW !== void 0) {
231
+ const parsedW = ooxmlIntSchema.safeParse(rawW);
232
+ if (parsedW.success && parsedW.data > 0) width = emuToPx(parsedW.data);
233
+ }
234
+ if (color === void 0 && width === void 0 && dash === void 0) return { noLine: false };
235
+ return {
236
+ noLine: false,
237
+ line: {
238
+ ...color === void 0 ? {} : { color },
239
+ ...width === void 0 ? {} : { width },
240
+ ...dash === void 0 ? {} : { dash }
241
+ }
242
+ };
243
+ }
244
+ function readSeriesSpPr(spPr, ignoreLine) {
245
+ const solidFill = spPr.child(A_NS, "solidFill");
246
+ const color = solidFill === void 0 ? void 0 : readSolidFillColor(solidFill);
247
+ const { line } = ignoreLine ? (consumeBenignLineElement(spPr), { line: void 0 }) : readLineFromSpPr(spPr);
248
+ consumeBenignChartSpPr(spPr);
249
+ return {
250
+ ...color === void 0 ? {} : { color },
251
+ ...line === void 0 ? {} : { line }
252
+ };
253
+ }
254
+ function resolveChartTypefaceToken(typeface) {
255
+ if (typeface === "+mn-lt" || typeface === "+mn-ea" || typeface === "+mn-cs") return "minor";
256
+ if (typeface === "+mj-lt" || typeface === "+mj-ea" || typeface === "+mj-cs") return "major";
257
+ return typeface;
258
+ }
259
+ function readChartOuterShadow(rPrCursor) {
260
+ const effectLst = rPrCursor.child(A_NS, "effectLst");
261
+ if (effectLst === void 0) return void 0;
262
+ const outerShdw = effectLst.child(A_NS, "outerShdw");
263
+ if (outerShdw === void 0) {
264
+ consumeSubtree(effectLst);
265
+ return;
266
+ }
267
+ const blurRadRaw = outerShdw.attr("blurRad");
268
+ const distRaw = outerShdw.attr("dist");
269
+ const dirRaw = outerShdw.attr("dir");
270
+ outerShdw.consumeAttr("algn");
271
+ outerShdw.consumeAttr("rotWithShape");
272
+ const color = readSolidFillColor(outerShdw);
273
+ consumeSubtree(outerShdw);
274
+ consumeSubtree(effectLst);
275
+ const blurRad = blurRadRaw === void 0 ? void 0 : ooxmlNonNegativeIntSchema.safeParse(blurRadRaw);
276
+ const dist = distRaw === void 0 ? void 0 : ooxmlNonNegativeIntSchema.safeParse(distRaw);
277
+ const dir = dirRaw === void 0 ? void 0 : ooxmlIntSchema.safeParse(dirRaw);
278
+ return {
279
+ ...color === void 0 ? {} : { color },
280
+ ...blurRad?.success ? { blur: emuToPx(blurRad.data) } : {},
281
+ ...dist?.success ? { distance: emuToPx(dist.data) } : {},
282
+ ...dir?.success ? { angle: dir.data / 6e4 } : {}
283
+ };
284
+ }
285
+ function readChartRunProperties(rPrCursor) {
286
+ const rawLang = rPrCursor.attr("lang");
287
+ const parsedLang = rawLang === void 0 ? void 0 : bcp47LangSchema.safeParse(rawLang);
288
+ const lang = parsedLang?.success ? parsedLang.data : void 0;
289
+ const szRaw = rPrCursor.attr("sz");
290
+ const szParsed = szRaw === void 0 ? void 0 : ooxmlIntSchema.safeParse(szRaw);
291
+ const fontSize = szParsed?.success && szParsed.data >= 100 && szParsed.data <= 4e5 ? `${szParsed.data / 100}pt` : void 0;
292
+ const bRaw = rPrCursor.attr("b");
293
+ const bParsed = bRaw === void 0 ? void 0 : ooxmlBoolSchema.safeParse(bRaw);
294
+ const fontWeight = bParsed?.success ? bParsed.data ? "bold" : "normal" : void 0;
295
+ const iRaw = rPrCursor.attr("i");
296
+ const iParsed = iRaw === void 0 ? void 0 : ooxmlBoolSchema.safeParse(iRaw);
297
+ const fontStyle = iParsed?.success ? iParsed.data ? "italic" : "normal" : void 0;
298
+ const uRaw = rPrCursor.attr("u");
299
+ const strikeRaw = rPrCursor.attr("strike");
300
+ let textDecoration;
301
+ if (uRaw === "sng") textDecoration = "underline";
302
+ else if (strikeRaw === "sngStrike") textDecoration = "line-through";
303
+ else if (uRaw === "none" && strikeRaw === "noStrike") textDecoration = "none";
304
+ const capRaw = rPrCursor.attr("cap");
305
+ let textTransform;
306
+ if (capRaw === "all") textTransform = "uppercase";
307
+ else if (capRaw === "none") textTransform = "none";
308
+ const spcRaw = rPrCursor.attr("spc");
309
+ const spcParsed = spcRaw === void 0 ? void 0 : ooxmlIntSchema.safeParse(spcRaw);
310
+ const letterSpacing = spcParsed?.success && spcParsed.data >= -4e5 && spcParsed.data <= 4e5 ? spcParsed.data / 75 : void 0;
311
+ const solidFill = rPrCursor.child(A_NS, "solidFill");
312
+ const color = solidFill === void 0 ? void 0 : readSolidFillColor(solidFill);
313
+ if (solidFill !== void 0) consumeSubtree(solidFill);
314
+ const textShadow = readChartOuterShadow(rPrCursor);
315
+ const latin = rPrCursor.child(A_NS, "latin");
316
+ const ea = rPrCursor.child(A_NS, "ea");
317
+ const cs = rPrCursor.child(A_NS, "cs");
318
+ const latinTypeface = latin?.attr("typeface");
319
+ const eaTypeface = ea?.attr("typeface");
320
+ const csTypeface = cs?.attr("typeface");
321
+ if (latin !== void 0) consumeSubtree(latin);
322
+ if (ea !== void 0) consumeSubtree(ea);
323
+ if (cs !== void 0) consumeSubtree(cs);
324
+ const typeface = latinTypeface ?? eaTypeface ?? csTypeface;
325
+ let fontFamily;
326
+ if (typeface !== void 0 && typeface.trim() !== "") fontFamily = resolveChartTypefaceToken(typeface);
327
+ consumeSubtree(rPrCursor);
328
+ return {
329
+ ...fontFamily === void 0 ? {} : { fontFamily },
330
+ ...fontSize === void 0 ? {} : { fontSize },
331
+ ...fontWeight === void 0 ? {} : { fontWeight },
332
+ ...fontStyle === void 0 ? {} : { fontStyle },
333
+ ...color === void 0 ? {} : { color },
334
+ ...letterSpacing === void 0 ? {} : { letterSpacing },
335
+ ...textTransform === void 0 ? {} : { textTransform },
336
+ ...textDecoration === void 0 ? {} : { textDecoration },
337
+ ...textShadow === void 0 ? {} : { textShadow },
338
+ ...lang === void 0 ? {} : { lang }
339
+ };
340
+ }
341
+ function readChartTextProperties(txPrCursor) {
342
+ let verticalAlign;
343
+ const bodyPr = txPrCursor.child(A_NS, "bodyPr");
344
+ if (bodyPr !== void 0) {
345
+ const anchor = bodyPr.attr("anchor");
346
+ if (anchor === "t") verticalAlign = "top";
347
+ else if (anchor === "ctr") verticalAlign = "middle";
348
+ else if (anchor === "b") verticalAlign = "bottom";
349
+ consumeSubtree(bodyPr);
350
+ }
351
+ let align;
352
+ let lineHeight;
353
+ let spacingAfter;
354
+ let defStyle = {};
355
+ let runStyle = {};
356
+ let endLang;
357
+ const p = txPrCursor.child(A_NS, "p");
358
+ if (p !== void 0) {
359
+ const pPr = p.child(A_NS, "pPr");
360
+ if (pPr !== void 0) {
361
+ const algn = pPr.attr("algn");
362
+ if (algn === "l") align = "left";
363
+ else if (algn === "ctr") align = "center";
364
+ else if (algn === "r") align = "right";
365
+ else if (algn === "just") align = "justify";
366
+ const lnSpc = pPr.child(A_NS, "lnSpc");
367
+ if (lnSpc !== void 0) {
368
+ const spcPts = readIntVal(lnSpc.child(A_NS, "spcPts"));
369
+ if (spcPts !== void 0 && spcPts > 0 && spcPts <= 158400) lineHeight = `${spcPts / 100}pt`;
370
+ consumeSubtree(lnSpc);
371
+ }
372
+ const spcAft = pPr.child(A_NS, "spcAft");
373
+ if (spcAft !== void 0) {
374
+ const spcPts = readIntVal(spcAft.child(A_NS, "spcPts"));
375
+ if (spcPts !== void 0 && spcPts >= 0 && spcPts <= 158400) spacingAfter = spcPts / 75;
376
+ consumeSubtree(spcAft);
377
+ }
378
+ const defRPr = pPr.child(A_NS, "defRPr");
379
+ if (defRPr !== void 0) defStyle = readChartRunProperties(defRPr);
380
+ consumeSubtree(pPr);
381
+ }
382
+ const r = p.child(A_NS, "r");
383
+ if (r !== void 0) {
384
+ const rPr = r.child(A_NS, "rPr");
385
+ if (rPr !== void 0) runStyle = readChartRunProperties(rPr);
386
+ consumeSubtree(r);
387
+ }
388
+ const endParaRPr = p.child(A_NS, "endParaRPr");
389
+ if (endParaRPr !== void 0) {
390
+ const rawLang = endParaRPr.attr("lang");
391
+ const parsedLang = rawLang === void 0 ? void 0 : bcp47LangSchema.safeParse(rawLang);
392
+ if (parsedLang?.success) endLang = parsedLang.data;
393
+ consumeSubtree(endParaRPr);
394
+ }
395
+ consumeSubtree(p);
396
+ }
397
+ consumeSubtree(txPrCursor);
398
+ const merged = {
399
+ ...defStyle,
400
+ ...runStyle,
401
+ ...endLang !== void 0 && defStyle.lang === void 0 && runStyle.lang === void 0 ? { lang: endLang } : {},
402
+ ...verticalAlign === void 0 ? {} : { verticalAlign },
403
+ ...align === void 0 ? {} : { align },
404
+ ...lineHeight === void 0 ? {} : { lineHeight },
405
+ ...spacingAfter === void 0 ? {} : { spacingAfter }
406
+ };
407
+ return Object.keys(merged).length === 0 ? void 0 : merged;
408
+ }
409
+ function fontSizePointsValue(value) {
410
+ if (typeof value === "number") return value * .75;
411
+ if (typeof value === "string") {
412
+ if (value.endsWith("pt")) return Number(value.slice(0, -2));
413
+ if (value.endsWith("px")) return Number(value.slice(0, -2)) * .75;
414
+ }
415
+ }
416
+ function stableJsonEqual(left, right) {
417
+ if (left === right) return true;
418
+ if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) return false;
419
+ const leftKeys = Object.keys(left).filter((k) => left[k] !== void 0);
420
+ const rightKeys = Object.keys(right).filter((k) => right[k] !== void 0);
421
+ if (leftKeys.length !== rightKeys.length) return false;
422
+ return leftKeys.every((key) => stableJsonEqual(left[key], right[key]));
423
+ }
424
+ function styleFieldEqual(key, left, right) {
425
+ if (left === right) return true;
426
+ if (key === "fontSize" || key === "lineHeight") {
427
+ const lPt = fontSizePointsValue(left);
428
+ const rPt = fontSizePointsValue(right);
429
+ return lPt !== void 0 && rPt !== void 0 && Math.abs(lPt - rPt) < 1e-6;
430
+ }
431
+ return stableJsonEqual(left, right);
432
+ }
433
+ function diffChartTextStyle(child, inherited) {
434
+ if (child === void 0) return void 0;
435
+ const baseline = {
436
+ fontWeight: "normal",
437
+ fontStyle: "normal",
438
+ verticalAlign: "top",
439
+ textDecoration: "none",
440
+ textTransform: "none",
441
+ color: "dk1",
442
+ ...inherited
443
+ };
444
+ const out = {};
445
+ for (const [key, value] of Object.entries(child)) {
446
+ if (value === void 0) continue;
447
+ const baseValue = baseline[key];
448
+ if (!styleFieldEqual(key, value, baseValue)) out[key] = value;
449
+ }
450
+ return Object.keys(out).length === 0 ? void 0 : out;
451
+ }
452
+ function normalizeRootChartStyle(rawStyle) {
453
+ if (rawStyle === void 0) return void 0;
454
+ const out = {};
455
+ for (const [key, value] of Object.entries(rawStyle)) {
456
+ if (value === void 0) continue;
457
+ if (key === "fontWeight" && value === "normal") continue;
458
+ if (key === "fontStyle" && value === "normal") continue;
459
+ if (key === "verticalAlign" && value === "top") continue;
460
+ if (key === "textDecoration" && value === "none") continue;
461
+ if (key === "textTransform" && value === "none") continue;
462
+ out[key] = value;
463
+ }
464
+ return Object.keys(out).length === 0 ? void 0 : out;
465
+ }
466
+ function readChartTitle(titleCursor, inheritedStyle) {
467
+ let titleText;
468
+ let richStyle;
469
+ const tx = titleCursor.child(C_NS, "tx");
470
+ if (tx !== void 0) {
471
+ const rich = tx.child(C_NS, "rich");
472
+ if (rich !== void 0) {
473
+ const bodyPr = rich.child(A_NS, "bodyPr");
474
+ const anchor = bodyPr?.attr("anchor");
475
+ const verticalAlign = anchor === "t" ? "top" : anchor === "ctr" ? "middle" : anchor === "b" ? "bottom" : void 0;
476
+ if (bodyPr !== void 0) consumeSubtree(bodyPr);
477
+ let align;
478
+ let lineHeight;
479
+ let spacingAfter;
480
+ let defRun = {};
481
+ let explicitRun = {};
482
+ const parts = [];
483
+ for (const [paraIndex, para] of rich.children(A_NS, "p").entries()) {
484
+ if (paraIndex === 0) {
485
+ const pPr = para.child(A_NS, "pPr");
486
+ if (pPr !== void 0) {
487
+ const algn = pPr.attr("algn");
488
+ align = algn === "l" ? "left" : algn === "ctr" ? "center" : algn === "r" ? "right" : algn === "just" ? "justify" : void 0;
489
+ const lnSpc = pPr.child(A_NS, "lnSpc");
490
+ if (lnSpc !== void 0) {
491
+ const spcPts = readIntVal(lnSpc.child(A_NS, "spcPts"));
492
+ if (spcPts !== void 0 && spcPts > 0 && spcPts <= 158400) lineHeight = `${spcPts / 100}pt`;
493
+ consumeSubtree(lnSpc);
494
+ }
495
+ const spcAft = pPr.child(A_NS, "spcAft");
496
+ if (spcAft !== void 0) {
497
+ const spcPts = readIntVal(spcAft.child(A_NS, "spcPts"));
498
+ if (spcPts !== void 0 && spcPts >= 0 && spcPts <= 158400) spacingAfter = spcPts / 75;
499
+ consumeSubtree(spcAft);
500
+ }
501
+ const defRPr = pPr.child(A_NS, "defRPr");
502
+ if (defRPr !== void 0) defRun = readChartRunProperties(defRPr);
503
+ consumeSubtree(pPr);
504
+ }
505
+ }
506
+ const runs = [];
507
+ for (const child of para.remainingElementChildren()) if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "r") {
508
+ if (paraIndex === 0 && Object.keys(explicitRun).length === 0) {
509
+ const rPr = child.child(A_NS, "rPr");
510
+ if (rPr !== void 0) explicitRun = readChartRunProperties(rPr);
511
+ }
512
+ const t = child.child(A_NS, "t");
513
+ if (t !== void 0) runs.push(t.textContent);
514
+ consumeSubtree(child);
515
+ } else if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "br") {
516
+ runs.push("\n");
517
+ consumeSubtree(child);
518
+ } else consumeSubtree(child);
519
+ consumeSubtree(para);
520
+ parts.push(runs.join(""));
521
+ }
522
+ titleText = parts.join("\n");
523
+ consumeSubtree(rich);
524
+ richStyle = {
525
+ ...defRun,
526
+ ...explicitRun,
527
+ ...verticalAlign === void 0 ? {} : { verticalAlign },
528
+ ...align === void 0 ? {} : { align },
529
+ ...lineHeight === void 0 ? {} : { lineHeight },
530
+ ...spacingAfter === void 0 ? {} : { spacingAfter }
531
+ };
532
+ } else {
533
+ const strRef = tx.child(C_NS, "strRef");
534
+ if (strRef !== void 0) {
535
+ const strCache = strRef.child(C_NS, "strCache");
536
+ if (strCache !== void 0) {
537
+ const v = strCache.children(C_NS, "pt")[0]?.child(C_NS, "v");
538
+ if (v !== void 0) titleText = v.textContent;
539
+ }
540
+ consumeSubtree(strRef);
541
+ } else {
542
+ const v = tx.child(C_NS, "v");
543
+ if (v !== void 0) titleText = v.textContent;
544
+ }
545
+ }
546
+ consumeSubtree(tx);
547
+ }
548
+ const txPr = titleCursor.child(C_NS, "txPr");
549
+ const txPrStyle = txPr === void 0 ? void 0 : readChartTextProperties(txPr);
550
+ consumeSubtree(titleCursor);
551
+ if (titleText === void 0 || titleText.trim() === "") return void 0;
552
+ const styleDiff = diffChartTextStyle(richStyle !== void 0 || txPrStyle !== void 0 ? {
553
+ ...txPrStyle,
554
+ ...richStyle
555
+ } : void 0, inheritedStyle);
556
+ return styleDiff === void 0 ? titleText : {
557
+ text: titleText,
558
+ style: styleDiff
559
+ };
560
+ }
561
+ function readPtCount(container) {
562
+ const ptCountCursor = container.child(C_NS, "ptCount");
563
+ if (ptCountCursor === void 0) return void 0;
564
+ const raw = readValAttr(ptCountCursor);
565
+ if (raw === void 0) return void 0;
566
+ const parsed = ooxmlNonNegativeIntSchema.safeParse(raw);
567
+ return parsed.success ? parsed.data : void 0;
568
+ }
569
+ function readStringCacheOrLit(container) {
570
+ const ptCount = readPtCount(container) ?? 0;
571
+ const pts = container.children(C_NS, "pt");
572
+ const size = Math.max(ptCount, pts.length);
573
+ if (size === 0) {
574
+ consumeSubtree(container);
575
+ return [];
576
+ }
577
+ const result = Array.from({ length: size }).fill("");
578
+ for (const pt of pts) {
579
+ const rawIdx = pt.attr("idx");
580
+ const parsedIdx = rawIdx === void 0 ? void 0 : ooxmlNonNegativeIntSchema.safeParse(rawIdx);
581
+ const text = pt.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "v")?.textContent ?? "";
582
+ consumeSubtree(pt);
583
+ if (parsedIdx?.success && parsedIdx.data < result.length) result[parsedIdx.data] = text;
584
+ }
585
+ consumeSubtree(container);
586
+ return result;
587
+ }
588
+ function readNumericCacheOrLitAsStrings(container) {
589
+ const formatCode = container.child(C_NS, "formatCode");
590
+ if (formatCode !== void 0) consumeSubtree(formatCode);
591
+ return readStringCacheOrLit(container);
592
+ }
593
+ function readNumericCacheOrLit(container) {
594
+ const formatCode = container.child(C_NS, "formatCode");
595
+ if (formatCode !== void 0) consumeSubtree(formatCode);
596
+ const ptCount = readPtCount(container);
597
+ const pts = container.children(C_NS, "pt");
598
+ if (ptCount === void 0 && pts.length === 0) {
599
+ consumeSubtree(container);
600
+ return [];
601
+ }
602
+ const length = ptCount ?? pts.length;
603
+ const result = Array.from({ length }).fill(null);
604
+ for (const pt of pts) {
605
+ const rawIdx = pt.attr("idx");
606
+ pt.consumeAttr("formatCode");
607
+ const parsedIdx = rawIdx === void 0 ? void 0 : ooxmlNonNegativeIntSchema.safeParse(rawIdx);
608
+ const rawVal = pt.child(C_NS, "v")?.textContent.trim();
609
+ consumeSubtree(pt);
610
+ if (parsedIdx?.success && parsedIdx.data < result.length && rawVal !== void 0 && rawVal !== "") {
611
+ const numeric = Number(rawVal);
612
+ if (Number.isFinite(numeric)) result[parsedIdx.data] = numeric;
613
+ }
614
+ }
615
+ consumeSubtree(container);
616
+ return result;
617
+ }
618
+ function readStringDataSource(sourceCursor) {
619
+ const strRef = sourceCursor.child(C_NS, "strRef");
620
+ if (strRef !== void 0) {
621
+ const formula = strRef.child(C_NS, "f")?.textContent;
622
+ const strCache = strRef.child(C_NS, "strCache");
623
+ const values = strCache === void 0 ? [] : readStringCacheOrLit(strCache);
624
+ consumeSubtree(strRef);
625
+ return {
626
+ ...formula === void 0 ? {} : { formula },
627
+ values
628
+ };
629
+ }
630
+ const strLit = sourceCursor.child(C_NS, "strLit");
631
+ if (strLit !== void 0) return { values: readStringCacheOrLit(strLit) };
632
+ const numRef = sourceCursor.child(C_NS, "numRef");
633
+ if (numRef !== void 0) {
634
+ const formula = numRef.child(C_NS, "f")?.textContent;
635
+ const numCache = numRef.child(C_NS, "numCache");
636
+ const values = numCache === void 0 ? [] : readNumericCacheOrLitAsStrings(numCache);
637
+ consumeSubtree(numRef);
638
+ return {
639
+ ...formula === void 0 ? {} : { formula },
640
+ values
641
+ };
642
+ }
643
+ const numLit = sourceCursor.child(C_NS, "numLit");
644
+ if (numLit !== void 0) return { values: readNumericCacheOrLitAsStrings(numLit) };
645
+ const multiLvlStrRef = sourceCursor.child(C_NS, "multiLvlStrRef");
646
+ if (multiLvlStrRef !== void 0) {
647
+ const formula = multiLvlStrRef.child(C_NS, "f")?.textContent;
648
+ const cache = multiLvlStrRef.child(C_NS, "multiLvlStrCache");
649
+ let values = [];
650
+ if (cache !== void 0) {
651
+ const ptCount = readPtCount(cache) ?? 0;
652
+ const lvls = cache.children(C_NS, "lvl");
653
+ if (ptCount > 0 && lvls.length > 0) {
654
+ const arr = Array.from({ length: ptCount }).fill("");
655
+ for (const pt of lvls[0].children(C_NS, "pt")) {
656
+ const rawIdx = pt.attr("idx");
657
+ const parsedIdx = rawIdx === void 0 ? void 0 : ooxmlNonNegativeIntSchema.safeParse(rawIdx);
658
+ const v = pt.child(C_NS, "v");
659
+ if (parsedIdx?.success && parsedIdx.data < arr.length && v !== void 0) arr[parsedIdx.data] = v.textContent;
660
+ consumeSubtree(pt);
661
+ }
662
+ values = arr;
663
+ }
664
+ consumeSubtree(cache);
665
+ }
666
+ consumeSubtree(multiLvlStrRef);
667
+ return {
668
+ ...formula === void 0 ? {} : { formula },
669
+ values
670
+ };
671
+ }
672
+ return { values: [] };
673
+ }
674
+ function readNumericDataSource(sourceCursor) {
675
+ const numRef = sourceCursor.child(C_NS, "numRef");
676
+ if (numRef !== void 0) {
677
+ const f = numRef.child(C_NS, "f");
678
+ if (f !== void 0) consumeSubtree(f);
679
+ const numCache = numRef.child(C_NS, "numCache");
680
+ const values = numCache === void 0 ? [] : readNumericCacheOrLit(numCache);
681
+ consumeSubtree(numRef);
682
+ return values;
683
+ }
684
+ const numLit = sourceCursor.child(C_NS, "numLit");
685
+ if (numLit !== void 0) return readNumericCacheOrLit(numLit);
686
+ return [];
687
+ }
688
+ function readSeriesName(txCursor) {
689
+ if (txCursor === void 0) return void 0;
690
+ const strRef = txCursor.child(C_NS, "strRef");
691
+ if (strRef !== void 0) {
692
+ const f = strRef.child(C_NS, "f");
693
+ if (f !== void 0) consumeSubtree(f);
694
+ const strCache = strRef.child(C_NS, "strCache");
695
+ const values = strCache === void 0 ? [] : readStringCacheOrLit(strCache);
696
+ consumeSubtree(strRef);
697
+ consumeSubtree(txCursor);
698
+ return values[0];
699
+ }
700
+ const text = txCursor.child(C_NS, "v")?.textContent;
701
+ consumeSubtree(txCursor);
702
+ return text;
703
+ }
704
+ function readMarkerElement(markerCursor) {
705
+ const symbolCursor = markerCursor.child(C_NS, "symbol");
706
+ const parsedSymbol = symbolCursor === void 0 ? void 0 : MarkerSymbolSchema.safeParse(symbolCursor.attrsObject(["val"]));
707
+ const symbol = parsedSymbol?.success ? parsedSymbol.data.val : void 0;
708
+ const size = readIntVal(markerCursor.child(C_NS, "size"));
709
+ const spPr = markerCursor.child(C_NS, "spPr");
710
+ let fill;
711
+ let line;
712
+ if (spPr !== void 0) {
713
+ const solidFill = spPr.child(A_NS, "solidFill");
714
+ if (solidFill !== void 0) fill = readSolidFillColor(solidFill);
715
+ line = readLineFromSpPr(spPr).line;
716
+ consumeSubtree(spPr);
717
+ }
718
+ consumeSubtree(markerCursor);
719
+ if (symbol === "none" && size === void 0 && fill === void 0 && line === void 0) return false;
720
+ if (symbol === void 0 && size === void 0 && fill === void 0 && line === void 0) return;
721
+ return {
722
+ ...symbol === void 0 ? {} : { symbol },
723
+ ...size !== void 0 && size >= 2 && size <= 72 ? { size } : {},
724
+ ...fill === void 0 ? {} : { fill },
725
+ ...line === void 0 ? {} : { line }
726
+ };
727
+ }
728
+ function readDataLabelSettingsBody(cursor, kind, isPointLevel = false) {
729
+ const numFmtCursor = cursor.child(C_NS, "numFmt");
730
+ let numberFormat;
731
+ if (numFmtCursor !== void 0) {
732
+ const code = numFmtCursor.attr("formatCode");
733
+ const slRaw = numFmtCursor.attr("sourceLinked");
734
+ if (code !== void 0 && code.trim() !== "" && (slRaw === "0" || slRaw === "false" || code !== "General")) numberFormat = code;
735
+ consumeSubtree(numFmtCursor);
736
+ }
737
+ const spPr = cursor.child(C_NS, "spPr");
738
+ if (spPr !== void 0) consumeSubtree(spPr);
739
+ const txPr = cursor.child(C_NS, "txPr");
740
+ const rawStyle = txPr === void 0 ? void 0 : readChartTextProperties(txPr);
741
+ const dLblPos = cursor.child(C_NS, "dLblPos");
742
+ let position;
743
+ if (dLblPos !== void 0) {
744
+ const parsed = DLblPosSchema.safeParse(dLblPos.attrsObject(["val"]));
745
+ if (parsed.success && kind !== "area" && kind !== "doughnut") {
746
+ const mapped = chartDataLabelPositionFromNative[parsed.data.val];
747
+ if (mapped !== void 0 && (kind !== "scatter" || [
748
+ "left",
749
+ "right",
750
+ "bottom",
751
+ "top",
752
+ "center"
753
+ ].includes(mapped))) position = mapped;
754
+ }
755
+ }
756
+ const legendKey = cursor.child(C_NS, "showLegendKey");
757
+ if (legendKey !== void 0) consumeSubtree(legendKey);
758
+ const showVal = readBoolVal(cursor.child(C_NS, "showVal"));
759
+ const showCatName = readBoolVal(cursor.child(C_NS, "showCatName"));
760
+ const showSerName = readBoolVal(cursor.child(C_NS, "showSerName"));
761
+ const showPercent = readBoolVal(cursor.child(C_NS, "showPercent"));
762
+ const showBubbleSize = cursor.child(C_NS, "showBubbleSize");
763
+ if (showBubbleSize !== void 0) consumeSubtree(showBubbleSize);
764
+ const sepCursor = cursor.child(C_NS, "separator");
765
+ const separator = sepCursor !== void 0 && sepCursor.textContent.length > 0 ? sepCursor.textContent : void 0;
766
+ const showLeaderLines = readBoolVal(cursor.child(C_NS, "showLeaderLines"));
767
+ const leaderLinesCursor = cursor.child(C_NS, "leaderLines");
768
+ let leaderLineStyle;
769
+ if (leaderLinesCursor !== void 0) {
770
+ const lSpPr = leaderLinesCursor.child(C_NS, "spPr");
771
+ if (lSpPr !== void 0) {
772
+ leaderLineStyle = readLineFromSpPr(lSpPr).line;
773
+ consumeSubtree(lSpPr);
774
+ }
775
+ consumeSubtree(leaderLinesCursor);
776
+ }
777
+ let showDataLabelsRange;
778
+ const extLst = cursor.child(C_NS, "extLst");
779
+ if (extLst !== void 0) for (const ext of extLst.children(C_NS, "ext")) {
780
+ const uri = ext.attr("uri");
781
+ if (uri === C15_DLBL_RANGE_FLAG_EXT_URI) {
782
+ showDataLabelsRange = readBoolVal(ext.child(C15_NS, "showDataLabelsRange"));
783
+ consumeSubtree(ext);
784
+ } else if (uri === "{CE6537A1-D6FC-4f65-9D91-7224C49458BB}" || uri === "{0b15fc19-7d7d-44ad-8c2d-2c3a37ce22c3}" || uri === C16_UNIQUE_ID_EXT_URI) consumeSubtree(ext);
785
+ else if (directElementChild(ext.element, C15_NS, "layout") !== void 0 || directElementChild(ext.element, C15_NS, "showLeaderLines") !== void 0 || directElementChild(ext.element, C15_NS, "leaderLines") !== void 0 || directElementChild(ext.element, C15_NS, "showDataLabelsRange") !== void 0) consumeSubtree(ext);
786
+ }
787
+ for (const rem of cursor.remainingElementChildren()) if (rem.namespaceUri === C15_NS) consumeSubtree(rem);
788
+ const category = kind === "scatter" ? void 0 : showDataLabelsRange === true ? true : showCatName === true ? true : showCatName === false && showDataLabelsRange === false ? false : void 0;
789
+ const xValue = kind === "scatter" && showCatName === true ? true : void 0;
790
+ const value = showVal === true ? true : showVal === false ? false : void 0;
791
+ const percent = (kind === "pie" || kind === "doughnut") && showPercent === true ? true : (kind === "pie" || kind === "doughnut") && showPercent === false ? false : void 0;
792
+ const seriesName = showSerName === true ? true : showSerName === false ? false : void 0;
793
+ const hasVisibleContent = value === true || percent === true || category === true || xValue === true || seriesName === true;
794
+ let leaderLines;
795
+ if (!isPointLevel && (kind === "pie" || kind === "doughnut") && hasVisibleContent) {
796
+ if (leaderLineStyle !== void 0) leaderLines = leaderLineStyle;
797
+ else if (showLeaderLines !== void 0) leaderLines = showLeaderLines;
798
+ }
799
+ return {
800
+ settings: {
801
+ ...value === void 0 ? {} : { value },
802
+ ...percent === void 0 ? {} : { percent },
803
+ ...category === void 0 ? {} : { category },
804
+ ...xValue === void 0 ? {} : { xValue },
805
+ ...seriesName === void 0 ? {} : { seriesName },
806
+ ...separator === void 0 ? {} : { separator },
807
+ ...position === void 0 ? {} : { position },
808
+ ...numberFormat === void 0 ? {} : { numberFormat },
809
+ ...leaderLines === void 0 ? {} : { leaderLines }
810
+ },
811
+ ...rawStyle === void 0 ? {} : { rawStyle },
812
+ ...showDataLabelsRange === void 0 ? {} : { showDataLabelsRange }
813
+ };
814
+ }
815
+ function readDataLabelsElement(dLblsCursor, kind, isGroupLevel, inheritedChartStyle) {
816
+ const pointLabels = /* @__PURE__ */ new Map();
817
+ const pointRawColors = /* @__PURE__ */ new Map();
818
+ for (const dLbl of dLblsCursor.children(C_NS, "dLbl")) {
819
+ const idx = readIntVal(dLbl.child(C_NS, "idx"));
820
+ const del = readBoolVal(dLbl.child(C_NS, "delete"));
821
+ if (idx !== void 0) {
822
+ if (del === true) pointLabels.set(idx, false);
823
+ else {
824
+ const { settings, rawStyle } = readDataLabelSettingsBody(dLbl, kind, true);
825
+ pointLabels.set(idx, settings);
826
+ if (rawStyle?.color !== void 0) pointRawColors.set(idx, rawStyle.color);
827
+ }
828
+ }
829
+ consumeSubtree(dLbl);
830
+ }
831
+ if (readBoolVal(dLblsCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "delete")) === true) {
832
+ consumeSubtree(dLblsCursor);
833
+ return {
834
+ dataLabels: false,
835
+ pointLabels,
836
+ pointLabelColors: /* @__PURE__ */ new Map()
837
+ };
838
+ }
839
+ const { settings, rawStyle, showDataLabelsRange } = readDataLabelSettingsBody(dLblsCursor, kind, false);
840
+ const dataLabelsStyle = diffChartTextStyle(rawStyle, inheritedChartStyle);
841
+ const inheritedLabelColor = rawStyle?.color ?? inheritedChartStyle?.color ?? "dk1";
842
+ const pointLabelColors = /* @__PURE__ */ new Map();
843
+ for (const [idx, color] of pointRawColors.entries()) if (!stableJsonEqual(color, inheritedLabelColor)) pointLabelColors.set(idx, color);
844
+ const hasAnyEnabledOrCustomized = settings.value === true || settings.percent === true || settings.category === true || settings.xValue === true || settings.seriesName === true || settings.separator !== void 0 || settings.numberFormat !== void 0 || settings.position !== void 0 || settings.leaderLines !== void 0 || dataLabelsStyle !== void 0;
845
+ if (isGroupLevel && !hasAnyEnabledOrCustomized) return {
846
+ pointLabels,
847
+ pointLabelColors
848
+ };
849
+ const normalized = {
850
+ ...settings.value === true ? { value: true } : {},
851
+ ...settings.percent === true ? { percent: true } : {},
852
+ ...settings.category === true ? { category: true } : {},
853
+ ...settings.xValue === true ? { xValue: true } : {},
854
+ ...settings.seriesName === true ? { seriesName: true } : {},
855
+ ...settings.separator === void 0 ? {} : { separator: settings.separator },
856
+ ...settings.position === void 0 ? {} : { position: settings.position },
857
+ ...settings.numberFormat === void 0 ? {} : { numberFormat: settings.numberFormat },
858
+ ...settings.leaderLines === void 0 ? {} : { leaderLines: settings.leaderLines }
859
+ };
860
+ return {
861
+ ...Object.keys(normalized).length > 0 ? { dataLabels: normalized } : {},
862
+ ...dataLabelsStyle === void 0 ? {} : { dataLabelsStyle },
863
+ pointLabels,
864
+ pointLabelColors,
865
+ ...showDataLabelsRange === void 0 ? {} : { showDataLabelsRange }
866
+ };
867
+ }
868
+ function diffPointDataLabels(pointLabels, seriesLabels) {
869
+ if (pointLabels === false) return false;
870
+ if (seriesLabels === void 0 || seriesLabels === false) return Object.keys(pointLabels).length === 0 ? void 0 : pointLabels;
871
+ const out = {};
872
+ for (const [key, value] of Object.entries(pointLabels)) {
873
+ if (value === void 0) continue;
874
+ const baseVal = seriesLabels[key];
875
+ if (!stableJsonEqual(value, baseVal)) out[key] = value;
876
+ }
877
+ return Object.keys(out).length === 0 ? void 0 : out;
878
+ }
879
+ function readSeriesTrendlines(serCursor, kind, stacking, pointCount, fitPoints) {
880
+ const nodes = serCursor.children(C_NS, "trendline");
881
+ if (nodes.length === 0) return void 0;
882
+ const supported = kind !== "pie" && kind !== "doughnut" && stacking === void 0;
883
+ const result = [];
884
+ for (const tl of nodes) {
885
+ const nameEl = tl.child(C_NS, "name");
886
+ if (nameEl !== void 0) consumeSubtree(nameEl);
887
+ const spPr = tl.child(C_NS, "spPr");
888
+ const line = spPr === void 0 ? void 0 : readLineFromSpPr(spPr).line;
889
+ if (spPr !== void 0) consumeSubtree(spPr);
890
+ const typeRaw = readValAttr(tl.child(C_NS, "trendlineType"));
891
+ const type = typeRaw === void 0 ? void 0 : chartTrendlineTypeFromNative[typeRaw];
892
+ const order = readIntVal(tl.child(C_NS, "order"));
893
+ const period = readIntVal(tl.child(C_NS, "period"));
894
+ const rawForward = readFloatVal(tl.child(C_NS, "forward"));
895
+ const rawBackward = readFloatVal(tl.child(C_NS, "backward"));
896
+ const rawIntercept = readFloatVal(tl.child(C_NS, "intercept"));
897
+ const displayRSquared = readBoolVal(tl.child(C_NS, "dispRSqr"));
898
+ const displayEquation = readBoolVal(tl.child(C_NS, "dispEq"));
899
+ consumeSubtree(tl);
900
+ if (!supported || type === void 0) continue;
901
+ const validForecast = (value) => {
902
+ if (value === void 0 || !Number.isFinite(value) || value <= 0) return;
903
+ if (kind !== "scatter" && Math.abs(value * 2 - Math.round(value * 2)) > 1e-9) return;
904
+ return value;
905
+ };
906
+ const forward = validForecast(rawForward);
907
+ const backward = validForecast(rawBackward);
908
+ const baseFields = {
909
+ ...line === void 0 ? {} : { line },
910
+ ...forward === void 0 ? {} : { forward },
911
+ ...backward === void 0 ? {} : { backward }
912
+ };
913
+ if (type === "movingAverage") {
914
+ if (period !== void 0 && period >= 2 && period <= 255 && period < pointCount) result.push({
915
+ ...baseFields,
916
+ type: "movingAverage",
917
+ period
918
+ });
919
+ continue;
920
+ }
921
+ const displayFields = {
922
+ ...baseFields,
923
+ ...displayEquation === void 0 ? {} : { displayEquation },
924
+ ...displayRSquared === void 0 ? {} : { displayRSquared }
925
+ };
926
+ if (type === "polynomial") {
927
+ if (order !== void 0 && order >= 2 && order <= 6) result.push({
928
+ ...displayFields,
929
+ type: "polynomial",
930
+ order,
931
+ ...rawIntercept === void 0 ? {} : { intercept: rawIntercept }
932
+ });
933
+ continue;
934
+ }
935
+ if (type === "logarithmic") {
936
+ if (!fitPoints.some(({ x }) => x <= 0)) result.push({
937
+ ...displayFields,
938
+ type: "logarithmic"
939
+ });
940
+ continue;
941
+ }
942
+ if (type === "exponential") {
943
+ if (!fitPoints.some(({ y }) => y <= 0)) result.push({
944
+ ...displayFields,
945
+ type: "exponential",
946
+ ...rawIntercept === void 0 ? {} : { intercept: rawIntercept }
947
+ });
948
+ continue;
949
+ }
950
+ if (type === "power") {
951
+ if (!fitPoints.some(({ x, y }) => x <= 0 || y <= 0)) result.push({
952
+ ...displayFields,
953
+ type: "power"
954
+ });
955
+ continue;
956
+ }
957
+ result.push({
958
+ ...displayFields,
959
+ type: "linear",
960
+ ...rawIntercept === void 0 ? {} : { intercept: rawIntercept }
961
+ });
962
+ }
963
+ return result.length === 0 ? void 0 : result;
964
+ }
965
+ function alignErrorBarValues(values, pointCount) {
966
+ return Array.from({ length: pointCount }, (_, idx) => {
967
+ const v = values[idx];
968
+ return v !== void 0 && v !== null && Number.isFinite(v) && v >= 0 ? v : null;
969
+ });
970
+ }
971
+ function readSingleErrorBars(errCursor, pointCount) {
972
+ const direction = readValAttr(errCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "errDir")) === "x" ? "x" : "y";
973
+ const includeParsed = ErrBarTypeSchema.safeParse(errCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "errBarType")?.attrsObject(["val"]) ?? {});
974
+ const include = includeParsed.success ? includeParsed.data.val : "both";
975
+ const errValTypeRaw = readValAttr(errCursor.child(C_NS, "errValType"));
976
+ const barType = errValTypeRaw === void 0 ? void 0 : chartErrorBarValueTypeFromNative[errValTypeRaw];
977
+ const endCap = readBoolVal(errCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "noEndCap")) === true ? false : void 0;
978
+ const plusCursor = errCursor.child(C_NS, "plus");
979
+ const rawPlus = plusCursor === void 0 ? void 0 : readNumericDataSource(plusCursor);
980
+ if (plusCursor !== void 0) consumeSubtree(plusCursor);
981
+ const minusCursor = errCursor.child(C_NS, "minus");
982
+ const rawMinus = minusCursor === void 0 ? void 0 : readNumericDataSource(minusCursor);
983
+ if (minusCursor !== void 0) consumeSubtree(minusCursor);
984
+ const val = readFloatVal(errCursor.child(C_NS, "val"));
985
+ const spPr = errCursor.child(C_NS, "spPr");
986
+ const line = spPr === void 0 ? void 0 : readLineFromSpPr(spPr).line;
987
+ if (spPr !== void 0) consumeSubtree(spPr);
988
+ consumeSubtree(errCursor);
989
+ if (barType === void 0) return { direction };
990
+ const styleFields = {
991
+ ...endCap === void 0 ? {} : { endCap },
992
+ ...line === void 0 ? {} : { line }
993
+ };
994
+ if (barType === "standardError") return {
995
+ direction,
996
+ bars: {
997
+ ...styleFields,
998
+ type: "standardError",
999
+ ...include === "both" ? {} : { include }
1000
+ }
1001
+ };
1002
+ if (barType === "custom") {
1003
+ const plus = rawPlus === void 0 ? void 0 : alignErrorBarValues(rawPlus, pointCount);
1004
+ const minus = rawMinus === void 0 ? void 0 : alignErrorBarValues(rawMinus, pointCount);
1005
+ let custom;
1006
+ if (include === "plus" && plus !== void 0) custom = {
1007
+ ...styleFields,
1008
+ type: "custom",
1009
+ include: "plus",
1010
+ plus
1011
+ };
1012
+ else if (include === "minus" && minus !== void 0) custom = {
1013
+ ...styleFields,
1014
+ type: "custom",
1015
+ include: "minus",
1016
+ minus
1017
+ };
1018
+ else if (plus !== void 0 && minus !== void 0) custom = {
1019
+ ...styleFields,
1020
+ type: "custom",
1021
+ include: "both",
1022
+ plus,
1023
+ minus
1024
+ };
1025
+ return {
1026
+ direction,
1027
+ ...custom === void 0 ? {} : { bars: custom }
1028
+ };
1029
+ }
1030
+ if (val === void 0 || !Number.isFinite(val) || val < 0) return { direction };
1031
+ return {
1032
+ direction,
1033
+ bars: {
1034
+ ...styleFields,
1035
+ type: barType,
1036
+ value: val,
1037
+ ...include === "both" ? {} : { include }
1038
+ }
1039
+ };
1040
+ }
1041
+ function readCategoryErrorBars(serCursor, kind, pointCount) {
1042
+ const nodes = serCursor.children(C_NS, "errBars");
1043
+ if (nodes.length === 0) return void 0;
1044
+ let result;
1045
+ for (const node of nodes) {
1046
+ const parsed = readSingleErrorBars(node, pointCount);
1047
+ if (kind !== "pie" && kind !== "doughnut" && result === void 0) result = parsed.bars;
1048
+ }
1049
+ return result;
1050
+ }
1051
+ function readScatterErrorBars(serCursor, pointCount) {
1052
+ const nodes = serCursor.children(C_NS, "errBars");
1053
+ if (nodes.length === 0) return void 0;
1054
+ let x;
1055
+ let y;
1056
+ for (const node of nodes) {
1057
+ const parsed = readSingleErrorBars(node, pointCount);
1058
+ if (parsed.bars === void 0) continue;
1059
+ if (parsed.direction === "x" && x === void 0) x = parsed.bars;
1060
+ else if (parsed.direction === "y" && y === void 0) y = parsed.bars;
1061
+ }
1062
+ if (x === void 0 && y === void 0) return void 0;
1063
+ return {
1064
+ ...x === void 0 ? {} : { x },
1065
+ ...y === void 0 ? {} : { y }
1066
+ };
1067
+ }
1068
+ function readCategorySeries(serCursor, kind, fallbackIndex, stacking, inheritedChartStyle) {
1069
+ const idx = readIntVal(serCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "idx")) ?? fallbackIndex;
1070
+ const order = readIntVal(serCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "order")) ?? idx;
1071
+ const name = readSeriesName(serCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "tx")) ?? `Series ${fallbackIndex + 1}`;
1072
+ const spPr = serCursor.child(C_NS, "spPr");
1073
+ const { color, line } = spPr === void 0 ? {} : readSeriesSpPr(spPr, false);
1074
+ const invertIfNegative = serCursor.child(C_NS, "invertIfNegative");
1075
+ if (invertIfNegative !== void 0) consumeSubtree(invertIfNegative);
1076
+ const markerCursor = serCursor.child(C_NS, "marker");
1077
+ const marker = markerCursor === void 0 ? void 0 : kind === "line" ? readMarkerElement(markerCursor) : (consumeSubtree(markerCursor), void 0);
1078
+ const explosionVal = readIntVal(serCursor.child(C_NS, "explosion"));
1079
+ const explosion = (kind === "pie" || kind === "doughnut") && explosionVal !== void 0 && explosionVal >= 0 ? explosionVal : void 0;
1080
+ const pointsRecord = {};
1081
+ for (const dPt of serCursor.children(C_NS, "dPt")) {
1082
+ const pointIdx = readIntVal(dPt.child(C_NS, "idx"));
1083
+ const inv = dPt.child(C_NS, "invertIfNegative");
1084
+ if (inv !== void 0) consumeSubtree(inv);
1085
+ const bubble3D = dPt.child(C_NS, "bubble3D");
1086
+ if (bubble3D !== void 0) consumeSubtree(bubble3D);
1087
+ const pMarkerCursor = dPt.child(C_NS, "marker");
1088
+ const pMarker = pMarkerCursor === void 0 ? void 0 : kind === "line" ? readMarkerElement(pMarkerCursor) : (consumeSubtree(pMarkerCursor), void 0);
1089
+ const pExplosionVal = readIntVal(dPt.child(C_NS, "explosion"));
1090
+ const pExplosion = (kind === "pie" || kind === "doughnut") && pExplosionVal !== void 0 && pExplosionVal >= 0 ? pExplosionVal : void 0;
1091
+ const pSpPr = dPt.child(C_NS, "spPr");
1092
+ const pStyle = pSpPr === void 0 ? {} : readSeriesSpPr(pSpPr, false);
1093
+ consumeSubtree(dPt);
1094
+ if (pointIdx !== void 0 && pointIdx >= 0) {
1095
+ const pointColor = kind === "area" ? void 0 : pStyle.color;
1096
+ if (pointColor !== void 0 || pStyle.line !== void 0 || pMarker !== void 0 || pExplosion !== void 0) pointsRecord[pointIdx] = {
1097
+ ...pointColor === void 0 ? {} : { color: pointColor },
1098
+ ...pStyle.line === void 0 ? {} : { line: pStyle.line },
1099
+ ...pMarker === void 0 ? {} : { marker: pMarker },
1100
+ ...pExplosion === void 0 ? {} : { explosion: pExplosion }
1101
+ };
1102
+ }
1103
+ }
1104
+ const dLblsCursor = serCursor.child(C_NS, "dLbls");
1105
+ const dLblsResult = dLblsCursor === void 0 ? void 0 : readDataLabelsElement(dLblsCursor, kind, false, inheritedChartStyle);
1106
+ if (dLblsResult !== void 0) {
1107
+ for (const [ptIdx, labelColor] of dLblsResult.pointLabelColors.entries()) pointsRecord[ptIdx] = {
1108
+ ...pointsRecord[ptIdx] ?? {},
1109
+ labelColor
1110
+ };
1111
+ for (const [ptIdx, ptLabel] of dLblsResult.pointLabels.entries()) {
1112
+ const diffed = diffPointDataLabels(ptLabel, dLblsResult.dataLabels);
1113
+ if (diffed === void 0) continue;
1114
+ pointsRecord[ptIdx] = {
1115
+ ...pointsRecord[ptIdx] ?? {},
1116
+ dataLabels: diffed
1117
+ };
1118
+ }
1119
+ }
1120
+ const catCursor = serCursor.child(C_NS, "cat");
1121
+ const catData = catCursor === void 0 ? { values: [] } : readStringDataSource(catCursor);
1122
+ const valCursor = serCursor.child(C_NS, "val");
1123
+ const valData = valCursor === void 0 ? [] : readNumericDataSource(valCursor);
1124
+ const smoothVal = readBoolVal(serCursor.child(C_NS, "smooth"));
1125
+ const smooth = kind === "line" ? smoothVal : void 0;
1126
+ const fitPoints = valData.flatMap((y, valueIndex) => y === null || !Number.isFinite(y) ? [] : [{
1127
+ x: valueIndex + 1,
1128
+ y
1129
+ }]);
1130
+ const trendlines = readSeriesTrendlines(serCursor, kind, stacking, valData.length, fitPoints);
1131
+ const errorBars = readCategoryErrorBars(serCursor, kind, valData.length);
1132
+ let datalabelsRange;
1133
+ const extLst = serCursor.child(C_NS, "extLst");
1134
+ if (extLst !== void 0) for (const ext of extLst.children(C_NS, "ext")) {
1135
+ const uri = ext.attr("uri");
1136
+ if (uri === C15_CAT_RANGE_EXT_URI) {
1137
+ const range = ext.child(C15_NS, "datalabelsRange");
1138
+ if (range !== void 0) {
1139
+ const f = range.child(C15_NS, "f");
1140
+ if (f !== void 0) consumeSubtree(f);
1141
+ const cache = range.child(C15_NS, "dlblRangeCache");
1142
+ if (cache !== void 0) datalabelsRange = readStringCacheOrLit(cache);
1143
+ consumeSubtree(range);
1144
+ }
1145
+ consumeSubtree(ext);
1146
+ } else if (uri === C16_UNIQUE_ID_EXT_URI) consumeSubtree(ext);
1147
+ }
1148
+ const pointCount = Math.max(catData.values.length, valData.length);
1149
+ const normalizedPoints = {};
1150
+ for (const [key, pt] of Object.entries(pointsRecord)) {
1151
+ const numKey = Number(key);
1152
+ if (numKey >= 0 && numKey < pointCount) normalizedPoints[numKey] = pt;
1153
+ }
1154
+ return {
1155
+ order,
1156
+ name: name.trim() === "" ? `Series ${fallbackIndex + 1}` : name,
1157
+ categories: catData.values,
1158
+ ...catData.formula === void 0 ? {} : { categoryFormula: catData.formula },
1159
+ values: valData,
1160
+ ...color === void 0 ? {} : { color },
1161
+ ...line === void 0 ? {} : { line },
1162
+ ...explosion === void 0 ? {} : { explosion },
1163
+ ...marker === void 0 ? {} : { marker },
1164
+ ...smooth === void 0 ? {} : { smooth },
1165
+ ...dLblsResult?.dataLabels === void 0 ? {} : { dataLabels: dLblsResult.dataLabels },
1166
+ ...dLblsResult?.dataLabelsStyle === void 0 ? {} : { dataLabelsStyle: dLblsResult.dataLabelsStyle },
1167
+ ...Object.keys(normalizedPoints).length === 0 ? {} : { points: normalizedPoints },
1168
+ ...trendlines === void 0 ? {} : { trendlines },
1169
+ ...errorBars === void 0 ? {} : { errorBars },
1170
+ ...datalabelsRange === void 0 ? {} : { datalabelsRange }
1171
+ };
1172
+ }
1173
+ function readScatterSeries(serCursor, groupLine, groupMarkers, fallbackIndex, inheritedChartStyle) {
1174
+ const idx = readIntVal(serCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "idx")) ?? fallbackIndex;
1175
+ const order = readIntVal(serCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "order")) ?? idx;
1176
+ const name = readSeriesName(serCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "tx")) ?? `Series ${fallbackIndex + 1}`;
1177
+ const spPr = serCursor.child(C_NS, "spPr");
1178
+ const spStyle = spPr === void 0 ? {} : readSeriesSpPr(spPr, !(groupLine !== void 0 && groupLine !== false));
1179
+ const markerCursor = serCursor.child(C_NS, "marker");
1180
+ const rawMarker = markerCursor === void 0 ? void 0 : readMarkerElement(markerCursor);
1181
+ const marker = !groupMarkers && rawMarker !== void 0 && rawMarker !== false ? void 0 : rawMarker;
1182
+ const pointsRecord = {};
1183
+ for (const dPt of serCursor.children(C_NS, "dPt")) {
1184
+ const pointIdx = readIntVal(dPt.child(C_NS, "idx"));
1185
+ const pMarkerCursor = dPt.child(C_NS, "marker");
1186
+ const rawPMarker = pMarkerCursor === void 0 ? void 0 : readMarkerElement(pMarkerCursor);
1187
+ const pMarker = !groupMarkers && rawPMarker !== void 0 && rawPMarker !== false ? void 0 : rawPMarker;
1188
+ const pSpPr = dPt.child(C_NS, "spPr");
1189
+ const pStyle = pSpPr === void 0 ? {} : readSeriesSpPr(pSpPr, false);
1190
+ consumeSubtree(dPt);
1191
+ if (pointIdx !== void 0 && pointIdx >= 0) {
1192
+ if (pStyle.color !== void 0 || pStyle.line !== void 0 || pMarker !== void 0) pointsRecord[pointIdx] = {
1193
+ ...pStyle.color === void 0 ? {} : { color: pStyle.color },
1194
+ ...pStyle.line === void 0 ? {} : { line: pStyle.line },
1195
+ ...pMarker === void 0 ? {} : { marker: pMarker }
1196
+ };
1197
+ }
1198
+ }
1199
+ const dLblsCursor = serCursor.child(C_NS, "dLbls");
1200
+ const dLblsResult = dLblsCursor === void 0 ? void 0 : readDataLabelsElement(dLblsCursor, "scatter", false, inheritedChartStyle);
1201
+ if (dLblsResult !== void 0) {
1202
+ for (const [ptIdx, labelColor] of dLblsResult.pointLabelColors.entries()) pointsRecord[ptIdx] = {
1203
+ ...pointsRecord[ptIdx] ?? {},
1204
+ labelColor
1205
+ };
1206
+ for (const [ptIdx, ptLabel] of dLblsResult.pointLabels.entries()) {
1207
+ const diffed = diffPointDataLabels(ptLabel, dLblsResult.dataLabels);
1208
+ if (diffed === void 0) continue;
1209
+ pointsRecord[ptIdx] = {
1210
+ ...pointsRecord[ptIdx] ?? {},
1211
+ dataLabels: diffed
1212
+ };
1213
+ }
1214
+ }
1215
+ const xCursor = serCursor.child(C_NS, "xVal");
1216
+ const yCursor = serCursor.child(C_NS, "yVal");
1217
+ let x = xCursor === void 0 ? [] : readNumericDataSource(xCursor);
1218
+ let y = yCursor === void 0 ? [] : readNumericDataSource(yCursor);
1219
+ if (x.length !== y.length) {
1220
+ const maxLen = Math.max(x.length, y.length);
1221
+ if (x.length < maxLen) x = [...x, ...Array.from({ length: maxLen - x.length }).fill(null)];
1222
+ if (y.length < maxLen) y = [...y, ...Array.from({ length: maxLen - y.length }).fill(null)];
1223
+ }
1224
+ const fitPoints = x.flatMap((xv, pointIdx) => {
1225
+ const yv = y[pointIdx];
1226
+ return xv === null || yv === void 0 || yv === null || !Number.isFinite(xv) || !Number.isFinite(yv) ? [] : [{
1227
+ x: xv,
1228
+ y: yv
1229
+ }];
1230
+ });
1231
+ const trendlines = readSeriesTrendlines(serCursor, "scatter", void 0, x.length, fitPoints);
1232
+ const errorBars = readScatterErrorBars(serCursor, x.length);
1233
+ const smoothCursor = serCursor.child(C_NS, "smooth");
1234
+ if (smoothCursor !== void 0) consumeSubtree(smoothCursor);
1235
+ const extLst = serCursor.child(C_NS, "extLst");
1236
+ if (extLst !== void 0) {
1237
+ for (const ext of extLst.children(C_NS, "ext")) if (ext.attr("uri") === C16_UNIQUE_ID_EXT_URI) consumeSubtree(ext);
1238
+ }
1239
+ const normalizedPoints = {};
1240
+ for (const [key, pt] of Object.entries(pointsRecord)) {
1241
+ const numKey = Number(key);
1242
+ if (numKey >= 0 && numKey < x.length) normalizedPoints[numKey] = pt;
1243
+ }
1244
+ return {
1245
+ order,
1246
+ ...dLblsResult?.dataLabelsStyle === void 0 ? {} : { dataLabelsStyle: dLblsResult.dataLabelsStyle },
1247
+ series: {
1248
+ name: name.trim() === "" ? `Series ${fallbackIndex + 1}` : name,
1249
+ x,
1250
+ y,
1251
+ ...spStyle.color === void 0 ? {} : { color: spStyle.color },
1252
+ ...spStyle.line === void 0 ? {} : { line: spStyle.line },
1253
+ ...dLblsResult?.dataLabels === void 0 ? {} : { dataLabels: dLblsResult.dataLabels },
1254
+ ...marker === void 0 ? {} : { marker },
1255
+ ...Object.keys(normalizedPoints).length === 0 ? {} : { points: normalizedPoints },
1256
+ ...trendlines === void 0 ? {} : { trendlines },
1257
+ ...errorBars === void 0 ? {} : { errorBars }
1258
+ }
1259
+ };
1260
+ }
1261
+ function readAxisGridline(el) {
1262
+ if (el === void 0) return void 0;
1263
+ const spPr = el.child(C_NS, "spPr");
1264
+ const result = spPr === void 0 ? true : readLineFromSpPr(spPr).line ?? true;
1265
+ consumeSubtree(el);
1266
+ return result;
1267
+ }
1268
+ function readAxisElement(axisCursor, kind, inheritedChartStyle) {
1269
+ const id = readIntVal(axisCursor.child(C_NS, "axId"));
1270
+ if (id === void 0) return void 0;
1271
+ let reversed;
1272
+ let min;
1273
+ let max;
1274
+ let logBase;
1275
+ const scaling = axisCursor.child(C_NS, "scaling");
1276
+ if (scaling !== void 0) {
1277
+ if (readValAttr(scaling.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "orientation")) === "maxMin") reversed = true;
1278
+ if (kind === "value") {
1279
+ logBase = readFloatVal(scaling.child(C_NS, "logBase"));
1280
+ min = readFloatVal(scaling.child(C_NS, "min"));
1281
+ max = readFloatVal(scaling.child(C_NS, "max"));
1282
+ }
1283
+ consumeSubtree(scaling);
1284
+ }
1285
+ const visible = readBoolVal(axisCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "delete")) === true ? false : void 0;
1286
+ let position;
1287
+ const axPos = axisCursor.child(C_NS, "axPos");
1288
+ if (axPos !== void 0) {
1289
+ const val = axPos.attrsObject(["val"])["val"];
1290
+ if (val !== void 0) position = chartAxisPositionFromNative[val];
1291
+ }
1292
+ const gridlines = readAxisGridline(axisCursor.child(C_NS, "majorGridlines"));
1293
+ const minorGridlines = readAxisGridline(axisCursor.child(C_NS, "minorGridlines"));
1294
+ const txPr = axisCursor.child(C_NS, "txPr");
1295
+ const rawAxisStyle = txPr === void 0 ? void 0 : readChartTextProperties(txPr);
1296
+ const style = diffChartTextStyle(rawAxisStyle, inheritedChartStyle);
1297
+ const titleCursor = axisCursor.child(C_NS, "title");
1298
+ const title = titleCursor === void 0 ? void 0 : readChartTitle(titleCursor, rawAxisStyle === void 0 && inheritedChartStyle === void 0 ? void 0 : {
1299
+ ...inheritedChartStyle,
1300
+ ...rawAxisStyle
1301
+ });
1302
+ const numFmtCursor = axisCursor.child(C_NS, "numFmt");
1303
+ let numberFormat;
1304
+ if (numFmtCursor !== void 0) {
1305
+ const code = numFmtCursor.attr("formatCode");
1306
+ const sourceLinked = numFmtCursor.attr("sourceLinked");
1307
+ if (kind === "value" && code !== void 0 && code.trim() !== "" && (sourceLinked === "0" || sourceLinked === "false" || code !== "General")) numberFormat = code;
1308
+ consumeSubtree(numFmtCursor);
1309
+ }
1310
+ const majorTickParsed = TickMarkSchema.safeParse(axisCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "majorTickMark")?.attrsObject(["val"]) ?? {});
1311
+ const majorTickMark = majorTickParsed.success ? majorTickParsed.data.val : void 0;
1312
+ const minorTickParsed = TickMarkSchema.safeParse(axisCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "minorTickMark")?.attrsObject(["val"]) ?? {});
1313
+ const minorTickMark = minorTickParsed.success ? minorTickParsed.data.val : void 0;
1314
+ const tickLblParsed = TickLblPosSchema.safeParse(axisCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "tickLblPos")?.attrsObject(["val"]) ?? {});
1315
+ const tickLabelPosition = tickLblParsed.success ? tickLblParsed.data.val : void 0;
1316
+ let line;
1317
+ const spPr = axisCursor.child(C_NS, "spPr");
1318
+ if (spPr !== void 0) {
1319
+ const lineRes = readLineFromSpPr(spPr);
1320
+ if (lineRes.noLine) line = false;
1321
+ else if (lineRes.line !== void 0) line = lineRes.line;
1322
+ consumeSubtree(spPr);
1323
+ }
1324
+ const crossAxisId = readIntVal(axisCursor.child(C_NS, "crossAx"));
1325
+ let rawCrossing;
1326
+ const crossesAtCursor = axisCursor.child(C_NS, "crossesAt");
1327
+ const crossesCursor = axisCursor.child(C_NS, "crosses");
1328
+ if (crossesAtCursor !== void 0) {
1329
+ const val = readFloatVal(crossesAtCursor);
1330
+ if (val !== void 0) rawCrossing = {
1331
+ kind: "crossesAt",
1332
+ value: val
1333
+ };
1334
+ } else if (crossesCursor !== void 0) {
1335
+ const parsedCross = CrossesSchema.safeParse(crossesCursor.attrsObject(["val"]));
1336
+ if (parsedCross.success) rawCrossing = {
1337
+ kind: "crosses",
1338
+ value: parsedCross.data.val
1339
+ };
1340
+ }
1341
+ const majorUnit = kind === "value" ? readFloatVal(axisCursor.child(C_NS, "majorUnit")) : void 0;
1342
+ const minorUnit = kind === "value" ? readFloatVal(axisCursor.child(C_NS, "minorUnit")) : void 0;
1343
+ for (const tag of [
1344
+ "crossBetween",
1345
+ "auto",
1346
+ "lblAlgn",
1347
+ "lblOffset",
1348
+ "noMultiLvlLbl",
1349
+ "tickLblSkip",
1350
+ "tickMarkSkip"
1351
+ ]) {
1352
+ const el = axisCursor.child(C_NS, tag);
1353
+ if (el !== void 0) consumeSubtree(el);
1354
+ }
1355
+ return {
1356
+ id,
1357
+ kind,
1358
+ ...crossAxisId === void 0 ? {} : { crossAxisId },
1359
+ ...position === void 0 ? {} : { position },
1360
+ ...visible === void 0 ? {} : { visible },
1361
+ ...reversed === void 0 ? {} : { reversed },
1362
+ ...gridlines === void 0 ? {} : { gridlines },
1363
+ ...minorGridlines === void 0 ? {} : { minorGridlines },
1364
+ ...line === void 0 ? {} : { line },
1365
+ ...style === void 0 ? {} : { style },
1366
+ ...title === void 0 ? {} : { title },
1367
+ ...majorTickMark === void 0 ? {} : { majorTickMark },
1368
+ ...minorTickMark === void 0 ? {} : { minorTickMark },
1369
+ ...tickLabelPosition === void 0 ? {} : { tickLabelPosition },
1370
+ ...min === void 0 ? {} : { min },
1371
+ ...max === void 0 ? {} : { max },
1372
+ ...majorUnit !== void 0 && majorUnit > 0 ? { majorUnit } : {},
1373
+ ...minorUnit !== void 0 && minorUnit > 0 ? { minorUnit } : {},
1374
+ ...numberFormat === void 0 ? {} : { numberFormat },
1375
+ ...logBase !== void 0 && logBase >= 2 && logBase <= 1e3 ? { logBase } : {},
1376
+ ...rawCrossing === void 0 ? {} : { rawCrossing }
1377
+ };
1378
+ }
1379
+ function readChartGroupElement(groupCursor, inheritedChartStyle) {
1380
+ const local = groupCursor.localName;
1381
+ const varyColors = groupCursor.child(C_NS, "varyColors");
1382
+ if (varyColors !== void 0) consumeSubtree(varyColors);
1383
+ if (local === "scatterChart") {
1384
+ const styleCursor = groupCursor.child(C_NS, "scatterStyle");
1385
+ const parsedStyle = ScatterStyleSchema.safeParse(styleCursor?.attrsObject(["val"]) ?? {});
1386
+ const styleVal = parsedStyle.success ? parsedStyle.data.val : "lineMarker";
1387
+ let line;
1388
+ let markers = true;
1389
+ if (styleVal === "marker") {
1390
+ line = false;
1391
+ markers = true;
1392
+ } else if (styleVal === "line") {
1393
+ line = "straight";
1394
+ markers = false;
1395
+ } else if (styleVal === "lineMarker") {
1396
+ line = "straight";
1397
+ markers = true;
1398
+ } else if (styleVal === "smooth") {
1399
+ line = "smooth";
1400
+ markers = false;
1401
+ } else if (styleVal === "smoothMarker") {
1402
+ line = "smooth";
1403
+ markers = true;
1404
+ }
1405
+ const rawEntries = groupCursor.children(C_NS, "ser").map((ser, idx) => readScatterSeries(ser, line, markers, idx, inheritedChartStyle)).toSorted((a, b) => a.order - b.order);
1406
+ const rawSeries = rawEntries.map((entry) => entry.series);
1407
+ const seriesDataLabelsStyle = rawEntries.find((entry) => entry.dataLabelsStyle !== void 0)?.dataLabelsStyle;
1408
+ const dLblsCursor = groupCursor.child(C_NS, "dLbls");
1409
+ const groupLabels = (dLblsCursor === void 0 ? void 0 : readDataLabelsElement(dLblsCursor, "scatter", true, inheritedChartStyle))?.dataLabels;
1410
+ return {
1411
+ kind: "scatter",
1412
+ axisIds: groupCursor.children(C_NS, "axId").map((c) => readIntVal(c)).filter((v) => v !== void 0),
1413
+ series: rawSeries,
1414
+ markers,
1415
+ ...line === void 0 ? {} : { line },
1416
+ ...groupLabels === void 0 ? {} : { dataLabels: groupLabels },
1417
+ ...seriesDataLabelsStyle === void 0 ? {} : { seriesDataLabelsStyle }
1418
+ };
1419
+ }
1420
+ let kind;
1421
+ if (local === "barChart") {
1422
+ const barDirCursor = groupCursor.child(C_NS, "barDir");
1423
+ const parsedDir = BarDirSchema.safeParse(barDirCursor?.attrsObject(["val"]) ?? {});
1424
+ kind = parsedDir.success && parsedDir.data.val === "bar" ? "bar" : "column";
1425
+ } else if (local === "lineChart") kind = "line";
1426
+ else if (local === "areaChart") kind = "area";
1427
+ else if (local === "pieChart") kind = "pie";
1428
+ else if (local === "doughnutChart") kind = "doughnut";
1429
+ else return;
1430
+ let stacking;
1431
+ if (kind === "column" || kind === "bar" || kind === "line" || kind === "area") {
1432
+ const groupingCursor = groupCursor.child(C_NS, "grouping");
1433
+ const parsedGrouping = GroupingSchema.safeParse(groupingCursor?.attrsObject(["val"]) ?? {});
1434
+ if (parsedGrouping.success) {
1435
+ if (parsedGrouping.data.val === "stacked") stacking = "stacked";
1436
+ else if (parsedGrouping.data.val === "percentStacked") stacking = "percent";
1437
+ }
1438
+ }
1439
+ const rawSeries = groupCursor.children(C_NS, "ser").map((ser, idx) => readCategorySeries(ser, kind, idx, stacking, inheritedChartStyle)).toSorted((a, b) => a.order - b.order);
1440
+ const seriesDataLabelsStyle = rawSeries.find((entry) => entry.dataLabelsStyle !== void 0)?.dataLabelsStyle;
1441
+ const dLblsCursor = groupCursor.child(C_NS, "dLbls");
1442
+ const groupLabels = (dLblsCursor === void 0 ? void 0 : readDataLabelsElement(dLblsCursor, kind, true, inheritedChartStyle))?.dataLabels;
1443
+ let gapWidth;
1444
+ let overlap;
1445
+ if (kind === "column" || kind === "bar") {
1446
+ const gw = readIntVal(groupCursor.child(C_NS, "gapWidth"));
1447
+ if (gw !== void 0 && gw >= 0 && gw <= 500) gapWidth = gw;
1448
+ const ov = readIntVal(groupCursor.child(C_NS, "overlap"));
1449
+ if (ov !== void 0 && ov >= -100 && ov <= 100) overlap = ov;
1450
+ }
1451
+ if (kind === "line") {
1452
+ const markerEl = groupCursor.child(C_NS, "marker");
1453
+ if (markerEl !== void 0) consumeSubtree(markerEl);
1454
+ const smoothEl = groupCursor.child(C_NS, "smooth");
1455
+ if (smoothEl !== void 0) consumeSubtree(smoothEl);
1456
+ }
1457
+ let firstSliceAngle;
1458
+ let holeSize;
1459
+ if (kind === "pie" || kind === "doughnut") {
1460
+ const ang = readIntVal(groupCursor.child(C_NS, "firstSliceAng"));
1461
+ if (ang !== void 0 && ang >= 0 && ang <= 360) firstSliceAngle = ang;
1462
+ if (kind === "doughnut") {
1463
+ const hs = readIntVal(groupCursor.child(C_NS, "holeSize"));
1464
+ if (hs !== void 0 && hs >= 10 && hs <= 90) holeSize = hs;
1465
+ }
1466
+ }
1467
+ const axisIds = groupCursor.children(C_NS, "axId").map((c) => readIntVal(c)).filter((v) => v !== void 0);
1468
+ return {
1469
+ kind,
1470
+ axisIds,
1471
+ series: rawSeries,
1472
+ ...groupLabels === void 0 ? {} : { dataLabels: groupLabels },
1473
+ ...seriesDataLabelsStyle === void 0 ? {} : { seriesDataLabelsStyle },
1474
+ ...stacking === void 0 ? {} : { stacking },
1475
+ ...gapWidth === void 0 ? {} : { gapWidth },
1476
+ ...overlap === void 0 ? {} : { overlap },
1477
+ ...firstSliceAngle === void 0 ? {} : { firstSliceAngle },
1478
+ ...holeSize === void 0 ? {} : { holeSize }
1479
+ };
1480
+ }
1481
+ function narrowGroupDataLabels(labels, allowedPositions) {
1482
+ if (labels === void 0 || labels === false) return labels;
1483
+ const { position, xValue: _xValue, ...rest } = labels;
1484
+ if (position !== void 0 && allowedPositions.includes(position)) return {
1485
+ ...rest,
1486
+ position
1487
+ };
1488
+ return rest;
1489
+ }
1490
+ function sameStringArray(a, b) {
1491
+ return a.length === b.length && a.every((item, idx) => item === b[idx]);
1492
+ }
1493
+ function sameRawCrossing(left, right) {
1494
+ return left.kind === right.kind && left.value === right.value;
1495
+ }
1496
+ function positionForImportedRawCrossing(crossing, partner, direction) {
1497
+ if (crossing.kind !== "crosses" || crossing.value === "autoZero") return;
1498
+ const maxAtFarEnd = partner.reversed !== true;
1499
+ if (direction === "vertical") return crossing.value === "max" === maxAtFarEnd ? "right" : "left";
1500
+ return crossing.value === "max" === maxAtFarEnd ? "top" : "bottom";
1501
+ }
1502
+ function importedCrossesKnownValueInterior(crossing, partner) {
1503
+ if (partner.kind !== "value") return false;
1504
+ if (partner.min === void 0 || partner.max === void 0) return false;
1505
+ const low = Math.min(partner.min, partner.max);
1506
+ const high = Math.max(partner.min, partner.max);
1507
+ if (crossing.kind === "crossesAt") return crossing.value > low && crossing.value < high;
1508
+ return crossing.kind === "crosses" && crossing.value === "autoZero" && low < 0 && high > 0;
1509
+ }
1510
+ function importedKnownValueEndpoint(crossing, partner) {
1511
+ if (partner.kind !== "value") return void 0;
1512
+ if (partner.min === void 0 || partner.max === void 0 || partner.min === partner.max) return;
1513
+ if (crossing.kind === "crossesAt") {
1514
+ if (crossing.value === partner.min) return "min";
1515
+ if (crossing.value === partner.max) return "max";
1516
+ return;
1517
+ }
1518
+ if (crossing.kind !== "crosses" || crossing.value !== "autoZero") return;
1519
+ if (partner.min === 0) return "min";
1520
+ if (partner.max === 0) return "max";
1521
+ }
1522
+ function withLiftedDataLabelsStyle(groupLabels, seriesStyle) {
1523
+ if (seriesStyle === void 0) return groupLabels;
1524
+ if (groupLabels === false || groupLabels === void 0) return { style: seriesStyle };
1525
+ return groupLabels.style === void 0 ? {
1526
+ ...groupLabels,
1527
+ style: seriesStyle
1528
+ } : groupLabels;
1529
+ }
1530
+ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1531
+ const axisById = new Map(importedAxes.map((ax) => [ax.id, ax]));
1532
+ const axisDirectionById = /* @__PURE__ */ new Map();
1533
+ for (const group of groupDrafts) {
1534
+ if (group.kind === "pie" || group.kind === "doughnut") continue;
1535
+ const [firstId, secondId] = group.axisIds;
1536
+ if (group.kind === "bar") {
1537
+ if (firstId !== void 0) axisDirectionById.set(firstId, "vertical");
1538
+ if (secondId !== void 0) axisDirectionById.set(secondId, "horizontal");
1539
+ } else {
1540
+ if (firstId !== void 0) axisDirectionById.set(firstId, "horizontal");
1541
+ if (secondId !== void 0) axisDirectionById.set(secondId, "vertical");
1542
+ }
1543
+ }
1544
+ const incomingByTarget = /* @__PURE__ */ new Map();
1545
+ for (const ax of importedAxes) {
1546
+ if (ax.crossAxisId === void 0) continue;
1547
+ const list = incomingByTarget.get(ax.crossAxisId) ?? [];
1548
+ list.push(ax);
1549
+ incomingByTarget.set(ax.crossAxisId, list);
1550
+ }
1551
+ const partnerCrossingFor = /* @__PURE__ */ new Map();
1552
+ const omitPositionIds = /* @__PURE__ */ new Set();
1553
+ for (const [targetId, incoming] of incomingByTarget.entries()) {
1554
+ const targetAxis = axisById.get(targetId);
1555
+ if (targetAxis === void 0 || incoming.length === 0) continue;
1556
+ const firstCrossing = incoming[0]?.rawCrossing;
1557
+ if (firstCrossing === void 0) continue;
1558
+ if (!incoming.every((ax) => ax.rawCrossing !== void 0 && sameRawCrossing(ax.rawCrossing, firstCrossing))) continue;
1559
+ if (firstCrossing.kind === "crossesAt") {
1560
+ if (targetAxis.kind === "category" && (!Number.isSafeInteger(firstCrossing.value) || firstCrossing.value < 1)) continue;
1561
+ partnerCrossingFor.set(targetId, firstCrossing);
1562
+ for (const ax of incoming) {
1563
+ if (ax.position === void 0) continue;
1564
+ const axDir = axisDirectionById.get(ax.id);
1565
+ const endpoint = importedKnownValueEndpoint(firstCrossing, targetAxis);
1566
+ const endpointEdge = endpoint !== void 0 && axDir !== void 0 ? positionForImportedRawCrossing({
1567
+ kind: "crosses",
1568
+ value: endpoint
1569
+ }, targetAxis, axDir) : void 0;
1570
+ if (importedCrossesKnownValueInterior(firstCrossing, targetAxis) || endpointEdge !== void 0 && endpointEdge !== ax.position) omitPositionIds.add(ax.id);
1571
+ }
1572
+ continue;
1573
+ }
1574
+ if (firstCrossing.value === "autoZero") {
1575
+ if (importedCrossesKnownValueInterior(firstCrossing, targetAxis)) {
1576
+ partnerCrossingFor.set(targetId, firstCrossing);
1577
+ for (const ax of incoming) omitPositionIds.add(ax.id);
1578
+ }
1579
+ continue;
1580
+ }
1581
+ if (incoming.every((ax) => {
1582
+ if (ax.position === void 0) return true;
1583
+ const axDir = axisDirectionById.get(ax.id);
1584
+ if (axDir === void 0) return true;
1585
+ const edge = positionForImportedRawCrossing(firstCrossing, targetAxis, axDir);
1586
+ return edge === void 0 || edge === ax.position;
1587
+ })) partnerCrossingFor.set(targetId, firstCrossing);
1588
+ }
1589
+ const axisNameById = /* @__PURE__ */ new Map();
1590
+ const usedNames = /* @__PURE__ */ new Set();
1591
+ const assignName = (id, preferred) => {
1592
+ const existing = axisNameById.get(id);
1593
+ if (existing !== void 0) return existing;
1594
+ let candidate = preferred;
1595
+ let suffix = 2;
1596
+ while (usedNames.has(candidate)) {
1597
+ candidate = `${preferred}${suffix}`;
1598
+ suffix += 1;
1599
+ }
1600
+ usedNames.add(candidate);
1601
+ axisNameById.set(id, candidate);
1602
+ return candidate;
1603
+ };
1604
+ for (const group of groupDrafts) {
1605
+ if (group.kind === "pie" || group.kind === "doughnut") continue;
1606
+ if (group.kind === "scatter") {
1607
+ const [xId, yId] = group.axisIds;
1608
+ if (xId !== void 0) assignName(xId, "x");
1609
+ if (yId !== void 0) assignName(yId, "y");
1610
+ } else {
1611
+ const [catId, valId] = group.axisIds;
1612
+ if (catId !== void 0) assignName(catId, "category");
1613
+ if (valId !== void 0) assignName(valId, "value");
1614
+ }
1615
+ }
1616
+ const axesRecord = {};
1617
+ for (const ax of importedAxes) {
1618
+ const name = axisNameById.get(ax.id);
1619
+ if (name === void 0) continue;
1620
+ const partnerCrossing = partnerCrossingFor.get(ax.id);
1621
+ const keepPosition = ax.position !== void 0 && !omitPositionIds.has(ax.id);
1622
+ const common = {
1623
+ ...ax.visible === void 0 ? {} : { visible: ax.visible },
1624
+ ...ax.gridlines === void 0 ? {} : { gridlines: ax.gridlines },
1625
+ ...ax.minorGridlines === void 0 ? {} : { minorGridlines: ax.minorGridlines },
1626
+ ...ax.line === void 0 ? {} : { line: ax.line },
1627
+ ...ax.style === void 0 ? {} : { style: ax.style },
1628
+ ...ax.title === void 0 ? {} : { title: ax.title },
1629
+ ...ax.majorTickMark === void 0 ? {} : { majorTickMark: ax.majorTickMark },
1630
+ ...ax.minorTickMark === void 0 ? {} : { minorTickMark: ax.minorTickMark },
1631
+ ...ax.tickLabelPosition === void 0 ? {} : { tickLabelPosition: ax.tickLabelPosition },
1632
+ ...ax.reversed === void 0 ? {} : { reversed: ax.reversed },
1633
+ ...keepPosition ? { position: ax.position } : {},
1634
+ ...partnerCrossing?.kind === "crosses" ? { crosses: partnerCrossing.value } : {},
1635
+ ...partnerCrossing?.kind === "crossesAt" && (ax.kind !== "category" || Number.isSafeInteger(partnerCrossing.value) && partnerCrossing.value >= 1) ? { crossesAt: partnerCrossing.value } : {}
1636
+ };
1637
+ if (ax.kind === "category") axesRecord[name] = {
1638
+ kind: "category",
1639
+ ...common
1640
+ };
1641
+ else axesRecord[name] = {
1642
+ kind: "value",
1643
+ ...common,
1644
+ ...ax.min === void 0 ? {} : { min: ax.min },
1645
+ ...ax.max === void 0 ? {} : { max: ax.max },
1646
+ ...ax.majorUnit === void 0 ? {} : { majorUnit: ax.majorUnit },
1647
+ ...ax.minorUnit === void 0 ? {} : { minorUnit: ax.minorUnit },
1648
+ ...ax.numberFormat === void 0 ? {} : { numberFormat: ax.numberFormat },
1649
+ ...ax.logBase === void 0 ? {} : { logBase: ax.logBase }
1650
+ };
1651
+ }
1652
+ const sharedDomainByCatAxis = /* @__PURE__ */ new Map();
1653
+ for (const group of groupDrafts) {
1654
+ if (group.kind === "scatter" || group.kind === "pie" || group.kind === "doughnut") continue;
1655
+ const catId = group.axisIds[0];
1656
+ if (catId === void 0 || sharedDomainByCatAxis.has(catId)) continue;
1657
+ const nonEmpty = group.series.find((s) => s.categories.length > 0);
1658
+ if (nonEmpty !== void 0) sharedDomainByCatAxis.set(catId, nonEmpty.categories);
1659
+ }
1660
+ const groups = groupDrafts.map((group) => {
1661
+ const liftedDataLabels = withLiftedDataLabelsStyle(group.dataLabels, group.seriesDataLabelsStyle);
1662
+ if (group.kind === "scatter") {
1663
+ const [xId, yId] = group.axisIds;
1664
+ const xName = xId === void 0 ? void 0 : axisNameById.get(xId);
1665
+ const yName = yId === void 0 ? void 0 : axisNameById.get(yId);
1666
+ return {
1667
+ kind: "scatter",
1668
+ data: { kind: "xy" },
1669
+ series: group.series,
1670
+ ...xName !== void 0 && yName !== void 0 && xName !== yName ? { axes: {
1671
+ x: xName,
1672
+ y: yName
1673
+ } } : {},
1674
+ ...group.line === void 0 ? {} : { line: group.line },
1675
+ markers: group.markers,
1676
+ ...liftedDataLabels === void 0 ? {} : { dataLabels: liftedDataLabels }
1677
+ };
1678
+ }
1679
+ if (group.kind === "doughnut") {
1680
+ if (group.series.some((s) => s.datalabelsRange !== void 0) || group.series.length > 1 && group.series.some((s) => s.categoryFormula !== void 0 && group.series[0]?.categoryFormula !== void 0 && s.categoryFormula !== group.series[0].categoryFormula || !sameStringArray(s.categories, group.series[0]?.categories ?? []))) {
1681
+ const series = group.series.map((item) => {
1682
+ const cats = item.datalabelsRange ?? item.categories;
1683
+ const values = item.values.length === cats.length ? item.values : cats.map((_, idx) => item.values[idx] ?? null);
1684
+ return {
1685
+ name: item.name,
1686
+ categories: cats,
1687
+ values,
1688
+ ...item.color === void 0 ? {} : { color: item.color },
1689
+ ...item.line === void 0 ? {} : { line: item.line },
1690
+ ...item.explosion === void 0 ? {} : { explosion: item.explosion },
1691
+ ...item.dataLabels === void 0 ? {} : { dataLabels: item.dataLabels },
1692
+ ...item.points === void 0 ? {} : { points: item.points },
1693
+ ...item.trendlines === void 0 ? {} : { trendlines: item.trendlines },
1694
+ ...item.errorBars === void 0 ? {} : { errorBars: item.errorBars }
1695
+ };
1696
+ });
1697
+ const indDoughnutLabels = narrowGroupDataLabels(liftedDataLabels, []);
1698
+ return {
1699
+ kind: "doughnut",
1700
+ data: { kind: "independent-categories" },
1701
+ series,
1702
+ ...group.firstSliceAngle === void 0 ? {} : { firstSliceAngle: group.firstSliceAngle },
1703
+ ...group.holeSize === void 0 ? {} : { holeSize: group.holeSize },
1704
+ ...indDoughnutLabels === void 0 ? {} : { dataLabels: indDoughnutLabels }
1705
+ };
1706
+ }
1707
+ }
1708
+ const catAxisId = group.kind === "pie" || group.kind === "doughnut" ? void 0 : group.axisIds[0];
1709
+ const domain = (catAxisId !== void 0 ? sharedDomainByCatAxis.get(catAxisId) : void 0) ?? group.series.find((s) => s.categories.length > 0)?.categories ?? [];
1710
+ const normalizedSeries = (group.kind === "pie" ? group.series.slice(0, 1) : group.series).map((item) => {
1711
+ const values = domain.length === 0 ? [] : item.values.length === domain.length ? item.values : domain.map((_, idx) => item.values[idx] ?? null);
1712
+ const safeValues = group.kind === "pie" || group.kind === "doughnut" ? values.map((v) => v !== null && v < 0 ? null : v) : values;
1713
+ return {
1714
+ name: item.name,
1715
+ values: safeValues,
1716
+ ...item.color === void 0 ? {} : { color: item.color },
1717
+ ...item.line === void 0 ? {} : { line: item.line },
1718
+ ...item.explosion === void 0 ? {} : { explosion: item.explosion },
1719
+ ...item.dataLabels === void 0 ? {} : { dataLabels: item.dataLabels },
1720
+ ...item.marker === void 0 ? {} : { marker: item.marker },
1721
+ ...item.smooth === void 0 ? {} : { smooth: item.smooth },
1722
+ ...item.points === void 0 ? {} : { points: item.points },
1723
+ ...item.trendlines === void 0 ? {} : { trendlines: item.trendlines },
1724
+ ...item.errorBars === void 0 ? {} : { errorBars: item.errorBars }
1725
+ };
1726
+ });
1727
+ if (group.kind === "pie") {
1728
+ const pieLabels = narrowGroupDataLabels(liftedDataLabels, [
1729
+ "center",
1730
+ "insideEnd",
1731
+ "outsideEnd",
1732
+ "bestFit"
1733
+ ]);
1734
+ return {
1735
+ kind: "pie",
1736
+ data: {
1737
+ kind: "shared-categories",
1738
+ categories: domain
1739
+ },
1740
+ series: normalizedSeries,
1741
+ ...group.firstSliceAngle === void 0 ? {} : { firstSliceAngle: group.firstSliceAngle },
1742
+ ...pieLabels === void 0 ? {} : { dataLabels: pieLabels }
1743
+ };
1744
+ }
1745
+ if (group.kind === "doughnut") {
1746
+ const doughnutLabels = narrowGroupDataLabels(liftedDataLabels, []);
1747
+ return {
1748
+ kind: "doughnut",
1749
+ data: {
1750
+ kind: "shared-categories",
1751
+ categories: domain
1752
+ },
1753
+ series: normalizedSeries,
1754
+ ...group.firstSliceAngle === void 0 ? {} : { firstSliceAngle: group.firstSliceAngle },
1755
+ ...group.holeSize === void 0 ? {} : { holeSize: group.holeSize },
1756
+ ...doughnutLabels === void 0 ? {} : { dataLabels: doughnutLabels }
1757
+ };
1758
+ }
1759
+ const [catId, valId] = group.axisIds;
1760
+ const catName = catId !== void 0 && axisById.has(catId) ? axisNameById.get(catId) : void 0;
1761
+ const valName = valId !== void 0 && axisById.has(valId) ? axisNameById.get(valId) : void 0;
1762
+ const axesRef = catName !== void 0 && valName !== void 0 && catName !== valName ? {
1763
+ category: catName,
1764
+ value: valName
1765
+ } : void 0;
1766
+ if (group.kind === "column" || group.kind === "bar") {
1767
+ const commonColBar = {
1768
+ kind: group.kind,
1769
+ data: {
1770
+ kind: "shared-categories",
1771
+ categories: domain
1772
+ },
1773
+ series: normalizedSeries,
1774
+ ...axesRef === void 0 ? {} : { axes: axesRef },
1775
+ ...group.gapWidth === void 0 ? {} : { gapWidth: group.gapWidth },
1776
+ ...group.overlap === void 0 ? {} : { overlap: group.overlap }
1777
+ };
1778
+ if (group.stacking !== void 0) {
1779
+ const stackedLabels = narrowGroupDataLabels(liftedDataLabels, [
1780
+ "center",
1781
+ "insideEnd",
1782
+ "insideBase"
1783
+ ]);
1784
+ return {
1785
+ ...commonColBar,
1786
+ stacking: group.stacking,
1787
+ ...stackedLabels === void 0 ? {} : { dataLabels: stackedLabels }
1788
+ };
1789
+ }
1790
+ const unstackedLabels = narrowGroupDataLabels(liftedDataLabels, [
1791
+ "center",
1792
+ "insideEnd",
1793
+ "insideBase",
1794
+ "outsideEnd"
1795
+ ]);
1796
+ return {
1797
+ ...commonColBar,
1798
+ ...unstackedLabels === void 0 ? {} : { dataLabels: unstackedLabels }
1799
+ };
1800
+ }
1801
+ if (group.kind === "line") {
1802
+ const lineLabels = narrowGroupDataLabels(liftedDataLabels, [
1803
+ "left",
1804
+ "right",
1805
+ "bottom",
1806
+ "top",
1807
+ "center"
1808
+ ]);
1809
+ return {
1810
+ kind: "line",
1811
+ data: {
1812
+ kind: "shared-categories",
1813
+ categories: domain
1814
+ },
1815
+ series: normalizedSeries,
1816
+ ...axesRef === void 0 ? {} : { axes: axesRef },
1817
+ ...group.stacking === void 0 ? {} : { stacking: group.stacking },
1818
+ ...lineLabels === void 0 ? {} : { dataLabels: lineLabels }
1819
+ };
1820
+ }
1821
+ const areaLabels = narrowGroupDataLabels(liftedDataLabels, []);
1822
+ return {
1823
+ kind: "area",
1824
+ data: {
1825
+ kind: "shared-categories",
1826
+ categories: domain
1827
+ },
1828
+ series: normalizedSeries,
1829
+ ...axesRef === void 0 ? {} : { axes: axesRef },
1830
+ ...group.stacking === void 0 ? {} : { stacking: group.stacking },
1831
+ ...areaLabels === void 0 ? {} : { dataLabels: areaLabels }
1832
+ };
1833
+ });
1834
+ return {
1835
+ ...Object.keys(axesRecord).length > 0 ? { axes: axesRecord } : {},
1836
+ groups
1837
+ };
1838
+ }
1839
+ function consumeChartAlternateContent(ac) {
1840
+ const choice = ac.child(MC_NS, "Choice");
1841
+ const fallback = ac.child(MC_NS, "Fallback");
1842
+ if (choice !== void 0) {
1843
+ choice.consumeAttr("Requires");
1844
+ const c14Style = choice.child(C14_NS, "style");
1845
+ if (c14Style !== void 0) {
1846
+ consumeSubtree(c14Style);
1847
+ if (fallback !== void 0) consumeSubtree(fallback);
1848
+ return true;
1849
+ }
1850
+ }
1851
+ return false;
1852
+ }
1853
+ /**
1854
+ * Reads a Transitional `<p:graphicFrame>` chart and its `ppt/charts/chart{n}.xml` part into an editable `ChartNode`.
1855
+ */
1856
+ function readChartGraphicFrame(context) {
1857
+ const { cursor, part, slideIndex, package: pkg, layoutPlaceholders } = context;
1858
+ const diagnostics = [];
1859
+ const nvGraphicFramePr = cursor.child(P_NS, "nvGraphicFramePr");
1860
+ if (nvGraphicFramePr === void 0) {
1861
+ diagnostics.push({
1862
+ code: "corrupt-part",
1863
+ category: "corrupt-input",
1864
+ disposition: "omitted",
1865
+ location: {
1866
+ part,
1867
+ xpath: cursor.xpath,
1868
+ slideIndex
1869
+ }
1870
+ });
1871
+ return { diagnostics };
1872
+ }
1873
+ let objectId;
1874
+ let objectName;
1875
+ let clickResult;
1876
+ const cNvPr = nvGraphicFramePr.child(P_NS, "cNvPr");
1877
+ if (cNvPr !== void 0) {
1878
+ const rawCNvPr = cNvPr.attrsObject(["id", "name"]);
1879
+ const parsedCNvPr = NonVisualIdSchema.safeParse(rawCNvPr);
1880
+ if (!parsedCNvPr.success) diagnostics.push({
1881
+ code: "invalid-xml-value",
1882
+ category: "corrupt-input",
1883
+ disposition: "recovered",
1884
+ location: {
1885
+ part,
1886
+ xpath: cNvPr.xpath,
1887
+ slideIndex
1888
+ },
1889
+ attributeOrElement: "p:cNvPr",
1890
+ rawValue: JSON.stringify(rawCNvPr)
1891
+ });
1892
+ else {
1893
+ objectId = parsedCNvPr.data.id;
1894
+ if (parsedCNvPr.data.name !== void 0 && parsedCNvPr.data.name.trim() !== "") objectName = parsedCNvPr.data.name;
1895
+ }
1896
+ const hlinkClick = cNvPr.child(A_NS, "hlinkClick");
1897
+ if (hlinkClick !== void 0) {
1898
+ clickResult = readClickLink(hlinkClick, context, {
1899
+ ...objectId === void 0 ? {} : { objectId },
1900
+ ...objectName === void 0 ? {} : { objectName }
1901
+ });
1902
+ diagnostics.push(...clickResult.diagnostics);
1903
+ }
1904
+ }
1905
+ const cNvGraphicFramePr = nvGraphicFramePr.child(P_NS, "cNvGraphicFramePr");
1906
+ if (cNvGraphicFramePr !== void 0) {
1907
+ const locks = cNvGraphicFramePr.child(A_NS, "graphicFrameLocks");
1908
+ if (locks !== void 0) consumeSubtree(locks);
1909
+ }
1910
+ const chartLocation = {
1911
+ part,
1912
+ xpath: cursor.xpath,
1913
+ slideIndex,
1914
+ ...objectId === void 0 ? {} : { objectId },
1915
+ ...objectName === void 0 ? {} : { objectName }
1916
+ };
1917
+ const nvPr = nvGraphicFramePr.child(P_NS, "nvPr");
1918
+ const phResult = readNvPrPlaceholder(nvPr, chartLocation, diagnostics);
1919
+ if (phResult.kind === "error") return { diagnostics };
1920
+ const nativeRef = phResult.kind === "ok" ? phResult.nativeRef : void 0;
1921
+ const matchedKey = nativeRef === void 0 ? void 0 : matchLayoutPlaceholderKey(layoutPlaceholders, {
1922
+ type: nativeRef.type,
1923
+ idx: nativeRef.idx
1924
+ });
1925
+ const xfrm = cursor.child(P_NS, "xfrm");
1926
+ const off = xfrm?.child(A_NS, "off");
1927
+ const ext = xfrm?.child(A_NS, "ext");
1928
+ if (xfrm === void 0 || off === void 0 || ext === void 0) {
1929
+ diagnostics.push({
1930
+ code: "corrupt-part",
1931
+ category: "corrupt-input",
1932
+ disposition: "omitted",
1933
+ location: {
1934
+ part,
1935
+ xpath: cursor.xpath,
1936
+ slideIndex,
1937
+ ...objectId === void 0 ? {} : { objectId },
1938
+ ...objectName === void 0 ? {} : { objectName }
1939
+ }
1940
+ });
1941
+ return { diagnostics };
1942
+ }
1943
+ const rawXfrm = xfrm.attrsObject([
1944
+ "rot",
1945
+ "flipH",
1946
+ "flipV"
1947
+ ]);
1948
+ transformAttributesFragmentSchema.safeParse(rawXfrm);
1949
+ const parsedOff = offsetEmuFragmentSchema.safeParse(off.attrsObject(["x", "y"]));
1950
+ const parsedExt = extentEmuFragmentSchema.safeParse(ext.attrsObject(["cx", "cy"]));
1951
+ if (!parsedOff.success || !parsedExt.success) {
1952
+ diagnostics.push({
1953
+ code: "invalid-xml-value",
1954
+ category: "corrupt-input",
1955
+ disposition: "omitted",
1956
+ location: {
1957
+ part,
1958
+ xpath: xfrm.xpath,
1959
+ slideIndex,
1960
+ ...objectId === void 0 ? {} : { objectId },
1961
+ ...objectName === void 0 ? {} : { objectName }
1962
+ },
1963
+ attributeOrElement: "a:xfrm"
1964
+ });
1965
+ return { diagnostics };
1966
+ }
1967
+ const boxX = emuToPx(parsedOff.data.x);
1968
+ const boxY = emuToPx(parsedOff.data.y);
1969
+ const boxWidth = emuToPx(parsedExt.data.cx);
1970
+ const boxHeight = emuToPx(parsedExt.data.cy);
1971
+ const graphicData = cursor.child(A_NS, "graphic")?.child(A_NS, "graphicData");
1972
+ if (graphicData !== void 0) GraphicDataAttrSchema.safeParse(graphicData.attrsObject(["uri"]));
1973
+ const cChart = graphicData?.child(C_NS, "chart");
1974
+ const rId = cChart?.attr("id", R_NS);
1975
+ if (cChart === void 0 || rId === void 0) {
1976
+ diagnostics.push({
1977
+ code: "corrupt-part",
1978
+ category: "corrupt-input",
1979
+ disposition: "omitted",
1980
+ location: {
1981
+ part,
1982
+ xpath: cursor.xpath,
1983
+ slideIndex,
1984
+ ...objectId === void 0 ? {} : { objectId },
1985
+ ...objectName === void 0 ? {} : { objectName }
1986
+ }
1987
+ });
1988
+ return { diagnostics };
1989
+ }
1990
+ const relsResult = pkg.readRelationships(part);
1991
+ diagnostics.push(...relsResult.diagnostics);
1992
+ const rel = relsResult.entries.find((entry) => entry.Id === rId && entry.Type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart" && entry.TargetMode === "Internal");
1993
+ if (rel === void 0) {
1994
+ diagnostics.push({
1995
+ code: "broken-relationship",
1996
+ category: "corrupt-input",
1997
+ disposition: "omitted",
1998
+ location: {
1999
+ part,
2000
+ xpath: cChart.xpath,
2001
+ slideIndex,
2002
+ ...objectId === void 0 ? {} : { objectId },
2003
+ ...objectName === void 0 ? {} : { objectName }
2004
+ },
2005
+ relationshipId: rId
2006
+ });
2007
+ return { diagnostics };
2008
+ }
2009
+ const chartPartPath = resolvePartPath(part, rel.Target);
2010
+ const chartXml = chartPartPath === void 0 ? void 0 : pkg.readTextPart(chartPartPath);
2011
+ if (chartPartPath === void 0 || chartXml === void 0) {
2012
+ diagnostics.push({
2013
+ code: "missing-target-part",
2014
+ category: "corrupt-input",
2015
+ disposition: "omitted",
2016
+ location: {
2017
+ part,
2018
+ xpath: cChart.xpath,
2019
+ slideIndex,
2020
+ ...objectId === void 0 ? {} : { objectId },
2021
+ ...objectName === void 0 ? {} : { objectName }
2022
+ },
2023
+ relationshipId: rId,
2024
+ targetPart: chartPartPath ?? rel.Target
2025
+ });
2026
+ return { diagnostics };
2027
+ }
2028
+ let chartRootEl;
2029
+ try {
2030
+ chartRootEl = parseXmlPart(chartPartPath, chartXml);
2031
+ } catch {
2032
+ diagnostics.push({
2033
+ code: "corrupt-part",
2034
+ category: "corrupt-input",
2035
+ disposition: "omitted",
2036
+ location: {
2037
+ part: chartPartPath,
2038
+ slideIndex,
2039
+ ...objectId === void 0 ? {} : { objectId },
2040
+ ...objectName === void 0 ? {} : { objectName }
2041
+ }
2042
+ });
2043
+ return { diagnostics };
2044
+ }
2045
+ const chartSpace = XmlElementCursor.createRoot(chartRootEl, chartPartPath, "/c:chartSpace");
2046
+ chartSpace.consumeAttr("lang", "http://www.w3.org/XML/1998/namespace");
2047
+ for (const tag of [
2048
+ "date1904",
2049
+ "lang",
2050
+ "roundedCorners",
2051
+ "style",
2052
+ "clrMapOvr"
2053
+ ]) {
2054
+ const el = chartSpace.child(C_NS, tag);
2055
+ if (el !== void 0) consumeSubtree(el);
2056
+ }
2057
+ for (const ac of chartSpace.children(MC_NS, "AlternateContent")) consumeChartAlternateContent(ac);
2058
+ const chartTxPr = chartSpace.child(C_NS, "txPr");
2059
+ const rawChartStyle = chartTxPr === void 0 ? void 0 : readChartTextProperties(chartTxPr);
2060
+ const chartStyle = normalizeRootChartStyle(rawChartStyle);
2061
+ for (const tag of ["spPr", "externalData"]) {
2062
+ const el = chartSpace.child(C_NS, tag);
2063
+ if (el !== void 0) consumeSubtree(el);
2064
+ }
2065
+ const chartEl = chartSpace.child(C_NS, "chart");
2066
+ if (chartEl === void 0) {
2067
+ diagnostics.push({
2068
+ code: "corrupt-part",
2069
+ category: "corrupt-input",
2070
+ disposition: "omitted",
2071
+ location: {
2072
+ part: chartPartPath,
2073
+ xpath: chartSpace.xpath,
2074
+ slideIndex,
2075
+ ...objectId === void 0 ? {} : { objectId },
2076
+ ...objectName === void 0 ? {} : { objectName }
2077
+ }
2078
+ });
2079
+ return { diagnostics };
2080
+ }
2081
+ const titleEl = chartEl.child(C_NS, "title");
2082
+ const title = titleEl === void 0 ? void 0 : readChartTitle(titleEl, rawChartStyle);
2083
+ const autoTitleDeleted = chartEl.child(C_NS, "autoTitleDeleted");
2084
+ if (autoTitleDeleted !== void 0) consumeSubtree(autoTitleDeleted);
2085
+ const pivotFmts = chartEl.child(C_NS, "pivotFmts");
2086
+ if (pivotFmts !== void 0) consumeSubtree(pivotFmts);
2087
+ let legend;
2088
+ const legendEl = chartEl.child(C_NS, "legend");
2089
+ if (legendEl !== void 0) {
2090
+ const posVal = legendEl.child(C_NS, "legendPos")?.attrsObject(["val"])["val"];
2091
+ legend = (posVal === void 0 ? void 0 : chartLegendPositionFromNative[posVal]) ?? "right";
2092
+ legendEl.child(C_NS, "overlay")?.attr("val");
2093
+ const legendLayoutEl = directElementChild(legendEl.element, C_NS, "layout");
2094
+ if (legendLayoutEl !== void 0 && isEmptyXmlElement(legendLayoutEl)) legendEl.child(C_NS, "layout");
2095
+ const legendTxPr = legendEl.child(C_NS, "txPr");
2096
+ if (legendTxPr !== void 0) readChartTextProperties(legendTxPr);
2097
+ for (const legendEntry of legendEl.children(C_NS, "legendEntry")) {
2098
+ legendEntry.child(C_NS, "idx")?.attr("val");
2099
+ legendEntry.child(C_NS, "delete")?.attr("val");
2100
+ }
2101
+ const legendSpPr = legendEl.child(C_NS, "spPr");
2102
+ if (legendSpPr !== void 0) consumeBenignChartSpPr(legendSpPr);
2103
+ }
2104
+ const plotVisOnly = chartEl.child(C_NS, "plotVisOnly");
2105
+ if (plotVisOnly !== void 0) consumeSubtree(plotVisOnly);
2106
+ const dispParsed = DispBlanksAsSchema.safeParse(chartEl.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "dispBlanksAs")?.attrsObject(["val"]) ?? {});
2107
+ let displayBlanksAs = dispParsed.success ? dispParsed.data.val : void 0;
2108
+ const showDLblsOverMax = chartEl.child(C_NS, "showDLblsOverMax");
2109
+ if (showDLblsOverMax !== void 0) consumeSubtree(showDLblsOverMax);
2110
+ const chartExtLst = chartEl.child(C_NS, "extLst");
2111
+ if (chartExtLst !== void 0) {
2112
+ for (const extEntry of chartExtLst.children(C_NS, "ext")) if (extEntry.attr("uri") === WPS_CHART_PROPS_EXT_URI || directElementChild(extEntry.element, WPS_ET_NS, "chartProps") !== void 0) consumeSubtree(extEntry);
2113
+ }
2114
+ const plotAreaEl = chartEl.child(C_NS, "plotArea");
2115
+ if (plotAreaEl === void 0) {
2116
+ diagnostics.push({
2117
+ code: "corrupt-part",
2118
+ category: "corrupt-input",
2119
+ disposition: "omitted",
2120
+ location: {
2121
+ part: chartPartPath,
2122
+ xpath: chartEl.xpath,
2123
+ slideIndex,
2124
+ ...objectId === void 0 ? {} : { objectId },
2125
+ ...objectName === void 0 ? {} : { objectName }
2126
+ }
2127
+ });
2128
+ return { diagnostics };
2129
+ }
2130
+ let plotArea;
2131
+ const layoutEl = plotAreaEl.child(C_NS, "layout");
2132
+ if (layoutEl !== void 0) {
2133
+ const manual = layoutEl.child(C_NS, "manualLayout");
2134
+ if (manual !== void 0) {
2135
+ const target = readValAttr(manual.child(C_NS, "layoutTarget"));
2136
+ const xMode = readValAttr(manual.child(C_NS, "xMode"));
2137
+ const yMode = readValAttr(manual.child(C_NS, "yMode"));
2138
+ const wMode = readValAttr(manual.child(C_NS, "wMode"));
2139
+ const hMode = readValAttr(manual.child(C_NS, "hMode"));
2140
+ const xFrac = readFloatVal(manual.child(C_NS, "x"));
2141
+ const yFrac = readFloatVal(manual.child(C_NS, "y"));
2142
+ const wFrac = readFloatVal(manual.child(C_NS, "w"));
2143
+ const hFrac = readFloatVal(manual.child(C_NS, "h"));
2144
+ if ((target === void 0 || target === "inner") && (xMode === void 0 || xMode === "edge") && (yMode === void 0 || yMode === "edge") && (wMode === void 0 || wMode === "factor") && (hMode === void 0 || hMode === "factor") && xFrac !== void 0 && yFrac !== void 0 && wFrac !== void 0 && hFrac !== void 0 && wFrac > 0 && hFrac > 0) {
2145
+ const left = Math.max(0, xFrac * boxWidth);
2146
+ const top = Math.max(0, yFrac * boxHeight);
2147
+ const width = Math.min(boxWidth - left, wFrac * boxWidth);
2148
+ const height = Math.min(boxHeight - top, hFrac * boxHeight);
2149
+ if (width > 0 && height > 0) plotArea = {
2150
+ left,
2151
+ top,
2152
+ width,
2153
+ height
2154
+ };
2155
+ }
2156
+ consumeSubtree(manual);
2157
+ }
2158
+ consumeSubtree(layoutEl);
2159
+ }
2160
+ const plotSpPr = plotAreaEl.child(C_NS, "spPr");
2161
+ if (plotSpPr !== void 0) consumeBenignChartSpPr(plotSpPr);
2162
+ const groupDrafts = [];
2163
+ const importedAxes = [];
2164
+ for (const child of plotAreaEl.remainingElementChildren()) {
2165
+ if (child.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/chart") continue;
2166
+ if (child.localName === "catAx") {
2167
+ const ax = readAxisElement(child, "category", rawChartStyle);
2168
+ if (ax !== void 0) importedAxes.push(ax);
2169
+ continue;
2170
+ }
2171
+ if (child.localName === "valAx") {
2172
+ const ax = readAxisElement(child, "value", rawChartStyle);
2173
+ if (ax !== void 0) importedAxes.push(ax);
2174
+ continue;
2175
+ }
2176
+ const group = readChartGroupElement(child, rawChartStyle);
2177
+ if (group !== void 0) {
2178
+ groupDrafts.push(group);
2179
+ continue;
2180
+ }
2181
+ diagnostics.push({
2182
+ code: "unsupported-mechanism",
2183
+ category: "unsupported",
2184
+ disposition: "omitted",
2185
+ location: {
2186
+ part: chartPartPath,
2187
+ xpath: child.xpath,
2188
+ slideIndex,
2189
+ ...objectId === void 0 ? {} : { objectId },
2190
+ ...objectName === void 0 ? {} : { objectName }
2191
+ },
2192
+ namespaceUri: child.namespaceUri,
2193
+ localName: child.localName
2194
+ });
2195
+ }
2196
+ for (const unconsumed of chartSpace.collectUnconsumed()) diagnostics.push({
2197
+ code: "unconsumed-xml",
2198
+ category: "unsupported",
2199
+ disposition: "omitted",
2200
+ kind: unconsumed.kind,
2201
+ location: {
2202
+ ...unconsumed.location,
2203
+ slideIndex,
2204
+ ...objectId === void 0 ? {} : { objectId },
2205
+ ...objectName === void 0 ? {} : { objectName }
2206
+ },
2207
+ namespaceUri: unconsumed.namespaceUri,
2208
+ localName: unconsumed.localName
2209
+ });
2210
+ if (groupDrafts.length === 0) {
2211
+ diagnostics.push({
2212
+ code: "corrupt-part",
2213
+ category: "corrupt-input",
2214
+ disposition: "omitted",
2215
+ location: {
2216
+ part: chartPartPath,
2217
+ xpath: plotAreaEl.xpath,
2218
+ slideIndex,
2219
+ ...objectId === void 0 ? {} : { objectId },
2220
+ ...objectName === void 0 ? {} : { objectName }
2221
+ }
2222
+ });
2223
+ return { diagnostics };
2224
+ }
2225
+ const { axes, groups } = buildChartAxesAndGroups(groupDrafts, importedAxes);
2226
+ if (displayBlanksAs !== void 0) {
2227
+ if (!groups.every((group) => {
2228
+ if (group.kind === "scatter") return !(displayBlanksAs === "span" && (group.line === void 0 || group.line === false));
2229
+ if (group.kind === "line") return group.stacking === void 0 ? true : displayBlanksAs === "zero";
2230
+ if (group.kind === "area") return group.stacking === void 0 ? displayBlanksAs === "gap" || displayBlanksAs === "zero" : displayBlanksAs === "zero";
2231
+ return displayBlanksAs === "gap" || displayBlanksAs === "zero";
2232
+ })) displayBlanksAs = void 0;
2233
+ }
2234
+ const props = {
2235
+ ...objectName === void 0 ? {} : { name: objectName },
2236
+ ...matchedKey === void 0 ? {} : { placeholder: matchedKey },
2237
+ ...nativeRef === void 0 ? {} : { nativePlaceholder: nativeRef },
2238
+ ...clickResult?.link === void 0 ? {} : { link: clickResult.link },
2239
+ x: boxX,
2240
+ y: boxY,
2241
+ width: boxWidth,
2242
+ height: boxHeight,
2243
+ ...axes === void 0 ? {} : { axes },
2244
+ groups,
2245
+ ...title === void 0 ? {} : { title },
2246
+ ...chartStyle === void 0 ? {} : { style: chartStyle },
2247
+ ...displayBlanksAs === void 0 ? {} : { displayBlanksAs },
2248
+ ...legend === void 0 ? {} : { legend },
2249
+ ...plotArea === void 0 ? {} : { plotArea }
2250
+ };
2251
+ const node = createChartNode(props);
2252
+ attachDeferredSlideLink(node, clickResult?.deferredSlideLink, context);
2253
+ return {
2254
+ node,
2255
+ diagnostics
2256
+ };
2257
+ }
2258
+ /** Shape-tree import handler wired into free chart canvas mechanisms. */
2259
+ const chartImportHandler = {
2260
+ target: "shape-tree",
2261
+ localName: "graphicFrame",
2262
+ matches: (cursor) => isChartGraphicFrame(cursor) && !isPlaceholderGraphicFrameElement(cursor),
2263
+ read: readChartGraphicFrame
2264
+ };
2265
+ /** Shape-tree import handler wired into `chartPlaceholderMechanism` for placeholder-bound charts. */
2266
+ const chartPlaceholderImportHandler = {
2267
+ target: "shape-tree",
2268
+ localName: "graphicFrame",
2269
+ matches: (cursor) => isChartGraphicFrame(cursor) && isPlaceholderGraphicFrameElement(cursor),
2270
+ read: readChartGraphicFrame
2271
+ };
2272
+ export { chartImportHandler, chartPlaceholderImportHandler, isChartGraphicFrame, readChartGraphicFrame };