@agile-team/mach-report 2.26.1 → 2.26.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 +14 -5
- package/dist/ExcelBindingWizard-CnjjpYxD.cjs +1 -0
- package/dist/{ExcelBindingWizard-Bzndrp_z.js → ExcelBindingWizard-DAprCgn-.js} +4 -4
- package/dist/{ParamEditor-BrUrInJH.js → ParamEditor-CY9d8QZD.js} +3 -3
- package/dist/ParamEditor-CiVjpbc-.cjs +1 -0
- package/dist/ReportBatchPanel-0-Oymcdm.cjs +1 -0
- package/dist/{ReportBatchPanel-2mXS1uol.js → ReportBatchPanel-CDp7xRHp.js} +4 -4
- package/dist/ReportLabelStudio-CsyHqBco.cjs +1 -0
- package/dist/{ReportLabelStudio-BUKNmYUY.js → ReportLabelStudio-DtKxk9n0.js} +4 -4
- package/dist/ReportParamPanel-CoKcXzSy.cjs +1 -0
- package/dist/{ReportParamPanel-Czm3OPo_.js → ReportParamPanel-jKDJVar2.js} +2 -2
- package/dist/{ReportPreview-C9c0Rp7Y.js → ReportPreview-DJqt40zA.js} +2863 -2836
- package/dist/ReportPreview-s7c2nrfo.cjs +6 -0
- package/dist/ReportTemplateLibrary-CsUm6edm.cjs +1 -0
- package/dist/{ReportTemplateLibrary-ovj03u0F.js → ReportTemplateLibrary-qPQX0Dt_.js} +2 -2
- package/dist/RuleEditor-CJBibiLY.cjs +1 -0
- package/dist/{RuleEditor-4JTKq_N7.js → RuleEditor-Di-JZ2Lb.js} +6 -6
- package/dist/{TemplateOutlinePanel-DfFRc91I.js → TemplateOutlinePanel-D0mKfVWf.js} +3 -3
- package/dist/TemplateOutlinePanel-RiRgXnnH.cjs +1 -0
- package/dist/TemplateReusePanel-BdK91T7z.cjs +1 -0
- package/dist/{TemplateReusePanel-CmX1rq69.js → TemplateReusePanel-J6PvD2Sf.js} +3 -3
- package/dist/TemplateReviewPanel-B5yUgOgb.cjs +1 -0
- package/dist/{TemplateReviewPanel-BKMo7Qd7.js → TemplateReviewPanel-BlUbD2GY.js} +3 -3
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.js +5 -5
- package/dist/artifact-integrity.json +112 -114
- package/dist/assets-CylgPA6P.cjs +1 -0
- package/dist/assets-Vt10jCtl.js +136 -0
- package/dist/auto-D3UNXBrM.cjs +1 -0
- package/dist/{auto-C7udkeAa.js → auto-Hq-xgrvS.js} +28 -25
- package/dist/{batch-DGCt44XM.js → batch-Be_NbW7U.js} +1 -1
- package/dist/{batch-DYcokH4v.cjs → batch-CI4ZpuoX.cjs} +1 -1
- package/dist/{charts-D-Vg-ak9.cjs → charts-Cy7muNWi.cjs} +1 -1
- package/dist/{charts-D48XCefN.js → charts-DLTz0OEG.js} +1 -1
- package/dist/{computed-BQgBrma-.cjs → computed-8nFyVnok.cjs} +1 -1
- package/dist/{computed-CH3NYPOW.js → computed-BR_O8uAv.js} +14 -20
- package/dist/{data-bar-DzceAVeR.cjs → data-bar--_aPWr-W.cjs} +1 -1
- package/dist/{data-bar-DjOgTLqu.js → data-bar-BVnzVbE9.js} +1 -1
- package/dist/designer-Bc5AXS38.cjs +2 -0
- package/dist/designer-CZqnLTyE.js +8350 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +108 -1
- package/dist/designer.d.ts +108 -1
- package/dist/designer.js +1 -1
- package/dist/{diagnostic-collector-C-JBA016.js → diagnostic-collector-CZ8DV6wA.js} +208 -186
- package/dist/diagnostic-collector-DwMJWEHo.cjs +1 -0
- package/dist/{dom-DgWc-DY1.js → dom-CbOWY7KE.js} +5 -5
- package/dist/dom-VuLh_fhL.cjs +1 -0
- package/dist/{encoding-tWc2Wn89.cjs → encoding-D0ITsCCp.cjs} +1 -1
- package/dist/{encoding-D480EM2r.js → encoding-TbA3oQLr.js} +2 -2
- package/dist/{execution-result-Ba65gieT.js → execution-result-BUPPNlaS.js} +3 -3
- package/dist/{execution-result-7sG_mdcD.cjs → execution-result-BgZtqlOT.cjs} +1 -1
- package/dist/{font-loader-CHmEwkHl.js → font-loader-BSRR-a0C.js} +1 -1
- package/dist/{font-loader-BIxme_9g.cjs → font-loader-BZ4CRPys.cjs} +1 -1
- package/dist/{grid-strokes-DsoICRjZ.js → grid-strokes-CovSH3A2.js} +1 -1
- package/dist/{grid-strokes-RFMR91jn.cjs → grid-strokes-G5omPT3s.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +23 -23
- package/dist/{json-snapshot-BZ0CIQln.js → json-snapshot-DRQmh_k5.js} +718 -683
- package/dist/json-snapshot-HR8bez8j.cjs +2 -0
- package/dist/{matrix-CB9TqTEy.js → matrix-6wjFVN0Z.js} +149 -142
- package/dist/matrix-DeA6__cd.cjs +1 -0
- package/dist/media-IV_r4Sp7.cjs +1 -0
- package/dist/media-jiLdCn3i.js +208 -0
- package/dist/{pdf-DTR7fAIr.js → pdf-BqnoP1L_.js} +14 -15
- package/dist/{pdf-d9oJ6V0P.cjs → pdf-Ddm0HCuT.cjs} +48 -48
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-B7Bi-1te.cjs → plugin-BFBLxfsq.cjs} +1 -1
- package/dist/{plugin-OKDFQFS4.js → plugin-BnRcXQzg.js} +1 -1
- package/dist/{prefill-C8fF91JB.js → prefill-BqbuktRt.js} +3 -3
- package/dist/{prefill-C_Bf_AMo.cjs → prefill-DPLV68I7.cjs} +1 -1
- package/dist/prepared-Cl7C69N7.cjs +1 -0
- package/dist/{prepared-DhgQ0d-h.js → prepared-V7tYf1qj.js} +68 -64
- package/dist/{protocol-CZ-BILne.cjs → protocol-BVhKnBmX.cjs} +1 -1
- package/dist/{protocol-DHO91-Jt.js → protocol-Bf33Gu9J.js} +3 -3
- package/dist/{record-bindings-KEs-DKCS.cjs → record-bindings-DVs_g_No.cjs} +1 -1
- package/dist/{record-bindings-DBrCu6zO.js → record-bindings-hxJqcLSK.js} +3 -3
- package/dist/{region-binding-workflow-ikpY1Kbw.cjs → region-binding-workflow-Bu31bqCr.cjs} +1 -1
- package/dist/{region-binding-workflow-FSyIZge8.js → region-binding-workflow-DRvX25XH.js} +2 -2
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/{rich-text-layout-BYbIc3eJ.cjs → rich-text-layout-6VphrIcj.cjs} +1 -1
- package/dist/{rich-text-layout-BtygMWZC.js → rich-text-layout-BCdxMT4m.js} +1 -1
- package/dist/{runtime-BsvAqz4a.js → runtime-ChdUbPvs.js} +9 -9
- package/dist/{runtime-B5HG8poy.cjs → runtime-D2noLfgC.cjs} +1 -1
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +5 -5
- package/dist/server-node.js +2099 -1959
- package/dist/server.cjs +1 -1
- package/dist/server.js +17 -13
- package/dist/sha256-C26wdjDi.cjs +1 -0
- package/dist/sha256-D-msitGX.js +166 -0
- package/dist/style.css +1 -1
- package/dist/{template-catalog-BbrN9dgu.js → template-catalog-CZfnMXKc.js} +4 -4
- package/dist/template-catalog-Dv4sOYaB.cjs +1 -0
- package/dist/{template-fragments-CUTE8-_I.js → template-fragments-BO6i19kt.js} +3 -3
- package/dist/{template-fragments-cyAQu7aw.cjs → template-fragments-CTfJeHoM.cjs} +1 -1
- package/dist/{template-registry-PSuLsnyq.js → template-registry-CIaC6qBW.js} +168 -171
- package/dist/template-registry-CKo-bogM.cjs +1 -0
- package/dist/template-serialization-Cb1ospyK.js +367 -0
- package/dist/template-serialization-D4Fofl9c.cjs +1 -0
- package/dist/{textwrap-LhJkHWb1.cjs → textwrap-BYSqmGGV.cjs} +1 -1
- package/dist/{textwrap-Bt_tnI6V.js → textwrap-CGjFy7gf.js} +1 -1
- package/dist/usePopoverBounds-C3hn7F1s.js +84 -0
- package/dist/usePopoverBounds-mJhJ-VqG.cjs +1 -0
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +13 -10
- package/dist/{workbook-session-BJfZVp4q.cjs → workbook-session-DL3uBAl8.cjs} +1 -1
- package/dist/{workbook-session-DRnMjIFK.js → workbook-session-nkvroJUE.js} +2 -2
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.js +28 -29
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-D1LZxm93.cjs +0 -1
- package/dist/ParamEditor-BTIx9UDt.cjs +0 -1
- package/dist/ReportBatchPanel-CU2BbpBg.cjs +0 -1
- package/dist/ReportLabelStudio-BXKE0GVs.cjs +0 -1
- package/dist/ReportParamPanel-Chxu4MTx.cjs +0 -1
- package/dist/ReportPreview-CIMR4ERo.cjs +0 -6
- package/dist/ReportTemplateLibrary-tv1sNa78.cjs +0 -1
- package/dist/RuleEditor-CvyjPyR6.cjs +0 -1
- package/dist/TemplateOutlinePanel-hb8cKkKR.cjs +0 -1
- package/dist/TemplateReusePanel-CR5jF00y.cjs +0 -1
- package/dist/TemplateReviewPanel-BU35FHwG.cjs +0 -1
- package/dist/_plugin-vue_export-helper-8SL1F89S.js +0 -53
- package/dist/_plugin-vue_export-helper-BLmdZLlg.cjs +0 -1
- package/dist/assets-BFTP-0WR.js +0 -137
- package/dist/assets-CZiZhTf2.cjs +0 -1
- package/dist/auto-CXd2E2aZ.cjs +0 -1
- package/dist/capabilities-D8UU2clQ.cjs +0 -1
- package/dist/capabilities-g0a2j9Yy.js +0 -125
- package/dist/designer-CEMTZomv.cjs +0 -2
- package/dist/designer-_IKm_n5N.js +0 -8002
- package/dist/diagnostic-collector-wASg6Fzs.cjs +0 -1
- package/dist/dom-Fk4NF-gN.cjs +0 -1
- package/dist/json-snapshot-DGFeI30h.cjs +0 -2
- package/dist/matrix-CcqYOuq_.cjs +0 -1
- package/dist/media-B7vnpD8k.cjs +0 -1
- package/dist/media-Y90dHK9z.js +0 -70
- package/dist/prepared-BLhV7vdE.cjs +0 -1
- package/dist/sha256-BDQ1Qk7A.js +0 -158
- package/dist/sha256-DgZAKXqI.cjs +0 -1
- package/dist/template-catalog-DDH-5J57.cjs +0 -1
- package/dist/template-registry-D24Z8aQf.cjs +0 -1
- package/dist/template-serialization-BOUidUlh.cjs +0 -1
- package/dist/template-serialization-BgGWYV_1.js +0 -307
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const P=require("./computed-8nFyVnok.cjs"),oe=require("./matrix-DeA6__cd.cjs"),k=require("./diagnostic-collector-DwMJWEHo.cjs"),fe=require("./code-options-BUTChiZZ.cjs"),W=require("./param-validation-C-8sRJLq.cjs"),w=require("./template-serialization-D4Fofl9c.cjs");function re(e,i,t){e!==void 0&&(typeof e!="string"||!e.trim()||e.length>4096)&&t.push({path:i,message:"来源范围应为不超过 4096 字符的非空字符串"})}function G(e,i,t){e.editable!==void 0&&typeof e.editable!="boolean"&&t.push({path:`${i}.editable`,message:"编辑控制应为布尔值"}),e.valueType!==void 0&&!["text","number","boolean"].includes(e.valueType)&&t.push({path:`${i}.valueType`,message:"编辑类型应为 text、number 或 boolean"})}function de(e,i,t){G(e,i,t),e.indentMm!==void 0&&(typeof e.indentMm!="number"||!Number.isFinite(e.indentMm)||e.indentMm<0)&&t.push({path:`${i}.indentMm`,message:"单元格缩进应为有限非负数"}),e.derived!==void 0&&typeof e.derived!="boolean"&&t.push({path:`${i}.derived`,message:"派生结果标记应为布尔值"}),U(e.source,`${i}.source`,t,!0),e.formula!==void 0&&typeof e.formula!="string"&&t.push({path:`${i}.formula`,message:"单元格公式应为字符串"})}function U(e,i,t,s=!1){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)){t.push({path:i,message:"业务来源应为对象"});return}const n=e;re(n.sourceScope,`${i}.sourceScope`,t);for(const a of["datasetId",...s?["field"]:[]])(typeof n[a]!="string"||!n[a].trim())&&t.push({path:`${i}.${a}`,message:"业务标识应为非空字符串"});for(const a of["rowKey","revision"]){const o=n[a];o===void 0&&!(s&&a==="rowKey")||typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o))&&t.push({path:`${i}.${a}`,message:"业务键及修订号应为字符串或有限数字"})}n.sourceToken!==void 0&&typeof n.sourceToken!="string"&&t.push({path:`${i}.sourceToken`,message:"来源令牌应为字符串"})}const ue=new Set(["text","image","barcode","qrcode","chart","line","rect","ellipse"]);function p(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R(e){return e===null?"null":typeof e=="string"?JSON.stringify(e.slice(0,120)):["number","boolean","undefined"].includes(typeof e)?String(e):`[${typeof e}]`}function ce(e,i,t,s){const n=e[i];(typeof n!="number"||!Number.isFinite(n))&&s.push({path:`${t}.${i}`,message:`应为有限数字,实际 ${R(n)}`})}function he(e,i,t){if(e!==void 0){const s=`${i}.table`;if(!p(e))t.push({path:s,message:"逻辑表来源应为对象"});else{U(e.source,`${s}.source`,t),(typeof e.id!="string"||!e.id.trim())&&t.push({path:`${s}.id`,message:"逻辑表 ID 应为非空字符串"});const n=e.role;["header","body","group-header","subtotal","grand-total"].includes(n)||t.push({path:`${s}.role`,message:"未知逻辑表行角色"});const a=e.rowIndex;(typeof a!="number"||!Number.isInteger(a)||(n==="header"?a!==-1:a<0))&&t.push({path:`${s}.rowIndex`,message:"表头索引应为 -1,内容行索引应为非负整数"}),(!Array.isArray(e.columnKeys)||e.columnKeys.some(o=>typeof o!="string"))&&t.push({path:`${s}.columnKeys`,message:"逻辑列字段应为字符串数组"}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${s}.layout`,message:"布局应为 page 或 wide"}),e.title!==void 0&&typeof e.title!="string"&&t.push({path:`${s}.title`,message:"逻辑表名称应为字符串"})}}}function me(e,i,t,s){if(e!==void 0)if(!p(e)||!Array.isArray(e.cells))t.push({path:`${i}.grid.cells`,message:"grid.cells 应为二维数组"});else{const n=e.paddingMm;n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<0)&&t.push({path:`${i}.grid.paddingMm`,message:"单元格内距应为有限非负数"}),e.cells.forEach((a,o)=>{if(!Array.isArray(a)){t.push({path:`${i}.grid.cells.${o}`,message:"行应为数组"});return}a.forEach((f,r)=>{if(f==null)return;const d=`${i}.grid.cells.${o}.${r}`;if(!p(f)){t.push({path:d,message:"网格单元格应为对象或 null"});return}de(f,d,t),f.dataBar!==void 0&&!k.validDataBar(f.dataBar)&&t.push({path:`${d}.dataBar`,message:"数据条应包含 0–1 有序比例与 #RRGGBB 颜色"}),z(f.richParagraphs,d,t),Array.isArray(f.children)&&f.children.forEach((u,m)=>{B(u,`${i}.grid.cells.${o}.${r}.children.${m}`,t,s)})})})}}function T(e,i,t,s){e!==void 0&&!i.includes(e)&&s.push({path:t,message:"未知富文本属性值"})}function O(e,i,t,s,n=0){for(const a of i){const o=e[a];o!==void 0&&(typeof o!="number"||!Number.isFinite(o)||o<n)&&s.push({path:`${t}.${a}`,message:"富文本数值应为范围内有限数字"})}}function ge(e,i,t){if(e!==void 0){if(!p(e)){t.push({path:i,message:"富文本样式应为对象"});return}for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本样式应为字符串"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])e[s]!==void 0&&typeof e[s]!="boolean"&&t.push({path:`${i}.${s}`,message:"富文本样式应为布尔值"});O(e,["fontSize","fontSizePx","lineWidthPt","lineHeight","opacity"],i,t),O(e,["letterSpacing","rotateDeg"],i,t,-1/0),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于1"}),T(e.align,["left","center","right","justify"],`${i}.align`,t),T(e.verticalAlign,["top","middle","bottom"],`${i}.verticalAlign`,t)}}function pe(e,i,t){if(!p(e)){t.push({path:i,message:"富文本片段应为对象"});return}T(e.kind,["text","field"],`${i}.kind`,t);for(const s of["text","field"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本内容应为字符串"});ge(e.style,`${i}.style`,t)}function z(e,i,t){if(e!==void 0){if(!Array.isArray(e)){t.push({path:`${i}.richParagraphs`,message:"richParagraphs 应为数组"});return}e.forEach((s,n)=>{const a=`${i}.richParagraphs.${n}`;if(!p(s)||!Array.isArray(s.segments)){t.push({path:a,message:"段落缺少 segments 数组"});return}T(s.align,["left","center","right","justify"],`${a}.align`,t),O(s,["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"],a,t),s.segments.forEach((o,f)=>pe(o,`${a}.segments.${f}`,t))})}}function D(e,i,t,s=[]){const n=k.componentTreeIssue([e],i);if(n){t.push(n);return}B(e,i,t,s)}function B(e,i,t,s=[]){if(!p(e)){t.push({path:i,message:"组件应为对象"});return}const n=e.kind;typeof n!="string"?t.push({path:`${i}.kind`,message:"组件缺少 kind 字符串"}):ue.has(n)||s.push({path:`${i}.kind`,message:`未知组件类型 ${R(n)},将以兜底方式渲染`});for(const a of["leftMm","topMm","widthMm","heightMm"])ce(e,a,i,t);typeof e.leftMm=="number"&&e.leftMm<-100&&t.push({path:`${i}.leftMm`,message:"几何数值异常(leftMm<-100)"});for(const a of["widthMm","heightMm"])typeof e[a]=="number"&&e[a]<0&&t.push({path:`${i}.${a}`,message:"组件尺寸不能为负数"});he(e.table,i,t),ye(e.code,n,i,t),le(e,i,t),e.pageAnchor!==void 0&&!["header","footer"].includes(e.pageAnchor)&&t.push({path:`${i}.pageAnchor`,message:"页面锚点应为 header 或 footer"}),e.lineDirection!==void 0&&!["down","up"].includes(e.lineDirection)&&t.push({path:`${i}.lineDirection`,message:"线段方向应为 down 或 up"}),me(e.grid,i,t,s),z(e.richParagraphs,i,t)}function le(e,i,t){if(e.chartBinding!==void 0)try{if(P.validateReportChartBinding(e.chartBinding),e.kind!=="chart"||["binding","imageData","grid","pageAnchor"].some(s=>e[s]!==void 0))throw new Error("绑定图表不能设置图片、网格、记录绑定或页眉页脚");if(typeof e.widthMm!="number"||e.widthMm<45||typeof e.heightMm!="number"||e.heightMm<35)throw new Error("绑定图表至少需要 45×35mm")}catch(s){t.push({path:`${i}.chartBinding`,message:s instanceof Error?s.message:String(s)})}}function ye(e,i,t,s){if(e!==void 0)for(const n of fe.codeOptionIssues(e,i))s.push({path:`${t}.code${n.path?`.${n.path}`:""}`,message:n.message})}function q(e,i,t){if(!p(e))return;e.binding!==void 0&&t.push({path:`${i}.binding`,message:"渲染计划不允许未解析字段绑定"}),e.chartBinding!==void 0&&t.push({path:`${i}.chartBinding`,message:"渲染计划不允许未解析图表绑定"});const s=e.grid;!p(s)||!Array.isArray(s.cells)||s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,f)=>{!p(o)||!Array.isArray(o.children)||o.children.forEach((r,d)=>q(r,`${i}.grid.cells.${a}.${f}.children.${d}`,t))})})}function X(e,i,t,s=[]){if(!p(e)){t.push({path:i,message:"页应为对象"});return}const n=e.pageWidthMm,a=e.pageHeightMm;(typeof n!="number"||!Number.isFinite(n)||n<=0)&&t.push({path:`${i}.pageWidthMm`,message:`页宽非法: ${R(n)}`}),(typeof a!="number"||!(a>0&&a<5e3))&&t.push({path:`${i}.pageHeightMm`,message:`页高非法: ${R(a)}`}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"});const o=e.components;if(!Array.isArray(o))t.push({path:`${i}.components`,message:"components 应为数组"});else if(Array.isArray(o)){const f=k.componentTreeIssue(o,`${i}.components`);if(f){t.push(f);return}o.forEach((r,d)=>{B(r,`${i}.components.${d}`,t,s),q(r,`${i}.components.${d}`,t)})}}function Y(e){const i=[],t=[],s=p(e)?e.pages:void 0;if(p(e)&&e.requiresRecalculation!==void 0&&typeof e.requiresRecalculation!="boolean"&&i.push({path:"$.requiresRecalculation",message:"重算能力要求应为布尔值"}),!Array.isArray(s))i.push({path:"$.pages",message:e==null?"渲染计划为空":"渲染计划缺少 pages 数组"});else{const n=k.renderTreeIssue(s);if(n)return{ok:!1,errors:[...i,n],warnings:t};s.forEach((o,f)=>X(o,`$.pages.${f}`,i,t)),s.length>2e3&&t.push({path:"$.pages",message:`页数异常大(${s.length} 页),渲染与打印耗时可能显著增加`});const a=s.reduce((o,f)=>o+(p(f)&&Array.isArray(f.components)?f.components.length:0),0);a>5e4&&t.push({path:"$.pages",message:`组件总数异常大(${a} 个),可能触发浏览器性能限制`})}return{ok:i.length===0,errors:i,warnings:t}}function $e(e){const i=Y(e);if(!i.ok){const t=i.errors.slice(0,3).map(s=>`${s.path}: ${s.message}`).join("; ");throw new Error(`渲染计划校验失败(${i.errors.length} 处): ${t}`)}return e.pages}function be(e){return e.kind==="list"?e.id:e.nid}function Ae(e){return e.kind==="list"?!1:e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&/\{(?:page|totalPages)\}/.test(e.text)}function we(e,i){if(e.filter(s=>s.kind==="list"&&s.cardinality!=="record").length&&e.length!==1)throw new Error("纵向重复区域必须独占流式分段,不能与静态或单记录区域并排");for(const s of e){const n=s.kind==="list"?s.topMm+(s.rowHeightMm??0):s.topMm+s.heightMm;if(s.topMm<i.topMm-.001||n>i.topMm+i.heightMm+.001)throw new Error("流式分段应完整包含其组件的原始纵向范围")}}function Me(e,i){Q(e,i)}function Ee(e,i){const t=[];return Q(e,i,t),t}function Q(e,i,t){if(!i||!Array.isArray(i.bands)||!i.bands.length||i.bands.length>1e4)throw new Error("流式排版应包含 1–10000 个区域");const s=new Map,n=new Set;for(const a of e){if(Ae(a))continue;const o=be(a);if(!o||s.has(o))throw new Error("流式排版组件应具有唯一标识");s.set(o,a)}if(ke(i,s,n,t),n.size!==s.size)throw new Error("流式排版必须显式包含每个非锚点组件")}function ke(e,i,t,s){let n=-1/0;for(const a of e.bands){if(!Number.isFinite(a.topMm)||!Number.isFinite(a.heightMm)||a.topMm<0||a.heightMm<=0||a.topMm<n-.001)throw new Error("流式区域应按原始位置排序,尺寸有效且不重叠");if(!Array.isArray(a.componentIds)||!a.componentIds.length)throw new Error("流式区域不能没有组件");const o=[];for(const f of a.componentIds){const r=i.get(f);if(!r||t.has(f))throw new Error(`流式区域组件缺失、重复或包含页锚点:${f}`);t.add(f),o.push(r)}we(o,a),s?.push({band:a,components:o}),n=a.topMm+a.heightMm}}const Se=new Set(["__proto__","prototype","constructor"]);function $(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function S(e){return typeof e=="string"&&!!e.trim()&&!Se.has(e)}function x(e,i,t,s){for(const n of Object.keys(e))i.includes(n)||s.push({path:`${t}.${n}`,message:"存在未知配置字段"})}function ve(e,i,t){if(e!==void 0){if(!$(e)||!["number","percent","date"].includes(String(e.kind))){t.push({path:i,message:"绑定格式应为 number、percent 或 date"});return}x(e,e.kind==="date"?["kind","pattern"]:e.kind==="number"?["kind","digits","thousands"]:["kind","digits"],i,t),e.digits!==void 0&&(!Number.isInteger(e.digits)||Number(e.digits)<0||Number(e.digits)>100)&&t.push({path:`${i}.digits`,message:"精度应为 0..100 整数"}),e.thousands!==void 0&&typeof e.thousands!="boolean"&&t.push({path:`${i}.thousands`,message:"千分位开关应为布尔值"}),e.pattern!==void 0&&typeof e.pattern!="string"&&t.push({path:`${i}.pattern`,message:"日期格式应为字符串"})}}function Ne(e,i,t){const s=e.binding;if(s===void 0)return;const n=`${i}.binding`;if(!$(s)){t.push({path:n,message:"字段绑定应为对象"});return}(!["text","image","barcode","qrcode"].includes(String(e.kind))||e.grid!==void 0)&&t.push({path:n,message:"绑定仅支持独立文本、图片、条码与二维码组件"}),x(s,["field","format","prefix","suffix","emptyText"],n,t),S(s.field)||t.push({path:`${n}.field`,message:"绑定字段应为安全的非空字段名(按字面读取自有字段)"});for(const a of["prefix","suffix","emptyText"])s[a]!==void 0&&typeof s[a]!="string"&&t.push({path:`${n}.${a}`,message:"应为字符串"});ve(s.format,`${n}.format`,t),e.kind==="image"&&["format","prefix","suffix"].some(a=>s[a]!==void 0)&&t.push({path:n,message:"图片绑定直接读取 PNG/JPEG data URL,不支持文本格式或前后缀"})}function Re(e,i){if(!$(e)){i.push({path:"$.repeat",message:"逐记录配置应为对象"});return}x(e,["dataset","rowKey","copies"],"$.repeat",i),S(e.dataset)||i.push({path:"$.repeat.dataset",message:"数据集应为安全的非空名称"}),e.rowKey!==void 0&&!S(e.rowKey)&&i.push({path:"$.repeat.rowKey",message:"业务主键应为安全的非空字段名"});const t=e.copies;t!==void 0&&($(t)?(x(t,["field"],"$.repeat.copies",i),S(t.field)||i.push({path:"$.repeat.copies.field",message:"复制数字段应为安全的非空字段名"})):(!Number.isSafeInteger(t)||Number(t)<1||Number(t)>1e3)&&i.push({path:"$.repeat.copies",message:"每条记录复制数应为 1..1000 整数"}))}function Z(e,i,t,s){if(!$(e))return;Ne(e,i,s),e.binding!==void 0&&!t&&s.push({path:`${i}.binding`,message:"字段绑定需要模板 repeat 数据集;普通报表请使用列表字段"}),t&&e.kind==="list"&&s.push({path:i,message:"逐记录标签使用固定组件;动态列表请使用普通报表模板"}),e.chartBinding!==void 0&&(t||i.includes(".children."))&&s.push({path:`${i}.chartBinding`,message:"数据图表应放在普通报表的页面或流式分区,不放在逐记录标签或嵌套单元格内"});const n=e.grid;$(n)&&Array.isArray(n.cells)&&n.cells.forEach((a,o)=>{Array.isArray(a)&&a.forEach((f,r)=>{$(f)&&Array.isArray(f.children)&&f.children.forEach((d,u)=>Z(d,`${i}.grid.cells.${o}.${r}.children.${u}`,t,s))})})}function ee(e,i){const t=e.repeat!==void 0;t&&Re(e.repeat,i),Array.isArray(e.pages)&&e.pages.forEach((s,n)=>{if(!$(s))return;const a=`$.pages.${n}`;t&&(s.layout==="wide"||s.flow!==void 0)&&i.push({path:a,message:"逐记录标签仅支持固定尺寸页面,不支持宽表或流式分区"}),Array.isArray(s.components)&&s.components.forEach((o,f)=>{const r=`${a}.components.${f}`;if(Z(o,r,t,i),!t||!$(o))return;const{leftMm:d,topMm:u,widthMm:m,heightMm:l}=o;[d,u,m,l,s.widthMm,s.heightMm].every(y=>typeof y=="number"&&Number.isFinite(y))&&(Number(d)<0||Number(u)<0||Number(d)+Number(m)>Number(s.widthMm)+.001||Number(u)+Number(l)>Number(s.heightMm)+.001)&&i.push({path:r,message:"标签组件超出纸张边界,请调整位置或尺寸"})})})}function Te(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function _(e,i,t){if(e!==void 0)try{P.compileReportPredicate(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function te(e,i,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>2048){t.push({path:i,message:"聚合应为数组且最多 2048 项"});return}const s=new Set;e.forEach((n,a)=>{const o=`${i}.${a}`;if(!Te(n)){t.push({path:o,message:"聚合应为对象"});return}const f=n.field;typeof f!="string"||!f.trim()||s.has(f)?t.push({path:`${o}.field`,message:"聚合输出字段应非空且唯一"}):s.add(f),n.numeric!==void 0&&n.numeric!=="number"&&n.numeric!=="decimal"&&t.push({path:`${o}.numeric`,message:"数值模式应为 number 或 decimal"}),n.digits!==void 0&&(!Number.isInteger(n.digits)||Number(n.digits)<0||Number(n.digits)>100)&&t.push({path:`${o}.digits`,message:"小数位应为 0–100 的整数"});try{P.createAggregateAccumulator({...n,field:n.valueField??f})}catch(r){t.push({path:o,message:r instanceof Error?r.message:String(r)})}})}function xe(e,i,t){if(e===void 0)return;const s=P.validateComputedFields(e);for(const n of s.errors)t.push({path:i,message:n})}function Ce(e,i,t){if(e!==void 0)try{oe.validateMatrixOptions(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function Pe(e,i,t){if(e.tree===void 0)return;const s=`${i}.tree`;try{w.validateTreeOptions(e.tree);const n=e.tree;if(e.matrix||e.detail||e.groupBy||Array.isArray(e.groups)&&e.groups.length||e.rowVisibleWhen)throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");if(e.rowKey!==void 0&&e.rowKey!==n.idField)throw new Error("树形 rowKey 应与 idField 一致");if(!Array.isArray(e.columns)||!e.columns.some(a=>a&&a.field===n.labelField&&!a.hidden))throw new Error("树形布局需要可见的标签列");Array.isArray(e.computed)&&w.validateTreeComputed(n,e.computed)}catch(n){t.push({path:s,message:n instanceof Error?n.message:String(n)})}}const Fe=new Set(["__proto__","prototype","constructor"]),Oe=new Set(["text","number","boolean","date","decimal"]);function v(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function I(e){return typeof e=="string"&&!!e.trim()&&e.length<=4096&&!Fe.has(e)}function _e(e,i,t){if(!Array.isArray(e)||!e.length||e.length>2048){t.push({path:i,message:"绑定契约应包含 1–2048 个字段"});return}const s=new Set;e.forEach((n,a)=>{const o=`${i}.${a}`;if(!v(n)||!I(n.field)||s.has(n.field)){t.push({path:o,message:"字段名应安全、非空且唯一"});return}s.add(n.field);for(const f of["label","semanticKey","unit"])n[f]!==void 0&&(typeof n[f]!="string"||String(n[f]).length>4096)&&t.push({path:`${o}.${f}`,message:"应为不超过 4096 位的字符串"});n.type!==void 0&&!Oe.has(String(n.type))&&t.push({path:`${o}.type`,message:"未知绑定字段类型"})})}function L(e,i,t){if(e===void 0)return;if(!v(e)||!v(e.datasets)){t.push({path:i,message:"模板数据契约应声明 datasets"});return}e.source!==void 0&&!I(e.source)&&t.push({path:`${i}.source`,message:"来源应为安全的非空业务标识"});const s=Object.entries(e.datasets);(!s.length||s.length>256)&&t.push({path:`${i}.datasets`,message:"应声明 1–256 个数据集"});for(const[n,a]of s){const o=`${i}.datasets.${n}`;!I(n)||!v(a)?t.push({path:o,message:"数据集应使用安全名称和字段契约"}):_e(a.fields,`${o}.fields`,t)}}function H(e,i){return new Map(e.datasets[i]?.fields.map(t=>[t.field,t])??[])}function Ie(e,i,t,s){const n=e.label||e.field;for(const[a,o,f]of[["semanticKey","semantic","业务含义"],["type","type","类型"],["unit","unit","单位"]])e[a]!==i[a]&&(e[a]!==void 0||i[a]!==void 0)&&s.push({...t,code:o,message:`字段“${n}”的${f}不兼容(${e[a]??"未声明"} → ${i[a]??"未声明"}),请重新绑定`})}function Le(e,i){const t=[],s=[];if(L(i,"$.target",s),L(e.dataContract,"$.template.dataContract",s),s.length)return{ok:!1,issues:s.map(o=>({...o,code:"contract"}))};const n=e.dataContract;if(!n)return{ok:!1,issues:[{code:"contract",path:"$.template.dataContract",message:"模板未声明数据来源,请核对业务字段并重新绑定"}]};n.source!==i.source&&t.push({code:"source",path:"$.template.dataContract.source",message:`模板来源与当前报表不一致(${n.source??"未声明"} → ${i.source??"未声明"}),请从当前报表创建或重新绑定模板`});const a=new Set;for(const o of w.collectTemplateDatasetBindings(e)){const f=H(n,o.dataset),r=H(i,o.dataset);if(!f.size||!r.size){t.push({code:"dataset",dataset:o.dataset,path:o.path,message:`数据集“${o.dataset}”缺少来源或目标字段契约`});continue}for(const d of o.fields){if(o.generated.has(d.field)||d.summary&&o.summaries.has(d.field))continue;const u=`${o.dataset}\0${d.field}`;if(a.has(u))continue;a.add(u);const m=f.get(d.field),l=r.get(d.field),y={...d,dataset:o.dataset};!m||!l?t.push({...y,code:"field",message:`数据集“${o.dataset}”的字段“${d.field}”未声明,请重新绑定`}):Ie(m,l,y,t)}}return{ok:t.length===0,issues:t}}const V="1.0";class M extends Error{constructor(i){super(`模板校验失败:${i.slice(0,3).map(t=>`${t.path}: ${t.message}`).join("; ")}`),this.errors=i,this.name="ReportTemplateError"}}const De=new Set(["__proto__","prototype","constructor"]),Be=new Set(["schemaVersion","id","name","revision","description","template"]),Ve=new Set(["left","center","right","justify"]),N=2e5,je=64;function c(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ke(e,i,t){const s=Object.getPrototypeOf(e),n=Array.isArray(e);if(n?s!==Array.prototype:s!==Object.prototype&&s!==null)return t.push({path:i,message:"模板对象必须使用普通 JSON 对象原型"}),!1;if(n){const a=Object.keys(e);if(a.length!==e.length||a.some(o=>!/^(0|[1-9]\d*)$/.test(o)||Number(o)>=e.length))return t.push({path:i,message:"模板数组不能包含空位或额外属性"}),!1}return Object.getOwnPropertySymbols(e).length>0?(t.push({path:i,message:"模板不能包含 Symbol 键"}),!1):!0}function He(e,i,t,s){return De.has(e)?(s.push({path:t,message:"模板不能包含可能污染原型的键"}),!1):i.get||i.set||!i.enumerable?(s.push({path:t,message:"模板不能包含访问器或不可枚举字段"}),!1):!0}function Je(e){return e===null||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function j(e,i){const t=new Set;let s=0,n=0,a=!1;const o=(f,r,d)=>{if(!a){if(++s>N){s===N+1&&i.push({path:r,message:"模板超过 JSON 节点安全上限"});return}if(d>je){i.push({path:r,message:"模板嵌套层级过深"});return}if(typeof f=="string"){n+=f.length,n>w.MAX_TEMPLATE_JSON_CHARACTERS&&(a=!0,i.push({path:r,message:"模板文本超过 1000 万字符的安全上限"}));return}if(!Je(f)){if(!f||typeof f!="object"){i.push({path:r,message:"模板只允许 JSON 值,不允许函数、undefined 或非有限数字"});return}if(t.has(f)){i.push({path:r,message:"模板不能包含循环引用"});return}if(Ke(f,r,i)){t.add(f);for(const[u,m]of Object.entries(Object.getOwnPropertyDescriptors(f))){if(Array.isArray(f)&&u==="length")continue;const l=`${r}.${u}`;if(He(u,m,l,i)&&o(m.value,l,d+1),s>N||a)break}t.delete(f)}}}};o(e,"$",0)}function h(e,i,t,s,n=!1){const a=e[i];a===void 0&&!n||(typeof a!="string"||n&&!a.trim())&&s.push({path:`${t}.${i}`,message:n?"应为非空字符串":"应为字符串"})}function g(e,i,t,s,n=0,a=!1){const o=e[i];o===void 0&&!a||(typeof o!="number"||!Number.isFinite(o)||o<n)&&s.push({path:`${t}.${i}`,message:`应为大于等于 ${n} 的有限数字`})}function A(e,i,t,s){e[i]!==void 0&&typeof e[i]!="boolean"&&s.push({path:`${t}.${i}`,message:"应为布尔值"})}function E(e,i,t,s=!1){e!==void 0&&!Ve.has(e)&&!(s&&e==="auto")&&t.push({path:i,message:`未知对齐方式${s?"(支持 auto)":""}`})}function b(e,i,t){if(e!==void 0){if(!c(e)){t.push({path:i,message:"样式应为对象"});return}E(e.align,`${i}.align`,t),e.verticalAlign!==void 0&&!["top","middle","bottom"].includes(e.verticalAlign)&&t.push({path:`${i}.verticalAlign`,message:"未知垂直对齐方式"});for(const s of["fontSize","fontSizePx","lineWidthPt","lineHeight"])g(e,s,i,t);for(const s of["letterSpacing","rotateDeg"])g(e,s,i,t,-1/0);g(e,"opacity",i,t),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于 1"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])A(e,s,i,t);for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])h(e,s,i,t)}}function We(e,i,t){if(e===void 0)return;if(!Array.isArray(e)){t.push({path:i,message:"参数定义应为数组"});return}const s=new Set,n=t.length;e.forEach((a,o)=>{const f=`${i}.${o}`;if(!c(a)){t.push({path:f,message:"参数定义应为对象"});return}h(a,"field",f,t,!0),typeof a.field=="string"&&(s.has(a.field)&&t.push({path:`${f}.field`,message:"参数名重复"}),s.add(a.field)),a.type!==void 0&&!["text","number","date","month","year","dateRange","select","multiSelect","cascader","numberRange"].includes(a.type)&&t.push({path:`${f}.type`,message:"未知参数类型"});for(const r of["label","defaultValue","placeholder"])h(a,r,f,t);A(a,"required",f,t);for(const r of["minLength","maxLength"]){const d=a[r];d!==void 0&&(typeof d!="number"||!Number.isSafeInteger(d)||d<0)&&t.push({path:`${f}.${r}`,message:"长度边界应为非负整数"})}Ge(a,f,t),a.options!==void 0&&(Array.isArray(a.options)?a.options.forEach((r,d)=>{const u=`${f}.options.${d}`;if(!c(r))t.push({path:u,message:"选项应为对象"});else for(const m of["label","value"])typeof r[m]!="string"&&t.push({path:`${u}.${m}`,message:"选项标签与值应为字符串(允许空白选项)"})}):t.push({path:`${f}.options`,message:"选项应为数组"}))}),t.length===n&&t.push(...W.validateReportParamDefinitions(e).map(a=>({path:a.path.replace("$.paramDefs",i),message:a.message})))}function Ge(e,i,t){for(const a of["min","max"]){const o=e[a];if(o===void 0)continue;W.isReportTemporalBound(e.type,o)||["number","numberRange"].includes(e.type)&&typeof o=="number"&&Number.isFinite(o)||t.push({path:`${i}.${a}`,message:"数字使用有限数字边界,日期/月/年使用对应规范字符串边界"})}const s=typeof e.min=="number"&&typeof e.max=="number"&&e.min>e.max,n=typeof e.min=="string"&&typeof e.max=="string"&&e.min>e.max;(s||n)&&t.push({path:i,message:"最小边界不能大于最大边界"}),typeof e.minLength=="number"&&typeof e.maxLength=="number"&&e.minLength>e.maxLength&&t.push({path:i,message:"最小长度不能大于最大长度"})}function ie(e,i,t){if(!Array.isArray(e)||e.length===0){t.push({path:i,message:"列表至少需要一列"});return}e.every(s=>c(s)&&s.hidden===!0)&&t.push({path:i,message:"列表至少需要一列可见列"}),e.forEach((s,n)=>{const a=`${i}.${n}`;if(!c(s)){t.push({path:a,message:"列应为对象"});return}if(G(s,a,t),s.visual!==void 0&&!w.validColumnVisual(s.visual)&&t.push({path:`${a}.visual`,message:"列可视化配置无效,请检查类型、数值范围和颜色"}),A(s,"hidden",a,t),_(s.visibleWhen,`${a}.visibleWhen`,t),typeof s.header!="string"&&t.push({path:`${a}.header`,message:"表头应为字符串(允许空白表头)"}),h(s,"field",a,t,!0),g(s,"widthMm",a,t,Number.MIN_VALUE,!0),b(s.style,`${a}.style`,t),b(s.headerStyle,`${a}.headerStyle`,t),E(s.align,`${a}.align`,t,!0),E(s.headerAlign,`${a}.headerAlign`,t),s.semanticRole!==void 0&&!["identifier","dimension","measure","date","text"].includes(s.semanticRole)&&t.push({path:`${a}.semanticRole`,message:"未知列语义"}),s.format!==void 0)if(!c(s.format)||!["number","percent","date"].includes(s.format.kind))t.push({path:`${a}.format`,message:"未知列格式"});else{const o=s.format.digits;o!==void 0&&(typeof o!="number"||!Number.isInteger(o)||o<0||o>100)&&t.push({path:`${a}.format.digits`,message:"小数位应为 0–100 的整数"}),A(s.format,"thousands",`${a}.format`,t),h(s.format,"pattern",`${a}.format`,t)}s.rules!==void 0&&(Array.isArray(s.rules)?s.rules.forEach((o,f)=>{const r=`${a}.rules.${f}`;if(!c(o)||!c(o.when)){t.push({path:r,message:"条件格式缺少 when 对象"});return}_(o.when,`${r}.when`,t),b(o.style,`${r}.style`,t)}):t.push({path:`${a}.rules`,message:"条件格式应为数组"}))})}function se(e,i,t){if(e!==void 0){if(!c(e)){t.push({path:i,message:"分组应为对象"});return}h(e,"field",i,t,!0);for(const s of["headerTemplate","subtotalLabel"])h(e,s,i,t);for(const s of["headerStyle","subtotalStyle"])b(e[s],`${i}.${s}`,t);A(e,"keepWithNext",i,t),A(e,"repeatHeader",i,t),te(e.aggregates,`${i}.aggregates`,t),e.subtotal!==void 0&&(!Array.isArray(e.subtotal)||e.subtotal.some(s=>typeof s!="string"))&&t.push({path:`${i}.subtotal`,message:"小计字段应为字符串数组"})}}function Ue(e,i,t){if(!(e===void 0||typeof e=="boolean")){if(!c(e)){t.push({path:i,message:"合计应为布尔值或对象"});return}h(e,"label",i,t),te(e.aggregates,`${i}.aggregates`,t),b(e.style,`${i}.style`,t),e.fields!==void 0&&(!Array.isArray(e.fields)||e.fields.some(s=>typeof s!="string"))&&t.push({path:`${i}.fields`,message:"合计字段应为字符串数组"})}}function ze(e,i,t,s){const n={kind:"rect",leftMm:0,topMm:0,widthMm:1,heightMm:1,grid:e};if(D(n,t,s,[]),K(n,t,s),!c(e)||!Array.isArray(e.cells))return;const a=e.cells,o=Array.isArray(i)?i.length:0;if(a.length*o>N){s.push({path:t,message:"表头逻辑网格超过 20 万格安全上限"});return}e.cells.length||s.push({path:`${t}.cells`,message:"表头至少需要一行"}),Array.isArray(e.colWidthsMm)&&e.colWidthsMm.length!==o&&s.push({path:`${t}.colWidthsMm`,message:"表头列宽数量应与列表列数一致"}),Array.isArray(e.rowHeightsMm)&&e.rowHeightsMm.length!==e.cells.length&&s.push({path:`${t}.rowHeightsMm`,message:"表头行高数量应与行数一致"}),qe(a,o,t,s)}function qe(e,i,t,s){const n=new Set;e.forEach((a,o)=>{if(!Array.isArray(a))return;let f=0;a.forEach((r,d)=>{for(;n.has(`${o}:${f}`);)f++;const u=c(r)&&typeof r.colSpan=="number"?r.colSpan:1,m=c(r)&&typeof r.rowSpan=="number"?r.rowSpan:1;(f+u>i||o+m>e.length)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域超出表头边界"});for(let l=o;l<Math.min(e.length,o+m);l++)for(let y=f;y<Math.min(i,f+u);y++)n.has(`${l}:${y}`)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域重叠"}),n.add(`${l}:${y}`);f+=u})})}function Xe(e,i,t){if(Pe(e,i,t),xe(e.computed,`${i}.computed`,t),Ce(e.matrix,`${i}.matrix`,t),e.matrix&&(e.detail||e.groupBy||Array.isArray(e.groups)&&e.groups.length||e.grandTotal)&&t.push({path:`${i}.matrix`,message:"矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细"}),_(e.rowVisibleWhen,`${i}.rowVisibleWhen`,t),e.groups!==void 0&&(!Array.isArray(e.groups)||e.groups.length>16?t.push({path:`${i}.groups`,message:"分组应为数组,最多 16 级"}):e.groups.forEach((a,o)=>se(a,`${i}.groups.${o}`,t))),e.detail===void 0)return;const s=e.detail,n=`${i}.detail`;if(!c(s)){t.push({path:n,message:"主从关联应为对象"});return}for(const a of["dataset","parentKey","foreignKey"])h(s,a,n,t,!0);for(const a of["rowKey","revisionField","sourceTokenField"])h(s,a,n,t,s[a]!==void 0);h(s,"label",n,t),A(s,"header",n,t),g(s,"rowHeightMm",n,t,Number.MIN_VALUE),ie(s.columns,`${n}.columns`,t),s.unmatched!==void 0&&s.unmatched!=="error"&&s.unmatched!=="ignore"&&t.push({path:`${n}.unmatched`,message:"未关联明细策略应为 error 或 ignore"})}function Ye(e,i,t){for(const s of["leftMm","topMm"])g(e,s,i,t,-1/0,!0);g(e,"widthMm",i,t,Number.MIN_VALUE,!0),h(e,"dataset",i,t,!0),h(e,"title",i,t);for(const s of["rowKey","revisionField","sourceTokenField"])h(e,s,i,t,e[s]!==void 0);e.headerGrid!==void 0&&ze(e.headerGrid,e.columns,`${i}.headerGrid`,t),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"}),ie(e.columns,`${i}.columns`,t);for(const s of["fontSizePt","rowHeightMm"])g(e,s,i,t,Number.MIN_VALUE);g(e,"paddingMm",i,t);for(const s of["header","headerBold","headerEveryPage","border"])A(e,s,i,t);e.cardinality!==void 0&&e.cardinality!=="record"&&t.push({path:`${i}.cardinality`,message:"单记录区域类型应为 record"}),h(e,"headerBackgroundColor",i,t),E(e.align,`${i}.align`,t,!0),E(e.headerAlign,`${i}.headerAlign`,t),b(e.headerStyle,`${i}.headerStyle`,t),Xe(e,i,t),se(e.groupBy,`${i}.groupBy`,t),Ue(e.grandTotal,`${i}.grandTotal`,t)}function J(e,i,t){Array.isArray(e.richParagraphs)&&e.richParagraphs.forEach((s,n)=>{if(!c(s))return;const a=`${i}.richParagraphs.${n}`;E(s.align,`${a}.align`,t);for(const o of["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"])g(s,o,a,t);Array.isArray(s.segments)&&s.segments.forEach((o,f)=>{const r=`${a}.segments.${f}`;if(!c(o)){t.push({path:r,message:"富文本片段应为对象"});return}o.kind!==void 0&&o.kind!=="text"&&o.kind!=="field"&&t.push({path:`${r}.kind`,message:"未知富文本片段类型"});for(const d of["text","field"])h(o,d,r,t);b(o.style,`${r}.style`,t)})})}function K(e,i,t){b(e.style,`${i}.style`,t);for(const n of["text","rawText","imageData","fallbackText","nid","rkey"])h(e,n,i,t);if(e.lines!==void 0&&(!Array.isArray(e.lines)||e.lines.some(n=>typeof n!="string"))&&t.push({path:`${i}.lines`,message:"文本行应为字符串数组"}),J(e,i,t),!c(e.grid))return;const s=e.grid;g(s,"gapMm",`${i}.grid`,t),g(s,"paddingMm",`${i}.grid`,t);for(const n of["colWidthsMm","rowHeightsMm"]){const a=s[n];a!==void 0&&(!Array.isArray(a)||a.some(o=>typeof o!="number"||!Number.isFinite(o)||o<0))&&t.push({path:`${i}.grid.${n}`,message:"网格尺寸应为有限非负数字数组"})}Array.isArray(s.cells)&&s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,f)=>{const r=`${i}.grid.cells.${a}.${f}`;if(o!==null){if(!c(o)){t.push({path:r,message:"网格单元格应为对象或 null"});return}for(const d of["text","rawText","numberFormat"])h(o,d,r,t);for(const d of["colSpan","rowSpan"]){const u=o[d];u!==void 0&&(typeof u!="number"||!Number.isInteger(u)||u<=0)&&t.push({path:`${r}.${d}`,message:"跨度应为正整数"})}o.value!==void 0&&o.value!==null&&!["string","number","boolean"].includes(typeof o.value)&&t.push({path:`${r}.value`,message:"Excel 原始值应为字符串、数字、布尔值或 null"}),b(o.style,`${r}.style`,t),J(o,r,t),o.children!==void 0&&(Array.isArray(o.children)?o.children.forEach((d,u)=>{c(d)&&K(d,`${r}.children.${u}`,t)}):t.push({path:`${r}.children`,message:"嵌套组件应为数组"}))}})})}function Qe(e,i,t){if(!(e.flow===void 0||!Array.isArray(e.components)))try{Me(e.components,e.flow)}catch(s){t.push({path:`${i}.flow`,message:s instanceof Error?s.message:String(s)})}}function ne(e){const i=[],t=[];return j(e,i),i.length?{ok:!1,errors:i,warnings:t}:(c(e)?(e.schemaVersion!==void 0&&e.schemaVersion!==k.RENDER_PLAN_SCHEMA_VERSION&&i.push({path:"$.schemaVersion",message:"不支持的模板 schemaVersion"}),We(e.params,"$.params",i),L(e.dataContract,"$.dataContract",i),ee(e,i),!Array.isArray(e.pages)||e.pages.length===0?i.push({path:"$.pages",message:"模板至少需要一页"}):e.pages.forEach((s,n)=>{const a=`$.pages.${n}`;if(!c(s)){i.push({path:a,message:"页应为对象"});return}g(s,"widthMm",a,i,Number.MIN_VALUE,!0),g(s,"heightMm",a,i,Number.MIN_VALUE,!0),s.layout!==void 0&&s.layout!=="page"&&s.layout!=="wide"&&i.push({path:`${a}.layout`,message:"布局应为 page 或 wide"}),typeof s.heightMm=="number"&&s.heightMm>=5e3&&i.push({path:`${a}.heightMm`,message:"页高应小于 5000mm"});for(const o of["marginTopMm","marginBottomMm","marginLeftMm","marginRightMm"])g(s,o,a,i);typeof s.widthMm=="number"&&Number(s.marginLeftMm??0)+Number(s.marginRightMm??0)>=s.widthMm&&i.push({path:a,message:"横向页边距占满页面"}),typeof s.heightMm=="number"&&Number(s.marginTopMm??0)+Number(s.marginBottomMm??0)>=s.heightMm&&i.push({path:a,message:"纵向页边距占满页面"}),Array.isArray(s.components)?s.components.forEach((o,f)=>{const r=`${a}.components.${f}`;c(o)&&o.kind==="list"?Ye(o,r,i):(D(o,r,i,t),c(o)&&K(o,r,i))}):i.push({path:`${a}.components`,message:"组件应为数组"}),Qe(s,a,i)})):i.push({path:"$",message:"模板应为对象"}),{ok:i.length===0,errors:i,warnings:t})}function ae(e){const i=[],t=[];if(j(e,i),i.length)return{ok:!1,errors:i,warnings:t};if(!c(e))i.push({path:"$",message:"模板文档应为对象"});else{for(const n of Object.keys(e))Be.has(n)||i.push({path:`$.${n}`,message:"模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据"});e.schemaVersion!==V&&i.push({path:"$.schemaVersion",message:"不支持的模板文档版本"});for(const n of["id","name"])h(e,n,"$",i,!0);for(const n of["revision","description"])h(e,n,"$",i);const s=ne(e.template);i.push(...s.errors.map(n=>({...n,path:`$.template${n.path.slice(1)}`}))),t.push(...s.warnings.map(n=>({...n,path:`$.template${n.path.slice(1)}`})))}return{ok:i.length===0,errors:i,warnings:t}}function F(e){const i=ae(e);if(!i.ok)throw new M(i.errors)}function Ze(e){const i=[];if(j(e,i),i.length)throw new M(i);const t={...e,schemaVersion:e.schemaVersion??V};return F(t),C(t)}function et(e){let i=e;if(typeof e=="string"){if(e.length>w.MAX_TEMPLATE_JSON_CHARACTERS)throw new M([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);try{i=JSON.parse(e)}catch{throw new M([{path:"$",message:"模板 JSON 语法无效"}])}}return F(i),C(i)}function tt(e){F(e);try{return w.stringifyValidatedTemplate(e)}catch(i){throw i instanceof RangeError?new M([{path:"$",message:i.message}]):i}}function C(e){return JSON.parse(JSON.stringify(e))}function it(e=[]){const i=new Map,t={get:s=>{const n=i.get(s);return n?C(n):void 0},list:()=>Array.from(i.values(),({template:s,...n})=>({...n})),register:(s,n={})=>{if(F(s),i.has(s.id)&&!n.replace)throw new M([{path:"$.id",message:`模板 ID ${s.id} 已注册;更新需显式 replace:true`}]);i.set(s.id,C(s))},remove:s=>i.delete(s)};for(const s of e)t.register(s);return t}exports.REPORT_TEMPLATE_DOCUMENT_VERSION=V;exports.ReportTemplateError=M;exports.assertRenderPlan=$e;exports.createTemplateRegistry=it;exports.defineReportTemplate=Ze;exports.inspectReportTemplateCompatibility=Le;exports.parseReportTemplate=et;exports.serializeReportTemplate=tt;exports.validateComponent=D;exports.validatePage=X;exports.validateRenderPlan=Y;exports.validateReportTemplate=ne;exports.validateReportTemplateDocument=ae;exports.validateTemplateRepeat=ee;exports.validatedReportFlowGroups=Ee;
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { e as K, c as S } from "./computed-BR_O8uAv.js";
|
|
2
|
+
function u(e) {
|
|
3
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
4
|
+
}
|
|
5
|
+
function a(e, r, t) {
|
|
6
|
+
typeof e == "string" ? t.push({ field: e, path: r }) : Array.isArray(e) && e.forEach((i, n) => a(i, `${r}[${n}]`, t));
|
|
7
|
+
}
|
|
8
|
+
function m(e, r, t) {
|
|
9
|
+
if (Array.isArray(e)) {
|
|
10
|
+
e.forEach((i, n) => m(i, `${r}[${n}]`, t));
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (u(e))
|
|
14
|
+
for (const [i, n] of Object.entries(e))
|
|
15
|
+
["field", "weightField"].includes(i) ? a(n, `${r}.${i}`, t) : i !== "value" && i !== "style" && m(n, `${r}.${i}`, t);
|
|
16
|
+
}
|
|
17
|
+
function $(e, r, t) {
|
|
18
|
+
Array.isArray(e) && e.forEach((i, n) => {
|
|
19
|
+
if (!u(i)) return;
|
|
20
|
+
typeof i.field == "string" && i.valueField !== void 0 && i.valueField !== i.field && t.summaries.add(i.field);
|
|
21
|
+
const o = i.valueField === void 0 ? "field" : "valueField";
|
|
22
|
+
a(i[o], `${r}[${n}].${o}`, t.fields), i.valueField !== void 0 && i.valueField === i.field && a(i.field, `${r}[${n}].field`, t.fields), a(i.weightField, `${r}[${n}].weightField`, t.fields);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function R(e, r, t) {
|
|
26
|
+
for (const n of ["rowKey", "revisionField", "sourceTokenField"]) a(e[n], `${r}.${n}`, t.fields);
|
|
27
|
+
if (!e.matrix && Array.isArray(e.columns) && e.columns.forEach((n, o) => {
|
|
28
|
+
u(n) && (typeof n.field == "string" && t.fields.push({ field: n.field, path: `${r}.columns[${o}].field`, summary: !0 }), m(n.rules, `${r}.columns[${o}].rules`, t.fields), m(n.visibleWhen, `${r}.columns[${o}].visibleWhen`, t.fields));
|
|
29
|
+
}), m(e.rowVisibleWhen, `${r}.rowVisibleWhen`, t.fields), Array.isArray(e.computed) && e.computed.forEach((n, o) => {
|
|
30
|
+
u(n) && (typeof n.field == "string" && t.generated.add(n.field), m(n.expression, `${r}.computed[${o}].expression`, t.fields), a(n.dependsOn, `${r}.computed[${o}].dependsOn`, t.fields), a(n.groupBy, `${r}.computed[${o}].groupBy`, t.fields));
|
|
31
|
+
}), (Array.isArray(e.groups) ? e.groups.map((n, o) => ({ group: n, path: `${r}.groups[${o}]` })) : e.groupBy ? [{ group: e.groupBy, path: `${r}.groupBy` }] : []).forEach(({ group: n, path: o }) => {
|
|
32
|
+
u(n) && (a(n.field, `${o}.field`, t.fields), a(n.subtotal, `${o}.subtotal`, t.fields), $(n.aggregates, `${o}.aggregates`, t));
|
|
33
|
+
}), u(e.grandTotal) && (a(e.grandTotal.fields, `${r}.grandTotal.fields`, t.fields), $(e.grandTotal.aggregates, `${r}.grandTotal.aggregates`, t)), u(e.matrix) && (a(e.matrix.rowFields, `${r}.matrix.rowFields`, t.fields), a(e.matrix.columnFields, `${r}.matrix.columnFields`, t.fields), $(e.matrix.measures, `${r}.matrix.measures`, t)), u(e.tree)) {
|
|
34
|
+
for (const n of ["idField", "parentField", "labelField"]) a(e.tree[n], `${r}.tree.${n}`, t.fields);
|
|
35
|
+
$(e.tree.aggregates, `${r}.tree.aggregates`, t);
|
|
36
|
+
}
|
|
37
|
+
u(e.detail) && a(e.detail.parentKey, `${r}.detail.parentKey`, t.fields);
|
|
38
|
+
}
|
|
39
|
+
function ne(e) {
|
|
40
|
+
const r = [], t = e.repeat, i = t ? { dataset: t.dataset, path: "$.template.repeat", fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() } : void 0;
|
|
41
|
+
i && t && (a(t.rowKey, "$.template.repeat.rowKey", i.fields), typeof t.copies == "object" && a(t.copies.field, "$.template.repeat.copies.field", i.fields), r.push(i));
|
|
42
|
+
function n(o, f) {
|
|
43
|
+
if (Array.isArray(o)) {
|
|
44
|
+
o.forEach((l, s) => n(l, `${f}[${s}]`));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (u(o)) {
|
|
48
|
+
if (i && u(o.binding) && a(o.binding.field, `${f}.binding.field`, i.fields), u(o.chartBinding) && typeof o.chartBinding.dataset == "string") {
|
|
49
|
+
const l = `${f}.chartBinding`, s = o.chartBinding, d = { dataset: s.dataset, path: l, fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() };
|
|
50
|
+
a(s.categoryField, `${l}.categoryField`, d.fields), m(s.measures, `${l}.measures`, d.fields), r.push(d);
|
|
51
|
+
}
|
|
52
|
+
if (typeof o.dataset == "string" && Array.isArray(o.columns)) {
|
|
53
|
+
const l = { dataset: o.dataset, path: f, fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() };
|
|
54
|
+
R(o, f, l), typeof o.foreignKey == "string" && a(o.foreignKey, `${f}.foreignKey`, l.fields), r.push(l);
|
|
55
|
+
}
|
|
56
|
+
for (const [l, s] of Object.entries(o)) n(s, `${f}.${l}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return n(e, "$.template"), r;
|
|
60
|
+
}
|
|
61
|
+
class D extends Error {
|
|
62
|
+
constructor(r) {
|
|
63
|
+
super(`树节点超出行数预算 ${r}`), this.limit = r, this.code = "tree-row-limit", this.name = "TreeRowLimitError";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function A(e, r, t, i) {
|
|
67
|
+
const n = e ?? r;
|
|
68
|
+
if (!Number.isInteger(n) || n < 1 || n > t) throw new Error(`${i}应为 1–${t} 的整数`);
|
|
69
|
+
return n;
|
|
70
|
+
}
|
|
71
|
+
function v(e) {
|
|
72
|
+
return { rows: A(e.maxRows, 1e5, 1e6, "树行数预算"), depth: A(e.maxDepth, 64, 256, "树深度预算"), visits: A(e.maxAggregationVisits, 1e6, 1e7, "树聚合访问预算") };
|
|
73
|
+
}
|
|
74
|
+
function T(e) {
|
|
75
|
+
return typeof e == "string" && !!e.trim();
|
|
76
|
+
}
|
|
77
|
+
function g(e) {
|
|
78
|
+
return T(e) && !["__proto__", "prototype", "constructor"].includes(e);
|
|
79
|
+
}
|
|
80
|
+
function x(e) {
|
|
81
|
+
if (T(e) || typeof e == "number" && Number.isFinite(e)) return e;
|
|
82
|
+
throw new Error("树节点业务键应为非空字符串或有限数字");
|
|
83
|
+
}
|
|
84
|
+
function N(e) {
|
|
85
|
+
return JSON.stringify([typeof e, e]);
|
|
86
|
+
}
|
|
87
|
+
function j(e) {
|
|
88
|
+
return [e.idField, ...e.input === "flat" ? [e.parentField ?? ""] : [e.childrenField ?? "children"]];
|
|
89
|
+
}
|
|
90
|
+
function I(e, r) {
|
|
91
|
+
const t = j(e);
|
|
92
|
+
if (r?.some((i) => i.scope && i.scope !== "row" || t.includes(i.field))) throw new Error("树形布局仅支持不覆盖结构键的当前行计算");
|
|
93
|
+
}
|
|
94
|
+
function p(e) {
|
|
95
|
+
if (!e?.aborted) return;
|
|
96
|
+
const r = new Error("树报表处理已取消");
|
|
97
|
+
throw r.name = "AbortError", r;
|
|
98
|
+
}
|
|
99
|
+
function _(e) {
|
|
100
|
+
const r = e.aggregates ?? [];
|
|
101
|
+
if (!Array.isArray(r) || r.length > 32) throw new Error("树聚合最多 32 项");
|
|
102
|
+
if (e.parentValues !== "leaf-aggregate" && r.length) throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");
|
|
103
|
+
if (e.parentValues === "leaf-aggregate" && !r.length) throw new Error("叶子聚合策略至少需要一个聚合字段");
|
|
104
|
+
const t = /* @__PURE__ */ new Set();
|
|
105
|
+
for (const i of r) {
|
|
106
|
+
if (!i || !g(i.field) || t.has(i.field)) throw new Error("树聚合输出字段应安全、非空且唯一");
|
|
107
|
+
for (const n of [i.valueField, i.weightField]) if (n !== void 0 && !g(n)) throw new Error("树聚合来源字段应安全且非空");
|
|
108
|
+
if ([...j(e), e.labelField].includes(i.field)) throw new Error("树聚合不能覆盖结构键或标签字段");
|
|
109
|
+
t.add(i.field), S({ ...i, field: i.valueField ?? i.field });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function J(e) {
|
|
113
|
+
if (!g(e.idField) || !g(e.labelField)) throw new Error("树需要安全的业务键和标签字段");
|
|
114
|
+
if (e.input === "flat" && (!g(e.parentField) || e.parentField === e.idField)) throw new Error("扁平树需要独立的父键字段");
|
|
115
|
+
if (e.childrenField !== void 0 && !g(e.childrenField)) throw new Error("子节点字段应安全且非空");
|
|
116
|
+
if (e.input === "nested" && [e.idField, e.labelField].includes(e.childrenField ?? "children")) throw new Error("子节点字段不能覆盖业务键或标签字段");
|
|
117
|
+
}
|
|
118
|
+
function W(e) {
|
|
119
|
+
if (!e || typeof e != "object" || !["flat", "nested"].includes(e.input)) throw new Error("树输入应为 flat 或 nested");
|
|
120
|
+
if (J(e), e.orphan !== void 0 && !["error", "root"].includes(e.orphan)) throw new Error("树孤儿策略应为 error 或 root");
|
|
121
|
+
if (e.parentValues !== void 0 && !["source", "leaf-aggregate"].includes(e.parentValues)) throw new Error("未知树父级取值策略");
|
|
122
|
+
if (e.indentMm !== void 0 && (!Number.isFinite(e.indentMm) || e.indentMm < 0 || e.indentMm > 20)) throw new Error("树每级缩进应为 0–20 mm");
|
|
123
|
+
v(e), _(e);
|
|
124
|
+
}
|
|
125
|
+
function C(e, r, t, i) {
|
|
126
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("树节点应为对象");
|
|
127
|
+
if (t.size >= i.rows) throw new D(i.rows);
|
|
128
|
+
const n = x(e[r.idField]), o = N(n);
|
|
129
|
+
if (t.has(o)) throw new Error(`树节点业务键重复:${String(n)}`);
|
|
130
|
+
const f = { original: e, row: e, key: n, depth: 0, children: [] };
|
|
131
|
+
return t.set(o, f), f;
|
|
132
|
+
}
|
|
133
|
+
function L(e, r, t, i, n) {
|
|
134
|
+
for (const f of e)
|
|
135
|
+
p(n), C(f, r, t, i);
|
|
136
|
+
const o = [];
|
|
137
|
+
for (const f of t.values()) {
|
|
138
|
+
p(n);
|
|
139
|
+
const l = f.row[r.parentField];
|
|
140
|
+
if (l == null) {
|
|
141
|
+
o.push(f);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const s = t.get(N(x(l)));
|
|
145
|
+
if (!s) {
|
|
146
|
+
if (r.orphan !== "root") throw new Error(`树节点 ${String(f.key)} 的父节点不存在`);
|
|
147
|
+
o.push(f);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (s === f) throw new Error("树节点不能以自身为父节点");
|
|
151
|
+
f.parent = s, s.children.push(f);
|
|
152
|
+
}
|
|
153
|
+
return o;
|
|
154
|
+
}
|
|
155
|
+
function P(e, r, t, i, n) {
|
|
156
|
+
const o = [], f = [{ rows: e, next: 0 }];
|
|
157
|
+
for (; f.length; ) {
|
|
158
|
+
p(n);
|
|
159
|
+
const l = f[f.length - 1];
|
|
160
|
+
if (l.next >= l.rows.length) {
|
|
161
|
+
f.pop();
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const s = C(l.rows[l.next++], r, t, i);
|
|
165
|
+
if (s.parent = l.parent, s.depth = f.length - 1, f.length > i.depth) throw new Error(`树节点超出深度预算 ${i.depth}`);
|
|
166
|
+
(l.parent?.children ?? o).push(s);
|
|
167
|
+
const d = s.row[r.childrenField ?? "children"];
|
|
168
|
+
if (d != null) {
|
|
169
|
+
if (!Array.isArray(d)) throw new Error("嵌套树 children 字段应为数组");
|
|
170
|
+
d.length && f.push({ rows: d, next: 0, parent: s });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return o;
|
|
174
|
+
}
|
|
175
|
+
function z(e, r, t, i) {
|
|
176
|
+
const n = [], o = [{ nodes: e, next: 0 }];
|
|
177
|
+
for (; o.length; ) {
|
|
178
|
+
p(i);
|
|
179
|
+
const f = o[o.length - 1];
|
|
180
|
+
if (f.next >= f.nodes.length) {
|
|
181
|
+
o.pop();
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (o.length > t.depth) throw new Error(`树节点超出深度预算 ${t.depth}`);
|
|
185
|
+
const l = f.nodes[f.next++];
|
|
186
|
+
l.depth = o.length - 1, n.push(l), l.children.length && o.push({ nodes: l.children, next: 0 });
|
|
187
|
+
}
|
|
188
|
+
if (n.length !== r) throw new Error("树父子关系存在循环");
|
|
189
|
+
return n;
|
|
190
|
+
}
|
|
191
|
+
function H(e, r, t, i) {
|
|
192
|
+
if (r.parentValues !== "leaf-aggregate") return;
|
|
193
|
+
const n = r.aggregates, o = /* @__PURE__ */ new Map();
|
|
194
|
+
for (const l of e) l.children.length && o.set(l, n.map((s) => S({ ...s, field: s.valueField ?? s.field })));
|
|
195
|
+
let f = 0;
|
|
196
|
+
for (const l of e)
|
|
197
|
+
if (!l.children.length)
|
|
198
|
+
for (let s = l.parent; s; s = s.parent) {
|
|
199
|
+
if (p(i), f += n.length, f > t.visits) throw new Error(`树聚合超出访问预算 ${t.visits}`);
|
|
200
|
+
for (const d of o.get(s)) d.add(l.row);
|
|
201
|
+
}
|
|
202
|
+
for (const [l, s] of o)
|
|
203
|
+
l.row = { ...l.row }, n.forEach((d, c) => {
|
|
204
|
+
l.row[d.field] = s[c].value();
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function B(e, r, t) {
|
|
208
|
+
if (W(r), p(t), !Array.isArray(e)) throw new Error("树数据应为节点数组");
|
|
209
|
+
const i = v(r), n = /* @__PURE__ */ new Map(), o = r.input === "flat" ? L(e, r, n, i, t) : P(e, r, n, i, t);
|
|
210
|
+
return z(o, n.size, i, t);
|
|
211
|
+
}
|
|
212
|
+
function ie(e, r, t) {
|
|
213
|
+
return B(e, r, t).map((i) => i.original);
|
|
214
|
+
}
|
|
215
|
+
function oe(e, r, t = {}) {
|
|
216
|
+
const i = B(e, r, t.signal);
|
|
217
|
+
if (I(r, t.computed?.fields), t.computed?.fields.length) {
|
|
218
|
+
const n = K(i.map((o) => o.row), { ...t.computed, signal: t.signal }).rows;
|
|
219
|
+
i.forEach((o, f) => {
|
|
220
|
+
o.row = n[f];
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return H(i, r, v(r), t.signal), { rows: i.map((n) => n.row), entries: i.map((n) => ({ row: n.row, original: n.original, key: n.key, depth: n.depth, hasChildren: !!n.children.length })), leaves: i.filter((n) => !n.children.length).map((n) => n.row) };
|
|
224
|
+
}
|
|
225
|
+
const X = /^#[0-9a-f]{6}$/i;
|
|
226
|
+
function q(e) {
|
|
227
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
228
|
+
const r = e;
|
|
229
|
+
return r.kind !== "colorScale" && r.kind !== "dataBar" || r.field !== void 0 && (typeof r.field != "string" || !r.field.trim()) || r.numeric !== void 0 && !["number", "decimal"].includes(r.numeric) || [r.min, r.max].some((t) => t !== void 0 && (typeof t != "number" || !Number.isFinite(t))) || r.min !== void 0 && r.max !== void 0 && r.min > r.max ? !1 : Object.entries(r).every(([t, i]) => !["color", "negativeColor", "lowColor", "highColor"].includes(t) || typeof i == "string" && X.test(i));
|
|
230
|
+
}
|
|
231
|
+
function k(e, r) {
|
|
232
|
+
if (typeof e == "number") return Number.isFinite(e) ? e : void 0;
|
|
233
|
+
if (r !== "decimal" || typeof e != "string" || e.length > 1024 || !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e)) return;
|
|
234
|
+
const t = Number(e);
|
|
235
|
+
return Number.isFinite(t) ? t : void 0;
|
|
236
|
+
}
|
|
237
|
+
function G(e, r, t) {
|
|
238
|
+
let i = "#";
|
|
239
|
+
for (const n of [1, 3, 5]) {
|
|
240
|
+
const o = parseInt(e.slice(n, n + 2), 16), f = parseInt(r.slice(n, n + 2), 16);
|
|
241
|
+
i += Math.round(o + (f - o) * t).toString(16).padStart(2, "0");
|
|
242
|
+
}
|
|
243
|
+
return i;
|
|
244
|
+
}
|
|
245
|
+
function b(e, r, t) {
|
|
246
|
+
if (r === t) return e < r ? 0 : e > t ? 1 : 0.5;
|
|
247
|
+
if (e <= r) return 0;
|
|
248
|
+
if (e >= t) return 1;
|
|
249
|
+
const i = t - r;
|
|
250
|
+
return Number.isFinite(i) ? (e - r) / i : (e / 2 - r / 2) / (t / 2 - r / 2);
|
|
251
|
+
}
|
|
252
|
+
function Q(e, r, t, i) {
|
|
253
|
+
const n = /* @__PURE__ */ new WeakMap();
|
|
254
|
+
return { apply(o, f) {
|
|
255
|
+
const l = k(f[r], e.numeric);
|
|
256
|
+
if (l === void 0) return;
|
|
257
|
+
if (e.kind === "dataBar") {
|
|
258
|
+
const w = Math.min(t, 0), y = Math.max(i, 0), E = b(0, w, y), M = w === y ? E : b(l, w, y);
|
|
259
|
+
o.dataBar = { start: Math.min(E, M), end: Math.max(E, M), color: l < 0 ? e.negativeColor ?? "#f3bcc3" : e.color ?? "#bad8fa" };
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const s = G(e.lowColor ?? "#f0f7ff", e.highColor ?? "#8bbcf1", b(l, t, i)), d = o.style ?? {}, c = n.get(d) ?? /* @__PURE__ */ new Map();
|
|
263
|
+
n.set(d, c);
|
|
264
|
+
let h = c.get(s);
|
|
265
|
+
h || (h = { ...d, backgroundColor: s }, c.set(s, h)), o.style = h;
|
|
266
|
+
} };
|
|
267
|
+
}
|
|
268
|
+
function O(e) {
|
|
269
|
+
try {
|
|
270
|
+
const r = Object.getPrototypeOf(e);
|
|
271
|
+
return (r === Object.prototype || r === null) && Reflect.ownKeys(e).every((t) => "value" in Object.getOwnPropertyDescriptor(e, t));
|
|
272
|
+
} catch {
|
|
273
|
+
return !1;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function U(e, r) {
|
|
277
|
+
try {
|
|
278
|
+
const t = Object.getOwnPropertyDescriptor(e, r);
|
|
279
|
+
return !!t && "value" in t;
|
|
280
|
+
} catch {
|
|
281
|
+
return !1;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function V(e, r) {
|
|
285
|
+
return JSON.stringify([e, r === "decimal" ? "decimal" : "number"]);
|
|
286
|
+
}
|
|
287
|
+
function Y(e) {
|
|
288
|
+
const r = /* @__PURE__ */ new Map();
|
|
289
|
+
for (const t of e) {
|
|
290
|
+
if (!O(t)) return /* @__PURE__ */ new Set();
|
|
291
|
+
const i = t.visual;
|
|
292
|
+
if (!i) continue;
|
|
293
|
+
if (typeof i != "object" || !O(i)) return /* @__PURE__ */ new Set();
|
|
294
|
+
const n = V(i.field ?? t.field, i.numeric);
|
|
295
|
+
r.set(n, (r.get(n) ?? 0) + 1);
|
|
296
|
+
}
|
|
297
|
+
return new Set([...r].filter(([, t]) => t > 1).map(([t]) => t));
|
|
298
|
+
}
|
|
299
|
+
function Z(e, r, t, i) {
|
|
300
|
+
let n = 1 / 0, o = -1 / 0, f = 0;
|
|
301
|
+
for (const l of e) {
|
|
302
|
+
(f++ & 1023) === 0 && F(i);
|
|
303
|
+
const s = k(l[r], t);
|
|
304
|
+
s !== void 0 && (n = Math.min(n, s), o = Math.max(o, s));
|
|
305
|
+
}
|
|
306
|
+
return { min: n, max: o, reusable: !1 };
|
|
307
|
+
}
|
|
308
|
+
function* ee(e, r, t, i, n, o) {
|
|
309
|
+
if (!o && !i) return Z(e, r, t, n);
|
|
310
|
+
let f = 1 / 0, l = -1 / 0, s = 0;
|
|
311
|
+
for (const d of e) {
|
|
312
|
+
(s++ & 1023) === 0 && F(n), i && !U(d, r) && (i = !1);
|
|
313
|
+
const c = k(d[r], t);
|
|
314
|
+
c !== void 0 && (f = Math.min(f, c), l = Math.max(l, c)), o && (s & 255) === 0 && (yield, F(n));
|
|
315
|
+
}
|
|
316
|
+
return { min: f, max: l, reusable: i };
|
|
317
|
+
}
|
|
318
|
+
function* se(e, r, t, i = !1) {
|
|
319
|
+
const n = [];
|
|
320
|
+
let o;
|
|
321
|
+
const f = /* @__PURE__ */ new Map();
|
|
322
|
+
for (const l of e) {
|
|
323
|
+
F(t);
|
|
324
|
+
const s = l.visual;
|
|
325
|
+
if (!s) {
|
|
326
|
+
n.push(void 0);
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (!q(s)) throw new TypeError("Invalid column visual rule");
|
|
330
|
+
const d = s.field ?? l.field;
|
|
331
|
+
let c;
|
|
332
|
+
if (s.min === void 0 || s.max === void 0) {
|
|
333
|
+
o ??= Y(e);
|
|
334
|
+
const y = V(d, s.numeric);
|
|
335
|
+
c = f.get(y), c || (c = yield* ee(r, d, s.numeric, o.has(y), t, i), c.reusable && f.set(y, c));
|
|
336
|
+
}
|
|
337
|
+
let h = s.min ?? c.min, w = s.max ?? c.max;
|
|
338
|
+
if (!Number.isFinite(h) || !Number.isFinite(w)) {
|
|
339
|
+
n.push(void 0);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
h > w && (s.min !== void 0 ? w = h : h = w), n.push(Q(s, d, h, w));
|
|
343
|
+
}
|
|
344
|
+
return n;
|
|
345
|
+
}
|
|
346
|
+
function F(e) {
|
|
347
|
+
if (e?.aborted) throw e.reason ?? new DOMException("Aborted", "AbortError");
|
|
348
|
+
}
|
|
349
|
+
const re = 1e7;
|
|
350
|
+
function fe(e) {
|
|
351
|
+
const r = JSON.stringify(e, null, 2);
|
|
352
|
+
if (r.length > re)
|
|
353
|
+
throw new RangeError("模板 JSON 超过 1000 万字符的导出/导入上限");
|
|
354
|
+
return r;
|
|
355
|
+
}
|
|
356
|
+
export {
|
|
357
|
+
re as M,
|
|
358
|
+
D as T,
|
|
359
|
+
W as a,
|
|
360
|
+
ne as b,
|
|
361
|
+
oe as c,
|
|
362
|
+
I as d,
|
|
363
|
+
ie as f,
|
|
364
|
+
se as i,
|
|
365
|
+
fe as s,
|
|
366
|
+
q as v
|
|
367
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const T=require("./computed-8nFyVnok.cjs");function u(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function a(e,r,t){typeof e=="string"?t.push({field:e,path:r}):Array.isArray(e)&&e.forEach((i,n)=>a(i,`${r}[${n}]`,t))}function m(e,r,t){if(Array.isArray(e)){e.forEach((i,n)=>m(i,`${r}[${n}]`,t));return}if(u(e))for(const[i,n]of Object.entries(e))["field","weightField"].includes(i)?a(n,`${r}.${i}`,t):i!=="value"&&i!=="style"&&m(n,`${r}.${i}`,t)}function $(e,r,t){Array.isArray(e)&&e.forEach((i,n)=>{if(!u(i))return;typeof i.field=="string"&&i.valueField!==void 0&&i.valueField!==i.field&&t.summaries.add(i.field);const o=i.valueField===void 0?"field":"valueField";a(i[o],`${r}[${n}].${o}`,t.fields),i.valueField!==void 0&&i.valueField===i.field&&a(i.field,`${r}[${n}].field`,t.fields),a(i.weightField,`${r}[${n}].weightField`,t.fields)})}function J(e,r,t){for(const n of["rowKey","revisionField","sourceTokenField"])a(e[n],`${r}.${n}`,t.fields);if(!e.matrix&&Array.isArray(e.columns)&&e.columns.forEach((n,o)=>{u(n)&&(typeof n.field=="string"&&t.fields.push({field:n.field,path:`${r}.columns[${o}].field`,summary:!0}),m(n.rules,`${r}.columns[${o}].rules`,t.fields),m(n.visibleWhen,`${r}.columns[${o}].visibleWhen`,t.fields))}),m(e.rowVisibleWhen,`${r}.rowVisibleWhen`,t.fields),Array.isArray(e.computed)&&e.computed.forEach((n,o)=>{u(n)&&(typeof n.field=="string"&&t.generated.add(n.field),m(n.expression,`${r}.computed[${o}].expression`,t.fields),a(n.dependsOn,`${r}.computed[${o}].dependsOn`,t.fields),a(n.groupBy,`${r}.computed[${o}].groupBy`,t.fields))}),(Array.isArray(e.groups)?e.groups.map((n,o)=>({group:n,path:`${r}.groups[${o}]`})):e.groupBy?[{group:e.groupBy,path:`${r}.groupBy`}]:[]).forEach(({group:n,path:o})=>{u(n)&&(a(n.field,`${o}.field`,t.fields),a(n.subtotal,`${o}.subtotal`,t.fields),$(n.aggregates,`${o}.aggregates`,t))}),u(e.grandTotal)&&(a(e.grandTotal.fields,`${r}.grandTotal.fields`,t.fields),$(e.grandTotal.aggregates,`${r}.grandTotal.aggregates`,t)),u(e.matrix)&&(a(e.matrix.rowFields,`${r}.matrix.rowFields`,t.fields),a(e.matrix.columnFields,`${r}.matrix.columnFields`,t.fields),$(e.matrix.measures,`${r}.matrix.measures`,t)),u(e.tree)){for(const n of["idField","parentField","labelField"])a(e.tree[n],`${r}.tree.${n}`,t.fields);$(e.tree.aggregates,`${r}.tree.aggregates`,t)}u(e.detail)&&a(e.detail.parentKey,`${r}.detail.parentKey`,t.fields)}function L(e){const r=[],t=e.repeat,i=t?{dataset:t.dataset,path:"$.template.repeat",fields:[],generated:new Set,summaries:new Set}:void 0;i&&t&&(a(t.rowKey,"$.template.repeat.rowKey",i.fields),typeof t.copies=="object"&&a(t.copies.field,"$.template.repeat.copies.field",i.fields),r.push(i));function n(o,f){if(Array.isArray(o)){o.forEach((l,s)=>n(l,`${f}[${s}]`));return}if(u(o)){if(i&&u(o.binding)&&a(o.binding.field,`${f}.binding.field`,i.fields),u(o.chartBinding)&&typeof o.chartBinding.dataset=="string"){const l=`${f}.chartBinding`,s=o.chartBinding,d={dataset:s.dataset,path:l,fields:[],generated:new Set,summaries:new Set};a(s.categoryField,`${l}.categoryField`,d.fields),m(s.measures,`${l}.measures`,d.fields),r.push(d)}if(typeof o.dataset=="string"&&Array.isArray(o.columns)){const l={dataset:o.dataset,path:f,fields:[],generated:new Set,summaries:new Set};J(o,f,l),typeof o.foreignKey=="string"&&a(o.foreignKey,`${f}.foreignKey`,l.fields),r.push(l)}for(const[l,s]of Object.entries(o))n(s,`${f}.${l}`)}}return n(e,"$.template"),r}class k extends Error{constructor(r){super(`树节点超出行数预算 ${r}`),this.limit=r,this.code="tree-row-limit",this.name="TreeRowLimitError"}}function A(e,r,t,i){const n=e??r;if(!Number.isInteger(n)||n<1||n>t)throw new Error(`${i}应为 1–${t} 的整数`);return n}function v(e){return{rows:A(e.maxRows,1e5,1e6,"树行数预算"),depth:A(e.maxDepth,64,256,"树深度预算"),visits:A(e.maxAggregationVisits,1e6,1e7,"树聚合访问预算")}}function N(e){return typeof e=="string"&&!!e.trim()}function g(e){return N(e)&&!["__proto__","prototype","constructor"].includes(e)}function C(e){if(N(e)||typeof e=="number"&&Number.isFinite(e))return e;throw new Error("树节点业务键应为非空字符串或有限数字")}function x(e){return JSON.stringify([typeof e,e])}function V(e){return[e.idField,...e.input==="flat"?[e.parentField??""]:[e.childrenField??"children"]]}function j(e,r){const t=V(e);if(r?.some(i=>i.scope&&i.scope!=="row"||t.includes(i.field)))throw new Error("树形布局仅支持不覆盖结构键的当前行计算")}function p(e){if(!e?.aborted)return;const r=new Error("树报表处理已取消");throw r.name="AbortError",r}function P(e){const r=e.aggregates??[];if(!Array.isArray(r)||r.length>32)throw new Error("树聚合最多 32 项");if(e.parentValues!=="leaf-aggregate"&&r.length)throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");if(e.parentValues==="leaf-aggregate"&&!r.length)throw new Error("叶子聚合策略至少需要一个聚合字段");const t=new Set;for(const i of r){if(!i||!g(i.field)||t.has(i.field))throw new Error("树聚合输出字段应安全、非空且唯一");for(const n of[i.valueField,i.weightField])if(n!==void 0&&!g(n))throw new Error("树聚合来源字段应安全且非空");if([...V(e),e.labelField].includes(i.field))throw new Error("树聚合不能覆盖结构键或标签字段");t.add(i.field),T.createAggregateAccumulator({...i,field:i.valueField??i.field})}}function W(e){if(!g(e.idField)||!g(e.labelField))throw new Error("树需要安全的业务键和标签字段");if(e.input==="flat"&&(!g(e.parentField)||e.parentField===e.idField))throw new Error("扁平树需要独立的父键字段");if(e.childrenField!==void 0&&!g(e.childrenField))throw new Error("子节点字段应安全且非空");if(e.input==="nested"&&[e.idField,e.labelField].includes(e.childrenField??"children"))throw new Error("子节点字段不能覆盖业务键或标签字段")}function B(e){if(!e||typeof e!="object"||!["flat","nested"].includes(e.input))throw new Error("树输入应为 flat 或 nested");if(W(e),e.orphan!==void 0&&!["error","root"].includes(e.orphan))throw new Error("树孤儿策略应为 error 或 root");if(e.parentValues!==void 0&&!["source","leaf-aggregate"].includes(e.parentValues))throw new Error("未知树父级取值策略");if(e.indentMm!==void 0&&(!Number.isFinite(e.indentMm)||e.indentMm<0||e.indentMm>20))throw new Error("树每级缩进应为 0–20 mm");v(e),P(e)}function R(e,r,t,i){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("树节点应为对象");if(t.size>=i.rows)throw new k(i.rows);const n=C(e[r.idField]),o=x(n);if(t.has(o))throw new Error(`树节点业务键重复:${String(n)}`);const f={original:e,row:e,key:n,depth:0,children:[]};return t.set(o,f),f}function z(e,r,t,i,n){for(const f of e)p(n),R(f,r,t,i);const o=[];for(const f of t.values()){p(n);const l=f.row[r.parentField];if(l==null){o.push(f);continue}const s=t.get(x(C(l)));if(!s){if(r.orphan!=="root")throw new Error(`树节点 ${String(f.key)} 的父节点不存在`);o.push(f);continue}if(s===f)throw new Error("树节点不能以自身为父节点");f.parent=s,s.children.push(f)}return o}function H(e,r,t,i,n){const o=[],f=[{rows:e,next:0}];for(;f.length;){p(n);const l=f[f.length-1];if(l.next>=l.rows.length){f.pop();continue}const s=R(l.rows[l.next++],r,t,i);if(s.parent=l.parent,s.depth=f.length-1,f.length>i.depth)throw new Error(`树节点超出深度预算 ${i.depth}`);(l.parent?.children??o).push(s);const d=s.row[r.childrenField??"children"];if(d!=null){if(!Array.isArray(d))throw new Error("嵌套树 children 字段应为数组");d.length&&f.push({rows:d,next:0,parent:s})}}return o}function X(e,r,t,i){const n=[],o=[{nodes:e,next:0}];for(;o.length;){p(i);const f=o[o.length-1];if(f.next>=f.nodes.length){o.pop();continue}if(o.length>t.depth)throw new Error(`树节点超出深度预算 ${t.depth}`);const l=f.nodes[f.next++];l.depth=o.length-1,n.push(l),l.children.length&&o.push({nodes:l.children,next:0})}if(n.length!==r)throw new Error("树父子关系存在循环");return n}function q(e,r,t,i){if(r.parentValues!=="leaf-aggregate")return;const n=r.aggregates,o=new Map;for(const l of e)l.children.length&&o.set(l,n.map(s=>T.createAggregateAccumulator({...s,field:s.valueField??s.field})));let f=0;for(const l of e)if(!l.children.length)for(let s=l.parent;s;s=s.parent){if(p(i),f+=n.length,f>t.visits)throw new Error(`树聚合超出访问预算 ${t.visits}`);for(const d of o.get(s))d.add(l.row)}for(const[l,s]of o)l.row={...l.row},n.forEach((d,c)=>{l.row[d.field]=s[c].value()})}function K(e,r,t){if(B(r),p(t),!Array.isArray(e))throw new Error("树数据应为节点数组");const i=v(r),n=new Map,o=r.input==="flat"?z(e,r,n,i,t):H(e,r,n,i,t);return X(o,n.size,i,t)}function G(e,r,t){return K(e,r,t).map(i=>i.original)}function Q(e,r,t={}){const i=K(e,r,t.signal);if(j(r,t.computed?.fields),t.computed?.fields.length){const n=T.computeDataset(i.map(o=>o.row),{...t.computed,signal:t.signal}).rows;i.forEach((o,f)=>{o.row=n[f]})}return q(i,r,v(r),t.signal),{rows:i.map(n=>n.row),entries:i.map(n=>({row:n.row,original:n.original,key:n.key,depth:n.depth,hasChildren:!!n.children.length})),leaves:i.filter(n=>!n.children.length).map(n=>n.row)}}const U=/^#[0-9a-f]{6}$/i;function D(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return r.kind!=="colorScale"&&r.kind!=="dataBar"||r.field!==void 0&&(typeof r.field!="string"||!r.field.trim())||r.numeric!==void 0&&!["number","decimal"].includes(r.numeric)||[r.min,r.max].some(t=>t!==void 0&&(typeof t!="number"||!Number.isFinite(t)))||r.min!==void 0&&r.max!==void 0&&r.min>r.max?!1:Object.entries(r).every(([t,i])=>!["color","negativeColor","lowColor","highColor"].includes(t)||typeof i=="string"&&U.test(i))}function M(e,r){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(r!=="decimal"||typeof e!="string"||e.length>1024||!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e))return;const t=Number(e);return Number.isFinite(t)?t:void 0}function Y(e,r,t){let i="#";for(const n of[1,3,5]){const o=parseInt(e.slice(n,n+2),16),f=parseInt(r.slice(n,n+2),16);i+=Math.round(o+(f-o)*t).toString(16).padStart(2,"0")}return i}function b(e,r,t){if(r===t)return e<r?0:e>t?1:.5;if(e<=r)return 0;if(e>=t)return 1;const i=t-r;return Number.isFinite(i)?(e-r)/i:(e/2-r/2)/(t/2-r/2)}function Z(e,r,t,i){const n=new WeakMap;return{apply(o,f){const l=M(f[r],e.numeric);if(l===void 0)return;if(e.kind==="dataBar"){const w=Math.min(t,0),y=Math.max(i,0),E=b(0,w,y),O=w===y?E:b(l,w,y);o.dataBar={start:Math.min(E,O),end:Math.max(E,O),color:l<0?e.negativeColor??"#f3bcc3":e.color??"#bad8fa"};return}const s=Y(e.lowColor??"#f0f7ff",e.highColor??"#8bbcf1",b(l,t,i)),d=o.style??{},c=n.get(d)??new Map;n.set(d,c);let h=c.get(s);h||(h={...d,backgroundColor:s},c.set(s,h)),o.style=h}}}function S(e){try{const r=Object.getPrototypeOf(e);return(r===Object.prototype||r===null)&&Reflect.ownKeys(e).every(t=>"value"in Object.getOwnPropertyDescriptor(e,t))}catch{return!1}}function ee(e,r){try{const t=Object.getOwnPropertyDescriptor(e,r);return!!t&&"value"in t}catch{return!1}}function I(e,r){return JSON.stringify([e,r==="decimal"?"decimal":"number"])}function re(e){const r=new Map;for(const t of e){if(!S(t))return new Set;const i=t.visual;if(!i)continue;if(typeof i!="object"||!S(i))return new Set;const n=I(i.field??t.field,i.numeric);r.set(n,(r.get(n)??0)+1)}return new Set([...r].filter(([,t])=>t>1).map(([t])=>t))}function te(e,r,t,i){let n=1/0,o=-1/0,f=0;for(const l of e){(f++&1023)===0&&F(i);const s=M(l[r],t);s!==void 0&&(n=Math.min(n,s),o=Math.max(o,s))}return{min:n,max:o,reusable:!1}}function*ne(e,r,t,i,n,o){if(!o&&!i)return te(e,r,t,n);let f=1/0,l=-1/0,s=0;for(const d of e){(s++&1023)===0&&F(n),i&&!ee(d,r)&&(i=!1);const c=M(d[r],t);c!==void 0&&(f=Math.min(f,c),l=Math.max(l,c)),o&&(s&255)===0&&(yield,F(n))}return{min:f,max:l,reusable:i}}function*ie(e,r,t,i=!1){const n=[];let o;const f=new Map;for(const l of e){F(t);const s=l.visual;if(!s){n.push(void 0);continue}if(!D(s))throw new TypeError("Invalid column visual rule");const d=s.field??l.field;let c;if(s.min===void 0||s.max===void 0){o??=re(e);const y=I(d,s.numeric);c=f.get(y),c||(c=yield*ne(r,d,s.numeric,o.has(y),t,i),c.reusable&&f.set(y,c))}let h=s.min??c.min,w=s.max??c.max;if(!Number.isFinite(h)||!Number.isFinite(w)){n.push(void 0);continue}h>w&&(s.min!==void 0?w=h:h=w),n.push(Z(s,d,h,w))}return n}function F(e){if(e?.aborted)throw e.reason??new DOMException("Aborted","AbortError")}const _=1e7;function oe(e){const r=JSON.stringify(e,null,2);if(r.length>_)throw new RangeError("模板 JSON 超过 1000 万字符的导出/导入上限");return r}exports.MAX_TEMPLATE_JSON_CHARACTERS=_;exports.TreeRowLimitError=k;exports.collectTemplateDatasetBindings=L;exports.createTreeTable=Q;exports.flattenTreeInput=G;exports.iterateColumnVisualResolvers=ie;exports.stringifyValidatedTemplate=oe;exports.validColumnVisual=D;exports.validateTreeComputed=j;exports.validateTreeOptions=B;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const w=require("./diagnostic-collector-
|
|
1
|
+
"use strict";const w=require("./diagnostic-collector-DwMJWEHo.cjs"),M=/[\u3000-\u9fff\uff00-\uffef]/,g=/[ \n\u3000-\u9fff\uff00-\uffef]/,s=new Uint8Array(128);{for(const t of"iljtf.,:;'`|!()[]")s[t.charCodeAt(0)]=1;for(const t of"mwMW@")s[t.charCodeAt(0)]=2;for(let t=48;t<=57;t++)s[t]=3;for(let t=65;t<=90;t++)s[t]=4;s[32]=5}const p=[.54,.26,.95,.59,.67,.3];function d(t){const e=t.charCodeAt(0);return e<128?p[s[e]]:M.test(t)?1:/[A-Z]/.test(t)?.67:.54}const o={measureMm(t,e){const{fontSizePt:i,bold:c=!1,letterSpacingPt:f=0}=e,r=25.4/72;let n=0,h=0;for(const a of t)n+=d(a),h++;return c&&(n*=1.04),(n*i+f*Math.max(0,h-1))*r}};function A(){return o}function T(t,e){return o.measureMm(t,e)}function x(t){let e;return{measureMm(i,c){if(e===void 0&&(e=t()),!e)return o.measureMm(i,c);const f=c.fontSizePt*96/72;e.font=`${c.italic?"italic ":""}${c.bold?"bold ":""}${f}px ${c.fontFamily??w.DEFAULT_FONT_FAMILY}`,"letterSpacing"in e&&(e.letterSpacing="0px");const r=(c.letterSpacingPt??0)*Math.max(0,Array.from(i).length-1);return e.measureText(i).width*25.4/96+r*25.4/72}}}function S(t,e,i){if(!g.test(t))return[{text:t,widthMm:i.measureMm(t,e),cjk:!1}];const c=[];let f="";const r=()=>{f&&(c.push({text:f,widthMm:i.measureMm(f,e),cjk:!1}),f="")};for(const n of t){if(n===`
|
|
2
2
|
`){r(),c.push({text:`
|
|
3
3
|
`,widthMm:0,cjk:!1,br:!0});continue}if(n===" "){r(),c.push({text:n,widthMm:i.measureMm(n,e),cjk:!1,space:!0});continue}if(M.test(n)){r(),c.push({text:n,widthMm:i.measureMm(n,e),cjk:!0});continue}f+=n}return r(),c}function C(t,e,i,c=o){if(!t)return[""];t=t.replace(/\r\n?/g,`
|
|
4
4
|
`);const f=[];let r="",n=0;const h=(i.letterSpacingPt??0)*25.4/72,a=()=>{f.push(r),r="",n=0};for(const u of S(t,i,c)){if(u.br){a();continue}const m=r.length>0?h:0;if(n+m+u.widthMm<=e){r+=u.text,n+=m+u.widthMm;continue}if(u.space){a();continue}if(u.cjk){r.length>0&&a(),r=u.text,n=u.widthMm;continue}if(r.length>0&&a(),u.widthMm<=e){r=u.text,n=u.widthMm;continue}for(const l of u.text)c.measureMm(r+l,i)>e&&r.length>0&&a(),r+=l,n=c.measureMm(r,i)}return a(),f}exports.charWidthEm=d;exports.createCanvasMeasurer=x;exports.createHeuristicMeasurer=A;exports.heuristicMeasurer=o;exports.measureTextMm=T;exports.wrapText=C;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as d } from "./diagnostic-collector-
|
|
1
|
+
import { D as d } from "./diagnostic-collector-CZ8DV6wA.js";
|
|
2
2
|
const M = /[\u3000-\u9fff\uff00-\uffef]/, w = /[ \n\u3000-\u9fff\uff00-\uffef]/, s = new Uint8Array(128);
|
|
3
3
|
{
|
|
4
4
|
for (const t of "iljtf.,:;'`|!()[]") s[t.charCodeAt(0)] = 1;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { defineComponent as w, openBlock as f, createElementBlock as g, createElementVNode as x, shallowRef as b, watch as H, onBeforeUnmount as _ } from "vue";
|
|
2
|
+
const B = ["width", "height"], $ = ["d"], V = /* @__PURE__ */ w({
|
|
3
|
+
__name: "ReportIcon",
|
|
4
|
+
props: {
|
|
5
|
+
name: {},
|
|
6
|
+
size: {}
|
|
7
|
+
},
|
|
8
|
+
setup(e) {
|
|
9
|
+
const t = {
|
|
10
|
+
search: "m15.5 15.5 4.5 4.5M18 10.5a7.5 7.5 0 1 1-15 0 7.5 7.5 0 0 1 15 0Z",
|
|
11
|
+
close: "m6 6 12 12M6 18 18 6",
|
|
12
|
+
"chevron-down": "m6 9 6 6 6-6",
|
|
13
|
+
"chevron-up": "m6 15 6-6 6 6",
|
|
14
|
+
"chevron-left": "m15 6-6 6 6 6",
|
|
15
|
+
"chevron-right": "m9 6 6 6-6 6",
|
|
16
|
+
download: "M12 3v12m-5-5 5 5 5-5M4 16v4h16v-4",
|
|
17
|
+
upload: "M12 16V4m-5 5 5-5 5 5M4 16v4h16v-4",
|
|
18
|
+
print: "M7 8V3h10v5M7 17H4V9h16v8h-3M7 14h10v7H7v-7m10-2h.01",
|
|
19
|
+
external: "M14 3h7v7m0-7L10 14M11 3H3v18h18v-8",
|
|
20
|
+
settings: "M3 6h18M3 12h18M3 18h18M8 3v6m8 0v6M9 15v6",
|
|
21
|
+
grid: "M3 3h18v18H3V3m6 0v18m6-18v18M3 9h18M3 15h18",
|
|
22
|
+
fit: "M8 5H3v14h5m8-14h5v14h-5M7 12h10m-7-3-3 3 3 3m4-6 3 3-3 3",
|
|
23
|
+
columns: "M3 4h18v16H3V4m6 0v16m6-16v16M3 9h18",
|
|
24
|
+
"arrow-right": "M4 12h16m-6-6 6 6-6 6",
|
|
25
|
+
file: "M14 3H5v18h14V8l-5-5Zm0 0v5h5M8 12h8m-8 4h6"
|
|
26
|
+
};
|
|
27
|
+
return (n, i) => (f(), g("svg", {
|
|
28
|
+
width: e.size ?? 16,
|
|
29
|
+
height: e.size ?? 16,
|
|
30
|
+
viewBox: "0 0 24 24",
|
|
31
|
+
fill: "none",
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
focusable: "false"
|
|
34
|
+
}, [
|
|
35
|
+
x("path", {
|
|
36
|
+
d: t[e.name],
|
|
37
|
+
stroke: "currentColor",
|
|
38
|
+
"stroke-width": "1.65",
|
|
39
|
+
"stroke-linecap": "round",
|
|
40
|
+
"stroke-linejoin": "round"
|
|
41
|
+
}, null, 8, $)
|
|
42
|
+
], 8, B));
|
|
43
|
+
}
|
|
44
|
+
}), E = (e, t) => {
|
|
45
|
+
const n = e.__vccOpts || e;
|
|
46
|
+
for (const [i, o] of t)
|
|
47
|
+
n[i] = o;
|
|
48
|
+
return n;
|
|
49
|
+
};
|
|
50
|
+
function k(e, t) {
|
|
51
|
+
const n = Math.max(0, t?.height ? t.top : 0) + 8, i = Math.min(window.innerHeight, t?.height ? t.bottom : window.innerHeight) - 8, o = i - e.bottom - 7, h = e.top - n - 7;
|
|
52
|
+
return Math.max(o, h) < 160 ? { top: `${n - e.top}px`, bottom: "auto", maxHeight: `${Math.max(24, i - n)}px` } : o >= h ? { top: `${e.height + 7}px`, bottom: "auto", maxHeight: `${o}px` } : { top: "auto", bottom: `${e.height + 7}px`, maxHeight: `${h}px` };
|
|
53
|
+
}
|
|
54
|
+
function R(e, t, n = 400) {
|
|
55
|
+
const i = b({});
|
|
56
|
+
let o = () => {
|
|
57
|
+
};
|
|
58
|
+
return H(e, (h) => {
|
|
59
|
+
if (o(), o = () => {
|
|
60
|
+
}, !h || !t.value || typeof window > "u") {
|
|
61
|
+
i.value = {};
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const c = t.value, m = c.closest(".mach-report-preview,.mr-designer,.mr-label-studio");
|
|
65
|
+
function s() {
|
|
66
|
+
const r = c.getBoundingClientRect(), a = m?.getBoundingClientRect(), u = Math.max(0, a?.width ? a.left : 0) + 8, p = Math.min(window.innerWidth, a?.width ? a.right : window.innerWidth) - 8, d = Math.min(n, Math.max(0, p - u)), M = Math.max(u, Math.min(r.right - d, p - d));
|
|
67
|
+
i.value = { width: `${d}px`, left: `${M - r.left}px`, right: "auto", ...k(r, a) };
|
|
68
|
+
}
|
|
69
|
+
s();
|
|
70
|
+
const v = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(s);
|
|
71
|
+
v?.observe(c), m && v?.observe(m);
|
|
72
|
+
function l(r) {
|
|
73
|
+
(!(r.target instanceof Node) || !c.contains(r.target)) && s();
|
|
74
|
+
}
|
|
75
|
+
window.addEventListener("resize", s), window.addEventListener("scroll", l, { capture: !0, passive: !0 }), o = () => {
|
|
76
|
+
v?.disconnect(), window.removeEventListener("resize", s), window.removeEventListener("scroll", l, !0);
|
|
77
|
+
};
|
|
78
|
+
}, { flush: "post" }), _(() => o()), i;
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
E as _,
|
|
82
|
+
V as a,
|
|
83
|
+
R as u
|
|
84
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("vue"),f=["width","height"],g=["d"],x=r.defineComponent({__name:"ReportIcon",props:{name:{},size:{}},setup(e){const t={search:"m15.5 15.5 4.5 4.5M18 10.5a7.5 7.5 0 1 1-15 0 7.5 7.5 0 0 1 15 0Z",close:"m6 6 12 12M6 18 18 6","chevron-down":"m6 9 6 6 6-6","chevron-up":"m6 15 6-6 6 6","chevron-left":"m15 6-6 6 6 6","chevron-right":"m9 6 6 6-6 6",download:"M12 3v12m-5-5 5 5 5-5M4 16v4h16v-4",upload:"M12 16V4m-5 5 5-5 5 5M4 16v4h16v-4",print:"M7 8V3h10v5M7 17H4V9h16v8h-3M7 14h10v7H7v-7m10-2h.01",external:"M14 3h7v7m0-7L10 14M11 3H3v18h18v-8",settings:"M3 6h18M3 12h18M3 18h18M8 3v6m8 0v6M9 15v6",grid:"M3 3h18v18H3V3m6 0v18m6-18v18M3 9h18M3 15h18",fit:"M8 5H3v14h5m8-14h5v14h-5M7 12h10m-7-3-3 3 3 3m4-6 3 3-3 3",columns:"M3 4h18v16H3V4m6 0v16m6-16v16M3 9h18","arrow-right":"M4 12h16m-6-6 6 6-6 6",file:"M14 3H5v18h14V8l-5-5Zm0 0v5h5M8 12h8m-8 4h6"};return(n,i)=>(r.openBlock(),r.createElementBlock("svg",{width:e.size??16,height:e.size??16,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false"},[r.createElementVNode("path",{d:t[e.name],stroke:"currentColor","stroke-width":"1.65","stroke-linecap":"round","stroke-linejoin":"round"},null,8,g)],8,f))}}),b=(e,t)=>{const n=e.__vccOpts||e;for(const[i,o]of t)n[i]=o;return n};function _(e,t){const n=Math.max(0,t?.height?t.top:0)+8,i=Math.min(window.innerHeight,t?.height?t.bottom:window.innerHeight)-8,o=i-e.bottom-7,s=e.top-n-7;return Math.max(o,s)<160?{top:`${n-e.top}px`,bottom:"auto",maxHeight:`${Math.max(24,i-n)}px`}:o>=s?{top:`${e.height+7}px`,bottom:"auto",maxHeight:`${o}px`}:{top:"auto",bottom:`${e.height+7}px`,maxHeight:`${s}px`}}function H(e,t,n=400){const i=r.shallowRef({});let o=()=>{};return r.watch(e,s=>{if(o(),o=()=>{},!s||!t.value||typeof window>"u"){i.value={};return}const m=t.value,v=m.closest(".mach-report-preview,.mr-designer,.mr-label-studio");function a(){const h=m.getBoundingClientRect(),c=v?.getBoundingClientRect(),p=Math.max(0,c?.width?c.left:0)+8,M=Math.min(window.innerWidth,c?.width?c.right:window.innerWidth)-8,u=Math.min(n,Math.max(0,M-p)),w=Math.max(p,Math.min(h.right-u,M-u));i.value={width:`${u}px`,left:`${w-h.left}px`,right:"auto",..._(h,c)}}a();const d=typeof ResizeObserver>"u"?void 0:new ResizeObserver(a);d?.observe(m),v&&d?.observe(v);function l(h){(!(h.target instanceof Node)||!m.contains(h.target))&&a()}window.addEventListener("resize",a),window.addEventListener("scroll",l,{capture:!0,passive:!0}),o=()=>{d?.disconnect(),window.removeEventListener("resize",a),window.removeEventListener("scroll",l,!0)}},{flush:"post"}),r.onBeforeUnmount(()=>o()),i}exports._export_sfc=b;exports._sfc_main=x;exports.usePopoverBounds=H;
|
package/dist/vue-async.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./plugin-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./plugin-BFBLxfsq.cjs");function i(){return Promise.resolve().then(()=>require("./ReportPreview-s7c2nrfo.cjs")).then(e=>e.ReportPreview$1)}const t={install(e,o={}){r.machReportPlugin.install(e,o)}};exports.MachReportPreview=r.MachReportPreview;exports.default=t;exports.machReportAsyncPlugin=t;exports.preloadMachReport=i;
|
package/dist/vue-async.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { m as o } from "./plugin-
|
|
2
|
-
import { M as l } from "./plugin-
|
|
1
|
+
import { m as o } from "./plugin-BnRcXQzg.js";
|
|
2
|
+
import { M as l } from "./plugin-BnRcXQzg.js";
|
|
3
3
|
function a() {
|
|
4
|
-
return import("./ReportPreview-
|
|
4
|
+
return import("./ReportPreview-DJqt40zA.js").then((t) => t.y);
|
|
5
5
|
}
|
|
6
6
|
const n = {
|
|
7
7
|
install(t, r = {}) {
|