@agile-team/mach-report 2.23.0 → 2.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/README.md +9 -2
  2. package/dist/ExcelBindingWizard-BV12hGiK.cjs +1 -0
  3. package/dist/ExcelBindingWizard-Cy_lPjWV.js +1486 -0
  4. package/dist/ParamEditor-DenKjvKu.cjs +1 -0
  5. package/dist/ParamEditor-PyOqHzzw.js +750 -0
  6. package/dist/ReportBatchPanel-8EFtMrKk.js +351 -0
  7. package/dist/ReportBatchPanel-pQ6d0yqJ.cjs +1 -0
  8. package/dist/ReportLabelStudio-B_KF3Zc_.cjs +1 -0
  9. package/dist/ReportLabelStudio-HUeo2TsU.js +784 -0
  10. package/dist/ReportParamPanel-8xR85nz-.cjs +1 -0
  11. package/dist/{ReportParamPanel-Dgmqro1Y.js → ReportParamPanel-DA-YpkvC.js} +342 -307
  12. package/dist/ReportPreview-CyUXJSVX.cjs +6 -0
  13. package/dist/ReportPreview-_wTJnsG1.js +7120 -0
  14. package/dist/ReportTemplateLibrary-CjArKxRG.cjs +1 -0
  15. package/dist/ReportTemplateLibrary-DH8jl9IF.js +312 -0
  16. package/dist/RuleEditor-Bmj98oC4.cjs +1 -0
  17. package/dist/RuleEditor-GDydlEHz.js +2354 -0
  18. package/dist/TemplateOutlinePanel-B554_qk1.cjs +1 -0
  19. package/dist/TemplateOutlinePanel-DjPqzU9h.js +97 -0
  20. package/dist/TemplateReusePanel-D0628OYc.cjs +1 -0
  21. package/dist/TemplateReusePanel-DtYbCN7U.js +389 -0
  22. package/dist/TemplateReviewPanel-CSwvCz3f.cjs +1 -0
  23. package/dist/TemplateReviewPanel-D_FR4ISq.js +602 -0
  24. package/dist/artifact-integrity.json +94 -94
  25. package/dist/assets-B4AJIOTB.cjs +1 -0
  26. package/dist/assets-D0FbszhB.js +137 -0
  27. package/dist/{auto-CTIJ6PnR.js → auto-BksreoKc.js} +5 -5
  28. package/dist/auto-C3mGqzJ8.cjs +1 -0
  29. package/dist/capabilities-CTwlcl8q.cjs +1 -0
  30. package/dist/capabilities-lqDEZSq5.js +121 -0
  31. package/dist/data-bar-2NLRzOCQ.cjs +1 -0
  32. package/dist/{data-bar-IkI6VvMQ.js → data-bar-BnGtnJ82.js} +1 -1
  33. package/dist/designer-BNf7NWd6.js +7589 -0
  34. package/dist/designer-DWnZZ_ej.cjs +2 -0
  35. package/dist/designer.cjs +1 -1
  36. package/dist/designer.d.cts +144 -4
  37. package/dist/designer.d.ts +144 -4
  38. package/dist/designer.js +6 -6
  39. package/dist/diagnostic-collector-1sqd7DQP.js +355 -0
  40. package/dist/diagnostic-collector-D3rlvxm3.cjs +1 -0
  41. package/dist/{dom-JWrchIre.js → dom-C90cTM6Y.js} +4 -4
  42. package/dist/dom-CxOkm_Sy.cjs +1 -0
  43. package/dist/{encoding-BefcaHdp.cjs → encoding-CkziAnZI.cjs} +1 -1
  44. package/dist/{encoding-CL6rXEkR.js → encoding-DSc9zv2F.js} +2 -2
  45. package/dist/{font-loader-Ga51c2VC.cjs → font-loader-D-znWNWS.cjs} +1 -1
  46. package/dist/{font-loader-BT5baV-o.js → font-loader-i7lZbqH_.js} +1 -1
  47. package/dist/{grid-strokes-EoY66L2f.js → grid-strokes-BPiV1WHe.js} +1 -1
  48. package/dist/grid-strokes-DYf-6DMl.cjs +1 -0
  49. package/dist/index.cjs +5 -5
  50. package/dist/index.d.cts +46 -7
  51. package/dist/index.d.ts +46 -7
  52. package/dist/index.js +69 -68
  53. package/dist/{json-snapshot-OqkPyUk5.js → json-snapshot-BJWZNryO.js} +919 -791
  54. package/dist/json-snapshot-C7QZrRBf.cjs +2 -0
  55. package/dist/{pdf-aobetCsy.js → pdf-0_5XiTCx.js} +2499 -2492
  56. package/dist/{pdf-HiEeXe9H.cjs → pdf-DWuq6uxx.cjs} +31 -31
  57. package/dist/pdf.cjs +1 -1
  58. package/dist/pdf.d.cts +18 -0
  59. package/dist/pdf.d.ts +18 -0
  60. package/dist/pdf.js +2 -2
  61. package/dist/{plugin-DeYYAL6F.js → plugin-B1ydqEmS.js} +1 -1
  62. package/dist/{plugin-BFANt-i8.cjs → plugin-BQBz2vLG.cjs} +1 -1
  63. package/dist/prefill-2p9wrpn9.cjs +1 -0
  64. package/dist/{prefill-Dk4C6S5R.js → prefill-Cuzh1wxf.js} +13 -13
  65. package/dist/prepared-CVbgO9KR.js +128 -0
  66. package/dist/prepared-DAwe8Il2.cjs +1 -0
  67. package/dist/protocol-BOri9qJL.js +105 -0
  68. package/dist/protocol-DD5dHSz-.cjs +1 -0
  69. package/dist/record-bindings-CAyM5tGg.cjs +1 -0
  70. package/dist/{record-bindings-DatJZv_e.js → record-bindings-fhav-NLG.js} +1 -1
  71. package/dist/{region-binding-workflow-DjrXuR1q.js → region-binding-workflow-Cm4mqhih.js} +2 -2
  72. package/dist/{region-binding-workflow-l7NGfagJ.cjs → region-binding-workflow-DWCUgjZl.cjs} +1 -1
  73. package/dist/report-encoding-worker.cjs +1 -1
  74. package/dist/report-encoding-worker.js +1 -1
  75. package/dist/rich-text-layout-X9YOz1JD.cjs +3 -0
  76. package/dist/{rich-text-layout-Ciwa6D2o.js → rich-text-layout-YJHtCWQI.js} +1 -1
  77. package/dist/runtime-BpSAgOw1.js +201 -0
  78. package/dist/runtime-Cd2UTnwe.cjs +1 -0
  79. package/dist/sbom.cdx.json +1 -1
  80. package/dist/server/node.d.cts +55 -7
  81. package/dist/server/node.d.ts +55 -7
  82. package/dist/server-node.cjs +5 -5
  83. package/dist/server-node.js +2710 -2418
  84. package/dist/server.cjs +1 -1
  85. package/dist/server.d.cts +47 -12
  86. package/dist/server.d.ts +47 -12
  87. package/dist/server.js +8 -8
  88. package/dist/style.css +1 -1
  89. package/dist/{template-catalog-CoT7jm_6.cjs → template-catalog--yBX169M.cjs} +1 -1
  90. package/dist/{template-catalog--cjxzgH7.js → template-catalog-Bu7s7ReF.js} +3 -3
  91. package/dist/template-fragments-5EzVn7bm.cjs +1 -0
  92. package/dist/{template-fragments-CPpGpQoz.js → template-fragments-Di2vDFnx.js} +2 -2
  93. package/dist/{template-registry-O0hNIOfB.js → template-registry-BCBF2b8j.js} +10 -10
  94. package/dist/template-registry-Bnh5aEYf.cjs +1 -0
  95. package/dist/textwrap-BPFxhpOw.cjs +4 -0
  96. package/dist/textwrap-CmVkhMhx.js +111 -0
  97. package/dist/vue/async.d.cts +104 -18
  98. package/dist/vue/async.d.ts +104 -18
  99. package/dist/vue/index.d.cts +134 -28
  100. package/dist/vue/index.d.ts +134 -28
  101. package/dist/vue-async.cjs +1 -1
  102. package/dist/vue-async.js +3 -3
  103. package/dist/vue.cjs +1 -1
  104. package/dist/vue.js +192 -162
  105. package/dist/{workbook-session-C9ZmCBwY.js → workbook-session-B6P_-5a4.js} +2 -2
  106. package/dist/{workbook-session-C6-SrnCT.cjs → workbook-session-BnPK3T58.cjs} +1 -1
  107. package/dist/worker.cjs +1 -1
  108. package/dist/worker.d.cts +55 -7
  109. package/dist/worker.d.ts +55 -7
  110. package/dist/worker.js +4 -4
  111. package/dist/xlsx.cjs +4 -4
  112. package/dist/xlsx.d.cts +18 -1
  113. package/dist/xlsx.d.ts +18 -1
  114. package/dist/xlsx.js +279 -272
  115. package/package.json +1 -1
  116. package/dist/ExcelBindingWizard-D4FLind-.js +0 -1485
  117. package/dist/ExcelBindingWizard-D4RS5Bpg.cjs +0 -1
  118. package/dist/ParamEditor-C-6C9rd2.cjs +0 -1
  119. package/dist/ParamEditor-CASZt-Ma.js +0 -732
  120. package/dist/ReportBatchPanel-Bq7t8a5r.js +0 -350
  121. package/dist/ReportBatchPanel-YVj5IO5y.cjs +0 -1
  122. package/dist/ReportLabelStudio-Cqhita1b.cjs +0 -1
  123. package/dist/ReportLabelStudio-Dj7GXhuv.js +0 -783
  124. package/dist/ReportParamPanel-DZbFVmDL.cjs +0 -1
  125. package/dist/ReportPreview-DeWzG8jQ.js +0 -6257
  126. package/dist/ReportPreview-FFIryrIr.cjs +0 -6
  127. package/dist/ReportTemplateLibrary-BaWodmpm.cjs +0 -1
  128. package/dist/ReportTemplateLibrary-DdAAAD2I.js +0 -311
  129. package/dist/RuleEditor-D2UwQGF6.js +0 -2341
  130. package/dist/RuleEditor-DcT9xI1v.cjs +0 -1
  131. package/dist/TemplateOutlinePanel-CUHFFiNM.cjs +0 -1
  132. package/dist/TemplateOutlinePanel-DrT7XN0m.js +0 -96
  133. package/dist/TemplateReusePanel-4eejkNqi.js +0 -388
  134. package/dist/TemplateReusePanel-DZMyiX5I.cjs +0 -1
  135. package/dist/TemplateReviewPanel-BIhNLeNw.js +0 -592
  136. package/dist/TemplateReviewPanel-DnYImiXu.cjs +0 -1
  137. package/dist/assets-D2gHc4Mz.cjs +0 -1
  138. package/dist/assets-T_gDeFaz.js +0 -132
  139. package/dist/auto-4pK9HePf.cjs +0 -1
  140. package/dist/capabilities-DiBj4Qgl.cjs +0 -1
  141. package/dist/capabilities-pg7j7VLT.js +0 -106
  142. package/dist/data-bar-CeZuFmYl.cjs +0 -1
  143. package/dist/designer-DhrE7jzw.js +0 -7169
  144. package/dist/designer-IAZu6kBX.cjs +0 -2
  145. package/dist/dom-ChE5D-L-.cjs +0 -1
  146. package/dist/grid-strokes-Be24LGuV.cjs +0 -1
  147. package/dist/json-snapshot-1tvQNzQE.cjs +0 -2
  148. package/dist/prefill-DsUD5OoK.cjs +0 -1
  149. package/dist/prepared-DCIxhKFo.js +0 -94
  150. package/dist/prepared-Dv-XM3i1.cjs +0 -1
  151. package/dist/progress-ByiOxUD3.js +0 -250
  152. package/dist/progress-WomPRP3B.cjs +0 -1
  153. package/dist/protocol-B9YgfQ_d.cjs +0 -1
  154. package/dist/protocol-DxeUKGYG.js +0 -90
  155. package/dist/record-bindings-MBxbeBsi.cjs +0 -1
  156. package/dist/rich-text-layout-DK7A_a5r.cjs +0 -3
  157. package/dist/runtime-75Y5Oq5B.js +0 -171
  158. package/dist/runtime-DKlGd_D4.cjs +0 -1
  159. package/dist/template-fragments-GVjpew_q.cjs +0 -1
  160. package/dist/template-registry-DI59PXVK.cjs +0 -1
  161. package/dist/textwrap-BIjtEWmq.js +0 -110
  162. package/dist/textwrap-Cy7o1hIR.cjs +0 -4
@@ -1,3 +1,3 @@
1
- "use strict";const F=require("./dataset-IrlXbUvh.cjs"),R=require("./template-registry-DI59PXVK.cjs"),N=require("./progress-WomPRP3B.cjs");function S(t){let e="";for(let o=t;o>0;o=Math.floor((o-1)/26))e=String.fromCharCode(65+(o-1)%26)+e;return e}function M(t){return`${S(t.left)}${t.top}:${S(t.right)}${t.bottom}`}function _(t){let e=0;for(const o of t.toUpperCase())e=e*26+o.charCodeAt(0)-64;return e}function d(t){if(typeof t!="string")throw new Error("Excel 范围应为 A1:B20 格式的字符串");const e=/^\$?([A-Z]{1,3})\$?([1-9]\d{0,6})(?::\$?([A-Z]{1,3})\$?([1-9]\d{0,6}))?$/i.exec(t.trim());if(!e)throw new Error(`Excel 范围无效:${t}`);const o={left:_(e[1]),top:Number(e[2]),right:_(e[3]??e[1]),bottom:Number(e[4]??e[2])};if(o.right<o.left||o.bottom<o.top||o.right>16384||o.bottom>1048576)throw new Error(`Excel 范围超出边界或顺序无效:${t}`);return o}function mt(t,e){if(e!==void 0)return d(e);const o=t.model.rows??[];if(!o.length)return{top:1,left:1,bottom:1,right:1};const r={top:1/0,left:1/0,bottom:1,right:1};for(const n of o)r.top=Math.min(r.top,n.number),r.bottom=Math.max(r.bottom,n.number),r.left=Math.min(r.left,n.min||1),r.right=Math.max(r.right,n.max||1);return r}function dt(t,e,o){const r=t.bottom-t.top+1,n=t.right-t.left+1;if(r>e.limits.maxRows||n>e.limits.maxColumns||r*n>o)throw new Error(`Excel 范围 ${M(t)} 超过导入行、列或单元格上限;请用 sheets/range 缩小范围`);return r*n}function pt(t,e){return t.top<=e.bottom&&t.bottom>=e.top&&t.left<=e.right&&t.right>=e.left}function ut(t,e){const o=[];for(const r of t.model.merges){const n=d(r);if(pt(e,n)){if(n.left<e.left||n.right>e.right||n.top<e.top||n.bottom>e.bottom)throw new Error(`${t.name}: 范围 ${M(e)} 截断合并单元格 ${r},请包含完整合并区域`);o.push(n)}}return o}function wt(t,e){const o=new Map;for(const n of e)o.set(n.top,Math.max(o.get(n.top)??n.top,n.bottom));const r=[];for(let n=t.top;n<=t.bottom;){let s=o.get(n)??n;for(let a=n;a<=s;a++)s=Math.max(s,o.get(a)??a);r.push({top:n,bottom:s}),n=s+1}return r}function yt(t,e,o,r){const n=[];let s,a=0;for(const i of t){const c=i.bottom-i.top+1;if(c>200)throw new Error("合并单元格跨越超过 200 行,无法安全分段;请先缩小或拆分该合并区域");let l=0;for(let h=i.top;h<=i.bottom;h++)l+=r(h);if(l>o&&Number.isFinite(o))throw new Error("合并区域或单行高度超过标准纸张可用高度;请使用 wide 或调整原模板行高");const f=s?i.bottom-s.top+1:c;s&&(f>e||a+l>o)&&(n.push(s),s=void 0,a=0),s?s.bottom=i.bottom:s={...i},a+=l}return s&&n.push(s),n}function Et(t){const e=new Map,o=new Set;for(const r of t){e.set(`${r.top}:${r.left}`,r);for(let n=r.top;n<=r.bottom;n++)for(let s=r.left;s<=r.right;s++)(n!==r.top||s!==r.left)&&o.add(`${n}:${s}`)}return{masters:e,covered:o}}function O(t){return JSON.parse(JSON.stringify(t))}function Mt(t,e){const o=t.template.pages.slice(e.pageStart,e.pageStart+e.pageCount),r=o[0];if(!r)throw new Error(`工作表 ${e.name} 没有可绑定页面`);const n=new Map;let s=[];for(const a of o)for(const i of a.components){if(i.kind==="list"||!i.grid||i.meta?.xlsxSheet!==e.name)continue;const c=d(String(i.meta.xlsxRange)),l=i.grid;s=l.colWidthsMm??[],l.cells.forEach((f,h)=>n.set(c.top+h,{cells:O(f),height:l.rowHeightsMm?.[h]??6}))}if(!s.length||!n.size)throw new Error(`工作表 ${e.name} 缺少导入几何元数据`);return{rows:n,widths:[...s],page:r,range:d(e.range)}}function j(t,e,o){const r=[],n=[];for(let s=e;s<=o;s++){const a=t.rows.get(s);if(!a)throw new Error(`导入模板缺少第 ${s} 行`);for(const i of a.cells)if(i&&s+(i.rowSpan??1)-1>o)throw new Error(`第 ${s} 行合并区域跨越绑定边界,请调整 header/detail 范围`);r.push(O(a.cells)),n.push(a.height)}return{cells:r,rowHeightsMm:n,colWidthsMm:t.widths,paddingMm:.25}}function xt(t,e){const o=d(t.header),r=t.detail?d(t.detail):{...e.range,top:o.bottom+1};for(const n of[o,r])if(n.left!==e.range.left||n.right!==e.range.right||n.top<e.range.top||n.bottom>e.range.bottom||n.top>n.bottom)throw new Error("绑定区域必须位于导入选区内并覆盖其完整列宽");if(r.top!==o.bottom+1)throw new Error("detail 应紧接 header,避免静态内容被隐式删除");if(t.columns.length!==e.widths.length)throw new Error("columns 应逐列映射整个选区;不能自动猜测业务字段");return bt(e,[o.top,o.bottom+1,r.bottom+1]),{header:o,detail:r}}function bt(t,e){for(const[o,r]of t.rows)for(const n of r.cells){const s=o+(n?.rowSpan??1);if(e.some(a=>o<a&&s>a))throw new Error(`第 ${o} 行合并区域跨越绑定边界,请调整 header/detail 范围`)}}function $t(t,e){const o=[];for(const r of N.resolveGridLayout(t,e.reduce((n,s)=>n+s,0),100).cells)for(let n=r.ci;n<Math.min(e.length,r.ci+(r.cell.colSpan??1));n++)o[n]=r.cell;return o}function St(t,e,o,r){if(e)return e;const n=t?.numberFormat;if(!n||n==="General")return;const s=/^(#,##)?0(?:\.(0+))?(%)?$/.exec(n);if(s){const a=s[2]?.length??0;if(a<=100)return s[3]?{kind:"percent",digits:a}:{kind:"number",digits:a,...s[1]?{thousands:!0}:{}}}r.push(`${o}: Excel 数字格式 ${n} 未自动套用到动态数据,请在 columns 中显式声明 format`)}function Rt(t,e,o,r,n){const s=$t(e,r),a=N.resolveGridLayout(o,r.reduce((f,h)=>f+h,0),20).cells;if(a.some(({cell:f})=>(f.colSpan??1)!==1||(f.rowSpan??1)!==1))throw new Error("动态明细样例行不能包含合并格;合并表头可以保留");const i=new Map(a.map(f=>[f.ci,f.cell])),c=new Set,l=t.columns.map((f,h)=>{const g=typeof f=="string"?{field:f}:f;if(!g||typeof g.field!="string"||!g.field.trim()||c.has(g.field))throw new Error(`columns[${h}] 需要唯一的非空 field`);c.add(g.field);const m=s[h]?.text??g.field,p=i.get(h),w=t.inferSampleFormats===!1?g.format:St(p,g.format,g.field,n);return{...g,...w?{format:w}:{},header:g.header??m,widthMm:r[h],style:{...p?.style,...g.style},...g.semanticRole&&!g.align?{align:"auto"}:{},...g.editable===void 0&&p?.editable===!1?{editable:!1}:{}}});return vt(t,s,l),l}function vt(t,e,o){const r=new Map;t.columns.forEach((n,s)=>{const a=e[s];if(!a||typeof n=="string")return;const i=r.get(a)??{style:{}};if(n.header!==void 0){if(i.text!==void 0&&i.text!==n.header)throw new Error("同一合并表头不能配置不同 header");i.text=n.header}kt(i.style,{...n.headerAlign?{align:n.headerAlign}:{},...n.headerStyle}),r.set(a,i)});for(const[n,s]of r)s.text!==void 0&&Object.assign(n,{text:s.text,rawText:s.text,value:s.text}),n.style={...n.style,...s.style},e.forEach((a,i)=>{a===n&&(s.text!==void 0&&(o[i].header=s.text),s.style.align!==void 0&&(o[i].headerAlign=s.style.align))})}function kt(t,e){for(const o of Object.keys(e))if(e[o]!==void 0){if(t[o]!==void 0&&t[o]!==e[o])throw new Error(`同一合并表头不能配置不同 ${o}`);Object.assign(t,{[o]:e[o]})}}function Bt(t,e){const o=t.page,r=e.rowHeightsMm.reduce((n,s)=>n+s,0);return{...o,heightMm:Math.max(o.heightMm,r+(o.marginTopMm??0)+(o.marginBottomMm??0)),components:[{kind:"rect",leftMm:o.marginLeftMm??0,topMm:o.marginTopMm??0,widthMm:t.widths.reduce((n,s)=>n+s,0),heightMm:r,grid:e}]}}function At(t,e,o,r){const n=Mt(t,e),{header:s,detail:a}=xt(o,n),i=j(n,n.range.top,s.bottom),c=j(n,a.top,a.top),l={...n.page,components:[]},f={kind:"list",id:`bound:${e.name}`,dataset:o.dataset??"detail",title:e.name,leftMm:l.marginLeftMm??0,topMm:l.marginTopMm??0,widthMm:n.widths.reduce((h,g)=>h+g,0),layout:l.layout??"page",headerGrid:i,columns:Rt(o,i,c,n.widths,r),rowHeightMm:c.rowHeightsMm[0],headerEveryPage:!0,align:"auto",paddingMm:.25,...o.rowKey?{rowKey:o.rowKey}:{},...o.revisionField?{revisionField:o.revisionField}:{},...o.sourceTokenField?{sourceTokenField:o.sourceTokenField}:{},...o.groupBy?{groupBy:o.groupBy}:{},...o.grandTotal===void 0?{}:{grandTotal:o.grandTotal}};return l.components.push(f),a.bottom===n.range.bottom?[l]:(r.push(`${e.name}: 明细区域后的静态内容保留为后续独立页面,不推断动态页脚定位`),[l,Bt(n,j(n,a.bottom+1,n.range.bottom))])}function V(t,e){const o=R.validateReportTemplate(t.template);if(!o.ok)throw new Error(`导入模板无效:${o.errors[0]?.message}`);if(!e.length)throw new Error("至少需要一个 Excel 业务绑定");const r=new Map;for(const c of e){if(!t.sheets.some(l=>l.name===c.sheet)||r.has(c.sheet))throw new Error(`绑定工作表不存在或重复:${c.sheet}`);r.set(c.sheet,c)}const n=[...t.warnings],s=t.sheets.flatMap(c=>{const l=r.get(c.name);return l?At(t,c,l,n):O(t.template.pages.slice(c.pageStart,c.pageStart+c.pageCount))}),a={...O(t.template),pages:s},i=R.validateReportTemplate(a);if(!i.ok)throw new Error(`业务模板无效:${i.errors[0]?.path} ${i.errors[0]?.message}`);return{template:a,warnings:n}}function z(t){const e=t.semanticRole??(t.type==="number"||t.type==="decimal"?"measure":t.type==="date"?"date":"text");return{field:t.field,semanticRole:e,editable:!1,...t.type==="number"&&t.digits!==void 0?{format:{kind:"number",digits:t.digits}}:{},...t.type==="date"?{format:{kind:"date",pattern:"YYYY-MM-DD"}}:{}}}function Ct(t){return t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)}function H(t,e=0){if(Ct(t))return;if(!t||typeof t!="object"||e>16)throw new Error("绑定会话元数据只允许有限深度的普通 JSON 值");const o=Object.getPrototypeOf(t);if(Array.isArray(t)?o!==Array.prototype:o!==Object.prototype&&o!==null)throw new Error("绑定会话不能包含特殊对象原型");if(Object.getOwnPropertySymbols(t).length)throw new Error("绑定会话不能包含 Symbol");if(Array.isArray(t)&&Object.keys(t).length!==t.length)throw new Error("绑定会话数组不能包含空位或额外属性");for(const[r,n]of Object.entries(Object.getOwnPropertyDescriptors(t)))if(!(Array.isArray(t)&&r==="length")){if(["__proto__","prototype","constructor"].includes(r)||n.get||n.set||!n.enumerable)throw new Error("绑定会话包含不安全元数据");H(n.value,e+1)}}function Ot(t,e){return Tt(t,e)}function Tt(t,e){const o=t.sheets.find(c=>c.name===e.sheet);if(!o)return[];const r=d(e.regions.header),n=d(e.regions.detail),s=[r.top,r.bottom+1,n.bottom+1],a=[],i=new Set;for(const c of t.template.pages.slice(o.pageStart,o.pageStart+o.pageCount))for(const l of c.components){if(l.kind==="list"||!l.grid||l.meta?.xlsxSheet!==e.sheet)continue;const f=d(String(l.meta.xlsxRange));l.grid.cells.forEach((h,g)=>{const m=f.top+g;for(const p of h){const w=s.some(b=>m<b&&m+(p?.rowSpan??1)>b),x=m===n.top&&((p?.rowSpan??1)>1||(p?.colSpan??1)>1);if(!w&&!x)continue;const E=w?"$.recipe.regions":"$.recipe.regions.detail";i.has(E)||(i.add(E),a.push({path:E,code:"region",message:w?`第 ${m} 行合并区域跨越绑定边界,请选择完整合并区域`:"动态明细原型行不能包含合并格"}))}})}return a}function Z(t){return JSON.parse(JSON.stringify(t))}function T(t){return t instanceof Error?t.message:String(t)}function u(t,e,o,r){t.push({path:e,code:o,message:r})}function U(t,e){return{fields:t.fields,...e?{rowKey:e}:{}}}function Ft(t,e){const o=new Set;for(const[r,n]of t.entries()){const s=`$.datasets[${r}]`;if(!n||typeof n.id!="string"||!n.id.trim()||o.has(n.id)){u(e,s,"schema","数据集标识应非空且唯一");continue}o.add(n.id);try{F.validateDatasetRows([],U(n,n.rowKey));for(const[a,i]of n.fields.entries())i.digits!==void 0&&(!Number.isInteger(i.digits)||i.digits<0||i.digits>100)&&u(e,`${s}.fields[${a}].digits`,"schema","显示精度应为 0–100 的整数")}catch(a){u(e,s,"schema",T(a))}}}function Nt(t,e,o){const r=t.sheets.find(i=>i.name===e.sheet);if(!r){u(o,"$.recipe.sheet","source","指定的工作表不存在");return}let n;try{n=d(r.range)}catch(i){u(o,"$.source.sheets","source",T(i));return}const s=new Map;for(const i of["title","header","detail","footer"]){const c=e.regions?.[i];if(!(!c&&(i==="title"||i==="footer")))try{const l=d(c??"");if(l.left!==n.left||l.right!==n.right||l.top<n.top||l.bottom>n.bottom)throw new Error("区域必须覆盖选区完整列宽,并位于原始工作表内");s.set(i,l)}catch(l){u(o,`$.recipe.regions.${i}`,"region",T(l))}}const a=[...s.values()];a.length&&(a[0].top!==n.top||a[a.length-1].bottom!==n.bottom)&&u(o,"$.recipe.regions","region","标题、表头、明细、页脚应完整覆盖来源,不能隐式删除静态内容");for(let i=1;i<a.length;i++)a[i].top!==a[i-1].bottom+1&&u(o,"$.recipe.regions","region","各区域应顺序相邻且不重叠")}function It(t,e,o,r){if(!Array.isArray(t.fields)||t.fields.length!==o)return u(r,"$.recipe.fields","mapping","每个物理 Excel 列必须显式绑定一个业务字段"),0;const n=new Set(e.fields.map(i=>i.field)),s=new Set;let a=0;t.fields.forEach((i,c)=>{typeof i!="string"||!n.has(i)?u(r,`$.recipe.fields[${c}]`,"mapping","请选择契约中已声明的字段"):s.has(i)?u(r,`$.recipe.fields[${c}]`,"mapping","同一业务字段不能重复绑定物理列"):(a++,s.add(i))});try{if(!t.rowKey)throw new Error("请明确选择稳定业务主键,不能使用展示行号");const i=U(e,t.rowKey),c=F.validateDatasetRows(e.samples??[],i,{path:`$.datasets.${e.id}.samples`,maxRows:100,maxCells:2e5,maxIssues:30});for(const l of c.issues)u(r,l.path,l.code==="row-key"?"row-key":"schema",l.message)}catch(i){u(r,"$.recipe.rowKey","row-key",T(i))}return a}function Q(t,e){const o=[];return!e||e.version!=="1.0"?[{path:"$.recipe.version",code:"schema",message:"不支持的 Excel 绑定配置版本"}]:(Nt(t,e,o),o.length||o.push(...Ot(t,e)),o)}function X(t,e,o){const r=[];if(!e||e.version!=="1.0")return{ok:!1,issues:[{path:"$.recipe.version",code:"schema",message:"不支持的 Excel 绑定配置版本"}],mapped:0,total:0};Ft(o,r);const n=t.sheets.find(i=>i.name===e.sheet)?.columnCount??0,s=o.find(i=>i.id===e.dataset);let a=0;return s?r.some(i=>i.code==="schema")||(a=It(e,s,n,r)):u(r,"$.recipe.dataset","schema","请明确选择宿主提供的数据集契约"),{ok:r.length===0,issues:r,mapped:a,total:n}}function tt(t,e,o){const r=X(t,e,o);if(!e||e.version!=="1.0")return r;const n=[...Q(t,e),...r.issues];return{...r,ok:n.length===0,issues:n}}function Kt(t,e,o,r){const n=tt(t,e,o);if(!n.ok)throw new Error(n.issues.map(f=>`${f.path}: ${f.message}`).join(`
1
+ "use strict";const F=require("./dataset-IrlXbUvh.cjs"),R=require("./template-registry-Bnh5aEYf.cjs"),N=require("./diagnostic-collector-D3rlvxm3.cjs");function S(t){let e="";for(let o=t;o>0;o=Math.floor((o-1)/26))e=String.fromCharCode(65+(o-1)%26)+e;return e}function M(t){return`${S(t.left)}${t.top}:${S(t.right)}${t.bottom}`}function _(t){let e=0;for(const o of t.toUpperCase())e=e*26+o.charCodeAt(0)-64;return e}function d(t){if(typeof t!="string")throw new Error("Excel 范围应为 A1:B20 格式的字符串");const e=/^\$?([A-Z]{1,3})\$?([1-9]\d{0,6})(?::\$?([A-Z]{1,3})\$?([1-9]\d{0,6}))?$/i.exec(t.trim());if(!e)throw new Error(`Excel 范围无效:${t}`);const o={left:_(e[1]),top:Number(e[2]),right:_(e[3]??e[1]),bottom:Number(e[4]??e[2])};if(o.right<o.left||o.bottom<o.top||o.right>16384||o.bottom>1048576)throw new Error(`Excel 范围超出边界或顺序无效:${t}`);return o}function mt(t,e){if(e!==void 0)return d(e);const o=t.model.rows??[];if(!o.length)return{top:1,left:1,bottom:1,right:1};const r={top:1/0,left:1/0,bottom:1,right:1};for(const n of o)r.top=Math.min(r.top,n.number),r.bottom=Math.max(r.bottom,n.number),r.left=Math.min(r.left,n.min||1),r.right=Math.max(r.right,n.max||1);return r}function dt(t,e,o){const r=t.bottom-t.top+1,n=t.right-t.left+1;if(r>e.limits.maxRows||n>e.limits.maxColumns||r*n>o)throw new Error(`Excel 范围 ${M(t)} 超过导入行、列或单元格上限;请用 sheets/range 缩小范围`);return r*n}function pt(t,e){return t.top<=e.bottom&&t.bottom>=e.top&&t.left<=e.right&&t.right>=e.left}function ut(t,e){const o=[];for(const r of t.model.merges){const n=d(r);if(pt(e,n)){if(n.left<e.left||n.right>e.right||n.top<e.top||n.bottom>e.bottom)throw new Error(`${t.name}: 范围 ${M(e)} 截断合并单元格 ${r},请包含完整合并区域`);o.push(n)}}return o}function wt(t,e){const o=new Map;for(const n of e)o.set(n.top,Math.max(o.get(n.top)??n.top,n.bottom));const r=[];for(let n=t.top;n<=t.bottom;){let s=o.get(n)??n;for(let a=n;a<=s;a++)s=Math.max(s,o.get(a)??a);r.push({top:n,bottom:s}),n=s+1}return r}function yt(t,e,o,r){const n=[];let s,a=0;for(const i of t){const c=i.bottom-i.top+1;if(c>200)throw new Error("合并单元格跨越超过 200 行,无法安全分段;请先缩小或拆分该合并区域");let l=0;for(let h=i.top;h<=i.bottom;h++)l+=r(h);if(l>o&&Number.isFinite(o))throw new Error("合并区域或单行高度超过标准纸张可用高度;请使用 wide 或调整原模板行高");const f=s?i.bottom-s.top+1:c;s&&(f>e||a+l>o)&&(n.push(s),s=void 0,a=0),s?s.bottom=i.bottom:s={...i},a+=l}return s&&n.push(s),n}function Et(t){const e=new Map,o=new Set;for(const r of t){e.set(`${r.top}:${r.left}`,r);for(let n=r.top;n<=r.bottom;n++)for(let s=r.left;s<=r.right;s++)(n!==r.top||s!==r.left)&&o.add(`${n}:${s}`)}return{masters:e,covered:o}}function O(t){return JSON.parse(JSON.stringify(t))}function Mt(t,e){const o=t.template.pages.slice(e.pageStart,e.pageStart+e.pageCount),r=o[0];if(!r)throw new Error(`工作表 ${e.name} 没有可绑定页面`);const n=new Map;let s=[];for(const a of o)for(const i of a.components){if(i.kind==="list"||!i.grid||i.meta?.xlsxSheet!==e.name)continue;const c=d(String(i.meta.xlsxRange)),l=i.grid;s=l.colWidthsMm??[],l.cells.forEach((f,h)=>n.set(c.top+h,{cells:O(f),height:l.rowHeightsMm?.[h]??6}))}if(!s.length||!n.size)throw new Error(`工作表 ${e.name} 缺少导入几何元数据`);return{rows:n,widths:[...s],page:r,range:d(e.range)}}function j(t,e,o){const r=[],n=[];for(let s=e;s<=o;s++){const a=t.rows.get(s);if(!a)throw new Error(`导入模板缺少第 ${s} 行`);for(const i of a.cells)if(i&&s+(i.rowSpan??1)-1>o)throw new Error(`第 ${s} 行合并区域跨越绑定边界,请调整 header/detail 范围`);r.push(O(a.cells)),n.push(a.height)}return{cells:r,rowHeightsMm:n,colWidthsMm:t.widths,paddingMm:.25}}function xt(t,e){const o=d(t.header),r=t.detail?d(t.detail):{...e.range,top:o.bottom+1};for(const n of[o,r])if(n.left!==e.range.left||n.right!==e.range.right||n.top<e.range.top||n.bottom>e.range.bottom||n.top>n.bottom)throw new Error("绑定区域必须位于导入选区内并覆盖其完整列宽");if(r.top!==o.bottom+1)throw new Error("detail 应紧接 header,避免静态内容被隐式删除");if(t.columns.length!==e.widths.length)throw new Error("columns 应逐列映射整个选区;不能自动猜测业务字段");return bt(e,[o.top,o.bottom+1,r.bottom+1]),{header:o,detail:r}}function bt(t,e){for(const[o,r]of t.rows)for(const n of r.cells){const s=o+(n?.rowSpan??1);if(e.some(a=>o<a&&s>a))throw new Error(`第 ${o} 行合并区域跨越绑定边界,请调整 header/detail 范围`)}}function $t(t,e){const o=[];for(const r of N.resolveGridLayout(t,e.reduce((n,s)=>n+s,0),100).cells)for(let n=r.ci;n<Math.min(e.length,r.ci+(r.cell.colSpan??1));n++)o[n]=r.cell;return o}function St(t,e,o,r){if(e)return e;const n=t?.numberFormat;if(!n||n==="General")return;const s=/^(#,##)?0(?:\.(0+))?(%)?$/.exec(n);if(s){const a=s[2]?.length??0;if(a<=100)return s[3]?{kind:"percent",digits:a}:{kind:"number",digits:a,...s[1]?{thousands:!0}:{}}}r.push(`${o}: Excel 数字格式 ${n} 未自动套用到动态数据,请在 columns 中显式声明 format`)}function Rt(t,e,o,r,n){const s=$t(e,r),a=N.resolveGridLayout(o,r.reduce((f,h)=>f+h,0),20).cells;if(a.some(({cell:f})=>(f.colSpan??1)!==1||(f.rowSpan??1)!==1))throw new Error("动态明细样例行不能包含合并格;合并表头可以保留");const i=new Map(a.map(f=>[f.ci,f.cell])),c=new Set,l=t.columns.map((f,h)=>{const g=typeof f=="string"?{field:f}:f;if(!g||typeof g.field!="string"||!g.field.trim()||c.has(g.field))throw new Error(`columns[${h}] 需要唯一的非空 field`);c.add(g.field);const m=s[h]?.text??g.field,p=i.get(h),w=t.inferSampleFormats===!1?g.format:St(p,g.format,g.field,n);return{...g,...w?{format:w}:{},header:g.header??m,widthMm:r[h],style:{...p?.style,...g.style},...g.semanticRole&&!g.align?{align:"auto"}:{},...g.editable===void 0&&p?.editable===!1?{editable:!1}:{}}});return vt(t,s,l),l}function vt(t,e,o){const r=new Map;t.columns.forEach((n,s)=>{const a=e[s];if(!a||typeof n=="string")return;const i=r.get(a)??{style:{}};if(n.header!==void 0){if(i.text!==void 0&&i.text!==n.header)throw new Error("同一合并表头不能配置不同 header");i.text=n.header}kt(i.style,{...n.headerAlign?{align:n.headerAlign}:{},...n.headerStyle}),r.set(a,i)});for(const[n,s]of r)s.text!==void 0&&Object.assign(n,{text:s.text,rawText:s.text,value:s.text}),n.style={...n.style,...s.style},e.forEach((a,i)=>{a===n&&(s.text!==void 0&&(o[i].header=s.text),s.style.align!==void 0&&(o[i].headerAlign=s.style.align))})}function kt(t,e){for(const o of Object.keys(e))if(e[o]!==void 0){if(t[o]!==void 0&&t[o]!==e[o])throw new Error(`同一合并表头不能配置不同 ${o}`);Object.assign(t,{[o]:e[o]})}}function Bt(t,e){const o=t.page,r=e.rowHeightsMm.reduce((n,s)=>n+s,0);return{...o,heightMm:Math.max(o.heightMm,r+(o.marginTopMm??0)+(o.marginBottomMm??0)),components:[{kind:"rect",leftMm:o.marginLeftMm??0,topMm:o.marginTopMm??0,widthMm:t.widths.reduce((n,s)=>n+s,0),heightMm:r,grid:e}]}}function At(t,e,o,r){const n=Mt(t,e),{header:s,detail:a}=xt(o,n),i=j(n,n.range.top,s.bottom),c=j(n,a.top,a.top),l={...n.page,components:[]},f={kind:"list",id:`bound:${e.name}`,dataset:o.dataset??"detail",title:e.name,leftMm:l.marginLeftMm??0,topMm:l.marginTopMm??0,widthMm:n.widths.reduce((h,g)=>h+g,0),layout:l.layout??"page",headerGrid:i,columns:Rt(o,i,c,n.widths,r),rowHeightMm:c.rowHeightsMm[0],headerEveryPage:!0,align:"auto",paddingMm:.25,...o.rowKey?{rowKey:o.rowKey}:{},...o.revisionField?{revisionField:o.revisionField}:{},...o.sourceTokenField?{sourceTokenField:o.sourceTokenField}:{},...o.groupBy?{groupBy:o.groupBy}:{},...o.grandTotal===void 0?{}:{grandTotal:o.grandTotal}};return l.components.push(f),a.bottom===n.range.bottom?[l]:(r.push(`${e.name}: 明细区域后的静态内容保留为后续独立页面,不推断动态页脚定位`),[l,Bt(n,j(n,a.bottom+1,n.range.bottom))])}function V(t,e){const o=R.validateReportTemplate(t.template);if(!o.ok)throw new Error(`导入模板无效:${o.errors[0]?.message}`);if(!e.length)throw new Error("至少需要一个 Excel 业务绑定");const r=new Map;for(const c of e){if(!t.sheets.some(l=>l.name===c.sheet)||r.has(c.sheet))throw new Error(`绑定工作表不存在或重复:${c.sheet}`);r.set(c.sheet,c)}const n=[...t.warnings],s=t.sheets.flatMap(c=>{const l=r.get(c.name);return l?At(t,c,l,n):O(t.template.pages.slice(c.pageStart,c.pageStart+c.pageCount))}),a={...O(t.template),pages:s},i=R.validateReportTemplate(a);if(!i.ok)throw new Error(`业务模板无效:${i.errors[0]?.path} ${i.errors[0]?.message}`);return{template:a,warnings:n}}function z(t){const e=t.semanticRole??(t.type==="number"||t.type==="decimal"?"measure":t.type==="date"?"date":"text");return{field:t.field,semanticRole:e,editable:!1,...t.type==="number"&&t.digits!==void 0?{format:{kind:"number",digits:t.digits}}:{},...t.type==="date"?{format:{kind:"date",pattern:"YYYY-MM-DD"}}:{}}}function Ct(t){return t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t)}function H(t,e=0){if(Ct(t))return;if(!t||typeof t!="object"||e>16)throw new Error("绑定会话元数据只允许有限深度的普通 JSON 值");const o=Object.getPrototypeOf(t);if(Array.isArray(t)?o!==Array.prototype:o!==Object.prototype&&o!==null)throw new Error("绑定会话不能包含特殊对象原型");if(Object.getOwnPropertySymbols(t).length)throw new Error("绑定会话不能包含 Symbol");if(Array.isArray(t)&&Object.keys(t).length!==t.length)throw new Error("绑定会话数组不能包含空位或额外属性");for(const[r,n]of Object.entries(Object.getOwnPropertyDescriptors(t)))if(!(Array.isArray(t)&&r==="length")){if(["__proto__","prototype","constructor"].includes(r)||n.get||n.set||!n.enumerable)throw new Error("绑定会话包含不安全元数据");H(n.value,e+1)}}function Ot(t,e){return Tt(t,e)}function Tt(t,e){const o=t.sheets.find(c=>c.name===e.sheet);if(!o)return[];const r=d(e.regions.header),n=d(e.regions.detail),s=[r.top,r.bottom+1,n.bottom+1],a=[],i=new Set;for(const c of t.template.pages.slice(o.pageStart,o.pageStart+o.pageCount))for(const l of c.components){if(l.kind==="list"||!l.grid||l.meta?.xlsxSheet!==e.sheet)continue;const f=d(String(l.meta.xlsxRange));l.grid.cells.forEach((h,g)=>{const m=f.top+g;for(const p of h){const w=s.some(b=>m<b&&m+(p?.rowSpan??1)>b),x=m===n.top&&((p?.rowSpan??1)>1||(p?.colSpan??1)>1);if(!w&&!x)continue;const E=w?"$.recipe.regions":"$.recipe.regions.detail";i.has(E)||(i.add(E),a.push({path:E,code:"region",message:w?`第 ${m} 行合并区域跨越绑定边界,请选择完整合并区域`:"动态明细原型行不能包含合并格"}))}})}return a}function Z(t){return JSON.parse(JSON.stringify(t))}function T(t){return t instanceof Error?t.message:String(t)}function u(t,e,o,r){t.push({path:e,code:o,message:r})}function U(t,e){return{fields:t.fields,...e?{rowKey:e}:{}}}function Ft(t,e){const o=new Set;for(const[r,n]of t.entries()){const s=`$.datasets[${r}]`;if(!n||typeof n.id!="string"||!n.id.trim()||o.has(n.id)){u(e,s,"schema","数据集标识应非空且唯一");continue}o.add(n.id);try{F.validateDatasetRows([],U(n,n.rowKey));for(const[a,i]of n.fields.entries())i.digits!==void 0&&(!Number.isInteger(i.digits)||i.digits<0||i.digits>100)&&u(e,`${s}.fields[${a}].digits`,"schema","显示精度应为 0–100 的整数")}catch(a){u(e,s,"schema",T(a))}}}function Nt(t,e,o){const r=t.sheets.find(i=>i.name===e.sheet);if(!r){u(o,"$.recipe.sheet","source","指定的工作表不存在");return}let n;try{n=d(r.range)}catch(i){u(o,"$.source.sheets","source",T(i));return}const s=new Map;for(const i of["title","header","detail","footer"]){const c=e.regions?.[i];if(!(!c&&(i==="title"||i==="footer")))try{const l=d(c??"");if(l.left!==n.left||l.right!==n.right||l.top<n.top||l.bottom>n.bottom)throw new Error("区域必须覆盖选区完整列宽,并位于原始工作表内");s.set(i,l)}catch(l){u(o,`$.recipe.regions.${i}`,"region",T(l))}}const a=[...s.values()];a.length&&(a[0].top!==n.top||a[a.length-1].bottom!==n.bottom)&&u(o,"$.recipe.regions","region","标题、表头、明细、页脚应完整覆盖来源,不能隐式删除静态内容");for(let i=1;i<a.length;i++)a[i].top!==a[i-1].bottom+1&&u(o,"$.recipe.regions","region","各区域应顺序相邻且不重叠")}function It(t,e,o,r){if(!Array.isArray(t.fields)||t.fields.length!==o)return u(r,"$.recipe.fields","mapping","每个物理 Excel 列必须显式绑定一个业务字段"),0;const n=new Set(e.fields.map(i=>i.field)),s=new Set;let a=0;t.fields.forEach((i,c)=>{typeof i!="string"||!n.has(i)?u(r,`$.recipe.fields[${c}]`,"mapping","请选择契约中已声明的字段"):s.has(i)?u(r,`$.recipe.fields[${c}]`,"mapping","同一业务字段不能重复绑定物理列"):(a++,s.add(i))});try{if(!t.rowKey)throw new Error("请明确选择稳定业务主键,不能使用展示行号");const i=U(e,t.rowKey),c=F.validateDatasetRows(e.samples??[],i,{path:`$.datasets.${e.id}.samples`,maxRows:100,maxCells:2e5,maxIssues:30});for(const l of c.issues)u(r,l.path,l.code==="row-key"?"row-key":"schema",l.message)}catch(i){u(r,"$.recipe.rowKey","row-key",T(i))}return a}function Q(t,e){const o=[];return!e||e.version!=="1.0"?[{path:"$.recipe.version",code:"schema",message:"不支持的 Excel 绑定配置版本"}]:(Nt(t,e,o),o.length||o.push(...Ot(t,e)),o)}function X(t,e,o){const r=[];if(!e||e.version!=="1.0")return{ok:!1,issues:[{path:"$.recipe.version",code:"schema",message:"不支持的 Excel 绑定配置版本"}],mapped:0,total:0};Ft(o,r);const n=t.sheets.find(i=>i.name===e.sheet)?.columnCount??0,s=o.find(i=>i.id===e.dataset);let a=0;return s?r.some(i=>i.code==="schema")||(a=It(e,s,n,r)):u(r,"$.recipe.dataset","schema","请明确选择宿主提供的数据集契约"),{ok:r.length===0,issues:r,mapped:a,total:n}}function tt(t,e,o){const r=X(t,e,o);if(!e||e.version!=="1.0")return r;const n=[...Q(t,e),...r.issues];return{...r,ok:n.length===0,issues:n}}function Kt(t,e,o,r){const n=tt(t,e,o);if(!n.ok)throw new Error(n.issues.map(f=>`${f.path}: ${f.message}`).join(`
2
2
  `));const s=t.sheets.find(f=>f.name===e.sheet),a={...t,sheets:[{...s,pageStart:0}],template:{...t.template,pages:t.template.pages.slice(s.pageStart,s.pageStart+s.pageCount)}},i=new Map(o.find(f=>f.id===e.dataset).fields.map(f=>[f.field,f])),c={sheet:e.sheet,dataset:e.dataset,header:e.regions.header,detail:e.regions.detail,rowKey:e.rowKey,inferSampleFormats:!1,columns:e.fields.map(f=>z(i.get(f)))},l=V(a,[c]);return{document:R.defineReportTemplate({...r,template:l.template}),recipe:Z(e),warnings:l.warnings}}function jt(t,e){if(t?.version!=="1.0"||!Array.isArray(t.fields)||t.fields.length>16384||t.fields.some(o=>typeof o!="string"))throw new Error("Excel 绑定配置无效");if(typeof t.dataset!="string"||typeof t.rowKey!="string"||!t.regions||typeof e?.id!="string"||typeof e.name!="string")throw new Error("Excel 绑定参数或标识无效");for(const o of Object.values(t.regions))o!==""&&d(o)}function Gt(t){for(const e of t.sheets)if(d(e.range),typeof e.name!="string"||![e.index,e.rowCount,e.columnCount,e.pageCount].every(o=>Number.isInteger(o)&&o>0)||!Number.isInteger(e.pageStart)||e.pageStart<0||e.pageStart+e.pageCount>t.template.pages.length)throw new Error("Excel 绑定工作表几何元数据无效")}function Ht(t,e,o){if(H({sheets:t.sheets,warnings:t.warnings,recipe:e,identity:o}),!Array.isArray(t.sheets)||!t.sheets.length||t.sheets.length>32||!Array.isArray(t.warnings)||t.warnings.some(r=>typeof r!="string"))throw new Error("Excel 绑定来源元数据无效");if(jt(e,o),!t.sheets.some(r=>r.name===e.sheet))throw new Error("Excel 绑定工作表不存在");Gt(t)}function et(t,e,o){return Ht(t,e,o),R.parseReportTemplate({schemaVersion:"1.0",id:o.id,name:o.name,template:t.template}),Z({version:"1.0",source:t,recipe:e,identity:o})}function Dt(t){if(typeof t=="string"&&t.length>1e7)throw new Error("Excel 绑定会话超过 1000 万字符上限");const e=typeof t=="string"?JSON.parse(t):t;if(!e||e.version!=="1.0"||e.recipe?.version!=="1.0"||!Array.isArray(e.source?.sheets))throw new Error("Excel 绑定会话结构或版本无效");return et(e.source,e.recipe,e.identity)}function Lt(t,e,o,r){const n=t.sheets.find(c=>c.name===e);if(!n)throw new Error("工作表不存在");const s=d(n.range),a=Math.min(o,r),i=Math.max(o,r);if(!Number.isInteger(a)||!Number.isInteger(i)||a<s.top||i>s.bottom)throw new Error("选中行超出来源区域");return M({...s,top:a,bottom:i})}function P(t,e,o){const r=t??e;if(!Number.isInteger(r)||r<1||r>o)throw new Error(`预览窗口大小应为 1–${o} 的整数`);return r}function Y(t,e,o){const r=t??e;if(!Number.isInteger(r))throw new Error("预览起点应为整数");return Math.max(e,Math.min(o,r))}function Jt(t,e,o={}){const r=t.sheets.find(g=>g.name===e);if(!r)throw new Error("指定的工作表不存在");const n=d(r.range),s=Y(o.row,n.top,n.bottom),a=Y(o.column,n.left,n.right),i=Math.min(n.bottom,s+P(o.rows,24,100)-1),c=Math.min(n.right,a+P(o.columns,12,32)-1),l=Array.from({length:i-s+1},(g,m)=>({row:s+m,cells:[]})),f=new Set;for(const g of t.template.pages.slice(r.pageStart,r.pageStart+r.pageCount))for(const m of g.components){if(m.kind==="list"||!m.grid||m.meta?.xlsxSheet!==e)continue;const p=d(String(m.meta.xlsxRange));if(p.bottom<s||p.top>i)continue;const w=N.resolveGridLayout(m.grid,m.widthMm,m.heightMm);for(const x of w.cells)h(x.cell,p.top+x.ri,p.left+x.ci)}for(const g of l){for(let m=a;m<=c;m++)f.has(`${g.row}:${m}`)||g.cells.push({address:`${S(m)}${g.row}`,row:g.row,column:m,text:"",rowSpan:1,colSpan:1,continued:!1});g.cells.sort((m,p)=>m.column-p.column)}return{top:s,bottom:i,left:a,right:c,source:n,rows:l,columns:Array.from({length:c-a+1},(g,m)=>({column:a+m,name:S(a+m)}))};function h(g,m,p){const w=m+(g.rowSpan??1)-1,x=p+(g.colSpan??1)-1;if(w<s||m>i||x<a||p>c)return;const E=Math.max(s,m),b=Math.max(a,p),J=Math.min(i,w)-E+1,W=Math.min(c,x)-b+1;l[E-s].cells.push({address:`${S(p)}${m}`,row:E,column:b,text:g.text??g.rawText??String(g.value??""),rowSpan:J,colSpan:W,continued:E!==m||b!==p,style:g.style});for(let I=E;I<E+J;I++)for(let K=b;K<b+W;K++)f.add(`${I}:${K}`)}}function v(t){return JSON.parse(JSON.stringify(t))}function ot(t,e){const o=t.sheets.find(i=>i.name===e);if(!o)throw new Error("指定的工作表不存在");const r=t.template.pages.slice(o.pageStart,o.pageStart+o.pageCount),n=r[0];if(!n)throw new Error("工作表没有可绑定的页面");const s={page:n,range:d(o.range),widths:[],heights:new Map,cells:[],cellsByRow:new Map,topOffsets:new Map};for(const i of r)for(const c of i.components){if(c.kind==="list"||!c.grid||c.meta?.xlsxSheet!==e)continue;const l=d(String(c.meta.xlsxRange));s.widths.length||(s.widths=[...c.grid.colWidthsMm??[]]),c.grid.cells.forEach((f,h)=>s.heights.set(l.top+h,c.grid.rowHeightsMm?.[h]??6));for(const f of N.resolveGridLayout(c.grid,c.widthMm,c.heightMm).cells){const h=l.top+f.ri,g=l.left+f.ci;s.cells.push({top:h,left:g,bottom:h+(f.cell.rowSpan??1)-1,right:g+(f.cell.colSpan??1)-1,cell:f.cell})}}if(s.widths.length!==s.range.right-s.range.left+1||s.heights.size!==s.range.bottom-s.range.top+1)throw new Error("来源工作表几何元数据不完整");let a=0;for(let i=s.range.top;i<=s.range.bottom;i++)s.topOffsets.set(i,a),a+=s.heights.get(i);s.topOffsets.set(s.range.bottom+1,a);for(const i of s.cells)for(let c=i.top;c<=i.bottom;c++){const l=s.cellsByRow.get(c)??[];l.push(i),s.cellsByRow.set(c,l)}return s}function rt(t,e){return t.left<=e.right&&e.left<=t.right&&t.top<=e.bottom&&e.top<=t.bottom}function k(t,e){return t.top<=e.top&&t.bottom>=e.bottom&&t.left<=e.left&&t.right>=e.right}function nt(t,e){return t.widths.slice(e.left-t.range.left,e.right-t.range.left+1).reduce((o,r)=>o+r,0)}function C(t,e){return(t.topOffsets.get(e.bottom+1)??0)-(t.topOffsets.get(e.top)??0)}function A(t,e){const o=new Set;for(let r=e.top;r<=e.bottom;r++)for(const n of t.cellsByRow.get(r)??[])rt(n,e)&&o.add(n);return[...o]}function st(t,e){for(const o of A(t,e))if(!k(e,o))throw new Error(`合并区域 ${M(o)} 跨越选区 ${M(e)}`)}function G(t,e,o=[]){const r=A(t,e);for(const i of r)if(!k(e,i))throw new Error(`合并区域 ${M(i)} 跨越选区 ${M(e)}`);const n=[],s=new Map,a=new Set;for(const i of r)if(!o.some(c=>k(c,i))){s.set(`${i.top}:${i.left}`,i);for(let c=i.top;c<=i.bottom;c++)for(let l=i.left;l<=i.right;l++)a.add(`${c}:${l}`)}for(let i=e.top;i<=e.bottom;i++){const c=[];for(let l=e.left;l<=e.right;l++){const f=s.get(`${i}:${l}`);f?(c.push(v(f.cell)),l=f.right):a.has(`${i}:${l}`)||c.push(null)}n.push(c)}return{cells:n,colWidthsMm:t.widths.slice(e.left-t.range.left,e.right-t.range.left+1),rowHeightsMm:Array.from({length:e.bottom-e.top+1},(i,c)=>t.heights.get(e.top+c)),paddingMm:.25}}function B(t){const e=d(t.range);return t.headerRange?{...e,top:d(t.headerRange).top}:e}function D(t,e){return(t.page.marginTopMm??0)+(t.topOffsets.get(e)??0)}function it(t,e){return{xlsxFlow:{version:"1.0",columnStart:e.left-t.range.left}}}function at(t,e,o,r,n=[]){const s=G(t,o,n);for(const a of s.cells)for(const i of a)i&&(i.editable=!1,delete i.source);return{kind:"rect",nid:r,leftMm:t.page.marginLeftMm??0,topMm:D(t,o.top),widthMm:nt(t,o),heightMm:C(t,o),grid:s,meta:it(t,o)}}function Wt(t,e,o,r){const n=d(o.range),s=B(o),a=G(t,n),i=new Map(r.fields.map(f=>[f.field,f])),c=a.colWidthsMm,l=o.fields.map((f,h)=>({...z(i.get(f)),header:i.get(f).label??f,widthMm:c[h],style:v(a.cells[0]?.[h]?.style??{}),align:"auto"}));return{kind:"list",id:`xlsx-region:${o.id}`,dataset:o.dataset,rowKey:o.rowKey,...o.revisionField?{revisionField:o.revisionField}:{},...o.sourceTokenField?{sourceTokenField:o.sourceTokenField}:{},title:`${e.sheet} · ${o.id}`,layout:t.page.layout??"wide",leftMm:(t.page.marginLeftMm??0)+t.widths.slice(0,n.left-t.range.left).reduce((f,h)=>f+h,0),topMm:D(t,s.top),widthMm:nt(t,n),rowHeightMm:a.rowHeightsMm[0],header:!!o.headerRange,headerEveryPage:o.mode==="repeat",...o.mode==="record"?{cardinality:"record"}:{},...o.headerRange?{headerGrid:G(t,d(o.headerRange))}:{},columns:l,paddingMm:a.paddingMm,meta:it(t,n)}}function q(t,e,o,r=0){const n=[],s=t.page.heightMm-(t.page.marginTopMm??0)-(t.page.marginBottomMm??0)-r,a=Math.max(1,Math.min(100,Math.floor(1e4/t.widths.length)));for(let i=e;i<=o;){const c=i;let l=i,f=0;for(;i<=o;){let h=i;for(let m=i;m<=h;m++)for(const p of t.cellsByRow.get(m)??[])h=Math.max(h,p.bottom);if(h>o)throw new Error("静态合并区域跨越动态绑定边界,请调整区域");const g=C(t,{...t.range,top:i,bottom:h});if(i>c&&(h-c+1>a||f+g>s))break;if(g>s)throw new Error("静态合并区域高度超过单页可用高度,请调整原始模板");f+=g,l=h,i=h+1}n.push({range:{...t.range,top:c,bottom:l},bindings:[]})}return n}function _t(t,e){const o=[...e.regions].sort((i,c)=>B(i).top-B(c).top),r=[];let n=t.range.top;const s=e.footerRange?C(t,d(e.footerRange)):0;for(const i of o){const c=B(i),l=r[r.length-1];if(l?.bindings.length&&l.range.top===c.top&&l.range.bottom===c.bottom){l.bindings.push(i);continue}n<c.top&&r.push(...q(t,n,c.top-1,s)),r.push({range:{...t.range,top:c.top,bottom:c.bottom},bindings:[i]}),n=c.bottom+1}const a=e.footerRange?d(e.footerRange).top-1:t.range.bottom;return n<=a&&r.push(...q(t,n,a,s)),r}function Pt(t,e,o,r,n){const s=[],a=o.bindings.map(B),i=o.bindings.some(l=>l.mode==="repeat"),c=A(t,o.range).some(l=>!a.some(f=>k(f,l)));!i&&(!o.bindings.length||c)&&s.push(at(t,e,o.range,`xlsx-static:${r}`,a));for(const l of o.bindings)s.push(Wt(t,e,l,n.find(f=>f.id===l.dataset)));return{components:s,flow:{componentIds:s.map(l=>l.kind==="list"?l.id:l.nid),topMm:D(t,o.range.top),heightMm:C(t,o.range)}}}function Yt(t,e,o,r){const n=ot(t,e.sheet),s={...v(n.page),components:[]},a=_t(n,e).map((i,c)=>Pt(n,e,i,c,o));if(s.components=a.flatMap(i=>i.components),s.flow={bands:a.map(i=>i.flow)},s.meta={xlsxFlow:{version:"1.0",templateId:r,sheet:e.sheet,fullWidthsMm:n.widths}},e.footerRange){const i=d(e.footerRange),c=at(n,e,i,"xlsx-footer");c.pageAnchor="footer",c.topMm=s.heightMm-(s.marginBottomMm??0)-c.heightMm,s.components.push(c)}return{...v(t.template),pages:[s]}}function $(t){return t instanceof Error?t.message:String(t)}function y(t,e,o,r){t.push({path:e,code:o,message:r})}function L(t,e,o=!1){const r=d(t);if(!k(e.range,r))throw new Error("绑定范围应完整位于来源工作表内");if(o&&r.top!==r.bottom)throw new Error("每个动态区域应选择一行原型;多个数据行由 repeat 自动扩展");return st(e,r),r}function qt(t){const e=t.cell;return!!e.formula||!!e.children?.length||e.value!==null&&e.value!==void 0&&e.value!==""||!!e.text||!!e.rawText}function Vt(t,e,o){if(!t.headerRange)return;const r=L(t.headerRange,e);if(r.left!==o.left||r.right!==o.right||r.bottom+1!==o.top)throw new Error("区域表头应与原型等列宽,并紧接原型上方");return r}function zt(t,e){const o=L(t.range,e,!0),r=Vt(t,e,o);if(st(e,{...e.range,top:r?.top??o.top,bottom:o.bottom}),A(e,o).some(s=>s.bottom!==s.top||s.left!==s.right))throw new Error("动态原型行不能包含合并格;请保留合并表头并选择其下方数据行");if(t.mode==="repeat"){const s={...e.range,top:r?.top??o.top,bottom:o.bottom};if(A(e,s).some(a=>!k({...o,top:s.top},a)&&qt(a)))throw new Error("纵向重复区域的旁列存在静态内容,无法安全拉伸;请扩大区域或将静态内容移至独立行")}return{...o,top:r?.top??o.top}}function lt(t){if(!t||t.version!=="2.0"||typeof t.sheet!="string"||!Array.isArray(t.regions)||!t.regions.length||t.regions.length>128)throw new Error("多区域绑定应为 version 2.0,并包含 1–128 个区域")}function ct(t,e){const o=[];try{lt(e)}catch(a){return[{path:"$.recipe",code:"schema",message:$(a)}]}let r;try{r=ot(t,e.sheet)}catch(a){return[{path:"$.recipe.sheet",code:"source",message:$(a)}]}const n=new Set,s=[];if(e.regions.forEach((a,i)=>{const c=`$.recipe.regions[${i}]`;try{if(!a||typeof a.id!="string"||!a.id.trim()||n.has(a.id))throw new Error("区域标识应非空且唯一");if(n.add(a.id),!["record","repeat"].includes(a.mode))throw new Error("区域模式应为 record 或 repeat");const l=zt(a,r);for(const f of s){if(rt(l,f.range))throw new Error(`区域与 ${f.path} 重叠(含表头)`);if(l.top<=f.range.bottom&&f.range.top<=l.bottom&&(a.mode==="repeat"||f.mode==="repeat"))throw new Error("同一行不能并排放置重复区域;请按纵向顺序排列");if(l.top<=f.range.bottom&&f.range.top<=l.bottom&&(l.top!==f.range.top||l.bottom!==f.range.bottom))throw new Error("并排单记录区域应使用相同的起止行(包括表头),避免不明确的位移")}s.push({range:l,mode:a.mode,path:c})}catch(l){y(o,c,"region",$(l))}}),e.footerRange)try{const a=L(e.footerRange,r);if(a.left!==r.range.left||a.right!==r.range.right||a.bottom!==r.range.bottom)throw new Error("重复页尾应覆盖完整列宽并位于来源最后几行");if(s.some(i=>i.range.bottom>=a.top))throw new Error("页尾与动态区域或区域表头相交");if(C(r,a)>=r.page.heightMm-(r.page.marginTopMm??0)-(r.page.marginBottomMm??0))throw new Error("页尾高度占满单页,不能为报表明细预留空间")}catch(a){y(o,"$.recipe.footerRange","region",$(a))}return o}function Zt(t,e){const o=new Map;for(const[r,n]of t.entries())try{if(!n||typeof n.id!="string"||!n.id.trim()||o.has(n.id))throw new Error("数据集标识应非空且唯一");F.validateDatasetRows([],{fields:n.fields,...n.rowKey?{rowKey:n.rowKey}:{}});for(const s of n.fields)if(s.digits!==void 0&&(!Number.isInteger(s.digits)||s.digits<0||s.digits>100))throw new Error("显示精度应为 0–100 的整数");o.set(n.id,n)}catch(s){y(e,`$.datasets[${r}]`,"schema",$(s))}return o}function Ut(t,e,o,r){const n=d(t.range),s=n.right-n.left+1;if(!Array.isArray(t.fields)||t.fields.length!==s)return y(r,`${o}.fields`,"mapping","区域每个物理列应显式绑定一个字段"),0;const a=new Set(e.fields.map(l=>l.field)),i=new Set;let c=0;if(t.fields.forEach((l,f)=>{!a.has(l)||i.has(l)?y(r,`${o}.fields[${f}]`,"mapping","请选择契约内已声明且不重复的字段"):(i.add(l),c++)}),!t.rowKey)y(r,`${o}.rowKey`,"row-key","每个区域应声明稳定业务主键");else{const l=F.validateDatasetRows(e.samples??[],{fields:e.fields,rowKey:t.rowKey},{path:`$.datasets.${e.id}.samples`,maxRows:100,maxIssues:30});for(const f of l.issues)y(r,f.path,f.code==="row-key"?"row-key":"schema",f.message)}for(const l of["revisionField","sourceTokenField"])t[l]!==void 0&&!a.has(t[l])&&y(r,`${o}.${l}`,"source","并发字段应引用同一区域数据集契约内的字段");return t.mode==="record"&&(e.samples?.length??0)>1&&y(r,o,"schema","record 区域数据集最多一行;多行请使用 repeat"),c}function ft(t,e){const o=[];try{lt(t)}catch(a){return{ok:!1,issues:[{path:"$.recipe",code:"schema",message:$(a)}],mapped:0,total:0}}const r=Zt(e,o);let n=0,s=0;for(const[a,i]of t.regions.entries()){const c=`$.recipe.regions[${a}]`;try{const l=d(i.range);s+=l.right-l.left+1;const f=r.get(i.dataset);f?n+=Ut(i,f,c,o):y(o,`${c}.dataset`,"source","请选择宿主提供的数据集契约")}catch(l){y(o,c,"schema",$(l))}}return{ok:o.length===0,issues:o,mapped:n,total:s}}function gt(t,e,o){const r=ft(e,o),n=[...ct(t,e),...r.issues];return{...r,ok:!n.length,issues:n}}function Qt(t,e,o,r){const n=gt(t,e,o);if(!n.ok)throw new Error(n.issues.map(s=>`${s.path}: ${s.message}`).join(`
3
3
  `));return{document:R.defineReportTemplate({...r,template:Yt(t,e,o,r.id)}),recipe:v(e),warnings:[...t.warnings]}}function Xt(t){if(!t||t.version!=="2.0"||typeof t.sheet!="string"||!Array.isArray(t.regions)||!t.regions.length||t.regions.length>128)throw new Error("多区域绑定会话配置或版本无效");for(const e of t.regions){if(!e||typeof e.id!="string"||typeof e.dataset!="string"||typeof e.rowKey!="string"||!["record","repeat"].includes(e.mode)||!Array.isArray(e.fields)||e.fields.length>2048||e.fields.some(o=>typeof o!="string"))throw new Error("多区域绑定会话的区域结构无效");e.range&&d(e.range),e.headerRange&&d(e.headerRange)}t.footerRange&&d(t.footerRange)}function ht(t,e,o){if(H({sheets:t.sheets,warnings:t.warnings,recipe:e,identity:o}),Xt(e),!Array.isArray(t.sheets)||!t.sheets.length||!Array.isArray(t.warnings)||t.warnings.some(r=>typeof r!="string")||!t.sheets.some(r=>r.name===e.sheet))throw new Error("多区域绑定会话的来源无效");for(const r of t.sheets)if(d(r.range),![r.index,r.rowCount,r.columnCount,r.pageCount].every(n=>Number.isInteger(n)&&n>0)||!Number.isInteger(r.pageStart)||r.pageStart<0||r.pageStart+r.pageCount>t.template.pages.length)throw new Error("多区域绑定会话的工作表几何无效");return R.parseReportTemplate({schemaVersion:"1.0",...o,template:t.template}),v({version:"2.0",source:t,recipe:e,identity:o})}function te(t){if(typeof t=="string"&&t.length>1e7)throw new Error("绑定会话超过 1000 万字符上限");const e=typeof t=="string"?JSON.parse(t):t;if(!e||e.version!=="2.0"||!e.source||!e.recipe||!e.identity)throw new Error("多区域绑定会话结构或版本无效");return ht(e.source,e.recipe,e.identity)}function ee(t,e,o,r=o){const n=t.sheets.find(i=>i.name===e);if(!n)throw new Error("工作表不存在");const s=d(n.range);if(![o.row,o.column,r.row,r.column].every(Number.isInteger))throw new Error("单元格坐标应为整数");const a={top:Math.min(o.row,r.row),bottom:Math.max(o.row,r.row),left:Math.min(o.column,r.column),right:Math.max(o.column,r.column)};if(a.top<s.top||a.bottom>s.bottom||a.left<s.left||a.right>s.right)throw new Error("选区超出来源工作表");return M(a)}exports.bindExcelTemplate=V;exports.checkedRange=dt;exports.columnName=S;exports.createExcelBindingDocument=Kt;exports.createExcelBindingSession=et;exports.createExcelRegionBindingDocument=Qt;exports.createExcelRegionBindingSession=ht;exports.excelBindingCellRange=ee;exports.excelBindingRowRange=Lt;exports.getExcelSheetWindow=Jt;exports.mergeLookup=Et;exports.mergeRowGroups=wt;exports.parseExcelBindingSession=Dt;exports.parseExcelRegionBindingSession=te;exports.parseImportRange=d;exports.rangeName=M;exports.rowSegments=yt;exports.selectedMerges=ut;exports.selectedRange=mt;exports.validateExcelBindingFields=X;exports.validateExcelBindingRecipe=tt;exports.validateExcelBindingRegions=Q;exports.validateExcelRegionBindings=gt;exports.validateExcelRegionFields=ft;exports.validateExcelRegionGeometry=ct;
@@ -1 +1 @@
1
- "use strict";const e=require("./encoding-BefcaHdp.cjs");e.serveReportEncodingWorker();
1
+ "use strict";const e=require("./encoding-CkziAnZI.cjs");e.serveReportEncodingWorker();
@@ -1,2 +1,2 @@
1
- import { s as r } from "./encoding-CL6rXEkR.js";
1
+ import { s as r } from "./encoding-DSc9zv2F.js";
2
2
  r();
@@ -0,0 +1,3 @@
1
+ "use strict";const u=require("./diagnostic-collector-D3rlvxm3.cjs");function m(e){const n=u.resolveFontSize(e).fontSizePt;return{runs:[],width:0,height:n*u.resolveLineHeight(e),fontSize:n}}function v(e,n,h,a){const r=e.runs[e.runs.length-1];r?.style===h?(r.text+=n,r.width+=a):e.runs.push({text:n,style:h,width:a});const o=u.resolveFontSize(h).fontSizePt;e.width+=a,e.fontSize=Math.max(e.fontSize,o),e.height=Math.max(e.height,o*u.resolveLineHeight(h))}function M(e,n,h,a,r){const o=e.richParagraphs[n],g=u.mergeComponentStyles(e.style,{...o.lineHeight===void 0?{}:{lineHeight:o.lineHeight}}),t=[m(g)];for(const s of o.segments){const c=u.mergeComponentStyles(g,s.style),d=s.kind==="field"?s.field??"":s.text??"";for(const l of d.replace(/\r\n|\r/g,`
2
+ `)){let i=t[t.length-1];if(l===`
3
+ `){t.push(m(c));continue}const f=r.measure(l,c);i.runs.length&&i.width+f>h-(t.length===1?a:0)&&(i=m(c),t.push(i)),v(i,l,c,f)}}return t}function y(e,n,h){const a=e.richParagraphs.map((t,s)=>{const c=(t.indentMm??0)*72/25.4,d=M(e,s,n.width,c,h),l=d.reduce((i,f)=>i+f.height,0)+((t.spaceBeforeMm??0)+(t.spaceAfterMm??0))*72/25.4;return{paragraph:t,indent:c,lines:d,height:l}}),r=a.reduce((t,s)=>t+s.height,0),o=e.style?.verticalAlign;let g=n.yTop-(o==="middle"?(n.height-r)/2:o==="bottom"?n.height-r:0);for(const{paragraph:t,indent:s,lines:c}of a){g-=(t.spaceBeforeMm??0)*72/25.4;const d=Math.max(0,n.width-s);for(const[l,i]of c.entries()){const f=t.align??e.style?.align,S=l===0?s:0,w=l===0?d:n.width;let z=n.x+S+(f==="center"?(w-i.width)/2:f==="right"?w-i.width:0);for(const p of i.runs)h.draw(p.text,{...p.style,align:"left"},z,g-i.fontSize,p.width),z+=p.width;g-=i.height}g-=(t.spaceAfterMm??0)*72/25.4}return r>n.height+.01}exports.drawRichText=y;
@@ -1,4 +1,4 @@
1
- import { m as z, a as M, b as S } from "./progress-ByiOxUD3.js";
1
+ import { m as z, a as M, b as S } from "./diagnostic-collector-1sqd7DQP.js";
2
2
  function p(t) {
3
3
  const n = M(t).fontSizePt;
4
4
  return { runs: [], width: 0, height: n * S(t), fontSize: n };
@@ -0,0 +1,201 @@
1
+ import { E as W, u as G } from "./diagnostic-collector-1sqd7DQP.js";
2
+ import { d as H, m as F, s as O, a as j, g as K, h as Y, i as Z, r as ee } from "./prepared-CVbgO9KR.js";
3
+ import { Q as S, R as h, S as te, N as T, H as k, n as ae, J as se, M as oe, o as re } from "./json-snapshot-BJWZNryO.js";
4
+ import { g as M } from "./report-params-D9tBuM9B.js";
5
+ import { l as _, r as ne, R as ie } from "./param-validation-CnDEd2l-.js";
6
+ import { t as P, b as x, D as ce, v as de, c as B, R as I } from "./sha256-BDQ1Qk7A.js";
7
+ import { b as me } from "./template-registry-BCBF2b8j.js";
8
+ import { T as le } from "./template-serialization-CWmHq7lX.js";
9
+ import { r as A } from "./assets-D0FbszhB.js";
10
+ import { f as ge, P as pe, e as fe } from "./record-bindings-fhav-NLG.js";
11
+ function ue(e) {
12
+ let t = `$.pages.${e.pageIndex}`;
13
+ if (e.componentIndex < 0) return t;
14
+ t += `.components.${e.componentIndex}`;
15
+ const s = e.componentPath ?? [];
16
+ for (let n = 0; n + 1 < s.length; n += 3)
17
+ t += `.grid.cells.${s[n]}.${s[n + 1]}`, s[n + 2] !== void 0 && (t += `.children.${s[n + 2]}`);
18
+ return t;
19
+ }
20
+ function C(e = []) {
21
+ return e.map((t) => ({ ...t, path: ue(t) }));
22
+ }
23
+ function xe(e, t) {
24
+ const s = G(t ?? (e.diagnosticSummary ? W : void 0));
25
+ return e.diagnosticSummary ? s.merge(e.diagnosticSummary) : e.diagnostics.forEach((n) => s.push(n)), s;
26
+ }
27
+ function J(e, t) {
28
+ t.diagnosticSummary ? e.merge({ ...t.diagnosticSummary, entries: C(t.diagnosticSummary.entries) }) : C(t.diagnostics).forEach((s) => e.push(s));
29
+ }
30
+ function we(e) {
31
+ const t = e.prepared.diagnosticSummary?.counts, s = t ? !!(t["asset-render-failed"] || t["asset-budget-exceeded"]) : e.prepared.diagnostics.some((n) => n.code === "asset-render-failed" || n.code === "asset-budget-exceeded");
32
+ if (e.fidelity === "strict" && s) throw new h("validate", "严格输出拒绝已有资产渲染降级,请修复组件后重新准备报表。");
33
+ }
34
+ async function N(e, t, s = Date.now()) {
35
+ const n = e.prepared;
36
+ H(e, t), we(e);
37
+ const a = xe(n, e.diagnosticLimit), o = e.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
38
+ P(e.signal);
39
+ const m = e.pdf?.customFontFaces ?? (e.pdf?.customFontBytes ? { regular: e.pdf.customFontBytes } : void 0), l = o && m ? o.createFontBytesMeasurer(m) : void 0, d = S(e), i = await d.run("encode", async () => {
40
+ let g;
41
+ const y = { fidelity: e.fidelity, diagnosticLimit: e.diagnosticLimit ?? (n.diagnosticSummary ? W : void 0), signal: e.signal, onProgress: (r, f) => d.progress("encode", r, f) };
42
+ if (e.format === "pdf") {
43
+ P(e.signal);
44
+ const r = await o.renderPlanToPdf(n.plan, { ...e.pdf, ...l ? { measurer: l } : {}, ...y });
45
+ g = r.bytes, J(a, r), F(a, "pdf-fidelity", r.fidelityWarnings, "warning", r.fidelityWarningCount), F(a, "pdf-page", r.pageErrors, "error", r.pageErrorCount), r.unsupportedTextCount && a.push({ code: "pdf-font", message: `${r.unsupportedTextCount} 段文本包含当前字体不支持的字符`, severity: "warning" });
46
+ } else {
47
+ const { renderPlanToXlsx: r } = await import("@agile-team/mach-report/xlsx");
48
+ P(e.signal);
49
+ const f = await r(n.plan, { ...e.xlsx, ...y });
50
+ g = new Uint8Array(f.buffer), J(a, f), F(a, "xlsx-fidelity", f.warnings, "warning", f.warningCount), f.notes?.forEach((R) => a.push({ code: "xlsx-snapshot", message: R, severity: "info" }));
51
+ }
52
+ return P(e.signal), g;
53
+ });
54
+ x(t, "maxOutputBytes", i.byteLength);
55
+ const { plan: w, ...u } = n;
56
+ return {
57
+ ...u,
58
+ diagnostics: a.entries,
59
+ ...e.diagnosticLimit === void 0 && !n.diagnosticSummary ? {} : { diagnosticSummary: a.snapshot() },
60
+ bytes: i,
61
+ format: e.format,
62
+ contentType: e.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
63
+ stats: { ...u.stats, durationMs: Date.now() - s, outputBytes: i.byteLength }
64
+ };
65
+ }
66
+ function U(e) {
67
+ return { ...e, reportIds: [...e.reportIds], ...e.params ? { params: { ...e.params } } : {} };
68
+ }
69
+ function Q(e, t) {
70
+ if (t.length === 0) throw new h("config", "缺少报表 ID");
71
+ return t.map((s) => {
72
+ if (!Object.prototype.hasOwnProperty.call(e, s)) throw new h("config", `未注册报表 ${s}`);
73
+ return e[s];
74
+ });
75
+ }
76
+ function L(e) {
77
+ return e.grid?.cells.reduce((t, s) => t + s.reduce((n, a) => n + (a ? 1 + (a.children?.reduce((o, m) => o + L(m), 0) ?? 0) : 0), 0), 0) ?? 0;
78
+ }
79
+ function ye(e, t, s) {
80
+ return e.pages.reduce((n, a) => n + a.components.reduce((o, m) => m.kind !== "list" ? o + L(m) : o + re(m, t, s), 0), 0);
81
+ }
82
+ function he(e, t = Object.keys(e)) {
83
+ return Q(e, t).map((s, n) => {
84
+ const a = t[n], o = M(e, [a]);
85
+ return {
86
+ id: a,
87
+ params: JSON.parse(JSON.stringify(o)),
88
+ paramsSchema: ne(o),
89
+ datasetsSchema: Object.fromEntries(Object.entries(s.dataSchema ?? {}).map(([m, l]) => [m, te(typeof s.template == "function" ? void 0 : s.template, m, l)])),
90
+ capabilities: {
91
+ save: !!s.provider?.save,
92
+ export: !!s.provider?.export,
93
+ templates: !!s.provider?.templates
94
+ }
95
+ };
96
+ });
97
+ }
98
+ function X(e, t) {
99
+ Q(e, t.reportIds);
100
+ const s = _(M(e, t.reportIds), t.params), n = t.reportIds.flatMap((o) => _(M(e, [o]), t.params).issues), a = new Map(n.map((o) => [JSON.stringify(o), o]));
101
+ return { ...s, ok: a.size === 0, issues: [...a.values()] };
102
+ }
103
+ function V(e, t) {
104
+ const s = me(e.plan);
105
+ if (!s.ok) throw new h("validate", `执行器返回无效计划:${s.errors[0]?.path}`);
106
+ const n = e.plan.pages.length, a = e.plan.pages.reduce((o, m) => o + m.components.reduce((l, d) => l + L(d), 0), 0);
107
+ return x(t, "maxRows", e.stats.rows), x(t, "maxPages", n), x(t, "maxCells", a), { ...e, stats: { ...e.stats, pages: n, cells: a } };
108
+ }
109
+ function q(e, t) {
110
+ const s = X(e.reports, t);
111
+ if (!s.ok) throw new ie(s.issues);
112
+ }
113
+ function Fe(e) {
114
+ const t = { ...ce, ...e.budget };
115
+ de(t);
116
+ const s = async (a, o) => {
117
+ const m = Date.now();
118
+ let l = 0, d = 0;
119
+ const i = G(a.diagnosticLimit), w = {}, u = [], g = Object.fromEntries(Object.entries(e.reports).map(([c, p]) => [c, {
120
+ ...p,
121
+ pagination: { ...e.pagination, ...p.pagination, ...o ? { measurer: o } : {} },
122
+ dataValidation: {
123
+ ...p.dataValidation,
124
+ maxRows: Math.min(t.maxRows ?? 1e5, p.dataValidation?.maxRows ?? 1 / 0),
125
+ maxCells: Math.min(t.maxCells ?? 2e6, p.dataValidation?.maxCells ?? 1 / 0)
126
+ }
127
+ }])), r = await ae(g, { maxPages: t.maxPages, maxCells: t.maxCells, maxChartComponents: t.maxChartComponents, onDatasets: (c, p, v) => {
128
+ try {
129
+ l += se(v, p, { maxRows: t.maxRows, signal: a.signal });
130
+ } catch (b) {
131
+ throw b instanceof le ? new I("budget", b.message, "$.budget.maxRows") : b;
132
+ }
133
+ x(t, "maxRows", l), d += ye(v, p, g[c]?.pagination), x(t, "maxCells", d);
134
+ } })({ ...a, params: a.params ?? {}, onWarning: (c) => i.push({ code: "layout", message: c, severity: "warning" }), onQueryResult: (c, p, v = 0) => {
135
+ const b = oe(v, c);
136
+ Object.defineProperty(w, c, { value: { revision: p.revision, sourceToken: p.sourceToken }, enumerable: !0, writable: !0 }), u.push({ reportId: c, reportIndex: v, reportScope: b, ...p.revision === void 0 ? {} : { revision: p.revision }, ...p.sourceToken === void 0 ? {} : { sourceToken: p.sourceToken } }), (p.diagnostics ?? []).forEach((E) => i.push({ ...E, ...E.target ? { target: {
137
+ ...E.target,
138
+ reportScope: b,
139
+ ...E.target.tableId ? { tableId: JSON.stringify([v, c, E.target.tableId]) } : {}
140
+ } } : {} }));
141
+ } }).catch((c) => {
142
+ throw c instanceof h && c.cause instanceof ge ? new I("budget", c.cause.message, "$.budget.maxPages") : c instanceof h && c.cause instanceof pe ? new I("budget", c.cause.message, "$.budget.maxCells") : c instanceof h && c.cause instanceof fe ? new I("budget", c.cause.message, "$.budget.maxChartComponents") : c;
143
+ });
144
+ P(a.signal);
145
+ const f = e.assets ? await S(a).run("assets", () => A(r, { ...e.assets, diagnosticLimit: a.diagnosticLimit, signal: a.signal })) : { plan: r, diagnostics: [] }, R = f.plan;
146
+ f.diagnosticSummary ? i.merge({ ...f.diagnosticSummary, entries: C(f.diagnosticSummary.entries) }) : C(f.diagnostics).forEach((c) => i.push(c));
147
+ const $ = R.pages.reduce((c, p) => c + p.components.reduce((v, b) => v + L(b), 0), 0);
148
+ x(t, "maxPages", R.pages.length), x(t, "maxCells", $);
149
+ const D = ee(a.pdf), z = e.pagination?.measurer || Object.values(e.reports).some((c) => c.pagination?.measurer);
150
+ return { plan: R, diagnostics: i.entries, ...a.diagnosticLimit === void 0 ? {} : { diagnosticSummary: i.snapshot() }, revisions: w, sources: u, layout: { textMetrics: D ? "font-bytes" : z ? "provided" : "heuristic", ...D ? { fontFingerprint: D } : {} }, stats: { rows: l, pages: R.pages.length, cells: $, durationMs: Date.now() - m } };
151
+ }, n = async (a) => {
152
+ const o = Date.now();
153
+ if (a.format !== "pdf" && a.format !== "xlsx") throw new h("config", "不支持的报表导出格式");
154
+ const m = a.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
155
+ P(a.signal);
156
+ const l = a.pdf?.customFontFaces ?? (a.pdf?.customFontBytes ? { regular: a.pdf.customFontBytes } : void 0), d = m && l ? m.createFontBytesMeasurer(l) : void 0, i = await s(a, d);
157
+ return P(a.signal), N({ ...a, prepared: i }, t, o);
158
+ };
159
+ return {
160
+ describe: (a) => he(e.reports, a),
161
+ validate: (a) => X(e.reports, a),
162
+ prepare: (a) => B(a.signal, t.maxDurationMs, async (o) => {
163
+ const { signal: m, onEvent: l, ...d } = U(a), i = { ...d, ...d.pdf ? { pdf: O(d.pdf) } : {}, taskId: d.taskId ?? T() }, w = l ? (f) => k(l, f, o) : void 0, u = { ...i, signal: o, onEvent: w };
164
+ S(u).runSync("validate", () => q(e, i));
165
+ let g;
166
+ const y = i.pdf?.customFontFaces ?? (i.pdf?.customFontBytes ? { regular: i.pdf.customFontBytes } : void 0);
167
+ if (!e.executor && y) {
168
+ const f = await import("@agile-team/mach-report/pdf");
169
+ P(o), g = f.createFontBytesMeasurer(y);
170
+ }
171
+ const r = e.executor ? await e.executor.prepare(i, o, w) : await s(u, g);
172
+ return V(r, t);
173
+ }),
174
+ exportPrepared: (a) => B(a.signal, t.maxDurationMs, async (o) => {
175
+ const m = Date.now(), { signal: l, onEvent: d, ...i } = a, w = V(K(a.prepared, t.maxPreparedBytes ?? 64e6, o), t), u = { ...i, xlsx: j(i.xlsx), prepared: w, ...i.pdf ? { pdf: O(i.pdf) } : {}, taskId: i.taskId ?? T() };
176
+ if (u.format !== "pdf" && u.format !== "xlsx") throw new h("config", "不支持的报表导出格式");
177
+ const g = d ? (r) => k(d, r, o) : void 0;
178
+ if (e.executor) {
179
+ if (!e.executor.exportPrepared) throw new h("config", "执行器未实现 exportPrepared;请升级执行器或显式使用本地运行时");
180
+ const r = await e.executor.exportPrepared(u, o, g);
181
+ return x(t, "maxRows", r.stats.rows), x(t, "maxPages", r.stats.pages), x(t, "maxCells", r.stats.cells), x(t, "maxOutputBytes", r.bytes.byteLength), { ...r, stats: { ...r.stats, outputBytes: r.bytes.byteLength } };
182
+ }
183
+ const y = { ...u, signal: o, onEvent: g };
184
+ if (S(y).runSync("validate", () => Y(y)), e.assets) {
185
+ const r = await S(y).run("assets", () => A(w.plan, { ...e.assets, diagnosticLimit: a.diagnosticLimit, signal: o }));
186
+ w.plan = r.plan, Z(w, C(r.diagnostics), r.diagnosticSummary ? { ...r.diagnosticSummary, entries: C(r.diagnosticSummary.entries) } : void 0, a.diagnosticLimit);
187
+ }
188
+ return N(y, t, m);
189
+ }),
190
+ export: (a) => B(a.signal, t.maxDurationMs, async (o) => {
191
+ const { signal: m, onEvent: l, ...d } = U(a), i = { ...d, xlsx: j(d.xlsx), ...d.pdf ? { pdf: O(d.pdf) } : {}, taskId: d.taskId ?? T() }, w = l ? (y) => k(l, y, o) : void 0, u = { ...i, signal: o, onEvent: w };
192
+ if (S(u).runSync("validate", () => q(e, i)), i.format !== "pdf" && i.format !== "xlsx") throw new h("config", "不支持的报表导出格式");
193
+ const g = e.executor ? await e.executor.export(i, o, w) : await n(u);
194
+ return x(t, "maxRows", g.stats.rows), x(t, "maxPages", g.stats.pages), x(t, "maxCells", g.stats.cells), x(t, "maxOutputBytes", g.bytes.byteLength), { ...g, stats: { ...g.stats, outputBytes: g.bytes.byteLength } };
195
+ })
196
+ };
197
+ }
198
+ export {
199
+ Fe as c,
200
+ V as e
201
+ };
@@ -0,0 +1 @@
1
+ "use strict";var V=Object.create;var M=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var Q=(e,t,a,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of W(t))!z.call(e,s)&&s!==a&&M(e,s,{get:()=>t[s],enumerable:!(o=G(t,s))||o.enumerable});return e};var I=(e,t,a)=>(a=e!=null?V(X(e)):{},Q(t||!e||!e.__esModule?M(a,"default",{value:e,enumerable:!0}):a,e));const B=require("./diagnostic-collector-D3rlvxm3.cjs"),v=require("./prepared-DAwe8Il2.cjs"),d=require("./json-snapshot-C7QZrRBf.cjs"),L=require("./report-params-VTg8MoCp.cjs"),C=require("./param-validation-C-8sRJLq.cjs"),i=require("./sha256-DgZAKXqI.cjs"),H=require("./template-registry-Bnh5aEYf.cjs"),K=require("./template-serialization-CqQY4zDg.cjs"),A=require("./assets-B4AJIOTB.cjs"),k=require("./record-bindings-CAyM5tGg.cjs");function Y(e){let t=`$.pages.${e.pageIndex}`;if(e.componentIndex<0)return t;t+=`.components.${e.componentIndex}`;const a=e.componentPath??[];for(let o=0;o+1<a.length;o+=3)t+=`.grid.cells.${a[o]}.${a[o+1]}`,a[o+2]!==void 0&&(t+=`.children.${a[o+2]}`);return t}function S(e=[]){return e.map(t=>({...t,path:Y(t)}))}function Z(e,t){const a=B.createDiagnosticCollector(t??(e.diagnosticSummary?B.DEFAULT_DIAGNOSTIC_LIMIT:void 0));return e.diagnosticSummary?a.merge(e.diagnosticSummary):e.diagnostics.forEach(o=>a.push(o)),a}function $(e,t){t.diagnosticSummary?e.merge({...t.diagnosticSummary,entries:S(t.diagnosticSummary.entries)}):S(t.diagnostics).forEach(a=>e.push(a))}function ee(e){const t=e.prepared.diagnosticSummary?.counts,a=t?!!(t["asset-render-failed"]||t["asset-budget-exceeded"]):e.prepared.diagnostics.some(o=>o.code==="asset-render-failed"||o.code==="asset-budget-exceeded");if(e.fidelity==="strict"&&a)throw new d.ReportSourceError("validate","严格输出拒绝已有资产渲染降级,请修复组件后重新准备报表。")}async function q(e,t,a=Date.now()){const o=e.prepared;v.assertPreparedOutputBudget(e,t),ee(e);const s=Z(o,e.diagnosticLimit),r=e.format==="pdf"?await import("@agile-team/mach-report/pdf"):void 0;i.throwIfAborted(e.signal);const g=e.pdf?.customFontFaces??(e.pdf?.customFontBytes?{regular:e.pdf.customFontBytes}:void 0),l=r&&g?r.createFontBytesMeasurer(g):void 0,m=d.createReportTaskReporter(e),c=await m.run("encode",async()=>{let u;const y={fidelity:e.fidelity,diagnosticLimit:e.diagnosticLimit??(o.diagnosticSummary?B.DEFAULT_DIAGNOSTIC_LIMIT:void 0),signal:e.signal,onProgress:(n,x)=>m.progress("encode",n,x)};if(e.format==="pdf"){i.throwIfAborted(e.signal);const n=await r.renderPlanToPdf(o.plan,{...e.pdf,...l?{measurer:l}:{},...y});u=n.bytes,$(s,n),v.mergeDiagnosticMessages(s,"pdf-fidelity",n.fidelityWarnings,"warning",n.fidelityWarningCount),v.mergeDiagnosticMessages(s,"pdf-page",n.pageErrors,"error",n.pageErrorCount),n.unsupportedTextCount&&s.push({code:"pdf-font",message:`${n.unsupportedTextCount} 段文本包含当前字体不支持的字符`,severity:"warning"})}else{const{renderPlanToXlsx:n}=await import("@agile-team/mach-report/xlsx");i.throwIfAborted(e.signal);const x=await n(o.plan,{...e.xlsx,...y});u=new Uint8Array(x.buffer),$(s,x),v.mergeDiagnosticMessages(s,"xlsx-fidelity",x.warnings,"warning",x.warningCount),x.notes?.forEach(P=>s.push({code:"xlsx-snapshot",message:P,severity:"info"}))}return i.throwIfAborted(e.signal),u});i.assertBudget(t,"maxOutputBytes",c.byteLength);const{plan:h,...w}=o;return{...w,diagnostics:s.entries,...e.diagnosticLimit===void 0&&!o.diagnosticSummary?{}:{diagnosticSummary:s.snapshot()},bytes:c,format:e.format,contentType:e.format==="pdf"?"application/pdf":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",stats:{...w.stats,durationMs:Date.now()-a,outputBytes:c.byteLength}}}function _(e){return{...e,reportIds:[...e.reportIds],...e.params?{params:{...e.params}}:{}}}function N(e,t){if(t.length===0)throw new d.ReportSourceError("config","缺少报表 ID");return t.map(a=>{if(!Object.prototype.hasOwnProperty.call(e,a))throw new d.ReportSourceError("config",`未注册报表 ${a}`);return e[a]})}function T(e){return e.grid?.cells.reduce((t,a)=>t+a.reduce((o,s)=>o+(s?1+(s.children?.reduce((r,g)=>r+T(g),0)??0):0),0),0)??0}function te(e,t,a){return e.pages.reduce((o,s)=>o+s.components.reduce((r,g)=>g.kind!=="list"?r+T(g):r+d.estimateListLayoutCells(g,t,a),0),0)}function se(e,t=Object.keys(e)){return N(e,t).map((a,o)=>{const s=t[o],r=L.getReportParamDefs(e,[s]);return{id:s,params:JSON.parse(JSON.stringify(r)),paramsSchema:C.reportParamsJsonSchema(r),datasetsSchema:Object.fromEntries(Object.entries(a.dataSchema??{}).map(([g,l])=>[g,d.templateDatasetJsonSchema(typeof a.template=="function"?void 0:a.template,g,l)])),capabilities:{save:!!a.provider?.save,export:!!a.provider?.export,templates:!!a.provider?.templates}}})}function J(e,t){N(e,t.reportIds);const a=C.validateReportParams(L.getReportParamDefs(e,t.reportIds),t.params),o=t.reportIds.flatMap(r=>C.validateReportParams(L.getReportParamDefs(e,[r]),t.params).issues),s=new Map(o.map(r=>[JSON.stringify(r),r]));return{...a,ok:s.size===0,issues:[...s.values()]}}function F(e,t){const a=H.validateRenderPlan(e.plan);if(!a.ok)throw new d.ReportSourceError("validate",`执行器返回无效计划:${a.errors[0]?.path}`);const o=e.plan.pages.length,s=e.plan.pages.reduce((r,g)=>r+g.components.reduce((l,m)=>l+T(m),0),0);return i.assertBudget(t,"maxRows",e.stats.rows),i.assertBudget(t,"maxPages",o),i.assertBudget(t,"maxCells",s),{...e,stats:{...e.stats,pages:o,cells:s}}}function j(e,t){const a=J(e.reports,t);if(!a.ok)throw new C.ReportParamValidationError(a.issues)}function ae(e){const t={...i.DEFAULT_REPORT_RUNTIME_BUDGET,...e.budget};i.validateBudget(t);const a=async(s,r)=>{const g=Date.now();let l=0,m=0;const c=B.createDiagnosticCollector(s.diagnosticLimit),h={},w=[],u=Object.fromEntries(Object.entries(e.reports).map(([p,f])=>[p,{...f,pagination:{...e.pagination,...f.pagination,...r?{measurer:r}:{}},dataValidation:{...f.dataValidation,maxRows:Math.min(t.maxRows??1e5,f.dataValidation?.maxRows??1/0),maxCells:Math.min(t.maxCells??2e6,f.dataValidation?.maxCells??1/0)}}])),n=await d.createReportSource(u,{maxPages:t.maxPages,maxCells:t.maxCells,maxChartComponents:t.maxChartComponents,onDatasets:(p,f,R)=>{try{l+=d.templateDatasetRowCount(R,f,{maxRows:t.maxRows,signal:s.signal})}catch(b){throw b instanceof K.TreeRowLimitError?new i.ReportRuntimeError("budget",b.message,"$.budget.maxRows"):b}i.assertBudget(t,"maxRows",l),m+=te(R,f,u[p]?.pagination),i.assertBudget(t,"maxCells",m)}})({...s,params:s.params??{},onWarning:p=>c.push({code:"layout",message:p,severity:"warning"}),onQueryResult:(p,f,R=0)=>{const b=d.reportOccurrenceScope(R,p);Object.defineProperty(h,p,{value:{revision:f.revision,sourceToken:f.sourceToken},enumerable:!0,writable:!0}),w.push({reportId:p,reportIndex:R,reportScope:b,...f.revision===void 0?{}:{revision:f.revision},...f.sourceToken===void 0?{}:{sourceToken:f.sourceToken}}),(f.diagnostics??[]).forEach(E=>c.push({...E,...E.target?{target:{...E.target,reportScope:b,...E.target.tableId?{tableId:JSON.stringify([R,p,E.target.tableId])}:{}}}:{}}))}}).catch(p=>{throw p instanceof d.ReportSourceError&&p.cause instanceof k.PaginatePageLimitError?new i.ReportRuntimeError("budget",p.cause.message,"$.budget.maxPages"):p instanceof d.ReportSourceError&&p.cause instanceof k.PaginateCellLimitError?new i.ReportRuntimeError("budget",p.cause.message,"$.budget.maxCells"):p instanceof d.ReportSourceError&&p.cause instanceof k.PaginateChartComponentLimitError?new i.ReportRuntimeError("budget",p.cause.message,"$.budget.maxChartComponents"):p});i.throwIfAborted(s.signal);const x=e.assets?await d.createReportTaskReporter(s).run("assets",()=>A.resolvePlanAssets(n,{...e.assets,diagnosticLimit:s.diagnosticLimit,signal:s.signal})):{plan:n,diagnostics:[]},P=x.plan;x.diagnosticSummary?c.merge({...x.diagnosticSummary,entries:S(x.diagnosticSummary.entries)}):S(x.diagnostics).forEach(p=>c.push(p));const O=P.pages.reduce((p,f)=>p+f.components.reduce((R,b)=>R+T(b),0),0);i.assertBudget(t,"maxPages",P.pages.length),i.assertBudget(t,"maxCells",O);const D=v.reportFontFingerprint(s.pdf),U=e.pagination?.measurer||Object.values(e.reports).some(p=>p.pagination?.measurer);return{plan:P,diagnostics:c.entries,...s.diagnosticLimit===void 0?{}:{diagnosticSummary:c.snapshot()},revisions:h,sources:w,layout:{textMetrics:D?"font-bytes":U?"provided":"heuristic",...D?{fontFingerprint:D}:{}},stats:{rows:l,pages:P.pages.length,cells:O,durationMs:Date.now()-g}}},o=async s=>{const r=Date.now();if(s.format!=="pdf"&&s.format!=="xlsx")throw new d.ReportSourceError("config","不支持的报表导出格式");const g=s.format==="pdf"?await import("@agile-team/mach-report/pdf"):void 0;i.throwIfAborted(s.signal);const l=s.pdf?.customFontFaces??(s.pdf?.customFontBytes?{regular:s.pdf.customFontBytes}:void 0),m=g&&l?g.createFontBytesMeasurer(l):void 0,c=await a(s,m);return i.throwIfAborted(s.signal),q({...s,prepared:c},t,r)};return{describe:s=>se(e.reports,s),validate:s=>J(e.reports,s),prepare:s=>i.controlled(s.signal,t.maxDurationMs,async r=>{const{signal:g,onEvent:l,...m}=_(s),c={...m,...m.pdf?{pdf:v.snapshotPdfFonts(m.pdf)}:{},taskId:m.taskId??d.reportTaskId()},h=l?x=>d.notifyReportTaskEvent(l,x,r):void 0,w={...c,signal:r,onEvent:h};d.createReportTaskReporter(w).runSync("validate",()=>j(e,c));let u;const y=c.pdf?.customFontFaces??(c.pdf?.customFontBytes?{regular:c.pdf.customFontBytes}:void 0);if(!e.executor&&y){const x=await import("@agile-team/mach-report/pdf");i.throwIfAborted(r),u=x.createFontBytesMeasurer(y)}const n=e.executor?await e.executor.prepare(c,r,h):await a(w,u);return F(n,t)}),exportPrepared:s=>i.controlled(s.signal,t.maxDurationMs,async r=>{const g=Date.now(),{signal:l,onEvent:m,...c}=s,h=F(v.snapshotPreparedReport(s.prepared,t.maxPreparedBytes??64e6,r),t),w={...c,xlsx:v.snapshotXlsxOptions(c.xlsx),prepared:h,...c.pdf?{pdf:v.snapshotPdfFonts(c.pdf)}:{},taskId:c.taskId??d.reportTaskId()};if(w.format!=="pdf"&&w.format!=="xlsx")throw new d.ReportSourceError("config","不支持的报表导出格式");const u=m?n=>d.notifyReportTaskEvent(m,n,r):void 0;if(e.executor){if(!e.executor.exportPrepared)throw new d.ReportSourceError("config","执行器未实现 exportPrepared;请升级执行器或显式使用本地运行时");const n=await e.executor.exportPrepared(w,r,u);return i.assertBudget(t,"maxRows",n.stats.rows),i.assertBudget(t,"maxPages",n.stats.pages),i.assertBudget(t,"maxCells",n.stats.cells),i.assertBudget(t,"maxOutputBytes",n.bytes.byteLength),{...n,stats:{...n.stats,outputBytes:n.bytes.byteLength}}}const y={...w,signal:r,onEvent:u};if(d.createReportTaskReporter(y).runSync("validate",()=>v.checkPreparedFont(y)),e.assets){const n=await d.createReportTaskReporter(y).run("assets",()=>A.resolvePlanAssets(h.plan,{...e.assets,diagnosticLimit:s.diagnosticLimit,signal:r}));h.plan=n.plan,v.appendPreparedDiagnostics(h,S(n.diagnostics),n.diagnosticSummary?{...n.diagnosticSummary,entries:S(n.diagnosticSummary.entries)}:void 0,s.diagnosticLimit)}return q(y,t,g)}),export:s=>i.controlled(s.signal,t.maxDurationMs,async r=>{const{signal:g,onEvent:l,...m}=_(s),c={...m,xlsx:v.snapshotXlsxOptions(m.xlsx),...m.pdf?{pdf:v.snapshotPdfFonts(m.pdf)}:{},taskId:m.taskId??d.reportTaskId()},h=l?y=>d.notifyReportTaskEvent(l,y,r):void 0,w={...c,signal:r,onEvent:h};if(d.createReportTaskReporter(w).runSync("validate",()=>j(e,c)),c.format!=="pdf"&&c.format!=="xlsx")throw new d.ReportSourceError("config","不支持的报表导出格式");const u=e.executor?await e.executor.export(c,r,h):await o(w);return i.assertBudget(t,"maxRows",u.stats.rows),i.assertBudget(t,"maxPages",u.stats.pages),i.assertBudget(t,"maxCells",u.stats.cells),i.assertBudget(t,"maxOutputBytes",u.bytes.byteLength),{...u,stats:{...u.stats,outputBytes:u.bytes.byteLength}}})}}exports.createReportRuntime=ae;exports.enforcePrepared=F;
@@ -6,7 +6,7 @@
6
6
  "component": {
7
7
  "type": "library",
8
8
  "name": "@agile-team/mach-report",
9
- "version": "2.23.0"
9
+ "version": "2.24.0"
10
10
  },
11
11
  "properties": [
12
12
  {
@@ -97,6 +97,19 @@ export declare function createNodeAutoReportExporter(options?: Omit<ReportExport
97
97
  /** 独立 worker_threads 适配器;worker 入口注册自己的模板/Provider,不把函数跨线程序列化。 */
98
98
  export declare function createNodeReportExecutor(options: NodeReportExecutorOptions): ReportRuntimeExecutor;
99
99
 
100
+ /** Bounded detail window with exact occurrence totals. Unknown business codes beyond 128 buckets share `other`. */
101
+ declare interface DiagnosticSummary<T> {
102
+ readonly total: number;
103
+ readonly counts: Readonly<Record<string, number>>;
104
+ readonly entries: readonly T[];
105
+ readonly omitted: number;
106
+ /** Business value explanations form a separate presentation channel, including omitted locations. */
107
+ readonly explanations?: {
108
+ readonly total: number;
109
+ readonly counts: Readonly<Record<string, number>>;
110
+ };
111
+ }
112
+
100
113
  export declare interface FileReportDocumentStore extends ReportDocumentStore {
101
114
  close(): Promise<void>;
102
115
  }
@@ -171,6 +184,26 @@ export declare function openFileReportDocumentStore(options: FileReportDocumentS
171
184
  /** Durable local store with one process owner; database adapters provide multi-instance atomic CAS. */
172
185
  export declare function openFileReportJobStore(options: FileReportJobStoreOptions): Promise<FileReportJobStore>;
173
186
 
187
+ declare interface OutputDiagnostic {
188
+ code: "invalid-image-data" | "image-budget-exceeded" | "component-render-failed" | "unsupported-text" | "output-degraded" | "missing-image" | "unsupported-component" | "unsupported-image-format" | "unsupported-style" | "rich-text-flattened" | "nested-components-omitted" | "async-image-required" | "image-decode-failed" | "asset-render-failed" | "asset-budget-exceeded";
189
+ severity: "warning";
190
+ format: OutputFormat;
191
+ pageIndex: number;
192
+ componentIndex: number;
193
+ /** Nested grid child location as repeating [rowIndex, columnIndex, childIndex] triples. */
194
+ componentPath?: readonly number[];
195
+ kind: string;
196
+ nid?: string;
197
+ /** Declarative extension identity only; no property values or business binding data enter diagnostics. */
198
+ extension?: {
199
+ id: string;
200
+ version: string;
201
+ };
202
+ message: string;
203
+ }
204
+
205
+ declare type OutputFormat = "dom" | "canvas" | "pdf" | "xlsx";
206
+
174
207
  declare interface PlanComponent {
175
208
  /** Template-only aggregate binding, expanded into shared primitives during layout. */
176
209
  chartBinding?: ReportChartBinding;
@@ -245,6 +278,8 @@ declare interface PlanTableFragment {
245
278
  declare interface PreparedReport {
246
279
  plan: RenderPlan;
247
280
  diagnostics: ReportDiagnostic[];
281
+ /** Present when an explicit diagnosticLimit bounds the detail array. Totals include omitted locations. */
282
+ diagnosticSummary?: DiagnosticSummary<ReportDiagnostic>;
248
283
  stats: ReportRuntimeStats;
249
284
  revisions: Record<string, {
250
285
  revision?: string;
@@ -349,7 +384,7 @@ declare interface ReportDescription {
349
384
  };
350
385
  }
351
386
 
352
- declare interface ReportDiagnostic {
387
+ declare interface ReportDiagnostic extends Partial<Pick<OutputDiagnostic, "format" | "pageIndex" | "componentIndex" | "componentPath" | "kind" | "nid" | "extension">> {
353
388
  code: string;
354
389
  message: string;
355
390
  path?: string;
@@ -576,6 +611,15 @@ declare interface ReportPdfFontOptions {
576
611
  };
577
612
  }
578
613
 
614
+ /** One ordered query occurrence, shared by browser editing and Node preparation. */
615
+ declare interface ReportQuerySource {
616
+ reportId: string;
617
+ reportIndex: number;
618
+ reportScope: string;
619
+ revision?: string;
620
+ sourceToken?: string;
621
+ }
622
+
579
623
  declare interface ReportRuntime {
580
624
  describe(reportIds?: string[]): ReportDescription[];
581
625
  validate(input: Omit<ReportRuntimeInput, "signal">): ReportParamValidation;
@@ -629,6 +673,8 @@ declare interface ReportRuntimeInput extends ReportTaskMonitoring {
629
673
  reportIds: string[];
630
674
  params?: Record<string, string>;
631
675
  signal?: AbortSignal;
676
+ /** Explicit bounded diagnostic detail window (0–1000); default retains all details. */
677
+ diagnosticLimit?: number;
632
678
  /** Prepare using the same licensed font bytes later supplied to PDF output. */
633
679
  pdf?: ReportPdfFontOptions;
634
680
  }
@@ -640,18 +686,16 @@ declare interface ReportRuntimePreparedExportInput extends ReportTaskMonitoring
640
686
  layoutPolicy?: "verify" | "preserve";
641
687
  format: ReportRuntimeExportInput["format"];
642
688
  fidelity?: ReportRuntimeExportInput["fidelity"];
689
+ diagnosticLimit?: number;
643
690
  pdf?: ReportPdfFontOptions;
644
691
  xlsx?: ReportRuntimeExportInput["xlsx"];
645
692
  signal?: AbortSignal;
646
693
  }
647
694
 
648
695
  /** One query occurrence; repeated report IDs retain independent provenance. */
649
- declare interface ReportRuntimeSource {
650
- reportId: string;
651
- reportIndex: number;
652
- reportScope: string;
653
- revision?: string;
654
- sourceToken?: string;
696
+ declare interface ReportRuntimeSource extends ReportQuerySource {
697
+ /** Runtime provenance uses the same ordered occurrence scope as the query session. */
698
+ reportScope: ReportQuerySource["reportScope"];
655
699
  }
656
700
 
657
701
  declare interface ReportRuntimeStats {
@@ -689,6 +733,8 @@ export declare class ReportWorkerError extends Error {
689
733
  readonly path?: string;
690
734
  readonly issues?: unknown;
691
735
  readonly diagnostics?: unknown;
736
+ readonly diagnosticSummary?: DiagnosticSummary<Record<string, unknown>>;
737
+ readonly issueSummary?: DiagnosticSummary<Record<string, string>>;
692
738
  constructor(error: SerializedReportError);
693
739
  }
694
740
 
@@ -720,6 +766,8 @@ declare interface SerializedReportError {
720
766
  path?: string;
721
767
  issues?: unknown;
722
768
  diagnostics?: unknown;
769
+ diagnosticSummary?: DiagnosticSummary<Record<string, unknown>>;
770
+ issueSummary?: DiagnosticSummary<Record<string, string>>;
723
771
  }
724
772
 
725
773
  /** Node Worker 入口调用;主线程调用会明确报错。 */