🚀. Socket Launch Week Day 2:Introducing Manifest Alerts.Learn more
Sign In

@office-open/core

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@office-open/core - npm Package Compare versions

Comparing version
0.6.6
to
0.6.7
+617
dist/chart-DO9i3S1G.mjs
import { a as BuilderElement, b as XmlComponent, c as chartAttr, h as wrapEl, o as EmptyElement } from "./xml-components-ctIqansl.mjs";
//#region src/chart/axes.ts
/**
* c:scaling — axis scaling configuration (minOccurs=1 in EG_AxShared).
*/
var Scaling = class extends XmlComponent {
constructor() {
super("c:scaling");
this.root.push(wrapEl("c:orientation", chartAttr({ val: "minMax" })));
}
};
/**
* c:catAx — category axis.
*
* XSD sequence: EG_AxShared (axId, scaling, delete, axPos, ..., crossAx, crosses)
* then: auto, lblAlgn, lblOffset, tickLblSkip, tickMarkSkip, noMultiLvlLbl
*/
var CatAx = class extends XmlComponent {
constructor(axId, crossAx) {
super("c:catAx");
this.root.push(wrapEl("c:axId", chartAttr({ val: axId })));
this.root.push(new Scaling());
this.root.push(wrapEl("c:delete", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:axPos", chartAttr({ val: "b" })));
this.root.push(wrapEl("c:crossAx", chartAttr({ val: crossAx })));
this.root.push(wrapEl("c:crosses", chartAttr({ val: "autoZero" })));
this.root.push(wrapEl("c:auto", chartAttr({ val: 1 })));
this.root.push(wrapEl("c:lblOffset", chartAttr({ val: 100 })));
this.root.push(wrapEl("c:noMultiLvlLbl", chartAttr({ val: 0 })));
}
};
/**
* c:valAx — value axis.
*
* XSD sequence: EG_AxShared (axId, scaling, delete, axPos, ..., spPr, ..., crossAx, crosses)
* then: crossBetween, majorUnit, minorUnit, dispUnits
*/
var ValAx = class extends XmlComponent {
constructor(axId, crossAx) {
super("c:valAx");
this.root.push(wrapEl("c:axId", chartAttr({ val: axId })));
this.root.push(new Scaling());
this.root.push(wrapEl("c:delete", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:axPos", chartAttr({ val: "l" })));
this.root.push(wrapEl("c:numFmt", chartAttr({
formatCode: "General",
sourceLinked: 1
})));
this.root.push(new BuilderElement({ name: "c:spPr" }));
this.root.push(wrapEl("c:crossAx", chartAttr({ val: crossAx })));
this.root.push(wrapEl("c:crosses", chartAttr({ val: "autoZero" })));
}
};
//#endregion
//#region src/chart/series/series-data.ts
const createStrRef = (values) => {
return new StrRef(typeof values === "string" ? [values] : values);
};
const createNumRef = (values) => new NumRef(values);
var StrRef = class extends XmlComponent {
constructor(values) {
super("c:strRef");
this.root.push(new EmptyElement("c:f"));
this.root.push(new StrCache(values));
}
};
var StrCache = class extends XmlComponent {
constructor(values) {
super("c:strCache");
this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
for (let i = 0; i < values.length; i++) this.root.push(new StrPt(i, values[i]));
}
};
var StrPt = class extends XmlComponent {
constructor(index, value) {
super("c:pt");
this.root.push(chartAttr({ idx: index }));
this.root.push(new StringValue("c:v", value));
}
};
var NumRef = class extends XmlComponent {
constructor(values) {
super("c:numRef");
this.root.push(new EmptyElement("c:f"));
this.root.push(new NumCache(values));
}
};
var NumCache = class extends XmlComponent {
constructor(values) {
super("c:numCache");
this.root.push(new FormatCode("General"));
this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
for (let i = 0; i < values.length; i++) this.root.push(new NumPt(i, values[i]));
}
};
var NumPt = class extends XmlComponent {
constructor(index, value) {
super("c:pt");
this.root.push(chartAttr({ idx: index }));
this.root.push(new StringValue("c:v", String(value)));
}
};
var FormatCode = class extends XmlComponent {
constructor(code) {
super("c:formatCode");
this.root.push(code);
}
};
var StringValue = class extends XmlComponent {
constructor(name, val) {
super(name);
this.root.push(val);
}
};
//#endregion
//#region src/chart/chart-types/area-chart.ts
var AreaChart = class extends XmlComponent {
constructor(options) {
super("c:areaChart");
this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new AreaSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var AreaSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$4(series.name));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new SeriesCat$4(categories));
this.root.push(new SeriesVal$4(series.values));
}
};
var SeriesTx$4 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$4 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$4 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/bar-chart.ts
var BarChart = class extends XmlComponent {
constructor(options) {
super("c:barChart");
this.root.push(wrapEl("c:barDir", chartAttr({ val: options.barDirection })));
this.root.push(wrapEl("c:grouping", chartAttr({ val: "clustered" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new BarSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var BarSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$3(series.name));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new SeriesCat$3(categories));
this.root.push(new SeriesVal$3(series.values));
}
};
var SeriesTx$3 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$3 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$3 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/line-chart.ts
var LineChart = class extends XmlComponent {
constructor(options) {
super("c:lineChart");
this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new LineSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var LineSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$2(series.name));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new SeriesCat$2(categories));
this.root.push(new SeriesVal$2(series.values));
}
};
var SeriesTx$2 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$2 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$2 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/pie-chart.ts
var PieChart = class extends XmlComponent {
constructor(options) {
super("c:pieChart");
this.root.push(wrapEl("c:varyColors", chartAttr({ val: true })));
for (let i = 0; i < options.series.length; i++) this.root.push(new PieSeries(i, options.series[i], options.categories));
}
};
var PieSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$1(series.name));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new SeriesCat$1(categories));
this.root.push(new SeriesVal$1(series.values));
}
};
var SeriesTx$1 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$1 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$1 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/scatter-chart.ts
var ScatterChart = class extends XmlComponent {
constructor(options) {
super("c:scatterChart");
this.root.push(wrapEl("c:scatterStyle", chartAttr({ val: "line" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new ScatterSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var ScatterSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx(series.name));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new SeriesCat(categories));
this.root.push(new SeriesVal(series.values));
this.root.push(new EmptyElement("c:size"));
}
};
var SeriesTx = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/create-chart-type.ts
const createChartType = (options) => {
switch (options.type) {
case "column":
case "bar": return new BarChart({
barDirection: options.type === "column" ? "col" : "bar",
categories: options.categories,
series: options.series
});
case "line": return new LineChart({
categories: options.categories,
series: options.series
});
case "pie": return new PieChart({
categories: options.categories,
series: options.series
});
case "area": return new AreaChart({
categories: options.categories,
series: options.series
});
case "scatter": return new ScatterChart({
categories: options.categories,
series: options.series
});
default: throw new Error(`Unsupported chart type: ${options.type}`);
}
};
//#endregion
//#region src/chart/title.ts
var ChartTitle = class extends XmlComponent {
constructor(title) {
super("c:title");
this.root.push(new TitleTx(title));
this.root.push(new TitleOverlay());
}
};
var TitleTx = class extends XmlComponent {
constructor(title) {
super("c:tx");
const rich = new class extends XmlComponent {
constructor() {
super("c:rich");
}
}();
rich["root"].push(new class extends XmlComponent {
constructor() {
super("a:bodyPr");
}
}());
rich["root"].push(new class extends XmlComponent {
constructor() {
super("a:lstStyle");
}
}());
const p = new class extends XmlComponent {
constructor() {
super("a:p");
}
}();
const r = new class extends XmlComponent {
constructor() {
super("a:r");
}
}();
r["root"].push(new class extends XmlComponent {
constructor() {
super("a:t");
this.root.push(title);
}
}());
p["root"].push(r);
rich["root"].push(p);
this.root.push(rich);
}
};
var TitleOverlay = class extends XmlComponent {
constructor() {
super("c:overlay");
this.root.push(chartAttr({ val: 0 }));
}
};
//#endregion
//#region src/chart/chart-space.ts
/**
* ChartSpace — root element for chart XML parts (c:chartSpace).
*
* Full XSD-compliant implementation with all optional elements.
*
* @module
*/
/**
* c:chartSpace — root element for chart XML parts.
*/
var ChartSpace = class extends XmlComponent {
constructor(options) {
super("c:chartSpace");
this.root.push(chartAttr({
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
"xmlns:c": "http://schemas.openxmlformats.org/drawingml/2006/chart",
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
}));
this.root.push(wrapEl("c:date1904", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:lang", chartAttr({ val: "en-US" })));
this.root.push(wrapEl("c:roundedCorners", chartAttr({ val: 0 })));
if (options.style !== void 0) this.root.push(new ChartStyle(options.style));
const chart = new ChartContainer();
if (options.title) chart["root"].push(new ChartTitle(options.title));
chart["root"].push(wrapEl("c:autoTitleDeleted", chartAttr({ val: 0 })));
const plotArea = new PlotArea();
plotArea["root"].push(new BuilderElement({ name: "c:layout" }));
plotArea["root"].push(createChartType({
categories: options.categories,
series: options.series,
type: options.type
}));
if (options.type !== "pie") if (options.type === "scatter") {
plotArea["root"].push(new ValAx(10, 20));
plotArea["root"].push(new ValAx(20, 10));
} else {
plotArea["root"].push(new CatAx(10, 20));
plotArea["root"].push(new ValAx(20, 10));
}
chart["root"].push(plotArea);
if (options.showLegend !== false) chart["root"].push(createLegend());
this.root.push(chart);
this.root.push(createChartSpPr());
this.root.push(createChartTxPr());
}
};
var ChartContainer = class extends XmlComponent {
constructor() {
super("c:chart");
}
};
var PlotArea = class extends XmlComponent {
constructor() {
super("c:plotArea");
}
};
function createLegend() {
const legend = new class extends XmlComponent {
constructor() {
super("c:legend");
}
}();
legend["root"].push(wrapEl("c:legendPos", chartAttr({ val: "b" })));
legend["root"].push(new BuilderElement({ name: "c:layout" }));
legend["root"].push(wrapEl("c:overlay", chartAttr({ val: 0 })));
legend["root"].push(createNoFillSpPr());
legend["root"].push(createTxPr());
return legend;
}
function createNoFillSpPr() {
const spPr = new class extends XmlComponent {
constructor() {
super("c:spPr");
}
}();
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:ln");
this.root.push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
}
}());
spPr["root"].push(new BuilderElement({ name: "a:effectLst" }));
return spPr;
}
function createChartSpPr() {
const spPr = new class extends XmlComponent {
constructor() {
super("c:spPr");
}
}();
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:ln");
this.root.push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
}
}());
spPr["root"].push(new BuilderElement({ name: "a:effectLst" }));
return spPr;
}
function createChartTxPr() {
const txPr = new class extends XmlComponent {
constructor() {
super("c:txPr");
}
}();
txPr["root"].push(new BuilderElement({ name: "a:bodyPr" }));
txPr["root"].push(new BuilderElement({ name: "a:lstStyle" }));
txPr["root"].push(createTextParagraph());
return txPr;
}
function createTxPr() {
const txPr = new class extends XmlComponent {
constructor() {
super("c:txPr");
}
}();
txPr["root"].push(createBodyPr());
txPr["root"].push(new BuilderElement({ name: "a:lstStyle" }));
txPr["root"].push(createTextParagraph());
return txPr;
}
function createBodyPr() {
return new BuilderElement({
name: "a:bodyPr",
attributes: {
rot: {
key: "rot",
value: "0"
},
spcFirstLastPara: {
key: "spcFirstLastPara",
value: "1"
},
vertOverflow: {
key: "vertOverflow",
value: "ellipsis"
},
vert: {
key: "vert",
value: "horz"
},
wrap: {
key: "wrap",
value: "square"
},
anchor: {
key: "anchor",
value: "ctr"
},
anchorCtr: {
key: "anchorCtr",
value: "1"
}
}
});
}
function createTextParagraph() {
const p = new class extends XmlComponent {
constructor() {
super("a:p");
}
}();
const pPr = new class extends XmlComponent {
constructor() {
super("a:pPr");
}
}();
pPr["root"].push(new BuilderElement({ name: "a:defRPr" }));
p["root"].push(pPr);
p["root"].push(new BuilderElement({
name: "a:endParaRPr",
attributes: { lang: {
key: "lang",
value: "en-US"
} }
}));
return p;
}
var ChartStyle = class extends XmlComponent {
constructor(val) {
super("c:style");
this.root.push(chartAttr({ val: String(val) }));
}
};
//#endregion
//#region src/chart/chart-collection.ts
var ChartCollection = class {
map;
constructor() {
this.map = /* @__PURE__ */ new Map();
}
addChart(key, chartData) {
this.map.set(key, chartData);
}
get array() {
return [...this.map.values()];
}
};
//#endregion
export { ScatterChart as a, BarChart as c, createStrRef as d, CatAx as f, createChartType as i, AreaChart as l, ChartSpace as n, PieChart as o, ValAx as p, ChartTitle as r, LineChart as s, ChartCollection as t, createNumRef as u };
import { _ as CatAx, a as ChartData, c as ChartSeriesData, d as createChartType, f as ScatterChart, g as AreaChart, h as BarChart, i as ChartCollection, l as ChartType, m as LineChart, n as createNumRef, o as ChartSpace, p as PieChart, r as createStrRef, s as ChartSpaceOptions, t as ChartTitle, u as ChartTypeOptions, v as ValAx } from "../index-Bf86IyeY.mjs";
export { AreaChart, BarChart, CatAx, ChartCollection, ChartData, ChartSeriesData, ChartSpace, ChartSpaceOptions, ChartTitle, ChartType, ChartTypeOptions, LineChart, PieChart, ScatterChart, ValAx, createChartType, createNumRef, createStrRef };
import { a as ScatterChart, c as BarChart, d as createStrRef, f as CatAx, i as createChartType, l as AreaChart, n as ChartSpace, o as PieChart, p as ValAx, r as ChartTitle, s as LineChart, t as ChartCollection, u as createNumRef } from "../chart-DO9i3S1G.mjs";
export { AreaChart, BarChart, CatAx, ChartCollection, ChartSpace, ChartTitle, LineChart, PieChart, ScatterChart, ValAx, createChartType, createNumRef, createStrRef };

Sorry, the diff of this file is too big to display

import { $ as RectAlignment, $t as createSolidFill, A as createBevel, At as FillOptions, B as createSoftEdgeEffect, Bt as RelativeRect, C as GeometryGuide, Ct as createGroupFill, D as createShape3D, Dt as createNoFill, E as Shape3DOptions, Et as createPatternFill, F as Point3D, Ft as GradientShadeOptions, G as EffectListOptions, Gt as TileOptions, H as EffectDagOptions, Ht as createGradientFill, I as Scene3DOptions, It as GradientStop, J as createReflectionEffect, Jt as createSourceRectangle, K as createEffectList, Kt as createTileInfo, L as SphereCoords, Lt as LinearShadeOptions, M as BackdropOptions, Mt as buildFill, N as CameraOptions, Nt as extractBlipFillMedia, O as BevelOptions, Ot as BlipFillConfigOptions, P as LightRigOptions, Pt as GradientFillOptions, Q as OuterShadowEffectOptions, Qt as createColorElement, R as Vector3D, Rt as PathShadeOptions, S as PresetGeometryOptions, St as createCustomDash, T as PresetMaterialType, Tt as PresetPattern, U as createEffectDag, Ut as createGradientStop, V as EffectContainerType, Vt as TileFlipMode, W as BlurEffectOptions, Wt as TileAlignment, X as PresetShadowVal, Xt as createBlipEffects, Y as PresetShadowEffectOptions, Yt as BlipEffectsOptions, Z as createPresetShadowEffect, Zt as SolidFillOptions, _ as PathCommand, _t as LineEndOptions, a as Transform2DOptions, an as createSchemeColor, at as BlendMode, b as createCustomGeometry, bt as createLineEnd, c as Stretch, cn as RgbColorOptions, ct as CompoundLine, d as createBlipFill, dn as PresetColorOptions, dt as OutlineFillProperties, en as SystemColor, et as createOuterShadowEffect, f as BlipOptions, fn as createPresetColor, ft as OutlineOptions, g as GeomRect, gn as createColorTransforms, gt as LineEndLength, h as CustomGeometryOptions, hn as ColorTransformOptions, ht as createOutline, i as GroupTransform2DOptions, in as SchemeColorOptions, it as createGlowEffect, j as createBottomBevel, jt as GradientStopOptions, k as BevelPresetType, kt as BlipFillMediaData, l as createExtentionList, ln as createRgbColor, lt as LineCap, m as ConnectionSite, mn as createHslColor, mt as PresetDash, n as MediaTransformation, nn as createSystemColor, nt as createInnerShadowEffect, o as createGroupTransform2D, on as ScRgbColorOptions, ot as FillOverlayEffectOptions, p as createBlip, pn as HslColorOptions, pt as PenAlignment, q as ReflectionEffectOptions, qt as SourceRectangleOptions, r as createTransformation, rn as SchemeColor, rt as GlowEffectOptions, s as createTransform2D, sn as createScRgbColor, st as createFillOverlayEffect, t as MediaDataTransformation, tn as SystemColorOptions, tt as InnerShadowEffectOptions, u as BlipFillOptions, un as PresetColor, ut as LineJoin, v as PathFillMode, vt as LineEndType, w as createAdjustmentValues, wt as PatternFillOptions, x as PresetGeometry, xt as DashStop, y as PathOptions, yt as LineEndWidth, z as createScene3D, zt as PathShadeType } from "../index-CCGNb26x.mjs";
export { BackdropOptions, BevelOptions, BevelPresetType, BlendMode, BlipEffectsOptions, BlipFillConfigOptions, BlipFillMediaData, BlipFillOptions, BlipOptions, BlurEffectOptions, CameraOptions, ColorTransformOptions, CompoundLine, ConnectionSite, CustomGeometryOptions, DashStop, EffectContainerType, EffectDagOptions, EffectListOptions, FillOptions, FillOverlayEffectOptions, GeomRect, GeometryGuide, GlowEffectOptions, GradientFillOptions, GradientShadeOptions, GradientStop, GradientStopOptions, GroupTransform2DOptions, HslColorOptions, InnerShadowEffectOptions, LightRigOptions, LineCap, LineEndLength, LineEndOptions, LineEndType, LineEndWidth, LineJoin, LinearShadeOptions, MediaDataTransformation, MediaTransformation, OuterShadowEffectOptions, OutlineFillProperties, OutlineOptions, PathCommand, PathFillMode, PathOptions, PathShadeOptions, PathShadeType, PatternFillOptions, PenAlignment, Point3D, PresetColor, PresetColorOptions, PresetDash, PresetGeometry, PresetGeometryOptions, PresetMaterialType, PresetPattern, PresetShadowEffectOptions, PresetShadowVal, RectAlignment, ReflectionEffectOptions, RelativeRect, RgbColorOptions, ScRgbColorOptions, Scene3DOptions, SchemeColor, SchemeColorOptions, Shape3DOptions, SolidFillOptions, SourceRectangleOptions, SphereCoords, Stretch, SystemColor, SystemColorOptions, TileAlignment, TileFlipMode, TileOptions, Transform2DOptions, Vector3D, buildFill, createAdjustmentValues, createBevel, createBlip, createBlipEffects, createBlipFill, createBottomBevel, createColorElement, createColorTransforms, createCustomDash, createCustomGeometry, createEffectDag, createEffectList, createExtentionList, createFillOverlayEffect, createGlowEffect, createGradientFill, createGradientStop, createGroupFill, createGroupTransform2D, createHslColor, createInnerShadowEffect, createLineEnd, createNoFill, createOuterShadowEffect, createOutline, createPatternFill, createPresetColor, createPresetShadowEffect, createReflectionEffect, createRgbColor, createScRgbColor, createScene3D, createSchemeColor, createShape3D, createSoftEdgeEffect, createSolidFill, createSourceRectangle, createSystemColor, createTileInfo, createTransform2D, createTransformation, extractBlipFillMedia };
import { A as LineJoin, B as createNoFill, C as createOuterShadowEffect, Ct as createSchemeColor, D as createFillOverlayEffect, Dt as createPresetColor, E as BlendMode, Et as PresetColor, F as LineEndType, G as PathShadeType, H as extractBlipFillMedia, I as LineEndWidth, J as createGradientStop, K as TileFlipMode, L as createLineEnd, M as PresetDash, N as createOutline, O as CompoundLine, Ot as createHslColor, P as LineEndLength, R as createCustomDash, S as RectAlignment, St as SchemeColor, T as createGlowEffect, Tt as createRgbColor, U as PresetPattern, V as buildFill, W as createPatternFill, X as createTileInfo, Y as TileAlignment, _ as createEffectList, _t as createBlipEffects, a as createBlip, b as PresetShadowVal, bt as SystemColor, c as PresetGeometry, d as createShape3D, f as BevelPresetType, g as createEffectDag, gt as createSourceRectangle, h as createScene3D, ht as Stretch, i as createBlipFill, j as PenAlignment, k as LineCap, kt as createColorTransforms, l as createAdjustmentValues, m as createBottomBevel, n as createGroupTransform2D, o as createExtentionList, p as createBevel, q as createGradientFill, r as createTransform2D, s as createCustomGeometry, t as createTransformation, u as PresetMaterialType, v as createSoftEdgeEffect, vt as createColorElement, w as createInnerShadowEffect, wt as createScRgbColor, x as createPresetShadowEffect, xt as createSystemColor, y as createReflectionEffect, yt as createSolidFill, z as createGroupFill } from "../drawingml-DzU9sEb0.mjs";
export { BevelPresetType, BlendMode, CompoundLine, LineCap, LineEndLength, LineEndType, LineEndWidth, LineJoin, PathShadeType, PenAlignment, PresetColor, PresetDash, PresetGeometry, PresetMaterialType, PresetPattern, PresetShadowVal, RectAlignment, SchemeColor, Stretch, SystemColor, TileAlignment, TileFlipMode, buildFill, createAdjustmentValues, createBevel, createBlip, createBlipEffects, createBlipFill, createBottomBevel, createColorElement, createColorTransforms, createCustomDash, createCustomGeometry, createEffectDag, createEffectList, createExtentionList, createFillOverlayEffect, createGlowEffect, createGradientFill, createGradientStop, createGroupFill, createGroupTransform2D, createHslColor, createInnerShadowEffect, createLineEnd, createNoFill, createOuterShadowEffect, createOutline, createPatternFill, createPresetColor, createPresetShadowEffect, createReflectionEffect, createRgbColor, createScRgbColor, createScene3D, createSchemeColor, createShape3D, createSoftEdgeEffect, createSolidFill, createSourceRectangle, createSystemColor, createTileInfo, createTransform2D, createTransformation, extractBlipFillMedia };
import { C as XmlComponent } from "./index-bZQnCpM1.mjs";
//#region src/smartart/categories.d.ts
/** Layout ID → OOXML category type */
declare const LAYOUT_CATEGORIES: Record<string, string>;
/** Style ID → OOXML category type */
declare const STYLE_CATEGORIES: Record<string, string>;
/** Color ID → OOXML category type */
declare const COLOR_CATEGORIES: Record<string, string>;
//#endregion
//#region src/smartart/built-in-definitions.d.ts
/**
* Returns layout XML. Full XML for "default", minimal stub for others.
* Stub has no layoutNode so PowerPoint falls back to built-in definitions
* based on the uniqueId / loTypeId in the data model.
*/
declare function getLayoutXml(layoutId: string): string;
/**
* Returns style stub XML with the given uniqueId.
*/
declare function getStyleXml(styleId: string): string;
/**
* Returns color stub XML with the given uniqueId.
*/
declare function getColorXml(colorId: string): string;
/** Minimal drawing cache for SmartArt (Office apps auto-regenerate this on open) */
declare const DEFAULT_DRAWING_XML: string;
//#endregion
//#region src/smartart/data-model/connection.d.ts
/**
* dgm:cxn — SmartArt data model connection (edge).
*/
declare class Connection extends XmlComponent {
constructor(modelId: string, srcId: string, destId: string, type?: string, srcOrd?: number, destOrd?: number, parTransId?: string, sibTransId?: string);
}
//#endregion
//#region src/smartart/data-model/data-model.d.ts
/**
* CT_DataModel — the complete data model for a SmartArt diagram.
*/
declare class DataModel extends XmlComponent {
constructor(points: readonly XmlComponent[], connections: readonly Connection[]);
}
//#endregion
//#region src/smartart/data-model/point.d.ts
/**
* dgm:pt — SmartArt data model point (node).
*/
declare class Point extends XmlComponent {
constructor(modelId: string, text: string, type?: string);
}
/**
* Transition point (parTrans or sibTrans) — no text body, references a connection.
*/
declare class TransPoint extends XmlComponent {
constructor(modelId: string, type: string, cxnId: string);
}
//#endregion
//#region src/smartart/smartart-collection.d.ts
interface SmartArtData {
readonly key: string;
readonly dataModel: DataModel;
readonly layout: string;
readonly style: string;
readonly color: string;
}
/**
* Manages SmartArt parts in a document.
*/
declare class SmartArtCollection {
private readonly map;
constructor();
addSmartArt(key: string, data: SmartArtData): void;
get array(): readonly SmartArtData[];
}
//#endregion
//#region src/smartart/tree-to-model.d.ts
interface TreeNode {
readonly text: string;
readonly children?: readonly TreeNode[];
}
/**
* Creates a DataModel from tree nodes with layout/style/color settings.
*/
declare const createDataModel: (nodes: readonly TreeNode[], layout?: string, style?: string, color?: string) => DataModel;
//#endregion
export { Point as a, Connection as c, getLayoutXml as d, getStyleXml as f, STYLE_CATEGORIES as h, SmartArtData as i, DEFAULT_DRAWING_XML as l, LAYOUT_CATEGORIES as m, createDataModel as n, TransPoint as o, COLOR_CATEGORIES as p, SmartArtCollection as r, DataModel as s, TreeNode as t, getColorXml as u };
import { C as XmlComponent } from "./index-bZQnCpM1.mjs";
//#region src/chart/axes.d.ts
/**
* c:catAx — category axis.
*
* XSD sequence: EG_AxShared (axId, scaling, delete, axPos, ..., crossAx, crosses)
* then: auto, lblAlgn, lblOffset, tickLblSkip, tickMarkSkip, noMultiLvlLbl
*/
declare class CatAx extends XmlComponent {
constructor(axId: number, crossAx: number);
}
/**
* c:valAx — value axis.
*
* XSD sequence: EG_AxShared (axId, scaling, delete, axPos, ..., spPr, ..., crossAx, crosses)
* then: crossBetween, majorUnit, minorUnit, dispUnits
*/
declare class ValAx extends XmlComponent {
constructor(axId: number, crossAx: number);
}
//#endregion
//#region src/chart/chart-types/area-chart.d.ts
interface AreaChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class AreaChart extends XmlComponent {
constructor(options: AreaChartOptions);
}
//#endregion
//#region src/chart/chart-types/bar-chart.d.ts
interface BarChartOptions {
readonly barDirection: "col" | "bar";
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class BarChart extends XmlComponent {
constructor(options: BarChartOptions);
}
//#endregion
//#region src/chart/chart-types/line-chart.d.ts
interface LineChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class LineChart extends XmlComponent {
constructor(options: LineChartOptions);
}
//#endregion
//#region src/chart/chart-types/pie-chart.d.ts
interface PieChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class PieChart extends XmlComponent {
constructor(options: PieChartOptions);
}
//#endregion
//#region src/chart/chart-types/scatter-chart.d.ts
interface ScatterChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class ScatterChart extends XmlComponent {
constructor(options: ScatterChartOptions);
}
//#endregion
//#region src/chart/create-chart-type.d.ts
interface ChartSeriesData {
readonly name: string;
readonly values: readonly number[];
}
type ChartType = "column" | "bar" | "line" | "pie" | "area" | "scatter";
interface ChartTypeOptions {
readonly type: ChartType;
readonly series: readonly ChartSeriesData[];
readonly categories: readonly string[];
}
declare const createChartType: (options: ChartTypeOptions) => ScatterChart | BarChart | LineChart | PieChart | AreaChart;
//#endregion
//#region src/chart/chart-space.d.ts
interface ChartSpaceOptions {
readonly title?: string;
readonly type: ChartType;
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
readonly showLegend?: boolean;
readonly style?: number;
}
/**
* c:chartSpace — root element for chart XML parts.
*/
declare class ChartSpace extends XmlComponent {
constructor(options: ChartSpaceOptions);
}
//#endregion
//#region src/chart/chart-collection.d.ts
interface ChartData {
readonly key: string;
readonly chartSpace: XmlComponent;
}
declare class ChartCollection {
private readonly map;
constructor();
addChart(key: string, chartData: ChartData): void;
get array(): readonly ChartData[];
}
//#endregion
//#region src/chart/series/series-data.d.ts
declare const createStrRef: (values: string | readonly string[]) => XmlComponent;
declare const createNumRef: (values: readonly number[]) => XmlComponent;
//#endregion
//#region src/chart/title.d.ts
declare class ChartTitle extends XmlComponent {
constructor(title: string);
}
//#endregion
export { CatAx as _, ChartData as a, ChartSeriesData as c, createChartType as d, ScatterChart as f, AreaChart as g, BarChart as h, ChartCollection as i, ChartType as l, LineChart as m, createNumRef as n, ChartSpace as o, PieChart as p, createStrRef as r, ChartSpaceOptions as s, ChartTitle as t, ChartTypeOptions as u, ValAx as v };
import { r as PositiveUniversalMeasure } from "./values-QyWq4U4A.mjs";
import { Element } from "@office-open/xml";
//#region src/xml-components/types.d.ts
/**
* XML-serializable object types for OOXML document generation.
*
* @module
*/
/**
* Attributes for an XML element.
*/
type IXmlAttribute = Readonly<Record<string, string | number | boolean>>;
/**
* Object that can be serialized to XML.
*/
type IXmlableObject = Readonly<Record<string, any>>;
//#endregion
//#region src/xml-components/base.d.ts
/**
* Context object passed through the XML tree during serialization.
*
* @typeParam TFileData - The type of the root file data object (format-specific)
*/
interface Context<TFileData = unknown> {
/** The root file data object being serialized (format-specific). */
readonly fileData?: TFileData;
/** Current traversal stack of components (mutable for performance). */
readonly stack: IXmlableObject[];
}
/**
* Abstract base class for all XML components.
*/
declare abstract class BaseXmlComponent {
/** The XML element name for this component (e.g., "w:p" for paragraph). */
protected readonly rootKey: string;
constructor(rootKey: string);
/**
* Prepares this component for XML serialization.
*
* @param context - The serialization context
* @returns The XML-serializable object, or undefined to exclude from output
*/
abstract prepForXml(context: Context): IXmlableObject | undefined;
/**
* Direct XML serialization. Override in subclasses for zero-allocation output.
* Default falls back to prepForXml() + xml().
*/
toXml(context: Context): string;
}
//#endregion
//#region src/xml-components/component.d.ts
/**
* Empty object singleton used for empty XML elements.
*
* @internal
*/
declare const EMPTY_OBJECT: {};
/**
* Base class for all XML components in OOXML documents.
*
* `toXml()` traverses the `root` array and calls `toXml()` on each
* `BaseXmlComponent` child — this avoids building the intermediate
* `IXmlableObject` tree. Inline `IXmlableObject` children fall back to
* `xml()` for serialization.
*/
declare abstract class XmlComponent extends BaseXmlComponent {
/**
* Array of child components, text nodes, and attributes.
*/
root: (BaseXmlComponent | IXmlableObject | string)[];
constructor(rootKey: string);
/**
* Prepares this component and its children for XML serialization.
*/
prepForXml(context: Context): IXmlableObject | undefined;
/**
* Direct XML serialization — traverses `root` and calls `toXml()` on
* each child, concatenating the results into a single string.
*/
toXml(context: Context): string;
/**
* @deprecated Internal use only.
*/
addChildElement(child: BaseXmlComponent | string): XmlComponent;
}
/**
* XML component that is excluded from output if it has no meaningful content.
*/
declare abstract class IgnoreIfEmptyXmlComponent extends XmlComponent {
private readonly includeIfEmpty;
constructor(rootKey: string, includeIfEmpty?: boolean);
prepForXml(context: Context): IXmlableObject | undefined;
/**
* Suppress empty elements — super.toXml() produces a self-closing tag
* (`<tag/>`) when there are no child elements; IgnoreIfEmpty returns ""
* in that case. Child components that already override toXml() (e.g.
* Worksheet) are unaffected.
*/
toXml(context: Context): string;
}
//#endregion
//#region src/xml-components/attributes.d.ts
/**
* Maps TypeScript property names to their XML attribute names.
*/
type AttributeMap<T> = Record<keyof T, string>;
/**
* Simple attribute data as a key-value record.
*/
type AttributeData = Record<string, boolean | number | string>;
/**
* Structured attribute payload with explicit key-value mapping.
*/
type AttributePayload<T> = { readonly [P in keyof T]: {
readonly key: string;
readonly value: T[P];
} };
/**
* Base class for creating XML attributes with automatic name mapping.
*/
declare abstract class XmlAttributeComponent<T extends Record<string, any>> extends BaseXmlComponent {
private readonly root;
/** Optional mapping from property names to XML attribute names. */
protected readonly xmlKeys?: AttributeMap<T>;
constructor(root: T);
prepForXml(_: Context): IXmlableObject;
}
/**
* Next-generation attribute component with explicit key-value pairs.
*/
declare class NextAttributeComponent<T> extends BaseXmlComponent {
private readonly root;
constructor(root: AttributePayload<T>);
prepForXml(_: Context): IXmlableObject;
/** Attribute components produce no XML output — attrs are inlined by the parent. */
toXml(_context: Context): string;
}
//#endregion
//#region src/xml-components/elements.d.ts
/**
* Build an XML element with arbitrary attributes, filtering out undefined values.
*/
declare function attrObj(name: string, attrs: Record<string, string | number | boolean | undefined>): IXmlableObject;
/**
* Build a CT_OnOff XML object without allocating any XmlComponent.
* `val=true` returns a frozen singleton (cached per name).
*/
declare function onOffObj(name: string, val?: boolean | undefined): IXmlableObject;
/**
* Build a CT_HpsMeasure XML object (half-point size) without allocation.
*/
declare function hpsMeasureObj(name: string, val: number | PositiveUniversalMeasure): IXmlableObject;
/**
* Build a CT_String XML object (string value attribute) without allocation.
*/
declare function stringValObj(name: string, val: string): IXmlableObject;
/**
* Build a numeric value attribute XML object without allocation.
*/
declare function numberValObj(name: string, val: number): IXmlableObject;
/**
* Build a string enum value attribute XML object without allocation.
*/
declare function stringEnumValObj<T extends string>(name: string, val: T): IXmlableObject;
/**
* Build an element wrapping a text string without allocation.
*/
declare function stringContainerObj(name: string, val: string): IXmlableObject;
/**
* XML element representing an empty element (CT_Empty).
*/
declare class EmptyElement extends XmlComponent {}
/**
* Flexible XML element builder with explicit attribute and child configuration.
*/
declare class BuilderElement<T = {}> extends XmlComponent {
constructor({
name,
attributes,
children
}: {
readonly name: string;
readonly attributes?: AttributePayload<T>;
readonly children?: readonly (BaseXmlComponent | IXmlableObject | string)[];
});
}
/**
* Creates a NextAttributeComponent with explicit XML attribute keys.
*/
declare const chartAttr: (attrs: Record<string, string | number | boolean>) => BaseXmlComponent;
/**
* Wraps a component in a named XmlComponent element.
*/
declare function wrapEl(elementName: string, child: BaseXmlComponent): XmlComponent;
//#endregion
//#region src/xml-components/imported.d.ts
/**
* Converts an xml-js Element into an XmlComponent tree.
*/
declare const convertToXmlComponent: (element: Element) => ImportedXmlComponent | string | undefined;
/**
* XML component representing imported XML content.
*/
declare class ImportedXmlComponent extends XmlComponent {
protected _sourceXml?: string;
static fromXmlString(importedContent: string): ImportedXmlComponent;
get sourceXml(): string | undefined;
toXml(_context: Context): string;
constructor(rootKey: string, _attr?: any);
push(xmlComponent: XmlComponent | string): void;
}
/**
* Represents attributes for imported root elements.
*/
declare class ImportedRootElementAttributes extends XmlComponent {
private readonly _attr;
constructor(_attr: any);
prepForXml(_: Context): IXmlableObject;
}
//#endregion
//#region src/xml-components/initializable.d.ts
/**
* XML component that can be initialized from another component.
*/
declare abstract class InitializableXmlComponent extends XmlComponent {
constructor(rootKey: string, initComponent?: XmlComponent);
}
//#endregion
export { XmlComponent as C, IXmlableObject as D, IXmlAttribute as E, IgnoreIfEmptyXmlComponent as S, Context as T, AttributeMap as _, BuilderElement as a, XmlAttributeComponent as b, chartAttr as c, onOffObj as d, stringContainerObj as f, AttributeData as g, wrapEl as h, convertToXmlComponent as i, hpsMeasureObj as l, stringValObj as m, ImportedRootElementAttributes as n, EmptyElement as o, stringEnumValObj as p, ImportedXmlComponent as r, attrObj as s, InitializableXmlComponent as t, numberValObj as u, AttributePayload as v, BaseXmlComponent as w, EMPTY_OBJECT as x, NextAttributeComponent as y };

Sorry, the diff of this file is too big to display

import { Element } from "@office-open/xml";
//#region src/patch/xml-namespace.d.ts
/**
* Namespace configuration for XML patch operations.
*
* Parameterises element names so the same patch algorithm works for both
* DOCX (`w:*`) and PPTX (`a:*`) documents.
*/
interface XmlNamespaceConfig {
readonly paragraph: string;
readonly run: string;
readonly text: string;
readonly runProperties: string;
}
declare const DOCX_NS: XmlNamespaceConfig;
declare const PPTX_NS: XmlNamespaceConfig;
//#endregion
//#region src/patch/xml-replacer.d.ts
interface ReplacerConfig {
readonly ns: XmlNamespaceConfig;
readonly formatChild: (child: unknown, context: unknown) => Element[];
readonly preserveSpace?: boolean;
}
interface ReplacerResult {
readonly element: Element;
readonly didFindOccurrence: boolean;
}
declare function createReplacer(config: ReplacerConfig): ({
json,
patch,
patchText,
context,
keepOriginalStyles
}: {
readonly json: Element;
readonly patch: {
readonly type: string;
readonly children: readonly unknown[];
};
readonly patchText: string;
readonly context: unknown;
readonly keepOriginalStyles?: boolean;
}) => ReplacerResult;
//#endregion
//#region src/patch/run-renderer.d.ts
interface ElementWrapper {
readonly element: Element;
readonly index: number;
readonly parent: ElementWrapper | undefined;
}
interface RenderedParagraphNode {
readonly text: string;
readonly runs: readonly IRenderedRunNode[];
readonly index: number;
readonly pathToParagraph: readonly number[];
}
interface StartAndEnd {
readonly start: number;
readonly end: number;
}
type IParts = {
readonly text: string;
readonly index: number;
} & StartAndEnd;
type IRenderedRunNode = {
readonly text: string;
readonly parts: readonly IParts[];
readonly index: number;
} & StartAndEnd;
declare function createRunRenderer(ns: XmlNamespaceConfig): (node: ElementWrapper) => RenderedParagraphNode;
//#endregion
//#region src/patch/xml-traverser.d.ts
declare function createTraverser(ns: XmlNamespaceConfig): {
traverse: (node: Element) => readonly RenderedParagraphNode[];
findLocationOfText: (node: Element, text: string) => readonly RenderedParagraphNode[];
};
//#endregion
//#region src/patch/paragraph-token-replacer.d.ts
declare function createTokenReplacer(createTextElementContents: (text: string) => Element[], options?: {
readonly preserveSpace?: boolean;
}): ({
paragraphElement,
renderedParagraph,
originalText,
replacementText
}: {
readonly paragraphElement: Element;
readonly renderedParagraph: RenderedParagraphNode;
readonly originalText: string;
readonly replacementText: string;
}) => Element;
//#endregion
//#region src/patch/paragraph-split-inject.d.ts
declare class TokenNotFoundError extends Error {
constructor(token: string);
}
declare function createSplitInject(ns: XmlNamespaceConfig, createTextElementContents: (text: string) => Element[], options?: {
readonly preserveSpace?: boolean;
}): {
findRunElementIndexWithToken: (paragraphElement: Element, token: string) => number;
splitRunElement: (runElement: Element, token: string) => {
readonly left: Element;
readonly right: Element;
};
};
//#endregion
//#region src/patch/xml-patch-utils.d.ts
declare const toJson: (xmlData: string) => Element;
/**
* Creates the inner content of a text element (`w:t` / `a:t`).
*
* Returns `[{ type: "text", text }]` for non-empty text, `[]` for empty.
* The `xml:space` attribute is handled separately by `patchSpaceAttribute`.
*/
declare const createTextElementContents: (text: string) => Element[];
declare const patchSpaceAttribute: (element: Element) => Element;
declare const getFirstLevelElements: (relationships: Element, id: string) => Element[];
//#endregion
//#region src/patch/content-types-manager.d.ts
declare const appendContentType: (element: Element, contentType: string, extension: string) => void;
//#endregion
//#region src/patch/relationship-manager.d.ts
declare const getNextRelationshipIndex: (relationships: Element) => number;
declare const appendRelationship: (relationships: Element, id: number | string, type: string, target: string, targetMode?: string) => readonly Element[];
//#endregion
export { PPTX_NS as _, getFirstLevelElements as a, TokenNotFoundError as c, createTraverser as d, RenderedParagraphNode as f, DOCX_NS as g, createReplacer as h, createTextElementContents as i, createSplitInject as l, ReplacerConfig as m, getNextRelationshipIndex as n, patchSpaceAttribute as o, createRunRenderer as p, appendContentType as r, toJson as s, appendRelationship as t, createTokenReplacer as u, XmlNamespaceConfig as v };
import { C as XmlComponent, D as IXmlableObject, E as IXmlAttribute, S as IgnoreIfEmptyXmlComponent, T as Context, _ as AttributeMap, a as BuilderElement, b as XmlAttributeComponent, c as chartAttr, d as onOffObj, f as stringContainerObj, g as AttributeData, h as wrapEl, i as convertToXmlComponent, l as hpsMeasureObj, m as stringValObj, n as ImportedRootElementAttributes, o as EmptyElement, p as stringEnumValObj, r as ImportedXmlComponent, s as attrObj, t as InitializableXmlComponent, u as numberValObj, v as AttributePayload, w as BaseXmlComponent, x as EMPTY_OBJECT, y as NextAttributeComponent } from "./index-bZQnCpM1.mjs";
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./values-QyWq4U4A.mjs";
import { _ as CatAx, a as ChartData, c as ChartSeriesData, d as createChartType, f as ScatterChart, g as AreaChart, h as BarChart, i as ChartCollection, l as ChartType, m as LineChart, n as createNumRef, o as ChartSpace, p as PieChart, r as createStrRef, s as ChartSpaceOptions, t as ChartTitle, u as ChartTypeOptions, v as ValAx } from "./index-Bf86IyeY.mjs";
import { $ as RectAlignment, $t as createSolidFill, A as createBevel, At as FillOptions, B as createSoftEdgeEffect, Bt as RelativeRect, C as GeometryGuide, Ct as createGroupFill, D as createShape3D, Dt as createNoFill, E as Shape3DOptions, Et as createPatternFill, F as Point3D, Ft as GradientShadeOptions, G as EffectListOptions, Gt as TileOptions, H as EffectDagOptions, Ht as createGradientFill, I as Scene3DOptions, It as GradientStop, J as createReflectionEffect, Jt as createSourceRectangle, K as createEffectList, Kt as createTileInfo, L as SphereCoords, Lt as LinearShadeOptions, M as BackdropOptions, Mt as buildFill, N as CameraOptions, Nt as extractBlipFillMedia, O as BevelOptions, Ot as BlipFillConfigOptions, P as LightRigOptions, Pt as GradientFillOptions, Q as OuterShadowEffectOptions, Qt as createColorElement, R as Vector3D, Rt as PathShadeOptions, S as PresetGeometryOptions, St as createCustomDash, T as PresetMaterialType, Tt as PresetPattern, U as createEffectDag, Ut as createGradientStop, V as EffectContainerType, Vt as TileFlipMode, W as BlurEffectOptions, Wt as TileAlignment, X as PresetShadowVal, Xt as createBlipEffects, Y as PresetShadowEffectOptions, Yt as BlipEffectsOptions, Z as createPresetShadowEffect, Zt as SolidFillOptions, _ as PathCommand, _t as LineEndOptions, a as Transform2DOptions, an as createSchemeColor, at as BlendMode, b as createCustomGeometry, bt as createLineEnd, c as Stretch, cn as RgbColorOptions, ct as CompoundLine, d as createBlipFill, dn as PresetColorOptions, dt as OutlineFillProperties, en as SystemColor, et as createOuterShadowEffect, f as BlipOptions, fn as createPresetColor, ft as OutlineOptions, g as GeomRect, gn as createColorTransforms, gt as LineEndLength, h as CustomGeometryOptions, hn as ColorTransformOptions, ht as createOutline, i as GroupTransform2DOptions, in as SchemeColorOptions, it as createGlowEffect, j as createBottomBevel, jt as GradientStopOptions, k as BevelPresetType, kt as BlipFillMediaData, l as createExtentionList, ln as createRgbColor, lt as LineCap, m as ConnectionSite, mn as createHslColor, mt as PresetDash, n as MediaTransformation, nn as createSystemColor, nt as createInnerShadowEffect, o as createGroupTransform2D, on as ScRgbColorOptions, ot as FillOverlayEffectOptions, p as createBlip, pn as HslColorOptions, pt as PenAlignment, q as ReflectionEffectOptions, qt as SourceRectangleOptions, r as createTransformation, rn as SchemeColor, rt as GlowEffectOptions, s as createTransform2D, sn as createScRgbColor, st as createFillOverlayEffect, t as MediaDataTransformation, tn as SystemColorOptions, tt as InnerShadowEffectOptions, u as BlipFillOptions, un as PresetColor, ut as LineJoin, v as PathFillMode, vt as LineEndType, w as createAdjustmentValues, wt as PatternFillOptions, x as PresetGeometry, xt as DashStop, y as PathOptions, yt as LineEndWidth, z as createScene3D, zt as PathShadeType } from "./index-CCGNb26x.mjs";
import { a as Point, c as Connection, d as getLayoutXml, f as getStyleXml, h as STYLE_CATEGORIES, i as SmartArtData, l as DEFAULT_DRAWING_XML, m as LAYOUT_CATEGORIES, n as createDataModel, o as TransPoint, p as COLOR_CATEGORIES, r as SmartArtCollection, s as DataModel, t as TreeNode, u as getColorXml } from "./index-BCjRiF78.mjs";
import { _ as PPTX_NS, a as getFirstLevelElements, c as TokenNotFoundError, d as createTraverser, f as RenderedParagraphNode, g as DOCX_NS, h as createReplacer, i as createTextElementContents, l as createSplitInject, m as ReplacerConfig, n as getNextRelationshipIndex, o as patchSpaceAttribute, p as createRunRenderer, r as appendContentType, s as toJson, t as appendRelationship, u as createTokenReplacer, v as XmlNamespaceConfig } from "./index-DNLRdIqy.mjs";
import { Element } from "@office-open/xml";
import { ZipOptions, Zippable, Zippable as Zippable$1, strFromU8, unzipSync } from "fflate";
//#region src/converters.d.ts
/**
* OOXML unit conversion utilities.
*
* @module
*/
/**
* Converts millimeters to TWIP (twentieths of a point).
*/
declare const convertMillimetersToTwip: (millimeters: number) => number;
/**
* Converts inches to TWIP (twentieths of a point).
*/
declare const convertInchesToTwip: (inches: number) => number;
/**
* Converts pixels to EMU (96 DPI).
*/
declare const convertPixelsToEmu: (pixels: number) => number;
/**
* Converts EMU to pixels (96 DPI).
*/
declare const convertEmuToPixels: (emus: number) => number;
/**
* Converts inches to EMU.
*/
declare const convertInchesToEmu: (inches: number) => number;
/**
* Converts EMU to inches.
*/
declare const convertEmuToInches: (emus: number) => number;
/**
* Converts points to EMU.
*/
declare const convertPointsToEmu: (points: number) => number;
/**
* Converts EMU to points.
*/
declare const convertEmuToPoints: (emus: number) => number;
//#endregion
//#region src/id-generators.d.ts
/**
* A function that generates unique sequential numeric IDs.
*/
type UniqueNumericIdCreator = () => number;
/**
* Creates a unique numeric ID generator with sequential numbering.
*/
declare const uniqueNumericIdCreator: (initial?: number) => UniqueNumericIdCreator;
/**
* Generates a unique lowercase alphanumeric ID using nanoid.
*/
declare const uniqueId: () => string;
/**
* Generates a SHA-1 hash of the provided data.
*/
declare const hashedId: (data: Buffer | string | Uint8Array | ArrayBuffer) => string;
/**
* Generates a UUID v4-style unique identifier.
*/
declare const uniqueUuid: () => string;
//#endregion
//#region src/output-type.d.ts
/**
* Output type definitions for OOXML document export.
*
* @module
*/
interface OutputByType {
readonly base64: string;
readonly string: string;
readonly text: string;
readonly binarystring: string;
readonly array: readonly number[];
readonly uint8array: Uint8Array;
readonly arraybuffer: ArrayBuffer;
readonly blob: Blob;
readonly nodebuffer: Buffer;
}
type OutputType = keyof OutputByType;
declare const OoxmlMimeType: {
readonly DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
readonly PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
readonly XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
};
declare const convertOutput: <T extends OutputType>(data: Uint8Array, type: T, mimeType?: string) => OutputByType[T];
//#endregion
//#region src/packer.d.ts
interface XmlifyedFile {
readonly path: string;
readonly data: string | Uint8Array;
}
/** Default DEFLATE compression level matching Microsoft Office behavior. */
declare const ZIP_DEFLATE_LEVEL = 6;
/** STORE level for already-compressed media formats (JPEG, PNG, GIF, etc.). */
declare const ZIP_STORED_LEVEL = 0;
/**
* Asynchronously compress files and convert to the requested output format.
*
* Uses fflate Web Workers for non-blocking DEFLATE compression.
* XML entries use DEFLATE by default; media entries should explicitly set
* `{ level: ZIP_STORED_LEVEL }` to avoid redundant compression.
*/
declare const zipAndConvert: <T extends OutputType>(files: Zippable$1, type: T, mimeType: string, level?: number) => Promise<OutputByType[T]>;
/**
* Synchronously compress files and convert to the requested output format.
*
* Uses synchronous DEFLATE compression for maximum throughput.
* Blocks the event loop — prefer {@link zipAndConvert} in server contexts.
*/
declare const zipSyncAndConvert: <T extends OutputType>(files: Zippable$1, type: T, mimeType: string, level?: number) => OutputByType[T];
/**
* Create a `ReadableStream<Uint8Array>` from compressed file entries.
*
* Uses fflate's `AsyncZipDeflate` for non-blocking DEFLATE compression.
* `STORED` entries (media) pass through synchronously.
* Works in both Node.js and browsers (Web Streams API).
*/
declare const createZipStream: (files: Zippable$1) => ReadableStream<Uint8Array>;
/**
* Compile function provided by each package to convert a file object into a Zippable map.
*/
type CompileFn<TFile> = (file: TFile, overrides?: readonly XmlifyedFile[]) => Zippable$1;
/**
* Packer interface returned by {@link createPacker}.
*
* Async methods use fflate Web Workers for non-blocking compression.
* Sync methods use synchronous compression for maximum throughput in
* CLI scripts and build tools.
*/
interface Packer<TFile> {
/** Compile file to Zippable map (synchronous). */
compile: CompileFn<TFile>;
/** Generic async output — returns the requested OutputType. */
pack<T extends OutputType>(file: TFile, type: T, overrides?: readonly XmlifyedFile[]): Promise<OutputByType[T]>;
/** Generic sync output — returns the requested OutputType. */
packSync<T extends OutputType>(file: TFile, type: T, overrides?: readonly XmlifyedFile[]): OutputByType[T];
/** Async → `Promise<Uint8Array>` (like `Response.bytes()`). */
toBytes(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<Uint8Array>;
/** Sync → `Uint8Array`. */
toBytesSync(file: TFile, overrides?: readonly XmlifyedFile[]): Uint8Array;
/** Async → `Promise<string>` (raw ZIP content as string). */
toString(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<string>;
/** Sync → `string`. */
toStringSync(file: TFile, overrides?: readonly XmlifyedFile[]): string;
/** Async → `Promise<Buffer>` (Node.js). */
toBuffer(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<Buffer>;
/** Sync → `Buffer` (Node.js). */
toBufferSync(file: TFile, overrides?: readonly XmlifyedFile[]): Buffer;
/** Async → `Promise<string>` (base64-encoded). */
toBase64String(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<string>;
/** Sync → `string` (base64-encoded). */
toBase64StringSync(file: TFile, overrides?: readonly XmlifyedFile[]): string;
/** Async → `Promise<Blob>` (browser). */
toBlob(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<Blob>;
/** Sync → `Blob`. */
toBlobSync(file: TFile, overrides?: readonly XmlifyedFile[]): Blob;
/** Async → `Promise<ArrayBuffer>`. */
toArrayBuffer(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<ArrayBuffer>;
/** Sync → `ArrayBuffer`. */
toArrayBufferSync(file: TFile, overrides?: readonly XmlifyedFile[]): ArrayBuffer;
/** Streaming output via `ReadableStream<Uint8Array>` (cross-platform, uses Web Workers). */
toStream(file: TFile, overrides?: readonly XmlifyedFile[]): ReadableStream<Uint8Array>;
}
/**
* Create a Packer object with all output format methods.
*
* Centralises the ZIP → convert pipeline and the streaming implementation
* so that each OOXML package only needs to provide a `compile` function and
* a MIME type.
*/
declare const createPacker: <TFile>(options: {
readonly compile: CompileFn<TFile>;
readonly mimeType: string;
}) => Packer<TFile>;
//#endregion
//#region src/opc/app-properties.d.ts
declare class AppProperties extends ImportedXmlComponent {
private static instance;
constructor();
prepForXml(): Readonly<Record<string, any>> | undefined;
toXml(_context: Context): string;
}
//#endregion
//#region src/opc/relationships.d.ts
type RelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" | "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors" | "http://schemas.microsoft.com/office/2007/relationships/diagramLayout" | "http://schemas.microsoft.com/office/2007/relationships/diagramStyle" | "http://schemas.microsoft.com/office/2007/relationships/diagramColors" | "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/bibliography" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/subDocument" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video" | "http://schemas.microsoft.com/office/2007/relationships/media" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing";
declare const TargetModeType: {
readonly EXTERNAL: "External";
};
declare class Relationships extends BaseXmlComponent {
private entries;
constructor();
addRelationship(id: number | string, type: RelationshipType, target: string, targetMode?: (typeof TargetModeType)[keyof typeof TargetModeType]): void;
get relationshipCount(): number;
/**
* Zero-allocation fast path: directly concatenate XML string.
* Bypasses the IXmlableObject intermediate tree entirely.
*/
toXml(_context: Context): string;
prepForXml(_context: Context): IXmlableObject;
}
//#endregion
//#region src/opc/content-types.d.ts
interface DefaultAttributes {
readonly contentType: string;
readonly extension?: string;
}
/**
* Creates a Default element mapping a file extension to a MIME content type.
*/
declare const createDefault: (contentType: string, extension?: string) => XmlComponent;
interface OverrideAttributes {
readonly contentType: string;
readonly partName?: string;
}
/**
* Creates an Override element mapping a specific part path to a MIME content type.
*/
declare const createOverride: (contentType: string, partName?: string) => XmlComponent;
//#endregion
//#region src/formatter.d.ts
/**
* Converts an XmlComponent tree into a serializable XML object or string.
*/
declare class Formatter {
format<T extends Context = Context>(input: BaseXmlComponent, context?: T): Record<string, any>;
/**
* Serialize a component directly to XML string via the toXml() fast path.
* Always includes XML declaration.
*/
formatToXml(input: BaseXmlComponent, context: Context): string;
}
//#endregion
//#region src/core-properties.d.ts
interface CoreProperties {
title?: string;
subject?: string;
creator?: string;
keywords?: string;
description?: string;
lastModifiedBy?: string;
revision?: string;
created?: string;
modified?: string;
}
/**
* Parse core properties from an already-parsed XML element.
* Shared by docx and pptx to extract Dublin Core metadata.
*/
declare function parseCorePropsElement(el: Element | undefined): CoreProperties;
/**
* Build a cp:coreProperties XML object from metadata.
*
* Shared by docx and pptx to avoid duplicating namespace declarations
* and Dublin Core property construction.
*/
declare function buildCorePropertiesXml(opts: {
readonly title?: string;
readonly subject?: string;
readonly creator?: string;
readonly keywords?: string;
readonly description?: string;
readonly lastModifiedBy?: string;
readonly revision?: number;
}): IXmlableObject;
/**
* Build a cp:coreProperties XML string directly (fast path).
*
* Shared by pptx and xlsx to bypass prepForXml → xml() pipeline.
*/
declare function buildCorePropertiesXmlString(opts: {
readonly title?: string;
readonly subject?: string;
readonly creator?: string;
readonly keywords?: string;
readonly description?: string;
readonly lastModifiedBy?: string;
readonly revision?: number;
}): string;
//#endregion
//#region src/parser.d.ts
/**
* Parsed OOXML archive backed by an unzipped ZIP map.
*
* Provides unstorage-style API (get/set/getRaw/setRaw/remove/has/keys)
* for reading and modifying individual parts, then serializing back to a ZIP buffer.
*/
declare class ParsedArchive {
private readonly zip;
private readonly modified;
private readonly wrapperCache;
constructor(data: Uint8Array);
/** Read an XML part as an Element tree. */
get(path: string): Element | undefined;
/** Write an XML part (Element → XML string). */
set(path: string, element: Element): void;
/** Read raw binary data (images, media, etc.). */
getRaw(path: string): Uint8Array | undefined;
/** Write raw binary data. */
setRaw(path: string, data: Uint8Array): void;
/** Remove a part. Returns true if it existed. */
remove(path: string): boolean;
/** Check if a part exists. */
has(path: string): boolean;
/** List all paths matching an optional prefix. */
keys(prefix?: string): string[];
/** Serialize back to a ZIP buffer, merging original zip + modifications. */
save(): Uint8Array;
}
/** Parse an OOXML archive (.docx, .pptx, .xlsx) into a ParsedArchive. */
declare function parseArchive(data: Uint8Array): ParsedArchive;
//#endregion
//#region src/raw-passthrough.d.ts
/**
* Convert an Element tree to xml-js compact format (IXmlableObject).
* Always wraps in a named key so the element name is preserved even for empty elements.
*/
declare function elementToCompact(el: Element): IXmlableObject;
/**
* Thin wrapper that passes a raw Element tree through the XML serialization pipeline.
* Used to include parsed-but-unrecognized XML in generated documents.
*/
declare class RawPassthrough extends BaseXmlComponent {
private readonly element;
constructor(element: Element);
prepForXml(_context: Context): IXmlableObject;
}
//#endregion
//#region src/placeholder.d.ts
/**
* Placeholder detection and replacement utilities for compiler post-processing.
*
* Both DOCX and PPTX compilers use placeholder tokens (e.g. `{chart:key}`)
* in XML strings to defer relationship ID assignment. This module provides
* fast pre-check utilities and shared replacement functions.
*/
type IdFormat = "rId" | "plain";
declare const formatId: (offset: number, index: number, style: IdFormat) => string;
declare function hasPlaceholders(xml: string): boolean;
declare function collectPlaceholderKeys(xml: string, prefix: string): string[];
declare function replaceImagePlaceholders(xml: string, mediaData: readonly {
readonly fileName: string;
}[], offset: number, idFormat?: IdFormat): string;
declare function getReferencedMedia(xml: string, mediaArray: readonly {
readonly fileName: string;
}[]): readonly {
readonly fileName: string;
}[];
declare function replaceChartPlaceholders(xml: string, chartKeys: readonly string[], offset: number, idFormat?: IdFormat): string;
interface SmartArtRelOptions {
readonly pathPrefix: string;
readonly styleRelType: RelationshipType;
}
declare function replaceSmartArtPlaceholders(xml: string, keys: readonly string[], dataOffset: number, idFormat?: IdFormat): string;
declare function addSmartArtRelationships(keys: readonly string[], addRel: (id: number, type: RelationshipType, target: string, targetMode?: string) => void, baseOffset: number, globalStartIndex: number, options: SmartArtRelOptions): void;
//#endregion
//#region src/xsd-mappings.d.ts
/**
* Bidirectional mappings between user-friendly values and XSD abbreviated values.
*
* When XSD uses full English words (e.g. "center", "start"), values are used directly — no mapping needed.
* When XSD uses abbreviations (e.g. "ctr", "l", "rnd"), this module maps them to full words.
*
* Usage in generation (Options → XML): xsdAlign.to("center") → "ctr"
* Usage in parsing (XML → Options): xsdAlign.from("ctr") → "center"
*/
/** Invert a Record<K, V> into Record<V, K>. */
declare function invertMap<K extends string, V extends string>(map: Record<K, V>): Record<V, K>;
declare const xsdRectAlignment: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"center" | "topLeft" | "top" | "topRight" | "left" | "right" | "bottomLeft" | "bottom" | "bottomRight", "tl" | "t" | "tr" | "l" | "ctr" | "r" | "bl" | "b" | "br">; /** The reverse map (XSD → user) */
reverse: Record<"tl" | "t" | "tr" | "l" | "ctr" | "r" | "bl" | "b" | "br", "center" | "topLeft" | "top" | "topRight" | "left" | "right" | "bottomLeft" | "bottom" | "bottomRight">;
};
declare const xsdTextAlign: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"center" | "left" | "right" | "justify", "l" | "ctr" | "r" | "just">; /** The reverse map (XSD → user) */
reverse: Record<"l" | "ctr" | "r" | "just", "center" | "left" | "right" | "justify">;
};
declare const xsdTextAnchor: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"center" | "top" | "bottom", "t" | "ctr" | "b">; /** The reverse map (XSD → user) */
reverse: Record<"t" | "ctr" | "b", "center" | "top" | "bottom">;
};
declare const xsdLineCap: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"round" | "square" | "flat", "flat" | "rnd" | "sq">; /** The reverse map (XSD → user) */
reverse: Record<"flat" | "rnd" | "sq", "round" | "square" | "flat">;
};
declare const xsdCompoundLine: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"single" | "double" | "thickThin" | "thinThick" | "triple", "thickThin" | "thinThick" | "sng" | "dbl" | "tri">; /** The reverse map (XSD → user) */
reverse: Record<"thickThin" | "thinThick" | "sng" | "dbl" | "tri", "single" | "double" | "thickThin" | "thinThick" | "triple">;
};
declare const xsdPenAlignment: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"center" | "inside", "in" | "ctr">; /** The reverse map (XSD → user) */
reverse: Record<"in" | "ctr", "center" | "inside">;
};
declare const xsdLineEndSize: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"small" | "medium" | "large", "sm" | "med" | "lg">; /** The reverse map (XSD → user) */
reverse: Record<"sm" | "med" | "lg", "small" | "medium" | "large">;
};
declare const xsdBlendMode: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"lighten" | "darken" | "over" | "multiply" | "screen", "lighten" | "darken" | "over" | "screen" | "mult">; /** The reverse map (XSD → user) */
reverse: Record<"lighten" | "darken" | "over" | "screen" | "mult", "lighten" | "darken" | "over" | "multiply" | "screen">;
};
declare const xsdPathFillMode: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"none" | "normal" | "lighten" | "lightenLess" | "darken" | "darkenLess", "none" | "lighten" | "lightenLess" | "darken" | "darkenLess" | "norm">; /** The reverse map (XSD → user) */
reverse: Record<"none" | "lighten" | "lightenLess" | "darken" | "darkenLess" | "norm", "none" | "normal" | "lighten" | "lightenLess" | "darken" | "darkenLess">;
};
declare const xsdEffectContainer: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"sibling" | "tree", "tree" | "sib">; /** The reverse map (XSD → user) */
reverse: Record<"tree" | "sib", "sibling" | "tree">;
};
declare const xsdPresetShadow: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"shadow1" | "shadow2" | "shadow3" | "shadow4" | "shadow5" | "shadow6" | "shadow7" | "shadow8" | "shadow9" | "shadow10" | "shadow11" | "shadow12" | "shadow13" | "shadow14" | "shadow15" | "shadow16" | "shadow17" | "shadow18" | "shadow19" | "shadow20", "shdw1" | "shdw2" | "shdw3" | "shdw4" | "shdw5" | "shdw6" | "shdw7" | "shdw8" | "shdw9" | "shdw10" | "shdw11" | "shdw12" | "shdw13" | "shdw14" | "shdw15" | "shdw16" | "shdw17" | "shdw18" | "shdw19" | "shdw20">; /** The reverse map (XSD → user) */
reverse: Record<"shdw1" | "shdw2" | "shdw3" | "shdw4" | "shdw5" | "shdw6" | "shdw7" | "shdw8" | "shdw9" | "shdw10" | "shdw11" | "shdw12" | "shdw13" | "shdw14" | "shdw15" | "shdw16" | "shdw17" | "shdw18" | "shdw19" | "shdw20", "shadow1" | "shadow2" | "shadow3" | "shadow4" | "shadow5" | "shadow6" | "shadow7" | "shadow8" | "shadow9" | "shadow10" | "shadow11" | "shadow12" | "shadow13" | "shadow14" | "shadow15" | "shadow16" | "shadow17" | "shadow18" | "shadow19" | "shadow20">;
};
declare const xsdMaterialType: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"flat" | "legacyMatte" | "legacyPlastic" | "legacyMetal" | "legacyWireframe" | "matte" | "plastic" | "metal" | "warmMatte" | "translucentPowder" | "powder" | "darkEdge" | "softEdge" | "clear" | "softMetal", "flat" | "legacyMatte" | "legacyPlastic" | "legacyMetal" | "legacyWireframe" | "matte" | "plastic" | "metal" | "warmMatte" | "translucentPowder" | "powder" | "softEdge" | "clear" | "dkEdge" | "softmetal">; /** The reverse map (XSD → user) */
reverse: Record<"flat" | "legacyMatte" | "legacyPlastic" | "legacyMetal" | "legacyWireframe" | "matte" | "plastic" | "metal" | "warmMatte" | "translucentPowder" | "powder" | "softEdge" | "clear" | "dkEdge" | "softmetal", "flat" | "legacyMatte" | "legacyPlastic" | "legacyMetal" | "legacyWireframe" | "matte" | "plastic" | "metal" | "warmMatte" | "translucentPowder" | "powder" | "darkEdge" | "softEdge" | "clear" | "softMetal">;
};
declare const xsdPattern: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"percent5" | "percent10" | "percent20" | "percent25" | "percent30" | "percent40" | "percent50" | "percent60" | "percent70" | "percent75" | "percent80" | "percent90" | "horizontal" | "vertical" | "lightHorizontal" | "lightVertical" | "darkHorizontal" | "darkVertical" | "narrowHorizontal" | "narrowVertical" | "dashedHorizontal" | "dashedVertical" | "cross" | "downDiagonal" | "upDiagonal" | "lightDownDiagonal" | "lightUpDiagonal" | "darkDownDiagonal" | "darkUpDiagonal" | "wideDownDiagonal" | "wideUpDiagonal" | "dashedDownDiagonal" | "dashedUpDiagonal" | "diagonalCross" | "smallChecker" | "largeChecker" | "smallGrid" | "largeGrid" | "dotGrid" | "smallConfetti" | "largeConfetti" | "horizontalBrick" | "diagonalBrick" | "solidDiamond" | "openDiamond" | "dottedDiamond" | "plaid" | "sphere" | "weave" | "divot" | "shingle" | "wave" | "trellis" | "zigZag", "cross" | "dotGrid" | "plaid" | "sphere" | "weave" | "divot" | "shingle" | "wave" | "trellis" | "zigZag" | "pct5" | "pct10" | "pct20" | "pct25" | "pct30" | "pct40" | "pct50" | "pct60" | "pct70" | "pct75" | "pct80" | "pct90" | "horz" | "vert" | "ltHorz" | "ltVert" | "dkHorz" | "dkVert" | "narHorz" | "narVert" | "dashHorz" | "dashVert" | "dnDiag" | "upDiag" | "ltDnDiag" | "ltUpDiag" | "dkDnDiag" | "dkUpDiag" | "wdDnDiag" | "wdUpDiag" | "dashDnDiag" | "dashUpDiag" | "diagCross" | "smCheck" | "lgCheck" | "smGrid" | "lgGrid" | "smConfetti" | "lgConfetti" | "horzBrick" | "diagBrick" | "solidDmnd" | "openDmnd" | "dotDmnd">; /** The reverse map (XSD → user) */
reverse: Record<"cross" | "dotGrid" | "plaid" | "sphere" | "weave" | "divot" | "shingle" | "wave" | "trellis" | "zigZag" | "pct5" | "pct10" | "pct20" | "pct25" | "pct30" | "pct40" | "pct50" | "pct60" | "pct70" | "pct75" | "pct80" | "pct90" | "horz" | "vert" | "ltHorz" | "ltVert" | "dkHorz" | "dkVert" | "narHorz" | "narVert" | "dashHorz" | "dashVert" | "dnDiag" | "upDiag" | "ltDnDiag" | "ltUpDiag" | "dkDnDiag" | "dkUpDiag" | "wdDnDiag" | "wdUpDiag" | "dashDnDiag" | "dashUpDiag" | "diagCross" | "smCheck" | "lgCheck" | "smGrid" | "lgGrid" | "smConfetti" | "lgConfetti" | "horzBrick" | "diagBrick" | "solidDmnd" | "openDmnd" | "dotDmnd", "percent5" | "percent10" | "percent20" | "percent25" | "percent30" | "percent40" | "percent50" | "percent60" | "percent70" | "percent75" | "percent80" | "percent90" | "horizontal" | "vertical" | "lightHorizontal" | "lightVertical" | "darkHorizontal" | "darkVertical" | "narrowHorizontal" | "narrowVertical" | "dashedHorizontal" | "dashedVertical" | "cross" | "downDiagonal" | "upDiagonal" | "lightDownDiagonal" | "lightUpDiagonal" | "darkDownDiagonal" | "darkUpDiagonal" | "wideDownDiagonal" | "wideUpDiagonal" | "dashedDownDiagonal" | "dashedUpDiagonal" | "diagonalCross" | "smallChecker" | "largeChecker" | "smallGrid" | "largeGrid" | "dotGrid" | "smallConfetti" | "largeConfetti" | "horizontalBrick" | "diagonalBrick" | "solidDiamond" | "openDiamond" | "dottedDiamond" | "plaid" | "sphere" | "weave" | "divot" | "shingle" | "wave" | "trellis" | "zigZag">;
};
declare const xsdVerticalMergeRev: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"continue" | "restart", "cont" | "rest">; /** The reverse map (XSD → user) */
reverse: Record<"cont" | "rest", "continue" | "restart">;
};
declare const xsdUnderlineStyle: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"none" | "single" | "double", "none" | "sng" | "dbl">; /** The reverse map (XSD → user) */
reverse: Record<"none" | "sng" | "dbl", "none" | "single" | "double">;
};
declare const xsdStrikeStyle: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"singleStrike" | "doubleStrike" | "noStrike", "sngStrike" | "dblStrike" | "noStrike">; /** The reverse map (XSD → user) */
reverse: Record<"sngStrike" | "dblStrike" | "noStrike", "singleStrike" | "doubleStrike" | "noStrike">;
};
declare const xsdTextCaps: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"none" | "small" | "all", "none" | "small" | "all">; /** The reverse map (XSD → user) */
reverse: Record<"none" | "small" | "all", "none" | "small" | "all">;
};
//#endregion
//#region src/compiler-utils.d.ts
/**
* Convert a mapping of XML files + overrides + media into a Zippable structure.
*
* Centralises the mapping→Zippable conversion shared by all three compilers.
*/
declare function compileMapping(mapping: Record<string, {
data: string;
path: string;
}>, overrides?: readonly XmlifyedFile[], media?: readonly {
data: Uint8Array;
path: string;
}[]): Zippable;
//#endregion
export { AppProperties, AreaChart, AttributeData, AttributeMap, AttributePayload, BackdropOptions, BarChart, BaseXmlComponent, BevelOptions, BevelPresetType, BlendMode, BlipEffectsOptions, BlipFillConfigOptions, BlipFillMediaData, BlipFillOptions, BlipOptions, BlurEffectOptions, BuilderElement, COLOR_CATEGORIES, CameraOptions, CatAx, ChartCollection, ChartData, ChartSeriesData, ChartSpace, ChartSpaceOptions, ChartTitle, ChartType, ChartTypeOptions, ColorTransformOptions, CompileFn, CompoundLine, Connection, ConnectionSite, Context, CoreProperties, CustomGeometryOptions, DEFAULT_DRAWING_XML, DOCX_NS, DashStop, DataModel, type DefaultAttributes, EMPTY_OBJECT, EffectContainerType, EffectDagOptions, EffectListOptions, EmptyElement, FillOptions, FillOverlayEffectOptions, Formatter, GeomRect, GeometryGuide, GlowEffectOptions, GradientFillOptions, GradientShadeOptions, GradientStop, GradientStopOptions, GroupTransform2DOptions, HslColorOptions, IXmlAttribute, IXmlableObject, IdFormat, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, InnerShadowEffectOptions, LAYOUT_CATEGORIES, LightRigOptions, LineCap, LineChart, LineEndLength, LineEndOptions, LineEndType, LineEndWidth, LineJoin, LinearShadeOptions, MediaDataTransformation, MediaTransformation, NextAttributeComponent, OoxmlMimeType, OuterShadowEffectOptions, OutlineFillProperties, OutlineOptions, OutputByType, OutputType, type OverrideAttributes, PPTX_NS, Packer, ParsedArchive, PathCommand, PathFillMode, PathOptions, PathShadeOptions, PathShadeType, PatternFillOptions, PenAlignment, Percentage, PieChart, Point, Point3D, PositivePercentage, PositiveUniversalMeasure, PresetColor, PresetColorOptions, PresetDash, PresetGeometry, PresetGeometryOptions, PresetMaterialType, PresetPattern, PresetShadowEffectOptions, PresetShadowVal, RawPassthrough, RectAlignment, ReflectionEffectOptions, type RelationshipType, Relationships, RelativeMeasure, RelativeRect, RenderedParagraphNode, ReplacerConfig, RgbColorOptions, STYLE_CATEGORIES, ScRgbColorOptions, ScatterChart, Scene3DOptions, SchemeColor, SchemeColorOptions, Shape3DOptions, SmartArtCollection, SmartArtData, SmartArtRelOptions, SolidFillOptions, SourceRectangleOptions, SphereCoords, Stretch, SystemColor, SystemColorOptions, TargetModeType, ThemeColor, ThemeFont, TileAlignment, TileFlipMode, TileOptions, TokenNotFoundError, TransPoint, Transform2DOptions, TreeNode, UniqueNumericIdCreator, UniversalMeasure, ValAx, Vector3D, XmlAttributeComponent, XmlComponent, XmlNamespaceConfig, XmlifyedFile, ZIP_DEFLATE_LEVEL, ZIP_STORED_LEVEL, type ZipOptions, type Zippable, addSmartArtRelationships, appendContentType, appendRelationship, attrObj, buildCorePropertiesXml, buildCorePropertiesXmlString, buildFill, chartAttr, collectPlaceholderKeys, compileMapping, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPointsToEmu, convertToXmlComponent, createAdjustmentValues, createBevel, createBlip, createBlipEffects, createBlipFill, createBottomBevel, createChartType, createColorElement, createColorTransforms, createCustomDash, createCustomGeometry, createDataModel, createDefault, createEffectDag, createEffectList, createExtentionList, createFillOverlayEffect, createGlowEffect, createGradientFill, createGradientStop, createGroupFill, createGroupTransform2D, createHslColor, createInnerShadowEffect, createLineEnd, createNoFill, createNumRef, createOuterShadowEffect, createOutline, createOverride, createPacker, createPatternFill, createPresetColor, createPresetShadowEffect, createReflectionEffect, createReplacer, createRgbColor, createRunRenderer, createScRgbColor, createScene3D, createSchemeColor, createShape3D, createSoftEdgeEffect, createSolidFill, createSourceRectangle, createSplitInject, createStrRef, createSystemColor, createTextElementContents, createTileInfo, createTokenReplacer, createTransform2D, createTransformation, createTraverser, createZipStream, dateTimeValue, decimalNumber, eighthPointMeasureValue, elementToCompact, extractBlipFillMedia, formatId, getColorXml, getFirstLevelElements, getLayoutXml, getNextRelationshipIndex, getReferencedMedia, getStyleXml, hasPlaceholders, hashedId, hexBinary, hexColorValue, hpsMeasureObj, hpsMeasureValue, invertMap, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseArchive, parseCorePropsElement, patchSpaceAttribute, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, strFromU8, stringContainerObj, stringEnumValObj, stringValObj, toJson, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipSync, wrapEl, xsdBlendMode, xsdCompoundLine, xsdEffectContainer, xsdLineCap, xsdLineEndSize, xsdMaterialType, xsdPathFillMode, xsdPattern, xsdPenAlignment, xsdPresetShadow, xsdRectAlignment, xsdStrikeStyle, xsdTextAlign, xsdTextAnchor, xsdTextCaps, xsdUnderlineStyle, xsdVerticalMergeRev, zipAndConvert, zipSyncAndConvert };
import { _ as XmlAttributeComponent, a as BuilderElement, b as XmlComponent, c as chartAttr, d as onOffObj, f as stringContainerObj, g as NextAttributeComponent, h as wrapEl, i as convertToXmlComponent, l as hpsMeasureObj, m as stringValObj, n as ImportedRootElementAttributes, o as EmptyElement, p as stringEnumValObj, r as ImportedXmlComponent, s as attrObj, t as InitializableXmlComponent, u as numberValObj, v as EMPTY_OBJECT, x as BaseXmlComponent, y as IgnoreIfEmptyXmlComponent } from "./xml-components-ctIqansl.mjs";
import { ThemeColor, ThemeFont, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber } from "./values.mjs";
import { $ as xsdCompoundLine, A as LineJoin, At as hashedId, B as createNoFill, Bt as convertPixelsToEmu, C as createOuterShadowEffect, Ct as createSchemeColor, D as createFillOverlayEffect, Dt as createPresetColor, E as BlendMode, Et as PresetColor, F as LineEndType, Ft as convertEmuToPixels, G as PathShadeType, H as extractBlipFillMedia, I as LineEndWidth, It as convertEmuToPoints, J as createGradientStop, K as TileFlipMode, L as createLineEnd, Lt as convertInchesToEmu, M as PresetDash, Mt as uniqueNumericIdCreator, N as createOutline, Nt as uniqueUuid, O as CompoundLine, Ot as createHslColor, P as LineEndLength, Pt as convertEmuToInches, Q as xsdBlendMode, R as createCustomDash, Rt as convertInchesToTwip, S as RectAlignment, St as SchemeColor, T as createGlowEffect, Tt as createRgbColor, U as PresetPattern, V as buildFill, Vt as convertPointsToEmu, W as createPatternFill, X as createTileInfo, Y as TileAlignment, Z as invertMap, _ as createEffectList, _t as createBlipEffects, a as createBlip, at as xsdPattern, b as PresetShadowVal, bt as SystemColor, c as PresetGeometry, ct as xsdRectAlignment, d as createShape3D, dt as xsdTextAnchor, et as xsdEffectContainer, f as BevelPresetType, ft as xsdTextCaps, g as createEffectDag, gt as createSourceRectangle, h as createScene3D, ht as Stretch, i as createBlipFill, it as xsdPathFillMode, j as PenAlignment, jt as uniqueId, k as LineCap, kt as createColorTransforms, l as createAdjustmentValues, lt as xsdStrikeStyle, m as createBottomBevel, mt as xsdVerticalMergeRev, n as createGroupTransform2D, nt as xsdLineEndSize, o as createExtentionList, ot as xsdPenAlignment, p as createBevel, pt as xsdUnderlineStyle, q as createGradientFill, r as createTransform2D, rt as xsdMaterialType, s as createCustomGeometry, st as xsdPresetShadow, t as createTransformation, tt as xsdLineCap, u as PresetMaterialType, ut as xsdTextAlign, v as createSoftEdgeEffect, vt as createColorElement, w as createInnerShadowEffect, wt as createScRgbColor, x as createPresetShadowEffect, xt as createSystemColor, y as createReflectionEffect, yt as createSolidFill, z as createGroupFill, zt as convertMillimetersToTwip } from "./drawingml-DzU9sEb0.mjs";
import { a as DataModel, c as getColorXml, d as COLOR_CATEGORIES, f as LAYOUT_CATEGORIES, i as TransPoint, l as getLayoutXml, n as SmartArtCollection, o as Connection, p as STYLE_CATEGORIES, r as Point, s as DEFAULT_DRAWING_XML, t as createDataModel, u as getStyleXml } from "./smartart-vyDm6U1_.mjs";
import { a as ScatterChart, c as BarChart, d as createStrRef, f as CatAx, i as createChartType, l as AreaChart, n as ChartSpace, o as PieChart, p as ValAx, r as ChartTitle, s as LineChart, t as ChartCollection, u as createNumRef } from "./chart-DO9i3S1G.mjs";
import { a as createTraverser, c as TokenNotFoundError, d as getFirstLevelElements, f as patchSpaceAttribute, h as PPTX_NS, i as createReplacer, l as createSplitInject, m as DOCX_NS, n as getNextRelationshipIndex, o as createRunRenderer, p as toJson, r as appendContentType, s as createTokenReplacer, t as appendRelationship, u as createTextElementContents } from "./patch-O6SD_BaJ.mjs";
import { escapeXml, js2xml, textOf, xml2js } from "@office-open/xml";
import { AsyncZipDeflate, Zip, ZipPassThrough, strFromU8, strFromU8 as strFromU8$1, strToU8, unzipSync, unzipSync as unzipSync$1, zip, zipSync } from "fflate";
//#region src/output-type.ts
/**
* Output type definitions for OOXML document export.
*
* @module
*/
const OoxmlMimeType = {
DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
};
const convertOutput = (data, type, mimeType = OoxmlMimeType.DOCX) => {
switch (type) {
case "nodebuffer": return Buffer.from(data);
case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: mimeType });
case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
case "uint8array": return data;
case "base64": return btoa(strFromU8$1(data, true));
case "string":
case "text":
case "binarystring": return strFromU8$1(data, true);
case "array": return [...data];
default: return data;
}
};
//#endregion
//#region src/packer.ts
/**
* Shared packer utilities for OOXML document generation.
*
* @module
*/
/** Default DEFLATE compression level matching Microsoft Office behavior. */
const ZIP_DEFLATE_LEVEL = 6;
/** STORE level for already-compressed media formats (JPEG, PNG, GIF, etc.). */
const ZIP_STORED_LEVEL = 0;
/**
* Asynchronously compress files and convert to the requested output format.
*
* Uses fflate Web Workers for non-blocking DEFLATE compression.
* XML entries use DEFLATE by default; media entries should explicitly set
* `{ level: ZIP_STORED_LEVEL }` to avoid redundant compression.
*/
const zipAndConvert = async (files, type, mimeType, level = 6) => {
return convertOutput(await new Promise((resolve, reject) => {
zip(files, {
level,
consume: true
}, (err, data) => {
if (err) reject(err);
else resolve(data);
});
}), type, mimeType);
};
/**
* Synchronously compress files and convert to the requested output format.
*
* Uses synchronous DEFLATE compression for maximum throughput.
* Blocks the event loop — prefer {@link zipAndConvert} in server contexts.
*/
const zipSyncAndConvert = (files, type, mimeType, level = 6) => {
return convertOutput(zipSync(files, { level }), type, mimeType);
};
/**
* Create a `ReadableStream<Uint8Array>` from compressed file entries.
*
* Uses fflate's `AsyncZipDeflate` for non-blocking DEFLATE compression.
* `STORED` entries (media) pass through synchronously.
* Works in both Node.js and browsers (Web Streams API).
*/
const createZipStream = (files) => {
return new ReadableStream({ start(controller) {
try {
const zip = new Zip((err, chunk, _final) => {
if (err) {
controller.error(err);
return;
}
controller.enqueue(chunk);
if (_final) controller.close();
});
for (const [name, data] of Object.entries(files)) {
const raw = Array.isArray(data) ? data[0] : data;
const level = Array.isArray(data) ? data[1].level ?? 6 : 6;
const entry = level === 0 ? new ZipPassThrough(name) : new AsyncZipDeflate(name, { level });
zip.add(entry);
entry.push(raw, true);
}
zip.end();
} catch (err) {
controller.error(err instanceof Error ? err : new Error(String(err)));
}
} });
};
/**
* Create a Packer object with all output format methods.
*
* Centralises the ZIP → convert pipeline and the streaming implementation
* so that each OOXML package only needs to provide a `compile` function and
* a MIME type.
*/
const createPacker = (options) => {
const { compile, mimeType } = options;
const compileFiles = (file, overrides = []) => compile(file, overrides);
const pack = async (file, type, overrides) => {
return zipAndConvert(compileFiles(file, overrides), type, mimeType);
};
const toBytes = (file, overrides) => pack(file, "uint8array", overrides);
const toString = (file, overrides) => pack(file, "string", overrides);
const toBuffer = (file, overrides) => pack(file, "nodebuffer", overrides);
const toBase64String = (file, overrides) => pack(file, "base64", overrides);
const toBlob = (file, overrides) => pack(file, "blob", overrides);
const toArrayBuffer = (file, overrides) => pack(file, "arraybuffer", overrides);
const packSync = (file, type, overrides) => {
return zipSyncAndConvert(compileFiles(file, overrides), type, mimeType);
};
const toBytesSync = (file, overrides) => packSync(file, "uint8array", overrides);
const toStringSync = (file, overrides) => packSync(file, "string", overrides);
const toBufferSync = (file, overrides) => packSync(file, "nodebuffer", overrides);
const toBase64StringSync = (file, overrides) => packSync(file, "base64", overrides);
const toBlobSync = (file, overrides) => packSync(file, "blob", overrides);
const toArrayBufferSync = (file, overrides) => packSync(file, "arraybuffer", overrides);
const toStream = (file, overrides) => {
let files;
try {
files = compileFiles(file, overrides);
} catch (err) {
return new ReadableStream({ start(controller) {
controller.error(err instanceof Error ? err : new Error(String(err)));
} });
}
return createZipStream(files);
};
return {
compile,
pack,
packSync,
toBytes,
toBytesSync,
toString,
toStringSync,
toBuffer,
toBufferSync,
toBase64String,
toBase64StringSync,
toBlob,
toBlobSync,
toArrayBuffer,
toArrayBufferSync,
toStream
};
};
//#endregion
//#region src/opc/app-properties.ts
const APP_PROPS_XML = "<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\"/>";
var AppProperties = class AppProperties extends ImportedXmlComponent {
static instance = ImportedXmlComponent.fromXmlString(APP_PROPS_XML);
constructor() {
super("Properties");
}
prepForXml() {
return AppProperties.instance.prepForXml({ stack: [] });
}
toXml(_context) {
return AppProperties.instance.toXml(_context);
}
};
//#endregion
//#region src/opc/relationships.ts
const TargetModeType = { EXTERNAL: "External" };
const RELS_ATTRS = { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } };
var Relationships = class extends BaseXmlComponent {
entries = [];
constructor() {
super("Relationships");
}
addRelationship(id, type, target, targetMode) {
this.entries.push({
id: `rId${id}`,
type,
target,
targetMode
});
}
get relationshipCount() {
return this.entries.length;
}
/**
* Zero-allocation fast path: directly concatenate XML string.
* Bypasses the IXmlableObject intermediate tree entirely.
*/
toXml(_context) {
const p = ["<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">"];
for (const e of this.entries) {
const tm = e.targetMode ? ` TargetMode="${escapeXml(e.targetMode)}"` : "";
p.push(`<Relationship Id="${escapeXml(e.id)}" Type="${escapeXml(e.type)}" Target="${escapeXml(e.target)}"${tm}/>`);
}
p.push("</Relationships>");
return p.join("");
}
prepForXml(_context) {
const children = [RELS_ATTRS];
for (const e of this.entries) {
const attrs = {
Id: e.id,
Type: e.type,
Target: e.target
};
if (e.targetMode) attrs.TargetMode = e.targetMode;
children.push({ Relationship: { _attr: attrs } });
}
if (children.length === 1 && "_attr" in children[0]) return { Relationships: children[0] };
return { Relationships: children };
}
};
//#endregion
//#region src/opc/content-types.ts
/**
* Content Types components for OPC (Open Packaging Convention).
*
* Provides Default and Override elements used in [Content_Types].xml
* to map file extensions and part paths to MIME content types.
*
* Reference: ECMA-376 Part 2, Section 10.1
*
* @module
*/
/**
* Creates a Default element mapping a file extension to a MIME content type.
*/
const createDefault = (contentType, extension) => new BuilderElement({
attributes: {
contentType: {
key: "ContentType",
value: contentType
},
extension: {
key: "Extension",
value: extension
}
},
name: "Default"
});
/**
* Creates an Override element mapping a specific part path to a MIME content type.
*/
const createOverride = (contentType, partName) => new BuilderElement({
attributes: {
contentType: {
key: "ContentType",
value: contentType
},
partName: {
key: "PartName",
value: partName
}
},
name: "Override"
});
//#endregion
//#region src/formatter.ts
const XML_DECL = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
/**
* Converts an XmlComponent tree into a serializable XML object or string.
*/
var Formatter = class {
format(input, context = { stack: [] }) {
const output = input.prepForXml(context);
if (output) return output;
throw new Error("XMLComponent did not format correctly");
}
/**
* Serialize a component directly to XML string via the toXml() fast path.
* Always includes XML declaration.
*/
formatToXml(input, context) {
const body = input.toXml(context);
return body ? XML_DECL + body : "";
}
};
//#endregion
//#region src/core-properties.ts
const FIELD_MAP = [
{
name: "dc:title",
key: "title"
},
{
name: "dc:subject",
key: "subject"
},
{
name: "dc:creator",
key: "creator"
},
{
name: "dc:description",
key: "description"
},
{
name: "cp:keywords",
key: "keywords"
},
{
name: "cp:lastModifiedBy",
key: "lastModifiedBy"
}
];
/**
* Parse core properties from an already-parsed XML element.
* Shared by docx and pptx to extract Dublin Core metadata.
*/
function parseCorePropsElement(el) {
if (!el) return {};
const props = {};
for (const field of FIELD_MAP) {
const child = el.elements?.find((e) => e.name === field.name);
const value = textOf(child) || void 0;
if (value) props[field.key] = value;
}
const revEl = el.elements?.find((e) => e.name === "cp:revision");
if (revEl) {
const rev = textOf(revEl);
if (rev) {
const n = Number(rev);
if (!isNaN(n)) props.revision = rev;
}
}
return props;
}
const CORE_PROPS_NS = Object.freeze({ _attr: Object.freeze({
"xmlns:cp": "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
"xmlns:dc": "http://purl.org/dc/elements/1.1/",
"xmlns:dcmitype": "http://purl.org/dc/dcmitype/",
"xmlns:dcterms": "http://purl.org/dc/terms/",
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
}) });
const W3CDTF_ATTR = Object.freeze({ _attr: Object.freeze({ "xsi:type": "dcterms:W3CDTF" }) });
/**
* Build a cp:coreProperties XML object from metadata.
*
* Shared by docx and pptx to avoid duplicating namespace declarations
* and Dublin Core property construction.
*/
function buildCorePropertiesXml(opts) {
const children = [CORE_PROPS_NS];
if (opts.title) children.push({ "dc:title": [opts.title] });
if (opts.subject) children.push({ "dc:subject": [opts.subject] });
if (opts.creator) children.push({ "dc:creator": [opts.creator] });
if (opts.keywords) children.push({ "cp:keywords": [opts.keywords] });
if (opts.description) children.push({ "dc:description": [opts.description] });
children.push({ "cp:lastModifiedBy": [opts.lastModifiedBy || opts.creator || "Unknown"] });
if (opts.revision) children.push({ "cp:revision": [String(opts.revision)] });
const now = (/* @__PURE__ */ new Date()).toISOString();
children.push({ "dcterms:created": [W3CDTF_ATTR, now] });
children.push({ "dcterms:modified": [W3CDTF_ATTR, now] });
return { "cp:coreProperties": children };
}
/**
* Build a cp:coreProperties XML string directly (fast path).
*
* Shared by pptx and xlsx to bypass prepForXml → xml() pipeline.
*/
function buildCorePropertiesXmlString(opts) {
const p = ["<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"];
if (opts.title) p.push(`<dc:title>${escapeXml(opts.title)}</dc:title>`);
if (opts.subject) p.push(`<dc:subject>${escapeXml(opts.subject)}</dc:subject>`);
if (opts.creator) p.push(`<dc:creator>${escapeXml(opts.creator)}</dc:creator>`);
if (opts.keywords) p.push(`<cp:keywords>${escapeXml(opts.keywords)}</cp:keywords>`);
if (opts.description) p.push(`<dc:description>${escapeXml(opts.description)}</dc:description>`);
p.push(`<cp:lastModifiedBy>${escapeXml(opts.lastModifiedBy || opts.creator || "Unknown")}</cp:lastModifiedBy>`);
if (opts.revision) p.push(`<cp:revision>${opts.revision}</cp:revision>`);
const now = (/* @__PURE__ */ new Date()).toISOString();
p.push(`<dcterms:created xsi:type="dcterms:W3CDTF">${now}</dcterms:created>`);
p.push(`<dcterms:modified xsi:type="dcterms:W3CDTF">${now}</dcterms:modified>`);
p.push("</cp:coreProperties>");
return p.join("");
}
//#endregion
//#region src/parser.ts
const XML_PARSE_OPTIONS = {
nativeTypeAttributes: true,
captureSpacesBetweenElements: true
};
/**
* Parsed OOXML archive backed by an unzipped ZIP map.
*
* Provides unstorage-style API (get/set/getRaw/setRaw/remove/has/keys)
* for reading and modifying individual parts, then serializing back to a ZIP buffer.
*/
var ParsedArchive = class {
zip;
modified = /* @__PURE__ */ new Map();
wrapperCache = /* @__PURE__ */ new Map();
constructor(data) {
this.zip = new Map(Object.entries(unzipSync$1(data)));
}
/** Read an XML part as an Element tree. */
get(path) {
const modData = this.modified.get(path);
if (modData) {
const wrapper = xml2js(strFromU8$1(modData), XML_PARSE_OPTIONS);
this.wrapperCache.set(path, wrapper);
return wrapper.elements?.find((e) => e.type === "element");
}
const data = this.zip.get(path);
if (data === void 0) return void 0;
const cached = this.wrapperCache.get(path);
if (cached) return cached.elements?.find((e) => e.type === "element");
const wrapper = xml2js(strFromU8$1(data), XML_PARSE_OPTIONS);
this.wrapperCache.set(path, wrapper);
return wrapper.elements?.find((e) => e.type === "element");
}
/** Write an XML part (Element → XML string). */
set(path, element) {
const wrapper = this.wrapperCache.get(path);
const xml = js2xml(wrapper ? {
...wrapper,
elements: [{
...element,
type: "element"
}]
} : { elements: [{
...element,
type: "element"
}] });
this.modified.set(path, strToU8(xml));
}
/** Read raw binary data (images, media, etc.). */
getRaw(path) {
return this.modified.get(path) ?? this.zip.get(path);
}
/** Write raw binary data. */
setRaw(path, data) {
this.modified.set(path, data);
this.wrapperCache.delete(path);
}
/** Remove a part. Returns true if it existed. */
remove(path) {
this.wrapperCache.delete(path);
return this.modified.delete(path) || this.zip.delete(path);
}
/** Check if a part exists. */
has(path) {
return this.modified.has(path) || this.zip.has(path);
}
/** List all paths matching an optional prefix. */
keys(prefix) {
const all = /* @__PURE__ */ new Set();
for (const key of this.zip.keys()) if (!prefix || key.startsWith(prefix)) all.add(key);
for (const key of this.modified.keys()) if (!prefix || key.startsWith(prefix)) all.add(key);
return [...all];
}
/** Serialize back to a ZIP buffer, merging original zip + modifications. */
save() {
const files = {};
for (const [path, data] of this.zip) if (!this.modified.has(path)) files[path] = isMediaPath(path) ? [data, { level: MEDIA_STORED_LEVEL }] : data;
for (const [path, data] of this.modified) files[path] = isMediaPath(path) ? [data, { level: MEDIA_STORED_LEVEL }] : data;
return zipSync(files);
}
};
/** Set of already-compressed media file extensions (lowercase, with dot prefix). */
const MEDIA_EXTENSIONS = new Set([
".png",
".jpg",
".jpeg",
".gif",
".wmf",
".emf",
".tif",
".tiff",
".avi",
".mp4",
".mp3",
".wav"
]);
/** Check if a file path has a media extension that should use STORE (no compression). */
function isMediaPath(path) {
const dot = path.lastIndexOf(".");
if (dot === -1) return false;
return MEDIA_EXTENSIONS.has(path.slice(dot).toLowerCase());
}
/** STORE level for already-compressed media formats. */
const MEDIA_STORED_LEVEL = 0;
/** Parse an OOXML archive (.docx, .pptx, .xlsx) into a ParsedArchive. */
function parseArchive(data) {
return new ParsedArchive(data);
}
//#endregion
//#region src/raw-passthrough.ts
/**
* Convert an Element tree to xml-js compact format (IXmlableObject).
* Always wraps in a named key so the element name is preserved even for empty elements.
*/
function elementToCompact(el) {
const inner = {};
if (el.attributes && Object.keys(el.attributes).length > 0) inner._attributes = el.attributes;
if (el.cdata) inner._cdata = el.cdata;
else if (el.text !== null && el.text !== void 0) inner._text = el.text;
if (el.elements) for (const child of el.elements) {
const key = child.name ?? "_unknown";
const compactChild = elementToCompact(child);
if (inner[key]) {
if (!Array.isArray(inner[key])) inner[key] = [inner[key]];
inner[key].push(compactChild);
} else inner[key] = compactChild;
}
const name = el.name ?? "unknown";
if (Object.keys(inner).length === 0) return { [name]: {} };
return { [name]: inner };
}
/**
* Thin wrapper that passes a raw Element tree through the XML serialization pipeline.
* Used to include parsed-but-unrecognized XML in generated documents.
*/
var RawPassthrough = class extends BaseXmlComponent {
constructor(element) {
super(element.name ?? "unknown");
this.element = element;
}
prepForXml(_context) {
return elementToCompact(this.element);
}
};
//#endregion
//#region src/placeholder.ts
const formatId = (offset, index, style) => style === "rId" ? `rId${offset + index}` : `${offset + index}`;
function hasPlaceholders(xml) {
return xml.includes("{");
}
function collectPlaceholderKeys(xml, prefix) {
const keys = [];
const search = `{${prefix}`;
let pos = 0;
while ((pos = xml.indexOf(search, pos)) !== -1) {
const keyStart = pos + search.length;
const keyEnd = xml.indexOf("}", keyStart);
if (keyEnd === -1) break;
const key = xml.substring(keyStart, keyEnd);
if (key.length > 0 && !keys.includes(key)) keys.push(key);
pos = keyEnd + 1;
}
return keys;
}
function replaceImagePlaceholders(xml, mediaData, offset, idFormat = "rId") {
let result = xml;
mediaData.forEach((image, i) => {
result = result.replaceAll(`{${image.fileName}}`, formatId(offset, i, idFormat));
});
return result;
}
function getReferencedMedia(xml, mediaArray) {
return mediaArray.filter((image) => xml.includes(`{${image.fileName}}`));
}
function replaceChartPlaceholders(xml, chartKeys, offset, idFormat = "rId") {
let result = xml;
chartKeys.forEach((key, i) => {
result = result.replaceAll(`{chart:${key}}`, formatId(offset, i, idFormat));
});
return result;
}
function replaceSmartArtPlaceholders(xml, keys, dataOffset, idFormat = "rId") {
let result = xml;
const count = keys.length;
const loOffset = dataOffset + count;
const qsOffset = loOffset + count;
const csOffset = qsOffset + count;
keys.forEach((key, i) => {
result = result.replaceAll(`{smartart:${key}}`, formatId(dataOffset, i, idFormat));
result = result.replaceAll(`{smartart-lo:${key}}`, formatId(loOffset, i, idFormat));
result = result.replaceAll(`{smartart-qs:${key}}`, formatId(qsOffset, i, idFormat));
result = result.replaceAll(`{smartart-cs:${key}}`, formatId(csOffset, i, idFormat));
});
return result;
}
function addSmartArtRelationships(keys, addRel, baseOffset, globalStartIndex, options) {
const { pathPrefix, styleRelType } = options;
const count = keys.length;
const loOffset = baseOffset + count;
const qsOffset = loOffset + count;
const csOffset = qsOffset + count;
keys.forEach((_key, i) => {
const gi = globalStartIndex + i;
addRel(baseOffset + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData", `${pathPrefix}diagrams/data${gi + 1}.xml`);
addRel(loOffset + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout", `${pathPrefix}diagrams/layout${gi + 1}.xml`);
addRel(qsOffset + i, styleRelType, `${pathPrefix}diagrams/quickStyle${gi + 1}.xml`);
addRel(csOffset + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors", `${pathPrefix}diagrams/colors${gi + 1}.xml`);
addRel(csOffset + count + i, "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing", `${pathPrefix}diagrams/drawing${gi + 1}.xml`);
});
}
//#endregion
//#region src/compiler-utils.ts
/** Default STORE level for already-compressed media formats. */
const ZIP_STORED_LEVEL$1 = 0;
/** Reusable TextEncoder instance (stateless, safe to share). */
const encoder = new TextEncoder();
/**
* Convert a mapping of XML files + overrides + media into a Zippable structure.
*
* Centralises the mapping→Zippable conversion shared by all three compilers.
*/
function compileMapping(mapping, overrides, media) {
const files = {};
for (const entry of Object.values(mapping)) files[entry.path] = encoder.encode(entry.data);
if (overrides) for (const o of overrides) files[o.path] = typeof o.data === "string" ? encoder.encode(o.data) : o.data;
if (media) for (const m of media) files[m.path] = [m.data, { level: ZIP_STORED_LEVEL$1 }];
return files;
}
//#endregion
export { AppProperties, AreaChart, BarChart, BaseXmlComponent, BevelPresetType, BlendMode, BuilderElement, COLOR_CATEGORIES, CatAx, ChartCollection, ChartSpace, ChartTitle, CompoundLine, Connection, DEFAULT_DRAWING_XML, DOCX_NS, DataModel, EMPTY_OBJECT, EmptyElement, Formatter, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, LAYOUT_CATEGORIES, LineCap, LineChart, LineEndLength, LineEndType, LineEndWidth, LineJoin, NextAttributeComponent, OoxmlMimeType, PPTX_NS, ParsedArchive, PathShadeType, PenAlignment, PieChart, Point, PresetColor, PresetDash, PresetGeometry, PresetMaterialType, PresetPattern, PresetShadowVal, RawPassthrough, RectAlignment, Relationships, STYLE_CATEGORIES, ScatterChart, SchemeColor, SmartArtCollection, Stretch, SystemColor, TargetModeType, ThemeColor, ThemeFont, TileAlignment, TileFlipMode, TokenNotFoundError, TransPoint, ValAx, XmlAttributeComponent, XmlComponent, ZIP_DEFLATE_LEVEL, ZIP_STORED_LEVEL, addSmartArtRelationships, appendContentType, appendRelationship, attrObj, buildCorePropertiesXml, buildCorePropertiesXmlString, buildFill, chartAttr, collectPlaceholderKeys, compileMapping, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPointsToEmu, convertToXmlComponent, createAdjustmentValues, createBevel, createBlip, createBlipEffects, createBlipFill, createBottomBevel, createChartType, createColorElement, createColorTransforms, createCustomDash, createCustomGeometry, createDataModel, createDefault, createEffectDag, createEffectList, createExtentionList, createFillOverlayEffect, createGlowEffect, createGradientFill, createGradientStop, createGroupFill, createGroupTransform2D, createHslColor, createInnerShadowEffect, createLineEnd, createNoFill, createNumRef, createOuterShadowEffect, createOutline, createOverride, createPacker, createPatternFill, createPresetColor, createPresetShadowEffect, createReflectionEffect, createReplacer, createRgbColor, createRunRenderer, createScRgbColor, createScene3D, createSchemeColor, createShape3D, createSoftEdgeEffect, createSolidFill, createSourceRectangle, createSplitInject, createStrRef, createSystemColor, createTextElementContents, createTileInfo, createTokenReplacer, createTransform2D, createTransformation, createTraverser, createZipStream, dateTimeValue, decimalNumber, eighthPointMeasureValue, elementToCompact, extractBlipFillMedia, formatId, getColorXml, getFirstLevelElements, getLayoutXml, getNextRelationshipIndex, getReferencedMedia, getStyleXml, hasPlaceholders, hashedId, hexBinary, hexColorValue, hpsMeasureObj, hpsMeasureValue, invertMap, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseArchive, parseCorePropsElement, patchSpaceAttribute, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, strFromU8, stringContainerObj, stringEnumValObj, stringValObj, toJson, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipSync, wrapEl, xsdBlendMode, xsdCompoundLine, xsdEffectContainer, xsdLineCap, xsdLineEndSize, xsdMaterialType, xsdPathFillMode, xsdPattern, xsdPenAlignment, xsdPresetShadow, xsdRectAlignment, xsdStrikeStyle, xsdTextAlign, xsdTextAnchor, xsdTextCaps, xsdUnderlineStyle, xsdVerticalMergeRev, zipAndConvert, zipSyncAndConvert };
import { xml2js } from "@office-open/xml";
//#region src/patch/xml-namespace.ts
const DOCX_NS = {
paragraph: "w:p",
run: "w:r",
text: "w:t",
runProperties: "w:rPr"
};
const PPTX_NS = {
paragraph: "a:p",
run: "a:r",
text: "a:t",
runProperties: "a:rPr"
};
//#endregion
//#region src/patch/xml-patch-utils.ts
/**
* XML utility functions for patch operations.
*/
const toJson = (xmlData) => {
return xml2js(xmlData, {
captureSpacesBetweenElements: true,
compact: false
});
};
/**
* Creates the inner content of a text element (`w:t` / `a:t`).
*
* Returns `[{ type: "text", text }]` for non-empty text, `[]` for empty.
* The `xml:space` attribute is handled separately by `patchSpaceAttribute`.
*/
const createTextElementContents = (text) => text === "" ? [] : [{
text,
type: "text"
}];
const patchSpaceAttribute = (element) => ({
...element,
attributes: { "xml:space": "preserve" }
});
const getFirstLevelElements = (relationships, id) => relationships.elements?.filter((e) => e.name === id)[0].elements ?? [];
//#endregion
//#region src/patch/paragraph-split-inject.ts
var TokenNotFoundError = class extends Error {
constructor(token) {
super(`Token ${token} not found`);
this.name = "TokenNotFoundError";
}
};
function createSplitInject(ns, createTextElementContents, options) {
const preserveSpace = options?.preserveSpace ?? true;
const findRunElementIndexWithToken = (paragraphElement, token) => {
for (let i = 0; i < (paragraphElement.elements ?? []).length; i++) {
const element = paragraphElement.elements[i];
if (element.type === "element" && element.name === ns.run) {
const textElement = (element.elements ?? []).filter((e) => e.type === "element" && e.name === ns.text);
for (const text of textElement) {
if (!text.elements?.[0]) continue;
if (text.elements[0].text?.includes(token)) return i;
}
}
}
throw new TokenNotFoundError(token);
};
const splitRunElement = (runElement, token) => {
let splitIndex = -1;
const splitElements = runElement.elements?.map((e, i) => {
if (splitIndex !== -1) return e;
if (e.type === "element" && e.name === ns.text) {
const splitText = (e.elements?.[0]?.text ?? "").split(token);
const newElements = splitText.map((t) => ({
...e,
...preserveSpace ? patchSpaceAttribute(e) : {},
elements: createTextElementContents(t)
}));
if (splitText.length > 1) splitIndex = i;
return newElements;
} else return e;
}).flat() ?? [];
return {
left: {
...structuredClone(runElement),
elements: splitElements.slice(0, splitIndex + 1)
},
right: {
...structuredClone(runElement),
elements: splitElements.slice(splitIndex + 1)
}
};
};
return {
findRunElementIndexWithToken,
splitRunElement
};
}
//#endregion
//#region src/patch/paragraph-token-replacer.ts
const ReplaceMode = {
START: 0,
MIDDLE: 1,
END: 2
};
function createTokenReplacer(createTextElementContents, options) {
const preserveSpace = options?.preserveSpace ?? true;
const patchTextElement = (element, text) => {
element.elements = createTextElementContents(text);
return element;
};
return ({ paragraphElement, renderedParagraph, originalText, replacementText }) => {
const startIndex = renderedParagraph.text.indexOf(originalText);
const endIndex = startIndex + originalText.length - 1;
let replaceMode = ReplaceMode.START;
for (const run of renderedParagraph.runs) for (const { text, index, start, end } of run.parts) switch (replaceMode) {
case ReplaceMode.START:
if (startIndex >= start && startIndex <= end) {
const offsetStartIndex = startIndex - start;
const offsetEndIndex = Math.min(endIndex, end) - start;
const partToReplace = text.substring(offsetStartIndex, offsetEndIndex + 1);
if (partToReplace === "") continue;
const firstPart = text.replace(partToReplace, replacementText);
patchTextElement(paragraphElement.elements[run.index].elements[index], firstPart);
replaceMode = ReplaceMode.MIDDLE;
continue;
}
break;
case ReplaceMode.MIDDLE:
if (endIndex <= end) {
const lastPart = text.substring(endIndex - start + 1);
patchTextElement(paragraphElement.elements[run.index].elements[index], lastPart);
const currentElement = paragraphElement.elements[run.index].elements[index];
paragraphElement.elements[run.index].elements[index] = preserveSpace ? patchSpaceAttribute(currentElement) : currentElement;
replaceMode = ReplaceMode.END;
} else patchTextElement(paragraphElement.elements[run.index].elements[index], "");
break;
}
return paragraphElement;
};
}
//#endregion
//#region src/patch/run-renderer.ts
function createRunRenderer(ns) {
const renderParagraphNode = (node) => {
if (node.element.name !== ns.paragraph) throw new Error(`Invalid node type: ${node.element.name}`);
if (!node.element.elements) return {
index: -1,
pathToParagraph: [],
runs: [],
text: ""
};
let currentRunStringLength = 0;
const runs = node.element.elements.map((element, i) => ({
element,
i
})).filter(({ element }) => element.name === ns.run).map(({ element, i }) => {
const renderedRunNode = renderRunNode(element, i, currentRunStringLength);
currentRunStringLength += renderedRunNode.text.length;
return renderedRunNode;
}).filter((e) => Boolean(e));
const text = runs.reduce((acc, curr) => acc + curr.text, "");
return {
index: node.index,
pathToParagraph: buildNodePath(node),
runs,
text
};
};
const renderRunNode = (node, index, currentRunStringIndex) => {
if (!node.elements) return {
end: currentRunStringIndex,
index: -1,
parts: [],
start: currentRunStringIndex,
text: ""
};
let currentTextStringIndex = currentRunStringIndex;
const parts = node.elements.map((element, i) => element.name === ns.text && element.elements && element.elements.length > 0 ? (() => {
const partStart = currentTextStringIndex;
currentTextStringIndex += (element.elements[0].text?.toString() ?? "").length;
return {
end: currentTextStringIndex - 1,
index: i,
start: partStart,
text: element.elements[0].text?.toString() ?? ""
};
})() : void 0).filter((e) => Boolean(e)).map((e) => e);
const text = parts.reduce((acc, curr) => acc + curr.text, "");
return {
end: currentTextStringIndex - 1,
index,
parts,
start: currentRunStringIndex,
text
};
};
return renderParagraphNode;
}
const buildNodePath = (node) => node.parent ? [...buildNodePath(node.parent), node.index] : [node.index];
//#endregion
//#region src/patch/xml-traverser.ts
const elementsToWrapper = (wrapper) => wrapper.element.elements?.map((e, i) => ({
element: e,
index: i,
parent: wrapper
})) ?? [];
function createTraverser(ns) {
const renderParagraphNode = createRunRenderer(ns);
const traverse = (node) => {
let renderedParagraphs = [];
const queue = [...elementsToWrapper({
element: node,
index: 0,
parent: void 0
})];
let currentNode;
while (queue.length > 0) {
currentNode = queue.shift();
if (currentNode.element.name === ns.paragraph) renderedParagraphs = [...renderedParagraphs, renderParagraphNode(currentNode)];
queue.push(...elementsToWrapper(currentNode));
}
return renderedParagraphs;
};
const findLocationOfText = (node, text) => traverse(node).filter((p) => p.text.includes(text));
return {
traverse,
findLocationOfText
};
}
//#endregion
//#region src/patch/xml-replacer.ts
const SPLIT_TOKEN = "ɵ";
function createReplacer(config) {
const { ns, formatChild } = config;
const { findLocationOfText } = createTraverser(ns);
const replaceTokenInParagraphElement = createTokenReplacer(createTextElementContents, { preserveSpace: config.preserveSpace });
const { findRunElementIndexWithToken, splitRunElement } = createSplitInject(ns, createTextElementContents, { preserveSpace: config.preserveSpace });
const replacer = ({ json, patch, patchText, context, keepOriginalStyles = true }) => {
const renderedParagraphs = findLocationOfText(json, patchText);
if (renderedParagraphs.length === 0) return {
didFindOccurrence: false,
element: json
};
for (const renderedParagraph of renderedParagraphs) {
const textJson = patch.children.flatMap((c) => formatChild(c, context));
switch (patch.type) {
case "file": {
const parentElement = goToParentElementFromPath(json, renderedParagraph.pathToParagraph);
const elementIndex = getLastElementIndexFromPath(renderedParagraph.pathToParagraph);
parentElement.elements.splice(elementIndex, 1, ...textJson);
break;
}
default: {
const paragraphElement = goToElementFromPath(json, renderedParagraph.pathToParagraph);
replaceTokenInParagraphElement({
originalText: patchText,
paragraphElement,
renderedParagraph,
replacementText: SPLIT_TOKEN
});
const index = findRunElementIndexWithToken(paragraphElement, SPLIT_TOKEN);
const runElementToBeReplaced = paragraphElement.elements[index];
const { left, right } = splitRunElement(runElementToBeReplaced, SPLIT_TOKEN);
let newRunElements = textJson;
let patchedRightElement = right;
if (keepOriginalStyles) {
const runElementNonTextualElements = runElementToBeReplaced.elements.filter((e) => e.type === "element" && e.name === ns.runProperties);
newRunElements = textJson.map((e) => {
if (e.type !== "element" || e.name !== ns.run || e.elements?.some((c) => c.type === "element" && c.name === ns.runProperties)) return e;
return {
...e,
elements: [...runElementNonTextualElements, ...e.elements ?? []]
};
});
patchedRightElement = {
...right,
elements: [...runElementNonTextualElements, ...right.elements]
};
}
paragraphElement.elements.splice(index, 1, left, ...newRunElements, patchedRightElement);
break;
}
}
}
return {
didFindOccurrence: true,
element: json
};
};
return replacer;
}
const goToElementFromPath = (json, path) => {
let element = json;
for (let i = 1; i < path.length; i++) {
const index = path[i];
element = element.elements[index];
}
return element;
};
const goToParentElementFromPath = (json, path) => goToElementFromPath(json, path.slice(0, -1));
const getLastElementIndexFromPath = (path) => path[path.length - 1];
//#endregion
//#region src/patch/content-types-manager.ts
const appendContentType = (element, contentType, extension) => {
const relationshipElements = getFirstLevelElements(element, "Types");
if (relationshipElements.some((el) => el.type === "element" && el.name === "Default" && el?.attributes?.ContentType === contentType && el?.attributes?.Extension === extension)) return;
relationshipElements.push({
attributes: {
ContentType: contentType,
Extension: extension
},
name: "Default",
type: "element"
});
};
//#endregion
//#region src/patch/relationship-manager.ts
const getIdFromRelationshipId = (relationshipId) => {
const output = parseInt(relationshipId.substring(3), 10);
return isNaN(output) ? 0 : output;
};
const getNextRelationshipIndex = (relationships) => {
return getFirstLevelElements(relationships, "Relationships").map((e) => getIdFromRelationshipId(e.attributes?.Id?.toString() ?? "")).reduce((acc, curr) => Math.max(acc, curr), 0) + 1;
};
const appendRelationship = (relationships, id, type, target, targetMode) => {
const relationshipElements = getFirstLevelElements(relationships, "Relationships");
relationshipElements.push({
attributes: {
Id: `rId${id}`,
Target: target,
TargetMode: targetMode,
Type: type
},
name: "Relationship",
type: "element"
});
return relationshipElements;
};
//#endregion
export { createTraverser as a, TokenNotFoundError as c, getFirstLevelElements as d, patchSpaceAttribute as f, PPTX_NS as h, createReplacer as i, createSplitInject as l, DOCX_NS as m, getNextRelationshipIndex as n, createRunRenderer as o, toJson as p, appendContentType as r, createTokenReplacer as s, appendRelationship as t, createTextElementContents as u };
import { _ as PPTX_NS, a as getFirstLevelElements, c as TokenNotFoundError, d as createTraverser, f as RenderedParagraphNode, g as DOCX_NS, h as createReplacer, i as createTextElementContents, l as createSplitInject, m as ReplacerConfig, n as getNextRelationshipIndex, o as patchSpaceAttribute, p as createRunRenderer, r as appendContentType, s as toJson, t as appendRelationship, u as createTokenReplacer, v as XmlNamespaceConfig } from "../index-DNLRdIqy.mjs";
export { DOCX_NS, PPTX_NS, RenderedParagraphNode, ReplacerConfig, TokenNotFoundError, XmlNamespaceConfig, appendContentType, appendRelationship, createReplacer, createRunRenderer, createSplitInject, createTextElementContents, createTokenReplacer, createTraverser, getFirstLevelElements, getNextRelationshipIndex, patchSpaceAttribute, toJson };
import { a as createTraverser, c as TokenNotFoundError, d as getFirstLevelElements, f as patchSpaceAttribute, h as PPTX_NS, i as createReplacer, l as createSplitInject, m as DOCX_NS, n as getNextRelationshipIndex, o as createRunRenderer, p as toJson, r as appendContentType, s as createTokenReplacer, t as appendRelationship, u as createTextElementContents } from "../patch-O6SD_BaJ.mjs";
export { DOCX_NS, PPTX_NS, TokenNotFoundError, appendContentType, appendRelationship, createReplacer, createRunRenderer, createSplitInject, createTextElementContents, createTokenReplacer, createTraverser, getFirstLevelElements, getNextRelationshipIndex, patchSpaceAttribute, toJson };
import { b as XmlComponent, c as chartAttr } from "./xml-components-ctIqansl.mjs";
//#region src/smartart/categories.ts
/** Layout ID → OOXML category type */
const LAYOUT_CATEGORIES = {
default: "list",
list1: "list",
list2: "list",
vList2: "list",
hList1: "list",
pList1: "list",
process1: "process",
process2: "process",
process3: "process",
process4: "process",
chevron1: "process",
chevron2: "process",
arrow1: "process",
arrow2: "process",
cycle1: "cycle",
cycle2: "cycle",
cycle3: "cycle",
cycle4: "cycle",
cycle5: "cycle",
hierarchy1: "hier",
hierarchy2: "hier",
hierarchy3: "hier",
hierarchy4: "hier",
orgChart1: "hier",
pyramid1: "pyramid",
pyramid2: "pyramid",
pyramid3: "pyramid",
matrix1: "matrix",
matrix2: "matrix",
matrix3: "matrix",
radial1: "rel",
radial2: "rel",
radial3: "rel",
venn1: "rel",
funnel1: "rel",
balance1: "rel",
gear1: "rel",
constOrg1: "rel",
oppId1: "rel"
};
/** Style ID → OOXML category type */
const STYLE_CATEGORIES = {
simple1: "simple",
simple2: "simple",
simple3: "simple",
simple4: "simple",
simple5: "simple",
moderate1: "moderate",
moderate2: "moderate",
moderate3: "moderate",
moderate4: "moderate",
polished1: "polished",
polished2: "polished",
polished3: "polished",
polished4: "polished",
professional1: "professional",
professional2: "professional",
professional3: "professional",
professional4: "professional",
cartoon1: "cartoon",
cartoon2: "cartoon",
cartoon3: "cartoon",
cartoon4: "cartoon",
powdery1: "powdery",
powdery2: "powdery",
powdery3: "powdery",
powdery4: "powdery",
burnt1: "burnt",
burnt2: "burnt",
burnt3: "burnt",
burnt4: "burnt"
};
/** Color ID → OOXML category type */
const COLOR_CATEGORIES = {
accent1_2: "accent1",
accent2_2: "accent2",
accent3_2: "accent3",
accent4_2: "accent4",
accent5_2: "accent5",
accent6_2: "accent6",
colorful1: "colorful",
colorful2: "colorful",
colorful3: "colorful",
colorful4: "colorful",
dark1: "dark",
dark2: "dark",
primary1: "primary",
primary2: "primary",
gray1: "gray",
gray2: "gray"
};
//#endregion
//#region src/smartart/built-in-definitions.ts
const DGM_NS = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
const XML_DECL = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
/** Full default list layout (urn:microsoft.com/office/officeart/2005/8/layout/default) */
const FULL_DEFAULT_LAYOUT_XML = "<dgm:layoutDef xmlns:dgm=\"" + DGM_NS + "\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" uniqueId=\"urn:microsoft.com/office/officeart/2005/8/layout/default\"><dgm:title val=\"\"/><dgm:desc val=\"\"/><dgm:catLst><dgm:cat type=\"list\" pri=\"400\"/></dgm:catLst><dgm:sampData><dgm:dataModel><dgm:ptLst><dgm:pt modelId=\"0\" type=\"doc\"/><dgm:pt modelId=\"1\"><dgm:prSet phldr=\"1\"/></dgm:pt><dgm:pt modelId=\"2\"><dgm:prSet phldr=\"1\"/></dgm:pt><dgm:pt modelId=\"3\"><dgm:prSet phldr=\"1\"/></dgm:pt><dgm:pt modelId=\"4\"><dgm:prSet phldr=\"1\"/></dgm:pt><dgm:pt modelId=\"5\"><dgm:prSet phldr=\"1\"/></dgm:pt></dgm:ptLst><dgm:cxnLst><dgm:cxn modelId=\"6\" srcId=\"0\" destId=\"1\" srcOrd=\"0\" destOrd=\"0\"/><dgm:cxn modelId=\"7\" srcId=\"0\" destId=\"2\" srcOrd=\"1\" destOrd=\"0\"/><dgm:cxn modelId=\"8\" srcId=\"0\" destId=\"3\" srcOrd=\"2\" destOrd=\"0\"/><dgm:cxn modelId=\"9\" srcId=\"0\" destId=\"4\" srcOrd=\"3\" destOrd=\"0\"/><dgm:cxn modelId=\"10\" srcId=\"0\" destId=\"5\" srcOrd=\"4\" destOrd=\"0\"/></dgm:cxnLst><dgm:bg/><dgm:whole/></dgm:dataModel></dgm:sampData><dgm:styleData><dgm:dataModel><dgm:ptLst><dgm:pt modelId=\"0\" type=\"doc\"/><dgm:pt modelId=\"1\"/><dgm:pt modelId=\"2\"/></dgm:ptLst><dgm:cxnLst><dgm:cxn modelId=\"3\" srcId=\"0\" destId=\"1\" srcOrd=\"0\" destOrd=\"0\"/><dgm:cxn modelId=\"4\" srcId=\"0\" destId=\"2\" srcOrd=\"1\" destOrd=\"0\"/></dgm:cxnLst><dgm:bg/><dgm:whole/></dgm:dataModel></dgm:styleData><dgm:clrData><dgm:dataModel><dgm:ptLst><dgm:pt modelId=\"0\" type=\"doc\"/><dgm:pt modelId=\"1\"/><dgm:pt modelId=\"2\"/><dgm:pt modelId=\"3\"/><dgm:pt modelId=\"4\"/><dgm:pt modelId=\"5\"/><dgm:pt modelId=\"6\"/></dgm:ptLst><dgm:cxnLst><dgm:cxn modelId=\"7\" srcId=\"0\" destId=\"1\" srcOrd=\"0\" destOrd=\"0\"/><dgm:cxn modelId=\"8\" srcId=\"0\" destId=\"2\" srcOrd=\"1\" destOrd=\"0\"/><dgm:cxn modelId=\"9\" srcId=\"0\" destId=\"3\" srcOrd=\"2\" destOrd=\"0\"/><dgm:cxn modelId=\"10\" srcId=\"0\" destId=\"4\" srcOrd=\"3\" destOrd=\"0\"/><dgm:cxn modelId=\"11\" srcId=\"0\" destId=\"5\" srcOrd=\"4\" destOrd=\"0\"/><dgm:cxn modelId=\"12\" srcId=\"0\" destId=\"6\" srcOrd=\"5\" destOrd=\"0\"/></dgm:cxnLst><dgm:bg/><dgm:whole/></dgm:dataModel></dgm:clrData><dgm:layoutNode name=\"diagram\"><dgm:varLst><dgm:dir/><dgm:resizeHandles val=\"exact\"/></dgm:varLst><dgm:choose name=\"Name0\"><dgm:if name=\"Name1\" func=\"var\" arg=\"dir\" op=\"equ\" val=\"norm\"><dgm:alg type=\"snake\"><dgm:param type=\"grDir\" val=\"tL\"/><dgm:param type=\"flowDir\" val=\"row\"/><dgm:param type=\"contDir\" val=\"sameDir\"/><dgm:param type=\"off\" val=\"ctr\"/></dgm:alg></dgm:if><dgm:else name=\"Name2\"><dgm:alg type=\"snake\"><dgm:param type=\"grDir\" val=\"tR\"/><dgm:param type=\"flowDir\" val=\"row\"/><dgm:param type=\"contDir\" val=\"sameDir\"/><dgm:param type=\"off\" val=\"ctr\"/></dgm:alg></dgm:else></dgm:choose><dgm:shape xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:blip=\"\"><dgm:adjLst/></dgm:shape><dgm:presOf/><dgm:constrLst><dgm:constr type=\"w\" for=\"ch\" forName=\"node\" refType=\"w\"/><dgm:constr type=\"h\" for=\"ch\" forName=\"node\" refType=\"w\" refFor=\"ch\" refForName=\"node\" fact=\"0.6\"/><dgm:constr type=\"w\" for=\"ch\" forName=\"sibTrans\" refType=\"w\" refFor=\"ch\" refForName=\"node\" fact=\"0.1\"/><dgm:constr type=\"sp\" refType=\"w\" refFor=\"ch\" refForName=\"sibTrans\"/><dgm:constr type=\"primFontSz\" for=\"ch\" forName=\"node\" op=\"equ\" val=\"65\"/></dgm:constrLst><dgm:ruleLst/><dgm:forEach name=\"Name3\" axis=\"ch\" ptType=\"node\"><dgm:layoutNode name=\"node\"><dgm:varLst><dgm:bulletEnabled val=\"1\"/></dgm:varLst><dgm:alg type=\"tx\"/><dgm:shape type=\"rect\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:blip=\"\"><dgm:adjLst/></dgm:shape><dgm:presOf axis=\"desOrSelf\" ptType=\"node\"/><dgm:constrLst><dgm:constr type=\"lMarg\" refType=\"primFontSz\" fact=\"0.3\"/><dgm:constr type=\"rMarg\" refType=\"primFontSz\" fact=\"0.3\"/><dgm:constr type=\"tMarg\" refType=\"primFontSz\" fact=\"0.3\"/><dgm:constr type=\"bMarg\" refType=\"primFontSz\" fact=\"0.3\"/></dgm:constrLst><dgm:ruleLst><dgm:rule type=\"primFontSz\" val=\"5\" fact=\"NaN\" max=\"NaN\"/></dgm:ruleLst></dgm:layoutNode><dgm:forEach name=\"Name4\" axis=\"followSib\" ptType=\"sibTrans\" cnt=\"1\"><dgm:layoutNode name=\"sibTrans\"><dgm:alg type=\"sp\"/><dgm:shape xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:blip=\"\"><dgm:adjLst/></dgm:shape><dgm:presOf/><dgm:constrLst/><dgm:ruleLst/></dgm:layoutNode></dgm:forEach></dgm:layoutNode></dgm:layoutDef>";
/**
* Returns layout XML. Full XML for "default", minimal stub for others.
* Stub has no layoutNode so PowerPoint falls back to built-in definitions
* based on the uniqueId / loTypeId in the data model.
*/
function getLayoutXml(layoutId) {
if (layoutId === "default") return XML_DECL + FULL_DEFAULT_LAYOUT_XML;
const cat = LAYOUT_CATEGORIES[layoutId] ?? "list";
return XML_DECL + "<dgm:layoutDef xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" uniqueId=\"urn:microsoft.com/office/officeart/2005/8/layout/" + layoutId + "\"><dgm:title val=\"\"/><dgm:desc val=\"\"/><dgm:catLst><dgm:cat type=\"" + cat + "\" pri=\"400\"/></dgm:catLst><dgm:sampData><dgm:dataModel><dgm:ptLst><dgm:pt modelId=\"0\" type=\"doc\"/><dgm:pt modelId=\"1\"><dgm:prSet phldr=\"1\"/></dgm:pt><dgm:pt modelId=\"2\"><dgm:prSet phldr=\"1\"/></dgm:pt></dgm:ptLst><dgm:cxnLst><dgm:cxn modelId=\"3\" srcId=\"0\" destId=\"1\" srcOrd=\"0\" destOrd=\"0\"/><dgm:cxn modelId=\"4\" srcId=\"0\" destId=\"2\" srcOrd=\"1\" destOrd=\"0\"/></dgm:cxnLst><dgm:bg/><dgm:whole/></dgm:dataModel></dgm:sampData></dgm:layoutDef>";
}
/**
* Returns style stub XML with the given uniqueId.
*/
function getStyleXml(styleId) {
const cat = STYLE_CATEGORIES[styleId] ?? "simple";
return XML_DECL + "<dgm:styleDef xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" uniqueId=\"urn:microsoft.com/office/officeart/2005/8/quickstyle/" + styleId + "\"><dgm:title val=\"\"/><dgm:desc val=\"\"/><dgm:catLst><dgm:cat type=\"" + cat + "\" pri=\"10100\"/></dgm:catLst><dgm:scene3d><a:camera prst=\"orthographicFront\"/><a:lightRig rig=\"threePt\" dir=\"t\"/></dgm:scene3d></dgm:styleDef>";
}
/**
* Returns color stub XML with the given uniqueId.
*/
function getColorXml(colorId) {
const cat = COLOR_CATEGORIES[colorId] ?? "accent1";
return XML_DECL + "<dgm:colorsDef xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" uniqueId=\"urn:microsoft.com/office/officeart/2005/8/colors/" + colorId + "\"><dgm:title val=\"\"/><dgm:desc val=\"\"/><dgm:catLst><dgm:cat type=\"" + cat + "\" pri=\"11200\"/></dgm:catLst></dgm:colorsDef>";
}
/** Minimal drawing cache for SmartArt (Office apps auto-regenerate this on open) */
const DEFAULT_DRAWING_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><dsp:drawing xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:dsp=\"http://schemas.microsoft.com/office/drawing/2008/diagram\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><dsp:spTree><dsp:nvGrpSpPr><dsp:cNvPr id=\"0\" name=\"\"/><dsp:cNvGrpSpPr/></dsp:nvGrpSpPr><dsp:grpSpPr/></dsp:spTree></dsp:drawing>";
//#endregion
//#region src/smartart/data-model/connection.ts
/**
* dgm:cxn — SmartArt data model connection (edge).
*/
var Connection = class extends XmlComponent {
constructor(modelId, srcId, destId, type, srcOrd = 0, destOrd = 0, parTransId, sibTransId) {
super("dgm:cxn");
const attrs = {
modelId,
srcId,
destId,
srcOrd,
destOrd
};
if (type) attrs.type = type;
if (parTransId) attrs.parTransId = parTransId;
if (sibTransId) attrs.sibTransId = sibTransId;
this.root.push(chartAttr(attrs));
}
};
//#endregion
//#region src/smartart/data-model/data-model.ts
/**
* CT_DataModel — the complete data model for a SmartArt diagram.
*/
var DataModel = class extends XmlComponent {
constructor(points, connections) {
super("dgm:dataModel");
this.root.push(chartAttr({
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
"xmlns:dgm": "http://schemas.openxmlformats.org/drawingml/2006/diagram"
}));
const ptLst = new class extends XmlComponent {
constructor() {
super("dgm:ptLst");
}
}();
for (const pt of points) ptLst["root"].push(pt);
this.root.push(ptLst);
const cxnLst = new class extends XmlComponent {
constructor() {
super("dgm:cxnLst");
}
}();
for (const cxn of connections) cxnLst["root"].push(cxn);
this.root.push(cxnLst);
this.root.push(new EmptyElement$2("dgm:bg"));
this.root.push(new EmptyElement$2("dgm:whole"));
}
};
var EmptyElement$2 = class extends XmlComponent {
constructor(tag) {
super(tag);
}
};
//#endregion
//#region src/smartart/data-model/point.ts
/**
* dgm:pt — SmartArt data model point (node).
*/
var Point = class extends XmlComponent {
constructor(modelId, text, type = "node") {
super("dgm:pt");
this.root.push(chartAttr({
modelId,
type
}));
this.root.push(new PointText(text));
}
};
/**
* Transition point (parTrans or sibTrans) — no text body, references a connection.
*/
var TransPoint = class extends XmlComponent {
constructor(modelId, type, cxnId) {
super("dgm:pt");
this.root.push(chartAttr({
modelId,
type,
cxnId
}));
this.root.push(new EmptyElement$1("dgm:spPr"));
}
};
var EmptyElement$1 = class extends XmlComponent {
constructor(tag) {
super(tag);
}
};
/**
* dgm:t — text body within a point.
*/
var PointText = class extends XmlComponent {
constructor(text) {
super("dgm:t");
this.root.push(new EmptyElement$1("a:bodyPr"));
this.root.push(new EmptyElement$1("a:lstStyle"));
const p = new EmptyElement$1("a:p");
if (text) {
const t = new class extends XmlComponent {
constructor() {
super("a:t");
}
}();
t["root"].push(text);
const r = new class extends XmlComponent {
constructor() {
super("a:r");
}
}();
r["root"].push(t);
p["root"].push(r);
}
this.root.push(p);
}
};
//#endregion
//#region src/smartart/smartart-collection.ts
/**
* Manages SmartArt parts in a document.
*/
var SmartArtCollection = class {
map;
constructor() {
this.map = /* @__PURE__ */ new Map();
}
addSmartArt(key, data) {
this.map.set(key, data);
}
get array() {
return [...this.map.values()];
}
};
//#endregion
//#region src/smartart/tree-to-model.ts
function createDocPoint(layout, style, color) {
const pt = new class extends XmlComponent {
constructor() {
super("dgm:pt");
}
}();
pt["root"].push(chartAttr({
modelId: 0,
type: "doc"
}));
const prSet = new class extends XmlComponent {
constructor() {
super("dgm:prSet");
}
}();
prSet["root"].push(chartAttr({
loTypeId: `urn:microsoft.com/office/officeart/2005/8/layout/${layout}`,
loCatId: LAYOUT_CATEGORIES[layout] ?? "list",
qsTypeId: `urn:microsoft.com/office/officeart/2005/8/quickstyle/${style}`,
qsCatId: STYLE_CATEGORIES[style] ?? "simple",
csTypeId: `urn:microsoft.com/office/officeart/2005/8/colors/${color}`,
csCatId: COLOR_CATEGORIES[color] ?? "accent1",
phldr: "0"
}));
pt["root"].push(prSet);
pt["root"].push(new EmptyElement("dgm:spPr"));
pt["root"].push(createEmptyTextBody());
return pt;
}
function createEmptyTextBody() {
const t = new class extends XmlComponent {
constructor() {
super("dgm:t");
}
}();
t["root"].push(new EmptyElement("a:bodyPr"));
t["root"].push(new EmptyElement("a:lstStyle"));
t["root"].push(new EmptyElement("a:p"));
return t;
}
var EmptyElement = class extends XmlComponent {
constructor(tag) {
super(tag);
}
};
function uuid() {
return `{${crypto.randomUUID().toUpperCase()}}`;
}
/**
* Creates a DataModel from tree nodes with layout/style/color settings.
*/
const createDataModel = (nodes, layout = "default", style = "simple1", color = "accent1_2") => {
const points = [];
const connections = [];
points.push(createDocPoint(layout, style, color));
for (let i = 0; i < nodes.length; i++) {
const walk = (node, parentUuid, srcOrd) => {
const nodeUuid = uuid();
const parTransUuid = uuid();
const sibTransUuid = uuid();
const cxnUuid = uuid();
points.push(new TransPoint(parTransUuid, "parTrans", cxnUuid));
points.push(new TransPoint(sibTransUuid, "sibTrans", cxnUuid));
points.push(new Point(nodeUuid, node.text));
connections.push(new Connection(parTransUuid, parentUuid, nodeUuid, void 0, srcOrd, 0, parTransUuid, sibTransUuid));
if (node.children) for (let j = 0; j < node.children.length; j++) walk(node.children[j], nodeUuid, j);
};
walk(nodes[i], "0", i);
}
return new DataModel(points, connections);
};
//#endregion
export { DataModel as a, getColorXml as c, COLOR_CATEGORIES as d, LAYOUT_CATEGORIES as f, TransPoint as i, getLayoutXml as l, SmartArtCollection as n, Connection as o, STYLE_CATEGORIES as p, Point as r, DEFAULT_DRAWING_XML as s, createDataModel as t, getStyleXml as u };
import { a as Point, c as Connection, d as getLayoutXml, f as getStyleXml, h as STYLE_CATEGORIES, i as SmartArtData, l as DEFAULT_DRAWING_XML, m as LAYOUT_CATEGORIES, n as createDataModel, o as TransPoint, p as COLOR_CATEGORIES, r as SmartArtCollection, s as DataModel, t as TreeNode, u as getColorXml } from "../index-BCjRiF78.mjs";
export { COLOR_CATEGORIES, Connection, DEFAULT_DRAWING_XML, DataModel, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, SmartArtData, TransPoint, TreeNode, createDataModel, getColorXml, getLayoutXml, getStyleXml };
import { a as DataModel, c as getColorXml, d as COLOR_CATEGORIES, f as LAYOUT_CATEGORIES, i as TransPoint, l as getLayoutXml, n as SmartArtCollection, o as Connection, p as STYLE_CATEGORIES, r as Point, s as DEFAULT_DRAWING_XML, t as createDataModel, u as getStyleXml } from "../smartart-vyDm6U1_.mjs";
export { COLOR_CATEGORIES, Connection, DEFAULT_DRAWING_XML, DataModel, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, TransPoint, createDataModel, getColorXml, getLayoutXml, getStyleXml };
//#region src/values.d.ts
/**
* Runtime validation and type conversion functions for OOXML specification values.
*
* This module provides runtime checks and cleanup for value types in the OOXML spec
* that aren't easily expressed through the TypeScript type system alone. These
* validators help prevent silent failures and corrupted documents by enforcing
* spec-compliant values at runtime.
*
* @module
*/
/**
* A measurement value with optional sign and unit suffix.
*
* Supports units: mm (millimeters), cm (centimeters), in (inches),
* pt (points), pc (picas), pi (picas).
*
* Pattern: `-?[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)`
*
* @example
* ```typescript
* const measure: UniversalMeasure = "10.5mm";
* const negative: UniversalMeasure = "-5pt";
* ```
*/
type UniversalMeasure = `${"-" | ""}${number}${"mm" | "cm" | "in" | "pt" | "pc" | "pi"}`;
/**
* A positive measurement value with unit suffix.
*
* Same as UniversalMeasure but restricted to positive values only.
*
* Reference: ST_PositiveUniversalMeasure in OOXML specification
*
* @example
* ```typescript
* const measure: PositiveUniversalMeasure = "10.5mm";
* ```
*/
type PositiveUniversalMeasure = `${number}${"mm" | "cm" | "in" | "pt" | "pc" | "pi"}`;
/**
* A percentage value with optional sign.
*
* Pattern: `-?[0-9]+(\.[0-9]+)?%`
*
* Reference: ST_Percentage in OOXML specification
*
* @example
* ```typescript
* const percent: Percentage = "50%";
* const negative: Percentage = "-10.5%";
* ```
*/
type Percentage = `${"-" | ""}${number}%`;
/**
* A positive percentage value.
*
* Same as Percentage but restricted to positive values only.
*
* Reference: ST_PositivePercentage in OOXML specification
*
* @example
* ```typescript
* const percent: PositivePercentage = "50%";
* ```
*/
type PositivePercentage = `${number}%`;
/**
* A relative measurement value using em or ex units.
*
* Used in VML text boxes for font-relative measurements.
*
* @example
* ```typescript
* const measure: RelativeMeasure = "2em";
* const negative: RelativeMeasure = "-0.5ex";
* ```
*/
type RelativeMeasure = `${"-" | ""}${number}${"em" | "ex"}`;
/**
* Validates and converts a number to an integer (decimal number).
*
* Reference: ST_DecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored integer value
* @throws Error if the value is NaN
*
* @example
* ```typescript
* const num = decimalNumber(10.7); // Returns 10
* const negative = decimalNumber(-5.3); // Returns -5
* ```
*/
declare const decimalNumber: (val: number) => number;
/**
* Validates and converts a number to a positive integer (unsigned decimal number).
*
* Reference: ST_UnsignedDecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored positive integer value
* @throws Error if the value is NaN or negative
*
* @example
* ```typescript
* const num = unsignedDecimalNumber(10.7); // Returns 10
* const invalid = unsignedDecimalNumber(-5); // Throws Error
* ```
*/
declare const unsignedDecimalNumber: (val: number) => number;
/**
* Validates and normalizes a hexadecimal binary value.
*
* The xsd:hexBinary type represents binary data as a sequence of binary octets
* using hexadecimal encoding, where each binary octet is a two-character
* hexadecimal number. Both lowercase and uppercase letters A-F are permitted.
*
* @param val - The hexadecimal string to validate
* @param length - The expected length in bytes (not characters)
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid hex string of the expected length
*
* @example
* ```typescript
* hexBinary("0FB8", 2); // Valid: 2 bytes = 4 characters
* hexBinary("ABC", 2); // Invalid: wrong length
* ```
*/
declare const hexBinary: (val: string, length: number) => string;
/**
* Validates a long hexadecimal number (4 bytes / 8 characters).
*
* Reference: ST_LongHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 8-character hex string
*
* @example
* ```typescript
* const hex = longHexNumber("ABCD1234"); // Valid
* ```
*/
declare const longHexNumber: (val: string) => string;
/**
* Validates a short hexadecimal number (2 bytes / 4 characters).
*
* Reference: ST_ShortHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 4-character hex string
*
* @example
* ```typescript
* const hex = shortHexNumber("AB12"); // Valid
* ```
*/
declare const shortHexNumber: (val: string) => string;
/**
* Validates a single-byte hexadecimal number (1 byte / 2 characters).
*
* Reference: ST_UcharHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 2-character hex string
*
* @example
* ```typescript
* const hex = uCharHexNumber("FF"); // Valid
* ```
*/
declare const uCharHexNumber: (val: string) => string;
/**
* Normalizes a universal measure value by parsing and reformatting.
*
* Ensures the numeric portion is properly formatted while preserving the unit.
*
* Reference: ST_UniversalMeasure in OOXML specification
*
* @param val - The universal measure string to normalize
* @returns The normalized universal measure
*
* @example
* ```typescript
* const measure = universalMeasureValue("10.500mm"); // Returns "10.5mm"
* ```
*/
declare const universalMeasureValue: (val: UniversalMeasure) => UniversalMeasure;
/**
* Validates and normalizes a positive universal measure value.
*
* Reference: ST_PositiveUniversalMeasure in OOXML specification
*
* @param val - The positive universal measure string to validate
* @returns The normalized positive universal measure
* @throws Error if the value is negative
*
* @example
* ```typescript
* const measure = positiveUniversalMeasureValue("10.5mm"); // Valid
* const invalid = positiveUniversalMeasureValue("-5mm"); // Throws Error
* ```
*/
declare const positiveUniversalMeasureValue: (val: PositiveUniversalMeasure) => PositiveUniversalMeasure;
/**
* Validates and normalizes a hexadecimal color value.
*
* Accepts either "auto" or a 6-character RGB hex value (with or without # prefix).
* The # prefix is commonly used but technically invalid in OOXML, so it is stripped
* for strict compliance.
*
* Reference: ST_HexColor in OOXML specification
*
* @param val - The color value to validate ("auto" or hex color)
* @returns The normalized color value
* @throws Error if the hex color is invalid
*
* @example
* ```typescript
* const color1 = hexColorValue("auto"); // Returns "auto"
* const color2 = hexColorValue("FF0000"); // Returns "FF0000"
* const color3 = hexColorValue("#00FF00"); // Returns "00FF00" (# stripped)
* ```
*/
declare const hexColorValue: (val: string) => string;
/**
* Validates a signed TWIP measurement value.
*
* Accepts either a universal measure string or a numeric TWIP value.
*
* Reference: ST_SignedTwipsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = signedTwipsMeasureValue("10mm");
* const measure2 = signedTwipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
declare const signedTwipsMeasureValue: (val: UniversalMeasure | number) => UniversalMeasure | number;
/**
* Validates a half-point (HPS) measurement value.
*
* Accepts either a positive universal measure string or a positive number.
* HPS (half-points) are commonly used for font sizes.
*
* Reference: ST_HpsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const fontSize1 = hpsMeasureValue("12pt");
* const fontSize2 = hpsMeasureValue(24); // 12pt in half-points
* ```
*/
declare const hpsMeasureValue: (val: PositiveUniversalMeasure | number) => string | number;
/**
* Validates a signed half-point (HPS) measurement value.
*
* Accepts either a universal measure string or a numeric value.
*
* Reference: ST_SignedHpsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const spacing1 = signedHpsMeasureValue("6pt");
* const spacing2 = signedHpsMeasureValue(-12); // Negative spacing
* ```
*/
declare const signedHpsMeasureValue: (val: UniversalMeasure | number) => string | number;
/**
* Validates a positive TWIP measurement value.
*
* Accepts either a positive universal measure string or a positive number.
*
* Reference: ST_TwipsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const width1 = twipsMeasureValue("25.4mm");
* const width2 = twipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
declare const twipsMeasureValue: (val: PositiveUniversalMeasure | number) => PositiveUniversalMeasure | number;
/**
* Normalizes a percentage value by parsing and reformatting.
*
* Reference: ST_Percentage in OOXML specification
*
* @param val - The percentage string to normalize
* @returns The normalized percentage
*
* @example
* ```typescript
* const percent = percentageValue("50.000%"); // Returns "50%"
* ```
*/
declare const percentageValue: (val: Percentage) => Percentage;
/**
* Validates a measurement value that can be expressed as a number, percentage, or universal measure.
*
* Reference: ST_MeasurementOrPercent in OOXML specification
*
* @param val - The measurement value (number, percentage, or universal measure)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = measurementOrPercentValue(100); // Unqualified number
* const measure2 = measurementOrPercentValue("50%"); // Percentage
* const measure3 = measurementOrPercentValue("10mm"); // Universal measure
* ```
*/
declare const measurementOrPercentValue: (val: number | Percentage | UniversalMeasure) => number | UniversalMeasure | Percentage;
/**
* Validates an eighth-point measurement value.
*
* Eighth-points are used for fine-grained measurements in text formatting.
*
* Reference: ST_EighthPointMeasure in OOXML specification
*
* @param val - The measurement value in eighth-points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const measure = eighthPointMeasureValue(16); // 2 points
* ```
*/
declare const eighthPointMeasureValue: (val: number) => number;
/**
* Validates a point measurement value.
*
* Reference: ST_PointMeasure in OOXML specification
*
* @param val - The measurement value in points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const fontSize = pointMeasureValue(12); // 12pt
* ```
*/
declare const pointMeasureValue: (val: number) => number;
/**
* Converts a JavaScript Date object to an ISO 8601 date-time string.
*
* The format is CCYY-MM-DDThh:mm:ss.sssZ where T is a literal and Z indicates UTC.
* This matches the xsd:dateTime format required by OOXML.
*
* Reference: ST_DateTime in OOXML specification
*
* @param val - The Date object to convert
* @returns An ISO 8601 formatted date-time string
*
* @example
* ```typescript
* const now = new Date();
* const timestamp = dateTimeValue(now); // Returns "2024-01-15T10:30:00.000Z"
* ```
*/
declare const dateTimeValue: (val: Date) => string;
/**
* Theme color values used throughout OOXML for referencing document theme colors.
*
* Reference: ST_ThemeColor in OOXML specification
*
* @publicApi
*/
declare const ThemeColor: {
readonly DARK1: "dark1";
readonly LIGHT1: "light1";
readonly DARK2: "dark2";
readonly LIGHT2: "light2";
readonly ACCENT1: "accent1";
readonly ACCENT2: "accent2";
readonly ACCENT3: "accent3";
readonly ACCENT4: "accent4";
readonly ACCENT5: "accent5";
readonly ACCENT6: "accent6";
readonly HYPERLINK: "hyperlink";
readonly FOLLOWED_HYPERLINK: "followedHyperlink";
readonly NONE: "none";
readonly BACKGROUND1: "background1";
readonly TEXT1: "text1";
readonly BACKGROUND2: "background2";
readonly TEXT2: "text2";
};
/**
* Theme font values used for referencing document theme fonts.
*
* Reference: ST_Theme in OOXML specification
*
* @publicApi
*/
declare const ThemeFont: {
readonly MAJOR_EAST_ASIA: "majorEastAsia";
readonly MAJOR_BIDI: "majorBidi";
readonly MAJOR_ASCII: "majorAscii";
readonly MAJOR_H_ANSI: "majorHAnsi";
readonly MINOR_EAST_ASIA: "minorEastAsia";
readonly MINOR_BIDI: "minorBidi";
readonly MINOR_ASCII: "minorAscii";
readonly MINOR_H_ANSI: "minorHAnsi";
};
//#endregion
export { uCharHexNumber as C, twipsMeasureValue as S, unsignedDecimalNumber as T, pointMeasureValue as _, ThemeColor as a, signedHpsMeasureValue as b, dateTimeValue as c, hexBinary as d, hexColorValue as f, percentageValue as g, measurementOrPercentValue as h, RelativeMeasure as i, decimalNumber as l, longHexNumber as m, PositivePercentage as n, ThemeFont as o, hpsMeasureValue as p, PositiveUniversalMeasure as r, UniversalMeasure as s, Percentage as t, eighthPointMeasureValue as u, positiveUniversalMeasureValue as v, universalMeasureValue as w, signedTwipsMeasureValue as x, shortHexNumber as y };
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./values-QyWq4U4A.mjs";
export { Percentage, PositivePercentage, PositiveUniversalMeasure, RelativeMeasure, ThemeColor, ThemeFont, UniversalMeasure, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber };
//#region src/values.ts
/**
* Validates and converts a number to an integer (decimal number).
*
* Reference: ST_DecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored integer value
* @throws Error if the value is NaN
*
* @example
* ```typescript
* const num = decimalNumber(10.7); // Returns 10
* const negative = decimalNumber(-5.3); // Returns -5
* ```
*/
const decimalNumber = (val) => {
if (isNaN(val)) throw new Error(`Invalid value '${val}' specified. Must be an integer.`);
return Math.floor(val);
};
/**
* Validates and converts a number to a positive integer (unsigned decimal number).
*
* Reference: ST_UnsignedDecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored positive integer value
* @throws Error if the value is NaN or negative
*
* @example
* ```typescript
* const num = unsignedDecimalNumber(10.7); // Returns 10
* const invalid = unsignedDecimalNumber(-5); // Throws Error
* ```
*/
const unsignedDecimalNumber = (val) => {
const value = decimalNumber(val);
if (value < 0) throw new Error(`Invalid value '${val}' specified. Must be a positive integer.`);
return value;
};
/**
* Validates and normalizes a hexadecimal binary value.
*
* The xsd:hexBinary type represents binary data as a sequence of binary octets
* using hexadecimal encoding, where each binary octet is a two-character
* hexadecimal number. Both lowercase and uppercase letters A-F are permitted.
*
* @param val - The hexadecimal string to validate
* @param length - The expected length in bytes (not characters)
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid hex string of the expected length
*
* @example
* ```typescript
* hexBinary("0FB8", 2); // Valid: 2 bytes = 4 characters
* hexBinary("ABC", 2); // Invalid: wrong length
* ```
*/
const hexBinary = (val, length) => {
const expectedLength = length * 2;
if (val.length !== expectedLength || isNaN(Number(`0x${val}`))) throw new Error(`Invalid hex value '${val}'. Expected ${expectedLength} digit hex value`);
return val;
};
/**
* Validates a long hexadecimal number (4 bytes / 8 characters).
*
* Reference: ST_LongHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 8-character hex string
*
* @example
* ```typescript
* const hex = longHexNumber("ABCD1234"); // Valid
* ```
*/
const longHexNumber = (val) => hexBinary(val, 4);
/**
* Validates a short hexadecimal number (2 bytes / 4 characters).
*
* Reference: ST_ShortHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 4-character hex string
*
* @example
* ```typescript
* const hex = shortHexNumber("AB12"); // Valid
* ```
*/
const shortHexNumber = (val) => hexBinary(val, 2);
/**
* Validates a single-byte hexadecimal number (1 byte / 2 characters).
*
* Reference: ST_UcharHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 2-character hex string
*
* @example
* ```typescript
* const hex = uCharHexNumber("FF"); // Valid
* ```
*/
const uCharHexNumber = (val) => hexBinary(val, 1);
/**
* Normalizes a universal measure value by parsing and reformatting.
*
* Ensures the numeric portion is properly formatted while preserving the unit.
*
* Reference: ST_UniversalMeasure in OOXML specification
*
* @param val - The universal measure string to normalize
* @returns The normalized universal measure
*
* @example
* ```typescript
* const measure = universalMeasureValue("10.500mm"); // Returns "10.5mm"
* ```
*/
const universalMeasureValue = (val) => {
const unit = val.slice(-2);
const amount = val.substring(0, val.length - 2);
return `${Number(amount)}${unit}`;
};
/**
* Validates and normalizes a positive universal measure value.
*
* Reference: ST_PositiveUniversalMeasure in OOXML specification
*
* @param val - The positive universal measure string to validate
* @returns The normalized positive universal measure
* @throws Error if the value is negative
*
* @example
* ```typescript
* const measure = positiveUniversalMeasureValue("10.5mm"); // Valid
* const invalid = positiveUniversalMeasureValue("-5mm"); // Throws Error
* ```
*/
const positiveUniversalMeasureValue = (val) => {
const value = universalMeasureValue(val);
if (parseFloat(value) < 0) throw new Error(`Invalid value '${value}' specified. Expected a positive number.`);
return value;
};
/**
* Validates and normalizes a hexadecimal color value.
*
* Accepts either "auto" or a 6-character RGB hex value (with or without # prefix).
* The # prefix is commonly used but technically invalid in OOXML, so it is stripped
* for strict compliance.
*
* Reference: ST_HexColor in OOXML specification
*
* @param val - The color value to validate ("auto" or hex color)
* @returns The normalized color value
* @throws Error if the hex color is invalid
*
* @example
* ```typescript
* const color1 = hexColorValue("auto"); // Returns "auto"
* const color2 = hexColorValue("FF0000"); // Returns "FF0000"
* const color3 = hexColorValue("#00FF00"); // Returns "00FF00" (# stripped)
* ```
*/
const hexColorValue = (val) => {
if (val === "auto") return val;
return hexBinary(val.charAt(0) === "#" ? val.substring(1) : val, 3);
};
/**
* Validates a signed TWIP measurement value.
*
* Accepts either a universal measure string or a numeric TWIP value.
*
* Reference: ST_SignedTwipsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = signedTwipsMeasureValue("10mm");
* const measure2 = signedTwipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
const signedTwipsMeasureValue = (val) => typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
/**
* Validates a half-point (HPS) measurement value.
*
* Accepts either a positive universal measure string or a positive number.
* HPS (half-points) are commonly used for font sizes.
*
* Reference: ST_HpsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const fontSize1 = hpsMeasureValue("12pt");
* const fontSize2 = hpsMeasureValue(24); // 12pt in half-points
* ```
*/
const hpsMeasureValue = (val) => typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
/**
* Validates a signed half-point (HPS) measurement value.
*
* Accepts either a universal measure string or a numeric value.
*
* Reference: ST_SignedHpsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const spacing1 = signedHpsMeasureValue("6pt");
* const spacing2 = signedHpsMeasureValue(-12); // Negative spacing
* ```
*/
const signedHpsMeasureValue = (val) => typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
/**
* Validates a positive TWIP measurement value.
*
* Accepts either a positive universal measure string or a positive number.
*
* Reference: ST_TwipsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const width1 = twipsMeasureValue("25.4mm");
* const width2 = twipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
const twipsMeasureValue = (val) => typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
/**
* Normalizes a percentage value by parsing and reformatting.
*
* Reference: ST_Percentage in OOXML specification
*
* @param val - The percentage string to normalize
* @returns The normalized percentage
*
* @example
* ```typescript
* const percent = percentageValue("50.000%"); // Returns "50%"
* ```
*/
const percentageValue = (val) => {
const percent = val.substring(0, val.length - 1);
return `${Number(percent)}%`;
};
/**
* Validates a measurement value that can be expressed as a number, percentage, or universal measure.
*
* Reference: ST_MeasurementOrPercent in OOXML specification
*
* @param val - The measurement value (number, percentage, or universal measure)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = measurementOrPercentValue(100); // Unqualified number
* const measure2 = measurementOrPercentValue("50%"); // Percentage
* const measure3 = measurementOrPercentValue("10mm"); // Universal measure
* ```
*/
const measurementOrPercentValue = (val) => {
if (typeof val === "number") return decimalNumber(val);
if (val.slice(-1) === "%") return percentageValue(val);
return universalMeasureValue(val);
};
/**
* Validates an eighth-point measurement value.
*
* Eighth-points are used for fine-grained measurements in text formatting.
*
* Reference: ST_EighthPointMeasure in OOXML specification
*
* @param val - The measurement value in eighth-points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const measure = eighthPointMeasureValue(16); // 2 points
* ```
*/
const eighthPointMeasureValue = unsignedDecimalNumber;
/**
* Validates a point measurement value.
*
* Reference: ST_PointMeasure in OOXML specification
*
* @param val - The measurement value in points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const fontSize = pointMeasureValue(12); // 12pt
* ```
*/
const pointMeasureValue = unsignedDecimalNumber;
/**
* Converts a JavaScript Date object to an ISO 8601 date-time string.
*
* The format is CCYY-MM-DDThh:mm:ss.sssZ where T is a literal and Z indicates UTC.
* This matches the xsd:dateTime format required by OOXML.
*
* Reference: ST_DateTime in OOXML specification
*
* @param val - The Date object to convert
* @returns An ISO 8601 formatted date-time string
*
* @example
* ```typescript
* const now = new Date();
* const timestamp = dateTimeValue(now); // Returns "2024-01-15T10:30:00.000Z"
* ```
*/
const dateTimeValue = (val) => val.toISOString();
/**
* Theme color values used throughout OOXML for referencing document theme colors.
*
* Reference: ST_ThemeColor in OOXML specification
*
* @publicApi
*/
const ThemeColor = {
DARK1: "dark1",
LIGHT1: "light1",
DARK2: "dark2",
LIGHT2: "light2",
ACCENT1: "accent1",
ACCENT2: "accent2",
ACCENT3: "accent3",
ACCENT4: "accent4",
ACCENT5: "accent5",
ACCENT6: "accent6",
HYPERLINK: "hyperlink",
FOLLOWED_HYPERLINK: "followedHyperlink",
NONE: "none",
BACKGROUND1: "background1",
TEXT1: "text1",
BACKGROUND2: "background2",
TEXT2: "text2"
};
/**
* Theme font values used for referencing document theme fonts.
*
* Reference: ST_Theme in OOXML specification
*
* @publicApi
*/
const ThemeFont = {
MAJOR_EAST_ASIA: "majorEastAsia",
MAJOR_BIDI: "majorBidi",
MAJOR_ASCII: "majorAscii",
MAJOR_H_ANSI: "majorHAnsi",
MINOR_EAST_ASIA: "minorEastAsia",
MINOR_BIDI: "minorBidi",
MINOR_ASCII: "minorAscii",
MINOR_H_ANSI: "minorHAnsi"
};
//#endregion
export { ThemeColor, ThemeFont, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber };
import { hpsMeasureValue } from "./values.mjs";
import { escapeXml, xml, xml2js } from "@office-open/xml";
//#region src/xml-components/base.ts
/**
* Base XML Component infrastructure for OOXML document generation.
*
* @module
*/
/**
* Abstract base class for all XML components.
*/
var BaseXmlComponent = class {
/** The XML element name for this component (e.g., "w:p" for paragraph). */
rootKey;
constructor(rootKey) {
this.rootKey = rootKey;
}
/**
* Direct XML serialization. Override in subclasses for zero-allocation output.
* Default falls back to prepForXml() + xml().
*/
toXml(context) {
const obj = this.prepForXml(context);
return obj ? xml(obj) : "";
}
};
//#endregion
//#region src/xml-components/component.ts
/**
* Core XML Component classes for building OOXML element trees.
*
* @module
*/
/**
* Empty object singleton used for empty XML elements.
*
* @internal
*/
const EMPTY_OBJECT = Object.seal({});
/**
* Base class for all XML components in OOXML documents.
*
* `toXml()` traverses the `root` array and calls `toXml()` on each
* `BaseXmlComponent` child — this avoids building the intermediate
* `IXmlableObject` tree. Inline `IXmlableObject` children fall back to
* `xml()` for serialization.
*/
var XmlComponent = class extends BaseXmlComponent {
/**
* Array of child components, text nodes, and attributes.
*/
root;
constructor(rootKey) {
super(rootKey);
this.root = [];
}
/**
* Prepares this component and its children for XML serialization.
*/
prepForXml(context) {
context.stack.push(this);
const children = [];
for (const comp of this.root) if (comp instanceof BaseXmlComponent) {
const prepared = comp.prepForXml(context);
if (prepared !== void 0) children.push(prepared);
} else children.push(comp);
context.stack.pop();
return { [this.rootKey]: children.length ? children.length === 1 && children[0] && typeof children[0] === "object" && "_attr" in children[0] ? children[0] : children : EMPTY_OBJECT };
}
/**
* Direct XML serialization — traverses `root` and calls `toXml()` on
* each child, concatenating the results into a single string.
*/
toXml(context) {
const childParts = [];
const attrParts = [];
for (const child of this.root) if (child instanceof BaseXmlComponent) {
const s = child.toXml(context);
if (s) childParts.push(s);
if (!s && child.constructor.name === "NextAttributeComponent") {
const prepped = child.prepForXml(context);
if (prepped && typeof prepped === "object" && "_attr" in prepped) {
const a = prepped._attr;
for (const key of Object.keys(a)) attrParts.push(`${key}="${escapeXml(String(a[key]))}"`);
}
}
} else if (typeof child === "string") childParts.push(escapeXml(child));
else if (child != null && typeof child === "object") if ("_attr" in child) {
const a = child._attr;
for (const key of Object.keys(a)) attrParts.push(`${key}="${escapeXml(String(a[key]))}"`);
} else if ("_attributes" in child) {
const a = child._attributes;
for (const key of Object.keys(a)) attrParts.push(`${key}="${escapeXml(String(a[key]))}"`);
} else childParts.push(xml(child));
const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
const body = childParts.join("");
return body.length === 0 ? `<${this.rootKey}${attrStr}/>` : `<${this.rootKey}${attrStr}>${body}</${this.rootKey}>`;
}
/**
* @deprecated Internal use only.
*/
addChildElement(child) {
this.root.push(child);
return this;
}
};
/**
* XML component that is excluded from output if it has no meaningful content.
*/
var IgnoreIfEmptyXmlComponent = class extends XmlComponent {
includeIfEmpty;
constructor(rootKey, includeIfEmpty) {
super(rootKey);
this.includeIfEmpty = includeIfEmpty;
}
prepForXml(context) {
const result = super.prepForXml(context);
if (this.includeIfEmpty) return result;
if (result && (typeof result[this.rootKey] !== "object" || Object.keys(result[this.rootKey]).length)) return result;
}
/**
* Suppress empty elements — super.toXml() produces a self-closing tag
* (`<tag/>`) when there are no child elements; IgnoreIfEmpty returns ""
* in that case. Child components that already override toXml() (e.g.
* Worksheet) are unaffected.
*/
toXml(context) {
if (this.includeIfEmpty) return super.toXml(context);
const result = super.toXml(context);
return result.endsWith("/>") ? "" : result;
}
};
//#endregion
//#region src/xml-components/attributes.ts
/**
* XML attribute components for OOXML document generation.
*
* @module
*/
/**
* Base class for creating XML attributes with automatic name mapping.
*/
var XmlAttributeComponent = class extends BaseXmlComponent {
/** Optional mapping from property names to XML attribute names. */
xmlKeys;
constructor(root) {
super("_attr");
this.root = root;
}
prepForXml(_) {
const attrs = {};
Object.entries(this.root).forEach(([key, value]) => {
if (value !== void 0) {
const newKey = this.xmlKeys && this.xmlKeys[key] || key;
attrs[newKey] = value;
}
});
return { _attr: attrs };
}
};
/**
* Next-generation attribute component with explicit key-value pairs.
*/
var NextAttributeComponent = class extends BaseXmlComponent {
constructor(root) {
super("_attr");
this.root = root;
}
prepForXml(_) {
const attrs = {};
const values = Object.values(this.root);
for (let i = 0; i < values.length; i++) {
const { key, value } = values[i];
if (value !== void 0) attrs[key] = value;
}
return { _attr: attrs };
}
/** Attribute components produce no XML output — attrs are inlined by the parent. */
toXml(_context) {
return "";
}
};
//#endregion
//#region src/xml-components/elements.ts
/**
* Simple XML element types for common OOXML patterns.
*
* @module
*/
/**
* Build an XML element with arbitrary attributes, filtering out undefined values.
*/
function attrObj(name, attrs) {
const filtered = {};
for (const [key, val] of Object.entries(attrs)) if (val !== void 0) filtered[key] = val;
return { [name]: { _attr: filtered } };
}
const ON_OFF_TRUE_CACHE = /* @__PURE__ */ new Map();
/**
* Build a CT_OnOff XML object without allocating any XmlComponent.
* `val=true` returns a frozen singleton (cached per name).
*/
function onOffObj(name, val = true) {
if (val === true) {
let cached = ON_OFF_TRUE_CACHE.get(name);
if (!cached) {
cached = Object.freeze({ [name]: Object.freeze({}) });
ON_OFF_TRUE_CACHE.set(name, cached);
}
return cached;
}
const ns = name.split(":")[0];
return { [name]: { _attr: { [`${ns}:val`]: val } } };
}
/**
* Build a CT_HpsMeasure XML object (half-point size) without allocation.
*/
function hpsMeasureObj(name, val) {
const ns = name.split(":")[0];
return { [name]: { _attr: { [`${ns}:val`]: hpsMeasureValue(val) } } };
}
/**
* Build a CT_String XML object (string value attribute) without allocation.
*/
function stringValObj(name, val) {
const ns = name.split(":")[0];
return { [name]: { _attr: { [`${ns}:val`]: val } } };
}
/**
* Build a numeric value attribute XML object without allocation.
*/
function numberValObj(name, val) {
const ns = name.split(":")[0];
return { [name]: { _attr: { [`${ns}:val`]: val } } };
}
/**
* Build a string enum value attribute XML object without allocation.
*/
function stringEnumValObj(name, val) {
const ns = name.split(":")[0];
return { [name]: { _attr: { [`${ns}:val`]: val } } };
}
/**
* Build an element wrapping a text string without allocation.
*/
function stringContainerObj(name, val) {
return { [name]: [val] };
}
/**
* XML element representing an empty element (CT_Empty).
*/
var EmptyElement = class extends XmlComponent {};
/**
* Flexible XML element builder with explicit attribute and child configuration.
*/
var BuilderElement = class extends XmlComponent {
constructor({ name, attributes, children }) {
super(name);
if (attributes) {
const attrs = {};
const vals = Object.values(attributes);
for (let i = 0; i < vals.length; i++) {
const { key, value } = vals[i];
if (value !== void 0) attrs[key] = value;
}
this.root.push({ _attr: attrs });
}
if (children) this.root.push(...children);
}
};
/**
* Creates a NextAttributeComponent with explicit XML attribute keys.
*/
const chartAttr = (attrs) => new NextAttributeComponent(Object.fromEntries(Object.entries(attrs).map(([key, value]) => [key, {
key,
value
}])));
/**
* Wraps a component in a named XmlComponent element.
*/
function wrapEl(elementName, child) {
const el = new class extends XmlComponent {
constructor(name) {
super(name);
}
}(elementName);
el["root"].push(child);
return el;
}
//#endregion
//#region src/xml-components/imported.ts
/**
* Imported XML Component module for handling external XML content.
*
* @module
*/
/**
* Converts an xml-js Element into an XmlComponent tree.
*/
const convertToXmlComponent = (element) => {
switch (element.type) {
case void 0:
case "element": {
const xmlComponent = new ImportedXmlComponent(element.name, element.attributes);
const childElements = element.elements || [];
for (const childElm of childElements) {
const child = convertToXmlComponent(childElm);
if (child !== void 0) xmlComponent.push(child);
}
return xmlComponent;
}
case "text": return element.text;
default: return;
}
};
/**
* XML component representing imported XML content.
*/
var ImportedXmlComponent = class extends XmlComponent {
_sourceXml;
static fromXmlString(importedContent) {
const xmlObj = xml2js(importedContent, { compact: false });
const component = convertToXmlComponent(xmlObj.elements?.[0] ?? xmlObj);
component._sourceXml = importedContent;
return component;
}
get sourceXml() {
return this._sourceXml;
}
toXml(_context) {
return this._sourceXml ?? super.toXml(_context);
}
constructor(rootKey, _attr) {
super(rootKey);
if (_attr) this.root.push({ _attr });
}
push(xmlComponent) {
this.root.push(xmlComponent);
}
};
/**
* Represents attributes for imported root elements.
*/
var ImportedRootElementAttributes = class extends XmlComponent {
constructor(_attr) {
super("");
this._attr = _attr;
}
prepForXml(_) {
return { _attr: this._attr };
}
};
//#endregion
//#region src/xml-components/initializable.ts
/**
* Initializable XML Component module.
*
* @module
*/
/**
* XML component that can be initialized from another component.
*/
var InitializableXmlComponent = class extends XmlComponent {
constructor(rootKey, initComponent) {
super(rootKey);
if (initComponent instanceof XmlComponent) this.root = initComponent.root;
}
};
//#endregion
export { XmlAttributeComponent as _, BuilderElement as a, XmlComponent as b, chartAttr as c, onOffObj as d, stringContainerObj as f, NextAttributeComponent as g, wrapEl as h, convertToXmlComponent as i, hpsMeasureObj as l, stringValObj as m, ImportedRootElementAttributes as n, EmptyElement as o, stringEnumValObj as p, ImportedXmlComponent as r, attrObj as s, InitializableXmlComponent as t, numberValObj as u, EMPTY_OBJECT as v, BaseXmlComponent as x, IgnoreIfEmptyXmlComponent as y };
+14
-14
{
"name": "@office-open/core",
"version": "0.6.6",
"version": "0.6.7",
"description": "Shared OOXML infrastructure: XmlComponent, value validators, unit converters",

@@ -30,24 +30,24 @@ "keywords": [

"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/index.mjs",
"types": "dist/index.d.mts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
"types": "./dist/index.d.mts",
"import": "./dist/index.mjs"
},
"./values": {
"types": "./dist/values.d.ts",
"import": "./dist/values.js"
"types": "./dist/values.d.mts",
"import": "./dist/values.mjs"
},
"./smartart": {
"types": "./dist/smartart/index.d.ts",
"import": "./dist/smartart/index.js"
"types": "./dist/smartart/index.d.mts",
"import": "./dist/smartart/index.mjs"
},
"./chart": {
"types": "./dist/chart/index.d.ts",
"import": "./dist/chart/index.js"
"types": "./dist/chart/index.d.mts",
"import": "./dist/chart/index.mjs"
},
"./drawingml": {
"types": "./dist/drawingml/index.d.ts",
"import": "./dist/drawingml/index.js"
"types": "./dist/drawingml/index.d.mts",
"import": "./dist/drawingml/index.mjs"
}

@@ -59,3 +59,3 @@ },

"nanoid": "5.1.11",
"@office-open/xml": "0.6.6"
"@office-open/xml": "0.6.7"
},

@@ -62,0 +62,0 @@ "scripts": {

import { a as BuilderElement, b as XmlComponent, c as chartAttr, h as wrapEl, o as EmptyElement } from "./xml-components-SxPlKGms.js";
//#region src/chart/axes.ts
/**
* c:scaling — axis scaling configuration (minOccurs=1 in EG_AxShared).
*/
var Scaling = class extends XmlComponent {
constructor() {
super("c:scaling");
this.root.push(wrapEl("c:orientation", chartAttr({ val: "minMax" })));
}
};
/**
* c:catAx — category axis.
*
* XSD sequence: EG_AxShared (axId, scaling, delete, axPos, ..., crossAx, crosses)
* then: auto, lblAlgn, lblOffset, tickLblSkip, tickMarkSkip, noMultiLvlLbl
*/
var CatAx = class extends XmlComponent {
constructor(axId, crossAx) {
super("c:catAx");
this.root.push(wrapEl("c:axId", chartAttr({ val: axId })));
this.root.push(new Scaling());
this.root.push(wrapEl("c:delete", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:axPos", chartAttr({ val: "b" })));
this.root.push(wrapEl("c:crossAx", chartAttr({ val: crossAx })));
this.root.push(wrapEl("c:crosses", chartAttr({ val: "autoZero" })));
this.root.push(wrapEl("c:auto", chartAttr({ val: 1 })));
this.root.push(wrapEl("c:lblOffset", chartAttr({ val: 100 })));
this.root.push(wrapEl("c:noMultiLvlLbl", chartAttr({ val: 0 })));
}
};
/**
* c:valAx — value axis.
*
* XSD sequence: EG_AxShared (axId, scaling, delete, axPos, ..., spPr, ..., crossAx, crosses)
* then: crossBetween, majorUnit, minorUnit, dispUnits
*/
var ValAx = class extends XmlComponent {
constructor(axId, crossAx) {
super("c:valAx");
this.root.push(wrapEl("c:axId", chartAttr({ val: axId })));
this.root.push(new Scaling());
this.root.push(wrapEl("c:delete", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:axPos", chartAttr({ val: "l" })));
this.root.push(wrapEl("c:numFmt", chartAttr({
formatCode: "General",
sourceLinked: 1
})));
this.root.push(new BuilderElement({ name: "c:spPr" }));
this.root.push(wrapEl("c:crossAx", chartAttr({ val: crossAx })));
this.root.push(wrapEl("c:crosses", chartAttr({ val: "autoZero" })));
}
};
//#endregion
//#region src/chart/series/series-data.ts
const createStrRef = (values) => {
return new StrRef(typeof values === "string" ? [values] : values);
};
const createNumRef = (values) => new NumRef(values);
var StrRef = class extends XmlComponent {
constructor(values) {
super("c:strRef");
this.root.push(new EmptyElement("c:f"));
this.root.push(new StrCache(values));
}
};
var StrCache = class extends XmlComponent {
constructor(values) {
super("c:strCache");
this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
for (let i = 0; i < values.length; i++) this.root.push(new StrPt(i, values[i]));
}
};
var StrPt = class extends XmlComponent {
constructor(index, value) {
super("c:pt");
this.root.push(chartAttr({ idx: index }));
this.root.push(new StringValue("c:v", value));
}
};
var NumRef = class extends XmlComponent {
constructor(values) {
super("c:numRef");
this.root.push(new EmptyElement("c:f"));
this.root.push(new NumCache(values));
}
};
var NumCache = class extends XmlComponent {
constructor(values) {
super("c:numCache");
this.root.push(new FormatCode("General"));
this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
for (let i = 0; i < values.length; i++) this.root.push(new NumPt(i, values[i]));
}
};
var NumPt = class extends XmlComponent {
constructor(index, value) {
super("c:pt");
this.root.push(chartAttr({ idx: index }));
this.root.push(new StringValue("c:v", String(value)));
}
};
var FormatCode = class extends XmlComponent {
constructor(code) {
super("c:formatCode");
this.root.push(code);
}
};
var StringValue = class extends XmlComponent {
constructor(name, val) {
super(name);
this.root.push(val);
}
};
//#endregion
//#region src/chart/chart-types/area-chart.ts
var AreaChart = class extends XmlComponent {
constructor(options) {
super("c:areaChart");
this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new AreaSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var AreaSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$4(series.name));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new SeriesCat$4(categories));
this.root.push(new SeriesVal$4(series.values));
}
};
var SeriesTx$4 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$4 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$4 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/bar-chart.ts
var BarChart = class extends XmlComponent {
constructor(options) {
super("c:barChart");
this.root.push(wrapEl("c:barDir", chartAttr({ val: options.barDirection })));
this.root.push(wrapEl("c:grouping", chartAttr({ val: "clustered" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new BarSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var BarSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$3(series.name));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new SeriesCat$3(categories));
this.root.push(new SeriesVal$3(series.values));
}
};
var SeriesTx$3 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$3 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$3 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/line-chart.ts
var LineChart = class extends XmlComponent {
constructor(options) {
super("c:lineChart");
this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new LineSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var LineSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$2(series.name));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new SeriesCat$2(categories));
this.root.push(new SeriesVal$2(series.values));
}
};
var SeriesTx$2 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$2 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$2 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/pie-chart.ts
var PieChart = class extends XmlComponent {
constructor(options) {
super("c:pieChart");
this.root.push(wrapEl("c:varyColors", chartAttr({ val: true })));
for (let i = 0; i < options.series.length; i++) this.root.push(new PieSeries(i, options.series[i], options.categories));
}
};
var PieSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$1(series.name));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new SeriesCat$1(categories));
this.root.push(new SeriesVal$1(series.values));
}
};
var SeriesTx$1 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$1 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$1 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/scatter-chart.ts
var ScatterChart = class extends XmlComponent {
constructor(options) {
super("c:scatterChart");
this.root.push(wrapEl("c:scatterStyle", chartAttr({ val: "line" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new ScatterSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var ScatterSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx(series.name));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new SeriesCat(categories));
this.root.push(new SeriesVal(series.values));
this.root.push(new EmptyElement("c:size"));
}
};
var SeriesTx = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/create-chart-type.ts
const createChartType = (options) => {
switch (options.type) {
case "column":
case "bar": return new BarChart({
barDirection: options.type === "column" ? "col" : "bar",
categories: options.categories,
series: options.series
});
case "line": return new LineChart({
categories: options.categories,
series: options.series
});
case "pie": return new PieChart({
categories: options.categories,
series: options.series
});
case "area": return new AreaChart({
categories: options.categories,
series: options.series
});
case "scatter": return new ScatterChart({
categories: options.categories,
series: options.series
});
default: throw new Error(`Unsupported chart type: ${options.type}`);
}
};
//#endregion
//#region src/chart/title.ts
var ChartTitle = class extends XmlComponent {
constructor(title) {
super("c:title");
this.root.push(new TitleTx(title));
this.root.push(new TitleOverlay());
}
};
var TitleTx = class extends XmlComponent {
constructor(title) {
super("c:tx");
const rich = new class extends XmlComponent {
constructor() {
super("c:rich");
}
}();
rich["root"].push(new class extends XmlComponent {
constructor() {
super("a:bodyPr");
}
}());
rich["root"].push(new class extends XmlComponent {
constructor() {
super("a:lstStyle");
}
}());
const p = new class extends XmlComponent {
constructor() {
super("a:p");
}
}();
const r = new class extends XmlComponent {
constructor() {
super("a:r");
}
}();
r["root"].push(new class extends XmlComponent {
constructor() {
super("a:t");
this.root.push(title);
}
}());
p["root"].push(r);
rich["root"].push(p);
this.root.push(rich);
}
};
var TitleOverlay = class extends XmlComponent {
constructor() {
super("c:overlay");
this.root.push(chartAttr({ val: 0 }));
}
};
//#endregion
//#region src/chart/chart-space.ts
/**
* ChartSpace — root element for chart XML parts (c:chartSpace).
*
* Full XSD-compliant implementation with all optional elements.
*
* @module
*/
/**
* c:chartSpace — root element for chart XML parts.
*/
var ChartSpace = class extends XmlComponent {
constructor(options) {
super("c:chartSpace");
this.root.push(chartAttr({
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
"xmlns:c": "http://schemas.openxmlformats.org/drawingml/2006/chart",
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
}));
this.root.push(wrapEl("c:date1904", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:lang", chartAttr({ val: "en-US" })));
this.root.push(wrapEl("c:roundedCorners", chartAttr({ val: 0 })));
if (options.style !== void 0) this.root.push(new ChartStyle(options.style));
const chart = new ChartContainer();
if (options.title) chart["root"].push(new ChartTitle(options.title));
chart["root"].push(wrapEl("c:autoTitleDeleted", chartAttr({ val: 0 })));
const plotArea = new PlotArea();
plotArea["root"].push(new BuilderElement({ name: "c:layout" }));
plotArea["root"].push(createChartType({
categories: options.categories,
series: options.series,
type: options.type
}));
if (options.type !== "pie") if (options.type === "scatter") {
plotArea["root"].push(new ValAx(10, 20));
plotArea["root"].push(new ValAx(20, 10));
} else {
plotArea["root"].push(new CatAx(10, 20));
plotArea["root"].push(new ValAx(20, 10));
}
chart["root"].push(plotArea);
if (options.showLegend !== false) chart["root"].push(createLegend());
this.root.push(chart);
this.root.push(createChartSpPr());
this.root.push(createChartTxPr());
}
};
var ChartContainer = class extends XmlComponent {
constructor() {
super("c:chart");
}
};
var PlotArea = class extends XmlComponent {
constructor() {
super("c:plotArea");
}
};
function createLegend() {
const legend = new class extends XmlComponent {
constructor() {
super("c:legend");
}
}();
legend["root"].push(wrapEl("c:legendPos", chartAttr({ val: "b" })));
legend["root"].push(new BuilderElement({ name: "c:layout" }));
legend["root"].push(wrapEl("c:overlay", chartAttr({ val: 0 })));
legend["root"].push(createNoFillSpPr());
legend["root"].push(createTxPr());
return legend;
}
function createNoFillSpPr() {
const spPr = new class extends XmlComponent {
constructor() {
super("c:spPr");
}
}();
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:ln");
this.root.push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
}
}());
spPr["root"].push(new BuilderElement({ name: "a:effectLst" }));
return spPr;
}
function createChartSpPr() {
const spPr = new class extends XmlComponent {
constructor() {
super("c:spPr");
}
}();
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:ln");
this.root.push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
}
}());
spPr["root"].push(new BuilderElement({ name: "a:effectLst" }));
return spPr;
}
function createChartTxPr() {
const txPr = new class extends XmlComponent {
constructor() {
super("c:txPr");
}
}();
txPr["root"].push(new BuilderElement({ name: "a:bodyPr" }));
txPr["root"].push(new BuilderElement({ name: "a:lstStyle" }));
txPr["root"].push(createTextParagraph());
return txPr;
}
function createTxPr() {
const txPr = new class extends XmlComponent {
constructor() {
super("c:txPr");
}
}();
txPr["root"].push(createBodyPr());
txPr["root"].push(new BuilderElement({ name: "a:lstStyle" }));
txPr["root"].push(createTextParagraph());
return txPr;
}
function createBodyPr() {
return new BuilderElement({
name: "a:bodyPr",
attributes: {
rot: {
key: "rot",
value: "0"
},
spcFirstLastPara: {
key: "spcFirstLastPara",
value: "1"
},
vertOverflow: {
key: "vertOverflow",
value: "ellipsis"
},
vert: {
key: "vert",
value: "horz"
},
wrap: {
key: "wrap",
value: "square"
},
anchor: {
key: "anchor",
value: "ctr"
},
anchorCtr: {
key: "anchorCtr",
value: "1"
}
}
});
}
function createTextParagraph() {
const p = new class extends XmlComponent {
constructor() {
super("a:p");
}
}();
const pPr = new class extends XmlComponent {
constructor() {
super("a:pPr");
}
}();
pPr["root"].push(new BuilderElement({ name: "a:defRPr" }));
p["root"].push(pPr);
p["root"].push(new BuilderElement({
name: "a:endParaRPr",
attributes: { lang: {
key: "lang",
value: "en-US"
} }
}));
return p;
}
var ChartStyle = class extends XmlComponent {
constructor(val) {
super("c:style");
this.root.push(chartAttr({ val: String(val) }));
}
};
//#endregion
//#region src/chart/chart-collection.ts
var ChartCollection = class {
map;
constructor() {
this.map = /* @__PURE__ */ new Map();
}
addChart(key, chartData) {
this.map.set(key, chartData);
}
get array() {
return [...this.map.values()];
}
};
//#endregion
export { ScatterChart as a, BarChart as c, createStrRef as d, CatAx as f, createChartType as i, AreaChart as l, ChartSpace as n, PieChart as o, ValAx as p, ChartTitle as r, LineChart as s, ChartCollection as t, createNumRef as u };
import { _ as CatAx, a as ChartData, c as ChartSeriesData, d as createChartType, f as ScatterChart, g as AreaChart, h as BarChart, i as ChartCollection, l as ChartType, m as LineChart, n as createNumRef, o as ChartSpace, p as PieChart, r as createStrRef, s as ChartSpaceOptions, t as ChartTitle, u as ChartTypeOptions, v as ValAx } from "../index-nyrpMDHV.js";
export { AreaChart, BarChart, CatAx, ChartCollection, ChartData, ChartSeriesData, ChartSpace, ChartSpaceOptions, ChartTitle, ChartType, ChartTypeOptions, LineChart, PieChart, ScatterChart, ValAx, createChartType, createNumRef, createStrRef };
import { a as ScatterChart, c as BarChart, d as createStrRef, f as CatAx, i as createChartType, l as AreaChart, n as ChartSpace, o as PieChart, p as ValAx, r as ChartTitle, s as LineChart, t as ChartCollection, u as createNumRef } from "../chart-BUlAcF2k.js";
export { AreaChart, BarChart, CatAx, ChartCollection, ChartSpace, ChartTitle, LineChart, PieChart, ScatterChart, ValAx, createChartType, createNumRef, createStrRef };

Sorry, the diff of this file is too big to display

import { $ as RectAlignment, $t as createSolidFill, A as createBevel, At as FillOptions, B as createSoftEdgeEffect, Bt as RelativeRect, C as GeometryGuide, Ct as createGroupFill, D as createShape3D, Dt as createNoFill, E as Shape3DOptions, Et as createPatternFill, F as Point3D, Ft as GradientShadeOptions, G as EffectListOptions, Gt as TileOptions, H as EffectDagOptions, Ht as createGradientFill, I as Scene3DOptions, It as GradientStop, J as createReflectionEffect, Jt as createSourceRectangle, K as createEffectList, Kt as createTileInfo, L as SphereCoords, Lt as LinearShadeOptions, M as BackdropOptions, Mt as buildFill, N as CameraOptions, Nt as extractBlipFillMedia, O as BevelOptions, Ot as BlipFillConfigOptions, P as LightRigOptions, Pt as GradientFillOptions, Q as OuterShadowEffectOptions, Qt as createColorElement, R as Vector3D, Rt as PathShadeOptions, S as PresetGeometryOptions, St as createCustomDash, T as PresetMaterialType, Tt as PresetPattern, U as createEffectDag, Ut as createGradientStop, V as EffectContainerType, Vt as TileFlipMode, W as BlurEffectOptions, Wt as TileAlignment, X as PresetShadowVal, Xt as createBlipEffects, Y as PresetShadowEffectOptions, Yt as BlipEffectsOptions, Z as createPresetShadowEffect, Zt as SolidFillOptions, _ as PathCommand, _t as LineEndOptions, a as Transform2DOptions, an as createSchemeColor, at as BlendMode, b as createCustomGeometry, bt as createLineEnd, c as Stretch, cn as RgbColorOptions, ct as CompoundLine, d as createBlipFill, dn as PresetColorOptions, dt as OutlineFillProperties, en as SystemColor, et as createOuterShadowEffect, f as BlipOptions, fn as createPresetColor, ft as OutlineOptions, g as GeomRect, gn as createColorTransforms, gt as LineEndLength, h as CustomGeometryOptions, hn as ColorTransformOptions, ht as createOutline, i as GroupTransform2DOptions, in as SchemeColorOptions, it as createGlowEffect, j as createBottomBevel, jt as GradientStopOptions, k as BevelPresetType, kt as BlipFillMediaData, l as createExtentionList, ln as createRgbColor, lt as LineCap, m as ConnectionSite, mn as createHslColor, mt as PresetDash, n as MediaTransformation, nn as createSystemColor, nt as createInnerShadowEffect, o as createGroupTransform2D, on as ScRgbColorOptions, ot as FillOverlayEffectOptions, p as createBlip, pn as HslColorOptions, pt as PenAlignment, q as ReflectionEffectOptions, qt as SourceRectangleOptions, r as createTransformation, rn as SchemeColor, rt as GlowEffectOptions, s as createTransform2D, sn as createScRgbColor, st as createFillOverlayEffect, t as MediaDataTransformation, tn as SystemColorOptions, tt as InnerShadowEffectOptions, u as BlipFillOptions, un as PresetColor, ut as LineJoin, v as PathFillMode, vt as LineEndType, w as createAdjustmentValues, wt as PatternFillOptions, x as PresetGeometry, xt as DashStop, y as PathOptions, yt as LineEndWidth, z as createScene3D, zt as PathShadeType } from "../index-C1jJNA2J.js";
export { BackdropOptions, BevelOptions, BevelPresetType, BlendMode, BlipEffectsOptions, BlipFillConfigOptions, BlipFillMediaData, BlipFillOptions, BlipOptions, BlurEffectOptions, CameraOptions, ColorTransformOptions, CompoundLine, ConnectionSite, CustomGeometryOptions, DashStop, EffectContainerType, EffectDagOptions, EffectListOptions, FillOptions, FillOverlayEffectOptions, GeomRect, GeometryGuide, GlowEffectOptions, GradientFillOptions, GradientShadeOptions, GradientStop, GradientStopOptions, GroupTransform2DOptions, HslColorOptions, InnerShadowEffectOptions, LightRigOptions, LineCap, LineEndLength, LineEndOptions, LineEndType, LineEndWidth, LineJoin, LinearShadeOptions, MediaDataTransformation, MediaTransformation, OuterShadowEffectOptions, OutlineFillProperties, OutlineOptions, PathCommand, PathFillMode, PathOptions, PathShadeOptions, PathShadeType, PatternFillOptions, PenAlignment, Point3D, PresetColor, PresetColorOptions, PresetDash, PresetGeometry, PresetGeometryOptions, PresetMaterialType, PresetPattern, PresetShadowEffectOptions, PresetShadowVal, RectAlignment, ReflectionEffectOptions, RelativeRect, RgbColorOptions, ScRgbColorOptions, Scene3DOptions, SchemeColor, SchemeColorOptions, Shape3DOptions, SolidFillOptions, SourceRectangleOptions, SphereCoords, Stretch, SystemColor, SystemColorOptions, TileAlignment, TileFlipMode, TileOptions, Transform2DOptions, Vector3D, buildFill, createAdjustmentValues, createBevel, createBlip, createBlipEffects, createBlipFill, createBottomBevel, createColorElement, createColorTransforms, createCustomDash, createCustomGeometry, createEffectDag, createEffectList, createExtentionList, createFillOverlayEffect, createGlowEffect, createGradientFill, createGradientStop, createGroupFill, createGroupTransform2D, createHslColor, createInnerShadowEffect, createLineEnd, createNoFill, createOuterShadowEffect, createOutline, createPatternFill, createPresetColor, createPresetShadowEffect, createReflectionEffect, createRgbColor, createScRgbColor, createScene3D, createSchemeColor, createShape3D, createSoftEdgeEffect, createSolidFill, createSourceRectangle, createSystemColor, createTileInfo, createTransform2D, createTransformation, extractBlipFillMedia };
import { A as LineJoin, B as createNoFill, C as createOuterShadowEffect, Ct as createSchemeColor, D as createFillOverlayEffect, Dt as createPresetColor, E as BlendMode, Et as PresetColor, F as LineEndType, G as PathShadeType, H as extractBlipFillMedia, I as LineEndWidth, J as createGradientStop, K as TileFlipMode, L as createLineEnd, M as PresetDash, N as createOutline, O as CompoundLine, Ot as createHslColor, P as LineEndLength, R as createCustomDash, S as RectAlignment, St as SchemeColor, T as createGlowEffect, Tt as createRgbColor, U as PresetPattern, V as buildFill, W as createPatternFill, X as createTileInfo, Y as TileAlignment, _ as createEffectList, _t as createBlipEffects, a as createBlip, b as PresetShadowVal, bt as SystemColor, c as PresetGeometry, d as createShape3D, f as BevelPresetType, g as createEffectDag, gt as createSourceRectangle, h as createScene3D, ht as Stretch, i as createBlipFill, j as PenAlignment, k as LineCap, kt as createColorTransforms, l as createAdjustmentValues, m as createBottomBevel, n as createGroupTransform2D, o as createExtentionList, p as createBevel, q as createGradientFill, r as createTransform2D, s as createCustomGeometry, t as createTransformation, u as PresetMaterialType, v as createSoftEdgeEffect, vt as createColorElement, w as createInnerShadowEffect, wt as createScRgbColor, x as createPresetShadowEffect, xt as createSystemColor, y as createReflectionEffect, yt as createSolidFill, z as createGroupFill } from "../drawingml-DG6euH0k.js";
export { BevelPresetType, BlendMode, CompoundLine, LineCap, LineEndLength, LineEndType, LineEndWidth, LineJoin, PathShadeType, PenAlignment, PresetColor, PresetDash, PresetGeometry, PresetMaterialType, PresetPattern, PresetShadowVal, RectAlignment, SchemeColor, Stretch, SystemColor, TileAlignment, TileFlipMode, buildFill, createAdjustmentValues, createBevel, createBlip, createBlipEffects, createBlipFill, createBottomBevel, createColorElement, createColorTransforms, createCustomDash, createCustomGeometry, createEffectDag, createEffectList, createExtentionList, createFillOverlayEffect, createGlowEffect, createGradientFill, createGradientStop, createGroupFill, createGroupTransform2D, createHslColor, createInnerShadowEffect, createLineEnd, createNoFill, createOuterShadowEffect, createOutline, createPatternFill, createPresetColor, createPresetShadowEffect, createReflectionEffect, createRgbColor, createScRgbColor, createScene3D, createSchemeColor, createShape3D, createSoftEdgeEffect, createSolidFill, createSourceRectangle, createSystemColor, createTileInfo, createTransform2D, createTransformation, extractBlipFillMedia };
import { C as XmlComponent } from "./index-k2ds4fI-.js";
//#region src/smartart/categories.d.ts
/** Layout ID → OOXML category type */
declare const LAYOUT_CATEGORIES: Record<string, string>;
/** Style ID → OOXML category type */
declare const STYLE_CATEGORIES: Record<string, string>;
/** Color ID → OOXML category type */
declare const COLOR_CATEGORIES: Record<string, string>;
//#endregion
//#region src/smartart/built-in-definitions.d.ts
/**
* Returns layout XML. Full XML for "default", minimal stub for others.
* Stub has no layoutNode so PowerPoint falls back to built-in definitions
* based on the uniqueId / loTypeId in the data model.
*/
declare function getLayoutXml(layoutId: string): string;
/**
* Returns style stub XML with the given uniqueId.
*/
declare function getStyleXml(styleId: string): string;
/**
* Returns color stub XML with the given uniqueId.
*/
declare function getColorXml(colorId: string): string;
/** Minimal drawing cache for SmartArt (Office apps auto-regenerate this on open) */
declare const DEFAULT_DRAWING_XML: string;
//#endregion
//#region src/smartart/data-model/connection.d.ts
/**
* dgm:cxn — SmartArt data model connection (edge).
*/
declare class Connection extends XmlComponent {
constructor(modelId: string, srcId: string, destId: string, type?: string, srcOrd?: number, destOrd?: number, parTransId?: string, sibTransId?: string);
}
//#endregion
//#region src/smartart/data-model/data-model.d.ts
/**
* CT_DataModel — the complete data model for a SmartArt diagram.
*/
declare class DataModel extends XmlComponent {
constructor(points: readonly XmlComponent[], connections: readonly Connection[]);
}
//#endregion
//#region src/smartart/data-model/point.d.ts
/**
* dgm:pt — SmartArt data model point (node).
*/
declare class Point extends XmlComponent {
constructor(modelId: string, text: string, type?: string);
}
/**
* Transition point (parTrans or sibTrans) — no text body, references a connection.
*/
declare class TransPoint extends XmlComponent {
constructor(modelId: string, type: string, cxnId: string);
}
//#endregion
//#region src/smartart/smartart-collection.d.ts
interface SmartArtData {
readonly key: string;
readonly dataModel: DataModel;
readonly layout: string;
readonly style: string;
readonly color: string;
}
/**
* Manages SmartArt parts in a document.
*/
declare class SmartArtCollection {
private readonly map;
constructor();
addSmartArt(key: string, data: SmartArtData): void;
get array(): readonly SmartArtData[];
}
//#endregion
//#region src/smartart/tree-to-model.d.ts
interface TreeNode {
readonly text: string;
readonly children?: readonly TreeNode[];
}
/**
* Creates a DataModel from tree nodes with layout/style/color settings.
*/
declare const createDataModel: (nodes: readonly TreeNode[], layout?: string, style?: string, color?: string) => DataModel;
//#endregion
export { Point as a, Connection as c, getLayoutXml as d, getStyleXml as f, STYLE_CATEGORIES as h, SmartArtData as i, DEFAULT_DRAWING_XML as l, LAYOUT_CATEGORIES as m, createDataModel as n, TransPoint as o, COLOR_CATEGORIES as p, SmartArtCollection as r, DataModel as s, TreeNode as t, getColorXml as u };

Sorry, the diff of this file is too big to display

import { r as PositiveUniversalMeasure } from "./values-CyCW27--.js";
import { Element } from "@office-open/xml";
//#region src/xml-components/types.d.ts
/**
* XML-serializable object types for OOXML document generation.
*
* @module
*/
/**
* Attributes for an XML element.
*/
type IXmlAttribute = Readonly<Record<string, string | number | boolean>>;
/**
* Object that can be serialized to XML.
*/
type IXmlableObject = Readonly<Record<string, any>>;
//#endregion
//#region src/xml-components/base.d.ts
/**
* Context object passed through the XML tree during serialization.
*
* @typeParam TFileData - The type of the root file data object (format-specific)
*/
interface Context<TFileData = unknown> {
/** The root file data object being serialized (format-specific). */
readonly fileData?: TFileData;
/** Current traversal stack of components (mutable for performance). */
readonly stack: IXmlableObject[];
}
/**
* Abstract base class for all XML components.
*/
declare abstract class BaseXmlComponent {
/** The XML element name for this component (e.g., "w:p" for paragraph). */
protected readonly rootKey: string;
constructor(rootKey: string);
/**
* Prepares this component for XML serialization.
*
* @param context - The serialization context
* @returns The XML-serializable object, or undefined to exclude from output
*/
abstract prepForXml(context: Context): IXmlableObject | undefined;
/**
* Direct XML serialization. Override in subclasses for zero-allocation output.
* Default falls back to prepForXml() + xml().
*/
toXml(context: Context): string;
}
//#endregion
//#region src/xml-components/component.d.ts
/**
* Empty object singleton used for empty XML elements.
*
* @internal
*/
declare const EMPTY_OBJECT: {};
/**
* Base class for all XML components in OOXML documents.
*
* `toXml()` traverses the `root` array and calls `toXml()` on each
* `BaseXmlComponent` child — this avoids building the intermediate
* `IXmlableObject` tree. Inline `IXmlableObject` children fall back to
* `xml()` for serialization.
*/
declare abstract class XmlComponent extends BaseXmlComponent {
/**
* Array of child components, text nodes, and attributes.
*/
root: (BaseXmlComponent | IXmlableObject | string)[];
constructor(rootKey: string);
/**
* Prepares this component and its children for XML serialization.
*/
prepForXml(context: Context): IXmlableObject | undefined;
/**
* Direct XML serialization — traverses `root` and calls `toXml()` on
* each child, concatenating the results into a single string.
*/
toXml(context: Context): string;
/**
* @deprecated Internal use only.
*/
addChildElement(child: BaseXmlComponent | string): XmlComponent;
}
/**
* XML component that is excluded from output if it has no meaningful content.
*/
declare abstract class IgnoreIfEmptyXmlComponent extends XmlComponent {
private readonly includeIfEmpty;
constructor(rootKey: string, includeIfEmpty?: boolean);
prepForXml(context: Context): IXmlableObject | undefined;
/**
* Suppress empty elements — super.toXml() produces a self-closing tag
* (`<tag/>`) when there are no child elements; IgnoreIfEmpty returns ""
* in that case. Child components that already override toXml() (e.g.
* Worksheet) are unaffected.
*/
toXml(context: Context): string;
}
//#endregion
//#region src/xml-components/attributes.d.ts
/**
* Maps TypeScript property names to their XML attribute names.
*/
type AttributeMap<T> = Record<keyof T, string>;
/**
* Simple attribute data as a key-value record.
*/
type AttributeData = Record<string, boolean | number | string>;
/**
* Structured attribute payload with explicit key-value mapping.
*/
type AttributePayload<T> = { readonly [P in keyof T]: {
readonly key: string;
readonly value: T[P];
} };
/**
* Base class for creating XML attributes with automatic name mapping.
*/
declare abstract class XmlAttributeComponent<T extends Record<string, any>> extends BaseXmlComponent {
private readonly root;
/** Optional mapping from property names to XML attribute names. */
protected readonly xmlKeys?: AttributeMap<T>;
constructor(root: T);
prepForXml(_: Context): IXmlableObject;
}
/**
* Next-generation attribute component with explicit key-value pairs.
*/
declare class NextAttributeComponent<T> extends BaseXmlComponent {
private readonly root;
constructor(root: AttributePayload<T>);
prepForXml(_: Context): IXmlableObject;
}
//#endregion
//#region src/xml-components/elements.d.ts
/**
* Build an XML element with arbitrary attributes, filtering out undefined values.
*/
declare function attrObj(name: string, attrs: Record<string, string | number | boolean | undefined>): IXmlableObject;
/**
* Build a CT_OnOff XML object without allocating any XmlComponent.
* `val=true` returns a frozen singleton (cached per name).
*/
declare function onOffObj(name: string, val?: boolean | undefined): IXmlableObject;
/**
* Build a CT_HpsMeasure XML object (half-point size) without allocation.
*/
declare function hpsMeasureObj(name: string, val: number | PositiveUniversalMeasure): IXmlableObject;
/**
* Build a CT_String XML object (string value attribute) without allocation.
*/
declare function stringValObj(name: string, val: string): IXmlableObject;
/**
* Build a numeric value attribute XML object without allocation.
*/
declare function numberValObj(name: string, val: number): IXmlableObject;
/**
* Build a string enum value attribute XML object without allocation.
*/
declare function stringEnumValObj<T extends string>(name: string, val: T): IXmlableObject;
/**
* Build an element wrapping a text string without allocation.
*/
declare function stringContainerObj(name: string, val: string): IXmlableObject;
/**
* XML element representing an empty element (CT_Empty).
*/
declare class EmptyElement extends XmlComponent {}
/**
* Flexible XML element builder with explicit attribute and child configuration.
*/
declare class BuilderElement<T = {}> extends XmlComponent {
constructor({
name,
attributes,
children
}: {
readonly name: string;
readonly attributes?: AttributePayload<T>;
readonly children?: readonly (BaseXmlComponent | IXmlableObject | string)[];
});
}
/**
* Creates a NextAttributeComponent with explicit XML attribute keys.
*/
declare const chartAttr: (attrs: Record<string, string | number | boolean>) => BaseXmlComponent;
/**
* Wraps a component in a named XmlComponent element.
*/
declare function wrapEl(elementName: string, child: BaseXmlComponent): XmlComponent;
//#endregion
//#region src/xml-components/imported.d.ts
/**
* Converts an xml-js Element into an XmlComponent tree.
*/
declare const convertToXmlComponent: (element: Element) => ImportedXmlComponent | string | undefined;
/**
* XML component representing imported XML content.
*/
declare class ImportedXmlComponent extends XmlComponent {
protected _sourceXml?: string;
static fromXmlString(importedContent: string): ImportedXmlComponent;
get sourceXml(): string | undefined;
toXml(_context: Context): string;
constructor(rootKey: string, _attr?: any);
push(xmlComponent: XmlComponent | string): void;
}
/**
* Represents attributes for imported root elements.
*/
declare class ImportedRootElementAttributes extends XmlComponent {
private readonly _attr;
constructor(_attr: any);
prepForXml(_: Context): IXmlableObject;
}
//#endregion
//#region src/xml-components/initializable.d.ts
/**
* XML component that can be initialized from another component.
*/
declare abstract class InitializableXmlComponent extends XmlComponent {
constructor(rootKey: string, initComponent?: XmlComponent);
}
//#endregion
export { XmlComponent as C, IXmlableObject as D, IXmlAttribute as E, IgnoreIfEmptyXmlComponent as S, Context as T, AttributeMap as _, BuilderElement as a, XmlAttributeComponent as b, chartAttr as c, onOffObj as d, stringContainerObj as f, AttributeData as g, wrapEl as h, convertToXmlComponent as i, hpsMeasureObj as l, stringValObj as m, ImportedRootElementAttributes as n, EmptyElement as o, stringEnumValObj as p, ImportedXmlComponent as r, attrObj as s, InitializableXmlComponent as t, numberValObj as u, AttributePayload as v, BaseXmlComponent as w, EMPTY_OBJECT as x, NextAttributeComponent as y };
import { Element } from "@office-open/xml";
//#region src/patch/xml-namespace.d.ts
/**
* Namespace configuration for XML patch operations.
*
* Parameterises element names so the same patch algorithm works for both
* DOCX (`w:*`) and PPTX (`a:*`) documents.
*/
interface XmlNamespaceConfig {
readonly paragraph: string;
readonly run: string;
readonly text: string;
readonly runProperties: string;
}
declare const DOCX_NS: XmlNamespaceConfig;
declare const PPTX_NS: XmlNamespaceConfig;
//#endregion
//#region src/patch/xml-replacer.d.ts
interface ReplacerConfig {
readonly ns: XmlNamespaceConfig;
readonly formatChild: (child: unknown, context: unknown) => Element[];
readonly preserveSpace?: boolean;
}
interface ReplacerResult {
readonly element: Element;
readonly didFindOccurrence: boolean;
}
declare function createReplacer(config: ReplacerConfig): ({
json,
patch,
patchText,
context,
keepOriginalStyles
}: {
readonly json: Element;
readonly patch: {
readonly type: string;
readonly children: readonly unknown[];
};
readonly patchText: string;
readonly context: unknown;
readonly keepOriginalStyles?: boolean;
}) => ReplacerResult;
//#endregion
//#region src/patch/run-renderer.d.ts
interface ElementWrapper {
readonly element: Element;
readonly index: number;
readonly parent: ElementWrapper | undefined;
}
interface RenderedParagraphNode {
readonly text: string;
readonly runs: readonly IRenderedRunNode[];
readonly index: number;
readonly pathToParagraph: readonly number[];
}
interface StartAndEnd {
readonly start: number;
readonly end: number;
}
type IParts = {
readonly text: string;
readonly index: number;
} & StartAndEnd;
type IRenderedRunNode = {
readonly text: string;
readonly parts: readonly IParts[];
readonly index: number;
} & StartAndEnd;
declare function createRunRenderer(ns: XmlNamespaceConfig): (node: ElementWrapper) => RenderedParagraphNode;
//#endregion
//#region src/patch/xml-traverser.d.ts
declare function createTraverser(ns: XmlNamespaceConfig): {
traverse: (node: Element) => readonly RenderedParagraphNode[];
findLocationOfText: (node: Element, text: string) => readonly RenderedParagraphNode[];
};
//#endregion
//#region src/patch/paragraph-token-replacer.d.ts
declare function createTokenReplacer(createTextElementContents: (text: string) => Element[], options?: {
readonly preserveSpace?: boolean;
}): ({
paragraphElement,
renderedParagraph,
originalText,
replacementText
}: {
readonly paragraphElement: Element;
readonly renderedParagraph: RenderedParagraphNode;
readonly originalText: string;
readonly replacementText: string;
}) => Element;
//#endregion
//#region src/patch/paragraph-split-inject.d.ts
declare class TokenNotFoundError extends Error {
constructor(token: string);
}
declare function createSplitInject(ns: XmlNamespaceConfig, createTextElementContents: (text: string) => Element[], options?: {
readonly preserveSpace?: boolean;
}): {
findRunElementIndexWithToken: (paragraphElement: Element, token: string) => number;
splitRunElement: (runElement: Element, token: string) => {
readonly left: Element;
readonly right: Element;
};
};
//#endregion
//#region src/patch/xml-patch-utils.d.ts
declare const toJson: (xmlData: string) => Element;
/**
* Creates the inner content of a text element (`w:t` / `a:t`).
*
* Returns `[{ type: "text", text }]` for non-empty text, `[]` for empty.
* The `xml:space` attribute is handled separately by `patchSpaceAttribute`.
*/
declare const createTextElementContents: (text: string) => Element[];
declare const patchSpaceAttribute: (element: Element) => Element;
declare const getFirstLevelElements: (relationships: Element, id: string) => Element[];
//#endregion
//#region src/patch/content-types-manager.d.ts
declare const appendContentType: (element: Element, contentType: string, extension: string) => void;
//#endregion
//#region src/patch/relationship-manager.d.ts
declare const getNextRelationshipIndex: (relationships: Element) => number;
declare const appendRelationship: (relationships: Element, id: number | string, type: string, target: string, targetMode?: string) => readonly Element[];
//#endregion
export { PPTX_NS as _, getFirstLevelElements as a, TokenNotFoundError as c, createTraverser as d, RenderedParagraphNode as f, DOCX_NS as g, createReplacer as h, createTextElementContents as i, createSplitInject as l, ReplacerConfig as m, getNextRelationshipIndex as n, patchSpaceAttribute as o, createRunRenderer as p, appendContentType as r, toJson as s, appendRelationship as t, createTokenReplacer as u, XmlNamespaceConfig as v };
import { C as XmlComponent } from "./index-k2ds4fI-.js";
//#region src/chart/axes.d.ts
/**
* c:catAx — category axis.
*
* XSD sequence: EG_AxShared (axId, scaling, delete, axPos, ..., crossAx, crosses)
* then: auto, lblAlgn, lblOffset, tickLblSkip, tickMarkSkip, noMultiLvlLbl
*/
declare class CatAx extends XmlComponent {
constructor(axId: number, crossAx: number);
}
/**
* c:valAx — value axis.
*
* XSD sequence: EG_AxShared (axId, scaling, delete, axPos, ..., spPr, ..., crossAx, crosses)
* then: crossBetween, majorUnit, minorUnit, dispUnits
*/
declare class ValAx extends XmlComponent {
constructor(axId: number, crossAx: number);
}
//#endregion
//#region src/chart/chart-types/area-chart.d.ts
interface AreaChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class AreaChart extends XmlComponent {
constructor(options: AreaChartOptions);
}
//#endregion
//#region src/chart/chart-types/bar-chart.d.ts
interface BarChartOptions {
readonly barDirection: "col" | "bar";
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class BarChart extends XmlComponent {
constructor(options: BarChartOptions);
}
//#endregion
//#region src/chart/chart-types/line-chart.d.ts
interface LineChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class LineChart extends XmlComponent {
constructor(options: LineChartOptions);
}
//#endregion
//#region src/chart/chart-types/pie-chart.d.ts
interface PieChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class PieChart extends XmlComponent {
constructor(options: PieChartOptions);
}
//#endregion
//#region src/chart/chart-types/scatter-chart.d.ts
interface ScatterChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class ScatterChart extends XmlComponent {
constructor(options: ScatterChartOptions);
}
//#endregion
//#region src/chart/create-chart-type.d.ts
interface ChartSeriesData {
readonly name: string;
readonly values: readonly number[];
}
type ChartType = "column" | "bar" | "line" | "pie" | "area" | "scatter";
interface ChartTypeOptions {
readonly type: ChartType;
readonly series: readonly ChartSeriesData[];
readonly categories: readonly string[];
}
declare const createChartType: (options: ChartTypeOptions) => ScatterChart | BarChart | LineChart | PieChart | AreaChart;
//#endregion
//#region src/chart/chart-space.d.ts
interface ChartSpaceOptions {
readonly title?: string;
readonly type: ChartType;
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
readonly showLegend?: boolean;
readonly style?: number;
}
/**
* c:chartSpace — root element for chart XML parts.
*/
declare class ChartSpace extends XmlComponent {
constructor(options: ChartSpaceOptions);
}
//#endregion
//#region src/chart/chart-collection.d.ts
interface ChartData {
readonly key: string;
readonly chartSpace: XmlComponent;
}
declare class ChartCollection {
private readonly map;
constructor();
addChart(key: string, chartData: ChartData): void;
get array(): readonly ChartData[];
}
//#endregion
//#region src/chart/series/series-data.d.ts
declare const createStrRef: (values: string | readonly string[]) => XmlComponent;
declare const createNumRef: (values: readonly number[]) => XmlComponent;
//#endregion
//#region src/chart/title.d.ts
declare class ChartTitle extends XmlComponent {
constructor(title: string);
}
//#endregion
export { CatAx as _, ChartData as a, ChartSeriesData as c, createChartType as d, ScatterChart as f, AreaChart as g, BarChart as h, ChartCollection as i, ChartType as l, LineChart as m, createNumRef as n, ChartSpace as o, PieChart as p, createStrRef as r, ChartSpaceOptions as s, ChartTitle as t, ChartTypeOptions as u, ValAx as v };
import { C as XmlComponent, D as IXmlableObject, E as IXmlAttribute, S as IgnoreIfEmptyXmlComponent, T as Context, _ as AttributeMap, a as BuilderElement, b as XmlAttributeComponent, c as chartAttr, d as onOffObj, f as stringContainerObj, g as AttributeData, h as wrapEl, i as convertToXmlComponent, l as hpsMeasureObj, m as stringValObj, n as ImportedRootElementAttributes, o as EmptyElement, p as stringEnumValObj, r as ImportedXmlComponent, s as attrObj, t as InitializableXmlComponent, u as numberValObj, v as AttributePayload, w as BaseXmlComponent, x as EMPTY_OBJECT, y as NextAttributeComponent } from "./index-k2ds4fI-.js";
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./values-CyCW27--.js";
import { _ as CatAx, a as ChartData, c as ChartSeriesData, d as createChartType, f as ScatterChart, g as AreaChart, h as BarChart, i as ChartCollection, l as ChartType, m as LineChart, n as createNumRef, o as ChartSpace, p as PieChart, r as createStrRef, s as ChartSpaceOptions, t as ChartTitle, u as ChartTypeOptions, v as ValAx } from "./index-nyrpMDHV.js";
import { $ as RectAlignment, $t as createSolidFill, A as createBevel, At as FillOptions, B as createSoftEdgeEffect, Bt as RelativeRect, C as GeometryGuide, Ct as createGroupFill, D as createShape3D, Dt as createNoFill, E as Shape3DOptions, Et as createPatternFill, F as Point3D, Ft as GradientShadeOptions, G as EffectListOptions, Gt as TileOptions, H as EffectDagOptions, Ht as createGradientFill, I as Scene3DOptions, It as GradientStop, J as createReflectionEffect, Jt as createSourceRectangle, K as createEffectList, Kt as createTileInfo, L as SphereCoords, Lt as LinearShadeOptions, M as BackdropOptions, Mt as buildFill, N as CameraOptions, Nt as extractBlipFillMedia, O as BevelOptions, Ot as BlipFillConfigOptions, P as LightRigOptions, Pt as GradientFillOptions, Q as OuterShadowEffectOptions, Qt as createColorElement, R as Vector3D, Rt as PathShadeOptions, S as PresetGeometryOptions, St as createCustomDash, T as PresetMaterialType, Tt as PresetPattern, U as createEffectDag, Ut as createGradientStop, V as EffectContainerType, Vt as TileFlipMode, W as BlurEffectOptions, Wt as TileAlignment, X as PresetShadowVal, Xt as createBlipEffects, Y as PresetShadowEffectOptions, Yt as BlipEffectsOptions, Z as createPresetShadowEffect, Zt as SolidFillOptions, _ as PathCommand, _t as LineEndOptions, a as Transform2DOptions, an as createSchemeColor, at as BlendMode, b as createCustomGeometry, bt as createLineEnd, c as Stretch, cn as RgbColorOptions, ct as CompoundLine, d as createBlipFill, dn as PresetColorOptions, dt as OutlineFillProperties, en as SystemColor, et as createOuterShadowEffect, f as BlipOptions, fn as createPresetColor, ft as OutlineOptions, g as GeomRect, gn as createColorTransforms, gt as LineEndLength, h as CustomGeometryOptions, hn as ColorTransformOptions, ht as createOutline, i as GroupTransform2DOptions, in as SchemeColorOptions, it as createGlowEffect, j as createBottomBevel, jt as GradientStopOptions, k as BevelPresetType, kt as BlipFillMediaData, l as createExtentionList, ln as createRgbColor, lt as LineCap, m as ConnectionSite, mn as createHslColor, mt as PresetDash, n as MediaTransformation, nn as createSystemColor, nt as createInnerShadowEffect, o as createGroupTransform2D, on as ScRgbColorOptions, ot as FillOverlayEffectOptions, p as createBlip, pn as HslColorOptions, pt as PenAlignment, q as ReflectionEffectOptions, qt as SourceRectangleOptions, r as createTransformation, rn as SchemeColor, rt as GlowEffectOptions, s as createTransform2D, sn as createScRgbColor, st as createFillOverlayEffect, t as MediaDataTransformation, tn as SystemColorOptions, tt as InnerShadowEffectOptions, u as BlipFillOptions, un as PresetColor, ut as LineJoin, v as PathFillMode, vt as LineEndType, w as createAdjustmentValues, wt as PatternFillOptions, x as PresetGeometry, xt as DashStop, y as PathOptions, yt as LineEndWidth, z as createScene3D, zt as PathShadeType } from "./index-C1jJNA2J.js";
import { a as Point, c as Connection, d as getLayoutXml, f as getStyleXml, h as STYLE_CATEGORIES, i as SmartArtData, l as DEFAULT_DRAWING_XML, m as LAYOUT_CATEGORIES, n as createDataModel, o as TransPoint, p as COLOR_CATEGORIES, r as SmartArtCollection, s as DataModel, t as TreeNode, u as getColorXml } from "./index-BDwL0MVx.js";
import { _ as PPTX_NS, a as getFirstLevelElements, c as TokenNotFoundError, d as createTraverser, f as RenderedParagraphNode, g as DOCX_NS, h as createReplacer, i as createTextElementContents, l as createSplitInject, m as ReplacerConfig, n as getNextRelationshipIndex, o as patchSpaceAttribute, p as createRunRenderer, r as appendContentType, s as toJson, t as appendRelationship, u as createTokenReplacer, v as XmlNamespaceConfig } from "./index-NK0k2I-R.js";
import { Element } from "@office-open/xml";
import { ZipOptions, Zippable, Zippable as Zippable$1, strFromU8, unzipSync } from "fflate";
//#region src/converters.d.ts
/**
* OOXML unit conversion utilities.
*
* @module
*/
/**
* Converts millimeters to TWIP (twentieths of a point).
*/
declare const convertMillimetersToTwip: (millimeters: number) => number;
/**
* Converts inches to TWIP (twentieths of a point).
*/
declare const convertInchesToTwip: (inches: number) => number;
/**
* Converts pixels to EMU (96 DPI).
*/
declare const convertPixelsToEmu: (pixels: number) => number;
/**
* Converts EMU to pixels (96 DPI).
*/
declare const convertEmuToPixels: (emus: number) => number;
/**
* Converts inches to EMU.
*/
declare const convertInchesToEmu: (inches: number) => number;
/**
* Converts EMU to inches.
*/
declare const convertEmuToInches: (emus: number) => number;
/**
* Converts points to EMU.
*/
declare const convertPointsToEmu: (points: number) => number;
/**
* Converts EMU to points.
*/
declare const convertEmuToPoints: (emus: number) => number;
//#endregion
//#region src/id-generators.d.ts
/**
* A function that generates unique sequential numeric IDs.
*/
type UniqueNumericIdCreator = () => number;
/**
* Creates a unique numeric ID generator with sequential numbering.
*/
declare const uniqueNumericIdCreator: (initial?: number) => UniqueNumericIdCreator;
/**
* Generates a unique lowercase alphanumeric ID using nanoid.
*/
declare const uniqueId: () => string;
/**
* Generates a SHA-1 hash of the provided data.
*/
declare const hashedId: (data: Buffer | string | Uint8Array | ArrayBuffer) => string;
/**
* Generates a UUID v4-style unique identifier.
*/
declare const uniqueUuid: () => string;
//#endregion
//#region src/output-type.d.ts
/**
* Output type definitions for OOXML document export.
*
* @module
*/
interface OutputByType {
readonly base64: string;
readonly string: string;
readonly text: string;
readonly binarystring: string;
readonly array: readonly number[];
readonly uint8array: Uint8Array;
readonly arraybuffer: ArrayBuffer;
readonly blob: Blob;
readonly nodebuffer: Buffer;
}
type OutputType = keyof OutputByType;
declare const OoxmlMimeType: {
readonly DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
readonly PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
readonly XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
};
declare const convertOutput: <T extends OutputType>(data: Uint8Array, type: T, mimeType?: string) => OutputByType[T];
//#endregion
//#region src/packer.d.ts
interface XmlifyedFile {
readonly path: string;
readonly data: string | Uint8Array;
}
/** Default DEFLATE compression level matching Microsoft Office behavior. */
declare const ZIP_DEFLATE_LEVEL = 6;
/** STORE level for already-compressed media formats (JPEG, PNG, GIF, etc.). */
declare const ZIP_STORED_LEVEL = 0;
/**
* Asynchronously compress files and convert to the requested output format.
*
* Uses fflate Web Workers for non-blocking DEFLATE compression.
* XML entries use DEFLATE by default; media entries should explicitly set
* `{ level: ZIP_STORED_LEVEL }` to avoid redundant compression.
*/
declare const zipAndConvert: <T extends OutputType>(files: Zippable$1, type: T, mimeType: string, level?: number) => Promise<OutputByType[T]>;
/**
* Synchronously compress files and convert to the requested output format.
*
* Uses synchronous DEFLATE compression for maximum throughput.
* Blocks the event loop — prefer {@link zipAndConvert} in server contexts.
*/
declare const zipSyncAndConvert: <T extends OutputType>(files: Zippable$1, type: T, mimeType: string, level?: number) => OutputByType[T];
/**
* Create a `ReadableStream<Uint8Array>` from compressed file entries.
*
* Uses fflate's `AsyncZipDeflate` for non-blocking DEFLATE compression.
* `STORED` entries (media) pass through synchronously.
* Works in both Node.js and browsers (Web Streams API).
*/
declare const createZipStream: (files: Zippable$1) => ReadableStream<Uint8Array>;
/**
* Compile function provided by each package to convert a file object into a Zippable map.
*/
type CompileFn<TFile> = (file: TFile, overrides?: readonly XmlifyedFile[]) => Zippable$1;
/**
* Packer interface returned by {@link createPacker}.
*
* Async methods use fflate Web Workers for non-blocking compression.
* Sync methods use synchronous compression for maximum throughput in
* CLI scripts and build tools.
*/
interface Packer<TFile> {
/** Compile file to Zippable map (synchronous). */
compile: CompileFn<TFile>;
/** Generic async output — returns the requested OutputType. */
pack<T extends OutputType>(file: TFile, type: T, overrides?: readonly XmlifyedFile[]): Promise<OutputByType[T]>;
/** Generic sync output — returns the requested OutputType. */
packSync<T extends OutputType>(file: TFile, type: T, overrides?: readonly XmlifyedFile[]): OutputByType[T];
/** Async → `Promise<Uint8Array>` (like `Response.bytes()`). */
toBytes(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<Uint8Array>;
/** Sync → `Uint8Array`. */
toBytesSync(file: TFile, overrides?: readonly XmlifyedFile[]): Uint8Array;
/** Async → `Promise<string>` (raw ZIP content as string). */
toString(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<string>;
/** Sync → `string`. */
toStringSync(file: TFile, overrides?: readonly XmlifyedFile[]): string;
/** Async → `Promise<Buffer>` (Node.js). */
toBuffer(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<Buffer>;
/** Sync → `Buffer` (Node.js). */
toBufferSync(file: TFile, overrides?: readonly XmlifyedFile[]): Buffer;
/** Async → `Promise<string>` (base64-encoded). */
toBase64String(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<string>;
/** Sync → `string` (base64-encoded). */
toBase64StringSync(file: TFile, overrides?: readonly XmlifyedFile[]): string;
/** Async → `Promise<Blob>` (browser). */
toBlob(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<Blob>;
/** Sync → `Blob`. */
toBlobSync(file: TFile, overrides?: readonly XmlifyedFile[]): Blob;
/** Async → `Promise<ArrayBuffer>`. */
toArrayBuffer(file: TFile, overrides?: readonly XmlifyedFile[]): Promise<ArrayBuffer>;
/** Sync → `ArrayBuffer`. */
toArrayBufferSync(file: TFile, overrides?: readonly XmlifyedFile[]): ArrayBuffer;
/** Streaming output via `ReadableStream<Uint8Array>` (cross-platform, uses Web Workers). */
toStream(file: TFile, overrides?: readonly XmlifyedFile[]): ReadableStream<Uint8Array>;
}
/**
* Create a Packer object with all output format methods.
*
* Centralises the ZIP → convert pipeline and the streaming implementation
* so that each OOXML package only needs to provide a `compile` function and
* a MIME type.
*/
declare const createPacker: <TFile>(options: {
readonly compile: CompileFn<TFile>;
readonly mimeType: string;
}) => Packer<TFile>;
//#endregion
//#region src/opc/app-properties.d.ts
declare class AppProperties extends ImportedXmlComponent {
private static instance;
constructor();
prepForXml(): Readonly<Record<string, any>> | undefined;
}
//#endregion
//#region src/opc/relationships.d.ts
type RelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" | "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors" | "http://schemas.microsoft.com/office/2007/relationships/diagramLayout" | "http://schemas.microsoft.com/office/2007/relationships/diagramStyle" | "http://schemas.microsoft.com/office/2007/relationships/diagramColors" | "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/bibliography" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/subDocument" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video" | "http://schemas.microsoft.com/office/2007/relationships/media" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing";
declare const TargetModeType: {
readonly EXTERNAL: "External";
};
declare class Relationships extends BaseXmlComponent {
private entries;
constructor();
addRelationship(id: number | string, type: RelationshipType, target: string, targetMode?: (typeof TargetModeType)[keyof typeof TargetModeType]): void;
get relationshipCount(): number;
/**
* Zero-allocation fast path: directly concatenate XML string.
* Bypasses the IXmlableObject intermediate tree entirely.
*/
toXml(_context: Context): string;
prepForXml(_context: Context): IXmlableObject;
}
//#endregion
//#region src/opc/content-types.d.ts
interface DefaultAttributes {
readonly contentType: string;
readonly extension?: string;
}
/**
* Creates a Default element mapping a file extension to a MIME content type.
*/
declare const createDefault: (contentType: string, extension?: string) => XmlComponent;
interface OverrideAttributes {
readonly contentType: string;
readonly partName?: string;
}
/**
* Creates an Override element mapping a specific part path to a MIME content type.
*/
declare const createOverride: (contentType: string, partName?: string) => XmlComponent;
//#endregion
//#region src/formatter.d.ts
/**
* Converts an XmlComponent tree into a serializable XML object or string.
*/
declare class Formatter {
format<T extends Context = Context>(input: BaseXmlComponent, context?: T): Record<string, any>;
/**
* Serialize a component directly to XML string via the toXml() fast path.
*/
formatToXml(input: BaseXmlComponent, context: Context, declaration?: boolean | {
encoding?: string;
standalone?: string;
}): string;
}
//#endregion
//#region src/core-properties.d.ts
interface CoreProperties {
title?: string;
subject?: string;
creator?: string;
keywords?: string;
description?: string;
lastModifiedBy?: string;
revision?: string;
created?: string;
modified?: string;
}
/**
* Parse core properties from an already-parsed XML element.
* Shared by docx and pptx to extract Dublin Core metadata.
*/
declare function parseCorePropsElement(el: Element | undefined): CoreProperties;
/**
* Build a cp:coreProperties XML object from metadata.
*
* Shared by docx and pptx to avoid duplicating namespace declarations
* and Dublin Core property construction.
*/
declare function buildCorePropertiesXml(opts: {
readonly title?: string;
readonly subject?: string;
readonly creator?: string;
readonly keywords?: string;
readonly description?: string;
readonly lastModifiedBy?: string;
readonly revision?: number;
}): IXmlableObject;
//#endregion
//#region src/parser.d.ts
/**
* Parsed OOXML archive backed by an unzipped ZIP map.
*
* Provides unstorage-style API (get/set/getRaw/setRaw/remove/has/keys)
* for reading and modifying individual parts, then serializing back to a ZIP buffer.
*/
declare class ParsedArchive {
private readonly zip;
private readonly modified;
private readonly wrapperCache;
constructor(data: Uint8Array);
/** Read an XML part as an Element tree. */
get(path: string): Element | undefined;
/** Write an XML part (Element → XML string). */
set(path: string, element: Element): void;
/** Read raw binary data (images, media, etc.). */
getRaw(path: string): Uint8Array | undefined;
/** Write raw binary data. */
setRaw(path: string, data: Uint8Array): void;
/** Remove a part. Returns true if it existed. */
remove(path: string): boolean;
/** Check if a part exists. */
has(path: string): boolean;
/** List all paths matching an optional prefix. */
keys(prefix?: string): string[];
/** Serialize back to a ZIP buffer, merging original zip + modifications. */
save(): Uint8Array;
}
/** Parse an OOXML archive (.docx, .pptx, .xlsx) into a ParsedArchive. */
declare function parseArchive(data: Uint8Array): ParsedArchive;
//#endregion
//#region src/raw-passthrough.d.ts
/**
* Convert an Element tree to xml-js compact format (IXmlableObject).
* Always wraps in a named key so the element name is preserved even for empty elements.
*/
declare function elementToCompact(el: Element): IXmlableObject;
/**
* Thin wrapper that passes a raw Element tree through the XML serialization pipeline.
* Used to include parsed-but-unrecognized XML in generated documents.
*/
declare class RawPassthrough extends BaseXmlComponent {
private readonly element;
constructor(element: Element);
prepForXml(_context: Context): IXmlableObject;
}
//#endregion
//#region src/placeholder.d.ts
/**
* Placeholder detection and replacement utilities for compiler post-processing.
*
* Both DOCX and PPTX compilers use placeholder tokens (e.g. `{chart:key}`)
* in XML strings to defer relationship ID assignment. This module provides
* fast pre-check utilities and shared replacement functions.
*/
type IdFormat = "rId" | "plain";
declare const formatId: (offset: number, index: number, style: IdFormat) => string;
declare function escapeRegex(str: string): string;
declare function hasPlaceholders(xml: string): boolean;
declare function collectPlaceholderKeys(xml: string, prefix: string): string[];
declare function replaceImagePlaceholders(xml: string, mediaData: readonly {
readonly fileName: string;
}[], offset: number, idFormat?: IdFormat): string;
declare function getReferencedMedia(xml: string, mediaArray: readonly {
readonly fileName: string;
}[]): readonly {
readonly fileName: string;
}[];
declare function replaceChartPlaceholders(xml: string, chartKeys: readonly string[], offset: number, idFormat?: IdFormat): string;
interface SmartArtRelOptions {
readonly pathPrefix: string;
readonly styleRelType: RelationshipType;
}
declare function replaceSmartArtPlaceholders(xml: string, keys: readonly string[], dataOffset: number, idFormat?: IdFormat): string;
declare function addSmartArtRelationships(keys: readonly string[], addRel: (id: number, type: RelationshipType, target: string, targetMode?: string) => void, baseOffset: number, globalStartIndex: number, options: SmartArtRelOptions): void;
//#endregion
//#region src/xsd-mappings.d.ts
/**
* Bidirectional mappings between user-friendly values and XSD abbreviated values.
*
* When XSD uses full English words (e.g. "center", "start"), values are used directly — no mapping needed.
* When XSD uses abbreviations (e.g. "ctr", "l", "rnd"), this module maps them to full words.
*
* Usage in generation (Options → XML): xsdAlign.to("center") → "ctr"
* Usage in parsing (XML → Options): xsdAlign.from("ctr") → "center"
*/
/** Invert a Record<K, V> into Record<V, K>. */
declare function invertMap<K extends string, V extends string>(map: Record<K, V>): Record<V, K>;
declare const xsdRectAlignment: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight", "tl" | "t" | "tr" | "l" | "ctr" | "r" | "bl" | "b" | "br">; /** The reverse map (XSD → user) */
reverse: Record<"tl" | "t" | "tr" | "l" | "ctr" | "r" | "bl" | "b" | "br", "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight">;
};
declare const xsdTextAlign: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"left" | "center" | "right" | "justify", "l" | "ctr" | "r" | "just">; /** The reverse map (XSD → user) */
reverse: Record<"l" | "ctr" | "r" | "just", "left" | "center" | "right" | "justify">;
};
declare const xsdTextAnchor: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"top" | "center" | "bottom", "t" | "ctr" | "b">; /** The reverse map (XSD → user) */
reverse: Record<"t" | "ctr" | "b", "top" | "center" | "bottom">;
};
declare const xsdLineCap: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"round" | "square" | "flat", "flat" | "rnd" | "sq">; /** The reverse map (XSD → user) */
reverse: Record<"flat" | "rnd" | "sq", "round" | "square" | "flat">;
};
declare const xsdCompoundLine: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"single" | "double" | "thickThin" | "thinThick" | "triple", "thickThin" | "thinThick" | "sng" | "dbl" | "tri">; /** The reverse map (XSD → user) */
reverse: Record<"thickThin" | "thinThick" | "sng" | "dbl" | "tri", "single" | "double" | "thickThin" | "thinThick" | "triple">;
};
declare const xsdPenAlignment: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"center" | "inside", "in" | "ctr">; /** The reverse map (XSD → user) */
reverse: Record<"in" | "ctr", "center" | "inside">;
};
declare const xsdLineEndSize: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"small" | "medium" | "large", "sm" | "med" | "lg">; /** The reverse map (XSD → user) */
reverse: Record<"sm" | "med" | "lg", "small" | "medium" | "large">;
};
declare const xsdBlendMode: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"over" | "multiply" | "screen" | "darken" | "lighten", "over" | "screen" | "darken" | "lighten" | "mult">; /** The reverse map (XSD → user) */
reverse: Record<"over" | "screen" | "darken" | "lighten" | "mult", "over" | "multiply" | "screen" | "darken" | "lighten">;
};
declare const xsdPathFillMode: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"none" | "darken" | "lighten" | "normal" | "lightenLess" | "darkenLess", "none" | "darken" | "lighten" | "lightenLess" | "darkenLess" | "norm">; /** The reverse map (XSD → user) */
reverse: Record<"none" | "darken" | "lighten" | "lightenLess" | "darkenLess" | "norm", "none" | "darken" | "lighten" | "normal" | "lightenLess" | "darkenLess">;
};
declare const xsdEffectContainer: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"sibling" | "tree", "tree" | "sib">; /** The reverse map (XSD → user) */
reverse: Record<"tree" | "sib", "sibling" | "tree">;
};
declare const xsdPresetShadow: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"shadow1" | "shadow2" | "shadow3" | "shadow4" | "shadow5" | "shadow6" | "shadow7" | "shadow8" | "shadow9" | "shadow10" | "shadow11" | "shadow12" | "shadow13" | "shadow14" | "shadow15" | "shadow16" | "shadow17" | "shadow18" | "shadow19" | "shadow20", "shdw1" | "shdw2" | "shdw3" | "shdw4" | "shdw5" | "shdw6" | "shdw7" | "shdw8" | "shdw9" | "shdw10" | "shdw11" | "shdw12" | "shdw13" | "shdw14" | "shdw15" | "shdw16" | "shdw17" | "shdw18" | "shdw19" | "shdw20">; /** The reverse map (XSD → user) */
reverse: Record<"shdw1" | "shdw2" | "shdw3" | "shdw4" | "shdw5" | "shdw6" | "shdw7" | "shdw8" | "shdw9" | "shdw10" | "shdw11" | "shdw12" | "shdw13" | "shdw14" | "shdw15" | "shdw16" | "shdw17" | "shdw18" | "shdw19" | "shdw20", "shadow1" | "shadow2" | "shadow3" | "shadow4" | "shadow5" | "shadow6" | "shadow7" | "shadow8" | "shadow9" | "shadow10" | "shadow11" | "shadow12" | "shadow13" | "shadow14" | "shadow15" | "shadow16" | "shadow17" | "shadow18" | "shadow19" | "shadow20">;
};
declare const xsdMaterialType: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"flat" | "legacyMatte" | "legacyPlastic" | "legacyMetal" | "legacyWireframe" | "matte" | "plastic" | "metal" | "warmMatte" | "translucentPowder" | "powder" | "darkEdge" | "softEdge" | "clear" | "softMetal", "flat" | "legacyMatte" | "legacyPlastic" | "legacyMetal" | "legacyWireframe" | "matte" | "plastic" | "metal" | "warmMatte" | "translucentPowder" | "powder" | "softEdge" | "clear" | "dkEdge" | "softmetal">; /** The reverse map (XSD → user) */
reverse: Record<"flat" | "legacyMatte" | "legacyPlastic" | "legacyMetal" | "legacyWireframe" | "matte" | "plastic" | "metal" | "warmMatte" | "translucentPowder" | "powder" | "softEdge" | "clear" | "dkEdge" | "softmetal", "flat" | "legacyMatte" | "legacyPlastic" | "legacyMetal" | "legacyWireframe" | "matte" | "plastic" | "metal" | "warmMatte" | "translucentPowder" | "powder" | "darkEdge" | "softEdge" | "clear" | "softMetal">;
};
declare const xsdPattern: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"percent5" | "percent10" | "percent20" | "percent25" | "percent30" | "percent40" | "percent50" | "percent60" | "percent70" | "percent75" | "percent80" | "percent90" | "horizontal" | "vertical" | "lightHorizontal" | "lightVertical" | "darkHorizontal" | "darkVertical" | "narrowHorizontal" | "narrowVertical" | "dashedHorizontal" | "dashedVertical" | "cross" | "downDiagonal" | "upDiagonal" | "lightDownDiagonal" | "lightUpDiagonal" | "darkDownDiagonal" | "darkUpDiagonal" | "wideDownDiagonal" | "wideUpDiagonal" | "dashedDownDiagonal" | "dashedUpDiagonal" | "diagonalCross" | "smallChecker" | "largeChecker" | "smallGrid" | "largeGrid" | "dotGrid" | "smallConfetti" | "largeConfetti" | "horizontalBrick" | "diagonalBrick" | "solidDiamond" | "openDiamond" | "dottedDiamond" | "plaid" | "sphere" | "weave" | "divot" | "shingle" | "wave" | "trellis" | "zigZag", "cross" | "dotGrid" | "plaid" | "sphere" | "weave" | "divot" | "shingle" | "wave" | "trellis" | "zigZag" | "pct5" | "pct10" | "pct20" | "pct25" | "pct30" | "pct40" | "pct50" | "pct60" | "pct70" | "pct75" | "pct80" | "pct90" | "horz" | "vert" | "ltHorz" | "ltVert" | "dkHorz" | "dkVert" | "narHorz" | "narVert" | "dashHorz" | "dashVert" | "dnDiag" | "upDiag" | "ltDnDiag" | "ltUpDiag" | "dkDnDiag" | "dkUpDiag" | "wdDnDiag" | "wdUpDiag" | "dashDnDiag" | "dashUpDiag" | "diagCross" | "smCheck" | "lgCheck" | "smGrid" | "lgGrid" | "smConfetti" | "lgConfetti" | "horzBrick" | "diagBrick" | "solidDmnd" | "openDmnd" | "dotDmnd">; /** The reverse map (XSD → user) */
reverse: Record<"cross" | "dotGrid" | "plaid" | "sphere" | "weave" | "divot" | "shingle" | "wave" | "trellis" | "zigZag" | "pct5" | "pct10" | "pct20" | "pct25" | "pct30" | "pct40" | "pct50" | "pct60" | "pct70" | "pct75" | "pct80" | "pct90" | "horz" | "vert" | "ltHorz" | "ltVert" | "dkHorz" | "dkVert" | "narHorz" | "narVert" | "dashHorz" | "dashVert" | "dnDiag" | "upDiag" | "ltDnDiag" | "ltUpDiag" | "dkDnDiag" | "dkUpDiag" | "wdDnDiag" | "wdUpDiag" | "dashDnDiag" | "dashUpDiag" | "diagCross" | "smCheck" | "lgCheck" | "smGrid" | "lgGrid" | "smConfetti" | "lgConfetti" | "horzBrick" | "diagBrick" | "solidDmnd" | "openDmnd" | "dotDmnd", "percent5" | "percent10" | "percent20" | "percent25" | "percent30" | "percent40" | "percent50" | "percent60" | "percent70" | "percent75" | "percent80" | "percent90" | "horizontal" | "vertical" | "lightHorizontal" | "lightVertical" | "darkHorizontal" | "darkVertical" | "narrowHorizontal" | "narrowVertical" | "dashedHorizontal" | "dashedVertical" | "cross" | "downDiagonal" | "upDiagonal" | "lightDownDiagonal" | "lightUpDiagonal" | "darkDownDiagonal" | "darkUpDiagonal" | "wideDownDiagonal" | "wideUpDiagonal" | "dashedDownDiagonal" | "dashedUpDiagonal" | "diagonalCross" | "smallChecker" | "largeChecker" | "smallGrid" | "largeGrid" | "dotGrid" | "smallConfetti" | "largeConfetti" | "horizontalBrick" | "diagonalBrick" | "solidDiamond" | "openDiamond" | "dottedDiamond" | "plaid" | "sphere" | "weave" | "divot" | "shingle" | "wave" | "trellis" | "zigZag">;
};
declare const xsdVerticalMergeRev: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"continue" | "restart", "cont" | "rest">; /** The reverse map (XSD → user) */
reverse: Record<"cont" | "rest", "continue" | "restart">;
};
declare const xsdUnderlineStyle: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"none" | "single" | "double", "none" | "sng" | "dbl">; /** The reverse map (XSD → user) */
reverse: Record<"none" | "sng" | "dbl", "none" | "single" | "double">;
};
declare const xsdStrikeStyle: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"singleStrike" | "doubleStrike" | "noStrike", "sngStrike" | "dblStrike" | "noStrike">; /** The reverse map (XSD → user) */
reverse: Record<"sngStrike" | "dblStrike" | "noStrike", "singleStrike" | "doubleStrike" | "noStrike">;
};
declare const xsdTextCaps: {
/** User-friendly value → XSD value */to: (key: string) => string; /** XSD value → user-friendly value */
from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"none" | "small" | "all", "none" | "small" | "all">; /** The reverse map (XSD → user) */
reverse: Record<"none" | "small" | "all", "none" | "small" | "all">;
};
//#endregion
//#region src/compiler-utils.d.ts
/**
* Convert a mapping of XML files + overrides + media into a Zippable structure.
*
* Centralises the mapping→Zippable conversion shared by all three compilers.
*/
declare function compileMapping(mapping: Record<string, {
data: string;
path: string;
}>, overrides?: readonly XmlifyedFile[], media?: readonly {
data: Uint8Array;
path: string;
}[]): Zippable;
//#endregion
export { AppProperties, AreaChart, AttributeData, AttributeMap, AttributePayload, BackdropOptions, BarChart, BaseXmlComponent, BevelOptions, BevelPresetType, BlendMode, BlipEffectsOptions, BlipFillConfigOptions, BlipFillMediaData, BlipFillOptions, BlipOptions, BlurEffectOptions, BuilderElement, COLOR_CATEGORIES, CameraOptions, CatAx, ChartCollection, ChartData, ChartSeriesData, ChartSpace, ChartSpaceOptions, ChartTitle, ChartType, ChartTypeOptions, ColorTransformOptions, CompileFn, CompoundLine, Connection, ConnectionSite, Context, CoreProperties, CustomGeometryOptions, DEFAULT_DRAWING_XML, DOCX_NS, DashStop, DataModel, type DefaultAttributes, EMPTY_OBJECT, EffectContainerType, EffectDagOptions, EffectListOptions, EmptyElement, FillOptions, FillOverlayEffectOptions, Formatter, GeomRect, GeometryGuide, GlowEffectOptions, GradientFillOptions, GradientShadeOptions, GradientStop, GradientStopOptions, GroupTransform2DOptions, HslColorOptions, IXmlAttribute, IXmlableObject, IdFormat, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, InnerShadowEffectOptions, LAYOUT_CATEGORIES, LightRigOptions, LineCap, LineChart, LineEndLength, LineEndOptions, LineEndType, LineEndWidth, LineJoin, LinearShadeOptions, MediaDataTransformation, MediaTransformation, NextAttributeComponent, OoxmlMimeType, OuterShadowEffectOptions, OutlineFillProperties, OutlineOptions, OutputByType, OutputType, type OverrideAttributes, PPTX_NS, Packer, ParsedArchive, PathCommand, PathFillMode, PathOptions, PathShadeOptions, PathShadeType, PatternFillOptions, PenAlignment, Percentage, PieChart, Point, Point3D, PositivePercentage, PositiveUniversalMeasure, PresetColor, PresetColorOptions, PresetDash, PresetGeometry, PresetGeometryOptions, PresetMaterialType, PresetPattern, PresetShadowEffectOptions, PresetShadowVal, RawPassthrough, RectAlignment, ReflectionEffectOptions, type RelationshipType, Relationships, RelativeMeasure, RelativeRect, RenderedParagraphNode, ReplacerConfig, RgbColorOptions, STYLE_CATEGORIES, ScRgbColorOptions, ScatterChart, Scene3DOptions, SchemeColor, SchemeColorOptions, Shape3DOptions, SmartArtCollection, SmartArtData, SmartArtRelOptions, SolidFillOptions, SourceRectangleOptions, SphereCoords, Stretch, SystemColor, SystemColorOptions, TargetModeType, ThemeColor, ThemeFont, TileAlignment, TileFlipMode, TileOptions, TokenNotFoundError, TransPoint, Transform2DOptions, TreeNode, UniqueNumericIdCreator, UniversalMeasure, ValAx, Vector3D, XmlAttributeComponent, XmlComponent, XmlNamespaceConfig, XmlifyedFile, ZIP_DEFLATE_LEVEL, ZIP_STORED_LEVEL, type ZipOptions, type Zippable, addSmartArtRelationships, appendContentType, appendRelationship, attrObj, buildCorePropertiesXml, buildFill, chartAttr, collectPlaceholderKeys, compileMapping, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPointsToEmu, convertToXmlComponent, createAdjustmentValues, createBevel, createBlip, createBlipEffects, createBlipFill, createBottomBevel, createChartType, createColorElement, createColorTransforms, createCustomDash, createCustomGeometry, createDataModel, createDefault, createEffectDag, createEffectList, createExtentionList, createFillOverlayEffect, createGlowEffect, createGradientFill, createGradientStop, createGroupFill, createGroupTransform2D, createHslColor, createInnerShadowEffect, createLineEnd, createNoFill, createNumRef, createOuterShadowEffect, createOutline, createOverride, createPacker, createPatternFill, createPresetColor, createPresetShadowEffect, createReflectionEffect, createReplacer, createRgbColor, createRunRenderer, createScRgbColor, createScene3D, createSchemeColor, createShape3D, createSoftEdgeEffect, createSolidFill, createSourceRectangle, createSplitInject, createStrRef, createSystemColor, createTextElementContents, createTileInfo, createTokenReplacer, createTransform2D, createTransformation, createTraverser, createZipStream, dateTimeValue, decimalNumber, eighthPointMeasureValue, elementToCompact, escapeRegex, extractBlipFillMedia, formatId, getColorXml, getFirstLevelElements, getLayoutXml, getNextRelationshipIndex, getReferencedMedia, getStyleXml, hasPlaceholders, hashedId, hexBinary, hexColorValue, hpsMeasureObj, hpsMeasureValue, invertMap, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseArchive, parseCorePropsElement, patchSpaceAttribute, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, strFromU8, stringContainerObj, stringEnumValObj, stringValObj, toJson, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipSync, wrapEl, xsdBlendMode, xsdCompoundLine, xsdEffectContainer, xsdLineCap, xsdLineEndSize, xsdMaterialType, xsdPathFillMode, xsdPattern, xsdPenAlignment, xsdPresetShadow, xsdRectAlignment, xsdStrikeStyle, xsdTextAlign, xsdTextAnchor, xsdTextCaps, xsdUnderlineStyle, xsdVerticalMergeRev, zipAndConvert, zipSyncAndConvert };
import { _ as XmlAttributeComponent, a as BuilderElement, b as XmlComponent, c as chartAttr, d as onOffObj, f as stringContainerObj, g as NextAttributeComponent, h as wrapEl, i as convertToXmlComponent, l as hpsMeasureObj, m as stringValObj, n as ImportedRootElementAttributes, o as EmptyElement, p as stringEnumValObj, r as ImportedXmlComponent, s as attrObj, t as InitializableXmlComponent, u as numberValObj, v as EMPTY_OBJECT, x as BaseXmlComponent, y as IgnoreIfEmptyXmlComponent } from "./xml-components-SxPlKGms.js";
import { ThemeColor, ThemeFont, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber } from "./values.js";
import { $ as xsdCompoundLine, A as LineJoin, At as hashedId, B as createNoFill, Bt as convertPixelsToEmu, C as createOuterShadowEffect, Ct as createSchemeColor, D as createFillOverlayEffect, Dt as createPresetColor, E as BlendMode, Et as PresetColor, F as LineEndType, Ft as convertEmuToPixels, G as PathShadeType, H as extractBlipFillMedia, I as LineEndWidth, It as convertEmuToPoints, J as createGradientStop, K as TileFlipMode, L as createLineEnd, Lt as convertInchesToEmu, M as PresetDash, Mt as uniqueNumericIdCreator, N as createOutline, Nt as uniqueUuid, O as CompoundLine, Ot as createHslColor, P as LineEndLength, Pt as convertEmuToInches, Q as xsdBlendMode, R as createCustomDash, Rt as convertInchesToTwip, S as RectAlignment, St as SchemeColor, T as createGlowEffect, Tt as createRgbColor, U as PresetPattern, V as buildFill, Vt as convertPointsToEmu, W as createPatternFill, X as createTileInfo, Y as TileAlignment, Z as invertMap, _ as createEffectList, _t as createBlipEffects, a as createBlip, at as xsdPattern, b as PresetShadowVal, bt as SystemColor, c as PresetGeometry, ct as xsdRectAlignment, d as createShape3D, dt as xsdTextAnchor, et as xsdEffectContainer, f as BevelPresetType, ft as xsdTextCaps, g as createEffectDag, gt as createSourceRectangle, h as createScene3D, ht as Stretch, i as createBlipFill, it as xsdPathFillMode, j as PenAlignment, jt as uniqueId, k as LineCap, kt as createColorTransforms, l as createAdjustmentValues, lt as xsdStrikeStyle, m as createBottomBevel, mt as xsdVerticalMergeRev, n as createGroupTransform2D, nt as xsdLineEndSize, o as createExtentionList, ot as xsdPenAlignment, p as createBevel, pt as xsdUnderlineStyle, q as createGradientFill, r as createTransform2D, rt as xsdMaterialType, s as createCustomGeometry, st as xsdPresetShadow, t as createTransformation, tt as xsdLineCap, u as PresetMaterialType, ut as xsdTextAlign, v as createSoftEdgeEffect, vt as createColorElement, w as createInnerShadowEffect, wt as createScRgbColor, x as createPresetShadowEffect, xt as createSystemColor, y as createReflectionEffect, yt as createSolidFill, z as createGroupFill, zt as convertMillimetersToTwip } from "./drawingml-DG6euH0k.js";
import { a as DataModel, c as getColorXml, d as COLOR_CATEGORIES, f as LAYOUT_CATEGORIES, i as TransPoint, l as getLayoutXml, n as SmartArtCollection, o as Connection, p as STYLE_CATEGORIES, r as Point, s as DEFAULT_DRAWING_XML, t as createDataModel, u as getStyleXml } from "./smartart-DGNfjKA9.js";
import { a as ScatterChart, c as BarChart, d as createStrRef, f as CatAx, i as createChartType, l as AreaChart, n as ChartSpace, o as PieChart, p as ValAx, r as ChartTitle, s as LineChart, t as ChartCollection, u as createNumRef } from "./chart-BUlAcF2k.js";
import { a as createTraverser, c as TokenNotFoundError, d as getFirstLevelElements, f as patchSpaceAttribute, h as PPTX_NS, i as createReplacer, l as createSplitInject, m as DOCX_NS, n as getNextRelationshipIndex, o as createRunRenderer, p as toJson, r as appendContentType, s as createTokenReplacer, t as appendRelationship, u as createTextElementContents } from "./patch-BWan_fhF.js";
import { escapeXml, js2xml, textOf, xml2js } from "@office-open/xml";
import { AsyncZipDeflate, Zip, ZipPassThrough, strFromU8, strFromU8 as strFromU8$1, strToU8, unzipSync, unzipSync as unzipSync$1, zip, zipSync } from "fflate";
//#region src/output-type.ts
/**
* Output type definitions for OOXML document export.
*
* @module
*/
const OoxmlMimeType = {
DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
};
const convertOutput = (data, type, mimeType = OoxmlMimeType.DOCX) => {
switch (type) {
case "nodebuffer": return Buffer.from(data);
case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: mimeType });
case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
case "uint8array": return data;
case "base64": return btoa(strFromU8$1(data, true));
case "string":
case "text":
case "binarystring": return strFromU8$1(data, true);
case "array": return [...data];
default: return data;
}
};
//#endregion
//#region src/packer.ts
/**
* Shared packer utilities for OOXML document generation.
*
* @module
*/
/** Default DEFLATE compression level matching Microsoft Office behavior. */
const ZIP_DEFLATE_LEVEL = 6;
/** STORE level for already-compressed media formats (JPEG, PNG, GIF, etc.). */
const ZIP_STORED_LEVEL = 0;
/**
* Asynchronously compress files and convert to the requested output format.
*
* Uses fflate Web Workers for non-blocking DEFLATE compression.
* XML entries use DEFLATE by default; media entries should explicitly set
* `{ level: ZIP_STORED_LEVEL }` to avoid redundant compression.
*/
const zipAndConvert = async (files, type, mimeType, level = 6) => {
return convertOutput(await new Promise((resolve, reject) => {
zip(files, {
level,
consume: true
}, (err, data) => {
if (err) reject(err);
else resolve(data);
});
}), type, mimeType);
};
/**
* Synchronously compress files and convert to the requested output format.
*
* Uses synchronous DEFLATE compression for maximum throughput.
* Blocks the event loop — prefer {@link zipAndConvert} in server contexts.
*/
const zipSyncAndConvert = (files, type, mimeType, level = 6) => {
return convertOutput(zipSync(files, { level }), type, mimeType);
};
/**
* Create a `ReadableStream<Uint8Array>` from compressed file entries.
*
* Uses fflate's `AsyncZipDeflate` for non-blocking DEFLATE compression.
* `STORED` entries (media) pass through synchronously.
* Works in both Node.js and browsers (Web Streams API).
*/
const createZipStream = (files) => {
return new ReadableStream({ start(controller) {
try {
const zip = new Zip((err, chunk, _final) => {
if (err) {
controller.error(err);
return;
}
controller.enqueue(chunk);
if (_final) controller.close();
});
for (const [name, data] of Object.entries(files)) {
const raw = Array.isArray(data) ? data[0] : data;
const level = Array.isArray(data) ? data[1].level ?? 6 : 6;
const entry = level === 0 ? new ZipPassThrough(name) : new AsyncZipDeflate(name, { level });
zip.add(entry);
entry.push(raw, true);
}
zip.end();
} catch (err) {
controller.error(err instanceof Error ? err : new Error(String(err)));
}
} });
};
/**
* Create a Packer object with all output format methods.
*
* Centralises the ZIP → convert pipeline and the streaming implementation
* so that each OOXML package only needs to provide a `compile` function and
* a MIME type.
*/
const createPacker = (options) => {
const { compile, mimeType } = options;
const compileFiles = (file, overrides = []) => compile(file, overrides);
const pack = async (file, type, overrides) => {
return zipAndConvert(compileFiles(file, overrides), type, mimeType);
};
const toBytes = (file, overrides) => pack(file, "uint8array", overrides);
const toString = (file, overrides) => pack(file, "string", overrides);
const toBuffer = (file, overrides) => pack(file, "nodebuffer", overrides);
const toBase64String = (file, overrides) => pack(file, "base64", overrides);
const toBlob = (file, overrides) => pack(file, "blob", overrides);
const toArrayBuffer = (file, overrides) => pack(file, "arraybuffer", overrides);
const packSync = (file, type, overrides) => {
return zipSyncAndConvert(compileFiles(file, overrides), type, mimeType);
};
const toBytesSync = (file, overrides) => packSync(file, "uint8array", overrides);
const toStringSync = (file, overrides) => packSync(file, "string", overrides);
const toBufferSync = (file, overrides) => packSync(file, "nodebuffer", overrides);
const toBase64StringSync = (file, overrides) => packSync(file, "base64", overrides);
const toBlobSync = (file, overrides) => packSync(file, "blob", overrides);
const toArrayBufferSync = (file, overrides) => packSync(file, "arraybuffer", overrides);
const toStream = (file, overrides) => {
let files;
try {
files = compileFiles(file, overrides);
} catch (err) {
return new ReadableStream({ start(controller) {
controller.error(err instanceof Error ? err : new Error(String(err)));
} });
}
return createZipStream(files);
};
return {
compile,
pack,
packSync,
toBytes,
toBytesSync,
toString,
toStringSync,
toBuffer,
toBufferSync,
toBase64String,
toBase64StringSync,
toBlob,
toBlobSync,
toArrayBuffer,
toArrayBufferSync,
toStream
};
};
//#endregion
//#region src/opc/app-properties.ts
const APP_PROPS_XML = "<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\"/>";
var AppProperties = class AppProperties extends ImportedXmlComponent {
static instance = ImportedXmlComponent.fromXmlString(APP_PROPS_XML);
constructor() {
super("Properties");
}
prepForXml() {
return AppProperties.instance.prepForXml({ stack: [] });
}
};
//#endregion
//#region src/opc/relationships.ts
const TargetModeType = { EXTERNAL: "External" };
const RELS_ATTRS = { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } };
var Relationships = class extends BaseXmlComponent {
entries = [];
constructor() {
super("Relationships");
}
addRelationship(id, type, target, targetMode) {
this.entries.push({
id: `rId${id}`,
type,
target,
targetMode
});
}
get relationshipCount() {
return this.entries.length;
}
/**
* Zero-allocation fast path: directly concatenate XML string.
* Bypasses the IXmlableObject intermediate tree entirely.
*/
toXml(_context) {
const p = ["<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">"];
for (const e of this.entries) {
const tm = e.targetMode ? ` TargetMode="${escapeXml(e.targetMode)}"` : "";
p.push(`<Relationship Id="${escapeXml(e.id)}" Type="${escapeXml(e.type)}" Target="${escapeXml(e.target)}"${tm}/>`);
}
p.push("</Relationships>");
return p.join("");
}
prepForXml(_context) {
const children = [RELS_ATTRS];
for (const e of this.entries) {
const attrs = {
Id: e.id,
Type: e.type,
Target: e.target
};
if (e.targetMode) attrs.TargetMode = e.targetMode;
children.push({ Relationship: { _attr: attrs } });
}
if (children.length === 1 && "_attr" in children[0]) return { Relationships: children[0] };
return { Relationships: children };
}
};
//#endregion
//#region src/opc/content-types.ts
/**
* Content Types components for OPC (Open Packaging Convention).
*
* Provides Default and Override elements used in [Content_Types].xml
* to map file extensions and part paths to MIME content types.
*
* Reference: ECMA-376 Part 2, Section 10.1
*
* @module
*/
/**
* Creates a Default element mapping a file extension to a MIME content type.
*/
const createDefault = (contentType, extension) => new BuilderElement({
attributes: {
contentType: {
key: "ContentType",
value: contentType
},
extension: {
key: "Extension",
value: extension
}
},
name: "Default"
});
/**
* Creates an Override element mapping a specific part path to a MIME content type.
*/
const createOverride = (contentType, partName) => new BuilderElement({
attributes: {
contentType: {
key: "ContentType",
value: contentType
},
partName: {
key: "PartName",
value: partName
}
},
name: "Override"
});
//#endregion
//#region src/formatter.ts
const XML_DECL = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
/**
* Converts an XmlComponent tree into a serializable XML object or string.
*/
var Formatter = class {
format(input, context = { stack: [] }) {
const output = input.prepForXml(context);
if (output) return output;
throw new Error("XMLComponent did not format correctly");
}
/**
* Serialize a component directly to XML string via the toXml() fast path.
*/
formatToXml(input, context, declaration) {
const body = input.toXml(context);
if (!body) return "";
if (declaration) return (declaration === true ? XML_DECL : `<?xml version="1.0" encoding="${declaration.encoding || "UTF-8"}"${declaration.standalone ? ` standalone="${declaration.standalone}"` : ""}?>`) + body;
return body;
}
};
//#endregion
//#region src/core-properties.ts
const FIELD_MAP = [
{
name: "dc:title",
key: "title"
},
{
name: "dc:subject",
key: "subject"
},
{
name: "dc:creator",
key: "creator"
},
{
name: "dc:description",
key: "description"
},
{
name: "cp:keywords",
key: "keywords"
},
{
name: "cp:lastModifiedBy",
key: "lastModifiedBy"
}
];
/**
* Parse core properties from an already-parsed XML element.
* Shared by docx and pptx to extract Dublin Core metadata.
*/
function parseCorePropsElement(el) {
if (!el) return {};
const props = {};
for (const field of FIELD_MAP) {
const child = el.elements?.find((e) => e.name === field.name);
const value = textOf(child) || void 0;
if (value) props[field.key] = value;
}
const revEl = el.elements?.find((e) => e.name === "cp:revision");
if (revEl) {
const rev = textOf(revEl);
if (rev) {
const n = Number(rev);
if (!isNaN(n)) props.revision = rev;
}
}
return props;
}
const CORE_PROPS_NS = Object.freeze({ _attr: Object.freeze({
"xmlns:cp": "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
"xmlns:dc": "http://purl.org/dc/elements/1.1/",
"xmlns:dcmitype": "http://purl.org/dc/dcmitype/",
"xmlns:dcterms": "http://purl.org/dc/terms/",
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
}) });
const W3CDTF_ATTR = Object.freeze({ _attr: Object.freeze({ "xsi:type": "dcterms:W3CDTF" }) });
/**
* Build a cp:coreProperties XML object from metadata.
*
* Shared by docx and pptx to avoid duplicating namespace declarations
* and Dublin Core property construction.
*/
function buildCorePropertiesXml(opts) {
const children = [CORE_PROPS_NS];
if (opts.title) children.push({ "dc:title": [opts.title] });
if (opts.subject) children.push({ "dc:subject": [opts.subject] });
if (opts.creator) children.push({ "dc:creator": [opts.creator] });
if (opts.keywords) children.push({ "cp:keywords": [opts.keywords] });
if (opts.description) children.push({ "dc:description": [opts.description] });
if (opts.lastModifiedBy) children.push({ "cp:lastModifiedBy": [opts.lastModifiedBy] });
if (opts.revision) children.push({ "cp:revision": [String(opts.revision)] });
const now = (/* @__PURE__ */ new Date()).toISOString();
children.push({ "dcterms:created": [W3CDTF_ATTR, now] });
children.push({ "dcterms:modified": [W3CDTF_ATTR, now] });
return { "cp:coreProperties": children };
}
//#endregion
//#region src/parser.ts
const XML_PARSE_OPTIONS = {
nativeTypeAttributes: true,
captureSpacesBetweenElements: true
};
/**
* Parsed OOXML archive backed by an unzipped ZIP map.
*
* Provides unstorage-style API (get/set/getRaw/setRaw/remove/has/keys)
* for reading and modifying individual parts, then serializing back to a ZIP buffer.
*/
var ParsedArchive = class {
zip;
modified = /* @__PURE__ */ new Map();
wrapperCache = /* @__PURE__ */ new Map();
constructor(data) {
this.zip = new Map(Object.entries(unzipSync$1(data)));
}
/** Read an XML part as an Element tree. */
get(path) {
const modData = this.modified.get(path);
if (modData) {
const wrapper = xml2js(strFromU8$1(modData), XML_PARSE_OPTIONS);
this.wrapperCache.set(path, wrapper);
return wrapper.elements?.find((e) => e.type === "element");
}
const data = this.zip.get(path);
if (data === void 0) return void 0;
const cached = this.wrapperCache.get(path);
if (cached) return cached.elements?.find((e) => e.type === "element");
const wrapper = xml2js(strFromU8$1(data), XML_PARSE_OPTIONS);
this.wrapperCache.set(path, wrapper);
return wrapper.elements?.find((e) => e.type === "element");
}
/** Write an XML part (Element → XML string). */
set(path, element) {
const wrapper = this.wrapperCache.get(path);
const xml = js2xml(wrapper ? {
...wrapper,
elements: [{
...element,
type: "element"
}]
} : { elements: [{
...element,
type: "element"
}] });
this.modified.set(path, strToU8(xml));
}
/** Read raw binary data (images, media, etc.). */
getRaw(path) {
return this.modified.get(path) ?? this.zip.get(path);
}
/** Write raw binary data. */
setRaw(path, data) {
this.modified.set(path, data);
this.wrapperCache.delete(path);
}
/** Remove a part. Returns true if it existed. */
remove(path) {
this.wrapperCache.delete(path);
return this.modified.delete(path) || this.zip.delete(path);
}
/** Check if a part exists. */
has(path) {
return this.modified.has(path) || this.zip.has(path);
}
/** List all paths matching an optional prefix. */
keys(prefix) {
const all = /* @__PURE__ */ new Set();
for (const key of this.zip.keys()) if (!prefix || key.startsWith(prefix)) all.add(key);
for (const key of this.modified.keys()) if (!prefix || key.startsWith(prefix)) all.add(key);
return [...all];
}
/** Serialize back to a ZIP buffer, merging original zip + modifications. */
save() {
const files = {};
for (const [path, data] of this.zip) if (!this.modified.has(path)) files[path] = MEDIA_PATTERN.test(path) ? [data, { level: MEDIA_STORED_LEVEL }] : data;
for (const [path, data] of this.modified) files[path] = MEDIA_PATTERN.test(path) ? [data, { level: MEDIA_STORED_LEVEL }] : data;
return zipSync(files);
}
};
/** Regex to detect already-compressed media file extensions. */
const MEDIA_PATTERN = /\.(png|jpe?g|gif|wmf|emf|tiff?|avi|mp4|mp3|wav)$/i;
/** STORE level for already-compressed media formats. */
const MEDIA_STORED_LEVEL = 0;
/** Parse an OOXML archive (.docx, .pptx, .xlsx) into a ParsedArchive. */
function parseArchive(data) {
return new ParsedArchive(data);
}
//#endregion
//#region src/raw-passthrough.ts
/**
* Convert an Element tree to xml-js compact format (IXmlableObject).
* Always wraps in a named key so the element name is preserved even for empty elements.
*/
function elementToCompact(el) {
const inner = {};
if (el.attributes && Object.keys(el.attributes).length > 0) inner._attributes = el.attributes;
if (el.cdata) inner._cdata = el.cdata;
else if (el.text !== null && el.text !== void 0) inner._text = el.text;
if (el.elements) for (const child of el.elements) {
const key = child.name ?? "_unknown";
const compactChild = elementToCompact(child);
if (inner[key]) {
if (!Array.isArray(inner[key])) inner[key] = [inner[key]];
inner[key].push(compactChild);
} else inner[key] = compactChild;
}
const name = el.name ?? "unknown";
if (Object.keys(inner).length === 0) return { [name]: {} };
return { [name]: inner };
}
/**
* Thin wrapper that passes a raw Element tree through the XML serialization pipeline.
* Used to include parsed-but-unrecognized XML in generated documents.
*/
var RawPassthrough = class extends BaseXmlComponent {
constructor(element) {
super(element.name ?? "unknown");
this.element = element;
}
prepForXml(_context) {
return elementToCompact(this.element);
}
};
//#endregion
//#region src/placeholder.ts
const formatId = (offset, index, style) => style === "rId" ? `rId${offset + index}` : `${offset + index}`;
function escapeRegex(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function hasPlaceholders(xml) {
return xml.includes("{");
}
function collectPlaceholderKeys(xml, prefix) {
const keys = [];
const search = `{${prefix}`;
let pos = 0;
while ((pos = xml.indexOf(search, pos)) !== -1) {
const keyStart = pos + search.length;
const keyEnd = xml.indexOf("}", keyStart);
if (keyEnd === -1) break;
const key = xml.substring(keyStart, keyEnd);
if (key.length > 0 && !keys.includes(key)) keys.push(key);
pos = keyEnd + 1;
}
return keys;
}
function replaceImagePlaceholders(xml, mediaData, offset, idFormat = "rId") {
let result = xml;
mediaData.forEach((image, i) => {
result = result.replace(new RegExp(`\\{${escapeRegex(image.fileName)}\\}`, "g"), formatId(offset, i, idFormat));
});
return result;
}
function getReferencedMedia(xml, mediaArray) {
return mediaArray.filter((image) => xml.includes(`{${image.fileName}}`));
}
function replaceChartPlaceholders(xml, chartKeys, offset, idFormat = "rId") {
let result = xml;
chartKeys.forEach((key, i) => {
result = result.replace(new RegExp(`\\{chart:${escapeRegex(key)}\\}`, "g"), formatId(offset, i, idFormat));
});
return result;
}
function replaceSmartArtPlaceholders(xml, keys, dataOffset, idFormat = "rId") {
let result = xml;
const count = keys.length;
const loOffset = dataOffset + count;
const qsOffset = loOffset + count;
const csOffset = qsOffset + count;
keys.forEach((key, i) => {
result = result.replace(new RegExp(`\\{smartart:${escapeRegex(key)}\\}`, "g"), formatId(dataOffset, i, idFormat));
result = result.replace(new RegExp(`\\{smartart-lo:${escapeRegex(key)}\\}`, "g"), formatId(loOffset, i, idFormat));
result = result.replace(new RegExp(`\\{smartart-qs:${escapeRegex(key)}\\}`, "g"), formatId(qsOffset, i, idFormat));
result = result.replace(new RegExp(`\\{smartart-cs:${escapeRegex(key)}\\}`, "g"), formatId(csOffset, i, idFormat));
});
return result;
}
function addSmartArtRelationships(keys, addRel, baseOffset, globalStartIndex, options) {
const { pathPrefix, styleRelType } = options;
const count = keys.length;
const loOffset = baseOffset + count;
const qsOffset = loOffset + count;
const csOffset = qsOffset + count;
keys.forEach((_key, i) => {
const gi = globalStartIndex + i;
addRel(baseOffset + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData", `${pathPrefix}diagrams/data${gi + 1}.xml`);
addRel(loOffset + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout", `${pathPrefix}diagrams/layout${gi + 1}.xml`);
addRel(qsOffset + i, styleRelType, `${pathPrefix}diagrams/quickStyle${gi + 1}.xml`);
addRel(csOffset + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors", `${pathPrefix}diagrams/colors${gi + 1}.xml`);
addRel(csOffset + count + i, "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing", `${pathPrefix}diagrams/drawing${gi + 1}.xml`);
});
}
//#endregion
//#region src/compiler-utils.ts
/** Default STORE level for already-compressed media formats. */
const ZIP_STORED_LEVEL$1 = 0;
/** Reusable TextEncoder instance (stateless, safe to share). */
const encoder = new TextEncoder();
/**
* Convert a mapping of XML files + overrides + media into a Zippable structure.
*
* Centralises the mapping→Zippable conversion shared by all three compilers.
*/
function compileMapping(mapping, overrides, media) {
const files = {};
for (const entry of Object.values(mapping)) files[entry.path] = encoder.encode(entry.data);
if (overrides) for (const o of overrides) files[o.path] = typeof o.data === "string" ? encoder.encode(o.data) : o.data;
if (media) for (const m of media) files[m.path] = [m.data, { level: ZIP_STORED_LEVEL$1 }];
return files;
}
//#endregion
export { AppProperties, AreaChart, BarChart, BaseXmlComponent, BevelPresetType, BlendMode, BuilderElement, COLOR_CATEGORIES, CatAx, ChartCollection, ChartSpace, ChartTitle, CompoundLine, Connection, DEFAULT_DRAWING_XML, DOCX_NS, DataModel, EMPTY_OBJECT, EmptyElement, Formatter, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, LAYOUT_CATEGORIES, LineCap, LineChart, LineEndLength, LineEndType, LineEndWidth, LineJoin, NextAttributeComponent, OoxmlMimeType, PPTX_NS, ParsedArchive, PathShadeType, PenAlignment, PieChart, Point, PresetColor, PresetDash, PresetGeometry, PresetMaterialType, PresetPattern, PresetShadowVal, RawPassthrough, RectAlignment, Relationships, STYLE_CATEGORIES, ScatterChart, SchemeColor, SmartArtCollection, Stretch, SystemColor, TargetModeType, ThemeColor, ThemeFont, TileAlignment, TileFlipMode, TokenNotFoundError, TransPoint, ValAx, XmlAttributeComponent, XmlComponent, ZIP_DEFLATE_LEVEL, ZIP_STORED_LEVEL, addSmartArtRelationships, appendContentType, appendRelationship, attrObj, buildCorePropertiesXml, buildFill, chartAttr, collectPlaceholderKeys, compileMapping, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPointsToEmu, convertToXmlComponent, createAdjustmentValues, createBevel, createBlip, createBlipEffects, createBlipFill, createBottomBevel, createChartType, createColorElement, createColorTransforms, createCustomDash, createCustomGeometry, createDataModel, createDefault, createEffectDag, createEffectList, createExtentionList, createFillOverlayEffect, createGlowEffect, createGradientFill, createGradientStop, createGroupFill, createGroupTransform2D, createHslColor, createInnerShadowEffect, createLineEnd, createNoFill, createNumRef, createOuterShadowEffect, createOutline, createOverride, createPacker, createPatternFill, createPresetColor, createPresetShadowEffect, createReflectionEffect, createReplacer, createRgbColor, createRunRenderer, createScRgbColor, createScene3D, createSchemeColor, createShape3D, createSoftEdgeEffect, createSolidFill, createSourceRectangle, createSplitInject, createStrRef, createSystemColor, createTextElementContents, createTileInfo, createTokenReplacer, createTransform2D, createTransformation, createTraverser, createZipStream, dateTimeValue, decimalNumber, eighthPointMeasureValue, elementToCompact, escapeRegex, extractBlipFillMedia, formatId, getColorXml, getFirstLevelElements, getLayoutXml, getNextRelationshipIndex, getReferencedMedia, getStyleXml, hasPlaceholders, hashedId, hexBinary, hexColorValue, hpsMeasureObj, hpsMeasureValue, invertMap, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseArchive, parseCorePropsElement, patchSpaceAttribute, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, strFromU8, stringContainerObj, stringEnumValObj, stringValObj, toJson, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipSync, wrapEl, xsdBlendMode, xsdCompoundLine, xsdEffectContainer, xsdLineCap, xsdLineEndSize, xsdMaterialType, xsdPathFillMode, xsdPattern, xsdPenAlignment, xsdPresetShadow, xsdRectAlignment, xsdStrikeStyle, xsdTextAlign, xsdTextAnchor, xsdTextCaps, xsdUnderlineStyle, xsdVerticalMergeRev, zipAndConvert, zipSyncAndConvert };
import { xml2js } from "@office-open/xml";
//#region src/patch/xml-namespace.ts
const DOCX_NS = {
paragraph: "w:p",
run: "w:r",
text: "w:t",
runProperties: "w:rPr"
};
const PPTX_NS = {
paragraph: "a:p",
run: "a:r",
text: "a:t",
runProperties: "a:rPr"
};
//#endregion
//#region src/patch/xml-patch-utils.ts
/**
* XML utility functions for patch operations.
*/
const toJson = (xmlData) => {
return xml2js(xmlData, {
captureSpacesBetweenElements: true,
compact: false
});
};
/**
* Creates the inner content of a text element (`w:t` / `a:t`).
*
* Returns `[{ type: "text", text }]` for non-empty text, `[]` for empty.
* The `xml:space` attribute is handled separately by `patchSpaceAttribute`.
*/
const createTextElementContents = (text) => text === "" ? [] : [{
text,
type: "text"
}];
const patchSpaceAttribute = (element) => ({
...element,
attributes: { "xml:space": "preserve" }
});
const getFirstLevelElements = (relationships, id) => relationships.elements?.filter((e) => e.name === id)[0].elements ?? [];
//#endregion
//#region src/patch/paragraph-split-inject.ts
var TokenNotFoundError = class extends Error {
constructor(token) {
super(`Token ${token} not found`);
this.name = "TokenNotFoundError";
}
};
function createSplitInject(ns, createTextElementContents, options) {
const preserveSpace = options?.preserveSpace ?? true;
const findRunElementIndexWithToken = (paragraphElement, token) => {
for (let i = 0; i < (paragraphElement.elements ?? []).length; i++) {
const element = paragraphElement.elements[i];
if (element.type === "element" && element.name === ns.run) {
const textElement = (element.elements ?? []).filter((e) => e.type === "element" && e.name === ns.text);
for (const text of textElement) {
if (!text.elements?.[0]) continue;
if (text.elements[0].text?.includes(token)) return i;
}
}
}
throw new TokenNotFoundError(token);
};
const splitRunElement = (runElement, token) => {
let splitIndex = -1;
const splitElements = runElement.elements?.map((e, i) => {
if (splitIndex !== -1) return e;
if (e.type === "element" && e.name === ns.text) {
const splitText = (e.elements?.[0]?.text ?? "").split(token);
const newElements = splitText.map((t) => ({
...e,
...preserveSpace ? patchSpaceAttribute(e) : {},
elements: createTextElementContents(t)
}));
if (splitText.length > 1) splitIndex = i;
return newElements;
} else return e;
}).flat() ?? [];
return {
left: {
...structuredClone(runElement),
elements: splitElements.slice(0, splitIndex + 1)
},
right: {
...structuredClone(runElement),
elements: splitElements.slice(splitIndex + 1)
}
};
};
return {
findRunElementIndexWithToken,
splitRunElement
};
}
//#endregion
//#region src/patch/paragraph-token-replacer.ts
const ReplaceMode = {
START: 0,
MIDDLE: 1,
END: 2
};
function createTokenReplacer(createTextElementContents, options) {
const preserveSpace = options?.preserveSpace ?? true;
const patchTextElement = (element, text) => {
element.elements = createTextElementContents(text);
return element;
};
return ({ paragraphElement, renderedParagraph, originalText, replacementText }) => {
const startIndex = renderedParagraph.text.indexOf(originalText);
const endIndex = startIndex + originalText.length - 1;
let replaceMode = ReplaceMode.START;
for (const run of renderedParagraph.runs) for (const { text, index, start, end } of run.parts) switch (replaceMode) {
case ReplaceMode.START:
if (startIndex >= start && startIndex <= end) {
const offsetStartIndex = startIndex - start;
const offsetEndIndex = Math.min(endIndex, end) - start;
const partToReplace = text.substring(offsetStartIndex, offsetEndIndex + 1);
if (partToReplace === "") continue;
const firstPart = text.replace(partToReplace, replacementText);
patchTextElement(paragraphElement.elements[run.index].elements[index], firstPart);
replaceMode = ReplaceMode.MIDDLE;
continue;
}
break;
case ReplaceMode.MIDDLE:
if (endIndex <= end) {
const lastPart = text.substring(endIndex - start + 1);
patchTextElement(paragraphElement.elements[run.index].elements[index], lastPart);
const currentElement = paragraphElement.elements[run.index].elements[index];
paragraphElement.elements[run.index].elements[index] = preserveSpace ? patchSpaceAttribute(currentElement) : currentElement;
replaceMode = ReplaceMode.END;
} else patchTextElement(paragraphElement.elements[run.index].elements[index], "");
break;
}
return paragraphElement;
};
}
//#endregion
//#region src/patch/run-renderer.ts
function createRunRenderer(ns) {
const renderParagraphNode = (node) => {
if (node.element.name !== ns.paragraph) throw new Error(`Invalid node type: ${node.element.name}`);
if (!node.element.elements) return {
index: -1,
pathToParagraph: [],
runs: [],
text: ""
};
let currentRunStringLength = 0;
const runs = node.element.elements.map((element, i) => ({
element,
i
})).filter(({ element }) => element.name === ns.run).map(({ element, i }) => {
const renderedRunNode = renderRunNode(element, i, currentRunStringLength);
currentRunStringLength += renderedRunNode.text.length;
return renderedRunNode;
}).filter((e) => Boolean(e));
const text = runs.reduce((acc, curr) => acc + curr.text, "");
return {
index: node.index,
pathToParagraph: buildNodePath(node),
runs,
text
};
};
const renderRunNode = (node, index, currentRunStringIndex) => {
if (!node.elements) return {
end: currentRunStringIndex,
index: -1,
parts: [],
start: currentRunStringIndex,
text: ""
};
let currentTextStringIndex = currentRunStringIndex;
const parts = node.elements.map((element, i) => element.name === ns.text && element.elements && element.elements.length > 0 ? (() => {
const partStart = currentTextStringIndex;
currentTextStringIndex += (element.elements[0].text?.toString() ?? "").length;
return {
end: currentTextStringIndex - 1,
index: i,
start: partStart,
text: element.elements[0].text?.toString() ?? ""
};
})() : void 0).filter((e) => Boolean(e)).map((e) => e);
const text = parts.reduce((acc, curr) => acc + curr.text, "");
return {
end: currentTextStringIndex - 1,
index,
parts,
start: currentRunStringIndex,
text
};
};
return renderParagraphNode;
}
const buildNodePath = (node) => node.parent ? [...buildNodePath(node.parent), node.index] : [node.index];
//#endregion
//#region src/patch/xml-traverser.ts
const elementsToWrapper = (wrapper) => wrapper.element.elements?.map((e, i) => ({
element: e,
index: i,
parent: wrapper
})) ?? [];
function createTraverser(ns) {
const renderParagraphNode = createRunRenderer(ns);
const traverse = (node) => {
let renderedParagraphs = [];
const queue = [...elementsToWrapper({
element: node,
index: 0,
parent: void 0
})];
let currentNode;
while (queue.length > 0) {
currentNode = queue.shift();
if (currentNode.element.name === ns.paragraph) renderedParagraphs = [...renderedParagraphs, renderParagraphNode(currentNode)];
queue.push(...elementsToWrapper(currentNode));
}
return renderedParagraphs;
};
const findLocationOfText = (node, text) => traverse(node).filter((p) => p.text.includes(text));
return {
traverse,
findLocationOfText
};
}
//#endregion
//#region src/patch/xml-replacer.ts
const SPLIT_TOKEN = "ɵ";
function createReplacer(config) {
const { ns, formatChild } = config;
const { findLocationOfText } = createTraverser(ns);
const replaceTokenInParagraphElement = createTokenReplacer(createTextElementContents, { preserveSpace: config.preserveSpace });
const { findRunElementIndexWithToken, splitRunElement } = createSplitInject(ns, createTextElementContents, { preserveSpace: config.preserveSpace });
const replacer = ({ json, patch, patchText, context, keepOriginalStyles = true }) => {
const renderedParagraphs = findLocationOfText(json, patchText);
if (renderedParagraphs.length === 0) return {
didFindOccurrence: false,
element: json
};
for (const renderedParagraph of renderedParagraphs) {
const textJson = patch.children.flatMap((c) => formatChild(c, context));
switch (patch.type) {
case "file": {
const parentElement = goToParentElementFromPath(json, renderedParagraph.pathToParagraph);
const elementIndex = getLastElementIndexFromPath(renderedParagraph.pathToParagraph);
parentElement.elements.splice(elementIndex, 1, ...textJson);
break;
}
default: {
const paragraphElement = goToElementFromPath(json, renderedParagraph.pathToParagraph);
replaceTokenInParagraphElement({
originalText: patchText,
paragraphElement,
renderedParagraph,
replacementText: SPLIT_TOKEN
});
const index = findRunElementIndexWithToken(paragraphElement, SPLIT_TOKEN);
const runElementToBeReplaced = paragraphElement.elements[index];
const { left, right } = splitRunElement(runElementToBeReplaced, SPLIT_TOKEN);
let newRunElements = textJson;
let patchedRightElement = right;
if (keepOriginalStyles) {
const runElementNonTextualElements = runElementToBeReplaced.elements.filter((e) => e.type === "element" && e.name === ns.runProperties);
newRunElements = textJson.map((e) => {
if (e.type !== "element" || e.name !== ns.run || e.elements?.some((c) => c.type === "element" && c.name === ns.runProperties)) return e;
return {
...e,
elements: [...runElementNonTextualElements, ...e.elements ?? []]
};
});
patchedRightElement = {
...right,
elements: [...runElementNonTextualElements, ...right.elements]
};
}
paragraphElement.elements.splice(index, 1, left, ...newRunElements, patchedRightElement);
break;
}
}
}
return {
didFindOccurrence: true,
element: json
};
};
return replacer;
}
const goToElementFromPath = (json, path) => {
let element = json;
for (let i = 1; i < path.length; i++) {
const index = path[i];
element = element.elements[index];
}
return element;
};
const goToParentElementFromPath = (json, path) => goToElementFromPath(json, path.slice(0, -1));
const getLastElementIndexFromPath = (path) => path[path.length - 1];
//#endregion
//#region src/patch/content-types-manager.ts
const appendContentType = (element, contentType, extension) => {
const relationshipElements = getFirstLevelElements(element, "Types");
if (relationshipElements.some((el) => el.type === "element" && el.name === "Default" && el?.attributes?.ContentType === contentType && el?.attributes?.Extension === extension)) return;
relationshipElements.push({
attributes: {
ContentType: contentType,
Extension: extension
},
name: "Default",
type: "element"
});
};
//#endregion
//#region src/patch/relationship-manager.ts
const getIdFromRelationshipId = (relationshipId) => {
const output = parseInt(relationshipId.substring(3), 10);
return isNaN(output) ? 0 : output;
};
const getNextRelationshipIndex = (relationships) => {
return getFirstLevelElements(relationships, "Relationships").map((e) => getIdFromRelationshipId(e.attributes?.Id?.toString() ?? "")).reduce((acc, curr) => Math.max(acc, curr), 0) + 1;
};
const appendRelationship = (relationships, id, type, target, targetMode) => {
const relationshipElements = getFirstLevelElements(relationships, "Relationships");
relationshipElements.push({
attributes: {
Id: `rId${id}`,
Target: target,
TargetMode: targetMode,
Type: type
},
name: "Relationship",
type: "element"
});
return relationshipElements;
};
//#endregion
export { createTraverser as a, TokenNotFoundError as c, getFirstLevelElements as d, patchSpaceAttribute as f, PPTX_NS as h, createReplacer as i, createSplitInject as l, DOCX_NS as m, getNextRelationshipIndex as n, createRunRenderer as o, toJson as p, appendContentType as r, createTokenReplacer as s, appendRelationship as t, createTextElementContents as u };
import { _ as PPTX_NS, a as getFirstLevelElements, c as TokenNotFoundError, d as createTraverser, f as RenderedParagraphNode, g as DOCX_NS, h as createReplacer, i as createTextElementContents, l as createSplitInject, m as ReplacerConfig, n as getNextRelationshipIndex, o as patchSpaceAttribute, p as createRunRenderer, r as appendContentType, s as toJson, t as appendRelationship, u as createTokenReplacer, v as XmlNamespaceConfig } from "../index-NK0k2I-R.js";
export { DOCX_NS, PPTX_NS, RenderedParagraphNode, ReplacerConfig, TokenNotFoundError, XmlNamespaceConfig, appendContentType, appendRelationship, createReplacer, createRunRenderer, createSplitInject, createTextElementContents, createTokenReplacer, createTraverser, getFirstLevelElements, getNextRelationshipIndex, patchSpaceAttribute, toJson };
import { a as createTraverser, c as TokenNotFoundError, d as getFirstLevelElements, f as patchSpaceAttribute, h as PPTX_NS, i as createReplacer, l as createSplitInject, m as DOCX_NS, n as getNextRelationshipIndex, o as createRunRenderer, p as toJson, r as appendContentType, s as createTokenReplacer, t as appendRelationship, u as createTextElementContents } from "../patch-BWan_fhF.js";
export { DOCX_NS, PPTX_NS, TokenNotFoundError, appendContentType, appendRelationship, createReplacer, createRunRenderer, createSplitInject, createTextElementContents, createTokenReplacer, createTraverser, getFirstLevelElements, getNextRelationshipIndex, patchSpaceAttribute, toJson };
import { b as XmlComponent, c as chartAttr } from "./xml-components-SxPlKGms.js";
//#region src/smartart/categories.ts
/** Layout ID → OOXML category type */
const LAYOUT_CATEGORIES = {
default: "list",
list1: "list",
list2: "list",
vList2: "list",
hList1: "list",
pList1: "list",
process1: "process",
process2: "process",
process3: "process",
process4: "process",
chevron1: "process",
chevron2: "process",
arrow1: "process",
arrow2: "process",
cycle1: "cycle",
cycle2: "cycle",
cycle3: "cycle",
cycle4: "cycle",
cycle5: "cycle",
hierarchy1: "hier",
hierarchy2: "hier",
hierarchy3: "hier",
hierarchy4: "hier",
orgChart1: "hier",
pyramid1: "pyramid",
pyramid2: "pyramid",
pyramid3: "pyramid",
matrix1: "matrix",
matrix2: "matrix",
matrix3: "matrix",
radial1: "rel",
radial2: "rel",
radial3: "rel",
venn1: "rel",
funnel1: "rel",
balance1: "rel",
gear1: "rel",
constOrg1: "rel",
oppId1: "rel"
};
/** Style ID → OOXML category type */
const STYLE_CATEGORIES = {
simple1: "simple",
simple2: "simple",
simple3: "simple",
simple4: "simple",
simple5: "simple",
moderate1: "moderate",
moderate2: "moderate",
moderate3: "moderate",
moderate4: "moderate",
polished1: "polished",
polished2: "polished",
polished3: "polished",
polished4: "polished",
professional1: "professional",
professional2: "professional",
professional3: "professional",
professional4: "professional",
cartoon1: "cartoon",
cartoon2: "cartoon",
cartoon3: "cartoon",
cartoon4: "cartoon",
powdery1: "powdery",
powdery2: "powdery",
powdery3: "powdery",
powdery4: "powdery",
burnt1: "burnt",
burnt2: "burnt",
burnt3: "burnt",
burnt4: "burnt"
};
/** Color ID → OOXML category type */
const COLOR_CATEGORIES = {
accent1_2: "accent1",
accent2_2: "accent2",
accent3_2: "accent3",
accent4_2: "accent4",
accent5_2: "accent5",
accent6_2: "accent6",
colorful1: "colorful",
colorful2: "colorful",
colorful3: "colorful",
colorful4: "colorful",
dark1: "dark",
dark2: "dark",
primary1: "primary",
primary2: "primary",
gray1: "gray",
gray2: "gray"
};
//#endregion
//#region src/smartart/built-in-definitions.ts
const DGM_NS = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
const XML_DECL = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
/** Full default list layout (urn:microsoft.com/office/officeart/2005/8/layout/default) */
const FULL_DEFAULT_LAYOUT_XML = "<dgm:layoutDef xmlns:dgm=\"" + DGM_NS + "\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" uniqueId=\"urn:microsoft.com/office/officeart/2005/8/layout/default\"><dgm:title val=\"\"/><dgm:desc val=\"\"/><dgm:catLst><dgm:cat type=\"list\" pri=\"400\"/></dgm:catLst><dgm:sampData><dgm:dataModel><dgm:ptLst><dgm:pt modelId=\"0\" type=\"doc\"/><dgm:pt modelId=\"1\"><dgm:prSet phldr=\"1\"/></dgm:pt><dgm:pt modelId=\"2\"><dgm:prSet phldr=\"1\"/></dgm:pt><dgm:pt modelId=\"3\"><dgm:prSet phldr=\"1\"/></dgm:pt><dgm:pt modelId=\"4\"><dgm:prSet phldr=\"1\"/></dgm:pt><dgm:pt modelId=\"5\"><dgm:prSet phldr=\"1\"/></dgm:pt></dgm:ptLst><dgm:cxnLst><dgm:cxn modelId=\"6\" srcId=\"0\" destId=\"1\" srcOrd=\"0\" destOrd=\"0\"/><dgm:cxn modelId=\"7\" srcId=\"0\" destId=\"2\" srcOrd=\"1\" destOrd=\"0\"/><dgm:cxn modelId=\"8\" srcId=\"0\" destId=\"3\" srcOrd=\"2\" destOrd=\"0\"/><dgm:cxn modelId=\"9\" srcId=\"0\" destId=\"4\" srcOrd=\"3\" destOrd=\"0\"/><dgm:cxn modelId=\"10\" srcId=\"0\" destId=\"5\" srcOrd=\"4\" destOrd=\"0\"/></dgm:cxnLst><dgm:bg/><dgm:whole/></dgm:dataModel></dgm:sampData><dgm:styleData><dgm:dataModel><dgm:ptLst><dgm:pt modelId=\"0\" type=\"doc\"/><dgm:pt modelId=\"1\"/><dgm:pt modelId=\"2\"/></dgm:ptLst><dgm:cxnLst><dgm:cxn modelId=\"3\" srcId=\"0\" destId=\"1\" srcOrd=\"0\" destOrd=\"0\"/><dgm:cxn modelId=\"4\" srcId=\"0\" destId=\"2\" srcOrd=\"1\" destOrd=\"0\"/></dgm:cxnLst><dgm:bg/><dgm:whole/></dgm:dataModel></dgm:styleData><dgm:clrData><dgm:dataModel><dgm:ptLst><dgm:pt modelId=\"0\" type=\"doc\"/><dgm:pt modelId=\"1\"/><dgm:pt modelId=\"2\"/><dgm:pt modelId=\"3\"/><dgm:pt modelId=\"4\"/><dgm:pt modelId=\"5\"/><dgm:pt modelId=\"6\"/></dgm:ptLst><dgm:cxnLst><dgm:cxn modelId=\"7\" srcId=\"0\" destId=\"1\" srcOrd=\"0\" destOrd=\"0\"/><dgm:cxn modelId=\"8\" srcId=\"0\" destId=\"2\" srcOrd=\"1\" destOrd=\"0\"/><dgm:cxn modelId=\"9\" srcId=\"0\" destId=\"3\" srcOrd=\"2\" destOrd=\"0\"/><dgm:cxn modelId=\"10\" srcId=\"0\" destId=\"4\" srcOrd=\"3\" destOrd=\"0\"/><dgm:cxn modelId=\"11\" srcId=\"0\" destId=\"5\" srcOrd=\"4\" destOrd=\"0\"/><dgm:cxn modelId=\"12\" srcId=\"0\" destId=\"6\" srcOrd=\"5\" destOrd=\"0\"/></dgm:cxnLst><dgm:bg/><dgm:whole/></dgm:dataModel></dgm:clrData><dgm:layoutNode name=\"diagram\"><dgm:varLst><dgm:dir/><dgm:resizeHandles val=\"exact\"/></dgm:varLst><dgm:choose name=\"Name0\"><dgm:if name=\"Name1\" func=\"var\" arg=\"dir\" op=\"equ\" val=\"norm\"><dgm:alg type=\"snake\"><dgm:param type=\"grDir\" val=\"tL\"/><dgm:param type=\"flowDir\" val=\"row\"/><dgm:param type=\"contDir\" val=\"sameDir\"/><dgm:param type=\"off\" val=\"ctr\"/></dgm:alg></dgm:if><dgm:else name=\"Name2\"><dgm:alg type=\"snake\"><dgm:param type=\"grDir\" val=\"tR\"/><dgm:param type=\"flowDir\" val=\"row\"/><dgm:param type=\"contDir\" val=\"sameDir\"/><dgm:param type=\"off\" val=\"ctr\"/></dgm:alg></dgm:else></dgm:choose><dgm:shape xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:blip=\"\"><dgm:adjLst/></dgm:shape><dgm:presOf/><dgm:constrLst><dgm:constr type=\"w\" for=\"ch\" forName=\"node\" refType=\"w\"/><dgm:constr type=\"h\" for=\"ch\" forName=\"node\" refType=\"w\" refFor=\"ch\" refForName=\"node\" fact=\"0.6\"/><dgm:constr type=\"w\" for=\"ch\" forName=\"sibTrans\" refType=\"w\" refFor=\"ch\" refForName=\"node\" fact=\"0.1\"/><dgm:constr type=\"sp\" refType=\"w\" refFor=\"ch\" refForName=\"sibTrans\"/><dgm:constr type=\"primFontSz\" for=\"ch\" forName=\"node\" op=\"equ\" val=\"65\"/></dgm:constrLst><dgm:ruleLst/><dgm:forEach name=\"Name3\" axis=\"ch\" ptType=\"node\"><dgm:layoutNode name=\"node\"><dgm:varLst><dgm:bulletEnabled val=\"1\"/></dgm:varLst><dgm:alg type=\"tx\"/><dgm:shape type=\"rect\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:blip=\"\"><dgm:adjLst/></dgm:shape><dgm:presOf axis=\"desOrSelf\" ptType=\"node\"/><dgm:constrLst><dgm:constr type=\"lMarg\" refType=\"primFontSz\" fact=\"0.3\"/><dgm:constr type=\"rMarg\" refType=\"primFontSz\" fact=\"0.3\"/><dgm:constr type=\"tMarg\" refType=\"primFontSz\" fact=\"0.3\"/><dgm:constr type=\"bMarg\" refType=\"primFontSz\" fact=\"0.3\"/></dgm:constrLst><dgm:ruleLst><dgm:rule type=\"primFontSz\" val=\"5\" fact=\"NaN\" max=\"NaN\"/></dgm:ruleLst></dgm:layoutNode><dgm:forEach name=\"Name4\" axis=\"followSib\" ptType=\"sibTrans\" cnt=\"1\"><dgm:layoutNode name=\"sibTrans\"><dgm:alg type=\"sp\"/><dgm:shape xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:blip=\"\"><dgm:adjLst/></dgm:shape><dgm:presOf/><dgm:constrLst/><dgm:ruleLst/></dgm:layoutNode></dgm:forEach></dgm:layoutNode></dgm:layoutDef>";
/**
* Returns layout XML. Full XML for "default", minimal stub for others.
* Stub has no layoutNode so PowerPoint falls back to built-in definitions
* based on the uniqueId / loTypeId in the data model.
*/
function getLayoutXml(layoutId) {
if (layoutId === "default") return XML_DECL + FULL_DEFAULT_LAYOUT_XML;
const cat = LAYOUT_CATEGORIES[layoutId] ?? "list";
return XML_DECL + "<dgm:layoutDef xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" uniqueId=\"urn:microsoft.com/office/officeart/2005/8/layout/" + layoutId + "\"><dgm:title val=\"\"/><dgm:desc val=\"\"/><dgm:catLst><dgm:cat type=\"" + cat + "\" pri=\"400\"/></dgm:catLst><dgm:sampData><dgm:dataModel><dgm:ptLst><dgm:pt modelId=\"0\" type=\"doc\"/><dgm:pt modelId=\"1\"><dgm:prSet phldr=\"1\"/></dgm:pt><dgm:pt modelId=\"2\"><dgm:prSet phldr=\"1\"/></dgm:pt></dgm:ptLst><dgm:cxnLst><dgm:cxn modelId=\"3\" srcId=\"0\" destId=\"1\" srcOrd=\"0\" destOrd=\"0\"/><dgm:cxn modelId=\"4\" srcId=\"0\" destId=\"2\" srcOrd=\"1\" destOrd=\"0\"/></dgm:cxnLst><dgm:bg/><dgm:whole/></dgm:dataModel></dgm:sampData></dgm:layoutDef>";
}
/**
* Returns style stub XML with the given uniqueId.
*/
function getStyleXml(styleId) {
const cat = STYLE_CATEGORIES[styleId] ?? "simple";
return XML_DECL + "<dgm:styleDef xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" uniqueId=\"urn:microsoft.com/office/officeart/2005/8/quickstyle/" + styleId + "\"><dgm:title val=\"\"/><dgm:desc val=\"\"/><dgm:catLst><dgm:cat type=\"" + cat + "\" pri=\"10100\"/></dgm:catLst><dgm:scene3d><a:camera prst=\"orthographicFront\"/><a:lightRig rig=\"threePt\" dir=\"t\"/></dgm:scene3d></dgm:styleDef>";
}
/**
* Returns color stub XML with the given uniqueId.
*/
function getColorXml(colorId) {
const cat = COLOR_CATEGORIES[colorId] ?? "accent1";
return XML_DECL + "<dgm:colorsDef xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" uniqueId=\"urn:microsoft.com/office/officeart/2005/8/colors/" + colorId + "\"><dgm:title val=\"\"/><dgm:desc val=\"\"/><dgm:catLst><dgm:cat type=\"" + cat + "\" pri=\"11200\"/></dgm:catLst></dgm:colorsDef>";
}
/** Minimal drawing cache for SmartArt (Office apps auto-regenerate this on open) */
const DEFAULT_DRAWING_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><dsp:drawing xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:dsp=\"http://schemas.microsoft.com/office/drawing/2008/diagram\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><dsp:spTree><dsp:nvGrpSpPr><dsp:cNvPr id=\"0\" name=\"\"/><dsp:cNvGrpSpPr/></dsp:nvGrpSpPr><dsp:grpSpPr/></dsp:spTree></dsp:drawing>";
//#endregion
//#region src/smartart/data-model/connection.ts
/**
* dgm:cxn — SmartArt data model connection (edge).
*/
var Connection = class extends XmlComponent {
constructor(modelId, srcId, destId, type, srcOrd = 0, destOrd = 0, parTransId, sibTransId) {
super("dgm:cxn");
const attrs = {
modelId,
srcId,
destId,
srcOrd,
destOrd
};
if (type) attrs.type = type;
if (parTransId) attrs.parTransId = parTransId;
if (sibTransId) attrs.sibTransId = sibTransId;
this.root.push(chartAttr(attrs));
}
};
//#endregion
//#region src/smartart/data-model/data-model.ts
/**
* CT_DataModel — the complete data model for a SmartArt diagram.
*/
var DataModel = class extends XmlComponent {
constructor(points, connections) {
super("dgm:dataModel");
this.root.push(chartAttr({
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
"xmlns:dgm": "http://schemas.openxmlformats.org/drawingml/2006/diagram"
}));
const ptLst = new class extends XmlComponent {
constructor() {
super("dgm:ptLst");
}
}();
for (const pt of points) ptLst["root"].push(pt);
this.root.push(ptLst);
const cxnLst = new class extends XmlComponent {
constructor() {
super("dgm:cxnLst");
}
}();
for (const cxn of connections) cxnLst["root"].push(cxn);
this.root.push(cxnLst);
this.root.push(new EmptyElement$2("dgm:bg"));
this.root.push(new EmptyElement$2("dgm:whole"));
}
};
var EmptyElement$2 = class extends XmlComponent {
constructor(tag) {
super(tag);
}
};
//#endregion
//#region src/smartart/data-model/point.ts
/**
* dgm:pt — SmartArt data model point (node).
*/
var Point = class extends XmlComponent {
constructor(modelId, text, type = "node") {
super("dgm:pt");
this.root.push(chartAttr({
modelId,
type
}));
this.root.push(new PointText(text));
}
};
/**
* Transition point (parTrans or sibTrans) — no text body, references a connection.
*/
var TransPoint = class extends XmlComponent {
constructor(modelId, type, cxnId) {
super("dgm:pt");
this.root.push(chartAttr({
modelId,
type,
cxnId
}));
this.root.push(new EmptyElement$1("dgm:spPr"));
}
};
var EmptyElement$1 = class extends XmlComponent {
constructor(tag) {
super(tag);
}
};
/**
* dgm:t — text body within a point.
*/
var PointText = class extends XmlComponent {
constructor(text) {
super("dgm:t");
this.root.push(new EmptyElement$1("a:bodyPr"));
this.root.push(new EmptyElement$1("a:lstStyle"));
const p = new EmptyElement$1("a:p");
if (text) {
const t = new class extends XmlComponent {
constructor() {
super("a:t");
}
}();
t["root"].push(text);
const r = new class extends XmlComponent {
constructor() {
super("a:r");
}
}();
r["root"].push(t);
p["root"].push(r);
}
this.root.push(p);
}
};
//#endregion
//#region src/smartart/smartart-collection.ts
/**
* Manages SmartArt parts in a document.
*/
var SmartArtCollection = class {
map;
constructor() {
this.map = /* @__PURE__ */ new Map();
}
addSmartArt(key, data) {
this.map.set(key, data);
}
get array() {
return [...this.map.values()];
}
};
//#endregion
//#region src/smartart/tree-to-model.ts
function createDocPoint(layout, style, color) {
const pt = new class extends XmlComponent {
constructor() {
super("dgm:pt");
}
}();
pt["root"].push(chartAttr({
modelId: 0,
type: "doc"
}));
const prSet = new class extends XmlComponent {
constructor() {
super("dgm:prSet");
}
}();
prSet["root"].push(chartAttr({
loTypeId: `urn:microsoft.com/office/officeart/2005/8/layout/${layout}`,
loCatId: LAYOUT_CATEGORIES[layout] ?? "list",
qsTypeId: `urn:microsoft.com/office/officeart/2005/8/quickstyle/${style}`,
qsCatId: STYLE_CATEGORIES[style] ?? "simple",
csTypeId: `urn:microsoft.com/office/officeart/2005/8/colors/${color}`,
csCatId: COLOR_CATEGORIES[color] ?? "accent1",
phldr: "0"
}));
pt["root"].push(prSet);
pt["root"].push(new EmptyElement("dgm:spPr"));
pt["root"].push(createEmptyTextBody());
return pt;
}
function createEmptyTextBody() {
const t = new class extends XmlComponent {
constructor() {
super("dgm:t");
}
}();
t["root"].push(new EmptyElement("a:bodyPr"));
t["root"].push(new EmptyElement("a:lstStyle"));
t["root"].push(new EmptyElement("a:p"));
return t;
}
var EmptyElement = class extends XmlComponent {
constructor(tag) {
super(tag);
}
};
function uuid() {
return `{${crypto.randomUUID().toUpperCase()}}`;
}
/**
* Creates a DataModel from tree nodes with layout/style/color settings.
*/
const createDataModel = (nodes, layout = "default", style = "simple1", color = "accent1_2") => {
const points = [];
const connections = [];
points.push(createDocPoint(layout, style, color));
for (let i = 0; i < nodes.length; i++) {
const walk = (node, parentUuid, srcOrd) => {
const nodeUuid = uuid();
const parTransUuid = uuid();
const sibTransUuid = uuid();
const cxnUuid = uuid();
points.push(new TransPoint(parTransUuid, "parTrans", cxnUuid));
points.push(new TransPoint(sibTransUuid, "sibTrans", cxnUuid));
points.push(new Point(nodeUuid, node.text));
connections.push(new Connection(parTransUuid, parentUuid, nodeUuid, void 0, srcOrd, 0, parTransUuid, sibTransUuid));
if (node.children) for (let j = 0; j < node.children.length; j++) walk(node.children[j], nodeUuid, j);
};
walk(nodes[i], "0", i);
}
return new DataModel(points, connections);
};
//#endregion
export { DataModel as a, getColorXml as c, COLOR_CATEGORIES as d, LAYOUT_CATEGORIES as f, TransPoint as i, getLayoutXml as l, SmartArtCollection as n, Connection as o, STYLE_CATEGORIES as p, Point as r, DEFAULT_DRAWING_XML as s, createDataModel as t, getStyleXml as u };
import { a as Point, c as Connection, d as getLayoutXml, f as getStyleXml, h as STYLE_CATEGORIES, i as SmartArtData, l as DEFAULT_DRAWING_XML, m as LAYOUT_CATEGORIES, n as createDataModel, o as TransPoint, p as COLOR_CATEGORIES, r as SmartArtCollection, s as DataModel, t as TreeNode, u as getColorXml } from "../index-BDwL0MVx.js";
export { COLOR_CATEGORIES, Connection, DEFAULT_DRAWING_XML, DataModel, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, SmartArtData, TransPoint, TreeNode, createDataModel, getColorXml, getLayoutXml, getStyleXml };
import { a as DataModel, c as getColorXml, d as COLOR_CATEGORIES, f as LAYOUT_CATEGORIES, i as TransPoint, l as getLayoutXml, n as SmartArtCollection, o as Connection, p as STYLE_CATEGORIES, r as Point, s as DEFAULT_DRAWING_XML, t as createDataModel, u as getStyleXml } from "../smartart-DGNfjKA9.js";
export { COLOR_CATEGORIES, Connection, DEFAULT_DRAWING_XML, DataModel, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, TransPoint, createDataModel, getColorXml, getLayoutXml, getStyleXml };
//#region src/values.d.ts
/**
* Runtime validation and type conversion functions for OOXML specification values.
*
* This module provides runtime checks and cleanup for value types in the OOXML spec
* that aren't easily expressed through the TypeScript type system alone. These
* validators help prevent silent failures and corrupted documents by enforcing
* spec-compliant values at runtime.
*
* @module
*/
/**
* A measurement value with optional sign and unit suffix.
*
* Supports units: mm (millimeters), cm (centimeters), in (inches),
* pt (points), pc (picas), pi (picas).
*
* Pattern: `-?[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)`
*
* @example
* ```typescript
* const measure: UniversalMeasure = "10.5mm";
* const negative: UniversalMeasure = "-5pt";
* ```
*/
type UniversalMeasure = `${"-" | ""}${number}${"mm" | "cm" | "in" | "pt" | "pc" | "pi"}`;
/**
* A positive measurement value with unit suffix.
*
* Same as UniversalMeasure but restricted to positive values only.
*
* Reference: ST_PositiveUniversalMeasure in OOXML specification
*
* @example
* ```typescript
* const measure: PositiveUniversalMeasure = "10.5mm";
* ```
*/
type PositiveUniversalMeasure = `${number}${"mm" | "cm" | "in" | "pt" | "pc" | "pi"}`;
/**
* A percentage value with optional sign.
*
* Pattern: `-?[0-9]+(\.[0-9]+)?%`
*
* Reference: ST_Percentage in OOXML specification
*
* @example
* ```typescript
* const percent: Percentage = "50%";
* const negative: Percentage = "-10.5%";
* ```
*/
type Percentage = `${"-" | ""}${number}%`;
/**
* A positive percentage value.
*
* Same as Percentage but restricted to positive values only.
*
* Reference: ST_PositivePercentage in OOXML specification
*
* @example
* ```typescript
* const percent: PositivePercentage = "50%";
* ```
*/
type PositivePercentage = `${number}%`;
/**
* A relative measurement value using em or ex units.
*
* Used in VML text boxes for font-relative measurements.
*
* @example
* ```typescript
* const measure: RelativeMeasure = "2em";
* const negative: RelativeMeasure = "-0.5ex";
* ```
*/
type RelativeMeasure = `${"-" | ""}${number}${"em" | "ex"}`;
/**
* Validates and converts a number to an integer (decimal number).
*
* Reference: ST_DecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored integer value
* @throws Error if the value is NaN
*
* @example
* ```typescript
* const num = decimalNumber(10.7); // Returns 10
* const negative = decimalNumber(-5.3); // Returns -5
* ```
*/
declare const decimalNumber: (val: number) => number;
/**
* Validates and converts a number to a positive integer (unsigned decimal number).
*
* Reference: ST_UnsignedDecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored positive integer value
* @throws Error if the value is NaN or negative
*
* @example
* ```typescript
* const num = unsignedDecimalNumber(10.7); // Returns 10
* const invalid = unsignedDecimalNumber(-5); // Throws Error
* ```
*/
declare const unsignedDecimalNumber: (val: number) => number;
/**
* Validates and normalizes a hexadecimal binary value.
*
* The xsd:hexBinary type represents binary data as a sequence of binary octets
* using hexadecimal encoding, where each binary octet is a two-character
* hexadecimal number. Both lowercase and uppercase letters A-F are permitted.
*
* @param val - The hexadecimal string to validate
* @param length - The expected length in bytes (not characters)
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid hex string of the expected length
*
* @example
* ```typescript
* hexBinary("0FB8", 2); // Valid: 2 bytes = 4 characters
* hexBinary("ABC", 2); // Invalid: wrong length
* ```
*/
declare const hexBinary: (val: string, length: number) => string;
/**
* Validates a long hexadecimal number (4 bytes / 8 characters).
*
* Reference: ST_LongHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 8-character hex string
*
* @example
* ```typescript
* const hex = longHexNumber("ABCD1234"); // Valid
* ```
*/
declare const longHexNumber: (val: string) => string;
/**
* Validates a short hexadecimal number (2 bytes / 4 characters).
*
* Reference: ST_ShortHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 4-character hex string
*
* @example
* ```typescript
* const hex = shortHexNumber("AB12"); // Valid
* ```
*/
declare const shortHexNumber: (val: string) => string;
/**
* Validates a single-byte hexadecimal number (1 byte / 2 characters).
*
* Reference: ST_UcharHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 2-character hex string
*
* @example
* ```typescript
* const hex = uCharHexNumber("FF"); // Valid
* ```
*/
declare const uCharHexNumber: (val: string) => string;
/**
* Normalizes a universal measure value by parsing and reformatting.
*
* Ensures the numeric portion is properly formatted while preserving the unit.
*
* Reference: ST_UniversalMeasure in OOXML specification
*
* @param val - The universal measure string to normalize
* @returns The normalized universal measure
*
* @example
* ```typescript
* const measure = universalMeasureValue("10.500mm"); // Returns "10.5mm"
* ```
*/
declare const universalMeasureValue: (val: UniversalMeasure) => UniversalMeasure;
/**
* Validates and normalizes a positive universal measure value.
*
* Reference: ST_PositiveUniversalMeasure in OOXML specification
*
* @param val - The positive universal measure string to validate
* @returns The normalized positive universal measure
* @throws Error if the value is negative
*
* @example
* ```typescript
* const measure = positiveUniversalMeasureValue("10.5mm"); // Valid
* const invalid = positiveUniversalMeasureValue("-5mm"); // Throws Error
* ```
*/
declare const positiveUniversalMeasureValue: (val: PositiveUniversalMeasure) => PositiveUniversalMeasure;
/**
* Validates and normalizes a hexadecimal color value.
*
* Accepts either "auto" or a 6-character RGB hex value (with or without # prefix).
* The # prefix is commonly used but technically invalid in OOXML, so it is stripped
* for strict compliance.
*
* Reference: ST_HexColor in OOXML specification
*
* @param val - The color value to validate ("auto" or hex color)
* @returns The normalized color value
* @throws Error if the hex color is invalid
*
* @example
* ```typescript
* const color1 = hexColorValue("auto"); // Returns "auto"
* const color2 = hexColorValue("FF0000"); // Returns "FF0000"
* const color3 = hexColorValue("#00FF00"); // Returns "00FF00" (# stripped)
* ```
*/
declare const hexColorValue: (val: string) => string;
/**
* Validates a signed TWIP measurement value.
*
* Accepts either a universal measure string or a numeric TWIP value.
*
* Reference: ST_SignedTwipsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = signedTwipsMeasureValue("10mm");
* const measure2 = signedTwipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
declare const signedTwipsMeasureValue: (val: UniversalMeasure | number) => UniversalMeasure | number;
/**
* Validates a half-point (HPS) measurement value.
*
* Accepts either a positive universal measure string or a positive number.
* HPS (half-points) are commonly used for font sizes.
*
* Reference: ST_HpsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const fontSize1 = hpsMeasureValue("12pt");
* const fontSize2 = hpsMeasureValue(24); // 12pt in half-points
* ```
*/
declare const hpsMeasureValue: (val: PositiveUniversalMeasure | number) => string | number;
/**
* Validates a signed half-point (HPS) measurement value.
*
* Accepts either a universal measure string or a numeric value.
*
* Reference: ST_SignedHpsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const spacing1 = signedHpsMeasureValue("6pt");
* const spacing2 = signedHpsMeasureValue(-12); // Negative spacing
* ```
*/
declare const signedHpsMeasureValue: (val: UniversalMeasure | number) => string | number;
/**
* Validates a positive TWIP measurement value.
*
* Accepts either a positive universal measure string or a positive number.
*
* Reference: ST_TwipsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const width1 = twipsMeasureValue("25.4mm");
* const width2 = twipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
declare const twipsMeasureValue: (val: PositiveUniversalMeasure | number) => PositiveUniversalMeasure | number;
/**
* Normalizes a percentage value by parsing and reformatting.
*
* Reference: ST_Percentage in OOXML specification
*
* @param val - The percentage string to normalize
* @returns The normalized percentage
*
* @example
* ```typescript
* const percent = percentageValue("50.000%"); // Returns "50%"
* ```
*/
declare const percentageValue: (val: Percentage) => Percentage;
/**
* Validates a measurement value that can be expressed as a number, percentage, or universal measure.
*
* Reference: ST_MeasurementOrPercent in OOXML specification
*
* @param val - The measurement value (number, percentage, or universal measure)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = measurementOrPercentValue(100); // Unqualified number
* const measure2 = measurementOrPercentValue("50%"); // Percentage
* const measure3 = measurementOrPercentValue("10mm"); // Universal measure
* ```
*/
declare const measurementOrPercentValue: (val: number | Percentage | UniversalMeasure) => number | UniversalMeasure | Percentage;
/**
* Validates an eighth-point measurement value.
*
* Eighth-points are used for fine-grained measurements in text formatting.
*
* Reference: ST_EighthPointMeasure in OOXML specification
*
* @param val - The measurement value in eighth-points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const measure = eighthPointMeasureValue(16); // 2 points
* ```
*/
declare const eighthPointMeasureValue: (val: number) => number;
/**
* Validates a point measurement value.
*
* Reference: ST_PointMeasure in OOXML specification
*
* @param val - The measurement value in points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const fontSize = pointMeasureValue(12); // 12pt
* ```
*/
declare const pointMeasureValue: (val: number) => number;
/**
* Converts a JavaScript Date object to an ISO 8601 date-time string.
*
* The format is CCYY-MM-DDThh:mm:ss.sssZ where T is a literal and Z indicates UTC.
* This matches the xsd:dateTime format required by OOXML.
*
* Reference: ST_DateTime in OOXML specification
*
* @param val - The Date object to convert
* @returns An ISO 8601 formatted date-time string
*
* @example
* ```typescript
* const now = new Date();
* const timestamp = dateTimeValue(now); // Returns "2024-01-15T10:30:00.000Z"
* ```
*/
declare const dateTimeValue: (val: Date) => string;
/**
* Theme color values used throughout OOXML for referencing document theme colors.
*
* Reference: ST_ThemeColor in OOXML specification
*
* @publicApi
*/
declare const ThemeColor: {
readonly DARK1: "dark1";
readonly LIGHT1: "light1";
readonly DARK2: "dark2";
readonly LIGHT2: "light2";
readonly ACCENT1: "accent1";
readonly ACCENT2: "accent2";
readonly ACCENT3: "accent3";
readonly ACCENT4: "accent4";
readonly ACCENT5: "accent5";
readonly ACCENT6: "accent6";
readonly HYPERLINK: "hyperlink";
readonly FOLLOWED_HYPERLINK: "followedHyperlink";
readonly NONE: "none";
readonly BACKGROUND1: "background1";
readonly TEXT1: "text1";
readonly BACKGROUND2: "background2";
readonly TEXT2: "text2";
};
/**
* Theme font values used for referencing document theme fonts.
*
* Reference: ST_Theme in OOXML specification
*
* @publicApi
*/
declare const ThemeFont: {
readonly MAJOR_EAST_ASIA: "majorEastAsia";
readonly MAJOR_BIDI: "majorBidi";
readonly MAJOR_ASCII: "majorAscii";
readonly MAJOR_H_ANSI: "majorHAnsi";
readonly MINOR_EAST_ASIA: "minorEastAsia";
readonly MINOR_BIDI: "minorBidi";
readonly MINOR_ASCII: "minorAscii";
readonly MINOR_H_ANSI: "minorHAnsi";
};
//#endregion
export { uCharHexNumber as C, twipsMeasureValue as S, unsignedDecimalNumber as T, pointMeasureValue as _, ThemeColor as a, signedHpsMeasureValue as b, dateTimeValue as c, hexBinary as d, hexColorValue as f, percentageValue as g, measurementOrPercentValue as h, RelativeMeasure as i, decimalNumber as l, longHexNumber as m, PositivePercentage as n, ThemeFont as o, hpsMeasureValue as p, PositiveUniversalMeasure as r, UniversalMeasure as s, Percentage as t, eighthPointMeasureValue as u, positiveUniversalMeasureValue as v, universalMeasureValue as w, signedTwipsMeasureValue as x, shortHexNumber as y };
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./values-CyCW27--.js";
export { Percentage, PositivePercentage, PositiveUniversalMeasure, RelativeMeasure, ThemeColor, ThemeFont, UniversalMeasure, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber };
//#region src/values.ts
/**
* Validates and converts a number to an integer (decimal number).
*
* Reference: ST_DecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored integer value
* @throws Error if the value is NaN
*
* @example
* ```typescript
* const num = decimalNumber(10.7); // Returns 10
* const negative = decimalNumber(-5.3); // Returns -5
* ```
*/
const decimalNumber = (val) => {
if (isNaN(val)) throw new Error(`Invalid value '${val}' specified. Must be an integer.`);
return Math.floor(val);
};
/**
* Validates and converts a number to a positive integer (unsigned decimal number).
*
* Reference: ST_UnsignedDecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored positive integer value
* @throws Error if the value is NaN or negative
*
* @example
* ```typescript
* const num = unsignedDecimalNumber(10.7); // Returns 10
* const invalid = unsignedDecimalNumber(-5); // Throws Error
* ```
*/
const unsignedDecimalNumber = (val) => {
const value = decimalNumber(val);
if (value < 0) throw new Error(`Invalid value '${val}' specified. Must be a positive integer.`);
return value;
};
/**
* Validates and normalizes a hexadecimal binary value.
*
* The xsd:hexBinary type represents binary data as a sequence of binary octets
* using hexadecimal encoding, where each binary octet is a two-character
* hexadecimal number. Both lowercase and uppercase letters A-F are permitted.
*
* @param val - The hexadecimal string to validate
* @param length - The expected length in bytes (not characters)
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid hex string of the expected length
*
* @example
* ```typescript
* hexBinary("0FB8", 2); // Valid: 2 bytes = 4 characters
* hexBinary("ABC", 2); // Invalid: wrong length
* ```
*/
const hexBinary = (val, length) => {
const expectedLength = length * 2;
if (val.length !== expectedLength || isNaN(Number(`0x${val}`))) throw new Error(`Invalid hex value '${val}'. Expected ${expectedLength} digit hex value`);
return val;
};
/**
* Validates a long hexadecimal number (4 bytes / 8 characters).
*
* Reference: ST_LongHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 8-character hex string
*
* @example
* ```typescript
* const hex = longHexNumber("ABCD1234"); // Valid
* ```
*/
const longHexNumber = (val) => hexBinary(val, 4);
/**
* Validates a short hexadecimal number (2 bytes / 4 characters).
*
* Reference: ST_ShortHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 4-character hex string
*
* @example
* ```typescript
* const hex = shortHexNumber("AB12"); // Valid
* ```
*/
const shortHexNumber = (val) => hexBinary(val, 2);
/**
* Validates a single-byte hexadecimal number (1 byte / 2 characters).
*
* Reference: ST_UcharHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 2-character hex string
*
* @example
* ```typescript
* const hex = uCharHexNumber("FF"); // Valid
* ```
*/
const uCharHexNumber = (val) => hexBinary(val, 1);
/**
* Normalizes a universal measure value by parsing and reformatting.
*
* Ensures the numeric portion is properly formatted while preserving the unit.
*
* Reference: ST_UniversalMeasure in OOXML specification
*
* @param val - The universal measure string to normalize
* @returns The normalized universal measure
*
* @example
* ```typescript
* const measure = universalMeasureValue("10.500mm"); // Returns "10.5mm"
* ```
*/
const universalMeasureValue = (val) => {
const unit = val.slice(-2);
const amount = val.substring(0, val.length - 2);
return `${Number(amount)}${unit}`;
};
/**
* Validates and normalizes a positive universal measure value.
*
* Reference: ST_PositiveUniversalMeasure in OOXML specification
*
* @param val - The positive universal measure string to validate
* @returns The normalized positive universal measure
* @throws Error if the value is negative
*
* @example
* ```typescript
* const measure = positiveUniversalMeasureValue("10.5mm"); // Valid
* const invalid = positiveUniversalMeasureValue("-5mm"); // Throws Error
* ```
*/
const positiveUniversalMeasureValue = (val) => {
const value = universalMeasureValue(val);
if (parseFloat(value) < 0) throw new Error(`Invalid value '${value}' specified. Expected a positive number.`);
return value;
};
/**
* Validates and normalizes a hexadecimal color value.
*
* Accepts either "auto" or a 6-character RGB hex value (with or without # prefix).
* The # prefix is commonly used but technically invalid in OOXML, so it is stripped
* for strict compliance.
*
* Reference: ST_HexColor in OOXML specification
*
* @param val - The color value to validate ("auto" or hex color)
* @returns The normalized color value
* @throws Error if the hex color is invalid
*
* @example
* ```typescript
* const color1 = hexColorValue("auto"); // Returns "auto"
* const color2 = hexColorValue("FF0000"); // Returns "FF0000"
* const color3 = hexColorValue("#00FF00"); // Returns "00FF00" (# stripped)
* ```
*/
const hexColorValue = (val) => {
if (val === "auto") return val;
return hexBinary(val.charAt(0) === "#" ? val.substring(1) : val, 3);
};
/**
* Validates a signed TWIP measurement value.
*
* Accepts either a universal measure string or a numeric TWIP value.
*
* Reference: ST_SignedTwipsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = signedTwipsMeasureValue("10mm");
* const measure2 = signedTwipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
const signedTwipsMeasureValue = (val) => typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
/**
* Validates a half-point (HPS) measurement value.
*
* Accepts either a positive universal measure string or a positive number.
* HPS (half-points) are commonly used for font sizes.
*
* Reference: ST_HpsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const fontSize1 = hpsMeasureValue("12pt");
* const fontSize2 = hpsMeasureValue(24); // 12pt in half-points
* ```
*/
const hpsMeasureValue = (val) => typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
/**
* Validates a signed half-point (HPS) measurement value.
*
* Accepts either a universal measure string or a numeric value.
*
* Reference: ST_SignedHpsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const spacing1 = signedHpsMeasureValue("6pt");
* const spacing2 = signedHpsMeasureValue(-12); // Negative spacing
* ```
*/
const signedHpsMeasureValue = (val) => typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
/**
* Validates a positive TWIP measurement value.
*
* Accepts either a positive universal measure string or a positive number.
*
* Reference: ST_TwipsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const width1 = twipsMeasureValue("25.4mm");
* const width2 = twipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
const twipsMeasureValue = (val) => typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
/**
* Normalizes a percentage value by parsing and reformatting.
*
* Reference: ST_Percentage in OOXML specification
*
* @param val - The percentage string to normalize
* @returns The normalized percentage
*
* @example
* ```typescript
* const percent = percentageValue("50.000%"); // Returns "50%"
* ```
*/
const percentageValue = (val) => {
const percent = val.substring(0, val.length - 1);
return `${Number(percent)}%`;
};
/**
* Validates a measurement value that can be expressed as a number, percentage, or universal measure.
*
* Reference: ST_MeasurementOrPercent in OOXML specification
*
* @param val - The measurement value (number, percentage, or universal measure)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = measurementOrPercentValue(100); // Unqualified number
* const measure2 = measurementOrPercentValue("50%"); // Percentage
* const measure3 = measurementOrPercentValue("10mm"); // Universal measure
* ```
*/
const measurementOrPercentValue = (val) => {
if (typeof val === "number") return decimalNumber(val);
if (val.slice(-1) === "%") return percentageValue(val);
return universalMeasureValue(val);
};
/**
* Validates an eighth-point measurement value.
*
* Eighth-points are used for fine-grained measurements in text formatting.
*
* Reference: ST_EighthPointMeasure in OOXML specification
*
* @param val - The measurement value in eighth-points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const measure = eighthPointMeasureValue(16); // 2 points
* ```
*/
const eighthPointMeasureValue = unsignedDecimalNumber;
/**
* Validates a point measurement value.
*
* Reference: ST_PointMeasure in OOXML specification
*
* @param val - The measurement value in points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const fontSize = pointMeasureValue(12); // 12pt
* ```
*/
const pointMeasureValue = unsignedDecimalNumber;
/**
* Converts a JavaScript Date object to an ISO 8601 date-time string.
*
* The format is CCYY-MM-DDThh:mm:ss.sssZ where T is a literal and Z indicates UTC.
* This matches the xsd:dateTime format required by OOXML.
*
* Reference: ST_DateTime in OOXML specification
*
* @param val - The Date object to convert
* @returns An ISO 8601 formatted date-time string
*
* @example
* ```typescript
* const now = new Date();
* const timestamp = dateTimeValue(now); // Returns "2024-01-15T10:30:00.000Z"
* ```
*/
const dateTimeValue = (val) => val.toISOString();
/**
* Theme color values used throughout OOXML for referencing document theme colors.
*
* Reference: ST_ThemeColor in OOXML specification
*
* @publicApi
*/
const ThemeColor = {
DARK1: "dark1",
LIGHT1: "light1",
DARK2: "dark2",
LIGHT2: "light2",
ACCENT1: "accent1",
ACCENT2: "accent2",
ACCENT3: "accent3",
ACCENT4: "accent4",
ACCENT5: "accent5",
ACCENT6: "accent6",
HYPERLINK: "hyperlink",
FOLLOWED_HYPERLINK: "followedHyperlink",
NONE: "none",
BACKGROUND1: "background1",
TEXT1: "text1",
BACKGROUND2: "background2",
TEXT2: "text2"
};
/**
* Theme font values used for referencing document theme fonts.
*
* Reference: ST_Theme in OOXML specification
*
* @publicApi
*/
const ThemeFont = {
MAJOR_EAST_ASIA: "majorEastAsia",
MAJOR_BIDI: "majorBidi",
MAJOR_ASCII: "majorAscii",
MAJOR_H_ANSI: "majorHAnsi",
MINOR_EAST_ASIA: "minorEastAsia",
MINOR_BIDI: "minorBidi",
MINOR_ASCII: "minorAscii",
MINOR_H_ANSI: "minorHAnsi"
};
//#endregion
export { ThemeColor, ThemeFont, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber };
import { hpsMeasureValue } from "./values.js";
import { escapeXml, xml, xml2js } from "@office-open/xml";
//#region src/xml-components/base.ts
/**
* Base XML Component infrastructure for OOXML document generation.
*
* @module
*/
/**
* Abstract base class for all XML components.
*/
var BaseXmlComponent = class {
/** The XML element name for this component (e.g., "w:p" for paragraph). */
rootKey;
constructor(rootKey) {
this.rootKey = rootKey;
}
/**
* Direct XML serialization. Override in subclasses for zero-allocation output.
* Default falls back to prepForXml() + xml().
*/
toXml(context) {
const obj = this.prepForXml(context);
return obj ? xml(obj) : "";
}
};
//#endregion
//#region src/xml-components/component.ts
/**
* Core XML Component classes for building OOXML element trees.
*
* @module
*/
/**
* Empty object singleton used for empty XML elements.
*
* @internal
*/
const EMPTY_OBJECT = Object.seal({});
/**
* Base class for all XML components in OOXML documents.
*
* `toXml()` traverses the `root` array and calls `toXml()` on each
* `BaseXmlComponent` child — this avoids building the intermediate
* `IXmlableObject` tree. Inline `IXmlableObject` children fall back to
* `xml()` for serialization.
*/
var XmlComponent = class extends BaseXmlComponent {
/**
* Array of child components, text nodes, and attributes.
*/
root;
constructor(rootKey) {
super(rootKey);
this.root = [];
}
/**
* Prepares this component and its children for XML serialization.
*/
prepForXml(context) {
context.stack.push(this);
const children = [];
for (const comp of this.root) if (comp instanceof BaseXmlComponent) {
const prepared = comp.prepForXml(context);
if (prepared !== void 0) children.push(prepared);
} else children.push(comp);
context.stack.pop();
return { [this.rootKey]: children.length ? children.length === 1 && children[0] && typeof children[0] === "object" && "_attr" in children[0] ? children[0] : children : EMPTY_OBJECT };
}
/**
* Direct XML serialization — traverses `root` and calls `toXml()` on
* each child, concatenating the results into a single string.
*/
toXml(context) {
const childParts = [];
const attrParts = [];
for (const child of this.root) if (child instanceof BaseXmlComponent) {
const s = child.toXml(context);
if (s) childParts.push(s);
} else if (typeof child === "string") childParts.push(escapeXml(child));
else if (child != null && typeof child === "object") if ("_attr" in child) {
const a = child._attr;
for (const key of Object.keys(a)) attrParts.push(`${key}="${escapeXml(String(a[key]))}"`);
} else if ("_attributes" in child) {
const a = child._attributes;
for (const key of Object.keys(a)) attrParts.push(`${key}="${escapeXml(String(a[key]))}"`);
} else childParts.push(xml(child));
const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
const body = childParts.join("");
return body.length === 0 ? `<${this.rootKey}${attrStr}/>` : `<${this.rootKey}${attrStr}>${body}</${this.rootKey}>`;
}
/**
* @deprecated Internal use only.
*/
addChildElement(child) {
this.root.push(child);
return this;
}
};
/**
* XML component that is excluded from output if it has no meaningful content.
*/
var IgnoreIfEmptyXmlComponent = class extends XmlComponent {
includeIfEmpty;
constructor(rootKey, includeIfEmpty) {
super(rootKey);
this.includeIfEmpty = includeIfEmpty;
}
prepForXml(context) {
const result = super.prepForXml(context);
if (this.includeIfEmpty) return result;
if (result && (typeof result[this.rootKey] !== "object" || Object.keys(result[this.rootKey]).length)) return result;
}
/**
* Suppress empty elements — super.toXml() produces a self-closing tag
* (`<tag/>`) when there are no child elements; IgnoreIfEmpty returns ""
* in that case. Child components that already override toXml() (e.g.
* Worksheet) are unaffected.
*/
toXml(context) {
if (this.includeIfEmpty) return super.toXml(context);
const result = super.toXml(context);
return result.endsWith("/>") ? "" : result;
}
};
//#endregion
//#region src/xml-components/attributes.ts
/**
* XML attribute components for OOXML document generation.
*
* @module
*/
/**
* Base class for creating XML attributes with automatic name mapping.
*/
var XmlAttributeComponent = class extends BaseXmlComponent {
/** Optional mapping from property names to XML attribute names. */
xmlKeys;
constructor(root) {
super("_attr");
this.root = root;
}
prepForXml(_) {
const attrs = {};
Object.entries(this.root).forEach(([key, value]) => {
if (value !== void 0) {
const newKey = this.xmlKeys && this.xmlKeys[key] || key;
attrs[newKey] = value;
}
});
return { _attr: attrs };
}
};
/**
* Next-generation attribute component with explicit key-value pairs.
*/
var NextAttributeComponent = class extends BaseXmlComponent {
constructor(root) {
super("_attr");
this.root = root;
}
prepForXml(_) {
const attrs = {};
const values = Object.values(this.root);
for (let i = 0; i < values.length; i++) {
const { key, value } = values[i];
if (value !== void 0) attrs[key] = value;
}
return { _attr: attrs };
}
};
//#endregion
//#region src/xml-components/elements.ts
/**
* Simple XML element types for common OOXML patterns.
*
* @module
*/
/**
* Build an XML element with arbitrary attributes, filtering out undefined values.
*/
function attrObj(name, attrs) {
const filtered = {};
for (const [key, val] of Object.entries(attrs)) if (val !== void 0) filtered[key] = val;
return { [name]: { _attr: filtered } };
}
const ON_OFF_TRUE_CACHE = /* @__PURE__ */ new Map();
/**
* Build a CT_OnOff XML object without allocating any XmlComponent.
* `val=true` returns a frozen singleton (cached per name).
*/
function onOffObj(name, val = true) {
if (val === true) {
let cached = ON_OFF_TRUE_CACHE.get(name);
if (!cached) {
cached = Object.freeze({ [name]: Object.freeze({}) });
ON_OFF_TRUE_CACHE.set(name, cached);
}
return cached;
}
const ns = name.split(":")[0];
return { [name]: { _attr: { [`${ns}:val`]: val } } };
}
/**
* Build a CT_HpsMeasure XML object (half-point size) without allocation.
*/
function hpsMeasureObj(name, val) {
const ns = name.split(":")[0];
return { [name]: { _attr: { [`${ns}:val`]: hpsMeasureValue(val) } } };
}
/**
* Build a CT_String XML object (string value attribute) without allocation.
*/
function stringValObj(name, val) {
const ns = name.split(":")[0];
return { [name]: { _attr: { [`${ns}:val`]: val } } };
}
/**
* Build a numeric value attribute XML object without allocation.
*/
function numberValObj(name, val) {
const ns = name.split(":")[0];
return { [name]: { _attr: { [`${ns}:val`]: val } } };
}
/**
* Build a string enum value attribute XML object without allocation.
*/
function stringEnumValObj(name, val) {
const ns = name.split(":")[0];
return { [name]: { _attr: { [`${ns}:val`]: val } } };
}
/**
* Build an element wrapping a text string without allocation.
*/
function stringContainerObj(name, val) {
return { [name]: [val] };
}
/**
* XML element representing an empty element (CT_Empty).
*/
var EmptyElement = class extends XmlComponent {};
/**
* Flexible XML element builder with explicit attribute and child configuration.
*/
var BuilderElement = class extends XmlComponent {
constructor({ name, attributes, children }) {
super(name);
if (attributes) {
const attrs = {};
const vals = Object.values(attributes);
for (let i = 0; i < vals.length; i++) {
const { key, value } = vals[i];
if (value !== void 0) attrs[key] = value;
}
this.root.push({ _attr: attrs });
}
if (children) this.root.push(...children);
}
};
/**
* Creates a NextAttributeComponent with explicit XML attribute keys.
*/
const chartAttr = (attrs) => new NextAttributeComponent(Object.fromEntries(Object.entries(attrs).map(([key, value]) => [key, {
key,
value
}])));
/**
* Wraps a component in a named XmlComponent element.
*/
function wrapEl(elementName, child) {
const el = new class extends XmlComponent {
constructor(name) {
super(name);
}
}(elementName);
el["root"].push(child);
return el;
}
//#endregion
//#region src/xml-components/imported.ts
/**
* Imported XML Component module for handling external XML content.
*
* @module
*/
/**
* Converts an xml-js Element into an XmlComponent tree.
*/
const convertToXmlComponent = (element) => {
switch (element.type) {
case void 0:
case "element": {
const xmlComponent = new ImportedXmlComponent(element.name, element.attributes);
const childElements = element.elements || [];
for (const childElm of childElements) {
const child = convertToXmlComponent(childElm);
if (child !== void 0) xmlComponent.push(child);
}
return xmlComponent;
}
case "text": return element.text;
default: return;
}
};
/**
* XML component representing imported XML content.
*/
var ImportedXmlComponent = class extends XmlComponent {
_sourceXml;
static fromXmlString(importedContent) {
const xmlObj = xml2js(importedContent, { compact: false });
const component = convertToXmlComponent(xmlObj.elements?.[0] ?? xmlObj);
component._sourceXml = importedContent;
return component;
}
get sourceXml() {
return this._sourceXml;
}
toXml(_context) {
return this._sourceXml ?? super.toXml(_context);
}
constructor(rootKey, _attr) {
super(rootKey);
if (_attr) this.root.push({ _attr });
}
push(xmlComponent) {
this.root.push(xmlComponent);
}
};
/**
* Represents attributes for imported root elements.
*/
var ImportedRootElementAttributes = class extends XmlComponent {
constructor(_attr) {
super("");
this._attr = _attr;
}
prepForXml(_) {
return { _attr: this._attr };
}
};
//#endregion
//#region src/xml-components/initializable.ts
/**
* Initializable XML Component module.
*
* @module
*/
/**
* XML component that can be initialized from another component.
*/
var InitializableXmlComponent = class extends XmlComponent {
constructor(rootKey, initComponent) {
super(rootKey);
if (initComponent instanceof XmlComponent) this.root = initComponent.root;
}
};
//#endregion
export { XmlAttributeComponent as _, BuilderElement as a, XmlComponent as b, chartAttr as c, onOffObj as d, stringContainerObj as f, NextAttributeComponent as g, wrapEl as h, convertToXmlComponent as i, hpsMeasureObj as l, stringValObj as m, ImportedRootElementAttributes as n, EmptyElement as o, stringEnumValObj as p, ImportedXmlComponent as r, attrObj as s, InitializableXmlComponent as t, numberValObj as u, EMPTY_OBJECT as v, BaseXmlComponent as x, IgnoreIfEmptyXmlComponent as y };