@agile-team/mach-report 2.25.0 → 2.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist/{ExcelBindingWizard-NQ_v396s.js → ExcelBindingWizard-bs3F4dD8.js} +3 -3
- package/dist/{ExcelBindingWizard-BgJG-T6k.cjs → ExcelBindingWizard-jSdjBtWw.cjs} +1 -1
- package/dist/{ParamEditor-Z-3yodp5.js → ParamEditor-B7YVD28E.js} +1 -1
- package/dist/{ParamEditor-DEP38mBp.cjs → ParamEditor-CGfaweYX.cjs} +1 -1
- package/dist/{ReportBatchPanel-D33LjMrA.cjs → ReportBatchPanel-BRJt0TXp.cjs} +1 -1
- package/dist/{ReportBatchPanel-DG8FV-5X.js → ReportBatchPanel-BTKHtLTW.js} +1 -1
- package/dist/{ReportLabelStudio-Bz-xAayk.cjs → ReportLabelStudio-BvK_WBke.cjs} +1 -1
- package/dist/{ReportLabelStudio-BZp23_hA.js → ReportLabelStudio-CZwqyO3t.js} +2 -2
- package/dist/ReportPreview-D1ZC5kzz.js +7317 -0
- package/dist/ReportPreview-DAU-V3Ov.cjs +6 -0
- package/dist/{ReportTemplateLibrary-DpSGgvFa.js → ReportTemplateLibrary-C7sB0Jay.js} +1 -1
- package/dist/{ReportTemplateLibrary-uG1gENaW.cjs → ReportTemplateLibrary-ClwxhnC0.cjs} +1 -1
- package/dist/{RuleEditor-BONALh1Q.js → RuleEditor-CsDGFaWz.js} +3 -3
- package/dist/{RuleEditor-bLXiRcxL.cjs → RuleEditor-D-OdaGdR.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-JGBKeF3e.js → TemplateOutlinePanel-CXOT7d1r.js} +1 -1
- package/dist/{TemplateOutlinePanel-C3nfHuaR.cjs → TemplateOutlinePanel-DAqR9zQi.cjs} +1 -1
- package/dist/{TemplateReusePanel-DXQUO6nQ.js → TemplateReusePanel-Dcfx3Hba.js} +2 -2
- package/dist/{TemplateReusePanel-BKhgp6kg.cjs → TemplateReusePanel-ygIi-Ajz.cjs} +1 -1
- package/dist/{TemplateReviewPanel-DhL7Hapy.js → TemplateReviewPanel-COU8FqPq.js} +1 -1
- package/dist/{TemplateReviewPanel-5RWFUUEf.cjs → TemplateReviewPanel-DyGULVxr.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.js +2 -2
- package/dist/artifact-integrity.json +71 -71
- package/dist/{auto-D-eDZa_V.cjs → auto-DjmvmcX-.cjs} +1 -1
- package/dist/{auto-umW_ozwr.js → auto-j7mr8Kvc.js} +82 -82
- package/dist/{designer-CCyj5WYS.js → designer-B597ZdC0.js} +4 -4
- package/dist/{designer-Cj7fn4Hh.cjs → designer-DFIdv_n7.cjs} +1 -1
- package/dist/designer.cjs +1 -1
- package/dist/designer.js +1 -1
- package/dist/{encoding-CEkBtlUP.js → encoding-BWEMdzFG.js} +2 -2
- package/dist/{encoding-Cipno7dq.cjs → encoding-DVea2qIR.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/{json-snapshot-x0JpllWL.js → json-snapshot-DdzALe8q.js} +995 -911
- package/dist/json-snapshot-L_gJ7KRS.cjs +2 -0
- package/dist/matrix-DUYPRL7t.cjs +1 -0
- package/dist/{matrix-C6e_r_vp.js → matrix-b6T291xo.js} +120 -104
- package/dist/{plugin-B_k23hut.cjs → plugin-D5BRHlne.cjs} +1 -1
- package/dist/{plugin-CttO46hc.js → plugin-FWhTnjr0.js} +1 -1
- package/dist/{prefill-BvkuwooY.cjs → prefill-DZymomY6.cjs} +1 -1
- package/dist/{prefill-BkF9Fw_p.js → prefill-m01IM1hl.js} +1 -1
- package/dist/{prepared-CSywIEAZ.cjs → prepared-BHu8bIdj.cjs} +1 -1
- package/dist/{prepared-Cyuh61fJ.js → prepared-DO5pe6Ed.js} +1 -1
- package/dist/{protocol-DwtxjXzO.js → protocol-CZddmu2n.js} +2 -2
- package/dist/{protocol-BwbJNVZl.cjs → protocol-CymmHWmL.cjs} +1 -1
- package/dist/{region-binding-workflow-D8I4QWRh.js → region-binding-workflow-EYxvUYJ-.js} +1 -1
- package/dist/{region-binding-workflow-COD8nISZ.cjs → region-binding-workflow-NdkMSFCh.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/{runtime-BE30icyB.js → runtime-D8AlfJ6S.js} +83 -76
- package/dist/runtime-ywf3oLBR.cjs +1 -0
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +5 -5
- package/dist/server-node.js +1880 -1773
- package/dist/server.cjs +1 -1
- package/dist/server.js +6 -6
- package/dist/{template-catalog-D_gl93va.js → template-catalog-DLu814zA.js} +2 -2
- package/dist/{template-catalog-C0riwrx7.cjs → template-catalog-Lil5Ryt-.cjs} +1 -1
- package/dist/{template-fragments-D94ZZmPc.js → template-fragments-BDxdCuMD.js} +1 -1
- package/dist/{template-fragments-CgzPdFKB.cjs → template-fragments-DbKdxI1z.cjs} +1 -1
- package/dist/template-registry-B-AK1oam.cjs +1 -0
- package/dist/{template-registry-DZOtRY7t.js → template-registry-DeVgwEZj.js} +143 -142
- package/dist/vue/index.d.cts +2 -1
- package/dist/vue/index.d.ts +2 -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 +127 -126
- package/dist/{workbook-session-SzfILBJJ.js → workbook-session-B6hRjTyX.js} +1 -1
- package/dist/{workbook-session-DR2j6Hxm.cjs → workbook-session-BclW7KKH.cjs} +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +1 -1
- package/dist/xlsx.js +3 -3
- package/package.json +1 -1
- package/dist/ReportPreview-CilFAS9U.js +0 -7170
- package/dist/ReportPreview-dOOzPts2.cjs +0 -6
- package/dist/json-snapshot-DQdkA_At.cjs +0 -2
- package/dist/matrix-B8QWbsGM.cjs +0 -1
- package/dist/runtime-DRSuy_SQ.cjs +0 -1
- package/dist/template-registry-BMScUmM4.cjs +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const E=require("./diagnostic-collector-wASg6Fzs.cjs"),N=require("./textwrap-LhJkHWb1.cjs"),I=require("./computed-DK6BruFz.cjs"),M=require("./record-bindings-B7djSjNs.cjs"),Je=require("./matrix-DUYPRL7t.cjs"),z=require("./template-serialization-CqQY4zDg.cjs"),H=require("./template-registry-B-AK1oam.cjs"),Kt=require("./report-params-VTg8MoCp.cjs"),De=require("./param-validation-C-8sRJLq.cjs"),qe=require("./number-format-CZ2T_5kF.cjs"),xe=require("./dataset-IrlXbUvh.cjs"),Dt=4096,He=128*1024;function Ht(e){const t=new Map;let r=0;return{measureMm(n,o){const a=JSON.stringify([n,o.fontSizePt,o.fontFamily,o.bold,o.italic,o.letterSpacingPt]),s=t.get(a);if(s!==void 0)return t.delete(a),t.set(a,s),s;const i=e.measureMm(n,o);if(Number.isFinite(i)&&a.length<=He){for(;t.size>=Dt||r+a.length>He;){const c=t.keys().next().value;r-=c.length,t.delete(c)}t.set(a,i),r+=a.length}return i}}}function Bt(e,t){return{member:"body",subtotal:"subtotal",total:"grand-total"}[e?.rows.get(t)?.kind??"member"]}function Gt(e){const t=e.matrix;if(!t.hierarchy)return t;const r=new Map(e.columns.map(o=>[o.field,o.header])),n={sum:"求和",count:"计数",avg:"平均",min:"最小",max:"最大",weightedAvg:"加权平均"};return{...t,hierarchy:{...t.hierarchy,row:{...t.hierarchy.row,labels:t.hierarchy.row?.labels??t.rowFields.map(o=>r.get(o)??o)},column:{...t.hierarchy.column,labels:t.hierarchy.column?.labels??t.columnFields.map(o=>r.get(o)??o)}},measures:t.measures.map(o=>{const a=r.get(o.field)??r.get(o.valueField??o.field);return o.label===void 0&&a?{...o,label:`${a}(${n[o.op]})`}:o})}}function Vt(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=Je.createMatrixTable(t,Gt(e)),n=r.columns.map(i=>({...i,widthMm:i.semanticRole==="dimension"?e.matrix.rowWidthMm??40:e.matrix.columnWidthMm??28,editable:!1,align:e.align??"auto"})),o={...e,columns:n,headerGrid:r.headerGrid,rowKey:void 0,revisionField:void 0,sourceTokenField:void 0};e.layout==="wide"&&(o.widthMm=n.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:o,rows:r.rows,...s?{matrix:s}:{}}}function _t(e,t){if(!e.matrix?.hierarchy||!e.headerGrid)return e.headerGrid;const r=e.paddingMm??1,n=e.headerGrid.cells.map(()=>e.rowHeightMm??0),o=e.columns.map(c=>c.widthMm),a=E.resolveGridLayout({...e.headerGrid,colWidthsMm:o},o.reduce((c,l)=>c+l,0),n.length),s=new WeakMap;for(const{cell:c,ci:l,ri:d,widthMm:f}of a.cells){const u={...M.resolveListHeaderStyle(e,e.columns[l]),...c.style},m=E.resolveFontSize(u).fontSizePt,b=(N.wrapText(c.text??"",Math.max(1,f-r*2),{fontSizePt:m,fontFamily:u.fontFamily,bold:u.bold,italic:u.italic,letterSpacingPt:u.letterSpacing},t).length*m*(u.lineHeight??E.LINE_HEIGHT)*25.4/72+r*2)/(c.rowSpan??1);for(let y=d;y<d+(c.rowSpan??1);y++)n[y]=Math.max(n[y]??0,b);s.set(c,u)}const i=e.headerGrid.cells.map(c=>c.map(l=>l?{...l,style:s.get(l)}:null));return{...e.headerGrid,cells:i,rowHeightsMm:n}}function Wt(e,t,r){const n=new Set,o=e.cells.map((a,s)=>{const i=[];let c=0;for(const l of a){for(;n.has(`${s}:${c}`);)c++;const d=l?.colSpan??1,f=l?.rowSpan??1;let u=0;for(let m=c;m<c+d;m++){t.has(m)&&u++;for(let g=s+1;g<s+f;g++)n.add(`${g}:${m}`)}u&&i.push(l?{...l,colSpan:u}:null),c+=d}return i});return{...e,cells:o,colWidthsMm:r}}function Ue(e){if(!e.columns.some(n=>n.hidden))return e;const t=new Set,r=e.columns.filter((n,o)=>n.hidden?!1:(t.add(o),!0));if(!r.length)throw new Error("列表至少需要一列可见列");return{...e,columns:r,...e.headerGrid?{headerGrid:Wt(e.headerGrid,t,r.map(n=>n.widthMm))}:{}}}function*zt(e){const{page:t}=e;H.validateReportPageFlow(t.components,t.flow);let r=0,n=0;for(const o of H.reportFlowGroups(t.components,t.flow)){e.active();const a=o.band,s=o.components.some(d=>d.kind==="list"&&d.cardinality!=="record"),i=s?0:o.components.reduce((d,f)=>Math.max(d,f.topMm-a.topMm+(f.kind==="list"?e.height(f):f.heightMm)),a.heightMm);let c=Math.max(e.top(),n+a.topMm-r);if(!s&&i>e.bottom()-e.top()+.001)throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);!s&&c+i>e.bottom()+.001&&(e.nextPage(),yield*e.takePages(),e.active(),c=e.top());let l=c+i;for(const d of o.components){const f=c+d.topMm-a.topMm;d.kind==="list"?(yield*e.list(d,f,u=>{l=s?u:Math.max(l,u)}),e.active()):e.append({...d,topMm:f})}n=l,r=a.topMm+a.heightMm}}function Jt(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 Re(e){return e.pages.some(t=>t.components.some(r=>r.kind==="list"?Jt(r):!!r.chartBinding))}const qt=512,Be=256*1024;function Ut(){const e=new Map;let t=0,r;return(n,o,a,s)=>{s!==r&&(e.clear(),t=0,r=s);const i=JSON.stringify([n,o,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=N.wrapText(n,o,a,s),d=i.length+l.reduce((f,u)=>f+u.length,0);if(d<=Be){for(;e.size>=qt||t+d>Be;){const f=e.keys().next().value;t-=e.get(f).units,e.delete(f)}e.set(i,{lines:l.slice(),units:d}),t+=d}return l}}const Xe=1e4,Ge=25e4;function Ce(e){if(e?.aborted)throw e.reason??new DOMException("标签生成已取消","AbortError")}function Ye(e,t,r){const n=typeof e.copies=="object"?M.readRecordScalar(t,e.copies.field,r):e.copies??1;if(typeof n!="number"||!Number.isSafeInteger(n)||n<1||n>1e3)throw new M.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}]`,"每条记录复制数必须是 1..1000 的数值型整数",r.rowIndex,typeof e.copies=="object"?e.copies.field:void 0);return n}function Qe(e,t,r){if(e.rowKey===void 0)return;const n=M.readRecordScalar(t,e.rowKey,r);if(typeof n=="string"&&n.trim()||typeof n=="number"&&Number.isFinite(n))return n;throw new M.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`,"业务主键必须是非空字符串或有限数字",r.rowIndex,e.rowKey)}function Xt(e){const t=r=>1+(r.grid?.cells.reduce((n,o)=>n+1+o.length+o.reduce((a,s)=>a+(s?.children?.reduce((i,c)=>i+t(c),0)??0),0),0)??0);return e.pages.reduce((r,n)=>r+n.components.reduce((o,a)=>o+t(a),0),0)}function Yt(e,t,r){const n=e.repeat,o=Object.prototype.hasOwnProperty.call(t,n.dataset)?t[n.dataset]:void 0;if(!Array.isArray(o))throw new M.ReportBindingError(`$.datasets.${n.dataset}`,"逐记录标签数据集缺失,应提供对象数组(允许空数组)");const a=new Set,s=r.maxPages??Xe,i=Xt(e);let c=0,l=0;for(const[d,f]of o.entries()){if(Ce(r.signal),!f||typeof f!="object"||Array.isArray(f))throw new M.ReportBindingError(`$.datasets.${n.dataset}[${d}]`,"标签记录应为对象",d);const u={rowIndex:d,dataset:n.dataset},m=Qe(n,f,u);if(m!==void 0){const b=JSON.stringify([typeof m,m]);if(a.has(b))throw new M.ReportBindingError(`$.datasets.${n.dataset}[${d}].${n.rowKey}`,"业务主键重复;请先确认记录来源,避免重复打印标签",d,n.rowKey);a.add(b)}const g=Ye(n,f,u);if(c+=g*e.pages.length,l+=g*i,c>s)throw new M.PaginatePageLimitError(s,c);if(l>Ge)throw new M.ReportBindingError("$.repeat",`标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Ge},请分批生成`,d)}return o}function Qt(e,t,r){if(!e.binding)return e;const{binding:n,...o}=e,a=M.resolveComponentBinding(n,t.row,t);if(e.kind==="image"){if(!a)return;if(!M.isLabelImageData(a))throw new M.ReportBindingError(`${r}.binding`,"图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换",t.rowIndex,n.field);return{...o,imageData:a}}return e.kind==="barcode"||e.kind==="qrcode"?(delete o.imageData,{...o,code:{...o.code,value:a},fallbackText:a}):(delete o.lines,delete o.richParagraphs,{...o,text:a})}function Zt(e,t,r){if(e.kind!=="text"||e.grid||e.richParagraphs?.length)return e;const n=e.style??{},o=E.resolveFontSize(n).fontSizePt,a=e.text??e.lines?.join(`
|
|
2
|
+
`)??"";if(a.length>16384)throw new M.ReportBindingError(r,"标签文本超过 16384 字符预算,请缩小字段内容",t.rowIndex);const s=t.wrapText(a,e.widthMm,{fontSizePt:o,bold:n.bold,italic:n.italic,fontFamily:n.fontFamily,letterSpacingPt:n.letterSpacing},t.options.measurer??N.heuristicMeasurer),i=s.length*o*E.resolveLineHeight(n)*25.4/72;if(i>e.heightMm+.05)throw new M.ReportBindingError(r,`标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`,t.rowIndex,e.binding?.field);return{...e,lines:s}}function Ze(e,t,r){Ce(t.options.signal);const n=Qt(e,t,r);if(!n)return;let o=n.grid;return o&&(o={...o,cells:o.cells.map((a,s)=>a.map((i,c)=>i?.children?.length?{...i,children:i.children.flatMap((l,d)=>{const f=Ze(l,t,`${r}.grid.cells.${s}.${c}.children.${d}`);return f?[f]:[]})}:i))}),Zt(o===n.grid?n:{...n,grid:o},t,r)}function er(e,t,r,n,o,a){return{...e,components:e.components.flatMap((s,i)=>{const c=Ze(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:n,copyCount:o,templatePageIndex:t}}}}function*tr(e,t,r){const n=[];if(H.validateTemplateRepeat(e,n),n.length)throw new M.ReportBindingError(n[0].path,n[0].message);if(!e.repeat){for(const[i,c]of e.pages.entries())yield{page:c,pageIndex:i};return}const o=e.repeat,a=Yt(e,t,r),s=Ut();for(const[i,c]of a.entries()){const l={row:c,rowIndex:i,dataset:o.dataset,options:r,wrapText:s},d=Ye(o,c,l),f=Qe(o,c,l);for(let u=0;u<d;u++)for(const[m,g]of e.pages.entries())Ce(r.signal),yield{page:er(g,m,l,u,d,f),pageIndex:m}}}const rr=Object.freeze({}),nr=16;function or(e){if(e===void 0)return rr;try{const t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null||Object.getOwnPropertySymbols(e).length)return;const r=Object.create(null);for(const n of Object.getOwnPropertyNames(e)){const o=Object.getOwnPropertyDescriptor(e,n);if(!o?.enumerable||o.get||o.set)return;const a=o.value;if(a!==null&&(typeof a=="object"||typeof a=="function"))return;r[n]=a}return r}catch{return}}function ar(e,t){const r=Object.keys(t);return r.length===Object.keys(e).length&&r.every(n=>Object.prototype.hasOwnProperty.call(e,n)&&Object.is(e[n],t[n]))}function sr(e){const t=[];return(r,n,o,a)=>{if(!Number.isInteger(r)||r<0||r>=nr)return e(o,a);const s=or(a);if(!s)return e(o,a);const i=t[r];if(i?.firstRow===n&&i.label===o&&ar(i.style,s))return i.row;const c=e(o,a);return t[r]={firstRow:n,label:o,style:s,row:c},c}}function ir(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 re(e,t){const r=t.heightMm-(e.layout==="wide"?t.marginBottomMm:e.marginBottomMm??t.marginBottomMm);return e.components.reduce((n,o)=>o.kind!=="list"&&o.pageAnchor==="footer"?Math.min(n,o.topMm):n,r)}function Q(e){return e.components.reduce((t,r)=>r.kind!=="list"&&r.pageAnchor==="header"?Math.max(t,r.topMm+r.heightMm):t,0)}function et(e,t){let r=e.textMetrics.get(t);if(!r){const n=E.resolveFontSize(t).fontSizePt;r={measureOptions:{fontSizePt:n,fontFamily:t.fontFamily??E.DEFAULT_FONT_FAMILY,italic:t.italic,bold:t.bold,letterSpacingPt:t.letterSpacing},lineMm:n*(t.lineHeight??E.LINE_HEIGHT)*25.4/72},e.textMetrics.set(t,r)}return r}function cr(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e}function Ee(e,t,r=[],n){const o=e.fontSizePt??E.DEFAULT_FONT_PT,a=e.paddingMm??1,s=e.columns.map(p=>p.align??p.style?.align??e.align??"auto"),i=e.columns.map((p,h)=>({...E.mergeComponentStyles({fontSize:o,verticalAlign:"middle"},p.style),align:s[h]==="auto"?"left":s[h]})),c=i.map((p,h)=>s[h]==="auto"?{left:p,center:{...p,align:"center"},right:{...p,align:"right"}}:void 0),l=e.columns.map((p,h)=>p.rules?.map(x=>{const k=c[h];if(k)return{left:E.mergeComponentStyles(k.left,x.style),center:E.mergeComponentStyles(k.center,x.style),right:E.mergeComponentStyles(k.right,x.style)};const F=E.mergeComponentStyles(i[h],x.style);return{left:F,center:F,right:F}})),d=e.columns.map(p=>M.resolveListHeaderStyle(e,p)),f=e.columns.map(p=>p.header);let u=e.rowHeightMm??0;for(let p=0;p<f.length;p++){const h=d[p],x=E.resolveFontSize(h).fontSizePt,k=N.wrapText(f[p],e.columns[p].widthMm-a*2,{fontSizePt:x,fontFamily:h.fontFamily??E.DEFAULT_FONT_FAMILY,italic:h.italic,bold:h.bold,letterSpacingPt:h.letterSpacing},t),F=x*(h.lineHeight??E.LINE_HEIGHT)*25.4/72;u=Math.max(u,Math.max(k.length,1)*F+a*2)}const m=f.map((p,h)=>({text:p,style:d[h]})),g=e.border===!1?{borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1}:{borderBottom:!0,borderLeft:!0,borderRight:!0,borderTop:!0},b=e.columns.map(p=>p.widthMm),y=lr(_t(e,t),b,{cells:[m],colWidthsMm:b,rowHeightsMm:[u],paddingMm:a});return{fontSizePt:o,paddingMm:a,visuals:z.createColumnVisualResolvers(e.columns,r,n),visibility:e.columns.map(p=>p.visibleWhen?I.compileReportPredicate(p.visibleWhen):void 0),ruleReaders:e.columns.map(p=>p.rules?.map(h=>I.compileReportPredicate(h.when))),cellStyles:i,autoStyles:c,ruleStyles:l,textMetrics:new WeakMap,numberFormats:e.columns.map(p=>M.toExcelNumberFormat(p.format)),derivedFields:new Set(e.computed?.map(p=>p.field)),borderStyle:g,headerHeightMm:y.rowHeightsMm.reduce((p,h)=>p+h,0),headerGrid:y,colWidthsMm:b,columns:e.columns}}function lr(e,t,r){if(!e)return r;if(!e.cells.length)throw new Error("自定义列表表头至少需要一行");const n=e.rowHeightsMm??e.cells.map(()=>r.rowHeightsMm[0]);if(n.length!==e.cells.length||n.some(o=>!Number.isFinite(o)||o<=0))throw new Error("自定义列表表头行高无效");return{...e,colWidthsMm:t,rowHeightsMm:n}}function dr(e,t,r){const n=t.format?.kind==="number"||t.format?.kind==="percent";t.valueType!==void 0?e.valueType=t.valueType:n&&(e.valueType="number"),t.editable!==void 0&&(e.editable=t.editable),(typeof e.value=="number"||e.value==null)&&r!==void 0&&(e.numberFormat=r)}function Z(e,t,r){const n=e.columns,o=e.tree?.rows.get(t);let a=e.rowHeightFloorMm;const s=new Array(n.length);for(let i=0;i<n.length;i++){const c=n[i],l=e.visibility[i]?.(t)!==!1,d=l?t[c.field]:null,f=e.autoStyles[i]?M.resolveListAutoAlignment(d,c.format,c.semanticRole,c.valueType):"left";let u=e.autoStyles[i]?.[f]??e.cellStyles[i];if(c.rules){for(let x=0;x<c.rules.length;x++)if(e.ruleReaders[i][x](t)){u=e.ruleStyles[i][x][f];break}}const m=c.format?M.formatValue(d,c.format):M.listCellText(d),g=ur(e,c,o);u=fr(e,c,u,o);const b=et(e,u),y=N.wrapText(m,Math.max(1,c.widthMm-e.paddingMm*2-g),b.measureOptions,r);a=Math.max(a,y.length*b.lineMm+e.paddingMm*2);const p=cr(d),h={text:m,style:u};d!=null&&e.visuals[i]?.apply(h,t),p!==void 0&&(h.value=p),dr(h,c,e.numberFormats[i]),mr(h,c,e,o,g),e.derivedFields.has(c.field)&&(h.derived=!0,h.editable=!1),l||(h.editable=!1),s[i]=h}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 ur(e,t,r){return!r||t.field!==e.tree.list.tree.labelField?0:M.listTreeIndent(e.tree.list,t,r,e.paddingMm)}function fr(e,t,r,n){return!n||t.field!==e.tree.list.tree.labelField||r.align==="left"?r:{...r,align:"left"}}function mr(e,t,r,n,o=0){n&&(o&&(e.indentMm=o),M.applyListTreeMetadata(e,t,n,r.tree.list))}function tt(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*rt(e,t,r=0){const n=t[r];if(!n){for(const a of e)yield{kind:"row",row:a};return}const o=new Map;for(const a of e){const s=tt(a[n.field]),i=o.get(s);i?i.push(a):o.set(s,[a])}for(const a of o.values())yield{kind:"groupHeader",label:(n.headerTemplate??"{value}").replace(/\{value\}/g,M.listCellText(a[0][n.field])),firstRow:a[0],group:n,depth:r,rows:a},yield*rt(a,t,r+1),(n.subtotal?.length||n.aggregates?.length)&&(yield{kind:"subtotal",label:n.subtotalLabel??"小计",rows:a,group:n,depth:r}),yield{kind:"groupEnd",depth:r}}function nt(e,t,r,n=[]){const o=[...r.filter(a=>!n.some(s=>s.field===a)).map(a=>({field:a,op:"sum"})),...n];return new Map(o.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:M.formatValue(i,s),...i===null?{}:{value:i},...typeof i=="number"?{numberFormat:M.toExcelNumberFormat(s)}:{}}]}))}function ot(e,t){const r=e.findIndex(n=>t.includes(n.field));return r<0?1:r}function ne(e,t,r,n,o,a){const s=[],i=Math.max(0,Math.min(a,e.columns.length)),c=E.mergeComponentStyles({fontSize:e.fontSizePt},o);i&&s.push({text:r,colSpan:i,style:{bold:!0,...c}});for(let u=i;u<e.columns.length;u++){const m=e.columns[u],g=n.get(m.field),b=e.autoStyles[u]?.[M.resolveListAutoAlignment(g?.value,m.format,m.semanticRole,m.valueType)]??e.cellStyles[u];s.push({...g,text:g?.text??"",style:E.mergeComponentStyles(b,o)})}const l={text:r,colSpan:e.columns.length,style:{bold:!0,...c}},d=i?[s]:[[l],s],f=d.map(u=>gr(e,u,t));return{grid:{cells:d,colWidthsMm:e.colWidthsMm,rowHeightsMm:f,paddingMm:e.paddingMm},heightMm:f.reduce((u,m)=>u+m,0)}}function gr(e,t,r){let n=e.rowHeightFloorMm,o=0;for(const a of t){let s=0;const i=o+(a.colSpan??1);for(;o<i;o++)s+=e.colWidthsMm[o]??0;const c=et(e,a.style),l=N.wrapText(a.text??"",s-e.paddingMm*2,c.measureOptions,r);n=Math.max(n,l.length*c.lineMm+e.paddingMm*2)}return n}function hr(e,t,r){const{templatePage:n,current:o,warnings:a,nextId:s,pushCurrent:i}=r,c=()=>re(n,o),l=Math.max(o.marginTopMm,Q(n)),d=n.layout==="wide"?Q(n):l,f={id:r.tableId,columnKeys:e.columns.map(w=>w.field),...e.layout===void 0?{}:{layout:e.layout},...e.title===void 0?{}:{title:e.title}},u=new Map,m=new Map,g={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}:{}}}:{}},b=w=>o.components.push({...g,topMm:w});if(r.flow&&e.header!==!1&&t.headerHeightMm>c()-l+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的表头高度超出单页可用范围`);let y=Math.max(r.startTop??e.topMm,l);e.header!==!1&&(b(y),y+=t.headerHeightMm+r.mmPerRow);function p(){const w=Math.max(r.flow||n.layout==="wide"?0:e.topMm,d);return(e.header!==!1&&e.headerEveryPage!==!1?w+t.headerHeightMm:d)+[...m.values()].reduce((C,$)=>C+$.heightMm,0)}function h(){const w=n.layout==="wide"?0:o.marginBottomMm;return Math.min(n.heightMm-w,re(n,o))-p()}function x(w){if(y+w<=c())return;i(),o.components=[],o.heightMm=n.heightMm,n.layout==="wide"&&(o.marginTopMm=0,o.marginBottomMm=0);const R=Math.max(r.flow||n.layout==="wide"?0:e.topMm,d);e.header!==!1&&e.headerEveryPage!==!1?(b(R),y=R+t.headerHeightMm):y=d;for(const C of m.values())F(C,"listgr","group-header")}function k(w,R,C,$){const P=h();if(r.flow&&w.heightMm>P+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的单行高度超出单页可用范围`);w.heightMm>P&&a.push(`列表 ${e.id??e.dataset} 行高 ${w.heightMm.toFixed(2)}mm 超出单页可用高度 ${P.toFixed(2)}mm,预览与打印可能截断内容`),x(w.heightMm),F(w,R,C,$)}function F(w,R,C,$){const P=w.table?.id??f.id,S=C==="header"?-1:u.get(P)??0;C!=="header"&&u.set(P,S+w.grid.cells.length),o.components.push({kind:"rect",leftMm:e.leftMm,topMm:y,widthMm:e.widthMm,heightMm:w.heightMm,grid:w.grid,nid:s(R),table:{...f,...w.table,role:C,rowIndex:S,...$?{source:$}:{}},style:t.borderStyle,...e.meta||w.meta?{meta:{...e.meta,...w.meta}}:{}}),y+=w.heightMm}function j(w){w<=h()&&x(w)}return{keepTogether:j,placeGridRow:k,setGroupHeader:(w,R)=>{R?m.set(w,R):m.delete(w)},bottom:()=>y}}function pr(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 n=e.revisionField?t[e.revisionField]:void 0,o=e.sourceTokenField?t[e.sourceTokenField]:void 0;if(n!==void 0&&typeof n!="string"&&!(typeof n=="number"&&Number.isFinite(n)))throw new Error("业务修订号应为字符串或有限数字");if(o!==void 0&&typeof o!="string")throw new Error("来源令牌应为字符串");return{datasetId:e.dataset,rowKey:r,...n===void 0?{}:{revision:n},...o===void 0?{}:{sourceToken:o}}}function ae(e,t){const r=new Map;if(!e.rowKey)return r;const n=new Set;for(const o of t){const a=pr(e,o),s=JSON.stringify(a.rowKey);if(n.has(s))throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);n.add(s),r.set(o,a)}return r}function wr(e,t,r,n,o){if(!e.grandTotal)return;const a=typeof e.grandTotal=="object"?e.grandTotal:void 0,s=se(e)[0],i=a?.fields??s?.subtotal??[],c=a?.aggregates??s?.aggregates??[];if(i.length===0&&c.length===0){n.warnings.push(`列表 ${e.id??""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);return}const l=ne(r,n.measurer,a?.label??"合计",nt(e.columns,t,i,c),a?.style??{},ot(e.columns,[...i,...c.map(d=>d.field)]));o.placeGridRow(l,"listgt","grand-total")}function D(e){if(e?.aborted){const t=new Error("报表排版已取消");throw t.name="AbortError",t}}function se(e){const t=e.groups??(e.groupBy?[e.groupBy]:[]);if(t.length>16)throw new Error("列表最多支持 16 级分组");return t}function Pe(e){const t=Ue(e),r=t.columns.reduce((o,a)=>o+a.widthMm,0),n=r>t.widthMm?t.widthMm/r:1;return n===1?t:{...t,columns:t.columns.map(o=>({...o,widthMm:o.widthMm*n}))}}function yr(e,t,r){const n=e.detail;if(!n)return;const o=new Set;for(const l of t){const d=he(l[n.parentKey]);if(o.has(d))throw new Error("主从明细的主表关联键重复");o.add(d)}const a=r.datasets[n.dataset]??[],s=new Map,i=[];for(const l of a){const d=l[n.foreignKey];if(!at(d)&&n.unmatched==="ignore")continue;const f=he(d);if(!o.has(f)){if(n.unmatched!=="ignore")throw new Error(`明细数据集 ${n.dataset} 存在未关联的业务键`);continue}const u=s.get(f);u?u.push(l):s.set(f,[l]),i.push(l)}const c=Pe({...e,id:`${e.id??e.dataset}:detail`,dataset:n.dataset,rowKey:n.rowKey,revisionField:n.revisionField,sourceTokenField:n.sourceTokenField,computed:void 0,columns:n.columns,headerGrid:void 0,rowHeightMm:n.rowHeightMm??e.rowHeightMm,detail:void 0});return{list:c,inter:{...Ee(c,r.measurer,i,r.signal),rowHeightFloorMm:c.rowHeightMm??0},rows:s,sources:ae(c,i)}}function at(e){return typeof e=="string"&&!!e.trim()||typeof e=="number"&&Number.isFinite(e)}function he(e){if(!at(e))throw new Error("主从关联键必须是非空字符串或有限数字");return tt(e)}function*br(e,t,r,n,o){if(!r)return;const a=r.rows.get(he(t[e.detail.parentKey]))??[];if(!a.length)return;const s={id:`${n.tableId}:detail`,columnKeys:r.list.columns.map(i=>i.field),title:e.detail.label};e.detail.label&&o.placeGridRow({...ne(r.inter,n.measurer,e.detail.label,new Map,{},r.list.columns.length),table:s},"listdl","group-header"),e.detail.header!==!1&&o.placeGridRow({grid:r.inter.headerGrid,heightMm:r.inter.headerHeightMm,table:s},"listdh","header"),yield*n.takePages();for(const i of a)D(n.signal),o.placeGridRow({...Z(r.inter,i,n.measurer),table:s},"listdr","body",r.sources.get(i)),yield*n.takePages()}function st(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("树形布局需要可见的标签列");z.validateTreeComputed(e.tree,e.computed)}function vr(e,t,r){st(e);const n=z.createTreeTable(t,e.tree,{signal:r.signal,computed:e.computed?.length?{fields:e.computed,formula:r.formula}:void 0}),o={...e,rowKey:e.tree.idField},a=ae(o,n.entries.map(c=>c.original)),s=new Map,i=new WeakMap;for(const c of n.entries)s.set(c.row,a.get(c.original)),i.set(c.row,c);return{list:o,rows:n.rows,sources:s,treeRows:i,totalRows:n.leaves}}function Mr(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 it(e,t,r){const n=r.prepared.get(e);if(n)return n;const o=Mr(e,t);if(o)return r.prepared.set(e,o),o;if(e.tree){const c=vr(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=Vt(e,a);if(!e.matrix){const c=ae(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 Sr(e,t,r,n){if(!n.flow)return;const{current:o,templatePage:a}=n,s=Math.max(o.marginTopMm,Q(a)),i=Math.max(n.startTop??e.topMm,s),c=(e.header===!1?0:t.headerHeightMm)+(r[0]?Z(t,r[0],n.measurer).heightMm:0);i+c<=re(a,o)+.001||i<=s+.001||(n.pushCurrent(),o.components=[],o.heightMm=a.heightMm,a.layout==="wide"&&(o.marginTopMm=0,o.marginBottomMm=0),n.startTop=Math.max(o.marginTopMm,Q(a)))}function*xr(e,t,r){const n=it(e,t,r),o=n.rows;e=n.list,e.layout==="wide"&&(r.current.widthMm=Math.max(r.current.widthMm,e.leftMm+e.widthMm+r.current.marginRightMm));const a=n.sources??ae(e,o),s=Pe(e),i=se(s),c={...Ee(s,r.measurer,o,r.signal),rowHeightFloorMm:s.rowHeightMm??0,matrix:n.matrix,...n.treeRows?{tree:{list:s,rows:n.treeRows}}:{}};Sr(s,c,o,r);const l=hr(s,c,r),d=yr(s,o,r),f=sr((m,g)=>ne(c,r.measurer,m,new Map,g??{},s.columns.length));let u;for(const m of rt(o,i)){if(D(r.signal),m.kind==="row")l.placeGridRow(u??Z(c,m.row,r.measurer),"listr",Bt(n.matrix,m.row),a.get(m.row)),u=void 0,yield*r.takePages(),yield*br(s,m.row,d,r,l);else if(m.kind==="groupHeader"){const g=f(m.depth,m.firstRow,m.label,m.group.headerStyle);if(m.group.keepWithNext!==!1){u??=Z(c,m.firstRow,r.measurer);let b=0;for(let y=m.depth+1;y<i.length;y++){const p=i[y],h=(p.headerTemplate??"{value}").replace(/\{value\}/g,M.listCellText(m.firstRow[p.field]));b+=f(y,m.firstRow,h,p.headerStyle).heightMm}l.keepTogether(g.heightMm+b+u.heightMm)}l.placeGridRow(g,"listg","group-header"),m.group.repeatHeader&&l.setGroupHeader(m.depth,g)}else if(m.kind==="subtotal"){const g=m.group.subtotal??[],b=m.group.aggregates??[],y=ne(c,r.measurer,m.label,nt(s.columns,m.rows,g,b),m.group.subtotalStyle??{},ot(s.columns,[...g,...b.map(p=>p.field)]));l.placeGridRow(y,"listst","subtotal")}else l.setGroupHeader(m.depth);yield*r.takePages()}wr(s,n.totalRows??o,c,r,l),r.finished?.(l.bottom()),yield*r.takePages()}function ie(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 ce(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(n=>({...n,...n.text===void 0?{}:{text:t(n.text)}}))}))}:{},...e.grid?{grid:{...e.grid,cells:e.grid.cells.map(r=>r.map(n=>n?{...n,...n.text===void 0?{}:{text:t(n.text)},...n.children?{children:n.children.map(o=>ce(o,t))}:{}}:null))}}:{}}}function Rr(e){let t=!1;for(const r of e.pages)for(const n of r.components)ie(n)&&ce(n,o=>(o.includes("{totalPages}")&&(t=!0),o));return t}function Cr(e,t,r,n,o,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(n));return a===void 0?l:l.replace(/\{totalPages\}/g,String(a))};for(const c of r)s.components.push(ce(c,i));if(e.layout==="wide"){const c=s.components.reduce((l,d)=>Math.max(l,d.topMm+d.heightMm),0);s.marginBottomMm=o?e.marginBottomMm??0:0,s.pageHeightMm=Math.max(1,c+s.marginBottomMm)}return s}function Te(e){return e.cells.reduce((t,r)=>t+r.reduce((n,o)=>n+(o?1+(o.children?.reduce((a,s)=>a+ct(s),0)??0):0),0),0)}function ct(e){return e.grid?Te(e.grid):0}function le(e){for(const t of["maxPages","maxCells","knownTotalPages"])if(e[t]!==void 0&&(!Number.isSafeInteger(e[t])||e[t]<1))throw new RangeError(`${t} 应为正安全整数`);M.validateChartComponentLimit(e.maxChartComponents)}function Er(e,t){const r=it(e,t.datasets[e.dataset]??[],t),n=Pe(r.list),o={...Ee(n,t.measurer,r.rows,t.signal),rowHeightFloorMm:n.rowHeightMm??0};return(n.header===!1?0:o.headerHeightMm)+r.rows.reduce((a,s)=>a+Z(o,s,t.measurer).heightMm,0)}function*Pr(e){const{templatePage:t,current:r}=e,n=new Map(t.components.map((a,s)=>[a,s])),o=(a,s,i)=>{const c=e.datasets[a.dataset];return Array.isArray(c)||e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id??""} 输出为空`),xr(a,Array.isArray(c)?c:[],{...e,tableId:`${e.tableId}:${n.get(a)}`,startTop:s,finished:i,flow:!!t.flow})};if(t.flow){yield*zt({page:t,active:()=>D(e.signal),top:()=>Math.max(r.marginTopMm,Q(t)),bottom:()=>re(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=>Er(a,e),list:o});return}for(const a of t.components)ie(a)||(a.kind==="list"?yield*o(a):r.components.push(...e.resolveChart(a)))}function*ee(e,t,r,n,o,a=new WeakMap,s){let i=0,c=0,l=0;const d=Ht(r.measurer??N.heuristicMeasurer),f=M.createChartResolver(t,r.signal,r.maxChartComponents),u=m=>`${m}_${(++i).toString(36)}`;for(const{pageIndex:m,page:g}of tr(e,t,r)){D(r.signal);const b=ir(g),y=g.components.filter(ie);let p=[];const h=(k=!1)=>{if(D(r.signal),r.maxPages!==void 0&&c>=r.maxPages)throw new M.PaginatePageLimitError(r.maxPages,c+1);if(r.maxCells!==void 0&&(l+=[...b.components,...y].reduce((F,j)=>F+ct(j),0),l>r.maxCells))throw new M.PaginateCellLimitError(r.maxCells,l);p.push(Cr(g,b,y,++c,k,o))},x=()=>{const k=p;return p=[],k};yield*Pr({templatePage:g,current:b,warnings:n,nextId:u,pushCurrent:h,takePages:x,datasets:t,resolveChart:f,signal:r.signal,formula:r.formula,prepared:a,measurer:d,mmPerRow:r.mmPerRow??0,tableId:`table:${m}`}),h(!0),yield*x()}s&&(s.chartComponents=f.used())}function Tr(e,t,r={}){le(r);let n=0;for(const o of ee(e,t,{...r,onWarning:void 0},[]))n++;return n}function*kr(e,t,r={}){yield*Ir(e,t,r)}function*Ir(e,t,r,n){le(r);const o=Rr(e),a=new WeakMap;let s=r.knownTotalPages;if(o&&s===void 0){s=0;for(const l of ee(e,t,r,[],void 0,a))s++}const i=[];let c=0;for(const l of ee(e,t,r,i,s,a,n)){for(;c<i.length;c++)r.onWarning?.(i[c]);yield l}}function ke(e,t,r={}){const n=typeof r=="number"?{mmPerRow:r}:r;le(n);const o=[],a={chartComponents:0},s=[...ee(e,t,n,o,n.knownTotalPages,void 0,a)];return dt(e,n,s,o,a)}async function lt(e,t,r={}){le(r),D(r.signal);const n=[],o=[],a={chartComponents:0};let s=performance.now(),i=0;for(const c of ee(e,t,r,n,r.knownTotalPages,void 0,a))o.push(c),(++i>=8||performance.now()-s>=8)&&(await new Promise(l=>setTimeout(l,0)),D(r.signal),s=performance.now(),i=0);return D(r.signal),dt(e,r,o,n,a)}function dt(e,t,r,n,o){for(const a of r)a.components=a.components.map(s=>ie(s)?ce(s,i=>i.replace(/\{totalPages\}/g,String(r.length))):s);return n.forEach(a=>t.onWarning?.(a)),{plan:{schemaVersion:E.RENDER_PLAN_SCHEMA_VERSION,...Re(e)?{requiresRecalculation:!0}:{},pages:r},warnings:n,...o}}function Fr(e){const t=e.columns.find(a=>!a.hidden)?.field;if(!t)return{groups:0,total:0};const r=se(e),n=(a=[],s=[])=>a.includes(t)||s.some(i=>i.field===t),o=typeof e.grandTotal=="object"?e.grandTotal:void 0;return{groups:r.filter(a=>n(a.subtotal,a.aggregates)).length,total:Number(n(o?.fields??r[0]?.subtotal,o?.aggregates??r[0]?.aggregates))}}function $r(e,t,r){st(e);const n=z.flattenTreeInput(t[e.dataset]??[],e.tree,r),o=e.columns.filter(s=>!s.hidden).length,a=e.header===!1?0:e.headerGrid?Te(e.headerGrid):o;return n.length*o+a+ +!!e.grandTotal*2*o}function Or(e,t,r={}){if(e.tree)return $r(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=Je.estimateMatrixTable(c,e.matrix);return l.cells+(e.header===!1?0:l.columnCount*(e.matrix.hierarchy?e.matrix.columnFields.length+1:1))}const n=t[e.dataset]?.length??0,o=e.columns.filter(c=>!c.hidden).length,a=se(e).length,s=Fr(e);let i=(n*(1+2*a+s.groups)+ +!!e.grandTotal*(1+s.total))*o;if(i+=e.header===!1?0:e.headerGrid?Te(e.headerGrid):o,e.cardinality==="record"&&n===0&&(i+=o),e.detail){const c=t[e.detail.dataset]?.length??0,l=e.detail.columns.filter(d=>!d.hidden).length;i+=(c+n*(+(e.detail.header!==!1)+ +!!e.detail.label))*l}if(!Number.isSafeInteger(i))throw new RangeError("报表单元格估算超出安全整数预算");return i}class ut extends Error{constructor(t){super(t.map(r=>r.message).join(";")),this.issues=t,this.name="ReportValidationError"}}function Ve(e,t,r){if(!Number.isSafeInteger(e)||e<1||e>r)throw new Error(`校验 ${t} 超出预算`);return e}function Ar(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 ft(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("未知校验范围");Ar(r);const n={nodes:0},o=I.compileReportPredicate(r.assert,n),a=r.when?I.compileReportPredicate(r.when,n):void 0;return{rule:r,assert:o,when:a,checks:n.nodes}})}function _e(e){if(e?.aborted){const t=new Error("报表校验已取消");throw t.name="AbortError",t}}function Nr(e,t,r,n){const o=n&&Object.prototype.hasOwnProperty.call(t,n)?t[n]:void 0;if(o!==void 0&&typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o)))throw new Error("校验定位需要稳定的文本或数值业务键");return{ruleId:e.id,rowIndex:r,...o===void 0?{}:{rowKey:o},field:e.field,severity:e.severity??"error",message:e.message}}function Lr(e,t){const r=t.computed?.length?{fields:t.computed,formula:t.formula,signal:t.signal}:void 0;if(t.tree){const o=z.createTreeTable(e,t.tree,{signal:t.signal,computed:r});if(o.rows.length>1e5)throw new Error("校验展开后数据最多 100000 行");return{rows:o.rows,summaryRows:o.leaves,rowKey:t.tree.idField}}const n=r?I.computeDataset(e,r).rows:e;return{rows:n,summaryRows:n,rowKey:t.rowKey}}function jr(e,t){const r=new Set;e.forEach(n=>{if(!n||typeof n!="object"||Array.isArray(n))throw new Error("校验数据行应为对象");if(!t)return;const o=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0;if(!(typeof o=="string"&&o.trim())&&!(typeof o=="number"&&Number.isFinite(o)))throw new Error("校验定位需要稳定业务键");if(r.has(o))throw new Error("校验业务键重复");r.add(o)})}function Kr(e,t){return mt(e,t,{checks:0})}function mt(e,t,r){if(!Array.isArray(e)||e.length>1e5)throw new Error("校验数据最多 100000 行");_e(t.signal);const n=Ve(t.maxChecks??2e6,"maxChecks",1e7),o=Ve(t.maxIssues??1e3,"maxIssues",1e4);t.rowKey!==void 0&&I.computationFieldName(t.rowKey);const a=Lr(e,t),{rows:s,summaryRows:i,rowKey:c}=a;jr(s,c);const l=ft(t.rules),d=l.reduce((u,m)=>u+(m.rule.scope==="dataset"?m.checks+i.length*(m.rule.aggregates?.length??0):s.length*m.checks),0);if(r.checks+=d,r.checks>n)throw new Error("整批校验超出 maxChecks 预算");const f=[];for(const u of l)(u.rule.scope==="dataset"?[Object.fromEntries((u.rule.aggregates??[]).map(g=>[g.field,I.aggregateRows(i,{...g,field:g.valueField??g.field})]))]:s).forEach((g,b)=>{if(_e(t.signal),!g||typeof g!="object"||Array.isArray(g))throw new Error("校验数据行应为对象");if(!(u.when&&!u.when(g)||u.assert(g))){if(f.length>=o)throw new Error("校验问题超出 maxIssues 预算,请缩小范围");f.push(Nr(u.rule,g,u.rule.scope==="dataset"?void 0:b,u.rule.scope==="dataset"?void 0:c))}});return f}function gt(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 ut(e)}function We(e,t,r){const n=e.get(t);if(n&&JSON.stringify(n)!==JSON.stringify(r))throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");e.set(t,r)}function Dr(e,t,r,n=[]){ft(t.rules);const o=[],a={checks:0};for(const[i,c]of e.entries()){const l=new Map;for(const d of c.template.pages)for(const f of d.components)f.kind==="list"&&(We(l,f.dataset,{rowKey:f.tree?.idField??f.rowKey,computed:f.computed,tree:f.tree}),f.detail&&We(l,f.detail.dataset,{rowKey:f.detail.rowKey}));for(const[d,f]of l){const u=t.rules.filter(m=>!m.dataset||m.dataset===d);if(u.length&&(o.push(...mt(c.datasets[d]??[],{...t,rules:u,...f,formula:n[i],signal:r},a).map(m=>({...m,dataset:d,sourceScope:c.sourceScope}))),o.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 o}function ht(e){return!e||typeof e!="object"?!1:[e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex].every(t=>Number.isInteger(t)&&t>=0)}function pt(e,t,r){const n=e.grid;if(!n)return null;const o=n.cells[t];if(!o)return null;const s=E.resolveGridLayout(n,e.widthMm,e.heightMm).cells.filter(c=>c.ri===t).findIndex(c=>c.ci===r),i=o[s];return i?{cell:i,sourceColumnIndex:s}:null}function Hr(e){return e.value!==void 0?e.value:e.rawText??e.text??null}function Br(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 Gr(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 Vr(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 _r(e,t,r){if(e.derived)return;if(e.source)return{...e.source};const n=t.table?.source,o=t.table?.columnKeys[r.columnIndex];if(!(!n||n.rowKey===void 0||o===void 0))return{...n,rowKey:n.rowKey,field:o}}function pe(e,t,r){const n=Hr(r),o=Gr(r,e);return{address:{...t},cell:r,component:e,value:n,valueType:Br(r,n),table:Vr(e,t),source:_r(r,e,t),editable:o===void 0,readOnlyReason:o}}function de(e,t){if(!ht(t))return null;const r=e.pages[t.pageIndex]?.components[t.componentIndex];if(!r)return null;const n=pt(r,t.rowIndex,t.columnIndex);return n?pe(r,t,n.cell):null}function wt(e,t=!0){const r=new Map;function n(i){if(!i.grid)return;let c=r.get(i);if(!c){const l=E.resolveGridLayout(i.grid,i.widthMm,i.heightMm),d=new Map,f=new Map;for(const u of l.cells){const m=d.get(u.ri)??0;d.set(u.ri,m+1);const g=i.grid.cells[u.ri]?.[m];g&&f.set(`${u.ri}:${u.ci}`,g)}c={layout:t?l:void 0,cells:f},r.set(i,c)}return c}function o(i){if(!ht(i))return null;const c=e.pages[i.pageIndex]?.components[i.componentIndex];if(!c)return null;const l=n(c)?.cells.get(`${i.rowIndex}:${i.columnIndex}`);return l?pe(c,i,l):null}function*a(i,c){const l=e.pages[i]?.components[c],d=l&&n(l);if(d)for(const f of s(l).cells){const u=d.cells.get(`${f.ri}:${f.ci}`);u&&(yield pe(l,{pageIndex:i,componentIndex:c,rowIndex:f.ri,columnIndex:f.ci},u))}}function s(i){const c=n(i);return c&&(c.layout??E.resolveGridLayout(i.grid,i.widthMm,i.heightMm))}return{resolve:o,entries:a,layout:s}}function G(e){return wt(e,!1).resolve}class v extends Error{constructor(t){super(`Invalid report cell edit: ${t}`),this.code=t,this.name="ReportCellEditError"}}function Wr(e,t){let r=e.trim();const n=t&&r.endsWith("%");if(n&&(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 v("number");return Number(r)/(n?100:1)}function zr(e,t){if(e===null||typeof e=="string"&&e.trim()==="")return null;if(typeof e!="string"&&typeof e!="number")throw new v("number");const r=typeof e=="number"?e:Wr(e,qe.isExcelPercentageFormat(t.cell.numberFormat));if(!Number.isFinite(r)||Number.isInteger(r)&&!Number.isSafeInteger(r))throw new v("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 v("boolean")}function Ie(e,t){return e.valueType==="number"?zr(t,e):e.valueType==="boolean"?Jr(t):t===null?null:String(t)}function qr(e,t){const r=t.cell.text,o=[["是","否"],["TRUE","FALSE"],["True","False"],["true","false"],["1","0"]].find(a=>a.includes(r??""));return o?o[e?0:1]:String(e)}function J(e,t){return t===null?"":typeof t=="boolean"?qr(t,e):typeof t=="number"?qe.formatExcelNumber(t,e.cell.numberFormat):String(t)}function Ur(e,t,r){const n=de(e,t);if(!n)throw new v("missing");return q(n,r)}function q(e,t){if(!e.editable)throw new v("readonly");const r=Ie(e,t);return{address:{...e.address},table:e.table,source:e.source,previousValue:e.value,previousText:e.cell.text??"",value:r,text:J(e,r)}}function Xr(e,t){const r=e.table,n=t.table;return!r||!n||r.columnKey===void 0?!1:r.id===n.id&&r.rowIndex===n.rowIndex&&r.role===n.role&&r.columnKey===n.columnKey}function yt(e,t,r){const n=e.grid,{rowIndex:o,columnIndex:a}=t.address,s=pt(e,o,a),i=[...n.cells],c=[...i[o]],l=J(t,r.value),d={...s.cell,value:r.value,text:l,rawText:l};return c[s.sourceColumnIndex]=d,i[o]=c,{...e,grid:{...n,cells:i}}}function Yr(e,t){const r=e.table?.columnKeys,n=t.table?.columnKey;return r&&n!==void 0?r.flatMap((o,a)=>o===n?[a]:[]):[]}function Qr(e,t,r,n,o,a){const s=t.table,i=o.table;if(!s||!i||s.id!==i.id||s.role!==i.role||!t.grid)return t;const c=i.rowIndex-s.rowIndex;if(c<0||c>=t.grid.cells.length)return t;let l=t;for(const d of Yr(t,o)){const f=de(e,{pageIndex:r,componentIndex:n,rowIndex:c,columnIndex:d});f?.editable&&Xr(o,f)&&(l=yt(l,f,a))}return l}function Zr(e,t,r,n,o,a){const s=o.address;return o.table?.columnKey!==void 0?Qr(e,t,r,n,o,a):s.pageIndex===r&&s.componentIndex===n?yt(t,o,a):t}function ue(e,t){const r=t.source;if(!r)return!1;const n=e.source;return!n||["sourceScope","datasetId","rowKey","field","revision","sourceToken"].some(o=>!Object.is(n[o],r[o]))}function en(e,t){const r=de(e,t.address);if(!r)throw new v("missing");if(!r.editable)throw new v("readonly");if(ue(r,t))throw new v("conflict");if(!Object.is(r.value,t.previousValue)||(r.cell.text??"")!==t.previousText)throw new v("conflict");const n=Ie(r,t.value),o={...t,value:n,text:J(r,n)};if(Object.is(n,r.value)&&o.text===r.cell.text)return e;const a=e.pages.map((s,i)=>{const c=s.components.map((l,d)=>Zr(e,l,i,d,r,o));return c.every((l,d)=>l===s.components[d])?s:{...s,components:c}});return{...e,pages:a}}function bt(e){const t=[];for(const r of e.template.pages)for(const n of r.components)n.kind==="list"&&(t.push(n.tree?{...n,rowKey:n.tree.idField}:n),n.detail&&t.push({...n.detail,relation:{detail:n.detail,parentRows:e.datasets[n.dataset]??[]}}));return t}function U(e){return JSON.stringify([e.sourceScope,e.datasetId])}function oe(e){return JSON.stringify([e.sourceScope,e.datasetId,e.rowKey])}function vt(e){const t=new Map,r=new Set;return e.forEach((n,o)=>{for(const a of bt(n)){if(!a.rowKey)continue;const s=a.relation,i=s?new Set(s.parentRows.map(c=>JSON.stringify(c[s.detail.parentKey]))):void 0;(n.datasets[a.dataset]??[]).forEach((c,l)=>{if(s&&!i.has(JSON.stringify(c[s.detail.foreignKey])))return;const d=c[a.rowKey];if(typeof d!="string"&&typeof d!="number")return;const f=`${o}:${a.dataset}:${l}:${a.rowKey}`;if(r.has(f))return;r.add(f);const u=oe({sourceScope:n.sourceScope,datasetId:a.dataset,rowKey:d}),m=t.get(u)??[];m.push({partIndex:o,dataset:a.dataset,rowIndex:l,row:c,binding:a}),t.set(u,m)})}}),n=>{const o=t.get(oe(n));if(!o?.length)throw new v("missing");if(new Set(o.map(a=>`${a.partIndex}:${a.dataset}`)).size!==o.length)throw new v("conflict");return o}}function Mt(e,t){const r=e.map(o=>({...o,datasets:{...o.datasets}})),n=new Map;for(const{row:o,field:a,value:s}of t){const i=r[o.partIndex],c=JSON.stringify([o.partIndex,o.dataset]);let l=n.get(c);l||(i.datasets[o.dataset]=[...i.datasets[o.dataset]],n.set(c,l=new Set));const d=i.datasets[o.dataset];l.has(o.rowIndex)||(d[o.rowIndex]={...d[o.rowIndex]},l.add(o.rowIndex));const f=d[o.rowIndex];Object.prototype.hasOwnProperty.call(f,a)?f[a]=s:Object.defineProperty(f,a,{value:s,enumerable:!0,writable:!0,configurable:!0})}for(const o of n.keys()){const[a,s]=JSON.parse(o);I.forkComputedDataset(e[a].datasets[s],r[a].datasets[s])}return r}function tn(e,t,r){const n=[],o=new Set;return e.forEach((a,s)=>{for(const i of bt(a))t.has(U({sourceScope:a.sourceScope,datasetId:i.dataset}))&&(a.datasets[i.dataset]??[]).forEach((c,l)=>{const d={partIndex:s,dataset:i.dataset,rowIndex:l,row:c,binding:i};for(const[f,u]of[[i.revisionField,r.revision],[i.sourceTokenField,r.sourceToken]]){if(!f||u===void 0)continue;const m=`${s}:${i.dataset}:${l}:${f}`;o.has(m)||(o.add(m),n.push({row:d,field:f,value:u}))}})}),n}function St(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return e;const n=new Set(t.edits.flatMap(o=>o.source?[U(o.source)]:[]));return Fe(e,new Map([...n].map(o=>[o,r])))}function Fe(e,t){if(!t.size)return e;function r(a){const s=a.datasetId&&t.get(U({...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 n(a){const s=a.map(i=>{const c=i.table?.source?r(i.table.source):void 0,l=i.table&&c!==i.table.source?{...i.table,source:c}:i.table,d=i.grid?.cells.map(u=>{const m=u.map(g=>{if(!g)return g;const b=g.source?r(g.source):void 0,y=g.children?n(g.children):void 0;return b===g.source&&y===g.children?g:{...g,source:b,children:y}});return m.some((g,b)=>g!==u[b])?m:u}),f=i.grid&&d?.some((u,m)=>u!==i.grid.cells[m])?{...i.grid,cells:d}:i.grid;return l!==i.table||f!==i.grid?{...i,table:l,grid:f}:i});return s.some((i,c)=>i!==a[c])?s:a}const o=e.pages.map(a=>{const s=n(a.components);return s!==a.components?{...a,components:s}:a});return o.some((a,s)=>a!==e.pages[s])?{...e,pages:o}:e}function rn(e){return JSON.stringify([e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex])}function ze(e){const t=e.table;return t?.columnKey!==void 0?JSON.stringify([t.id,t.role,t.rowIndex,t.columnKey]):rn(e.address)}function nn(e,t){if(!t.length)return e;const r=new Map(t.map(c=>[ze(c),c])),n=new Set(t.flatMap(c=>c.table?[c.table.id]:[])),o=new Set(t.map(c=>`${c.address.pageIndex}:${c.address.componentIndex}`)),a=G(e);function s(c,l,d){const f=c.grid;if(!f||!o.has(`${l}:${d}`)&&!n.has(c.table?.id??""))return c;const u=new Map,m=new Map;for(const g of E.resolveGridLayout(f,c.widthMm,c.heightMm).cells){const b=m.get(g.ri)??0;m.set(g.ri,b+1);const y=a({pageIndex:l,componentIndex:d,rowIndex:g.ri,columnIndex:g.ci}),p=y&&r.get(ze(y));if(!p||!y.editable)continue;const h=u.get(g.ri)??[...f.cells[g.ri]],x=J(y,p.value);Object.is(y.value,p.value)&&x===y.cell.text||(h[b]={...g.cell,value:p.value,text:x,rawText:x},u.set(g.ri,h))}return u.size?{...c,grid:{...f,cells:f.cells.map((g,b)=>u.get(b)??g)}}:c}const i=e.pages.map((c,l)=>{const d=c.components.map((f,u)=>s(f,l,u));return d.every((f,u)=>f===c.components[u])?c:{...c,components:d}});return i.every((c,l)=>c===e.pages[l])?e:{...e,pages:i}}function L(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 n=e.address;return JSON.stringify([n.pageIndex,n.componentIndex,n.rowIndex,n.columnIndex])}function on(e,t,r){if(typeof r!="string"||!r.trim()||!Array.isArray(t))throw new v("missing");if(t.length>1e4)throw new v("limit");const n=new Set,o=G(e),a=t.map(({address:s,value:i})=>{const c=o(s);if(!c)throw new v("missing");const l=q(c,i),d=L(l);if(n.has(d))throw new v("duplicate");return n.add(d),l});return{requestId:r,edits:a}}function an(e,t){if(t.edits.length>1e4)throw new v("limit");const r=G(e),n=new Set,o=t.edits.map(a=>{const s=r(a.address);if(!s)throw new v("missing");const i=L(a);if(n.has(i))throw new v("duplicate");if(n.add(i),ue(s,a)||!Object.is(s.value,a.previousValue)||(s.cell.text??"")!==a.previousText)throw new v("conflict");return q(s,a.value)});return nn(e,o)}function sn(e){const t=new Map;for(const r of e){const n=L(r),o=t.get(n),a=o?{...r,previousValue:o.previousValue,previousText:o.previousText}:{...r};Object.is(a.previousValue,a.value)?t.delete(n):t.set(n,a)}return[...t.values()]}function xt(e){const t=new Map,r=G(e);return e.pages.forEach((n,o)=>n.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:o,componentIndex:s,rowIndex:i,columnIndex:c});l?.source&&l.editable&&t.set(L(l),l)}})),t}function cn(e,t,r){const n=xt(e),o=G(e);return t.map(a=>{const s=a.source?n.get(L(a)):o(a.address);if(!s||L(s)!==L(a))throw new v("missing");return{address:{...s.address},value:a[r]}})}function Rt(e,t){if(++e.nodes>1e6||t>128)throw new v("limit")}function te(e,t){const r=Object.getOwnPropertyDescriptor(e,t);if(!r||r.get||r.set)throw new v("conflict");return r.value}function $e(e){if(Object.getOwnPropertyDescriptor(e,"toJSON"))throw new v("conflict");const t=Object.getPrototypeOf(e);if(Array.isArray(e)&&(t!==Array.prototype||Object.keys(e).length!==e.length))throw new v("conflict");if(!(e instanceof Date)&&!Array.isArray(e)&&t!==Object.prototype&&t!==null)throw new v("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 v("conflict");if(e instanceof Date||Array.isArray(e)&&!/^(0|[1-9]\d*)$/.test(r))throw new v("conflict")}}function Ct(e,t,r,n,o,a){if(Rt(n,o),typeof e=="function"||typeof e=="symbol")throw new v("conflict");if(e===null||typeof e!="object")return;if($e(e),r.has(e))throw new v("conflict");if(a?.has(e))return;a?.add(e),r.add(e);const s=Object.keys(e),i=s.map(c=>te(e,c));t.push({object:e,prototype:Object.getPrototypeOf(e),keys:s,values:i,...e instanceof Date?{date:Date.prototype.getTime.call(e)}:{},...Array.isArray(e)?{length:e.length}:{}});for(const c of i)Ct(c,t,r,n,o+1,a);r.delete(e)}function ln(e){const{object:t,keys:r,values:n}=e;if($e(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 o=Object.keys(t);return o.length===r.length&&r.every((a,s)=>o[s]===a&&Object.is(te(t,a),n[s]))}function dn(e){return Et(e)}function we(e){return Et(e,new Set)}function Et(e,t){const r=[];return Ct(e,r,new Set,{nodes:0},0,t),()=>{try{return r.every(ln)}catch{return!1}}}function W(e,t,r,n=!1,o){if(Rt(t,r),n){if(typeof e=="function"||typeof e=="symbol")throw new v("conflict");e!==null&&typeof e=="object"&&$e(e)}if(e===null||typeof e!="object")return e;const a=o?.get(e);if(a)return a;if(e instanceof Date){const s=new Date(Date.prototype.getTime.call(e));return o?.set(e,s),s}if(Array.isArray(e)){const s=[];o?.set(e,s);for(let i=0;i<e.length;i++)s[i]=W(te(e,String(i)),t,r+1,n,o);return s}return un(e,t,r,n,o)}function un(e,t,r,n,o){if(!o)return Object.fromEntries(Object.keys(e).map(s=>[s,W(te(e,s),t,r+1,n)]));const a={};o.set(e,a);for(const s of Object.keys(e))Object.defineProperty(a,s,{value:W(te(e,s),t,r+1,n,o),enumerable:!0,writable:!0,configurable:!0});return a}function fn(e){return W(e,{nodes:0},0,!0,new WeakMap)}function mn(e){return W(e,{nodes:0},0,!0)}function gn(e){const t=W(e,{nodes:0},0);for(const r of t)for(const n of Object.values(r.datasets))I.registerComputedDataset(n);return t}async function hn(e,t,r={}){return(await Pt(e,t,r)).plan}async function Pt(e,t,r={}){return lt(e,t,{...r,knownTotalPages:void 0})}function pn(e){return e.computed||e.groupBy||e.groups||e.grandTotal||e.tree||e.matrix||e.detail||e.rowVisibleWhen||e.headerGrid?!1:e.columns.every(t=>!t.format&&!t.rules&&!t.visibleWhen&&!t.visual)}function wn(e,t){return e.length!==t.length||t.some(r=>r?.measurer||r?.formula||r?.mmPerRow||r?.knownTotalPages!==void 0)?!1:e.every(r=>!r.template.repeat&&r.template.pages.every(n=>!n.flow&&n.components.every(o=>o.kind==="list"?pn(o):!o.binding&&!o.chartBinding&&!o.grid&&!o.table&&!o.richParagraphs)))}function yn(e){const t=new Map;for(const r of e){if(!r.source||typeof r.value!="string"||typeof r.previousValue!="string"||r.previousText!==r.previousValue||![r.previousValue,r.value].every(a=>a.trim().length&&a.length<=16384&&!/[\r\n]/.test(a)))return null;const n=oe(r.source),o=t.get(n)??new Map;o.set(r.source.field,r),t.set(n,o)}return t}function Oe(e){return!e.source&&!e.formula&&!e.derived&&!e.richParagraphs&&!e.children&&!e.dataBar&&!e.numberFormat&&!e.colSpan&&!e.rowSpan&&!e.indentMm&&!e.style?.rotateDeg}function bn(e){return e.pages.every(t=>t.components.every(r=>!r.grid||r.grid.cells.every(n=>n.every(o=>!!o&&Oe(o)))))}function vn(e,t,r,n){if(!Oe(e)||e.value!==t.previousValue||e.text!==t.previousText)return!1;const o=r-n*2,a=e.style,s=E.resolveFontSize(a).fontSizePt;if(!Number.isFinite(o)||o<1||!Number.isFinite(s)||s<=0)return!1;const i={fontSizePt:s,fontFamily:a?.fontFamily??E.DEFAULT_FONT_FAMILY,italic:a?.italic,bold:a?.bold,letterSpacingPt:a?.letterSpacing};return N.wrapText(t.previousText,o,i,N.heuristicMeasurer).length===N.wrapText(t.value,o,i,N.heuristicMeasurer).length}function Mn(e,t){const r=e.colWidthsMm;if(!r||r.length!==e.cells[0].length||r.length!==t.table.columnKeys.length)return!1;const n=r.reduce((o,a)=>o+a,0);return Number.isFinite(n)&&Math.abs(n-t.widthMm)<=Math.max(1e-7,n*1e-10)}function Sn(e,t,r){const n=e.table?.source;if(e.table?.role!=="body"||n?.rowKey===void 0)return e;const o=t.get(oe({...n,rowKey:n.rowKey}));if(!o)return e;const a=e.grid;if(!a||a.cells.length!==1||!Mn(a,e)||e.style?.rotateDeg)return null;const s=a.cells[0],i=[...s];for(let c=0;c<s.length;c++){const l=s[c];if(!l||!Oe(l))return null;const d=o.get(e.table.columnKeys[c]);if(d){if(!vn(l,d,a.colWidthsMm[c],a.paddingMm??.5))return null;i[c]={...l,value:d.value,text:d.value},r.add(d)}}return i.some((c,l)=>c!==s[l])?{...e,grid:{...a,cells:[i]}}:e}async function xn(e,t,r){const n=yn(t);if(!n||!t.length)return null;const o=new Set,a=[];let s=0;for(const c of e.pages){const l=[];for(const d of c.components){if(r?.aborted)return null;const f=Sn(d,n,o);if(!f)return null;l.push(f),++s%128===0&&await new Promise(u=>setTimeout(u,0))}a.push(l.some((d,f)=>d!==c.components[f])?{...c,components:l}:c)}if(o.size!==t.length)return null;const i={...e,pages:a};return H.validateRenderPlan(i).ok?i:null}function Rn(e,t,r){let n=wn(t,r),o=e,a;function s(c){if(o=c,a=void 0,!!n){if(!bn(c)){n=!1;return}try{a=we(c)}catch{n=!1}}}s(e);async function i(c,l,d){if(!n||c!==o||!a?.())return null;const f=a,u=await xn(c,l,d);return u&&f()?{plan:u,unchanged:f}:null}return{candidate:i,publish:s}}function Cn(e,t){const r=t?void 0:we(e);let n,o;function a(){if(r&&!r()||o&&!o())throw new v("conflict")}return{get plan(){if(!n){a();const s=fn(e),i=we(s);n=s,o=i}return n},assertUnchanged:a}}const ye=new WeakMap;function En(e){return ye.get(e)}function Y(e){if(e?.aborted){const t=new Error("报表重算已取消");throw t.name="AbortError",t}}function Tt(e,t){return e[t]===void 0?"":e[t]}function Pn(e,t){if(t.edits.length>1e4)throw new v("limit");const r=G(e),n=new Set,o=[],a=t.edits.map(s=>{const i=r(s.address);if(!i?.source)throw new v("missing");const c=L(s);if(n.has(c))throw new v("duplicate");if(n.add(c),ue(i,s)||!Object.is(i.value,s.previousValue)||(i.cell.text??"")!==s.previousText)throw new v("conflict");return o.push(i),q(i,s.value)});return{batch:{requestId:t.requestId,edits:a},contexts:o}}function Tn(e,t){const r=vt(e);return t.flatMap(n=>{if(!n.source)throw new v("missing");return r(n.source).map(o=>{if(!Object.is(Tt(o.row,n.source.field),n.previousValue))throw new v("conflict");if(o.binding.rowKey===n.source.field)throw new v("readonly");return{row:o,field:n.source.field,value:n.value}})})}function me(e,t,r){const n={...e,value:t,source:{...e.source,...r?.revision===void 0?{}:{revision:r.revision},...r?.sourceToken===void 0?{}:{sourceToken:r.sourceToken}}};return n.cell={...e.cell,value:n.value,text:J(n,n.value)},n}function kn(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return[...e];const n=new Set(t.edits.flatMap(o=>o.source?[U(o.source)]:[]));return Mt(e,tn(e,n,r))}function In(e,t,r){const n=new Set(t.edits.map(o=>U(o.source)));for(const o of n)e.set(o,{...e.get(o),...r.revision!==void 0?{revision:r.revision}:{},...r.sourceToken!==void 0?{sourceToken:r.sourceToken}:{}});return n}function Fn(e,t){return Ae(e,t)}function Ae(e,t,r){let n=t.parts;const o=t.rebuild,a=[...t.validationFormulas??[]],s=r?Rn(e,n,r):void 0;let i=dn(n),c=e,l;const d=new Map,f=new Map;function u(b){if(b!==c)throw new v("conflict");if(l)return l;if(!i?.())throw new v("conflict");return gn(n)}async function m(b,y,p,h={}){Y(h.signal),y={requestId:y.requestId,edits:y.edits.map(S=>({...S,address:{...S.address},source:S.source?{...S.source}:void 0,table:S.table?{...S.table}:void 0}))},p=p.map(S=>({...S,address:{...S.address},source:S.source?{...S.source}:void 0,table:S.table?{...S.table}:void 0,cell:{...S.cell}})),await new Promise(S=>setTimeout(S,0)),Y(h.signal);const x=u(b),k=Mt(x,Tn(x,y.edits)),F=await s?.candidate(b,y.edits,h.signal);Y(h.signal);const j=Fe(F?.plan??await o(k,h.signal),f);Y(h.signal);const K=Cn(j,r!==void 0);let w=!1,R=[],C="allow",$=!1;function P(S){return $=!0,K.assertUnchanged(),R=Object.freeze(Dr(k,S,h.signal,a).map(A=>Object.freeze({...A}))),K.assertUnchanged(),$=!1,C=S.warningPolicy??"allow",R}return h.validation&&P(h.validation),{get plan(){return K.plan},get validationIssues(){return R},validate:P,commit(S){if(Y(h.signal),w||c!==b)throw new v("conflict");if(F&&!F.unchanged())throw new v("conflict");if(K.assertUnchanged(),S?.conflicts?.length)throw new v("conflict");if($)throw new Error("候选规则校验未完成,不能提交");gt(R,C);const A=kn(k,y,S),V=St(j,y,S);if(S){const _=In(f,y,S);for(const[B,X]of d)_.has(U(X.source))&&d.set(B,me(X,X.value,S))}return p.forEach((_,B)=>d.set(L(_),me(_,y.edits[B].value,S))),w=!0,l=A,n=void 0,i=void 0,c=V,s?.publish(c),ye.set(c,g),c}}}const g={get plan(){return c},async prepare(b,y,p){const h=Pn(b,y);return m(b,h.batch,h.contexts,p)},async prepareHistory(b,y,p,h,x){if(!h.trim()||y.length>1e4)throw new v("limit");const k=u(b),F=vt(k),j=xt(b),K=new Set,R=y.map(P=>{if(!P.source)throw new v("missing");const S=L(P);if(K.has(S))throw new v("duplicate");K.add(S);const A=j.get(S)??d.get(S);if(!A?.source)throw new v("missing");const V=F(A.source)[0];return me(A,Tt(V.row,A.source.field))}).map((P,S)=>({context:P,edit:q(P,y[S][p])})).filter(({edit:P})=>!Object.is(P.previousValue,P.value)),C={requestId:h,edits:R.map(({edit:P})=>P)},$=R.map(({context:P})=>P);return{batch:C,contexts:$,prepared:await m(b,C,$,x)}}};return ye.set(e,g),g}function $n(e){const t=ke(e.template,e.datasets,e.pagination).plan;return Ae(t,{validationFormulas:[e.pagination?.formula],parts:[{template:e.template,datasets:e.datasets}],rebuild:(r,n)=>hn(r[0].template,r[0].datasets,{...e.pagination,signal:n})},[e.pagination])}let On=0;function kt(){return`report-${Date.now()}-${++On}`}function be(e,t,r){if(!r?.aborted)try{const n=e?.({...t});n&&typeof n.then=="function"&&Promise.resolve(n).catch(()=>{})}catch{}}function It(e){const t=e.taskId??kt(),r=(n,o,a)=>{be(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:n,status:o,...a===void 0?{}:{reportId:a}},e.signal)};return{taskId:t,progress(n,o,a){be(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:n,status:"started",completed:o,total:a},e.signal)},async run(n,o,a){r(n,"started",a);try{const s=await o();return r(n,"completed",a),s}catch(s){throw r(n,"failed",a),s}},runSync(n,o,a){r(n,"started",a);try{const s=o();return r(n,"completed",a),s}catch(s){throw r(n,"failed",a),s}}}}function Ne(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e,r=n=>typeof n=="string"&&n.trim().length>0&&n.length<=256;return!r(t.datasetId)||!r(t.field)||t.tableId!==void 0&&!r(t.tableId)||t.reportScope!==void 0&&(typeof t.reportScope!="string"||!t.reportScope.trim()||t.reportScope.length>4096)?!1:t.rowKey===void 0?!0:typeof t.rowKey=="string"?t.rowKey.trim().length>0&&t.rowKey.length<=1024:typeof t.rowKey=="number"&&Number.isFinite(t.rowKey)}function Ft(e){return e==="missing-source"||e==="not-applicable"||e==="not-calculable"}function $t(e){return e.target!==void 0&&!Ne(e.target)?!1:e.valueState===void 0||Ft(e.valueState)&&e.target!==void 0}function An(e,t){if(xe.validateDatasetRows([],e),!Ne(t))throw new Error("数据说明目标无效");const r=e.fields.find(o=>o.field===t.field);if(!r)throw new Error("数据说明字段未在契约中声明");const n=[];return r.description&&n.push({code:"field-definition",severity:"info",message:r.description,target:{...t}}),r.calculation&&n.push({code:"field-calculation",severity:"info",message:r.calculation.description,target:{...t}}),n}function Le(e,t,r={}){const n=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=n.get(s.dataset);if(i&&(i.childrenField??"children")!==(s.tree.childrenField??"children"))throw new Error("同一数据集的嵌套树应使用相同 childrenField");n.set(s.dataset,s.tree)}if(!n.size)return t;const o={...t};for(const[a,s]of n){const i=Math.min(s.maxRows??1e5,r.maxRows??1/0);o[a]=z.flattenTreeInput(t[a]??[],{...s,maxRows:i},r.signal)}return o}function Nn(e,t,r={}){return Object.values(Le(e,t,r)).reduce((n,o)=>n+o.length,0)}function Ln(e,t,r){const n=xe.datasetJsonSchema(r),o=e?.pages.flatMap(i=>i.components).find(i=>i.kind==="list"&&i.dataset===t&&i.tree?.input==="nested");if(!o||o.kind!=="list"||!o.tree)return n;const a=n.items,s=o.tree.childrenField??"children";return{...n,items:{$ref:"#/$defs/treeNode"},$defs:{treeNode:{...a,properties:{...a.properties,[s]:{anyOf:[{type:"null"},{type:"array",items:{$ref:"#/$defs/treeNode"}}]}}}}}}function je(e,t){return JSON.stringify([e,t])}function Ke(e,t,r){return r===void 0?je(e,t):JSON.stringify(["shared",r])}function Ot(e,t,r){return e.map(n=>{const o=n.table?{...n.table,id:r(n.table.id),...n.table.source?{source:{...n.table.source,sourceScope:t}}:{}}:void 0,a=n.grid?.cells.map(s=>s.map(i=>!i||!i.source&&!i.children?i:{...i,...i.source?{source:{...i.source,sourceScope:t}}:{},...i.children?{children:Ot(i.children,t,r)}:{}}));return o||a?{...n,...o?{table:o}:{},...a?{grid:{...n.grid,cells:a}}:{}}:n})}function ve(e){return M.validateChartComponentLimit(e.maxChartComponents),{maxPages:e.maxPages,maxCells:e.maxCells,maxChartComponents:e.maxChartComponents??M.DEFAULT_CHART_COMPONENT_LIMIT,usedPages:0,usedCells:0,usedChartComponents:0}}function jn(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 Kn(e){const t=r=>r.grid?.cells.reduce((n,o)=>n+o.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,n)=>r+n.components.reduce((o,a)=>o+t(a),0),0)}function Me(e,t){return e===void 0?void 0:e-t}function ge(e,t){return e===void 0?t:Math.max(1,Math.min(e,t??e))}function At(e,t,r,n,o){M.validateChartComponentLimit(e?.maxChartComponents);const a=Me(t.maxPages,t.usedPages),s=t.maxChartComponents-t.usedChartComponents;if(a!==void 0&&a<1&&r.pages.length&&!jn(r,n))throw new M.PaginatePageLimitError(0,1);if(s<1&&r.pages.some(i=>i.components.some(c=>c.kind!=="list"&&c.chartBinding)))throw new M.PaginateChartComponentLimitError(s,1);return{...e,signal:o??e?.signal,maxPages:ge(a,e?.maxPages),maxCells:ge(Me(t.maxCells,t.usedCells),e?.maxCells),maxChartComponents:ge(s,e?.maxChartComponents)}}function Nt(e,t){const r=Kn(t.plan),n=Me(e.maxCells,e.usedCells);if(n!==void 0&&r>n)throw new M.PaginateCellLimitError(n,r);e.usedPages+=t.plan.pages.length,e.usedCells+=r,e.usedChartComponents+=t.chartComponents}function Lt(e,t){return e instanceof M.PaginatePageLimitError&&t.maxPages!==void 0&&(e.limit===t.maxPages-t.usedPages||e.limit===0)?new M.PaginatePageLimitError(t.maxPages,t.usedPages+e.actual):e instanceof M.PaginateCellLimitError&&t.maxCells!==void 0?new M.PaginateCellLimitError(t.maxCells,t.usedCells+e.actual):e instanceof M.PaginateChartComponentLimitError&&e.limit===t.maxChartComponents-t.usedChartComponents?new M.PaginateChartComponentLimitError(t.maxChartComponents,t.usedChartComponents+e.estimated):e}function Dn(e){if(!("mapData"in e))return e;const{load:t,mapData:r,...n}=e;return{...n,load:async o=>{const a=await t(o);O(o.signal);try{return r(a,o)}catch(s){throw new T("validate",`报表 ${o.reportId} 数据映射失败`,s)}}}}class T extends Error{constructor(t,r,n){super(r),this.name="ReportSourceError",this.code=t,this.cause=n}}function fe(e){const t=new Error("报表加载已取消");return t.name="AbortError",Object.defineProperty(t,"cause",{value:e.reason}),t}function O(e){if(e?.aborted)throw fe(e)}function Se(e,t){return t?new Promise((r,n)=>{const o=()=>t.removeEventListener("abort",a),a=()=>{o(),n(fe(t))};t.addEventListener("abort",a,{once:!0}),t.aborted&&a(),Promise.resolve(e).then(s=>{o(),r(s)},s=>{o(),n(s)})}):Promise.resolve(e)}function Hn(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new T("validate",`报表 ${t} 的数据集应为对象`);for(const[r,n]of Object.entries(e))if(!Array.isArray(n)||n.some(o=>!o||typeof o!="object"||Array.isArray(o)))throw new T("validate",`报表 ${t} 的数据集 ${r} 应为对象数组`)}async function Bn(e,t,r){const{reportId:n,signal:o}=t;try{const a=await Se(e(t),o);O(o);const s=H.validateReportTemplate(a);if(!s.ok)throw new T("validate",`报表 ${n} 模板校验失败:${s.errors.slice(0,3).map(i=>`${i.path}: ${i.message}`).join("; ")}`);return r.push(...s.warnings.map(i=>`${n}: ${i.path}: ${i.message}`)),a}catch(a){throw o?.aborted?fe(o):a instanceof T?a:a instanceof H.ReportTemplateError?new T("validate",`报表 ${n} 模板校验失败:${a.message}`,a):new T("fetch",`报表 ${n} 模板加载失败:${a instanceof Error?a.message:String(a)}`,a)}}async function Gn(e,t,r,n){const o=t.signal;let a;try{if(e.load)a=await Se(e.load(t),o);else if(e.provider){const s=await Se(e.provider.query(t),o);O(o),Vn(s,r),a=s.datasets,n?.(r,s)}else a=e.datasets??{}}catch(s){throw o?.aborted?fe(o):s instanceof T?s:new T("fetch",`报表 ${r} 取数失败:${s instanceof Error?s.message:String(s)}`,s)}return O(o),a}function Vn(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new T("validate",`报表 ${t} Provider 应返回 datasets 结果对象`);for(const r of["revision","sourceToken"])if(e[r]!==void 0&&typeof e[r]!="string")throw new T("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 T("validate",`报表 ${t} Provider diagnostics 不符合结构化诊断契约`);if(e.diagnostics?.some(r=>!$t(r)))throw new T("validate",`报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`)}function _n(e,t,r,n,o){try{t=Le(n,t,{maxRows:e.dataValidation?.maxRows,signal:o})}catch(a){throw new T("validate",`报表 ${r} 树形数据无效:${a instanceof Error?a.message:String(a)}`,a)}for(const[a,s]of Object.entries(e.dataSchema??{})){let i;try{i=xe.validateDatasetRows(Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0,s,{...e.dataValidation,path:`$.datasets.${a}`})}catch(c){throw new T("config",`报表 ${r} 数据集 ${a} 字段契约配置无效`,c)}if(!i.ok)throw new T("validate",`报表 ${r} 数据集 ${a} 不符合字段契约:${i.issues[0]?.message}`,{issues:i.issues})}}async function Wn(e,t,r,n,o){try{let a;try{a=mn(e)}catch{}const s=a??e,i=At(t.pagination,n,s.template,s.datasets,o),c=a?await lt(s.template,s.datasets,i):ke(s.template,s.datasets,i);return Nt(n,c),{result:c,part:s}}catch(a){O(o);const s=Lt(a,n);throw new T("validate",`报表 ${r} 排版失败:${s instanceof Error?s.message:String(s)}`,s)}}function jt(e,t,r,n,o){const a=new Map,s=i=>{let c=a.get(i);return c===void 0&&(c=JSON.stringify([r,n,i]),a.set(i,c)),c};for(const i of t.pages)e.push({...i,meta:{...i.meta,reportScope:je(r,n)},components:Ot(i.components,o??Ke(r,n),s)})}async function zn(e,t,r,n,o){const a=[],s=ve(n);for(const[l,d]of e.entries()){O(o);try{const f=await Pt(d.template,d.datasets,At(t[l]?.pagination,s,d.template,d.datasets,o));Nt(s,f),jt(a,f.plan,l,r[l],d.sourceScope)}catch(f){throw Lt(f,s)}}const i={schemaVersion:E.RENDER_PLAN_SCHEMA_VERSION,...e.some(l=>Re(l.template))?{requiresRecalculation:!0}:{},pages:a},c=H.validateRenderPlan(i);if(!c.ok)throw new T("validate",`重算渲染计划校验失败:${c.errors[0]?.message}`);return i}function Jn(e,t={}){if(t.maxPages!==void 0&&(!Number.isSafeInteger(t.maxPages)||t.maxPages<1))throw new T("config","maxPages 应为正安全整数");if(t.maxCells!==void 0&&(!Number.isSafeInteger(t.maxCells)||t.maxCells<1))throw new T("config","maxCells 应为正安全整数");try{ve(t)}catch(o){throw new T("config","maxChartComponents 应为 1..1000000 的安全整数",o)}function r(o){const a=Object.prototype.hasOwnProperty.call(e,o)?e[o]:void 0;if(!a)throw new T("config",`未注册报表 ${o}`);if(a.sourceScope!==void 0&&(typeof a.sourceScope!="string"||!a.sourceScope.trim()||a.sourceScope.length>512))throw new T("config","sourceScope 应为不超过 512 字符的非空字符串");return a}return Object.assign(async({reportIds:o,params:a,signal:s,onWarning:i,onQueryResult:c,...l})=>{O(s);const d=It({...l,signal:s}),f=[...o],u={...a};if(f.length===0)throw new T("config","缺少报表 ID");const m=f.map(r),g=d.runSync("validate",()=>m.map(w=>De.assertReportParams(w.params??(typeof w.template=="function"?[]:w.template.params)??[],u))),b=[],y=[],p=ve(t),h=[];for(const[w,R]of m.entries()){O(s);const C=f[w],$={reportId:C,params:g[w],signal:s},P=typeof R.template=="function"?await d.run("query",()=>Bn(R.template,$,h),C):R.template;$.params=d.runSync("validate",()=>De.assertReportParams(R.params??P.params??[],$.params),C);const S=await d.run("query",()=>Gn(R,$,C,(B,X)=>c?.(B,X,w)),C);d.runSync("validate",()=>{Hn(S,C),t.onDatasets?.(C,S,P),_n(R,S,C,P,s)},C),O(s);const A=Ke(w,C,R.sourceScope),{result:V,part:_}=await d.run("layout",()=>Wn({template:P,datasets:S,sourceScope:A},R,C,p,s),C);y.push(_),jt(b,V.plan,w,C,A),h.push(...V.warnings.map(B=>`${C}: ${B}`))}O(s);const x={schemaVersion:E.RENDER_PLAN_SCHEMA_VERSION,...y.some(w=>Re(w.template))?{requiresRecalculation:!0}:{},pages:b},k=d.runSync("validate",()=>{const w=H.validateRenderPlan(x);if(!w.ok)throw new T("validate",`渲染计划校验失败:${w.errors.slice(0,3).map(R=>`${R.path}: ${R.message}`).join("; ")}`);return w});h.push(...k.warnings.map(w=>`${w.path}: ${w.message}`));const F=m.map(w=>({...w,pagination:{...w.pagination}})),j={maxPages:t.maxPages,maxCells:t.maxCells,maxChartComponents:t.maxChartComponents};try{Ae(x,{parts:y,validationFormulas:F.map(w=>w.pagination?.formula),rebuild:(w,R)=>zn(w,F,f,j,R)},F.map(w=>w.pagination))}catch{h.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算")}const K=i??t.onWarning??(w=>console.warn("[mach-report]",w));for(const w of h)O(s),K(w);return O(s),x},{getParamDefs:o=>Kt.getReportParamDefs(e,o)})}const qn=new Set([8,9,10,12,13]);function Un(e,t){const r=Array.isArray(e),n=Object.getPrototypeOf(e);if(n!==(r?Array.prototype:Object.prototype)&&!(n===null&&!r)||Object.getOwnPropertySymbols(e).length)throw t("input","快照应为普通 JSON 对象");const o=Object.getOwnPropertyNames(e).filter(a=>!(r&&a==="length"));if(r&&(o.length!==e.length||o.some((a,s)=>a!==String(s))))throw t("input","快照数组应为连续数组");return{array:r,keys:o}}function Xn(e){if(/^[\u0020-\u007e]*$/.test(e)&&!/["\\]/.test(e))return e.length+2;let t=2;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<32)t+=qn.has(n)?2:6;else if(n===34||n===92)t+=2;else if(n<128)t++;else if(n<2048)t+=2;else if(n>=55296&&n<=57343){const o=e.charCodeAt(r+1);n<=56319&&o>=56320&&o<=57343?(t+=4,r++):t+=6}else t+=3}return t}function Yn(e,t){const r=t.maxNodes??1e6;if(![t.maxBytes,r].every(u=>Number.isSafeInteger(u)&&u>0))throw t.error("budget","快照预算应为正安全整数");let n=0,o=0;const a=new Set,s=new Map;function i(u){if(u.length+2>t.maxBytes-o)throw t.error("budget","快照超过字节预算");const m=s.get(u);if(m!==void 0)return m;const g=Xn(u);return u.length<=256&&s.size<4096&&s.set(u,g),g}function c(u){if(o+=u,o>t.maxBytes)throw t.error("budget","快照超过字节预算")}function l(u,m){if(++n>r||m>64)throw t.error("budget","快照节点或深度超过预算");if(n%1024===0&&t.check?.(),typeof u=="string")return c(i(u)),u;if(u===null||typeof u=="boolean"||typeof u=="number"&&Number.isFinite(u))return c(String(u).length),typeof u=="number"&&Object.is(u,-0)?0:u;if(!u||typeof u!="object"||a.has(u))throw t.error("input","快照应为无循环的有限 JSON 值");return d(u,m)}function d(u,m){const{array:g,keys:b}=Un(u,t.error);a.add(u),c(2);const y=g?[]:{};let p=0;for(const h of b){const x=Object.getOwnPropertyDescriptor(u,h);if(x.get||x.set||!x.enumerable||["__proto__","constructor","prototype"].includes(h))throw t.error("input","快照不允许访问器或危险键");if(x.value===void 0&&!g)continue;c((p++?1:0)+(g?0:i(h)+1));const k=l(x.value===void 0?null:x.value,m+1);h in y?Object.defineProperty(y,h,{value:k,enumerable:!0,configurable:!0,writable:!0}):y[h]=k}return a.delete(u),y}t.check?.();const f=l(e,0);return t.check?.(),f}exports.DEFAULT_LABEL_PAGE_LIMIT=Xe;exports.ReportCellEditError=v;exports.ReportSourceError=T;exports.ReportValidationError=ut;exports.applyReportCellEdit=en;exports.applyReportCellEditBatch=an;exports.applyReportEditResult=St;exports.applyReportSourceMetadata=Fe;exports.assertReportValidation=gt;exports.countTemplatePages=Tr;exports.createReportCellEdit=Ur;exports.createReportCellEditBatch=on;exports.createReportCellIndex=wt;exports.createReportCellResolver=G;exports.createReportEditSession=$n;exports.createReportSource=Jn;exports.createReportTaskReporter=It;exports.defineReport=Dn;exports.editFromContext=q;exports.estimateListLayoutCells=Or;exports.explainDatasetField=An;exports.formatReportCellEdit=J;exports.getReportCellContext=de;exports.getReportEditSession=En;exports.hasValidDataExplanation=$t;exports.isReportDataTarget=Ne;exports.isReportValueState=Ft;exports.notifyReportTaskEvent=be;exports.paginateTemplate=ke;exports.paginateTemplatePages=kr;exports.parseReportCellInput=Ie;exports.projectListColumns=Ue;exports.registerReportEditSession=Fn;exports.relocateReportCellEdits=cn;exports.reportCellEditKey=L;exports.reportOccurrenceScope=je;exports.reportSourceScope=Ke;exports.reportTaskId=kt;exports.snapshotReportJson=Yn;exports.sourceChanged=ue;exports.summarizeReportCellEdits=sn;exports.templateDatasetJsonSchema=Ln;exports.templateDatasetRowCount=Nn;exports.templateValidationDatasets=Le;exports.validateReportDataset=Kr;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const m=require("./computed-DK6BruFz.cjs");function M(e,r){const l=()=>r.measures.map(c=>m.createAggregateAccumulator(c)),t=new Map,a=new Map,o=new Map,n=r.totals?l():void 0,s=(c,u)=>c?.forEach(i=>i.add(u));for(const c of e){const u=r.row(c),i=r.column(c);a.has(i.key)||a.set(i.key,i.label);let f=t.get(u.key);f||(f={label:u.label,cells:new Map,...r.totals?{totals:l()}:{}},t.set(u.key,f)),r.check(t.size,a.size);let d=f.cells.get(i.key);if(d||(d=l(),f.cells.set(i.key,d)),s(d,c),!r.totals)continue;let h=o.get(i.key);h||(h=l(),o.set(i.key,h)),s(f.totals,c),s(h,c),s(n,c)}return{groups:t,columns:a,columnTotals:o,totals:n}}function $(e,r){return JSON.stringify([e.slice(0,r.length),r.map(l=>[l===null?"null":typeof l,l])])}function x(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("矩阵层级标签应为字符串");b(e.row,r.length),b(e.column,l.length)}function b(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 k(e,r,l){return{fields:e,options:r??{},hierarchy:l,root:{key:$(e,[]),values:[],children:new Map},leaves:0,expanded:0}}function A(e,r){const l=x(r,e.fields);let t=e.root;for(let a=1;a<=l.length;a++){const o=l[a-1];let n=t.children.get(o);if(!n){const s=l.slice(0,a);n={key:$(e.fields,s),values:s,children:new Map,parent:t},t.children.set(o,n),a===l.length?(e.leaves++,e.expanded++):e.options.subtotals?.includes(a)&&e.expanded++}t=n}}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,a)=>L(t.values[t.values.length-1],a.values[a.values.length-1])*(r==="desc"?-1:1)),l}function y(e,r,l){const{key:t,values:a}=r;return{key:t,kind:l,depth:a.length,fields:e.fields.slice(0,a.length),values:a,labels:a.map(o=>o===null?e.hierarchy.emptyLabel??"(空)":String(o))}}function F(e,r){const l=[];function t(a){for(const o of R(a,e.options.sort?.[a.values.length]))o.children.size?(t(o),e.options.subtotals?.includes(o.values.length)&&l.push(y(e,o,"subtotal"))):l.push(y(e,o,"member"))}return t(e.root),r&&e.leaves&&l.push(y(e,e.root,"total")),l}function v(e,r,l){const t=x(r,e.fields);let a=e.root;for(const c of t){const u=a.children.get(c);if(!u)throw new Error("矩阵维度在预算检查后发生变化");a=u}const o=l?a.totalKeys:a.keys;if(o)return o;const n=[];for(let c=a;c;c=c.parent)n[c.values.length]=c.key;const s=[a.key,...(e.options.subtotals??[]).map(c=>n[c])];return l?(s.push(e.root.key),a.totalKeys=s):a.keys=s,s}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,a=Array.from({length:l},()=>Array(t+r.length).fill(null));for(let o=0;o<e.columnFields.length;o++){let n;r.forEach((s,c)=>{const u=z(s,o,e.hierarchy);if(!u){n=void 0;return}if(n?.key===u.key){n.cell.colSpan=(n.cell.colSpan??1)+1;return}const i={text:u.text,rowSpan:u.rowSpan||e.columnFields.length-o,editable:!1,derived:!0};a[o][t+c]=i,n={key:u.key,cell:i}})}return e.rowFields.forEach((o,n)=>{a[0][n]={text:e.hierarchy.row?.labels?.[n]??o,rowSpan:l,editable:!1,derived:!0}}),r.forEach((o,n)=>{const s=e.measures[o.measure];a[l-1][t+n]={text:s.label??`${s.field} (${s.op})`,editable:!1,derived:!0}}),{cells:a.map(o=>o.filter(n=>n!==null)),colWidthsMm:[...e.rowFields.map(()=>e.rowWidthMm??40),...r.map(()=>e.columnWidthMm??28)]}}function E(e,r,l,t){const a=+(!!r.totals&&e>0),o=l.expanded+a,n=(t.expanded+a)*r.measures.length+r.rowFields.length;if(o>(r.maxRows??1e3)||t.expanded+a>(r.maxColumns??200))throw new Error("矩阵层级展开数量超出预算(包含小计/总计)");if(o*n>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算");return{rowCount:o,columnCount:n,cells:o*n}}function S(e,r){if(!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const l=k(r.rowFields,r.hierarchy.row,r.hierarchy),t=k(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=E(0,r,l,t);for(const n of e){if(!n||typeof n!="object"||Array.isArray(n))throw new Error("矩阵数据行应为对象");A(l,n),A(t,n),o=E(e.length,r,l,t)}return{row:l,column:t,shape:o}}function j(e,r){return S(e,r).shape}function p(e,r,l){const t=new Map;for(const a of e){const o=v(l.row,a,!!r.totals),n=v(l.column,a,!!r.totals);for(const s of o){let c=t.get(s);c||(c=new Map,t.set(s,c));for(const u of n){let i=c.get(u);i||(i=r.measures.map(f=>m.createAggregateAccumulator({...f,field:f.valueField??f.field})),c.set(u,i)),i.forEach(f=>f.add(a))}}}return t}function K(e,r){return e.flatMap((l,t)=>r.measures.map((a,o)=>({...l,field:l.kind==="total"?`total_${o}`:`c${t}_${o}`,measure:o,measureField:a.field,valueField:a.valueField??a.field,operation:a.op})))}function H(e,r){return e.kind==="total"?r.hierarchy.totalLabel??"合计":[...e.labels,...e.kind==="subtotal"?[r.hierarchy.subtotalLabel??"小计"]:[]].join(" / ")}function I(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:`${H(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(a=>{const o={};l.rowFields.forEach((n,s)=>{o[`r${s}`]=a.kind==="total"?s===0?l.hierarchy.totalLabel??"合计":null:a.labels[s]??(s===a.depth?l.hierarchy.subtotalLabel??"小计":null)});for(const n of r)o[n.field]=t.get(a.key)?.get(n.key)?.[n.measure]?.value()??(l.measures[n.measure].op==="count"?0:null);return o})}function _(e,r){const l=S(e,r),t=F(l.row,!!r.totals),a=K(F(l.column,!!r.totals),r),o=p(e,r,l);return{columns:I(a,r),rows:T(t,a,r,o),headerGrid:O(r,a),metadata:{rowFields:[...r.rowFields],rowLabels:[...r.hierarchy.row?.labels??r.rowFields],columnFields:[...r.columnFields],columnLabels:[...r.hierarchy.column?.labels??r.columnFields],rows:t,columns:a}}}function w(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 g(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(m.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(g(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 n of e){if(!n||typeof n!="object"||Array.isArray(n))throw new Error("矩阵数据行应为对象");if(l.add(w(n,r.rowFields).key),t.add(w(n,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 a=l.size+ +(!!r.totals&&e.length>0),o=(t.size+ +!!r.totals)*r.measures.length+1;return{rowCount:a,columnCount:o,cells:a*o}}function P(e,r){if(r?.hierarchy)return g(r),_(e,r);C(e,r);const l=M(e,{row:n=>w(n,r.rowFields),column:n=>w(n,r.columnFields),measures:r.measures.map(n=>({...n,field:n.valueField??n.field})),totals:r.totals,check:()=>{}}),t=[...l.groups.values()].map(n=>({rowLabel:n.label})),a=[{field:"rowLabel",header:r.rowHeader??r.rowFields.join(" / "),semanticRole:"dimension"}],o={rowLabel:"合计"};return r.measures.forEach((n,s)=>{const c=[...l.columns.entries()].map(([u,i],f)=>({key:u,label:i,field:`c${f}_${s}`}));r.totals&&c.push({key:"",label:"合计",field:`total_${s}`});for(const u of c){const i=u.field===`total_${s}`;a.push({field:u.field,header:`${u.label} · ${n.label??`${n.field} (${n.op})`}`,semanticRole:"measure",...n.digits===void 0?{}:{format:{kind:"number",digits:n.digits}}});let f=0;for(const d of l.groups.values())t[f++][u.field]=(i?d.totals?.[s]:d.cells.get(u.key)?.[s])?.value()??(n.op==="count"?0:null);o[u.field]=(i?l.totals?.[s]:l.columnTotals.get(u.key)?.[s])?.value()??(n.op==="count"?0:null)}}),r.totals&&e.length&&t.push(o),{rows:t,columns:a}}exports.accumulatePivotRows=M;exports.createMatrixTable=P;exports.estimateMatrixTable=C;exports.validateMatrixOptions=g;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as m } from "./computed-f3pOqWLX.js";
|
|
2
2
|
function x(e, r) {
|
|
3
|
-
const l = () => r.measures.map((
|
|
4
|
-
for (const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
let f = t.get(
|
|
8
|
-
f || (f = { label:
|
|
9
|
-
let d = f.cells.get(
|
|
10
|
-
if (d || (d = l(), f.cells.set(
|
|
11
|
-
let
|
|
12
|
-
|
|
3
|
+
const l = () => r.measures.map((c) => m(c)), t = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), n = r.totals ? l() : void 0, s = (c, u) => c?.forEach((i) => i.add(u));
|
|
4
|
+
for (const c of e) {
|
|
5
|
+
const u = r.row(c), i = r.column(c);
|
|
6
|
+
a.has(i.key) || a.set(i.key, i.label);
|
|
7
|
+
let f = t.get(u.key);
|
|
8
|
+
f || (f = { label: u.label, cells: /* @__PURE__ */ new Map(), ...r.totals ? { totals: l() } : {} }, t.set(u.key, f)), r.check(t.size, a.size);
|
|
9
|
+
let d = f.cells.get(i.key);
|
|
10
|
+
if (d || (d = l(), f.cells.set(i.key, d)), s(d, c), !r.totals) continue;
|
|
11
|
+
let h = o.get(i.key);
|
|
12
|
+
h || (h = l(), o.set(i.key, h)), s(f.totals, c), s(h, c), s(n, c);
|
|
13
13
|
}
|
|
14
|
-
return { groups: t, columns:
|
|
14
|
+
return { groups: t, columns: a, columnTotals: o, totals: n };
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function E(e, r) {
|
|
17
17
|
return JSON.stringify([e.slice(0, r.length), r.map((l) => [l === null ? "null" : typeof l, l])]);
|
|
18
18
|
}
|
|
19
19
|
function M(e, r) {
|
|
@@ -27,9 +27,9 @@ function M(e, r) {
|
|
|
27
27
|
function C(e, r, l) {
|
|
28
28
|
if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("矩阵层级应为对象");
|
|
29
29
|
for (const t of [e.emptyLabel, e.subtotalLabel, e.totalLabel]) if (t !== void 0 && typeof t != "string") throw new Error("矩阵层级标签应为字符串");
|
|
30
|
-
|
|
30
|
+
g(e.row, r.length), g(e.column, l.length);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function g(e, r) {
|
|
33
33
|
if (e !== void 0) {
|
|
34
34
|
if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("矩阵轴配置应为对象");
|
|
35
35
|
if (e.labels !== void 0 && (!Array.isArray(e.labels) || e.labels.length !== r || e.labels.some((l) => typeof l != "string"))) throw new Error("矩阵维度标签必须与维度字段一一对应");
|
|
@@ -37,16 +37,20 @@ function b(e, r) {
|
|
|
37
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
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
return { fields: e, options: r ?? {}, hierarchy: l, root: { values: [], children: /* @__PURE__ */ new Map() }, leaves: 0, expanded: 0 };
|
|
40
|
+
function b(e, r, l) {
|
|
41
|
+
return { fields: e, options: r ?? {}, hierarchy: l, root: { key: E(e, []), values: [], children: /* @__PURE__ */ new Map() }, leaves: 0, expanded: 0 };
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function k(e, r) {
|
|
44
44
|
const l = M(r, e.fields);
|
|
45
45
|
let t = e.root;
|
|
46
|
-
for (let
|
|
47
|
-
const o = l
|
|
48
|
-
let
|
|
49
|
-
|
|
46
|
+
for (let a = 1; a <= l.length; a++) {
|
|
47
|
+
const o = l[a - 1];
|
|
48
|
+
let n = t.children.get(o);
|
|
49
|
+
if (!n) {
|
|
50
|
+
const s = l.slice(0, a);
|
|
51
|
+
n = { key: E(e.fields, s), values: s, children: /* @__PURE__ */ new Map(), parent: t }, t.children.set(o, n), a === l.length ? (e.leaves++, e.expanded++) : e.options.subtotals?.includes(a) && e.expanded++;
|
|
52
|
+
}
|
|
53
|
+
t = n;
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
function N(e, r) {
|
|
@@ -59,76 +63,88 @@ function N(e, r) {
|
|
|
59
63
|
}
|
|
60
64
|
function L(e, r) {
|
|
61
65
|
const l = [...e.children.values()];
|
|
62
|
-
return r && r !== "source" && l.sort((t,
|
|
66
|
+
return r && r !== "source" && l.sort((t, a) => N(t.values[t.values.length - 1], a.values[a.values.length - 1]) * (r === "desc" ? -1 : 1)), l;
|
|
63
67
|
}
|
|
64
68
|
function y(e, r, l) {
|
|
69
|
+
const { key: t, values: a } = r;
|
|
65
70
|
return {
|
|
66
|
-
key:
|
|
71
|
+
key: t,
|
|
67
72
|
kind: l,
|
|
68
|
-
depth:
|
|
69
|
-
fields: e.fields.slice(0,
|
|
70
|
-
values:
|
|
71
|
-
labels:
|
|
73
|
+
depth: a.length,
|
|
74
|
+
fields: e.fields.slice(0, a.length),
|
|
75
|
+
values: a,
|
|
76
|
+
labels: a.map((o) => o === null ? e.hierarchy.emptyLabel ?? "(空)" : String(o))
|
|
72
77
|
};
|
|
73
78
|
}
|
|
74
|
-
function
|
|
79
|
+
function F(e, r) {
|
|
75
80
|
const l = [];
|
|
76
|
-
function t(
|
|
77
|
-
for (const o of L(
|
|
78
|
-
o.children.size ? (t(o), e.options.subtotals?.includes(o.values.length) && l.push(y(e, o
|
|
81
|
+
function t(a) {
|
|
82
|
+
for (const o of L(a, e.options.sort?.[a.values.length]))
|
|
83
|
+
o.children.size ? (t(o), e.options.subtotals?.includes(o.values.length) && l.push(y(e, o, "subtotal"))) : l.push(y(e, o, "member"));
|
|
79
84
|
}
|
|
80
|
-
return t(e.root), r && e.leaves && l.push(y(e,
|
|
85
|
+
return t(e.root), r && e.leaves && l.push(y(e, e.root, "total")), l;
|
|
81
86
|
}
|
|
82
|
-
function
|
|
83
|
-
const t = M(r, e.fields)
|
|
84
|
-
|
|
87
|
+
function A(e, r, l) {
|
|
88
|
+
const t = M(r, e.fields);
|
|
89
|
+
let a = e.root;
|
|
90
|
+
for (const c of t) {
|
|
91
|
+
const u = a.children.get(c);
|
|
92
|
+
if (!u) throw new Error("矩阵维度在预算检查后发生变化");
|
|
93
|
+
a = u;
|
|
94
|
+
}
|
|
95
|
+
const o = l ? a.totalKeys : a.keys;
|
|
96
|
+
if (o) return o;
|
|
97
|
+
const n = [];
|
|
98
|
+
for (let c = a; c; c = c.parent) n[c.values.length] = c.key;
|
|
99
|
+
const s = [a.key, ...(e.options.subtotals ?? []).map((c) => n[c])];
|
|
100
|
+
return l ? (s.push(e.root.key), a.totalKeys = s) : a.keys = s, s;
|
|
85
101
|
}
|
|
86
102
|
function R(e, r, l) {
|
|
87
103
|
if (!(e.kind !== "member" && r > e.depth))
|
|
88
104
|
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
105
|
}
|
|
90
106
|
function z(e, r) {
|
|
91
|
-
const l = e.columnFields.length + 1, t = e.rowFields.length,
|
|
107
|
+
const l = e.columnFields.length + 1, t = e.rowFields.length, a = Array.from({ length: l }, () => Array(t + r.length).fill(null));
|
|
92
108
|
for (let o = 0; o < e.columnFields.length; o++) {
|
|
93
|
-
let
|
|
94
|
-
r.forEach((s,
|
|
95
|
-
const
|
|
96
|
-
if (!
|
|
97
|
-
|
|
109
|
+
let n;
|
|
110
|
+
r.forEach((s, c) => {
|
|
111
|
+
const u = R(s, o, e.hierarchy);
|
|
112
|
+
if (!u) {
|
|
113
|
+
n = void 0;
|
|
98
114
|
return;
|
|
99
115
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
116
|
+
if (n?.key === u.key) {
|
|
117
|
+
n.cell.colSpan = (n.cell.colSpan ?? 1) + 1;
|
|
102
118
|
return;
|
|
103
119
|
}
|
|
104
|
-
const
|
|
105
|
-
|
|
120
|
+
const i = { text: u.text, rowSpan: u.rowSpan || e.columnFields.length - o, editable: !1, derived: !0 };
|
|
121
|
+
a[o][t + c] = i, n = { key: u.key, cell: i };
|
|
106
122
|
});
|
|
107
123
|
}
|
|
108
|
-
return e.rowFields.forEach((o,
|
|
109
|
-
|
|
110
|
-
}), r.forEach((o,
|
|
124
|
+
return e.rowFields.forEach((o, n) => {
|
|
125
|
+
a[0][n] = { text: e.hierarchy.row?.labels?.[n] ?? o, rowSpan: l, editable: !1, derived: !0 };
|
|
126
|
+
}), r.forEach((o, n) => {
|
|
111
127
|
const s = e.measures[o.measure];
|
|
112
|
-
|
|
128
|
+
a[l - 1][t + n] = { text: s.label ?? `${s.field} (${s.op})`, editable: !1, derived: !0 };
|
|
113
129
|
}), {
|
|
114
|
-
cells:
|
|
130
|
+
cells: a.map((o) => o.filter((n) => n !== null)),
|
|
115
131
|
colWidthsMm: [...e.rowFields.map(() => e.rowWidthMm ?? 40), ...r.map(() => e.columnWidthMm ?? 28)]
|
|
116
132
|
};
|
|
117
133
|
}
|
|
118
134
|
function v(e, r, l, t) {
|
|
119
|
-
const
|
|
120
|
-
if (o > (r.maxRows ?? 1e3) || t.expanded +
|
|
121
|
-
if (o *
|
|
122
|
-
return { rowCount: o, columnCount:
|
|
135
|
+
const a = +(!!r.totals && e > 0), o = l.expanded + a, n = (t.expanded + a) * r.measures.length + r.rowFields.length;
|
|
136
|
+
if (o > (r.maxRows ?? 1e3) || t.expanded + a > (r.maxColumns ?? 200)) throw new Error("矩阵层级展开数量超出预算(包含小计/总计)");
|
|
137
|
+
if (o * n > (r.maxCells ?? 2e6)) throw new Error("矩阵输出超出 maxCells 预算");
|
|
138
|
+
return { rowCount: o, columnCount: n, cells: o * n };
|
|
123
139
|
}
|
|
124
140
|
function $(e, r) {
|
|
125
141
|
if (!Array.isArray(e) || e.length > (r.maxInputRows ?? 1e5)) throw new Error("矩阵输入超出预算");
|
|
126
|
-
const l =
|
|
142
|
+
const l = b(r.rowFields, r.hierarchy.row, r.hierarchy), t = b(r.columnFields, r.hierarchy.column, r.hierarchy);
|
|
127
143
|
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
144
|
let o = v(0, r, l, t);
|
|
129
|
-
for (const
|
|
130
|
-
if (!
|
|
131
|
-
|
|
145
|
+
for (const n of e) {
|
|
146
|
+
if (!n || typeof n != "object" || Array.isArray(n)) throw new Error("矩阵数据行应为对象");
|
|
147
|
+
k(l, n), k(t, n), o = v(e.length, r, l, t);
|
|
132
148
|
}
|
|
133
149
|
return { row: l, column: t, shape: o };
|
|
134
150
|
}
|
|
@@ -137,68 +153,68 @@ function j(e, r) {
|
|
|
137
153
|
}
|
|
138
154
|
function O(e, r, l) {
|
|
139
155
|
const t = /* @__PURE__ */ new Map();
|
|
140
|
-
for (const
|
|
141
|
-
const o =
|
|
156
|
+
for (const a of e) {
|
|
157
|
+
const o = A(l.row, a, !!r.totals), n = A(l.column, a, !!r.totals);
|
|
142
158
|
for (const s of o) {
|
|
143
|
-
let
|
|
144
|
-
|
|
145
|
-
for (const
|
|
146
|
-
let
|
|
147
|
-
|
|
159
|
+
let c = t.get(s);
|
|
160
|
+
c || (c = /* @__PURE__ */ new Map(), t.set(s, c));
|
|
161
|
+
for (const u of n) {
|
|
162
|
+
let i = c.get(u);
|
|
163
|
+
i || (i = r.measures.map((f) => m({ ...f, field: f.valueField ?? f.field })), c.set(u, i)), i.forEach((f) => f.add(a));
|
|
148
164
|
}
|
|
149
165
|
}
|
|
150
166
|
}
|
|
151
167
|
return t;
|
|
152
168
|
}
|
|
153
169
|
function p(e, r) {
|
|
154
|
-
return e.flatMap((l, t) => r.measures.map((
|
|
170
|
+
return e.flatMap((l, t) => r.measures.map((a, o) => ({
|
|
155
171
|
...l,
|
|
156
172
|
field: l.kind === "total" ? `total_${o}` : `c${t}_${o}`,
|
|
157
173
|
measure: o,
|
|
158
|
-
measureField:
|
|
159
|
-
valueField:
|
|
160
|
-
operation:
|
|
174
|
+
measureField: a.field,
|
|
175
|
+
valueField: a.valueField ?? a.field,
|
|
176
|
+
operation: a.op
|
|
161
177
|
})));
|
|
162
178
|
}
|
|
163
|
-
function
|
|
179
|
+
function K(e, r) {
|
|
164
180
|
return e.kind === "total" ? r.hierarchy.totalLabel ?? "合计" : [...e.labels, ...e.kind === "subtotal" ? [r.hierarchy.subtotalLabel ?? "小计"] : []].join(" / ");
|
|
165
181
|
}
|
|
166
|
-
function
|
|
182
|
+
function H(e, r) {
|
|
167
183
|
return [
|
|
168
184
|
...r.rowFields.map((l, t) => ({ field: `r${t}`, header: r.hierarchy.row?.labels?.[t] ?? l, semanticRole: "dimension" })),
|
|
169
185
|
...e.map((l) => {
|
|
170
186
|
const t = r.measures[l.measure];
|
|
171
187
|
return {
|
|
172
188
|
field: l.field,
|
|
173
|
-
header: `${
|
|
189
|
+
header: `${K(l, r)} · ${t.label ?? `${t.field} (${t.op})`}`,
|
|
174
190
|
semanticRole: "measure",
|
|
175
191
|
...t.digits === void 0 ? {} : { format: { kind: "number", digits: t.digits } }
|
|
176
192
|
};
|
|
177
193
|
})
|
|
178
194
|
];
|
|
179
195
|
}
|
|
180
|
-
function
|
|
181
|
-
return e.map((
|
|
196
|
+
function I(e, r, l, t) {
|
|
197
|
+
return e.map((a) => {
|
|
182
198
|
const o = {};
|
|
183
|
-
l.rowFields.forEach((
|
|
184
|
-
o[`r${s}`] =
|
|
199
|
+
l.rowFields.forEach((n, s) => {
|
|
200
|
+
o[`r${s}`] = a.kind === "total" ? s === 0 ? l.hierarchy.totalLabel ?? "合计" : null : a.labels[s] ?? (s === a.depth ? l.hierarchy.subtotalLabel ?? "小计" : null);
|
|
185
201
|
});
|
|
186
|
-
for (const
|
|
202
|
+
for (const n of r) o[n.field] = t.get(a.key)?.get(n.key)?.[n.measure]?.value() ?? (l.measures[n.measure].op === "count" ? 0 : null);
|
|
187
203
|
return o;
|
|
188
204
|
});
|
|
189
205
|
}
|
|
190
206
|
function _(e, r) {
|
|
191
|
-
const l = $(e, r), t =
|
|
192
|
-
return { columns:
|
|
207
|
+
const l = $(e, r), t = F(l.row, !!r.totals), a = p(F(l.column, !!r.totals), r), o = O(e, r, l);
|
|
208
|
+
return { columns: H(a, r), rows: I(t, a, r, o), headerGrid: z(r, a), metadata: {
|
|
193
209
|
rowFields: [...r.rowFields],
|
|
194
210
|
rowLabels: [...r.hierarchy.row?.labels ?? r.rowFields],
|
|
195
211
|
columnFields: [...r.columnFields],
|
|
196
212
|
columnLabels: [...r.hierarchy.column?.labels ?? r.columnFields],
|
|
197
213
|
rows: t,
|
|
198
|
-
columns:
|
|
214
|
+
columns: a
|
|
199
215
|
} };
|
|
200
216
|
}
|
|
201
|
-
function
|
|
217
|
+
function w(e, r) {
|
|
202
218
|
const l = r.map(
|
|
203
219
|
(t) => Object.prototype.hasOwnProperty.call(e, t) ? e[t] : null
|
|
204
220
|
);
|
|
@@ -237,7 +253,7 @@ function S(e) {
|
|
|
237
253
|
throw new Error("矩阵需要 1–32 个度量");
|
|
238
254
|
if (e.measures.map((l) => {
|
|
239
255
|
if (!l || typeof l != "object") throw new Error("矩阵度量应为对象");
|
|
240
|
-
if (
|
|
256
|
+
if (m({
|
|
241
257
|
...l,
|
|
242
258
|
field: l.valueField ?? l.field
|
|
243
259
|
}), l.label !== void 0 && typeof l.label != "string")
|
|
@@ -252,47 +268,47 @@ function W(e, r) {
|
|
|
252
268
|
if (!Array.isArray(e) || e.length > (r.maxInputRows ?? 1e5))
|
|
253
269
|
throw new Error("矩阵输入超出预算");
|
|
254
270
|
const l = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
|
|
255
|
-
for (const
|
|
256
|
-
if (!
|
|
271
|
+
for (const n of e) {
|
|
272
|
+
if (!n || typeof n != "object" || Array.isArray(n))
|
|
257
273
|
throw new Error("矩阵数据行应为对象");
|
|
258
|
-
if (l.add(
|
|
274
|
+
if (l.add(w(n, r.rowFields).key), t.add(w(n, r.columnFields).key), l.size > (r.maxRows ?? 1e3) || t.size > (r.maxColumns ?? 200))
|
|
259
275
|
throw new Error("矩阵维度数量超出预算");
|
|
260
276
|
if ((l.size + +!!r.totals) * ((t.size + +!!r.totals) * r.measures.length + 1) > (r.maxCells ?? 2e6))
|
|
261
277
|
throw new Error("矩阵输出超出 maxCells 预算");
|
|
262
278
|
}
|
|
263
|
-
const
|
|
264
|
-
return { rowCount:
|
|
279
|
+
const a = l.size + +(!!r.totals && e.length > 0), o = (t.size + +!!r.totals) * r.measures.length + 1;
|
|
280
|
+
return { rowCount: a, columnCount: o, cells: a * o };
|
|
265
281
|
}
|
|
266
282
|
function T(e, r) {
|
|
267
283
|
if (r?.hierarchy)
|
|
268
284
|
return S(r), _(e, r);
|
|
269
285
|
W(e, r);
|
|
270
286
|
const l = x(e, {
|
|
271
|
-
row: (
|
|
272
|
-
column: (
|
|
273
|
-
measures: r.measures.map((
|
|
287
|
+
row: (n) => w(n, r.rowFields),
|
|
288
|
+
column: (n) => w(n, r.columnFields),
|
|
289
|
+
measures: r.measures.map((n) => ({ ...n, field: n.valueField ?? n.field })),
|
|
274
290
|
totals: r.totals,
|
|
275
291
|
check: () => {
|
|
276
292
|
}
|
|
277
293
|
// Cardinality/budgets were checked before allocating accumulators.
|
|
278
|
-
}), t = [...l.groups.values()].map((
|
|
279
|
-
return r.measures.forEach((
|
|
280
|
-
const
|
|
281
|
-
r.totals &&
|
|
282
|
-
for (const
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
field:
|
|
286
|
-
header: `${
|
|
294
|
+
}), t = [...l.groups.values()].map((n) => ({ rowLabel: n.label })), a = [{ field: "rowLabel", header: r.rowHeader ?? r.rowFields.join(" / "), semanticRole: "dimension" }], o = { rowLabel: "合计" };
|
|
295
|
+
return r.measures.forEach((n, s) => {
|
|
296
|
+
const c = [...l.columns.entries()].map(([u, i], f) => ({ key: u, label: i, field: `c${f}_${s}` }));
|
|
297
|
+
r.totals && c.push({ key: "", label: "合计", field: `total_${s}` });
|
|
298
|
+
for (const u of c) {
|
|
299
|
+
const i = u.field === `total_${s}`;
|
|
300
|
+
a.push({
|
|
301
|
+
field: u.field,
|
|
302
|
+
header: `${u.label} · ${n.label ?? `${n.field} (${n.op})`}`,
|
|
287
303
|
semanticRole: "measure",
|
|
288
|
-
...
|
|
304
|
+
...n.digits === void 0 ? {} : { format: { kind: "number", digits: n.digits } }
|
|
289
305
|
});
|
|
290
306
|
let f = 0;
|
|
291
307
|
for (const d of l.groups.values())
|
|
292
|
-
t[f++][
|
|
293
|
-
o[
|
|
308
|
+
t[f++][u.field] = (i ? d.totals?.[s] : d.cells.get(u.key)?.[s])?.value() ?? (n.op === "count" ? 0 : null);
|
|
309
|
+
o[u.field] = (i ? l.totals?.[s] : l.columnTotals.get(u.key)?.[s])?.value() ?? (n.op === "count" ? 0 : null);
|
|
294
310
|
}
|
|
295
|
-
}), r.totals && e.length && t.push(o), { rows: t, columns:
|
|
311
|
+
}), r.totals && e.length && t.push(o), { rows: t, columns: a };
|
|
296
312
|
}
|
|
297
313
|
export {
|
|
298
314
|
x as a,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var R=Object.create;var f=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var m=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of P(e))!p.call(r,o)&&o!==t&&f(r,o,{get:()=>e[o],enumerable:!(n=u(e,o))||n.enumerable});return r};var E=(r,e,t)=>(t=r!=null?R(d(r)):{},m(e||!r||!r.__esModule?f(t,"default",{value:r,enumerable:!0}):t,r));const l=require("vue"),i=require("./injection-keys-Db_DyLkm.cjs"),h=require("./report-params-VTg8MoCp.cjs"),s=l.defineAsyncComponent(()=>Promise.resolve().then(()=>require("./ReportPreview-
|
|
1
|
+
"use strict";var R=Object.create;var f=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var m=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of P(e))!p.call(r,o)&&o!==t&&f(r,o,{get:()=>e[o],enumerable:!(n=u(e,o))||n.enumerable});return r};var E=(r,e,t)=>(t=r!=null?R(d(r)):{},m(e||!r||!r.__esModule?f(t,"default",{value:r,enumerable:!0}):t,r));const l=require("vue"),i=require("./injection-keys-Db_DyLkm.cjs"),h=require("./report-params-VTg8MoCp.cjs"),s=l.defineAsyncComponent(()=>Promise.resolve().then(()=>require("./ReportPreview-DAU-V3Ov.cjs")).then(r=>r.ReportPreview$1)),v={install(r,e={}){let t=e.fetcher;if(!t&&e.reports){const n=e.reports;let o;t=async c=>(o??=import("@agile-team/mach-report").then(({createReportSource:a})=>a(n)),(await o)(c)),t.getParamDefs=c=>h.getReportParamDefs(n,c)}t&&r.provide(i.MACH_REPORT_FETCHER_KEY,t),e.pdfExporter&&r.provide(i.MACH_REPORT_PDF_EXPORTER_KEY,e.pdfExporter),r.provide(i.MACH_REPORT_CONFIG_KEY,l.computed(()=>{if(e.pdfFontUrl===void 0)return e.config??null;const n=e.config??{defaults:{},presets:{}};return{...n,defaults:{...n.defaults,pdfFontUrl:e.pdfFontUrl}}})),e.globalComponent!==!1&&!r.component("MachReportPreview")&&r.component("MachReportPreview",s)}};exports.MachReportPreview=s;exports.machReportPlugin=v;
|