@officedk/pptxdk 0.1.0 → 0.2.1

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 (338) hide show
  1. package/dist/build.d.ts +14 -76
  2. package/dist/build.js +69 -97
  3. package/dist/cli.js +1 -1
  4. package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
  5. package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
  6. package/dist/core/dist/capabilities/audio/entry.js +122 -0
  7. package/dist/core/dist/capabilities/box/box-codegen.js +83 -0
  8. package/dist/core/dist/capabilities/box/box-declaration.js +32 -0
  9. package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +32 -29
  10. package/dist/core/dist/capabilities/box/entry.js +2 -0
  11. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +17 -22
  12. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
  13. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +1025 -471
  14. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
  15. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +3 -3
  16. package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
  17. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +216 -212
  18. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
  19. package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +228 -171
  20. package/dist/core/dist/capabilities/chart/entry.js +2 -0
  21. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +23 -10
  22. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
  23. package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
  24. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
  25. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +30 -9
  26. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +160 -89
  27. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +4 -4
  28. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +4 -4
  29. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
  30. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
  31. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
  32. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +3 -3
  33. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +15 -3
  34. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
  35. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +5 -5
  36. package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
  37. package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
  38. package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
  39. package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
  40. package/dist/core/dist/capabilities/comment/comment.js +141 -0
  41. package/dist/core/dist/capabilities/comment/entry.js +1 -0
  42. package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
  43. package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
  44. package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +194 -133
  45. package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
  46. package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
  47. package/dist/core/dist/capabilities/group/entry.js +2 -0
  48. package/dist/core/dist/capabilities/group/group-codegen.js +73 -0
  49. package/dist/core/dist/capabilities/group/group-declaration.js +41 -0
  50. package/dist/core/dist/capabilities/group/group-import.js +608 -0
  51. package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +4 -3
  52. package/dist/core/dist/capabilities/group/group.js +260 -0
  53. package/dist/core/dist/capabilities/image/entry.js +4 -0
  54. package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
  55. package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
  56. package/dist/core/dist/capabilities/image/image-import.js +26 -0
  57. package/dist/core/dist/capabilities/image/image.js +57 -0
  58. package/dist/core/dist/capabilities/line/entry.js +3 -0
  59. package/dist/core/dist/capabilities/line/line-codegen.js +88 -0
  60. package/dist/core/dist/capabilities/line/line-declaration.js +78 -0
  61. package/dist/core/dist/capabilities/line/line-import.js +424 -0
  62. package/dist/core/dist/capabilities/line/line-xml.js +9 -0
  63. package/dist/core/dist/capabilities/line/line.js +329 -0
  64. package/dist/core/dist/capabilities/masters/entry.js +1 -0
  65. package/dist/core/dist/capabilities/masters/masters-codegen.js +50 -0
  66. package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +35 -47
  67. package/dist/core/dist/capabilities/motion/entry.js +5 -0
  68. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +97 -51
  69. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +653 -102
  70. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +317 -163
  71. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +9 -6
  72. package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +357 -108
  73. package/dist/core/dist/capabilities/notes/entry.js +2 -0
  74. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +5 -7
  75. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
  76. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
  77. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +12 -9
  78. package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +20 -42
  79. package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
  80. package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
  81. package/dist/core/dist/capabilities/placeholder/placeholder-codegen.js +44 -0
  82. package/dist/core/dist/capabilities/placeholder/placeholder-schemas.js +31 -0
  83. package/dist/core/dist/capabilities/placeholder/placeholder.js +394 -0
  84. package/dist/core/dist/capabilities/shape/entry.js +6 -0
  85. package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
  86. package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
  87. package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
  88. package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +100 -103
  89. package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
  90. package/dist/core/dist/capabilities/shared/date-time.js +98 -0
  91. package/dist/core/dist/capabilities/shared/font/font-embedding.js +118 -0
  92. package/dist/core/dist/capabilities/shared/font/font-engine.js +855 -0
  93. package/dist/core/dist/capabilities/shared/font/font-import.js +805 -0
  94. package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
  95. package/dist/core/dist/capabilities/shared/font/font.js +72 -0
  96. package/dist/{capabilities/dist/shape/shape-codegen.js → core/dist/capabilities/shared/geometry-codegen.js} +4 -69
  97. package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +384 -123
  98. package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
  99. package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
  100. package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -56
  101. package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +49 -61
  102. package/dist/core/dist/capabilities/shared/line-match.js +78 -0
  103. package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
  104. package/dist/core/dist/capabilities/shared/media-import.js +156 -0
  105. package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
  106. package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
  107. package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
  108. package/dist/core/dist/capabilities/shared/media-source.js +107 -0
  109. package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
  110. package/dist/core/dist/capabilities/shared/media.js +134 -0
  111. package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
  112. package/dist/core/dist/capabilities/shared/motion-api.js +770 -0
  113. package/dist/core/dist/capabilities/shared/motion-schemas.js +353 -0
  114. package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +313 -168
  115. package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
  116. package/dist/core/dist/capabilities/shared/picture.js +510 -0
  117. package/dist/core/dist/capabilities/shared/placeholder-import.js +268 -0
  118. package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
  119. package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1221 -188
  120. package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
  121. package/dist/core/dist/capabilities/shared/rich-text-codegen.js +119 -0
  122. package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
  123. package/dist/core/dist/capabilities/shared/shape-declaration.js +45 -0
  124. package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +26 -24
  125. package/dist/core/dist/capabilities/shared/text-declaration.js +31 -0
  126. package/dist/core/dist/capabilities/shared/text-schemas.js +241 -0
  127. package/dist/core/dist/capabilities/shared/text-service.js +2563 -0
  128. package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +441 -137
  129. package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
  130. package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
  131. package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +12 -7
  132. package/dist/core/dist/capabilities/slide-background/slide-background-xml.js +33 -0
  133. package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +61 -50
  134. package/dist/core/dist/capabilities/table/entry.js +2 -0
  135. package/dist/core/dist/capabilities/table/table-codegen.js +118 -0
  136. package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
  137. package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +116 -84
  138. package/dist/core/dist/capabilities/table/table-schemas.js +337 -0
  139. package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +13 -15
  140. package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +284 -192
  141. package/dist/core/dist/capabilities/text/entry.js +3 -0
  142. package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
  143. package/dist/core/dist/capabilities/text/text-import.js +468 -0
  144. package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
  145. package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +103 -111
  146. package/dist/core/dist/capabilities/transition/entry.js +3 -0
  147. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +13 -16
  148. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
  149. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
  150. package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
  151. package/dist/core/dist/capabilities/video/entry.js +77 -0
  152. package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
  153. package/dist/core/dist/capabilities/video/video-source.js +42 -0
  154. package/dist/{codegen/dist → core/dist/codegen}/assets.js +16 -10
  155. package/dist/{codegen/dist → core/dist/codegen}/codegen.js +152 -140
  156. package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +27 -1
  157. package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
  158. package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
  159. package/dist/core/dist/document/all.js +41 -0
  160. package/dist/core/dist/document/default.js +10 -0
  161. package/dist/core/dist/document/document.js +218 -0
  162. package/dist/core/dist/document/index.js +62 -0
  163. package/dist/core/dist/document/stages.js +54 -0
  164. package/dist/{emit/dist → core/dist/emit}/emit.js +173 -90
  165. package/dist/core/dist/emit/index.js +6 -0
  166. package/dist/core/dist/emit/ooxml.js +241 -0
  167. package/dist/core/dist/import/import.js +547 -0
  168. package/dist/core/dist/import/index.js +19 -0
  169. package/dist/{import/dist → core/dist/import}/masters.js +404 -328
  170. package/dist/core/dist/import/media-timing.js +233 -0
  171. package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
  172. package/dist/core/dist/index.js +47 -15
  173. package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +9 -6
  174. package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +105 -127
  175. package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +225 -142
  176. package/dist/core/dist/kernel/build.js +4 -0
  177. package/dist/core/dist/kernel/capability.js +17 -0
  178. package/dist/core/dist/kernel/codegen.js +97 -0
  179. package/dist/core/dist/kernel/container-slots.js +104 -0
  180. package/dist/core/dist/kernel/date-time-format.js +18 -0
  181. package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
  182. package/dist/core/dist/{declaration.js → kernel/declaration.js} +3 -2
  183. package/dist/core/dist/kernel/diagnostics.js +370 -0
  184. package/dist/core/dist/kernel/document-internals.js +26 -0
  185. package/dist/core/dist/{document.js → kernel/document.js} +23 -13
  186. package/dist/core/dist/kernel/drawing-units.js +14 -0
  187. package/dist/core/dist/kernel/font-seal.js +204 -0
  188. package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +21 -18
  189. package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +177 -72
  190. package/dist/core/dist/{host.js → kernel/host.js} +1 -1
  191. package/dist/core/dist/kernel/index.js +24 -0
  192. package/dist/core/dist/kernel/input-values.js +62 -0
  193. package/dist/core/dist/kernel/layout-definition.js +7 -0
  194. package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +5 -10
  195. package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +33 -44
  196. package/dist/core/dist/kernel/layout.js +339 -0
  197. package/dist/core/dist/kernel/masters.js +171 -0
  198. package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
  199. package/dist/core/dist/kernel/placeholders.js +289 -0
  200. package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
  201. package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +33 -29
  202. package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
  203. package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +71 -12
  204. package/dist/core/dist/kernel/pptx-read/index.js +15 -0
  205. package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
  206. package/dist/core/dist/kernel/pptx-read/media.js +26 -0
  207. package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +6 -7
  208. package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
  209. package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
  210. package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
  211. package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +182 -41
  212. package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +175 -88
  213. package/dist/core/dist/kernel/pptx-read/xml-fragments.js +320 -0
  214. package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
  215. package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
  216. package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
  217. package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +133 -290
  218. package/dist/core/dist/{query.js → kernel/query.js} +76 -37
  219. package/dist/core/dist/{resolution.js → kernel/resolution.js} +2 -1
  220. package/dist/core/dist/kernel/resolve-work.js +58 -0
  221. package/dist/core/dist/{resolve.js → kernel/resolve.js} +797 -409
  222. package/dist/core/dist/kernel/resource-source.js +11 -0
  223. package/dist/core/dist/kernel/stage-options.js +312 -0
  224. package/dist/core/dist/{theme.js → kernel/theme.js} +399 -289
  225. package/dist/core/dist/kernel/transform-geometry.js +72 -0
  226. package/dist/core/dist/kernel/xml-values.js +13 -0
  227. package/dist/document-C0lPlH-L.d.ts +1442 -0
  228. package/dist/index-B9_OUeA-.d.ts +2238 -0
  229. package/dist/index-BJEzQxWV.d.ts +75 -0
  230. package/dist/index-DA9flrlR.d.ts +146 -0
  231. package/dist/index-GSt0t9VO.d.ts +54 -0
  232. package/dist/index.d.ts +7 -7
  233. package/dist/index.js +75 -61
  234. package/dist/node.d.ts +37 -35
  235. package/dist/node.js +125 -51
  236. package/dist/pptxdk/src/cli-commands.js +79 -81
  237. package/dist/pptxdk/src/compose.js +32 -24
  238. package/dist/pptxdk/src/preview-result.js +24 -0
  239. package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
  240. package/dist/preview/dist/index.js +229 -77
  241. package/dist/preview/dist/options.js +17 -26
  242. package/dist/preview/dist/raster.js +66 -0
  243. package/dist/preview/dist/svg-guard.js +1090 -0
  244. package/dist/preview.d.ts +6 -3
  245. package/dist/preview.js +8 -24
  246. package/dist/react/dist/append.js +3 -3
  247. package/dist/react/dist/author/audio-elements.js +14 -0
  248. package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
  249. package/dist/react/dist/author/chart-elements.js +14 -0
  250. package/dist/react/dist/author/comment-elements.js +15 -0
  251. package/dist/react/dist/author/group-elements.js +14 -0
  252. package/dist/react/dist/author/image-elements.js +14 -0
  253. package/dist/react/dist/author/line-elements.js +14 -0
  254. package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
  255. package/dist/react/dist/author/notes-elements.js +14 -0
  256. package/dist/react/dist/author/placeholder-elements.js +14 -0
  257. package/dist/react/dist/author/shape-elements.js +14 -0
  258. package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
  259. package/dist/react/dist/author/text-elements.js +64 -0
  260. package/dist/react/dist/author/video-elements.js +14 -0
  261. package/dist/react/dist/document-adapter.js +376 -37
  262. package/dist/react/dist/elements.js +30 -4
  263. package/dist/react/dist/from-vanilla.js +57 -0
  264. package/dist/react/dist/index.js +47 -12
  265. package/dist/react/dist/mount.js +34 -0
  266. package/dist/react/dist/reconciler.js +26 -26
  267. package/dist/react.d.ts +174 -50
  268. package/dist/react.js +31 -27
  269. package/dist/stages-DYHSHKt4.d.ts +80 -0
  270. package/dist/vanilla.d.ts +4 -4
  271. package/dist/vanilla.js +14 -14
  272. package/package.json +6 -8
  273. package/README.md +0 -49
  274. package/dist/capabilities/dist/all.js +0 -32
  275. package/dist/capabilities/dist/box/box-codegen.js +0 -51
  276. package/dist/capabilities/dist/box/box-declaration.js +0 -31
  277. package/dist/capabilities/dist/chart/chart-elements.js +0 -12
  278. package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
  279. package/dist/capabilities/dist/document.js +0 -148
  280. package/dist/capabilities/dist/font/font-embedding.js +0 -289
  281. package/dist/capabilities/dist/font/font-family.js +0 -10
  282. package/dist/capabilities/dist/font/font-import.js +0 -302
  283. package/dist/capabilities/dist/font/font.js +0 -25
  284. package/dist/capabilities/dist/group/group-codegen.js +0 -51
  285. package/dist/capabilities/dist/group/group-declaration.js +0 -42
  286. package/dist/capabilities/dist/group/group-elements.js +0 -12
  287. package/dist/capabilities/dist/group/group-import.js +0 -319
  288. package/dist/capabilities/dist/group/group.js +0 -211
  289. package/dist/capabilities/dist/image/image-codegen.js +0 -94
  290. package/dist/capabilities/dist/image/image-declaration.js +0 -8
  291. package/dist/capabilities/dist/image/image-elements.js +0 -12
  292. package/dist/capabilities/dist/image/image-xml.js +0 -12
  293. package/dist/capabilities/dist/image/image.js +0 -472
  294. package/dist/capabilities/dist/masters/masters-codegen.js +0 -21
  295. package/dist/capabilities/dist/motion/motion-api.js +0 -527
  296. package/dist/capabilities/dist/motion/motion-schemas.js +0 -216
  297. package/dist/capabilities/dist/notes/notes-elements.js +0 -12
  298. package/dist/capabilities/dist/notes/notes-xml.js +0 -38
  299. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +0 -23
  300. package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -12
  301. package/dist/capabilities/dist/placeholder/placeholder.js +0 -292
  302. package/dist/capabilities/dist/shape/shape-declaration.js +0 -57
  303. package/dist/capabilities/dist/shape/shape-elements.js +0 -12
  304. package/dist/capabilities/dist/shape/shape-import.js +0 -579
  305. package/dist/capabilities/dist/shared/placeholder-import.js +0 -113
  306. package/dist/capabilities/dist/shared/style-parse.js +0 -11
  307. package/dist/capabilities/dist/shared/text-schemas.js +0 -216
  308. package/dist/capabilities/dist/shared/text-service.js +0 -1883
  309. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
  310. package/dist/capabilities/dist/slide-background/slide-background-xml.js +0 -21
  311. package/dist/capabilities/dist/table/table-codegen.js +0 -81
  312. package/dist/capabilities/dist/table/table-schemas.js +0 -279
  313. package/dist/capabilities/dist/text/text-codegen.js +0 -129
  314. package/dist/capabilities/dist/text/text-declaration.js +0 -19
  315. package/dist/capabilities/dist/text/text-elements.js +0 -38
  316. package/dist/capabilities/dist/text/text-import.js +0 -1077
  317. package/dist/capability-D_xeNVIw.d.ts +0 -29496
  318. package/dist/codegen/dist/types.js +0 -49
  319. package/dist/core/dist/build.js +0 -4
  320. package/dist/core/dist/capability.js +0 -13
  321. package/dist/core/dist/diagnostics.js +0 -21
  322. package/dist/core/dist/document-internals.js +0 -13
  323. package/dist/core/dist/input-values.js +0 -45
  324. package/dist/core/dist/layout.js +0 -299
  325. package/dist/core/dist/masters.js +0 -169
  326. package/dist/core/dist/placeholders.js +0 -213
  327. package/dist/core/dist/stage-options.js +0 -67
  328. package/dist/document-BHPUODPP.d.ts +0 -27759
  329. package/dist/emit/dist/index.js +0 -5
  330. package/dist/import/dist/import.js +0 -504
  331. package/dist/import/dist/index.js +0 -16
  332. package/dist/import/dist/xml-fragments.js +0 -36
  333. package/dist/index-B5m3hqjC.d.ts +0 -7
  334. package/dist/index-CCy-Yo8G.d.ts +0 -1208
  335. package/dist/index-DpxcZ4Gs.d.ts +0 -725
  336. package/dist/pptxdk/src/slide.js +0 -9
  337. package/dist/preview-Cfw0QdMM.d.ts +0 -86
  338. package/dist/transition-Cips9wma.d.ts +0 -82
@@ -1,17 +1,22 @@
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";
1
+ import { emuToPx } from "../../kernel/drawing-units.js";
2
+ import { colorMapSchema, schemeColorNameSchema } from "../../kernel/theme.js";
9
3
  import { attachDeferredSlideLink, readClickLink } from "../shared/identity.js";
10
- import { isPlaceholderGraphicFrameElement, readNvPrPlaceholder } from "../shared/placeholder-import.js";
4
+ import { emitPlaceholderUnbindDiagnostic, isPlaceholderGraphicFrameElement, readNvPrPlaceholder, readPlaceholderFrameBox, resolvePlaceholderImportClaim } from "../shared/placeholder-import.js";
5
+ import { A_NS, C_NS, MC_NS, P_NS, R_NS } from "../../kernel/pptx-read/namespaces.js";
6
+ import { XmlElementCursor, parseXmlPart } from "../../kernel/pptx-read/xml-reader.js";
7
+ import { resolvePartPath } from "../../kernel/pptx-read/opc.js";
8
+ import { cascadeOoxmlTextDecoration, hexRgb6Schema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlListLevelSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveFixedAngleSchema, ooxmlPositiveLineWidthEmuSchema, ooxmlWritableExtentEmuSchema, projectOoxmlTextDecoration, readOoxmlRunAttrStyles, readOoxmlTextDecoration, reportOoxmlTextDecorationLoss } from "../../kernel/pptx-read/xml-fragments.js";
9
+ import { readDrawingColor, readRunFillAndStroke } from "../../kernel/pptx-read/visual.js";
10
+ import { readPartThemeOverride } from "../../kernel/pptx-read/themes.js";
11
+ import { readRunFontSlots } from "../../kernel/pptx-read/fonts.js";
12
+ import "../../kernel/capability.js";
13
+ import { readDrawingParagraphLayout } from "../../kernel/pptx-read/drawing-list-import.js";
14
+ import "../../kernel/pptx-read/index.js";
11
15
  import { createChartNode } from "./chart-declaration.js";
12
- import { chartAxisPositionFromNative, chartDataLabelPositionFromNative, chartErrorBarValueTypeFromNative, chartLegendPositionFromNative, chartLineDashFromNative, chartTrendlineTypeFromNative } from "./chart-labels.js";
16
+ import { chartAxisPositionFromNative, chartDataLabelFieldOrder, chartDataLabelPositionFromNative, chartErrorBarValueTypeFromNative, chartLegendPositionFromNative, chartLineDashFromNative, chartTrendlineTypeFromNative, hasAutomaticDataLabels, hasVisibleDataLabels, hasVisibleSeriesDataLabels, mergeDataLabels } from "./chart-labels.js";
17
+ import { formatChartNumber } from "./chart-number-format.js";
13
18
  import { z } from "zod";
14
- // ../capabilities/dist/chart/chart-import.js
19
+ // ../core/dist/capabilities/chart/chart-import.js
15
20
  const C14_NS = "http://schemas.microsoft.com/office/drawing/2007/8/2/chart";
16
21
  const C15_NS = "http://schemas.microsoft.com/office/drawing/2012/chart";
17
22
  const WPS_ET_NS = "https://web.wps.cn/et/2018/main";
@@ -126,9 +131,10 @@ function consumeSubtree(cursor) {
126
131
  function readValAttr(cursor) {
127
132
  return cursor?.attr("val");
128
133
  }
129
- function readBoolVal(cursor) {
134
+ function readBoolVal(cursor, defaultValue) {
135
+ if (cursor === void 0) return void 0;
130
136
  const raw = readValAttr(cursor);
131
- if (raw === void 0) return void 0;
137
+ if (raw === void 0) return defaultValue;
132
138
  const parsed = ooxmlBoolSchema.safeParse(raw);
133
139
  return parsed.success ? parsed.data : void 0;
134
140
  }
@@ -174,9 +180,9 @@ function readSolidFillColor(fillCursor) {
174
180
  const lumOff = readColorModifier(colorCursor, "lumOff");
175
181
  const alpha = readColorModifier(colorCursor, "alpha");
176
182
  consumeSubtree(colorCursor);
177
- const baseColor = schemeSlot !== void 0 && lumMod !== void 0 ? {
183
+ const baseColor = schemeSlot !== void 0 && (lumMod !== void 0 || lumOff !== void 0) ? {
178
184
  slot: schemeSlot,
179
- lumMod: Math.min(1, lumMod),
185
+ lumMod: Math.min(1, lumMod ?? 1),
180
186
  ...lumOff === void 0 ? {} : { lumOff: Math.min(1, lumOff) }
181
187
  } : schemeSlot ?? baseString;
182
188
  if (baseColor === void 0) return void 0;
@@ -200,6 +206,27 @@ function consumeBenignLineElement(spPr) {
200
206
  for (const child of ln.remainingElementChildren()) consumeSubtree(child);
201
207
  return true;
202
208
  }
209
+ /** Reads the host's shape properties and reports unsupported fills on the shape itself. */
210
+ function readChartSpPr(host, ctx) {
211
+ const spPr = host.child(C_NS, "spPr");
212
+ const fills = spPr?.matchingChildren((element) => element.namespaceURI === "http://schemas.openxmlformats.org/drawingml/2006/main" && (element.localName === "blipFill" || element.localName === "gradFill" || element.localName === "pattFill")) ?? [];
213
+ for (const fill of fills) {
214
+ ctx.diagnostics.push({
215
+ code: "unsupported-mechanism",
216
+ category: "unsupported",
217
+ disposition: "omitted",
218
+ location: {
219
+ ...ctx.location,
220
+ xpath: fill.xpath
221
+ },
222
+ namespaceUri: fill.namespaceUri,
223
+ localName: fill.localName,
224
+ mechanismHint: "chart-shape-fill"
225
+ });
226
+ fill.suppressUnconsumed();
227
+ }
228
+ return spPr;
229
+ }
203
230
  function consumeBenignChartSpPr(spPr) {
204
231
  const noFillEl = directElementChild(spPr.element, A_NS, "noFill");
205
232
  if (noFillEl !== void 0 && isEmptyXmlElement(noFillEl)) spPr.child(A_NS, "noFill");
@@ -228,8 +255,8 @@ function readLineFromSpPr(spPr) {
228
255
  if (roundEl !== void 0 && isEmptyXmlElement(roundEl)) ln.child(A_NS, "round");
229
256
  let width;
230
257
  if (rawW !== void 0) {
231
- const parsedW = ooxmlIntSchema.safeParse(rawW);
232
- if (parsedW.success && parsedW.data > 0) width = emuToPx(parsedW.data);
258
+ const parsedW = ooxmlPositiveLineWidthEmuSchema.safeParse(rawW);
259
+ if (parsedW.success) width = emuToPx(parsedW.data);
233
260
  }
234
261
  if (color === void 0 && width === void 0 && dash === void 0) return { noLine: false };
235
262
  return {
@@ -251,96 +278,114 @@ function readSeriesSpPr(spPr, ignoreLine) {
251
278
  ...line === void 0 ? {} : { line }
252
279
  };
253
280
  }
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) {
281
+ const chartShadowGeometrySchema = z.object({
282
+ blurRad: ooxmlWritableExtentEmuSchema.optional(),
283
+ dist: ooxmlWritableExtentEmuSchema.optional(),
284
+ dir: ooxmlPositiveFixedAngleSchema.optional()
285
+ });
286
+ function readChartOuterShadow(rPrCursor, ctx) {
287
+ if (rPrCursor.ignoreEmptyChild("http://schemas.openxmlformats.org/drawingml/2006/main", "effectLst")) return "none";
260
288
  const effectLst = rPrCursor.child(A_NS, "effectLst");
261
289
  if (effectLst === void 0) return void 0;
262
290
  const outerShdw = effectLst.child(A_NS, "outerShdw");
263
- if (outerShdw === void 0) {
264
- consumeSubtree(effectLst);
265
- return;
291
+ for (const effect of effectLst.remainingElementChildren()) {
292
+ ctx.diagnostics.push({
293
+ code: "unconsumed-xml",
294
+ category: "unsupported",
295
+ disposition: "omitted",
296
+ location: {
297
+ ...ctx.location,
298
+ xpath: effect.xpath
299
+ },
300
+ kind: "element",
301
+ namespaceUri: effect.namespaceUri,
302
+ localName: effect.localName
303
+ });
304
+ effect.suppressUnconsumed();
266
305
  }
267
- const blurRadRaw = outerShdw.attr("blurRad");
268
- const distRaw = outerShdw.attr("dist");
269
- const dirRaw = outerShdw.attr("dir");
306
+ if (outerShdw === void 0) return void 0;
307
+ const attributes = outerShdw.attrsObject([
308
+ "blurRad",
309
+ "dist",
310
+ "dir"
311
+ ]);
270
312
  outerShdw.consumeAttr("algn");
271
313
  outerShdw.consumeAttr("rotWithShape");
272
- const color = readSolidFillColor(outerShdw);
314
+ const color = readDrawingColor(outerShdw, ctx.location, ctx.diagnostics);
273
315
  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);
316
+ const geometry = chartShadowGeometrySchema.safeParse(attributes);
317
+ if (!geometry.success) {
318
+ const invalidAttributes = new Set(geometry.error.issues.map((issue) => String(issue.path[0])));
319
+ for (const name of invalidAttributes) ctx.diagnostics.push({
320
+ code: "invalid-xml-value",
321
+ category: "corrupt-input",
322
+ disposition: "omitted",
323
+ location: {
324
+ ...ctx.location,
325
+ xpath: `${outerShdw.xpath}/@${name}`
326
+ },
327
+ attributeOrElement: `a:outerShdw/@${name}`,
328
+ rawValue: attributes[name] ?? ""
329
+ });
330
+ return;
331
+ }
332
+ const { blurRad, dist, dir } = geometry.data;
278
333
  return {
279
334
  ...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 } : {}
335
+ ...blurRad === void 0 ? {} : { blur: emuToPx(blurRad) },
336
+ ...dist === void 0 ? {} : { distance: emuToPx(dist) },
337
+ ...dir === void 0 ? {} : { angle: dir / 6e4 }
283
338
  };
284
339
  }
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);
340
+ /** Keep both native axes until the final chart text position is known. */
341
+ function cascadeChartStyle(inherited, local) {
342
+ return {
343
+ ...inherited,
344
+ ...local,
345
+ ...local?.decoration === void 0 ? {} : { decoration: cascadeOoxmlTextDecoration(inherited?.decoration, local.decoration) }
346
+ };
347
+ }
348
+ function projectChartStyle(native) {
349
+ const { decoration, ...style } = native;
350
+ const textDecoration = projectOoxmlTextDecoration(decoration);
351
+ return {
352
+ ...style,
353
+ ...textDecoration === void 0 ? {} : { textDecoration }
354
+ };
355
+ }
356
+ function diffNativeChartStyle(local, inherited) {
357
+ return local === void 0 ? void 0 : diffChartTextStyle(projectChartStyle(cascadeChartStyle(inherited, local)), projectChartStyle(inherited ?? {}));
358
+ }
359
+ function readChartRunProperties(rPrCursor, ctx) {
360
+ const attrStyles = readOoxmlRunAttrStyles({
361
+ rPrCursor,
362
+ location: ctx.location,
363
+ diagnostics: ctx.diagnostics,
364
+ allowBaseline: false,
365
+ diagnoseUnsupportedEnums: true
366
+ });
367
+ const { color, textStroke } = readRunFillAndStroke(rPrCursor, ctx.location, ctx.diagnostics);
368
+ const textShadow = readChartOuterShadow(rPrCursor, ctx);
369
+ const { fontFamily, eastAsianFontFamily } = readRunFontSlots(rPrCursor);
327
370
  consumeSubtree(rPrCursor);
328
371
  return {
329
372
  ...fontFamily === void 0 ? {} : { fontFamily },
330
- ...fontSize === void 0 ? {} : { fontSize },
331
- ...fontWeight === void 0 ? {} : { fontWeight },
332
- ...fontStyle === void 0 ? {} : { fontStyle },
373
+ ...eastAsianFontFamily === void 0 ? {} : { eastAsianFontFamily },
374
+ ...attrStyles.fontSize === void 0 ? {} : { fontSize: attrStyles.fontSize },
375
+ ...attrStyles.fontWeight === void 0 ? {} : { fontWeight: attrStyles.fontWeight },
376
+ ...attrStyles.fontStyle === void 0 ? {} : { fontStyle: attrStyles.fontStyle },
333
377
  ...color === void 0 ? {} : { color },
334
- ...letterSpacing === void 0 ? {} : { letterSpacing },
335
- ...textTransform === void 0 ? {} : { textTransform },
336
- ...textDecoration === void 0 ? {} : { textDecoration },
378
+ ...attrStyles.letterSpacing === void 0 ? {} : { letterSpacing: attrStyles.letterSpacing },
379
+ ...attrStyles.textTransform === void 0 ? {} : { textTransform: attrStyles.textTransform },
380
+ ...attrStyles.decoration === void 0 ? {} : { decoration: attrStyles.decoration },
337
381
  ...textShadow === void 0 ? {} : { textShadow },
338
- ...lang === void 0 ? {} : { lang }
382
+ ...textStroke === void 0 ? {} : { textStroke },
383
+ ...attrStyles.lang === void 0 ? {} : { lang: attrStyles.lang }
339
384
  };
340
385
  }
341
- function readChartTextProperties(txPrCursor) {
386
+ function readChartTextBodyStyle(cursor) {
342
387
  let verticalAlign;
343
- const bodyPr = txPrCursor.child(A_NS, "bodyPr");
388
+ const bodyPr = cursor.child(A_NS, "bodyPr");
344
389
  if (bodyPr !== void 0) {
345
390
  const anchor = bodyPr.attr("anchor");
346
391
  if (anchor === "t") verticalAlign = "top";
@@ -348,61 +393,68 @@ function readChartTextProperties(txPrCursor) {
348
393
  else if (anchor === "b") verticalAlign = "bottom";
349
394
  consumeSubtree(bodyPr);
350
395
  }
351
- let align;
352
- let lineHeight;
353
- let spacingAfter;
354
- let defStyle = {};
355
- let runStyle = {};
356
- let endLang;
396
+ return verticalAlign === void 0 ? {} : { verticalAlign };
397
+ }
398
+ function readChartListDecorations(body, ctx) {
399
+ if (body.ignoreEmptyChild("http://schemas.openxmlformats.org/drawingml/2006/main", "lstStyle")) return void 0;
400
+ const list = body.child(A_NS, "lstStyle");
401
+ if (list === void 0) return void 0;
402
+ const read = (name) => {
403
+ const defaults = list.child(A_NS, name)?.child(A_NS, "defRPr");
404
+ return defaults === void 0 ? void 0 : readOoxmlTextDecoration(defaults, ctx.location, ctx.diagnostics, true);
405
+ };
406
+ const base = read("defPPr");
407
+ return Array.from({ length: 9 }, (_, index) => {
408
+ const level = read(`lvl${index + 1}pPr`);
409
+ return level === void 0 ? base : cascadeOoxmlTextDecoration(base, level);
410
+ });
411
+ }
412
+ function readChartParagraphStyle(pPr, ctx, levels) {
413
+ const level = ooxmlListLevelSchema.safeParse(pPr?.attr("lvl"));
414
+ const decoration = levels?.[level.success ? level.data : 0];
415
+ const inherited = decoration === void 0 ? {} : { decoration };
416
+ if (pPr === void 0) return inherited;
417
+ const layout = readDrawingParagraphLayout(pPr, ctx.location, ctx.diagnostics);
418
+ const defRPr = pPr.child(A_NS, "defRPr");
419
+ const defStyle = defRPr === void 0 ? {} : readChartRunProperties(defRPr, ctx);
420
+ for (const name of ["lnSpc", "spcAft"]) {
421
+ const spacing = pPr.child(A_NS, name);
422
+ if (spacing !== void 0) consumeSubtree(spacing);
423
+ }
424
+ consumeSubtree(pPr);
425
+ return {
426
+ ...cascadeChartStyle(inherited, defStyle),
427
+ ...layout
428
+ };
429
+ }
430
+ function readChartTextProperties(txPrCursor, ctx) {
431
+ const body = readChartTextBodyStyle(txPrCursor);
357
432
  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);
433
+ if (p === void 0) {
434
+ consumeSubtree(txPrCursor);
435
+ return Object.keys(body).length === 0 ? void 0 : body;
436
+ }
437
+ const defaults = readChartParagraphStyle(p.child(A_NS, "pPr"), ctx, readChartListDecorations(txPrCursor, ctx));
438
+ const rPr = p.child(A_NS, "r")?.child(A_NS, "rPr");
439
+ const runStyle = rPr === void 0 ? {} : readChartRunProperties(rPr, ctx);
440
+ let endLang;
441
+ const endParaRPr = p.child(A_NS, "endParaRPr");
442
+ if (endParaRPr !== void 0) {
443
+ const endAttrs = readOoxmlRunAttrStyles({
444
+ rPrCursor: endParaRPr,
445
+ location: ctx.location,
446
+ diagnostics: ctx.diagnostics,
447
+ allowBaseline: false,
448
+ diagnoseUnsupportedEnums: true
449
+ });
450
+ if (endAttrs.lang !== void 0) endLang = endAttrs.lang;
451
+ consumeSubtree(endParaRPr);
396
452
  }
397
453
  consumeSubtree(txPrCursor);
398
454
  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 }
455
+ ...body,
456
+ ...cascadeChartStyle(defaults, runStyle),
457
+ ...endLang !== void 0 && defaults.lang === void 0 && runStyle.lang === void 0 ? { lang: endLang } : {}
406
458
  };
407
459
  return Object.keys(merged).length === 0 ? void 0 : merged;
408
460
  }
@@ -424,6 +476,7 @@ function stableJsonEqual(left, right) {
424
476
  function styleFieldEqual(key, left, right) {
425
477
  if (left === right) return true;
426
478
  if (key === "fontSize" || key === "lineHeight") {
479
+ if (key === "lineHeight" && typeof left === "string" && typeof right === "string" && left.endsWith("%") && right.endsWith("%")) return Math.abs(Number(left.slice(0, -1)) - Number(right.slice(0, -1))) < 1e-6;
427
480
  const lPt = fontSizePointsValue(left);
428
481
  const rPt = fontSizePointsValue(right);
429
482
  return lPt !== void 0 && rPt !== void 0 && Math.abs(lPt - rPt) < 1e-6;
@@ -438,6 +491,9 @@ function diffChartTextStyle(child, inherited) {
438
491
  verticalAlign: "top",
439
492
  textDecoration: "none",
440
493
  textTransform: "none",
494
+ textShadow: "none",
495
+ letterSpacing: 0,
496
+ spacingAfter: 0,
441
497
  color: "dk1",
442
498
  ...inherited
443
499
  };
@@ -463,51 +519,26 @@ function normalizeRootChartStyle(rawStyle) {
463
519
  }
464
520
  return Object.keys(out).length === 0 ? void 0 : out;
465
521
  }
466
- function readChartTitle(titleCursor, inheritedStyle) {
522
+ function readChartTitle(titleCursor, inheritedStyle, ctx) {
523
+ const spPr = readChartSpPr(titleCursor, ctx);
524
+ if (spPr !== void 0) consumeBenignChartSpPr(spPr);
467
525
  let titleText;
468
526
  let richStyle;
469
527
  const tx = titleCursor.child(C_NS, "tx");
470
528
  if (tx !== void 0) {
471
529
  const rich = tx.child(C_NS, "rich");
472
530
  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 = {};
531
+ const body = readChartTextBodyStyle(rich);
532
+ let paragraphStyle = {};
481
533
  let explicitRun = {};
482
534
  const parts = [];
483
535
  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
- }
536
+ if (paraIndex === 0) paragraphStyle = readChartParagraphStyle(para.child(A_NS, "pPr"), ctx);
506
537
  const runs = [];
507
538
  for (const child of para.remainingElementChildren()) if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "r") {
508
539
  if (paraIndex === 0 && Object.keys(explicitRun).length === 0) {
509
540
  const rPr = child.child(A_NS, "rPr");
510
- if (rPr !== void 0) explicitRun = readChartRunProperties(rPr);
541
+ if (rPr !== void 0) explicitRun = readChartRunProperties(rPr, ctx);
511
542
  }
512
543
  const t = child.child(A_NS, "t");
513
544
  if (t !== void 0) runs.push(t.textContent);
@@ -522,12 +553,8 @@ function readChartTitle(titleCursor, inheritedStyle) {
522
553
  titleText = parts.join("\n");
523
554
  consumeSubtree(rich);
524
555
  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 }
556
+ ...cascadeChartStyle(paragraphStyle, explicitRun),
557
+ ...body
531
558
  };
532
559
  } else {
533
560
  const strRef = tx.child(C_NS, "strRef");
@@ -546,13 +573,10 @@ function readChartTitle(titleCursor, inheritedStyle) {
546
573
  consumeSubtree(tx);
547
574
  }
548
575
  const txPr = titleCursor.child(C_NS, "txPr");
549
- const txPrStyle = txPr === void 0 ? void 0 : readChartTextProperties(txPr);
576
+ const txPrStyle = txPr === void 0 ? void 0 : readChartTextProperties(txPr, ctx);
550
577
  consumeSubtree(titleCursor);
551
578
  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);
579
+ const styleDiff = diffNativeChartStyle(richStyle !== void 0 || txPrStyle !== void 0 ? cascadeChartStyle(txPrStyle, richStyle) : void 0, inheritedStyle);
556
580
  return styleDiff === void 0 ? titleText : {
557
581
  text: titleText,
558
582
  style: styleDiff
@@ -701,12 +725,12 @@ function readSeriesName(txCursor) {
701
725
  consumeSubtree(txCursor);
702
726
  return text;
703
727
  }
704
- function readMarkerElement(markerCursor) {
728
+ function readMarkerElement(markerCursor, ctx) {
705
729
  const symbolCursor = markerCursor.child(C_NS, "symbol");
706
730
  const parsedSymbol = symbolCursor === void 0 ? void 0 : MarkerSymbolSchema.safeParse(symbolCursor.attrsObject(["val"]));
707
731
  const symbol = parsedSymbol?.success ? parsedSymbol.data.val : void 0;
708
732
  const size = readIntVal(markerCursor.child(C_NS, "size"));
709
- const spPr = markerCursor.child(C_NS, "spPr");
733
+ const spPr = readChartSpPr(markerCursor, ctx);
710
734
  let fill;
711
735
  let line;
712
736
  if (spPr !== void 0) {
@@ -725,7 +749,215 @@ function readMarkerElement(markerCursor) {
725
749
  ...line === void 0 ? {} : { line }
726
750
  };
727
751
  }
728
- function readDataLabelSettingsBody(cursor, kind, isPointLevel = false) {
752
+ /** Resolve same-node category aliases before cascading the two independent switches. */
753
+ function mergeCategoryFlags(categoryRange, ...levels) {
754
+ const flags = {};
755
+ for (const level of levels) {
756
+ if (level?.name !== void 0) flags.name = level.name && !(categoryRange && level.range !== void 0);
757
+ if (level?.range !== void 0) flags.range = level.range;
758
+ }
759
+ return flags;
760
+ }
761
+ function categoryLabelOverride(local, parent, inheritedCategory) {
762
+ const name = local.name ?? parent?.name;
763
+ const range = local.range ?? parent?.range;
764
+ const enabled = name === true || range === true;
765
+ return local.name || local.range || enabled !== (inheritedCategory === true) ? enabled : void 0;
766
+ }
767
+ function readPointLabelField(nativeType, scatter) {
768
+ switch (nativeType?.toUpperCase()) {
769
+ case "SERIESNAME": return "seriesName";
770
+ case "CATEGORYNAME": return scatter ? "xValue" : "category";
771
+ case "XVALUE": return "xValue";
772
+ case "VALUE":
773
+ case "YVALUE": return "value";
774
+ case "PERCENTAGE": return "percent";
775
+ case "CELLRANGE": return "cellRange";
776
+ default: return;
777
+ }
778
+ }
779
+ function formatPointLabelField(field, point, numberFormat) {
780
+ if (field === void 0) return void 0;
781
+ const data = point[field];
782
+ return typeof data === "number" ? formatChartNumber(data, numberFormat ?? (field === "percent" ? "0%" : void 0)) : data ?? void 0;
783
+ }
784
+ function isAutomaticPointLabel(tokens, settings) {
785
+ const fields = chartDataLabelFieldOrder.filter((field) => settings[field] === true);
786
+ const separator = settings.separator ?? ", ";
787
+ let index = 0;
788
+ let literal = "";
789
+ for (const token of tokens) if (!("field" in token)) literal += token.text;
790
+ else {
791
+ if (literal !== (index === 0 ? "" : separator) || token.field !== fields[index] || index >= fields.length) return false;
792
+ literal = "";
793
+ index += 1;
794
+ }
795
+ return index === fields.length && literal === "";
796
+ }
797
+ /** Reads the XML once; group point labels may be evaluated for several series. */
798
+ function readPointLabelText(tx, kind, ctx) {
799
+ const rich = tx.child(C_NS, "rich");
800
+ if (rich === void 0) {
801
+ const strRef = tx.child(C_NS, "strRef");
802
+ const cache = strRef?.child(C_NS, "strCache");
803
+ const first = cache?.child(C_NS, "pt");
804
+ const text = first?.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "v")?.textContent ?? "";
805
+ if (first !== void 0) consumeSubtree(first);
806
+ if (cache !== void 0) consumeSubtree(cache);
807
+ if (strRef !== void 0) consumeSubtree(strRef);
808
+ consumeSubtree(tx);
809
+ return {
810
+ xpath: tx.xpath,
811
+ tokens: [{ text }],
812
+ hasFields: false
813
+ };
814
+ }
815
+ const body = readChartTextBodyStyle(rich);
816
+ const levels = readChartListDecorations(rich, ctx);
817
+ const tokens = [];
818
+ let hasFields = false;
819
+ for (const [index, paragraph] of rich.children(A_NS, "p").entries()) {
820
+ if (index > 0) tokens.push({ text: "\n" });
821
+ const paragraphStyle = readChartParagraphStyle(paragraph.child(A_NS, "pPr"), ctx, levels);
822
+ const endParaRPr = paragraph.child(A_NS, "endParaRPr");
823
+ if (endParaRPr !== void 0) consumeSubtree(endParaRPr);
824
+ const inlines = paragraph.matchingChildren((child) => child.namespaceURI === "http://schemas.openxmlformats.org/drawingml/2006/main" && (child.localName === "r" || child.localName === "br" || child.localName === "fld"));
825
+ for (const child of inlines) {
826
+ if (child.localName === "br") tokens.push({ text: "\n" });
827
+ else {
828
+ const textNode = child.child(A_NS, "t");
829
+ const text = textNode?.textContent ?? "";
830
+ if (textNode !== void 0) consumeSubtree(textNode);
831
+ const rPr = child.child(A_NS, "rPr");
832
+ const run = rPr === void 0 ? {} : readChartRunProperties(rPr, ctx);
833
+ const style = {
834
+ ...body,
835
+ ...cascadeChartStyle(paragraphStyle, run)
836
+ };
837
+ if (child.localName === "fld") {
838
+ hasFields = true;
839
+ const field = readPointLabelField(child.attr("type"), kind === "scatter");
840
+ tokens.push({
841
+ text,
842
+ style,
843
+ field,
844
+ xpath: child.xpath
845
+ });
846
+ } else tokens.push({
847
+ text,
848
+ style,
849
+ xpath: child.xpath
850
+ });
851
+ }
852
+ consumeSubtree(child);
853
+ }
854
+ consumeSubtree(paragraph);
855
+ }
856
+ consumeSubtree(rich);
857
+ consumeSubtree(tx);
858
+ return {
859
+ xpath: rich.xpath,
860
+ bodyStyle: body,
861
+ tokens,
862
+ hasFields
863
+ };
864
+ }
865
+ /** Resolves cached or dynamic text and retains the first visible run's style. */
866
+ function resolvePointLabelText(source, base, settings, point) {
867
+ let style;
868
+ const decorations = [];
869
+ let mixedStyles = false;
870
+ let text = "";
871
+ for (const token of source.tokens) {
872
+ const value = "field" in token && point !== void 0 ? formatPointLabelField(token.field, point, settings.numberFormat) ?? token.text : token.text;
873
+ text += value;
874
+ if (value === "" || token.style === void 0) continue;
875
+ const native = cascadeChartStyle(base, token.style);
876
+ const projected = projectChartStyle(native);
877
+ if (native.decoration !== void 0 && token.xpath !== void 0) decorations.push({
878
+ xpath: token.xpath,
879
+ state: native.decoration
880
+ });
881
+ if (style === void 0) style = projected;
882
+ else if (!mixedStyles) mixedStyles = diffChartTextStyle(projected, style) !== void 0 || diffChartTextStyle(style, projected) !== void 0;
883
+ }
884
+ const automatic = source.hasFields && isAutomaticPointLabel(source.tokens, settings);
885
+ if (text !== "" && !automatic) style ??= projectChartStyle(cascadeChartStyle(base, source.bodyStyle));
886
+ return {
887
+ ...text === "" || automatic ? {} : { text },
888
+ ...style === void 0 ? {} : { style },
889
+ mixedStyles,
890
+ decorations,
891
+ staticFieldFallback: source.hasFields && !automatic
892
+ };
893
+ }
894
+ function reportLabelDecoration(state, xpath, ctx) {
895
+ if (state === void 0 || ctx.reportedLabelFallbacks.has(xpath)) return;
896
+ const before = ctx.diagnostics.length;
897
+ reportOoxmlTextDecorationLoss(state, {
898
+ ...ctx.location,
899
+ xpath
900
+ }, ctx.diagnostics);
901
+ if (ctx.diagnostics.length > before) ctx.reportedLabelFallbacks.add(xpath);
902
+ }
903
+ function applyPointLabelText(kind, source, settings, baseStyle, baseline, ctx, point) {
904
+ const effective = mergeDataLabels(baseline, settings) || {};
905
+ const { text, style, mixedStyles, staticFieldFallback, decorations } = "resolved" in source ? source.resolved : resolvePointLabelText(source, baseStyle, effective, point);
906
+ function reportFallback(preferredMechanism, selectedFallback, retainedAs) {
907
+ const key = `${source.xpath}:${preferredMechanism}`;
908
+ if (ctx.reportedLabelFallbacks.has(key)) return;
909
+ ctx.reportedLabelFallbacks.add(key);
910
+ ctx.diagnostics.push({
911
+ code: "compatibility-fallback",
912
+ category: "unsupported",
913
+ disposition: "fallback",
914
+ location: {
915
+ ...ctx.location,
916
+ xpath: source.xpath
917
+ },
918
+ preferredMechanism,
919
+ selectedFallback,
920
+ loss: {
921
+ lost: "native-mechanism",
922
+ retainedAs
923
+ }
924
+ });
925
+ }
926
+ if (text !== void 0 || hasAutomaticDataLabels(kind, effective)) {
927
+ if (decorations.length === 0) reportLabelDecoration(baseStyle.decoration, source.xpath, ctx);
928
+ for (const { xpath, state } of decorations) reportLabelDecoration(state, xpath, ctx);
929
+ }
930
+ if (mixedStyles) reportFallback("mixed chart data label text styles", "first visible run style", "uniform chart data label style");
931
+ if (staticFieldFallback) reportFallback("dynamic chart data label fields", "static chart data label text", "static chart data label text");
932
+ return {
933
+ ...settings,
934
+ ...text === void 0 ? {} : { text },
935
+ ...style === void 0 ? {} : { style }
936
+ };
937
+ }
938
+ function readDataLabelFlag(cursor, name) {
939
+ return readBoolVal(cursor.child(C_NS, name), true);
940
+ }
941
+ /** Drops point-label layout, which the editable chart model cannot represent. */
942
+ function omitPointLabelLayout(layout, ctx) {
943
+ if (layout === void 0 || layout.ignoreEmptyChild("http://schemas.openxmlformats.org/drawingml/2006/chart", "manualLayout")) return;
944
+ const manual = layout.child(C_NS, "manualLayout");
945
+ if (manual === void 0) return;
946
+ ctx.diagnostics.push({
947
+ code: "unsupported-mechanism",
948
+ category: "unsupported",
949
+ disposition: "omitted",
950
+ location: {
951
+ ...ctx.location,
952
+ xpath: manual.xpath
953
+ },
954
+ namespaceUri: manual.namespaceUri,
955
+ localName: manual.localName,
956
+ mechanismHint: "manualLayout"
957
+ });
958
+ manual.suppressUnconsumed();
959
+ }
960
+ function readDataLabelSettingsBody(cursor, kind, ctx, isPointLevel) {
729
961
  const numFmtCursor = cursor.child(C_NS, "numFmt");
730
962
  let numberFormat;
731
963
  if (numFmtCursor !== void 0) {
@@ -734,10 +966,10 @@ function readDataLabelSettingsBody(cursor, kind, isPointLevel = false) {
734
966
  if (code !== void 0 && code.trim() !== "" && (slRaw === "0" || slRaw === "false" || code !== "General")) numberFormat = code;
735
967
  consumeSubtree(numFmtCursor);
736
968
  }
737
- const spPr = cursor.child(C_NS, "spPr");
969
+ const spPr = readChartSpPr(cursor, ctx);
738
970
  if (spPr !== void 0) consumeSubtree(spPr);
739
971
  const txPr = cursor.child(C_NS, "txPr");
740
- const rawStyle = txPr === void 0 ? void 0 : readChartTextProperties(txPr);
972
+ const rawStyle = txPr === void 0 ? void 0 : readChartTextProperties(txPr, ctx);
741
973
  const dLblPos = cursor.child(C_NS, "dLblPos");
742
974
  let position;
743
975
  if (dLblPos !== void 0) {
@@ -755,19 +987,19 @@ function readDataLabelSettingsBody(cursor, kind, isPointLevel = false) {
755
987
  }
756
988
  const legendKey = cursor.child(C_NS, "showLegendKey");
757
989
  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"));
990
+ const showVal = readDataLabelFlag(cursor, "showVal");
991
+ const showCatName = readDataLabelFlag(cursor, "showCatName");
992
+ const showSerName = readDataLabelFlag(cursor, "showSerName");
993
+ const showPercent = readDataLabelFlag(cursor, "showPercent");
762
994
  const showBubbleSize = cursor.child(C_NS, "showBubbleSize");
763
995
  if (showBubbleSize !== void 0) consumeSubtree(showBubbleSize);
764
996
  const sepCursor = cursor.child(C_NS, "separator");
765
997
  const separator = sepCursor !== void 0 && sepCursor.textContent.length > 0 ? sepCursor.textContent : void 0;
766
- const showLeaderLines = readBoolVal(cursor.child(C_NS, "showLeaderLines"));
998
+ const showLeaderLines = readDataLabelFlag(cursor, "showLeaderLines");
767
999
  const leaderLinesCursor = cursor.child(C_NS, "leaderLines");
768
1000
  let leaderLineStyle;
769
1001
  if (leaderLinesCursor !== void 0) {
770
- const lSpPr = leaderLinesCursor.child(C_NS, "spPr");
1002
+ const lSpPr = readChartSpPr(leaderLinesCursor, ctx);
771
1003
  if (lSpPr !== void 0) {
772
1004
  leaderLineStyle = readLineFromSpPr(lSpPr).line;
773
1005
  consumeSubtree(lSpPr);
@@ -777,81 +1009,114 @@ function readDataLabelSettingsBody(cursor, kind, isPointLevel = false) {
777
1009
  let showDataLabelsRange;
778
1010
  const extLst = cursor.child(C_NS, "extLst");
779
1011
  if (extLst !== void 0) for (const ext of extLst.children(C_NS, "ext")) {
1012
+ if (isPointLevel) omitPointLabelLayout(ext.child(C15_NS, "layout"), ctx);
780
1013
  const uri = ext.attr("uri");
781
1014
  if (uri === C15_DLBL_RANGE_FLAG_EXT_URI) {
782
- showDataLabelsRange = readBoolVal(ext.child(C15_NS, "showDataLabelsRange"));
1015
+ showDataLabelsRange = readBoolVal(ext.child(C15_NS, "showDataLabelsRange"), true);
783
1016
  consumeSubtree(ext);
784
1017
  } else if (uri === "{CE6537A1-D6FC-4f65-9D91-7224C49458BB}" || uri === "{0b15fc19-7d7d-44ad-8c2d-2c3a37ce22c3}" || uri === C16_UNIQUE_ID_EXT_URI) consumeSubtree(ext);
785
1018
  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
1019
  }
787
1020
  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
- }
1021
+ const xValue = kind === "scatter" ? showCatName : void 0;
1022
+ const value = showVal;
1023
+ const percent = kind === "pie" || kind === "doughnut" ? showPercent : void 0;
1024
+ const seriesName = showSerName;
1025
+ const settings = {
1026
+ ...value === void 0 ? {} : { value },
1027
+ ...percent === void 0 ? {} : { percent },
1028
+ ...xValue === void 0 ? {} : { xValue },
1029
+ ...seriesName === void 0 ? {} : { seriesName },
1030
+ ...separator === void 0 ? {} : { separator },
1031
+ ...position === void 0 ? {} : { position },
1032
+ ...numberFormat === void 0 ? {} : { numberFormat }
1033
+ };
1034
+ const leaderLines = !isPointLevel && (kind === "pie" || kind === "doughnut") ? leaderLineStyle ?? showLeaderLines : void 0;
799
1035
  return {
1036
+ ...kind === "scatter" ? {} : { categoryFlags: {
1037
+ ...showCatName === void 0 ? {} : { name: showCatName },
1038
+ ...showDataLabelsRange === void 0 ? {} : { range: showDataLabelsRange }
1039
+ } },
800
1040
  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 },
1041
+ ...settings,
809
1042
  ...leaderLines === void 0 ? {} : { leaderLines }
810
1043
  },
811
- ...rawStyle === void 0 ? {} : { rawStyle },
812
- ...showDataLabelsRange === void 0 ? {} : { showDataLabelsRange }
1044
+ ...rawStyle === void 0 ? {} : { rawStyle }
813
1045
  };
814
1046
  }
815
- function readDataLabelsElement(dLblsCursor, kind, isGroupLevel, inheritedChartStyle) {
1047
+ function readDataLabelsElement(dLblsCursor, kind, isGroupLevel, inheritedChartStyle, ctx, group, categoryRange = false) {
816
1048
  const pointLabels = /* @__PURE__ */ new Map();
817
- const pointRawColors = /* @__PURE__ */ new Map();
1049
+ const inheritedLabels = group?.dataLabels;
1050
+ const del = readBoolVal(dLblsCursor.child(C_NS, "delete"), true);
1051
+ const { settings: body, categoryFlags, rawStyle } = del === true ? { settings: {} } : readDataLabelSettingsBody(dLblsCursor, kind, ctx, false);
1052
+ const category = isGroupLevel ? categoryLabelOverride(mergeCategoryFlags(categoryRange, categoryFlags)) : void 0;
1053
+ const settings = category === void 0 ? body : {
1054
+ ...body,
1055
+ category
1056
+ };
1057
+ const nativeCategory = categoryFlags === void 0 ? {} : { categoryFlags };
1058
+ const dataLabelsStyle = diffNativeChartStyle(rawStyle, inheritedChartStyle);
1059
+ const style = rawStyle === void 0 ? {} : { style: rawStyle };
818
1060
  for (const dLbl of dLblsCursor.children(C_NS, "dLbl")) {
819
1061
  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);
1062
+ if (idx === void 0) {
1063
+ consumeSubtree(dLbl);
1064
+ continue;
1065
+ }
1066
+ if (readBoolVal(dLbl.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "delete"), true) === true) {
1067
+ pointLabels.set(idx, {
1068
+ settings: false,
1069
+ xpath: dLbl.xpath
1070
+ });
1071
+ consumeSubtree(dLbl);
1072
+ continue;
1073
+ }
1074
+ omitPointLabelLayout(dLbl.child(C_NS, "layout"), ctx);
1075
+ const local = readDataLabelSettingsBody(dLbl, kind, ctx, true);
1076
+ const tx = dLbl.child(C_NS, "tx");
1077
+ let source;
1078
+ if (tx !== void 0) {
1079
+ source = readPointLabelText(tx, kind, ctx);
1080
+ if (!isGroupLevel && !source.hasFields) {
1081
+ const groupPoint = del === true || inheritedLabels === false ? void 0 : group?.pointLabels.get(idx);
1082
+ const pointStyle = cascadeChartStyle(cascadeChartStyle(cascadeChartStyle(inheritedChartStyle, rawStyle), groupPoint?.style), local.rawStyle);
1083
+ source = {
1084
+ xpath: source.xpath,
1085
+ hasFields: false,
1086
+ resolved: resolvePointLabelText(source, pointStyle, local.settings)
1087
+ };
827
1088
  }
828
1089
  }
1090
+ pointLabels.set(idx, {
1091
+ xpath: dLbl.xpath,
1092
+ settings: local.settings,
1093
+ ...local.categoryFlags === void 0 ? {} : { categoryFlags: local.categoryFlags },
1094
+ ...local.rawStyle === void 0 ? {} : { style: local.rawStyle },
1095
+ ...source === void 0 ? {} : { source }
1096
+ });
829
1097
  consumeSubtree(dLbl);
830
1098
  }
831
- if (readBoolVal(dLblsCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "delete")) === true) {
1099
+ if (del === true) {
832
1100
  consumeSubtree(dLblsCursor);
833
1101
  return {
834
1102
  dataLabels: false,
835
- pointLabels,
836
- pointLabelColors: /* @__PURE__ */ new Map()
1103
+ pointLabels
837
1104
  };
838
1105
  }
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
1106
  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
1107
  if (isGroupLevel && !hasAnyEnabledOrCustomized) return {
846
1108
  pointLabels,
847
- pointLabelColors
1109
+ ...style,
1110
+ ...nativeCategory
848
1111
  };
1112
+ const flags = {};
1113
+ for (const field of chartDataLabelFieldOrder) {
1114
+ const enabled = settings[field];
1115
+ if (enabled !== void 0 && (enabled || inheritedLabels && inheritedLabels[field] === true)) flags[field] = enabled;
1116
+ }
849
1117
  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 } : {},
1118
+ ...flags,
1119
+ ...dataLabelsStyle === void 0 ? {} : { style: dataLabelsStyle },
855
1120
  ...settings.separator === void 0 ? {} : { separator: settings.separator },
856
1121
  ...settings.position === void 0 ? {} : { position: settings.position },
857
1122
  ...settings.numberFormat === void 0 ? {} : { numberFormat: settings.numberFormat },
@@ -859,24 +1124,67 @@ function readDataLabelsElement(dLblsCursor, kind, isGroupLevel, inheritedChartSt
859
1124
  };
860
1125
  return {
861
1126
  ...Object.keys(normalized).length > 0 ? { dataLabels: normalized } : {},
862
- ...dataLabelsStyle === void 0 ? {} : { dataLabelsStyle },
863
1127
  pointLabels,
864
- pointLabelColors,
865
- ...showDataLabelsRange === void 0 ? {} : { showDataLabelsRange }
1128
+ ...nativeCategory,
1129
+ ...style
866
1130
  };
867
1131
  }
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;
1132
+ function diffPointDataLabels(pointLabels, seriesLabels, seriesStyle) {
1133
+ if (!pointLabels) return pointLabels;
1134
+ const { style, text } = pointLabels;
1135
+ const seriesSettings = seriesLabels || void 0;
1136
+ const styleDiff = diffChartTextStyle(style, seriesStyle);
1137
+ const out = styleDiff === void 0 ? {} : { style: styleDiff };
1138
+ if (text === void 0) for (const field of chartDataLabelFieldOrder) {
1139
+ const enabled = pointLabels[field];
1140
+ if (enabled === true || enabled === false && seriesSettings?.[field] === true) out[field] = enabled;
1141
+ }
1142
+ else out.text = text;
1143
+ for (const field of [
1144
+ "position",
1145
+ "numberFormat",
1146
+ "separator"
1147
+ ]) {
1148
+ const value = pointLabels[field];
1149
+ if (value !== void 0 && value !== seriesSettings?.[field]) out[field] = value;
876
1150
  }
877
1151
  return Object.keys(out).length === 0 ? void 0 : out;
878
1152
  }
879
- function readSeriesTrendlines(serCursor, kind, stacking, pointCount, fitPoints) {
1153
+ function readEffectivePointLabels(kind, group, series, pointCount, inheritedChartStyle, seriesXpath, pointData, ctx, categoryRange = false) {
1154
+ const result = /* @__PURE__ */ new Map();
1155
+ const baseline = mergeDataLabels(group?.dataLabels, series?.dataLabels);
1156
+ const useGroup = series?.dataLabels !== false && group?.dataLabels !== false;
1157
+ const parentFlags = mergeCategoryFlags(categoryRange, useGroup ? group?.categoryFlags : void 0, series?.categoryFlags);
1158
+ const indexes = /* @__PURE__ */ new Set([...useGroup ? group?.pointLabels.keys() ?? [] : [], ...series?.pointLabels.keys() ?? []]);
1159
+ const seriesStyle = cascadeChartStyle(inheritedChartStyle, series?.style);
1160
+ const publicSeriesStyle = projectChartStyle(seriesStyle);
1161
+ let defaultCount = pointCount;
1162
+ for (const index of indexes) {
1163
+ if (useGroup && !series?.pointLabels.has(index) && (index < 0 || index >= pointCount)) continue;
1164
+ const groupPoint = useGroup ? group?.pointLabels.get(index) : void 0;
1165
+ const seriesPoint = series?.pointLabels.get(index);
1166
+ let settings = mergeDataLabels(groupPoint?.settings, seriesPoint?.settings);
1167
+ const inRange = index >= 0 && index < pointCount;
1168
+ if (inRange) defaultCount -= 1;
1169
+ if (settings) {
1170
+ const category = categoryLabelOverride(mergeCategoryFlags(categoryRange, groupPoint?.categoryFlags, seriesPoint?.categoryFlags), parentFlags, baseline ? baseline.category : void 0);
1171
+ const pointStyle = cascadeChartStyle(cascadeChartStyle(seriesStyle, groupPoint?.style), seriesPoint?.style);
1172
+ settings = {
1173
+ ...settings,
1174
+ ...category === void 0 ? {} : { category },
1175
+ style: projectChartStyle(pointStyle)
1176
+ };
1177
+ const source = seriesPoint?.source ?? groupPoint?.source;
1178
+ if (source !== void 0 && inRange) settings = applyPointLabelText(kind, source, settings, pointStyle, baseline, ctx, source.hasFields ? pointData(index) : void 0);
1179
+ else if (inRange && hasVisibleDataLabels(kind, mergeDataLabels(baseline, settings))) reportLabelDecoration(pointStyle.decoration, (seriesPoint ?? groupPoint).xpath, ctx);
1180
+ }
1181
+ const point = diffPointDataLabels(settings, baseline, publicSeriesStyle);
1182
+ if (point !== void 0) result.set(index, point);
1183
+ }
1184
+ if (defaultCount > 0 && hasVisibleDataLabels(kind, baseline)) reportLabelDecoration(seriesStyle.decoration, seriesXpath, ctx);
1185
+ return result;
1186
+ }
1187
+ function readSeriesTrendlines(serCursor, kind, stacking, pointCount, fitPoints, ctx) {
880
1188
  const nodes = serCursor.children(C_NS, "trendline");
881
1189
  if (nodes.length === 0) return void 0;
882
1190
  const supported = kind !== "pie" && kind !== "doughnut" && stacking === void 0;
@@ -884,7 +1192,7 @@ function readSeriesTrendlines(serCursor, kind, stacking, pointCount, fitPoints)
884
1192
  for (const tl of nodes) {
885
1193
  const nameEl = tl.child(C_NS, "name");
886
1194
  if (nameEl !== void 0) consumeSubtree(nameEl);
887
- const spPr = tl.child(C_NS, "spPr");
1195
+ const spPr = readChartSpPr(tl, ctx);
888
1196
  const line = spPr === void 0 ? void 0 : readLineFromSpPr(spPr).line;
889
1197
  if (spPr !== void 0) consumeSubtree(spPr);
890
1198
  const typeRaw = readValAttr(tl.child(C_NS, "trendlineType"));
@@ -896,6 +1204,12 @@ function readSeriesTrendlines(serCursor, kind, stacking, pointCount, fitPoints)
896
1204
  const rawIntercept = readFloatVal(tl.child(C_NS, "intercept"));
897
1205
  const displayRSquared = readBoolVal(tl.child(C_NS, "dispRSqr"));
898
1206
  const displayEquation = readBoolVal(tl.child(C_NS, "dispEq"));
1207
+ const label = tl.child(C_NS, "trendlineLbl");
1208
+ if (label !== void 0) {
1209
+ const labelSpPr = readChartSpPr(label, ctx);
1210
+ if (labelSpPr !== void 0) consumeSubtree(labelSpPr);
1211
+ consumeSubtree(label);
1212
+ }
899
1213
  consumeSubtree(tl);
900
1214
  if (!supported || type === void 0) continue;
901
1215
  const validForecast = (value) => {
@@ -968,7 +1282,7 @@ function alignErrorBarValues(values, pointCount) {
968
1282
  return v !== void 0 && v !== null && Number.isFinite(v) && v >= 0 ? v : null;
969
1283
  });
970
1284
  }
971
- function readSingleErrorBars(errCursor, pointCount) {
1285
+ function readSingleErrorBars(errCursor, pointCount, ctx) {
972
1286
  const direction = readValAttr(errCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "errDir")) === "x" ? "x" : "y";
973
1287
  const includeParsed = ErrBarTypeSchema.safeParse(errCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "errBarType")?.attrsObject(["val"]) ?? {});
974
1288
  const include = includeParsed.success ? includeParsed.data.val : "both";
@@ -982,7 +1296,7 @@ function readSingleErrorBars(errCursor, pointCount) {
982
1296
  const rawMinus = minusCursor === void 0 ? void 0 : readNumericDataSource(minusCursor);
983
1297
  if (minusCursor !== void 0) consumeSubtree(minusCursor);
984
1298
  const val = readFloatVal(errCursor.child(C_NS, "val"));
985
- const spPr = errCursor.child(C_NS, "spPr");
1299
+ const spPr = readChartSpPr(errCursor, ctx);
986
1300
  const line = spPr === void 0 ? void 0 : readLineFromSpPr(spPr).line;
987
1301
  if (spPr !== void 0) consumeSubtree(spPr);
988
1302
  consumeSubtree(errCursor);
@@ -1038,23 +1352,23 @@ function readSingleErrorBars(errCursor, pointCount) {
1038
1352
  }
1039
1353
  };
1040
1354
  }
1041
- function readCategoryErrorBars(serCursor, kind, pointCount) {
1355
+ function readCategoryErrorBars(serCursor, kind, pointCount, ctx) {
1042
1356
  const nodes = serCursor.children(C_NS, "errBars");
1043
1357
  if (nodes.length === 0) return void 0;
1044
1358
  let result;
1045
1359
  for (const node of nodes) {
1046
- const parsed = readSingleErrorBars(node, pointCount);
1360
+ const parsed = readSingleErrorBars(node, pointCount, ctx);
1047
1361
  if (kind !== "pie" && kind !== "doughnut" && result === void 0) result = parsed.bars;
1048
1362
  }
1049
1363
  return result;
1050
1364
  }
1051
- function readScatterErrorBars(serCursor, pointCount) {
1365
+ function readScatterErrorBars(serCursor, pointCount, ctx) {
1052
1366
  const nodes = serCursor.children(C_NS, "errBars");
1053
1367
  if (nodes.length === 0) return void 0;
1054
1368
  let x;
1055
1369
  let y;
1056
1370
  for (const node of nodes) {
1057
- const parsed = readSingleErrorBars(node, pointCount);
1371
+ const parsed = readSingleErrorBars(node, pointCount, ctx);
1058
1372
  if (parsed.bars === void 0) continue;
1059
1373
  if (parsed.direction === "x" && x === void 0) x = parsed.bars;
1060
1374
  else if (parsed.direction === "y" && y === void 0) y = parsed.bars;
@@ -1065,16 +1379,51 @@ function readScatterErrorBars(serCursor, pointCount) {
1065
1379
  ...y === void 0 ? {} : { y }
1066
1380
  };
1067
1381
  }
1068
- function readCategorySeries(serCursor, kind, fallbackIndex, stacking, inheritedChartStyle) {
1382
+ function readSeriesDataLabelRange(serCursor) {
1383
+ let datalabelsRange;
1384
+ const extLst = serCursor.child(C_NS, "extLst");
1385
+ if (extLst !== void 0) for (const ext of extLst.children(C_NS, "ext")) {
1386
+ const uri = ext.attr("uri");
1387
+ if (uri === C15_CAT_RANGE_EXT_URI) {
1388
+ const range = ext.child(C15_NS, "datalabelsRange");
1389
+ if (range !== void 0) {
1390
+ const f = range.child(C15_NS, "f");
1391
+ const formula = f?.textContent;
1392
+ if (f !== void 0) consumeSubtree(f);
1393
+ const cache = range.child(C15_NS, "dlblRangeCache");
1394
+ if (cache !== void 0) datalabelsRange = {
1395
+ ...formula === void 0 ? {} : { formula },
1396
+ values: readStringCacheOrLit(cache)
1397
+ };
1398
+ consumeSubtree(range);
1399
+ }
1400
+ consumeSubtree(ext);
1401
+ } else if (uri === C16_UNIQUE_ID_EXT_URI) consumeSubtree(ext);
1402
+ }
1403
+ return datalabelsRange;
1404
+ }
1405
+ function readSeriesCategoryData(ser) {
1406
+ const catCursor = ser.child(C_NS, "cat");
1407
+ const categories = catCursor === void 0 ? { values: [] } : readStringDataSource(catCursor);
1408
+ const range = readSeriesDataLabelRange(ser);
1409
+ return {
1410
+ categories,
1411
+ range,
1412
+ categoryRange: range?.formula !== void 0 && range.formula === categories.formula
1413
+ };
1414
+ }
1415
+ function readCategorySeries(serCursor, kind, fallbackIndex, source, stacking, inheritedChartStyle, groupLabels, ctx) {
1069
1416
  const idx = readIntVal(serCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "idx")) ?? fallbackIndex;
1070
1417
  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");
1418
+ const nativeName = readSeriesName(serCursor.child(C_NS, "tx"));
1419
+ const name = nativeName?.trim() ? nativeName : `Series ${fallbackIndex + 1}`;
1420
+ const spPr = readChartSpPr(serCursor, ctx);
1073
1421
  const { color, line } = spPr === void 0 ? {} : readSeriesSpPr(spPr, false);
1074
1422
  const invertIfNegative = serCursor.child(C_NS, "invertIfNegative");
1075
1423
  if (invertIfNegative !== void 0) consumeSubtree(invertIfNegative);
1076
1424
  const markerCursor = serCursor.child(C_NS, "marker");
1077
- const marker = markerCursor === void 0 ? void 0 : kind === "line" ? readMarkerElement(markerCursor) : (consumeSubtree(markerCursor), void 0);
1425
+ const importedMarker = markerCursor === void 0 ? void 0 : readMarkerElement(markerCursor, ctx);
1426
+ const marker = kind === "line" ? importedMarker : void 0;
1078
1427
  const explosionVal = readIntVal(serCursor.child(C_NS, "explosion"));
1079
1428
  const explosion = (kind === "pie" || kind === "doughnut") && explosionVal !== void 0 && explosionVal >= 0 ? explosionVal : void 0;
1080
1429
  const pointsRecord = {};
@@ -1085,10 +1434,11 @@ function readCategorySeries(serCursor, kind, fallbackIndex, stacking, inheritedC
1085
1434
  const bubble3D = dPt.child(C_NS, "bubble3D");
1086
1435
  if (bubble3D !== void 0) consumeSubtree(bubble3D);
1087
1436
  const pMarkerCursor = dPt.child(C_NS, "marker");
1088
- const pMarker = pMarkerCursor === void 0 ? void 0 : kind === "line" ? readMarkerElement(pMarkerCursor) : (consumeSubtree(pMarkerCursor), void 0);
1437
+ const importedPointMarker = pMarkerCursor === void 0 ? void 0 : readMarkerElement(pMarkerCursor, ctx);
1438
+ const pMarker = kind === "line" ? importedPointMarker : void 0;
1089
1439
  const pExplosionVal = readIntVal(dPt.child(C_NS, "explosion"));
1090
1440
  const pExplosion = (kind === "pie" || kind === "doughnut") && pExplosionVal !== void 0 && pExplosionVal >= 0 ? pExplosionVal : void 0;
1091
- const pSpPr = dPt.child(C_NS, "spPr");
1441
+ const pSpPr = readChartSpPr(dPt, ctx);
1092
1442
  const pStyle = pSpPr === void 0 ? {} : readSeriesSpPr(pSpPr, false);
1093
1443
  consumeSubtree(dPt);
1094
1444
  if (pointIdx !== void 0 && pointIdx >= 0) {
@@ -1102,23 +1452,20 @@ function readCategorySeries(serCursor, kind, fallbackIndex, stacking, inheritedC
1102
1452
  }
1103
1453
  }
1104
1454
  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
1455
+ let dLblsResult = dLblsCursor === void 0 ? void 0 : readDataLabelsElement(dLblsCursor, kind, false, inheritedChartStyle, ctx, groupLabels);
1456
+ if (dLblsResult?.dataLabels !== false) {
1457
+ const groupSettings = groupLabels?.dataLabels || void 0;
1458
+ const category = categoryLabelOverride(mergeCategoryFlags(source.categoryRange, dLblsResult?.categoryFlags), mergeCategoryFlags(source.categoryRange, groupLabels?.categoryFlags), groupSettings?.category);
1459
+ if (category !== void 0) dLblsResult = {
1460
+ ...dLblsResult,
1461
+ pointLabels: dLblsResult?.pointLabels ?? /* @__PURE__ */ new Map(),
1462
+ dataLabels: {
1463
+ ...dLblsResult?.dataLabels,
1464
+ category
1465
+ }
1110
1466
  };
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
1467
  }
1120
- const catCursor = serCursor.child(C_NS, "cat");
1121
- const catData = catCursor === void 0 ? { values: [] } : readStringDataSource(catCursor);
1468
+ const catData = source.categories;
1122
1469
  const valCursor = serCursor.child(C_NS, "val");
1123
1470
  const valData = valCursor === void 0 ? [] : readNumericDataSource(valCursor);
1124
1471
  const smoothVal = readBoolVal(serCursor.child(C_NS, "smooth"));
@@ -1127,34 +1474,50 @@ function readCategorySeries(serCursor, kind, fallbackIndex, stacking, inheritedC
1127
1474
  x: valueIndex + 1,
1128
1475
  y
1129
1476
  }]);
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);
1477
+ const trendlines = readSeriesTrendlines(serCursor, kind, stacking, valData.length, fitPoints, ctx);
1478
+ const errorBars = readCategoryErrorBars(serCursor, kind, valData.length, ctx);
1479
+ const datalabelsRange = source.range?.values;
1480
+ const categories = catData.values.length === 0 && valData.length > 0 ? Array.from({ length: valData.length }, (_, i) => String(i + 1)) : catData.values;
1481
+ let ringCategories = source.categoryRange ? datalabelsRange : void 0;
1482
+ if (kind === "doughnut" && !source.categoryRange && datalabelsRange !== void 0) {
1483
+ const group = groupLabels?.dataLabels !== false && dLblsResult?.dataLabels !== false ? groupLabels : void 0;
1484
+ const base = {
1485
+ ...group?.categoryFlags,
1486
+ ...dLblsResult?.categoryFlags
1487
+ };
1488
+ ringCategories = categories.map((category, index) => {
1489
+ const groupPoint = group?.pointLabels.get(index);
1490
+ const seriesPoint = dLblsResult?.pointLabels.get(index);
1491
+ const flags = {
1492
+ ...base,
1493
+ ...groupPoint?.categoryFlags,
1494
+ ...seriesPoint?.categoryFlags
1495
+ };
1496
+ return flags.range && !flags.name && (seriesPoint?.settings ?? groupPoint?.settings) !== false ? datalabelsRange[index] ?? category : category;
1497
+ });
1147
1498
  }
1148
- const pointCount = Math.max(catData.values.length, valData.length);
1499
+ const pointCount = Math.max(categories.length, valData.length);
1500
+ const total = kind === "pie" || kind === "doughnut" ? valData.reduce((sum, value) => sum + Math.max(0, value ?? 0), 0) : 0;
1501
+ for (const [index, dataLabels] of readEffectivePointLabels(kind, groupLabels, dLblsResult, pointCount, inheritedChartStyle, serCursor.xpath, (index) => ({
1502
+ seriesName: name,
1503
+ category: categories[index],
1504
+ value: valData[index],
1505
+ percent: total > 0 ? (valData[index] ?? 0) / total : void 0,
1506
+ cellRange: datalabelsRange?.[index]
1507
+ }), ctx, source.categoryRange)) pointsRecord[index] = {
1508
+ ...pointsRecord[index],
1509
+ dataLabels
1510
+ };
1149
1511
  const normalizedPoints = {};
1150
1512
  for (const [key, pt] of Object.entries(pointsRecord)) {
1151
1513
  const numKey = Number(key);
1152
- if (numKey >= 0 && numKey < pointCount) normalizedPoints[numKey] = pt;
1514
+ if (numKey >= 0 && Number.isSafeInteger(numKey)) normalizedPoints[numKey] = pt;
1153
1515
  }
1516
+ const seriesDataLabels = dLblsResult?.dataLabels;
1154
1517
  return {
1155
1518
  order,
1156
- name: name.trim() === "" ? `Series ${fallbackIndex + 1}` : name,
1157
- categories: catData.values,
1519
+ name,
1520
+ categories,
1158
1521
  ...catData.formula === void 0 ? {} : { categoryFormula: catData.formula },
1159
1522
  values: valData,
1160
1523
  ...color === void 0 ? {} : { color },
@@ -1162,30 +1525,30 @@ function readCategorySeries(serCursor, kind, fallbackIndex, stacking, inheritedC
1162
1525
  ...explosion === void 0 ? {} : { explosion },
1163
1526
  ...marker === void 0 ? {} : { marker },
1164
1527
  ...smooth === void 0 ? {} : { smooth },
1165
- ...dLblsResult?.dataLabels === void 0 ? {} : { dataLabels: dLblsResult.dataLabels },
1166
- ...dLblsResult?.dataLabelsStyle === void 0 ? {} : { dataLabelsStyle: dLblsResult.dataLabelsStyle },
1528
+ ...seriesDataLabels === void 0 ? {} : { dataLabels: seriesDataLabels },
1167
1529
  ...Object.keys(normalizedPoints).length === 0 ? {} : { points: normalizedPoints },
1168
- ...trendlines === void 0 ? {} : { trendlines },
1530
+ ...trendlines === void 0 || pointCount === 0 ? {} : { trendlines },
1169
1531
  ...errorBars === void 0 ? {} : { errorBars },
1170
- ...datalabelsRange === void 0 ? {} : { datalabelsRange }
1532
+ ...ringCategories === void 0 || ringCategories.length === 0 ? {} : { datalabelsRange: ringCategories }
1171
1533
  };
1172
1534
  }
1173
- function readScatterSeries(serCursor, groupLine, groupMarkers, fallbackIndex, inheritedChartStyle) {
1535
+ function readScatterSeries(serCursor, groupLine, groupMarkers, fallbackIndex, inheritedChartStyle, groupLabels, ctx) {
1174
1536
  const idx = readIntVal(serCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "idx")) ?? fallbackIndex;
1175
1537
  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");
1538
+ const nativeName = readSeriesName(serCursor.child(C_NS, "tx"));
1539
+ const name = nativeName?.trim() ? nativeName : `Series ${fallbackIndex + 1}`;
1540
+ const spPr = readChartSpPr(serCursor, ctx);
1178
1541
  const spStyle = spPr === void 0 ? {} : readSeriesSpPr(spPr, !(groupLine !== void 0 && groupLine !== false));
1179
1542
  const markerCursor = serCursor.child(C_NS, "marker");
1180
- const rawMarker = markerCursor === void 0 ? void 0 : readMarkerElement(markerCursor);
1543
+ const rawMarker = markerCursor === void 0 ? void 0 : readMarkerElement(markerCursor, ctx);
1181
1544
  const marker = !groupMarkers && rawMarker !== void 0 && rawMarker !== false ? void 0 : rawMarker;
1182
1545
  const pointsRecord = {};
1183
1546
  for (const dPt of serCursor.children(C_NS, "dPt")) {
1184
1547
  const pointIdx = readIntVal(dPt.child(C_NS, "idx"));
1185
1548
  const pMarkerCursor = dPt.child(C_NS, "marker");
1186
- const rawPMarker = pMarkerCursor === void 0 ? void 0 : readMarkerElement(pMarkerCursor);
1549
+ const rawPMarker = pMarkerCursor === void 0 ? void 0 : readMarkerElement(pMarkerCursor, ctx);
1187
1550
  const pMarker = !groupMarkers && rawPMarker !== void 0 && rawPMarker !== false ? void 0 : rawPMarker;
1188
- const pSpPr = dPt.child(C_NS, "spPr");
1551
+ const pSpPr = readChartSpPr(dPt, ctx);
1189
1552
  const pStyle = pSpPr === void 0 ? {} : readSeriesSpPr(pSpPr, false);
1190
1553
  consumeSubtree(dPt);
1191
1554
  if (pointIdx !== void 0 && pointIdx >= 0) {
@@ -1197,21 +1560,7 @@ function readScatterSeries(serCursor, groupLine, groupMarkers, fallbackIndex, in
1197
1560
  }
1198
1561
  }
1199
1562
  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
- }
1563
+ const dLblsResult = dLblsCursor === void 0 ? void 0 : readDataLabelsElement(dLblsCursor, "scatter", false, inheritedChartStyle, ctx, groupLabels);
1215
1564
  const xCursor = serCursor.child(C_NS, "xVal");
1216
1565
  const yCursor = serCursor.child(C_NS, "yVal");
1217
1566
  let x = xCursor === void 0 ? [] : readNumericDataSource(xCursor);
@@ -1228,29 +1577,35 @@ function readScatterSeries(serCursor, groupLine, groupMarkers, fallbackIndex, in
1228
1577
  y: yv
1229
1578
  }];
1230
1579
  });
1231
- const trendlines = readSeriesTrendlines(serCursor, "scatter", void 0, x.length, fitPoints);
1232
- const errorBars = readScatterErrorBars(serCursor, x.length);
1580
+ const trendlines = readSeriesTrendlines(serCursor, "scatter", void 0, x.length, fitPoints, ctx);
1581
+ const errorBars = readScatterErrorBars(serCursor, x.length, ctx);
1233
1582
  const smoothCursor = serCursor.child(C_NS, "smooth");
1234
1583
  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
- }
1584
+ const datalabelsRange = readSeriesDataLabelRange(serCursor);
1585
+ for (const [index, dataLabels] of readEffectivePointLabels("scatter", groupLabels, dLblsResult, x.length, inheritedChartStyle, serCursor.xpath, (index) => ({
1586
+ seriesName: name,
1587
+ xValue: x[index],
1588
+ value: y[index],
1589
+ cellRange: datalabelsRange?.values[index]
1590
+ }), ctx)) pointsRecord[index] = {
1591
+ ...pointsRecord[index],
1592
+ dataLabels
1593
+ };
1239
1594
  const normalizedPoints = {};
1240
1595
  for (const [key, pt] of Object.entries(pointsRecord)) {
1241
1596
  const numKey = Number(key);
1242
- if (numKey >= 0 && numKey < x.length) normalizedPoints[numKey] = pt;
1597
+ if (numKey >= 0 && Number.isSafeInteger(numKey)) normalizedPoints[numKey] = pt;
1243
1598
  }
1599
+ const seriesDataLabels = dLblsResult?.dataLabels;
1244
1600
  return {
1245
1601
  order,
1246
- ...dLblsResult?.dataLabelsStyle === void 0 ? {} : { dataLabelsStyle: dLblsResult.dataLabelsStyle },
1247
1602
  series: {
1248
- name: name.trim() === "" ? `Series ${fallbackIndex + 1}` : name,
1603
+ name,
1249
1604
  x,
1250
1605
  y,
1251
1606
  ...spStyle.color === void 0 ? {} : { color: spStyle.color },
1252
1607
  ...spStyle.line === void 0 ? {} : { line: spStyle.line },
1253
- ...dLblsResult?.dataLabels === void 0 ? {} : { dataLabels: dLblsResult.dataLabels },
1608
+ ...seriesDataLabels === void 0 ? {} : { dataLabels: seriesDataLabels },
1254
1609
  ...marker === void 0 ? {} : { marker },
1255
1610
  ...Object.keys(normalizedPoints).length === 0 ? {} : { points: normalizedPoints },
1256
1611
  ...trendlines === void 0 ? {} : { trendlines },
@@ -1258,14 +1613,14 @@ function readScatterSeries(serCursor, groupLine, groupMarkers, fallbackIndex, in
1258
1613
  }
1259
1614
  };
1260
1615
  }
1261
- function readAxisGridline(el) {
1616
+ function readAxisGridline(el, ctx) {
1262
1617
  if (el === void 0) return void 0;
1263
- const spPr = el.child(C_NS, "spPr");
1618
+ const spPr = readChartSpPr(el, ctx);
1264
1619
  const result = spPr === void 0 ? true : readLineFromSpPr(spPr).line ?? true;
1265
1620
  consumeSubtree(el);
1266
1621
  return result;
1267
1622
  }
1268
- function readAxisElement(axisCursor, kind, inheritedChartStyle) {
1623
+ function readAxisElement(axisCursor, kind, inheritedChartStyle, ctx) {
1269
1624
  const id = readIntVal(axisCursor.child(C_NS, "axId"));
1270
1625
  if (id === void 0) return void 0;
1271
1626
  let reversed;
@@ -1289,16 +1644,13 @@ function readAxisElement(axisCursor, kind, inheritedChartStyle) {
1289
1644
  const val = axPos.attrsObject(["val"])["val"];
1290
1645
  if (val !== void 0) position = chartAxisPositionFromNative[val];
1291
1646
  }
1292
- const gridlines = readAxisGridline(axisCursor.child(C_NS, "majorGridlines"));
1293
- const minorGridlines = readAxisGridline(axisCursor.child(C_NS, "minorGridlines"));
1647
+ const gridlines = readAxisGridline(axisCursor.child(C_NS, "majorGridlines"), ctx);
1648
+ const minorGridlines = readAxisGridline(axisCursor.child(C_NS, "minorGridlines"), ctx);
1294
1649
  const txPr = axisCursor.child(C_NS, "txPr");
1295
- const rawAxisStyle = txPr === void 0 ? void 0 : readChartTextProperties(txPr);
1296
- const style = diffChartTextStyle(rawAxisStyle, inheritedChartStyle);
1650
+ const rawAxisStyle = txPr === void 0 ? void 0 : readChartTextProperties(txPr, ctx);
1651
+ const style = diffNativeChartStyle(rawAxisStyle, inheritedChartStyle);
1297
1652
  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
- });
1653
+ const title = titleCursor === void 0 ? void 0 : readChartTitle(titleCursor, cascadeChartStyle(inheritedChartStyle, rawAxisStyle), ctx);
1302
1654
  const numFmtCursor = axisCursor.child(C_NS, "numFmt");
1303
1655
  let numberFormat;
1304
1656
  if (numFmtCursor !== void 0) {
@@ -1314,7 +1666,7 @@ function readAxisElement(axisCursor, kind, inheritedChartStyle) {
1314
1666
  const tickLblParsed = TickLblPosSchema.safeParse(axisCursor.child("http://schemas.openxmlformats.org/drawingml/2006/chart", "tickLblPos")?.attrsObject(["val"]) ?? {});
1315
1667
  const tickLabelPosition = tickLblParsed.success ? tickLblParsed.data.val : void 0;
1316
1668
  let line;
1317
- const spPr = axisCursor.child(C_NS, "spPr");
1669
+ const spPr = readChartSpPr(axisCursor, ctx);
1318
1670
  if (spPr !== void 0) {
1319
1671
  const lineRes = readLineFromSpPr(spPr);
1320
1672
  if (lineRes.noLine) line = false;
@@ -1376,7 +1728,25 @@ function readAxisElement(axisCursor, kind, inheritedChartStyle) {
1376
1728
  ...rawCrossing === void 0 ? {} : { rawCrossing }
1377
1729
  };
1378
1730
  }
1379
- function readChartGroupElement(groupCursor, inheritedChartStyle) {
1731
+ function reportInvalidGroupPointLabelIndexes(labels, pointCount, location, diagnostics) {
1732
+ for (const label of labels?.children("http://schemas.openxmlformats.org/drawingml/2006/chart", "dLbl") ?? []) {
1733
+ const idx = label.child(C_NS, "idx");
1734
+ const value = readIntVal(idx);
1735
+ if (idx === void 0 || value !== void 0 && value >= 0 && value < pointCount) continue;
1736
+ diagnostics.push({
1737
+ code: "invalid-xml-value",
1738
+ category: "corrupt-input",
1739
+ disposition: "recovered",
1740
+ location: {
1741
+ ...location,
1742
+ xpath: `${idx.xpath}/@val`
1743
+ },
1744
+ attributeOrElement: "c:idx/@val",
1745
+ rawValue: idx.attr("val")
1746
+ });
1747
+ }
1748
+ }
1749
+ function readChartGroupElement(groupCursor, inheritedChartStyle, ctx) {
1380
1750
  const local = groupCursor.localName;
1381
1751
  const varyColors = groupCursor.child(C_NS, "varyColors");
1382
1752
  if (varyColors !== void 0) consumeSubtree(varyColors);
@@ -1402,19 +1772,21 @@ function readChartGroupElement(groupCursor, inheritedChartStyle) {
1402
1772
  line = "smooth";
1403
1773
  markers = true;
1404
1774
  }
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
1775
  const dLblsCursor = groupCursor.child(C_NS, "dLbls");
1409
- const groupLabels = (dLblsCursor === void 0 ? void 0 : readDataLabelsElement(dLblsCursor, "scatter", true, inheritedChartStyle))?.dataLabels;
1776
+ const groupLabelsResult = dLblsCursor === void 0 ? void 0 : readDataLabelsElement(dLblsCursor, "scatter", true, inheritedChartStyle, ctx);
1777
+ const groupLabels = groupLabelsResult?.dataLabels;
1778
+ const seriesBaseStyle = cascadeChartStyle(inheritedChartStyle, groupLabelsResult?.style);
1779
+ const rawSeries = groupCursor.children(C_NS, "ser").map((ser, idx) => readScatterSeries(ser, line, markers, idx, seriesBaseStyle, groupLabelsResult, ctx)).toSorted((a, b) => a.order - b.order).map((entry) => entry.series);
1780
+ reportInvalidGroupPointLabelIndexes(dLblsCursor, rawSeries.reduce((max, series) => Math.max(max, series.x.length), 0), ctx.location, ctx.diagnostics);
1781
+ const axisIds = groupCursor.children(C_NS, "axId").map((c) => readIntVal(c));
1410
1782
  return {
1411
1783
  kind: "scatter",
1412
- axisIds: groupCursor.children(C_NS, "axId").map((c) => readIntVal(c)).filter((v) => v !== void 0),
1784
+ xpath: groupCursor.xpath,
1785
+ axisIds,
1413
1786
  series: rawSeries,
1414
1787
  markers,
1415
1788
  ...line === void 0 ? {} : { line },
1416
- ...groupLabels === void 0 ? {} : { dataLabels: groupLabels },
1417
- ...seriesDataLabelsStyle === void 0 ? {} : { seriesDataLabelsStyle }
1789
+ ...groupLabels === void 0 ? {} : { dataLabels: groupLabels }
1418
1790
  };
1419
1791
  }
1420
1792
  let kind;
@@ -1436,10 +1808,16 @@ function readChartGroupElement(groupCursor, inheritedChartStyle) {
1436
1808
  else if (parsedGrouping.data.val === "percentStacked") stacking = "percent";
1437
1809
  }
1438
1810
  }
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;
1811
+ const seriesSources = groupCursor.children(C_NS, "ser").map((ser) => ({
1812
+ ser,
1813
+ source: readSeriesCategoryData(ser)
1814
+ }));
1441
1815
  const dLblsCursor = groupCursor.child(C_NS, "dLbls");
1442
- const groupLabels = (dLblsCursor === void 0 ? void 0 : readDataLabelsElement(dLblsCursor, kind, true, inheritedChartStyle))?.dataLabels;
1816
+ const groupLabelsResult = dLblsCursor === void 0 ? void 0 : readDataLabelsElement(dLblsCursor, kind, true, inheritedChartStyle, ctx, void 0, seriesSources.every(({ source }) => source.categoryRange));
1817
+ const groupLabels = groupLabelsResult?.dataLabels;
1818
+ const seriesBaseStyle = cascadeChartStyle(inheritedChartStyle, groupLabelsResult?.style);
1819
+ const rawSeries = seriesSources.map(({ ser, source }, idx) => readCategorySeries(ser, kind, idx, source, stacking, seriesBaseStyle, groupLabelsResult, ctx)).toSorted((a, b) => a.order - b.order);
1820
+ reportInvalidGroupPointLabelIndexes(dLblsCursor, rawSeries.reduce((max, series) => Math.max(max, series.categories.length, series.values.length), 0), ctx.location, ctx.diagnostics);
1443
1821
  let gapWidth;
1444
1822
  let overlap;
1445
1823
  if (kind === "column" || kind === "bar") {
@@ -1464,13 +1842,13 @@ function readChartGroupElement(groupCursor, inheritedChartStyle) {
1464
1842
  if (hs !== void 0 && hs >= 10 && hs <= 90) holeSize = hs;
1465
1843
  }
1466
1844
  }
1467
- const axisIds = groupCursor.children(C_NS, "axId").map((c) => readIntVal(c)).filter((v) => v !== void 0);
1845
+ const axisIds = groupCursor.children(C_NS, "axId").map((c) => readIntVal(c));
1468
1846
  return {
1469
1847
  kind,
1848
+ xpath: groupCursor.xpath,
1470
1849
  axisIds,
1471
1850
  series: rawSeries,
1472
1851
  ...groupLabels === void 0 ? {} : { dataLabels: groupLabels },
1473
- ...seriesDataLabelsStyle === void 0 ? {} : { seriesDataLabelsStyle },
1474
1852
  ...stacking === void 0 ? {} : { stacking },
1475
1853
  ...gapWidth === void 0 ? {} : { gapWidth },
1476
1854
  ...overlap === void 0 ? {} : { overlap },
@@ -1519,28 +1897,142 @@ function importedKnownValueEndpoint(crossing, partner) {
1519
1897
  if (partner.min === 0) return "min";
1520
1898
  if (partner.max === 0) return "max";
1521
1899
  }
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;
1900
+ function trimSeriesPointsToLength(points, pointCount, chartLocation, diagnostics) {
1901
+ if (points === void 0) return void 0;
1902
+ const trimmed = {};
1903
+ for (const [rawKey, value] of Object.entries(points)) {
1904
+ const idx = Number(rawKey);
1905
+ if (!Number.isSafeInteger(idx) || idx < 0 || idx >= pointCount) {
1906
+ diagnostics.push({
1907
+ code: "invalid-xml-value",
1908
+ category: "corrupt-input",
1909
+ disposition: "recovered",
1910
+ location: chartLocation,
1911
+ attributeOrElement: "c:dPt/@idx",
1912
+ rawValue: rawKey
1913
+ });
1914
+ continue;
1915
+ }
1916
+ trimmed[idx] = value;
1917
+ }
1918
+ return Object.keys(trimmed).length === 0 ? void 0 : trimmed;
1919
+ }
1920
+ /** Resolves leader-line visibility once the final point indexes are known. */
1921
+ function normalizeCircularLeaderLines(kind, series, groupLabels) {
1922
+ if ((!groupLabels || groupLabels.leaderLines === void 0) && !series.some(({ dataLabels }) => dataLabels && dataLabels.leaderLines !== void 0)) return {
1923
+ series,
1924
+ dataLabels: groupLabels
1925
+ };
1926
+ const withVisibility = series.map((item) => {
1927
+ const labels = mergeDataLabels(groupLabels, item.dataLabels);
1928
+ return {
1929
+ item,
1930
+ visible: hasVisibleSeriesDataLabels(kind, labels, item.points)
1931
+ };
1932
+ });
1933
+ const dataLabels = withVisibility.some(({ visible }) => visible) ? groupLabels : omitLeaderLines(groupLabels);
1934
+ const enabledGroupLines = dataLabels && dataLabels.leaderLines;
1935
+ return {
1936
+ dataLabels,
1937
+ series: withVisibility.map(({ item, visible }) => {
1938
+ const labels = item.dataLabels;
1939
+ if (visible || labels === false) return item;
1940
+ const normalized = enabledGroupLines ? {
1941
+ ...labels,
1942
+ leaderLines: false
1943
+ } : omitLeaderLines(labels);
1944
+ if (normalized === labels) return item;
1945
+ const { dataLabels: _labels, ...rest } = item;
1946
+ return normalized === void 0 ? rest : {
1947
+ ...rest,
1948
+ dataLabels: normalized
1949
+ };
1950
+ })
1951
+ };
1952
+ }
1953
+ function omitLeaderLines(labels) {
1954
+ if (!labels || labels.leaderLines === void 0) return labels;
1955
+ const { leaderLines: _leaderLines, ...remaining } = labels;
1956
+ return Object.keys(remaining).length === 0 ? void 0 : remaining;
1957
+ }
1958
+ function alignCustomErrorBars(errorBars, pointCount) {
1959
+ if (errorBars === void 0 || errorBars.type !== "custom") return errorBars;
1960
+ const plus = errorBars.plus === void 0 ? void 0 : alignErrorBarValues(errorBars.plus, pointCount);
1961
+ const minus = errorBars.minus === void 0 ? void 0 : alignErrorBarValues(errorBars.minus, pointCount);
1962
+ if (errorBars.include === "plus" && plus !== void 0) return {
1963
+ ...errorBars,
1964
+ plus
1965
+ };
1966
+ if (errorBars.include === "minus" && minus !== void 0) return {
1967
+ ...errorBars,
1968
+ minus
1969
+ };
1970
+ if (errorBars.include === "both" && plus !== void 0 && minus !== void 0) return {
1971
+ ...errorBars,
1972
+ plus,
1973
+ minus
1974
+ };
1975
+ }
1976
+ function filterValidTrendlines(trendlines, pointCount) {
1977
+ if (trendlines === void 0) return void 0;
1978
+ const kept = trendlines.filter((item) => item.type !== "movingAverage" || item.period < pointCount);
1979
+ return kept.length === 0 ? void 0 : kept;
1529
1980
  }
1530
- function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1981
+ function buildChartAxesAndGroups(groupDrafts, importedAxes, unsupportedAxisIds, chartLocation, diagnostics) {
1531
1982
  const axisById = new Map(importedAxes.map((ax) => [ax.id, ax]));
1532
1983
  const axisDirectionById = /* @__PURE__ */ new Map();
1984
+ const referencedAxisIds = /* @__PURE__ */ new Set();
1985
+ const validGroupDrafts = [];
1533
1986
  for (const group of groupDrafts) {
1534
- if (group.kind === "pie" || group.kind === "doughnut") continue;
1987
+ const needsAxes = group.kind !== "pie" && group.kind !== "doughnut";
1535
1988
  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");
1989
+ const firstAxis = firstId === void 0 ? void 0 : axisById.get(firstId);
1990
+ const secondAxis = secondId === void 0 ? void 0 : axisById.get(secondId);
1991
+ const firstUnsupported = firstAxis === void 0 && firstId !== void 0 && unsupportedAxisIds.has(firstId);
1992
+ const secondUnsupported = secondAxis === void 0 && secondId !== void 0 && unsupportedAxisIds.has(secondId);
1993
+ const firstKind = group.kind === "scatter" ? "value" : "category";
1994
+ const firstDir = group.kind === "bar" ? "vertical" : "horizontal";
1995
+ const secondDir = group.kind === "bar" ? "horizontal" : "vertical";
1996
+ const brokenAxes = group.axisIds.length !== 2 || firstId === secondId || (firstAxis === void 0 ? !firstUnsupported : firstAxis.kind !== firstKind) || (secondAxis === void 0 ? !secondUnsupported : secondAxis.kind !== "value");
1997
+ if (group.series.length === 0 || needsAxes && brokenAxes) {
1998
+ diagnostics.push({
1999
+ code: "corrupt-part",
2000
+ category: "corrupt-input",
2001
+ disposition: "omitted",
2002
+ location: {
2003
+ ...chartLocation,
2004
+ xpath: group.xpath
2005
+ }
2006
+ });
2007
+ continue;
1542
2008
  }
2009
+ if (!needsAxes) {
2010
+ validGroupDrafts.push(group);
2011
+ continue;
2012
+ }
2013
+ if (firstAxis === void 0 || secondAxis === void 0) continue;
2014
+ const firstExistingDir = axisDirectionById.get(firstAxis.id);
2015
+ const secondExistingDir = axisDirectionById.get(secondAxis.id);
2016
+ const nextAxisCount = referencedAxisIds.size + Number(!referencedAxisIds.has(firstAxis.id)) + Number(!referencedAxisIds.has(secondAxis.id));
2017
+ if (firstExistingDir !== void 0 && firstExistingDir !== firstDir || secondExistingDir !== void 0 && secondExistingDir !== secondDir || nextAxisCount > 4) {
2018
+ diagnostics.push({
2019
+ code: "corrupt-part",
2020
+ category: "corrupt-input",
2021
+ disposition: "omitted",
2022
+ location: {
2023
+ ...chartLocation,
2024
+ xpath: group.xpath
2025
+ }
2026
+ });
2027
+ continue;
2028
+ }
2029
+ axisDirectionById.set(firstAxis.id, firstDir);
2030
+ axisDirectionById.set(secondAxis.id, secondDir);
2031
+ referencedAxisIds.add(firstAxis.id);
2032
+ referencedAxisIds.add(secondAxis.id);
2033
+ validGroupDrafts.push(group);
1543
2034
  }
2035
+ if (validGroupDrafts.length === 0) return { groups: [] };
1544
2036
  const incomingByTarget = /* @__PURE__ */ new Map();
1545
2037
  for (const ax of importedAxes) {
1546
2038
  if (ax.crossAxisId === void 0) continue;
@@ -1601,7 +2093,7 @@ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1601
2093
  axisNameById.set(id, candidate);
1602
2094
  return candidate;
1603
2095
  };
1604
- for (const group of groupDrafts) {
2096
+ for (const group of validGroupDrafts) {
1605
2097
  if (group.kind === "pie" || group.kind === "doughnut") continue;
1606
2098
  if (group.kind === "scatter") {
1607
2099
  const [xId, yId] = group.axisIds;
@@ -1650,37 +2142,61 @@ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1650
2142
  };
1651
2143
  }
1652
2144
  const sharedDomainByCatAxis = /* @__PURE__ */ new Map();
1653
- for (const group of groupDrafts) {
2145
+ for (const group of validGroupDrafts) {
1654
2146
  if (group.kind === "scatter" || group.kind === "pie" || group.kind === "doughnut") continue;
1655
2147
  const catId = group.axisIds[0];
1656
2148
  if (catId === void 0 || sharedDomainByCatAxis.has(catId)) continue;
1657
2149
  const nonEmpty = group.series.find((s) => s.categories.length > 0);
1658
2150
  if (nonEmpty !== void 0) sharedDomainByCatAxis.set(catId, nonEmpty.categories);
1659
2151
  }
1660
- const groups = groupDrafts.map((group) => {
1661
- const liftedDataLabels = withLiftedDataLabelsStyle(group.dataLabels, group.seriesDataLabelsStyle);
2152
+ const groups = validGroupDrafts.map((group) => {
1662
2153
  if (group.kind === "scatter") {
1663
2154
  const [xId, yId] = group.axisIds;
1664
2155
  const xName = xId === void 0 ? void 0 : axisNameById.get(xId);
1665
2156
  const yName = yId === void 0 ? void 0 : axisNameById.get(yId);
2157
+ const scatterMarkers = group.line !== void 0 && group.line !== false ? group.markers : true;
1666
2158
  return {
1667
2159
  kind: "scatter",
1668
2160
  data: { kind: "xy" },
1669
- series: group.series,
2161
+ series: group.series.map((item) => {
2162
+ const trimmedPoints = trimSeriesPointsToLength(item.points, item.x.length, chartLocation, diagnostics);
2163
+ const trimmedTrendlines = filterValidTrendlines(item.trendlines, item.x.length);
2164
+ const xErr = alignCustomErrorBars(item.errorBars?.x, item.x.length);
2165
+ const yErr = alignCustomErrorBars(item.errorBars?.y, item.y.length);
2166
+ const errorBars = xErr !== void 0 || yErr !== void 0 ? {
2167
+ ...xErr === void 0 ? {} : { x: xErr },
2168
+ ...yErr === void 0 ? {} : { y: yErr }
2169
+ } : void 0;
2170
+ return {
2171
+ ...item,
2172
+ ...trimmedPoints === void 0 ? { points: void 0 } : { points: trimmedPoints },
2173
+ ...trimmedTrendlines === void 0 ? { trendlines: void 0 } : { trendlines: trimmedTrendlines },
2174
+ ...errorBars === void 0 ? { errorBars: void 0 } : { errorBars }
2175
+ };
2176
+ }).map((item) => {
2177
+ const { points: pt, trendlines: tl, errorBars: eb, ...rest } = item;
2178
+ return {
2179
+ ...rest,
2180
+ ...pt === void 0 ? {} : { points: pt },
2181
+ ...tl === void 0 ? {} : { trendlines: tl },
2182
+ ...eb === void 0 ? {} : { errorBars: eb }
2183
+ };
2184
+ }),
1670
2185
  ...xName !== void 0 && yName !== void 0 && xName !== yName ? { axes: {
1671
2186
  x: xName,
1672
2187
  y: yName
1673
2188
  } } : {},
1674
2189
  ...group.line === void 0 ? {} : { line: group.line },
1675
- markers: group.markers,
1676
- ...liftedDataLabels === void 0 ? {} : { dataLabels: liftedDataLabels }
2190
+ markers: scatterMarkers,
2191
+ ...group.dataLabels === void 0 ? {} : { dataLabels: group.dataLabels }
1677
2192
  };
1678
2193
  }
1679
2194
  if (group.kind === "doughnut") {
1680
2195
  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
2196
  const series = group.series.map((item) => {
1682
2197
  const cats = item.datalabelsRange ?? item.categories;
1683
- const values = item.values.length === cats.length ? item.values : cats.map((_, idx) => item.values[idx] ?? null);
2198
+ const values = (item.values.length === cats.length ? item.values : cats.map((_, idx) => item.values[idx] ?? null)).map((v) => v !== null && v < 0 ? null : v);
2199
+ const trimmedPoints = trimSeriesPointsToLength(item.points, cats.length, chartLocation, diagnostics);
1684
2200
  return {
1685
2201
  name: item.name,
1686
2202
  categories: cats,
@@ -1689,16 +2205,15 @@ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1689
2205
  ...item.line === void 0 ? {} : { line: item.line },
1690
2206
  ...item.explosion === void 0 ? {} : { explosion: item.explosion },
1691
2207
  ...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 }
2208
+ ...trimmedPoints === void 0 ? {} : { points: trimmedPoints }
1695
2209
  };
1696
2210
  });
1697
- const indDoughnutLabels = narrowGroupDataLabels(liftedDataLabels, []);
2211
+ const normalized = normalizeCircularLeaderLines(group.kind, series, group.dataLabels);
2212
+ const indDoughnutLabels = narrowGroupDataLabels(normalized.dataLabels, []);
1698
2213
  return {
1699
2214
  kind: "doughnut",
1700
2215
  data: { kind: "independent-categories" },
1701
- series,
2216
+ series: normalized.series,
1702
2217
  ...group.firstSliceAngle === void 0 ? {} : { firstSliceAngle: group.firstSliceAngle },
1703
2218
  ...group.holeSize === void 0 ? {} : { holeSize: group.holeSize },
1704
2219
  ...indDoughnutLabels === void 0 ? {} : { dataLabels: indDoughnutLabels }
@@ -1710,6 +2225,9 @@ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1710
2225
  const normalizedSeries = (group.kind === "pie" ? group.series.slice(0, 1) : group.series).map((item) => {
1711
2226
  const values = domain.length === 0 ? [] : item.values.length === domain.length ? item.values : domain.map((_, idx) => item.values[idx] ?? null);
1712
2227
  const safeValues = group.kind === "pie" || group.kind === "doughnut" ? values.map((v) => v !== null && v < 0 ? null : v) : values;
2228
+ const trimmedPoints = trimSeriesPointsToLength(item.points, domain.length, chartLocation, diagnostics);
2229
+ const trimmedTrendlines = filterValidTrendlines(item.trendlines, domain.length);
2230
+ const alignedErrorBars = alignCustomErrorBars(item.errorBars, domain.length);
1713
2231
  return {
1714
2232
  name: item.name,
1715
2233
  values: safeValues,
@@ -1719,13 +2237,14 @@ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1719
2237
  ...item.dataLabels === void 0 ? {} : { dataLabels: item.dataLabels },
1720
2238
  ...item.marker === void 0 ? {} : { marker: item.marker },
1721
2239
  ...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 }
2240
+ ...trimmedPoints === void 0 ? {} : { points: trimmedPoints },
2241
+ ...trimmedTrendlines === void 0 ? {} : { trendlines: trimmedTrendlines },
2242
+ ...alignedErrorBars === void 0 ? {} : { errorBars: alignedErrorBars }
1725
2243
  };
1726
2244
  });
1727
2245
  if (group.kind === "pie") {
1728
- const pieLabels = narrowGroupDataLabels(liftedDataLabels, [
2246
+ const normalized = normalizeCircularLeaderLines(group.kind, normalizedSeries, group.dataLabels);
2247
+ const pieLabels = narrowGroupDataLabels(normalized.dataLabels, [
1729
2248
  "center",
1730
2249
  "insideEnd",
1731
2250
  "outsideEnd",
@@ -1737,20 +2256,21 @@ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1737
2256
  kind: "shared-categories",
1738
2257
  categories: domain
1739
2258
  },
1740
- series: normalizedSeries,
2259
+ series: normalized.series,
1741
2260
  ...group.firstSliceAngle === void 0 ? {} : { firstSliceAngle: group.firstSliceAngle },
1742
2261
  ...pieLabels === void 0 ? {} : { dataLabels: pieLabels }
1743
2262
  };
1744
2263
  }
1745
2264
  if (group.kind === "doughnut") {
1746
- const doughnutLabels = narrowGroupDataLabels(liftedDataLabels, []);
2265
+ const normalized = normalizeCircularLeaderLines(group.kind, normalizedSeries, group.dataLabels);
2266
+ const doughnutLabels = narrowGroupDataLabels(normalized.dataLabels, []);
1747
2267
  return {
1748
2268
  kind: "doughnut",
1749
2269
  data: {
1750
2270
  kind: "shared-categories",
1751
2271
  categories: domain
1752
2272
  },
1753
- series: normalizedSeries,
2273
+ series: normalized.series,
1754
2274
  ...group.firstSliceAngle === void 0 ? {} : { firstSliceAngle: group.firstSliceAngle },
1755
2275
  ...group.holeSize === void 0 ? {} : { holeSize: group.holeSize },
1756
2276
  ...doughnutLabels === void 0 ? {} : { dataLabels: doughnutLabels }
@@ -1776,7 +2296,7 @@ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1776
2296
  ...group.overlap === void 0 ? {} : { overlap: group.overlap }
1777
2297
  };
1778
2298
  if (group.stacking !== void 0) {
1779
- const stackedLabels = narrowGroupDataLabels(liftedDataLabels, [
2299
+ const stackedLabels = narrowGroupDataLabels(group.dataLabels, [
1780
2300
  "center",
1781
2301
  "insideEnd",
1782
2302
  "insideBase"
@@ -1787,7 +2307,7 @@ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1787
2307
  ...stackedLabels === void 0 ? {} : { dataLabels: stackedLabels }
1788
2308
  };
1789
2309
  }
1790
- const unstackedLabels = narrowGroupDataLabels(liftedDataLabels, [
2310
+ const unstackedLabels = narrowGroupDataLabels(group.dataLabels, [
1791
2311
  "center",
1792
2312
  "insideEnd",
1793
2313
  "insideBase",
@@ -1799,7 +2319,7 @@ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1799
2319
  };
1800
2320
  }
1801
2321
  if (group.kind === "line") {
1802
- const lineLabels = narrowGroupDataLabels(liftedDataLabels, [
2322
+ const lineLabels = narrowGroupDataLabels(group.dataLabels, [
1803
2323
  "left",
1804
2324
  "right",
1805
2325
  "bottom",
@@ -1818,7 +2338,7 @@ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1818
2338
  ...lineLabels === void 0 ? {} : { dataLabels: lineLabels }
1819
2339
  };
1820
2340
  }
1821
- const areaLabels = narrowGroupDataLabels(liftedDataLabels, []);
2341
+ const areaLabels = narrowGroupDataLabels(group.dataLabels, []);
1822
2342
  return {
1823
2343
  kind: "area",
1824
2344
  data: {
@@ -1836,6 +2356,18 @@ function buildChartAxesAndGroups(groupDrafts, importedAxes) {
1836
2356
  groups
1837
2357
  };
1838
2358
  }
2359
+ const unsupportedChartGroups = /* @__PURE__ */ new Set([
2360
+ "area3DChart",
2361
+ "bar3DChart",
2362
+ "bubbleChart",
2363
+ "line3DChart",
2364
+ "ofPieChart",
2365
+ "pie3DChart",
2366
+ "radarChart",
2367
+ "stockChart",
2368
+ "surfaceChart",
2369
+ "surface3DChart"
2370
+ ]);
1839
2371
  function consumeChartAlternateContent(ac) {
1840
2372
  const choice = ac.child(MC_NS, "Choice");
1841
2373
  const fallback = ac.child(MC_NS, "Fallback");
@@ -1854,7 +2386,7 @@ function consumeChartAlternateContent(ac) {
1854
2386
  * Reads a Transitional `<p:graphicFrame>` chart and its `ppt/charts/chart{n}.xml` part into an editable `ChartNode`.
1855
2387
  */
1856
2388
  function readChartGraphicFrame(context) {
1857
- const { cursor, part, slideIndex, package: pkg, layoutPlaceholders } = context;
2389
+ const { cursor, part, slideIndex, package: pkg } = context;
1858
2390
  const diagnostics = [];
1859
2391
  const nvGraphicFramePr = cursor.child(P_NS, "nvGraphicFramePr");
1860
2392
  if (nvGraphicFramePr === void 0) {
@@ -1918,56 +2450,16 @@ function readChartGraphicFrame(context) {
1918
2450
  const phResult = readNvPrPlaceholder(nvPr, chartLocation, diagnostics);
1919
2451
  if (phResult.kind === "error") return { diagnostics };
1920
2452
  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
2453
+ const claim = nativeRef === void 0 ? void 0 : resolvePlaceholderImportClaim({
2454
+ context,
2455
+ nativeRef,
2456
+ objectKind: "chart"
1924
2457
  });
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);
2458
+ const matchedKey = claim?.bound === true ? claim.key : void 0;
2459
+ const unboundPlaceholder = claim !== void 0 && !claim.bound;
2460
+ const frameBox = readPlaceholderFrameBox(cursor.child(P_NS, "xfrm"), claim, chartLocation, diagnostics);
2461
+ if (frameBox === void 0) return { diagnostics };
2462
+ const { x: boxX, y: boxY, width: boxWidth, height: boxHeight } = context.mapBox?.(frameBox) ?? frameBox;
1971
2463
  const graphicData = cursor.child(A_NS, "graphic")?.child(A_NS, "graphicData");
1972
2464
  if (graphicData !== void 0) GraphicDataAttrSchema.safeParse(graphicData.attrsObject(["uri"]));
1973
2465
  const cChart = graphicData?.child(C_NS, "chart");
@@ -2048,20 +2540,52 @@ function readChartGraphicFrame(context) {
2048
2540
  "date1904",
2049
2541
  "lang",
2050
2542
  "roundedCorners",
2051
- "style",
2052
- "clrMapOvr"
2543
+ "style"
2053
2544
  ]) {
2054
2545
  const el = chartSpace.child(C_NS, tag);
2055
2546
  if (el !== void 0) consumeSubtree(el);
2056
2547
  }
2057
2548
  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);
2549
+ const chartCtx = {
2550
+ reportedLabelFallbacks: /* @__PURE__ */ new Set(),
2551
+ location: {
2552
+ ...chartLocation,
2553
+ part: chartPartPath
2554
+ },
2555
+ diagnostics
2556
+ };
2557
+ const chartRels = pkg.readRelationships(chartPartPath);
2558
+ diagnostics.push(...chartRels.diagnostics);
2559
+ const themeOverride = readPartThemeOverride(pkg, chartRels.entries, chartCtx.location, diagnostics);
2560
+ const colorMapElement = chartSpace.child(C_NS, "clrMapOvr");
2561
+ let colorMapOverride;
2562
+ if (colorMapElement !== void 0) {
2563
+ const slotNames = Array.from(colorMapElement.element.attributes).filter((attribute) => !attribute.namespaceURI).map((attribute) => attribute.localName ?? attribute.name);
2564
+ const attrs = colorMapElement.attrsObject(slotNames);
2565
+ const parsed = colorMapSchema.safeParse(attrs);
2566
+ if (parsed.success) colorMapOverride = parsed.data;
2567
+ else {
2568
+ const badSlots = parsed.error.issues.flatMap((issue) => issue.code === "unrecognized_keys" ? issue.keys : [String(issue.path[0])]);
2569
+ for (const slot of badSlots) diagnostics.push({
2570
+ code: "invalid-xml-value",
2571
+ category: "corrupt-input",
2572
+ disposition: "recovered",
2573
+ location: {
2574
+ ...chartCtx.location,
2575
+ xpath: `${colorMapElement.xpath}/@${slot}`
2576
+ },
2577
+ attributeOrElement: `@${slot}`,
2578
+ rawValue: attrs[slot] ?? ""
2579
+ });
2580
+ }
2064
2581
  }
2582
+ const chartTxPr = chartSpace.child(C_NS, "txPr");
2583
+ const rawChartStyle = chartTxPr === void 0 ? void 0 : readChartTextProperties(chartTxPr, chartCtx);
2584
+ const chartStyle = normalizeRootChartStyle(projectChartStyle(rawChartStyle ?? {}));
2585
+ const chartSpPr = readChartSpPr(chartSpace, chartCtx);
2586
+ if (chartSpPr !== void 0) consumeSubtree(chartSpPr);
2587
+ const externalData = chartSpace.child(C_NS, "externalData");
2588
+ if (externalData !== void 0) consumeSubtree(externalData);
2065
2589
  const chartEl = chartSpace.child(C_NS, "chart");
2066
2590
  if (chartEl === void 0) {
2067
2591
  diagnostics.push({
@@ -2079,12 +2603,13 @@ function readChartGraphicFrame(context) {
2079
2603
  return { diagnostics };
2080
2604
  }
2081
2605
  const titleEl = chartEl.child(C_NS, "title");
2082
- const title = titleEl === void 0 ? void 0 : readChartTitle(titleEl, rawChartStyle);
2606
+ const title = titleEl === void 0 ? void 0 : readChartTitle(titleEl, rawChartStyle, chartCtx);
2083
2607
  const autoTitleDeleted = chartEl.child(C_NS, "autoTitleDeleted");
2084
2608
  if (autoTitleDeleted !== void 0) consumeSubtree(autoTitleDeleted);
2085
2609
  const pivotFmts = chartEl.child(C_NS, "pivotFmts");
2086
2610
  if (pivotFmts !== void 0) consumeSubtree(pivotFmts);
2087
2611
  let legend;
2612
+ let legendStyle;
2088
2613
  const legendEl = chartEl.child(C_NS, "legend");
2089
2614
  if (legendEl !== void 0) {
2090
2615
  const posVal = legendEl.child(C_NS, "legendPos")?.attrsObject(["val"])["val"];
@@ -2093,12 +2618,12 @@ function readChartGraphicFrame(context) {
2093
2618
  const legendLayoutEl = directElementChild(legendEl.element, C_NS, "layout");
2094
2619
  if (legendLayoutEl !== void 0 && isEmptyXmlElement(legendLayoutEl)) legendEl.child(C_NS, "layout");
2095
2620
  const legendTxPr = legendEl.child(C_NS, "txPr");
2096
- if (legendTxPr !== void 0) readChartTextProperties(legendTxPr);
2621
+ if (legendTxPr !== void 0) legendStyle = diffNativeChartStyle(readChartTextProperties(legendTxPr, chartCtx), rawChartStyle);
2097
2622
  for (const legendEntry of legendEl.children(C_NS, "legendEntry")) {
2098
2623
  legendEntry.child(C_NS, "idx")?.attr("val");
2099
2624
  legendEntry.child(C_NS, "delete")?.attr("val");
2100
2625
  }
2101
- const legendSpPr = legendEl.child(C_NS, "spPr");
2626
+ const legendSpPr = readChartSpPr(legendEl, chartCtx);
2102
2627
  if (legendSpPr !== void 0) consumeBenignChartSpPr(legendSpPr);
2103
2628
  }
2104
2629
  const plotVisOnly = chartEl.child(C_NS, "plotVisOnly");
@@ -2157,27 +2682,37 @@ function readChartGraphicFrame(context) {
2157
2682
  }
2158
2683
  consumeSubtree(layoutEl);
2159
2684
  }
2160
- const plotSpPr = plotAreaEl.child(C_NS, "spPr");
2685
+ const plotSpPr = readChartSpPr(plotAreaEl, chartCtx);
2161
2686
  if (plotSpPr !== void 0) consumeBenignChartSpPr(plotSpPr);
2162
2687
  const groupDrafts = [];
2163
2688
  const importedAxes = [];
2689
+ const unsupportedAxisIds = /* @__PURE__ */ new Set();
2690
+ let omittedUnsupportedGroup = false;
2164
2691
  for (const child of plotAreaEl.remainingElementChildren()) {
2165
2692
  if (child.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/chart") continue;
2166
2693
  if (child.localName === "catAx") {
2167
- const ax = readAxisElement(child, "category", rawChartStyle);
2694
+ const ax = readAxisElement(child, "category", rawChartStyle, chartCtx);
2168
2695
  if (ax !== void 0) importedAxes.push(ax);
2169
2696
  continue;
2170
2697
  }
2171
2698
  if (child.localName === "valAx") {
2172
- const ax = readAxisElement(child, "value", rawChartStyle);
2699
+ const ax = readAxisElement(child, "value", rawChartStyle, chartCtx);
2173
2700
  if (ax !== void 0) importedAxes.push(ax);
2174
2701
  continue;
2175
2702
  }
2176
- const group = readChartGroupElement(child, rawChartStyle);
2703
+ const group = readChartGroupElement(child, rawChartStyle, chartCtx);
2177
2704
  if (group !== void 0) {
2178
2705
  groupDrafts.push(group);
2179
2706
  continue;
2180
2707
  }
2708
+ if (child.localName === "dateAx" || child.localName === "serAx") {
2709
+ const id = readIntVal(child.child(C_NS, "axId"));
2710
+ if (id !== void 0) unsupportedAxisIds.add(id);
2711
+ consumeSubtree(child);
2712
+ } else if (unsupportedChartGroups.has(child.localName)) {
2713
+ omittedUnsupportedGroup = true;
2714
+ consumeSubtree(child);
2715
+ }
2181
2716
  diagnostics.push({
2182
2717
  code: "unsupported-mechanism",
2183
2718
  category: "unsupported",
@@ -2208,6 +2743,7 @@ function readChartGraphicFrame(context) {
2208
2743
  localName: unconsumed.localName
2209
2744
  });
2210
2745
  if (groupDrafts.length === 0) {
2746
+ if (omittedUnsupportedGroup) return { diagnostics };
2211
2747
  diagnostics.push({
2212
2748
  code: "corrupt-part",
2213
2749
  category: "corrupt-input",
@@ -2222,7 +2758,14 @@ function readChartGraphicFrame(context) {
2222
2758
  });
2223
2759
  return { diagnostics };
2224
2760
  }
2225
- const { axes, groups } = buildChartAxesAndGroups(groupDrafts, importedAxes);
2761
+ const { axes, groups } = buildChartAxesAndGroups(groupDrafts, importedAxes, unsupportedAxisIds, {
2762
+ part: chartPartPath,
2763
+ xpath: plotAreaEl.xpath,
2764
+ slideIndex,
2765
+ ...objectId === void 0 ? {} : { objectId },
2766
+ ...objectName === void 0 ? {} : { objectName }
2767
+ }, diagnostics);
2768
+ if (groups.length === 0) return { diagnostics };
2226
2769
  if (displayBlanksAs !== void 0) {
2227
2770
  if (!groups.every((group) => {
2228
2771
  if (group.kind === "scatter") return !(displayBlanksAs === "span" && (group.line === void 0 || group.line === false));
@@ -2232,22 +2775,32 @@ function readChartGraphicFrame(context) {
2232
2775
  })) displayBlanksAs = void 0;
2233
2776
  }
2234
2777
  const props = {
2778
+ ...themeOverride === void 0 ? {} : { themeOverride },
2779
+ ...colorMapOverride === void 0 ? {} : { colorMapOverride },
2235
2780
  ...objectName === void 0 ? {} : { name: objectName },
2236
2781
  ...matchedKey === void 0 ? {} : { placeholder: matchedKey },
2237
- ...nativeRef === void 0 ? {} : { nativePlaceholder: nativeRef },
2238
2782
  ...clickResult?.link === void 0 ? {} : { link: clickResult.link },
2239
- x: boxX,
2240
- y: boxY,
2241
- width: boxWidth,
2242
- height: boxHeight,
2243
2783
  ...axes === void 0 ? {} : { axes },
2244
2784
  groups,
2245
2785
  ...title === void 0 ? {} : { title },
2246
- ...chartStyle === void 0 ? {} : { style: chartStyle },
2786
+ style: {
2787
+ position: "absolute",
2788
+ left: boxX,
2789
+ top: boxY,
2790
+ width: boxWidth,
2791
+ height: boxHeight,
2792
+ ...chartStyle
2793
+ },
2247
2794
  ...displayBlanksAs === void 0 ? {} : { displayBlanksAs },
2248
2795
  ...legend === void 0 ? {} : { legend },
2796
+ ...legendStyle === void 0 ? {} : { legendStyle },
2249
2797
  ...plotArea === void 0 ? {} : { plotArea }
2250
2798
  };
2799
+ if (unboundPlaceholder) emitPlaceholderUnbindDiagnostic({
2800
+ diagnostics,
2801
+ location: chartLocation,
2802
+ retainedAs: "chart"
2803
+ });
2251
2804
  const node = createChartNode(props);
2252
2805
  attachDeferredSlideLink(node, clickResult?.deferredSlideLink, context);
2253
2806
  return {
@@ -2260,7 +2813,8 @@ const chartImportHandler = {
2260
2813
  target: "shape-tree",
2261
2814
  localName: "graphicFrame",
2262
2815
  matches: (cursor) => isChartGraphicFrame(cursor) && !isPlaceholderGraphicFrameElement(cursor),
2263
- read: readChartGraphicFrame
2816
+ read: readChartGraphicFrame,
2817
+ groupMember: true
2264
2818
  };
2265
2819
  /** Shape-tree import handler wired into `chartPlaceholderMechanism` for placeholder-bound charts. */
2266
2820
  const chartPlaceholderImportHandler = {