@agile-team/mach-report 2.4.1 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +119 -13
  2. package/dist/ReportPreview-Dk-28QAi.js +2946 -0
  3. package/dist/ReportPreview-FSvcBLjH.cjs +6 -0
  4. package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
  5. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  6. package/dist/analytics.cjs +1 -0
  7. package/dist/analytics.d.cts +276 -0
  8. package/dist/analytics.d.ts +276 -0
  9. package/dist/analytics.js +223 -0
  10. package/dist/assets-66UBlhES.cjs +1 -0
  11. package/dist/assets-NVA_sftu.js +163 -0
  12. package/dist/capabilities-CNjIirfo.js +36 -0
  13. package/dist/capabilities-D4xeVYSR.cjs +1 -0
  14. package/dist/designer.cjs +1 -0
  15. package/dist/designer.d.cts +753 -0
  16. package/dist/designer.d.ts +753 -0
  17. package/dist/designer.js +372 -0
  18. package/dist/grid-geometry-BNptEcMm.js +65 -0
  19. package/dist/grid-geometry-CZ_cYB6O.cjs +1 -0
  20. package/dist/index.cjs +8 -5
  21. package/dist/index.d.cts +413 -8
  22. package/dist/index.d.ts +413 -8
  23. package/dist/index.js +1016 -1501
  24. package/dist/param-validation-BWNjLcN0.js +116 -0
  25. package/dist/param-validation-CiTxFeZ8.cjs +1 -0
  26. package/dist/pdf.cjs +48 -48
  27. package/dist/pdf.d.cts +111 -1
  28. package/dist/pdf.d.ts +111 -1
  29. package/dist/pdf.js +3931 -3868
  30. package/dist/{plugin-DwKr8oF6.cjs → plugin-BqBkn_kI.cjs} +1 -1
  31. package/dist/{plugin-CKnSVuVe.js → plugin-Ds10VnQO.js} +2 -2
  32. package/dist/render-plan-CckPEQyf.cjs +1 -0
  33. package/dist/{render-plan-CXBWRog4.js → render-plan-uzZYYSy1.js} +11 -10
  34. package/dist/report-params-B_VCihAh.js +12 -0
  35. package/dist/report-params-CjWrjPl6.cjs +1 -0
  36. package/dist/report-source-B9bENO0F.js +750 -0
  37. package/dist/report-source-BbNkkBDy.cjs +1 -0
  38. package/dist/server/node.d.cts +297 -0
  39. package/dist/server/node.d.ts +297 -0
  40. package/dist/server-node.cjs +1 -0
  41. package/dist/server-node.js +270 -0
  42. package/dist/server.cjs +1 -0
  43. package/dist/server.d.cts +643 -0
  44. package/dist/server.d.ts +643 -0
  45. package/dist/server.js +237 -0
  46. package/dist/style-CpwiOPyB.cjs +1 -0
  47. package/dist/style-Dv5o_x6b.js +67 -0
  48. package/dist/style.css +1 -1
  49. package/dist/template-registry-DWExx0gU.cjs +1 -0
  50. package/dist/template-registry-NpOakidD.js +354 -0
  51. package/dist/textwrap-CnGsEum6.cjs +4 -0
  52. package/dist/textwrap-DOl04hCQ.js +110 -0
  53. package/dist/validate-DfHPD8wX.cjs +1 -0
  54. package/dist/validate-S6CgIm5d.js +148 -0
  55. package/dist/vue/async.d.cts +694 -54
  56. package/dist/vue/async.d.ts +694 -54
  57. package/dist/vue/index.d.cts +1212 -111
  58. package/dist/vue/index.d.ts +1212 -111
  59. package/dist/vue-async.cjs +1 -1
  60. package/dist/vue-async.js +3 -3
  61. package/dist/vue.cjs +1 -1
  62. package/dist/vue.js +167 -80
  63. package/dist/worker.cjs +1 -0
  64. package/dist/worker.d.cts +302 -0
  65. package/dist/worker.d.ts +302 -0
  66. package/dist/worker.js +133 -0
  67. package/dist/xlsx/node.d.cts +47 -0
  68. package/dist/xlsx/node.d.ts +47 -0
  69. package/dist/xlsx-node.cjs +221 -0
  70. package/dist/xlsx-node.js +36409 -0
  71. package/dist/xlsx.cjs +20 -20
  72. package/dist/xlsx.d.cts +78 -1
  73. package/dist/xlsx.d.ts +78 -1
  74. package/dist/xlsx.js +5974 -5831
  75. package/package.json +62 -2
  76. package/dist/ReportPreview-BVTpw9Tb.cjs +0 -6
  77. package/dist/ReportPreview-XF8iSUG1.js +0 -1910
  78. package/dist/grid-geometry-BNIvw52m.cjs +0 -1
  79. package/dist/grid-geometry-C8hGoe9o.js +0 -130
  80. package/dist/render-plan-CCTL4F9v.cjs +0 -1
  81. package/dist/report-params-B3Fia6JO.js +0 -10
  82. package/dist/report-params-D1gZ1DME.cjs +0 -1
  83. package/dist/textwrap-nH0UYU6D.js +0 -108
  84. package/dist/textwrap-oD-t4b4B.cjs +0 -4
@@ -0,0 +1,276 @@
1
+ /**
2
+ * 列值格式化(声明式、JSON 可序列化)。
3
+ * 在 paginate 的 cellText 出口统一消费:格式化发生在进 RenderPlan 之前,
4
+ * 三后端(DOM/Canvas/PDF)零改动。
5
+ *
6
+ * 语义约定(v0.9 固化):
7
+ * - number.digits 显式给出 → 精确保留(12.5 + digits:2 → "12.50")
8
+ * - number.thousands 默认 false(千分位显式开启)
9
+ * - date 字符串按"本地时区的日历日"解析(YYYY-MM-DD / YYYY/MM/DD 直取年月日,
10
+ * 不经 Date 字符串构造——后者按 UTC 零点,负时区环境会少一天)
11
+ */
12
+ declare type ColumnFormat = {
13
+ kind: "number";
14
+ thousands?: boolean;
15
+ digits?: number;
16
+ } | {
17
+ kind: "percent";
18
+ digits?: number;
19
+ } | {
20
+ kind: "date";
21
+ pattern?: string;
22
+ };
23
+
24
+ declare type ComponentKind = "text" | "image" | "barcode" | "qrcode" | "chart" | "line" | "rect" | "ellipse";
25
+
26
+ declare interface ComponentStyle {
27
+ fontSizePx?: number;
28
+ fontSize?: number;
29
+ fontFamily?: string;
30
+ bold?: boolean;
31
+ italic?: boolean;
32
+ underline?: boolean;
33
+ color?: string;
34
+ backgroundColor?: string;
35
+ align?: "left" | "center" | "right" | "justify";
36
+ verticalAlign?: "top" | "middle" | "bottom";
37
+ lineColor?: string;
38
+ borderColor?: string;
39
+ lineWidthPt?: number;
40
+ borderTop?: boolean;
41
+ borderRight?: boolean;
42
+ borderBottom?: boolean;
43
+ borderLeft?: boolean;
44
+ lineHeight?: number;
45
+ letterSpacing?: number;
46
+ opacity?: number;
47
+ rotateDeg?: number;
48
+ }
49
+
50
+ export declare interface ComputationIssue {
51
+ rowIndex: number;
52
+ field: string;
53
+ message: string;
54
+ }
55
+
56
+ /** 纯数据计算与界面解耦;字段按声明顺序计算,可供后续字段引用,不修改输入数据。 */
57
+ export declare function computeDataset(input: readonly Record<string, unknown>[], options: ComputedDatasetOptions): {
58
+ rows: Record<string, unknown>[];
59
+ issues: ComputationIssue[];
60
+ };
61
+
62
+ export declare interface ComputedDatasetOptions {
63
+ fields: readonly ComputedField[];
64
+ formula?: FormulaAdapter;
65
+ maxRows?: number;
66
+ /** Calculated cells (rows × fields), default 2 million; at most 2048 field definitions. */
67
+ maxCells?: number;
68
+ signal?: AbortSignal;
69
+ onError?: "throw" | "null";
70
+ }
71
+
72
+ export declare interface ComputedField {
73
+ field: string;
74
+ expression: ReportExpression | string;
75
+ }
76
+
77
+ /** 轻量柱/折线图展开为共用基础图元,无外部图表依赖,DOM/Canvas/PDF 使用同一计划。 */
78
+ export declare function createChartComponents(options: ReportChartOptions): PlanComponent[];
79
+
80
+ /** 通用交叉聚合;合计直接累计原始度量,平均值不会错误地平均各分组合计。 */
81
+ export declare function createCrossTable(input: readonly Record<string, unknown>[], options: CrossTableOptions): CrossTableResult;
82
+
83
+ export declare interface CrossTableOptions {
84
+ rowField: string;
85
+ columnField: string;
86
+ valueField?: string;
87
+ aggregate?: "sum" | "count" | "avg" | "min" | "max";
88
+ totals?: boolean;
89
+ rowHeader?: string;
90
+ maxRows?: number;
91
+ maxColumns?: number;
92
+ maxInputRows?: number;
93
+ /** Dense output cells, including the dimension column and optional totals; default 2 million. */
94
+ maxCells?: number;
95
+ }
96
+
97
+ export declare interface CrossTableResult {
98
+ columns: TableTemplateColumn[];
99
+ rows: Record<string, unknown>[];
100
+ }
101
+
102
+ export declare interface FormulaAdapter {
103
+ /** 显式注入受信任的公式引擎;核心不执行 eval、宏或外部工作簿引用。 */
104
+ evaluate(expression: string, context: {
105
+ row: Readonly<Record<string, unknown>>;
106
+ rowIndex: number;
107
+ }): unknown;
108
+ }
109
+
110
+ declare interface GridCell {
111
+ text?: string;
112
+ rawText?: string;
113
+ /** 原始值,仅供 Excel raw 模式消费;不参与预览、分页与 PDF 绘制。 */
114
+ value?: string | number | boolean | null;
115
+ /** Excel 数字格式(例如 #,##0.00 / 0.00%),不改变 text。 */
116
+ numberFormat?: string;
117
+ /** 编辑输入类型;省略时只按原始值推断,数字字符串不会被转换为数值。 */
118
+ valueType?: "text" | "number" | "boolean";
119
+ /** 单元格级编辑控制;预览仍需显式开启 editing。 */
120
+ editable?: boolean;
121
+ source?: ReportCellSource;
122
+ /** Excel 公式保留元数据;当前引擎不计算公式,公式格始终只读。 */
123
+ formula?: string;
124
+ children?: PlanComponent[];
125
+ colSpan?: number;
126
+ rowSpan?: number;
127
+ style?: ComponentStyle;
128
+ }
129
+
130
+ /** auto:真实数字/显式数值格式居右,日期与布尔居中,其他内容居左。 */
131
+ declare type ListAlignment = NonNullable<ComponentStyle["align"]> | "auto";
132
+
133
+ declare interface ListColumn {
134
+ header: string;
135
+ field: string;
136
+ widthMm: number;
137
+ style?: ComponentStyle;
138
+ /** 内容对齐,优先于 style.align;数值字符串不会自动判为数字。 */
139
+ align?: ListAlignment;
140
+ /** 独立的表头对齐,不改变内容对齐。 */
141
+ headerAlign?: ComponentStyle["align"];
142
+ /** 独立的表头样式,优先于列表级表头样式。 */
143
+ headerStyle?: ComponentStyle;
144
+ /** 值格式化(声明式):千分位/小数位、百分比、日期 pattern */
145
+ format?: ColumnFormat;
146
+ /** 条件格式规则(声明式,命中合并进单元格样式;如负数红字) */
147
+ rules?: StyleRule[];
148
+ /** 内容列编辑控制;仍需由预览显式开启 editing,不影响表头/小计只读规则。 */
149
+ editable?: boolean;
150
+ /** 空值列或特殊数据类型可显式声明编辑输入类型。 */
151
+ valueType?: GridCell["valueType"];
152
+ /** 字段语义用于 auto 对齐;明确声明编号,避免把数字编号当成度量。 */
153
+ semanticRole?: "identifier" | "dimension" | "measure" | "date" | "text";
154
+ }
155
+
156
+ declare interface PlanComponent {
157
+ kind: ComponentKind;
158
+ leftMm: number;
159
+ topMm: number;
160
+ widthMm: number;
161
+ heightMm: number;
162
+ nid?: string;
163
+ rkey?: string;
164
+ text?: string;
165
+ rawText?: string;
166
+ lines?: string[];
167
+ richParagraphs?: RichParagraph[];
168
+ imageData?: string;
169
+ /** 明确指定线段方向;省略保持历史水平线行为。 */
170
+ lineDirection?: "down" | "up";
171
+ grid?: PlanGrid;
172
+ table?: PlanTableFragment;
173
+ style?: ComponentStyle;
174
+ meta?: Record<string, unknown>;
175
+ /** MachReport 扩展字段:未知 kind 的兜底渲染标记 */
176
+ fallbackText?: string;
177
+ }
178
+
179
+ declare interface PlanGrid {
180
+ /** 行内允许 null 空位;渲染器按空单元格处理 */
181
+ cells: (GridCell | null)[][];
182
+ colWidthsMm?: number[];
183
+ rowHeightsMm?: number[];
184
+ gapMm?: number;
185
+ /** 单元格四边内距;旧静态网格默认 0.5mm,分页列表使用其真实测量内距。 */
186
+ paddingMm?: number;
187
+ }
188
+
189
+ /** 列表的逻辑行来源;用于连续 Excel 重组,避免按文本猜测重复表头。 */
190
+ declare interface PlanTableFragment {
191
+ /** 在整个计划中唯一的逻辑表身份;同一表的分页片段共享身份。 */
192
+ id: string;
193
+ /** 表头固定 -1;其余行(包括组头/小计/总计)从 0 连续递增。 */
194
+ rowIndex: number;
195
+ role: "header" | "body" | "group-header" | "subtotal" | "grand-total";
196
+ /** 按物理列顺序保存字段身份;不以表头显示文本判断列结构。 */
197
+ columnKeys: string[];
198
+ layout?: "page" | "wide";
199
+ title?: string;
200
+ /** 只有宿主声明稳定 rowKey 时生成,不能用显示顺序替代业务主键。 */
201
+ source?: Omit<ReportCellSource, "field" | "rowKey"> & {
202
+ rowKey?: string | number;
203
+ };
204
+ }
205
+
206
+ /** 可持久化的业务身份与计划坐标独立;权限及并发校验仍由业务服务器执行。 */
207
+ declare interface ReportCellSource {
208
+ datasetId: string;
209
+ rowKey: string | number;
210
+ field: string;
211
+ revision?: string | number;
212
+ sourceToken?: string;
213
+ }
214
+
215
+ export declare interface ReportChartOptions {
216
+ type: "bar" | "line";
217
+ categories: readonly string[];
218
+ series: readonly ReportChartSeries[];
219
+ leftMm: number;
220
+ topMm: number;
221
+ widthMm: number;
222
+ heightMm: number;
223
+ title?: string;
224
+ showValues?: boolean;
225
+ }
226
+
227
+ export declare interface ReportChartSeries {
228
+ name: string;
229
+ values: readonly (number | null)[];
230
+ color?: string;
231
+ }
232
+
233
+ export declare type ReportExpression = {
234
+ field: string;
235
+ } | {
236
+ value: string | number | boolean | null;
237
+ } | {
238
+ op: "add" | "subtract" | "multiply" | "divide" | "coalesce";
239
+ args: readonly ReportExpression[];
240
+ };
241
+
242
+ declare interface RichParagraph {
243
+ segments: RichSegment[];
244
+ align?: ComponentStyle["align"];
245
+ lineHeight?: number;
246
+ spaceBeforeMm?: number;
247
+ spaceAfterMm?: number;
248
+ indentMm?: number;
249
+ }
250
+
251
+ declare interface RichSegment {
252
+ kind?: "text" | "field";
253
+ text?: string;
254
+ field?: string;
255
+ style?: ComponentStyle;
256
+ }
257
+
258
+ /** 条件格式规则求值(声明式,见 ListColumn.rules) */
259
+ declare interface StyleRule {
260
+ when: {
261
+ field: string;
262
+ op: ">" | ">=" | "<" | "<=" | "==" | "!=";
263
+ value: number | string;
264
+ };
265
+ /** 命中时合并进单元格样式(color/bold/backgroundColor 等) */
266
+ style: Record<string, unknown>;
267
+ }
268
+
269
+ /** 明细列:显式 widthMm 优先;纸张模式按 flex 分余量,宽表模式按 flex 放大基准列宽。 */
270
+ declare type TableTemplateColumn = Omit<ListColumn, "widthMm"> & {
271
+ widthMm?: number;
272
+ /** 自动列的宽度权重,默认 1(有 widthMm 时不参与分配)。 */
273
+ flex?: number;
274
+ };
275
+
276
+ export { }
@@ -0,0 +1,223 @@
1
+ const E = ["#2563eb", "#0d9488", "#d97706", "#7c3aed", "#dc2626", "#0284c7"];
2
+ function $(e) {
3
+ if (e.type !== "bar" && e.type !== "line") throw new Error("图表 type 应为 bar 或 line");
4
+ if (!Array.isArray(e.categories) || !Array.isArray(e.series) || !e.categories.length || e.categories.length > 200 || !e.series.length || e.series.length > 12) throw new Error("图表支持 1–200 个分类、1–12 个系列;大数据应先聚合");
5
+ if (e.categories.some((r) => typeof r != "string")) throw new Error("图表分类应为字符串");
6
+ z(e);
7
+ for (const r of e.series) L(r, e.categories.length);
8
+ }
9
+ function z(e) {
10
+ for (const r of ["leftMm", "topMm", "widthMm", "heightMm"])
11
+ if (!Number.isFinite(e[r]) || e[r] < 0) throw new Error(`${r} 应为有限非负数`);
12
+ if (e.widthMm < 45 || e.heightMm < 35) throw new Error("图表至少需要 45×35mm");
13
+ if (!Number.isFinite(e.leftMm + e.widthMm) || !Number.isFinite(e.topMm + e.heightMm)) throw new Error("图表几何范围溢出");
14
+ }
15
+ function L(e, r) {
16
+ if (!e || typeof e.name != "string" || !Array.isArray(e.values) || e.values.length !== r || e.values.some((t) => t !== null && !Number.isFinite(t))) throw new Error("图表系列应提供名称及逐分类的有限数字或 null");
17
+ if (e.color !== void 0 && !/^#[\da-f]{6}$/i.test(e.color)) throw new Error("图表颜色应为 #RRGGBB");
18
+ }
19
+ function F(e, r, t, n, i, l = 0.8) {
20
+ return { kind: "line", leftMm: Math.min(e, t), topMm: Math.min(r, n), widthMm: Math.abs(t - e), heightMm: Math.abs(n - r), lineDirection: n < r ? "up" : "down", style: { lineColor: i, lineWidthPt: l } };
21
+ }
22
+ function d(e, r, t, n, i = "center") {
23
+ return { kind: "text", text: e, leftMm: r, topMm: t, widthMm: n, heightMm: 5, style: { fontSize: 8, color: "#475569", align: i, verticalAlign: "middle" } };
24
+ }
25
+ function S(e) {
26
+ return Number(e.toPrecision(5)).toString();
27
+ }
28
+ function j(e) {
29
+ let r = 0, t = 0;
30
+ for (const h of e.series) for (const a of h.values) a !== null && (r = Math.min(r, a), t = Math.max(t, a));
31
+ r === t && (t = r + 1);
32
+ const n = e.leftMm + 13, i = e.topMm + 8, l = e.widthMm - 17, c = e.heightMm - 23, f = Math.max(Math.abs(r), Math.abs(t), 1), o = r / f, u = t / f - o;
33
+ return { left: n, top: i, width: l, height: c, min: r, max: t, y: (h) => i + c * (1 - (h / f - o) / u) };
34
+ }
35
+ function x(e, r) {
36
+ const t = [];
37
+ e.title && t.push({ ...d(e.title, e.leftMm, e.topMm, e.widthMm), style: { fontSize: 10, bold: !0, align: "left" } });
38
+ for (let l = 0; l <= 4; l++) {
39
+ const c = l / 4, f = r.min * (1 - c) + r.max * c, o = r.y(f);
40
+ t.push(F(r.left, o, r.left + r.width, o, "#e2e8f0", 0.4), d(S(f), e.leftMm, o - 2.5, 11, "right"));
41
+ }
42
+ t.push(F(r.left, r.top, r.left, r.top + r.height, "#94a3b8"));
43
+ const n = Math.max(1, Math.ceil(e.categories.length / Math.max(1, Math.floor(r.width / 14))));
44
+ e.categories.forEach((l, c) => {
45
+ c % n === 0 && t.push(d(l, r.left + (c + 0.5) * r.width / e.categories.length - 7, r.top + r.height + 1, 14));
46
+ });
47
+ const i = r.width / e.series.length;
48
+ return e.series.forEach((l, c) => {
49
+ t.push({ ...d(l.name, r.left + c * i, e.topMm + e.heightMm - 5, i), style: { fontSize: 8, color: l.color ?? E[c % E.length], align: "center" } });
50
+ }), t;
51
+ }
52
+ function P(e, r, t, n) {
53
+ const i = [], l = t.color ?? E[n % E.length], c = r.width / e.categories.length, f = c * 0.75 / e.series.length;
54
+ let o;
55
+ return t.values.forEach((u, h) => {
56
+ if (u === null) {
57
+ o = void 0;
58
+ return;
59
+ }
60
+ const a = r.left + (h + 0.5) * c, m = r.y(u);
61
+ e.type === "bar" ? i.push({ kind: "rect", leftMm: r.left + h * c + c * 0.125 + n * f, topMm: Math.min(m, r.y(0)), widthMm: f, heightMm: Math.abs(r.y(0) - m), style: { backgroundColor: l, borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } }) : (o && i.push(F(o.x, o.y, a, m, l, 1.2)), i.push({ kind: "ellipse", leftMm: a - 0.7, topMm: m - 0.7, widthMm: 1.4, heightMm: 1.4, style: { backgroundColor: l, borderColor: l } }), o = { x: a, y: m }), e.showValues && i.push({ ...d(S(u), a - c / 2, Math.max(r.top, m - 5), c), style: { fontSize: 7, color: l, align: "center" } });
62
+ }), i;
63
+ }
64
+ function U(e) {
65
+ $(e);
66
+ const r = j(e);
67
+ return [...x(e, r), ...e.series.flatMap((t, n) => P(e, r, t, n))];
68
+ }
69
+ function y() {
70
+ return { count: 0, sum: 0, correction: 0, min: 1 / 0, max: -1 / 0 };
71
+ }
72
+ function w(e, r) {
73
+ return Object.prototype.hasOwnProperty.call(e, r) ? e[r] : void 0;
74
+ }
75
+ function A(e) {
76
+ if (e == null) return "null";
77
+ if (typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("交叉表维度应为字符串、布尔、有限数字或空值");
78
+ return JSON.stringify([typeof e, e]);
79
+ }
80
+ function N(e) {
81
+ return e == null ? "" : String(e);
82
+ }
83
+ function W(e, r, t) {
84
+ const n = t === "count";
85
+ if (!n && r == null) return;
86
+ if (!n && (typeof r != "number" || !Number.isFinite(r))) throw new Error("交叉表度量必须是有限数字;编号和小数文本不能隐式转为数字");
87
+ const i = n ? 1 : r;
88
+ (t === "sum" || t === "avg") && _(e, i), e.count++, e.min = Math.min(e.min, i), e.max = Math.max(e.max, i);
89
+ }
90
+ function _(e, r) {
91
+ const t = r - e.correction, n = e.sum + t;
92
+ if (!Number.isFinite(n)) throw new Error("交叉表聚合溢出");
93
+ e.correction = n - e.sum - t, e.sum = n;
94
+ }
95
+ function b(e, r) {
96
+ return e?.count ? r === "count" ? e.count : r === "avg" ? e.sum / e.count : r === "sum" ? e.sum : e[r] : r === "count" ? 0 : null;
97
+ }
98
+ function M(e, r) {
99
+ const t = e ?? r;
100
+ if (!Number.isInteger(t) || t < 1) throw new Error("交叉表预算应为正整数");
101
+ return t;
102
+ }
103
+ function B(e, r, t, n) {
104
+ const i = t ? 1 : 0;
105
+ if ((e + i) * (r + 1 + i) > n) throw new Error("交叉表输出单元格超出 maxCells 预算,请减少维度或服务端预聚合");
106
+ }
107
+ function V(e, r) {
108
+ const t = r.aggregate ?? "sum";
109
+ if (!["sum", "count", "avg", "min", "max"].includes(t)) throw new Error("未知交叉表聚合类型");
110
+ if (!r.rowField || !r.columnField || t !== "count" && !r.valueField) throw new Error("交叉表需要明确的行维度、列维度和度量字段");
111
+ if (e.length > M(r.maxInputRows, 1e5)) throw new Error("交叉表输入超出预算,请在服务端预聚合");
112
+ const n = M(r.maxRows, 1e3), i = M(r.maxColumns, 200), l = M(r.maxCells, 2e6), c = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), u = y();
113
+ for (const a of e) {
114
+ const m = A(w(a, r.rowField)), s = A(w(a, r.columnField));
115
+ if (c.has(s) || c.set(s, N(w(a, r.columnField))), f.has(m) || f.set(m, { label: N(w(a, r.rowField)), cells: /* @__PURE__ */ new Map(), total: y() }), c.size > i || f.size > n) throw new Error("交叉表维度数量超出预算");
116
+ B(f.size, c.size, r.totals, l);
117
+ const g = f.get(m);
118
+ g.cells.has(s) || g.cells.set(s, y()), o.has(s) || o.set(s, y());
119
+ const k = r.valueField ? w(a, r.valueField) : void 0;
120
+ for (const R of [g.cells.get(s), g.total, o.get(s), u]) W(R, k, t);
121
+ }
122
+ const h = {
123
+ columns: [{ header: r.rowHeader ?? r.rowField, field: "rowLabel", semanticRole: "dimension" }, ...[...c.values()].map((a, m) => ({ header: a, field: `c${m}`, semanticRole: "measure" }))],
124
+ rows: [...f.values()].map((a) => ({ rowLabel: a.label, ...Object.fromEntries([...c.keys()].map((m, s) => [`c${s}`, b(a.cells.get(m), t)])), ...r.totals ? { total: b(a.total, t) } : {} }))
125
+ };
126
+ return r.totals && (h.columns.push({ header: "合计", field: "total", semanticRole: "measure" }), e.length && h.rows.push({ rowLabel: "合计", ...Object.fromEntries([...c.keys()].map((a, m) => [`c${m}`, b(o.get(a), t)])), total: b(u, t) })), h;
127
+ }
128
+ const G = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
129
+ function C(e) {
130
+ if (typeof e != "string" || !e.trim() || G.has(e)) throw new Error("计算字段应为安全的非空字段名");
131
+ }
132
+ function v(e) {
133
+ return e === null || ["string", "boolean"].includes(typeof e) || typeof e == "number" && Number.isFinite(e);
134
+ }
135
+ function I(e) {
136
+ if (e.some((r) => typeof r != "number" || !Number.isFinite(r))) throw new Error("算术参数必须是有限数字;空值和小数文本不会隐式转换");
137
+ return e;
138
+ }
139
+ function J(e, r) {
140
+ const t = I(r);
141
+ let n;
142
+ if (e === "add") n = t.reduce((i, l) => i + l, 0);
143
+ else if (e === "multiply") n = t.reduce((i, l) => i * l, 1);
144
+ else if (e === "subtract") n = t[0] - t[1];
145
+ else {
146
+ if (t[1] === 0) throw new Error("不能除以零");
147
+ n = t[0] / t[1];
148
+ }
149
+ if (!Number.isFinite(n)) throw new Error("计算结果不是有限数字");
150
+ return n;
151
+ }
152
+ function O(e, r, t = 0) {
153
+ if (++r.nodes > 256 || t > 16) throw new Error("计算表达式超出深度或节点预算");
154
+ if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("计算表达式应为声明式对象");
155
+ if ("field" in e) {
156
+ C(e.field);
157
+ const i = e.field;
158
+ return (l) => Object.prototype.hasOwnProperty.call(l, i) ? l[i] : void 0;
159
+ }
160
+ if ("value" in e) {
161
+ if (!v(e.value)) throw new Error("常量应为有限 JSON 标量");
162
+ return () => e.value;
163
+ }
164
+ if (!["add", "subtract", "multiply", "divide", "coalesce"].includes(e.op) || !Array.isArray(e.args)) throw new Error("未知计算操作");
165
+ if (e.args.length < 2 || ["subtract", "divide"].includes(e.op) && e.args.length !== 2) throw new Error("运算参数数量不正确");
166
+ const n = e.args.map((i) => O(i, r, t + 1));
167
+ return e.op === "coalesce" ? (i, l) => T(n, i, l) : (i, l) => J(e.op, n.map((c) => c(i, l)));
168
+ }
169
+ function T(e, r, t) {
170
+ for (const n of e) {
171
+ const i = n(r, t);
172
+ if (i != null) return i;
173
+ }
174
+ return null;
175
+ }
176
+ function D(e) {
177
+ const r = /* @__PURE__ */ new Set();
178
+ return e.fields.map((t) => {
179
+ if (C(t.field), r.has(t.field)) throw new Error(`计算字段重复:${t.field}`);
180
+ r.add(t.field);
181
+ const n = t.expression;
182
+ let i;
183
+ if (typeof n == "string") {
184
+ if (!e.formula) throw new Error("字符串公式需要显式配置 formula adapter");
185
+ i = (l, c) => e.formula.evaluate(n, { row: l, rowIndex: c });
186
+ } else i = O(n, { nodes: 0 });
187
+ return { field: t.field, read: i };
188
+ });
189
+ }
190
+ function H(e, r) {
191
+ const t = r.maxRows ?? 1e5, n = r.maxCells ?? 2e6;
192
+ if (!Array.isArray(e) || !Number.isSafeInteger(t) || t < 1 || e.length > t) throw new Error("计算数据行数超出预算或输入不是数组");
193
+ if (!Array.isArray(r.fields) || r.fields.length > 2048) throw new Error("计算字段应为数组且最多2048项");
194
+ if (!Number.isSafeInteger(n) || n < 1 || e.length * r.fields.length > n) throw new Error("计算单元格超出 maxCells 预算");
195
+ }
196
+ function q(e, r) {
197
+ H(e, r);
198
+ const t = D(r), n = [];
199
+ return { rows: e.map((l, c) => {
200
+ if (!l || typeof l != "object" || Array.isArray(l)) throw new Error(`第 ${c + 1} 行应为对象`);
201
+ if (r.signal?.aborted) {
202
+ const o = new Error("数据计算已取消");
203
+ throw o.name = "AbortError", o;
204
+ }
205
+ const f = { ...l };
206
+ for (const o of t)
207
+ try {
208
+ const u = o.read(f, c);
209
+ if (u !== void 0 && !v(u)) throw new Error("计算结果应为有限 JSON 标量,异步公式请先在数据源中求值");
210
+ f[o.field] = u ?? null;
211
+ } catch (u) {
212
+ const h = u instanceof Error ? u.message : String(u);
213
+ if (r.onError !== "null") throw Object.assign(new Error(`第 ${c + 1} 行 ${o.field}:${h}`), { cause: u });
214
+ f[o.field] = null, n.push({ rowIndex: c, field: o.field, message: h });
215
+ }
216
+ return f;
217
+ }), issues: n };
218
+ }
219
+ export {
220
+ q as computeDataset,
221
+ U as createChartComponents,
222
+ V as createCrossTable
223
+ };
@@ -0,0 +1 @@
1
+ "use strict";const h=require("./style-CpwiOPyB.cjs"),I=["borderTop","borderRight","borderBottom","borderLeft","borderColor","lineColor","lineWidthPt"];function M(t,e){const r=h.resolveBoxBorders(e.style),n=r.inner?[...t.edges]:[];r.top&&n.push({kind:"h",pos:0,from:0,to:e.widthMm}),r.bottom&&n.push({kind:"h",pos:e.heightMm,from:0,to:e.widthMm}),r.left&&n.push({kind:"v",pos:0,from:0,to:e.heightMm}),r.right&&n.push({kind:"v",pos:e.widthMm,from:0,to:e.heightMm});const o=h.resolveStroke(e.style);return n.map(s=>({...s,...o}))}function k(t,e,r){const n=t.get(e);(!n||r.widthPt>n.widthPt)&&t.set(e,r)}function w(t,e,r,n,o,s){const i=r<e.rows.length?e.rows[r].pos:e.rows[e.rows.length-1].pos+e.rows[e.rows.length-1].size;for(let c=n;c<o;c++){const d=e.columns[c];k(t,`h:${r}:${c}`,{kind:"h",pos:i,from:d.pos,to:d.pos+d.size,...s})}}function b(t,e,r,n,o,s){const i=r<e.columns.length?e.columns[r].pos:e.columns[e.columns.length-1].pos+e.columns[e.columns.length-1].size;for(let c=n;c<o;c++){const d=e.rows[c];k(t,`v:${r}:${c}`,{kind:"v",pos:i,from:d.pos,to:d.pos+d.size,...s})}}function v(t,e,r,n){const o=Math.min(e.columns.length,r.ci+(r.cell.colSpan??1)),s=Math.min(e.rows.length,r.ri+(r.cell.rowSpan??1)),i=h.mergeComponentStyles(n,r.cell.style),c=h.resolveBoxBorders(i),d=h.resolveStroke(i);c.top&&w(t,e,r.ri,r.ci,o,d),c.bottom&&w(t,e,s,r.ci,o,d),c.left&&b(t,e,r.ci,r.ri,s,d),c.right&&b(t,e,o,r.ri,s,d)}function A(t){const e=[...t.values()].sort((n,o)=>n.kind.localeCompare(o.kind)||n.pos-o.pos||n.from-o.from),r=[];for(const n of e){const o=r[r.length-1];o&&o.kind===n.kind&&o.pos===n.pos&&Math.abs(o.to-n.from)<1e-6&&o.color===n.color&&o.widthPt===n.widthPt?o.to=n.to:r.push({...n})}return r}function S(t,e){if(!t.cells.some(({cell:s})=>I.some(i=>s.style?.[i]!==void 0)))return M(t,e);const r=new Map,n=new Set,o=t.columns.length;for(const s of t.cells){v(r,t,s,e.style);const i=Math.min(t.rows.length,s.ri+(s.cell.rowSpan??1)),c=Math.min(o,s.ci+(s.cell.colSpan??1));for(let d=s.ri;d<i;d++)for(let a=s.ci;a<c;a++)n.add(d*o+a)}for(let s=0;s<t.rows.length;s++)for(let i=0;i<o;i++)n.has(s*o+i)||v(r,t,{ri:s,ci:i,cell:{}},e.style);return A(r)}class f extends Error{constructor(e,r){super(e.message),this.name="OutputAssetError",this.diagnostic=e,this.cause=r}}function p(t){if(t.aborted)throw t.reason??new DOMException("The operation was aborted.","AbortError")}function P(t,e){return p(e),new Promise((r,n)=>{const o=()=>n(e.reason??new DOMException("The operation was aborted.","AbortError"));e.addEventListener("abort",o,{once:!0}),Promise.resolve(t).then(r,n).finally(()=>e.removeEventListener("abort",o))})}function y(t){const e={maxAssets:1e3,maxImageBytes:33554432,maxTotalImageBytes:134217728,maxDurationMs:3e4,...t.assetBudget};for(const[r,n]of Object.entries(e))if(!Number.isSafeInteger(n)||n<=0||n>2147483647)throw new RangeError(`${r} must be a positive safe integer at most 2147483647.`);return e}function B(t){const e=/^data:image\/[a-z0-9.+-]+(;base64)?,(.*)$/is.exec(t);if(!e)throw new TypeError("Asset renderers must return an image data URL.");return e[1]?Math.ceil(e[2].length*3/4):new TextEncoder().encode(decodeURIComponent(e[2])).byteLength}function u(t,e,r,n,o){const s={code:r,message:n,severity:"warning",format:t.options.format??"dom",pageIndex:e.pageIndex,componentIndex:e.componentIndex,componentPath:e.componentPath,kind:e.component.kind,nid:e.component.nid};if(t.diagnostics.push(s),t.options.onDiagnostic?.(s),t.options.assetFailure!=="placeholder")throw new f(s,o)}async function D(t,e,r){const n=t.options.assetRenderers?.[e.kind];if(e.imageData||!n)return e.imageData;if(++t.rendered>t.budget.maxAssets)return u(t,r,"asset-budget-exceeded","Output exceeded the asset count budget.");let o;try{if(t.active=r,o=await P(n({...r,signal:t.signal}),t.signal),p(t.signal),o.length>t.budget.maxImageBytes*4+1024)return u(t,r,"asset-budget-exceeded","Output exceeded the image payload byte budget.");const s=B(o);if(s>t.budget.maxImageBytes||t.bytes+s>t.budget.maxTotalImageBytes)return u(t,r,"asset-budget-exceeded","Output exceeded the encoded image byte budget.");t.bytes+=s}catch(s){if(t.signal.aborted||s instanceof f)throw s;return u(t,r,"asset-render-failed",`Asset renderer failed for ${e.kind}; output was not silently omitted.`,s)}return o}function O(t,e){const r=t.active;if(!r){e.abort(new Error("Asset rendering exceeded maxDurationMs."));return}const n={code:"asset-budget-exceeded",message:"Asset rendering exceeded maxDurationMs.",severity:"warning",format:t.options.format??"dom",pageIndex:r.pageIndex,componentIndex:r.componentIndex,componentPath:r.componentPath,kind:r.component.kind,nid:r.component.nid};t.diagnostics.push(n);try{t.options.onDiagnostic?.(n)}catch(o){e.abort(o);return}e.abort(new f(n))}async function T(t,e,r,n,o){if(!e?.children?.length)return e;const s=[];for(const[i,c]of e.children.entries())s.push(await x(t,c,{...r,component:c,componentPath:[...n,i]},o));return s.some((i,c)=>i!==e.children[c])?{...e,children:s}:e}async function x(t,e,r,n){if(p(t.signal),n.has(e))throw new TypeError("Cyclic grid children cannot be rendered.");let o=t.cache.get(e);o||(o=D(t,e,r),t.cache.set(e,o));const s=await o;let i=e.grid;if(i){const c=new Set(n).add(e),d=[];for(const[a,m]of i.cells.entries()){const g=[];for(const[l,E]of m.entries())g.push(await T(t,E,r,[...r.componentPath,a,l],c));d.push(g)}d.some((a,m)=>a.some((g,l)=>g!==i.cells[m][l]))&&(i={...i,cells:d})}return s!==e.imageData||i!==e.grid?{...e,imageData:s,grid:i}:e}async function C(t,e={}){const r=y(e);if(e.signal?.aborted)throw e.signal.reason??new DOMException("The operation was aborted.","AbortError");const n=new AbortController,o=()=>n.abort(e.signal?.reason);if(e.signal?.addEventListener("abort",o,{once:!0}),!e.assetRenderers||!Object.keys(e.assetRenderers).length)return e.signal?.removeEventListener("abort",o),{plan:t,diagnostics:[]};const s={options:e,signal:n.signal,diagnostics:[],rendered:0,bytes:0,budget:r,cache:new WeakMap},i=setTimeout(()=>O(s,n),r.maxDurationMs);try{const c=[];for(const[d,a]of t.pages.entries()){if(d<(e.start??0)||d>(e.end??t.pages.length-1)){c.push(a);continue}const m=[];for(const[g,l]of a.components.entries())m.push(await x(s,l,{component:l,pageIndex:d,componentIndex:g,componentPath:[]},new Set));c.push(m.some((g,l)=>g!==a.components[l])?{...a,components:m}:a)}return{plan:c.some((d,a)=>d!==t.pages[a])?{...t,pages:c}:t,diagnostics:s.diagnostics}}finally{clearTimeout(i),e.signal?.removeEventListener("abort",o)}}exports.OutputAssetError=f;exports.resolveGridStrokes=S;exports.resolvePlanAssets=C;
@@ -0,0 +1,163 @@
1
+ import { d as v, c as k, e as M } from "./style-Dv5o_x6b.js";
2
+ const A = ["borderTop", "borderRight", "borderBottom", "borderLeft", "borderColor", "lineColor", "lineWidthPt"];
3
+ function S(n, e) {
4
+ const t = v(e.style), r = t.inner ? [...n.edges] : [];
5
+ t.top && r.push({ kind: "h", pos: 0, from: 0, to: e.widthMm }), t.bottom && r.push({ kind: "h", pos: e.heightMm, from: 0, to: e.widthMm }), t.left && r.push({ kind: "v", pos: 0, from: 0, to: e.heightMm }), t.right && r.push({ kind: "v", pos: e.widthMm, from: 0, to: e.heightMm });
6
+ const o = k(e.style);
7
+ return r.map((s) => ({ ...s, ...o }));
8
+ }
9
+ function x(n, e, t) {
10
+ const r = n.get(e);
11
+ (!r || t.widthPt > r.widthPt) && n.set(e, t);
12
+ }
13
+ function p(n, e, t, r, o, s) {
14
+ const i = t < e.rows.length ? e.rows[t].pos : e.rows[e.rows.length - 1].pos + e.rows[e.rows.length - 1].size;
15
+ for (let a = r; a < o; a++) {
16
+ const c = e.columns[a];
17
+ x(n, `h:${t}:${a}`, { kind: "h", pos: i, from: c.pos, to: c.pos + c.size, ...s });
18
+ }
19
+ }
20
+ function w(n, e, t, r, o, s) {
21
+ const i = t < e.columns.length ? e.columns[t].pos : e.columns[e.columns.length - 1].pos + e.columns[e.columns.length - 1].size;
22
+ for (let a = r; a < o; a++) {
23
+ const c = e.rows[a];
24
+ x(n, `v:${t}:${a}`, { kind: "v", pos: i, from: c.pos, to: c.pos + c.size, ...s });
25
+ }
26
+ }
27
+ function b(n, e, t, r) {
28
+ const o = Math.min(e.columns.length, t.ci + (t.cell.colSpan ?? 1)), s = Math.min(e.rows.length, t.ri + (t.cell.rowSpan ?? 1)), i = M(r, t.cell.style), a = v(i), c = k(i);
29
+ a.top && p(n, e, t.ri, t.ci, o, c), a.bottom && p(n, e, s, t.ci, o, c), a.left && w(n, e, t.ci, t.ri, s, c), a.right && w(n, e, o, t.ri, s, c);
30
+ }
31
+ function P(n) {
32
+ const e = [...n.values()].sort((r, o) => r.kind.localeCompare(o.kind) || r.pos - o.pos || r.from - o.from), t = [];
33
+ for (const r of e) {
34
+ const o = t[t.length - 1];
35
+ o && o.kind === r.kind && o.pos === r.pos && Math.abs(o.to - r.from) < 1e-6 && o.color === r.color && o.widthPt === r.widthPt ? o.to = r.to : t.push({ ...r });
36
+ }
37
+ return t;
38
+ }
39
+ function L(n, e) {
40
+ if (!n.cells.some(({ cell: s }) => A.some((i) => s.style?.[i] !== void 0))) return S(n, e);
41
+ const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), o = n.columns.length;
42
+ for (const s of n.cells) {
43
+ b(t, n, s, e.style);
44
+ const i = Math.min(n.rows.length, s.ri + (s.cell.rowSpan ?? 1)), a = Math.min(o, s.ci + (s.cell.colSpan ?? 1));
45
+ for (let c = s.ri; c < i; c++) for (let d = s.ci; d < a; d++) r.add(c * o + d);
46
+ }
47
+ for (let s = 0; s < n.rows.length; s++) for (let i = 0; i < o; i++)
48
+ r.has(s * o + i) || b(t, n, { ri: s, ci: i, cell: {} }, e.style);
49
+ return P(t);
50
+ }
51
+ class l extends Error {
52
+ constructor(e, t) {
53
+ super(e.message), this.name = "OutputAssetError", this.diagnostic = e, this.cause = t;
54
+ }
55
+ }
56
+ function u(n) {
57
+ if (n.aborted) throw n.reason ?? new DOMException("The operation was aborted.", "AbortError");
58
+ }
59
+ function y(n, e) {
60
+ return u(e), new Promise((t, r) => {
61
+ const o = () => r(e.reason ?? new DOMException("The operation was aborted.", "AbortError"));
62
+ e.addEventListener("abort", o, { once: !0 }), Promise.resolve(n).then(t, r).finally(() => e.removeEventListener("abort", o));
63
+ });
64
+ }
65
+ function D(n) {
66
+ const e = { maxAssets: 1e3, maxImageBytes: 33554432, maxTotalImageBytes: 134217728, maxDurationMs: 3e4, ...n.assetBudget };
67
+ for (const [t, r] of Object.entries(e))
68
+ if (!Number.isSafeInteger(r) || r <= 0 || r > 2147483647) throw new RangeError(`${t} must be a positive safe integer at most 2147483647.`);
69
+ return e;
70
+ }
71
+ function B(n) {
72
+ const e = /^data:image\/[a-z0-9.+-]+(;base64)?,(.*)$/is.exec(n);
73
+ if (!e) throw new TypeError("Asset renderers must return an image data URL.");
74
+ return e[1] ? Math.ceil(e[2].length * 3 / 4) : new TextEncoder().encode(decodeURIComponent(e[2])).byteLength;
75
+ }
76
+ function f(n, e, t, r, o) {
77
+ const s = { code: t, message: r, severity: "warning", format: n.options.format ?? "dom", pageIndex: e.pageIndex, componentIndex: e.componentIndex, componentPath: e.componentPath, kind: e.component.kind, nid: e.component.nid };
78
+ if (n.diagnostics.push(s), n.options.onDiagnostic?.(s), n.options.assetFailure !== "placeholder") throw new l(s, o);
79
+ }
80
+ async function O(n, e, t) {
81
+ const r = n.options.assetRenderers?.[e.kind];
82
+ if (e.imageData || !r) return e.imageData;
83
+ if (++n.rendered > n.budget.maxAssets) return f(n, t, "asset-budget-exceeded", "Output exceeded the asset count budget.");
84
+ let o;
85
+ try {
86
+ if (n.active = t, o = await y(r({ ...t, signal: n.signal }), n.signal), u(n.signal), o.length > n.budget.maxImageBytes * 4 + 1024) return f(n, t, "asset-budget-exceeded", "Output exceeded the image payload byte budget.");
87
+ const s = B(o);
88
+ if (s > n.budget.maxImageBytes || n.bytes + s > n.budget.maxTotalImageBytes) return f(n, t, "asset-budget-exceeded", "Output exceeded the encoded image byte budget.");
89
+ n.bytes += s;
90
+ } catch (s) {
91
+ if (n.signal.aborted || s instanceof l) throw s;
92
+ return f(n, t, "asset-render-failed", `Asset renderer failed for ${e.kind}; output was not silently omitted.`, s);
93
+ }
94
+ return o;
95
+ }
96
+ function T(n, e) {
97
+ const t = n.active;
98
+ if (!t) {
99
+ e.abort(new Error("Asset rendering exceeded maxDurationMs."));
100
+ return;
101
+ }
102
+ const r = { code: "asset-budget-exceeded", message: "Asset rendering exceeded maxDurationMs.", severity: "warning", format: n.options.format ?? "dom", pageIndex: t.pageIndex, componentIndex: t.componentIndex, componentPath: t.componentPath, kind: t.component.kind, nid: t.component.nid };
103
+ n.diagnostics.push(r);
104
+ try {
105
+ n.options.onDiagnostic?.(r);
106
+ } catch (o) {
107
+ e.abort(o);
108
+ return;
109
+ }
110
+ e.abort(new l(r));
111
+ }
112
+ async function C(n, e, t, r, o) {
113
+ if (!e?.children?.length) return e;
114
+ const s = [];
115
+ for (const [i, a] of e.children.entries())
116
+ s.push(await E(n, a, { ...t, component: a, componentPath: [...r, i] }, o));
117
+ return s.some((i, a) => i !== e.children[a]) ? { ...e, children: s } : e;
118
+ }
119
+ async function E(n, e, t, r) {
120
+ if (u(n.signal), r.has(e)) throw new TypeError("Cyclic grid children cannot be rendered.");
121
+ let o = n.cache.get(e);
122
+ o || (o = O(n, e, t), n.cache.set(e, o));
123
+ const s = await o;
124
+ let i = e.grid;
125
+ if (i) {
126
+ const a = new Set(r).add(e), c = [];
127
+ for (const [d, h] of i.cells.entries()) {
128
+ const g = [];
129
+ for (const [m, I] of h.entries()) g.push(await C(n, I, t, [...t.componentPath, d, m], a));
130
+ c.push(g);
131
+ }
132
+ c.some((d, h) => d.some((g, m) => g !== i.cells[h][m])) && (i = { ...i, cells: c });
133
+ }
134
+ return s !== e.imageData || i !== e.grid ? { ...e, imageData: s, grid: i } : e;
135
+ }
136
+ async function $(n, e = {}) {
137
+ const t = D(e);
138
+ if (e.signal?.aborted) throw e.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
139
+ const r = new AbortController(), o = () => r.abort(e.signal?.reason);
140
+ if (e.signal?.addEventListener("abort", o, { once: !0 }), !e.assetRenderers || !Object.keys(e.assetRenderers).length)
141
+ return e.signal?.removeEventListener("abort", o), { plan: n, diagnostics: [] };
142
+ const s = { options: e, signal: r.signal, diagnostics: [], rendered: 0, bytes: 0, budget: t, cache: /* @__PURE__ */ new WeakMap() }, i = setTimeout(() => T(s, r), t.maxDurationMs);
143
+ try {
144
+ const a = [];
145
+ for (const [c, d] of n.pages.entries()) {
146
+ if (c < (e.start ?? 0) || c > (e.end ?? n.pages.length - 1)) {
147
+ a.push(d);
148
+ continue;
149
+ }
150
+ const h = [];
151
+ for (const [g, m] of d.components.entries()) h.push(await E(s, m, { component: m, pageIndex: c, componentIndex: g, componentPath: [] }, /* @__PURE__ */ new Set()));
152
+ a.push(h.some((g, m) => g !== d.components[m]) ? { ...d, components: h } : d);
153
+ }
154
+ return { plan: a.some((c, d) => c !== n.pages[d]) ? { ...n, pages: a } : n, diagnostics: s.diagnostics };
155
+ } finally {
156
+ clearTimeout(i), e.signal?.removeEventListener("abort", o);
157
+ }
158
+ }
159
+ export {
160
+ l as O,
161
+ $ as a,
162
+ L as r
163
+ };