ooxml-core 1.29.0 → 1.30.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.
- package/dist/{PptxHandler-CZG6ISCZ.cjs → PptxHandler-DHQPVTUI.cjs} +3 -3
- package/dist/PptxHandler-E4DDV3FQ.mjs +4 -0
- package/dist/{PptxHandler-QIHYALOV.mjs → PptxHandler-KKLAYUGQ.mjs} +2 -2
- package/dist/{PresentationBuilder-66EU3N3O.cjs → PresentationBuilder-JORMF5CP.cjs} +5 -5
- package/dist/{PresentationBuilder-5YM2L7DA.mjs → PresentationBuilder-Q2Z33LLM.mjs} +2 -2
- package/dist/{PresentationBuilder-UAINQZA2.mjs → PresentationBuilder-YYZYCKTZ.mjs} +2 -2
- package/dist/automation/index.cjs +4250 -3145
- package/dist/automation/index.mjs +4250 -3145
- package/dist/chart/box-distribution.d.ts +10 -0
- package/dist/chart/box-distribution.d.ts.map +1 -0
- package/dist/chart/data-table-layout.d.ts +8 -0
- package/dist/chart/data-table-layout.d.ts.map +1 -0
- package/dist/chart/date-axis.d.ts +3 -0
- package/dist/chart/date-axis.d.ts.map +1 -0
- package/dist/chart/date-format.d.ts +39 -0
- package/dist/chart/date-format.d.ts.map +1 -0
- package/dist/chart/edit/chartex-action.d.ts.map +1 -1
- package/dist/chart/edit/chartex-axis.d.ts.map +1 -1
- package/dist/chart/edit/chartex-structure.d.ts.map +1 -1
- package/dist/chart/edit/chartex.d.ts +3 -1
- package/dist/chart/edit/chartex.d.ts.map +1 -1
- package/dist/chart/edit/draft.d.ts.map +1 -1
- package/dist/chart/funnel-geometry.d.ts +15 -0
- package/dist/chart/funnel-geometry.d.ts.map +1 -0
- package/dist/chart/index.cjs +1392 -404
- package/dist/chart/index.d.ts +6 -0
- package/dist/chart/index.d.ts.map +1 -1
- package/dist/chart/index.mjs +1379 -405
- package/dist/chart/line-path.d.ts +30 -0
- package/dist/chart/line-path.d.ts.map +1 -0
- package/dist/chart/manual-layout.d.ts +15 -0
- package/dist/chart/manual-layout.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-analysis.d.ts +2 -0
- package/dist/chart/render/chart-svg-analysis.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-bars.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-box.d.ts +5 -0
- package/dist/chart/render/chart-svg-box.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-cartesian.d.ts +3 -1
- package/dist/chart/render/chart-svg-cartesian.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-data-table.d.ts +11 -0
- package/dist/chart/render/chart-svg-data-table.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-date-axis.d.ts +9 -0
- package/dist/chart/render/chart-svg-date-axis.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-funnel.d.ts +4 -0
- package/dist/chart/render/chart-svg-funnel.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-labels.d.ts +16 -16
- package/dist/chart/render/chart-svg-labels.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-line.d.ts +5 -0
- package/dist/chart/render/chart-svg-line.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-plot-layout.d.ts +6 -0
- package/dist/chart/render/chart-svg-plot-layout.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-plots.d.ts +2 -1
- package/dist/chart/render/chart-svg-plots.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-radial.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-slice-labels.d.ts +18 -0
- package/dist/chart/render/chart-svg-slice-labels.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-xy.d.ts +2 -1
- package/dist/chart/render/chart-svg-xy.d.ts.map +1 -1
- package/dist/chart/render/chart-svg.d.ts.map +1 -1
- package/dist/chart/render/chart-title-text.d.ts +3 -1
- package/dist/chart/render/chart-title-text.d.ts.map +1 -1
- package/dist/chart/render/chart-view-analysis.d.ts +2 -1
- package/dist/chart/render/chart-view-analysis.d.ts.map +1 -1
- package/dist/chart/render/chart-view-data-table.d.ts +13 -0
- package/dist/chart/render/chart-view-data-table.d.ts.map +1 -0
- package/dist/chart/render/chart-view-labels.d.ts +6 -1
- package/dist/chart/render/chart-view-labels.d.ts.map +1 -1
- package/dist/chart/render/chart-view-series.d.ts.map +1 -1
- package/dist/chart/render/chart-view.d.ts +13 -0
- package/dist/chart/render/chart-view.d.ts.map +1 -1
- package/dist/chart/render/render-space.d.ts.map +1 -1
- package/dist/chart/render/summary-ex-series.d.ts +5 -0
- package/dist/chart/render/summary-ex-series.d.ts.map +1 -0
- package/dist/chart/render/summary-from-chartex.d.ts.map +1 -1
- package/dist/chart/render/summary-from-space.d.ts +1 -1
- package/dist/chart/render/summary-from-space.d.ts.map +1 -1
- package/dist/chart/render/summary-labels.d.ts.map +1 -1
- package/dist/chart/render/summary.d.ts +14 -1
- package/dist/chart/render/summary.d.ts.map +1 -1
- package/dist/{chunk-6C4NLBLB.mjs → chunk-6FXOAMNL.mjs} +1 -1
- package/dist/{chunk-T7HBA3CW.cjs → chunk-7T3SJQA6.cjs} +11 -9
- package/dist/{chunk-XROY25LN.cjs → chunk-7XYVFUB3.cjs} +4 -0
- package/dist/{chunk-I2CGNAP2.cjs → chunk-B4LXDHBX.cjs} +1409 -1389
- package/dist/{chunk-GUNTIFGT.cjs → chunk-CZXM4ZJH.cjs} +158 -26
- package/dist/{chunk-RYOJHYA3.mjs → chunk-DJ3CDTMX.mjs} +157 -27
- package/dist/{chunk-BBK3UB7M.mjs → chunk-FFJBOR2Y.mjs} +4 -4
- package/dist/{chunk-DWEQWFQU.mjs → chunk-GJDFCP2T.mjs} +248 -228
- package/dist/{chunk-KBER3RAP.mjs → chunk-KWJYMAEF.mjs} +248 -228
- package/dist/{chunk-XCRDAVFN.mjs → chunk-MKDONWNO.mjs} +237 -95
- package/dist/{chunk-3UMDVJRN.mjs → chunk-NBMXEVHL.mjs} +4 -1
- package/dist/{chunk-TVJL7QIG.cjs → chunk-OGEL4Z4S.cjs} +8 -1
- package/dist/{chunk-HRU3KOE5.mjs → chunk-OORQCSVA.mjs} +5 -3
- package/dist/{chunk-7RJYOVQU.mjs → chunk-R7NS42KQ.mjs} +5 -2
- package/dist/{chunk-DXOBT2JE.mjs → chunk-UZWV2HAJ.mjs} +8 -2
- package/dist/{chunk-PDZ4GQLI.mjs → chunk-WZJ25K7P.mjs} +1 -1
- package/dist/{chunk-IETFPVLN.cjs → chunk-XTUX5RMG.cjs} +15 -12
- package/dist/diagram/drawing.d.ts.map +1 -1
- package/dist/diagram/index.cjs +1218 -592
- package/dist/diagram/index.mjs +1218 -592
- package/dist/diagram/load.d.ts.map +1 -1
- package/dist/diagram/relationships.d.ts +1 -0
- package/dist/diagram/relationships.d.ts.map +1 -1
- package/dist/diagram/types.d.ts +2 -0
- package/dist/diagram/types.d.ts.map +1 -1
- package/dist/docx/diagram.d.ts.map +1 -1
- package/dist/docx/drawing.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +1850 -1138
- package/dist/docx/embedded.mjs +1850 -1138
- package/dist/docx/index.cjs +3312 -1713
- package/dist/docx/index.mjs +3312 -1713
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/fonts.d.ts +1 -1
- package/dist/docx/layout/fonts.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +1933 -518
- package/dist/docx/layout/index.mjs +1933 -518
- package/dist/docx/layout/script-fonts.d.ts +6 -0
- package/dist/docx/layout/script-fonts.d.ts.map +1 -0
- package/dist/docx/load/index.cjs +1853 -1141
- package/dist/docx/load/index.mjs +1853 -1141
- package/dist/docx/parse.d.ts.map +1 -1
- package/dist/docx/shape-model.d.ts +2 -0
- package/dist/docx/shape-model.d.ts.map +1 -1
- package/dist/docx/shape-parse.d.ts.map +1 -1
- package/dist/docx/shape-svg.d.ts.map +1 -1
- package/dist/docx/ui/index.cjs +1763 -593
- package/dist/docx/ui/index.mjs +1763 -593
- package/dist/docx/write-shape.d.ts.map +1 -1
- package/dist/drawingml/custom-geometry.d.ts +5 -0
- package/dist/drawingml/custom-geometry.d.ts.map +1 -0
- package/dist/drawingml/drawing-fill.d.ts.map +1 -1
- package/dist/drawingml/drawing-geometry.d.ts.map +1 -1
- package/dist/drawingml/image-content-type.d.ts +2 -0
- package/dist/drawingml/image-content-type.d.ts.map +1 -0
- package/dist/drawingml/index.cjs +1128 -179
- package/dist/drawingml/index.d.ts +9 -0
- package/dist/drawingml/index.d.ts.map +1 -1
- package/dist/drawingml/index.mjs +1110 -180
- package/dist/drawingml/path-data.d.ts +4 -0
- package/dist/drawingml/path-data.d.ts.map +1 -0
- package/dist/drawingml/picture-crop.d.ts +8 -0
- package/dist/drawingml/picture-crop.d.ts.map +1 -0
- package/dist/drawingml/picture-effects.d.ts +37 -0
- package/dist/drawingml/picture-effects.d.ts.map +1 -0
- package/dist/drawingml/picture-fill.d.ts +7 -0
- package/dist/drawingml/picture-fill.d.ts.map +1 -0
- package/dist/drawingml/read-3d-values.d.ts +8 -0
- package/dist/drawingml/read-3d-values.d.ts.map +1 -0
- package/dist/drawingml/read-text-3d.d.ts +8 -0
- package/dist/drawingml/read-text-3d.d.ts.map +1 -0
- package/dist/drawingml/read-text-body.d.ts.map +1 -1
- package/dist/drawingml/scene3d-coordinate.d.ts +45 -0
- package/dist/drawingml/scene3d-coordinate.d.ts.map +1 -0
- package/dist/drawingml/scene3d-presets.d.ts +12 -0
- package/dist/drawingml/scene3d-presets.d.ts.map +1 -0
- package/dist/drawingml/text-3d-model.d.ts +71 -0
- package/dist/drawingml/text-3d-model.d.ts.map +1 -0
- package/dist/drawingml/text-model.d.ts +3 -0
- package/dist/drawingml/text-model.d.ts.map +1 -1
- package/dist/drawingml/types.d.ts +3 -0
- package/dist/drawingml/types.d.ts.map +1 -1
- package/dist/drawingml/write-pattern-picture.d.ts.map +1 -1
- package/dist/drawingml/write-text-3d.d.ts +6 -0
- package/dist/drawingml/write-text-3d.d.ts.map +1 -0
- package/dist/drawingml/write-text-body.d.ts.map +1 -1
- package/dist/geometry/element-transform.d.ts +3 -0
- package/dist/geometry/element-transform.d.ts.map +1 -1
- package/dist/geometry/index.cjs +69 -4
- package/dist/geometry/index.d.ts +2 -0
- package/dist/geometry/index.d.ts.map +1 -1
- package/dist/geometry/index.mjs +66 -5
- package/dist/geometry/picture-crop.d.ts +21 -0
- package/dist/geometry/picture-crop.d.ts.map +1 -0
- package/dist/geometry/resize-aspect.d.ts +12 -0
- package/dist/geometry/resize-aspect.d.ts.map +1 -0
- package/dist/index.cjs +4201 -2058
- package/dist/index.mjs +4201 -2058
- package/dist/opc/index.cjs +9 -6
- package/dist/opc/index.mjs +9 -6
- package/dist/opc/safe-href.d.ts +10 -3
- package/dist/opc/safe-href.d.ts.map +1 -1
- package/dist/pptx/automation/index.cjs +634 -361
- package/dist/pptx/automation/index.d.ts +6 -6
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{elements-CCEghtE_.d.ts → elements-mSCZ84Tc.d.ts} +4 -4
- package/dist/pptx/chunks/elements-mSCZ84Tc.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-D90lhgiE.d.ts → index-BQDcu_0a.d.ts} +19 -111
- package/dist/pptx/chunks/index-BQDcu_0a.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-CmnbpSCL.d.ts → index-CBV1oHN7.d.ts} +5 -5
- package/dist/pptx/chunks/{index-CmnbpSCL.d.ts.map → index-CBV1oHN7.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-DJIPX0Ge.d.ts → index-PdM5zpmu.d.ts} +5 -5
- package/dist/pptx/chunks/{index-DJIPX0Ge.d.ts.map → index-PdM5zpmu.d.ts.map} +1 -1
- package/dist/pptx/chunks/{smart-art-BLBSej3J.d.ts → smart-art-DLumQo90.d.ts} +135 -103
- package/dist/pptx/chunks/smart-art-DLumQo90.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-D49FKllA.d.ts → text-P9xVnXXf.d.ts} +49 -60
- package/dist/pptx/chunks/text-P9xVnXXf.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-operations-DZ1IgDJN.d.ts → text-operations-hyPODwIQ.d.ts} +4 -4
- package/dist/pptx/chunks/{text-operations-DZ1IgDJN.d.ts.map → text-operations-hyPODwIQ.d.ts.map} +1 -1
- package/dist/pptx/cli/index.cjs +630 -357
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +102 -67
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/collaboration-assets.cjs +15 -11
- package/dist/pptx/editor/render/collaboration-assets.d.ts +2 -2
- package/dist/pptx/editor/render/collaboration-assets.mjs +1 -1
- package/dist/pptx/editor/render/collaboration-live-patch-target.cjs +5 -5
- package/dist/pptx/editor/render/collaboration-live-patch-target.mjs +3 -3
- package/dist/pptx/editor/render/collaboration-reconcile.cjs +9 -9
- package/dist/pptx/editor/render/collaboration-reconcile.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-reconcile.mjs +3 -3
- package/dist/pptx/editor/render/collaboration-sync.cjs +29 -25
- package/dist/pptx/editor/render/collaboration-sync.d.ts +7 -0
- package/dist/pptx/editor/render/collaboration-sync.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-sync.mjs +2 -2
- package/dist/pptx/editor/render/find-replace.cjs +14 -14
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +1 -1
- package/dist/pptx/editor/render/font-family-update.d.ts +1 -1
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +1 -1
- package/dist/pptx/editor/render/slide-operations.cjs +8 -8
- package/dist/pptx/editor/render/slide-operations.mjs +2 -2
- package/dist/pptx/editor/render/table-cell-edit.cjs +8 -4
- package/dist/pptx/editor/render/table-cell-edit.d.ts +5 -0
- package/dist/pptx/editor/render/table-cell-edit.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-cell-edit.mjs +1 -1
- package/dist/pptx/editor/render/table-cell-merge.cjs +3 -3
- package/dist/pptx/editor/render/table-cell-merge.mjs +1 -1
- package/dist/pptx/editor/render/table-data-grid-ops.cjs +2 -2
- package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
- package/dist/pptx/editor/render/table-merge.cjs +5 -5
- package/dist/pptx/editor/render/table-merge.mjs +1 -1
- package/dist/pptx/editor/render/text-content-style.d.ts +1 -1
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +2 -2
- package/dist/pptx/editor/render/text-style-scope.d.ts +2 -2
- package/dist/pptx/editor/render/update-text-segment-style.d.ts +1 -1
- package/dist/pptx/index.cjs +696 -419
- package/dist/pptx/index.d.ts +8 -8
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/node/index.d.ts +1 -1
- package/dist/pptx/smartart-layouts/index.d.ts +1 -1
- package/dist/teams/index.cjs +1816 -1049
- package/dist/teams/index.mjs +1816 -1049
- package/dist/text/font-style-name.d.ts +11 -0
- package/dist/text/font-style-name.d.ts.map +1 -0
- package/dist/text/font-substitution-map.d.ts +3 -0
- package/dist/text/font-substitution-map.d.ts.map +1 -0
- package/dist/text/font-substitution.d.ts +34 -0
- package/dist/text/font-substitution.d.ts.map +1 -0
- package/dist/text/index.cjs +460 -0
- package/dist/text/index.d.ts +3 -0
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.mjs +443 -1
- package/dist/text/metric-font-family.d.ts +7 -0
- package/dist/text/metric-font-family.d.ts.map +1 -0
- package/dist/text/panose.d.ts +55 -0
- package/dist/text/panose.d.ts.map +1 -0
- package/dist/text/script-fonts.d.ts +26 -0
- package/dist/text/script-fonts.d.ts.map +1 -0
- package/dist/visio/edit-geometry-admission.d.ts +1 -1
- package/dist/visio/edit-geometry-admission.d.ts.map +1 -1
- package/dist/visio/edit-group-resize.d.ts +26 -0
- package/dist/visio/edit-group-resize.d.ts.map +1 -0
- package/dist/visio/edit-recalculate-index.d.ts +2 -0
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-resize-anchor.d.ts.map +1 -1
- package/dist/visio/edit-resize-plan.d.ts +14 -0
- package/dist/visio/edit-resize-plan.d.ts.map +1 -0
- package/dist/visio/edit-scope.d.ts.map +1 -1
- package/dist/visio/index.cjs +1326 -389
- package/dist/visio/index.mjs +1326 -389
- package/dist/visio/ui/geometry-expectation.d.ts +17 -0
- package/dist/visio/ui/geometry-expectation.d.ts.map +1 -0
- package/dist/visio/ui/guides.d.ts +2 -0
- package/dist/visio/ui/guides.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +1582 -411
- package/dist/visio/ui/index.d.ts +2 -0
- package/dist/visio/ui/index.d.ts.map +1 -1
- package/dist/visio/ui/index.mjs +1579 -412
- package/dist/visio/ui/selection-resize.d.ts +19 -0
- package/dist/visio/ui/selection-resize.d.ts.map +1 -0
- package/dist/visio/ui/shape-move.d.ts +1 -1
- package/dist/visio/ui/shape-move.d.ts.map +1 -1
- package/dist/visio/ui/shape-resize.d.ts.map +1 -1
- package/dist/xlsx/edit/drawings.d.ts +5 -0
- package/dist/xlsx/edit/drawings.d.ts.map +1 -1
- package/dist/xlsx/edit/session.d.ts.map +1 -1
- package/dist/xlsx/edit/types.d.ts +4 -0
- package/dist/xlsx/edit/types.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +3908 -2256
- package/dist/xlsx/index.mjs +3908 -2256
- package/dist/xlsx/layout/chart-view.d.ts.map +1 -1
- package/dist/xlsx/load/index.cjs +2003 -1239
- package/dist/xlsx/load/index.mjs +2003 -1239
- package/dist/xlsx/model.d.ts +4 -0
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/chart.d.ts.map +1 -1
- package/dist/xlsx/read/drawing.d.ts.map +1 -1
- package/dist/xlsx/read/smart-art.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +3880 -2228
- package/dist/xlsx/ui/index.mjs +3880 -2228
- package/dist/xlsx/write/drawing.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/PptxHandler-DSXSXMEG.mjs +0 -4
- package/dist/pptx/chunks/elements-CCEghtE_.d.ts.map +0 -1
- package/dist/pptx/chunks/index-D90lhgiE.d.ts.map +0 -1
- package/dist/pptx/chunks/smart-art-BLBSej3J.d.ts.map +0 -1
- package/dist/pptx/chunks/text-D49FKllA.d.ts.map +0 -1
package/dist/docx/ui/index.cjs
CHANGED
|
@@ -172,25 +172,25 @@ var inlineRunFormattingAttrs = Object.fromEntries(
|
|
|
172
172
|
[...RUN_PROPERTY_ATTRIBUTES].map((name) => [name, { default: null }])
|
|
173
173
|
);
|
|
174
174
|
function inlineRunProperties(node) {
|
|
175
|
-
const
|
|
175
|
+
const properties3 = typeof node.attrs.format === "string" ? JSON.parse(node.attrs.format) : {};
|
|
176
176
|
for (const key of DIRECT_RUN_PROPERTY_KEYS) {
|
|
177
177
|
const override = node.attrs[attributeName(key)];
|
|
178
178
|
if (typeof override !== "string") continue;
|
|
179
179
|
const value = JSON.parse(override);
|
|
180
|
-
if (value === null) delete
|
|
181
|
-
else
|
|
180
|
+
if (value === null) delete properties3[key];
|
|
181
|
+
else properties3[key] = value;
|
|
182
182
|
}
|
|
183
183
|
const projection = node.marks.find((mark) => mark.type.name === "inlineCommentAnchors");
|
|
184
184
|
if (projection) {
|
|
185
185
|
const ids = projection.attrs.ids;
|
|
186
|
-
if (ids.length)
|
|
187
|
-
else delete
|
|
186
|
+
if (ids.length) properties3.commentIds = [...ids];
|
|
187
|
+
else delete properties3.commentIds;
|
|
188
188
|
}
|
|
189
|
-
return
|
|
189
|
+
return properties3;
|
|
190
190
|
}
|
|
191
191
|
function inlineRunPropertiesDomAttrs(node) {
|
|
192
|
-
const
|
|
193
|
-
return Object.keys(
|
|
192
|
+
const properties3 = inlineRunProperties(node);
|
|
193
|
+
return Object.keys(properties3).length ? { "data-run-properties": JSON.stringify(properties3) } : {};
|
|
194
194
|
}
|
|
195
195
|
function updatedInlineRunAttributes(node, format) {
|
|
196
196
|
if (!node.type.spec.attrs?.[attributeName("bold")]) return { ...node.attrs, format };
|
|
@@ -490,8 +490,8 @@ function parseHalfPoints(value) {
|
|
|
490
490
|
function parseSignedHalfPoints(value) {
|
|
491
491
|
if (value === null || value === void 0) return void 0;
|
|
492
492
|
const text2 = value.trim();
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
493
|
+
const integer3 = parseInteger(text2);
|
|
494
|
+
if (integer3 !== void 0) return halfPoints(integer3);
|
|
495
495
|
const twips2 = universalMeasureToTwips(text2);
|
|
496
496
|
return twips2 === void 0 ? void 0 : halfPoints(Math.sign(twips2) * Math.round(Math.abs(twips2) / 10));
|
|
497
497
|
}
|
|
@@ -686,20 +686,20 @@ function freshControlId(used) {
|
|
|
686
686
|
var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|am\/pm|AM\/PM|'[^']*'/g;
|
|
687
687
|
function formatWordDate(date, picture, locale = "en-US") {
|
|
688
688
|
const name = (options2) => new Intl.DateTimeFormat(locale, options2).format(date);
|
|
689
|
-
const
|
|
689
|
+
const pad2 = (value) => String(value).padStart(2, "0");
|
|
690
690
|
const hours12 = date.getHours() % 12 || 12;
|
|
691
691
|
return picture.replace(TOKENS, (token) => {
|
|
692
692
|
switch (token) {
|
|
693
693
|
case "yyyy":
|
|
694
694
|
return String(date.getFullYear());
|
|
695
695
|
case "yy":
|
|
696
|
-
return
|
|
696
|
+
return pad2(date.getFullYear() % 100);
|
|
697
697
|
case "MMMM":
|
|
698
698
|
return name({ month: "long" });
|
|
699
699
|
case "MMM":
|
|
700
700
|
return name({ month: "short" });
|
|
701
701
|
case "MM":
|
|
702
|
-
return
|
|
702
|
+
return pad2(date.getMonth() + 1);
|
|
703
703
|
case "M":
|
|
704
704
|
return String(date.getMonth() + 1);
|
|
705
705
|
case "dddd":
|
|
@@ -707,21 +707,21 @@ function formatWordDate(date, picture, locale = "en-US") {
|
|
|
707
707
|
case "ddd":
|
|
708
708
|
return name({ weekday: "short" });
|
|
709
709
|
case "dd":
|
|
710
|
-
return
|
|
710
|
+
return pad2(date.getDate());
|
|
711
711
|
case "d":
|
|
712
712
|
return String(date.getDate());
|
|
713
713
|
case "HH":
|
|
714
|
-
return
|
|
714
|
+
return pad2(date.getHours());
|
|
715
715
|
case "H":
|
|
716
716
|
return String(date.getHours());
|
|
717
717
|
case "hh":
|
|
718
|
-
return
|
|
718
|
+
return pad2(hours12);
|
|
719
719
|
case "h":
|
|
720
720
|
return String(hours12);
|
|
721
721
|
case "mm":
|
|
722
|
-
return
|
|
722
|
+
return pad2(date.getMinutes());
|
|
723
723
|
case "ss":
|
|
724
|
-
return
|
|
724
|
+
return pad2(date.getSeconds());
|
|
725
725
|
case "am/pm":
|
|
726
726
|
return date.getHours() < 12 ? "am" : "pm";
|
|
727
727
|
case "AM/PM":
|
|
@@ -787,13 +787,13 @@ function withValue(control) {
|
|
|
787
787
|
// docx/ui/content-control-rows.ts
|
|
788
788
|
var rowControlOf = (node) => node.type.name === "tableRow" ? node.attrs.properties?.contentControl ?? void 0 : void 0;
|
|
789
789
|
function rowControlSpans(doc) {
|
|
790
|
-
const
|
|
790
|
+
const rows2 = [];
|
|
791
791
|
doc.descendants((node, pos) => {
|
|
792
792
|
const control = rowControlOf(node);
|
|
793
|
-
if (control)
|
|
793
|
+
if (control) rows2.push({ control, level: "row", from: pos, to: pos + node.nodeSize });
|
|
794
794
|
return !node.isTextblock;
|
|
795
795
|
});
|
|
796
|
-
return
|
|
796
|
+
return rows2;
|
|
797
797
|
}
|
|
798
798
|
|
|
799
799
|
// docx/ui/content-control-spans.ts
|
|
@@ -1269,10 +1269,10 @@ function nodeControlOf(node) {
|
|
|
1269
1269
|
}
|
|
1270
1270
|
function attrsWithControl(node, control) {
|
|
1271
1271
|
if (node.type.name !== "tableRow") return { ...node.attrs, contentControl: control ?? null };
|
|
1272
|
-
const { contentControl: _held, ...
|
|
1272
|
+
const { contentControl: _held, ...properties3 } = node.attrs.properties ?? {};
|
|
1273
1273
|
return {
|
|
1274
1274
|
...node.attrs,
|
|
1275
|
-
properties: control ? { ...
|
|
1275
|
+
properties: control ? { ...properties3, contentControl: control } : Object.keys(properties3).length ? properties3 : null
|
|
1276
1276
|
};
|
|
1277
1277
|
}
|
|
1278
1278
|
function otherControlSourcesOf(slice) {
|
|
@@ -2845,6 +2845,141 @@ function drawingColorCss(value) {
|
|
|
2845
2845
|
return `rgba(${channels.join(",")},${value.alpha})`;
|
|
2846
2846
|
}
|
|
2847
2847
|
|
|
2848
|
+
// drawingml/picture-crop.ts
|
|
2849
|
+
var SIDES = { l: "cropLeft", t: "cropTop", r: "cropRight", b: "cropBottom" };
|
|
2850
|
+
function parsePictureCrop(blipFill) {
|
|
2851
|
+
const rect3 = first(blipFill, "srcRect", NS.a);
|
|
2852
|
+
if (!rect3) return void 0;
|
|
2853
|
+
const result = {};
|
|
2854
|
+
for (const [attr2, key] of Object.entries(SIDES)) {
|
|
2855
|
+
const raw = rect3.getAttribute(attr2);
|
|
2856
|
+
if (raw === null || !raw.trim()) continue;
|
|
2857
|
+
const percent = raw.endsWith("%");
|
|
2858
|
+
const value = Number(percent ? raw.slice(0, -1) : raw) / (percent ? 100 : 1e5);
|
|
2859
|
+
if (Number.isFinite(value)) result[key] = value;
|
|
2860
|
+
}
|
|
2861
|
+
return result;
|
|
2862
|
+
}
|
|
2863
|
+
function applyPictureCrop(blipFill, crop) {
|
|
2864
|
+
let rect3 = first(blipFill, "srcRect", NS.a);
|
|
2865
|
+
if (!rect3 && crop && Object.values(crop).some((value) => value !== void 0)) {
|
|
2866
|
+
rect3 = blipFill.ownerDocument.createElementNS(NS.a, "a:srcRect");
|
|
2867
|
+
const blip = first(blipFill, "blip", NS.a);
|
|
2868
|
+
blipFill.insertBefore(rect3, blip?.nextSibling ?? blipFill.firstChild);
|
|
2869
|
+
}
|
|
2870
|
+
if (!rect3) return;
|
|
2871
|
+
for (const [attr2, key] of Object.entries(SIDES)) {
|
|
2872
|
+
const value = crop?.[key];
|
|
2873
|
+
if (value === void 0) rect3.removeAttribute(attr2);
|
|
2874
|
+
else {
|
|
2875
|
+
if (!Number.isFinite(value)) throw new RangeError("Picture crop must be finite");
|
|
2876
|
+
rect3.setAttribute(attr2, String(Math.round(value * 1e5)));
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
// drawingml/picture-effects.ts
|
|
2882
|
+
function picturePercentage(value) {
|
|
2883
|
+
const text2 = String(value ?? "").trim();
|
|
2884
|
+
if (!text2) return void 0;
|
|
2885
|
+
const percent = text2.endsWith("%");
|
|
2886
|
+
const n2 = Number(percent ? text2.slice(0, -1) : text2) / (percent ? 100 : 1e5);
|
|
2887
|
+
return Number.isFinite(n2) ? n2 : void 0;
|
|
2888
|
+
}
|
|
2889
|
+
function readPictureEffect(name, attribute) {
|
|
2890
|
+
if (name === "grayscl") return { kind: "grayscale" };
|
|
2891
|
+
if (name === "lum") {
|
|
2892
|
+
const brightness = picturePercentage(attribute("bright"));
|
|
2893
|
+
const contrast = picturePercentage(attribute("contrast"));
|
|
2894
|
+
for (const [name2, value] of [
|
|
2895
|
+
["bright", brightness],
|
|
2896
|
+
["contrast", contrast]
|
|
2897
|
+
]) {
|
|
2898
|
+
const raw = attribute(name2);
|
|
2899
|
+
if (raw !== void 0 && raw !== null && (value === void 0 || Math.abs(value) > 1))
|
|
2900
|
+
return void 0;
|
|
2901
|
+
}
|
|
2902
|
+
return {
|
|
2903
|
+
kind: "luminance",
|
|
2904
|
+
...brightness !== void 0 ? { brightness } : {},
|
|
2905
|
+
...contrast !== void 0 ? { contrast } : {}
|
|
2906
|
+
};
|
|
2907
|
+
}
|
|
2908
|
+
if (name === "alphaModFix") {
|
|
2909
|
+
const raw = attribute("amt");
|
|
2910
|
+
const amount = raw === void 0 || raw === null ? 1 : picturePercentage(raw);
|
|
2911
|
+
if (amount !== void 0 && amount >= 0) return { kind: "alphaModFix", amount };
|
|
2912
|
+
}
|
|
2913
|
+
return void 0;
|
|
2914
|
+
}
|
|
2915
|
+
function parsePictureEffects(blip) {
|
|
2916
|
+
if (!blip) return [];
|
|
2917
|
+
return elements(blip).map((node) => ({
|
|
2918
|
+
...(node.namespaceURI === NS.a ? readPictureEffect(node.localName, (name) => node.getAttribute(name)) : void 0) ?? { kind: "unsupported", name: node.localName },
|
|
2919
|
+
sourceXml: buildXml(node)
|
|
2920
|
+
}));
|
|
2921
|
+
}
|
|
2922
|
+
function applyPictureEffects(blip, effects) {
|
|
2923
|
+
if (JSON.stringify(parsePictureEffects(blip)) === JSON.stringify(effects)) return;
|
|
2924
|
+
const nodes = effects.map((effect) => {
|
|
2925
|
+
const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind;
|
|
2926
|
+
const source = effect.sourceXml ? parseXml(effect.sourceXml).documentElement : void 0;
|
|
2927
|
+
if (effect.kind === "unsupported" && !source)
|
|
2928
|
+
throw new Error("An unsupported picture effect needs source XML");
|
|
2929
|
+
const node = source ? blip.ownerDocument.importNode(source, true) : blip.ownerDocument.createElementNS(NS.a, `a:${name}`);
|
|
2930
|
+
if (effect.kind !== "unsupported" && (node.namespaceURI !== NS.a || node.localName !== name))
|
|
2931
|
+
throw new Error("Picture effect source does not match its kind");
|
|
2932
|
+
const set = (name2, value) => {
|
|
2933
|
+
const original = picturePercentage(node.getAttribute(name2));
|
|
2934
|
+
if (value === void 0) node.removeAttribute(name2);
|
|
2935
|
+
else if (value !== original) {
|
|
2936
|
+
if (!Number.isFinite(value)) throw new RangeError("Picture effect must be finite");
|
|
2937
|
+
node.setAttribute(name2, String(Math.round(value * 1e5)));
|
|
2938
|
+
}
|
|
2939
|
+
};
|
|
2940
|
+
if (effect.kind === "luminance") {
|
|
2941
|
+
if ([effect.brightness, effect.contrast].some(
|
|
2942
|
+
(value) => value !== void 0 && (!Number.isFinite(value) || Math.abs(value) > 1)
|
|
2943
|
+
))
|
|
2944
|
+
throw new RangeError("Picture luminance must be between -1 and 1");
|
|
2945
|
+
set("bright", effect.brightness);
|
|
2946
|
+
set("contrast", effect.contrast);
|
|
2947
|
+
}
|
|
2948
|
+
if (effect.kind === "alphaModFix") {
|
|
2949
|
+
if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
|
|
2950
|
+
set("amt", effect.amount);
|
|
2951
|
+
}
|
|
2952
|
+
return node;
|
|
2953
|
+
});
|
|
2954
|
+
for (const node of elements(blip)) blip.removeChild(node);
|
|
2955
|
+
for (const node of nodes) blip.appendChild(node);
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
// drawingml/picture-fill.ts
|
|
2959
|
+
function parseDrawingPictureFill(fill) {
|
|
2960
|
+
const blip = first(fill, "blip", NS.a);
|
|
2961
|
+
const relId = blip?.getAttributeNS(NS.r, "embed") || blip?.getAttribute("r:embed") || void 0;
|
|
2962
|
+
const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
|
|
2963
|
+
const crop = parsePictureCrop(fill);
|
|
2964
|
+
const effects = parsePictureEffects(blip);
|
|
2965
|
+
const tile = first(fill, "tile", NS.a);
|
|
2966
|
+
const rect3 = first(first(fill, "stretch", NS.a), "fillRect", NS.a);
|
|
2967
|
+
const unsupported = [
|
|
2968
|
+
...tile ? ["tile"] : [],
|
|
2969
|
+
...rect3 && ["l", "t", "r", "b"].some((key) => Number(rect3.getAttribute(key) ?? 0) !== 0) ? ["fillRect"] : [],
|
|
2970
|
+
...fill.getAttribute("rotWithShape") === "0" || fill.getAttribute("rotWithShape") === "false" ? ["rotWithShape"] : []
|
|
2971
|
+
];
|
|
2972
|
+
return {
|
|
2973
|
+
kind: "picture",
|
|
2974
|
+
sourceXml: buildXml(fill),
|
|
2975
|
+
...relId ? { relId } : {},
|
|
2976
|
+
...linkRelId ? { linkRelId } : {},
|
|
2977
|
+
...crop ? { crop } : {},
|
|
2978
|
+
...effects.length ? { effects } : {},
|
|
2979
|
+
...unsupported.length ? { unsupportedPicture: unsupported } : {}
|
|
2980
|
+
};
|
|
2981
|
+
}
|
|
2982
|
+
|
|
2848
2983
|
// drawingml/drawing-fill.ts
|
|
2849
2984
|
var FILL_ELEMENTS = /* @__PURE__ */ new Set([
|
|
2850
2985
|
"noFill",
|
|
@@ -2854,13 +2989,13 @@ var FILL_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
2854
2989
|
"blipFill",
|
|
2855
2990
|
"grpFill"
|
|
2856
2991
|
]);
|
|
2857
|
-
function fillElementOf(
|
|
2858
|
-
return
|
|
2992
|
+
function fillElementOf(properties3) {
|
|
2993
|
+
return properties3 ? elements(properties3).find(
|
|
2859
2994
|
(element3) => FILL_ELEMENTS.has(element3.localName) && (!element3.namespaceURI || element3.namespaceURI === NS.a)
|
|
2860
2995
|
) : void 0;
|
|
2861
2996
|
}
|
|
2862
|
-
function parseDrawingFill(
|
|
2863
|
-
const fill = fillElementOf(
|
|
2997
|
+
function parseDrawingFill(properties3) {
|
|
2998
|
+
const fill = fillElementOf(properties3);
|
|
2864
2999
|
if (!fill) return void 0;
|
|
2865
3000
|
switch (fill.localName) {
|
|
2866
3001
|
case "noFill":
|
|
@@ -2915,17 +3050,8 @@ function parseDrawingFill(properties4) {
|
|
|
2915
3050
|
...background ? { background } : {}
|
|
2916
3051
|
};
|
|
2917
3052
|
}
|
|
2918
|
-
case "blipFill":
|
|
2919
|
-
|
|
2920
|
-
const relId = blip?.getAttributeNS(NS.r, "embed") || blip?.getAttribute("r:embed") || void 0;
|
|
2921
|
-
const linkRelId = blip?.getAttributeNS(NS.r, "link") || void 0;
|
|
2922
|
-
return {
|
|
2923
|
-
kind: "picture",
|
|
2924
|
-
sourceXml: buildXml(fill),
|
|
2925
|
-
...relId ? { relId } : {},
|
|
2926
|
-
...linkRelId ? { linkRelId } : {}
|
|
2927
|
-
};
|
|
2928
|
-
}
|
|
3053
|
+
case "blipFill":
|
|
3054
|
+
return parseDrawingPictureFill(fill);
|
|
2929
3055
|
default:
|
|
2930
3056
|
return { kind: "unsupported", element: fill.localName };
|
|
2931
3057
|
}
|
|
@@ -2981,6 +3107,194 @@ function drawingDashLength(value) {
|
|
|
2981
3107
|
return Number.isSafeInteger(number) && number <= 2147483647 ? number : void 0;
|
|
2982
3108
|
}
|
|
2983
3109
|
|
|
3110
|
+
// geometry/guide-formula-eval.ts
|
|
3111
|
+
var ANGLE_SCALE = 6e4;
|
|
3112
|
+
function angleToRadians(ooxmlAngle) {
|
|
3113
|
+
return ooxmlAngle / ANGLE_SCALE * (Math.PI / 180);
|
|
3114
|
+
}
|
|
3115
|
+
function parseFormula(fmla) {
|
|
3116
|
+
const parts = fmla.trim().split(/\s+/);
|
|
3117
|
+
const op = parts[0] ?? "";
|
|
3118
|
+
const args = parts.slice(1);
|
|
3119
|
+
return { op, args };
|
|
3120
|
+
}
|
|
3121
|
+
function resolveOperand(token, variables) {
|
|
3122
|
+
const num2 = Number(token);
|
|
3123
|
+
if (Number.isFinite(num2)) {
|
|
3124
|
+
return num2;
|
|
3125
|
+
}
|
|
3126
|
+
const value = variables.get(token);
|
|
3127
|
+
if (value !== void 0) {
|
|
3128
|
+
return value;
|
|
3129
|
+
}
|
|
3130
|
+
return 0;
|
|
3131
|
+
}
|
|
3132
|
+
function evaluateFormula(parsed, vars) {
|
|
3133
|
+
const r = (idx) => resolveOperand(parsed.args[idx] ?? "0", vars);
|
|
3134
|
+
switch (parsed.op) {
|
|
3135
|
+
// val x — literal value
|
|
3136
|
+
case "val":
|
|
3137
|
+
return r(0);
|
|
3138
|
+
// abs x — absolute value
|
|
3139
|
+
case "abs":
|
|
3140
|
+
return Math.abs(r(0));
|
|
3141
|
+
// sqrt x — square root
|
|
3142
|
+
case "sqrt":
|
|
3143
|
+
return Math.sqrt(Math.max(r(0), 0));
|
|
3144
|
+
// +- x y z — x + y - z
|
|
3145
|
+
case "+-":
|
|
3146
|
+
return r(0) + r(1) - r(2);
|
|
3147
|
+
// */ x y z — (x * y) / z
|
|
3148
|
+
case "*/": {
|
|
3149
|
+
const z = r(2);
|
|
3150
|
+
if (z === 0) {
|
|
3151
|
+
return 0;
|
|
3152
|
+
}
|
|
3153
|
+
return r(0) * r(1) / z;
|
|
3154
|
+
}
|
|
3155
|
+
// +/ x y z — (x + y) / z
|
|
3156
|
+
case "+/": {
|
|
3157
|
+
const z = r(2);
|
|
3158
|
+
if (z === 0) {
|
|
3159
|
+
return 0;
|
|
3160
|
+
}
|
|
3161
|
+
return (r(0) + r(1)) / z;
|
|
3162
|
+
}
|
|
3163
|
+
// ?: x y z — if x > 0 then y else z
|
|
3164
|
+
case "?:":
|
|
3165
|
+
case "if":
|
|
3166
|
+
return r(0) > 0 ? r(1) : r(2);
|
|
3167
|
+
// min x y — minimum
|
|
3168
|
+
case "min":
|
|
3169
|
+
return Math.min(r(0), r(1));
|
|
3170
|
+
// max x y — maximum
|
|
3171
|
+
case "max":
|
|
3172
|
+
return Math.max(r(0), r(1));
|
|
3173
|
+
// mod x y z — sqrt(x² + y² + z²)
|
|
3174
|
+
case "mod": {
|
|
3175
|
+
const a = r(0);
|
|
3176
|
+
const b = r(1);
|
|
3177
|
+
const c = r(2);
|
|
3178
|
+
return Math.sqrt(a * a + b * b + c * c);
|
|
3179
|
+
}
|
|
3180
|
+
// pin x y z — clamp y between x and z
|
|
3181
|
+
case "pin": {
|
|
3182
|
+
const lo = r(0);
|
|
3183
|
+
const val = r(1);
|
|
3184
|
+
const hi = r(2);
|
|
3185
|
+
return Math.max(lo, Math.min(val, hi));
|
|
3186
|
+
}
|
|
3187
|
+
// sin x y — x * sin(y) where y is in OOXML angle units
|
|
3188
|
+
case "sin": {
|
|
3189
|
+
const sinVal = Math.sin(angleToRadians(r(1)));
|
|
3190
|
+
if (!Number.isFinite(sinVal)) {
|
|
3191
|
+
return 0;
|
|
3192
|
+
}
|
|
3193
|
+
return r(0) * sinVal;
|
|
3194
|
+
}
|
|
3195
|
+
// cos x y — x * cos(y) where y is in OOXML angle units
|
|
3196
|
+
case "cos": {
|
|
3197
|
+
const cosVal = Math.cos(angleToRadians(r(1)));
|
|
3198
|
+
if (!Number.isFinite(cosVal)) {
|
|
3199
|
+
return 0;
|
|
3200
|
+
}
|
|
3201
|
+
return r(0) * cosVal;
|
|
3202
|
+
}
|
|
3203
|
+
// tan x y — x * tan(y) where y is in OOXML angle units
|
|
3204
|
+
case "tan": {
|
|
3205
|
+
const angle = angleToRadians(r(1));
|
|
3206
|
+
const tanVal = Math.tan(angle);
|
|
3207
|
+
if (!Number.isFinite(tanVal)) {
|
|
3208
|
+
return 0;
|
|
3209
|
+
}
|
|
3210
|
+
return r(0) * tanVal;
|
|
3211
|
+
}
|
|
3212
|
+
// atan x — atan(x) result in OOXML angle units
|
|
3213
|
+
// x is a ratio scaled by the shape coordinate space
|
|
3214
|
+
case "atan": {
|
|
3215
|
+
const radians = Math.atan(r(0));
|
|
3216
|
+
return radians * 180 * ANGLE_SCALE / Math.PI;
|
|
3217
|
+
}
|
|
3218
|
+
// at2 x y -> arctan(y / x), i.e. Math.atan2(y, x), result in OOXML angle
|
|
3219
|
+
// units. ECMA-376 / ISO-IEC-29500-1 section 20.1.9.6 defines the operand
|
|
3220
|
+
// order as (x, y) with the ARGUMENTS REVERSED relative to Math.atan2, so
|
|
3221
|
+
// the first operand is the horizontal component and the second is the
|
|
3222
|
+
// vertical one. This matches the companion `cat2`/`sat2` operators below,
|
|
3223
|
+
// which take (x, y, z) and compute atan2(z, y).
|
|
3224
|
+
case "at2":
|
|
3225
|
+
case "atan2": {
|
|
3226
|
+
const radians = Math.atan2(r(1), r(0));
|
|
3227
|
+
return radians * 180 * ANGLE_SCALE / Math.PI;
|
|
3228
|
+
}
|
|
3229
|
+
// cat2 x y z — x * cos(atan2(z, y))
|
|
3230
|
+
// Computes the cosine-component of a vector scaled by x
|
|
3231
|
+
case "cat2": {
|
|
3232
|
+
const angle = Math.atan2(r(2), r(1));
|
|
3233
|
+
return r(0) * Math.cos(angle);
|
|
3234
|
+
}
|
|
3235
|
+
// sat2 x y z — x * sin(atan2(z, y))
|
|
3236
|
+
// Computes the sine-component of a vector scaled by x
|
|
3237
|
+
case "sat2": {
|
|
3238
|
+
const angle = Math.atan2(r(2), r(1));
|
|
3239
|
+
return r(0) * Math.sin(angle);
|
|
3240
|
+
}
|
|
3241
|
+
default:
|
|
3242
|
+
return Number(parsed.op) || 0;
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
|
|
3246
|
+
// geometry/guide-formula-api.ts
|
|
3247
|
+
function createBuiltinVariables(ctx) {
|
|
3248
|
+
const { w, h } = ctx;
|
|
3249
|
+
const vars = /* @__PURE__ */ new Map();
|
|
3250
|
+
vars.set("w", w);
|
|
3251
|
+
vars.set("h", h);
|
|
3252
|
+
vars.set("l", 0);
|
|
3253
|
+
vars.set("t", 0);
|
|
3254
|
+
vars.set("r", w);
|
|
3255
|
+
vars.set("b", h);
|
|
3256
|
+
vars.set("hc", w / 2);
|
|
3257
|
+
vars.set("vc", h / 2);
|
|
3258
|
+
const widthDivisors = [2, 3, 4, 5, 6, 8, 10, 12, 16, 32];
|
|
3259
|
+
for (const d of widthDivisors) {
|
|
3260
|
+
vars.set(`wd${d}`, w / d);
|
|
3261
|
+
}
|
|
3262
|
+
const heightDivisors = [2, 3, 4, 5, 6, 8, 10, 12, 16, 32];
|
|
3263
|
+
for (const d of heightDivisors) {
|
|
3264
|
+
vars.set(`hd${d}`, h / d);
|
|
3265
|
+
}
|
|
3266
|
+
const ss = Math.min(w, h);
|
|
3267
|
+
const ls = Math.max(w, h);
|
|
3268
|
+
vars.set("ss", ss);
|
|
3269
|
+
vars.set("ls", ls);
|
|
3270
|
+
const ssDivisors = [2, 4, 6, 8, 16, 32];
|
|
3271
|
+
for (const d of ssDivisors) {
|
|
3272
|
+
vars.set(`ssd${d}`, ss / d);
|
|
3273
|
+
}
|
|
3274
|
+
vars.set("cd2", 180 * ANGLE_SCALE);
|
|
3275
|
+
vars.set("cd4", 90 * ANGLE_SCALE);
|
|
3276
|
+
vars.set("cd8", 45 * ANGLE_SCALE);
|
|
3277
|
+
vars.set("3cd4", 270 * ANGLE_SCALE);
|
|
3278
|
+
vars.set("3cd8", 135 * ANGLE_SCALE);
|
|
3279
|
+
vars.set("5cd8", 225 * ANGLE_SCALE);
|
|
3280
|
+
vars.set("7cd8", 315 * ANGLE_SCALE);
|
|
3281
|
+
return vars;
|
|
3282
|
+
}
|
|
3283
|
+
function evaluateGuides(guides, ctx, adjustments) {
|
|
3284
|
+
const vars = createBuiltinVariables(ctx);
|
|
3285
|
+
if (adjustments) {
|
|
3286
|
+
for (const [name, value] of adjustments) {
|
|
3287
|
+
vars.set(name, value);
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
for (const guide of guides) {
|
|
3291
|
+
const parsed = parseFormula(guide.formula);
|
|
3292
|
+
const value = evaluateFormula(parsed, vars);
|
|
3293
|
+
vars.set(guide.name, Number.isFinite(value) ? value : 0);
|
|
3294
|
+
}
|
|
3295
|
+
return vars;
|
|
3296
|
+
}
|
|
3297
|
+
|
|
2984
3298
|
// drawingml/write-color.ts
|
|
2985
3299
|
var ELEMENTS = {
|
|
2986
3300
|
srgb: "srgbClr",
|
|
@@ -3112,6 +3426,10 @@ function drawingPatternPictureXml(fill) {
|
|
|
3112
3426
|
else if (blip.getAttributeNS(NS.r, attribute) !== value)
|
|
3113
3427
|
blip.setAttributeNS(NS.r, `r:${attribute}`, value);
|
|
3114
3428
|
}
|
|
3429
|
+
if (fill.crop !== void 0 && JSON.stringify(before?.kind === "picture" ? before.crop : void 0) !== JSON.stringify(fill.crop))
|
|
3430
|
+
applyPictureCrop(root, fill.crop);
|
|
3431
|
+
if (fill.effects !== void 0 && JSON.stringify(before?.kind === "picture" ? before.effects ?? [] : []) !== JSON.stringify(fill.effects ?? []))
|
|
3432
|
+
applyPictureEffects(blip, fill.effects ?? []);
|
|
3115
3433
|
if (!fill.sourceXml) {
|
|
3116
3434
|
const stretch = doc.createElementNS(NS.a, "a:stretch");
|
|
3117
3435
|
stretch.appendChild(doc.createElementNS(NS.a, "a:fillRect"));
|
|
@@ -3889,36 +4207,243 @@ function parseDrawingParagraphProperties(element3) {
|
|
|
3889
4207
|
return out;
|
|
3890
4208
|
}
|
|
3891
4209
|
|
|
3892
|
-
// drawingml/
|
|
3893
|
-
var
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
4210
|
+
// drawingml/scene3d-presets.ts
|
|
4211
|
+
var CAMERA_PRESETS = /* @__PURE__ */ new Set([
|
|
4212
|
+
"legacyObliqueTopLeft",
|
|
4213
|
+
"legacyObliqueTop",
|
|
4214
|
+
"legacyObliqueTopRight",
|
|
4215
|
+
"legacyObliqueLeft",
|
|
4216
|
+
"legacyObliqueFront",
|
|
4217
|
+
"legacyObliqueRight",
|
|
4218
|
+
"legacyObliqueBottomLeft",
|
|
4219
|
+
"legacyObliqueBottom",
|
|
4220
|
+
"legacyObliqueBottomRight",
|
|
4221
|
+
"legacyPerspectiveTopLeft",
|
|
4222
|
+
"legacyPerspectiveTop",
|
|
4223
|
+
"legacyPerspectiveTopRight",
|
|
4224
|
+
"legacyPerspectiveLeft",
|
|
4225
|
+
"legacyPerspectiveFront",
|
|
4226
|
+
"legacyPerspectiveRight",
|
|
4227
|
+
"legacyPerspectiveBottomLeft",
|
|
4228
|
+
"legacyPerspectiveBottom",
|
|
4229
|
+
"legacyPerspectiveBottomRight",
|
|
4230
|
+
"orthographicFront",
|
|
4231
|
+
"isometricTopUp",
|
|
4232
|
+
"isometricTopDown",
|
|
4233
|
+
"isometricBottomUp",
|
|
4234
|
+
"isometricBottomDown",
|
|
4235
|
+
"isometricLeftUp",
|
|
4236
|
+
"isometricLeftDown",
|
|
4237
|
+
"isometricRightUp",
|
|
4238
|
+
"isometricRightDown",
|
|
4239
|
+
"isometricOffAxis1Left",
|
|
4240
|
+
"isometricOffAxis1Right",
|
|
4241
|
+
"isometricOffAxis1Top",
|
|
4242
|
+
"isometricOffAxis2Left",
|
|
4243
|
+
"isometricOffAxis2Right",
|
|
4244
|
+
"isometricOffAxis2Top",
|
|
4245
|
+
"isometricOffAxis3Left",
|
|
4246
|
+
"isometricOffAxis3Right",
|
|
4247
|
+
"isometricOffAxis3Bottom",
|
|
4248
|
+
"isometricOffAxis4Left",
|
|
4249
|
+
"isometricOffAxis4Right",
|
|
4250
|
+
"isometricOffAxis4Bottom",
|
|
4251
|
+
"obliqueTopLeft",
|
|
4252
|
+
"obliqueTop",
|
|
4253
|
+
"obliqueTopRight",
|
|
4254
|
+
"obliqueLeft",
|
|
4255
|
+
"obliqueRight",
|
|
4256
|
+
"obliqueBottomLeft",
|
|
4257
|
+
"obliqueBottom",
|
|
4258
|
+
"obliqueBottomRight",
|
|
4259
|
+
"perspectiveFront",
|
|
4260
|
+
"perspectiveLeft",
|
|
4261
|
+
"perspectiveRight",
|
|
4262
|
+
"perspectiveAbove",
|
|
4263
|
+
"perspectiveBelow",
|
|
4264
|
+
"perspectiveAboveLeftFacing",
|
|
4265
|
+
"perspectiveAboveRightFacing",
|
|
4266
|
+
"perspectiveContrastingLeftFacing",
|
|
4267
|
+
"perspectiveContrastingRightFacing",
|
|
4268
|
+
"perspectiveHeroicLeftFacing",
|
|
4269
|
+
"perspectiveHeroicRightFacing",
|
|
4270
|
+
"perspectiveHeroicExtremeLeftFacing",
|
|
4271
|
+
"perspectiveHeroicExtremeRightFacing",
|
|
4272
|
+
"perspectiveRelaxed",
|
|
4273
|
+
"perspectiveRelaxedModerately"
|
|
4274
|
+
]);
|
|
4275
|
+
var LIGHT_RIGS = /* @__PURE__ */ new Set([
|
|
4276
|
+
"legacyFlat1",
|
|
4277
|
+
"legacyFlat2",
|
|
4278
|
+
"legacyFlat3",
|
|
4279
|
+
"legacyFlat4",
|
|
4280
|
+
"legacyNormal1",
|
|
4281
|
+
"legacyNormal2",
|
|
4282
|
+
"legacyNormal3",
|
|
4283
|
+
"legacyNormal4",
|
|
4284
|
+
"legacyHarsh1",
|
|
4285
|
+
"legacyHarsh2",
|
|
4286
|
+
"legacyHarsh3",
|
|
4287
|
+
"legacyHarsh4",
|
|
4288
|
+
"threePt",
|
|
4289
|
+
"balanced",
|
|
4290
|
+
"soft",
|
|
4291
|
+
"harsh",
|
|
4292
|
+
"flood",
|
|
4293
|
+
"contrasting",
|
|
4294
|
+
"morning",
|
|
4295
|
+
"sunrise",
|
|
4296
|
+
"sunset",
|
|
4297
|
+
"chilly",
|
|
4298
|
+
"freezing",
|
|
4299
|
+
"flat",
|
|
4300
|
+
"twoPt",
|
|
4301
|
+
"glow",
|
|
4302
|
+
"brightRoom"
|
|
4303
|
+
]);
|
|
4304
|
+
var LIGHT_DIRECTIONS = /* @__PURE__ */ new Set(["tl", "t", "tr", "l", "r", "bl", "b", "br"]);
|
|
4305
|
+
|
|
4306
|
+
// drawingml/read-3d-values.ts
|
|
4307
|
+
var integer2 = (value) => {
|
|
4308
|
+
if (value === void 0 || value === null || String(value).trim() === "") return void 0;
|
|
4309
|
+
const n2 = Number(value);
|
|
4310
|
+
return Number.isSafeInteger(n2) ? n2 : void 0;
|
|
4311
|
+
};
|
|
4312
|
+
function readScene3DValues(node, read) {
|
|
4313
|
+
const out = {};
|
|
4314
|
+
const camera = read.child(node, "camera");
|
|
4315
|
+
const light = read.child(node, "lightRig");
|
|
4316
|
+
for (const [key, source, attribute, choices] of [
|
|
4317
|
+
["cameraPreset", camera, "prst", CAMERA_PRESETS],
|
|
4318
|
+
["lightRigType", light, "rig", LIGHT_RIGS],
|
|
4319
|
+
["lightRigDirection", light, "dir", LIGHT_DIRECTIONS]
|
|
4320
|
+
]) {
|
|
4321
|
+
const token = String(read.attribute(source, attribute) ?? "").trim();
|
|
4322
|
+
if (choices.has(token)) out[key] = token;
|
|
4323
|
+
}
|
|
4324
|
+
const fov = integer2(read.attribute(camera, "fov"));
|
|
4325
|
+
if (fov !== void 0 && fov >= 0 && fov <= 108e5) out.cameraFieldOfView = fov;
|
|
4326
|
+
const zoom = picturePercentage(read.attribute(camera, "zoom"));
|
|
4327
|
+
if (zoom !== void 0 && zoom > 0) out.cameraZoom = zoom;
|
|
4328
|
+
for (const [prefix, source] of [
|
|
4329
|
+
["camera", camera],
|
|
4330
|
+
["lightRig", light]
|
|
4331
|
+
]) {
|
|
4332
|
+
const rot = read.child(source, "rot");
|
|
4333
|
+
for (const [axis, key] of [
|
|
4334
|
+
["lat", "RotX"],
|
|
4335
|
+
["lon", "RotY"],
|
|
4336
|
+
["rev", "RotZ"]
|
|
4337
|
+
]) {
|
|
4338
|
+
const value = integer2(read.attribute(rot, axis));
|
|
4339
|
+
if (value !== void 0 && value >= 0 && value < 216e5) out[`${prefix}${key}`] = value;
|
|
4340
|
+
}
|
|
4341
|
+
}
|
|
4342
|
+
const backdrop = read.child(node, "backdrop");
|
|
4343
|
+
if (backdrop !== void 0) {
|
|
4344
|
+
out.hasBackdrop = true;
|
|
4345
|
+
for (const [name, prefix, attr2] of [
|
|
4346
|
+
["anchor", "backdropAnchor", ""],
|
|
4347
|
+
["norm", "backdropNormal", "d"],
|
|
4348
|
+
["up", "backdropUp", "d"]
|
|
4349
|
+
]) {
|
|
4350
|
+
const point = read.child(backdrop, name);
|
|
4351
|
+
for (const [axis, suffix] of [
|
|
4352
|
+
["x", "X"],
|
|
4353
|
+
["y", "Y"],
|
|
4354
|
+
["z", "Z"]
|
|
4355
|
+
]) {
|
|
4356
|
+
const value = integer2(read.attribute(point, `${attr2}${axis}`));
|
|
4357
|
+
if (value !== void 0) out[`${prefix}${suffix}`] = value;
|
|
4358
|
+
}
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
return out;
|
|
4362
|
+
}
|
|
4363
|
+
function readText3DValues(node, read) {
|
|
4364
|
+
const out = {};
|
|
4365
|
+
for (const [key, attribute] of [
|
|
4366
|
+
["extrusionHeight", "extrusionH"],
|
|
4367
|
+
["contourWidth", "contourW"],
|
|
4368
|
+
["z", "z"]
|
|
4369
|
+
]) {
|
|
4370
|
+
const value = integer2(read.attribute(node, attribute));
|
|
4371
|
+
if (value !== void 0) out[key] = value;
|
|
4372
|
+
}
|
|
4373
|
+
const material = String(read.attribute(node, "prstMaterial") ?? "").trim();
|
|
4374
|
+
if (material) out.presetMaterial = material;
|
|
4375
|
+
for (const [name, prefix] of [
|
|
4376
|
+
["bevelT", "bevelTop"],
|
|
4377
|
+
["bevelB", "bevelBottom"]
|
|
4378
|
+
]) {
|
|
4379
|
+
const bevel2 = read.child(node, name);
|
|
4380
|
+
if (!bevel2) continue;
|
|
4381
|
+
out[`${prefix}Type`] = String(read.attribute(bevel2, "prst") || "circle").trim();
|
|
4382
|
+
for (const [attribute, suffix] of [
|
|
4383
|
+
["w", "Width"],
|
|
4384
|
+
["h", "Height"]
|
|
4385
|
+
]) {
|
|
4386
|
+
const value = integer2(read.attribute(bevel2, attribute));
|
|
4387
|
+
if (value !== void 0) out[`${prefix}${suffix}`] = value;
|
|
4388
|
+
}
|
|
4389
|
+
}
|
|
4390
|
+
return out;
|
|
4391
|
+
}
|
|
4392
|
+
|
|
4393
|
+
// drawingml/read-text-3d.ts
|
|
4394
|
+
var DOM_3D_READER = {
|
|
4395
|
+
attribute: (node, name) => node?.getAttribute(name),
|
|
4396
|
+
child: (node, name) => first(node, name, NS.a)
|
|
4397
|
+
};
|
|
4398
|
+
function parseDrawingTextScene3D(node) {
|
|
4399
|
+
return { ...readScene3DValues(node, DOM_3D_READER), sourceXml: buildXml(node) };
|
|
4400
|
+
}
|
|
4401
|
+
function parseDrawingTextShape3D(node) {
|
|
4402
|
+
const extrusionColor = parseDrawingColorIn(first(node, "extrusionClr", NS.a));
|
|
4403
|
+
const contourColor = parseDrawingColorIn(first(node, "contourClr", NS.a));
|
|
4404
|
+
return {
|
|
4405
|
+
...readText3DValues(node, DOM_3D_READER),
|
|
4406
|
+
sourceXml: buildXml(node),
|
|
4407
|
+
...extrusionColor ? { extrusionColor } : {},
|
|
4408
|
+
...contourColor ? { contourColor } : {}
|
|
4409
|
+
};
|
|
4410
|
+
}
|
|
4411
|
+
function parseDrawingFlatText3D(node) {
|
|
4412
|
+
const raw = node.getAttribute("z");
|
|
4413
|
+
const z = raw === null || !raw.trim() ? NaN : Number(raw);
|
|
4414
|
+
return { sourceXml: buildXml(node), ...Number.isSafeInteger(z) ? { z } : {} };
|
|
4415
|
+
}
|
|
4416
|
+
|
|
4417
|
+
// drawingml/read-text-body.ts
|
|
4418
|
+
var BODY_STRINGS = [
|
|
4419
|
+
["verticalOverflow", "vertOverflow"],
|
|
4420
|
+
["horizontalOverflow", "horzOverflow"],
|
|
4421
|
+
["vertical", "vert"],
|
|
4422
|
+
["wrap", "wrap"],
|
|
4423
|
+
["anchor", "anchor"]
|
|
4424
|
+
];
|
|
4425
|
+
var BODY_INTEGERS = [
|
|
4426
|
+
["insetLeftEmu", "lIns"],
|
|
4427
|
+
["insetTopEmu", "tIns"],
|
|
4428
|
+
["insetRightEmu", "rIns"],
|
|
4429
|
+
["insetBottomEmu", "bIns"],
|
|
4430
|
+
["columnCount", "numCol"],
|
|
4431
|
+
["columnSpacingEmu", "spcCol"]
|
|
4432
|
+
];
|
|
4433
|
+
var BODY_BOOLEANS = [
|
|
4434
|
+
["spaceFirstLastParagraph", "spcFirstLastPara"],
|
|
4435
|
+
["rightToLeftColumns", "rtlCol"],
|
|
4436
|
+
["fromWordArt", "fromWordArt"],
|
|
4437
|
+
["anchorCenter", "anchorCtr"],
|
|
4438
|
+
["forceAntiAlias", "forceAA"],
|
|
4439
|
+
["upright", "upright"],
|
|
4440
|
+
["compatibleLineSpacing", "compatLnSpc"]
|
|
4441
|
+
];
|
|
4442
|
+
function parseDrawingBodyProperties(element3) {
|
|
4443
|
+
if (!element3) return void 0;
|
|
4444
|
+
const out = {};
|
|
4445
|
+
const rotation = integerAttribute(element3, "rot");
|
|
4446
|
+
if (rotation !== void 0) out.rotation = rotation / 6e4;
|
|
3922
4447
|
for (const [key, name] of BODY_STRINGS) {
|
|
3923
4448
|
const value = stringAttribute(element3, name);
|
|
3924
4449
|
if (value) out[key] = value;
|
|
@@ -3945,7 +4470,13 @@ function parseDrawingBodyProperties(element3) {
|
|
|
3945
4470
|
...read("fontScale") !== void 0 && fontScale !== void 0 ? { fontScale } : {},
|
|
3946
4471
|
...read("lnSpcReduction") !== void 0 && reduction !== void 0 ? { lineSpacingReduction: reduction } : {}
|
|
3947
4472
|
};
|
|
3948
|
-
} else
|
|
4473
|
+
} else if (name === "scene3d" && children(element3, "scene3d", NS.a).length === 1)
|
|
4474
|
+
out.scene3d = parseDrawingTextScene3D(child3);
|
|
4475
|
+
else if (name === "sp3d" && children(element3, "sp3d", NS.a).length === 1 && !first(element3, "flatTx", NS.a))
|
|
4476
|
+
out.shape3d = parseDrawingTextShape3D(child3);
|
|
4477
|
+
else if (name === "flatTx" && children(element3, "flatTx", NS.a).length === 1 && !first(element3, "sp3d", NS.a))
|
|
4478
|
+
out.flatText3d = parseDrawingFlatText3D(child3);
|
|
4479
|
+
else extra.push(outerXml(child3));
|
|
3949
4480
|
}
|
|
3950
4481
|
if (extra.length) out.extraXml = extra;
|
|
3951
4482
|
return out;
|
|
@@ -3972,15 +4503,15 @@ function readItem(child3) {
|
|
|
3972
4503
|
const name = isDrawingElement(child3) ? child3.localName : "";
|
|
3973
4504
|
if (name === "pPr" || name === "endParaRPr") return void 0;
|
|
3974
4505
|
if (name === "r") {
|
|
3975
|
-
const
|
|
3976
|
-
return { kind: "run", text: textOf(child3), ...
|
|
4506
|
+
const properties3 = parseDrawingRunProperties(first(child3, "rPr", NS.a));
|
|
4507
|
+
return { kind: "run", text: textOf(child3), ...properties3 ? { properties: properties3 } : {} };
|
|
3977
4508
|
}
|
|
3978
4509
|
if (name === "br") {
|
|
3979
|
-
const
|
|
3980
|
-
return { kind: "break", ...
|
|
4510
|
+
const properties3 = parseDrawingRunProperties(first(child3, "rPr", NS.a));
|
|
4511
|
+
return { kind: "break", ...properties3 ? { properties: properties3 } : {} };
|
|
3981
4512
|
}
|
|
3982
4513
|
if (name === "fld") {
|
|
3983
|
-
const
|
|
4514
|
+
const properties3 = parseDrawingRunProperties(first(child3, "rPr", NS.a));
|
|
3984
4515
|
const paragraphProperties2 = parseDrawingParagraphProperties(first(child3, "pPr", NS.a));
|
|
3985
4516
|
const type = child3.getAttribute("type");
|
|
3986
4517
|
return {
|
|
@@ -3988,7 +4519,7 @@ function readItem(child3) {
|
|
|
3988
4519
|
id: child3.getAttribute("id") ?? "",
|
|
3989
4520
|
...type ? { type } : {},
|
|
3990
4521
|
text: textOf(child3),
|
|
3991
|
-
...
|
|
4522
|
+
...properties3 ? { properties: properties3 } : {},
|
|
3992
4523
|
...paragraphProperties2 ? { paragraphProperties: paragraphProperties2 } : {}
|
|
3993
4524
|
};
|
|
3994
4525
|
}
|
|
@@ -4000,10 +4531,10 @@ function parseDrawingParagraph(element3) {
|
|
|
4000
4531
|
const item2 = readItem(child3);
|
|
4001
4532
|
if (item2) items.push(item2);
|
|
4002
4533
|
}
|
|
4003
|
-
const
|
|
4534
|
+
const properties3 = parseDrawingParagraphProperties(first(element3, "pPr", NS.a));
|
|
4004
4535
|
const endProperties = parseDrawingRunProperties(first(element3, "endParaRPr", NS.a));
|
|
4005
4536
|
return {
|
|
4006
|
-
...
|
|
4537
|
+
...properties3 ? { properties: properties3 } : {},
|
|
4007
4538
|
items,
|
|
4008
4539
|
...endProperties ? { endProperties } : {}
|
|
4009
4540
|
};
|
|
@@ -4025,194 +4556,6 @@ function keptChildName(xml) {
|
|
|
4025
4556
|
return match?.[1] ?? "";
|
|
4026
4557
|
}
|
|
4027
4558
|
|
|
4028
|
-
// geometry/guide-formula-eval.ts
|
|
4029
|
-
var ANGLE_SCALE = 6e4;
|
|
4030
|
-
function angleToRadians(ooxmlAngle) {
|
|
4031
|
-
return ooxmlAngle / ANGLE_SCALE * (Math.PI / 180);
|
|
4032
|
-
}
|
|
4033
|
-
function parseFormula(fmla) {
|
|
4034
|
-
const parts = fmla.trim().split(/\s+/);
|
|
4035
|
-
const op = parts[0] ?? "";
|
|
4036
|
-
const args = parts.slice(1);
|
|
4037
|
-
return { op, args };
|
|
4038
|
-
}
|
|
4039
|
-
function resolveOperand(token, variables) {
|
|
4040
|
-
const num2 = Number(token);
|
|
4041
|
-
if (Number.isFinite(num2)) {
|
|
4042
|
-
return num2;
|
|
4043
|
-
}
|
|
4044
|
-
const value = variables.get(token);
|
|
4045
|
-
if (value !== void 0) {
|
|
4046
|
-
return value;
|
|
4047
|
-
}
|
|
4048
|
-
return 0;
|
|
4049
|
-
}
|
|
4050
|
-
function evaluateFormula(parsed, vars) {
|
|
4051
|
-
const r = (idx) => resolveOperand(parsed.args[idx] ?? "0", vars);
|
|
4052
|
-
switch (parsed.op) {
|
|
4053
|
-
// val x — literal value
|
|
4054
|
-
case "val":
|
|
4055
|
-
return r(0);
|
|
4056
|
-
// abs x — absolute value
|
|
4057
|
-
case "abs":
|
|
4058
|
-
return Math.abs(r(0));
|
|
4059
|
-
// sqrt x — square root
|
|
4060
|
-
case "sqrt":
|
|
4061
|
-
return Math.sqrt(Math.max(r(0), 0));
|
|
4062
|
-
// +- x y z — x + y - z
|
|
4063
|
-
case "+-":
|
|
4064
|
-
return r(0) + r(1) - r(2);
|
|
4065
|
-
// */ x y z — (x * y) / z
|
|
4066
|
-
case "*/": {
|
|
4067
|
-
const z = r(2);
|
|
4068
|
-
if (z === 0) {
|
|
4069
|
-
return 0;
|
|
4070
|
-
}
|
|
4071
|
-
return r(0) * r(1) / z;
|
|
4072
|
-
}
|
|
4073
|
-
// +/ x y z — (x + y) / z
|
|
4074
|
-
case "+/": {
|
|
4075
|
-
const z = r(2);
|
|
4076
|
-
if (z === 0) {
|
|
4077
|
-
return 0;
|
|
4078
|
-
}
|
|
4079
|
-
return (r(0) + r(1)) / z;
|
|
4080
|
-
}
|
|
4081
|
-
// ?: x y z — if x > 0 then y else z
|
|
4082
|
-
case "?:":
|
|
4083
|
-
case "if":
|
|
4084
|
-
return r(0) > 0 ? r(1) : r(2);
|
|
4085
|
-
// min x y — minimum
|
|
4086
|
-
case "min":
|
|
4087
|
-
return Math.min(r(0), r(1));
|
|
4088
|
-
// max x y — maximum
|
|
4089
|
-
case "max":
|
|
4090
|
-
return Math.max(r(0), r(1));
|
|
4091
|
-
// mod x y z — sqrt(x² + y² + z²)
|
|
4092
|
-
case "mod": {
|
|
4093
|
-
const a = r(0);
|
|
4094
|
-
const b = r(1);
|
|
4095
|
-
const c = r(2);
|
|
4096
|
-
return Math.sqrt(a * a + b * b + c * c);
|
|
4097
|
-
}
|
|
4098
|
-
// pin x y z — clamp y between x and z
|
|
4099
|
-
case "pin": {
|
|
4100
|
-
const lo = r(0);
|
|
4101
|
-
const val = r(1);
|
|
4102
|
-
const hi = r(2);
|
|
4103
|
-
return Math.max(lo, Math.min(val, hi));
|
|
4104
|
-
}
|
|
4105
|
-
// sin x y — x * sin(y) where y is in OOXML angle units
|
|
4106
|
-
case "sin": {
|
|
4107
|
-
const sinVal = Math.sin(angleToRadians(r(1)));
|
|
4108
|
-
if (!Number.isFinite(sinVal)) {
|
|
4109
|
-
return 0;
|
|
4110
|
-
}
|
|
4111
|
-
return r(0) * sinVal;
|
|
4112
|
-
}
|
|
4113
|
-
// cos x y — x * cos(y) where y is in OOXML angle units
|
|
4114
|
-
case "cos": {
|
|
4115
|
-
const cosVal = Math.cos(angleToRadians(r(1)));
|
|
4116
|
-
if (!Number.isFinite(cosVal)) {
|
|
4117
|
-
return 0;
|
|
4118
|
-
}
|
|
4119
|
-
return r(0) * cosVal;
|
|
4120
|
-
}
|
|
4121
|
-
// tan x y — x * tan(y) where y is in OOXML angle units
|
|
4122
|
-
case "tan": {
|
|
4123
|
-
const angle = angleToRadians(r(1));
|
|
4124
|
-
const tanVal = Math.tan(angle);
|
|
4125
|
-
if (!Number.isFinite(tanVal)) {
|
|
4126
|
-
return 0;
|
|
4127
|
-
}
|
|
4128
|
-
return r(0) * tanVal;
|
|
4129
|
-
}
|
|
4130
|
-
// atan x — atan(x) result in OOXML angle units
|
|
4131
|
-
// x is a ratio scaled by the shape coordinate space
|
|
4132
|
-
case "atan": {
|
|
4133
|
-
const radians = Math.atan(r(0));
|
|
4134
|
-
return radians * 180 * ANGLE_SCALE / Math.PI;
|
|
4135
|
-
}
|
|
4136
|
-
// at2 x y -> arctan(y / x), i.e. Math.atan2(y, x), result in OOXML angle
|
|
4137
|
-
// units. ECMA-376 / ISO-IEC-29500-1 section 20.1.9.6 defines the operand
|
|
4138
|
-
// order as (x, y) with the ARGUMENTS REVERSED relative to Math.atan2, so
|
|
4139
|
-
// the first operand is the horizontal component and the second is the
|
|
4140
|
-
// vertical one. This matches the companion `cat2`/`sat2` operators below,
|
|
4141
|
-
// which take (x, y, z) and compute atan2(z, y).
|
|
4142
|
-
case "at2":
|
|
4143
|
-
case "atan2": {
|
|
4144
|
-
const radians = Math.atan2(r(1), r(0));
|
|
4145
|
-
return radians * 180 * ANGLE_SCALE / Math.PI;
|
|
4146
|
-
}
|
|
4147
|
-
// cat2 x y z — x * cos(atan2(z, y))
|
|
4148
|
-
// Computes the cosine-component of a vector scaled by x
|
|
4149
|
-
case "cat2": {
|
|
4150
|
-
const angle = Math.atan2(r(2), r(1));
|
|
4151
|
-
return r(0) * Math.cos(angle);
|
|
4152
|
-
}
|
|
4153
|
-
// sat2 x y z — x * sin(atan2(z, y))
|
|
4154
|
-
// Computes the sine-component of a vector scaled by x
|
|
4155
|
-
case "sat2": {
|
|
4156
|
-
const angle = Math.atan2(r(2), r(1));
|
|
4157
|
-
return r(0) * Math.sin(angle);
|
|
4158
|
-
}
|
|
4159
|
-
default:
|
|
4160
|
-
return Number(parsed.op) || 0;
|
|
4161
|
-
}
|
|
4162
|
-
}
|
|
4163
|
-
|
|
4164
|
-
// geometry/guide-formula-api.ts
|
|
4165
|
-
function createBuiltinVariables(ctx) {
|
|
4166
|
-
const { w, h } = ctx;
|
|
4167
|
-
const vars = /* @__PURE__ */ new Map();
|
|
4168
|
-
vars.set("w", w);
|
|
4169
|
-
vars.set("h", h);
|
|
4170
|
-
vars.set("l", 0);
|
|
4171
|
-
vars.set("t", 0);
|
|
4172
|
-
vars.set("r", w);
|
|
4173
|
-
vars.set("b", h);
|
|
4174
|
-
vars.set("hc", w / 2);
|
|
4175
|
-
vars.set("vc", h / 2);
|
|
4176
|
-
const widthDivisors = [2, 3, 4, 5, 6, 8, 10, 12, 16, 32];
|
|
4177
|
-
for (const d of widthDivisors) {
|
|
4178
|
-
vars.set(`wd${d}`, w / d);
|
|
4179
|
-
}
|
|
4180
|
-
const heightDivisors = [2, 3, 4, 5, 6, 8, 10, 12, 16, 32];
|
|
4181
|
-
for (const d of heightDivisors) {
|
|
4182
|
-
vars.set(`hd${d}`, h / d);
|
|
4183
|
-
}
|
|
4184
|
-
const ss = Math.min(w, h);
|
|
4185
|
-
const ls = Math.max(w, h);
|
|
4186
|
-
vars.set("ss", ss);
|
|
4187
|
-
vars.set("ls", ls);
|
|
4188
|
-
const ssDivisors = [2, 4, 6, 8, 16, 32];
|
|
4189
|
-
for (const d of ssDivisors) {
|
|
4190
|
-
vars.set(`ssd${d}`, ss / d);
|
|
4191
|
-
}
|
|
4192
|
-
vars.set("cd2", 180 * ANGLE_SCALE);
|
|
4193
|
-
vars.set("cd4", 90 * ANGLE_SCALE);
|
|
4194
|
-
vars.set("cd8", 45 * ANGLE_SCALE);
|
|
4195
|
-
vars.set("3cd4", 270 * ANGLE_SCALE);
|
|
4196
|
-
vars.set("3cd8", 135 * ANGLE_SCALE);
|
|
4197
|
-
vars.set("5cd8", 225 * ANGLE_SCALE);
|
|
4198
|
-
vars.set("7cd8", 315 * ANGLE_SCALE);
|
|
4199
|
-
return vars;
|
|
4200
|
-
}
|
|
4201
|
-
function evaluateGuides(guides, ctx, adjustments) {
|
|
4202
|
-
const vars = createBuiltinVariables(ctx);
|
|
4203
|
-
if (adjustments) {
|
|
4204
|
-
for (const [name, value] of adjustments) {
|
|
4205
|
-
vars.set(name, value);
|
|
4206
|
-
}
|
|
4207
|
-
}
|
|
4208
|
-
for (const guide of guides) {
|
|
4209
|
-
const parsed = parseFormula(guide.formula);
|
|
4210
|
-
const value = evaluateFormula(parsed, vars);
|
|
4211
|
-
vars.set(guide.name, Number.isFinite(value) ? value : 0);
|
|
4212
|
-
}
|
|
4213
|
-
return vars;
|
|
4214
|
-
}
|
|
4215
|
-
|
|
4216
4559
|
// geometry/ooxml-arc.ts
|
|
4217
4560
|
function ooxmlArcToSvg(wR, hR, stAng, swAng, penX, penY) {
|
|
4218
4561
|
if (![wR, hR, stAng, swAng, penX, penY].every(Number.isFinite) || wR <= 0 || hR <= 0 || swAng === 0) {
|
|
@@ -15515,10 +15858,10 @@ function textBoxAt(node, boxW, boxH) {
|
|
|
15515
15858
|
const upright = (node.alg.params.autoTxRot ?? "upr") === "upr";
|
|
15516
15859
|
return sideways && upright ? { w: th, h: tw } : { w: tw, h: th };
|
|
15517
15860
|
}
|
|
15518
|
-
var
|
|
15861
|
+
var SIDES2 = ["lMarg", "rMarg", "tMarg", "bMarg"];
|
|
15519
15862
|
function nodeMarginsPt(node, sizePt, refSize) {
|
|
15520
15863
|
const out = { lMarg: 0, rMarg: 0, tMarg: 0, bMarg: 0 };
|
|
15521
|
-
for (const side of
|
|
15864
|
+
for (const side of SIDES2) {
|
|
15522
15865
|
const deferred = node.deferred.find((d) => d.type === side && FONT_TYPES.has(d.refType));
|
|
15523
15866
|
if (deferred) {
|
|
15524
15867
|
const base = deferred.ref === node ? sizePt : refSize?.(deferred.ref) ?? sizePt;
|
|
@@ -16734,7 +17077,7 @@ function measureHierRoot(root) {
|
|
|
16734
17077
|
const { side, align } = parseHierAlign(root.alg.params.hierAlign);
|
|
16735
17078
|
const vertical = side === "t" || side === "b";
|
|
16736
17079
|
const assistantRows = side === "t" ? rowNodes.filter((row) => isAssistantRow(row, itemsOf(row))) : [];
|
|
16737
|
-
const
|
|
17080
|
+
const rows2 = rowNodes.filter((row) => !assistantRows.includes(row));
|
|
16738
17081
|
let top = size.h + sp;
|
|
16739
17082
|
const centre = size.dx + size.partW / 2;
|
|
16740
17083
|
const assistants = [];
|
|
@@ -16749,26 +17092,26 @@ function measureHierRoot(root) {
|
|
|
16749
17092
|
assistants.push(...band.rects);
|
|
16750
17093
|
top = band.bottom + sp;
|
|
16751
17094
|
}
|
|
16752
|
-
if (
|
|
17095
|
+
if (rows2.length === 0) {
|
|
16753
17096
|
return { rects: [...own2, ...assistants], head };
|
|
16754
17097
|
}
|
|
16755
|
-
if (side === "t" &&
|
|
17098
|
+
if (side === "t" && rows2.every(isTwoColumnRow)) {
|
|
16756
17099
|
const hung = placeTwoColumns(
|
|
16757
|
-
|
|
17100
|
+
rows2.flatMap((row) => itemsOf(row).map(measureHierRoot)),
|
|
16758
17101
|
centre,
|
|
16759
17102
|
top,
|
|
16760
|
-
Math.max(0,
|
|
17103
|
+
Math.max(0, rows2[0].values.get("sibSp") ?? 0),
|
|
16761
17104
|
sp
|
|
16762
17105
|
);
|
|
16763
17106
|
return { rects: [...own2, ...assistants, ...hung.rects], head };
|
|
16764
17107
|
}
|
|
16765
|
-
const group2 = pack(
|
|
17108
|
+
const group2 = pack(rows2.map(measureHierChild), vertical, sp, false);
|
|
16766
17109
|
const groupBounds = boundsOf(group2.rects);
|
|
16767
17110
|
let placed;
|
|
16768
17111
|
if (vertical) {
|
|
16769
17112
|
const dy = side === "t" ? top - groupBounds.y : -sp - (groupBounds.y + groupBounds.h);
|
|
16770
17113
|
let dx = alignShift(head, group2.head, align, true);
|
|
16771
|
-
if (side === "t" && align !== "center" &&
|
|
17114
|
+
if (side === "t" && align !== "center" && rows2.every(isColumn)) {
|
|
16772
17115
|
const inset = hangInset(root) * size.w;
|
|
16773
17116
|
dx = align === "start" ? head.x + inset - group2.head.x : head.x + head.w - inset - (group2.head.x + group2.head.w);
|
|
16774
17117
|
}
|
|
@@ -18645,11 +18988,11 @@ function reflowBending(nodes, bounds) {
|
|
|
18645
18988
|
const COLS = 4;
|
|
18646
18989
|
const padding = 8;
|
|
18647
18990
|
const gap = 6;
|
|
18648
|
-
const
|
|
18991
|
+
const rows2 = Math.ceil(nodes.length / COLS);
|
|
18649
18992
|
const usableW = bounds.width - padding * 2;
|
|
18650
18993
|
const usableH = bounds.height - padding * 2;
|
|
18651
18994
|
const cellW = (usableW - gap * (COLS - 1)) / COLS;
|
|
18652
|
-
const cellH = (usableH - gap * (
|
|
18995
|
+
const cellH = (usableH - gap * (rows2 - 1)) / Math.max(rows2, 1);
|
|
18653
18996
|
const boxW = cellW * 0.85;
|
|
18654
18997
|
const boxH = Math.min(cellH * 0.7, 40);
|
|
18655
18998
|
const shapes = [];
|
|
@@ -18732,13 +19075,13 @@ function reflowCycle(nodes, bounds) {
|
|
|
18732
19075
|
}
|
|
18733
19076
|
function reflowMatrix(nodes, bounds) {
|
|
18734
19077
|
const cols = Math.ceil(Math.sqrt(nodes.length));
|
|
18735
|
-
const
|
|
19078
|
+
const rows2 = Math.ceil(nodes.length / cols);
|
|
18736
19079
|
const padding = 8;
|
|
18737
19080
|
const gap = 6;
|
|
18738
19081
|
const usableW = bounds.width - padding * 2;
|
|
18739
19082
|
const usableH = bounds.height - padding * 2;
|
|
18740
19083
|
const cellW = (usableW - gap * (cols - 1)) / cols;
|
|
18741
|
-
const cellH = (usableH - gap * (
|
|
19084
|
+
const cellH = (usableH - gap * (rows2 - 1)) / rows2;
|
|
18742
19085
|
return nodes.map((node, i) => {
|
|
18743
19086
|
const col = i % cols;
|
|
18744
19087
|
const row = Math.floor(i / cols);
|
|
@@ -19210,9 +19553,9 @@ function parsePoint(element3) {
|
|
|
19210
19553
|
text: paragraphs.join("\n"),
|
|
19211
19554
|
...textParagraphs2 ? { textParagraphs: textParagraphs2 } : {}
|
|
19212
19555
|
};
|
|
19213
|
-
const
|
|
19214
|
-
const fill = parseDrawingFill(
|
|
19215
|
-
const line3 = parseDrawingLine(first(
|
|
19556
|
+
const properties3 = first(element3, "spPr", NS.dgm);
|
|
19557
|
+
const fill = parseDrawingFill(properties3);
|
|
19558
|
+
const line3 = parseDrawingLine(first(properties3, "ln", NS.a));
|
|
19216
19559
|
if (fill) point.fill = fill;
|
|
19217
19560
|
if (line3) point.line = line3;
|
|
19218
19561
|
const optional = [
|
|
@@ -19453,15 +19796,15 @@ function diagramPreviewText(nodes, fontSize) {
|
|
|
19453
19796
|
paragraphs.push(paragraph);
|
|
19454
19797
|
continue;
|
|
19455
19798
|
}
|
|
19456
|
-
const
|
|
19799
|
+
const properties3 = segment2.style.run;
|
|
19457
19800
|
const run = {
|
|
19458
19801
|
text: segment2.text,
|
|
19459
|
-
sizePt:
|
|
19460
|
-
...
|
|
19461
|
-
...
|
|
19462
|
-
...
|
|
19463
|
-
...
|
|
19464
|
-
...
|
|
19802
|
+
sizePt: properties3.sizePt ?? fontSize * 0.75,
|
|
19803
|
+
...properties3.bold !== void 0 ? { bold: properties3.bold } : {},
|
|
19804
|
+
...properties3.italic !== void 0 ? { italic: properties3.italic } : {},
|
|
19805
|
+
...properties3.underline ? { underline: properties3.underline !== "none" } : {},
|
|
19806
|
+
...properties3.fill?.kind === "solid" ? { color: properties3.fill.color } : {},
|
|
19807
|
+
...properties3.latin?.typeface ? { typeface: properties3.latin.typeface } : {}
|
|
19465
19808
|
};
|
|
19466
19809
|
const align = segment2.style.paragraph.align;
|
|
19467
19810
|
if (align) paragraph.align = align;
|
|
@@ -19810,17 +20153,47 @@ function groupRowsByCategory(rawCategories) {
|
|
|
19810
20153
|
const rowIndexesByCategory = /* @__PURE__ */ new Map();
|
|
19811
20154
|
rawCategories.forEach((rawLabel, rowIndex) => {
|
|
19812
20155
|
const label = rawLabel ?? "";
|
|
19813
|
-
let
|
|
19814
|
-
if (!
|
|
19815
|
-
|
|
19816
|
-
rowIndexesByCategory.set(label,
|
|
20156
|
+
let rows2 = rowIndexesByCategory.get(label);
|
|
20157
|
+
if (!rows2) {
|
|
20158
|
+
rows2 = [];
|
|
20159
|
+
rowIndexesByCategory.set(label, rows2);
|
|
19817
20160
|
uniqueCategories.push(label);
|
|
19818
20161
|
}
|
|
19819
|
-
|
|
20162
|
+
rows2.push(rowIndex);
|
|
19820
20163
|
});
|
|
19821
20164
|
return { uniqueCategories, rowIndexesByCategory };
|
|
19822
20165
|
}
|
|
19823
|
-
|
|
20166
|
+
function percentile(sorted, p, method) {
|
|
20167
|
+
const rank2 = method === "inclusive" ? (sorted.length - 1) * p : (sorted.length + 1) * p - 1;
|
|
20168
|
+
const clamped = Math.max(0, Math.min(rank2, sorted.length - 1));
|
|
20169
|
+
const lower = Math.floor(clamped);
|
|
20170
|
+
const upper = Math.ceil(clamped);
|
|
20171
|
+
const fraction = clamped - lower;
|
|
20172
|
+
return sorted[lower] + (sorted[upper] - sorted[lower]) * fraction;
|
|
20173
|
+
}
|
|
20174
|
+
function computeBoxStats(values, method) {
|
|
20175
|
+
if (values.length < 2) {
|
|
20176
|
+
return void 0;
|
|
20177
|
+
}
|
|
20178
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
20179
|
+
if (!method) {
|
|
20180
|
+
return {
|
|
20181
|
+
min: sorted[0],
|
|
20182
|
+
q1: sorted[Math.floor(sorted.length * 0.25)],
|
|
20183
|
+
median: sorted[Math.floor(sorted.length * 0.5)],
|
|
20184
|
+
q3: sorted[Math.floor(sorted.length * 0.75)],
|
|
20185
|
+
max: sorted[sorted.length - 1]
|
|
20186
|
+
};
|
|
20187
|
+
}
|
|
20188
|
+
return {
|
|
20189
|
+
min: sorted[0],
|
|
20190
|
+
q1: percentile(sorted, 0.25, method),
|
|
20191
|
+
median: percentile(sorted, 0.5, method),
|
|
20192
|
+
q3: percentile(sorted, 0.75, method),
|
|
20193
|
+
max: sorted[sorted.length - 1]
|
|
20194
|
+
};
|
|
20195
|
+
}
|
|
20196
|
+
|
|
19824
20197
|
// chart/number-format-pattern.ts
|
|
19825
20198
|
var NAMED_FORMAT_COLORS = {
|
|
19826
20199
|
black: "#000000",
|
|
@@ -20515,11 +20888,11 @@ function computeHistogramBins(values, options2, format = String) {
|
|
|
20515
20888
|
function aggregateByCategory(values, rawCategories) {
|
|
20516
20889
|
const { uniqueCategories, rowIndexesByCategory } = groupRowsByCategory(rawCategories);
|
|
20517
20890
|
return uniqueCategories.map((label) => {
|
|
20518
|
-
const
|
|
20891
|
+
const rows2 = rowIndexesByCategory.get(label) ?? [];
|
|
20519
20892
|
return {
|
|
20520
|
-
value:
|
|
20893
|
+
value: rows2.reduce((sum, row) => sum + (values[row] ?? 0), 0),
|
|
20521
20894
|
label,
|
|
20522
|
-
sourceIndices:
|
|
20895
|
+
sourceIndices: rows2
|
|
20523
20896
|
};
|
|
20524
20897
|
});
|
|
20525
20898
|
}
|
|
@@ -20771,6 +21144,62 @@ function placeBestFitLabel(slice, w, h) {
|
|
|
20771
21144
|
return { x: slice.cx + outside * ux, y: slice.cy + outside * uy, inside: false };
|
|
20772
21145
|
}
|
|
20773
21146
|
|
|
21147
|
+
// chart/pie-label-collision.ts
|
|
21148
|
+
var LABEL_COLLISION_GAP = 2;
|
|
21149
|
+
function boxDistanceToCentre(box, y, disc) {
|
|
21150
|
+
const nearestX = Math.max(box.x - box.w / 2, Math.min(disc.cx, box.x + box.w / 2));
|
|
21151
|
+
const nearestY = Math.max(y - box.h / 2, Math.min(disc.cy, y + box.h / 2));
|
|
21152
|
+
return Math.hypot(nearestX - disc.cx, nearestY - disc.cy);
|
|
21153
|
+
}
|
|
21154
|
+
function clearOfDisc(box, y, disc) {
|
|
21155
|
+
if (boxDistanceToCentre(box, y, disc) >= disc.r) {
|
|
21156
|
+
return 0;
|
|
21157
|
+
}
|
|
21158
|
+
const sign = box.x >= disc.cx ? 1 : -1;
|
|
21159
|
+
let dx = 0;
|
|
21160
|
+
while (dx < disc.r * 2 && boxDistanceToCentre({ ...box, x: box.x + sign * dx }, y, disc) < disc.r) {
|
|
21161
|
+
dx += 1;
|
|
21162
|
+
}
|
|
21163
|
+
return sign * dx;
|
|
21164
|
+
}
|
|
21165
|
+
function overlapsX(a, b) {
|
|
21166
|
+
return Math.abs(a.x - b.x) < (a.w + b.w) / 2;
|
|
21167
|
+
}
|
|
21168
|
+
function sweepSide(boxes, minY, maxY) {
|
|
21169
|
+
const sorted = [...boxes].sort((a, b) => a.y - b.y || a.id - b.id);
|
|
21170
|
+
const ys = sorted.map((box) => box.y);
|
|
21171
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
21172
|
+
const prev = sorted[i - 1];
|
|
21173
|
+
const box = sorted[i];
|
|
21174
|
+
if (overlapsX(prev, box)) {
|
|
21175
|
+
ys[i] = Math.max(ys[i], ys[i - 1] + (prev.h + box.h) / 2 + LABEL_COLLISION_GAP);
|
|
21176
|
+
}
|
|
21177
|
+
}
|
|
21178
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
21179
|
+
const box = sorted[i];
|
|
21180
|
+
const limit = i === sorted.length - 1 ? maxY - box.h / 2 : ys[i + 1] - (box.h + sorted[i + 1].h) / 2 - LABEL_COLLISION_GAP;
|
|
21181
|
+
if (ys[i] > limit) {
|
|
21182
|
+
ys[i] = Math.max(limit, minY + box.h / 2);
|
|
21183
|
+
}
|
|
21184
|
+
}
|
|
21185
|
+
return new Map(sorted.map((box, i) => [box.id, ys[i]]));
|
|
21186
|
+
}
|
|
21187
|
+
function nudgeOutsideLabels(boxes, disc, minY, maxY) {
|
|
21188
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
21189
|
+
for (const side of [
|
|
21190
|
+
boxes.filter((box) => box.x >= disc.cx),
|
|
21191
|
+
boxes.filter((box) => box.x < disc.cx)
|
|
21192
|
+
]) {
|
|
21193
|
+
for (const [id, y] of sweepSide(side, minY, maxY)) {
|
|
21194
|
+
resolved.set(id, y);
|
|
21195
|
+
}
|
|
21196
|
+
}
|
|
21197
|
+
return boxes.map((box) => {
|
|
21198
|
+
const y = resolved.get(box.id) ?? box.y;
|
|
21199
|
+
return { id: box.id, dx: y === box.y ? 0 : clearOfDisc(box, y, disc), dy: y - box.y };
|
|
21200
|
+
});
|
|
21201
|
+
}
|
|
21202
|
+
|
|
20774
21203
|
// chart/color-palettes.ts
|
|
20775
21204
|
var COLORFUL_VARIATIONS = [
|
|
20776
21205
|
{},
|
|
@@ -20932,6 +21361,20 @@ function resolveManualLayoutRect(layout, frame2, auto) {
|
|
|
20932
21361
|
const height = layout.height === void 0 ? auto.height : layout.heightMode === "edge" ? layout.height * frame2.height - y : layout.height * frame2.height;
|
|
20933
21362
|
return { x, y, width: Math.max(width, 1), height: Math.max(height, 1) };
|
|
20934
21363
|
}
|
|
21364
|
+
function resolveManualPlotRect(layout, frame2, auto, bands) {
|
|
21365
|
+
const rect3 = resolveManualLayoutRect(layout, frame2, auto);
|
|
21366
|
+
if (!rect3 || layout?.layoutTarget === "inner") return rect3;
|
|
21367
|
+
return {
|
|
21368
|
+
x: rect3.x + bands.left,
|
|
21369
|
+
y: rect3.y + bands.top,
|
|
21370
|
+
width: Math.max(1, rect3.width - bands.left - bands.right),
|
|
21371
|
+
height: Math.max(1, rect3.height - bands.top - bands.bottom)
|
|
21372
|
+
};
|
|
21373
|
+
}
|
|
21374
|
+
function applyLabelManualLayout(layout, frame2, point) {
|
|
21375
|
+
const rect3 = resolveManualLayoutRect(layout, frame2, { ...point, width: 1, height: 1 });
|
|
21376
|
+
return rect3 ? { x: rect3.x, y: rect3.y } : point;
|
|
21377
|
+
}
|
|
20935
21378
|
|
|
20936
21379
|
// chart/gradient-stop-edit.ts
|
|
20937
21380
|
function sortGradientStops(stops) {
|
|
@@ -21325,6 +21768,9 @@ function summaryAnalysis(series) {
|
|
|
21325
21768
|
// chart/render/summary-labels.ts
|
|
21326
21769
|
function level2(options2, custom) {
|
|
21327
21770
|
const out = {};
|
|
21771
|
+
if (options2.layout) out.layout = options2.layout;
|
|
21772
|
+
if (options2.showLeaderLines !== void 0) out.showLeaderLines = options2.showLeaderLines;
|
|
21773
|
+
if (options2.leaderLines?.spPr?.line) out.leaderLine = options2.leaderLines.spPr.line;
|
|
21328
21774
|
if (options2.deleted !== void 0) out.deleted = options2.deleted;
|
|
21329
21775
|
if (options2.showValue !== void 0) out.showValue = options2.showValue;
|
|
21330
21776
|
if (options2.showCategoryName !== void 0) out.showCategory = options2.showCategoryName;
|
|
@@ -21374,7 +21820,7 @@ var GROUP_TYPES = {
|
|
|
21374
21820
|
surface: "surface"
|
|
21375
21821
|
};
|
|
21376
21822
|
var GROUPINGS = /* @__PURE__ */ new Set(["clustered", "stacked", "percentStacked", "standard"]);
|
|
21377
|
-
function chartSummarySeries(source, chartType, groupLabels) {
|
|
21823
|
+
function chartSummarySeries(source, chartType, groupLabels, groupSmooth) {
|
|
21378
21824
|
const categories = source.categories ?? source.xValues;
|
|
21379
21825
|
const values = source.values ?? source.yValues;
|
|
21380
21826
|
const numeric = (v) => typeof v === "number" ? v : v === "" ? null : Number.isFinite(Number(v)) ? Number(v) : null;
|
|
@@ -21382,6 +21828,9 @@ function chartSummarySeries(source, chartType, groupLabels) {
|
|
|
21382
21828
|
categories: chartSourceValues(categories),
|
|
21383
21829
|
values: chartSourceValues(values).map(numeric)
|
|
21384
21830
|
};
|
|
21831
|
+
const smooth = source.smooth ?? groupSmooth;
|
|
21832
|
+
if (smooth !== void 0) out.smooth = smooth;
|
|
21833
|
+
if (source.spPr?.line) out.line = source.spPr.line;
|
|
21385
21834
|
if (values?.cache?.formatCode !== void 0) out.numberFormat = values.cache.formatCode;
|
|
21386
21835
|
if (source.bubbleSizes) {
|
|
21387
21836
|
out.bubbleSizes = chartSourceValues(source.bubbleSizes).map(numeric);
|
|
@@ -21402,12 +21851,12 @@ function chartSummarySeries(source, chartType, groupLabels) {
|
|
|
21402
21851
|
const points = {};
|
|
21403
21852
|
const pointFills = {};
|
|
21404
21853
|
for (const point of source.dataPoints) {
|
|
21405
|
-
const
|
|
21854
|
+
const properties3 = point.spPr ?? point.marker?.spPr;
|
|
21406
21855
|
if (point.index === void 0) continue;
|
|
21407
|
-
const pointColor = solidColor(
|
|
21856
|
+
const pointColor = solidColor(properties3?.fill);
|
|
21408
21857
|
if (pointColor) points[point.index] = pointColor;
|
|
21409
|
-
if (
|
|
21410
|
-
pointFills[point.index] =
|
|
21858
|
+
if (properties3?.fill && properties3.fill.kind !== "solid")
|
|
21859
|
+
pointFills[point.index] = properties3.fill;
|
|
21411
21860
|
}
|
|
21412
21861
|
if (Object.keys(points).length) out.pointColors = points;
|
|
21413
21862
|
if (Object.keys(pointFills).length) out.pointFills = pointFills;
|
|
@@ -21441,7 +21890,12 @@ function extraGroups(chartSpace, firstType) {
|
|
|
21441
21890
|
const entry = {
|
|
21442
21891
|
chartType: type,
|
|
21443
21892
|
series: group2.series.map((source, index) => ({
|
|
21444
|
-
...chartSummarySeries(
|
|
21893
|
+
...chartSummarySeries(
|
|
21894
|
+
source,
|
|
21895
|
+
type,
|
|
21896
|
+
group2.dataLabels,
|
|
21897
|
+
group2.smooth ?? (group2.scatterStyle ? ["smooth", "smoothMarker"].includes(group2.scatterStyle) : void 0)
|
|
21898
|
+
),
|
|
21445
21899
|
...summaryMarkers(source, group2, index)
|
|
21446
21900
|
})),
|
|
21447
21901
|
secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
|
|
@@ -21462,8 +21916,14 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
21462
21916
|
let chartType = group2 ? GROUP_TYPES[group2.kind] : "column";
|
|
21463
21917
|
if (chartType === "bar" && group2?.barDirection !== "bar") chartType = "column";
|
|
21464
21918
|
const series = (group2?.series ?? []).map((source, index) => ({
|
|
21465
|
-
...chartSummarySeries(
|
|
21466
|
-
|
|
21919
|
+
...chartSummarySeries(
|
|
21920
|
+
source,
|
|
21921
|
+
chartType,
|
|
21922
|
+
group2?.dataLabels,
|
|
21923
|
+
group2?.smooth ?? (group2?.scatterStyle ? ["smooth", "smoothMarker"].includes(group2.scatterStyle) : void 0)
|
|
21924
|
+
),
|
|
21925
|
+
...group2 ? summaryMarkers(source, group2, index) : {},
|
|
21926
|
+
...group2?.kind === "scatter" ? { showLine: !["marker", "none"].includes(group2.scatterStyle ?? "marker") } : {}
|
|
21467
21927
|
}));
|
|
21468
21928
|
const summary = {
|
|
21469
21929
|
chartType,
|
|
@@ -21472,6 +21932,9 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
21472
21932
|
axes: chartSpace.plotArea.axes,
|
|
21473
21933
|
axisIds: group2?.axisIds ?? []
|
|
21474
21934
|
};
|
|
21935
|
+
if (chartSpace.plotArea.dataTable) summary.dataTable = chartSpace.plotArea.dataTable;
|
|
21936
|
+
if (chartSpace.date1904 !== void 0) summary.date1904 = chartSpace.date1904;
|
|
21937
|
+
if (chartSpace.plotArea.layout) summary.plotLayout = chartSpace.plotArea.layout;
|
|
21475
21938
|
const combined = extraGroups(chartSpace, chartType);
|
|
21476
21939
|
if (combined.length) summary.extraGroups = combined;
|
|
21477
21940
|
if (chartType === "stock" && group2) summary.stock = stockStyle(group2);
|
|
@@ -21510,45 +21973,15 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
21510
21973
|
return summary;
|
|
21511
21974
|
}
|
|
21512
21975
|
|
|
21513
|
-
// chart/
|
|
21514
|
-
|
|
21515
|
-
|
|
21516
|
-
|
|
21517
|
-
|
|
21518
|
-
|
|
21519
|
-
|
|
21520
|
-
}
|
|
21521
|
-
|
|
21522
|
-
var textWidth = (text2, size = FONT_SIZE) => text2.length * size * 0.55;
|
|
21523
|
-
function text(x, y, content, attrs2 = {}) {
|
|
21524
|
-
const parts = [`x="${n(x)}"`, `y="${n(y)}"`];
|
|
21525
|
-
parts.push(`font-size="${attrs2.size ?? FONT_SIZE}"`);
|
|
21526
|
-
parts.push(`fill="${esc(attrs2.fill ?? TEXT_COLOR)}"`);
|
|
21527
|
-
if (attrs2.anchor && attrs2.anchor !== "start") parts.push(`text-anchor="${attrs2.anchor}"`);
|
|
21528
|
-
if (attrs2.weight) parts.push(`font-weight="${attrs2.weight}"`);
|
|
21529
|
-
if (attrs2.baseline) parts.push(`dominant-baseline="${attrs2.baseline}"`);
|
|
21530
|
-
if (attrs2.family) parts.push(`font-family="${esc(attrs2.family)}"`);
|
|
21531
|
-
if (attrs2.filter) parts.push(`filter="${esc(attrs2.filter)}"`);
|
|
21532
|
-
if (attrs2.italic !== void 0) parts.push(`font-style="${attrs2.italic ? "italic" : "normal"}"`);
|
|
21533
|
-
if (attrs2.underline !== void 0)
|
|
21534
|
-
parts.push(`text-decoration="${attrs2.underline ? "underline" : "none"}"`);
|
|
21535
|
-
return `<text ${parts.join(" ")}>${esc(content)}</text>`;
|
|
21536
|
-
}
|
|
21537
|
-
var line2 = (x1, y1, x2, y2, stroke, width = 1) => `<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" stroke="${stroke}" stroke-width="${width}"/>`;
|
|
21538
|
-
var rect2 = (x, y, w, h, fill, filter) => `<rect x="${n(x)}" y="${n(y)}" width="${n(Math.max(0, w))}" height="${n(Math.max(0, h))}" fill="${fill}"${filter ? ` filter="${esc(filter)}"` : ""}/>`;
|
|
21539
|
-
function fit(content, maxWidth, size = FONT_SIZE) {
|
|
21540
|
-
if (textWidth(content, size) <= maxWidth) return content;
|
|
21541
|
-
const chars = Math.max(1, Math.floor(maxWidth / (size * 0.55)) - 1);
|
|
21542
|
-
return `${content.slice(0, chars)}\u2026`;
|
|
21543
|
-
}
|
|
21544
|
-
|
|
21545
|
-
// chart/render/chart-spacing.ts
|
|
21546
|
-
function chartBarSpacing(chart) {
|
|
21547
|
-
const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
|
|
21548
|
-
return {
|
|
21549
|
-
barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
|
|
21550
|
-
barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
|
|
21551
|
-
};
|
|
21976
|
+
// chart/funnel-geometry.ts
|
|
21977
|
+
function computeFunnelGeometry(values, plot) {
|
|
21978
|
+
const max = Math.max(...values.map((v) => Math.abs(v)), 1);
|
|
21979
|
+
const height = plot.height / Math.max(1, values.length);
|
|
21980
|
+
const center = plot.x + plot.width / 2;
|
|
21981
|
+
return values.map((value, index) => {
|
|
21982
|
+
const width = Math.abs(value) / max * plot.width;
|
|
21983
|
+
return { index, x: center - width / 2, y: plot.y + index * height, width, height, center };
|
|
21984
|
+
});
|
|
21552
21985
|
}
|
|
21553
21986
|
|
|
21554
21987
|
// chart/render/theme-palette.ts
|
|
@@ -21691,6 +22124,38 @@ function chartAppearance(chart, theme) {
|
|
|
21691
22124
|
return out;
|
|
21692
22125
|
}
|
|
21693
22126
|
|
|
22127
|
+
// chart/render/chart-svg-util.ts
|
|
22128
|
+
var TEXT_COLOR = "#595959";
|
|
22129
|
+
var GRID_COLOR = "#D9D9D9";
|
|
22130
|
+
var AXIS_COLOR = "#BFBFBF";
|
|
22131
|
+
var FONT_SIZE = 10;
|
|
22132
|
+
function esc(text2) {
|
|
22133
|
+
return text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
22134
|
+
}
|
|
22135
|
+
var n = (value) => String(Math.round(value * 100) / 100);
|
|
22136
|
+
var textWidth = (text2, size = FONT_SIZE) => text2.length * size * 0.55;
|
|
22137
|
+
function text(x, y, content, attrs2 = {}) {
|
|
22138
|
+
const parts = [`x="${n(x)}"`, `y="${n(y)}"`];
|
|
22139
|
+
parts.push(`font-size="${attrs2.size ?? FONT_SIZE}"`);
|
|
22140
|
+
parts.push(`fill="${esc(attrs2.fill ?? TEXT_COLOR)}"`);
|
|
22141
|
+
if (attrs2.anchor && attrs2.anchor !== "start") parts.push(`text-anchor="${attrs2.anchor}"`);
|
|
22142
|
+
if (attrs2.weight) parts.push(`font-weight="${attrs2.weight}"`);
|
|
22143
|
+
if (attrs2.baseline) parts.push(`dominant-baseline="${attrs2.baseline}"`);
|
|
22144
|
+
if (attrs2.family) parts.push(`font-family="${esc(attrs2.family)}"`);
|
|
22145
|
+
if (attrs2.filter) parts.push(`filter="${esc(attrs2.filter)}"`);
|
|
22146
|
+
if (attrs2.italic !== void 0) parts.push(`font-style="${attrs2.italic ? "italic" : "normal"}"`);
|
|
22147
|
+
if (attrs2.underline !== void 0)
|
|
22148
|
+
parts.push(`text-decoration="${attrs2.underline ? "underline" : "none"}"`);
|
|
22149
|
+
return `<text ${parts.join(" ")}>${esc(content)}</text>`;
|
|
22150
|
+
}
|
|
22151
|
+
var line2 = (x1, y1, x2, y2, stroke, width = 1) => `<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" stroke="${stroke}" stroke-width="${width}"/>`;
|
|
22152
|
+
var rect2 = (x, y, w, h, fill, filter) => `<rect x="${n(x)}" y="${n(y)}" width="${n(Math.max(0, w))}" height="${n(Math.max(0, h))}" fill="${fill}"${filter ? ` filter="${esc(filter)}"` : ""}/>`;
|
|
22153
|
+
function fit(content, maxWidth, size = FONT_SIZE) {
|
|
22154
|
+
if (textWidth(content, size) <= maxWidth) return content;
|
|
22155
|
+
const chars = Math.max(1, Math.floor(maxWidth / (size * 0.55)) - 1);
|
|
22156
|
+
return `${content.slice(0, chars)}\u2026`;
|
|
22157
|
+
}
|
|
22158
|
+
|
|
21694
22159
|
// text/css-font-family.ts
|
|
21695
22160
|
var FALLBACKS = {
|
|
21696
22161
|
calibri: '"Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
|
|
@@ -21716,9 +22181,9 @@ function chartGradientPaint(model, width = 1024, height = 768) {
|
|
|
21716
22181
|
const defs = [];
|
|
21717
22182
|
const shadowPaint = (shadow, suffix) => {
|
|
21718
22183
|
const id = `${prefix}-${suffix}`;
|
|
21719
|
-
const
|
|
22184
|
+
const pad2 = Math.max(4, shadow.blur * 3 + Math.abs(shadow.dx) + Math.abs(shadow.dy));
|
|
21720
22185
|
defs.push(
|
|
21721
|
-
`<filter id="${id}" filterUnits="userSpaceOnUse" x="${n(-
|
|
22186
|
+
`<filter id="${id}" filterUnits="userSpaceOnUse" x="${n(-pad2)}" y="${n(-pad2)}" width="${n(width + pad2 * 2)}" height="${n(height + pad2 * 2)}" color-interpolation-filters="sRGB">${svgDropShadowElement(shadow, { number: n, color: (value) => esc(value) })}</filter>`
|
|
21722
22187
|
);
|
|
21723
22188
|
return `url(#${id})`;
|
|
21724
22189
|
};
|
|
@@ -21796,6 +22261,155 @@ function chartAreaRect(model, part, area) {
|
|
|
21796
22261
|
return `${defs}<rect x="${n(area.x)}" y="${n(area.y)}" width="${n(area.w)}" height="${n(area.h)}" fill="${esc(fill)}" stroke="${esc(stroke)}" stroke-width="${n(width)}" data-chart-part="${part}"/>`;
|
|
21797
22262
|
}
|
|
21798
22263
|
|
|
22264
|
+
// chart/render/chart-svg-funnel.ts
|
|
22265
|
+
function funnelSvg(model, area) {
|
|
22266
|
+
const series = model.series[0];
|
|
22267
|
+
if (!series || series.hidden) return "";
|
|
22268
|
+
const attrs2 = chartTextAttributes(model, "categoryAxis", 10);
|
|
22269
|
+
const width = Math.min(
|
|
22270
|
+
area.w * 0.3,
|
|
22271
|
+
Math.max(32, ...model.categories.map((s) => s.length * (attrs2.size ?? 10) * 0.55 + 8))
|
|
22272
|
+
);
|
|
22273
|
+
const plot = { x: area.x + width, y: area.y, width: Math.max(1, area.w - width), height: area.h };
|
|
22274
|
+
const out = [
|
|
22275
|
+
chartAreaRect(model, "plotArea", { x: plot.x, y: plot.y, w: plot.width, h: plot.height })
|
|
22276
|
+
];
|
|
22277
|
+
for (const bar of computeFunnelGeometry(
|
|
22278
|
+
series.values.map((v) => v ?? 0),
|
|
22279
|
+
plot
|
|
22280
|
+
)) {
|
|
22281
|
+
const value = series.values[bar.index];
|
|
22282
|
+
if (value === null || value === void 0) continue;
|
|
22283
|
+
out.push(`<g data-chart-series="${series.sourceIndex ?? 0}" data-chart-point="${bar.index}">`);
|
|
22284
|
+
out.push(
|
|
22285
|
+
rect2(bar.x, bar.y, bar.width, bar.height, series.pointColors?.[bar.index] ?? series.color)
|
|
22286
|
+
);
|
|
22287
|
+
const size = Math.min(10, bar.height * 0.4);
|
|
22288
|
+
const label = series.labels?.[bar.index];
|
|
22289
|
+
if (label)
|
|
22290
|
+
out.push(
|
|
22291
|
+
text(bar.center, bar.y + bar.height / 2 + size * 0.35, label.text, {
|
|
22292
|
+
...chartTextAttributes(model, "dataLabel", size),
|
|
22293
|
+
size,
|
|
22294
|
+
anchor: "middle"
|
|
22295
|
+
})
|
|
22296
|
+
);
|
|
22297
|
+
out.push(
|
|
22298
|
+
text(
|
|
22299
|
+
plot.x - 8,
|
|
22300
|
+
bar.y + bar.height / 2 + (attrs2.size ?? 10) * 0.35,
|
|
22301
|
+
fit(model.categories[bar.index] ?? "", width - 8, attrs2.size ?? 10),
|
|
22302
|
+
{ ...attrs2, anchor: "end" }
|
|
22303
|
+
)
|
|
22304
|
+
);
|
|
22305
|
+
out.push("</g>");
|
|
22306
|
+
}
|
|
22307
|
+
return out.join("");
|
|
22308
|
+
}
|
|
22309
|
+
|
|
22310
|
+
// chart/box-distribution.ts
|
|
22311
|
+
function boxWhiskerDistribution(values, method = "exclusive", trimOutliers = false) {
|
|
22312
|
+
const stats = computeBoxStats(values, method);
|
|
22313
|
+
if (!stats) return void 0;
|
|
22314
|
+
const iqr = stats.q3 - stats.q1;
|
|
22315
|
+
const lowerFence = stats.q1 - 1.5 * iqr;
|
|
22316
|
+
const upperFence = stats.q3 + 1.5 * iqr;
|
|
22317
|
+
const inliers = values.filter((v) => !trimOutliers || v >= lowerFence && v <= upperFence);
|
|
22318
|
+
return {
|
|
22319
|
+
stats,
|
|
22320
|
+
whiskerMin: inliers.length ? Math.min(...inliers) : stats.min,
|
|
22321
|
+
whiskerMax: inliers.length ? Math.max(...inliers) : stats.max,
|
|
22322
|
+
mean: values.reduce((a, b) => a + b, 0) / values.length
|
|
22323
|
+
};
|
|
22324
|
+
}
|
|
22325
|
+
function boxMeanMarkerPath(x, y, radius = 3) {
|
|
22326
|
+
return `M${x - radius},${y - radius} L${x + radius},${y + radius} M${x - radius},${y + radius} L${x + radius},${y - radius}`;
|
|
22327
|
+
}
|
|
22328
|
+
|
|
22329
|
+
// chart/render/chart-svg-box.ts
|
|
22330
|
+
function boxWhiskerSvg(model, frame2, out) {
|
|
22331
|
+
const visible = model.series.filter((s) => !s.hidden);
|
|
22332
|
+
const slot = frame2.bandSize / Math.max(1, visible.length);
|
|
22333
|
+
const width = slot * 0.7;
|
|
22334
|
+
visible.forEach((series, si) => {
|
|
22335
|
+
if (series.hidden) return;
|
|
22336
|
+
const groups = groupRowsByCategory(series.boxCategories ?? []);
|
|
22337
|
+
model.categories.forEach((category, ci) => {
|
|
22338
|
+
const observations = (groups.rowIndexesByCategory.get(category) ?? []).flatMap((row) => {
|
|
22339
|
+
const value = series.values[row];
|
|
22340
|
+
return value === null || value === void 0 ? [] : [{ row, value }];
|
|
22341
|
+
});
|
|
22342
|
+
const options2 = series.boxWhisker;
|
|
22343
|
+
const rawMethod = options2?.statistics?.quartileMethod;
|
|
22344
|
+
const method = rawMethod === "inclusive" ? "inclusive" : "exclusive";
|
|
22345
|
+
const visibility = options2?.visibility;
|
|
22346
|
+
const trim = rawMethod === "inclusive" || rawMethod === "exclusive" || !!visibility && Object.values(visibility).some((v) => v !== void 0);
|
|
22347
|
+
const distribution = boxWhiskerDistribution(
|
|
22348
|
+
observations.map((p) => p.value),
|
|
22349
|
+
method,
|
|
22350
|
+
trim
|
|
22351
|
+
);
|
|
22352
|
+
if (!distribution) return;
|
|
22353
|
+
const { stats, whiskerMin, whiskerMax, mean } = distribution;
|
|
22354
|
+
const x = frame2.band(ci) - frame2.bandSize / 2 + si * slot + (slot - width) / 2;
|
|
22355
|
+
const mid = x + width / 2;
|
|
22356
|
+
const y = frame2.value;
|
|
22357
|
+
out.push(
|
|
22358
|
+
`<g data-chart-part="box" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${ci}">`
|
|
22359
|
+
);
|
|
22360
|
+
out.push(line2(mid, y(whiskerMax), mid, y(stats.q3), "#64748b", 1));
|
|
22361
|
+
out.push(line2(mid, y(stats.q1), mid, y(whiskerMin), "#64748b", 1));
|
|
22362
|
+
out.push(
|
|
22363
|
+
line2(x + width * 0.25, y(whiskerMin), x + width * 0.75, y(whiskerMin), "#64748b", 1)
|
|
22364
|
+
);
|
|
22365
|
+
out.push(
|
|
22366
|
+
line2(x + width * 0.25, y(whiskerMax), x + width * 0.75, y(whiskerMax), "#64748b", 1)
|
|
22367
|
+
);
|
|
22368
|
+
out.push(
|
|
22369
|
+
rect2(
|
|
22370
|
+
x,
|
|
22371
|
+
Math.min(y(stats.q1), y(stats.q3)),
|
|
22372
|
+
width,
|
|
22373
|
+
Math.abs(y(stats.q1) - y(stats.q3)),
|
|
22374
|
+
series.pointColors?.[ci] ?? series.color
|
|
22375
|
+
)
|
|
22376
|
+
);
|
|
22377
|
+
out.push(line2(x, y(stats.median), x + width, y(stats.median), "#1e293b", 2));
|
|
22378
|
+
if (visibility?.meanLine) out.push(line2(x, y(mean), x + width, y(mean), "#0f766e", 1.5));
|
|
22379
|
+
if (visibility?.meanMarker !== false)
|
|
22380
|
+
out.push(
|
|
22381
|
+
`<path d="${boxMeanMarkerPath(mid, y(mean))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
|
|
22382
|
+
);
|
|
22383
|
+
observations.forEach((point, index) => {
|
|
22384
|
+
const outlier = point.value < whiskerMin || point.value > whiskerMax;
|
|
22385
|
+
if (outlier ? !visibility?.outliers : !visibility?.nonoutliers) return;
|
|
22386
|
+
const px = x + width * (0.2 + 0.6 * (index + 1) / (observations.length + 1));
|
|
22387
|
+
out.push(
|
|
22388
|
+
`<circle cx="${n(px)}" cy="${n(y(point.value))}" r="2.25" fill="${outlier ? "#dc2626" : "#1e293b"}" data-chart-series="${series.sourceIndex ?? si}" data-chart-point="${point.row}" data-chart-part="${outlier ? "outlier" : "observation"}"/>`
|
|
22389
|
+
);
|
|
22390
|
+
});
|
|
22391
|
+
out.push("</g>");
|
|
22392
|
+
});
|
|
22393
|
+
});
|
|
22394
|
+
}
|
|
22395
|
+
|
|
22396
|
+
// chart/data-table-layout.ts
|
|
22397
|
+
function chartDataTableMetrics(fontSize, names, showKeys = true) {
|
|
22398
|
+
const rowH = Math.max(14, Math.round(fontSize * 1.45));
|
|
22399
|
+
const longestName = names.reduce((m, name) => Math.max(m, name.length), 0);
|
|
22400
|
+
const keyW = Math.min(160, Math.max(40, longestName * fontSize * 0.55 + (showKeys ? 24 : 8)));
|
|
22401
|
+
return { fontSize, rowH, keyW, height: rowH * (1 + names.length) };
|
|
22402
|
+
}
|
|
22403
|
+
|
|
22404
|
+
// chart/render/chart-spacing.ts
|
|
22405
|
+
function chartBarSpacing(chart) {
|
|
22406
|
+
const stacked = chart.grouping === "stacked" || chart.grouping === "percentStacked";
|
|
22407
|
+
return {
|
|
22408
|
+
barGapWidth: chart.barGapWidth ?? DEFAULT_BAR_GAP_WIDTH,
|
|
22409
|
+
barOverlap: chart.barOverlap ?? (stacked ? 100 : 0)
|
|
22410
|
+
};
|
|
22411
|
+
}
|
|
22412
|
+
|
|
21799
22413
|
// chart/render/chart-svg-labels.ts
|
|
21800
22414
|
var GAP = 3;
|
|
21801
22415
|
var LINE = 1.2;
|
|
@@ -21805,6 +22419,7 @@ function measure3(model, label) {
|
|
|
21805
22419
|
const size = attrs2.size ?? 10;
|
|
21806
22420
|
const lines = label.text.split("\n");
|
|
21807
22421
|
return {
|
|
22422
|
+
...model.frameSize ? { frame: model.frameSize } : {},
|
|
21808
22423
|
lines,
|
|
21809
22424
|
size,
|
|
21810
22425
|
w: Math.max(...lines.map((l) => textWidth(l, size))),
|
|
@@ -21813,6 +22428,7 @@ function measure3(model, label) {
|
|
|
21813
22428
|
};
|
|
21814
22429
|
}
|
|
21815
22430
|
function draw(m, label, x, y, anchor, out) {
|
|
22431
|
+
if (m.frame) ({ x, y } = applyLabelManualLayout(label.layout, m.frame, { x, y }));
|
|
21816
22432
|
const fill = label.color && NAMED_COLORS.test(label.color) ? label.color.toLowerCase() : void 0;
|
|
21817
22433
|
m.lines.forEach((line3, k) => {
|
|
21818
22434
|
const lineY = y - m.h / 2 + (k + 0.5) * m.size * LINE + m.size * 0.35;
|
|
@@ -21872,46 +22488,6 @@ function pointLabels(model, marks, out) {
|
|
|
21872
22488
|
}
|
|
21873
22489
|
}
|
|
21874
22490
|
}
|
|
21875
|
-
function sliceLabels(model, marks, out) {
|
|
21876
|
-
for (const mark of marks) {
|
|
21877
|
-
const label = mark.series.labels?.[mark.index];
|
|
21878
|
-
if (!label) continue;
|
|
21879
|
-
const m = measure3(model, label);
|
|
21880
|
-
const mid = (mark.start + mark.end) / 2;
|
|
21881
|
-
const ux = Math.sin(mid);
|
|
21882
|
-
const uy = -Math.cos(mid);
|
|
21883
|
-
const place2 = (radius) => [
|
|
21884
|
-
mark.cx + radius * ux,
|
|
21885
|
-
mark.cy + radius * uy
|
|
21886
|
-
];
|
|
21887
|
-
const position2 = model.type === "doughnut" ? "ctr" : label.position ?? "bestFit";
|
|
21888
|
-
let x;
|
|
21889
|
-
let y;
|
|
21890
|
-
if (position2 === "ctr") [x, y] = place2(mark.inner + (mark.outer - mark.inner) / 2);
|
|
21891
|
-
else if (position2 === "inEnd") {
|
|
21892
|
-
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
21893
|
-
[x, y] = place2(Math.max(0, mark.outer - GAP - extent));
|
|
21894
|
-
} else if (position2 === "outEnd") {
|
|
21895
|
-
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
21896
|
-
[x, y] = place2(mark.outer + GAP + extent);
|
|
21897
|
-
} else {
|
|
21898
|
-
const placed = placeBestFitLabel(
|
|
21899
|
-
{
|
|
21900
|
-
cx: mark.cx,
|
|
21901
|
-
cy: mark.cy,
|
|
21902
|
-
outerR: mark.outer,
|
|
21903
|
-
startAngle: mark.start - Math.PI / 2,
|
|
21904
|
-
endAngle: mark.end - Math.PI / 2
|
|
21905
|
-
},
|
|
21906
|
-
m.w,
|
|
21907
|
-
m.h
|
|
21908
|
-
);
|
|
21909
|
-
x = placed.x;
|
|
21910
|
-
y = placed.y;
|
|
21911
|
-
}
|
|
21912
|
-
draw(m, label, x, y, "middle", out);
|
|
21913
|
-
}
|
|
21914
|
-
}
|
|
21915
22491
|
function hasOutsideLabels(model) {
|
|
21916
22492
|
return model.series.some(
|
|
21917
22493
|
(s) => s.labels?.some(
|
|
@@ -21937,7 +22513,8 @@ function bars(model, frame2, out, values) {
|
|
|
21937
22513
|
const marks = [];
|
|
21938
22514
|
model.series.forEach((s, si) => {
|
|
21939
22515
|
values[si]?.forEach((v, i) => {
|
|
21940
|
-
if (v === null || i >= model.categories.length)
|
|
22516
|
+
if (v === null || i >= model.categories.length || frame2.order && !frame2.order.includes(i))
|
|
22517
|
+
return;
|
|
21941
22518
|
let from = 0;
|
|
21942
22519
|
let to = v;
|
|
21943
22520
|
if (stacked) {
|
|
@@ -22055,12 +22632,482 @@ function categoryAnalysis(model, frame2, out) {
|
|
|
22055
22632
|
seriesAnalysis(series, si, (i) => i + 1, plane, barPlane, true, out);
|
|
22056
22633
|
});
|
|
22057
22634
|
}
|
|
22058
|
-
function scatterAnalysis(model, px, py, out) {
|
|
22059
|
-
const plane = (x, y) => [px(x), py(y)];
|
|
22060
|
-
model.series.forEach((series, si) => {
|
|
22061
|
-
if (!series.trendlines && !series.errorBars) return;
|
|
22062
|
-
seriesAnalysis(series, si, (i) => series.xValues?.[i] ?? null, plane, plane, false, out);
|
|
22063
|
-
});
|
|
22635
|
+
function scatterAnalysis(model, px, py, out) {
|
|
22636
|
+
const plane = (x, y) => [px(x), py(y)];
|
|
22637
|
+
model.series.forEach((series, si) => {
|
|
22638
|
+
if (!series.trendlines && !series.errorBars) return;
|
|
22639
|
+
seriesAnalysis(series, si, (i) => series.xValues?.[i] ?? null, plane, plane, false, out);
|
|
22640
|
+
});
|
|
22641
|
+
}
|
|
22642
|
+
|
|
22643
|
+
// chart/render/chart-scale.ts
|
|
22644
|
+
var clean = (n2) => Number(n2.toPrecision(12));
|
|
22645
|
+
function* units(raw) {
|
|
22646
|
+
let exp = Math.floor(Math.log10(raw)) - 1;
|
|
22647
|
+
for (; ; ) {
|
|
22648
|
+
const base = 10 ** exp;
|
|
22649
|
+
for (const m of [1, 2, 5]) yield clean(m * base);
|
|
22650
|
+
exp++;
|
|
22651
|
+
}
|
|
22652
|
+
}
|
|
22653
|
+
function niceScale(dataMin, dataMax, options2 = {}) {
|
|
22654
|
+
const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
|
|
22655
|
+
let lo = Number.isFinite(dataMin) ? dataMin : 0;
|
|
22656
|
+
let hi = Number.isFinite(dataMax) ? dataMax : 0;
|
|
22657
|
+
if (lo > hi) [lo, hi] = [hi, lo];
|
|
22658
|
+
if (lo === hi) {
|
|
22659
|
+
if (lo === 0) hi = 1;
|
|
22660
|
+
else if (options2.noZero) {
|
|
22661
|
+
const pad2 = Math.abs(lo) * 0.1 || 1;
|
|
22662
|
+
lo -= pad2;
|
|
22663
|
+
hi += pad2;
|
|
22664
|
+
} else if (lo > 0) lo = 0;
|
|
22665
|
+
else hi = 0;
|
|
22666
|
+
}
|
|
22667
|
+
let fixedLo = false;
|
|
22668
|
+
let fixedHi = false;
|
|
22669
|
+
if (!options2.noZero) {
|
|
22670
|
+
if (lo >= 0 && hi - lo >= hi / 6) {
|
|
22671
|
+
lo = 0;
|
|
22672
|
+
fixedLo = true;
|
|
22673
|
+
} else if (hi <= 0 && hi - lo >= -lo / 6) {
|
|
22674
|
+
hi = 0;
|
|
22675
|
+
fixedHi = true;
|
|
22676
|
+
}
|
|
22677
|
+
}
|
|
22678
|
+
const range = hi - lo;
|
|
22679
|
+
const top = fixedHi ? hi : hi + range * 0.05;
|
|
22680
|
+
const bottom = fixedLo ? lo : lo - range * 0.05;
|
|
22681
|
+
for (const unit of units(range / maxIntervals)) {
|
|
22682
|
+
const min = fixedLo ? lo : Math.floor(clean(bottom / unit)) * unit;
|
|
22683
|
+
const max = fixedHi ? hi : Math.ceil(clean(top / unit)) * unit;
|
|
22684
|
+
const intervals = Math.round((max - min) / unit);
|
|
22685
|
+
if (intervals <= maxIntervals && intervals > 0) {
|
|
22686
|
+
const ticks = [];
|
|
22687
|
+
for (let i = 0; i <= intervals; i++) ticks.push(clean(min + i * unit));
|
|
22688
|
+
return { min: clean(min), max: clean(max), majorUnit: unit, ticks };
|
|
22689
|
+
}
|
|
22690
|
+
}
|
|
22691
|
+
return { min: lo, max: hi, majorUnit: range, ticks: [lo, hi] };
|
|
22692
|
+
}
|
|
22693
|
+
var PERCENT_SCALE = {
|
|
22694
|
+
min: 0,
|
|
22695
|
+
max: 1,
|
|
22696
|
+
majorUnit: 0.1,
|
|
22697
|
+
ticks: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
|
|
22698
|
+
};
|
|
22699
|
+
function formatAxisValue(value, percent = false) {
|
|
22700
|
+
if (percent) return `${clean(value * 100)}%`;
|
|
22701
|
+
const v = clean(value);
|
|
22702
|
+
if (Math.abs(v) >= 1e15 || v !== 0 && Math.abs(v) < 1e-6)
|
|
22703
|
+
return v.toExponential(2).replace("e+", "E+").replace("e-", "E-");
|
|
22704
|
+
const [int = "0", frac] = String(Math.abs(v)).split(".");
|
|
22705
|
+
const grouped = int.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
22706
|
+
return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
|
|
22707
|
+
}
|
|
22708
|
+
|
|
22709
|
+
// chart/render/chart-svg-data-table.ts
|
|
22710
|
+
var rows = (model) => [
|
|
22711
|
+
...model.series,
|
|
22712
|
+
...(model.extraGroups ?? []).flatMap((g) => g.series)
|
|
22713
|
+
];
|
|
22714
|
+
function chartTableMetrics(model) {
|
|
22715
|
+
if (!model.dataTable) return void 0;
|
|
22716
|
+
const size = model.dataTable.text?.fontSize;
|
|
22717
|
+
return chartDataTableMetrics(
|
|
22718
|
+
size === void 0 ? 13.333333333333334 : chartPointsToPixels(size),
|
|
22719
|
+
rows(model).map((s) => s.name),
|
|
22720
|
+
model.dataTable.source.showKeys !== false
|
|
22721
|
+
);
|
|
22722
|
+
}
|
|
22723
|
+
function chartDataTableSvg(model, plot) {
|
|
22724
|
+
const table = model.dataTable;
|
|
22725
|
+
const metrics = chartTableMetrics(model);
|
|
22726
|
+
if (!table || !metrics) return "";
|
|
22727
|
+
const { source } = table;
|
|
22728
|
+
const { rowH, keyW, height, fontSize } = metrics;
|
|
22729
|
+
const series = rows(model);
|
|
22730
|
+
const top = plot.y + plot.h;
|
|
22731
|
+
const left = plot.x - keyW;
|
|
22732
|
+
const right = plot.x + plot.w;
|
|
22733
|
+
const bottom = top + height;
|
|
22734
|
+
const cellW = plot.w / Math.max(1, model.categories.length);
|
|
22735
|
+
const styled = { ...model, appearance: { ...model.appearance, dataLabel: table.text ?? {} } };
|
|
22736
|
+
const attrs2 = chartTextAttributes(styled, "dataLabel", fontSize);
|
|
22737
|
+
const out = ['<g data-chart-part="dataTable">'];
|
|
22738
|
+
const border = (x1, y1, x2, y2) => out.push(
|
|
22739
|
+
`<line x1="${n(x1)}" y1="${n(y1)}" x2="${n(x2)}" y2="${n(y2)}" ${strokeAttributes(table.stroke)}/>`
|
|
22740
|
+
);
|
|
22741
|
+
const label = (x, y, value, width, anchor = "middle") => out.push(
|
|
22742
|
+
text(x, y + fontSize * 0.35, fit(value, Math.max(1, width), fontSize), { ...attrs2, anchor })
|
|
22743
|
+
);
|
|
22744
|
+
if (table.fill) out.push(rect2(left, top, right - left, height, table.fill));
|
|
22745
|
+
if (source.showOutline !== false) {
|
|
22746
|
+
border(plot.x, top, right, top);
|
|
22747
|
+
border(right, top, right, bottom);
|
|
22748
|
+
border(right, bottom, left, bottom);
|
|
22749
|
+
border(left, bottom, left, top + rowH);
|
|
22750
|
+
border(left, top + rowH, plot.x, top + rowH);
|
|
22751
|
+
border(plot.x, top, plot.x, top + rowH);
|
|
22752
|
+
}
|
|
22753
|
+
model.categories.forEach((category, i) => {
|
|
22754
|
+
label(plot.x + (i + 0.5) * cellW, top + rowH / 2, category, cellW - 4);
|
|
22755
|
+
if (source.showVerticalBorder !== false && i > 0)
|
|
22756
|
+
border(plot.x + i * cellW, top, plot.x + i * cellW, bottom);
|
|
22757
|
+
});
|
|
22758
|
+
if (source.showVerticalBorder !== false) border(plot.x, top, plot.x, bottom);
|
|
22759
|
+
series.forEach((s, i) => {
|
|
22760
|
+
const rowTop = top + rowH * (i + 1);
|
|
22761
|
+
const cy = rowTop + rowH / 2;
|
|
22762
|
+
if (source.showHorizontalBorder !== false) border(left, rowTop, right, rowTop);
|
|
22763
|
+
if (source.showKeys !== false) {
|
|
22764
|
+
const swatch = Math.max(6, Math.round(fontSize * 0.55));
|
|
22765
|
+
out.push(rect2(left + 4, cy - swatch / 2, swatch, swatch, s.color));
|
|
22766
|
+
}
|
|
22767
|
+
const keyInset = source.showKeys !== false ? Math.max(6, Math.round(fontSize * 0.55)) + 7 : 4;
|
|
22768
|
+
label(left + keyInset, cy, s.name, keyW - keyInset - 4, "start");
|
|
22769
|
+
model.categories.forEach((_, j) => {
|
|
22770
|
+
const value = s.values[j];
|
|
22771
|
+
const formatted = value === null || value === void 0 ? "" : formatChartNumber(value, s.numberFormat) ?? formatAxisValue(value);
|
|
22772
|
+
label(plot.x + (j + 0.5) * cellW, cy, formatted, cellW - 4);
|
|
22773
|
+
});
|
|
22774
|
+
});
|
|
22775
|
+
return out.join("") + "</g>";
|
|
22776
|
+
}
|
|
22777
|
+
|
|
22778
|
+
// chart/date-axis.ts
|
|
22779
|
+
var DAY_MS = 864e5;
|
|
22780
|
+
function excelSerialToDate(serial, date1904 = false) {
|
|
22781
|
+
const epoch = date1904 ? Date.UTC(1904, 0, 1) : Date.UTC(1899, 11, serial < 60 ? 31 : 30);
|
|
22782
|
+
return new Date(epoch + serial * DAY_MS);
|
|
22783
|
+
}
|
|
22784
|
+
function addUnit(date, amount, unit) {
|
|
22785
|
+
const next = new Date(date);
|
|
22786
|
+
if (unit === "days") {
|
|
22787
|
+
next.setUTCDate(next.getUTCDate() + amount);
|
|
22788
|
+
} else if (unit === "months") {
|
|
22789
|
+
next.setUTCMonth(next.getUTCMonth() + amount);
|
|
22790
|
+
} else {
|
|
22791
|
+
next.setUTCFullYear(next.getUTCFullYear() + amount);
|
|
22792
|
+
}
|
|
22793
|
+
return next;
|
|
22794
|
+
}
|
|
22795
|
+
function calendarTicks(min, max, date1904, unit, step) {
|
|
22796
|
+
const result = [];
|
|
22797
|
+
let date = excelSerialToDate(min, date1904);
|
|
22798
|
+
for (let guard = 0; guard < 1e3 && date.getTime() <= excelSerialToDate(max, date1904).getTime(); guard++) {
|
|
22799
|
+
result.push(min + (date.getTime() - excelSerialToDate(min, date1904).getTime()) / DAY_MS);
|
|
22800
|
+
date = addUnit(date, step, unit);
|
|
22801
|
+
}
|
|
22802
|
+
return result;
|
|
22803
|
+
}
|
|
22804
|
+
|
|
22805
|
+
// chart/date-format.ts
|
|
22806
|
+
var MONTH_ABBR = [
|
|
22807
|
+
"Jan",
|
|
22808
|
+
"Feb",
|
|
22809
|
+
"Mar",
|
|
22810
|
+
"Apr",
|
|
22811
|
+
"May",
|
|
22812
|
+
"Jun",
|
|
22813
|
+
"Jul",
|
|
22814
|
+
"Aug",
|
|
22815
|
+
"Sep",
|
|
22816
|
+
"Oct",
|
|
22817
|
+
"Nov",
|
|
22818
|
+
"Dec"
|
|
22819
|
+
];
|
|
22820
|
+
var MONTH_FULL = [
|
|
22821
|
+
"January",
|
|
22822
|
+
"February",
|
|
22823
|
+
"March",
|
|
22824
|
+
"April",
|
|
22825
|
+
"May",
|
|
22826
|
+
"June",
|
|
22827
|
+
"July",
|
|
22828
|
+
"August",
|
|
22829
|
+
"September",
|
|
22830
|
+
"October",
|
|
22831
|
+
"November",
|
|
22832
|
+
"December"
|
|
22833
|
+
];
|
|
22834
|
+
var WEEKDAY_ABBR = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
22835
|
+
var WEEKDAY_FULL = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
22836
|
+
function scanDateFormatTokens(code) {
|
|
22837
|
+
const tokens = [];
|
|
22838
|
+
let i = 0;
|
|
22839
|
+
while (i < code.length) {
|
|
22840
|
+
const ch = code[i];
|
|
22841
|
+
if (ch === '"') {
|
|
22842
|
+
const close = code.indexOf('"', i + 1);
|
|
22843
|
+
tokens.push({
|
|
22844
|
+
kind: "literal",
|
|
22845
|
+
text: close === -1 ? code.slice(i + 1) : code.slice(i + 1, close)
|
|
22846
|
+
});
|
|
22847
|
+
i = close === -1 ? code.length : close + 1;
|
|
22848
|
+
continue;
|
|
22849
|
+
}
|
|
22850
|
+
if (ch === "\\") {
|
|
22851
|
+
tokens.push({ kind: "literal", text: code[i + 1] ?? "" });
|
|
22852
|
+
i += 2;
|
|
22853
|
+
continue;
|
|
22854
|
+
}
|
|
22855
|
+
const rest = code.slice(i);
|
|
22856
|
+
if (/^am\/pm/iu.test(rest)) {
|
|
22857
|
+
tokens.push({ kind: "ampm", upper: ch === ch.toUpperCase(), short: false });
|
|
22858
|
+
i += 5;
|
|
22859
|
+
continue;
|
|
22860
|
+
}
|
|
22861
|
+
if (/^a\/p/iu.test(rest)) {
|
|
22862
|
+
tokens.push({ kind: "ampm", upper: ch === ch.toUpperCase(), short: true });
|
|
22863
|
+
i += 3;
|
|
22864
|
+
continue;
|
|
22865
|
+
}
|
|
22866
|
+
if (/[ymdhs]/iu.test(ch)) {
|
|
22867
|
+
let j = i + 1;
|
|
22868
|
+
while (j < code.length && code[j].toLowerCase() === ch.toLowerCase()) {
|
|
22869
|
+
j += 1;
|
|
22870
|
+
}
|
|
22871
|
+
tokens.push({
|
|
22872
|
+
kind: "letters",
|
|
22873
|
+
letter: ch.toLowerCase(),
|
|
22874
|
+
count: j - i
|
|
22875
|
+
});
|
|
22876
|
+
i = j;
|
|
22877
|
+
continue;
|
|
22878
|
+
}
|
|
22879
|
+
tokens.push({ kind: "literal", text: ch });
|
|
22880
|
+
i += 1;
|
|
22881
|
+
}
|
|
22882
|
+
return tokens;
|
|
22883
|
+
}
|
|
22884
|
+
function findNonLiteral(tokens, index, step) {
|
|
22885
|
+
for (let i = index + step; i >= 0 && i < tokens.length; i += step) {
|
|
22886
|
+
if (tokens[i].kind !== "literal") {
|
|
22887
|
+
return tokens[i];
|
|
22888
|
+
}
|
|
22889
|
+
}
|
|
22890
|
+
return void 0;
|
|
22891
|
+
}
|
|
22892
|
+
function pad(n2, width) {
|
|
22893
|
+
return String(n2).padStart(width, "0");
|
|
22894
|
+
}
|
|
22895
|
+
function renderDatePart(part, count, date, twelveHour) {
|
|
22896
|
+
switch (part) {
|
|
22897
|
+
case "year":
|
|
22898
|
+
return count >= 4 ? pad(date.getUTCFullYear(), 4) : pad(date.getUTCFullYear() % 100, 2);
|
|
22899
|
+
case "month":
|
|
22900
|
+
if (count >= 4) {
|
|
22901
|
+
return MONTH_FULL[date.getUTCMonth()] ?? "";
|
|
22902
|
+
}
|
|
22903
|
+
if (count === 3) {
|
|
22904
|
+
return MONTH_ABBR[date.getUTCMonth()] ?? "";
|
|
22905
|
+
}
|
|
22906
|
+
return count >= 2 ? pad(date.getUTCMonth() + 1, 2) : String(date.getUTCMonth() + 1);
|
|
22907
|
+
case "day":
|
|
22908
|
+
if (count >= 4) {
|
|
22909
|
+
return WEEKDAY_FULL[date.getUTCDay()] ?? "";
|
|
22910
|
+
}
|
|
22911
|
+
if (count === 3) {
|
|
22912
|
+
return WEEKDAY_ABBR[date.getUTCDay()] ?? "";
|
|
22913
|
+
}
|
|
22914
|
+
return count >= 2 ? pad(date.getUTCDate(), 2) : String(date.getUTCDate());
|
|
22915
|
+
case "hour": {
|
|
22916
|
+
const h24 = date.getUTCHours();
|
|
22917
|
+
const h = twelveHour ? h24 % 12 === 0 ? 12 : h24 % 12 : h24;
|
|
22918
|
+
return count >= 2 ? pad(h, 2) : String(h);
|
|
22919
|
+
}
|
|
22920
|
+
case "minute":
|
|
22921
|
+
return count >= 2 ? pad(date.getUTCMinutes(), 2) : String(date.getUTCMinutes());
|
|
22922
|
+
case "second":
|
|
22923
|
+
return count >= 2 ? pad(date.getUTCSeconds(), 2) : String(date.getUTCSeconds());
|
|
22924
|
+
}
|
|
22925
|
+
}
|
|
22926
|
+
function renderExcelDateFormat(date, code) {
|
|
22927
|
+
const tokens = scanDateFormatTokens(code);
|
|
22928
|
+
const hasAmPm = tokens.some((t) => t.kind === "ampm");
|
|
22929
|
+
let out = "";
|
|
22930
|
+
for (const [index, token] of tokens.entries()) {
|
|
22931
|
+
if (token.kind === "literal") {
|
|
22932
|
+
out += token.text;
|
|
22933
|
+
continue;
|
|
22934
|
+
}
|
|
22935
|
+
if (token.kind === "ampm") {
|
|
22936
|
+
const hour = date.getUTCHours(), text2 = token.short ? hour < 12 ? "A" : "P" : hour < 12 ? "AM" : "PM";
|
|
22937
|
+
out += token.upper ? text2 : text2.toLowerCase();
|
|
22938
|
+
continue;
|
|
22939
|
+
}
|
|
22940
|
+
if (token.letter === "m") {
|
|
22941
|
+
const prev = findNonLiteral(tokens, index, -1), next = findNonLiteral(tokens, index, 1), isMinute = prev?.kind === "letters" && prev.letter === "h" || next?.kind === "letters" && next.letter === "s";
|
|
22942
|
+
out += renderDatePart(isMinute ? "minute" : "month", token.count, date, hasAmPm);
|
|
22943
|
+
continue;
|
|
22944
|
+
}
|
|
22945
|
+
const part = { y: "year", d: "day", h: "hour", s: "second" };
|
|
22946
|
+
out += renderDatePart(part[token.letter], token.count, date, hasAmPm);
|
|
22947
|
+
}
|
|
22948
|
+
return out;
|
|
22949
|
+
}
|
|
22950
|
+
function formatDate(date, unit, format) {
|
|
22951
|
+
if (format && /[ymdhs]/iu.test(format)) {
|
|
22952
|
+
const rendered = renderExcelDateFormat(date, format);
|
|
22953
|
+
if (rendered.length > 0) {
|
|
22954
|
+
return rendered;
|
|
22955
|
+
}
|
|
22956
|
+
}
|
|
22957
|
+
const month = date.toLocaleString("en-US", { month: "short", timeZone: "UTC" }), year = String(date.getUTCFullYear()), day = String(date.getUTCDate());
|
|
22958
|
+
if (unit === "years") {
|
|
22959
|
+
return year;
|
|
22960
|
+
}
|
|
22961
|
+
if (unit === "months") {
|
|
22962
|
+
return `${month} ${year}`;
|
|
22963
|
+
}
|
|
22964
|
+
return `${day} ${month}`;
|
|
22965
|
+
}
|
|
22966
|
+
|
|
22967
|
+
// chart/render/chart-svg-date-axis.ts
|
|
22968
|
+
function chartDateAxis(model, plot, out) {
|
|
22969
|
+
const axis = model.axes?.category?.source;
|
|
22970
|
+
const values = model.dateCategories;
|
|
22971
|
+
if (axis?.kind !== "date" || !values?.length) return void 0;
|
|
22972
|
+
const points = values.flatMap(
|
|
22973
|
+
(value, index) => value === null || !Number.isFinite(value) ? [] : [{ value, index }]
|
|
22974
|
+
).sort((a, b) => a.value - b.value);
|
|
22975
|
+
if (!points.length) return void 0;
|
|
22976
|
+
const min = axis.scaling.min ?? points[0].value;
|
|
22977
|
+
const max = axis.scaling.max ?? points.at(-1).value;
|
|
22978
|
+
if (!Number.isFinite(min) || !Number.isFinite(max) || max < min) return void 0;
|
|
22979
|
+
const position2 = (value) => {
|
|
22980
|
+
const ratio = max === min ? 0.5 : (value - min) / (max - min);
|
|
22981
|
+
const t = axis.scaling.orientation === "maxMin" ? 1 - ratio : ratio;
|
|
22982
|
+
return model.horizontal ? plot.y + plot.h * (1 - t) : plot.x + plot.w * t;
|
|
22983
|
+
};
|
|
22984
|
+
const visible = points.filter((p) => p.value >= min && p.value <= max);
|
|
22985
|
+
const unitOf = (unit2) => unit2 === "months" || unit2 === "years" ? unit2 : "days";
|
|
22986
|
+
const unit = unitOf(axis.majorTimeUnit ?? axis.baseTimeUnit);
|
|
22987
|
+
const ticks = calendarTicks(
|
|
22988
|
+
min,
|
|
22989
|
+
max,
|
|
22990
|
+
model.date1904 ?? false,
|
|
22991
|
+
unit,
|
|
22992
|
+
Math.max(1, axis.majorUnit ?? 1)
|
|
22993
|
+
);
|
|
22994
|
+
const attrs2 = chartTextAttributes(model, "categoryAxis");
|
|
22995
|
+
const size = attrs2.size ?? 10;
|
|
22996
|
+
const y = axis.position === "t" ? plot.y : plot.y + plot.h;
|
|
22997
|
+
const paint2 = model.axes?.category?.line;
|
|
22998
|
+
const stroke = { color: paint2?.color ?? "#BFBFBF", width: paint2?.width ?? 1 };
|
|
22999
|
+
const mark = (serial, placement, length) => {
|
|
23000
|
+
if (!placement || placement === "none" || axis.deleted) return;
|
|
23001
|
+
const inward = axis.position === "t" ? length : -length;
|
|
23002
|
+
const start = placement === "cross" ? -length : 0;
|
|
23003
|
+
const end = placement === "cross" ? length : placement === "in" ? inward : -inward;
|
|
23004
|
+
if (model.horizontal) {
|
|
23005
|
+
const x = axis.position === "r" ? plot.x + plot.w : plot.x;
|
|
23006
|
+
const direction = axis.position === "r" ? -1 : 1;
|
|
23007
|
+
const a = placement === "cross" ? -length : 0;
|
|
23008
|
+
const b = placement === "cross" ? length : placement === "in" ? direction * length : -direction * length;
|
|
23009
|
+
out.push(
|
|
23010
|
+
`<line x1="${x + a}" y1="${position2(serial)}" x2="${x + b}" y2="${position2(serial)}" ${strokeAttributes(stroke)} data-chart-part="dateTick"/>`
|
|
23011
|
+
);
|
|
23012
|
+
} else
|
|
23013
|
+
out.push(
|
|
23014
|
+
`<line x1="${position2(serial)}" y1="${y + start}" x2="${position2(serial)}" y2="${y + end}" ${strokeAttributes(stroke)} data-chart-part="dateTick"/>`
|
|
23015
|
+
);
|
|
23016
|
+
};
|
|
23017
|
+
ticks.forEach((serial, index) => {
|
|
23018
|
+
if (index % Math.max(1, axis.tickMarkSkip ?? 1) === 0) mark(serial, axis.majorTickMark, 4);
|
|
23019
|
+
if (axis.deleted || model.dataTable || axis.tickLabelPosition === "none" || index % Math.max(1, axis.tickLabelSkip ?? 1))
|
|
23020
|
+
return;
|
|
23021
|
+
const label = formatDate(
|
|
23022
|
+
excelSerialToDate(serial, model.date1904),
|
|
23023
|
+
unit,
|
|
23024
|
+
axis.numberFormat?.formatCode
|
|
23025
|
+
);
|
|
23026
|
+
if (model.horizontal)
|
|
23027
|
+
out.push(text(plot.x - 4, position2(serial) + size * 0.3, label, { ...attrs2, anchor: "end" }));
|
|
23028
|
+
else {
|
|
23029
|
+
const above = axis.tickLabelPosition === "high" || axis.tickLabelPosition !== "low" && axis.position === "t";
|
|
23030
|
+
const baseline = axis.tickLabelPosition === "high" ? plot.y : axis.tickLabelPosition === "low" ? plot.y + plot.h : y;
|
|
23031
|
+
out.push(
|
|
23032
|
+
text(position2(serial), baseline + (above ? -4 : size + 3), label, {
|
|
23033
|
+
...attrs2,
|
|
23034
|
+
anchor: "middle"
|
|
23035
|
+
})
|
|
23036
|
+
);
|
|
23037
|
+
}
|
|
23038
|
+
});
|
|
23039
|
+
if (axis.minorTickMark && axis.minorTickMark !== "none")
|
|
23040
|
+
for (const serial of calendarTicks(
|
|
23041
|
+
min,
|
|
23042
|
+
max,
|
|
23043
|
+
model.date1904 ?? false,
|
|
23044
|
+
unitOf(axis.minorTimeUnit ?? axis.baseTimeUnit ?? unit),
|
|
23045
|
+
Math.max(1, axis.minorUnit ?? 1)
|
|
23046
|
+
))
|
|
23047
|
+
mark(serial, axis.minorTickMark, 2.5);
|
|
23048
|
+
return {
|
|
23049
|
+
order: visible.map((p) => p.index),
|
|
23050
|
+
band: (index) => position2(values[index] ?? min),
|
|
23051
|
+
bandSize: (model.horizontal ? plot.h : plot.w) / Math.max(1, max - min + 1)
|
|
23052
|
+
};
|
|
23053
|
+
}
|
|
23054
|
+
|
|
23055
|
+
// chart/line-path.ts
|
|
23056
|
+
function smoothLinePath(points) {
|
|
23057
|
+
if (points.length === 0) {
|
|
23058
|
+
return "";
|
|
23059
|
+
}
|
|
23060
|
+
if (points.length === 1) {
|
|
23061
|
+
return `M${points[0].x.toFixed(2)},${points[0].y.toFixed(2)}`;
|
|
23062
|
+
}
|
|
23063
|
+
if (points.length === 2) {
|
|
23064
|
+
return `M${points[0].x.toFixed(2)},${points[0].y.toFixed(2)} L${points[1].x.toFixed(2)},${points[1].y.toFixed(2)}`;
|
|
23065
|
+
}
|
|
23066
|
+
let d = `M${points[0].x.toFixed(2)},${points[0].y.toFixed(2)}`;
|
|
23067
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
23068
|
+
const [cp1, cp2, end] = smoothSegment(points, i);
|
|
23069
|
+
d += ` C${cp1.x.toFixed(2)},${cp1.y.toFixed(2)} ${cp2.x.toFixed(2)},${cp2.y.toFixed(2)} ${end.x.toFixed(2)},${end.y.toFixed(2)}`;
|
|
23070
|
+
}
|
|
23071
|
+
return d;
|
|
23072
|
+
}
|
|
23073
|
+
function smoothSegment(points, i) {
|
|
23074
|
+
const p0 = points[i - 1] ?? points[i];
|
|
23075
|
+
const p1 = points[i];
|
|
23076
|
+
const p2 = points[i + 1];
|
|
23077
|
+
const p3 = points[i + 2] ?? p2;
|
|
23078
|
+
return [
|
|
23079
|
+
{ x: p1.x + (p2.x - p0.x) / 6, y: p1.y + (p2.y - p0.y) / 6 },
|
|
23080
|
+
{ x: p2.x - (p3.x - p1.x) / 6, y: p2.y - (p3.y - p1.y) / 6 },
|
|
23081
|
+
p2
|
|
23082
|
+
];
|
|
23083
|
+
}
|
|
23084
|
+
|
|
23085
|
+
// chart/render/chart-svg-line.ts
|
|
23086
|
+
function chartLineSvg(points, series) {
|
|
23087
|
+
if (points.length < 2) return "";
|
|
23088
|
+
const stroke = series.stroke;
|
|
23089
|
+
const attrs2 = strokeAttributes(
|
|
23090
|
+
stroke ? { ...stroke, color: stroke.color === "none" ? "none" : series.color } : { color: series.color, width: 2.25 }
|
|
23091
|
+
);
|
|
23092
|
+
const filter = series.shadowFilter ? ` filter="${series.shadowFilter}"` : "";
|
|
23093
|
+
return series.smooth ? `<path d="${smoothLinePath(points)}" fill="none" ${attrs2} stroke-linejoin="round"${filter}/>` : `<polyline points="${points.map((p) => `${n(p.x)},${n(p.y)}`).join(" ")}" fill="none" ${attrs2} stroke-linejoin="round"${filter}/>`;
|
|
23094
|
+
}
|
|
23095
|
+
|
|
23096
|
+
// chart/render/chart-svg-plot-layout.ts
|
|
23097
|
+
function chartPlotRect(model, auto, outer, frame2) {
|
|
23098
|
+
if (!frame2) return auto;
|
|
23099
|
+
const rect3 = resolveManualPlotRect(
|
|
23100
|
+
model.plotLayout,
|
|
23101
|
+
frame2,
|
|
23102
|
+
{ x: auto.x, y: auto.y, width: auto.w, height: auto.h },
|
|
23103
|
+
{
|
|
23104
|
+
left: auto.x - outer.x,
|
|
23105
|
+
top: auto.y - outer.y,
|
|
23106
|
+
right: Math.max(0, outer.x + outer.w - auto.x - auto.w),
|
|
23107
|
+
bottom: Math.max(0, outer.y + outer.h - auto.y - auto.h)
|
|
23108
|
+
}
|
|
23109
|
+
);
|
|
23110
|
+
return rect3 ? { x: rect3.x, y: rect3.y, w: rect3.width, h: rect3.height } : auto;
|
|
22064
23111
|
}
|
|
22065
23112
|
|
|
22066
23113
|
// chart/render/chart-svg-markers.ts
|
|
@@ -22117,72 +23164,6 @@ function chartLineDashArray(style, width) {
|
|
|
22117
23164
|
return `${unit * 3} ${unit * 2}`;
|
|
22118
23165
|
}
|
|
22119
23166
|
|
|
22120
|
-
// chart/render/chart-scale.ts
|
|
22121
|
-
var clean = (n2) => Number(n2.toPrecision(12));
|
|
22122
|
-
function* units(raw) {
|
|
22123
|
-
let exp = Math.floor(Math.log10(raw)) - 1;
|
|
22124
|
-
for (; ; ) {
|
|
22125
|
-
const base = 10 ** exp;
|
|
22126
|
-
for (const m of [1, 2, 5]) yield clean(m * base);
|
|
22127
|
-
exp++;
|
|
22128
|
-
}
|
|
22129
|
-
}
|
|
22130
|
-
function niceScale(dataMin, dataMax, options2 = {}) {
|
|
22131
|
-
const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
|
|
22132
|
-
let lo = Number.isFinite(dataMin) ? dataMin : 0;
|
|
22133
|
-
let hi = Number.isFinite(dataMax) ? dataMax : 0;
|
|
22134
|
-
if (lo > hi) [lo, hi] = [hi, lo];
|
|
22135
|
-
if (lo === hi) {
|
|
22136
|
-
if (lo === 0) hi = 1;
|
|
22137
|
-
else if (options2.noZero) {
|
|
22138
|
-
const pad = Math.abs(lo) * 0.1 || 1;
|
|
22139
|
-
lo -= pad;
|
|
22140
|
-
hi += pad;
|
|
22141
|
-
} else if (lo > 0) lo = 0;
|
|
22142
|
-
else hi = 0;
|
|
22143
|
-
}
|
|
22144
|
-
let fixedLo = false;
|
|
22145
|
-
let fixedHi = false;
|
|
22146
|
-
if (!options2.noZero) {
|
|
22147
|
-
if (lo >= 0 && hi - lo >= hi / 6) {
|
|
22148
|
-
lo = 0;
|
|
22149
|
-
fixedLo = true;
|
|
22150
|
-
} else if (hi <= 0 && hi - lo >= -lo / 6) {
|
|
22151
|
-
hi = 0;
|
|
22152
|
-
fixedHi = true;
|
|
22153
|
-
}
|
|
22154
|
-
}
|
|
22155
|
-
const range = hi - lo;
|
|
22156
|
-
const top = fixedHi ? hi : hi + range * 0.05;
|
|
22157
|
-
const bottom = fixedLo ? lo : lo - range * 0.05;
|
|
22158
|
-
for (const unit of units(range / maxIntervals)) {
|
|
22159
|
-
const min = fixedLo ? lo : Math.floor(clean(bottom / unit)) * unit;
|
|
22160
|
-
const max = fixedHi ? hi : Math.ceil(clean(top / unit)) * unit;
|
|
22161
|
-
const intervals = Math.round((max - min) / unit);
|
|
22162
|
-
if (intervals <= maxIntervals && intervals > 0) {
|
|
22163
|
-
const ticks = [];
|
|
22164
|
-
for (let i = 0; i <= intervals; i++) ticks.push(clean(min + i * unit));
|
|
22165
|
-
return { min: clean(min), max: clean(max), majorUnit: unit, ticks };
|
|
22166
|
-
}
|
|
22167
|
-
}
|
|
22168
|
-
return { min: lo, max: hi, majorUnit: range, ticks: [lo, hi] };
|
|
22169
|
-
}
|
|
22170
|
-
var PERCENT_SCALE = {
|
|
22171
|
-
min: 0,
|
|
22172
|
-
max: 1,
|
|
22173
|
-
majorUnit: 0.1,
|
|
22174
|
-
ticks: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
|
|
22175
|
-
};
|
|
22176
|
-
function formatAxisValue(value, percent = false) {
|
|
22177
|
-
if (percent) return `${clean(value * 100)}%`;
|
|
22178
|
-
const v = clean(value);
|
|
22179
|
-
if (Math.abs(v) >= 1e15 || v !== 0 && Math.abs(v) < 1e-6)
|
|
22180
|
-
return v.toExponential(2).replace("e+", "E+").replace("e-", "E-");
|
|
22181
|
-
const [int = "0", frac] = String(Math.abs(v)).split(".");
|
|
22182
|
-
const grouped = int.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
22183
|
-
return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
|
|
22184
|
-
}
|
|
22185
|
-
|
|
22186
23167
|
// chart/render/chart-svg-axes.ts
|
|
22187
23168
|
function axisTickText(value, axis, percent = false) {
|
|
22188
23169
|
return formatChartNumber(value, axis?.source.numberFormat?.formatCode) ?? formatAxisValue(value, percent);
|
|
@@ -22409,6 +23390,50 @@ function applyChartAxes(model, chart, color) {
|
|
|
22409
23390
|
model.axes = out;
|
|
22410
23391
|
}
|
|
22411
23392
|
|
|
23393
|
+
// chart/render/chart-title-text.ts
|
|
23394
|
+
function chartRunStyle(run) {
|
|
23395
|
+
return {
|
|
23396
|
+
...run.sizePt === void 0 ? {} : { fontSize: run.sizePt },
|
|
23397
|
+
...run.bold === void 0 ? {} : { bold: run.bold },
|
|
23398
|
+
...run.italic === void 0 ? {} : { italic: run.italic },
|
|
23399
|
+
...run.underline === void 0 ? {} : { underline: run.underline },
|
|
23400
|
+
...run.typeface === void 0 ? {} : { typeface: run.typeface },
|
|
23401
|
+
...run.color === void 0 ? {} : { textColor: run.color }
|
|
23402
|
+
};
|
|
23403
|
+
}
|
|
23404
|
+
function chartTitleText(chart, theme) {
|
|
23405
|
+
const formatting2 = chart.formatting;
|
|
23406
|
+
const entry = formatting2?.entries.title;
|
|
23407
|
+
const body = entry?.textBody;
|
|
23408
|
+
if (!formatting2 || !body || body.text !== chart.title) return void 0;
|
|
23409
|
+
if (body.paragraphs.length === 1 && body.paragraphs[0].runs.length <= 1 && !body.text.includes("\n") && !body.paragraphs[0].lineSpacing && !body.paragraphs[0].spaceBefore && !body.paragraphs[0].spaceAfter)
|
|
23410
|
+
return void 0;
|
|
23411
|
+
return {
|
|
23412
|
+
paragraphs: body.paragraphs.map((paragraph) => ({
|
|
23413
|
+
...paragraph.align ? { align: paragraph.align } : {},
|
|
23414
|
+
...paragraph.lineSpacing ? { lineSpacing: paragraph.lineSpacing } : {},
|
|
23415
|
+
...paragraph.spaceBefore ? { spaceBefore: paragraph.spaceBefore } : {},
|
|
23416
|
+
...paragraph.spaceAfter ? { spaceAfter: paragraph.spaceAfter } : {},
|
|
23417
|
+
runs: paragraph.runs.map((run) => {
|
|
23418
|
+
const direct = {
|
|
23419
|
+
sourceXml: "",
|
|
23420
|
+
...entry.textBodyStyle,
|
|
23421
|
+
...chartRunStyle(paragraph.defaultProperties ?? {}),
|
|
23422
|
+
...chartRunStyle(run)
|
|
23423
|
+
};
|
|
23424
|
+
const appearance = chartAppearance(
|
|
23425
|
+
{
|
|
23426
|
+
...chart,
|
|
23427
|
+
formatting: { ...formatting2, entries: { ...formatting2.entries, title: direct } }
|
|
23428
|
+
},
|
|
23429
|
+
theme
|
|
23430
|
+
)?.title ?? {};
|
|
23431
|
+
return { text: run.text, appearance };
|
|
23432
|
+
})
|
|
23433
|
+
}))
|
|
23434
|
+
};
|
|
23435
|
+
}
|
|
23436
|
+
|
|
22412
23437
|
// chart/render/chart-view-analysis.ts
|
|
22413
23438
|
function strokeOf(line3, fallback, resolve) {
|
|
22414
23439
|
if (line3?.fill?.kind === "none") return void 0;
|
|
@@ -22436,6 +23461,40 @@ function analysisView(source, seriesColor, resolve) {
|
|
|
22436
23461
|
};
|
|
22437
23462
|
}
|
|
22438
23463
|
|
|
23464
|
+
// chart/render/chart-view-data-table.ts
|
|
23465
|
+
function chartDataTableView(chart, theme, color) {
|
|
23466
|
+
const source = chart.dataTable;
|
|
23467
|
+
if (!source) return void 0;
|
|
23468
|
+
const props = source.txPr?.paragraphs[0];
|
|
23469
|
+
const direct = {
|
|
23470
|
+
sourceXml: "",
|
|
23471
|
+
...chartRunStyle(props?.defaultProperties ?? {}),
|
|
23472
|
+
...chartRunStyle(props?.runs[0] ?? {})
|
|
23473
|
+
};
|
|
23474
|
+
const formatting2 = chart.formatting;
|
|
23475
|
+
const appearance = chartAppearance(
|
|
23476
|
+
{
|
|
23477
|
+
...chart,
|
|
23478
|
+
formatting: {
|
|
23479
|
+
...formatting2,
|
|
23480
|
+
sourceXml: formatting2?.sourceXml ?? "",
|
|
23481
|
+
entries: { ...formatting2?.entries, categoryAxis: direct }
|
|
23482
|
+
}
|
|
23483
|
+
},
|
|
23484
|
+
theme
|
|
23485
|
+
);
|
|
23486
|
+
const fill = source.spPr?.fill;
|
|
23487
|
+
return {
|
|
23488
|
+
source,
|
|
23489
|
+
stroke: strokeOf(source.spPr?.line, { color: "#D9D9D9", width: 1 }, color) ?? {
|
|
23490
|
+
color: "none",
|
|
23491
|
+
width: 0
|
|
23492
|
+
},
|
|
23493
|
+
...fill?.kind === "solid" && color(fill.color) ? { fill: color(fill.color) } : {},
|
|
23494
|
+
...appearance?.categoryAxis ? { text: appearance.categoryAxis } : {}
|
|
23495
|
+
};
|
|
23496
|
+
}
|
|
23497
|
+
|
|
22439
23498
|
// chart/render/chart-view-series.ts
|
|
22440
23499
|
var isRefError = (value) => typeof value === "object" && value !== null && "error" in value;
|
|
22441
23500
|
function toText(value) {
|
|
@@ -22477,7 +23536,8 @@ function seriesContext(chart, theme, options2) {
|
|
|
22477
23536
|
function seriesView(ctx, s, index, total, categoriesOf) {
|
|
22478
23537
|
const { theme, scheme: scheme2, palette, evaluateRef } = ctx;
|
|
22479
23538
|
const values = resolveRef(s.valuesRef, evaluateRef)?.map(toNumber) ?? s.values.map(toNumber);
|
|
22480
|
-
|
|
23539
|
+
const categoryValues = resolveRef(s.categoriesRef, evaluateRef) ?? s.categories;
|
|
23540
|
+
categoriesOf(categoryValues);
|
|
22481
23541
|
const paletteColor = palette && chartPaletteSeriesColor(palette, index, total, scheme2);
|
|
22482
23542
|
const color = s.fill?.kind === "none" ? "none" : ctx.drawingColor(s.fill?.kind === "solid" ? s.fill.color : s.drawingColor) ?? ctx.seriesColor?.(s, index) ?? paletteColor ?? autoSeriesColor(theme, index);
|
|
22483
23543
|
const view = {
|
|
@@ -22486,6 +23546,19 @@ function seriesView(ctx, s, index, total, categoriesOf) {
|
|
|
22486
23546
|
color,
|
|
22487
23547
|
sourceIndex: index
|
|
22488
23548
|
};
|
|
23549
|
+
if (s.hidden !== void 0) view.hidden = s.hidden;
|
|
23550
|
+
if (s.boxWhisker) {
|
|
23551
|
+
view.boxWhisker = s.boxWhisker;
|
|
23552
|
+
view.boxCategories = categoryValues.map(toText);
|
|
23553
|
+
}
|
|
23554
|
+
if (s.numberFormat !== void 0) view.numberFormat = s.numberFormat;
|
|
23555
|
+
if (s.showLine !== void 0) view.showLine = s.showLine;
|
|
23556
|
+
if (s.smooth !== void 0) view.smooth = s.smooth;
|
|
23557
|
+
if (s.line)
|
|
23558
|
+
view.stroke = strokeOf(s.line, { color, width: 2.25 }, ctx.drawingColor) ?? {
|
|
23559
|
+
color: "none",
|
|
23560
|
+
width: 0
|
|
23561
|
+
};
|
|
22489
23562
|
const shadow = resolveDrawingShadowXml(s.effectsXml, { scheme: (name) => scheme2[name] });
|
|
22490
23563
|
if (shadow) view.shadow = shadow;
|
|
22491
23564
|
const resolvedGradient = ctx.gradient(s.fill);
|
|
@@ -22630,52 +23703,8 @@ function categoryTotals(model) {
|
|
|
22630
23703
|
);
|
|
22631
23704
|
}
|
|
22632
23705
|
|
|
22633
|
-
// chart/render/chart-title-text.ts
|
|
22634
|
-
function properties(run) {
|
|
22635
|
-
return {
|
|
22636
|
-
...run.sizePt === void 0 ? {} : { fontSize: run.sizePt },
|
|
22637
|
-
...run.bold === void 0 ? {} : { bold: run.bold },
|
|
22638
|
-
...run.italic === void 0 ? {} : { italic: run.italic },
|
|
22639
|
-
...run.underline === void 0 ? {} : { underline: run.underline },
|
|
22640
|
-
...run.typeface === void 0 ? {} : { typeface: run.typeface },
|
|
22641
|
-
...run.color === void 0 ? {} : { textColor: run.color }
|
|
22642
|
-
};
|
|
22643
|
-
}
|
|
22644
|
-
function chartTitleText(chart, theme) {
|
|
22645
|
-
const formatting2 = chart.formatting;
|
|
22646
|
-
const entry = formatting2?.entries.title;
|
|
22647
|
-
const body = entry?.textBody;
|
|
22648
|
-
if (!formatting2 || !body || body.text !== chart.title) return void 0;
|
|
22649
|
-
if (body.paragraphs.length === 1 && body.paragraphs[0].runs.length <= 1 && !body.text.includes("\n") && !body.paragraphs[0].lineSpacing && !body.paragraphs[0].spaceBefore && !body.paragraphs[0].spaceAfter)
|
|
22650
|
-
return void 0;
|
|
22651
|
-
return {
|
|
22652
|
-
paragraphs: body.paragraphs.map((paragraph) => ({
|
|
22653
|
-
...paragraph.align ? { align: paragraph.align } : {},
|
|
22654
|
-
...paragraph.lineSpacing ? { lineSpacing: paragraph.lineSpacing } : {},
|
|
22655
|
-
...paragraph.spaceBefore ? { spaceBefore: paragraph.spaceBefore } : {},
|
|
22656
|
-
...paragraph.spaceAfter ? { spaceAfter: paragraph.spaceAfter } : {},
|
|
22657
|
-
runs: paragraph.runs.map((run) => {
|
|
22658
|
-
const direct = {
|
|
22659
|
-
sourceXml: "",
|
|
22660
|
-
...entry.textBodyStyle,
|
|
22661
|
-
...properties(paragraph.defaultProperties ?? {}),
|
|
22662
|
-
...properties(run)
|
|
22663
|
-
};
|
|
22664
|
-
const appearance = chartAppearance(
|
|
22665
|
-
{
|
|
22666
|
-
...chart,
|
|
22667
|
-
formatting: { ...formatting2, entries: { ...formatting2.entries, title: direct } }
|
|
22668
|
-
},
|
|
22669
|
-
theme
|
|
22670
|
-
)?.title ?? {};
|
|
22671
|
-
return { text: run.text, appearance };
|
|
22672
|
-
})
|
|
22673
|
-
}))
|
|
22674
|
-
};
|
|
22675
|
-
}
|
|
22676
|
-
|
|
22677
23706
|
// chart/render/chart-view-labels.ts
|
|
22678
|
-
function labelsOf(source, view, categories, numberFormat) {
|
|
23707
|
+
function labelsOf(source, view, categories, numberFormat, resolveColor) {
|
|
22679
23708
|
const { chart, series, points } = source;
|
|
22680
23709
|
if ((series?.deleted ?? chart?.deleted) === true) return void 0;
|
|
22681
23710
|
const percentBase = view.values.reduce(
|
|
@@ -22711,19 +23740,35 @@ function labelsOf(source, view, categories, numberFormat) {
|
|
|
22711
23740
|
});
|
|
22712
23741
|
}
|
|
22713
23742
|
if (!built) return;
|
|
23743
|
+
const layout = point?.layout;
|
|
23744
|
+
const showLeaderLines = series?.showLeaderLines ?? chart?.showLeaderLines;
|
|
23745
|
+
const leaderLine = strokeOf(
|
|
23746
|
+
series?.leaderLine ?? chart?.leaderLine,
|
|
23747
|
+
{ color: "#94a3b8", width: 0.75 },
|
|
23748
|
+
resolveColor
|
|
23749
|
+
) ?? { color: "none", width: 0 };
|
|
22714
23750
|
any = true;
|
|
22715
23751
|
out[i] = {
|
|
22716
23752
|
text: built.text,
|
|
23753
|
+
...layout ? { layout } : {},
|
|
23754
|
+
...showLeaderLines !== void 0 ? { showLeaderLines } : {},
|
|
23755
|
+
...leaderLine ? { leaderLine } : {},
|
|
22717
23756
|
...position2 ? { position: position2 } : {},
|
|
22718
23757
|
...built.color ? { color: built.color } : {}
|
|
22719
23758
|
};
|
|
22720
23759
|
});
|
|
22721
23760
|
return any ? out : void 0;
|
|
22722
23761
|
}
|
|
22723
|
-
function applyDataLabels(model, sources, extra) {
|
|
23762
|
+
function applyDataLabels(model, sources, extra, resolveColor) {
|
|
22724
23763
|
const apply = (source, view) => {
|
|
22725
23764
|
if (!source?.dataLabels) return;
|
|
22726
|
-
const labels = labelsOf(
|
|
23765
|
+
const labels = labelsOf(
|
|
23766
|
+
source.dataLabels,
|
|
23767
|
+
view,
|
|
23768
|
+
model.categories,
|
|
23769
|
+
source.numberFormat,
|
|
23770
|
+
resolveColor
|
|
23771
|
+
);
|
|
22727
23772
|
if (labels) view.labels = labels;
|
|
22728
23773
|
};
|
|
22729
23774
|
model.series.forEach((view, i) => apply(sources[i], view));
|
|
@@ -22828,7 +23873,9 @@ var SUPPORTED = /* @__PURE__ */ new Set([
|
|
|
22828
23873
|
"bubble",
|
|
22829
23874
|
"stock",
|
|
22830
23875
|
"treemap",
|
|
22831
|
-
"sunburst"
|
|
23876
|
+
"sunburst",
|
|
23877
|
+
"funnel",
|
|
23878
|
+
"boxWhisker"
|
|
22832
23879
|
]);
|
|
22833
23880
|
function chartSummaryView(chart, theme, options2 = {}) {
|
|
22834
23881
|
const type = chart.chartType;
|
|
@@ -22886,10 +23933,17 @@ function chartSummaryView(chart, theme, options2 = {}) {
|
|
|
22886
23933
|
showLegend: chart.showLegend,
|
|
22887
23934
|
legendPosition: chart.legendPosition ?? "r",
|
|
22888
23935
|
categories,
|
|
22889
|
-
series,
|
|
23936
|
+
series: type === "boxWhisker" ? series.filter((s) => !s.hidden) : series,
|
|
22890
23937
|
horizontal: type === "bar",
|
|
22891
23938
|
supported: SUPPORTED.has(type)
|
|
22892
23939
|
};
|
|
23940
|
+
const table = chartDataTableView(chart, theme, ctx.drawingColor);
|
|
23941
|
+
if (table) model.dataTable = table;
|
|
23942
|
+
if (chart.date1904 !== void 0) model.date1904 = chart.date1904;
|
|
23943
|
+
if (chart.axes?.some((a) => a.kind === "date")) model.dateCategories = firstCats.map(toNumber);
|
|
23944
|
+
if (chart.plotLayout) model.plotLayout = chart.plotLayout;
|
|
23945
|
+
if (type === "boxWhisker")
|
|
23946
|
+
model.categories = [...new Set(model.series.flatMap((s) => s.boxCategories ?? []))];
|
|
22893
23947
|
if (chart.title) model.title = chart.title;
|
|
22894
23948
|
const titleFormatting = chart.formatting?.entries.title;
|
|
22895
23949
|
if (titleFormatting?.layout) model.titleLayout = titleFormatting.layout;
|
|
@@ -22911,6 +23965,11 @@ function chartSummaryView(chart, theme, options2 = {}) {
|
|
|
22911
23965
|
const range = extentOf(xs);
|
|
22912
23966
|
model.xAxis = xs.length ? niceScale(range.min, range.max) : niceScale(0, 1);
|
|
22913
23967
|
}
|
|
23968
|
+
if (type === "funnel" || type === "boxWhisker")
|
|
23969
|
+
series.forEach((s, i) => {
|
|
23970
|
+
const points = chart.series[i]?.pointColors;
|
|
23971
|
+
if (points) s.pointColors = s.values.map((_, j) => drawingColor(points[j]) ?? s.color);
|
|
23972
|
+
});
|
|
22914
23973
|
if (type === "stock") model.stock = stockView(chart.stock, ctx);
|
|
22915
23974
|
if (type === "bubble") bubbleView(chart, model, ctx.evaluateRef);
|
|
22916
23975
|
if (type === "treemap" || type === "sunburst") hierarchyView(chart, model, ctx.evaluateRef);
|
|
@@ -22919,23 +23978,31 @@ function chartSummaryView(chart, theme, options2 = {}) {
|
|
|
22919
23978
|
chartExtraView(chart, model, ctx, total, collect);
|
|
22920
23979
|
if (type === "waterfall") waterfallView(chart, model, ctx);
|
|
22921
23980
|
else if (!byPoint) model.valueAxis = valueAxis(model);
|
|
22922
|
-
applyDataLabels(model, chart.series, extra);
|
|
23981
|
+
applyDataLabels(model, chart.series, extra, ctx.drawingColor);
|
|
22923
23982
|
chartExtraAxes(model);
|
|
22924
23983
|
applyChartAxes(model, chart, ctx.drawingColor);
|
|
22925
23984
|
return model;
|
|
22926
23985
|
}
|
|
22927
23986
|
|
|
22928
23987
|
// chart/render/chart-svg-cartesian.ts
|
|
22929
|
-
function cartesianAxes(model, area, out) {
|
|
23988
|
+
function cartesianAxes(model, area, out, size) {
|
|
22930
23989
|
const scale = model.valueAxis;
|
|
22931
23990
|
if (!scale) return void 0;
|
|
23991
|
+
const table = chartTableMetrics(model);
|
|
23992
|
+
if (table)
|
|
23993
|
+
area = {
|
|
23994
|
+
...area,
|
|
23995
|
+
x: Math.max(area.x, table.keyW + 8),
|
|
23996
|
+
w: Math.max(1, area.w - Math.max(0, table.keyW + 8 - area.x)),
|
|
23997
|
+
h: Math.max(1, area.h - table.height)
|
|
23998
|
+
};
|
|
22932
23999
|
const labels = scale.ticks.map((t) => axisTickText(t, model.axes?.value, scale.percent));
|
|
22933
24000
|
const valueAttrs = chartTextAttributes(model, "valueAxis");
|
|
22934
24001
|
const categoryAttrs = chartTextAttributes(model, "categoryAxis");
|
|
22935
24002
|
const valueSize = valueAttrs.size ?? 10;
|
|
22936
24003
|
const categorySize = categoryAttrs.size ?? 10;
|
|
22937
24004
|
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
22938
|
-
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
24005
|
+
const categoryLabels = !table && chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
22939
24006
|
const labelW = valueLabels ? Math.max(...labels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
22940
24007
|
const horizontal = model.horizontal;
|
|
22941
24008
|
const cats = Math.max(1, model.categories.length);
|
|
@@ -22946,7 +24013,7 @@ function cartesianAxes(model, area, out) {
|
|
|
22946
24013
|
const second = horizontal ? void 0 : model.secondaryAxis;
|
|
22947
24014
|
const secondLabels = second?.ticks.map((t) => axisTickText(t, model.axes?.secondary, second.percent)) ?? [];
|
|
22948
24015
|
const secondW = second ? valueLabels ? Math.max(...secondLabels.map((l) => textWidth(l, valueSize)), 8) + 8 : 4 : 0;
|
|
22949
|
-
const
|
|
24016
|
+
const auto = horizontal ? {
|
|
22950
24017
|
x: area.x + catW,
|
|
22951
24018
|
y: area.y,
|
|
22952
24019
|
w: Math.max(1, area.w - catW - 4),
|
|
@@ -22957,10 +24024,13 @@ function cartesianAxes(model, area, out) {
|
|
|
22957
24024
|
w: Math.max(1, area.w - labelW - 4 - secondW),
|
|
22958
24025
|
h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
|
|
22959
24026
|
};
|
|
24027
|
+
const plot = chartPlotRect(model, auto, area, size);
|
|
22960
24028
|
const value = horizontal ? (v) => plot.x + chartAxisRatio(v, scale, model.axes?.value) * plot.w : (v) => plot.y + plot.h - chartAxisRatio(v, scale, model.axes?.value) * plot.h;
|
|
22961
|
-
const
|
|
24029
|
+
const dateMarkup = [];
|
|
24030
|
+
const dates = chartDateAxis(model, plot, dateMarkup);
|
|
24031
|
+
const bandSize = dates?.bandSize ?? (horizontal ? plot.h : plot.w) / cats;
|
|
22962
24032
|
const index = (i) => model.axes?.category?.range.reverseOrder ? cats - 1 - i : i;
|
|
22963
|
-
const band = horizontal ? (i) => plot.y + plot.h - bandSize * (index(i) + 0.5) : (i) => plot.x + bandSize * (index(i) + 0.5);
|
|
24033
|
+
const band = dates?.band ?? (horizontal ? (i) => plot.y + plot.h - bandSize * (index(i) + 0.5) : (i) => plot.x + bandSize * (index(i) + 0.5));
|
|
22964
24034
|
out.push(chartAreaRect(model, "plotArea", plot));
|
|
22965
24035
|
out.push(axisGridlines(model, model.axes?.value, scale.ticks, value, plot, horizontal));
|
|
22966
24036
|
if (model.axes?.category?.source.majorGridlines || model.axes?.category?.source.minorGridlines)
|
|
@@ -22998,12 +24068,13 @@ function cartesianAxes(model, area, out) {
|
|
|
22998
24068
|
out.push(
|
|
22999
24069
|
axisLine(model, model.axes?.category, "categoryAxis", plot.x, zero, plot.x + plot.w, zero)
|
|
23000
24070
|
);
|
|
24071
|
+
out.push(...dateMarkup);
|
|
23001
24072
|
const step = Math.max(
|
|
23002
24073
|
1,
|
|
23003
24074
|
Math.ceil(cats / Math.max(1, Math.floor((horizontal ? plot.h : plot.w) / 14)))
|
|
23004
24075
|
);
|
|
23005
24076
|
model.categories.forEach((c, i) => {
|
|
23006
|
-
if (!categoryLabels || i % step !== 0) return;
|
|
24077
|
+
if (dates || !categoryLabels || i % step !== 0) return;
|
|
23007
24078
|
const p = band(i);
|
|
23008
24079
|
if (horizontal)
|
|
23009
24080
|
out.push(
|
|
@@ -23020,7 +24091,7 @@ function cartesianAxes(model, area, out) {
|
|
|
23020
24091
|
})
|
|
23021
24092
|
);
|
|
23022
24093
|
});
|
|
23023
|
-
const frame2 = { plot, value, band, bandSize };
|
|
24094
|
+
const frame2 = { plot, value, band, bandSize, ...dates ? { order: dates.order } : {} };
|
|
23024
24095
|
if (second) {
|
|
23025
24096
|
frame2.secondary = (v) => plot.y + plot.h - chartAxisRatio(v, second, model.axes?.secondary) * plot.h;
|
|
23026
24097
|
out.push(
|
|
@@ -23067,7 +24138,7 @@ function linesAndAreas(model, frame2, out) {
|
|
|
23067
24138
|
model.series.forEach((s, si) => {
|
|
23068
24139
|
const points = [];
|
|
23069
24140
|
const lower = [];
|
|
23070
|
-
model.categories.
|
|
24141
|
+
(frame2.order ?? model.categories.map((_, i) => i)).forEach((i) => {
|
|
23071
24142
|
const v = values[si]?.[i] ?? null;
|
|
23072
24143
|
if (v === null && !area) {
|
|
23073
24144
|
points.push([NaN, NaN]);
|
|
@@ -23102,26 +24173,24 @@ function linesAndAreas(model, frame2, out) {
|
|
|
23102
24173
|
}
|
|
23103
24174
|
let segment2 = [];
|
|
23104
24175
|
const flush = () => {
|
|
23105
|
-
|
|
23106
|
-
out.push(
|
|
23107
|
-
`<polyline points="${segment2.join(" ")}" fill="none" stroke="${color}" stroke-width="2.25" stroke-linejoin="round"${filter}/>`
|
|
23108
|
-
);
|
|
24176
|
+
out.push(chartLineSvg(segment2, series));
|
|
23109
24177
|
segment2 = [];
|
|
23110
24178
|
};
|
|
23111
24179
|
for (const [x, y] of points) {
|
|
23112
24180
|
if (Number.isNaN(x)) flush();
|
|
23113
|
-
else segment2.push(
|
|
24181
|
+
else segment2.push({ x, y });
|
|
23114
24182
|
}
|
|
23115
24183
|
flush();
|
|
23116
24184
|
points.forEach(([x, y], index) => {
|
|
23117
|
-
if (!Number.isNaN(x))
|
|
24185
|
+
if (!Number.isNaN(x))
|
|
24186
|
+
out.push(chartSeriesMarkerSvg(series, frame2.order?.[index] ?? index, x, y, 2.5));
|
|
23118
24187
|
});
|
|
23119
24188
|
}
|
|
23120
24189
|
pointLabels(model, marks, out);
|
|
23121
24190
|
}
|
|
23122
24191
|
|
|
23123
24192
|
// chart/render/chart-svg-xy.ts
|
|
23124
|
-
function scatter(model, area, out) {
|
|
24193
|
+
function scatter(model, area, out, size) {
|
|
23125
24194
|
const ys = model.valueAxis;
|
|
23126
24195
|
const xs = model.xAxis;
|
|
23127
24196
|
if (!ys || !xs) return;
|
|
@@ -23134,18 +24203,19 @@ function scatter(model, area, out) {
|
|
|
23134
24203
|
const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
|
|
23135
24204
|
const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
|
|
23136
24205
|
const labelW = valueLabels ? Math.max(...yLabels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
|
|
23137
|
-
const
|
|
24206
|
+
const auto = {
|
|
23138
24207
|
x: area.x + labelW,
|
|
23139
24208
|
y: area.y + 4,
|
|
23140
24209
|
w: Math.max(1, area.w - labelW - 8),
|
|
23141
24210
|
h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
|
|
23142
24211
|
};
|
|
24212
|
+
const plot = chartPlotRect(model, auto, area, size);
|
|
23143
24213
|
const bubble = model.type === "bubble" ? model.bubble : void 0;
|
|
23144
24214
|
const biggest = maxBubbleSize(
|
|
23145
24215
|
model.series.flatMap((s) => (s.sizes ?? []).filter((v) => v !== null))
|
|
23146
24216
|
);
|
|
23147
24217
|
const median = medianBubbleRadius(plot.w, plot.h);
|
|
23148
|
-
const radiusOf = (
|
|
24218
|
+
const radiusOf = (size2) => bubble && !(size2 !== void 0 && size2 < 0 && !bubble.showNegativeBubbles) ? computeBubbleRadius(size2, biggest, median, bubble) : void 0;
|
|
23149
24219
|
let reach = 0;
|
|
23150
24220
|
if (bubble)
|
|
23151
24221
|
for (const s of model.series)
|
|
@@ -23154,11 +24224,11 @@ function scatter(model, area, out) {
|
|
|
23154
24224
|
});
|
|
23155
24225
|
const widen = (s, length, axis) => {
|
|
23156
24226
|
if (axis?.range.logScale) return s;
|
|
23157
|
-
const
|
|
24227
|
+
const pad2 = reach * (s.max - s.min || 1) / Math.max(1, length - 2 * reach);
|
|
23158
24228
|
return {
|
|
23159
24229
|
...s,
|
|
23160
|
-
min: axis?.source.scaling.min === void 0 ? s.min -
|
|
23161
|
-
max: axis?.source.scaling.max === void 0 ? s.max +
|
|
24230
|
+
min: axis?.source.scaling.min === void 0 ? s.min - pad2 : s.min,
|
|
24231
|
+
max: axis?.source.scaling.max === void 0 ? s.max + pad2 : s.max
|
|
23162
24232
|
};
|
|
23163
24233
|
};
|
|
23164
24234
|
const xView = widen(xs, plot.w, model.axes?.category);
|
|
@@ -23203,6 +24273,21 @@ function scatter(model, area, out) {
|
|
|
23203
24273
|
out.push(
|
|
23204
24274
|
axisLine(model, model.axes?.value, "valueAxis", plot.x, plot.y, plot.x, plot.y + plot.h)
|
|
23205
24275
|
);
|
|
24276
|
+
if (!bubble)
|
|
24277
|
+
for (const series of model.series) {
|
|
24278
|
+
if (!series.showLine) continue;
|
|
24279
|
+
let run = [];
|
|
24280
|
+
const flush = () => {
|
|
24281
|
+
out.push(chartLineSvg(run, series));
|
|
24282
|
+
run = [];
|
|
24283
|
+
};
|
|
24284
|
+
series.values.forEach((value, i) => {
|
|
24285
|
+
const x = series.xValues?.[i];
|
|
24286
|
+
if (value === null || x === null || x === void 0) flush();
|
|
24287
|
+
else run.push({ x: px(x), y: py(value) });
|
|
24288
|
+
});
|
|
24289
|
+
flush();
|
|
24290
|
+
}
|
|
23206
24291
|
const marks = [];
|
|
23207
24292
|
for (const [si, s] of model.series.entries())
|
|
23208
24293
|
s.values.forEach((v, i) => {
|
|
@@ -23334,14 +24419,19 @@ function clusterLayers(layers) {
|
|
|
23334
24419
|
}
|
|
23335
24420
|
return out;
|
|
23336
24421
|
}
|
|
23337
|
-
function cartesianSvg(model, area) {
|
|
24422
|
+
function cartesianSvg(model, area, size) {
|
|
23338
24423
|
const out = [];
|
|
23339
24424
|
if (model.type === "scatter" || model.type === "bubble") {
|
|
23340
|
-
scatter(model, area, out);
|
|
24425
|
+
scatter(model, area, out, size);
|
|
23341
24426
|
return out.join("");
|
|
23342
24427
|
}
|
|
23343
|
-
const frame2 = cartesianAxes(model, area, out);
|
|
24428
|
+
const frame2 = cartesianAxes(model, area, out, size);
|
|
23344
24429
|
if (!frame2) return "";
|
|
24430
|
+
out.push(chartDataTableSvg(model, frame2.plot));
|
|
24431
|
+
if (model.type === "boxWhisker") {
|
|
24432
|
+
boxWhiskerSvg(model, frame2, out);
|
|
24433
|
+
return out.join("");
|
|
24434
|
+
}
|
|
23345
24435
|
if (model.type === "waterfall") {
|
|
23346
24436
|
waterfallBars(model, frame2, out);
|
|
23347
24437
|
return out.join("");
|
|
@@ -23374,6 +24464,83 @@ function cartesianSvg(model, area) {
|
|
|
23374
24464
|
return out.join("");
|
|
23375
24465
|
}
|
|
23376
24466
|
|
|
24467
|
+
// chart/render/chart-svg-slice-labels.ts
|
|
24468
|
+
var GAP2 = 3;
|
|
24469
|
+
function sliceLabels(model, marks, out) {
|
|
24470
|
+
const items = [];
|
|
24471
|
+
for (const mark of marks) {
|
|
24472
|
+
const label = mark.series.labels?.[mark.index];
|
|
24473
|
+
if (!label) continue;
|
|
24474
|
+
const m = measure3(model, label);
|
|
24475
|
+
const mid = (mark.start + mark.end) / 2;
|
|
24476
|
+
const ux = Math.sin(mid);
|
|
24477
|
+
const uy = -Math.cos(mid);
|
|
24478
|
+
const place2 = (radius) => [
|
|
24479
|
+
mark.cx + radius * ux,
|
|
24480
|
+
mark.cy + radius * uy
|
|
24481
|
+
];
|
|
24482
|
+
const position2 = label.position ?? (model.type === "doughnut" ? "ctr" : "bestFit");
|
|
24483
|
+
let x;
|
|
24484
|
+
let y;
|
|
24485
|
+
if (position2 === "ctr") [x, y] = place2(mark.inner + (mark.outer - mark.inner) / 2);
|
|
24486
|
+
else if (position2 === "inEnd") {
|
|
24487
|
+
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
24488
|
+
[x, y] = place2(Math.max(0, mark.outer - GAP2 - extent));
|
|
24489
|
+
} else if (position2 === "outEnd") {
|
|
24490
|
+
const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
|
|
24491
|
+
[x, y] = place2(mark.outer + GAP2 + extent);
|
|
24492
|
+
} else {
|
|
24493
|
+
const placed = placeBestFitLabel(
|
|
24494
|
+
{
|
|
24495
|
+
cx: mark.cx,
|
|
24496
|
+
cy: mark.cy,
|
|
24497
|
+
outerR: mark.outer,
|
|
24498
|
+
startAngle: mark.start - Math.PI / 2,
|
|
24499
|
+
endAngle: mark.end - Math.PI / 2
|
|
24500
|
+
},
|
|
24501
|
+
m.w,
|
|
24502
|
+
m.h
|
|
24503
|
+
);
|
|
24504
|
+
x = placed.x;
|
|
24505
|
+
y = placed.y;
|
|
24506
|
+
}
|
|
24507
|
+
items.push({
|
|
24508
|
+
mark,
|
|
24509
|
+
label,
|
|
24510
|
+
m,
|
|
24511
|
+
x,
|
|
24512
|
+
y,
|
|
24513
|
+
outside: Math.hypot(x - mark.cx, y - mark.cy) > mark.outer
|
|
24514
|
+
});
|
|
24515
|
+
}
|
|
24516
|
+
const first3 = marks[0];
|
|
24517
|
+
if (!first3) return;
|
|
24518
|
+
const nudges = nudgeOutsideLabels(
|
|
24519
|
+
items.flatMap(
|
|
24520
|
+
(item2, id) => item2.outside && !item2.label.layout ? [{ id, x: item2.x, y: item2.y, w: item2.m.w, h: item2.m.h }] : []
|
|
24521
|
+
),
|
|
24522
|
+
{ cx: first3.cx, cy: first3.cy, r: first3.outer },
|
|
24523
|
+
first3.cy - first3.outer,
|
|
24524
|
+
first3.cy + first3.outer
|
|
24525
|
+
);
|
|
24526
|
+
for (const [id, item2] of items.entries()) {
|
|
24527
|
+
const { mark, label, m } = item2;
|
|
24528
|
+
const nudge = nudges.find((n2) => n2.id === id);
|
|
24529
|
+
let point = { x: item2.x + (nudge?.dx ?? 0), y: item2.y + (nudge?.dy ?? 0) };
|
|
24530
|
+
if (model.frameSize) point = applyLabelManualLayout(label.layout, model.frameSize, point);
|
|
24531
|
+
const moved = point.x !== item2.x || point.y !== item2.y;
|
|
24532
|
+
if (label.showLeaderLines !== false && (item2.outside || moved)) {
|
|
24533
|
+
const mid = (mark.start + mark.end) / 2;
|
|
24534
|
+
const stroke = label.leaderLine ?? { color: "#94a3b8", width: 0.75 };
|
|
24535
|
+
out.push(
|
|
24536
|
+
`<line x1="${n(mark.cx + mark.outer * Math.sin(mid))}" y1="${n(mark.cy - mark.outer * Math.cos(mid))}" x2="${n(point.x)}" y2="${n(point.y)}" ${strokeAttributes(stroke)} data-chart-part="leaderLine"/>`
|
|
24537
|
+
);
|
|
24538
|
+
}
|
|
24539
|
+
const { layout: _layout, ...fixed } = label;
|
|
24540
|
+
draw(m, fixed, point.x, point.y, "middle", out);
|
|
24541
|
+
}
|
|
24542
|
+
}
|
|
24543
|
+
|
|
23377
24544
|
// chart/render/chart-svg-radial.ts
|
|
23378
24545
|
var polar = (cx, cy, r, angle) => [
|
|
23379
24546
|
cx + r * Math.sin(angle),
|
|
@@ -23856,9 +25023,9 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
|
23856
25023
|
),
|
|
23857
25024
|
{ breakWords: true }
|
|
23858
25025
|
);
|
|
23859
|
-
const { spaceBefore, spaceAfter, ...
|
|
25026
|
+
const { spaceBefore, spaceAfter, ...properties3 } = line3;
|
|
23860
25027
|
return wrapped.map((runs, index) => ({
|
|
23861
|
-
...
|
|
25028
|
+
...properties3,
|
|
23862
25029
|
runs,
|
|
23863
25030
|
...index === 0 && spaceBefore ? { spaceBefore } : {},
|
|
23864
25031
|
...index === wrapped.length - 1 && spaceAfter ? { spaceAfter } : {}
|
|
@@ -23945,7 +25112,7 @@ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
|
|
|
23945
25112
|
// chart/render/chart-svg.ts
|
|
23946
25113
|
function renderChartSvg(model, width, height, options2 = {}) {
|
|
23947
25114
|
const paint2 = chartGradientPaint(model, Math.max(1, width), Math.max(1, height));
|
|
23948
|
-
model = paint2.model;
|
|
25115
|
+
model = { ...paint2.model, frameSize: { width: Math.max(1, width), height: Math.max(1, height) } };
|
|
23949
25116
|
const w = Math.max(1, width);
|
|
23950
25117
|
const h = Math.max(1, height);
|
|
23951
25118
|
const out = [];
|
|
@@ -24001,10 +25168,11 @@ function renderChartSvg(model, width, height, options2 = {}) {
|
|
|
24001
25168
|
if (!legend.foreground) out.push(legend.markup);
|
|
24002
25169
|
if (area.w > 4 && area.h > 4) {
|
|
24003
25170
|
if (model.type === "pie" || model.type === "doughnut") out.push(pieSvg(model, area));
|
|
25171
|
+
else if (model.type === "funnel") out.push(funnelSvg(model, area));
|
|
24004
25172
|
else if (model.type === "radar") out.push(radarSvg(model, area));
|
|
24005
25173
|
else if (model.type === "treemap") out.push(treemapSvg(model, area));
|
|
24006
25174
|
else if (model.type === "sunburst") out.push(sunburstSvg(model, area));
|
|
24007
|
-
else out.push(cartesianSvg(model, area));
|
|
25175
|
+
else out.push(cartesianSvg(model, area, { width: w, height: h }));
|
|
24008
25176
|
}
|
|
24009
25177
|
if (legend.foreground) out.push(legend.markup);
|
|
24010
25178
|
if (foregroundTitle) out.push(foregroundTitle);
|
|
@@ -24027,7 +25195,9 @@ var DRAWN_CHART_TYPES = /* @__PURE__ */ new Set([
|
|
|
24027
25195
|
"bubble",
|
|
24028
25196
|
"stock",
|
|
24029
25197
|
"treemap",
|
|
24030
|
-
"sunburst"
|
|
25198
|
+
"sunburst",
|
|
25199
|
+
"funnel",
|
|
25200
|
+
"boxWhisker"
|
|
24031
25201
|
]);
|
|
24032
25202
|
function chartThemePalette(theme, fonts = {}) {
|
|
24033
25203
|
return {
|
|
@@ -24214,7 +25384,7 @@ function geometry(doc, spec) {
|
|
|
24214
25384
|
const avLst = el2(doc, A_NS2, "a:avLst");
|
|
24215
25385
|
for (const [name, value] of Object.entries(spec.adjustments ?? {}))
|
|
24216
25386
|
add2(avLst, attrs(el2(doc, A_NS2, "a:gd"), { name, fmla: `val ${Math.round(value)}` }));
|
|
24217
|
-
const nodes = [add2(prst, avLst)];
|
|
25387
|
+
const nodes = spec.customGeometryXml ? importFragment(doc, spec.customGeometryXml) : [add2(prst, avLst)];
|
|
24218
25388
|
if (spec.fill) {
|
|
24219
25389
|
const xml = drawingFillXml(spec.fill);
|
|
24220
25390
|
if (xml) nodes.push(...importFragment(doc, xml));
|
|
@@ -24746,10 +25916,10 @@ function hasUnexpectedAttributes(element3, allowed, allowDateUtc = false) {
|
|
|
24746
25916
|
}
|
|
24747
25917
|
return false;
|
|
24748
25918
|
}
|
|
24749
|
-
function runPropertiesHaveUnknownContent(
|
|
24750
|
-
if (!
|
|
24751
|
-
if (hasUnexpectedAttributes(
|
|
24752
|
-
for (const node of Array.from(
|
|
25919
|
+
function runPropertiesHaveUnknownContent(properties3) {
|
|
25920
|
+
if (!properties3) return false;
|
|
25921
|
+
if (hasUnexpectedAttributes(properties3, [])) return true;
|
|
25922
|
+
for (const node of Array.from(properties3.childNodes)) {
|
|
24753
25923
|
if (node.nodeType !== 1) {
|
|
24754
25924
|
if (node.nodeType === 3 && node.textContent?.trim()) return true;
|
|
24755
25925
|
continue;
|
|
@@ -25207,7 +26377,7 @@ function parseRunStyleCatalog(xml) {
|
|
|
25207
26377
|
}
|
|
25208
26378
|
|
|
25209
26379
|
// docx/table-borders.ts
|
|
25210
|
-
var
|
|
26380
|
+
var SIDES3 = [
|
|
25211
26381
|
"top",
|
|
25212
26382
|
"bottom",
|
|
25213
26383
|
"left",
|
|
@@ -25233,7 +26403,7 @@ function parseTableBorders(bordersElement) {
|
|
|
25233
26403
|
if (!bordersElement) return void 0;
|
|
25234
26404
|
const result = {};
|
|
25235
26405
|
const alias = { left: "start", right: "end" };
|
|
25236
|
-
for (const side of
|
|
26406
|
+
for (const side of SIDES3) {
|
|
25237
26407
|
const aliasName = alias[side];
|
|
25238
26408
|
const value = borderSide(
|
|
25239
26409
|
first2(bordersElement, side) ?? (aliasName ? first2(bordersElement, aliasName) : void 0)
|
|
@@ -26457,12 +27627,12 @@ function contentLength(child3) {
|
|
|
26457
27627
|
}
|
|
26458
27628
|
function splitRun(run, offset) {
|
|
26459
27629
|
const children3 = Array.from(run.childNodes).filter(isElement);
|
|
26460
|
-
const
|
|
27630
|
+
const properties3 = children3.find((child3) => named2(child3, "rPr"));
|
|
26461
27631
|
const second = run.cloneNode(false);
|
|
26462
|
-
if (
|
|
27632
|
+
if (properties3) second.appendChild(properties3.cloneNode(true));
|
|
26463
27633
|
let seen = 0;
|
|
26464
27634
|
for (const child3 of children3) {
|
|
26465
|
-
if (child3 ===
|
|
27635
|
+
if (child3 === properties3) continue;
|
|
26466
27636
|
const length = contentLength(child3);
|
|
26467
27637
|
if (seen >= offset) second.appendChild(child3);
|
|
26468
27638
|
else if (seen + length > offset) {
|
|
@@ -26478,7 +27648,7 @@ function splitRun(run, offset) {
|
|
|
26478
27648
|
}
|
|
26479
27649
|
seen += length;
|
|
26480
27650
|
}
|
|
26481
|
-
if (second.childNodes.length === (
|
|
27651
|
+
if (second.childNodes.length === (properties3 ? 1 : 0)) return void 0;
|
|
26482
27652
|
run.parentNode.insertBefore(second, run.nextSibling);
|
|
26483
27653
|
return second;
|
|
26484
27654
|
}
|
|
@@ -26657,7 +27827,7 @@ function restoreAnnotations(markers, before, after) {
|
|
|
26657
27827
|
}
|
|
26658
27828
|
|
|
26659
27829
|
// docx/write-paragraph-decoration.ts
|
|
26660
|
-
var
|
|
27830
|
+
var SIDES4 = ["top", "left", "bottom", "right", "between"];
|
|
26661
27831
|
function wordColor(color) {
|
|
26662
27832
|
const hex = /^#?([0-9a-f]{6})$/i.exec(color ?? "")?.[1];
|
|
26663
27833
|
return hex ? hex.toUpperCase() : "auto";
|
|
@@ -26691,7 +27861,7 @@ function updateBorders(doc, props, paragraph, base) {
|
|
|
26691
27861
|
const borders = paragraph.borders;
|
|
26692
27862
|
if (!borders) return;
|
|
26693
27863
|
const pBdr = makeW(doc, "pBdr");
|
|
26694
|
-
for (const side of
|
|
27864
|
+
for (const side of SIDES4) {
|
|
26695
27865
|
const value = borders[side];
|
|
26696
27866
|
if (value) pBdr.appendChild(borderElement(doc, side, value));
|
|
26697
27867
|
}
|
|
@@ -27556,9 +28726,9 @@ function resolveNumberingLevel(catalog, numId, level3) {
|
|
|
27556
28726
|
let base = override?.lvl ?? abstract;
|
|
27557
28727
|
if (!base) return void 0;
|
|
27558
28728
|
if (override?.lvl) {
|
|
27559
|
-
const { lvlRestart: _ignored, ...
|
|
28729
|
+
const { lvlRestart: _ignored, ...properties3 } = base;
|
|
27560
28730
|
base = {
|
|
27561
|
-
...
|
|
28731
|
+
...properties3,
|
|
27562
28732
|
...abstract?.lvlRestart !== void 0 ? { lvlRestart: abstract.lvlRestart } : {}
|
|
27563
28733
|
};
|
|
27564
28734
|
}
|
|
@@ -27703,20 +28873,20 @@ function restoreParagraphFormatting(paragraph) {
|
|
|
27703
28873
|
throw new Error(
|
|
27704
28874
|
"Cannot reject a paragraph formatting revision without its prior properties snapshot."
|
|
27705
28875
|
);
|
|
27706
|
-
const
|
|
28876
|
+
const properties3 = parsePropertiesSnapshot(xml, "pPr");
|
|
27707
28877
|
if (paragraph.sourceParagraphPropertiesXml) {
|
|
27708
28878
|
const current = parsePropertiesSnapshot(paragraph.sourceParagraphPropertiesXml, "pPr");
|
|
27709
28879
|
for (const name of ["rPr", "sectPr"]) {
|
|
27710
28880
|
const element3 = first2(current, name);
|
|
27711
|
-
if (element3 && !first2(
|
|
27712
|
-
|
|
28881
|
+
if (element3 && !first2(properties3, name))
|
|
28882
|
+
properties3.appendChild(properties3.ownerDocument.importNode(element3, true));
|
|
27713
28883
|
}
|
|
27714
|
-
orderParagraphProperties(
|
|
28884
|
+
orderParagraphProperties(properties3);
|
|
27715
28885
|
}
|
|
27716
|
-
const previous = parseDirectParagraphProperties(
|
|
28886
|
+
const previous = parseDirectParagraphProperties(properties3);
|
|
27717
28887
|
for (const key of PARAGRAPH_FORMAT_KEYS) delete paragraph[key];
|
|
27718
28888
|
Object.assign(paragraph, previous);
|
|
27719
|
-
paragraph.restoredParagraphPropertiesXml = buildXml(
|
|
28889
|
+
paragraph.restoredParagraphPropertiesXml = buildXml(properties3);
|
|
27720
28890
|
if (paragraph.sourceParagraphPropertiesXml)
|
|
27721
28891
|
paragraph.sourceParagraphPropertiesXml = paragraph.restoredParagraphPropertiesXml;
|
|
27722
28892
|
delete paragraph.formatRevision;
|
|
@@ -28392,8 +29562,8 @@ function applyInlineFormat(run, child3) {
|
|
|
28392
29562
|
Object.assign(run, inlineRunProperties(child3));
|
|
28393
29563
|
const marks = { text: "", ...run.revision ? { revision: run.revision } : {} };
|
|
28394
29564
|
applyMarkFormatting(marks, child3);
|
|
28395
|
-
const { text: _text, ...
|
|
28396
|
-
Object.assign(run,
|
|
29565
|
+
const { text: _text, ...properties3 } = marks;
|
|
29566
|
+
Object.assign(run, properties3);
|
|
28397
29567
|
const ids = commentIdsFromNode(child3);
|
|
28398
29568
|
if (ids.length) run.commentIds = ids;
|
|
28399
29569
|
else delete run.commentIds;
|
|
@@ -28552,14 +29722,14 @@ function resolveFormattingRange(tr, from, to, mode) {
|
|
|
28552
29722
|
setInlineRunFormatting(tr, piece.from, run2);
|
|
28553
29723
|
continue;
|
|
28554
29724
|
}
|
|
28555
|
-
const
|
|
29725
|
+
const properties3 = piece.node.marks.find((mark) => mark.type.name === "runProperties");
|
|
28556
29726
|
if (mode === "accept") {
|
|
28557
|
-
const props = { ...
|
|
29727
|
+
const props = { ...properties3.attrs.props };
|
|
28558
29728
|
if (props.formatRevision) delete props.formatRevision;
|
|
28559
29729
|
else delete props.revision;
|
|
28560
|
-
tr.removeMark(piece.from, piece.to,
|
|
29730
|
+
tr.removeMark(piece.from, piece.to, properties3);
|
|
28561
29731
|
if (Object.keys(props).length)
|
|
28562
|
-
tr.addMark(piece.from, piece.to,
|
|
29732
|
+
tr.addMark(piece.from, piece.to, properties3.type.create({ props }));
|
|
28563
29733
|
continue;
|
|
28564
29734
|
}
|
|
28565
29735
|
const run = { text: "", revision: piece.revision };
|
|
@@ -28571,7 +29741,7 @@ function resolveFormattingRange(tr, from, to, mode) {
|
|
|
28571
29741
|
}
|
|
28572
29742
|
|
|
28573
29743
|
// docx/ui/track-run-formatting.ts
|
|
28574
|
-
function
|
|
29744
|
+
function properties(node) {
|
|
28575
29745
|
const run = inlineNodeRun(node) ?? { text: "" };
|
|
28576
29746
|
run.text = "";
|
|
28577
29747
|
delete run.image;
|
|
@@ -28607,8 +29777,8 @@ function trackRunFormatting(steps, oldState, newState, author, date, nextId) {
|
|
|
28607
29777
|
if (!previous.isInline || previous.type.name === "equation") return;
|
|
28608
29778
|
const start = Math.max(from, previousPos);
|
|
28609
29779
|
const end = Math.min(to, previousPos + previous.nodeSize);
|
|
28610
|
-
const before =
|
|
28611
|
-
const after =
|
|
29780
|
+
const before = properties(previous);
|
|
29781
|
+
const after = properties(node);
|
|
28612
29782
|
if (propertiesSignature(before) === propertiesSignature(after)) {
|
|
28613
29783
|
if (hasInlineRunAttributes(node) && node.marks.some((mark2) => RUN_FORMAT_MARKS.has(mark2.type.name)))
|
|
28614
29784
|
setInlineRunFormatting(tr, start, inlineNodeRun(node));
|
|
@@ -28771,7 +29941,7 @@ function paragraphProperties(element3) {
|
|
|
28771
29941
|
for (const child3 of children2(element3, name)) element3.removeChild(child3);
|
|
28772
29942
|
return element3;
|
|
28773
29943
|
}
|
|
28774
|
-
function
|
|
29944
|
+
function properties2(node) {
|
|
28775
29945
|
const paragraph = paragraphFromAttrs(node.attrs, String(node.attrs.id), []);
|
|
28776
29946
|
delete paragraph.formatRevision;
|
|
28777
29947
|
delete paragraph.markRevision;
|
|
@@ -28789,8 +29959,8 @@ function trackParagraphFormatting(steps, oldState, newState, author, date, nextI
|
|
|
28789
29959
|
if (node.type.name !== "paragraph" || !node.type.spec.attrs?.formatRevision) return;
|
|
28790
29960
|
const previous = oldState.doc.nodeAt(pos);
|
|
28791
29961
|
if (previous === node) return;
|
|
28792
|
-
const before =
|
|
28793
|
-
const after =
|
|
29962
|
+
const before = properties2(previous);
|
|
29963
|
+
const after = properties2(node);
|
|
28794
29964
|
if (propertiesSignature(before) === propertiesSignature(after)) return;
|
|
28795
29965
|
const pending = paragraphFormattingRevision(previous);
|
|
28796
29966
|
const priorXml = pending?.previousParagraphPropertiesXml ?? buildXml(before);
|
|
@@ -28912,9 +30082,9 @@ function fieldClipboardSlice(slice) {
|
|
|
28912
30082
|
});
|
|
28913
30083
|
return node.copy(prosemirrorModel.Fragment.fromArray(children4));
|
|
28914
30084
|
}
|
|
28915
|
-
const
|
|
30085
|
+
const properties3 = !node.isText && node.type.spec.attrs?.format ? inlineRunProperties(node) : void 0;
|
|
28916
30086
|
const field = node.marks.find((mark) => mark.type.name === "field");
|
|
28917
|
-
const cached2 =
|
|
30087
|
+
const cached2 = properties3?.field;
|
|
28918
30088
|
if (!field && !cached2) return node;
|
|
28919
30089
|
if (!(field?.attrs.simple ?? cached2?.simple) && complete.has(pos)) return node;
|
|
28920
30090
|
const marks = node.marks.flatMap((mark) => {
|
|
@@ -28923,8 +30093,8 @@ function fieldClipboardSlice(slice) {
|
|
|
28923
30093
|
const { fieldInstanceId: _identity, fieldFlags: _flags2, ...props } = mark.attrs.props ?? {};
|
|
28924
30094
|
return Object.keys(props).length ? [mark.type.create({ ...mark.attrs, props })] : [];
|
|
28925
30095
|
});
|
|
28926
|
-
if (!
|
|
28927
|
-
const { field: _field, fieldInstanceId: _id, fieldFlags: _flags, ...literal2 } =
|
|
30096
|
+
if (!properties3 || !cached2) return node.mark(marks);
|
|
30097
|
+
const { field: _field, fieldInstanceId: _id, fieldFlags: _flags, ...literal2 } = properties3;
|
|
28928
30098
|
return node.type.create(
|
|
28929
30099
|
updatedInlineRunAttributes(
|
|
28930
30100
|
node,
|
|
@@ -28987,14 +30157,14 @@ function trackSimpleFieldDeletion(transform, from, to, slice, author, date, next
|
|
|
28987
30157
|
function sourceProperties(value) {
|
|
28988
30158
|
if (typeof value !== "string" || !value) return value;
|
|
28989
30159
|
try {
|
|
28990
|
-
const
|
|
28991
|
-
const run = first2(
|
|
30160
|
+
const properties3 = parsePropertiesSnapshot(value, "pPr");
|
|
30161
|
+
const run = first2(properties3, "rPr");
|
|
28992
30162
|
if (run) {
|
|
28993
30163
|
for (const name of ["ins", "del"])
|
|
28994
30164
|
for (const revision of children2(run, name)) run.removeChild(revision);
|
|
28995
|
-
if (!run.childNodes.length && !run.attributes.length)
|
|
30165
|
+
if (!run.childNodes.length && !run.attributes.length) properties3.removeChild(run);
|
|
28996
30166
|
}
|
|
28997
|
-
return propertiesSignature(
|
|
30167
|
+
return propertiesSignature(properties3);
|
|
28998
30168
|
} catch {
|
|
28999
30169
|
return value;
|
|
29000
30170
|
}
|
|
@@ -29090,14 +30260,14 @@ function resultMarks(node, field) {
|
|
|
29090
30260
|
...typeof id === "string" && { fieldInstanceId: id },
|
|
29091
30261
|
...source?.fieldFlags && { fieldFlags: source.fieldFlags }
|
|
29092
30262
|
};
|
|
29093
|
-
const
|
|
29094
|
-
if (
|
|
29095
|
-
const old =
|
|
30263
|
+
const properties3 = node.type.schema.marks.runProperties;
|
|
30264
|
+
if (properties3) {
|
|
30265
|
+
const old = properties3.isInSet(marks);
|
|
29096
30266
|
const { fieldInstanceId: _identity, fieldFlags: _flags, ...other } = old?.attrs.props ?? {};
|
|
29097
30267
|
const props = { ...other, ...state };
|
|
29098
|
-
marks =
|
|
30268
|
+
marks = properties3.removeFromSet(marks);
|
|
29099
30269
|
if (Object.keys(props).length)
|
|
29100
|
-
marks =
|
|
30270
|
+
marks = properties3.create({ ...old?.attrs ?? {}, props }).addToSet(marks);
|
|
29101
30271
|
}
|
|
29102
30272
|
return marks;
|
|
29103
30273
|
}
|
|
@@ -29573,8 +30743,8 @@ function removeControl(tr, span) {
|
|
|
29573
30743
|
const { id } = span.control;
|
|
29574
30744
|
if (span.level === "row") {
|
|
29575
30745
|
const row = tr.doc.nodeAt(span.from);
|
|
29576
|
-
const { contentControl: _control, ...
|
|
29577
|
-
if (row) tr.setNodeMarkup(span.from, void 0, { ...row.attrs, properties:
|
|
30746
|
+
const { contentControl: _control, ...properties3 } = row?.attrs.properties ?? {};
|
|
30747
|
+
if (row) tr.setNodeMarkup(span.from, void 0, { ...row.attrs, properties: properties3 });
|
|
29578
30748
|
return tr;
|
|
29579
30749
|
}
|
|
29580
30750
|
if (span.level === "cell") {
|
|
@@ -30736,12 +31906,12 @@ function independentCommentAnchors(node) {
|
|
|
30736
31906
|
if (!node.isText && node.type.spec.attrs?.format && node.marks.some(
|
|
30737
31907
|
(mark) => mark.type.name === "comment" || mark.type.name === "inlineCommentAnchors"
|
|
30738
31908
|
)) {
|
|
30739
|
-
const
|
|
31909
|
+
const properties3 = inlineRunProperties(node);
|
|
30740
31910
|
const ids = commentIdsFromNode(node);
|
|
30741
|
-
if (ids.length)
|
|
30742
|
-
else delete
|
|
31911
|
+
if (ids.length) properties3.commentIds = ids;
|
|
31912
|
+
else delete properties3.commentIds;
|
|
30743
31913
|
return node.type.create(
|
|
30744
|
-
updatedInlineRunAttributes(node, JSON.stringify(
|
|
31914
|
+
updatedInlineRunAttributes(node, JSON.stringify(properties3)),
|
|
30745
31915
|
void 0,
|
|
30746
31916
|
marks.filter(
|
|
30747
31917
|
(mark) => mark.type.name !== "inlineCommentAnchors" && mark.type.name !== "comment"
|
|
@@ -31413,10 +32583,10 @@ var removeWordLink = (state, dispatch, view) => {
|
|
|
31413
32583
|
function patchedRun(node, patch) {
|
|
31414
32584
|
const run = inlineNodeRun(node);
|
|
31415
32585
|
if (!run) return void 0;
|
|
31416
|
-
const
|
|
32586
|
+
const properties3 = run;
|
|
31417
32587
|
for (const [key, value] of Object.entries(patch)) {
|
|
31418
|
-
if (value === void 0) delete
|
|
31419
|
-
else
|
|
32588
|
+
if (value === void 0) delete properties3[key];
|
|
32589
|
+
else properties3[key] = value;
|
|
31420
32590
|
}
|
|
31421
32591
|
return run;
|
|
31422
32592
|
}
|