@agile-team/mach-report 2.20.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist/{ExcelBindingWizard-B7aeRg46.cjs → ExcelBindingWizard-B2xXBOJu.cjs} +1 -1
- package/dist/{ExcelBindingWizard-Chn6ZC2-.js → ExcelBindingWizard-CixTPQAL.js} +3 -3
- package/dist/{ParamEditor-BdFMa1CX.cjs → ParamEditor-DhHlNxai.cjs} +1 -1
- package/dist/{ParamEditor-o-7E7WZZ.js → ParamEditor-gKhvEsnr.js} +1 -1
- package/dist/{ReportBatchPanel-DVpmB7tG.cjs → ReportBatchPanel-BUdUfTdm.cjs} +1 -1
- package/dist/{ReportBatchPanel-CNJ4Useq.js → ReportBatchPanel-D-lyWKyf.js} +1 -1
- package/dist/ReportLabelStudio-BcjQt73a.cjs +1 -0
- package/dist/ReportLabelStudio-N2w6DdaZ.js +764 -0
- package/dist/{ReportPreview-CGcxwkAn.js → ReportPreview-BBJNlu2U.js} +8 -8
- package/dist/{ReportPreview-hlwvZ1wf.cjs → ReportPreview-nf4Dk1Jc.cjs} +2 -2
- package/dist/{ReportTemplateLibrary-DjjyZnZB.cjs → ReportTemplateLibrary-Cs9WKneQ.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-DyIJhJjX.js → ReportTemplateLibrary-WZl-AK-2.js} +1 -1
- package/dist/{RuleEditor-BeknHHOD.js → RuleEditor-DGpmjCko.js} +3 -3
- package/dist/RuleEditor-Dtcq-7LO.cjs +1 -0
- package/dist/{TemplateOutlinePanel-D6TXg1aV.cjs → TemplateOutlinePanel-CkCh506f.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-Bv8CxbXS.js → TemplateOutlinePanel-cxp95OT9.js} +1 -1
- package/dist/{TemplateReusePanel-CfousvPY.js → TemplateReusePanel-BZ8VTtrO.js} +2 -2
- package/dist/{TemplateReusePanel-wrSbd_mr.cjs → TemplateReusePanel-CwttuSta.cjs} +1 -1
- package/dist/{TemplateReviewPanel-BKFcSbTh.cjs → TemplateReviewPanel-C2YjiaEC.cjs} +1 -1
- package/dist/{TemplateReviewPanel-F2tqWNLO.js → TemplateReviewPanel-C9cTvsRs.js} +1 -1
- package/dist/artifact-integrity.json +90 -92
- package/dist/{assets-2eC3mOcV.js → assets-CxHunY_9.js} +2 -2
- package/dist/{assets-B0Hxn4l6.cjs → assets-vbjAGgk8.cjs} +1 -1
- package/dist/{auto-BlchZ1b8.js → auto-BkdGiNtr.js} +4 -4
- package/dist/{auto-B0EZFIK1.cjs → auto-Tq7ReIC1.cjs} +1 -1
- package/dist/{component-tree-CvW4lzpv.js → component-tree-1_QCiQJX.js} +1 -1
- package/dist/component-tree-BjZIp6w9.cjs +1 -0
- package/dist/{data-bar-PtjXhMgN.js → data-bar-8baGYEZ9.js} +1 -1
- package/dist/{data-bar-Ce38juRZ.cjs → data-bar-YltqGTaC.cjs} +1 -1
- package/dist/designer-CDqok4S5.cjs +2 -0
- package/dist/designer-CIDHt5xz.js +6869 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +25 -3
- package/dist/designer.d.ts +25 -3
- package/dist/designer.js +1 -1
- package/dist/{encoding-B--eZpp1.cjs → encoding-B79hW4zq.cjs} +1 -1
- package/dist/{encoding-mctOLocI.js → encoding-BSeUwrN7.js} +2 -2
- package/dist/{font-loader-DBBJ5KE9.cjs → font-loader-BB372_XN.cjs} +1 -1
- package/dist/{font-loader-DW8tIaNp.js → font-loader-Di0lQKFf.js} +1 -1
- package/dist/grid-geometry-D3SJgWFv.js +136 -0
- package/dist/grid-geometry-D8ReblRV.cjs +1 -0
- package/dist/index.cjs +6 -6
- package/dist/index.js +194 -195
- package/dist/json-snapshot-I5VI84Vp.cjs +2 -0
- package/dist/{json-snapshot-By4ZVVUt.js → json-snapshot-Kgn459Oj.js} +895 -879
- package/dist/{pdf-DqyxJ96U.cjs → pdf-CARdBcuw.cjs} +45 -45
- package/dist/{pdf-CKROKygt.js → pdf-DmlnL5eB.js} +13 -14
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-BMsIIJDh.cjs → plugin-BaRUGORD.cjs} +1 -1
- package/dist/{plugin-Co1oKD7T.js → plugin-D4kAxfLG.js} +1 -1
- package/dist/{prefill-D7EswyTI.cjs → prefill-Bpyn58AZ.cjs} +1 -1
- package/dist/{prefill-B8H9qwE4.js → prefill-CJSazcVY.js} +2 -2
- package/dist/{prepared-CGVphji3.cjs → prepared-BiSz_9vN.cjs} +1 -1
- package/dist/{prepared-BE-4jfX5.js → prepared-BwjwEzFz.js} +1 -1
- package/dist/{protocol-Cr81vFSQ.js → protocol-Bs9-ohHN.js} +3 -3
- package/dist/{protocol-ByRVzzQG.cjs → protocol-C8VWF9An.cjs} +1 -1
- package/dist/record-bindings-Ct1HkPrc.cjs +1 -0
- package/dist/{record-bindings-DEJtmo3p.js → record-bindings-VZGS-Qd8.js} +1 -1
- package/dist/{region-binding-workflow-CBg0l_tj.js → region-binding-workflow-Cy4GIOUo.js} +2 -2
- package/dist/{region-binding-workflow-D05tOYn3.cjs → region-binding-workflow-JNowHd0A.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/rich-text-layout-K48VHUoW.cjs +3 -0
- package/dist/{rich-text-layout-Ct5WrY1g.js → rich-text-layout-wxBhnAS7.js} +1 -1
- package/dist/{runtime-CEMvybO7.js → runtime-BDf5x1i1.js} +5 -5
- package/dist/runtime-DsJt1PIf.cjs +1 -0
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +4 -4
- package/dist/server-node.js +1272 -1274
- package/dist/server.cjs +1 -1
- package/dist/server.js +8 -8
- package/dist/style.css +1 -1
- package/dist/{template-catalog-CmbWOJqy.js → template-catalog-DFwIS9aN.js} +3 -3
- package/dist/{template-catalog-Utu4GP09.cjs → template-catalog-D_2jdnkL.cjs} +1 -1
- package/dist/template-fragments-DZVUBhuB.cjs +1 -0
- package/dist/{template-fragments-DWgo9tlZ.js → template-fragments-Dng-AlHk.js} +11 -11
- package/dist/{template-registry-BIhIHOab.js → template-registry-DhBqoD7W.js} +120 -118
- package/dist/template-registry-DpLUSLwF.cjs +1 -0
- package/dist/{column-visual-BpgQVWwT.js → template-serialization-Cc3h-miv.js} +74 -65
- package/dist/{column-visual-CtYxnBCP.cjs → template-serialization-D1R5oAqh.cjs} +1 -1
- package/dist/{textwrap-BEIg2w8y.js → textwrap-CkGjRFT3.js} +1 -1
- package/dist/textwrap-OTOUMr4f.cjs +4 -0
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +4 -4
- package/dist/{workbook-session-B94EwVa_.cjs → workbook-session-NYv01LHe.cjs} +1 -1
- package/dist/{workbook-session-BoScoOg-.js → workbook-session-oinxX3qo.js} +2 -2
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.js +204 -205
- package/package.json +1 -1
- package/dist/ReportLabelStudio-Drsm9sAS.cjs +0 -1
- package/dist/ReportLabelStudio-r8VFnhGQ.js +0 -589
- package/dist/RuleEditor-BVuRn_OQ.cjs +0 -1
- package/dist/component-tree-6TV7W6Yj.cjs +0 -1
- package/dist/designer-B52ddmHO.js +0 -6676
- package/dist/designer-Dtsw_rh7.cjs +0 -2
- package/dist/grid-geometry-BNptEcMm.js +0 -65
- package/dist/grid-geometry-CZ_cYB6O.cjs +0 -1
- package/dist/json-snapshot-jiXff4lc.cjs +0 -2
- package/dist/record-bindings-ehjnCDHt.cjs +0 -1
- package/dist/rich-text-layout-ALlMoYOG.cjs +0 -3
- package/dist/runtime-CDA6d263.cjs +0 -1
- package/dist/style-67OqfNed.js +0 -73
- package/dist/style-C22Pbv3T.cjs +0 -1
- package/dist/template-fragments-C_zSHJAa.cjs +0 -1
- package/dist/template-registry-DzWswQI5.cjs +0 -1
- package/dist/textwrap-BI-yJ6Wt.cjs +0 -4
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
function W(s, p) {
|
|
2
|
-
const i = s.length;
|
|
3
|
-
if (i === 0) return [];
|
|
4
|
-
const d = s.reduce((c, r) => c + r, 0), a = d > 0 && p > 0 ? p / d : 1, e = [];
|
|
5
|
-
let f = 0;
|
|
6
|
-
for (let c = 0; c < i; c++) {
|
|
7
|
-
const r = Math.max(0, s[c] * a);
|
|
8
|
-
e.push({ pos: f, size: r }), f += r;
|
|
9
|
-
}
|
|
10
|
-
return e;
|
|
11
|
-
}
|
|
12
|
-
function C(s, p, i) {
|
|
13
|
-
return s?.length ? W(s, p) : Array.from({ length: i }, (d, a) => ({
|
|
14
|
-
pos: p * a / i,
|
|
15
|
-
size: p / i
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
function b(s, p, i) {
|
|
19
|
-
const d = s.cells ?? [], a = Math.max(d.length, 1), e = s.colWidthsMm?.length ?? Math.max(1, ...d.map((t) => Array.isArray(t) ? t.length : 0)), f = C(s.colWidthsMm, p, e), c = (t) => t <= 0 ? 0 : t >= e ? f[f.length - 1].pos + f[f.length - 1].size : f[t].pos, r = C(s.rowHeightsMm, i, a), m = (t) => t <= 0 ? 0 : t >= a ? r[r.length - 1].pos + r[r.length - 1].size : r[t].pos, M = /* @__PURE__ */ new Set(), S = (t, n) => `${t}:${n}`, x = [], v = /* @__PURE__ */ new Set(), A = /* @__PURE__ */ new Set(), $ = (t, n) => `v${t}:${n}`, k = (t, n) => `h${t}:${n}`;
|
|
20
|
-
d.forEach((t, n) => {
|
|
21
|
-
if (!Array.isArray(t)) return;
|
|
22
|
-
let o = 0;
|
|
23
|
-
for (const u of t) {
|
|
24
|
-
for (; o < e && M.has(S(n, o)); ) o++;
|
|
25
|
-
if (o >= e) break;
|
|
26
|
-
const K = Math.max(1, Math.min(u?.colSpan ?? 1, e - o)), P = Math.max(1, u?.rowSpan ?? 1), g = Math.min(a, n + P), w = Math.min(e, o + K);
|
|
27
|
-
for (let l = n; l < g; l++)
|
|
28
|
-
for (let h = o; h < w; h++)
|
|
29
|
-
M.add(S(l, h));
|
|
30
|
-
for (let l = o + 1; l < w; l++)
|
|
31
|
-
for (let h = n; h < g; h++) v.add($(l, h));
|
|
32
|
-
for (let l = n + 1; l < g; l++)
|
|
33
|
-
for (let h = o; h < w; h++) A.add(k(l, h));
|
|
34
|
-
const E = c(o), B = m(n);
|
|
35
|
-
x.push({
|
|
36
|
-
ri: n,
|
|
37
|
-
ci: o,
|
|
38
|
-
cell: u ?? {},
|
|
39
|
-
xMm: E,
|
|
40
|
-
yMm: B,
|
|
41
|
-
widthMm: c(w) - E,
|
|
42
|
-
heightMm: m(g) - B
|
|
43
|
-
}), o = w;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const y = [];
|
|
47
|
-
for (let t = 1; t < e; t++) {
|
|
48
|
-
let n = -1;
|
|
49
|
-
for (let o = 0; o <= a; o++) {
|
|
50
|
-
const u = o < a && !v.has($(t, o));
|
|
51
|
-
u && n < 0 && (n = o), !u && n >= 0 && (y.push({ kind: "v", pos: c(t), from: m(n), to: m(o) }), n = -1);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
for (let t = 1; t < a; t++) {
|
|
55
|
-
let n = -1;
|
|
56
|
-
for (let o = 0; o <= e; o++) {
|
|
57
|
-
const u = o < e && !A.has(k(t, o));
|
|
58
|
-
u && n < 0 && (n = o), !u && n >= 0 && (y.push({ kind: "h", pos: m(t), from: c(n), to: c(o) }), n = -1);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return { columns: f, rows: r, cells: x, edges: y };
|
|
62
|
-
}
|
|
63
|
-
export {
|
|
64
|
-
b as r
|
|
65
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function L(s,i){const d=s.length;if(d===0)return[];const p=s.reduce((c,r)=>c+r,0),a=p>0&&i>0?i/p:1,e=[];let f=0;for(let c=0;c<d;c++){const r=Math.max(0,s[c]*a);e.push({pos:f,size:r}),f+=r}return e}function C(s,i,d){return s?.length?L(s,i):Array.from({length:d},(p,a)=>({pos:i*a/d,size:i/d}))}function P(s,i,d){const p=s.cells??[],a=Math.max(p.length,1),e=s.colWidthsMm?.length??Math.max(1,...p.map(t=>Array.isArray(t)?t.length:0)),f=C(s.colWidthsMm,i,e),c=t=>t<=0?0:t>=e?f[f.length-1].pos+f[f.length-1].size:f[t].pos,r=C(s.rowHeightsMm,d,a),m=t=>t<=0?0:t>=a?r[r.length-1].pos+r[r.length-1].size:r[t].pos,M=new Set,S=(t,n)=>`${t}:${n}`,v=[],x=new Set,A=new Set,$=(t,n)=>`v${t}:${n}`,k=(t,n)=>`h${t}:${n}`;p.forEach((t,n)=>{if(!Array.isArray(t))return;let o=0;for(const u of t){for(;o<e&&M.has(S(n,o));)o++;if(o>=e)break;const G=Math.max(1,Math.min(u?.colSpan??1,e-o)),K=Math.max(1,u?.rowSpan??1),g=Math.min(a,n+K),w=Math.min(e,o+G);for(let l=n;l<g;l++)for(let h=o;h<w;h++)M.add(S(l,h));for(let l=o+1;l<w;l++)for(let h=n;h<g;h++)x.add($(l,h));for(let l=n+1;l<g;l++)for(let h=o;h<w;h++)A.add(k(l,h));const E=c(o),B=m(n);v.push({ri:n,ci:o,cell:u??{},xMm:E,yMm:B,widthMm:c(w)-E,heightMm:m(g)-B}),o=w}});const y=[];for(let t=1;t<e;t++){let n=-1;for(let o=0;o<=a;o++){const u=o<a&&!x.has($(t,o));u&&n<0&&(n=o),!u&&n>=0&&(y.push({kind:"v",pos:c(t),from:m(n),to:m(o)}),n=-1)}}for(let t=1;t<a;t++){let n=-1;for(let o=0;o<=e;o++){const u=o<e&&!A.has(k(t,o));u&&n<0&&(n=o),!u&&n>=0&&(y.push({kind:"h",pos:m(t),from:c(n),to:c(o)}),n=-1)}}return{columns:f,rows:r,cells:v,edges:y}}exports.resolveGridLayout=P;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const re=require("./component-tree-6TV7W6Yj.cjs"),$=require("./style-C22Pbv3T.cjs"),j=require("./textwrap-BI-yJ6Wt.cjs"),P=require("./computed-4TnxzgIh.cjs"),E=require("./record-bindings-ehjnCDHt.cjs"),Be=require("./charts-aCtoswXq.cjs"),xe=require("./matrix-0hywp0-F.cjs"),oe=require("./grid-geometry-CZ_cYB6O.cjs"),V=require("./column-visual-CtYxnBCP.cjs"),K=require("./template-registry-DzWswQI5.cjs"),Bt=require("./report-params-VTg8MoCp.cjs"),He=require("./param-validation-C-8sRJLq.cjs"),Xe=require("./number-format-CZ2T_5kF.cjs"),Ee=require("./dataset-IrlXbUvh.cjs"),Ht=4096,Ve=128*1024;function Vt(e){const t=new Map;let r=0;return{measureMm(o,n){const a=JSON.stringify([o,n.fontSizePt,n.fontFamily,n.bold,n.italic,n.letterSpacingPt]),s=t.get(a);if(s!==void 0)return t.delete(a),t.set(a,s),s;const i=e.measureMm(o,n);if(Number.isFinite(i)&&a.length<=Ve){for(;t.size>=Ht||r+a.length>Ve;){const c=t.keys().next().value;r-=c.length,t.delete(c)}t.set(a,i),r+=a.length}return i}}}class H extends Error{constructor(t,r){super(`报表页数超出上限 ${t}(至少 ${r} 页)`),this.limit=t,this.actual=r,this.code="page-limit",this.name="PaginatePageLimitError"}}class J extends Error{constructor(t,r){super(`报表单元格数量超出上限 ${t}(至少 ${r} 格)`),this.limit=t,this.actual=r,this.code="cell-limit",this.name="PaginateCellLimitError"}}class q extends Error{constructor(t,r){super(`报表图表图元数量预计超出上限 ${t}(本次估算 ${r})`),this.limit=t,this.estimated=r,this.code="chart-component-limit",this.name="PaginateChartComponentLimitError"}}const Re=5e4;function ne(e=Re){if(!Number.isSafeInteger(e)||e<1||e>1e6)throw new RangeError("maxChartComponents 应为 1..1000000 的安全整数")}function Gt(e,t,r){const o=e.chartBinding;if(e.kind!=="chart"||e.grid||e.imageData||e.binding||e.pageAnchor)throw new TypeError("绑定图表不能同时设置图片、网格、记录绑定或页眉页脚");const n=Object.prototype.hasOwnProperty.call(t,o.dataset)?t[o.dataset]:void 0;if(!Array.isArray(n))throw new TypeError(`图表数据集 ${o.dataset} 未提供`);return{...xe.createReportChartData(n,o,r),type:o.type,leftMm:e.leftMm,topMm:e.topMm,widthMm:e.widthMm,heightMm:e.heightMm,title:o.title,showValues:o.showValues}}function _t(e,t,r=Re){ne(r);let o=0;return Object.assign(a=>{if(!a.chartBinding)return[a];const s=Gt(a,e,t),i=o+(s.categories.length?Be.chartComponentUpperBound(s):1);if(!Number.isSafeInteger(i))throw new RangeError("图表图元估算应为有限安全整数");if(i>r)throw new q(r,i);const c=s.categories.length?Be.createChartComponents(s):[{kind:"text",leftMm:a.leftMm,topMm:a.topMm,widthMm:a.widthMm,heightMm:a.heightMm,text:"—",style:{align:"center",verticalAlign:"middle",color:"#94a3b8",fontSize:10}}];return o+=c.length,c},{used:()=>o})}function Wt(e,t){return{member:"body",subtotal:"subtotal",total:"grand-total"}[e?.rows.get(t)?.kind??"member"]}function zt(e){const t=e.matrix;if(!t.hierarchy)return t;const r=new Map(e.columns.map(n=>[n.field,n.header])),o={sum:"求和",count:"计数",avg:"平均",min:"最小",max:"最大",weightedAvg:"加权平均"};return{...t,hierarchy:{...t.hierarchy,row:{...t.hierarchy.row,labels:t.hierarchy.row?.labels??t.rowFields.map(n=>r.get(n)??n)},column:{...t.hierarchy.column,labels:t.hierarchy.column?.labels??t.columnFields.map(n=>r.get(n)??n)}},measures:t.measures.map(n=>{const a=r.get(n.field)??r.get(n.valueField??n.field);return n.label===void 0&&a?{...n,label:`${a}(${o[n.op]})`}:n})}}function Jt(e,t){if(!e.matrix)return{list:e,rows:t};if(e.detail||e.groupBy||e.groups?.length||e.grandTotal)throw new Error("矩阵不能同时配置普通分组、总计或主从明细");const r=xe.createMatrixTable(t,zt(e)),o=r.columns.map(i=>({...i,widthMm:i.semanticRole==="dimension"?e.matrix.rowWidthMm??40:e.matrix.columnWidthMm??28,editable:!1,align:i.semanticRole==="dimension"?"center":"right"})),n={...e,columns:o,headerGrid:r.headerGrid,rowKey:void 0,revisionField:void 0,sourceTokenField:void 0};e.layout==="wide"&&(n.widthMm=o.reduce((i,c)=>i+c.widthMm,0));const a=r.metadata,s=a?{rows:new WeakMap(r.rows.map((i,c)=>[i,a.rows[c]])),header:{columns:a.columns,rowFields:a.rowFields,rowLabels:a.rowLabels,columnFields:a.columnFields,columnLabels:a.columnLabels}}:void 0;return{list:n,rows:r.rows,...s?{matrix:s}:{}}}function qt(e,t){if(!e.matrix?.hierarchy||!e.headerGrid)return e.headerGrid;const r=e.paddingMm??1,o=e.headerGrid.cells.map(()=>e.rowHeightMm??0),n=e.columns.map(c=>c.widthMm),a=oe.resolveGridLayout({...e.headerGrid,colWidthsMm:n},n.reduce((c,l)=>c+l,0),o.length),s=new WeakMap;for(const{cell:c,ci:l,ri:d,widthMm:f}of a.cells){const u={...E.resolveListHeaderStyle(e,e.columns[l]),...c.style},g=$.resolveFontSize(u).fontSizePt,v=(j.wrapText(c.text??"",Math.max(1,f-r*2),{fontSizePt:g,fontFamily:u.fontFamily,bold:u.bold,italic:u.italic,letterSpacingPt:u.letterSpacing},t).length*g*(u.lineHeight??$.LINE_HEIGHT)*25.4/72+r*2)/(c.rowSpan??1);for(let y=d;y<d+(c.rowSpan??1);y++)o[y]=Math.max(o[y]??0,v);s.set(c,u)}const i=e.headerGrid.cells.map(c=>c.map(l=>l?{...l,style:s.get(l)}:null));return{...e.headerGrid,cells:i,rowHeightsMm:o}}function Ut(e,t,r){const o=new Set,n=e.cells.map((a,s)=>{const i=[];let c=0;for(const l of a){for(;o.has(`${s}:${c}`);)c++;const d=l?.colSpan??1,f=l?.rowSpan??1;let u=0;for(let g=c;g<c+d;g++){t.has(g)&&u++;for(let m=s+1;m<s+f;m++)o.add(`${m}:${g}`)}u&&i.push(l?{...l,colSpan:u}:null),c+=d}return i});return{...e,cells:n,colWidthsMm:r}}function Ye(e){if(!e.columns.some(o=>o.hidden))return e;const t=new Set,r=e.columns.filter((o,n)=>o.hidden?!1:(t.add(n),!0));if(!r.length)throw new Error("列表至少需要一列可见列");return{...e,columns:r,...e.headerGrid?{headerGrid:Ut(e.headerGrid,t,r.map(o=>o.widthMm))}:{}}}function*Xt(e){const{page:t}=e;K.validateReportPageFlow(t.components,t.flow);let r=0,o=0;for(const n of K.reportFlowGroups(t.components,t.flow)){e.active();const a=n.band,s=n.components.some(d=>d.kind==="list"&&d.cardinality!=="record"),i=s?0:n.components.reduce((d,f)=>Math.max(d,f.topMm-a.topMm+(f.kind==="list"?e.height(f):f.heightMm)),a.heightMm);let c=Math.max(e.top(),o+a.topMm-r);if(!s&&i>e.bottom()-e.top()+.001)throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);!s&&c+i>e.bottom()+.001&&(e.nextPage(),yield*e.takePages(),e.active(),c=e.top());let l=c+i;for(const d of n.components){const f=c+d.topMm-a.topMm;d.kind==="list"?(yield*e.list(d,f,u=>{l=s?u:Math.max(l,u)}),e.active()):e.append({...d,topMm:f})}o=l,r=a.topMm+a.heightMm}}function Yt(e){return!!(e.computed?.length||e.groups?.length||e.groupBy||e.grandTotal||e.rowVisibleWhen||e.matrix||e.tree||e.detail||e.columns.some(t=>t.rules?.length||t.visibleWhen||t.visual))}function ae(e){return e.pages.some(t=>t.components.some(r=>r.kind==="list"?Yt(r):!!r.chartBinding))}const Qt=512,Ge=256*1024;function Zt(){const e=new Map;let t=0,r;return(o,n,a,s)=>{s!==r&&(e.clear(),t=0,r=s);const i=JSON.stringify([o,n,a.fontSizePt,a.fontFamily,a.bold,a.italic,a.letterSpacingPt]),c=e.get(i);if(c)return e.delete(i),e.set(i,c),c.lines.slice();const l=j.wrapText(o,n,a,s),d=i.length+l.reduce((f,u)=>f+u.length,0);if(d<=Ge){for(;e.size>=Qt||t+d>Ge;){const f=e.keys().next().value;t-=e.get(f).units,e.delete(f)}e.set(i,{lines:l.slice(),units:d}),t+=d}return l}}const Qe=1e4,_e=25e4;function Ce(e){if(e?.aborted)throw e.reason??new DOMException("标签生成已取消","AbortError")}function Ze(e,t,r){const o=typeof e.copies=="object"?E.readRecordScalar(t,e.copies.field,r):e.copies??1;if(typeof o!="number"||!Number.isSafeInteger(o)||o<1||o>1e3)throw new E.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}]`,"每条记录复制数必须是 1..1000 的数值型整数",r.rowIndex,typeof e.copies=="object"?e.copies.field:void 0);return o}function et(e,t,r){if(e.rowKey===void 0)return;const o=E.readRecordScalar(t,e.rowKey,r);if(typeof o=="string"&&o.trim()||typeof o=="number"&&Number.isFinite(o))return o;throw new E.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`,"业务主键必须是非空字符串或有限数字",r.rowIndex,e.rowKey)}function er(e){const t=r=>1+(r.grid?.cells.reduce((o,n)=>o+1+n.length+n.reduce((a,s)=>a+(s?.children?.reduce((i,c)=>i+t(c),0)??0),0),0)??0);return e.pages.reduce((r,o)=>r+o.components.reduce((n,a)=>n+t(a),0),0)}function tr(e,t,r){const o=e.repeat,n=Object.prototype.hasOwnProperty.call(t,o.dataset)?t[o.dataset]:void 0;if(!Array.isArray(n))throw new E.ReportBindingError(`$.datasets.${o.dataset}`,"逐记录标签数据集缺失,应提供对象数组(允许空数组)");const a=new Set,s=r.maxPages??Qe,i=er(e);let c=0,l=0;for(const[d,f]of n.entries()){if(Ce(r.signal),!f||typeof f!="object"||Array.isArray(f))throw new E.ReportBindingError(`$.datasets.${o.dataset}[${d}]`,"标签记录应为对象",d);const u={rowIndex:d,dataset:o.dataset},g=et(o,f,u);if(g!==void 0){const v=JSON.stringify([typeof g,g]);if(a.has(v))throw new E.ReportBindingError(`$.datasets.${o.dataset}[${d}].${o.rowKey}`,"业务主键重复;请先确认记录来源,避免重复打印标签",d,o.rowKey);a.add(v)}const m=Ze(o,f,u);if(c+=m*e.pages.length,l+=m*i,c>s)throw new H(s,c);if(l>_e)throw new E.ReportBindingError("$.repeat",`标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${_e},请分批生成`,d)}return n}function rr(e,t,r){if(!e.binding)return e;const{binding:o,...n}=e,a=E.resolveComponentBinding(o,t.row,t);if(e.kind==="image"){if(!a)return;if(!E.isLabelImageData(a))throw new E.ReportBindingError(`${r}.binding`,"图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换",t.rowIndex,o.field);return{...n,imageData:a}}return e.kind==="barcode"||e.kind==="qrcode"?(delete n.imageData,{...n,code:{...n.code,value:a},fallbackText:a}):(delete n.lines,delete n.richParagraphs,{...n,text:a})}function or(e,t,r){if(e.kind!=="text"||e.grid||e.richParagraphs?.length)return e;const o=e.style??{},n=$.resolveFontSize(o).fontSizePt,a=e.text??e.lines?.join(`
|
|
2
|
-
`)??"";if(a.length>16384)throw new E.ReportBindingError(r,"标签文本超过 16384 字符预算,请缩小字段内容",t.rowIndex);const s=t.wrapText(a,e.widthMm,{fontSizePt:n,bold:o.bold,italic:o.italic,fontFamily:o.fontFamily,letterSpacingPt:o.letterSpacing},t.options.measurer??j.heuristicMeasurer),i=s.length*n*$.resolveLineHeight(o)*25.4/72;if(i>e.heightMm+.05)throw new E.ReportBindingError(r,`标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`,t.rowIndex,e.binding?.field);return{...e,lines:s}}function tt(e,t,r){Ce(t.options.signal);const o=rr(e,t,r);if(!o)return;let n=o.grid;return n&&(n={...n,cells:n.cells.map((a,s)=>a.map((i,c)=>i?.children?.length?{...i,children:i.children.flatMap((l,d)=>{const f=tt(l,t,`${r}.grid.cells.${s}.${c}.children.${d}`);return f?[f]:[]})}:i))}),or(n===o.grid?o:{...o,grid:n},t,r)}function nr(e,t,r,o,n,a){return{...e,components:e.components.flatMap((s,i)=>{const c=tt(s,r,`$.pages.${t}.components.${i}`);return c?[{...c,meta:{...c.meta,labelSource:{pageIndex:t,componentIndex:i}}}]:[]}),meta:{...e.meta,record:{dataset:r.dataset,rowIndex:r.rowIndex,...a===void 0?{}:{rowKey:a},copyIndex:o,copyCount:n,templatePageIndex:t}}}}function*ar(e,t,r){const o=[];if(K.validateTemplateRepeat(e,o),o.length)throw new E.ReportBindingError(o[0].path,o[0].message);if(!e.repeat){for(const[i,c]of e.pages.entries())yield{page:c,pageIndex:i};return}const n=e.repeat,a=tr(e,t,r),s=Zt();for(const[i,c]of a.entries()){const l={row:c,rowIndex:i,dataset:n.dataset,options:r,wrapText:s},d=Ze(n,c,l),f=et(n,c,l);for(let u=0;u<d;u++)for(const[g,m]of e.pages.entries())Ce(r.signal),yield{page:nr(m,g,l,u,d,f),pageIndex:g}}}function sr(e){return{widthMm:e.widthMm,heightMm:e.heightMm,marginTopMm:e.marginTopMm??0,marginBottomMm:e.marginBottomMm??0,marginLeftMm:e.marginLeftMm??0,marginRightMm:e.marginRightMm??0,components:[]}}function Z(e,t){const r=t.heightMm-(e.layout==="wide"?t.marginBottomMm:e.marginBottomMm??t.marginBottomMm);return e.components.reduce((o,n)=>n.kind!=="list"&&n.pageAnchor==="footer"?Math.min(o,n.topMm):o,r)}function U(e){return e.components.reduce((t,r)=>r.kind!=="list"&&r.pageAnchor==="header"?Math.max(t,r.topMm+r.heightMm):t,0)}function rt(e,t){let r=e.textMetrics.get(t);if(!r){const o=$.resolveFontSize(t).fontSizePt;r={measureOptions:{fontSizePt:o,fontFamily:t.fontFamily??$.DEFAULT_FONT_FAMILY,italic:t.italic,bold:t.bold,letterSpacingPt:t.letterSpacing},lineMm:o*(t.lineHeight??$.LINE_HEIGHT)*25.4/72},e.textMetrics.set(t,r)}return r}function ir(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e}function Te(e,t,r=[],o){const n=e.fontSizePt??$.DEFAULT_FONT_PT,a=e.paddingMm??1,s=e.columns.map(h=>h.align??h.style?.align??e.align??"left"),i=e.columns.map((h,w)=>({...$.mergeComponentStyles({fontSize:n,verticalAlign:"middle"},h.style),align:s[w]==="auto"?"left":s[w]})),c=i.map((h,w)=>s[w]==="auto"?{left:h,center:{...h,align:"center"},right:{...h,align:"right"}}:void 0),l=e.columns.map((h,w)=>h.rules?.map(x=>{const I=c[w];if(I)return{left:$.mergeComponentStyles(I.left,x.style),center:$.mergeComponentStyles(I.center,x.style),right:$.mergeComponentStyles(I.right,x.style)};const T=$.mergeComponentStyles(i[w],x.style);return{left:T,center:T,right:T}})),d=e.columns.map(h=>E.resolveListHeaderStyle(e,h)),f=e.columns.map(h=>h.header);let u=e.rowHeightMm??0;for(let h=0;h<f.length;h++){const w=d[h],x=$.resolveFontSize(w).fontSizePt,I=j.wrapText(f[h],e.columns[h].widthMm-a*2,{fontSizePt:x,fontFamily:w.fontFamily??$.DEFAULT_FONT_FAMILY,italic:w.italic,bold:w.bold,letterSpacingPt:w.letterSpacing},t),T=x*(w.lineHeight??$.LINE_HEIGHT)*25.4/72;u=Math.max(u,Math.max(I.length,1)*T+a*2)}const g=f.map((h,w)=>({text:h,style:d[w]})),m=e.border===!1?{borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1}:{borderBottom:!0,borderLeft:!0,borderRight:!0,borderTop:!0},v=e.columns.map(h=>h.widthMm),y=cr(qt(e,t),v,{cells:[g],colWidthsMm:v,rowHeightsMm:[u],paddingMm:a});return{fontSizePt:n,paddingMm:a,visuals:V.createColumnVisualResolvers(e.columns,r,o),visibility:e.columns.map(h=>h.visibleWhen?P.compileReportPredicate(h.visibleWhen):void 0),ruleReaders:e.columns.map(h=>h.rules?.map(w=>P.compileReportPredicate(w.when))),cellStyles:i,autoStyles:c,ruleStyles:l,textMetrics:new WeakMap,numberFormats:e.columns.map(h=>E.toExcelNumberFormat(h.format)),derivedFields:new Set(e.computed?.map(h=>h.field)),borderStyle:m,headerHeightMm:y.rowHeightsMm.reduce((h,w)=>h+w,0),headerGrid:y,colWidthsMm:v,columns:e.columns}}function cr(e,t,r){if(!e)return r;if(!e.cells.length)throw new Error("自定义列表表头至少需要一行");const o=e.rowHeightsMm??e.cells.map(()=>r.rowHeightsMm[0]);if(o.length!==e.cells.length||o.some(n=>!Number.isFinite(n)||n<=0))throw new Error("自定义列表表头行高无效");return{...e,colWidthsMm:t,rowHeightsMm:o}}function lr(e,t,r){const o=t.format?.kind==="number"||t.format?.kind==="percent";t.valueType!==void 0?e.valueType=t.valueType:o&&(e.valueType="number"),t.editable!==void 0&&(e.editable=t.editable),(typeof e.value=="number"||e.value==null)&&r!==void 0&&(e.numberFormat=r)}function X(e,t,r){const o=e.columns,n=e.tree?.rows.get(t);let a=e.rowHeightFloorMm;const s=new Array(o.length);for(let i=0;i<o.length;i++){const c=o[i],l=e.visibility[i]?.(t)!==!1,d=l?t[c.field]:null,f=e.autoStyles[i]?E.resolveListAutoAlignment(d,c.format,c.semanticRole):"left";let u=e.autoStyles[i]?.[f]??e.cellStyles[i];if(c.rules){for(let x=0;x<c.rules.length;x++)if(e.ruleReaders[i][x](t)){u=e.ruleStyles[i][x][f];break}}const g=c.format?E.formatValue(d,c.format):E.listCellText(d),m=dr(e,c,n);u=ur(e,c,u,n);const v=rt(e,u),y=j.wrapText(g,Math.max(1,c.widthMm-e.paddingMm*2-m),v.measureOptions,r);a=Math.max(a,y.length*v.lineMm+e.paddingMm*2);const h=ir(d),w={text:g,style:u};d!=null&&e.visuals[i]?.apply(w,t),h!==void 0&&(w.value=h),lr(w,c,e.numberFormats[i]),fr(w,c,e,n,m),e.derivedFields.has(c.field)&&(w.derived=!0,w.editable=!1),l||(w.editable=!1),s[i]=w}return{grid:{cells:[s],colWidthsMm:e.colWidthsMm,rowHeightsMm:[a],paddingMm:e.paddingMm},heightMm:a,...e.matrix?{meta:{matrix:{row:e.matrix.rows.get(t)}}}:{}}}function dr(e,t,r){return!r||t.field!==e.tree.list.tree.labelField?0:E.listTreeIndent(e.tree.list,t,r,e.paddingMm)}function ur(e,t,r,o){return!o||t.field!==e.tree.list.tree.labelField||r.align==="left"?r:{...r,align:"left"}}function fr(e,t,r,o,n=0){o&&(n&&(e.indentMm=n),E.applyListTreeMetadata(e,t,o,r.tree.list))}function ot(e){if(e!=null&&typeof e!="string"&&typeof e!="boolean"&&!(typeof e=="number"&&Number.isFinite(e)))throw new Error("分组字段应为有限 JSON 标量");return JSON.stringify([typeof e,e??null])}function*nt(e,t,r=0){const o=t[r];if(!o){for(const a of e)yield{kind:"row",row:a};return}const n=new Map;for(const a of e){const s=ot(a[o.field]),i=n.get(s);i?i.push(a):n.set(s,[a])}for(const a of n.values())yield{kind:"groupHeader",label:(o.headerTemplate??"{value}").replace(/\{value\}/g,E.listCellText(a[0][o.field])),firstRow:a[0],group:o,depth:r,rows:a},yield*nt(a,t,r+1),(o.subtotal?.length||o.aggregates?.length)&&(yield{kind:"subtotal",label:o.subtotalLabel??"小计",rows:a,group:o,depth:r}),yield{kind:"groupEnd",depth:r}}function at(e,t,r,o=[]){const n=[...r.filter(a=>!o.some(s=>s.field===a)).map(a=>({field:a,op:"sum"})),...o];return new Map(n.map(a=>{const s=e.find(c=>c.field===a.field)?.format??{kind:"number",thousands:!0},i=P.aggregateRows(t,{...a,field:a.valueField??a.field});return[a.field,{text:E.formatValue(i,s),...i===null?{}:{value:i},...typeof i=="number"?{numberFormat:E.toExcelNumberFormat(s)}:{}}]}))}function st(e,t){const r=e.findIndex(o=>t.includes(o.field));return r<0?1:r}function z(e,t,r,o,n,a){const s=[],i=Math.max(0,Math.min(a,e.columns.length)),c=$.mergeComponentStyles({fontSize:e.fontSizePt},n);i&&s.push({text:r,colSpan:i,style:{bold:!0,...c}});for(let u=i;u<e.columns.length;u++){const g=e.columns[u],m=o.get(g.field),v=e.autoStyles[u]?.[E.resolveListAutoAlignment(m?.value,g.format)]??e.cellStyles[u];s.push({...m,text:m?.text??"",style:$.mergeComponentStyles(v,n)})}const l={text:r,colSpan:e.columns.length,style:{bold:!0,...c}},d=i?[s]:[[l],s],f=d.map(u=>mr(e,u,t));return{grid:{cells:d,colWidthsMm:e.colWidthsMm,rowHeightsMm:f,paddingMm:e.paddingMm},heightMm:f.reduce((u,g)=>u+g,0)}}function mr(e,t,r){let o=e.rowHeightFloorMm,n=0;for(const a of t){let s=0;const i=n+(a.colSpan??1);for(;n<i;n++)s+=e.colWidthsMm[n]??0;const c=rt(e,a.style),l=j.wrapText(a.text??"",s-e.paddingMm*2,c.measureOptions,r);o=Math.max(o,l.length*c.lineMm+e.paddingMm*2)}return o}function gr(e,t,r){const{templatePage:o,current:n,warnings:a,nextId:s,pushCurrent:i}=r,c=()=>Z(o,n),l=Math.max(n.marginTopMm,U(o)),d=o.layout==="wide"?U(o):l,f={id:r.tableId,columnKeys:e.columns.map(p=>p.field),...e.layout===void 0?{}:{layout:e.layout},...e.title===void 0?{}:{title:e.title}},u=new Map,g=new Map,m={kind:"rect",leftMm:e.leftMm,topMm:0,widthMm:e.widthMm,heightMm:t.headerHeightMm,grid:t.headerGrid,nid:s("listh"),table:{...f,role:"header",rowIndex:-1},style:t.borderStyle,...e.meta||t.matrix?{meta:{...e.meta,...t.matrix?{matrix:t.matrix.header}:{}}}:{}},v=p=>n.components.push({...m,topMm:p});if(r.flow&&e.header!==!1&&t.headerHeightMm>c()-l+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的表头高度超出单页可用范围`);let y=Math.max(r.startTop??e.topMm,l);e.header!==!1&&(v(y),y+=t.headerHeightMm+r.mmPerRow);function h(){const p=Math.max(r.flow||o.layout==="wide"?0:e.topMm,d);return(e.header!==!1&&e.headerEveryPage!==!1?p+t.headerHeightMm:d)+[...g.values()].reduce((S,k)=>S+k.heightMm,0)}function w(){const p=o.layout==="wide"?0:n.marginBottomMm;return Math.min(o.heightMm-p,Z(o,n))-h()}function x(p){if(y+p<=c())return;i(),n.components=[],n.heightMm=o.heightMm,o.layout==="wide"&&(n.marginTopMm=0,n.marginBottomMm=0);const b=Math.max(r.flow||o.layout==="wide"?0:e.topMm,d);e.header!==!1&&e.headerEveryPage!==!1?(v(b),y=b+t.headerHeightMm):y=d;for(const S of g.values())T(S,"listgr","group-header")}function I(p,b,S,k){const C=w();if(r.flow&&p.heightMm>C+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的单行高度超出单页可用范围`);p.heightMm>C&&a.push(`列表 ${e.id??e.dataset} 行高 ${p.heightMm.toFixed(2)}mm 超出单页可用高度 ${C.toFixed(2)}mm,预览与打印可能截断内容`),x(p.heightMm),T(p,b,S,k)}function T(p,b,S,k){const C=p.table?.id??f.id,F=S==="header"?-1:u.get(C)??0;S!=="header"&&u.set(C,F+p.grid.cells.length),n.components.push({kind:"rect",leftMm:e.leftMm,topMm:y,widthMm:e.widthMm,heightMm:p.heightMm,grid:p.grid,nid:s(b),table:{...f,...p.table,role:S,rowIndex:F,...k?{source:k}:{}},style:t.borderStyle,...e.meta||p.meta?{meta:{...e.meta,...p.meta}}:{}}),y+=p.heightMm}function N(p){p<=w()&&x(p)}return{keepTogether:N,placeGridRow:I,setGroupHeader:(p,b)=>{b?g.set(p,b):g.delete(p)},bottom:()=>y}}function hr(e,t){if(!e.rowKey)return;const r=t[e.rowKey];if((typeof r!="string"||!r.trim())&&!(typeof r=="number"&&Number.isFinite(r)))throw new Error(`数据集 ${e.dataset} 的 ${e.rowKey} 应为稳定的字符串或有限数字主键`);const o=e.revisionField?t[e.revisionField]:void 0,n=e.sourceTokenField?t[e.sourceTokenField]:void 0;if(o!==void 0&&typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o)))throw new Error("业务修订号应为字符串或有限数字");if(n!==void 0&&typeof n!="string")throw new Error("来源令牌应为字符串");return{datasetId:e.dataset,rowKey:r,...o===void 0?{}:{revision:o},...n===void 0?{}:{sourceToken:n}}}function se(e,t){const r=new Map;if(!e.rowKey)return r;const o=new Set;for(const n of t){const a=hr(e,n),s=JSON.stringify(a.rowKey);if(o.has(s))throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);o.add(s),r.set(n,a)}return r}function pr(e,t,r,o,n){if(!e.grandTotal)return;const a=typeof e.grandTotal=="object"?e.grandTotal:void 0,s=ie(e)[0],i=a?.fields??s?.subtotal??[],c=a?.aggregates??s?.aggregates??[];if(i.length===0&&c.length===0){o.warnings.push(`列表 ${e.id??""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);return}const l=z(r,o.measurer,a?.label??"合计",at(e.columns,t,i,c),a?.style??{},st(e.columns,[...i,...c.map(d=>d.field)]));n.placeGridRow(l,"listgt","grand-total")}function Y(e){if(e?.aborted){const t=new Error("报表排版已取消");throw t.name="AbortError",t}}function ie(e){const t=e.groups??(e.groupBy?[e.groupBy]:[]);if(t.length>16)throw new Error("列表最多支持 16 级分组");return t}function Pe(e){const t=Ye(e),r=t.columns.reduce((n,a)=>n+a.widthMm,0),o=r>t.widthMm?t.widthMm/r:1;return o===1?t:{...t,columns:t.columns.map(n=>({...n,widthMm:n.widthMm*o}))}}function wr(e,t,r){const o=e.detail;if(!o)return;const n=new Set;for(const l of t){const d=pe(l[o.parentKey]);if(n.has(d))throw new Error("主从明细的主表关联键重复");n.add(d)}const a=r.datasets[o.dataset]??[],s=new Map,i=[];for(const l of a){const d=l[o.foreignKey];if(!it(d)&&o.unmatched==="ignore")continue;const f=pe(d);if(!n.has(f)){if(o.unmatched!=="ignore")throw new Error(`明细数据集 ${o.dataset} 存在未关联的业务键`);continue}const u=s.get(f);u?u.push(l):s.set(f,[l]),i.push(l)}const c=Pe({...e,id:`${e.id??e.dataset}:detail`,dataset:o.dataset,rowKey:o.rowKey,revisionField:o.revisionField,sourceTokenField:o.sourceTokenField,computed:void 0,columns:o.columns,headerGrid:void 0,rowHeightMm:o.rowHeightMm??e.rowHeightMm,detail:void 0});return{list:c,inter:{...Te(c,r.measurer,i,r.signal),rowHeightFloorMm:c.rowHeightMm??0},rows:s,sources:se(c,i)}}function it(e){return typeof e=="string"&&!!e.trim()||typeof e=="number"&&Number.isFinite(e)}function pe(e){if(!it(e))throw new Error("主从关联键必须是非空字符串或有限数字");return ot(e)}function*yr(e,t,r,o,n){if(!r)return;const a=r.rows.get(pe(t[e.detail.parentKey]))??[];if(!a.length)return;const s={id:`${o.tableId}:detail`,columnKeys:r.list.columns.map(i=>i.field),title:e.detail.label};e.detail.label&&n.placeGridRow({...z(r.inter,o.measurer,e.detail.label,new Map,{},r.list.columns.length),table:s},"listdl","group-header"),e.detail.header!==!1&&n.placeGridRow({grid:r.inter.headerGrid,heightMm:r.inter.headerHeightMm,table:s},"listdh","header"),yield*o.takePages();for(const i of a)Y(o.signal),n.placeGridRow({...X(r.inter,i,o.measurer),table:s},"listdr","body",r.sources.get(i)),yield*o.takePages()}function ct(e){if(e.matrix||e.detail||e.groups?.length||e.groupBy||e.rowVisibleWhen)throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");if(e.rowKey&&e.rowKey!==e.tree.idField)throw new Error("树形布局的 rowKey 应与 idField 一致");if(!e.columns.some(t=>t.field===e.tree.labelField&&!t.hidden))throw new Error("树形布局需要可见的标签列");V.validateTreeComputed(e.tree,e.computed)}function br(e,t,r){ct(e);const o=V.createTreeTable(t,e.tree,{signal:r.signal,computed:e.computed?.length?{fields:e.computed,formula:r.formula}:void 0}),n={...e,rowKey:e.tree.idField},a=se(n,o.entries.map(c=>c.original)),s=new Map,i=new WeakMap;for(const c of o.entries)s.set(c.row,a.get(c.original)),i.set(c.row,c);return{list:n,rows:o.rows,sources:s,treeRows:i,totalRows:o.leaves}}function vr(e,t){if(e.cardinality==="record"){if(t.length>1)throw new Error(`单记录区域 ${e.id??e.dataset} 仅允许 0 或 1 行数据`);if(e.tree||e.matrix||e.detail||e.groups?.length||e.groupBy||e.grandTotal||e.rowVisibleWhen)throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");if(!t.length)return{list:{...e,columns:e.columns.map(r=>({...r,editable:!1}))},rows:[{}],sources:new Map}}}function lt(e,t,r){const o=r.prepared.get(e);if(o)return o;const n=vr(e,t);if(n)return r.prepared.set(e,n),n;if(e.tree){const c=br(e,t,r);return r.prepared.set(e,c),c}let a=e.computed?.length?P.computeDataset(t,{fields:e.computed,signal:r.signal,formula:r.formula}).rows:t;const s=a===t?void 0:new Map(a.map((c,l)=>[c,t[l]]));e.rowVisibleWhen&&(a=a.filter(P.compileReportPredicate(e.rowVisibleWhen)));const i=Jt(e,a);if(!e.matrix){const c=se(e,s?a.map(l=>s.get(l)):a);i.sources=s?new Map(a.map(l=>[l,c.get(s.get(l))])):c}return r.prepared.set(e,i),i}function Mr(e,t,r,o){if(!o.flow)return;const{current:n,templatePage:a}=o,s=Math.max(n.marginTopMm,U(a)),i=Math.max(o.startTop??e.topMm,s),c=(e.header===!1?0:t.headerHeightMm)+(r[0]?X(t,r[0],o.measurer).heightMm:0);i+c<=Z(a,n)+.001||i<=s+.001||(o.pushCurrent(),n.components=[],n.heightMm=a.heightMm,a.layout==="wide"&&(n.marginTopMm=0,n.marginBottomMm=0),o.startTop=Math.max(n.marginTopMm,U(a)))}function*Sr(e,t,r){const o=lt(e,t,r),n=o.rows;e=o.list,e.layout==="wide"&&(r.current.widthMm=Math.max(r.current.widthMm,e.leftMm+e.widthMm+r.current.marginRightMm));const a=o.sources??se(e,n),s=Pe(e),i=ie(s),c={...Te(s,r.measurer,n,r.signal),rowHeightFloorMm:s.rowHeightMm??0,matrix:o.matrix,...o.treeRows?{tree:{list:s,rows:o.treeRows}}:{}};Mr(s,c,n,r);const l=gr(s,c,r),d=wr(s,n,r);let f;for(const u of nt(n,i)){if(Y(r.signal),u.kind==="row")l.placeGridRow(f??X(c,u.row,r.measurer),"listr",Wt(o.matrix,u.row),a.get(u.row)),f=void 0,yield*r.takePages(),yield*yr(s,u.row,d,r,l);else if(u.kind==="groupHeader"){const g=z(c,r.measurer,u.label,new Map,u.group.headerStyle??{},s.columns.length);f??=X(c,u.firstRow,r.measurer);const m=i.slice(u.depth+1).reduce((v,y)=>v+z(c,r.measurer,(y.headerTemplate??"{value}").replace(/\{value\}/g,E.listCellText(u.firstRow[y.field])),new Map,y.headerStyle??{},s.columns.length).heightMm,0);u.group.keepWithNext!==!1&&l.keepTogether(g.heightMm+m+f.heightMm),l.placeGridRow(g,"listg","group-header"),u.group.repeatHeader&&l.setGroupHeader(u.depth,g)}else if(u.kind==="subtotal"){const g=u.group.subtotal??[],m=u.group.aggregates??[],v=z(c,r.measurer,u.label,at(s.columns,u.rows,g,m),u.group.subtotalStyle??{},st(s.columns,[...g,...m.map(y=>y.field)]));l.placeGridRow(v,"listst","subtotal")}else l.setGroupHeader(u.depth);yield*r.takePages()}pr(s,o.totalRows??n,c,r,l),r.finished?.(l.bottom()),yield*r.takePages()}function ce(e){return e.kind!=="list"&&(e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&(e.text.includes("{page}")||e.text.includes("{totalPages}")))}function le(e,t){return{...e,...e.text===void 0?{}:{text:t(e.text)},...e.lines?{lines:e.lines.map(t)}:{},...e.richParagraphs?{richParagraphs:e.richParagraphs.map(r=>({...r,segments:r.segments.map(o=>({...o,...o.text===void 0?{}:{text:t(o.text)}}))}))}:{},...e.grid?{grid:{...e.grid,cells:e.grid.cells.map(r=>r.map(o=>o?{...o,...o.text===void 0?{}:{text:t(o.text)},...o.children?{children:o.children.map(n=>le(n,t))}:{}}:null))}}:{}}}function xr(e){let t=!1;for(const r of e.pages)for(const o of r.components)ce(o)&&le(o,n=>(n.includes("{totalPages}")&&(t=!0),n));return t}function Er(e,t,r,o,n,a){const s={pageWidthMm:t.widthMm,pageHeightMm:t.heightMm,...e.layout===void 0?{}:{layout:e.layout},marginTopMm:t.marginTopMm,marginBottomMm:t.marginBottomMm,marginLeftMm:t.marginLeftMm,marginRightMm:t.marginRightMm,components:t.components,...e.meta?{meta:e.meta}:{}},i=c=>{const l=c.replace(/\{page\}/g,String(o));return a===void 0?l:l.replace(/\{totalPages\}/g,String(a))};for(const c of r)s.components.push(le(c,i));if(e.layout==="wide"){const c=s.components.reduce((l,d)=>Math.max(l,d.topMm+d.heightMm),0);s.marginBottomMm=n?e.marginBottomMm??0:0,s.pageHeightMm=Math.max(1,c+s.marginBottomMm)}return s}function ke(e){return e.cells.reduce((t,r)=>t+r.reduce((o,n)=>o+(n?1+(n.children?.reduce((a,s)=>a+dt(s),0)??0):0),0),0)}function dt(e){return e.grid?ke(e.grid):0}function Ie(e){for(const t of["maxPages","maxCells","knownTotalPages"])if(e[t]!==void 0&&(!Number.isSafeInteger(e[t])||e[t]<1))throw new RangeError(`${t} 应为正安全整数`);ne(e.maxChartComponents)}function Rr(e,t){const r=lt(e,t.datasets[e.dataset]??[],t),o=Pe(r.list),n={...Te(o,t.measurer,r.rows,t.signal),rowHeightFloorMm:o.rowHeightMm??0};return(o.header===!1?0:n.headerHeightMm)+r.rows.reduce((a,s)=>a+X(n,s,t.measurer).heightMm,0)}function*Cr(e){const{templatePage:t,current:r}=e,o=new Map(t.components.map((a,s)=>[a,s])),n=(a,s,i)=>{const c=e.datasets[a.dataset];return Array.isArray(c)||e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id??""} 输出为空`),Sr(a,Array.isArray(c)?c:[],{...e,tableId:`${e.tableId}:${o.get(a)}`,startTop:s,finished:i,flow:!!t.flow})};if(t.flow){yield*Xt({page:t,active:()=>Y(e.signal),top:()=>Math.max(r.marginTopMm,U(t)),bottom:()=>Z(t,r),append:a=>{r.components.push(...e.resolveChart(a))},nextPage:()=>{e.pushCurrent(),r.components=[],r.heightMm=t.heightMm,t.layout==="wide"&&(r.marginTopMm=0,r.marginBottomMm=0)},takePages:e.takePages,height:a=>Rr(a,e),list:n});return}for(const a of t.components)ce(a)||(a.kind==="list"?yield*n(a):r.components.push(...e.resolveChart(a)))}function*ee(e,t,r,o,n,a=new WeakMap,s){let i=0,c=0,l=0;const d=Vt(r.measurer??j.heuristicMeasurer),f=_t(t,r.signal,r.maxChartComponents),u=g=>`${g}_${(++i).toString(36)}`;for(const{pageIndex:g,page:m}of ar(e,t,r)){Y(r.signal);const v=sr(m),y=m.components.filter(ce);let h=[];const w=(I=!1)=>{if(Y(r.signal),r.maxPages!==void 0&&c>=r.maxPages)throw new H(r.maxPages,c+1);if(r.maxCells!==void 0&&(l+=[...v.components,...y].reduce((T,N)=>T+dt(N),0),l>r.maxCells))throw new J(r.maxCells,l);h.push(Er(m,v,y,++c,I,n))},x=()=>{const I=h;return h=[],I};yield*Cr({templatePage:m,current:v,warnings:o,nextId:u,pushCurrent:w,takePages:x,datasets:t,resolveChart:f,signal:r.signal,formula:r.formula,prepared:a,measurer:d,mmPerRow:r.mmPerRow??0,tableId:`table:${g}`}),w(!0),yield*x()}s&&(s.chartComponents=f.used())}function Tr(e,t,r={}){Ie(r);let o=0;for(const n of ee(e,t,{...r,onWarning:void 0},[]))o++;return o}function*Pr(e,t,r={}){yield*ut(e,t,r)}function*ut(e,t,r,o){Ie(r);const n=xr(e),a=new WeakMap;let s=r.knownTotalPages;if(n&&s===void 0){s=0;for(const l of ee(e,t,r,[],void 0,a))s++}const i=[];let c=0;for(const l of ee(e,t,r,i,s,a,o)){for(;c<i.length;c++)r.onWarning?.(i[c]);yield l}}function $e(e,t,r={}){const o=typeof r=="number"?{mmPerRow:r}:r;Ie(o);const n=[],a={chartComponents:0},s=[...ee(e,t,o,n,o.knownTotalPages,void 0,a)];for(const i of s)i.components=i.components.map(c=>ce(c)?le(c,l=>l.replace(/\{totalPages\}/g,String(s.length))):c);return n.forEach(i=>o.onWarning?.(i)),{plan:{schemaVersion:re.RENDER_PLAN_SCHEMA_VERSION,...ae(e)?{requiresRecalculation:!0}:{},pages:s},warnings:n,...a}}function kr(e){const t=e.columns.find(a=>!a.hidden)?.field;if(!t)return{groups:0,total:0};const r=ie(e),o=(a=[],s=[])=>a.includes(t)||s.some(i=>i.field===t),n=typeof e.grandTotal=="object"?e.grandTotal:void 0;return{groups:r.filter(a=>o(a.subtotal,a.aggregates)).length,total:Number(o(n?.fields??r[0]?.subtotal,n?.aggregates??r[0]?.aggregates))}}function Ir(e,t,r){ct(e);const o=V.flattenTreeInput(t[e.dataset]??[],e.tree,r),n=e.columns.filter(s=>!s.hidden).length,a=e.header===!1?0:e.headerGrid?ke(e.headerGrid):n;return o.length*n+a+ +!!e.grandTotal*2*n}function $r(e,t,r={}){if(e.tree)return Ir(e,t,r.signal);if(e.matrix){let c=t[e.dataset]??[];e.computed?.length&&(c=P.computeDataset(c,{fields:e.computed,...r}).rows),e.rowVisibleWhen&&(c=c.filter(P.compileReportPredicate(e.rowVisibleWhen)));const l=xe.estimateMatrixTable(c,e.matrix);return l.cells+(e.header===!1?0:l.columnCount*(e.matrix.hierarchy?e.matrix.columnFields.length+1:1))}const o=t[e.dataset]?.length??0,n=e.columns.filter(c=>!c.hidden).length,a=ie(e).length,s=kr(e);let i=(o*(1+2*a+s.groups)+ +!!e.grandTotal*(1+s.total))*n;if(i+=e.header===!1?0:e.headerGrid?ke(e.headerGrid):n,e.cardinality==="record"&&o===0&&(i+=n),e.detail){const c=t[e.detail.dataset]?.length??0,l=e.detail.columns.filter(d=>!d.hidden).length;i+=(c+o*(+(e.detail.header!==!1)+ +!!e.detail.label))*l}if(!Number.isSafeInteger(i))throw new RangeError("报表单元格估算超出安全整数预算");return i}class ft extends Error{constructor(t){super(t.map(r=>r.message).join(";")),this.issues=t,this.name="ReportValidationError"}}function We(e,t,r){if(!Number.isSafeInteger(e)||e<1||e>r)throw new Error(`校验 ${t} 超出预算`);return e}function Fr(e){if(e.aggregates&&e.scope!=="dataset")throw new Error("仅数据集规则允许汇总");if(e.aggregates&&(!Array.isArray(e.aggregates)||e.aggregates.length>64))throw new Error("校验汇总最多 64 项");const t=new Set;for(const r of e.aggregates??[]){if(P.computationFieldName(r.field),t.has(r.field))throw new Error("校验汇总字段重复");t.add(r.field),r.valueField!==void 0&&P.computationFieldName(r.valueField),r.weightField!==void 0&&P.computationFieldName(r.weightField),P.aggregateRows([],{...r,field:r.valueField??r.field})}}function mt(e){if(!Array.isArray(e)||e.length>256||Object.keys(e).length!==e.length)throw new Error("校验规则最多 256 条且不允许空位");const t=new Set;return e.map(r=>{if(!r||typeof r!="object")throw new Error("校验规则应为声明式对象");if(P.computationFieldName(r.id),t.has(r.id))throw new Error("校验规则 id 重复");if(t.add(r.id),r.field!==void 0&&P.computationFieldName(r.field),r.dataset!==void 0&&P.computationFieldName(r.dataset),typeof r.message!="string"||!r.message.trim()||r.message.length>2048)throw new Error("校验规则需要有界提示文案");if(r.severity!==void 0&&!["error","warning"].includes(r.severity))throw new Error("未知校验严重程度");if(r.scope!==void 0&&!["row","dataset"].includes(r.scope))throw new Error("未知校验范围");Fr(r);const o={nodes:0},n=P.compileReportPredicate(r.assert,o),a=r.when?P.compileReportPredicate(r.when,o):void 0;return{rule:r,assert:n,when:a,checks:o.nodes}})}function ze(e){if(e?.aborted){const t=new Error("报表校验已取消");throw t.name="AbortError",t}}function Or(e,t,r,o){const n=o&&Object.prototype.hasOwnProperty.call(t,o)?t[o]:void 0;if(n!==void 0&&typeof n!="string"&&!(typeof n=="number"&&Number.isFinite(n)))throw new Error("校验定位需要稳定的文本或数值业务键");return{ruleId:e.id,rowIndex:r,...n===void 0?{}:{rowKey:n},field:e.field,severity:e.severity??"error",message:e.message}}function Ar(e,t){const r=t.computed?.length?{fields:t.computed,formula:t.formula,signal:t.signal}:void 0;if(t.tree){const n=V.createTreeTable(e,t.tree,{signal:t.signal,computed:r});if(n.rows.length>1e5)throw new Error("校验展开后数据最多 100000 行");return{rows:n.rows,summaryRows:n.leaves,rowKey:t.tree.idField}}const o=r?P.computeDataset(e,r).rows:e;return{rows:o,summaryRows:o,rowKey:t.rowKey}}function Nr(e,t){const r=new Set;e.forEach(o=>{if(!o||typeof o!="object"||Array.isArray(o))throw new Error("校验数据行应为对象");if(!t)return;const n=Object.prototype.hasOwnProperty.call(o,t)?o[t]:void 0;if(!(typeof n=="string"&&n.trim())&&!(typeof n=="number"&&Number.isFinite(n)))throw new Error("校验定位需要稳定业务键");if(r.has(n))throw new Error("校验业务键重复");r.add(n)})}function Lr(e,t){return gt(e,t,{checks:0})}function gt(e,t,r){if(!Array.isArray(e)||e.length>1e5)throw new Error("校验数据最多 100000 行");ze(t.signal);const o=We(t.maxChecks??2e6,"maxChecks",1e7),n=We(t.maxIssues??1e3,"maxIssues",1e4);t.rowKey!==void 0&&P.computationFieldName(t.rowKey);const a=Ar(e,t),{rows:s,summaryRows:i,rowKey:c}=a;Nr(s,c);const l=mt(t.rules),d=l.reduce((u,g)=>u+(g.rule.scope==="dataset"?g.checks+i.length*(g.rule.aggregates?.length??0):s.length*g.checks),0);if(r.checks+=d,r.checks>o)throw new Error("整批校验超出 maxChecks 预算");const f=[];for(const u of l)(u.rule.scope==="dataset"?[Object.fromEntries((u.rule.aggregates??[]).map(m=>[m.field,P.aggregateRows(i,{...m,field:m.valueField??m.field})]))]:s).forEach((m,v)=>{if(ze(t.signal),!m||typeof m!="object"||Array.isArray(m))throw new Error("校验数据行应为对象");if(!(u.when&&!u.when(m)||u.assert(m))){if(f.length>=n)throw new Error("校验问题超出 maxIssues 预算,请缩小范围");f.push(Or(u.rule,m,u.rule.scope==="dataset"?void 0:v,u.rule.scope==="dataset"?void 0:c))}});return f}function ht(e,t="allow"){if(!["allow","block"].includes(t))throw new Error("未知校验警告策略");if(!Array.isArray(e)||e.length>1e4||e.some(r=>!r||!["error","warning"].includes(r.severity)||typeof r.ruleId!="string"||!r.ruleId.trim()||typeof r.message!="string"||!r.message.trim()))throw new Error("校验问题结构无效");if(e.some(r=>r.severity==="error"||t==="block"))throw new ft(e)}function Je(e,t,r){const o=e.get(t);if(o&&JSON.stringify(o)!==JSON.stringify(r))throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");e.set(t,r)}function Kr(e,t,r,o=[]){mt(t.rules);const n=[],a={checks:0};for(const[i,c]of e.entries()){const l=new Map;for(const d of c.template.pages)for(const f of d.components)f.kind==="list"&&(Je(l,f.dataset,{rowKey:f.tree?.idField??f.rowKey,computed:f.computed,tree:f.tree}),f.detail&&Je(l,f.detail.dataset,{rowKey:f.detail.rowKey}));for(const[d,f]of l){const u=t.rules.filter(g=>!g.dataset||g.dataset===d);if(u.length&&(n.push(...gt(c.datasets[d]??[],{...t,rules:u,...f,formula:o[i],signal:r},a).map(g=>({...g,dataset:d,sourceScope:c.sourceScope}))),n.length>(t.maxIssues??1e3)))throw new Error("整批候选校验问题超出 maxIssues 预算")}}const s=new Set(e.flatMap(i=>i.template.pages.flatMap(c=>c.components.flatMap(l=>l.kind==="list"?[l.dataset,...l.detail?[l.detail.dataset]:[]]:[]))));if(t.rules.some(i=>i.dataset&&!s.has(i.dataset)))throw new Error("校验目标数据集不存在");return n}function pt(e){return!e||typeof e!="object"?!1:[e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex].every(t=>Number.isInteger(t)&&t>=0)}function wt(e,t,r){const o=e.grid;if(!o)return null;const n=o.cells[t];if(!n)return null;const s=oe.resolveGridLayout(o,e.widthMm,e.heightMm).cells.filter(c=>c.ri===t).findIndex(c=>c.ci===r),i=n[s];return i?{cell:i,sourceColumnIndex:s}:null}function jr(e){return e.value!==void 0?e.value:e.rawText??e.text??null}function Dr(e,t){return e.valueType?e.valueType:typeof t=="number"?"number":typeof t=="boolean"?"boolean":t===null&&e.numberFormat&&/[0#?]/.test(e.numberFormat)?"number":"text"}function Br(e,t){if(e.derived)return"derived";if(e.editable===!1)return"cell";if(e.formula!==void 0)return"formula";if(e.children?.length||e.richParagraphs?.length)return"complex";if(t.table&&t.table.role!=="body"&&e.editable!==!0)return"structure"}function Hr(e,t){const r=e.table;if(r)return{id:r.id,rowIndex:r.rowIndex+t.rowIndex,role:r.role,columnKey:r.columnKeys[t.columnIndex]}}function Vr(e,t,r){if(e.derived)return;if(e.source)return{...e.source};const o=t.table?.source,n=t.table?.columnKeys[r.columnIndex];if(!(!o||o.rowKey===void 0||n===void 0))return{...o,rowKey:o.rowKey,field:n}}function yt(e,t,r){const o=jr(r),n=Br(r,e);return{address:{...t},cell:r,component:e,value:o,valueType:Dr(r,o),table:Hr(e,t),source:Vr(r,e,t),editable:n===void 0,readOnlyReason:n}}function de(e,t){if(!pt(t))return null;const r=e.pages[t.pageIndex]?.components[t.componentIndex];if(!r)return null;const o=wt(r,t.rowIndex,t.columnIndex);return o?yt(r,t,o.cell):null}function D(e){const t=new Map;return r=>{if(!pt(r))return null;const o=e.pages[r.pageIndex]?.components[r.componentIndex];if(!o?.grid)return null;let n=t.get(o);if(!n){const s=new Map;n=new Map;for(const i of oe.resolveGridLayout(o.grid,o.widthMm,o.heightMm).cells){const c=s.get(i.ri)??0;s.set(i.ri,c+1);const l=o.grid.cells[i.ri]?.[c];l&&n.set(`${i.ri}:${i.ci}`,l)}t.set(o,n)}const a=n.get(`${r.rowIndex}:${r.columnIndex}`);return a?yt(o,r,a):null}}class M extends Error{constructor(t){super(`Invalid report cell edit: ${t}`),this.code=t,this.name="ReportCellEditError"}}function Gr(e,t){let r=e.trim();const o=t&&r.endsWith("%");if(o&&(r=r.slice(0,-1).trim()),/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(r)&&(r=r.replace(/,/g,"")),!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(r))throw new M("number");return Number(r)/(o?100:1)}function _r(e,t){if(e===null||typeof e=="string"&&e.trim()==="")return null;if(typeof e!="string"&&typeof e!="number")throw new M("number");const r=typeof e=="number"?e:Gr(e,Xe.isExcelPercentageFormat(t.cell.numberFormat));if(!Number.isFinite(r)||Number.isInteger(r)&&!Number.isSafeInteger(r))throw new M("number");return r}function Wr(e){if(e===null||typeof e=="string"&&e.trim()==="")return null;if(typeof e=="boolean")return e;const t=String(e).trim().toLowerCase();if(["true","yes","是","1"].includes(t))return!0;if(["false","no","否","0"].includes(t))return!1;throw new M("boolean")}function Fe(e,t){return e.valueType==="number"?_r(t,e):e.valueType==="boolean"?Wr(t):t===null?null:String(t)}function zr(e,t){const r=t.cell.text,n=[["是","否"],["TRUE","FALSE"],["True","False"],["true","false"],["1","0"]].find(a=>a.includes(r??""));return n?n[e?0:1]:String(e)}function G(e,t){return t===null?"":typeof t=="boolean"?zr(t,e):typeof t=="number"?Xe.formatExcelNumber(t,e.cell.numberFormat):String(t)}function Jr(e,t,r){const o=de(e,t);if(!o)throw new M("missing");return _(o,r)}function _(e,t){if(!e.editable)throw new M("readonly");const r=Fe(e,t);return{address:{...e.address},table:e.table,source:e.source,previousValue:e.value,previousText:e.cell.text??"",value:r,text:G(e,r)}}function qr(e,t){const r=e.table,o=t.table;return!r||!o||r.columnKey===void 0?!1:r.id===o.id&&r.rowIndex===o.rowIndex&&r.role===o.role&&r.columnKey===o.columnKey}function bt(e,t,r){const o=e.grid,{rowIndex:n,columnIndex:a}=t.address,s=wt(e,n,a),i=[...o.cells],c=[...i[n]],l=G(t,r.value),d={...s.cell,value:r.value,text:l,rawText:l};return c[s.sourceColumnIndex]=d,i[n]=c,{...e,grid:{...o,cells:i}}}function Ur(e,t){const r=e.table?.columnKeys,o=t.table?.columnKey;return r&&o!==void 0?r.flatMap((n,a)=>n===o?[a]:[]):[]}function Xr(e,t,r,o,n,a){const s=t.table,i=n.table;if(!s||!i||s.id!==i.id||s.role!==i.role||!t.grid)return t;const c=i.rowIndex-s.rowIndex;if(c<0||c>=t.grid.cells.length)return t;let l=t;for(const d of Ur(t,n)){const f=de(e,{pageIndex:r,componentIndex:o,rowIndex:c,columnIndex:d});f?.editable&&qr(n,f)&&(l=bt(l,f,a))}return l}function Yr(e,t,r,o,n,a){const s=n.address;return n.table?.columnKey!==void 0?Xr(e,t,r,o,n,a):s.pageIndex===r&&s.componentIndex===o?bt(t,n,a):t}function ue(e,t){const r=t.source;if(!r)return!1;const o=e.source;return!o||["sourceScope","datasetId","rowKey","field","revision","sourceToken"].some(n=>!Object.is(o[n],r[n]))}function Qr(e,t){const r=de(e,t.address);if(!r)throw new M("missing");if(!r.editable)throw new M("readonly");if(ue(r,t))throw new M("conflict");if(!Object.is(r.value,t.previousValue)||(r.cell.text??"")!==t.previousText)throw new M("conflict");const o=Fe(r,t.value),n={...t,value:o,text:G(r,o)};if(Object.is(o,r.value)&&n.text===r.cell.text)return e;const a=e.pages.map((s,i)=>{const c=s.components.map((l,d)=>Yr(e,l,i,d,r,n));return c.every((l,d)=>l===s.components[d])?s:{...s,components:c}});return{...e,pages:a}}function vt(e){const t=[];for(const r of e.template.pages)for(const o of r.components)o.kind==="list"&&(t.push(o.tree?{...o,rowKey:o.tree.idField}:o),o.detail&&t.push({...o.detail,relation:{detail:o.detail,parentRows:e.datasets[o.dataset]??[]}}));return t}function W(e){return JSON.stringify([e.sourceScope,e.datasetId])}function qe(e){return JSON.stringify([e.sourceScope,e.datasetId,e.rowKey])}function Mt(e){const t=new Map,r=new Set;return e.forEach((o,n)=>{for(const a of vt(o)){if(!a.rowKey)continue;const s=a.relation,i=s?new Set(s.parentRows.map(c=>JSON.stringify(c[s.detail.parentKey]))):void 0;(o.datasets[a.dataset]??[]).forEach((c,l)=>{if(s&&!i.has(JSON.stringify(c[s.detail.foreignKey])))return;const d=c[a.rowKey];if(typeof d!="string"&&typeof d!="number")return;const f=`${n}:${a.dataset}:${l}:${a.rowKey}`;if(r.has(f))return;r.add(f);const u=qe({sourceScope:o.sourceScope,datasetId:a.dataset,rowKey:d}),g=t.get(u)??[];g.push({partIndex:n,dataset:a.dataset,rowIndex:l,row:c,binding:a}),t.set(u,g)})}}),o=>{const n=t.get(qe(o));if(!n?.length)throw new M("missing");if(new Set(n.map(a=>`${a.partIndex}:${a.dataset}`)).size!==n.length)throw new M("conflict");return n}}function St(e,t){const r=e.map(n=>({...n,datasets:{...n.datasets}})),o=new Set;for(const{row:n,field:a,value:s}of t){const i=r[n.partIndex],c=JSON.stringify([n.partIndex,n.dataset]);o.has(c)||(i.datasets[n.dataset]=[...i.datasets[n.dataset]],o.add(c)),i.datasets[n.dataset][n.rowIndex]={...i.datasets[n.dataset][n.rowIndex],[a]:s}}for(const n of o){const[a,s]=JSON.parse(n);P.forkComputedDataset(e[a].datasets[s],r[a].datasets[s])}return r}function Zr(e,t,r){const o=[],n=new Set;return e.forEach((a,s)=>{for(const i of vt(a))t.has(W({sourceScope:a.sourceScope,datasetId:i.dataset}))&&(a.datasets[i.dataset]??[]).forEach((c,l)=>{const d={partIndex:s,dataset:i.dataset,rowIndex:l,row:c,binding:i};for(const[f,u]of[[i.revisionField,r.revision],[i.sourceTokenField,r.sourceToken]]){if(!f||u===void 0)continue;const g=`${s}:${i.dataset}:${l}:${f}`;n.has(g)||(n.add(g),o.push({row:d,field:f,value:u}))}})}),o}function xt(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return e;const o=new Set(t.edits.flatMap(n=>n.source?[W(n.source)]:[]));return Oe(e,new Map([...o].map(n=>[n,r])))}function Oe(e,t){if(!t.size)return e;function r(a){const s=a.datasetId&&t.get(W({...a,datasetId:a.datasetId}));return!s||(s.revision===void 0||Object.is(s.revision,a.revision))&&(s.sourceToken===void 0||s.sourceToken===a.sourceToken)?a:{...a,...s.revision!==void 0?{revision:s.revision}:{},...s.sourceToken!==void 0?{sourceToken:s.sourceToken}:{}}}function o(a){const s=a.map(i=>{const c=i.table?.source?r(i.table.source):void 0,l=i.table&&c!==i.table.source?{...i.table,source:c}:i.table,d=i.grid?.cells.map(u=>{const g=u.map(m=>{if(!m)return m;const v=m.source?r(m.source):void 0,y=m.children?o(m.children):void 0;return v===m.source&&y===m.children?m:{...m,source:v,children:y}});return g.some((m,v)=>m!==u[v])?g:u}),f=i.grid&&d?.some((u,g)=>u!==i.grid.cells[g])?{...i.grid,cells:d}:i.grid;return l!==i.table||f!==i.grid?{...i,table:l,grid:f}:i});return s.some((i,c)=>i!==a[c])?s:a}const n=e.pages.map(a=>{const s=o(a.components);return s!==a.components?{...a,components:s}:a});return n.some((a,s)=>a!==e.pages[s])?{...e,pages:n}:e}function eo(e){return JSON.stringify([e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex])}function Ue(e){const t=e.table;return t?.columnKey!==void 0?JSON.stringify([t.id,t.role,t.rowIndex,t.columnKey]):eo(e.address)}function to(e,t){if(!t.length)return e;const r=new Map(t.map(c=>[Ue(c),c])),o=new Set(t.flatMap(c=>c.table?[c.table.id]:[])),n=new Set(t.map(c=>`${c.address.pageIndex}:${c.address.componentIndex}`)),a=D(e);function s(c,l,d){const f=c.grid;if(!f||!n.has(`${l}:${d}`)&&!o.has(c.table?.id??""))return c;const u=new Map,g=new Map;for(const m of oe.resolveGridLayout(f,c.widthMm,c.heightMm).cells){const v=g.get(m.ri)??0;g.set(m.ri,v+1);const y=a({pageIndex:l,componentIndex:d,rowIndex:m.ri,columnIndex:m.ci}),h=y&&r.get(Ue(y));if(!h||!y.editable)continue;const w=u.get(m.ri)??[...f.cells[m.ri]],x=G(y,h.value);Object.is(y.value,h.value)&&x===y.cell.text||(w[v]={...m.cell,value:h.value,text:x,rawText:x},u.set(m.ri,w))}return u.size?{...c,grid:{...f,cells:f.cells.map((m,v)=>u.get(v)??m)}}:c}const i=e.pages.map((c,l)=>{const d=c.components.map((f,u)=>s(f,l,u));return d.every((f,u)=>f===c.components[u])?c:{...c,components:d}});return i.every((c,l)=>c===e.pages[l])?e:{...e,pages:i}}function A(e){const t=e.source;if(t)return JSON.stringify([t.sourceScope,t.datasetId,t.rowKey,t.field]);const r=e.table;if(r?.columnKey!==void 0)return JSON.stringify([r.id,r.role,r.rowIndex,r.columnKey]);const o=e.address;return JSON.stringify([o.pageIndex,o.componentIndex,o.rowIndex,o.columnIndex])}function ro(e,t,r){if(typeof r!="string"||!r.trim()||!Array.isArray(t))throw new M("missing");if(t.length>1e4)throw new M("limit");const o=new Set,n=D(e),a=t.map(({address:s,value:i})=>{const c=n(s);if(!c)throw new M("missing");const l=_(c,i),d=A(l);if(o.has(d))throw new M("duplicate");return o.add(d),l});return{requestId:r,edits:a}}function oo(e,t){if(t.edits.length>1e4)throw new M("limit");const r=D(e),o=new Set,n=t.edits.map(a=>{const s=r(a.address);if(!s)throw new M("missing");const i=A(a);if(o.has(i))throw new M("duplicate");if(o.add(i),ue(s,a)||!Object.is(s.value,a.previousValue)||(s.cell.text??"")!==a.previousText)throw new M("conflict");return _(s,a.value)});return to(e,n)}function no(e){const t=new Map;for(const r of e){const o=A(r),n=t.get(o),a=n?{...r,previousValue:n.previousValue,previousText:n.previousText}:{...r};Object.is(a.previousValue,a.value)?t.delete(o):t.set(o,a)}return[...t.values()]}function Et(e){const t=new Map,r=D(e);return e.pages.forEach((o,n)=>o.components.forEach((a,s)=>{if(!(!a.grid||a.table?.role!=="body"))for(let i=0;i<a.grid.cells.length;i++)for(let c=0;c<a.table.columnKeys.length;c++){const l=r({pageIndex:n,componentIndex:s,rowIndex:i,columnIndex:c});l?.source&&l.editable&&t.set(A(l),l)}})),t}function ao(e,t,r){const o=Et(e),n=D(e);return t.map(a=>{const s=a.source?o.get(A(a)):n(a.address);if(!s||A(s)!==A(a))throw new M("missing");return{address:{...s.address},value:a[r]}})}function Rt(e,t){if(++e.nodes>1e6||t>128)throw new M("limit")}function te(e,t){const r=Object.getOwnPropertyDescriptor(e,t);if(!r||r.get||r.set)throw new M("conflict");return r.value}function Ct(e){if(Object.getOwnPropertyDescriptor(e,"toJSON"))throw new M("conflict");const t=Object.getPrototypeOf(e);if(Array.isArray(e)&&(t!==Array.prototype||Object.keys(e).length!==e.length))throw new M("conflict");if(!(e instanceof Date)&&!Array.isArray(e)&&t!==Object.prototype&&t!==null)throw new M("conflict");for(const r of Reflect.ownKeys(e))if(!(Array.isArray(e)&&r==="length")){if(typeof r=="symbol"||!Object.getOwnPropertyDescriptor(e,r)?.enumerable)throw new M("conflict");if(e instanceof Date||Array.isArray(e)&&!/^(0|[1-9]\d*)$/.test(r))throw new M("conflict")}}function Tt(e,t,r,o,n){if(Rt(o,n),typeof e=="function"||typeof e=="symbol")throw new M("conflict");if(e===null||typeof e!="object")return;if(Ct(e),r.has(e))throw new M("conflict");r.add(e);const a=Object.keys(e),s=a.map(i=>te(e,i));t.push({object:e,prototype:Object.getPrototypeOf(e),keys:a,values:s,...e instanceof Date?{date:Date.prototype.getTime.call(e)}:{},...Array.isArray(e)?{length:e.length}:{}});for(const i of s)Tt(i,t,r,o,n+1);r.delete(e)}function so(e){const{object:t,keys:r,values:o}=e;if(Ct(t),Object.getPrototypeOf(t)!==e.prototype||Object.getOwnPropertyDescriptor(t,"toJSON")||e.date!==void 0&&!Object.is(Date.prototype.getTime.call(t),e.date)||e.length!==void 0&&t.length!==e.length)return!1;const n=Object.keys(t);return n.length===r.length&&r.every((a,s)=>n[s]===a&&Object.is(te(t,a),o[s]))}function io(e){const t=[];return Tt(e,t,new Set,{nodes:0},0),()=>{try{return t.every(so)}catch{return!1}}}function we(e,t,r){if(Rt(t,r),e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(Date.prototype.getTime.call(e));if(Array.isArray(e)){const o=[];for(let n=0;n<e.length;n++)o[n]=we(te(e,String(n)),t,r+1);return o}return Object.fromEntries(Object.keys(e).map(o=>[o,we(te(e,o),t,r+1)]))}function co(e){const t=we(e,{nodes:0},0);for(const r of t)for(const o of Object.values(r.datasets))P.registerComputedDataset(o);return t}async function lo(e,t,r={}){return(await Pt(e,t,r)).plan}async function Pt(e,t,r={}){const o=[],n={chartComponents:0},a={...r,knownTotalPages:void 0};for(const s of ut(e,t,a,n))o.push(s),o.length%8===0&&await new Promise(i=>setTimeout(i,0));if(r.signal?.aborted){const s=new Error("报表重算已取消");throw s.name="AbortError",s}return{plan:{schemaVersion:re.RENDER_PLAN_SCHEMA_VERSION,...ae(e)?{requiresRecalculation:!0}:{},pages:o},...n}}const ye=new WeakMap;function uo(e){return ye.get(e)}function Q(e){if(e?.aborted){const t=new Error("报表重算已取消");throw t.name="AbortError",t}}function kt(e,t){return e[t]===void 0?"":e[t]}function fo(e,t){if(t.edits.length>1e4)throw new M("limit");const r=D(e),o=new Set,n=[],a=t.edits.map(s=>{const i=r(s.address);if(!i?.source)throw new M("missing");const c=A(s);if(o.has(c))throw new M("duplicate");if(o.add(c),ue(i,s)||!Object.is(i.value,s.previousValue)||(i.cell.text??"")!==s.previousText)throw new M("conflict");return n.push(i),_(i,s.value)});return{batch:{requestId:t.requestId,edits:a},contexts:n}}function mo(e,t){const r=Mt(e);return t.flatMap(o=>{if(!o.source)throw new M("missing");return r(o.source).map(n=>{if(!Object.is(kt(n.row,o.source.field),o.previousValue))throw new M("conflict");if(n.binding.rowKey===o.source.field)throw new M("readonly");return{row:n,field:o.source.field,value:o.value}})})}function ge(e,t,r){const o={...e,value:t,source:{...e.source,...r?.revision===void 0?{}:{revision:r.revision},...r?.sourceToken===void 0?{}:{sourceToken:r.sourceToken}}};return o.cell={...e.cell,value:o.value,text:G(o,o.value)},o}function go(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return[...e];const o=new Set(t.edits.flatMap(n=>n.source?[W(n.source)]:[]));return St(e,Zr(e,o,r))}function ho(e,t,r){const o=new Set(t.edits.map(n=>W(n.source)));for(const n of o)e.set(n,{...e.get(n),...r.revision!==void 0?{revision:r.revision}:{},...r.sourceToken!==void 0?{sourceToken:r.sourceToken}:{}});return o}function Ae(e,t){let r=t.parts;const o=t.rebuild,n=[...t.validationFormulas??[]];let a=io(r),s=e,i;const c=new Map,l=new Map;function d(g){if(g!==s)throw new M("conflict");if(i)return i;if(!a?.())throw new M("conflict");return co(r)}async function f(g,m,v,y={}){Q(y.signal),m={requestId:m.requestId,edits:m.edits.map(b=>({...b,address:{...b.address},source:b.source?{...b.source}:void 0,table:b.table?{...b.table}:void 0}))},v=v.map(b=>({...b,address:{...b.address},source:b.source?{...b.source}:void 0,table:b.table?{...b.table}:void 0,cell:{...b.cell}})),await new Promise(b=>setTimeout(b,0)),Q(y.signal);const h=d(g),w=St(h,mo(h,m.edits)),x=Oe(await o(w,y.signal),l);Q(y.signal);let I=!1,T=[],N="allow",L=!1;function p(b){return L=!0,T=Object.freeze(Kr(w,b,y.signal,n).map(S=>Object.freeze({...S}))),L=!1,N=b.warningPolicy??"allow",T}return y.validation&&p(y.validation),{plan:x,get validationIssues(){return T},validate:p,commit(b){if(Q(y.signal),I||s!==g)throw new M("conflict");if(b?.conflicts?.length)throw new M("conflict");if(L)throw new Error("候选规则校验未完成,不能提交");ht(T,N);const S=go(w,m,b),k=xt(x,m,b);if(b){const C=ho(l,m,b);for(const[F,B]of c)C.has(W(B.source))&&c.set(F,ge(B,B.value,b))}return v.forEach((C,F)=>c.set(A(C),ge(C,m.edits[F].value,b))),I=!0,i=S,r=void 0,a=void 0,s=k,ye.set(s,u),s}}}const u={get plan(){return s},async prepare(g,m,v){const y=fo(g,m);return f(g,y.batch,y.contexts,v)},async prepareHistory(g,m,v,y,h){if(!y.trim()||m.length>1e4)throw new M("limit");const w=d(g),x=Mt(w),I=Et(g),T=new Set,L=m.map(S=>{if(!S.source)throw new M("missing");const k=A(S);if(T.has(k))throw new M("duplicate");T.add(k);const C=I.get(k)??c.get(k);if(!C?.source)throw new M("missing");const F=x(C.source)[0];return ge(C,kt(F.row,C.source.field))}).map((S,k)=>({context:S,edit:_(S,m[k][v])})).filter(({edit:S})=>!Object.is(S.previousValue,S.value)),p={requestId:y,edits:L.map(({edit:S})=>S)},b=L.map(({context:S})=>S);return{batch:p,contexts:b,prepared:await f(g,p,b,h)}}};return ye.set(e,u),u}function po(e){const t=$e(e.template,e.datasets,e.pagination).plan;return Ae(t,{validationFormulas:[e.pagination?.formula],parts:[{template:e.template,datasets:e.datasets}],rebuild:(r,o)=>lo(r[0].template,r[0].datasets,{...e.pagination,signal:o})})}let wo=0;function It(){return`report-${Date.now()}-${++wo}`}function be(e,t,r){if(!r?.aborted)try{const o=e?.({...t});o&&typeof o.then=="function"&&Promise.resolve(o).catch(()=>{})}catch{}}function $t(e){const t=e.taskId??It(),r=(o,n,a)=>{be(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:o,status:n,...a===void 0?{}:{reportId:a}},e.signal)};return{taskId:t,progress(o,n,a){be(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:o,status:"started",completed:n,total:a},e.signal)},async run(o,n,a){r(o,"started",a);try{const s=await n();return r(o,"completed",a),s}catch(s){throw r(o,"failed",a),s}},runSync(o,n,a){r(o,"started",a);try{const s=n();return r(o,"completed",a),s}catch(s){throw r(o,"failed",a),s}}}}function Ne(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e,r=o=>typeof o=="string"&&o.trim().length>0&&o.length<=256;return!r(t.datasetId)||!r(t.field)||t.tableId!==void 0&&!r(t.tableId)||t.reportScope!==void 0&&(typeof t.reportScope!="string"||!t.reportScope.trim()||t.reportScope.length>4096)?!1:t.rowKey===void 0?!0:typeof t.rowKey=="string"?t.rowKey.trim().length>0&&t.rowKey.length<=1024:typeof t.rowKey=="number"&&Number.isFinite(t.rowKey)}function Ft(e){return e==="missing-source"||e==="not-applicable"||e==="not-calculable"}function Ot(e){return e.target!==void 0&&!Ne(e.target)?!1:e.valueState===void 0||Ft(e.valueState)&&e.target!==void 0}function yo(e,t){if(Ee.validateDatasetRows([],e),!Ne(t))throw new Error("数据说明目标无效");const r=e.fields.find(n=>n.field===t.field);if(!r)throw new Error("数据说明字段未在契约中声明");const o=[];return r.description&&o.push({code:"field-definition",severity:"info",message:r.description,target:{...t}}),r.calculation&&o.push({code:"field-calculation",severity:"info",message:r.calculation.description,target:{...t}}),o}function Le(e,t,r={}){const o=new Map;for(const a of e.pages)for(const s of a.components){if(s.kind!=="list"||s.tree?.input!=="nested")continue;const i=o.get(s.dataset);if(i&&(i.childrenField??"children")!==(s.tree.childrenField??"children"))throw new Error("同一数据集的嵌套树应使用相同 childrenField");o.set(s.dataset,s.tree)}if(!o.size)return t;const n={...t};for(const[a,s]of o){const i=Math.min(s.maxRows??1e5,r.maxRows??1/0);n[a]=V.flattenTreeInput(t[a]??[],{...s,maxRows:i},r.signal)}return n}function bo(e,t,r={}){return Object.values(Le(e,t,r)).reduce((o,n)=>o+n.length,0)}function vo(e,t,r){const o=Ee.datasetJsonSchema(r),n=e?.pages.flatMap(i=>i.components).find(i=>i.kind==="list"&&i.dataset===t&&i.tree?.input==="nested");if(!n||n.kind!=="list"||!n.tree)return o;const a=o.items,s=n.tree.childrenField??"children";return{...o,items:{$ref:"#/$defs/treeNode"},$defs:{treeNode:{...a,properties:{...a.properties,[s]:{anyOf:[{type:"null"},{type:"array",items:{$ref:"#/$defs/treeNode"}}]}}}}}}function Ke(e,t){return JSON.stringify([e,t])}function je(e,t,r){return r===void 0?Ke(e,t):JSON.stringify(["shared",r])}function At(e,t,r){return e.map(o=>{const n=o.table?{...o.table,id:r(o.table.id),...o.table.source?{source:{...o.table.source,sourceScope:t}}:{}}:void 0,a=o.grid?.cells.map(s=>s.map(i=>!i||!i.source&&!i.children?i:{...i,...i.source?{source:{...i.source,sourceScope:t}}:{},...i.children?{children:At(i.children,t,r)}:{}}));return n||a?{...o,...n?{table:n}:{},...a?{grid:{...o.grid,cells:a}}:{}}:o})}function ve(e){return ne(e.maxChartComponents),{maxPages:e.maxPages,maxCells:e.maxCells,maxChartComponents:e.maxChartComponents??Re,usedPages:0,usedCells:0,usedChartComponents:0}}function Mo(e,t){if(!e.repeat)return!1;const r=Object.prototype.hasOwnProperty.call(t,e.repeat.dataset)?t[e.repeat.dataset]:void 0;return Array.isArray(r)&&r.length===0}function So(e){const t=r=>r.grid?.cells.reduce((o,n)=>o+n.reduce((a,s)=>a+(s?1+(s.children?.reduce((i,c)=>i+t(c),0)??0):0),0),0)??0;return e.pages.reduce((r,o)=>r+o.components.reduce((n,a)=>n+t(a),0),0)}function Me(e,t){return e===void 0?void 0:e-t}function he(e,t){return e===void 0?t:Math.max(1,Math.min(e,t??e))}function Nt(e,t,r,o,n){ne(e?.maxChartComponents);const a=Me(t.maxPages,t.usedPages),s=t.maxChartComponents-t.usedChartComponents;if(a!==void 0&&a<1&&r.pages.length&&!Mo(r,o))throw new H(0,1);if(s<1&&r.pages.some(i=>i.components.some(c=>c.kind!=="list"&&c.chartBinding)))throw new q(s,1);return{...e,signal:n??e?.signal,maxPages:he(a,e?.maxPages),maxCells:he(Me(t.maxCells,t.usedCells),e?.maxCells),maxChartComponents:he(s,e?.maxChartComponents)}}function Lt(e,t){const r=So(t.plan),o=Me(e.maxCells,e.usedCells);if(o!==void 0&&r>o)throw new J(o,r);e.usedPages+=t.plan.pages.length,e.usedCells+=r,e.usedChartComponents+=t.chartComponents}function Kt(e,t){return e instanceof H&&t.maxPages!==void 0&&(e.limit===t.maxPages-t.usedPages||e.limit===0)?new H(t.maxPages,t.usedPages+e.actual):e instanceof J&&t.maxCells!==void 0?new J(t.maxCells,t.usedCells+e.actual):e instanceof q&&e.limit===t.maxChartComponents-t.usedChartComponents?new q(t.maxChartComponents,t.usedChartComponents+e.estimated):e}function xo(e){if(!("mapData"in e))return e;const{load:t,mapData:r,...o}=e;return{...o,load:async n=>{const a=await t(n);O(n.signal);try{return r(a,n)}catch(s){throw new R("validate",`报表 ${n.reportId} 数据映射失败`,s)}}}}class R extends Error{constructor(t,r,o){super(r),this.name="ReportSourceError",this.code=t,this.cause=o}}function fe(e){const t=new Error("报表加载已取消");return t.name="AbortError",Object.defineProperty(t,"cause",{value:e.reason}),t}function O(e){if(e?.aborted)throw fe(e)}function Se(e,t){return t?new Promise((r,o)=>{const n=()=>t.removeEventListener("abort",a),a=()=>{n(),o(fe(t))};t.addEventListener("abort",a,{once:!0}),t.aborted&&a(),Promise.resolve(e).then(s=>{n(),r(s)},s=>{n(),o(s)})}):Promise.resolve(e)}function Eo(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new R("validate",`报表 ${t} 的数据集应为对象`);for(const[r,o]of Object.entries(e))if(!Array.isArray(o)||o.some(n=>!n||typeof n!="object"||Array.isArray(n)))throw new R("validate",`报表 ${t} 的数据集 ${r} 应为对象数组`)}async function Ro(e,t,r){const{reportId:o,signal:n}=t;try{const a=await Se(e(t),n);O(n);const s=K.validateReportTemplate(a);if(!s.ok)throw new R("validate",`报表 ${o} 模板校验失败:${s.errors.slice(0,3).map(i=>`${i.path}: ${i.message}`).join("; ")}`);return r.push(...s.warnings.map(i=>`${o}: ${i.path}: ${i.message}`)),a}catch(a){throw n?.aborted?fe(n):a instanceof R?a:a instanceof K.ReportTemplateError?new R("validate",`报表 ${o} 模板校验失败:${a.message}`,a):new R("fetch",`报表 ${o} 模板加载失败:${a instanceof Error?a.message:String(a)}`,a)}}async function Co(e,t,r,o){const n=t.signal;let a;try{if(e.load)a=await Se(e.load(t),n);else if(e.provider){const s=await Se(e.provider.query(t),n);O(n),To(s,r),a=s.datasets,o?.(r,s)}else a=e.datasets??{}}catch(s){throw n?.aborted?fe(n):s instanceof R?s:new R("fetch",`报表 ${r} 取数失败:${s instanceof Error?s.message:String(s)}`,s)}return O(n),a}function To(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new R("validate",`报表 ${t} Provider 应返回 datasets 结果对象`);for(const r of["revision","sourceToken"])if(e[r]!==void 0&&typeof e[r]!="string")throw new R("validate",`报表 ${t} Provider ${r} 应为字符串`);if(e.diagnostics!==void 0&&(!Array.isArray(e.diagnostics)||e.diagnostics.some(r=>!r||typeof r.code!="string"||typeof r.message!="string"||!["info","warning","error"].includes(r.severity))))throw new R("validate",`报表 ${t} Provider diagnostics 不符合结构化诊断契约`);if(e.diagnostics?.some(r=>!Ot(r)))throw new R("validate",`报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`)}function Po(e,t,r,o,n){try{t=Le(o,t,{maxRows:e.dataValidation?.maxRows,signal:n})}catch(a){throw new R("validate",`报表 ${r} 树形数据无效:${a instanceof Error?a.message:String(a)}`,a)}for(const[a,s]of Object.entries(e.dataSchema??{})){let i;try{i=Ee.validateDatasetRows(Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0,s,{...e.dataValidation,path:`$.datasets.${a}`})}catch(c){throw new R("config",`报表 ${r} 数据集 ${a} 字段契约配置无效`,c)}if(!i.ok)throw new R("validate",`报表 ${r} 数据集 ${a} 不符合字段契约:${i.issues[0]?.message}`,{issues:i.issues})}}function ko(e,t,r,o,n,a){try{const s=Nt(r.pagination,n,e,t,a),i=$e(e,t,s);return Lt(n,i),i}catch(s){const i=Kt(s,n);throw new R("validate",`报表 ${o} 排版失败:${i instanceof Error?i.message:String(i)}`,i)}}function jt(e,t,r,o,n){const a=new Map,s=i=>{let c=a.get(i);return c===void 0&&(c=JSON.stringify([r,o,i]),a.set(i,c)),c};for(const i of t.pages)e.push({...i,meta:{...i.meta,reportScope:Ke(r,o)},components:At(i.components,n??je(r,o),s)})}async function Io(e,t,r,o,n){const a=[],s=ve(o);for(const[l,d]of e.entries()){O(n);try{const f=await Pt(d.template,d.datasets,Nt(t[l]?.pagination,s,d.template,d.datasets,n));Lt(s,f),jt(a,f.plan,l,r[l],d.sourceScope)}catch(f){throw Kt(f,s)}}const i={schemaVersion:re.RENDER_PLAN_SCHEMA_VERSION,...e.some(l=>ae(l.template))?{requiresRecalculation:!0}:{},pages:a},c=K.validateRenderPlan(i);if(!c.ok)throw new R("validate",`重算渲染计划校验失败:${c.errors[0]?.message}`);return i}function $o(e,t={}){if(t.maxPages!==void 0&&(!Number.isSafeInteger(t.maxPages)||t.maxPages<1))throw new R("config","maxPages 应为正安全整数");if(t.maxCells!==void 0&&(!Number.isSafeInteger(t.maxCells)||t.maxCells<1))throw new R("config","maxCells 应为正安全整数");try{ve(t)}catch(n){throw new R("config","maxChartComponents 应为 1..1000000 的安全整数",n)}function r(n){const a=Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0;if(!a)throw new R("config",`未注册报表 ${n}`);if(a.sourceScope!==void 0&&(typeof a.sourceScope!="string"||!a.sourceScope.trim()||a.sourceScope.length>512))throw new R("config","sourceScope 应为不超过 512 字符的非空字符串");return a}return Object.assign(async({reportIds:n,params:a,signal:s,onWarning:i,onQueryResult:c,...l})=>{O(s);const d=$t({...l,signal:s}),f=[...n],u={...a};if(f.length===0)throw new R("config","缺少报表 ID");const g=f.map(r),m=d.runSync("validate",()=>g.map(p=>He.assertReportParams(p.params??(typeof p.template=="function"?[]:p.template.params)??[],u))),v=[],y=[],h=ve(t),w=[];for(const[p,b]of g.entries()){O(s);const S=f[p],k={reportId:S,params:m[p],signal:s},C=typeof b.template=="function"?await d.run("query",()=>Ro(b.template,k,w),S):b.template;k.params=d.runSync("validate",()=>He.assertReportParams(b.params??C.params??[],k.params),S);const F=await d.run("query",()=>Co(b,k,S,(me,Dt)=>c?.(me,Dt,p)),S);d.runSync("validate",()=>{Eo(F,S),t.onDatasets?.(S,F,C),Po(b,F,S,C,s)},S),O(s);const B=d.runSync("layout",()=>ko(C,F,b,S,h,s),S),De=je(p,S,b.sourceScope);y.push({template:C,datasets:F,sourceScope:De}),jt(v,B.plan,p,S,De),w.push(...B.warnings.map(me=>`${S}: ${me}`))}O(s);const x={schemaVersion:re.RENDER_PLAN_SCHEMA_VERSION,...y.some(p=>ae(p.template))?{requiresRecalculation:!0}:{},pages:v},I=d.runSync("validate",()=>{const p=K.validateRenderPlan(x);if(!p.ok)throw new R("validate",`渲染计划校验失败:${p.errors.slice(0,3).map(b=>`${b.path}: ${b.message}`).join("; ")}`);return p});w.push(...I.warnings.map(p=>`${p.path}: ${p.message}`));const T=g.map(p=>({...p,pagination:{...p.pagination}})),N={maxPages:t.maxPages,maxCells:t.maxCells,maxChartComponents:t.maxChartComponents};try{Ae(x,{parts:y,validationFormulas:T.map(p=>p.pagination?.formula),rebuild:(p,b)=>Io(p,T,f,N,b)})}catch{w.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算")}const L=i??t.onWarning??(p=>console.warn("[mach-report]",p));for(const p of w)O(s),L(p);return O(s),x},{getParamDefs:n=>Bt.getReportParamDefs(e,n)})}function Fo(e,t){const r=t.maxNodes??1e6;if(![t.maxBytes,r].every(d=>Number.isSafeInteger(d)&&d>0))throw t.error("budget","快照预算应为正安全整数");let o=0,n=0;const a=new Set;function s(d){if(n+=d,n>t.maxBytes)throw t.error("budget","快照超过字节预算")}function i(d,f){if(++o>r||f>64)throw t.error("budget","快照节点或深度超过预算");if(o%1024===0&&t.check?.(),typeof d=="string")return s(d.length+2),d;if(d===null||typeof d=="boolean"||typeof d=="number"&&Number.isFinite(d))return s(String(d).length),d;if(!d||typeof d!="object"||a.has(d))throw t.error("input","快照应为无循环的有限 JSON 值");return c(d,f)}function c(d,f){const u=Array.isArray(d),g=Object.getPrototypeOf(d);if(g!==(u?Array.prototype:Object.prototype)&&!(g===null&&!u)||Object.getOwnPropertySymbols(d).length)throw t.error("input","快照应为普通 JSON 对象");const m=Object.getOwnPropertyNames(d).filter(h=>!(u&&h==="length"));if(u&&(m.length!==d.length||m.some((h,w)=>h!==String(w))))throw t.error("input","快照数组应为连续数组");a.add(d),s(2);const v=Object.create(null);let y=0;for(const h of m){const w=Object.getOwnPropertyDescriptor(d,h);if(w.get||w.set||!w.enumerable||["__proto__","constructor","prototype"].includes(h))throw t.error("input","快照不允许访问器或危险键");w.value===void 0&&!u||(s((y++?1:0)+(u?0:h.length+3)),v[h]=i(w.value===void 0?null:w.value,f+1))}return a.delete(d),u?m.map(h=>v[h]):v}t.check?.();const l=JSON.stringify(i(e,0));if(new TextEncoder().encode(l).byteLength>t.maxBytes)throw t.error("budget","快照超过字节预算");return JSON.parse(l)}exports.DEFAULT_LABEL_PAGE_LIMIT=Qe;exports.PaginateCellLimitError=J;exports.PaginateChartComponentLimitError=q;exports.PaginatePageLimitError=H;exports.ReportCellEditError=M;exports.ReportSourceError=R;exports.ReportValidationError=ft;exports.applyReportCellEdit=Qr;exports.applyReportCellEditBatch=oo;exports.applyReportEditResult=xt;exports.applyReportSourceMetadata=Oe;exports.assertReportValidation=ht;exports.countTemplatePages=Tr;exports.createReportCellEdit=Jr;exports.createReportCellEditBatch=ro;exports.createReportCellResolver=D;exports.createReportEditSession=po;exports.createReportSource=$o;exports.createReportTaskReporter=$t;exports.defineReport=xo;exports.editFromContext=_;exports.estimateListLayoutCells=$r;exports.explainDatasetField=yo;exports.formatReportCellEdit=G;exports.getReportCellContext=de;exports.getReportEditSession=uo;exports.hasValidDataExplanation=Ot;exports.isReportDataTarget=Ne;exports.isReportValueState=Ft;exports.notifyReportTaskEvent=be;exports.paginateTemplate=$e;exports.paginateTemplatePages=Pr;exports.parseReportCellInput=Fe;exports.projectListColumns=Ye;exports.registerReportEditSession=Ae;exports.relocateReportCellEdits=ao;exports.reportCellEditKey=A;exports.reportOccurrenceScope=Ke;exports.reportSourceScope=je;exports.reportTaskId=It;exports.snapshotReportJson=Fo;exports.sourceChanged=ue;exports.summarizeReportCellEdits=no;exports.templateDatasetJsonSchema=vo;exports.templateDatasetRowCount=bo;exports.templateValidationDatasets=Le;exports.validateReportDataset=Lr;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const d=require("./style-C22Pbv3T.cjs"),u=require("./computed-4TnxzgIh.cjs");function y(e){if(!e||e.kind==="date")return;const t=e.digits;if(!(t!==void 0&&(!Number.isInteger(t)||t<0||t>100))){if(e.kind==="percent"){const r=t??2;return`0${r?`.${"0".repeat(r)}`:""}%`}return t===void 0?e.thousands?"#,##0.###############":void 0:`${e.thousands?"#,##0":"0"}${t?`.${"0".repeat(t)}`:""}`}}function h(e){const t=/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(e.trim());if(t){const n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return Number.isNaN(n.getTime())?null:n}const r=new Date(e);return Number.isNaN(r.getTime())?null:r}function g(e,t){return e.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})}function L(e,t){const r=n=>String(n).padStart(2,"0");return t.replace(/YYYY/g,String(e.getFullYear())).replace(/MM/g,r(e.getMonth()+1)).replace(/DD/g,r(e.getDate())).replace(/hh/g,r(e.getHours())).replace(/mm/g,r(e.getMinutes())).replace(/ss/g,r(e.getSeconds()))}function x(e,t,r){return r!=null?t?g(e,r):e.toFixed(r):t?g(e):String(e)}function c(e){const t=typeof e=="number"?e:Number(String(e).replace(/,/g,""));return Number.isFinite(t)?t:null}function b(e,t){if(e==null||e===""||!t)return String(e??"");switch(t.kind){case"number":{if(typeof e=="string")try{return u.formatDecimal(e,t.digits,t.thousands===!0)}catch{return e}const r=c(e);return r==null?String(e):x(r,t.thousands===!0,t.digits)}case"percent":{if(typeof e=="string")try{return u.formatDecimal(e,t.digits??2,!0,!0)}catch{return e}const r=c(e);return r==null?String(e):`${g(r*100,t.digits??2)}%`}case"date":{const r=t.pattern??"YYYY-MM-DD",n=e instanceof Date?e:h(String(e));return n?L(n,r):String(e)}default:return String(e)}}function p(e,t){return u.compileReportPredicate(t)(e)}function S(e,t,r,n=e.paddingMm??1){return t.field!==e.tree.labelField?0:Math.min(r.depth*(e.tree.indentMm??3),Math.max(0,t.widthMm-n*2-4))}function N(e,t,r,n){const i=n.tree;(i.input==="nested"||[i.idField,i.parentField].includes(t.field))&&(e.editable=!1),r.hasChildren&&i.parentValues==="leaf-aggregate"&&i.aggregates?.some(o=>o.field===t.field)&&(e.derived=!0,e.editable=!1)}function D(e,t,r){return r==="identifier"||r==="dimension"||r==="date"?"center":r==="measure"?"right":r==="text"?"left":t?.kind==="number"||t?.kind==="percent"?"right":t?.kind==="date"||e instanceof Date||typeof e=="boolean"?"center":typeof e=="number"&&Number.isFinite(e)?"right":"left"}function T(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number")return String(e);if(typeof e=="boolean")return e?"是":"否";if(e instanceof Date)return e.toISOString().slice(0,10);try{return JSON.stringify(e)}catch{return String(e)}}function C(e,t){let r=d.mergeComponentStyles({fontSize:e.fontSizePt??d.DEFAULT_FONT_PT,bold:e.headerBold??!0,align:"center",verticalAlign:"middle",backgroundColor:e.headerBackgroundColor},t.style);return e.headerAlign!==void 0&&(r.align=e.headerAlign),r=d.mergeComponentStyles(r,e.headerStyle),t.headerAlign!==void 0&&(r.align=t.headerAlign),d.mergeComponentStyles(r,t.headerStyle)}function M(e,t,r){(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))&&(e.value=r);const n=t.format?.kind==="number"||t.format?.kind==="percent";t.valueType!==void 0?e.valueType=t.valueType:n&&(e.valueType="number"),t.editable!==void 0&&(e.editable=t.editable);const i=y(t.format);(typeof e.value=="number"||e.value==null)&&i!==void 0&&(e.numberFormat=i)}function F(e,t,r){const n=!!t.visibleWhen&&!p(r,t.visibleWhen),i=n?null:r[t.field],o=t.align??t.style?.align??e.align??"left";let a=d.mergeComponentStyles({fontSize:e.fontSizePt??d.DEFAULT_FONT_PT,verticalAlign:"middle"},t.style);a.align=o==="auto"?D(i,t.format,t.semanticRole):o;const s=t.rules?.find(f=>p(r,f.when));s&&(a=d.mergeComponentStyles(a,s.style));const l={text:t.format?b(i,t.format):T(i),style:a};return M(l,t,i),e.computed?.some(f=>f.field===t.field)&&(l.derived=!0,l.editable=!1),n&&(l.editable=!1),l}function w(e,t,r){const n=F(e,t,r.row),i=S(e,t,r);return t.field===e.tree.labelField&&(n.style={...n.style,align:"left"}),i&&(n.indentMm=i),N(n,t,r,e),n}function A(e){return typeof e=="string"&&/^data:image\/(png|jpe?g);base64,[A-Za-z0-9+/\r\n]+=*$/.test(e)}class m extends Error{constructor(t,r,n,i){super(`${t}: ${r}`),this.path=t,this.rowIndex=n,this.field=i,this.code="report-binding",this.name="ReportBindingError"}}function $(e,t,r={}){const n=r.rowIndex??0,o=`$.datasets.${r.dataset??"label"}[${n}].${t}`,a=Object.getOwnPropertyDescriptor(e,t);if(!a||a.get||a.set)throw new m(o,"字段必须是记录的自有数据字段,不能缺失、使用访问器或从原型继承",n,t);const s=a.value;if(s==null||typeof s=="string"||typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s))return s;throw new m(o,"绑定值应为字符串、有限数字、布尔值或空值",n,t)}function k(e,t,r={}){const n=$(t,e.field,r);return n==null||n===""?e.emptyText??"":`${e.prefix??""}${b(n,e.format)}${e.suffix??""}`}exports.ReportBindingError=m;exports.applyListTreeMetadata=N;exports.evalStyleRule=p;exports.formatValue=b;exports.isLabelImageData=A;exports.listCellText=T;exports.listTreeIndent=S;exports.parseDateLocal=h;exports.readRecordScalar=$;exports.resolveComponentBinding=k;exports.resolveListAutoAlignment=D;exports.resolveListHeaderStyle=C;exports.resolveListSampleCell=F;exports.resolveTreeListSampleCell=w;exports.toExcelNumberFormat=y;exports.toNumber=c;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const d=require("./style-C22Pbv3T.cjs"),B=["borderTop","borderRight","borderBottom","borderLeft","borderColor","lineColor","lineWidthPt"];function C(n,e){const t=d.resolveBoxBorders(e.style),s=t.inner?[...n.edges]:[];t.top&&s.push({kind:"h",pos:0,from:0,to:e.widthMm}),t.bottom&&s.push({kind:"h",pos:e.heightMm,from:0,to:e.widthMm}),t.left&&s.push({kind:"v",pos:0,from:0,to:e.heightMm}),t.right&&s.push({kind:"v",pos:e.widthMm,from:0,to:e.heightMm});const o=d.resolveStroke(e.style);return s.map(i=>({...i,...o}))}function z(n,e,t){const s=n.get(e);(!s||t.widthPt>s.widthPt)&&n.set(e,t)}function v(n,e,t,s,o,i){const c=t<e.rows.length?e.rows[t].pos:e.rows[e.rows.length-1].pos+e.rows[e.rows.length-1].size;for(let r=s;r<o;r++){const h=e.columns[r];z(n,`h:${t}:${r}`,{kind:"h",pos:c,from:h.pos,to:h.pos+h.size,...i})}}function k(n,e,t,s,o,i){const c=t<e.columns.length?e.columns[t].pos:e.columns[e.columns.length-1].pos+e.columns[e.columns.length-1].size;for(let r=s;r<o;r++){const h=e.rows[r];z(n,`v:${t}:${r}`,{kind:"v",pos:c,from:h.pos,to:h.pos+h.size,...i})}}function M(n,e,t,s){const o=Math.min(e.columns.length,t.ci+(t.cell.colSpan??1)),i=Math.min(e.rows.length,t.ri+(t.cell.rowSpan??1)),c=d.mergeComponentStyles(s,t.cell.style),r=d.resolveBoxBorders(c),h=d.resolveStroke(c);r.top&&v(n,e,t.ri,t.ci,o,h),r.bottom&&v(n,e,i,t.ci,o,h),r.left&&k(n,e,t.ci,t.ri,i,h),r.right&&k(n,e,o,t.ri,i,h)}function H(n){const e=[...n.values()].sort((s,o)=>s.kind.localeCompare(o.kind)||s.pos-o.pos||s.from-o.from),t=[];for(const s of e){const o=t[t.length-1];o&&o.kind===s.kind&&o.pos===s.pos&&Math.abs(o.to-s.from)<1e-6&&o.color===s.color&&o.widthPt===s.widthPt?o.to=s.to:t.push({...s})}return t}function L(n,e){if(!n.cells.some(({cell:i})=>B.some(c=>i.style?.[c]!==void 0)))return C(n,e);const t=new Map,s=new Set,o=n.columns.length;for(const i of n.cells){M(t,n,i,e.style);const c=Math.min(n.rows.length,i.ri+(i.cell.rowSpan??1)),r=Math.min(o,i.ci+(i.cell.colSpan??1));for(let h=i.ri;h<c;h++)for(let l=i.ci;l<r;l++)s.add(h*o+l)}for(let i=0;i<n.rows.length;i++)for(let c=0;c<o;c++)s.has(i*o+c)||M(t,n,{ri:i,ci:c,cell:{}},e.style);return H(t)}function u(n){const e=d.resolveFontSize(n).fontSizePt;return{runs:[],width:0,height:e*d.resolveLineHeight(n),fontSize:e}}function R(n,e,t,s){const o=n.runs[n.runs.length-1];o?.style===t?(o.text+=e,o.width+=s):n.runs.push({text:e,style:t,width:s});const i=d.resolveFontSize(t).fontSizePt;n.width+=s,n.fontSize=Math.max(n.fontSize,i),n.height=Math.max(n.height,i*d.resolveLineHeight(t))}function T(n,e,t,s,o){const i=n.richParagraphs[e],c=d.mergeComponentStyles(n.style,{...i.lineHeight===void 0?{}:{lineHeight:i.lineHeight}}),r=[u(c)];for(const h of i.segments){const l=d.mergeComponentStyles(c,h.style),p=h.kind==="field"?h.field??"":h.text??"";for(const g of p.replace(/\r\n|\r/g,`
|
|
2
|
-
`)){let f=r[r.length-1];if(g===`
|
|
3
|
-
`){r.push(u(l));continue}const m=o.measure(g,l);f.runs.length&&f.width+m>t-(r.length===1?s:0)&&(f=u(l),r.push(f)),R(f,g,l,m)}}return r}function A(n,e,t){const s=n.richParagraphs.map((r,h)=>{const l=(r.indentMm??0)*72/25.4,p=T(n,h,e.width,l,t),g=p.reduce((f,m)=>f+m.height,0)+((r.spaceBeforeMm??0)+(r.spaceAfterMm??0))*72/25.4;return{paragraph:r,indent:l,lines:p,height:g}}),o=s.reduce((r,h)=>r+h.height,0),i=n.style?.verticalAlign;let c=e.yTop-(i==="middle"?(e.height-o)/2:i==="bottom"?e.height-o:0);for(const{paragraph:r,indent:h,lines:l}of s){c-=(r.spaceBeforeMm??0)*72/25.4;const p=Math.max(0,e.width-h);for(const[g,f]of l.entries()){const m=r.align??n.style?.align,P=g===0?h:0,a=g===0?p:e.width;let S=e.x+P+(m==="center"?(a-f.width)/2:m==="right"?a-f.width:0);for(const w of f.runs)t.draw(w.text,{...w.style,align:"left"},S,c-f.fontSize,w.width),S+=w.width;c-=f.height}c-=(r.spaceAfterMm??0)*72/25.4}return o>e.height+.01}exports.drawRichText=A;exports.resolveGridStrokes=L;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var _=Object.create;var D=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var W=(e,t,a,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of N(t))!X.call(e,s)&&s!==a&&D(e,s,{get:()=>t[s],enumerable:!(c=J(t,s))||c.enumerable});return e};var B=(e,t,a)=>(a=e!=null?_(U(e)):{},W(t||!e||!e.__esModule?D(a,"default",{value:e,enumerable:!0}):a,e));const n=require("./json-snapshot-jiXff4lc.cjs"),T=require("./report-params-VTg8MoCp.cjs"),k=require("./param-validation-C-8sRJLq.cjs"),o=require("./sha256-DgZAKXqI.cjs"),z=require("./template-registry-DzWswQI5.cjs"),G=require("./column-visual-CtYxnBCP.cjs"),M=require("./assets-B0Hxn4l6.cjs"),b=require("./prepared-CGVphji3.cjs");function I(e=[]){return e.map(({code:t,message:a,severity:c,pageIndex:s,componentIndex:r})=>({code:t,message:a,severity:c,path:r<0?`$.pages.${s}`:`$.pages.${s}.components.${r}`}))}async function L(e,t,a=Date.now()){const c=e.prepared;if(e.fidelity==="strict"&&c.diagnostics.some(w=>w.code==="asset-render-failed"||w.code==="asset-budget-exceeded"))throw new n.ReportSourceError("validate","严格输出拒绝已有资产渲染降级,请修复组件后重新准备报表。");const s=e.format==="pdf"?await import("@agile-team/mach-report/pdf"):void 0;o.throwIfAborted(e.signal);const r=e.pdf?.customFontFaces??(e.pdf?.customFontBytes?{regular:e.pdf.customFontBytes}:void 0),m=s&&r?s.createFontBytesMeasurer(r):void 0,g=n.createReportTaskReporter(e),u=await g.run("encode",async()=>{let w;if(e.format==="pdf"){o.throwIfAborted(e.signal);const d=await s.renderPlanToPdf(c.plan,{...e.pdf,...m?{measurer:m}:{},fidelity:e.fidelity,signal:e.signal,onProgress:(f,p)=>g.progress("encode",f,p)});w=d.bytes,c.diagnostics.push(...I(d.diagnostics)),c.diagnostics.push(...d.fidelityWarnings.map(f=>({code:"pdf-fidelity",message:f,severity:"warning"})),...d.pageErrors.map(f=>({code:"pdf-page",message:f,severity:"error"}))),d.unsupportedTextCount&&c.diagnostics.push({code:"pdf-font",message:`${d.unsupportedTextCount} 段文本包含当前字体不支持的字符`,severity:"warning"})}else{const{renderPlanToXlsx:d}=await import("@agile-team/mach-report/xlsx");o.throwIfAborted(e.signal);const f=await d(c.plan,{...e.xlsx,fidelity:e.fidelity,signal:e.signal,onProgress:(p,y)=>g.progress("encode",p,y)});w=new Uint8Array(f.buffer),c.diagnostics.push(...I(f.diagnostics)),c.diagnostics.push(...f.warnings.map(p=>({code:"xlsx-fidelity",message:p,severity:"warning"}))),c.diagnostics.push(...(f.notes??[]).map(p=>({code:"xlsx-snapshot",message:p,severity:"info"})))}return o.throwIfAborted(e.signal),w});o.assertBudget(t,"maxOutputBytes",u.byteLength);const{plan:i,...h}=c;return{...h,bytes:u,format:e.format,contentType:e.format==="pdf"?"application/pdf":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",stats:{...h.stats,durationMs:Date.now()-a,outputBytes:u.byteLength}}}function $(e){return{...e,reportIds:[...e.reportIds],...e.params?{params:{...e.params}}:{}}}function A(e,t){if(t.length===0)throw new n.ReportSourceError("config","缺少报表 ID");return t.map(a=>{if(!Object.prototype.hasOwnProperty.call(e,a))throw new n.ReportSourceError("config",`未注册报表 ${a}`);return e[a]})}function C(e){return e.grid?.cells.reduce((t,a)=>t+a.reduce((c,s)=>c+(s?1+(s.children?.reduce((r,m)=>r+C(m),0)??0):0),0),0)??0}function Q(e,t,a){return e.pages.reduce((c,s)=>c+s.components.reduce((r,m)=>m.kind!=="list"?r+C(m):r+n.estimateListLayoutCells(m,t,a),0),0)}function H(e,t=Object.keys(e)){return A(e,t).map((a,c)=>{const s=t[c],r=T.getReportParamDefs(e,[s]);return{id:s,params:JSON.parse(JSON.stringify(r)),paramsSchema:k.reportParamsJsonSchema(r),datasetsSchema:Object.fromEntries(Object.entries(a.dataSchema??{}).map(([m,g])=>[m,n.templateDatasetJsonSchema(typeof a.template=="function"?void 0:a.template,m,g)])),capabilities:{save:!!a.provider?.save,export:!!a.provider?.export,templates:!!a.provider?.templates}}})}function j(e,t){A(e,t.reportIds);const a=k.validateReportParams(T.getReportParamDefs(e,t.reportIds),t.params),c=t.reportIds.flatMap(r=>k.validateReportParams(T.getReportParamDefs(e,[r]),t.params).issues),s=new Map(c.map(r=>[JSON.stringify(r),r]));return{...a,ok:s.size===0,issues:[...s.values()]}}function F(e,t){const a=z.validateRenderPlan(e.plan);if(!a.ok)throw new n.ReportSourceError("validate",`执行器返回无效计划:${a.errors[0]?.path}`);const c=e.plan.pages.length,s=e.plan.pages.reduce((r,m)=>r+m.components.reduce((g,u)=>g+C(u),0),0);return o.assertBudget(t,"maxRows",e.stats.rows),o.assertBudget(t,"maxPages",c),o.assertBudget(t,"maxCells",s),{...e,stats:{...e.stats,pages:c,cells:s}}}function q(e,t){const a=j(e.reports,t);if(!a.ok)throw new k.ReportParamValidationError(a.issues)}function K(e){const t={...o.DEFAULT_REPORT_RUNTIME_BUDGET,...e.budget};o.validateBudget(t);const a=async(s,r)=>{const m=Date.now();let g=0,u=0;const i=[],h={},w=[],d=Object.fromEntries(Object.entries(e.reports).map(([l,x])=>[l,{...x,pagination:{...e.pagination,...x.pagination,...r?{measurer:r}:{}},dataValidation:{...x.dataValidation,maxRows:Math.min(t.maxRows??1e5,x.dataValidation?.maxRows??1/0),maxCells:Math.min(t.maxCells??2e6,x.dataValidation?.maxCells??1/0)}}])),p=await n.createReportSource(d,{maxPages:t.maxPages,maxCells:t.maxCells,maxChartComponents:t.maxChartComponents,onDatasets:(l,x,v)=>{try{g+=n.templateDatasetRowCount(v,x,{maxRows:t.maxRows,signal:s.signal})}catch(R){throw R instanceof G.TreeRowLimitError?new o.ReportRuntimeError("budget",R.message,"$.budget.maxRows"):R}o.assertBudget(t,"maxRows",g),u+=Q(v,x,d[l]?.pagination),o.assertBudget(t,"maxCells",u)}})({...s,params:s.params??{},onWarning:l=>i.push({code:"layout",message:l,severity:"warning"}),onQueryResult:(l,x,v=0)=>{const R=n.reportOccurrenceScope(v,l);Object.defineProperty(h,l,{value:{revision:x.revision,sourceToken:x.sourceToken},enumerable:!0,writable:!0}),w.push({reportId:l,reportIndex:v,reportScope:R,...x.revision===void 0?{}:{revision:x.revision},...x.sourceToken===void 0?{}:{sourceToken:x.sourceToken}}),i.push(...(x.diagnostics??[]).map(P=>({...P,...P.target?{target:{...P.target,reportScope:R,...P.target.tableId?{tableId:JSON.stringify([v,l,P.target.tableId])}:{}}}:{}})))}}).catch(l=>{throw l instanceof n.ReportSourceError&&l.cause instanceof n.PaginatePageLimitError?new o.ReportRuntimeError("budget",l.cause.message,"$.budget.maxPages"):l instanceof n.ReportSourceError&&l.cause instanceof n.PaginateCellLimitError?new o.ReportRuntimeError("budget",l.cause.message,"$.budget.maxCells"):l instanceof n.ReportSourceError&&l.cause instanceof n.PaginateChartComponentLimitError?new o.ReportRuntimeError("budget",l.cause.message,"$.budget.maxChartComponents"):l});o.throwIfAborted(s.signal);const y=e.assets?await n.createReportTaskReporter(s).run("assets",()=>M.resolvePlanAssets(p,{...e.assets,signal:s.signal})):{plan:p,diagnostics:[]},E=y.plan;i.push(...I(y.diagnostics));const O=E.pages.reduce((l,x)=>l+x.components.reduce((v,R)=>v+C(R),0),0);o.assertBudget(t,"maxPages",E.pages.length),o.assertBudget(t,"maxCells",O);const S=b.reportFontFingerprint(s.pdf),V=e.pagination?.measurer||Object.values(e.reports).some(l=>l.pagination?.measurer);return{plan:E,diagnostics:i,revisions:h,sources:w,layout:{textMetrics:S?"font-bytes":V?"provided":"heuristic",...S?{fontFingerprint:S}:{}},stats:{rows:g,pages:E.pages.length,cells:O,durationMs:Date.now()-m}}},c=async s=>{const r=Date.now();if(s.format!=="pdf"&&s.format!=="xlsx")throw new n.ReportSourceError("config","不支持的报表导出格式");const m=s.format==="pdf"?await import("@agile-team/mach-report/pdf"):void 0;o.throwIfAborted(s.signal);const g=s.pdf?.customFontFaces??(s.pdf?.customFontBytes?{regular:s.pdf.customFontBytes}:void 0),u=m&&g?m.createFontBytesMeasurer(g):void 0,i=await a(s,u);return o.throwIfAborted(s.signal),L({...s,prepared:i},t,r)};return{describe:s=>H(e.reports,s),validate:s=>j(e.reports,s),prepare:s=>o.controlled(s.signal,t.maxDurationMs,async r=>{const{signal:m,onEvent:g,...u}=$(s),i={...u,...u.pdf?{pdf:b.snapshotPdfFonts(u.pdf)}:{},taskId:u.taskId??n.reportTaskId()},h=g?y=>n.notifyReportTaskEvent(g,y,r):void 0,w={...i,signal:r,onEvent:h};n.createReportTaskReporter(w).runSync("validate",()=>q(e,i));let d;const f=i.pdf?.customFontFaces??(i.pdf?.customFontBytes?{regular:i.pdf.customFontBytes}:void 0);if(!e.executor&&f){const y=await import("@agile-team/mach-report/pdf");o.throwIfAborted(r),d=y.createFontBytesMeasurer(f)}const p=e.executor?await e.executor.prepare(i,r,h):await a(w,d);return F(p,t)}),exportPrepared:s=>o.controlled(s.signal,t.maxDurationMs,async r=>{const m=Date.now(),{signal:g,onEvent:u,...i}=s,h=F(b.snapshotPreparedReport(s.prepared,t.maxPreparedBytes??64e6,r),t),w={...i,xlsx:b.snapshotXlsxOptions(i.xlsx),prepared:h,...i.pdf?{pdf:b.snapshotPdfFonts(i.pdf)}:{},taskId:i.taskId??n.reportTaskId()};if(w.format!=="pdf"&&w.format!=="xlsx")throw new n.ReportSourceError("config","不支持的报表导出格式");const d=u?p=>n.notifyReportTaskEvent(u,p,r):void 0;if(e.executor){if(!e.executor.exportPrepared)throw new n.ReportSourceError("config","执行器未实现 exportPrepared;请升级执行器或显式使用本地运行时");const p=await e.executor.exportPrepared(w,r,d);return o.assertBudget(t,"maxRows",p.stats.rows),o.assertBudget(t,"maxPages",p.stats.pages),o.assertBudget(t,"maxCells",p.stats.cells),o.assertBudget(t,"maxOutputBytes",p.bytes.byteLength),{...p,stats:{...p.stats,outputBytes:p.bytes.byteLength}}}const f={...w,signal:r,onEvent:d};if(n.createReportTaskReporter(f).runSync("validate",()=>b.checkPreparedFont(f)),e.assets){const p=await n.createReportTaskReporter(f).run("assets",()=>M.resolvePlanAssets(h.plan,{...e.assets,signal:r}));h.plan=p.plan,h.diagnostics.push(...I(p.diagnostics))}return L(f,t,m)}),export:s=>o.controlled(s.signal,t.maxDurationMs,async r=>{const{signal:m,onEvent:g,...u}=$(s),i={...u,xlsx:b.snapshotXlsxOptions(u.xlsx),...u.pdf?{pdf:b.snapshotPdfFonts(u.pdf)}:{},taskId:u.taskId??n.reportTaskId()},h=g?f=>n.notifyReportTaskEvent(g,f,r):void 0,w={...i,signal:r,onEvent:h};if(n.createReportTaskReporter(w).runSync("validate",()=>q(e,i)),i.format!=="pdf"&&i.format!=="xlsx")throw new n.ReportSourceError("config","不支持的报表导出格式");const d=e.executor?await e.executor.export(i,r,h):await c(w);return o.assertBudget(t,"maxRows",d.stats.rows),o.assertBudget(t,"maxPages",d.stats.pages),o.assertBudget(t,"maxCells",d.stats.cells),o.assertBudget(t,"maxOutputBytes",d.bytes.byteLength),{...d,stats:{...d.stats,outputBytes:d.bytes.byteLength}}})}}exports.createReportRuntime=K;exports.enforcePrepared=F;
|
package/dist/style-67OqfNed.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const c = 1.35, S = 10.5, u = '"Microsoft YaHei", sans-serif', P = 0.75, s = "#333333", f = "#000000", _ = "1.0.0-mach", T = 25.4, h = 96;
|
|
2
|
-
function i(t = 96) {
|
|
3
|
-
return t / 25.4;
|
|
4
|
-
}
|
|
5
|
-
function l(t, n = 96) {
|
|
6
|
-
return (t || 0) * i(n);
|
|
7
|
-
}
|
|
8
|
-
function m(t, n = 96) {
|
|
9
|
-
return t / i(n);
|
|
10
|
-
}
|
|
11
|
-
function a(t, n = 96) {
|
|
12
|
-
return t * n / 72;
|
|
13
|
-
}
|
|
14
|
-
function E(t, n) {
|
|
15
|
-
const o = 10 ** n;
|
|
16
|
-
return Math.round(t * o) / o;
|
|
17
|
-
}
|
|
18
|
-
const M = {
|
|
19
|
-
a3: { widthMm: 297, heightMm: 420 },
|
|
20
|
-
a4: { widthMm: 210, heightMm: 297 },
|
|
21
|
-
a5: { widthMm: 148, heightMm: 210 },
|
|
22
|
-
b4: { widthMm: 250, heightMm: 353 },
|
|
23
|
-
b5: { widthMm: 176, heightMm: 250 }
|
|
24
|
-
};
|
|
25
|
-
function C(t, n = 96, o = 10.5) {
|
|
26
|
-
if (t?.fontSizePx != null)
|
|
27
|
-
return { fontSizePt: t.fontSizePx * 72 / n, fontSizePx: t.fontSizePx };
|
|
28
|
-
const e = t?.fontSize ?? o;
|
|
29
|
-
return { fontSizePt: e, fontSizePx: a(e, n) };
|
|
30
|
-
}
|
|
31
|
-
function x(t, n = s) {
|
|
32
|
-
return {
|
|
33
|
-
color: t?.borderColor ?? t?.lineColor ?? n,
|
|
34
|
-
widthPt: t?.lineWidthPt ?? 0.75
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function z(t, n = f) {
|
|
38
|
-
return t?.color ?? n;
|
|
39
|
-
}
|
|
40
|
-
function D(t) {
|
|
41
|
-
return t?.lineHeight ?? 1.35;
|
|
42
|
-
}
|
|
43
|
-
function L(t) {
|
|
44
|
-
const n = t?.borderTop !== !1, o = t?.borderRight !== !1, e = t?.borderBottom !== !1, r = t?.borderLeft !== !1;
|
|
45
|
-
return { top: n, right: o, bottom: e, left: r, inner: n || o || e || r };
|
|
46
|
-
}
|
|
47
|
-
function d(t, n) {
|
|
48
|
-
const o = { ...t, ...n };
|
|
49
|
-
return n?.fontSize != null && n.fontSizePx == null && delete o.fontSizePx, n?.fontSizePx != null && n.fontSize == null && delete o.fontSize, o;
|
|
50
|
-
}
|
|
51
|
-
export {
|
|
52
|
-
h as C,
|
|
53
|
-
u as D,
|
|
54
|
-
c as L,
|
|
55
|
-
T as M,
|
|
56
|
-
M as P,
|
|
57
|
-
_ as S,
|
|
58
|
-
E as a,
|
|
59
|
-
D as b,
|
|
60
|
-
f as c,
|
|
61
|
-
x as d,
|
|
62
|
-
L as e,
|
|
63
|
-
d as f,
|
|
64
|
-
z as g,
|
|
65
|
-
P as h,
|
|
66
|
-
S as i,
|
|
67
|
-
s as j,
|
|
68
|
-
i as k,
|
|
69
|
-
m as l,
|
|
70
|
-
l as m,
|
|
71
|
-
a as p,
|
|
72
|
-
C as r
|
|
73
|
-
};
|
package/dist/style-C22Pbv3T.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const E='"Microsoft YaHei", sans-serif';const i="#333333",T="#000000",P="1.0.0-mach";function r(o=96){return o/25.4}function f(o,t=96){return(o||0)*r(t)}function c(o,t=96){return o/r(t)}function S(o,t=96){return o*t/72}function s(o,t){const n=10**t;return Math.round(o*n)/n}const u={a3:{widthMm:297,heightMm:420},a4:{widthMm:210,heightMm:297},a5:{widthMm:148,heightMm:210},b4:{widthMm:250,heightMm:353},b5:{widthMm:176,heightMm:250}};function l(o,t=96,n=10.5){if(o?.fontSizePx!=null)return{fontSizePt:o.fontSizePx*72/t,fontSizePx:o.fontSizePx};const e=o?.fontSize??n;return{fontSizePt:e,fontSizePx:S(e,t)}}function m(o,t=i){return{color:o?.borderColor??o?.lineColor??t,widthPt:o?.lineWidthPt??.75}}function M(o,t=T){return o?.color??t}function L(o){return o?.lineHeight??1.35}function F(o){const t=o?.borderTop!==!1,n=o?.borderRight!==!1,e=o?.borderBottom!==!1,_=o?.borderLeft!==!1;return{top:t,right:n,bottom:e,left:_,inner:t||n||e||_}}function C(o,t){const n={...o,...t};return t?.fontSize!=null&&t.fontSizePx==null&&delete n.fontSizePx,t?.fontSizePx!=null&&t.fontSize==null&&delete n.fontSize,n}exports.CSS_DPI=96;exports.DEFAULT_BORDER_PT=.75;exports.DEFAULT_FONT_FAMILY=E;exports.DEFAULT_FONT_PT=10.5;exports.DEFAULT_STROKE_COLOR=i;exports.DEFAULT_TEXT_COLOR=T;exports.LINE_HEIGHT=1.35;exports.MM_PER_INCH=25.4;exports.PAPER_SIZES=u;exports.SCHEMA_VERSION_MACH=P;exports.mergeComponentStyles=C;exports.mmToPx=f;exports.mmToPxFactor=r;exports.ptToPx=S;exports.pxToMm=c;exports.resolveBoxBorders=F;exports.resolveFontSize=l;exports.resolveLineHeight=L;exports.resolveStroke=m;exports.resolveTextColor=M;exports.round=s;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const f=require("./template-registry-DzWswQI5.cjs"),T=require("./template-bindings-Cg5oBLFT.cjs"),g=require("./style-C22Pbv3T.cjs");function p(t){return JSON.parse(JSON.stringify(t))}function u(t){return{...t.repeatDataset?{repeat:{dataset:t.repeatDataset}}:{},pages:[{widthMm:4999,heightMm:4999,components:t.components}]}}function y(t){if(!t.id.trim()||!t.name.trim()||!t.revision.trim())throw new Error("Fragment identity, name and revision are required");if(!t.components.length||t.components.length>200)throw new RangeError("A fragment must contain 1–200 components");f.parseReportTemplate({schemaVersion:"1.0",id:t.id,name:t.name,template:u(t)})}function E(t,n,e,a){const r=f.parseReportTemplate(t).template.pages[n];if(!r||!e.length||e.some(o=>!Number.isSafeInteger(o)||!r.components[o]))throw new Error("Select existing components to capture a fragment");const s=[...new Set(e)].map(o=>r.components[o]),l=Math.min(...s.map(o=>o.leftMm)),i=Math.min(...s.map(o=>o.topMm)),m={...a,...t.template.repeat?{repeatDataset:t.template.repeat.dataset}:{},components:p(s).map(o=>({...o,leftMm:o.leftMm-l,topMm:o.topMm-i}))};return y(m),m}function b(t){y(t);const n=new Map;for(const e of T.collectTemplateDatasetBindings(u(t))){const a=n.get(e.dataset)??new Set;for(const r of e.fields)!e.generated.has(r.field)&&!e.summaries.has(r.field)&&a.add(r.field);n.set(e.dataset,a)}return[...n].map(([e,a])=>({dataset:e,fields:[...a]}))}function S(t,n,e){const a=n.replace(/^\$\.template\./,"").replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const s of a.slice(0,-1))r=r[s];r[a[a.length-1]]=e}function F(t,n,e={}){const a=u({...t,components:n});for(const r of T.collectTemplateDatasetBindings(a)){for(const l of r.fields){const i=e.fields?.[r.dataset]?.[l.field];i!==void 0&&S(a,l.path,i)}const s=e.datasets?.[r.dataset];s!==void 0&&S(a,`${r.path}.dataset`,s)}}function h(t){if(!t||typeof t!="object")return;if(Array.isArray(t)){t.forEach(h);return}const n=t;for(const e of["nid","rkey","table","source"])delete n[e];if(n.kind==="list"&&delete n.id,n.meta&&typeof n.meta=="object")for(const e of["fragment","labelSource","record"])delete n.meta[e];Object.values(n).forEach(h)}function D(t){const n=new Set(t.template.pages.flatMap(a=>a.components.map(r=>r.meta?.fragment?.instance)));let e=1;for(;n.has(`fragment-${e}`);)e++;return`fragment-${e}`}function R(t,n,e){const a=e?t.components.flatMap((s,l)=>s.meta?.fragment?.instance===e?[l]:[]):[];if(e&&!a.length)throw new Error("Fragment instance no longer exists");const r=a.map(s=>t.components[s]);if(r.some(s=>s.meta?.fragment?.id!==n.id))throw new Error("An upgrade must use the same fragment identity");return{replacing:a,left:r.length?Math.min(...r.map(s=>s.leftMm)):t.marginLeftMm??0,top:r.length?Math.min(...r.map(s=>s.topMm)):t.marginTopMm??0}}function x(t,n){if(n.some(e=>e.leftMm<0||e.topMm<0||e.leftMm+e.widthMm>t.widthMm+.001||e.topMm+(e.kind==="list"?e.rowHeightMm??7:e.heightMm)>t.heightMm+.001))throw new Error("Fragment exceeds the target page; choose a larger page or adjust its placement")}function k(t,n,e){y(n);const a=f.parseReportTemplate(t),r=a.template.pages[e.pageIndex];if(!r||r.flow)throw new Error("Choose a fixed page before inserting a fragment");const s=R(r,n,e.replaceInstance),l=s.replacing,i=e.leftMm??s.left,m=e.topMm??s.top,o=p(n.components),M=e.replaceInstance??D(a);if(n.repeatDataset&&a.template.repeat?.dataset!==(e.bindings?.datasets?.[n.repeatDataset]??n.repeatDataset))throw new Error("Bind this label fragment to the current record dataset");F(n,o,e.bindings),o.forEach(h),o.forEach((c,d)=>{c.leftMm+=i,c.topMm+=m,c.meta={...c.meta,fragment:{id:n.id,revision:n.revision,instance:M,slot:d}}}),x(r,o);const w=l[0]??r.components.length;return r.components=r.components.filter((c,d)=>!l.includes(d)),r.components.splice(w,0,...o),{document:f.parseReportTemplate(a),componentIndices:o.map((c,d)=>w+d),instance:M}}function C(t,n,e,a){const r=f.parseReportTemplate(t),s=r.template.pages[n];if(!s)throw new Error("Page no longer exists");for(const l of e){const i=s.components[l];if(!i)throw new Error("Component no longer exists");i.kind==="list"?a.target==="header"?I(i,a.style):i.columns.forEach(m=>{m.style=g.mergeComponentStyles(m.style,p(a.style)),a.style.align&&(m.align=a.style.align)}):i.style=g.mergeComponentStyles(i.style,p(a.style))}return f.parseReportTemplate(r)}function I(t,n){if(t.headerStyle=g.mergeComponentStyles(t.headerStyle,p(n)),t.columns.forEach(e=>{e.headerStyle=g.mergeComponentStyles(e.headerStyle,p(n)),n.align&&(e.headerAlign=n.align)}),t.headerGrid)for(const e of t.headerGrid.cells)for(const a of e)a&&(a.style=g.mergeComponentStyles(a.style,p(n)))}exports.applyReportDocumentStyle=C;exports.captureTemplateFragment=E;exports.insertTemplateFragment=k;exports.inspectTemplateFragmentBindings=b;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const I=require("./computed-4TnxzgIh.cjs"),H=require("./matrix-0hywp0-F.cjs"),v=require("./component-tree-6TV7W6Yj.cjs"),ae=require("./code-options-BUTChiZZ.cjs"),J=require("./param-validation-C-8sRJLq.cjs"),P=require("./column-visual-CtYxnBCP.cjs");function oe(e,i,t){e!==void 0&&(typeof e!="string"||!e.trim()||e.length>4096)&&t.push({path:i,message:"来源范围应为不超过 4096 字符的非空字符串"})}function W(e,i,t){e.editable!==void 0&&typeof e.editable!="boolean"&&t.push({path:`${i}.editable`,message:"编辑控制应为布尔值"}),e.valueType!==void 0&&!["text","number","boolean"].includes(e.valueType)&&t.push({path:`${i}.valueType`,message:"编辑类型应为 text、number 或 boolean"})}function fe(e,i,t){W(e,i,t),e.indentMm!==void 0&&(typeof e.indentMm!="number"||!Number.isFinite(e.indentMm)||e.indentMm<0)&&t.push({path:`${i}.indentMm`,message:"单元格缩进应为有限非负数"}),e.derived!==void 0&&typeof e.derived!="boolean"&&t.push({path:`${i}.derived`,message:"派生结果标记应为布尔值"}),G(e.source,`${i}.source`,t,!0),e.formula!==void 0&&typeof e.formula!="string"&&t.push({path:`${i}.formula`,message:"单元格公式应为字符串"})}function G(e,i,t,s=!1){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)){t.push({path:i,message:"业务来源应为对象"});return}const n=e;oe(n.sourceScope,`${i}.sourceScope`,t);for(const a of["datasetId",...s?["field"]:[]])(typeof n[a]!="string"||!n[a].trim())&&t.push({path:`${i}.${a}`,message:"业务标识应为非空字符串"});for(const a of["rowKey","revision"]){const o=n[a];o===void 0&&!(s&&a==="rowKey")||typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o))&&t.push({path:`${i}.${a}`,message:"业务键及修订号应为字符串或有限数字"})}n.sourceToken!==void 0&&typeof n.sourceToken!="string"&&t.push({path:`${i}.sourceToken`,message:"来源令牌应为字符串"})}const re=new Set(["text","image","barcode","qrcode","chart","line","rect","ellipse"]);function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function k(e){return e===null?"null":typeof e=="string"?JSON.stringify(e.slice(0,120)):["number","boolean","undefined"].includes(typeof e)?String(e):`[${typeof e}]`}function de(e,i,t,s){const n=e[i];(typeof n!="number"||!Number.isFinite(n))&&s.push({path:`${t}.${i}`,message:`应为有限数字,实际 ${k(n)}`})}function ue(e,i,t){if(e!==void 0){const s=`${i}.table`;if(!g(e))t.push({path:s,message:"逻辑表来源应为对象"});else{G(e.source,`${s}.source`,t),(typeof e.id!="string"||!e.id.trim())&&t.push({path:`${s}.id`,message:"逻辑表 ID 应为非空字符串"});const n=e.role;["header","body","group-header","subtotal","grand-total"].includes(n)||t.push({path:`${s}.role`,message:"未知逻辑表行角色"});const a=e.rowIndex;(typeof a!="number"||!Number.isInteger(a)||(n==="header"?a!==-1:a<0))&&t.push({path:`${s}.rowIndex`,message:"表头索引应为 -1,内容行索引应为非负整数"}),(!Array.isArray(e.columnKeys)||e.columnKeys.some(o=>typeof o!="string"))&&t.push({path:`${s}.columnKeys`,message:"逻辑列字段应为字符串数组"}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${s}.layout`,message:"布局应为 page 或 wide"}),e.title!==void 0&&typeof e.title!="string"&&t.push({path:`${s}.title`,message:"逻辑表名称应为字符串"})}}}function he(e,i,t,s){if(e!==void 0)if(!g(e)||!Array.isArray(e.cells))t.push({path:`${i}.grid.cells`,message:"grid.cells 应为二维数组"});else{const n=e.paddingMm;n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<0)&&t.push({path:`${i}.grid.paddingMm`,message:"单元格内距应为有限非负数"}),e.cells.forEach((a,o)=>{if(!Array.isArray(a)){t.push({path:`${i}.grid.cells.${o}`,message:"行应为数组"});return}a.forEach((f,r)=>{if(f==null)return;const d=`${i}.grid.cells.${o}.${r}`;if(!g(f)){t.push({path:d,message:"网格单元格应为对象或 null"});return}fe(f,d,t),f.dataBar!==void 0&&!v.validDataBar(f.dataBar)&&t.push({path:`${d}.dataBar`,message:"数据条应包含 0–1 有序比例与 #RRGGBB 颜色"}),U(f.richParagraphs,d,t),Array.isArray(f.children)&&f.children.forEach((u,p)=>{C(u,`${i}.grid.cells.${o}.${r}.children.${p}`,t,s)})})})}}function S(e,i,t,s){e!==void 0&&!i.includes(e)&&s.push({path:t,message:"未知富文本属性值"})}function O(e,i,t,s,n=0){for(const a of i){const o=e[a];o!==void 0&&(typeof o!="number"||!Number.isFinite(o)||o<n)&&s.push({path:`${t}.${a}`,message:"富文本数值应为范围内有限数字"})}}function me(e,i,t){if(e!==void 0){if(!g(e)){t.push({path:i,message:"富文本样式应为对象"});return}for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本样式应为字符串"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])e[s]!==void 0&&typeof e[s]!="boolean"&&t.push({path:`${i}.${s}`,message:"富文本样式应为布尔值"});O(e,["fontSize","fontSizePx","lineWidthPt","lineHeight","opacity"],i,t),O(e,["letterSpacing","rotateDeg"],i,t,-1/0),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于1"}),S(e.align,["left","center","right","justify"],`${i}.align`,t),S(e.verticalAlign,["top","middle","bottom"],`${i}.verticalAlign`,t)}}function ce(e,i,t){if(!g(e)){t.push({path:i,message:"富文本片段应为对象"});return}S(e.kind,["text","field"],`${i}.kind`,t);for(const s of["text","field"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本内容应为字符串"});me(e.style,`${i}.style`,t)}function U(e,i,t){if(e!==void 0){if(!Array.isArray(e)){t.push({path:`${i}.richParagraphs`,message:"richParagraphs 应为数组"});return}e.forEach((s,n)=>{const a=`${i}.richParagraphs.${n}`;if(!g(s)||!Array.isArray(s.segments)){t.push({path:a,message:"段落缺少 segments 数组"});return}S(s.align,["left","center","right","justify"],`${a}.align`,t),O(s,["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"],a,t),s.segments.forEach((o,f)=>ce(o,`${a}.segments.${f}`,t))})}}function _(e,i,t,s=[]){const n=v.componentTreeIssue([e],i);if(n){t.push(n);return}C(e,i,t,s)}function C(e,i,t,s=[]){if(!g(e)){t.push({path:i,message:"组件应为对象"});return}const n=e.kind;typeof n!="string"?t.push({path:`${i}.kind`,message:"组件缺少 kind 字符串"}):re.has(n)||s.push({path:`${i}.kind`,message:`未知组件类型 ${k(n)},将以兜底方式渲染`});for(const a of["leftMm","topMm","widthMm","heightMm"])de(e,a,i,t);typeof e.leftMm=="number"&&e.leftMm<-100&&t.push({path:`${i}.leftMm`,message:"几何数值异常(leftMm<-100)"});for(const a of["widthMm","heightMm"])typeof e[a]=="number"&&e[a]<0&&t.push({path:`${i}.${a}`,message:"组件尺寸不能为负数"});ue(e.table,i,t),pe(e.code,n,i,t),ge(e,i,t),e.pageAnchor!==void 0&&!["header","footer"].includes(e.pageAnchor)&&t.push({path:`${i}.pageAnchor`,message:"页面锚点应为 header 或 footer"}),e.lineDirection!==void 0&&!["down","up"].includes(e.lineDirection)&&t.push({path:`${i}.lineDirection`,message:"线段方向应为 down 或 up"}),he(e.grid,i,t,s),U(e.richParagraphs,i,t)}function ge(e,i,t){if(e.chartBinding!==void 0)try{if(H.validateReportChartBinding(e.chartBinding),e.kind!=="chart"||["binding","imageData","grid","pageAnchor"].some(s=>e[s]!==void 0))throw new Error("绑定图表不能设置图片、网格、记录绑定或页眉页脚");if(typeof e.widthMm!="number"||e.widthMm<45||typeof e.heightMm!="number"||e.heightMm<35)throw new Error("绑定图表至少需要 45×35mm")}catch(s){t.push({path:`${i}.chartBinding`,message:s instanceof Error?s.message:String(s)})}}function pe(e,i,t,s){if(e!==void 0)for(const n of ae.codeOptionIssues(e,i))s.push({path:`${t}.code${n.path?`.${n.path}`:""}`,message:n.message})}function q(e,i,t){if(!g(e))return;e.binding!==void 0&&t.push({path:`${i}.binding`,message:"渲染计划不允许未解析字段绑定"}),e.chartBinding!==void 0&&t.push({path:`${i}.chartBinding`,message:"渲染计划不允许未解析图表绑定"});const s=e.grid;!g(s)||!Array.isArray(s.cells)||s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,f)=>{!g(o)||!Array.isArray(o.children)||o.children.forEach((r,d)=>q(r,`${i}.grid.cells.${a}.${f}.children.${d}`,t))})})}function z(e,i,t,s=[]){if(!g(e)){t.push({path:i,message:"页应为对象"});return}const n=e.pageWidthMm,a=e.pageHeightMm;(typeof n!="number"||!Number.isFinite(n)||n<=0)&&t.push({path:`${i}.pageWidthMm`,message:`页宽非法: ${k(n)}`}),(typeof a!="number"||!(a>0&&a<5e3))&&t.push({path:`${i}.pageHeightMm`,message:`页高非法: ${k(a)}`}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"});const o=e.components;if(!Array.isArray(o))t.push({path:`${i}.components`,message:"components 应为数组"});else if(Array.isArray(o)){const f=v.componentTreeIssue(o,`${i}.components`);if(f){t.push(f);return}o.forEach((r,d)=>{C(r,`${i}.components.${d}`,t,s),q(r,`${i}.components.${d}`,t)})}}function X(e){const i=[],t=[],s=g(e)?e.pages:void 0;if(g(e)&&e.requiresRecalculation!==void 0&&typeof e.requiresRecalculation!="boolean"&&i.push({path:"$.requiresRecalculation",message:"重算能力要求应为布尔值"}),!Array.isArray(s))i.push({path:"$.pages",message:e==null?"渲染计划为空":"渲染计划缺少 pages 数组"});else{const n=v.renderTreeIssue(s);if(n)return{ok:!1,errors:[...i,n],warnings:t};s.forEach((o,f)=>z(o,`$.pages.${f}`,i,t)),s.length>2e3&&t.push({path:"$.pages",message:`页数异常大(${s.length} 页),渲染与打印耗时可能显著增加`});const a=s.reduce((o,f)=>o+(g(f)&&Array.isArray(f.components)?f.components.length:0),0);a>5e4&&t.push({path:"$.pages",message:`组件总数异常大(${a} 个),可能触发浏览器性能限制`})}return{ok:i.length===0,errors:i,warnings:t}}function ye(e){const i=X(e);if(!i.ok){const t=i.errors.slice(0,3).map(s=>`${s.path}: ${s.message}`).join("; ");throw new Error(`渲染计划校验失败(${i.errors.length} 处): ${t}`)}return e.pages}function L(e){return e.kind==="list"?e.id:e.nid}function le(e){return e.kind==="list"?!1:e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&/\{(?:page|totalPages)\}/.test(e.text)}function $e(e,i){const t=e.filter(n=>i.componentIds.includes(L(n)??""));if(t.filter(n=>n.kind==="list"&&n.cardinality!=="record").length&&t.length!==1)throw new Error("纵向重复区域必须独占流式分段,不能与静态或单记录区域并排");for(const n of t){const a=n.kind==="list"?n.topMm+(n.rowHeightMm??0):n.topMm+n.heightMm;if(n.topMm<i.topMm-.001||a>i.topMm+i.heightMm+.001)throw new Error("流式分段应完整包含其组件的原始纵向范围")}}function be(e,i){if(!i)return e.map(s=>({components:[s]}));const t=new Map(e.map(s=>[L(s),s]));return i.bands.map(s=>({band:s,components:s.componentIds.map(n=>{const a=t.get(n);if(!a)throw new Error(`流式区域引用不存在的组件:${n}`);return a})}))}function Y(e,i){if(!i||!Array.isArray(i.bands)||!i.bands.length||i.bands.length>1e4)throw new Error("流式排版应包含 1–10000 个区域");const t=new Set,s=new Set;for(const n of e){if(le(n))continue;const a=L(n);if(!a||t.has(a))throw new Error("流式排版组件应具有唯一标识");t.add(a)}if(Ae(e,i,t,s),s.size!==t.size)throw new Error("流式排版必须显式包含每个非锚点组件")}function Ae(e,i,t,s){let n=-1/0;for(const a of i.bands){if(!Number.isFinite(a.topMm)||!Number.isFinite(a.heightMm)||a.topMm<0||a.heightMm<=0||a.topMm<n-.001)throw new Error("流式区域应按原始位置排序,尺寸有效且不重叠");if(!Array.isArray(a.componentIds)||!a.componentIds.length)throw new Error("流式区域不能没有组件");for(const o of a.componentIds){if(!t.has(o)||s.has(o))throw new Error(`流式区域组件缺失、重复或包含页锚点:${o}`);s.add(o)}$e(e,a),n=a.topMm+a.heightMm}}const we=new Set(["__proto__","prototype","constructor"]);function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function E(e){return typeof e=="string"&&!!e.trim()&&!we.has(e)}function R(e,i,t,s){for(const n of Object.keys(e))i.includes(n)||s.push({path:`${t}.${n}`,message:"存在未知配置字段"})}function Me(e,i,t){if(e!==void 0){if(!l(e)||!["number","percent","date"].includes(String(e.kind))){t.push({path:i,message:"绑定格式应为 number、percent 或 date"});return}R(e,e.kind==="date"?["kind","pattern"]:e.kind==="number"?["kind","digits","thousands"]:["kind","digits"],i,t),e.digits!==void 0&&(!Number.isInteger(e.digits)||Number(e.digits)<0||Number(e.digits)>100)&&t.push({path:`${i}.digits`,message:"精度应为 0..100 整数"}),e.thousands!==void 0&&typeof e.thousands!="boolean"&&t.push({path:`${i}.thousands`,message:"千分位开关应为布尔值"}),e.pattern!==void 0&&typeof e.pattern!="string"&&t.push({path:`${i}.pattern`,message:"日期格式应为字符串"})}}function ve(e,i,t){const s=e.binding;if(s===void 0)return;const n=`${i}.binding`;if(!l(s)){t.push({path:n,message:"字段绑定应为对象"});return}(!["text","image","barcode","qrcode"].includes(String(e.kind))||e.grid!==void 0)&&t.push({path:n,message:"绑定仅支持独立文本、图片、条码与二维码组件"}),R(s,["field","format","prefix","suffix","emptyText"],n,t),E(s.field)||t.push({path:`${n}.field`,message:"绑定字段应为安全的非空字段名(按字面读取自有字段)"});for(const a of["prefix","suffix","emptyText"])s[a]!==void 0&&typeof s[a]!="string"&&t.push({path:`${n}.${a}`,message:"应为字符串"});Me(s.format,`${n}.format`,t),e.kind==="image"&&["format","prefix","suffix"].some(a=>s[a]!==void 0)&&t.push({path:n,message:"图片绑定直接读取 PNG/JPEG data URL,不支持文本格式或前后缀"})}function Ee(e,i){if(!l(e)){i.push({path:"$.repeat",message:"逐记录配置应为对象"});return}R(e,["dataset","rowKey","copies"],"$.repeat",i),E(e.dataset)||i.push({path:"$.repeat.dataset",message:"数据集应为安全的非空名称"}),e.rowKey!==void 0&&!E(e.rowKey)&&i.push({path:"$.repeat.rowKey",message:"业务主键应为安全的非空字段名"});const t=e.copies;t!==void 0&&(l(t)?(R(t,["field"],"$.repeat.copies",i),E(t.field)||i.push({path:"$.repeat.copies.field",message:"复制数字段应为安全的非空字段名"})):(!Number.isSafeInteger(t)||Number(t)<1||Number(t)>1e3)&&i.push({path:"$.repeat.copies",message:"每条记录复制数应为 1..1000 整数"}))}function Q(e,i,t,s){if(!l(e))return;ve(e,i,s),e.binding!==void 0&&!t&&s.push({path:`${i}.binding`,message:"字段绑定需要模板 repeat 数据集;普通报表请使用列表字段"}),t&&e.kind==="list"&&s.push({path:i,message:"逐记录标签使用固定组件;动态列表请使用普通报表模板"}),e.chartBinding!==void 0&&(t||i.includes(".children."))&&s.push({path:`${i}.chartBinding`,message:"数据图表应放在普通报表的页面或流式分区,不放在逐记录标签或嵌套单元格内"});const n=e.grid;l(n)&&Array.isArray(n.cells)&&n.cells.forEach((a,o)=>{Array.isArray(a)&&a.forEach((f,r)=>{l(f)&&Array.isArray(f.children)&&f.children.forEach((d,u)=>Q(d,`${i}.grid.cells.${o}.${r}.children.${u}`,t,s))})})}function Z(e,i){const t=e.repeat!==void 0;t&&Ee(e.repeat,i),Array.isArray(e.pages)&&e.pages.forEach((s,n)=>{if(!l(s))return;const a=`$.pages.${n}`;t&&(s.layout==="wide"||s.flow!==void 0)&&i.push({path:a,message:"逐记录标签仅支持固定尺寸页面,不支持宽表或流式分区"}),Array.isArray(s.components)&&s.components.forEach((o,f)=>{const r=`${a}.components.${f}`;if(Q(o,r,t,i),!t||!l(o))return;const{leftMm:d,topMm:u,widthMm:p,heightMm:y}=o;[d,u,p,y,s.widthMm,s.heightMm].every(A=>typeof A=="number"&&Number.isFinite(A))&&(Number(d)<0||Number(u)<0||Number(d)+Number(p)>Number(s.widthMm)+.001||Number(u)+Number(y)>Number(s.heightMm)+.001)&&i.push({path:r,message:"标签组件超出纸张边界,请调整位置或尺寸"})})})}function Ne(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function F(e,i,t){if(e!==void 0)try{I.compileReportPredicate(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function ee(e,i,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>2048){t.push({path:i,message:"聚合应为数组且最多 2048 项"});return}const s=new Set;e.forEach((n,a)=>{const o=`${i}.${a}`;if(!Ne(n)){t.push({path:o,message:"聚合应为对象"});return}const f=n.field;typeof f!="string"||!f.trim()||s.has(f)?t.push({path:`${o}.field`,message:"聚合输出字段应非空且唯一"}):s.add(f),n.numeric!==void 0&&n.numeric!=="number"&&n.numeric!=="decimal"&&t.push({path:`${o}.numeric`,message:"数值模式应为 number 或 decimal"}),n.digits!==void 0&&(!Number.isInteger(n.digits)||Number(n.digits)<0||Number(n.digits)>100)&&t.push({path:`${o}.digits`,message:"小数位应为 0–100 的整数"});try{I.createAggregateAccumulator({...n,field:n.valueField??f})}catch(r){t.push({path:o,message:r instanceof Error?r.message:String(r)})}})}function ke(e,i,t){if(e===void 0)return;const s=I.validateComputedFields(e);for(const n of s.errors)t.push({path:i,message:n})}function Se(e,i,t){if(e!==void 0)try{H.validateMatrixOptions(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function Re(e,i,t){if(e.tree===void 0)return;const s=`${i}.tree`;try{P.validateTreeOptions(e.tree);const n=e.tree;if(e.matrix||e.detail||e.groupBy||Array.isArray(e.groups)&&e.groups.length||e.rowVisibleWhen)throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");if(e.rowKey!==void 0&&e.rowKey!==n.idField)throw new Error("树形 rowKey 应与 idField 一致");if(!Array.isArray(e.columns)||!e.columns.some(a=>a&&a.field===n.labelField&&!a.hidden))throw new Error("树形布局需要可见的标签列");Array.isArray(e.computed)&&P.validateTreeComputed(n,e.computed)}catch(n){t.push({path:s,message:n instanceof Error?n.message:String(n)})}}const D="1.0";class w extends Error{constructor(i){super(`模板校验失败:${i.slice(0,3).map(t=>`${t.path}: ${t.message}`).join("; ")}`),this.errors=i,this.name="ReportTemplateError"}}const xe=new Set(["__proto__","prototype","constructor"]),Te=new Set(["schemaVersion","id","name","revision","description","template"]),Pe=new Set(["left","center","right","justify"]),N=2e5,Oe=64,V=1e7;function h(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Fe(e,i,t){const s=Object.getPrototypeOf(e),n=Array.isArray(e);if(n?s!==Array.prototype:s!==Object.prototype&&s!==null)return t.push({path:i,message:"模板对象必须使用普通 JSON 对象原型"}),!1;if(n){const a=Object.keys(e);if(a.length!==e.length||a.some(o=>!/^(0|[1-9]\d*)$/.test(o)||Number(o)>=e.length))return t.push({path:i,message:"模板数组不能包含空位或额外属性"}),!1}return Object.getOwnPropertySymbols(e).length>0?(t.push({path:i,message:"模板不能包含 Symbol 键"}),!1):!0}function Ie(e,i,t,s){return xe.has(e)?(s.push({path:t,message:"模板不能包含可能污染原型的键"}),!1):i.get||i.set||!i.enumerable?(s.push({path:t,message:"模板不能包含访问器或不可枚举字段"}),!1):!0}function _e(e){return e===null||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function B(e,i){const t=new Set;let s=0,n=0,a=!1;const o=(f,r,d)=>{if(!a){if(++s>N){s===N+1&&i.push({path:r,message:"模板超过 JSON 节点安全上限"});return}if(d>Oe){i.push({path:r,message:"模板嵌套层级过深"});return}if(typeof f=="string"){n+=f.length,n>V&&(a=!0,i.push({path:r,message:"模板文本超过 1000 万字符的安全上限"}));return}if(!_e(f)){if(!f||typeof f!="object"){i.push({path:r,message:"模板只允许 JSON 值,不允许函数、undefined 或非有限数字"});return}if(t.has(f)){i.push({path:r,message:"模板不能包含循环引用"});return}if(Fe(f,r,i)){t.add(f);for(const[u,p]of Object.entries(Object.getOwnPropertyDescriptors(f))){if(Array.isArray(f)&&u==="length")continue;const y=`${r}.${u}`;if(Ie(u,p,y,i)&&o(p.value,y,d+1),s>N||a)break}t.delete(f)}}}};o(e,"$",0)}function m(e,i,t,s,n=!1){const a=e[i];a===void 0&&!n||(typeof a!="string"||n&&!a.trim())&&s.push({path:`${t}.${i}`,message:n?"应为非空字符串":"应为字符串"})}function c(e,i,t,s,n=0,a=!1){const o=e[i];o===void 0&&!a||(typeof o!="number"||!Number.isFinite(o)||o<n)&&s.push({path:`${t}.${i}`,message:`应为大于等于 ${n} 的有限数字`})}function b(e,i,t,s){e[i]!==void 0&&typeof e[i]!="boolean"&&s.push({path:`${t}.${i}`,message:"应为布尔值"})}function M(e,i,t,s=!1){e!==void 0&&!Pe.has(e)&&!(s&&e==="auto")&&t.push({path:i,message:`未知对齐方式${s?"(支持 auto)":""}`})}function $(e,i,t){if(e!==void 0){if(!h(e)){t.push({path:i,message:"样式应为对象"});return}M(e.align,`${i}.align`,t),e.verticalAlign!==void 0&&!["top","middle","bottom"].includes(e.verticalAlign)&&t.push({path:`${i}.verticalAlign`,message:"未知垂直对齐方式"});for(const s of["fontSize","fontSizePx","lineWidthPt","lineHeight"])c(e,s,i,t);for(const s of["letterSpacing","rotateDeg"])c(e,s,i,t,-1/0);c(e,"opacity",i,t),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于 1"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])b(e,s,i,t);for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])m(e,s,i,t)}}function Ce(e,i,t){if(e===void 0)return;if(!Array.isArray(e)){t.push({path:i,message:"参数定义应为数组"});return}const s=new Set,n=t.length;e.forEach((a,o)=>{const f=`${i}.${o}`;if(!h(a)){t.push({path:f,message:"参数定义应为对象"});return}m(a,"field",f,t,!0),typeof a.field=="string"&&(s.has(a.field)&&t.push({path:`${f}.field`,message:"参数名重复"}),s.add(a.field)),a.type!==void 0&&!["text","number","date","month","year","dateRange","select","multiSelect","cascader","numberRange"].includes(a.type)&&t.push({path:`${f}.type`,message:"未知参数类型"});for(const r of["label","defaultValue","placeholder"])m(a,r,f,t);b(a,"required",f,t);for(const r of["minLength","maxLength"]){const d=a[r];d!==void 0&&(typeof d!="number"||!Number.isSafeInteger(d)||d<0)&&t.push({path:`${f}.${r}`,message:"长度边界应为非负整数"})}Le(a,f,t),a.options!==void 0&&(Array.isArray(a.options)?a.options.forEach((r,d)=>{const u=`${f}.options.${d}`;if(!h(r))t.push({path:u,message:"选项应为对象"});else for(const p of["label","value"])typeof r[p]!="string"&&t.push({path:`${u}.${p}`,message:"选项标签与值应为字符串(允许空白选项)"})}):t.push({path:`${f}.options`,message:"选项应为数组"}))}),t.length===n&&t.push(...J.validateReportParamDefinitions(e).map(a=>({path:a.path.replace("$.paramDefs",i),message:a.message})))}function Le(e,i,t){for(const a of["min","max"]){const o=e[a];if(o===void 0)continue;J.isReportTemporalBound(e.type,o)||["number","numberRange"].includes(e.type)&&typeof o=="number"&&Number.isFinite(o)||t.push({path:`${i}.${a}`,message:"数字使用有限数字边界,日期/月/年使用对应规范字符串边界"})}const s=typeof e.min=="number"&&typeof e.max=="number"&&e.min>e.max,n=typeof e.min=="string"&&typeof e.max=="string"&&e.min>e.max;(s||n)&&t.push({path:i,message:"最小边界不能大于最大边界"}),typeof e.minLength=="number"&&typeof e.maxLength=="number"&&e.minLength>e.maxLength&&t.push({path:i,message:"最小长度不能大于最大长度"})}function te(e,i,t){if(!Array.isArray(e)||e.length===0){t.push({path:i,message:"列表至少需要一列"});return}e.every(s=>h(s)&&s.hidden===!0)&&t.push({path:i,message:"列表至少需要一列可见列"}),e.forEach((s,n)=>{const a=`${i}.${n}`;if(!h(s)){t.push({path:a,message:"列应为对象"});return}if(W(s,a,t),s.visual!==void 0&&!P.validColumnVisual(s.visual)&&t.push({path:`${a}.visual`,message:"列可视化配置无效,请检查类型、数值范围和颜色"}),b(s,"hidden",a,t),F(s.visibleWhen,`${a}.visibleWhen`,t),typeof s.header!="string"&&t.push({path:`${a}.header`,message:"表头应为字符串(允许空白表头)"}),m(s,"field",a,t,!0),c(s,"widthMm",a,t,Number.MIN_VALUE,!0),$(s.style,`${a}.style`,t),$(s.headerStyle,`${a}.headerStyle`,t),M(s.align,`${a}.align`,t,!0),M(s.headerAlign,`${a}.headerAlign`,t),s.semanticRole!==void 0&&!["identifier","dimension","measure","date","text"].includes(s.semanticRole)&&t.push({path:`${a}.semanticRole`,message:"未知列语义"}),s.format!==void 0)if(!h(s.format)||!["number","percent","date"].includes(s.format.kind))t.push({path:`${a}.format`,message:"未知列格式"});else{const o=s.format.digits;o!==void 0&&(typeof o!="number"||!Number.isInteger(o)||o<0||o>100)&&t.push({path:`${a}.format.digits`,message:"小数位应为 0–100 的整数"}),b(s.format,"thousands",`${a}.format`,t),m(s.format,"pattern",`${a}.format`,t)}s.rules!==void 0&&(Array.isArray(s.rules)?s.rules.forEach((o,f)=>{const r=`${a}.rules.${f}`;if(!h(o)||!h(o.when)){t.push({path:r,message:"条件格式缺少 when 对象"});return}F(o.when,`${r}.when`,t),$(o.style,`${r}.style`,t)}):t.push({path:`${a}.rules`,message:"条件格式应为数组"}))})}function ie(e,i,t){if(e!==void 0){if(!h(e)){t.push({path:i,message:"分组应为对象"});return}m(e,"field",i,t,!0);for(const s of["headerTemplate","subtotalLabel"])m(e,s,i,t);for(const s of["headerStyle","subtotalStyle"])$(e[s],`${i}.${s}`,t);b(e,"keepWithNext",i,t),b(e,"repeatHeader",i,t),ee(e.aggregates,`${i}.aggregates`,t),e.subtotal!==void 0&&(!Array.isArray(e.subtotal)||e.subtotal.some(s=>typeof s!="string"))&&t.push({path:`${i}.subtotal`,message:"小计字段应为字符串数组"})}}function De(e,i,t){if(!(e===void 0||typeof e=="boolean")){if(!h(e)){t.push({path:i,message:"合计应为布尔值或对象"});return}m(e,"label",i,t),ee(e.aggregates,`${i}.aggregates`,t),$(e.style,`${i}.style`,t),e.fields!==void 0&&(!Array.isArray(e.fields)||e.fields.some(s=>typeof s!="string"))&&t.push({path:`${i}.fields`,message:"合计字段应为字符串数组"})}}function Ve(e,i,t,s){const n={kind:"rect",leftMm:0,topMm:0,widthMm:1,heightMm:1,grid:e};if(_(n,t,s,[]),j(n,t,s),!h(e)||!Array.isArray(e.cells))return;const a=e.cells,o=Array.isArray(i)?i.length:0;if(a.length*o>N){s.push({path:t,message:"表头逻辑网格超过 20 万格安全上限"});return}e.cells.length||s.push({path:`${t}.cells`,message:"表头至少需要一行"}),Array.isArray(e.colWidthsMm)&&e.colWidthsMm.length!==o&&s.push({path:`${t}.colWidthsMm`,message:"表头列宽数量应与列表列数一致"}),Array.isArray(e.rowHeightsMm)&&e.rowHeightsMm.length!==e.cells.length&&s.push({path:`${t}.rowHeightsMm`,message:"表头行高数量应与行数一致"}),Be(a,o,t,s)}function Be(e,i,t,s){const n=new Set;e.forEach((a,o)=>{if(!Array.isArray(a))return;let f=0;a.forEach((r,d)=>{for(;n.has(`${o}:${f}`);)f++;const u=h(r)&&typeof r.colSpan=="number"?r.colSpan:1,p=h(r)&&typeof r.rowSpan=="number"?r.rowSpan:1;(f+u>i||o+p>e.length)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域超出表头边界"});for(let y=o;y<Math.min(e.length,o+p);y++)for(let A=f;A<Math.min(i,f+u);A++)n.has(`${y}:${A}`)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域重叠"}),n.add(`${y}:${A}`);f+=u})})}function je(e,i,t){if(Re(e,i,t),ke(e.computed,`${i}.computed`,t),Se(e.matrix,`${i}.matrix`,t),e.matrix&&(e.detail||e.groupBy||Array.isArray(e.groups)&&e.groups.length||e.grandTotal)&&t.push({path:`${i}.matrix`,message:"矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细"}),F(e.rowVisibleWhen,`${i}.rowVisibleWhen`,t),e.groups!==void 0&&(!Array.isArray(e.groups)||e.groups.length>16?t.push({path:`${i}.groups`,message:"分组应为数组,最多 16 级"}):e.groups.forEach((a,o)=>ie(a,`${i}.groups.${o}`,t))),e.detail===void 0)return;const s=e.detail,n=`${i}.detail`;if(!h(s)){t.push({path:n,message:"主从关联应为对象"});return}for(const a of["dataset","parentKey","foreignKey"])m(s,a,n,t,!0);for(const a of["rowKey","revisionField","sourceTokenField"])m(s,a,n,t,s[a]!==void 0);m(s,"label",n,t),b(s,"header",n,t),c(s,"rowHeightMm",n,t,Number.MIN_VALUE),te(s.columns,`${n}.columns`,t),s.unmatched!==void 0&&s.unmatched!=="error"&&s.unmatched!=="ignore"&&t.push({path:`${n}.unmatched`,message:"未关联明细策略应为 error 或 ignore"})}function Ke(e,i,t){for(const s of["leftMm","topMm"])c(e,s,i,t,-1/0,!0);c(e,"widthMm",i,t,Number.MIN_VALUE,!0),m(e,"dataset",i,t,!0),m(e,"title",i,t);for(const s of["rowKey","revisionField","sourceTokenField"])m(e,s,i,t,e[s]!==void 0);e.headerGrid!==void 0&&Ve(e.headerGrid,e.columns,`${i}.headerGrid`,t),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"}),te(e.columns,`${i}.columns`,t);for(const s of["fontSizePt","rowHeightMm"])c(e,s,i,t,Number.MIN_VALUE);c(e,"paddingMm",i,t);for(const s of["header","headerBold","headerEveryPage","border"])b(e,s,i,t);e.cardinality!==void 0&&e.cardinality!=="record"&&t.push({path:`${i}.cardinality`,message:"单记录区域类型应为 record"}),m(e,"headerBackgroundColor",i,t),M(e.align,`${i}.align`,t,!0),M(e.headerAlign,`${i}.headerAlign`,t),$(e.headerStyle,`${i}.headerStyle`,t),je(e,i,t),ie(e.groupBy,`${i}.groupBy`,t),De(e.grandTotal,`${i}.grandTotal`,t)}function K(e,i,t){Array.isArray(e.richParagraphs)&&e.richParagraphs.forEach((s,n)=>{if(!h(s))return;const a=`${i}.richParagraphs.${n}`;M(s.align,`${a}.align`,t);for(const o of["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"])c(s,o,a,t);Array.isArray(s.segments)&&s.segments.forEach((o,f)=>{const r=`${a}.segments.${f}`;if(!h(o)){t.push({path:r,message:"富文本片段应为对象"});return}o.kind!==void 0&&o.kind!=="text"&&o.kind!=="field"&&t.push({path:`${r}.kind`,message:"未知富文本片段类型"});for(const d of["text","field"])m(o,d,r,t);$(o.style,`${r}.style`,t)})})}function j(e,i,t){$(e.style,`${i}.style`,t);for(const n of["text","rawText","imageData","fallbackText","nid","rkey"])m(e,n,i,t);if(e.lines!==void 0&&(!Array.isArray(e.lines)||e.lines.some(n=>typeof n!="string"))&&t.push({path:`${i}.lines`,message:"文本行应为字符串数组"}),K(e,i,t),!h(e.grid))return;const s=e.grid;c(s,"gapMm",`${i}.grid`,t),c(s,"paddingMm",`${i}.grid`,t);for(const n of["colWidthsMm","rowHeightsMm"]){const a=s[n];a!==void 0&&(!Array.isArray(a)||a.some(o=>typeof o!="number"||!Number.isFinite(o)||o<0))&&t.push({path:`${i}.grid.${n}`,message:"网格尺寸应为有限非负数字数组"})}Array.isArray(s.cells)&&s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,f)=>{const r=`${i}.grid.cells.${a}.${f}`;if(o!==null){if(!h(o)){t.push({path:r,message:"网格单元格应为对象或 null"});return}for(const d of["text","rawText","numberFormat"])m(o,d,r,t);for(const d of["colSpan","rowSpan"]){const u=o[d];u!==void 0&&(typeof u!="number"||!Number.isInteger(u)||u<=0)&&t.push({path:`${r}.${d}`,message:"跨度应为正整数"})}o.value!==void 0&&o.value!==null&&!["string","number","boolean"].includes(typeof o.value)&&t.push({path:`${r}.value`,message:"Excel 原始值应为字符串、数字、布尔值或 null"}),$(o.style,`${r}.style`,t),K(o,r,t),o.children!==void 0&&(Array.isArray(o.children)?o.children.forEach((d,u)=>{h(d)&&j(d,`${r}.children.${u}`,t)}):t.push({path:`${r}.children`,message:"嵌套组件应为数组"}))}})})}function He(e,i,t){if(!(e.flow===void 0||!Array.isArray(e.components)))try{Y(e.components,e.flow)}catch(s){t.push({path:`${i}.flow`,message:s instanceof Error?s.message:String(s)})}}function se(e){const i=[],t=[];return B(e,i),i.length?{ok:!1,errors:i,warnings:t}:(h(e)?(e.schemaVersion!==void 0&&e.schemaVersion!==v.RENDER_PLAN_SCHEMA_VERSION&&i.push({path:"$.schemaVersion",message:"不支持的模板 schemaVersion"}),Ce(e.params,"$.params",i),Z(e,i),!Array.isArray(e.pages)||e.pages.length===0?i.push({path:"$.pages",message:"模板至少需要一页"}):e.pages.forEach((s,n)=>{const a=`$.pages.${n}`;if(!h(s)){i.push({path:a,message:"页应为对象"});return}c(s,"widthMm",a,i,Number.MIN_VALUE,!0),c(s,"heightMm",a,i,Number.MIN_VALUE,!0),s.layout!==void 0&&s.layout!=="page"&&s.layout!=="wide"&&i.push({path:`${a}.layout`,message:"布局应为 page 或 wide"}),typeof s.heightMm=="number"&&s.heightMm>=5e3&&i.push({path:`${a}.heightMm`,message:"页高应小于 5000mm"});for(const o of["marginTopMm","marginBottomMm","marginLeftMm","marginRightMm"])c(s,o,a,i);typeof s.widthMm=="number"&&Number(s.marginLeftMm??0)+Number(s.marginRightMm??0)>=s.widthMm&&i.push({path:a,message:"横向页边距占满页面"}),typeof s.heightMm=="number"&&Number(s.marginTopMm??0)+Number(s.marginBottomMm??0)>=s.heightMm&&i.push({path:a,message:"纵向页边距占满页面"}),Array.isArray(s.components)?s.components.forEach((o,f)=>{const r=`${a}.components.${f}`;h(o)&&o.kind==="list"?Ke(o,r,i):(_(o,r,i,t),h(o)&&j(o,r,i))}):i.push({path:`${a}.components`,message:"组件应为数组"}),He(s,a,i)})):i.push({path:"$",message:"模板应为对象"}),{ok:i.length===0,errors:i,warnings:t})}function ne(e){const i=[],t=[];if(B(e,i),i.length)return{ok:!1,errors:i,warnings:t};if(!h(e))i.push({path:"$",message:"模板文档应为对象"});else{for(const n of Object.keys(e))Te.has(n)||i.push({path:`$.${n}`,message:"模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据"});e.schemaVersion!==D&&i.push({path:"$.schemaVersion",message:"不支持的模板文档版本"});for(const n of["id","name"])m(e,n,"$",i,!0);for(const n of["revision","description"])m(e,n,"$",i);const s=se(e.template);i.push(...s.errors.map(n=>({...n,path:`$.template${n.path.slice(1)}`}))),t.push(...s.warnings.map(n=>({...n,path:`$.template${n.path.slice(1)}`})))}return{ok:i.length===0,errors:i,warnings:t}}function T(e){const i=ne(e);if(!i.ok)throw new w(i.errors)}function Je(e){const i=[];if(B(e,i),i.length)throw new w(i);const t={...e,schemaVersion:e.schemaVersion??D};return T(t),x(t)}function We(e){let i=e;if(typeof e=="string"){if(e.length>V)throw new w([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);try{i=JSON.parse(e)}catch{throw new w([{path:"$",message:"模板 JSON 语法无效"}])}}return T(i),x(i)}function Ge(e){T(e);const i=JSON.stringify(e,null,2);if(i.length>V)throw new w([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);return i}function x(e){return JSON.parse(JSON.stringify(e))}function Ue(e=[]){const i=new Map,t={get:s=>{const n=i.get(s);return n?x(n):void 0},list:()=>Array.from(i.values(),({template:s,...n})=>({...n})),register:(s,n={})=>{if(T(s),i.has(s.id)&&!n.replace)throw new w([{path:"$.id",message:`模板 ID ${s.id} 已注册;更新需显式 replace:true`}]);i.set(s.id,x(s))},remove:s=>i.delete(s)};for(const s of e)t.register(s);return t}exports.REPORT_TEMPLATE_DOCUMENT_VERSION=D;exports.ReportTemplateError=w;exports.assertRenderPlan=ye;exports.createTemplateRegistry=Ue;exports.defineReportTemplate=Je;exports.parseReportTemplate=We;exports.reportFlowGroups=be;exports.serializeReportTemplate=Ge;exports.validateComponent=_;exports.validatePage=z;exports.validateRenderPlan=X;exports.validateReportPageFlow=Y;exports.validateReportTemplate=se;exports.validateReportTemplateDocument=ne;exports.validateTemplateRepeat=Z;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";const w=require("./style-C22Pbv3T.cjs"),M=/[\u3000-\u9fff\uff00-\uffef]/,s=new Uint8Array(128);{for(const t of"iljtf.,:;'`|!()[]")s[t.charCodeAt(0)]=1;for(const t of"mwMW@")s[t.charCodeAt(0)]=2;for(let t=48;t<=57;t++)s[t]=3;for(let t=65;t<=90;t++)s[t]=4;s[32]=5}const g=[.54,.26,.95,.59,.67,.3];function d(t){const e=t.charCodeAt(0);return e<128?g[s[e]]:M.test(t)?1:/[A-Z]/.test(t)?.67:.54}const o={measureMm(t,e){const{fontSizePt:i,bold:c=!1,letterSpacingPt:u=0}=e,r=25.4/72;let n=0;for(const h of t)n+=d(h);return c&&(n*=1.04),(n*i+u*Math.max(0,Array.from(t).length-1))*r}};function p(){return o}function A(t,e){return o.measureMm(t,e)}function x(t){let e;return{measureMm(i,c){if(e===void 0&&(e=t()),!e)return o.measureMm(i,c);const u=c.fontSizePt*96/72;e.font=`${c.italic?"italic ":""}${c.bold?"bold ":""}${u}px ${c.fontFamily??w.DEFAULT_FONT_FAMILY}`,"letterSpacing"in e&&(e.letterSpacing="0px");const r=(c.letterSpacingPt??0)*Math.max(0,Array.from(i).length-1);return e.measureText(i).width*25.4/96+r*25.4/72}}}function T(t,e,i){const c=[];let u="";const r=()=>{u&&(c.push({text:u,widthMm:i.measureMm(u,e),cjk:!1}),u="")};for(const n of t){if(n===`
|
|
2
|
-
`){r(),c.push({text:`
|
|
3
|
-
`,widthMm:0,cjk:!1,br:!0});continue}if(n===" "){r(),c.push({text:n,widthMm:i.measureMm(n,e),cjk:!1,space:!0});continue}if(M.test(n)){r(),c.push({text:n,widthMm:i.measureMm(n,e),cjk:!0});continue}u+=n}return r(),c}function S(t,e,i,c=o){if(!t)return[""];t=t.replace(/\r\n?/g,`
|
|
4
|
-
`);const u=[];let r="",n=0;const h=(i.letterSpacingPt??0)*25.4/72,a=()=>{u.push(r),r="",n=0};for(const f of T(t,i,c)){if(f.br){a();continue}const m=r.length>0?h:0;if(n+m+f.widthMm<=e){r+=f.text,n+=m+f.widthMm;continue}if(f.space){a();continue}if(f.cjk){r.length>0&&a(),r=f.text,n=f.widthMm;continue}if(r.length>0&&a(),f.widthMm<=e){r=f.text,n=f.widthMm;continue}for(const l of f.text)c.measureMm(r+l,i)>e&&r.length>0&&a(),r+=l,n=c.measureMm(r,i)}return a(),u}exports.charWidthEm=d;exports.createCanvasMeasurer=x;exports.createHeuristicMeasurer=p;exports.heuristicMeasurer=o;exports.measureTextMm=A;exports.wrapText=S;
|