@agile-team/mach-report 2.22.0 → 2.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/ExcelBindingWizard-BrTmdo7f.cjs +1 -0
- package/dist/ExcelBindingWizard-CcDMLO8Q.js +1486 -0
- package/dist/ParamEditor-BGjovFUe.js +737 -0
- package/dist/ParamEditor-CeNp4_zQ.cjs +1 -0
- package/dist/ReportBatchPanel-CHxBtG9R.cjs +1 -0
- package/dist/ReportBatchPanel-CJB67WNd.js +351 -0
- package/dist/ReportLabelStudio-Tplc1TLJ.js +784 -0
- package/dist/ReportLabelStudio-g8PkqJWn.cjs +1 -0
- package/dist/ReportParamPanel-C7fZTllk.cjs +1 -0
- package/dist/{ReportParamPanel-BHSKVL8k.js → ReportParamPanel-GI43aGa0.js} +146 -127
- package/dist/ReportPreview-BoGBGyRr.cjs +6 -0
- package/dist/ReportPreview-QLONCyci.js +6257 -0
- package/dist/ReportTemplateLibrary-BFQIX0sg.cjs +1 -0
- package/dist/ReportTemplateLibrary-KqX4E2sN.js +312 -0
- package/dist/RuleEditor-BZUP9yvL.cjs +1 -0
- package/dist/RuleEditor-OPX1awrH.js +2342 -0
- package/dist/TemplateOutlinePanel-CVYKVLv_.cjs +1 -0
- package/dist/TemplateOutlinePanel-DQS-eOs6.js +97 -0
- package/dist/TemplateReusePanel-CY6O93Zk.cjs +1 -0
- package/dist/TemplateReusePanel-DKXiFTyB.js +389 -0
- package/dist/TemplateReviewPanel-DbeNC8Ms.cjs +1 -0
- package/dist/TemplateReviewPanel-Dijwm9YE.js +593 -0
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.js +26 -26
- package/dist/artifact-integrity.json +106 -104
- package/dist/assets-D2gHc4Mz.cjs +1 -0
- package/dist/assets-T_gDeFaz.js +132 -0
- package/dist/auto-BB99S802.js +257 -0
- package/dist/auto-BrPWo7Xm.cjs +1 -0
- package/dist/capabilities-DiBj4Qgl.cjs +1 -0
- package/dist/capabilities-pg7j7VLT.js +106 -0
- package/dist/charts-Cjw5AYkg.cjs +1 -0
- package/dist/{charts-Dlv8j2AG.js → charts-CxJZ0XaY.js} +1 -1
- package/dist/computed-DK6BruFz.cjs +1 -0
- package/dist/{computed-C8NRZQss.js → computed-f3pOqWLX.js} +381 -301
- package/dist/data-bar-CeZuFmYl.cjs +1 -0
- package/dist/{data-bar-8baGYEZ9.js → data-bar-IkI6VvMQ.js} +1 -1
- package/dist/designer-BZoVWTgl.js +7172 -0
- package/dist/designer-zS2uKJmY.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +105 -45
- package/dist/designer.d.ts +105 -45
- package/dist/designer.js +4 -4
- package/dist/dom-ChE5D-L-.cjs +1 -0
- package/dist/dom-JWrchIre.js +452 -0
- package/dist/dom-cell-address-DLD1mkTB.cjs +1 -0
- package/dist/dom-cell-address-Fn-8nk7D.js +11 -0
- package/dist/{encoding-ncQAvyOv.cjs → encoding-7lquyj0w.cjs} +1 -1
- package/dist/{encoding-DbnhbwI8.js → encoding-CEd-dq9A.js} +2 -2
- package/dist/{font-loader-Di0lQKFf.js → font-loader-CNWXomuV.js} +1 -1
- package/dist/{font-loader-BB372_XN.cjs → font-loader-D8pI87fL.cjs} +1 -1
- package/dist/grid-strokes-Be24LGuV.cjs +1 -0
- package/dist/grid-strokes-EoY66L2f.js +53 -0
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +944 -1259
- package/dist/{json-snapshot-DvQbZlD7.js → json-snapshot-BRnzKudk.js} +763 -776
- package/dist/json-snapshot-DNiIbpOr.cjs +2 -0
- package/dist/matrix-B8QWbsGM.cjs +1 -0
- package/dist/matrix-C6e_r_vp.js +302 -0
- package/dist/{pdf-DmlnL5eB.js → pdf-CJToa81Z.js} +20 -20
- package/dist/{pdf-CARdBcuw.cjs → pdf-DpMkW72B.cjs} +42 -42
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-AcAQ2m9X.cjs → plugin-BWTp-X7b.cjs} +1 -1
- package/dist/{plugin-w5Nyt08U.js → plugin-_BkUVc2z.js} +1 -1
- package/dist/{prefill-BXBxx5We.js → prefill-CWGdnqQd.js} +21 -21
- package/dist/prefill-PaAy6wLk.cjs +1 -0
- package/dist/prepared-CJy_qk7d.js +94 -0
- package/dist/prepared-D0yCSxSO.cjs +1 -0
- package/dist/progress-ByiOxUD3.js +250 -0
- package/dist/progress-WomPRP3B.cjs +1 -0
- package/dist/{protocol-fjaeKkjf.js → protocol-BG16rz6D.js} +3 -3
- package/dist/{protocol-C9ZaylID.cjs → protocol-wzhl1Fim.cjs} +1 -1
- package/dist/record-bindings-DatJZv_e.js +200 -0
- package/dist/record-bindings-MBxbeBsi.cjs +1 -0
- package/dist/{region-binding-workflow-aA8nxmkZ.js → region-binding-workflow-DjrXuR1q.js} +2 -2
- package/dist/{region-binding-workflow-BiJQ7NU6.cjs → region-binding-workflow-l7NGfagJ.cjs} +2 -2
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/rich-text-layout-Ciwa6D2o.js +52 -0
- package/dist/rich-text-layout-DK7A_a5r.cjs +3 -0
- package/dist/runtime-DYMOS_gz.cjs +1 -0
- package/dist/{runtime-BTtpjF3D.js → runtime-PiCax9zQ.js} +52 -51
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +5 -5
- package/dist/server-node.js +1676 -1619
- package/dist/server.cjs +1 -1
- package/dist/server.js +24 -24
- package/dist/style.css +1 -1
- package/dist/{template-catalog-JSxSqk5y.js → template-catalog-CRuZL3pi.js} +17 -17
- package/dist/template-catalog-DtrtT1FY.cjs +1 -0
- package/dist/{template-fragments-D2JFj7Du.js → template-fragments-CPpGpQoz.js} +12 -12
- package/dist/template-fragments-GVjpew_q.cjs +1 -0
- package/dist/template-registry-DI59PXVK.cjs +1 -0
- package/dist/{template-registry-Do1Uav2Z.js → template-registry-O0hNIOfB.js} +17 -17
- package/dist/{template-serialization-CU4n_Miu.js → template-serialization-CWmHq7lX.js} +1 -1
- package/dist/{template-serialization-CgqBo6s-.cjs → template-serialization-CqQY4zDg.cjs} +1 -1
- package/dist/textwrap-D4ZksyMK.js +111 -0
- package/dist/textwrap-DEHqAjKZ.cjs +4 -0
- package/dist/vue/async.d.cts +31 -0
- package/dist/vue/async.d.ts +31 -0
- package/dist/vue/index.d.cts +32 -1
- package/dist/vue/index.d.ts +32 -1
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +52 -47
- package/dist/{workbook-session-BvEBRRMz.cjs → workbook-session-C6-SrnCT.cjs} +4 -4
- package/dist/{workbook-session-f0wVlzst.js → workbook-session-C9ZmCBwY.js} +15 -16
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.js +184 -179
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-CW79I6Gl.cjs +0 -1
- package/dist/ExcelBindingWizard-CZyppD7I.js +0 -1485
- package/dist/ParamEditor-CiYCJI0b.cjs +0 -1
- package/dist/ParamEditor-DQit-Gdf.js +0 -732
- package/dist/ReportBatchPanel-DKTpV7MU.js +0 -350
- package/dist/ReportBatchPanel-Db6TAfG5.cjs +0 -1
- package/dist/ReportLabelStudio-B0i9ohQj.cjs +0 -1
- package/dist/ReportLabelStudio-BYnRqmje.js +0 -780
- package/dist/ReportParamPanel-lngONOEz.cjs +0 -1
- package/dist/ReportPreview-BDgKssYR.js +0 -5887
- package/dist/ReportPreview-Dw-4icG6.cjs +0 -6
- package/dist/ReportTemplateLibrary-BZuKn0YK.js +0 -311
- package/dist/ReportTemplateLibrary-DEXH07ND.cjs +0 -1
- package/dist/RuleEditor-CIQn547x.js +0 -2341
- package/dist/RuleEditor-zSUmPjKa.cjs +0 -1
- package/dist/TemplateOutlinePanel-B5SfGYVN.cjs +0 -1
- package/dist/TemplateOutlinePanel-D0PgOSQE.js +0 -96
- package/dist/TemplateReusePanel-BKlAEF8-.js +0 -388
- package/dist/TemplateReusePanel-DAy_Hwqz.cjs +0 -1
- package/dist/TemplateReviewPanel-CowmHaQQ.cjs +0 -1
- package/dist/TemplateReviewPanel-div-EH_m.js +0 -592
- package/dist/assets-CxHunY_9.js +0 -232
- package/dist/assets-vbjAGgk8.cjs +0 -1
- package/dist/auto-DcUHlKob.cjs +0 -1
- package/dist/auto-moShblh1.js +0 -240
- package/dist/charts-aCtoswXq.cjs +0 -1
- package/dist/component-tree-1_QCiQJX.js +0 -67
- package/dist/component-tree-BjZIp6w9.cjs +0 -1
- package/dist/computed-4TnxzgIh.cjs +0 -1
- package/dist/data-bar-YltqGTaC.cjs +0 -1
- package/dist/designer-B7jJeAeG.js +0 -6914
- package/dist/designer-BWQVpJeN.cjs +0 -2
- package/dist/grid-geometry-D3SJgWFv.js +0 -136
- package/dist/grid-geometry-D8ReblRV.cjs +0 -1
- package/dist/json-snapshot-nyV63AbB.cjs +0 -2
- package/dist/matrix-0hywp0-F.cjs +0 -1
- package/dist/matrix-Dy-tyY7E.js +0 -381
- package/dist/prefill-DUvejVt1.cjs +0 -1
- package/dist/prepared-YXy-fVLw.cjs +0 -1
- package/dist/prepared-rXCKqdHY.js +0 -88
- package/dist/progress-B0ctFpKf.cjs +0 -1
- package/dist/progress-Hc2vxoCs.js +0 -52
- package/dist/record-bindings-Ct1HkPrc.cjs +0 -1
- package/dist/record-bindings-VZGS-Qd8.js +0 -155
- package/dist/rich-text-layout-K48VHUoW.cjs +0 -3
- package/dist/rich-text-layout-wxBhnAS7.js +0 -102
- package/dist/runtime-Dq0LUsyS.cjs +0 -1
- package/dist/template-catalog-CLAM4w7H.cjs +0 -1
- package/dist/template-fragments-Ca25Jt7e.cjs +0 -1
- package/dist/template-outline-CDWXptuj.js +0 -88
- package/dist/template-outline-K4jGhATu.cjs +0 -1
- package/dist/template-registry-CWnuGqyP.cjs +0 -1
- package/dist/textwrap-CkGjRFT3.js +0 -110
- package/dist/textwrap-OTOUMr4f.cjs +0 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const R=require("./progress-WomPRP3B.cjs"),D=require("./textwrap-DEHqAjKZ.cjs"),I=require("./computed-DK6BruFz.cjs"),S=require("./record-bindings-MBxbeBsi.cjs"),Ge=require("./matrix-B8QWbsGM.cjs"),G=require("./template-serialization-CqQY4zDg.cjs"),j=require("./template-registry-DI59PXVK.cjs"),At=require("./report-params-VTg8MoCp.cjs"),Oe=require("./param-validation-C-8sRJLq.cjs"),Ve=require("./number-format-CZ2T_5kF.cjs"),we=require("./dataset-IrlXbUvh.cjs"),Nt=4096,Ae=128*1024;function Lt(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<=Ae){for(;t.size>=Nt||r+a.length>Ae;){const c=t.keys().next().value;r-=c.length,t.delete(c)}t.set(a,i),r+=a.length}return i}}}function Kt(e,t){return{member:"body",subtotal:"subtotal",total:"grand-total"}[e?.rows.get(t)?.kind??"member"]}function jt(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 Dt(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=Ge.createMatrixTable(t,jt(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 Bt(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=R.resolveGridLayout({...e.headerGrid,colWidthsMm:n},n.reduce((c,l)=>c+l,0),o.length),s=new WeakMap;for(const{cell:c,ci:l,ri:u,widthMm:f}of a.cells){const d={...S.resolveListHeaderStyle(e,e.columns[l]),...c.style},g=R.resolveFontSize(d).fontSizePt,v=(D.wrapText(c.text??"",Math.max(1,f-r*2),{fontSizePt:g,fontFamily:d.fontFamily,bold:d.bold,italic:d.italic,letterSpacingPt:d.letterSpacing},t).length*g*(d.lineHeight??R.LINE_HEIGHT)*25.4/72+r*2)/(c.rowSpan??1);for(let p=u;p<u+(c.rowSpan??1);p++)o[p]=Math.max(o[p]??0,v);s.set(c,d)}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 Ht(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 u=l?.colSpan??1,f=l?.rowSpan??1;let d=0;for(let g=c;g<c+u;g++){t.has(g)&&d++;for(let m=s+1;m<s+f;m++)o.add(`${m}:${g}`)}d&&i.push(l?{...l,colSpan:d}:null),c+=u}return i});return{...e,cells:n,colWidthsMm:r}}function _e(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:Ht(e.headerGrid,t,r.map(o=>o.widthMm))}:{}}}function*Gt(e){const{page:t}=e;j.validateReportPageFlow(t.components,t.flow);let r=0,o=0;for(const n of j.reportFlowGroups(t.components,t.flow)){e.active();const a=n.band,s=n.components.some(u=>u.kind==="list"&&u.cardinality!=="record"),i=s?0:n.components.reduce((u,f)=>Math.max(u,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 u of n.components){const f=c+u.topMm-a.topMm;u.kind==="list"?(yield*e.list(u,f,d=>{l=s?d:Math.max(l,d)}),e.active()):e.append({...u,topMm:f})}o=l,r=a.topMm+a.heightMm}}function Vt(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 ye(e){return e.pages.some(t=>t.components.some(r=>r.kind==="list"?Vt(r):!!r.chartBinding))}const _t=512,Ne=256*1024;function Wt(){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=D.wrapText(o,n,a,s),u=i.length+l.reduce((f,d)=>f+d.length,0);if(u<=Ne){for(;e.size>=_t||t+u>Ne;){const f=e.keys().next().value;t-=e.get(f).units,e.delete(f)}e.set(i,{lines:l.slice(),units:u}),t+=u}return l}}const We=1e4,Le=25e4;function be(e){if(e?.aborted)throw e.reason??new DOMException("标签生成已取消","AbortError")}function ze(e,t,r){const o=typeof e.copies=="object"?S.readRecordScalar(t,e.copies.field,r):e.copies??1;if(typeof o!="number"||!Number.isSafeInteger(o)||o<1||o>1e3)throw new S.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}]`,"每条记录复制数必须是 1..1000 的数值型整数",r.rowIndex,typeof e.copies=="object"?e.copies.field:void 0);return o}function Je(e,t,r){if(e.rowKey===void 0)return;const o=S.readRecordScalar(t,e.rowKey,r);if(typeof o=="string"&&o.trim()||typeof o=="number"&&Number.isFinite(o))return o;throw new S.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`,"业务主键必须是非空字符串或有限数字",r.rowIndex,e.rowKey)}function zt(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 Jt(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 S.ReportBindingError(`$.datasets.${o.dataset}`,"逐记录标签数据集缺失,应提供对象数组(允许空数组)");const a=new Set,s=r.maxPages??We,i=zt(e);let c=0,l=0;for(const[u,f]of n.entries()){if(be(r.signal),!f||typeof f!="object"||Array.isArray(f))throw new S.ReportBindingError(`$.datasets.${o.dataset}[${u}]`,"标签记录应为对象",u);const d={rowIndex:u,dataset:o.dataset},g=Je(o,f,d);if(g!==void 0){const v=JSON.stringify([typeof g,g]);if(a.has(v))throw new S.ReportBindingError(`$.datasets.${o.dataset}[${u}].${o.rowKey}`,"业务主键重复;请先确认记录来源,避免重复打印标签",u,o.rowKey);a.add(v)}const m=ze(o,f,d);if(c+=m*e.pages.length,l+=m*i,c>s)throw new S.PaginatePageLimitError(s,c);if(l>Le)throw new S.ReportBindingError("$.repeat",`标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Le},请分批生成`,u)}return n}function qt(e,t,r){if(!e.binding)return e;const{binding:o,...n}=e,a=S.resolveComponentBinding(o,t.row,t);if(e.kind==="image"){if(!a)return;if(!S.isLabelImageData(a))throw new S.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 Ut(e,t,r){if(e.kind!=="text"||e.grid||e.richParagraphs?.length)return e;const o=e.style??{},n=R.resolveFontSize(o).fontSizePt,a=e.text??e.lines?.join(`
|
|
2
|
+
`)??"";if(a.length>16384)throw new S.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??D.heuristicMeasurer),i=s.length*n*R.resolveLineHeight(o)*25.4/72;if(i>e.heightMm+.05)throw new S.ReportBindingError(r,`标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`,t.rowIndex,e.binding?.field);return{...e,lines:s}}function qe(e,t,r){be(t.options.signal);const o=qt(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,u)=>{const f=qe(l,t,`${r}.grid.cells.${s}.${c}.children.${u}`);return f?[f]:[]})}:i))}),Ut(n===o.grid?o:{...o,grid:n},t,r)}function Xt(e,t,r,o,n,a){return{...e,components:e.components.flatMap((s,i)=>{const c=qe(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*Yt(e,t,r){const o=[];if(j.validateTemplateRepeat(e,o),o.length)throw new S.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=Jt(e,t,r),s=Wt();for(const[i,c]of a.entries()){const l={row:c,rowIndex:i,dataset:n.dataset,options:r,wrapText:s},u=ze(n,c,l),f=Je(n,c,l);for(let d=0;d<u;d++)for(const[g,m]of e.pages.entries())be(r.signal),yield{page:Xt(m,g,l,d,u,f),pageIndex:g}}}function Qt(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 Y(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 J(e){return e.components.reduce((t,r)=>r.kind!=="list"&&r.pageAnchor==="header"?Math.max(t,r.topMm+r.heightMm):t,0)}function Ue(e,t){let r=e.textMetrics.get(t);if(!r){const o=R.resolveFontSize(t).fontSizePt;r={measureOptions:{fontSizePt:o,fontFamily:t.fontFamily??R.DEFAULT_FONT_FAMILY,italic:t.italic,bold:t.bold,letterSpacingPt:t.letterSpacing},lineMm:o*(t.lineHeight??R.LINE_HEIGHT)*25.4/72},e.textMetrics.set(t,r)}return r}function Zt(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e}function ve(e,t,r=[],o){const n=e.fontSizePt??R.DEFAULT_FONT_PT,a=e.paddingMm??1,s=e.columns.map(w=>w.align??w.style?.align??e.align??"left"),i=e.columns.map((w,y)=>({...R.mergeComponentStyles({fontSize:n,verticalAlign:"middle"},w.style),align:s[y]==="auto"?"left":s[y]})),c=i.map((w,y)=>s[y]==="auto"?{left:w,center:{...w,align:"center"},right:{...w,align:"right"}}:void 0),l=e.columns.map((w,y)=>w.rules?.map(C=>{const P=c[y];if(P)return{left:R.mergeComponentStyles(P.left,C.style),center:R.mergeComponentStyles(P.center,C.style),right:R.mergeComponentStyles(P.right,C.style)};const T=R.mergeComponentStyles(i[y],C.style);return{left:T,center:T,right:T}})),u=e.columns.map(w=>S.resolveListHeaderStyle(e,w)),f=e.columns.map(w=>w.header);let d=e.rowHeightMm??0;for(let w=0;w<f.length;w++){const y=u[w],C=R.resolveFontSize(y).fontSizePt,P=D.wrapText(f[w],e.columns[w].widthMm-a*2,{fontSizePt:C,fontFamily:y.fontFamily??R.DEFAULT_FONT_FAMILY,italic:y.italic,bold:y.bold,letterSpacingPt:y.letterSpacing},t),T=C*(y.lineHeight??R.LINE_HEIGHT)*25.4/72;d=Math.max(d,Math.max(P.length,1)*T+a*2)}const g=f.map((w,y)=>({text:w,style:u[y]})),m=e.border===!1?{borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1}:{borderBottom:!0,borderLeft:!0,borderRight:!0,borderTop:!0},v=e.columns.map(w=>w.widthMm),p=er(Bt(e,t),v,{cells:[g],colWidthsMm:v,rowHeightsMm:[d],paddingMm:a});return{fontSizePt:n,paddingMm:a,visuals:G.createColumnVisualResolvers(e.columns,r,o),visibility:e.columns.map(w=>w.visibleWhen?I.compileReportPredicate(w.visibleWhen):void 0),ruleReaders:e.columns.map(w=>w.rules?.map(y=>I.compileReportPredicate(y.when))),cellStyles:i,autoStyles:c,ruleStyles:l,textMetrics:new WeakMap,numberFormats:e.columns.map(w=>S.toExcelNumberFormat(w.format)),derivedFields:new Set(e.computed?.map(w=>w.field)),borderStyle:m,headerHeightMm:p.rowHeightsMm.reduce((w,y)=>w+y,0),headerGrid:p,colWidthsMm:v,columns:e.columns}}function er(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 tr(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 q(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,u=l?t[c.field]:null,f=e.autoStyles[i]?S.resolveListAutoAlignment(u,c.format,c.semanticRole):"left";let d=e.autoStyles[i]?.[f]??e.cellStyles[i];if(c.rules){for(let C=0;C<c.rules.length;C++)if(e.ruleReaders[i][C](t)){d=e.ruleStyles[i][C][f];break}}const g=c.format?S.formatValue(u,c.format):S.listCellText(u),m=rr(e,c,n);d=or(e,c,d,n);const v=Ue(e,d),p=D.wrapText(g,Math.max(1,c.widthMm-e.paddingMm*2-m),v.measureOptions,r);a=Math.max(a,p.length*v.lineMm+e.paddingMm*2);const w=Zt(u),y={text:g,style:d};u!=null&&e.visuals[i]?.apply(y,t),w!==void 0&&(y.value=w),tr(y,c,e.numberFormats[i]),nr(y,c,e,n,m),e.derivedFields.has(c.field)&&(y.derived=!0,y.editable=!1),l||(y.editable=!1),s[i]=y}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 rr(e,t,r){return!r||t.field!==e.tree.list.tree.labelField?0:S.listTreeIndent(e.tree.list,t,r,e.paddingMm)}function or(e,t,r,o){return!o||t.field!==e.tree.list.tree.labelField||r.align==="left"?r:{...r,align:"left"}}function nr(e,t,r,o,n=0){o&&(n&&(e.indentMm=n),S.applyListTreeMetadata(e,t,o,r.tree.list))}function Xe(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*Ye(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=Xe(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,S.listCellText(a[0][o.field])),firstRow:a[0],group:o,depth:r,rows:a},yield*Ye(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 Qe(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=I.aggregateRows(t,{...a,field:a.valueField??a.field});return[a.field,{text:S.formatValue(i,s),...i===null?{}:{value:i},...typeof i=="number"?{numberFormat:S.toExcelNumberFormat(s)}:{}}]}))}function Ze(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=R.mergeComponentStyles({fontSize:e.fontSizePt},n);i&&s.push({text:r,colSpan:i,style:{bold:!0,...c}});for(let d=i;d<e.columns.length;d++){const g=e.columns[d],m=o.get(g.field),v=e.autoStyles[d]?.[S.resolveListAutoAlignment(m?.value,g.format)]??e.cellStyles[d];s.push({...m,text:m?.text??"",style:R.mergeComponentStyles(v,n)})}const l={text:r,colSpan:e.columns.length,style:{bold:!0,...c}},u=i?[s]:[[l],s],f=u.map(d=>ar(e,d,t));return{grid:{cells:u,colWidthsMm:e.colWidthsMm,rowHeightsMm:f,paddingMm:e.paddingMm},heightMm:f.reduce((d,g)=>d+g,0)}}function ar(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=Ue(e,a.style),l=D.wrapText(a.text??"",s-e.paddingMm*2,c.measureOptions,r);o=Math.max(o,l.length*c.lineMm+e.paddingMm*2)}return o}function sr(e,t,r){const{templatePage:o,current:n,warnings:a,nextId:s,pushCurrent:i}=r,c=()=>Y(o,n),l=Math.max(n.marginTopMm,J(o)),u=o.layout==="wide"?J(o):l,f={id:r.tableId,columnKeys:e.columns.map(h=>h.field),...e.layout===void 0?{}:{layout:e.layout},...e.title===void 0?{}:{title:e.title}},d=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=h=>n.components.push({...m,topMm:h});if(r.flow&&e.header!==!1&&t.headerHeightMm>c()-l+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的表头高度超出单页可用范围`);let p=Math.max(r.startTop??e.topMm,l);e.header!==!1&&(v(p),p+=t.headerHeightMm+r.mmPerRow);function w(){const h=Math.max(r.flow||o.layout==="wide"?0:e.topMm,u);return(e.header!==!1&&e.headerEveryPage!==!1?h+t.headerHeightMm:u)+[...g.values()].reduce((x,$)=>x+$.heightMm,0)}function y(){const h=o.layout==="wide"?0:n.marginBottomMm;return Math.min(o.heightMm-h,Y(o,n))-w()}function C(h){if(p+h<=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,u);e.header!==!1&&e.headerEveryPage!==!1?(v(b),p=b+t.headerHeightMm):p=u;for(const x of g.values())T(x,"listgr","group-header")}function P(h,b,x,$){const k=y();if(r.flow&&h.heightMm>k+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的单行高度超出单页可用范围`);h.heightMm>k&&a.push(`列表 ${e.id??e.dataset} 行高 ${h.heightMm.toFixed(2)}mm 超出单页可用高度 ${k.toFixed(2)}mm,预览与打印可能截断内容`),C(h.heightMm),T(h,b,x,$)}function T(h,b,x,$){const k=h.table?.id??f.id,F=x==="header"?-1:d.get(k)??0;x!=="header"&&d.set(k,F+h.grid.cells.length),n.components.push({kind:"rect",leftMm:e.leftMm,topMm:p,widthMm:e.widthMm,heightMm:h.heightMm,grid:h.grid,nid:s(b),table:{...f,...h.table,role:x,rowIndex:F,...$?{source:$}:{}},style:t.borderStyle,...e.meta||h.meta?{meta:{...e.meta,...h.meta}}:{}}),p+=h.heightMm}function N(h){h<=y()&&C(h)}return{keepTogether:N,placeGridRow:P,setGroupHeader:(h,b)=>{b?g.set(h,b):g.delete(h)},bottom:()=>p}}function ir(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 ee(e,t){const r=new Map;if(!e.rowKey)return r;const o=new Set;for(const n of t){const a=ir(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 cr(e,t,r,o,n){if(!e.grandTotal)return;const a=typeof e.grandTotal=="object"?e.grandTotal:void 0,s=te(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??"合计",Qe(e.columns,t,i,c),a?.style??{},Ze(e.columns,[...i,...c.map(u=>u.field)]));n.placeGridRow(l,"listgt","grand-total")}function K(e){if(e?.aborted){const t=new Error("报表排版已取消");throw t.name="AbortError",t}}function te(e){const t=e.groups??(e.groupBy?[e.groupBy]:[]);if(t.length>16)throw new Error("列表最多支持 16 级分组");return t}function Me(e){const t=_e(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 lr(e,t,r){const o=e.detail;if(!o)return;const n=new Set;for(const l of t){const u=ue(l[o.parentKey]);if(n.has(u))throw new Error("主从明细的主表关联键重复");n.add(u)}const a=r.datasets[o.dataset]??[],s=new Map,i=[];for(const l of a){const u=l[o.foreignKey];if(!et(u)&&o.unmatched==="ignore")continue;const f=ue(u);if(!n.has(f)){if(o.unmatched!=="ignore")throw new Error(`明细数据集 ${o.dataset} 存在未关联的业务键`);continue}const d=s.get(f);d?d.push(l):s.set(f,[l]),i.push(l)}const c=Me({...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:{...ve(c,r.measurer,i,r.signal),rowHeightFloorMm:c.rowHeightMm??0},rows:s,sources:ee(c,i)}}function et(e){return typeof e=="string"&&!!e.trim()||typeof e=="number"&&Number.isFinite(e)}function ue(e){if(!et(e))throw new Error("主从关联键必须是非空字符串或有限数字");return Xe(e)}function*dr(e,t,r,o,n){if(!r)return;const a=r.rows.get(ue(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)K(o.signal),n.placeGridRow({...q(r.inter,i,o.measurer),table:s},"listdr","body",r.sources.get(i)),yield*o.takePages()}function tt(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("树形布局需要可见的标签列");G.validateTreeComputed(e.tree,e.computed)}function ur(e,t,r){tt(e);const o=G.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=ee(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 fr(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 rt(e,t,r){const o=r.prepared.get(e);if(o)return o;const n=fr(e,t);if(n)return r.prepared.set(e,n),n;if(e.tree){const c=ur(e,t,r);return r.prepared.set(e,c),c}let a=e.computed?.length?I.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(I.compileReportPredicate(e.rowVisibleWhen)));const i=Dt(e,a);if(!e.matrix){const c=ee(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,J(a)),i=Math.max(o.startTop??e.topMm,s),c=(e.header===!1?0:t.headerHeightMm)+(r[0]?q(t,r[0],o.measurer).heightMm:0);i+c<=Y(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,J(a)))}function*gr(e,t,r){const o=rt(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??ee(e,n),s=Me(e),i=te(s),c={...ve(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=sr(s,c,r),u=lr(s,n,r);let f;for(const d of Ye(n,i)){if(K(r.signal),d.kind==="row")l.placeGridRow(f??q(c,d.row,r.measurer),"listr",Kt(o.matrix,d.row),a.get(d.row)),f=void 0,yield*r.takePages(),yield*dr(s,d.row,u,r,l);else if(d.kind==="groupHeader"){const g=z(c,r.measurer,d.label,new Map,d.group.headerStyle??{},s.columns.length);f??=q(c,d.firstRow,r.measurer);const m=i.slice(d.depth+1).reduce((v,p)=>v+z(c,r.measurer,(p.headerTemplate??"{value}").replace(/\{value\}/g,S.listCellText(d.firstRow[p.field])),new Map,p.headerStyle??{},s.columns.length).heightMm,0);d.group.keepWithNext!==!1&&l.keepTogether(g.heightMm+m+f.heightMm),l.placeGridRow(g,"listg","group-header"),d.group.repeatHeader&&l.setGroupHeader(d.depth,g)}else if(d.kind==="subtotal"){const g=d.group.subtotal??[],m=d.group.aggregates??[],v=z(c,r.measurer,d.label,Qe(s.columns,d.rows,g,m),d.group.subtotalStyle??{},Ze(s.columns,[...g,...m.map(p=>p.field)]));l.placeGridRow(v,"listst","subtotal")}else l.setGroupHeader(d.depth);yield*r.takePages()}cr(s,o.totalRows??n,c,r,l),r.finished?.(l.bottom()),yield*r.takePages()}function re(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 oe(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=>oe(n,t))}:{}}:null))}}:{}}}function hr(e){let t=!1;for(const r of e.pages)for(const o of r.components)re(o)&&oe(o,n=>(n.includes("{totalPages}")&&(t=!0),n));return t}function pr(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(oe(c,i));if(e.layout==="wide"){const c=s.components.reduce((l,u)=>Math.max(l,u.topMm+u.heightMm),0);s.marginBottomMm=n?e.marginBottomMm??0:0,s.pageHeightMm=Math.max(1,c+s.marginBottomMm)}return s}function Se(e){return e.cells.reduce((t,r)=>t+r.reduce((o,n)=>o+(n?1+(n.children?.reduce((a,s)=>a+ot(s),0)??0):0),0),0)}function ot(e){return e.grid?Se(e.grid):0}function ne(e){for(const t of["maxPages","maxCells","knownTotalPages"])if(e[t]!==void 0&&(!Number.isSafeInteger(e[t])||e[t]<1))throw new RangeError(`${t} 应为正安全整数`);S.validateChartComponentLimit(e.maxChartComponents)}function wr(e,t){const r=rt(e,t.datasets[e.dataset]??[],t),o=Me(r.list),n={...ve(o,t.measurer,r.rows,t.signal),rowHeightFloorMm:o.rowHeightMm??0};return(o.header===!1?0:n.headerHeightMm)+r.rows.reduce((a,s)=>a+q(n,s,t.measurer).heightMm,0)}function*yr(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??""} 输出为空`),gr(a,Array.isArray(c)?c:[],{...e,tableId:`${e.tableId}:${o.get(a)}`,startTop:s,finished:i,flow:!!t.flow})};if(t.flow){yield*Gt({page:t,active:()=>K(e.signal),top:()=>Math.max(r.marginTopMm,J(t)),bottom:()=>Y(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=>wr(a,e),list:n});return}for(const a of t.components)re(a)||(a.kind==="list"?yield*n(a):r.components.push(...e.resolveChart(a)))}function*U(e,t,r,o,n,a=new WeakMap,s){let i=0,c=0,l=0;const u=Lt(r.measurer??D.heuristicMeasurer),f=S.createChartResolver(t,r.signal,r.maxChartComponents),d=g=>`${g}_${(++i).toString(36)}`;for(const{pageIndex:g,page:m}of Yt(e,t,r)){K(r.signal);const v=Qt(m),p=m.components.filter(re);let w=[];const y=(P=!1)=>{if(K(r.signal),r.maxPages!==void 0&&c>=r.maxPages)throw new S.PaginatePageLimitError(r.maxPages,c+1);if(r.maxCells!==void 0&&(l+=[...v.components,...p].reduce((T,N)=>T+ot(N),0),l>r.maxCells))throw new S.PaginateCellLimitError(r.maxCells,l);w.push(pr(m,v,p,++c,P,n))},C=()=>{const P=w;return w=[],P};yield*yr({templatePage:m,current:v,warnings:o,nextId:d,pushCurrent:y,takePages:C,datasets:t,resolveChart:f,signal:r.signal,formula:r.formula,prepared:a,measurer:u,mmPerRow:r.mmPerRow??0,tableId:`table:${g}`}),y(!0),yield*C()}s&&(s.chartComponents=f.used())}function br(e,t,r={}){ne(r);let o=0;for(const n of U(e,t,{...r,onWarning:void 0},[]))o++;return o}function*vr(e,t,r={}){yield*Mr(e,t,r)}function*Mr(e,t,r,o){ne(r);const n=hr(e),a=new WeakMap;let s=r.knownTotalPages;if(n&&s===void 0){s=0;for(const l of U(e,t,r,[],void 0,a))s++}const i=[];let c=0;for(const l of U(e,t,r,i,s,a,o)){for(;c<i.length;c++)r.onWarning?.(i[c]);yield l}}function xe(e,t,r={}){const o=typeof r=="number"?{mmPerRow:r}:r;ne(o);const n=[],a={chartComponents:0},s=[...U(e,t,o,n,o.knownTotalPages,void 0,a)];return at(e,o,s,n,a)}async function nt(e,t,r={}){ne(r),K(r.signal);const o=[],n=[],a={chartComponents:0};let s=performance.now(),i=0;for(const c of U(e,t,r,o,r.knownTotalPages,void 0,a))n.push(c),(++i>=8||performance.now()-s>=8)&&(await new Promise(l=>setTimeout(l,0)),K(r.signal),s=performance.now(),i=0);return K(r.signal),at(e,r,n,o,a)}function at(e,t,r,o,n){for(const a of r)a.components=a.components.map(s=>re(s)?oe(s,i=>i.replace(/\{totalPages\}/g,String(r.length))):s);return o.forEach(a=>t.onWarning?.(a)),{plan:{schemaVersion:R.RENDER_PLAN_SCHEMA_VERSION,...ye(e)?{requiresRecalculation:!0}:{},pages:r},warnings:o,...n}}function Sr(e){const t=e.columns.find(a=>!a.hidden)?.field;if(!t)return{groups:0,total:0};const r=te(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 xr(e,t,r){tt(e);const o=G.flattenTreeInput(t[e.dataset]??[],e.tree,r),n=e.columns.filter(s=>!s.hidden).length,a=e.header===!1?0:e.headerGrid?Se(e.headerGrid):n;return o.length*n+a+ +!!e.grandTotal*2*n}function Cr(e,t,r={}){if(e.tree)return xr(e,t,r.signal);if(e.matrix){let c=t[e.dataset]??[];e.computed?.length&&(c=I.computeDataset(c,{fields:e.computed,...r}).rows),e.rowVisibleWhen&&(c=c.filter(I.compileReportPredicate(e.rowVisibleWhen)));const l=Ge.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=te(e).length,s=Sr(e);let i=(o*(1+2*a+s.groups)+ +!!e.grandTotal*(1+s.total))*n;if(i+=e.header===!1?0:e.headerGrid?Se(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(u=>!u.hidden).length;i+=(c+o*(+(e.detail.header!==!1)+ +!!e.detail.label))*l}if(!Number.isSafeInteger(i))throw new RangeError("报表单元格估算超出安全整数预算");return i}class st extends Error{constructor(t){super(t.map(r=>r.message).join(";")),this.issues=t,this.name="ReportValidationError"}}function Ke(e,t,r){if(!Number.isSafeInteger(e)||e<1||e>r)throw new Error(`校验 ${t} 超出预算`);return e}function Er(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(I.computationFieldName(r.field),t.has(r.field))throw new Error("校验汇总字段重复");t.add(r.field),r.valueField!==void 0&&I.computationFieldName(r.valueField),r.weightField!==void 0&&I.computationFieldName(r.weightField),I.aggregateRows([],{...r,field:r.valueField??r.field})}}function it(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(I.computationFieldName(r.id),t.has(r.id))throw new Error("校验规则 id 重复");if(t.add(r.id),r.field!==void 0&&I.computationFieldName(r.field),r.dataset!==void 0&&I.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("未知校验范围");Er(r);const o={nodes:0},n=I.compileReportPredicate(r.assert,o),a=r.when?I.compileReportPredicate(r.when,o):void 0;return{rule:r,assert:n,when:a,checks:o.nodes}})}function je(e){if(e?.aborted){const t=new Error("报表校验已取消");throw t.name="AbortError",t}}function Rr(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 Pr(e,t){const r=t.computed?.length?{fields:t.computed,formula:t.formula,signal:t.signal}:void 0;if(t.tree){const n=G.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?I.computeDataset(e,r).rows:e;return{rows:o,summaryRows:o,rowKey:t.rowKey}}function Tr(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 kr(e,t){return ct(e,t,{checks:0})}function ct(e,t,r){if(!Array.isArray(e)||e.length>1e5)throw new Error("校验数据最多 100000 行");je(t.signal);const o=Ke(t.maxChecks??2e6,"maxChecks",1e7),n=Ke(t.maxIssues??1e3,"maxIssues",1e4);t.rowKey!==void 0&&I.computationFieldName(t.rowKey);const a=Pr(e,t),{rows:s,summaryRows:i,rowKey:c}=a;Tr(s,c);const l=it(t.rules),u=l.reduce((d,g)=>d+(g.rule.scope==="dataset"?g.checks+i.length*(g.rule.aggregates?.length??0):s.length*g.checks),0);if(r.checks+=u,r.checks>o)throw new Error("整批校验超出 maxChecks 预算");const f=[];for(const d of l)(d.rule.scope==="dataset"?[Object.fromEntries((d.rule.aggregates??[]).map(m=>[m.field,I.aggregateRows(i,{...m,field:m.valueField??m.field})]))]:s).forEach((m,v)=>{if(je(t.signal),!m||typeof m!="object"||Array.isArray(m))throw new Error("校验数据行应为对象");if(!(d.when&&!d.when(m)||d.assert(m))){if(f.length>=n)throw new Error("校验问题超出 maxIssues 预算,请缩小范围");f.push(Rr(d.rule,m,d.rule.scope==="dataset"?void 0:v,d.rule.scope==="dataset"?void 0:c))}});return f}function lt(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 st(e)}function De(e,t,r){const o=e.get(t);if(o&&JSON.stringify(o)!==JSON.stringify(r))throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");e.set(t,r)}function Ir(e,t,r,o=[]){it(t.rules);const n=[],a={checks:0};for(const[i,c]of e.entries()){const l=new Map;for(const u of c.template.pages)for(const f of u.components)f.kind==="list"&&(De(l,f.dataset,{rowKey:f.tree?.idField??f.rowKey,computed:f.computed,tree:f.tree}),f.detail&&De(l,f.detail.dataset,{rowKey:f.detail.rowKey}));for(const[u,f]of l){const d=t.rules.filter(g=>!g.dataset||g.dataset===u);if(d.length&&(n.push(...ct(c.datasets[u]??[],{...t,rules:d,...f,formula:o[i],signal:r},a).map(g=>({...g,dataset:u,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 dt(e){return!e||typeof e!="object"?!1:[e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex].every(t=>Number.isInteger(t)&&t>=0)}function ut(e,t,r){const o=e.grid;if(!o)return null;const n=o.cells[t];if(!n)return null;const s=R.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 $r(e){return e.value!==void 0?e.value:e.rawText??e.text??null}function Fr(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 Or(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 Ar(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 Nr(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 ft(e,t,r){const o=$r(r),n=Or(r,e);return{address:{...t},cell:r,component:e,value:o,valueType:Fr(r,o),table:Ar(e,t),source:Nr(r,e,t),editable:n===void 0,readOnlyReason:n}}function ae(e,t){if(!dt(t))return null;const r=e.pages[t.pageIndex]?.components[t.componentIndex];if(!r)return null;const o=ut(r,t.rowIndex,t.columnIndex);return o?ft(r,t,o.cell):null}function B(e){const t=new Map;return r=>{if(!dt(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 R.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?ft(o,r,a):null}}class M extends Error{constructor(t){super(`Invalid report cell edit: ${t}`),this.code=t,this.name="ReportCellEditError"}}function Lr(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 Kr(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:Lr(e,Ve.isExcelPercentageFormat(t.cell.numberFormat));if(!Number.isFinite(r)||Number.isInteger(r)&&!Number.isSafeInteger(r))throw new M("number");return r}function jr(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 Ce(e,t){return e.valueType==="number"?Kr(t,e):e.valueType==="boolean"?jr(t):t===null?null:String(t)}function Dr(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 V(e,t){return t===null?"":typeof t=="boolean"?Dr(t,e):typeof t=="number"?Ve.formatExcelNumber(t,e.cell.numberFormat):String(t)}function Br(e,t,r){const o=ae(e,t);if(!o)throw new M("missing");return _(o,r)}function _(e,t){if(!e.editable)throw new M("readonly");const r=Ce(e,t);return{address:{...e.address},table:e.table,source:e.source,previousValue:e.value,previousText:e.cell.text??"",value:r,text:V(e,r)}}function Hr(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 mt(e,t,r){const o=e.grid,{rowIndex:n,columnIndex:a}=t.address,s=ut(e,n,a),i=[...o.cells],c=[...i[n]],l=V(t,r.value),u={...s.cell,value:r.value,text:l,rawText:l};return c[s.sourceColumnIndex]=u,i[n]=c,{...e,grid:{...o,cells:i}}}function Gr(e,t){const r=e.table?.columnKeys,o=t.table?.columnKey;return r&&o!==void 0?r.flatMap((n,a)=>n===o?[a]:[]):[]}function Vr(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 u of Gr(t,n)){const f=ae(e,{pageIndex:r,componentIndex:o,rowIndex:c,columnIndex:u});f?.editable&&Hr(n,f)&&(l=mt(l,f,a))}return l}function _r(e,t,r,o,n,a){const s=n.address;return n.table?.columnKey!==void 0?Vr(e,t,r,o,n,a):s.pageIndex===r&&s.componentIndex===o?mt(t,n,a):t}function se(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 Wr(e,t){const r=ae(e,t.address);if(!r)throw new M("missing");if(!r.editable)throw new M("readonly");if(se(r,t))throw new M("conflict");if(!Object.is(r.value,t.previousValue)||(r.cell.text??"")!==t.previousText)throw new M("conflict");const o=Ce(r,t.value),n={...t,value:o,text:V(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,u)=>_r(e,l,i,u,r,n));return c.every((l,u)=>l===s.components[u])?s:{...s,components:c}});return{...e,pages:a}}function gt(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 Be(e){return JSON.stringify([e.sourceScope,e.datasetId,e.rowKey])}function ht(e){const t=new Map,r=new Set;return e.forEach((o,n)=>{for(const a of gt(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 u=c[a.rowKey];if(typeof u!="string"&&typeof u!="number")return;const f=`${n}:${a.dataset}:${l}:${a.rowKey}`;if(r.has(f))return;r.add(f);const d=Be({sourceScope:o.sourceScope,datasetId:a.dataset,rowKey:u}),g=t.get(d)??[];g.push({partIndex:n,dataset:a.dataset,rowIndex:l,row:c,binding:a}),t.set(d,g)})}}),o=>{const n=t.get(Be(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 pt(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);I.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 gt(a))t.has(W({sourceScope:a.sourceScope,datasetId:i.dataset}))&&(a.datasets[i.dataset]??[]).forEach((c,l)=>{const u={partIndex:s,dataset:i.dataset,rowIndex:l,row:c,binding:i};for(const[f,d]of[[i.revisionField,r.revision],[i.sourceTokenField,r.sourceToken]]){if(!f||d===void 0)continue;const g=`${s}:${i.dataset}:${l}:${f}`;n.has(g)||(n.add(g),o.push({row:u,field:f,value:d}))}})}),o}function wt(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 Ee(e,new Map([...o].map(n=>[n,r])))}function Ee(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,u=i.grid?.cells.map(d=>{const g=d.map(m=>{if(!m)return m;const v=m.source?r(m.source):void 0,p=m.children?o(m.children):void 0;return v===m.source&&p===m.children?m:{...m,source:v,children:p}});return g.some((m,v)=>m!==d[v])?g:d}),f=i.grid&&u?.some((d,g)=>d!==i.grid.cells[g])?{...i.grid,cells:u}: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 Jr(e){return JSON.stringify([e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex])}function He(e){const t=e.table;return t?.columnKey!==void 0?JSON.stringify([t.id,t.role,t.rowIndex,t.columnKey]):Jr(e.address)}function qr(e,t){if(!t.length)return e;const r=new Map(t.map(c=>[He(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=B(e);function s(c,l,u){const f=c.grid;if(!f||!n.has(`${l}:${u}`)&&!o.has(c.table?.id??""))return c;const d=new Map,g=new Map;for(const m of R.resolveGridLayout(f,c.widthMm,c.heightMm).cells){const v=g.get(m.ri)??0;g.set(m.ri,v+1);const p=a({pageIndex:l,componentIndex:u,rowIndex:m.ri,columnIndex:m.ci}),w=p&&r.get(He(p));if(!w||!p.editable)continue;const y=d.get(m.ri)??[...f.cells[m.ri]],C=V(p,w.value);Object.is(p.value,w.value)&&C===p.cell.text||(y[v]={...m.cell,value:w.value,text:C,rawText:C},d.set(m.ri,y))}return d.size?{...c,grid:{...f,cells:f.cells.map((m,v)=>d.get(v)??m)}}:c}const i=e.pages.map((c,l)=>{const u=c.components.map((f,d)=>s(f,l,d));return u.every((f,d)=>f===c.components[d])?c:{...c,components:u}});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 Ur(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=B(e),a=t.map(({address:s,value:i})=>{const c=n(s);if(!c)throw new M("missing");const l=_(c,i),u=A(l);if(o.has(u))throw new M("duplicate");return o.add(u),l});return{requestId:r,edits:a}}function Xr(e,t){if(t.edits.length>1e4)throw new M("limit");const r=B(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),se(s,a)||!Object.is(s.value,a.previousValue)||(s.cell.text??"")!==a.previousText)throw new M("conflict");return _(s,a.value)});return qr(e,n)}function Yr(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 yt(e){const t=new Map,r=B(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 Qr(e,t,r){const o=yt(e),n=B(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 bt(e,t){if(++e.nodes>1e6||t>128)throw new M("limit")}function Q(e,t){const r=Object.getOwnPropertyDescriptor(e,t);if(!r||r.get||r.set)throw new M("conflict");return r.value}function Re(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 vt(e,t,r,o,n){if(bt(o,n),typeof e=="function"||typeof e=="symbol")throw new M("conflict");if(e===null||typeof e!="object")return;if(Re(e),r.has(e))throw new M("conflict");r.add(e);const a=Object.keys(e),s=a.map(i=>Q(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)vt(i,t,r,o,n+1);r.delete(e)}function Zr(e){const{object:t,keys:r,values:o}=e;if(Re(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(Q(t,a),o[s]))}function eo(e){const t=[];return vt(e,t,new Set,{nodes:0},0),()=>{try{return t.every(Zr)}catch{return!1}}}function Z(e,t,r,o=!1){if(bt(t,r),o){if(typeof e=="function"||typeof e=="symbol")throw new M("conflict");e!==null&&typeof e=="object"&&Re(e)}if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(Date.prototype.getTime.call(e));if(Array.isArray(e)){const n=[];for(let a=0;a<e.length;a++)n[a]=Z(Q(e,String(a)),t,r+1,o);return n}return Object.fromEntries(Object.keys(e).map(n=>[n,Z(Q(e,n),t,r+1,o)]))}function to(e){return Z(e,{nodes:0},0,!0)}function ro(e){const t=Z(e,{nodes:0},0);for(const r of t)for(const o of Object.values(r.datasets))I.registerComputedDataset(o);return t}async function oo(e,t,r={}){return(await Mt(e,t,r)).plan}async function Mt(e,t,r={}){return nt(e,t,{...r,knownTotalPages:void 0})}const fe=new WeakMap;function no(e){return fe.get(e)}function X(e){if(e?.aborted){const t=new Error("报表重算已取消");throw t.name="AbortError",t}}function St(e,t){return e[t]===void 0?"":e[t]}function ao(e,t){if(t.edits.length>1e4)throw new M("limit");const r=B(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),se(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 so(e,t){const r=ht(e);return t.flatMap(o=>{if(!o.source)throw new M("missing");return r(o.source).map(n=>{if(!Object.is(St(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 le(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:V(o,o.value)},o}function io(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 pt(e,zr(e,o,r))}function co(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 Pe(e,t){let r=t.parts;const o=t.rebuild,n=[...t.validationFormulas??[]];let a=eo(r),s=e,i;const c=new Map,l=new Map;function u(g){if(g!==s)throw new M("conflict");if(i)return i;if(!a?.())throw new M("conflict");return ro(r)}async function f(g,m,v,p={}){X(p.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)),X(p.signal);const w=u(g),y=pt(w,so(w,m.edits)),C=Ee(await o(y,p.signal),l);X(p.signal);let P=!1,T=[],N="allow",L=!1;function h(b){return L=!0,T=Object.freeze(Ir(y,b,p.signal,n).map(x=>Object.freeze({...x}))),L=!1,N=b.warningPolicy??"allow",T}return p.validation&&h(p.validation),{plan:C,get validationIssues(){return T},validate:h,commit(b){if(X(p.signal),P||s!==g)throw new M("conflict");if(b?.conflicts?.length)throw new M("conflict");if(L)throw new Error("候选规则校验未完成,不能提交");lt(T,N);const x=io(y,m,b),$=wt(C,m,b);if(b){const k=co(l,m,b);for(const[F,H]of c)k.has(W(H.source))&&c.set(F,le(H,H.value,b))}return v.forEach((k,F)=>c.set(A(k),le(k,m.edits[F].value,b))),P=!0,i=x,r=void 0,a=void 0,s=$,fe.set(s,d),s}}}const d={get plan(){return s},async prepare(g,m,v){const p=ao(g,m);return f(g,p.batch,p.contexts,v)},async prepareHistory(g,m,v,p,w){if(!p.trim()||m.length>1e4)throw new M("limit");const y=u(g),C=ht(y),P=yt(g),T=new Set,L=m.map(x=>{if(!x.source)throw new M("missing");const $=A(x);if(T.has($))throw new M("duplicate");T.add($);const k=P.get($)??c.get($);if(!k?.source)throw new M("missing");const F=C(k.source)[0];return le(k,St(F.row,k.source.field))}).map((x,$)=>({context:x,edit:_(x,m[$][v])})).filter(({edit:x})=>!Object.is(x.previousValue,x.value)),h={requestId:p,edits:L.map(({edit:x})=>x)},b=L.map(({context:x})=>x);return{batch:h,contexts:b,prepared:await f(g,h,b,w)}}};return fe.set(e,d),d}function lo(e){const t=xe(e.template,e.datasets,e.pagination).plan;return Pe(t,{validationFormulas:[e.pagination?.formula],parts:[{template:e.template,datasets:e.datasets}],rebuild:(r,o)=>oo(r[0].template,r[0].datasets,{...e.pagination,signal:o})})}let uo=0;function xt(){return`report-${Date.now()}-${++uo}`}function me(e,t,r){if(!r?.aborted)try{const o=e?.({...t});o&&typeof o.then=="function"&&Promise.resolve(o).catch(()=>{})}catch{}}function Ct(e){const t=e.taskId??xt(),r=(o,n,a)=>{me(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){me(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 Te(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 Et(e){return e==="missing-source"||e==="not-applicable"||e==="not-calculable"}function Rt(e){return e.target!==void 0&&!Te(e.target)?!1:e.valueState===void 0||Et(e.valueState)&&e.target!==void 0}function fo(e,t){if(we.validateDatasetRows([],e),!Te(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 ke(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]=G.flattenTreeInput(t[a]??[],{...s,maxRows:i},r.signal)}return n}function mo(e,t,r={}){return Object.values(ke(e,t,r)).reduce((o,n)=>o+n.length,0)}function go(e,t,r){const o=we.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 Ie(e,t){return JSON.stringify([e,t])}function $e(e,t,r){return r===void 0?Ie(e,t):JSON.stringify(["shared",r])}function Pt(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:Pt(i.children,t,r)}:{}}));return n||a?{...o,...n?{table:n}:{},...a?{grid:{...o.grid,cells:a}}:{}}:o})}function ge(e){return S.validateChartComponentLimit(e.maxChartComponents),{maxPages:e.maxPages,maxCells:e.maxCells,maxChartComponents:e.maxChartComponents??S.DEFAULT_CHART_COMPONENT_LIMIT,usedPages:0,usedCells:0,usedChartComponents:0}}function ho(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 po(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 he(e,t){return e===void 0?void 0:e-t}function de(e,t){return e===void 0?t:Math.max(1,Math.min(e,t??e))}function Tt(e,t,r,o,n){S.validateChartComponentLimit(e?.maxChartComponents);const a=he(t.maxPages,t.usedPages),s=t.maxChartComponents-t.usedChartComponents;if(a!==void 0&&a<1&&r.pages.length&&!ho(r,o))throw new S.PaginatePageLimitError(0,1);if(s<1&&r.pages.some(i=>i.components.some(c=>c.kind!=="list"&&c.chartBinding)))throw new S.PaginateChartComponentLimitError(s,1);return{...e,signal:n??e?.signal,maxPages:de(a,e?.maxPages),maxCells:de(he(t.maxCells,t.usedCells),e?.maxCells),maxChartComponents:de(s,e?.maxChartComponents)}}function kt(e,t){const r=po(t.plan),o=he(e.maxCells,e.usedCells);if(o!==void 0&&r>o)throw new S.PaginateCellLimitError(o,r);e.usedPages+=t.plan.pages.length,e.usedCells+=r,e.usedChartComponents+=t.chartComponents}function It(e,t){return e instanceof S.PaginatePageLimitError&&t.maxPages!==void 0&&(e.limit===t.maxPages-t.usedPages||e.limit===0)?new S.PaginatePageLimitError(t.maxPages,t.usedPages+e.actual):e instanceof S.PaginateCellLimitError&&t.maxCells!==void 0?new S.PaginateCellLimitError(t.maxCells,t.usedCells+e.actual):e instanceof S.PaginateChartComponentLimitError&&e.limit===t.maxChartComponents-t.usedChartComponents?new S.PaginateChartComponentLimitError(t.maxChartComponents,t.usedChartComponents+e.estimated):e}function wo(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 E("validate",`报表 ${n.reportId} 数据映射失败`,s)}}}}class E extends Error{constructor(t,r,o){super(r),this.name="ReportSourceError",this.code=t,this.cause=o}}function ie(e){const t=new Error("报表加载已取消");return t.name="AbortError",Object.defineProperty(t,"cause",{value:e.reason}),t}function O(e){if(e?.aborted)throw ie(e)}function pe(e,t){return t?new Promise((r,o)=>{const n=()=>t.removeEventListener("abort",a),a=()=>{n(),o(ie(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 yo(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new E("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 E("validate",`报表 ${t} 的数据集 ${r} 应为对象数组`)}async function bo(e,t,r){const{reportId:o,signal:n}=t;try{const a=await pe(e(t),n);O(n);const s=j.validateReportTemplate(a);if(!s.ok)throw new E("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?ie(n):a instanceof E?a:a instanceof j.ReportTemplateError?new E("validate",`报表 ${o} 模板校验失败:${a.message}`,a):new E("fetch",`报表 ${o} 模板加载失败:${a instanceof Error?a.message:String(a)}`,a)}}async function vo(e,t,r,o){const n=t.signal;let a;try{if(e.load)a=await pe(e.load(t),n);else if(e.provider){const s=await pe(e.provider.query(t),n);O(n),Mo(s,r),a=s.datasets,o?.(r,s)}else a=e.datasets??{}}catch(s){throw n?.aborted?ie(n):s instanceof E?s:new E("fetch",`报表 ${r} 取数失败:${s instanceof Error?s.message:String(s)}`,s)}return O(n),a}function Mo(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new E("validate",`报表 ${t} Provider 应返回 datasets 结果对象`);for(const r of["revision","sourceToken"])if(e[r]!==void 0&&typeof e[r]!="string")throw new E("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 E("validate",`报表 ${t} Provider diagnostics 不符合结构化诊断契约`);if(e.diagnostics?.some(r=>!Rt(r)))throw new E("validate",`报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`)}function So(e,t,r,o,n){try{t=ke(o,t,{maxRows:e.dataValidation?.maxRows,signal:n})}catch(a){throw new E("validate",`报表 ${r} 树形数据无效:${a instanceof Error?a.message:String(a)}`,a)}for(const[a,s]of Object.entries(e.dataSchema??{})){let i;try{i=we.validateDatasetRows(Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0,s,{...e.dataValidation,path:`$.datasets.${a}`})}catch(c){throw new E("config",`报表 ${r} 数据集 ${a} 字段契约配置无效`,c)}if(!i.ok)throw new E("validate",`报表 ${r} 数据集 ${a} 不符合字段契约:${i.issues[0]?.message}`,{issues:i.issues})}}async function xo(e,t,r,o,n){try{let a;try{a=to(e)}catch{}const s=a??e,i=Tt(t.pagination,o,s.template,s.datasets,n),c=a?await nt(s.template,s.datasets,i):xe(s.template,s.datasets,i);return kt(o,c),{result:c,part:s}}catch(a){O(n);const s=It(a,o);throw new E("validate",`报表 ${r} 排版失败:${s instanceof Error?s.message:String(s)}`,s)}}function $t(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:Ie(r,o)},components:Pt(i.components,n??$e(r,o),s)})}async function Co(e,t,r,o,n){const a=[],s=ge(o);for(const[l,u]of e.entries()){O(n);try{const f=await Mt(u.template,u.datasets,Tt(t[l]?.pagination,s,u.template,u.datasets,n));kt(s,f),$t(a,f.plan,l,r[l],u.sourceScope)}catch(f){throw It(f,s)}}const i={schemaVersion:R.RENDER_PLAN_SCHEMA_VERSION,...e.some(l=>ye(l.template))?{requiresRecalculation:!0}:{},pages:a},c=j.validateRenderPlan(i);if(!c.ok)throw new E("validate",`重算渲染计划校验失败:${c.errors[0]?.message}`);return i}function Eo(e,t={}){if(t.maxPages!==void 0&&(!Number.isSafeInteger(t.maxPages)||t.maxPages<1))throw new E("config","maxPages 应为正安全整数");if(t.maxCells!==void 0&&(!Number.isSafeInteger(t.maxCells)||t.maxCells<1))throw new E("config","maxCells 应为正安全整数");try{ge(t)}catch(n){throw new E("config","maxChartComponents 应为 1..1000000 的安全整数",n)}function r(n){const a=Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0;if(!a)throw new E("config",`未注册报表 ${n}`);if(a.sourceScope!==void 0&&(typeof a.sourceScope!="string"||!a.sourceScope.trim()||a.sourceScope.length>512))throw new E("config","sourceScope 应为不超过 512 字符的非空字符串");return a}return Object.assign(async({reportIds:n,params:a,signal:s,onWarning:i,onQueryResult:c,...l})=>{O(s);const u=Ct({...l,signal:s}),f=[...n],d={...a};if(f.length===0)throw new E("config","缺少报表 ID");const g=f.map(r),m=u.runSync("validate",()=>g.map(h=>Oe.assertReportParams(h.params??(typeof h.template=="function"?[]:h.template.params)??[],d))),v=[],p=[],w=ge(t),y=[];for(const[h,b]of g.entries()){O(s);const x=f[h],$={reportId:x,params:m[h],signal:s},k=typeof b.template=="function"?await u.run("query",()=>bo(b.template,$,y),x):b.template;$.params=u.runSync("validate",()=>Oe.assertReportParams(b.params??k.params??[],$.params),x);const F=await u.run("query",()=>vo(b,$,x,(ce,Ot)=>c?.(ce,Ot,h)),x);u.runSync("validate",()=>{yo(F,x),t.onDatasets?.(x,F,k),So(b,F,x,k,s)},x),O(s);const H=$e(h,x,b.sourceScope),{result:Fe,part:Ft}=await u.run("layout",()=>xo({template:k,datasets:F,sourceScope:H},b,x,w,s),x);p.push(Ft),$t(v,Fe.plan,h,x,H),y.push(...Fe.warnings.map(ce=>`${x}: ${ce}`))}O(s);const C={schemaVersion:R.RENDER_PLAN_SCHEMA_VERSION,...p.some(h=>ye(h.template))?{requiresRecalculation:!0}:{},pages:v},P=u.runSync("validate",()=>{const h=j.validateRenderPlan(C);if(!h.ok)throw new E("validate",`渲染计划校验失败:${h.errors.slice(0,3).map(b=>`${b.path}: ${b.message}`).join("; ")}`);return h});y.push(...P.warnings.map(h=>`${h.path}: ${h.message}`));const T=g.map(h=>({...h,pagination:{...h.pagination}})),N={maxPages:t.maxPages,maxCells:t.maxCells,maxChartComponents:t.maxChartComponents};try{Pe(C,{parts:p,validationFormulas:T.map(h=>h.pagination?.formula),rebuild:(h,b)=>Co(h,T,f,N,b)})}catch{y.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算")}const L=i??t.onWarning??(h=>console.warn("[mach-report]",h));for(const h of y)O(s),L(h);return O(s),C},{getParamDefs:n=>At.getReportParamDefs(e,n)})}const Ro=new Set([8,9,10,12,13]);function Po(e,t){const r=Array.isArray(e),o=Object.getPrototypeOf(e);if(o!==(r?Array.prototype:Object.prototype)&&!(o===null&&!r)||Object.getOwnPropertySymbols(e).length)throw t("input","快照应为普通 JSON 对象");const n=Object.getOwnPropertyNames(e).filter(a=>!(r&&a==="length"));if(r&&(n.length!==e.length||n.some((a,s)=>a!==String(s))))throw t("input","快照数组应为连续数组");return{array:r,keys:n}}function To(e){if(/^[\u0020-\u007e]*$/.test(e)&&!/["\\]/.test(e))return e.length+2;let t=2;for(let r=0;r<e.length;r++){const o=e.charCodeAt(r);if(o<32)t+=Ro.has(o)?2:6;else if(o===34||o===92)t+=2;else if(o<128)t++;else if(o<2048)t+=2;else if(o>=55296&&o<=57343){const n=e.charCodeAt(r+1);o<=56319&&n>=56320&&n<=57343?(t+=4,r++):t+=6}else t+=3}return t}function ko(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,s=new Map;function i(d){if(d.length+2>t.maxBytes-n)throw t.error("budget","快照超过字节预算");const g=s.get(d);if(g!==void 0)return g;const m=To(d);return d.length<=256&&s.size<4096&&s.set(d,m),m}function c(d){if(n+=d,n>t.maxBytes)throw t.error("budget","快照超过字节预算")}function l(d,g){if(++o>r||g>64)throw t.error("budget","快照节点或深度超过预算");if(o%1024===0&&t.check?.(),typeof d=="string")return c(i(d)),d;if(d===null||typeof d=="boolean"||typeof d=="number"&&Number.isFinite(d))return c(String(d).length),typeof d=="number"&&Object.is(d,-0)?0:d;if(!d||typeof d!="object"||a.has(d))throw t.error("input","快照应为无循环的有限 JSON 值");return u(d,g)}function u(d,g){const{array:m,keys:v}=Po(d,t.error);a.add(d),c(2);const p=m?[]:{};let w=0;for(const y of v){const C=Object.getOwnPropertyDescriptor(d,y);if(C.get||C.set||!C.enumerable||["__proto__","constructor","prototype"].includes(y))throw t.error("input","快照不允许访问器或危险键");if(C.value===void 0&&!m)continue;c((w++?1:0)+(m?0:i(y)+1));const P=l(C.value===void 0?null:C.value,g+1);y in p?Object.defineProperty(p,y,{value:P,enumerable:!0,configurable:!0,writable:!0}):p[y]=P}return a.delete(d),p}t.check?.();const f=l(e,0);return t.check?.(),f}exports.DEFAULT_LABEL_PAGE_LIMIT=We;exports.ReportCellEditError=M;exports.ReportSourceError=E;exports.ReportValidationError=st;exports.applyReportCellEdit=Wr;exports.applyReportCellEditBatch=Xr;exports.applyReportEditResult=wt;exports.applyReportSourceMetadata=Ee;exports.assertReportValidation=lt;exports.countTemplatePages=br;exports.createReportCellEdit=Br;exports.createReportCellEditBatch=Ur;exports.createReportCellResolver=B;exports.createReportEditSession=lo;exports.createReportSource=Eo;exports.createReportTaskReporter=Ct;exports.defineReport=wo;exports.editFromContext=_;exports.estimateListLayoutCells=Cr;exports.explainDatasetField=fo;exports.formatReportCellEdit=V;exports.getReportCellContext=ae;exports.getReportEditSession=no;exports.hasValidDataExplanation=Rt;exports.isReportDataTarget=Te;exports.isReportValueState=Et;exports.notifyReportTaskEvent=me;exports.paginateTemplate=xe;exports.paginateTemplatePages=vr;exports.parseReportCellInput=Ce;exports.projectListColumns=_e;exports.registerReportEditSession=Pe;exports.relocateReportCellEdits=Qr;exports.reportCellEditKey=A;exports.reportOccurrenceScope=Ie;exports.reportSourceScope=$e;exports.reportTaskId=xt;exports.snapshotReportJson=ko;exports.sourceChanged=se;exports.summarizeReportCellEdits=Yr;exports.templateDatasetJsonSchema=go;exports.templateDatasetRowCount=mo;exports.templateValidationDatasets=ke;exports.validateReportDataset=kr;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const g=require("./computed-DK6BruFz.cjs");function $(e,r){const l=()=>r.measures.map(i=>g.createAggregateAccumulator(i)),t=new Map,n=new Map,o=new Map,a=r.totals?l():void 0,s=(i,c)=>i?.forEach(u=>u.add(c));for(const i of e){const c=r.row(i),u=r.column(i);n.has(u.key)||n.set(u.key,u.label);let f=t.get(c.key);f||(f={label:c.label,cells:new Map,...r.totals?{totals:l()}:{}},t.set(c.key,f)),r.check(t.size,n.size);let d=f.cells.get(u.key);if(d||(d=l(),f.cells.set(u.key,d)),s(d,i),!r.totals)continue;let w=o.get(u.key);w||(w=l(),o.set(u.key,w)),s(f.totals,i),s(w,i),s(a,i)}return{groups:t,columns:n,columnTotals:o,totals:a}}function h(e,r){return JSON.stringify([e.slice(0,r.length),r.map(l=>[l===null?"null":typeof l,l])])}function S(e,r){return r.map(l=>{const t=Object.prototype.hasOwnProperty.call(e,l)?e[l]:null;if(t==null)return null;if(typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t))return t;throw new Error("矩阵维度必须是有限 JSON 标量")})}function N(e,r,l){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("矩阵层级应为对象");for(const t of[e.emptyLabel,e.subtotalLabel,e.totalLabel])if(t!==void 0&&typeof t!="string")throw new Error("矩阵层级标签应为字符串");k(e.row,r.length),k(e.column,l.length)}function k(e,r){if(e!==void 0){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("矩阵轴配置应为对象");if(e.labels!==void 0&&(!Array.isArray(e.labels)||e.labels.length!==r||e.labels.some(l=>typeof l!="string")))throw new Error("矩阵维度标签必须与维度字段一一对应");if(e.sort!==void 0&&(!Array.isArray(e.sort)||e.sort.length>r||e.sort.some(l=>!["source","asc","desc"].includes(l))))throw new Error("矩阵维度排序应为 source、asc 或 desc");if(e.subtotals!==void 0&&(!Array.isArray(e.subtotals)||new Set(e.subtotals).size!==e.subtotals.length||e.subtotals.some(l=>!Number.isInteger(l)||l<1||l>=r)))throw new Error("矩阵小计深度应唯一且位于 1 至末级之前")}}function A(e,r,l){return{fields:e,options:r??{},hierarchy:l,root:{values:[],children:new Map},leaves:0,expanded:0}}function F(e,r){const l=S(r,e.fields);let t=e.root;for(let n=1;n<=l.length;n++){const o=l.slice(0,n),a=h(e.fields,o);let s=t.children.get(a);s||(s={values:o,children:new Map},t.children.set(a,s),n===l.length?(e.leaves++,e.expanded++):e.options.subtotals?.includes(n)&&e.expanded++),t=s}}function L(e,r){if(e===r)return 0;if(e===null)return-1;if(r===null)return 1;if(typeof e=="number"&&typeof r=="number")return e-r;const l=`${typeof e}:${e}`,t=`${typeof r}:${r}`;return l<t?-1:1}function R(e,r){const l=[...e.children.values()];return r&&r!=="source"&&l.sort((t,n)=>L(t.values[t.values.length-1],n.values[n.values.length-1])*(r==="desc"?-1:1)),l}function y(e,r,l){return{key:h(e.fields,r),kind:l,depth:r.length,fields:e.fields.slice(0,r.length),values:r,labels:r.map(t=>t===null?e.hierarchy.emptyLabel??"(空)":String(t))}}function E(e,r){const l=[];function t(n){for(const o of R(n,e.options.sort?.[n.values.length]))o.children.size?(t(o),e.options.subtotals?.includes(o.values.length)&&l.push(y(e,o.values,"subtotal"))):l.push(y(e,o.values,"member"))}return t(e.root),r&&e.leaves&&l.push(y(e,[],"total")),l}function v(e,r,l){const t=S(r,e.fields),n=[h(e.fields,t),...(e.options.subtotals??[]).map(o=>h(e.fields,t.slice(0,o)))];return l&&n.push(h(e.fields,[])),n}function z(e,r,l){if(!(e.kind!=="member"&&r>e.depth))return e.kind==="total"?{key:"total",text:l.totalLabel??"合计",rowSpan:0}:e.kind==="subtotal"&&r===e.depth?{key:e.key,text:l.subtotalLabel??"小计",rowSpan:0}:{key:JSON.stringify(e.values.slice(0,r+1).map(t=>[typeof t,t])),text:e.labels[r],rowSpan:1}}function O(e,r){const l=e.columnFields.length+1,t=e.rowFields.length,n=Array.from({length:l},()=>Array(t+r.length).fill(null));for(let o=0;o<e.columnFields.length;o++){let a;r.forEach((s,i)=>{const c=z(s,o,e.hierarchy);if(!c){a=void 0;return}if(a?.key===c.key){a.cell.colSpan=(a.cell.colSpan??1)+1;return}const u={text:c.text,rowSpan:c.rowSpan||e.columnFields.length-o,editable:!1,derived:!0};n[o][t+i]=u,a={key:c.key,cell:u}})}return e.rowFields.forEach((o,a)=>{n[0][a]={text:e.hierarchy.row?.labels?.[a]??o,rowSpan:l,editable:!1,derived:!0}}),r.forEach((o,a)=>{const s=e.measures[o.measure];n[l-1][t+a]={text:s.label??`${s.field} (${s.op})`,editable:!1,derived:!0}}),{cells:n.map(o=>o.filter(a=>a!==null)),colWidthsMm:[...e.rowFields.map(()=>e.rowWidthMm??40),...r.map(()=>e.columnWidthMm??28)]}}function M(e,r,l,t){const n=+(!!r.totals&&e>0),o=l.expanded+n,a=(t.expanded+n)*r.measures.length+r.rowFields.length;if(o>(r.maxRows??1e3)||t.expanded+n>(r.maxColumns??200))throw new Error("矩阵层级展开数量超出预算(包含小计/总计)");if(o*a>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算");return{rowCount:o,columnCount:a,cells:o*a}}function x(e,r){if(!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const l=A(r.rowFields,r.hierarchy.row,r.hierarchy),t=A(r.columnFields,r.hierarchy.column,r.hierarchy);if(e.length*(1+(l.options.subtotals?.length??0)+ +!!r.totals)*(1+(t.options.subtotals?.length??0)+ +!!r.totals)*r.measures.length>(r.maxAggregateUpdates??1e7))throw new Error("矩阵聚合更新超出 maxAggregateUpdates 预算");let o=M(0,r,l,t);for(const a of e){if(!a||typeof a!="object"||Array.isArray(a))throw new Error("矩阵数据行应为对象");F(l,a),F(t,a),o=M(e.length,r,l,t)}return{row:l,column:t,shape:o}}function j(e,r){return x(e,r).shape}function p(e,r,l){const t=new Map;for(const n of e){const o=v(l.row,n,!!r.totals),a=v(l.column,n,!!r.totals);for(const s of o){let i=t.get(s);i||(i=new Map,t.set(s,i));for(const c of a){let u=i.get(c);u||(u=r.measures.map(f=>g.createAggregateAccumulator({...f,field:f.valueField??f.field})),i.set(c,u)),u.forEach(f=>f.add(n))}}}return t}function H(e,r){return e.flatMap((l,t)=>r.measures.map((n,o)=>({...l,field:l.kind==="total"?`total_${o}`:`c${t}_${o}`,measure:o,measureField:n.field,valueField:n.valueField??n.field,operation:n.op})))}function I(e,r){return e.kind==="total"?r.hierarchy.totalLabel??"合计":[...e.labels,...e.kind==="subtotal"?[r.hierarchy.subtotalLabel??"小计"]:[]].join(" / ")}function K(e,r){return[...r.rowFields.map((l,t)=>({field:`r${t}`,header:r.hierarchy.row?.labels?.[t]??l,semanticRole:"dimension"})),...e.map(l=>{const t=r.measures[l.measure];return{field:l.field,header:`${I(l,r)} · ${t.label??`${t.field} (${t.op})`}`,semanticRole:"measure",...t.digits===void 0?{}:{format:{kind:"number",digits:t.digits}}}})]}function T(e,r,l,t){return e.map(n=>{const o={};l.rowFields.forEach((a,s)=>{o[`r${s}`]=n.kind==="total"?s===0?l.hierarchy.totalLabel??"合计":null:n.labels[s]??(s===n.depth?l.hierarchy.subtotalLabel??"小计":null)});for(const a of r)o[a.field]=t.get(n.key)?.get(a.key)?.[a.measure]?.value()??(l.measures[a.measure].op==="count"?0:null);return o})}function _(e,r){const l=x(e,r),t=E(l.row,!!r.totals),n=H(E(l.column,!!r.totals),r),o=p(e,r,l);return{columns:K(n,r),rows:T(t,n,r,o),headerGrid:O(r,n),metadata:{rowFields:[...r.rowFields],rowLabels:[...r.hierarchy.row?.labels??r.rowFields],columnFields:[...r.columnFields],columnLabels:[...r.hierarchy.column?.labels??r.columnFields],rows:t,columns:n}}}function m(e,r){const l=r.map(t=>Object.prototype.hasOwnProperty.call(e,t)?e[t]:null);if(l.some(t=>t!=null&&typeof t!="string"&&typeof t!="boolean"&&!(typeof t=="number"&&Number.isFinite(t))))throw new Error("矩阵维度必须是有限 JSON 标量");return{key:JSON.stringify(l.map(t=>[typeof t,t??null])),label:l.map(t=>t==null?"":String(t)).join(" / ")}}function J(e){for(const r of["maxRows","maxColumns","maxInputRows","maxCells","maxAggregateUpdates"])if(e[r]!==void 0&&(!Number.isSafeInteger(e[r])||e[r]<1))throw new Error("矩阵预算应为正安全整数");for(const r of["columnWidthMm","rowWidthMm"])if(e[r]!==void 0&&(!Number.isFinite(e[r])||e[r]<=0))throw new Error("矩阵列宽应为正数")}function b(e){if(!e||!Array.isArray(e.rowFields)||!Array.isArray(e.columnFields)||!Array.isArray(e.measures))throw new Error("矩阵需要行维度、列维度和度量数组");for(const l of[e.rowFields,e.columnFields])if(l.some(t=>typeof t!="string"||!t.trim())||new Set(l).size!==l.length)throw new Error("矩阵维度字段应非空且唯一");if(J(e),!e.rowFields.length||!e.columnFields.length||e.rowFields.length>16||e.columnFields.length>16)throw new Error("矩阵需要 1–16 个行/列维度");if(!e.measures.length||e.measures.length>32)throw new Error("矩阵需要 1–32 个度量");if(e.measures.map(l=>{if(!l||typeof l!="object")throw new Error("矩阵度量应为对象");if(g.createAggregateAccumulator({...l,field:l.valueField??l.field}),l.label!==void 0&&typeof l.label!="string")throw new Error("矩阵度量标签应为字符串");return l.field}).some(l=>typeof l!="string"||!l.trim()))throw new Error("矩阵度量字段应非空");e.hierarchy!==void 0&&N(e.hierarchy,e.rowFields,e.columnFields)}function C(e,r){if(b(r),r.hierarchy)return j(e,r);if(!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const l=new Set,t=new Set;for(const a of e){if(!a||typeof a!="object"||Array.isArray(a))throw new Error("矩阵数据行应为对象");if(l.add(m(a,r.rowFields).key),t.add(m(a,r.columnFields).key),l.size>(r.maxRows??1e3)||t.size>(r.maxColumns??200))throw new Error("矩阵维度数量超出预算");if((l.size+ +!!r.totals)*((t.size+ +!!r.totals)*r.measures.length+1)>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算")}const n=l.size+ +(!!r.totals&&e.length>0),o=(t.size+ +!!r.totals)*r.measures.length+1;return{rowCount:n,columnCount:o,cells:n*o}}function P(e,r){if(r?.hierarchy)return b(r),_(e,r);C(e,r);const l=$(e,{row:a=>m(a,r.rowFields),column:a=>m(a,r.columnFields),measures:r.measures.map(a=>({...a,field:a.valueField??a.field})),totals:r.totals,check:()=>{}}),t=[...l.groups.values()].map(a=>({rowLabel:a.label})),n=[{field:"rowLabel",header:r.rowHeader??r.rowFields.join(" / "),semanticRole:"dimension"}],o={rowLabel:"合计"};return r.measures.forEach((a,s)=>{const i=[...l.columns.entries()].map(([c,u],f)=>({key:c,label:u,field:`c${f}_${s}`}));r.totals&&i.push({key:"",label:"合计",field:`total_${s}`});for(const c of i){const u=c.field===`total_${s}`;n.push({field:c.field,header:`${c.label} · ${a.label??`${a.field} (${a.op})`}`,semanticRole:"measure",...a.digits===void 0?{}:{format:{kind:"number",digits:a.digits}}});let f=0;for(const d of l.groups.values())t[f++][c.field]=(u?d.totals?.[s]:d.cells.get(c.key)?.[s])?.value()??(a.op==="count"?0:null);o[c.field]=(u?l.totals?.[s]:l.columnTotals.get(c.key)?.[s])?.value()??(a.op==="count"?0:null)}}),r.totals&&e.length&&t.push(o),{rows:t,columns:n}}exports.accumulatePivotRows=$;exports.createMatrixTable=P;exports.estimateMatrixTable=C;exports.validateMatrixOptions=b;
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { c as g } from "./computed-f3pOqWLX.js";
|
|
2
|
+
function x(e, r) {
|
|
3
|
+
const l = () => r.measures.map((i) => g(i)), t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = r.totals ? l() : void 0, s = (i, c) => i?.forEach((u) => u.add(c));
|
|
4
|
+
for (const i of e) {
|
|
5
|
+
const c = r.row(i), u = r.column(i);
|
|
6
|
+
n.has(u.key) || n.set(u.key, u.label);
|
|
7
|
+
let f = t.get(c.key);
|
|
8
|
+
f || (f = { label: c.label, cells: /* @__PURE__ */ new Map(), ...r.totals ? { totals: l() } : {} }, t.set(c.key, f)), r.check(t.size, n.size);
|
|
9
|
+
let d = f.cells.get(u.key);
|
|
10
|
+
if (d || (d = l(), f.cells.set(u.key, d)), s(d, i), !r.totals) continue;
|
|
11
|
+
let w = o.get(u.key);
|
|
12
|
+
w || (w = l(), o.set(u.key, w)), s(f.totals, i), s(w, i), s(a, i);
|
|
13
|
+
}
|
|
14
|
+
return { groups: t, columns: n, columnTotals: o, totals: a };
|
|
15
|
+
}
|
|
16
|
+
function h(e, r) {
|
|
17
|
+
return JSON.stringify([e.slice(0, r.length), r.map((l) => [l === null ? "null" : typeof l, l])]);
|
|
18
|
+
}
|
|
19
|
+
function M(e, r) {
|
|
20
|
+
return r.map((l) => {
|
|
21
|
+
const t = Object.prototype.hasOwnProperty.call(e, l) ? e[l] : null;
|
|
22
|
+
if (t == null) return null;
|
|
23
|
+
if (typeof t == "string" || typeof t == "boolean" || typeof t == "number" && Number.isFinite(t)) return t;
|
|
24
|
+
throw new Error("矩阵维度必须是有限 JSON 标量");
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function C(e, r, l) {
|
|
28
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("矩阵层级应为对象");
|
|
29
|
+
for (const t of [e.emptyLabel, e.subtotalLabel, e.totalLabel]) if (t !== void 0 && typeof t != "string") throw new Error("矩阵层级标签应为字符串");
|
|
30
|
+
b(e.row, r.length), b(e.column, l.length);
|
|
31
|
+
}
|
|
32
|
+
function b(e, r) {
|
|
33
|
+
if (e !== void 0) {
|
|
34
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("矩阵轴配置应为对象");
|
|
35
|
+
if (e.labels !== void 0 && (!Array.isArray(e.labels) || e.labels.length !== r || e.labels.some((l) => typeof l != "string"))) throw new Error("矩阵维度标签必须与维度字段一一对应");
|
|
36
|
+
if (e.sort !== void 0 && (!Array.isArray(e.sort) || e.sort.length > r || e.sort.some((l) => !["source", "asc", "desc"].includes(l)))) throw new Error("矩阵维度排序应为 source、asc 或 desc");
|
|
37
|
+
if (e.subtotals !== void 0 && (!Array.isArray(e.subtotals) || new Set(e.subtotals).size !== e.subtotals.length || e.subtotals.some((l) => !Number.isInteger(l) || l < 1 || l >= r))) throw new Error("矩阵小计深度应唯一且位于 1 至末级之前");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function k(e, r, l) {
|
|
41
|
+
return { fields: e, options: r ?? {}, hierarchy: l, root: { values: [], children: /* @__PURE__ */ new Map() }, leaves: 0, expanded: 0 };
|
|
42
|
+
}
|
|
43
|
+
function F(e, r) {
|
|
44
|
+
const l = M(r, e.fields);
|
|
45
|
+
let t = e.root;
|
|
46
|
+
for (let n = 1; n <= l.length; n++) {
|
|
47
|
+
const o = l.slice(0, n), a = h(e.fields, o);
|
|
48
|
+
let s = t.children.get(a);
|
|
49
|
+
s || (s = { values: o, children: /* @__PURE__ */ new Map() }, t.children.set(a, s), n === l.length ? (e.leaves++, e.expanded++) : e.options.subtotals?.includes(n) && e.expanded++), t = s;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function N(e, r) {
|
|
53
|
+
if (e === r) return 0;
|
|
54
|
+
if (e === null) return -1;
|
|
55
|
+
if (r === null) return 1;
|
|
56
|
+
if (typeof e == "number" && typeof r == "number") return e - r;
|
|
57
|
+
const l = `${typeof e}:${e}`, t = `${typeof r}:${r}`;
|
|
58
|
+
return l < t ? -1 : 1;
|
|
59
|
+
}
|
|
60
|
+
function L(e, r) {
|
|
61
|
+
const l = [...e.children.values()];
|
|
62
|
+
return r && r !== "source" && l.sort((t, n) => N(t.values[t.values.length - 1], n.values[n.values.length - 1]) * (r === "desc" ? -1 : 1)), l;
|
|
63
|
+
}
|
|
64
|
+
function y(e, r, l) {
|
|
65
|
+
return {
|
|
66
|
+
key: h(e.fields, r),
|
|
67
|
+
kind: l,
|
|
68
|
+
depth: r.length,
|
|
69
|
+
fields: e.fields.slice(0, r.length),
|
|
70
|
+
values: r,
|
|
71
|
+
labels: r.map((t) => t === null ? e.hierarchy.emptyLabel ?? "(空)" : String(t))
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function A(e, r) {
|
|
75
|
+
const l = [];
|
|
76
|
+
function t(n) {
|
|
77
|
+
for (const o of L(n, e.options.sort?.[n.values.length]))
|
|
78
|
+
o.children.size ? (t(o), e.options.subtotals?.includes(o.values.length) && l.push(y(e, o.values, "subtotal"))) : l.push(y(e, o.values, "member"));
|
|
79
|
+
}
|
|
80
|
+
return t(e.root), r && e.leaves && l.push(y(e, [], "total")), l;
|
|
81
|
+
}
|
|
82
|
+
function E(e, r, l) {
|
|
83
|
+
const t = M(r, e.fields), n = [h(e.fields, t), ...(e.options.subtotals ?? []).map((o) => h(e.fields, t.slice(0, o)))];
|
|
84
|
+
return l && n.push(h(e.fields, [])), n;
|
|
85
|
+
}
|
|
86
|
+
function R(e, r, l) {
|
|
87
|
+
if (!(e.kind !== "member" && r > e.depth))
|
|
88
|
+
return e.kind === "total" ? { key: "total", text: l.totalLabel ?? "合计", rowSpan: 0 } : e.kind === "subtotal" && r === e.depth ? { key: e.key, text: l.subtotalLabel ?? "小计", rowSpan: 0 } : { key: JSON.stringify(e.values.slice(0, r + 1).map((t) => [typeof t, t])), text: e.labels[r], rowSpan: 1 };
|
|
89
|
+
}
|
|
90
|
+
function z(e, r) {
|
|
91
|
+
const l = e.columnFields.length + 1, t = e.rowFields.length, n = Array.from({ length: l }, () => Array(t + r.length).fill(null));
|
|
92
|
+
for (let o = 0; o < e.columnFields.length; o++) {
|
|
93
|
+
let a;
|
|
94
|
+
r.forEach((s, i) => {
|
|
95
|
+
const c = R(s, o, e.hierarchy);
|
|
96
|
+
if (!c) {
|
|
97
|
+
a = void 0;
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (a?.key === c.key) {
|
|
101
|
+
a.cell.colSpan = (a.cell.colSpan ?? 1) + 1;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const u = { text: c.text, rowSpan: c.rowSpan || e.columnFields.length - o, editable: !1, derived: !0 };
|
|
105
|
+
n[o][t + i] = u, a = { key: c.key, cell: u };
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return e.rowFields.forEach((o, a) => {
|
|
109
|
+
n[0][a] = { text: e.hierarchy.row?.labels?.[a] ?? o, rowSpan: l, editable: !1, derived: !0 };
|
|
110
|
+
}), r.forEach((o, a) => {
|
|
111
|
+
const s = e.measures[o.measure];
|
|
112
|
+
n[l - 1][t + a] = { text: s.label ?? `${s.field} (${s.op})`, editable: !1, derived: !0 };
|
|
113
|
+
}), {
|
|
114
|
+
cells: n.map((o) => o.filter((a) => a !== null)),
|
|
115
|
+
colWidthsMm: [...e.rowFields.map(() => e.rowWidthMm ?? 40), ...r.map(() => e.columnWidthMm ?? 28)]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function v(e, r, l, t) {
|
|
119
|
+
const n = +(!!r.totals && e > 0), o = l.expanded + n, a = (t.expanded + n) * r.measures.length + r.rowFields.length;
|
|
120
|
+
if (o > (r.maxRows ?? 1e3) || t.expanded + n > (r.maxColumns ?? 200)) throw new Error("矩阵层级展开数量超出预算(包含小计/总计)");
|
|
121
|
+
if (o * a > (r.maxCells ?? 2e6)) throw new Error("矩阵输出超出 maxCells 预算");
|
|
122
|
+
return { rowCount: o, columnCount: a, cells: o * a };
|
|
123
|
+
}
|
|
124
|
+
function $(e, r) {
|
|
125
|
+
if (!Array.isArray(e) || e.length > (r.maxInputRows ?? 1e5)) throw new Error("矩阵输入超出预算");
|
|
126
|
+
const l = k(r.rowFields, r.hierarchy.row, r.hierarchy), t = k(r.columnFields, r.hierarchy.column, r.hierarchy);
|
|
127
|
+
if (e.length * (1 + (l.options.subtotals?.length ?? 0) + +!!r.totals) * (1 + (t.options.subtotals?.length ?? 0) + +!!r.totals) * r.measures.length > (r.maxAggregateUpdates ?? 1e7)) throw new Error("矩阵聚合更新超出 maxAggregateUpdates 预算");
|
|
128
|
+
let o = v(0, r, l, t);
|
|
129
|
+
for (const a of e) {
|
|
130
|
+
if (!a || typeof a != "object" || Array.isArray(a)) throw new Error("矩阵数据行应为对象");
|
|
131
|
+
F(l, a), F(t, a), o = v(e.length, r, l, t);
|
|
132
|
+
}
|
|
133
|
+
return { row: l, column: t, shape: o };
|
|
134
|
+
}
|
|
135
|
+
function j(e, r) {
|
|
136
|
+
return $(e, r).shape;
|
|
137
|
+
}
|
|
138
|
+
function O(e, r, l) {
|
|
139
|
+
const t = /* @__PURE__ */ new Map();
|
|
140
|
+
for (const n of e) {
|
|
141
|
+
const o = E(l.row, n, !!r.totals), a = E(l.column, n, !!r.totals);
|
|
142
|
+
for (const s of o) {
|
|
143
|
+
let i = t.get(s);
|
|
144
|
+
i || (i = /* @__PURE__ */ new Map(), t.set(s, i));
|
|
145
|
+
for (const c of a) {
|
|
146
|
+
let u = i.get(c);
|
|
147
|
+
u || (u = r.measures.map((f) => g({ ...f, field: f.valueField ?? f.field })), i.set(c, u)), u.forEach((f) => f.add(n));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return t;
|
|
152
|
+
}
|
|
153
|
+
function p(e, r) {
|
|
154
|
+
return e.flatMap((l, t) => r.measures.map((n, o) => ({
|
|
155
|
+
...l,
|
|
156
|
+
field: l.kind === "total" ? `total_${o}` : `c${t}_${o}`,
|
|
157
|
+
measure: o,
|
|
158
|
+
measureField: n.field,
|
|
159
|
+
valueField: n.valueField ?? n.field,
|
|
160
|
+
operation: n.op
|
|
161
|
+
})));
|
|
162
|
+
}
|
|
163
|
+
function H(e, r) {
|
|
164
|
+
return e.kind === "total" ? r.hierarchy.totalLabel ?? "合计" : [...e.labels, ...e.kind === "subtotal" ? [r.hierarchy.subtotalLabel ?? "小计"] : []].join(" / ");
|
|
165
|
+
}
|
|
166
|
+
function I(e, r) {
|
|
167
|
+
return [
|
|
168
|
+
...r.rowFields.map((l, t) => ({ field: `r${t}`, header: r.hierarchy.row?.labels?.[t] ?? l, semanticRole: "dimension" })),
|
|
169
|
+
...e.map((l) => {
|
|
170
|
+
const t = r.measures[l.measure];
|
|
171
|
+
return {
|
|
172
|
+
field: l.field,
|
|
173
|
+
header: `${H(l, r)} · ${t.label ?? `${t.field} (${t.op})`}`,
|
|
174
|
+
semanticRole: "measure",
|
|
175
|
+
...t.digits === void 0 ? {} : { format: { kind: "number", digits: t.digits } }
|
|
176
|
+
};
|
|
177
|
+
})
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
function K(e, r, l, t) {
|
|
181
|
+
return e.map((n) => {
|
|
182
|
+
const o = {};
|
|
183
|
+
l.rowFields.forEach((a, s) => {
|
|
184
|
+
o[`r${s}`] = n.kind === "total" ? s === 0 ? l.hierarchy.totalLabel ?? "合计" : null : n.labels[s] ?? (s === n.depth ? l.hierarchy.subtotalLabel ?? "小计" : null);
|
|
185
|
+
});
|
|
186
|
+
for (const a of r) o[a.field] = t.get(n.key)?.get(a.key)?.[a.measure]?.value() ?? (l.measures[a.measure].op === "count" ? 0 : null);
|
|
187
|
+
return o;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function _(e, r) {
|
|
191
|
+
const l = $(e, r), t = A(l.row, !!r.totals), n = p(A(l.column, !!r.totals), r), o = O(e, r, l);
|
|
192
|
+
return { columns: I(n, r), rows: K(t, n, r, o), headerGrid: z(r, n), metadata: {
|
|
193
|
+
rowFields: [...r.rowFields],
|
|
194
|
+
rowLabels: [...r.hierarchy.row?.labels ?? r.rowFields],
|
|
195
|
+
columnFields: [...r.columnFields],
|
|
196
|
+
columnLabels: [...r.hierarchy.column?.labels ?? r.columnFields],
|
|
197
|
+
rows: t,
|
|
198
|
+
columns: n
|
|
199
|
+
} };
|
|
200
|
+
}
|
|
201
|
+
function m(e, r) {
|
|
202
|
+
const l = r.map(
|
|
203
|
+
(t) => Object.prototype.hasOwnProperty.call(e, t) ? e[t] : null
|
|
204
|
+
);
|
|
205
|
+
if (l.some(
|
|
206
|
+
(t) => t != null && typeof t != "string" && typeof t != "boolean" && !(typeof t == "number" && Number.isFinite(t))
|
|
207
|
+
))
|
|
208
|
+
throw new Error("矩阵维度必须是有限 JSON 标量");
|
|
209
|
+
return {
|
|
210
|
+
key: JSON.stringify(l.map((t) => [typeof t, t ?? null])),
|
|
211
|
+
label: l.map((t) => t == null ? "" : String(t)).join(" / ")
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function J(e) {
|
|
215
|
+
for (const r of [
|
|
216
|
+
"maxRows",
|
|
217
|
+
"maxColumns",
|
|
218
|
+
"maxInputRows",
|
|
219
|
+
"maxCells",
|
|
220
|
+
"maxAggregateUpdates"
|
|
221
|
+
])
|
|
222
|
+
if (e[r] !== void 0 && (!Number.isSafeInteger(e[r]) || e[r] < 1))
|
|
223
|
+
throw new Error("矩阵预算应为正安全整数");
|
|
224
|
+
for (const r of ["columnWidthMm", "rowWidthMm"])
|
|
225
|
+
if (e[r] !== void 0 && (!Number.isFinite(e[r]) || e[r] <= 0))
|
|
226
|
+
throw new Error("矩阵列宽应为正数");
|
|
227
|
+
}
|
|
228
|
+
function S(e) {
|
|
229
|
+
if (!e || !Array.isArray(e.rowFields) || !Array.isArray(e.columnFields) || !Array.isArray(e.measures))
|
|
230
|
+
throw new Error("矩阵需要行维度、列维度和度量数组");
|
|
231
|
+
for (const l of [e.rowFields, e.columnFields])
|
|
232
|
+
if (l.some((t) => typeof t != "string" || !t.trim()) || new Set(l).size !== l.length)
|
|
233
|
+
throw new Error("矩阵维度字段应非空且唯一");
|
|
234
|
+
if (J(e), !e.rowFields.length || !e.columnFields.length || e.rowFields.length > 16 || e.columnFields.length > 16)
|
|
235
|
+
throw new Error("矩阵需要 1–16 个行/列维度");
|
|
236
|
+
if (!e.measures.length || e.measures.length > 32)
|
|
237
|
+
throw new Error("矩阵需要 1–32 个度量");
|
|
238
|
+
if (e.measures.map((l) => {
|
|
239
|
+
if (!l || typeof l != "object") throw new Error("矩阵度量应为对象");
|
|
240
|
+
if (g({
|
|
241
|
+
...l,
|
|
242
|
+
field: l.valueField ?? l.field
|
|
243
|
+
}), l.label !== void 0 && typeof l.label != "string")
|
|
244
|
+
throw new Error("矩阵度量标签应为字符串");
|
|
245
|
+
return l.field;
|
|
246
|
+
}).some((l) => typeof l != "string" || !l.trim()))
|
|
247
|
+
throw new Error("矩阵度量字段应非空");
|
|
248
|
+
e.hierarchy !== void 0 && C(e.hierarchy, e.rowFields, e.columnFields);
|
|
249
|
+
}
|
|
250
|
+
function W(e, r) {
|
|
251
|
+
if (S(r), r.hierarchy) return j(e, r);
|
|
252
|
+
if (!Array.isArray(e) || e.length > (r.maxInputRows ?? 1e5))
|
|
253
|
+
throw new Error("矩阵输入超出预算");
|
|
254
|
+
const l = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
|
|
255
|
+
for (const a of e) {
|
|
256
|
+
if (!a || typeof a != "object" || Array.isArray(a))
|
|
257
|
+
throw new Error("矩阵数据行应为对象");
|
|
258
|
+
if (l.add(m(a, r.rowFields).key), t.add(m(a, r.columnFields).key), l.size > (r.maxRows ?? 1e3) || t.size > (r.maxColumns ?? 200))
|
|
259
|
+
throw new Error("矩阵维度数量超出预算");
|
|
260
|
+
if ((l.size + +!!r.totals) * ((t.size + +!!r.totals) * r.measures.length + 1) > (r.maxCells ?? 2e6))
|
|
261
|
+
throw new Error("矩阵输出超出 maxCells 预算");
|
|
262
|
+
}
|
|
263
|
+
const n = l.size + +(!!r.totals && e.length > 0), o = (t.size + +!!r.totals) * r.measures.length + 1;
|
|
264
|
+
return { rowCount: n, columnCount: o, cells: n * o };
|
|
265
|
+
}
|
|
266
|
+
function T(e, r) {
|
|
267
|
+
if (r?.hierarchy)
|
|
268
|
+
return S(r), _(e, r);
|
|
269
|
+
W(e, r);
|
|
270
|
+
const l = x(e, {
|
|
271
|
+
row: (a) => m(a, r.rowFields),
|
|
272
|
+
column: (a) => m(a, r.columnFields),
|
|
273
|
+
measures: r.measures.map((a) => ({ ...a, field: a.valueField ?? a.field })),
|
|
274
|
+
totals: r.totals,
|
|
275
|
+
check: () => {
|
|
276
|
+
}
|
|
277
|
+
// Cardinality/budgets were checked before allocating accumulators.
|
|
278
|
+
}), t = [...l.groups.values()].map((a) => ({ rowLabel: a.label })), n = [{ field: "rowLabel", header: r.rowHeader ?? r.rowFields.join(" / "), semanticRole: "dimension" }], o = { rowLabel: "合计" };
|
|
279
|
+
return r.measures.forEach((a, s) => {
|
|
280
|
+
const i = [...l.columns.entries()].map(([c, u], f) => ({ key: c, label: u, field: `c${f}_${s}` }));
|
|
281
|
+
r.totals && i.push({ key: "", label: "合计", field: `total_${s}` });
|
|
282
|
+
for (const c of i) {
|
|
283
|
+
const u = c.field === `total_${s}`;
|
|
284
|
+
n.push({
|
|
285
|
+
field: c.field,
|
|
286
|
+
header: `${c.label} · ${a.label ?? `${a.field} (${a.op})`}`,
|
|
287
|
+
semanticRole: "measure",
|
|
288
|
+
...a.digits === void 0 ? {} : { format: { kind: "number", digits: a.digits } }
|
|
289
|
+
});
|
|
290
|
+
let f = 0;
|
|
291
|
+
for (const d of l.groups.values())
|
|
292
|
+
t[f++][c.field] = (u ? d.totals?.[s] : d.cells.get(c.key)?.[s])?.value() ?? (a.op === "count" ? 0 : null);
|
|
293
|
+
o[c.field] = (u ? l.totals?.[s] : l.columnTotals.get(c.key)?.[s])?.value() ?? (a.op === "count" ? 0 : null);
|
|
294
|
+
}
|
|
295
|
+
}), r.totals && e.length && t.push(o), { rows: t, columns: n };
|
|
296
|
+
}
|
|
297
|
+
export {
|
|
298
|
+
x as a,
|
|
299
|
+
T as c,
|
|
300
|
+
W as e,
|
|
301
|
+
S as v
|
|
302
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import "./font-loader-
|
|
1
|
+
import "./font-loader-CNWXomuV.js";
|
|
2
2
|
import { g as Z1 } from "./_commonjsHelpers-DaMA6jEr.js";
|
|
3
|
-
import { h as Rd, w as Y1 } from "./textwrap-
|
|
4
|
-
import { d as J1 } from "./data-bar-
|
|
5
|
-
import { o as Q1,
|
|
6
|
-
import {
|
|
7
|
-
import { I as wl, c as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
3
|
+
import { h as Rd, w as Y1 } from "./textwrap-D4ZksyMK.js";
|
|
4
|
+
import { d as J1 } from "./data-bar-IkI6VvMQ.js";
|
|
5
|
+
import { o as Q1, t as _1, i as $1, r as eg, f as tg, a as pi, b as ss, d as Md, m as rg, e as ng } from "./progress-ByiOxUD3.js";
|
|
6
|
+
import { r as ig, n as ag, O as og } from "./capabilities-pg7j7VLT.js";
|
|
7
|
+
import { I as wl, c as sg } from "./media-Y90dHK9z.js";
|
|
8
|
+
import { r as ug } from "./assets-T_gDeFaz.js";
|
|
9
|
+
import { r as fg } from "./grid-strokes-EoY66L2f.js";
|
|
10
|
+
import { d as cg } from "./rich-text-layout-Ciwa6D2o.js";
|
|
11
11
|
var Af = function(t, e) {
|
|
12
12
|
return Af = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) {
|
|
13
13
|
r.__proto__ = n;
|
|
@@ -36084,8 +36084,8 @@ function tT(t, e) {
|
|
|
36084
36084
|
}
|
|
36085
36085
|
function nc(t, e, r, n, i) {
|
|
36086
36086
|
const a = r.style ?? {};
|
|
36087
|
-
if (rc(t, a, i),
|
|
36088
|
-
|
|
36087
|
+
if (rc(t, a, i), tg(r)) {
|
|
36088
|
+
cg(r, n, {
|
|
36089
36089
|
measure(f, l) {
|
|
36090
36090
|
const h = W1(t, l), d = pi(l).fontSizePt;
|
|
36091
36091
|
try {
|
|
@@ -36126,11 +36126,11 @@ function vi(t, e, r, n) {
|
|
|
36126
36126
|
t.drawLine({ start: r, end: n, thickness: Math.max(0.1, i.widthPt), color: ca(i.color, [0.2, 0.2, 0.2]) });
|
|
36127
36127
|
}
|
|
36128
36128
|
function nT(t, e, r) {
|
|
36129
|
-
const n =
|
|
36129
|
+
const n = ng(e), i = r.x + r.width, a = r.yTop - r.height;
|
|
36130
36130
|
n.top && vi(t, e, { x: r.x, y: r.yTop }, { x: i, y: r.yTop }), n.right && vi(t, e, { x: i, y: r.yTop }, { x: i, y: a }), n.bottom && vi(t, e, { x: i, y: a }, { x: r.x, y: a }), n.left && vi(t, e, { x: r.x, y: a }, { x: r.x, y: r.yTop });
|
|
36131
36131
|
}
|
|
36132
36132
|
function iT(t, e, r, n) {
|
|
36133
|
-
for (const i of
|
|
36133
|
+
for (const i of fg(n, e)) {
|
|
36134
36134
|
const a = { borderColor: i.color, lineWidthPt: i.widthPt };
|
|
36135
36135
|
i.kind === "v" ? vi(
|
|
36136
36136
|
t,
|
|
@@ -36146,7 +36146,7 @@ function iT(t, e, r, n) {
|
|
|
36146
36146
|
}
|
|
36147
36147
|
}
|
|
36148
36148
|
async function aT(t, e, r, n, i, a) {
|
|
36149
|
-
const o =
|
|
36149
|
+
const o = rg(r.style, n.cell.style), s = {
|
|
36150
36150
|
x: i.x + At(n.xMm),
|
|
36151
36151
|
yTop: i.yTop - At(n.yMm),
|
|
36152
36152
|
width: At(n.widthMm),
|
|
@@ -36181,7 +36181,7 @@ function oT(t, e, r, n, i, a) {
|
|
|
36181
36181
|
o.length > u && t.fidelityWarnings.push(`${a}: 单元格文本超出可用高度,PDF 文本裁切;请增加行高或减少字号(${o.length} 行,可容纳 ${u} 行)`), G1(t, e, o.slice(0, Math.max(1, u)), { verticalAlign: "middle", ...n }, i);
|
|
36182
36182
|
}
|
|
36183
36183
|
async function sT(t, e, r, n, i) {
|
|
36184
|
-
const a =
|
|
36184
|
+
const a = eg(r.grid, r.widthMm, r.heightMm);
|
|
36185
36185
|
mu(e, n, r.style?.backgroundColor);
|
|
36186
36186
|
for (const o of a.cells) {
|
|
36187
36187
|
await aT(t, e, r, o, n, `${i} cell ${o.ri + 1}:${o.ci + 1}`);
|
|
@@ -36219,7 +36219,7 @@ function uT(t, e, r) {
|
|
|
36219
36219
|
async function K1(t, e, r, n, i) {
|
|
36220
36220
|
Ua(t.signal);
|
|
36221
36221
|
const a = eT(r, n);
|
|
36222
|
-
if (
|
|
36222
|
+
if ($1(r)) {
|
|
36223
36223
|
const o = await rT(t, r.imageData);
|
|
36224
36224
|
if (o) {
|
|
36225
36225
|
const s = Math.min(a.width / o.width, a.height / o.height), u = o.width * s, f = o.height * s;
|
|
@@ -36249,7 +36249,7 @@ async function fT(t, e) {
|
|
|
36249
36249
|
embedding: r,
|
|
36250
36250
|
measurer: e.measurer ?? Rd,
|
|
36251
36251
|
imageCache: /* @__PURE__ */ new Map(),
|
|
36252
|
-
inspectImage:
|
|
36252
|
+
inspectImage: sg(e),
|
|
36253
36253
|
fidelityWarnings: [],
|
|
36254
36254
|
styleWarnings: /* @__PURE__ */ new Set(),
|
|
36255
36255
|
unsupportedTextCount: 0
|
|
@@ -36263,9 +36263,9 @@ function X1(t, e, r) {
|
|
|
36263
36263
|
return n || (n = t.embed(e), r.set(e, n)), n;
|
|
36264
36264
|
}
|
|
36265
36265
|
async function FT(t, e = {}) {
|
|
36266
|
-
const r = await
|
|
36266
|
+
const r = await ug(t, { ...e, format: "pdf" });
|
|
36267
36267
|
t = r.plan;
|
|
36268
|
-
const n = [...r.diagnostics, ...
|
|
36268
|
+
const n = [...r.diagnostics, ...ig(t, "pdf", e)], i = n.length, a = await Gn.create(), o = await fT(a, e), s = [];
|
|
36269
36269
|
for (const [f, l] of t.pages.entries()) {
|
|
36270
36270
|
Ua(e.signal);
|
|
36271
36271
|
const h = At(l.pageWidthMm), d = At(l.pageHeightMm);
|
|
@@ -36289,7 +36289,7 @@ async function FT(t, e = {}) {
|
|
|
36289
36289
|
}
|
|
36290
36290
|
await Q1(e, f + 1, t.pages.length);
|
|
36291
36291
|
}
|
|
36292
|
-
if (Ua(e.signal), n.slice(i).forEach((f) =>
|
|
36292
|
+
if (Ua(e.signal), n.slice(i).forEach((f) => ag(f, e)), e.fidelity === "strict" && n.length) throw new og(n);
|
|
36293
36293
|
await o.embedding.finalize();
|
|
36294
36294
|
const u = await a.save();
|
|
36295
36295
|
return Ua(e.signal), {
|