@worm-vue3-print/canvas 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +54 -0
  2. package/dist/canvas.css +1 -0
  3. package/dist/components/CanvasArea.vue.d.ts +102 -0
  4. package/dist/components/CanvasPaper.vue.d.ts +50 -0
  5. package/dist/components/DesignerToolbar.vue.d.ts +59 -0
  6. package/dist/components/ExpressionEditor.vue.d.ts +16 -0
  7. package/dist/components/FieldTreePanel.vue.d.ts +11 -0
  8. package/dist/components/LayerPanel.vue.d.ts +14 -0
  9. package/dist/components/LeftPanel.vue.d.ts +24 -0
  10. package/dist/components/PresetColorPicker.vue.d.ts +10 -0
  11. package/dist/components/PrintDesigner.vue.d.ts +27 -0
  12. package/dist/components/PrintHtmlPreview.vue.d.ts +23 -0
  13. package/dist/components/PropertyPanel.vue.d.ts +23 -0
  14. package/dist/components/Ruler.vue.d.ts +12 -0
  15. package/dist/components/StatusBar.vue.d.ts +14 -0
  16. package/dist/components/WatermarkConfig.vue.d.ts +12 -0
  17. package/dist/components/elements/BarcodeElement.vue.d.ts +9 -0
  18. package/dist/components/elements/BaseElement.vue.d.ts +45 -0
  19. package/dist/components/elements/CellBarcode.vue.d.ts +10 -0
  20. package/dist/components/elements/HtmlElement.vue.d.ts +9 -0
  21. package/dist/components/elements/ImageElement.vue.d.ts +9 -0
  22. package/dist/components/elements/LineElement.vue.d.ts +7 -0
  23. package/dist/components/elements/LongTextElement.vue.d.ts +9 -0
  24. package/dist/components/elements/PageNumberElement.vue.d.ts +9 -0
  25. package/dist/components/elements/QrcodeElement.vue.d.ts +9 -0
  26. package/dist/components/elements/ShapeElement.vue.d.ts +7 -0
  27. package/dist/components/elements/TableContextMenu.vue.d.ts +19 -0
  28. package/dist/components/elements/TableElement.vue.d.ts +17 -0
  29. package/dist/components/elements/TextElement.vue.d.ts +9 -0
  30. package/dist/components/property/AdvancedGroup.vue.d.ts +13 -0
  31. package/dist/components/property/AppearanceGroup.vue.d.ts +10 -0
  32. package/dist/components/property/BindingControl.vue.d.ts +13 -0
  33. package/dist/components/property/BorderBgGroup.vue.d.ts +9 -0
  34. package/dist/components/property/CodeGroup.vue.d.ts +13 -0
  35. package/dist/components/property/ImageContentUpload.vue.d.ts +10 -0
  36. package/dist/components/property/PaginationGroup.vue.d.ts +9 -0
  37. package/dist/components/property/PositionSizeGroup.vue.d.ts +9 -0
  38. package/dist/components/property/PropertyGroup.vue.d.ts +19 -0
  39. package/dist/components/property/PropertySearch.vue.d.ts +7 -0
  40. package/dist/components/property/TableCellGroup.vue.d.ts +12 -0
  41. package/dist/components/property/TableRowGroup.vue.d.ts +8 -0
  42. package/dist/components/property/TableSettingsGroup.vue.d.ts +8 -0
  43. package/dist/composables/useAdsorb.d.ts +26 -0
  44. package/dist/composables/useAdsorbManager.d.ts +31 -0
  45. package/dist/composables/useAlign.d.ts +5 -0
  46. package/dist/composables/useBindingDisplay.d.ts +11 -0
  47. package/dist/composables/useClipboard.d.ts +251 -0
  48. package/dist/composables/useDesignerState.d.ts +1149 -0
  49. package/dist/composables/useDrag.d.ts +51 -0
  50. package/dist/composables/useGroup.d.ts +7 -0
  51. package/dist/composables/useGuides.d.ts +12 -0
  52. package/dist/composables/useHistory.d.ts +31 -0
  53. package/dist/composables/useHostAdapter.d.ts +4 -0
  54. package/dist/composables/useKeyboard.d.ts +22 -0
  55. package/dist/composables/useResize.d.ts +26 -0
  56. package/dist/composables/useSelection.d.ts +26 -0
  57. package/dist/composables/useStudioChrome.d.ts +8 -0
  58. package/dist/composables/useTableSelection.d.ts +10 -0
  59. package/dist/index.cjs +4 -0
  60. package/dist/index.cjs.map +1 -0
  61. package/dist/index.d.ts +9 -0
  62. package/dist/index.js +6444 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/render/browser-code-renderer.d.ts +3 -0
  65. package/dist/render/browser-pagination.d.ts +17 -0
  66. package/dist/types.d.ts +282 -0
  67. package/dist/utils/binding-registry.d.ts +8 -0
  68. package/dist/utils/binding.d.ts +16 -0
  69. package/dist/utils/default-config.d.ts +13 -0
  70. package/dist/utils/demo-data.d.ts +2 -0
  71. package/dist/utils/element-factory.d.ts +4 -0
  72. package/dist/utils/engine.d.ts +2 -0
  73. package/dist/utils/expression-eval.d.ts +30 -0
  74. package/dist/utils/field-groups.d.ts +21 -0
  75. package/dist/utils/migrate.d.ts +2 -0
  76. package/dist/utils/preset-colors.d.ts +2 -0
  77. package/dist/utils/property-search.d.ts +18 -0
  78. package/dist/utils/ruler.d.ts +7 -0
  79. package/dist/utils/scale.d.ts +2 -0
  80. package/dist/utils/table-matrix.d.ts +61 -0
  81. package/dist/utils/units.d.ts +4 -0
  82. package/dist/utils/zone-layout.d.ts +27 -0
  83. package/package.json +55 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),ie=require("@worm-vue3-print/core"),et=require("jsbarcode"),tt=require("qrcode"),Jt=require("dompurify");function Zt(){let t=0;return function(){return t+=1,`cell-${Date.now().toString(36)}-${t}`}}function Qt(){let t=0;return function(){return t+=1,`row-${Date.now().toString(36)}-${t}`}}const _t=Zt(),en=Qt(),Be={width:.75,style:"solid",color:"#333333"};function nt(t){return JSON.parse(JSON.stringify(t))}function ot(t){return{id:_t(),borders:{top:{...Be},right:{...Be},bottom:{...Be},left:{...Be}},...t}}function tn(){const t=[50,50,50],l=(n,a)=>({id:en(),type:n,height:8,...a!==void 0?{repeatOnPage:a}:{},cells:t.map(()=>ot())}),o=l("header",!0);return o.cells.forEach((n,a)=>{n.formatter=`列${a+1}`,n.align="center",n.fontWeight="bold"}),{rows:[o,l("data"),l("subtotal"),l("summary")],colWidths:t}}function lt(t,l,o){if(!t[l].cells[o].merged)return{r:l,c:o};for(let n=l;n>=0;n--)for(let a=o;a>=0;a--){const i=t[n].cells[a];if(i.merged)continue;const r=i.rowspan??1,s=i.colspan??1;if(n+r-1>=l&&a+s-1>=o)return{r:n,c:a}}return{r:l,c:o}}function he(t,l,o){const n=lt(t,l,o),a=t[n.r].cells[n.c];return{r1:n.r,c1:n.c,r2:n.r+(a.rowspan??1)-1,c2:n.c+(a.colspan??1)-1}}function Vt(t,l,o){let n={r1:Math.min(l.r,o.r),c1:Math.min(l.c,o.c),r2:Math.max(l.r,o.r),c2:Math.max(l.c,o.c)};for(;;){let a=!1;for(let i=n.r1;i<=n.r2;i++)for(let r=n.c1;r<=n.c2;r++){const s=he(t,i,r),d={r1:Math.min(n.r1,s.r1),c1:Math.min(n.c1,s.c1),r2:Math.max(n.r2,s.r2),c2:Math.max(n.c2,s.c2)};(d.r1!==n.r1||d.c1!==n.c1||d.r2!==n.r2||d.c2!==n.c2)&&(n=d,a=!0)}if(!a)return n}}function Nt(t,l){if((l.r2-l.r1+1)*(l.c2-l.c1+1)<2)return"至少选择 2 个单元格";const n=new Set;for(let i=l.r1;i<=l.r2;i++)n.add(t[i].type);if(n.size>1)return"合并区域不能跨越不同类型的行";const a=Vt(t,{r:l.r1,c:l.c1},{r:l.r2,c:l.c2});return a.r1!==l.r1||a.c1!==l.c1||a.r2!==l.r2||a.c2!==l.c2?"选区与已有合并区域部分重叠":null}function Ct(t,l){const o=t[l.r1].cells[l.c1],n=[];for(let a=l.r1;a<=l.r2;a++)for(let i=l.c1;i<=l.c2;i++){const r=t[a].cells[i];r.formatter&&n.push(r.formatter),!(a===l.r1&&i===l.c1)&&(r.merged=!0,r.rowspan=1,r.colspan=1,r.formatter="")}o.rowspan=l.r2-l.r1+1,o.colspan=l.c2-l.c1+1,o.formatter=n.join(" ")}function St(t,l){for(let o=l.r1;o<=l.r2;o++)for(let n=l.c1;n<=l.c2;n++){const a=t[o].cells[n];if(!a.merged&&((a.rowspan??1)>1||(a.colspan??1)>1)){const i=he(t,o,n),r=a;for(let s=i.r1;s<=i.r2;s++)for(let d=i.c1;d<=i.c2;d++){const u=t[s].cells[d];u.merged=!1,u.rowspan=1,u.colspan=1,nn(r,u)}a.rowspan=1,a.colspan=1}}}function nn(t,l){t!==l&&(l.align=t.align,l.valign=t.valign,l.fontSize=t.fontSize,l.fontWeight=t.fontWeight,l.color=t.color,l.backgroundColor=t.backgroundColor,l.borders=t.borders?nt(t.borders):void 0,l.padding=t.padding,l.wordWrap=t.wordWrap)}function ut(t,l,o){const n=o==="above"?l:l+1,a=t[l],i=a.cells.length,r=a.type==="data"?"header":a.type,s={id:`row-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,type:r,height:a.height,cells:Array.from({length:i},()=>ot())};for(let d=0;d<i;d++)if(n>0&&n<t.length){const u=he(t,n-1,d);if(u.r1<n&&u.r2>=n){const v=t[u.r1].cells[u.c1];v.rowspan=(v.rowspan??1)+1,s.cells[d].merged=!0}}t.splice(n,0,s)}function on(t,l){if(t.length<=1)return"不能删除最后一行";const o=t[l],n=o.cells.length;for(let a=0;a<n;a++){const i=o.cells[a];if(!i.merged&&(i.rowspan??1)>1){const r=t[l+1].cells[a];Object.assign(r,nt(i),{id:r.id}),r.rowspan=(i.rowspan??1)-1,r.merged=!1}else if(i.merged){const r=he(t,l,a);if(r.r1<l&&r.c1===a){const s=t[r.r1].cells[r.c1];s.rowspan=(s.rowspan??1)-1}}}return t.splice(l,1),null}function mt(t,l,o,n){const a=n==="left"?o:o+1;l.splice(a,0,l[o]);for(const i of t){const r=ot();if(a>0&&a<i.cells.length){const s=t.indexOf(i),d=he(t,s,a-1);if(d.c1<a&&d.c2>=a){const u=t[d.r1].cells[d.c1];s===d.r1&&(u.colspan=(u.colspan??1)+1),r.merged=!0}}i.cells.splice(a,0,r)}}function ln(t,l,o){if(l.length<=1)return"不能删除最后一列";for(let n=0;n<t.length;n++){const a=t[n].cells[o];if(!a.merged&&(a.colspan??1)>1){const i=t[n].cells[o+1];Object.assign(i,nt(a),{id:i.id}),i.colspan=(a.colspan??1)-1,i.merged=!1}else if(a.merged){const i=he(t,n,o);if(i.c1<o&&i.r1===n){const r=t[i.r1].cells[i.c1];r.colspan=(r.colspan??1)-1}}}for(const n of t)n.cells.splice(o,1);return l.splice(o,1),null}function Je(t,l,o){if(o==="data"){const n=t.findIndex((a,i)=>a.type==="data"&&i!==l);if(n>=0)return`数据行已存在(第 ${n+1} 行),全表最多一行`}if(o==="header"){for(let n=0;n<l;n++)if(t[n].type!=="header")return"标题行必须从表格顶部连续设置"}if(o==="subtotal"||o==="summary"){const n=t.findIndex(a=>a.type==="data");if(n<0)return"请先设置数据行,小计/汇总行必须位于数据行之后";if(l<n)return"小计/汇总行必须位于数据行之后"}if(o==="subtotal"&&t.slice(0,l).some(n=>n.type==="summary"))return"小计行必须位于汇总行之前";if(o==="summary"&&t.slice(l+1).some(n=>n.type==="subtotal"))return"汇总行必须位于小计行之后";if(t[l].type==="header"&&o!=="header"){for(let n=l+1;n<t.length;n++)if(t[n].type==="header")return"取消该标题行会导致标题行不连续,请先调整后续标题行"}return t[l].type=o,o!=="header"&&delete t[l].repeatOnPage,null}function an(t,l,o,n){for(let a=l.r1;a<=l.r2;a++)for(let i=l.c1;i<=l.c2;i++){const r=t[a].cells[i];if(r.merged)continue;if(o==="none"){delete r.borders;continue}const s=he(t,a,i),d=s.r1===l.r1,u=s.r2===l.r2,v=s.c1===l.c1,p=s.c2===l.c2,k={...r.borders??{}};o==="all"?(k.top={...n},k.bottom={...n},k.left={...n},k.right={...n}):o==="outer"?(d&&(k.top={...n}),u&&(k.bottom={...n}),v&&(k.left={...n}),p&&(k.right={...n})):o==="inner"&&(d||(k.top={...n}),u||(k.bottom={...n}),v||(k.left={...n}),p||(k.right={...n})),r.borders=k}}const rn="1px dashed rgba(0,0,0,0.18)";function De(t,l={}){return t&&t.style!=="none"?`${t.width}pt ${t.style} ${t.color}`:l.designMode&&l.showGhostBorder!==!1?rn:"none"}function Pe(t){const l=(t.tableColWidths??[]).reduce((n,a)=>n+a,0),o=(t.tableRows??[]).reduce((n,a)=>n+a.height,0);t.width=Math.round(l*100)/100,t.height=Math.round(o*100)/100}function Ee(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function sn(t){const l={left:7,top:17.6,width:42.3,height:7.1};switch(t){case"text":return{...l,formatter:"文本",fontSize:12,textAlign:"left",height:5.3};case"image":return{...l,width:28.2,height:28.2,fit:"contain"};case"longText":return{...l,width:141.1,height:28.2,fontSize:12,lineHeight:18};case"table":{const{rows:o,colWidths:n}=tn(),a=n.reduce((r,s)=>r+s,0),i=o.reduce((r,s)=>r+s.height,0);return{...l,width:a,height:i,tableMode:"dynamic",tableRows:o,tableColWidths:n,tableDefaultFontSize:10,tableDefaultColor:"#333333",tableDefaultPadding:1,fields:[],tablePagination:{enabled:!0}}}case"hline":return{...l,width:70.6,height:1.8,borderWidth:.75};case"vline":return{...l,width:1.8,height:35.3,borderWidth:.75};case"rect":return{...l,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"oval":return{...l,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"barcode":return{...l,width:56.4,height:14.1,title:"条形码",barcodeType:"code128",testData:"12345678"};case"qrcode":return{...l,width:28.2,height:28.2,title:"二维码",testData:"qrcode"};case"html":return{...l,width:28.2,height:28.2};default:return l}}function $t(t,l){const o={text:{title:"文本"},image:{title:"图片"},longText:{title:"长文"},table:{title:"表格"},hline:{title:"横线"},vline:{title:"竖线"},rect:{title:"矩形"},oval:{title:"椭圆"},barcode:{title:"条形码"},qrcode:{title:"二维码"},html:{title:"HTML"},pageNumber:{title:"页码"}};return{id:Ee(),options:{...sn(t),...l},printElementType:{type:t,title:o[t]?.title||t}}}const at=new ie.TemplateEngine;function Mt(){return ue}const ue={supplier:{name:"鑫达五金有限公司",phone:"0571-88776655",address:"杭州市萧山区经济开发区88号"},receiver:{name:"李四",phone:"13912345678",address:"杭州市余杭区文一西路998号"},order:{no:"PO20260801001",date:"2026-08-01",total:69543.75},goods:[{name:"碳钢螺丝 M8",spec:"M14×10",unit:"个",qty:100,price:.5,amount:50,remark:"A级"},{name:"不锈钢螺母 M10",spec:"M16×11",unit:"套",qty:117,price:.75,amount:87.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×12",unit:"盒",qty:134,price:1,amount:134,remark:""},{name:"六角螺栓 M14",spec:"M5×13",unit:"支",qty:151,price:1.25,amount:188.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×14",unit:"袋",qty:168,price:1.5,amount:252,remark:""},{name:"平垫圈 M6",spec:"M4×15",unit:"件",qty:185,price:1.75,amount:323.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×16",unit:"根",qty:202,price:2,amount:404,remark:""},{name:"双头螺柱 M20",spec:"M8×17",unit:"包",qty:219,price:2.25,amount:492.75,remark:"A级"},{name:"紧定螺钉 M4",spec:"M10×18",unit:"只",qty:236,price:2.5,amount:590,remark:""},{name:"十字盘头钉 M3",spec:"M12×19",unit:"组",qty:253,price:2.75,amount:695.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×20",unit:"个",qty:270,price:3,amount:810,remark:""},{name:"不锈钢螺母 M10",spec:"M16×21",unit:"套",qty:287,price:3.25,amount:932.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×22",unit:"盒",qty:304,price:3.5,amount:1064,remark:""},{name:"六角螺栓 M14",spec:"M5×23",unit:"支",qty:321,price:3.75,amount:1203.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×24",unit:"袋",qty:338,price:4,amount:1352,remark:"A级"},{name:"平垫圈 M6",spec:"M4×25",unit:"件",qty:355,price:4.25,amount:1508.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×26",unit:"根",qty:372,price:4.5,amount:1674,remark:""},{name:"双头螺柱 M20",spec:"M8×27",unit:"包",qty:389,price:4.75,amount:1847.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×28",unit:"只",qty:406,price:5,amount:2030,remark:""},{name:"十字盘头钉 M3",spec:"M12×29",unit:"组",qty:423,price:5.25,amount:2220.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×30",unit:"个",qty:440,price:.5,amount:220,remark:""},{name:"不锈钢螺母 M10",spec:"M16×31",unit:"套",qty:457,price:.75,amount:342.75,remark:"A级"},{name:"弹簧垫圈 M12",spec:"M6×32",unit:"盒",qty:474,price:1,amount:474,remark:""},{name:"六角螺栓 M14",spec:"M5×33",unit:"支",qty:491,price:1.25,amount:613.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×34",unit:"袋",qty:508,price:1.5,amount:762,remark:""},{name:"平垫圈 M6",spec:"M4×35",unit:"件",qty:525,price:1.75,amount:918.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×36",unit:"根",qty:542,price:2,amount:1084,remark:""},{name:"双头螺柱 M20",spec:"M8×37",unit:"包",qty:559,price:2.25,amount:1257.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×38",unit:"只",qty:576,price:2.5,amount:1440,remark:"A级"},{name:"十字盘头钉 M3",spec:"M12×39",unit:"组",qty:593,price:2.75,amount:1630.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×40",unit:"个",qty:610,price:3,amount:1830,remark:""},{name:"不锈钢螺母 M10",spec:"M16×41",unit:"套",qty:627,price:3.25,amount:2037.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×42",unit:"盒",qty:644,price:3.5,amount:2254,remark:""},{name:"六角螺栓 M14",spec:"M5×43",unit:"支",qty:661,price:3.75,amount:2478.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×44",unit:"袋",qty:678,price:4,amount:2712,remark:""},{name:"平垫圈 M6",spec:"M4×45",unit:"件",qty:695,price:4.25,amount:2953.75,remark:"A级"},{name:"自攻螺钉 M5",spec:"M3×46",unit:"根",qty:712,price:4.5,amount:3204,remark:""},{name:"双头螺柱 M20",spec:"M8×47",unit:"包",qty:729,price:4.75,amount:3462.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×48",unit:"只",qty:746,price:5,amount:3730,remark:""},{name:"十字盘头钉 M3",spec:"M12×49",unit:"组",qty:763,price:5.25,amount:4005.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×10",unit:"个",qty:780,price:.5,amount:390,remark:""},{name:"不锈钢螺母 M10",spec:"M16×11",unit:"套",qty:797,price:.75,amount:597.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×12",unit:"盒",qty:814,price:1,amount:814,remark:"A级"},{name:"六角螺栓 M14",spec:"M5×13",unit:"支",qty:831,price:1.25,amount:1038.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×14",unit:"袋",qty:848,price:1.5,amount:1272,remark:""},{name:"平垫圈 M6",spec:"M4×15",unit:"件",qty:865,price:1.75,amount:1513.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×16",unit:"根",qty:882,price:2,amount:1764,remark:""},{name:"双头螺柱 M20",spec:"M8×17",unit:"包",qty:899,price:2.25,amount:2022.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×18",unit:"只",qty:916,price:2.5,amount:2290,remark:""},{name:"十字盘头钉 M3",spec:"M12×19",unit:"组",qty:933,price:2.75,amount:2565.75,remark:"A级"}]},dn={MONEY:ie.formatMoney,CONCAT:(...t)=>t.filter(l=>l!=null).join(""),IF:ie.ifFn,FORMAT:t=>typeof t!="number"?String(t):t.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}),SUBSTR:(t,l,o)=>String(t).slice(l,o?l+o:void 0),LEN:t=>String(t).length,ROUND:(t,l)=>Number(Number(t).toFixed(l)),NOW:()=>new Date().toISOString().split("T")[0],IFEMPTY:(t,l)=>t!=null&&t!==""?String(t):l,PAD:(t,l,o)=>String(t).padStart(l,o),REPLACE:(t,l,o)=>String(t).replace(new RegExp(l,"g"),o),JSON:t=>JSON.stringify(t,null,2),DATE:ie.formatDate,UPPER:ie.toUpperCaseAmount};for(const[t,l]of Object.entries(dn))at.registerFunction(t,l);function cn(t,l,o){switch(t.toUpperCase()){case"SUM":return ie.sum(o,l);case"AVG":return ie.avg(o,l);case"COUNT":return ie.count(o,l);case"MIN":return ie.min(o,l);case"MAX":return ie.max(o,l);default:return 0}}function Le(t,l){if(!t)return"";if(!t.includes("{"))return t;const o=Array.isArray(l.rows)?l.rows:[];let n=t.replace(/\{([^}]+)\}/g,(a,i)=>{let r=i.trim();return r=r.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(s,d,u)=>{const v=u.trim().replace(/^['"]|['"]$/g,"");return String(cn(d,v,o))}),`{${r}}`});try{return at.render(n,l)}catch{return t}}function un(t){return $t("text",{formatter:`{${t.fieldKey}}`,title:t.fieldLabel})}function Ae(t,l){if(t.formatter){if(!l||l.length===0)return"";const o=l[0];try{return at.render(t.formatter,o??{})}catch{return t.formatter}}return""}function pt(t){let l=ue;for(const o of t.split(".")){if(l==null)return;l=Array.isArray(l)?l[0]?.[o]:l[o]}return l}function mn(t,l){const o=l?.[0];return(t??"").replace(/\{([^{}]+)\}/g,(a,i)=>{const r=i.trim(),s=r.includes(".")?pt(r):o?.[r]??pt(r);return s==null?"":String(s)}).trim()||"1234567890128"}function pn(t){return t/2.83464566929}function xe(t){return t*(25.4/96)}const fn=["left","top","width","height"];function vn(t){const l={...t.options};for(const o of fn){const n=l[o];typeof n=="number"&&Number.isFinite(n)&&(l[o]=gn(pn(n)))}return{...t,options:l}}function gn(t){return Math.round(t*100)/100}function hn(t){if(t.unit==="mm")return t;const l=o=>o?.map(vn)??[];return{...t,unit:"mm",elements:l(t.elements),header:t.header?{...t.header,elements:l(t.header.elements)}:t.header,footer:t.footer?{...t.footer,elements:l(t.footer.elements)}:t.footer,firstPageOverlay:t.firstPageOverlay?{...t.firstPageOverlay,elements:l(t.firstPageOverlay.elements)}:t.firstPageOverlay}}const Ze={A4:{width:210,height:297},A3:{width:297,height:420},A5:{width:148,height:210},Letter:{width:216,height:279},Legal:{width:216,height:356}};function we(t){let l;return t.paperSize==="CUSTOM"?l={width:t.customWidth??210,height:t.customHeight??297}:l=Ze[t.paperSize]||Ze.A4,t.orientation==="landscape"?{width:l.height,height:l.width}:l}function bn(t,l,o,n,a=.9){if(o<=0||n<=0)return 100;const i=Math.min(t/o,l/n)*a,r=Math.round(i*100);return Math.min(200,Math.max(50,r))}const Bt=["text","image","hline","vline","rect","oval","barcode","qrcode"];function yn(t){return we(t)}function Ie(t){const l=yn(t),o=t.margins,n=t.header.height,a=t.footer.height,i=l.width-o.left-o.right,r=l.height-o.top-o.bottom-n-a,s=(d,u,v,p)=>({left:d,top:u,width:v,height:p});return{header:s(o.left,o.top,i,n),content:s(o.left,o.top+n,i,r),footer:s(o.left,l.height-o.bottom-a,i,a)}}function Dt(t,l,o){const n=Ie(t);return n.footer.height>0&&o>=n.footer.top?"footer":n.header.height>0&&o<n.header.top+n.header.height?"header":"content"}function Qe(t,l){const o=t.options;o.width=Math.min(o.width,l.width),o.height=Math.min(o.height,l.height),o.left=Math.min(Math.max(0,o.left),l.width-o.width),o.top=Math.min(Math.max(0,o.top),l.height-o.height)}function kn(t,l){const o=Ie(l),n=t.zone||"content",a=o[n],i=a.left+t.options.left+t.options.width/2,r=a.top+t.options.top+t.options.height/2;let s=Dt(l,i,r),d=!1;if(s!=="content"&&!Bt.includes(t.printElementType.type)&&(s="content",d=!0),s!==n){const u=o[s];t.options.left=a.left+t.options.left-u.left,t.options.top=a.top+t.options.top-u.top,t.zone=s}return s!=="content"?Qe(t,o[s]):d&&Qe(t,o.content),{rejected:d}}const xt=Symbol("selected-ids"),Tt=Symbol("preview-ids");function En(t){const l=e.ref(new Set),o=e.ref(new Set),n=e.computed(()=>t.value.filter(k=>l.value.has(k.id))),a=e.computed(()=>l.value.size>0);function i(k,C=!1){if(C){const D=new Set(l.value);D.has(k)?D.delete(k):D.add(k),l.value=D}else l.value=new Set([k])}function r(){l.value=new Set}function s(k){l.value=new Set(k)}function d(k){o.value=new Set(k)}function u(){o.value=new Set}function v(){l.value=new Set(o.value),o.value=new Set}function p(){const k=n.value;if(k.length===0)return null;let C=1/0,D=1/0,w=-1/0,L=-1/0;return k.forEach(I=>{C=Math.min(C,I.options.left),D=Math.min(D,I.options.top),w=Math.max(w,I.options.left+I.options.width),L=Math.max(L,I.options.top+I.options.height)}),{left:C,top:D,width:w-C,height:L-D}}return{selectedIds:l,selectedElements:n,hasSelection:a,select:i,clearSelection:r,selectAll:s,getSelectionBounds:p,previewIds:o,setPreview:d,clearPreview:u,commitPreview:v}}function wn(){const t=e.ref(null);function l(a){t.value=a.map(i=>({options:{...i.options},printElementType:{...i.printElementType}}))}function o(a=10){return t.value?t.value.map(i=>({id:Ee(),options:{...i.options,left:i.options.left+a,top:i.options.top+a},printElementType:{...i.printElementType}})):null}function n(){return t.value!==null&&t.value.length>0}return{clipboard:t,copy:l,paste:o,hasData:n}}function Vn(){function t(l,o){if(l.length<2)return;const n={minLeft:Math.min(...l.map(a=>a.options.left)),maxRight:Math.max(...l.map(a=>a.options.left+a.options.width)),minTop:Math.min(...l.map(a=>a.options.top)),maxBottom:Math.max(...l.map(a=>a.options.top+a.options.height))};switch(o){case"left":l.forEach(a=>{a.options.left=n.minLeft});break;case"right":l.forEach(a=>{a.options.left=n.maxRight-a.options.width});break;case"top":l.forEach(a=>{a.options.top=n.minTop});break;case"bottom":l.forEach(a=>{a.options.top=n.maxBottom-a.options.height});break;case"vertical":{const a=n.minLeft+(n.maxRight-n.minLeft)/2;l.forEach(i=>{i.options.left=a-i.options.width/2});break}case"horizontal":{const a=n.minTop+(n.maxBottom-n.minTop)/2;l.forEach(i=>{i.options.top=a-i.options.height/2});break}case"distributeHor":{const a=[...l].sort((d,u)=>d.options.left-u.options.left),i=a.reduce((d,u)=>d+u.options.width,0),r=(n.maxRight-n.minLeft-i)/(a.length-1);let s=n.minLeft;a.forEach(d=>{d.options.left=s,s+=d.options.width+r});break}case"distributeVer":{const a=[...l].sort((d,u)=>d.options.top-u.options.top),i=a.reduce((d,u)=>d+u.options.height,0),r=(n.maxBottom-n.minTop-i)/(a.length-1);let s=n.minTop;a.forEach(d=>{d.options.top=s,s+=d.options.height+r});break}}}return{align:t}}function Nn(){return`grp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function Cn(){function t(n,a){if(n.filter(s=>a.has(s.id)).length<2)return n;const r=Nn();return n.map(s=>a.has(s.id)?{...s,options:{...s.options,groupId:r}}:s)}function l(n,a){const i=n.filter(s=>a.has(s.id)),r=new Set(i.map(s=>s.options.groupId).filter(Boolean));return n.map(s=>s.options.groupId&&r.has(s.options.groupId)?{...s,options:{...s.options,groupId:void 0}}:s)}function o(n,a){const i=n.find(s=>s.id===a);if(!i?.options.groupId)return new Set([a]);const r=new Set;for(const s of n)s.options.groupId===i.options.groupId&&r.add(s.id);return r}return{group:t,ungroup:l,getGroupedIds:o}}function Sn(t){const o=e.ref([]),n=e.ref([]),a=e.ref(!1),i=e.ref(!1);function r(){a.value=o.value.length>0,i.value=n.value.length>0}function s(C){return{elements:JSON.parse(JSON.stringify(C?.elements??[])),templateData:JSON.parse(JSON.stringify(C?.templateData??{}))}}function d(C){return s(C)}function u(C){o.value.push(d(C)),n.value=[],o.value.length>50&&o.value.shift(),r()}function v(C){if(o.value.length===0)return null;const D=o.value.pop();return n.value.push(C?d(C):s(D)),r(),o.value.length>0?s(o.value[o.value.length-1]):null}function p(C){if(n.value.length===0)return null;const D=n.value.pop();return o.value.push(C?d(C):s(D)),r(),s(D)}function k(){o.value=[],n.value=[],r()}return{push:u,undo:v,redo:p,canUndo:a,canRedo:i,clear:k}}const $n=1,Mn=10,Bn=.5;function Dn(t){function l(a){const i=a.target.tagName;if(i==="INPUT"||i==="TEXTAREA"||i==="SELECT")return;const r=a.ctrlKey||a.metaKey;if(a.key.startsWith("Arrow")){a.preventDefault();const s=a.shiftKey?Mn:a.ctrlKey?Bn:$n,d=a.key==="ArrowLeft"?-s:a.key==="ArrowRight"?s:0,u=a.key==="ArrowUp"?-s:a.key==="ArrowDown"?s:0;t.onMove?.(d,u);return}if(a.key==="Delete"||a.key==="Backspace"){a.preventDefault(),t.onDelete?.();return}if(r){const s=a.key.toLowerCase();s==="c"?(a.preventDefault(),t.onCopy?.()):s==="v"?(a.preventDefault(),t.onPaste?.()):s==="a"?(a.preventDefault(),t.onSelectAll?.()):s==="d"?(a.preventDefault(),t.onDuplicate?.()):s==="z"?(a.preventDefault(),a.shiftKey?t.onRedo?.():t.onUndo?.()):s==="y"?(a.preventDefault(),t.onRedo?.()):s==="1"?(a.preventDefault(),t.onResetZoom?.()):s==="l"?(a.preventDefault(),t.onAlignLeft?.()):s==="r"?(a.preventDefault(),t.onAlignRight?.()):s==="e"?(a.preventDefault(),t.onAlignCenterH?.()):s==="t"?(a.preventDefault(),t.onAlignTop?.()):s==="b"?(a.preventDefault(),t.onAlignBottom?.()):s==="g"&&(a.preventDefault(),a.shiftKey?t.onUngroup?.():t.onGroup?.())}}function o(){document.addEventListener("keydown",l)}function n(){document.removeEventListener("keydown",l)}return{setup:o,cleanup:n}}function zt(){return{paperSize:"A4",orientation:"portrait",unit:"mm",margins:{top:10,right:10,bottom:10,left:10},header:{height:10,elements:[]},footer:{height:10,elements:[]},firstPageOverlay:{height:0,elements:[]},elements:[],watermark:{}}}function _e(t){const l=(o,n)=>(o??[]).map(a=>{const i={...a.options};return(a.printElementType?.type??a.type)==="table"&&Pe(i),{id:a.id||Ee(),zone:n,options:i,printElementType:{...a.printElementType}}});return{...t,margins:{...t.margins},header:{height:t.header?.height??10,elements:[]},footer:{height:t.footer?.height??10,elements:[]},firstPageOverlay:{height:t.firstPageOverlay?.height??0,elements:[...t.firstPageOverlay?.elements??[]]},guides:[...t.guides??[]],elements:[...l(t.elements??[],"content"),...l(t.header?.elements??[],"header"),...l(t.footer?.elements??[],"footer")]}}function xn(t={}){const l=e.ref(100),o=e.ref(!0),n=e.ref(!1),a=e.ref(!0),i=e.ref(_e(t.initialTemplate||zt())),r=e.computed({get:()=>i.value.elements,set:R=>{i.value.elements=R}}),s=e.ref(t.initialFields||[]),{selectedIds:d,selectedElements:u,select:v,clearSelection:p,selectAll:k,previewIds:C,setPreview:D,clearPreview:w,commitPreview:L}=En(r),{group:I,ungroup:U}=Cn(),{copy:H,paste:z,hasData:O}=wn(),{align:Y}=Vn(),{push:j,undo:W,redo:y,canUndo:f,canRedo:h}=Sn(),c=e.computed(()=>{if(d.value.size===0)return null;const R=d.value.values().next().value;return r.value.find(_=>_.id===R)||null}),g=e.ref(null);function $(R){g.value=R}function G(){return{elements:r.value.map(R=>({id:R.id,zone:R.zone,options:JSON.parse(JSON.stringify(R.options)),printElementType:{...R.printElementType}})),templateData:{paperSize:i.value.paperSize,orientation:i.value.orientation,margins:{...i.value.margins},header:{height:i.value.header.height,elements:[]},footer:{height:i.value.footer.height,elements:[]},firstPageOverlay:{height:i.value.firstPageOverlay.height,elements:[]},elements:[],customWidth:i.value.customWidth,customHeight:i.value.customHeight,watermark:i.value.watermark?{...i.value.watermark}:void 0,guides:[...i.value.guides??[]]}}}function K(){j(G())}function X(){const R=W(G());R?.templateData&&(i.value={...R.templateData,elements:R.elements})}function ae(){const R=y(G());R?.templateData&&(i.value={...R.templateData,elements:R.elements})}function M(){H(u.value)}function B(){H(u.value),le()}function T(){const R=z();R&&R.length>0&&(r.value.push(...R),K())}function q(){H(u.value);const R=z();R&&R.length>0&&(R.forEach(_=>{_.options.left+=5,_.options.top+=5}),r.value.push(...R),v(R[0].id,!1),K())}function m(){l.value=100}const b=e.computed(()=>O());let E=!1,N=null;const F=300;function Z(R,_){const J=u.value.filter(te=>!te.options.locked);J.length!==0&&(J.forEach(te=>{te.options.left+=R,te.options.top+=_}),E||(E=!0,K()),N&&clearTimeout(N),N=setTimeout(()=>{E=!1,N=null},F))}function S(){k(r.value.map(R=>R.id))}function V(R){Y(u.value,R),K()}function P(){r.value=I(r.value,d.value),K()}function Q(){r.value=U(r.value,d.value),K()}function le(){d.value.size!==0&&(r.value=r.value.filter(R=>!d.value.has(R.id)),p(),K())}const{setup:de,cleanup:pe}=Dn({onMove:Z,onDelete:le,onCopy:M,onPaste:T,onSelectAll:S,onUndo:X,onRedo:ae,onDuplicate:q,onResetZoom:m,onAlignLeft:()=>V("left"),onAlignRight:()=>V("right"),onAlignCenterH:()=>V("vertical"),onAlignTop:()=>V("top"),onAlignBottom:()=>V("bottom"),onGroup:P,onUngroup:Q});let ve=null;function Re(){ve=G()}function Fe(){if(!ve)return;const R=new Map(ve.elements.map(oe=>[oe.id,oe]));let _=!1;for(const oe of r.value){const re=R.get(oe.id);if(!re)continue;(re.options.left!==oe.options.left||re.options.top!==oe.options.top||re.options.width!==oe.options.width||re.options.height!==oe.options.height)&&kn(oe,i.value).rejected&&(_=!0)}_&&alert("该元素类型不能放入页眉/页脚");const J=oe=>`${oe.id}:${oe.zone||"content"}:${oe.options.left},${oe.options.top},${oe.options.width},${oe.options.height}`,te=ve.elements.map(J).join("|"),ce=G().elements.map(J).join("|");ve=null,te!==ce&&K()}function Ve(R,_){const J=Dt(i.value,_.x,_.y);if(J!=="content"&&!Bt.includes(R.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const te=Ie(i.value)[J];return R.zone=J,R.options.left=_.x-te.left,R.options.top=_.y-te.top,J!=="content"&&Qe(R,te),!0}function ge(R,_){const J=$t(R);_&&!Ve(J,_)||(r.value.push(J),v(J.id,!1),K())}function be(R,_){const J=un(R);_&&!Ve(J,_)||(r.value.push(J),v(J.id,!1),K())}function Ue(R){if(d.value.size===0)return;const _=d.value.values().next().value,J=r.value.find(ye=>ye.id===_);if(!J)return;const te=J.options.zIndex??0,ce=r.value.map(ye=>ye.options.zIndex??0),oe=Math.max(...ce,0),re=Math.min(...ce,0);switch(R){case"top":J.options.zIndex=oe+1;break;case"bottom":J.options.zIndex=re-1;break;case"up":J.options.zIndex=te+1;break;case"down":J.options.zIndex=te-1;break}K()}function He(R,_){const{width:J,height:te}=we(i.value),ce=96/25.4;l.value=bn(R,_,J*ce,te*ce)}function $e(R){i.value={...R},K()}function Ge(){const R=r.value,_=J=>R.filter(te=>(te.zone||"content")===J).map(te=>({id:te.id,type:te.printElementType.type,options:{...te.options},printElementType:{...te.printElementType}}));return{unit:"mm",...i.value,header:{...i.value.header,elements:_("header")},footer:{...i.value.footer,elements:_("footer")},firstPageOverlay:{...i.value.firstPageOverlay,elements:i.value.firstPageOverlay.elements.map(J=>({id:J.id||Ee(),type:J.printElementType?.type||"text",options:{...J.options},printElementType:{...J.printElementType}}))},elements:_("content"),guides:[...i.value.guides??[]]}}function Oe(R,_){const J=hn(R);i.value=_e(J),_&&(i.value={...i.value,elements:_.map(te=>({...te,id:te.id||Ee(),zone:te.zone||"content",options:{...te.options},printElementType:{...te.printElementType}}))}),j(G())}return j(G()),e.onMounted(()=>de()),e.onUnmounted(()=>{pe(),N&&(clearTimeout(N),N=null)}),{scale:l,showGrid:o,snapToGrid:n,showTableGhostBorder:a,templateData:i,elements:r,fields:s,selectedIds:d,selectedElements:u,selectedElement:c,select:v,clearSelection:p,selectAll:S,previewIds:C,setPreview:D,clearPreview:w,commitPreview:L,hasClipboard:b,copy:M,paste:T,cutSelected:B,tableSelection:g,setTableSelection:$,canUndo:f,canRedo:h,undo:X,redo:ae,recordHistory:K,alignSelected:V,groupSelected:P,ungroupSelected:Q,deleteSelected:le,duplicateSelected:q,resetZoom:m,dragStart:Re,dragStop:Fe,addElement:ge,addFieldElement:be,moveLayer:Ue,fitToWindow:He,updateTemplateData:$e,getTemplateJson:Ge,loadTemplate:Oe}}let ft=0;function Tn(){return ft+=1,`guide-${ft}`}function zn(t,l){const o=e.computed(()=>t.value.guides??[]);function n(d){t.value={...t.value,guides:d([...t.value.guides??[]])},l()}function a(d,u){n(v=>(v.push({type:d,position:u,id:Tn()}),v))}function i(d,u){n(v=>v.map(p=>p.id===d?{...p,position:u}:p))}function r(d){n(u=>u.filter(v=>v.id!==d))}function s(){const d=[],u=[];for(const v of o.value)v.type==="vertical"?d.push(v.position):u.push(v.position);return{vertical:d,horizontal:u}}return{guides:o,addGuide:a,moveGuide:i,removeGuide:r,getGuidePositions:s}}const Se=Symbol("table-edit"),it=Symbol("print-upload-image"),Ln={class:"designer-toolbar"},Pn={class:"tb-group"},An={class:"tb-title"},In={class:"tb-title-name"},Rn={class:"tb-group"},Fn=["disabled"],Un=["disabled"],Hn={key:0,class:"tb-group"},Gn={key:1,class:"tb-group"},On={key:2,class:"tb-group"},qn={key:3,class:"tb-group"},Wn={class:"tb-group"},Kn={class:"tb-zoom"},Yn={class:"tb-group"},Xn={class:"tb-group"},jn=e.defineComponent({__name:"DesignerToolbar",props:e.mergeModels({isEdit:{type:Boolean},canUndo:{type:Boolean},canRedo:{type:Boolean},hasMultiSelection:{type:Boolean},hasSelection:{type:Boolean},showGrid:{type:Boolean},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},selectedElementHasGroup:{type:Boolean},overlayVisible:{type:Boolean},showLoadDefault:{type:Boolean}},{scale:{default:100},scaleModifiers:{}}),emits:e.mergeModels(["back","preview","save","load-default","undo","redo","align","move-layer","toggle-grid","toggle-snap","toggle-table-ghost-border","toggle-overlay","group","ungroup","add-overlay-element","fit-window","zoom"],["update:scale"]),setup(t){const l=e.useModel(t,"scale");return(o,n)=>(e.openBlock(),e.createElementBlock("div",Ln,[e.createElementVNode("div",Pn,[e.createElementVNode("button",{class:"tb-btn tb-icon",title:"返回",onClick:n[0]||(n[0]=a=>o.$emit("back"))},"←"),n[29]||(n[29]=e.createStaticVNode('<span class="tb-mark" aria-hidden="true" data-v-2895245c><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-2895245c><rect x="5" y="3" width="14" height="18" rx="2.5" data-v-2895245c></rect><line x1="8.5" y1="8.5" x2="15.5" y2="8.5" data-v-2895245c></line><line x1="8.5" y1="12.5" x2="15.5" y2="12.5" data-v-2895245c></line><line x1="8.5" y1="16.5" x2="12.5" y2="16.5" data-v-2895245c></line></svg></span>',1)),e.createElementVNode("div",An,[e.createElementVNode("span",In,e.toDisplayString(t.isEdit?"编辑模板":"新建模板"),1),n[28]||(n[28]=e.createElementVNode("span",{class:"tb-title-sub"},"印刷工作台",-1))])]),e.createElementVNode("div",Rn,[e.createElementVNode("button",{class:"tb-btn tb-icon",disabled:!t.canUndo,onClick:n[1]||(n[1]=a=>o.$emit("undo")),title:"撤销"},"↶",8,Fn),e.createElementVNode("button",{class:"tb-btn tb-icon",disabled:!t.canRedo,onClick:n[2]||(n[2]=a=>o.$emit("redo")),title:"重做"},"↷",8,Un)]),t.hasMultiSelection?(e.openBlock(),e.createElementBlock("div",Hn,[e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[3]||(n[3]=a=>o.$emit("align","left")),title:"左对齐"},"⇤"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[4]||(n[4]=a=>o.$emit("align","right")),title:"右对齐"},"⇥"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[5]||(n[5]=a=>o.$emit("align","top")),title:"顶对齐"},"⇡"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[6]||(n[6]=a=>o.$emit("align","bottom")),title:"底对齐"},"⇣"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[7]||(n[7]=a=>o.$emit("align","vertical")),title:"水平居中"},"↔"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[8]||(n[8]=a=>o.$emit("align","horizontal")),title:"垂直居中"},"↕"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[9]||(n[9]=a=>o.$emit("align","distributeHor")),title:"水平分布"},"⇔"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[10]||(n[10]=a=>o.$emit("align","distributeVer")),title:"垂直分布"},"⇕")])):e.createCommentVNode("",!0),t.hasMultiSelection?(e.openBlock(),e.createElementBlock("div",Gn,[e.createElementVNode("button",{class:"tb-btn",onClick:n[11]||(n[11]=a=>o.$emit("group")),title:"组合"},"组合")])):e.createCommentVNode("",!0),!t.hasMultiSelection&&t.selectedElementHasGroup?(e.openBlock(),e.createElementBlock("div",On,[e.createElementVNode("button",{class:"tb-btn",onClick:n[12]||(n[12]=a=>o.$emit("ungroup")),title:"取消组合"},"取消组合")])):e.createCommentVNode("",!0),t.hasSelection?(e.openBlock(),e.createElementBlock("div",qn,[e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[13]||(n[13]=a=>o.$emit("move-layer","top")),title:"置顶"},"⤒"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[14]||(n[14]=a=>o.$emit("move-layer","up")),title:"上移"},"↑"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[15]||(n[15]=a=>o.$emit("move-layer","down")),title:"下移"},"↓"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[16]||(n[16]=a=>o.$emit("move-layer","bottom")),title:"置底"},"⤓")])):e.createCommentVNode("",!0),e.createElementVNode("div",Wn,[e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{on:t.showGrid}]),onClick:n[17]||(n[17]=a=>o.$emit("toggle-grid"))},[...n[30]||(n[30]=[e.createElementVNode("span",{class:"dot"},null,-1),e.createTextVNode(" 网格 ",-1)])],2),e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{on:t.showTableGhostBorder}]),title:"显示/隐藏无边框表格的虚拟虚线",onClick:n[18]||(n[18]=a=>o.$emit("toggle-table-ghost-border"))},[...n[31]||(n[31]=[e.createElementVNode("span",{class:"dot"},null,-1),e.createTextVNode(" 虚框 ",-1)])],2),e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{on:t.snapToGrid}]),onClick:n[19]||(n[19]=a=>o.$emit("toggle-snap"))},[...n[32]||(n[32]=[e.createElementVNode("span",{class:"dot"},null,-1),e.createTextVNode(" 吸附 ",-1)])],2),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[20]||(n[20]=a=>o.$emit("fit-window")),title:"适应窗口"},"⤢"),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[21]||(n[21]=a=>o.$emit("zoom",-10)),title:"缩小"},"−"),e.createElementVNode("span",Kn,e.toDisplayString(l.value)+"%",1),e.createElementVNode("button",{class:"tb-btn tb-icon",onClick:n[22]||(n[22]=a=>o.$emit("zoom",10)),title:"放大"},"+")]),n[33]||(n[33]=e.createElementVNode("div",{class:"tb-spacer"},null,-1)),e.createElementVNode("div",Yn,[e.createElementVNode("button",{class:"tb-btn",onClick:n[23]||(n[23]=a=>o.$emit("add-overlay-element"))},"首页专属"),e.createElementVNode("button",{class:e.normalizeClass(["tb-btn",{warn:t.overlayVisible}]),onClick:n[24]||(n[24]=a=>o.$emit("toggle-overlay"))},"叠层对比",2)]),e.createElementVNode("div",Xn,[t.showLoadDefault?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn-secondary",onClick:n[25]||(n[25]=a=>o.$emit("load-default"))},"加载默认布局")):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"btn-secondary",onClick:n[26]||(n[26]=a=>o.$emit("preview"))},"预览"),e.createElementVNode("button",{class:"btn-primary",onClick:n[27]||(n[27]=a=>o.$emit("save"))},"保存")])]))}}),ee=(t,l)=>{const o=t.__vccOpts||t;for(const[n,a]of l)o[n]=a;return o},Jn=ee(jn,[["__scopeId","data-v-2895245c"]]),Zn={class:"layer-panel"},Qn=["onClick"],_n={class:"layer-icon"},eo={class:"layer-name"},to={key:0,class:"layer-zone"},no={class:"layer-zindex"},oo={key:0,class:"layer-actions"},lo=e.defineComponent({__name:"LayerPanel",props:{elements:{},selectedIds:{}},emits:["select","move-layer"],setup(t){const l=t,o=e.computed(()=>[...l.elements].sort((s,d)=>(d.options.zIndex??0)-(s.options.zIndex??0))),n={text:"T",longText:"¶",table:"⊞",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function a(s){return n[s.printElementType.type]||"?"}function i(s){return s.options.title||s.printElementType.title||s.printElementType.type}function r(s){return s.zone==="header"?"页眉":s.zone==="footer"?"页脚":""}return(s,d)=>(e.openBlock(),e.createElementBlock("div",Zn,[d[4]||(d[4]=e.createElementVNode("div",{class:"panel-title"},"图层",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,u=>(e.openBlock(),e.createElementBlock("div",{key:u.id,class:e.normalizeClass(["layer-item",{active:t.selectedIds.has(u.id)}]),onClick:v=>s.$emit("select",u.id,!1)},[e.createElementVNode("span",_n,e.toDisplayString(a(u)),1),e.createElementVNode("span",eo,e.toDisplayString(i(u)),1),r(u)?(e.openBlock(),e.createElementBlock("span",to,e.toDisplayString(r(u)),1)):e.createCommentVNode("",!0),e.createElementVNode("span",no,"z:"+e.toDisplayString(u.options.zIndex??0),1)],10,Qn))),128)),o.value.length>0?(e.openBlock(),e.createElementBlock("div",oo,[e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:d[0]||(d[0]=u=>s.$emit("move-layer","top")),title:"置顶"}," ⤒ "),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:d[1]||(d[1]=u=>s.$emit("move-layer","up")),title:"上移"}," ↑ "),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:d[2]||(d[2]=u=>s.$emit("move-layer","down")),title:"下移"}," ↓ "),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:d[3]||(d[3]=u=>s.$emit("move-layer","bottom")),title:"置底"}," ⤓ ")])):e.createCommentVNode("",!0)]))}}),ao=ee(lo,[["__scopeId","data-v-d091c3fa"]]);function Lt(t){const l=[...t].sort((r,s)=>(r.sortOrder??0)-(s.sortOrder??0)),o=new Map,n=[];for(const r of l){const s=r.fieldKey.indexOf(".");if(s===-1)continue;const d=r.fieldKey.slice(0,s);let u=o.get(d);u||(u={key:d,label:d,isList:!1,fields:[]},o.set(d,u),n.push(d)),u.fields.push(r)}const a=[],i=[];for(const r of l){if(r.fieldKey.includes("."))continue;const s=o.get(r.fieldKey);s?(s.label=r.fieldLabel,s.isList=r.fieldType==="list"):i.push(r)}i.length&&a.push({key:"",label:"",isList:!1,fields:i});for(const r of n)a.push(o.get(r));return a}function Pt(t,l){const o=l.trim().toLowerCase();return o?t.map(n=>({...n,fields:n.fields.filter(a=>a.fieldLabel.toLowerCase().includes(o)||a.fieldKey.toLowerCase().includes(o))})).filter(n=>n.fields.length>0):t}const io={class:"field-tree-panel"},ro={class:"tree-container"},so=["onClick"],co={class:"expand-icon"},uo={class:"node-icon"},mo={class:"group-label"},po=["onDragstart"],fo={class:"node-label"},vo={class:"node-key"},go={key:0,class:"pd-empty"},ho=e.defineComponent({__name:"FieldTreePanel",props:{fields:{}},emits:["field-drag"],setup(t,{emit:l}){const o=t,n=l,a=e.ref(""),i=e.ref(new Set),r=e.computed(()=>!!a.value.trim()),s=e.computed(()=>Pt(Lt(o.fields),a.value));function d(v){const p=new Set(i.value);p.has(v)?p.delete(v):p.add(v),i.value=p}function u(v,p){v.dataTransfer?.setData("fieldData",JSON.stringify({fieldKey:p.fieldKey,fieldLabel:p.fieldLabel})),v.dataTransfer&&(v.dataTransfer.effectAllowed="copy"),n("field-drag",p)}return(v,p)=>(e.openBlock(),e.createElementBlock("div",io,[p[2]||(p[2]=e.createElementVNode("div",{class:"panel-title"},"业务字段",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[0]||(p[0]=k=>a.value=k),class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段"},null,512),[[e.vModelText,a.value]]),e.createElementVNode("div",ro,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,k=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k.key||"_top"},[k.key?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["field-group-header",{"is-list":k.isList}]),onClick:C=>d(k.key)},[e.createElementVNode("span",co,e.toDisplayString(i.value.has(k.key)&&!r.value?"▶":"▼"),1),e.createElementVNode("span",uo,e.toDisplayString(k.isList?"📋":"📁"),1),e.createElementVNode("span",mo,e.toDisplayString(k.label),1)],10,so)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("div",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.fields,C=>(e.openBlock(),e.createElementBlock("div",{key:C.fieldKey,class:"field-row",draggable:"true",style:e.normalizeStyle({paddingLeft:(k.key?22:8)+"px"}),onDragstart:D=>u(D,C)},[p[1]||(p[1]=e.createElementVNode("span",{class:"node-icon"},"📄",-1)),e.createElementVNode("span",fo,e.toDisplayString(C.fieldLabel),1),e.createElementVNode("span",vo,"("+e.toDisplayString(C.fieldKey)+")",1)],44,po))),128))],512),[[e.vShow,!k.key||r.value||!i.value.has(k.key)]])],64))),128))]),s.value.length===0?(e.openBlock(),e.createElementBlock("p",go,"暂无字段")):e.createCommentVNode("",!0)]))}}),bo=ee(ho,[["__scopeId","data-v-cc814de0"]]),yo={key:0,class:"left-collapsed"},ko={class:"left-head"},Eo={class:"pd-tabs left-tabs"},wo={class:"pd-tab-bar",role:"tablist"},Vo={class:"pd-tab-pane",role:"tabpanel"},No=["onDragstart"],Co={class:"material-icon"},So={class:"material-label"},$o={class:"pd-tab-pane",role:"tabpanel"},Mo={class:"pd-tab-pane",role:"tabpanel"},Bo=e.defineComponent({__name:"LeftPanel",props:{fields:{},elements:{},selectedIds:{},collapsed:{type:Boolean}},emits:["select","move-layer","toggle-visible","toggle-locked","field-drag","toggle-collapse"],setup(t,{emit:l}){const o=l,n=e.ref("elements"),a=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"longText",label:"长文",icon:"¶"},{type:"hline",label:"横线",icon:"―"},{type:"vline",label:"竖线",icon:"│"},{type:"rect",label:"矩形",icon:"▭"},{type:"oval",label:"椭圆",icon:"◯"},{type:"html",label:"HTML",icon:"<>"}];function i(d,u){d.dataTransfer?.setData("elementType",u)}function r(d){o("field-drag",d)}function s(d){n.value=d,o("toggle-collapse")}return(d,u)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["left-panel",{collapsed:t.collapsed}])},[t.collapsed?(e.openBlock(),e.createElementBlock("div",yo,[e.createElementVNode("button",{class:"lc-btn",title:"展开素材台",onClick:u[0]||(u[0]=v=>s(n.value))},"»"),e.createElementVNode("button",{class:e.normalizeClass(["lc-btn",{on:n.value==="elements"}]),title:"元素",onClick:u[1]||(u[1]=v=>s("elements"))},"▦",2),e.createElementVNode("button",{class:e.normalizeClass(["lc-btn",{on:n.value==="fields"}]),title:"字段",onClick:u[2]||(u[2]=v=>s("fields"))},"⊛",2),e.createElementVNode("button",{class:e.normalizeClass(["lc-btn",{on:n.value==="layers"}]),title:"图层",onClick:u[3]||(u[3]=v=>s("layers"))},"≡",2)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",ko,[u[12]||(u[12]=e.createElementVNode("span",{class:"left-title"},"素材台",-1)),e.createElementVNode("button",{class:"collapse-btn",title:"收起素材台",onClick:u[4]||(u[4]=v=>d.$emit("toggle-collapse"))},"«")]),e.createElementVNode("div",Eo,[e.createElementVNode("div",wo,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:n.value==="elements"}]),onClick:u[5]||(u[5]=v=>n.value="elements")},"元素",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:n.value==="fields"}]),onClick:u[6]||(u[6]=v=>n.value="fields")},"字段",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:n.value==="layers"}]),onClick:u[7]||(u[7]=v=>n.value="layers")},"图层",2)]),e.withDirectives(e.createElementVNode("div",Vo,[u[13]||(u[13]=e.createElementVNode("div",{class:"panel-title"},"拖拽元素到画布",-1)),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,v=>e.createElementVNode("div",{key:v.type,class:"material-card",draggable:"true",onDragstart:p=>i(p,v.type)},[e.createElementVNode("span",Co,e.toDisplayString(v.icon),1),e.createElementVNode("span",So,e.toDisplayString(v.label),1)],40,No)),64))],512),[[e.vShow,n.value==="elements"]]),e.withDirectives(e.createElementVNode("div",$o,[e.createVNode(bo,{fields:t.fields,onFieldDrag:r},null,8,["fields"])],512),[[e.vShow,n.value==="fields"]]),e.withDirectives(e.createElementVNode("div",Mo,[e.createVNode(ao,{elements:t.elements,"selected-ids":t.selectedIds,onSelect:u[8]||(u[8]=(v,p)=>d.$emit("select",v,p)),onMoveLayer:u[9]||(u[9]=v=>d.$emit("move-layer",v)),onToggleVisible:u[10]||(u[10]=v=>d.$emit("toggle-visible",v)),onToggleLocked:u[11]||(u[11]=v=>d.$emit("toggle-locked",v))},null,8,["elements","selected-ids"])],512),[[e.vShow,n.value==="layers"]])])],64))],2))}}),Do=ee(Bo,[["__scopeId","data-v-eb646f19"]]);function xo(t,l){const o=e.ref(!1),n=e.ref(null);let a=0,i=0,r=0,s=0,d=!1;function u(w){if(l.disabled)return;const L=w.target;if(!(L instanceof HTMLElement)||L.classList.contains("resize-handle"))return;o.value=!0,d=w.altKey,a=w.clientX,i=w.clientY;const I=t.value;I&&(r=parseFloat(I.style.left)||0,s=parseFloat(I.style.top)||0,n.value={left:r,top:s,width:parseFloat(I.style.width)||0,height:parseFloat(I.style.height)||0},l.onStart?.({altKey:d}),document.addEventListener("mousemove",p),document.addEventListener("mouseup",k),w.preventDefault())}function v(w){const L=l.getScale?.()??1;let I=r+(w.clientX-a)/L,U=s+(w.clientY-i)/L;if(l.axis==="x"&&(U=s),l.axis==="y"&&(I=r),l.onAdsorb){const H=t.value;if(H){const z=parseFloat(H.style.width)||0,O=parseFloat(H.style.height)||0,Y=l.onAdsorb({left:I,top:U,width:z,height:O});I=Y.left,U=Y.top}}return{left:I,top:U}}function p(w){const L=v(w);n.value&&(n.value.left=L.left,n.value.top=L.top),l.onDrag(L)}function k(w){o.value=!1;const L=v(w);l.onDragEnd?.(L,{altKey:d}),l.onStop?.(),n.value=null,document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",k)}function C(){const w=t.value;w&&w.removeEventListener("mousedown",u),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",k)}function D(){C();const w=t.value;w&&w.addEventListener("mousedown",u)}return{isDragging:o,dragPreview:n,setup:D,cleanup:C}}const To=["nw","n","ne","e","se","s","sw","w"];function zo(t,l,o,n,a,i){let{left:r,top:s,width:d,height:u}=l;switch(t){case"e":d=Math.max(a,l.width+o);break;case"w":d=Math.max(a,l.width-o),r=l.left+l.width-d;break;case"s":u=Math.max(i,l.height+n);break;case"n":u=Math.max(i,l.height-n),s=l.top+l.height-u;break;case"se":d=Math.max(a,l.width+o),u=Math.max(i,l.height+n);break;case"sw":d=Math.max(a,l.width-o),r=l.left+l.width-d,u=Math.max(i,l.height+n);break;case"ne":d=Math.max(a,l.width+o),u=Math.max(i,l.height-n),s=l.top+l.height-u;break;case"nw":d=Math.max(a,l.width-o),r=l.left+l.width-d,u=Math.max(i,l.height-n),s=l.top+l.height-u;break}return{left:r,top:s,width:d,height:u}}function Lo(t){let l=0,o=0,n={left:0,top:0,width:0,height:0},a=null;function i(u,v){a=u,l=v.clientX,o=v.clientY,n={...t.getRect()},t.onStart?.(),document.addEventListener("mousemove",r),document.addEventListener("mouseup",s),v.preventDefault()}function r(u){if(!a)return;const v=t.getScale?.()||1,p=(u.clientX-l)/v,k=(u.clientY-o)/v,C=t.minWidth||20,D=t.minHeight||20;t.onResize(zo(a,n,p,k,C,D))}function s(){a=null,t.onStop?.(),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",s)}function d(){document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",s)}return{startResize:i,cleanup:d}}function Po(t,l){return l.split(".").reduce((o,n)=>o?.[n],t)}function Ao(){function t(l){const o=l.options.formatter,n=l.options.title;if(!o)return{status:"unbound",badge:n||"文本",badgeColor:"#909399",demoPreview:n||"文本"};const a=Mt(),i=o.match(/\{([^}]+)\}/);if(i){const r=i[1],s=Po(a,r);return{status:"bound",badge:`fx ${o}`,badgeColor:"#409EFF",demoPreview:s!=null?String(s):o}}return{status:"bound",badge:`fx ${o}`,badgeColor:"#409EFF",demoPreview:o}}return{getBindingDisplayState:t}}const Io=e.defineComponent({__name:"TextElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,o={top:"flex-start",middle:"center",bottom:"flex-end"},n={left:"flex-start",center:"center",right:"flex-end"},a=e.computed(()=>{const r=l.element.options;return{fontSize:(r.fontSize||12)+"pt",fontWeight:r.fontWeight||"normal",fontFamily:r.fontFamily||"inherit",color:r.color||"#333",backgroundColor:r.backgroundColor||"transparent",textAlign:r.textAlign||"left",lineHeight:r.lineHeight?r.lineHeight+"pt":"normal",letterSpacing:r.letterSpacing?r.letterSpacing+"pt":"normal",textDecoration:r.textDecoration||"none",padding:`${r.contentPaddingTop||0}pt ${r.contentPaddingRight||0}pt ${r.contentPaddingBottom||0}pt ${r.contentPaddingLeft||0}pt`,width:"100%",height:"100%",boxSizing:"border-box",overflow:"hidden",...r.verticalAlign?{display:"flex",alignItems:o[r.verticalAlign]??"flex-start",justifyContent:n[r.textAlign||"left"]??"flex-start"}:{}}}),i=e.computed(()=>l.designMode?l.element.options.testData?l.element.options.testData:l.element.options.formatter||"文本":Ae(l.element.options,l.data));return(r,s)=>(e.openBlock(),e.createElementBlock("div",{class:"print-text",style:e.normalizeStyle(a.value)},e.toDisplayString(i.value),5))}}),Ro={class:"print-image"},Fo=["src"],Uo={key:1,class:"image-placeholder"},Ho=e.defineComponent({__name:"ImageElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,o=e.computed(()=>{const r=l.element.options.src||"";return r?r.includes("{")?l.designMode?Le(r,ue):Le(r,l.data?.[0]||{}):r:""}),n=e.ref(!1);function a(){n.value=!0}e.watch(o,()=>{n.value=!1});const i=e.computed(()=>({objectFit:l.element.options.fit||"contain"}));return(r,s)=>(e.openBlock(),e.createElementBlock("div",Ro,[o.value&&!n.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:o.value,style:e.normalizeStyle(i.value),onError:a},null,44,Fo)):(e.openBlock(),e.createElementBlock("div",Uo,"图片"))]))}}),Go=ee(Ho,[["__scopeId","data-v-530ee54f"]]),Oo=e.defineComponent({__name:"LongTextElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,o={top:"flex-start",middle:"center",bottom:"flex-end"},n={left:"flex-start",center:"center",right:"flex-end"},a=e.computed(()=>{const r=l.element.options;return{fontSize:(r.fontSize||12)+"pt",fontWeight:r.fontWeight||"normal",fontFamily:r.fontFamily||"inherit",color:r.color||"#333",backgroundColor:r.backgroundColor||"transparent",textAlign:r.textAlign||"left",lineHeight:r.lineHeight?r.lineHeight+"pt":"1.5",letterSpacing:r.letterSpacing?r.letterSpacing+"pt":"normal",textIndent:r.longTextIndent?r.longTextIndent+"pt":"0",width:"100%",height:"100%",overflow:"hidden",wordBreak:"break-all",boxSizing:"border-box",...r.verticalAlign?{display:"flex",alignItems:o[r.verticalAlign]??"flex-start",justifyContent:n[r.textAlign||"left"]??"flex-start"}:{}}}),i=e.computed(()=>l.designMode?l.element.options.formatter?l.element.options.formatter:"长文本内容":Ae(l.element.options,l.data));return(r,s)=>(e.openBlock(),e.createElementBlock("div",{class:"print-longtext",style:e.normalizeStyle(a.value)},e.toDisplayString(i.value),5))}}),qo=["title"],Wo=["title","onClick"],Ko=e.defineComponent({__name:"TableContextMenu",props:{visible:{type:Boolean},x:{},y:{},canDeleteRow:{type:Boolean},canDeleteCol:{type:Boolean},mergeDisabledReason:{},canSplit:{type:Boolean},currentRowType:{},rowTypeDisabledReason:{type:Function}},emits:["action"],setup(t,{emit:l}){const o=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],n=l;function a(i,r){n("action",i,r)}return(i,r)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[t.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:"table-ctx-menu",style:e.normalizeStyle({left:t.x+"px",top:t.y+"px"}),onMousedown:r[8]||(r[8]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:"menu-item",onClick:r[0]||(r[0]=s=>a("insert-row-above"))},"在上方插入行"),e.createElementVNode("div",{class:"menu-item",onClick:r[1]||(r[1]=s=>a("insert-row-below"))},"在下方插入行"),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!t.canDeleteRow}]),onClick:r[2]||(r[2]=s=>t.canDeleteRow&&a("delete-row"))}," 删除行 ",2),r[9]||(r[9]=e.createElementVNode("div",{class:"menu-divider"},null,-1)),e.createElementVNode("div",{class:"menu-item",onClick:r[3]||(r[3]=s=>a("insert-col-left"))},"在左侧插入列"),e.createElementVNode("div",{class:"menu-item",onClick:r[4]||(r[4]=s=>a("insert-col-right"))},"在右侧插入列"),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!t.canDeleteCol}]),onClick:r[5]||(r[5]=s=>t.canDeleteCol&&a("delete-col"))}," 删除列 ",2),r[10]||(r[10]=e.createElementVNode("div",{class:"menu-divider"},null,-1)),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!!t.mergeDisabledReason}]),title:t.mergeDisabledReason||"",onClick:r[6]||(r[6]=s=>!t.mergeDisabledReason&&a("merge"))}," 合并单元格 ",10,qo),e.createElementVNode("div",{class:e.normalizeClass(["menu-item",{disabled:!t.canSplit}]),onClick:r[7]||(r[7]=s=>t.canSplit&&a("split"))}," 拆分单元格 ",2),r[11]||(r[11]=e.createElementVNode("div",{class:"menu-divider"},null,-1)),r[12]||(r[12]=e.createElementVNode("div",{class:"menu-group-title"},"行类型",-1)),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,s=>e.createElementVNode("div",{key:s.value,class:e.normalizeClass(["menu-item",{disabled:!!t.rowTypeDisabledReason(s.value),active:t.currentRowType===s.value}]),title:t.rowTypeDisabledReason(s.value)||"",onClick:d=>!t.rowTypeDisabledReason(s.value)&&a("set-row-type",s.value)},e.toDisplayString(s.label),11,Wo)),64))],36)):e.createCommentVNode("",!0)]))}}),Yo=ee(Ko,[["__scopeId","data-v-3f0b28d4"]]),Xo={class:"cell-barcode"},jo=["src"],Jo={key:1,class:"cell-barcode-fallback"},Zo=e.defineComponent({__name:"CellBarcode",props:{cellType:{},value:{},barcodeType:{},qrCodeLevel:{},showText:{type:Boolean}},setup(t){const l=t,o=e.ref(null),n=e.ref(!1),a=e.ref("");function i(){if(n.value=!1,!!o.value)try{et(o.value,l.value,{format:l.barcodeType||"CODE128",width:1,height:28,displayValue:l.showText!==!1,fontSize:9,margin:0}),n.value=!0}catch{}}async function r(){if(!l.value){a.value="";return}try{a.value=await tt.toDataURL(l.value,{width:96,margin:1,errorCorrectionLevel:l.qrCodeLevel||"M"})}catch{a.value=""}}function s(){l.cellType==="barcode"?i():r()}return e.onMounted(s),e.watch(()=>[l.cellType,l.value,l.barcodeType,l.qrCodeLevel,l.showText],s),(d,u)=>(e.openBlock(),e.createElementBlock("div",Xo,[e.withDirectives((e.openBlock(),e.createElementBlock("svg",{ref_key:"barcodeSvg",ref:o,preserveAspectRatio:"xMidYMid meet"},null,512)),[[e.vShow,t.cellType==="barcode"&&n.value]]),t.cellType==="qrcode"&&a.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:a.value,alt:"qrcode"},null,8,jo)):e.createCommentVNode("",!0),!n.value&&t.cellType==="barcode"?(e.openBlock(),e.createElementBlock("span",Jo,e.toDisplayString(t.value||"条码"),1)):e.createCommentVNode("",!0)]))}}),Qo=ee(Zo,[["__scopeId","data-v-8ff197a1"]]),_o=["rowspan","colspan","onMousedown","onMouseenter","onDblclick","onContextmenu"],el={key:1,class:"data-placeholder"},tl={key:0,class:"row-badges"},Ke=3.7795275591,nl=.1,ol=e.defineComponent({__name:"TableElement",props:{element:{},designMode:{type:Boolean},isSelected:{type:Boolean},showTableGhostBorder:{type:Boolean}},emits:["dblclick-element","dblclick-cell"],setup(t,{emit:l}){const o={header:"题",data:"数",subtotal:"小",summary:"汇"},n=t,a=l,i=e.inject(Se,{tableSelection:e.ref(null),setTableSelection:()=>{},recordHistory:()=>{},maxTableWidth:e.ref(1/0)}),r=e.computed(()=>n.element.options.tableRows??[]),s=e.computed(()=>n.element.options.tableColWidths??[]),d=e.computed(()=>n.element.options.tableDefaultFontSize??10),u=e.computed(()=>n.element.options.tableDefaultColor??"#333333"),v=e.computed(()=>{const M=i.tableSelection.value;return M&&M.elementId===n.element.id?M:null});function p(M){let B=0;for(let T=0;T<M;T++)B+=r.value[T].height;return B}const k=e.ref(null),C=e.ref([]);function D(){if(!n.designMode)return;const M=k.value;if(!M)return;const B=M.offsetHeight;if(B<=0)return;const T=n.element.options,q=B/Ke;Math.abs(q-(T.height??0))>nl&&(T.height=Math.round(q*100)/100);const m=M.offsetTop;C.value=Array.from(M.rows).map(b=>({top:(b.offsetTop-m)/Ke,height:b.offsetHeight/Ke}))}function w(M){return C.value[M]?.top??p(M)}function L(M){return C.value[M]?.height??r.value[M]?.height??0}e.watch(()=>[n.element.options,n.designMode],()=>D(),{deep:!0,flush:"post"}),e.onMounted(()=>{D(),document.fonts?.ready.then(()=>D())});const I=e.computed(()=>{const M=n.element.options.dataSource;if(M&&Array.isArray(ue[M]))return ue[M];for(const B of Object.values(ue))if(Array.isArray(B))return B});function U(M){return M.cellType==="barcode"||M.cellType==="qrcode"}function H(M,B){return U(B)?mn(B.formatter,I.value):B.formatter||""}function z(M,B){const T=n.element.options,q={designMode:n.designMode,showGhostBorder:n.showTableGhostBorder};return{fontFamily:B.fontFamily||"inherit",textAlign:B.align??"left",verticalAlign:B.valign??"middle",fontSize:(B.fontSize??d.value)+"pt",fontWeight:B.fontWeight??"normal",color:B.color??u.value,backgroundColor:B.backgroundColor??"transparent",borderTop:De(B.borders?.top,q),borderRight:De(B.borders?.right,q),borderBottom:De(B.borders?.bottom,q),borderLeft:De(B.borders?.left,q),padding:(B.padding??T.tableDefaultPadding??1)+"mm",whiteSpace:B.wordWrap??!0?"normal":"nowrap",overflow:B.wordWrap??!0?"visible":"hidden"}}function O(M,B){const T=v.value;return{"cell-selected":!!T&&M>=T.r1&&M<=T.r2&&B>=T.c1&&B<=T.c2,"row-data-bg":r.value[M].type==="data"}}const Y=e.ref(null);function j(M,B){const T=Vt(r.value,M,B);i.setTableSelection({elementId:n.element.id,...T})}function W(M,B,T){!n.designMode||!n.isSelected||(T.stopPropagation(),T.shiftKey&&v.value?j({r:v.value.r1,c:v.value.c1},{r:M,c:B}):(Y.value={r:M,c:B},j({r:M,c:B},{r:M,c:B})),window.addEventListener("mouseup",()=>{Y.value=null},{once:!0}))}function y(M,B){Y.value&&j(Y.value,{r:M,c:B})}function f(M,B){n.designMode&&a("dblclick-cell",n.element.id,M,B)}const h=e.reactive({visible:!1,x:0,y:0});function c(M,B,T){if(!n.designMode||!n.isSelected)return;const q=v.value;q&&M>=q.r1&&M<=q.r2&&B>=q.c1&&B<=q.c2||j({r:M,c:B},{r:M,c:B}),h.x=T.clientX,h.y=T.clientY,h.visible=!0,window.addEventListener("mousedown",()=>{h.visible=!1},{once:!0})}const g=e.computed(()=>{const M=v.value;return M?Nt(r.value,M):"未选择单元格"}),$=e.computed(()=>{const M=v.value;if(!M)return!1;for(let B=M.r1;B<=M.r2;B++)for(let T=M.c1;T<=M.c2;T++){const q=r.value[B].cells[T];if(!q.merged&&((q.rowspan??1)>1||(q.colspan??1)>1))return!0}return!1});function G(M){const B=v.value;if(!B)return"未选择单元格";if(B.r1!==B.r2)return"行类型仅支持单行设置";const T=JSON.parse(JSON.stringify(r.value));return Je(T,B.r1,M)}function K(){Pe(n.element.options)}function X(M,B){const T=i.maxTableWidth.value,q=M.reduce((m,b)=>m+b,0)+M[B];return q>T?`插入后表格总宽 ${Math.round(q*10)/10}mm 超过打印范围宽度 ${T}mm,请先缩小列宽`:null}function ae(M,B){const T=v.value;if(!T)return;h.visible=!1;const q=n.element.options,m=q.tableRows,b=q.tableColWidths;let E=null;switch(M){case"insert-row-above":ut(m,T.r1,"above");break;case"insert-row-below":ut(m,T.r2,"below");break;case"delete-row":E=on(m,T.r1);break;case"insert-col-left":E=X(b,T.c1),E||mt(m,b,T.c1,"left");break;case"insert-col-right":E=X(b,T.c2),E||mt(m,b,T.c2,"right");break;case"delete-col":E=ln(m,b,T.c1);break;case"merge":Ct(m,T);break;case"split":St(m,T);break;case"set-row-type":E=Je(m,T.r1,B);break}if(E){alert(E);return}i.setTableSelection(null),K(),i.recordHistory()}return(M,B)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["print-table",{"design-mode":t.designMode}]),onContextmenu:B[0]||(B[0]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("table",{ref_key:"tableRef",ref:k,style:e.normalizeStyle({fontSize:d.value+"pt",color:u.value})},[e.createElementVNode("colgroup",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,(T,q)=>(e.openBlock(),e.createElementBlock("col",{key:q,style:e.normalizeStyle({width:T+"mm"})},null,4))),128))]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(T,q)=>(e.openBlock(),e.createElementBlock("tr",{key:T.id,style:e.normalizeStyle({height:T.height+"mm"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.cells,(m,b)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:m.id},[m.merged?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("td",{key:0,rowspan:m.rowspan||1,colspan:m.colspan||1,class:e.normalizeClass(O(q,b)),style:e.normalizeStyle(z(T,m)),onMousedown:e.withModifiers(E=>W(q,b,E),["left"]),onMouseenter:E=>y(q,b),onDblclick:e.withModifiers(E=>f(q,b),["stop"]),onContextmenu:e.withModifiers(E=>c(q,b,E),["prevent","stop"])},[U(m)?(e.openBlock(),e.createBlock(Qo,{key:0,"cell-type":m.cellType,value:H(T,m),"barcode-type":m.barcodeType,"qr-code-level":m.qrCodeLevel,"show-text":m.showBarcodeText},null,8,["cell-type","value","barcode-type","qr-code-level","show-text"])):T.type==="data"?(e.openBlock(),e.createElementBlock("span",el,e.toDisplayString(H(T,m)),1)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(e.toDisplayString(H(T,m)),1)],64))],46,_o))],64))),128))],4))),128))])],4),t.designMode&&t.isSelected?(e.openBlock(),e.createElementBlock("div",tl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(T,q)=>(e.openBlock(),e.createElementBlock("span",{key:T.id,class:"row-badge",style:e.normalizeStyle({top:w(q)+"mm",height:L(q)+"mm"})},e.toDisplayString(o[T.type]),5))),128))])):e.createCommentVNode("",!0),e.createVNode(Yo,{visible:h.visible,x:h.x,y:h.y,"can-delete-row":r.value.length>1,"can-delete-col":s.value.length>1,"merge-disabled-reason":g.value,"can-split":$.value,"current-row-type":v.value?r.value[v.value.r1]?.type??null:null,"row-type-disabled-reason":G,onAction:ae},null,8,["visible","x","y","can-delete-row","can-delete-col","merge-disabled-reason","can-split","current-row-type"])],34))}}),ll=ee(ol,[["__scopeId","data-v-e3e66079"]]),vt=e.defineComponent({__name:"LineElement",props:{element:{}},setup(t){const l=t,o=e.computed(()=>l.element.printElementType.type==="hline"),n=e.computed(()=>{const a=l.element.options,i=(a.borderWidth||.75)+"pt",r=a.borderStyle||"solid",s=a.borderColor||"#333";return o.value?{width:"100%",height:"0",borderTop:`${i} ${r} ${s}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${i} ${r} ${s}`,boxSizing:"border-box"}});return(a,i)=>(e.openBlock(),e.createElementBlock("div",{class:"print-line",style:e.normalizeStyle(n.value)},null,4))}}),gt=e.defineComponent({__name:"ShapeElement",props:{element:{}},setup(t){const l=t,o=e.computed(()=>l.element.printElementType.type==="oval"),n=e.computed(()=>{const a=l.element.options;return{width:"100%",height:"100%",borderWidth:(a.borderWidth||1)+"pt",borderStyle:a.borderStyle||"solid",borderColor:a.borderColor||"#333",backgroundColor:a.backgroundColor||"transparent",borderRadius:o.value?"50%":"0",boxSizing:"border-box"}});return(a,i)=>(e.openBlock(),e.createElementBlock("div",{class:"print-shape",style:e.normalizeStyle(n.value)},null,4))}}),al={class:"print-barcode",ref:"containerRef"},il=96/25.4,rl=e.defineComponent({__name:"BarcodeElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,o=e.ref(null);function n(){if(!o.value)return;const a=l.element.options,i=(l.designMode?a.testData||a.formatter:Ae(a,l.data))||"条码",r=!a.hideTitle,s=(a.fontSize||12)*(96/72),d=(a.height||40)*il,u=r?s+4:0,v=Math.max(8,d-u);try{et(o.value,i,{format:a.barcodeType||"CODE128",width:a.barWidth?a.barWidth/2:1,height:v,displayValue:r,fontSize:s,margin:2})}catch{}}return e.onMounted(n),e.watch(()=>[l.element.options.formatter,l.element.options.testData,l.element.options.barcodeType,l.element.options.width,l.element.options.height,l.element.options.barWidth,l.element.options.hideTitle,l.element.options.fontSize],n),(a,i)=>(e.openBlock(),e.createElementBlock("div",al,[(e.openBlock(),e.createElementBlock("svg",{ref_key:"svgRef",ref:o,preserveAspectRatio:"xMidYMid meet"},null,512))],512))}}),sl=ee(rl,[["__scopeId","data-v-a71e7c44"]]),dl={class:"print-qrcode"},cl=["src"],ul=e.defineComponent({__name:"QrcodeElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,o=e.ref("");async function n(){const a=l.element.options,i=(l.designMode?a.testData||a.formatter:Ae(a,l.data))||"二维码",r=Math.min(a.width||80,a.height||80);try{o.value=await tt.toDataURL(i,{width:r,margin:1,errorCorrectionLevel:String(a.qrCodeLevel??"M")})}catch{o.value=""}}return e.onMounted(n),e.watch(()=>[l.element.options.formatter,l.element.options.testData],n),(a,i)=>(e.openBlock(),e.createElementBlock("div",dl,[o.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:o.value,alt:"qrcode"},null,8,cl)):e.createCommentVNode("",!0)]))}}),ml=ee(ul,[["__scopeId","data-v-90b31b7e"]]),pl=["innerHTML"],fl=e.defineComponent({__name:"HtmlElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,o=e.computed(()=>{if(l.element.options.formatter){const n=l.data&&l.data.length>0?l.data[0]:{},a=Le(l.element.options.formatter,n??{});return a?Jt.sanitize(a):""}return'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>'});return(n,a)=>(e.openBlock(),e.createElementBlock("div",{class:"print-html",innerHTML:o.value},null,8,pl))}}),vl=ee(fl,[["__scopeId","data-v-f0a224c2"]]),gl=e.defineComponent({__name:"PageNumberElement",props:{element:{},data:{},designMode:{type:Boolean}},setup(t){const l=t,o=e.computed(()=>{const a=l.element.options;return{fontSize:(a.fontSize||12)+"pt",fontWeight:a.fontWeight||"normal",fontFamily:a.fontFamily||"inherit",color:a.color||"#333",textAlign:a.textAlign||"left",lineHeight:a.lineHeight?a.lineHeight+"pt":"normal",letterSpacing:a.letterSpacing?a.letterSpacing+"pt":"normal"}}),n=e.computed(()=>l.designMode?l.element.options.title||"{pageIndex}/{totalPages}":l.element.options.title||"");return(a,i)=>(e.openBlock(),e.createElementBlock("div",{class:"page-number-element",style:e.normalizeStyle(o.value)},e.toDisplayString(n.value),5))}}),hl=ee(gl,[["__scopeId","data-v-c3750ca3"]]),bl={key:0,class:"drag-preview"},yl={key:1,class:"resize-handles"},kl=["onMousedown"],El={key:2,class:"selected-indicator"},wl={class:"position-label"},Vl=e.defineComponent({__name:"BaseElement",props:{element:{},isSelected:{type:Boolean},designMode:{type:Boolean},printData:{},scale:{},allElements:{},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},zone:{},adsorbHandler:{type:Function},clearAdsorbGuides:{type:Function}},emits:["select","update:element","drag-start","drag-stop","dblclick-element","dblclick-cell","contextmenu","clone-element"],setup(t,{emit:l}){const o=t,n=l,a=e.ref(null),i=e.inject(xt,null),r=e.computed(()=>i?.value?i.value.has(o.element.id):o.isSelected??!1),s=e.inject(Tt,null),d=e.computed(()=>s?.value.has(o.element.id)??!1),u={text:e.markRaw(Io),image:e.markRaw(Go),longText:e.markRaw(Oo),table:e.markRaw(ll),hline:e.markRaw(vt),vline:e.markRaw(vt),rect:e.markRaw(gt),oval:e.markRaw(gt),barcode:e.markRaw(sl),qrcode:e.markRaw(ml),html:e.markRaw(vl),pageNumber:e.markRaw(hl)},{getBindingDisplayState:v}=Ao(),p=e.computed(()=>o.designMode?v(o.element):null),k=e.computed(()=>u[o.element.printElementType.type]),C=e.computed(()=>o.element.printElementType.type==="table"?{showTableGhostBorder:o.showTableGhostBorder}:{}),D=e.computed(()=>{const g=o.element.options;return{position:"absolute",left:g.left+"mm",top:g.top+"mm",width:g.width+"mm",height:g.height+"mm",zIndex:g.zIndex||"auto"}}),w=e.computed(()=>{const g=o.element.options;return`x:${Math.round(g.left)} y:${Math.round(g.top)} ${Math.round(g.width)}×${Math.round(g.height)}mm`});let L=0,I=0;const U=e.reactive({disabled:!o.designMode||!!o.element.options.locked,getScale:()=>o.scale||1,onDrag:g=>{const $=g.left-L,G=g.top-I;a.value&&(a.value.style.transform=`translate(${$}mm, ${G}mm)`)},onDragEnd:(g,$)=>{if($.altKey){const X=JSON.parse(JSON.stringify(o.element));X.id=Ee(),X.options.left=g.left,X.options.top=g.top,n("clone-element",X,{left:g.left,top:g.top}),a.value&&(a.value.style.transform="");return}const G=g.left-L,K=g.top-I;if(o.element.options.left=g.left,o.element.options.top=g.top,a.value&&(a.value.style.transform=""),o.element.options.groupId&&o.allElements)for(const X of o.allElements)X.id!==o.element.id&&X.options.groupId===o.element.options.groupId&&(X.options.left+=G,X.options.top+=K)},onStart:()=>{L=o.element.options.left,I=o.element.options.top,n("select",o.element.id,!1),n("drag-start")},onStop:()=>{o.clearAdsorbGuides?.(),n("drag-stop")},onAdsorb:g=>{let $=g.left,G=g.top;return o.snapToGrid&&($=Math.round(g.left/5)*5,G=Math.round(g.top/5)*5),o.adsorbHandler?o.adsorbHandler({id:o.element.id,left:$,top:G,width:o.element.options.width,height:o.element.options.height}):{left:$,top:G,lines:[]}}}),{setup:H,cleanup:z,isDragging:O}=xo(a,U);e.watchEffect(()=>{U.disabled=!o.designMode||!!o.element.options.locked});const Y=e.computed(()=>r.value&&!!o.designMode&&!o.element.options.locked&&o.element.printElementType.type!=="table"),{startResize:j,cleanup:W}=Lo({minWidth:3.5,minHeight:3.5,getScale:()=>o.scale||1,getRect:()=>({left:o.element.options.left,top:o.element.options.top,width:o.element.options.width,height:o.element.options.height}),onResize:g=>{o.element.options.left=g.left,o.element.options.top=g.top,o.element.options.width=g.width,o.element.options.height=g.height},onStart:()=>{n("drag-start")},onStop:()=>{n("drag-stop")}});function y(g){o.designMode&&n("select",o.element.id,g.ctrlKey||g.metaKey)}function f(){o.designMode&&n("dblclick-element",o.element.id)}function h(g,$,G){o.designMode&&n("dblclick-cell",g,$,G)}e.onMounted(()=>{o.designMode&&H()});function c(){z(),W(),o.clearAdsorbGuides?.()}return e.onUnmounted(()=>{c()}),(g,$)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"elRef",ref:a,class:e.normalizeClass(["print-element",{selected:r.value,previewed:d.value,"design-mode":t.designMode,locked:t.element.options.locked,hidden:t.element.options.visible===!1,"drag-ghost":e.unref(O),[`type-${t.element.printElementType.type}`]:!0,[`zone-${t.zone||"content"}`]:!0}]),style:e.normalizeStyle(D.value),onMousedown:e.withModifiers(y,["stop"]),onDblclick:e.withModifiers(f,["stop"]),onContextmenu:$[0]||($[0]=e.withModifiers(G=>g.$emit("contextmenu",t.element.id,G),["prevent","stop"]))},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.value),e.mergeProps({element:t.element,data:t.printData,"design-mode":t.designMode,"is-selected":r.value},C.value,{onDblclickCell:h}),null,16,["element","data","design-mode","is-selected"])),e.unref(O)?(e.openBlock(),e.createElementBlock("div",bl)):e.createCommentVNode("",!0),Y.value?(e.openBlock(),e.createElementBlock("div",yl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(To),G=>(e.openBlock(),e.createElementBlock("div",{key:G,class:e.normalizeClass(["resize-handle",`handle-${G}`]),onMousedown:e.withModifiers(K=>e.unref(j)(G,K),["stop"])},null,42,kl))),128))])):e.createCommentVNode("",!0),r.value&&t.designMode?(e.openBlock(),e.createElementBlock("div",El,[e.createElementVNode("div",wl,e.toDisplayString(w.value),1)])):e.createCommentVNode("",!0),t.designMode&&p.value?(e.openBlock(),e.createElementBlock("div",{key:3,class:"binding-badge",style:e.normalizeStyle({color:p.value.badgeColor})},e.toDisplayString(p.value.badge),5)):e.createCommentVNode("",!0)],38))}}),Ye=ee(Vl,[["__scopeId","data-v-ab693d09"]]);function Nl(t){const l=[];for(let o=0;o<=t+1e-9;o+=5){const n=Math.round(o*100)/100,a=n%10===0;a?l.push({mm:n,major:a,label:String(n)}):l.push({mm:n,major:a})}return l}const Xe=96/25.4,ke=16,Cl=e.defineComponent({__name:"Ruler",props:{orientation:{},lengthMM:{},scale:{}},emits:["add-guide"],setup(t,{emit:l}){const o=t,n=l,a=e.ref(null),i=e.computed(()=>o.orientation==="horizontal"?{width:o.lengthMM+"mm",height:ke+"px"}:{width:ke+"px",height:o.lengthMM+"mm"});function r(){const p=a.value;if(!p)return;const k=window.devicePixelRatio||1,C=o.lengthMM*Xe,D=o.orientation==="horizontal";p.width=(D?C:ke)*k,p.height=(D?ke:C)*k;const w=p.getContext("2d");if(!w)return;w.scale(k,k);const L=getComputedStyle(p),I=L.getPropertyValue("--pd-ruler-bg").trim()||"#FFFFFF",U=L.getPropertyValue("--pd-ruler").trim()||"#9CA3AF";w.fillStyle=I,w.fillRect(0,0,D?C:ke,D?ke:C),w.strokeStyle=U,w.fillStyle=U,w.lineWidth=1,w.font="8px ui-monospace, Menlo, monospace";for(const H of Nl(o.lengthMM)){const z=Math.round(H.mm*Xe)+.5,O=H.major?8:4;w.beginPath(),D?(w.moveTo(z,0),w.lineTo(z,O)):(w.moveTo(0,z),w.lineTo(O,z)),w.stroke(),H.major&&H.label&&(D?w.fillText(H.label,z+2,14):(w.save(),w.translate(12,z+2),w.rotate(-Math.PI/2),w.fillText(H.label,-w.measureText(H.label).width,0),w.restore()))}}e.watch(()=>[o.lengthMM,o.orientation],r),e.onMounted(r);let s=!1;function d(p){s=!0,p.preventDefault(),window.addEventListener("mousemove",u),window.addEventListener("mouseup",v)}function u(){}function v(p){if(!s)return;s=!1,window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",v);const k=a.value;if(!k)return;const C=k.getBoundingClientRect(),D=o.scale??1,L=(o.orientation==="horizontal"?(p.clientX-C.left)/D:(p.clientY-C.top)/D)/Xe;L>0&&L<o.lengthMM&&n("add-guide",o.orientation==="horizontal"?"horizontal":"vertical",L)}return(p,k)=>(e.openBlock(),e.createElementBlock("canvas",{ref_key:"canvasRef",ref:a,class:"pd-ruler",style:e.normalizeStyle(i.value),onMousedown:d},null,36))}}),ht=ee(Cl,[["__scopeId","data-v-fdb82e87"]]);function Sl(t={}){const l=t.adsorbMin??1,o=t.adsorbLineMin??2,n=t.showAdsorbLine??!0,a=e.ref([]),i=e.ref({width:0,height:0}),r={left:"#3b82f6",center:"#10b981",right:"#f59e0b",top:"#3b82f6",middle:"#10b981",bottom:"#f59e0b"};function s(p){return p==="vCenter"?r.center:p==="hCenter"?r.middle:r[p]??r.left}function d(p,k,C){let D=p.left,w=p.top;const L=[],I={left:p.left,right:p.left+p.width,vCenter:p.left+p.width/2,top:p.top,bottom:p.top+p.height,hCenter:p.top+p.height/2};let U=1/0;for(const z of k){if(z.id===p.id)continue;const O={left:z.left,right:z.left+z.width,vCenter:z.left+z.width/2,top:z.top,bottom:z.top+z.height,hCenter:z.top+z.height/2},Y=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],j=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[W,y]of Y){const f=Math.abs(I[W]-O[y]);f<=l&&f<U&&(U=f,D=p.left+(O[y]-I[W]))}for(const[W,y]of j){const f=Math.abs(I[W]-O[y]);f<=l&&f<U&&(U=f,w=p.top+(O[y]-I[W]))}}if(C){const z={left:D,right:D+p.width,vCenter:D+p.width/2,top:w,bottom:w+p.height,hCenter:w+p.height/2},O=["left","vCenter","right"];for(const j of C.vertical)for(const W of O){const y=Math.abs(z[W]-j);y<=l&&y<U&&(U=y,D=p.left+(j-z[W]))}const Y=["top","hCenter","bottom"];for(const j of C.horizontal)for(const W of Y){const y=Math.abs(z[W]-j);y<=l&&y<U&&(U=y,w=p.top+(j-z[W]))}}const H={left:D,right:D+p.width,vCenter:D+p.width/2,top:w,bottom:w+p.height,hCenter:w+p.height/2};if(n){const z=new Set;for(const O of k){if(O.id===p.id)continue;const Y={left:O.left,right:O.left+O.width,vCenter:O.left+O.width/2,top:O.top,bottom:O.top+O.height,hCenter:O.top+O.height/2},j=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],W=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[y,f]of j)if(Math.abs(H[y]-Y[f])<=o){const c=`v:${Y[f]}`;z.has(c)||(z.add(c),L.push({type:"vertical",position:Y[f],id:O.id,color:s(y)}))}for(const[y,f]of W)if(Math.abs(H[y]-Y[f])<=o){const c=`h:${Y[f]}`;z.has(c)||(z.add(c),L.push({type:"horizontal",position:Y[f],id:O.id,color:s(y)}))}}}if(C){for(const z of C.vertical)L.some(O=>O.type==="vertical"&&O.position===z)||L.push({type:"vertical",position:z});for(const z of C.horizontal)L.some(O=>O.type==="horizontal"&&O.position===z)||L.push({type:"horizontal",position:z})}return{left:D,top:w,lines:L}}function u(p,k,C){a.value=p,i.value={width:k,height:C}}function v(){a.value=[]}return{check:d,renderLines:u,clearLines:v,guideLines:a,paperSize:i}}function $l(t){const{check:l,renderLines:o,clearLines:n,guideLines:a,paperSize:i}=Sl(t.config??{adsorbMin:1,adsorbLineMin:2,showAdsorbLine:!0});function r(d){const u=t.getElements().filter(k=>k.id!==d.id).map(k=>({id:k.id,left:k.options.left,top:k.options.top,width:k.options.width,height:k.options.height})),v=l(d,u,t.getGuides?.()),p=t.getPaperSize();return o(v.lines,p.width,p.height),v}function s(){n()}return{requestAdsorb:r,clearGuides:s,guideLines:a,paperSize:i}}const Ml={key:0,class:"zone-label"},Bl={key:0,class:"zone-height-tip"},Dl={key:0,class:"zone-label"},xl={key:0,class:"zone-height-tip"},Tl=["onMousedown","onDblclick"],zl=e.defineComponent({__name:"CanvasPaper",props:{templateData:{},runtimeElements:{},designMode:{type:Boolean},printData:{},scale:{},showRuler:{type:Boolean},showGrid:{type:Boolean},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},guides:{}},emits:["select","drag-start","drag-stop","dblclick-element","dblclick-cell","contextmenu","zone-height-change","zone-height-commit","add-guide","guide-move","guide-remove","clone-element"],setup(t,{expose:l,emit:o}){const n=t,a=o,i=e.ref(null),r=e.computed(()=>we(n.templateData).width),s=e.computed(()=>we(n.templateData).height),d=e.computed(()=>{const m=n.templateData.margins,b=n.templateData.header.height,E=n.templateData.footer.height,N=r.value-m.left-m.right;return{header:{left:m.left,top:m.top,width:N,height:b},content:{left:m.left,top:m.top+b,width:N,height:s.value-m.top-m.bottom-b-E},footer:{left:m.left,top:s.value-m.bottom-E,width:N,height:E}}});function u(m){return{position:"absolute",left:m.left+"mm",top:m.top+"mm",width:m.width+"mm",height:m.height+"mm"}}const v=e.computed(()=>{const m={header:[],footer:[],content:[]};for(const b of n.runtimeElements)b.zone==="header"?m.header.push(b):b.zone==="footer"?m.footer.push(b):m.content.push(b);return m}),p=e.computed(()=>v.value.header),k=e.computed(()=>v.value.footer),C=e.computed(()=>v.value.content);let D="content";const{requestAdsorb:w,clearGuides:L,guideLines:I,paperSize:U}=$l({getElements:()=>v.value[D],getPaperSize:()=>{const m=d.value[D];return{width:m.width,height:m.height}},getGuides:()=>{const m=[],b=[];for(const E of n.guides??[])E.type==="vertical"?m.push(E.position):b.push(E.position);return{vertical:m,horizontal:b}}});function H(m){D=n.runtimeElements.find(N=>N.id===m.id)?.zone||"content";const E=w(m);return(E.left!==m.left||E.top!==m.top)&&c(E.left+m.width/2,E.top+m.height/2),E}function z(m,b){const E=b.position,N=m.clientX,F=m.clientY,Z=n.scale??1,S=25.4/96,V=Q=>{const le=(b.type==="vertical"?Q.clientX-N:Q.clientY-F)/Z*S;a("guide-move",b.id,E+le)},P=()=>{window.removeEventListener("mousemove",V),window.removeEventListener("mouseup",P)};window.addEventListener("mousemove",V),window.addEventListener("mouseup",P)}const O=e.computed(()=>({width:r.value+"mm",minHeight:s.value+"mm",background:"var(--pd-paper, #fff)",boxShadow:"var(--pd-shadow-paper, 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08))",margin:"0 auto",overflow:"hidden",position:"relative",transform:n.scale?`scale(${n.scale})`:void 0,transformOrigin:"0 0"})),Y=e.computed(()=>{const m=n.templateData.margins;return{padding:`${m.top}mm ${m.right}mm ${m.bottom}mm ${m.left}mm`,position:"relative",minHeight:s.value+"mm"}}),j=e.computed(()=>n.showRuler!==!1&&!!n.designMode),W=e.computed(()=>({backgroundImage:`url("data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M0 .5H20M.5 0V20" fill="none" stroke="rgba(0,0,0,0.08)" stroke-width="1" stroke-dasharray="4 4"/></svg>')}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}));let y=0,f=null;const h=e.ref(null);function c(m,b){y+=1,h.value={left:m,top:b,key:y},f&&clearTimeout(f),f=setTimeout(()=>{h.value=null},300)}const g=e.computed(()=>{const m=n.templateData.watermark;return m?!m.mode||m.mode==="fixed"?!!m.content&&m.content.trim().length>0:!!m.binding:!1}),$=e.computed(()=>{const m=n.templateData.watermark||{},b=m.color||"#cccccc",E=m.opacity??.15,N=m.rotate??-30;let F=G(m);if(m.timestamp){const Z=new Date,S=`${Z.getFullYear()}-${String(Z.getMonth()+1).padStart(2,"0")}-${String(Z.getDate()).padStart(2,"0")} ${String(Z.getHours()).padStart(2,"0")}:${String(Z.getMinutes()).padStart(2,"0")}`;F=F?`${F} ${S}`:S}return{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"0",overflow:"hidden",opacity:String(E),backgroundImage:K(F,b,N),backgroundRepeat:"repeat"}});function G(m){if(!m.mode||m.mode==="fixed")return m.content||"";if(m.binding){const b=n.printData?.[0];return b&&b[m.binding]!==void 0&&b[m.binding]!==null?String(b[m.binding]):m.testData||`[${m.binding}]`}return""}function K(m,b,E){const N=m.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),F=`<svg xmlns="http://www.w3.org/2000/svg" width="260" height="180">
2
+ <text x="130" y="90" font-size="16" fill="${b}" text-anchor="middle" dominant-baseline="middle" transform="rotate(${E},130,90)">${N}</text>
3
+ </svg>`;return`url("data:image/svg+xml,${encodeURIComponent(F)}")`}const X=e.ref(null);function ae(m,b){T(),X.value={zone:m,startY:b.clientY,startH:n.templateData[m].height},window.addEventListener("mousemove",M),window.addEventListener("mouseup",B)}function M(m){if(!X.value)return;const{zone:b,startY:E,startH:N}=X.value,Z=(m.clientY-E)/(n.scale||1)*25.4/96,S=b==="header"?Z:-Z,V=Math.min(100,s.value-n.templateData.margins.top-n.templateData.margins.bottom-(b==="header"?n.templateData.footer.height:n.templateData.header.height)-10),P=Math.min(V,Math.max(0,Math.round((N+S)*10)/10));a("zone-height-change",b,P)}function B(){if(!X.value)return;const m=X.value.zone;X.value=null,window.removeEventListener("mousemove",M),window.removeEventListener("mouseup",B),a("zone-height-commit",m)}function T(){window.removeEventListener("mousemove",M),window.removeEventListener("mouseup",B),X.value=null}e.onUnmounted(()=>{T(),f&&clearTimeout(f)});function q(m,b){a("select",m,b)}return l({contentRef:i}),(m,b)=>(e.openBlock(),e.createElementBlock("div",{class:"hiprint-printPaper",style:e.normalizeStyle(O.value)},[e.createElementVNode("div",{class:"hiprint-printPaper-content",ref_key:"contentRef",ref:i,style:e.normalizeStyle(Y.value)},[j.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(ht,{orientation:"horizontal","length-m-m":r.value,scale:t.scale,onAddGuide:b[0]||(b[0]=(E,N)=>a("add-guide",E,N))},null,8,["length-m-m","scale"]),e.createVNode(ht,{orientation:"vertical","length-m-m":s.value,scale:t.scale,onAddGuide:b[1]||(b[1]=(E,N)=>a("add-guide",E,N))},null,8,["length-m-m","scale"])],64)):e.createCommentVNode("",!0),t.showGrid&&t.designMode?(e.openBlock(),e.createElementBlock("div",{key:1,class:"grid-bg",style:e.normalizeStyle(W.value)},null,4)):e.createCommentVNode("",!0),h.value?(e.openBlock(),e.createElementBlock("div",{key:h.value.key,class:"snap-indicator",style:e.normalizeStyle({left:h.value.left+"mm",top:h.value.top+"mm"})},null,4)):e.createCommentVNode("",!0),g.value?(e.openBlock(),e.createElementBlock("div",{key:3,class:"watermark-layer",style:e.normalizeStyle($.value)},null,4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["zone-layer zone-header",{"design-mode":t.designMode}]),style:e.normalizeStyle(u(d.value.header))},[t.designMode?(e.openBlock(),e.createElementBlock("span",Ml,"页眉")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,E=>(e.openBlock(),e.createBlock(Ye,{key:E.id,element:E,"design-mode":t.designMode,"print-data":t.printData,scale:t.scale,"all-elements":p.value,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,zone:"header","adsorb-handler":H,"clear-adsorb-guides":e.unref(L),onSelect:q,onDragStart:b[2]||(b[2]=N=>m.$emit("drag-start")),onDragStop:b[3]||(b[3]=N=>m.$emit("drag-stop")),onDblclickElement:b[4]||(b[4]=N=>m.$emit("dblclick-element",N)),onDblclickCell:b[5]||(b[5]=(N,F,Z)=>m.$emit("dblclick-cell",N,F,Z)),onContextmenu:b[6]||(b[6]=(N,F)=>m.$emit("contextmenu",N,F)),onCloneElement:(N,F)=>m.$emit("clone-element",N,F)},null,8,["element","design-mode","print-data","scale","all-elements","snap-to-grid","show-table-ghost-border","clear-adsorb-guides","onCloneElement"]))),128)),t.designMode?(e.openBlock(),e.createElementBlock("div",{key:1,class:"zone-resize-handle handle-bottom",onMousedown:b[7]||(b[7]=e.withModifiers(E=>ae("header",E),["prevent","stop"]))},[X.value?.zone==="header"?(e.openBlock(),e.createElementBlock("div",Bl,e.toDisplayString(t.templateData.header.height.toFixed(1))+"mm ",1)):e.createCommentVNode("",!0)],32)):e.createCommentVNode("",!0)],6),e.createElementVNode("div",{class:e.normalizeClass(["zone-layer zone-content",{"design-mode":t.designMode}]),style:e.normalizeStyle(u(d.value.content))},[t.designMode&&t.templateData.firstPageOverlay.height>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"zone-overlay",style:e.normalizeStyle({height:t.templateData.firstPageOverlay.height+"mm"})},[...b[19]||(b[19]=[e.createElementVNode("span",{class:"zone-label"},"首页叠加",-1)])],4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,E=>(e.openBlock(),e.createBlock(Ye,{key:E.id,element:E,"design-mode":t.designMode,"print-data":t.printData,scale:t.scale,"all-elements":C.value,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,zone:"content","adsorb-handler":H,"clear-adsorb-guides":e.unref(L),onSelect:q,onDragStart:b[8]||(b[8]=N=>m.$emit("drag-start")),onDragStop:b[9]||(b[9]=N=>m.$emit("drag-stop")),onDblclickElement:b[10]||(b[10]=N=>m.$emit("dblclick-element",N)),onDblclickCell:b[11]||(b[11]=(N,F,Z)=>m.$emit("dblclick-cell",N,F,Z)),onContextmenu:b[12]||(b[12]=(N,F)=>m.$emit("contextmenu",N,F)),onCloneElement:(N,F)=>m.$emit("clone-element",N,F)},null,8,["element","design-mode","print-data","scale","all-elements","snap-to-grid","show-table-ghost-border","clear-adsorb-guides","onCloneElement"]))),128))],6),e.createElementVNode("div",{class:e.normalizeClass(["zone-layer zone-footer",{"design-mode":t.designMode}]),style:e.normalizeStyle(u(d.value.footer))},[t.designMode?(e.openBlock(),e.createElementBlock("span",Dl,"页脚")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,E=>(e.openBlock(),e.createBlock(Ye,{key:E.id,element:E,"design-mode":t.designMode,"print-data":t.printData,scale:t.scale,"all-elements":k.value,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,zone:"footer","adsorb-handler":H,"clear-adsorb-guides":e.unref(L),onSelect:q,onDragStart:b[13]||(b[13]=N=>m.$emit("drag-start")),onDragStop:b[14]||(b[14]=N=>m.$emit("drag-stop")),onDblclickElement:b[15]||(b[15]=N=>m.$emit("dblclick-element",N)),onDblclickCell:b[16]||(b[16]=(N,F,Z)=>m.$emit("dblclick-cell",N,F,Z)),onContextmenu:b[17]||(b[17]=(N,F)=>m.$emit("contextmenu",N,F)),onCloneElement:(N,F)=>m.$emit("clone-element",N,F)},null,8,["element","design-mode","print-data","scale","all-elements","snap-to-grid","show-table-ghost-border","clear-adsorb-guides","onCloneElement"]))),128)),t.designMode?(e.openBlock(),e.createElementBlock("div",{key:1,class:"zone-resize-handle handle-top",onMousedown:b[18]||(b[18]=e.withModifiers(E=>ae("footer",E),["prevent","stop"]))},[X.value?.zone==="footer"?(e.openBlock(),e.createElementBlock("div",xl,e.toDisplayString(t.templateData.footer.height.toFixed(1))+"mm ",1)):e.createCommentVNode("",!0)],32)):e.createCommentVNode("",!0)],6),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(I),(E,N)=>(e.openBlock(),e.createElementBlock("div",{key:N,class:e.normalizeClass(["adsorb-guide",[`guide-${E.type}`]]),style:e.normalizeStyle(E.type==="vertical"?{left:E.position+"mm",top:"0",height:e.unref(U).height+"mm",borderLeftColor:E.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:E.position+"mm",left:"0",width:e.unref(U).width+"mm",borderTopColor:E.color||"var(--pd-accent-secondary, #f56c6c)"})},null,6))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.guides,E=>(e.openBlock(),e.createElementBlock("div",{key:"mg-"+E.id,class:e.normalizeClass(["manual-guide",[`guide-${E.type}`]]),style:e.normalizeStyle(E.type==="vertical"?{left:E.position+"mm",top:"0",height:s.value+"mm"}:{top:E.position+"mm",left:"0",width:r.value+"mm"}),onMousedown:e.withModifiers(N=>z(N,E),["prevent","stop"]),onDblclick:e.withModifiers(N=>E.id&&a("guide-remove",E.id),["prevent","stop"])},null,46,Tl))),128))],4)],4))}}),Ll=ee(zl,[["__scopeId","data-v-0f1286d9"]]),Pl={class:"canvas-scroll"},Al={key:0,class:"overlay-layer"},Il=["src"],Te=96/25.4,Rl=e.defineComponent({__name:"CanvasArea",props:{templateData:{},elements:{},scale:{},showGrid:{type:Boolean},snapToGrid:{type:Boolean},showTableGhostBorder:{type:Boolean},hasClipboard:{type:Boolean},guides:{},overlayVisible:{type:Boolean},screenshotUrl:{},overlayOpacity:{},selectedElementHasGroup:{type:Boolean}},emits:["select","drop-element","drop-field","drag-start","drag-stop","dblclick-element","dblclick-cell","zone-height-change","zone-height-commit","select-all","clear-selection","preview","commit-preview","paste","copy","cut","delete","move-layer","group","ungroup","coordinate","add-guide","guide-move","guide-remove","zoom","clone-element"],setup(t,{emit:l}){const o=t,n=l;function a(y,f){n("select",y,f)}const i=e.ref(null);function r(y){const f=i.value?.querySelector(".hiprint-printPaper");if(!f)return;const h=f.getBoundingClientRect(),c=o.scale||1,g=xe((y.clientX-h.left)/c),$=xe((y.clientY-h.top)/c);if(!(g<0||$<0))return{x:g,y:$}}function s(y){const f=r(y),h=y.dataTransfer?.getData("fieldData");if(h)try{const g=JSON.parse(h);n("drop-field",g,f);return}catch{}const c=y.dataTransfer?.getData("elementType");c&&n("drop-element",c,f)}const d=e.reactive({visible:!1,x:0,y:0,w:0,h:0});let u={x:0,y:0};function v(y){return!y||!(y instanceof HTMLElement)?!1:!!(y===i.value||y.classList.contains("canvas-scroll")||y.classList.contains("hiprint-printPaper")||y.classList.contains("hiprint-printPaper-content")||y.classList.contains("zone-layer")||y.classList.contains("grid-bg")||y.classList.contains("watermark-layer"))}function p(y){const f=i.value?.querySelector(".hiprint-printPaper");if(!f)return;const h=f.getBoundingClientRect(),c=o.scale||1,g=xe((y.clientX-h.left)/c),$=xe((y.clientY-h.top)/c);if(g<0||$<0){n("coordinate",null);return}n("coordinate",{x:g,y:$})}function k(){n("coordinate",null)}function C(y){if(!(y.ctrlKey||y.metaKey))return;y.preventDefault();const f=o.scale,h=Math.max(.25,Math.min(3,f+(y.deltaY>0?-.1:.1)));if(h===f)return;const c=i.value;if(c){const g=c.getBoundingClientRect(),$=y.clientX-g.left,G=y.clientY-g.top,K=h/f;c.scrollLeft=(c.scrollLeft+$)*K-$,c.scrollTop=(c.scrollTop+G)*K-G}n("zoom",(h-f)*100)}function D(y){y.button!==2&&v(y.target)&&(n("clear-selection"),u={x:y.clientX,y:y.clientY},d.visible=!0,d.x=y.clientX,d.y=y.clientY,d.w=0,d.h=0,window.addEventListener("mousemove",L),window.addEventListener("mouseup",I))}function w(){if(d.w<3||d.h<3)return[];const y=i.value?.querySelector(".hiprint-printPaper");if(!y)return[];const f=y.getBoundingClientRect(),h=o.scale||1,c=d.x<u.x,g=[];for(const $ of o.elements){if($.options.visible===!1||$.options.locked)continue;const G=f.left+$.options.left*Te*h,K=f.top+$.options.top*Te*h,X=G+$.options.width*Te*h,ae=K+$.options.height*Te*h,M=G<d.x+d.w&&X>d.x&&K<d.y+d.h&&ae>d.y,B=G>=d.x&&X<=d.x+d.w&&K>=d.y&&ae<=d.y+d.h;(c?B:M)&&g.push($.id)}return g}function L(y){const f=y.clientX-u.x,h=y.clientY-u.y;d.x=f>=0?u.x:y.clientX,d.y=h>=0?u.y:y.clientY,d.w=Math.abs(f),d.h=Math.abs(h),n("preview",w())}function I(){window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",I);const y=w();n("preview",y),y.length>0?n("commit-preview"):n("clear-selection"),n("preview",[]),d.visible=!1}const U=e.reactive({visible:!1,x:0,y:0,targetId:null});function H(y,f){if(!f&&!v(y.target))return;const h=i.value?.getBoundingClientRect();h&&(U.x=y.clientX-h.left,U.y=y.clientY-h.top,U.targetId=f??null,U.visible=!0,window.removeEventListener("mousedown",z),setTimeout(()=>{window.addEventListener("mousedown",z,{once:!0})},0))}function z(){U.visible=!1,window.removeEventListener("mousedown",z)}function O(){U.visible=!1,o.hasClipboard&&n("paste")}function Y(){U.visible=!1,n("select-all")}function j(){U.visible=!1,n("clear-selection")}function W(y,f){U.visible=!1,y==="copy"?n("copy"):y==="cut"?n("cut"):y==="paste"?n("paste"):y==="delete"?n("delete"):y==="move-layer"?n("move-layer",f):y==="group"?n("group"):y==="ungroup"&&o.selectedElementHasGroup&&n("ungroup")}return e.onBeforeUnmount(()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",I)}),(y,f)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootRef",ref:i,class:"canvas-area",onDragover:f[21]||(f[21]=e.withModifiers(()=>{},["prevent"])),onDrop:s,onMousedown:D,onMousemove:p,onMouseleave:k,onWheel:C,onContextmenu:e.withModifiers(H,["prevent"])},[e.createElementVNode("div",Pl,[e.createVNode(Ll,{"template-data":t.templateData,"runtime-elements":t.elements,"design-mode":!0,"print-data":[],scale:t.scale,"show-grid":t.showGrid,"snap-to-grid":t.snapToGrid,"show-table-ghost-border":t.showTableGhostBorder,guides:t.guides,onSelect:a,onAddGuide:f[0]||(f[0]=(h,c)=>y.$emit("add-guide",h,c)),onGuideMove:f[1]||(f[1]=(h,c)=>y.$emit("guide-move",h,c)),onGuideRemove:f[2]||(f[2]=h=>y.$emit("guide-remove",h)),onDragStart:f[3]||(f[3]=h=>y.$emit("drag-start")),onDragStop:f[4]||(f[4]=h=>y.$emit("drag-stop")),onDblclickElement:f[5]||(f[5]=h=>y.$emit("dblclick-element",h)),onDblclickCell:f[6]||(f[6]=(h,c,g)=>y.$emit("dblclick-cell",h,c,g)),onContextmenu:f[7]||(f[7]=(h,c)=>H(c,h)),onZoneHeightChange:f[8]||(f[8]=(h,c)=>y.$emit("zone-height-change",h,c)),onZoneHeightCommit:f[9]||(f[9]=h=>y.$emit("zone-height-commit",h)),onCloneElement:f[10]||(f[10]=(h,c)=>y.$emit("clone-element",h,c))},null,8,["template-data","runtime-elements","scale","show-grid","snap-to-grid","show-table-ghost-border","guides"]),t.overlayVisible&&t.screenshotUrl?(e.openBlock(),e.createElementBlock("div",Al,[e.createElementVNode("img",{src:t.screenshotUrl,class:"overlay-image",style:e.normalizeStyle({opacity:t.overlayOpacity??.5})},null,12,Il)])):e.createCommentVNode("",!0)]),d.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:"marquee-selection",style:e.normalizeStyle({left:d.x+"px",top:d.y+"px",width:d.w+"px",height:d.h+"px"})},null,4)):e.createCommentVNode("",!0),U.visible?(e.openBlock(),e.createElementBlock("div",{key:1,class:"context-menu",style:e.normalizeStyle({left:U.x+"px",top:U.y+"px"})},[U.targetId?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",{class:"context-menu-item",onClick:f[11]||(f[11]=h=>W("copy"))},"复制"),e.createElementVNode("div",{class:"context-menu-item",onClick:f[12]||(f[12]=h=>W("cut"))},"剪切"),e.createElementVNode("div",{class:e.normalizeClass(["context-menu-item",{disabled:!t.hasClipboard}]),onClick:f[13]||(f[13]=h=>W("paste"))},"粘贴",2),e.createElementVNode("div",{class:"context-menu-item",onClick:f[14]||(f[14]=h=>W("delete"))},"删除"),f[22]||(f[22]=e.createElementVNode("div",{class:"context-menu-sep"},null,-1)),e.createElementVNode("div",{class:"context-menu-item",onClick:f[15]||(f[15]=h=>W("move-layer","top"))},"置顶"),e.createElementVNode("div",{class:"context-menu-item",onClick:f[16]||(f[16]=h=>W("move-layer","up"))},"上移"),e.createElementVNode("div",{class:"context-menu-item",onClick:f[17]||(f[17]=h=>W("move-layer","down"))},"下移"),e.createElementVNode("div",{class:"context-menu-item",onClick:f[18]||(f[18]=h=>W("move-layer","bottom"))},"置底"),f[23]||(f[23]=e.createElementVNode("div",{class:"context-menu-sep"},null,-1)),e.createElementVNode("div",{class:"context-menu-item",onClick:f[19]||(f[19]=h=>W("group"))},"编组 Ctrl+G"),e.createElementVNode("div",{class:e.normalizeClass(["context-menu-item",{disabled:!t.selectedElementHasGroup}]),onClick:f[20]||(f[20]=h=>W("ungroup"))},"取消编组 Ctrl+Shift+G",2)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",{class:e.normalizeClass(["context-menu-item",{disabled:!t.hasClipboard}]),onClick:O},"粘贴",2),e.createElementVNode("div",{class:"context-menu-item",onClick:Y},"全选"),e.createElementVNode("div",{class:"context-menu-item",onClick:j},"取消选择")],64))],4)):e.createCommentVNode("",!0)],544))}}),Fl=ee(Rl,[["__scopeId","data-v-c6288512"]]),Ul=[{group:"position-size",groupLabel:"位置与尺寸",items:[{key:"ps-left",keywords:["X","横坐标","left","位置"]},{key:"ps-top",keywords:["Y","纵坐标","top","位置"]},{key:"ps-width",keywords:["W","宽度","width","尺寸"]},{key:"ps-height",keywords:["H","高度","height","尺寸"]}]},{group:"appearance",groupLabel:"外观",items:[{key:"ap-font-size",keywords:["字体大小","fontsize","字号"]},{key:"ap-font-weight",keywords:["字体粗细","粗体","bold"]},{key:"ap-align",keywords:["对齐","align"]},{key:"ap-vertical-align",keywords:["垂直对齐","verticalalign","顶对齐","底对齐"]},{key:"ap-color",keywords:["颜色","color"]},{key:"ap-bg-color",keywords:["背景色","background"]},{key:"ap-line-height",keywords:["行高","lineheight"]},{key:"ap-letter-spacing",keywords:["字间距","letterspacing"]}]},{group:"content",groupLabel:"内容",items:[{key:"ct-title",keywords:["内容","文本","title"]},{key:"ct-formatter",keywords:["格式化","表达式","formatter"]},{key:"ct-table-mode",keywords:["数据模式","静态布局","动态数据"]},{key:"ct-table-source",keywords:["数据源","列表字段"]},{key:"ct-table-font",keywords:["默认字号","默认颜色","默认内边距"]},{key:"ct-table-cols",keywords:["列宽","表格列"]}]},{group:"border-bg",groupLabel:"边框与背景",items:[{key:"bb-border-width",keywords:["边框宽度","border"]},{key:"bb-border-color",keywords:["边框颜色"]},{key:"bb-bg-color",keywords:["背景色","background"]}]},{group:"binding",groupLabel:"字段绑定",items:[{key:"bd-formatter",keywords:["格式化","表达式","formatter","fx","字段","绑定","field"]},{key:"bd-content",keywords:["内容","表达式","文本","变量"]}]},{group:"pagination",groupLabel:"分页",items:[{key:"pg-enabled",keywords:["分页","pagination","启用分页"]},{key:"pg-pageable",keywords:["参与分页","pageable"]},{key:"pg-keep-with-next",keywords:["同页","keepWithNext"]}]},{group:"advanced",groupLabel:"高级",items:[{key:"ad-locked",keywords:["锁定","lock"]},{key:"ad-fixed",keywords:["每页重复","repeat"]},{key:"ad-z-index",keywords:["层级","zindex"]},{key:"ad-delete",keywords:["删除"]}]}];function Hl(t,l){const o=t.trim().toLowerCase();return o?l.some(n=>n.toLowerCase().includes(o)):!0}function Gl(t){const l=[],o=new Set;for(const n of Ul){const a=n.items.filter(i=>Hl(t,[...i.keywords,n.groupLabel]));if(a.length>0){l.push(n.group);for(const i of a)o.add(i.key)}}return{groups:l,itemKeys:o}}const Ol={class:"property-search"},ql=e.defineComponent({__name:"PropertySearch",emits:["search"],setup(t,{emit:l}){const o=e.ref(""),n=l;function a(){n("search",o.value)}return(i,r)=>(e.openBlock(),e.createElementBlock("div",Ol,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":r[0]||(r[0]=s=>o.value=s),class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",onInput:a},null,544),[[e.vModelText,o.value]])]))}}),Wl=ee(ql,[["__scopeId","data-v-10ab6c84"]]),Kl={class:"group-icon"},Yl={class:"group-title"},Xl={class:"expand-icon"},jl={class:"group-content"},Jl=e.defineComponent({__name:"PropertyGroup",props:{title:{},icon:{},defaultExpanded:{type:Boolean},groupKey:{}},setup(t){const l=t,o=e.ref(l.defaultExpanded??!0),a={Document:"≡",Brush:"◧",Setting:"⚙"}[l.icon]||"•";function i(){o.value=!o.value,r()}function r(){const d=`property-group-${l.groupKey}`;try{localStorage.setItem(d,String(o.value))}catch{}}function s(){const d=`property-group-${l.groupKey}`;try{const u=localStorage.getItem(d);u!==null&&(o.value=u==="true")}catch{}}return e.onMounted(()=>{s()}),(d,u)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["property-group",{"is-expanded":o.value}])},[e.createElementVNode("div",{class:"group-header",onClick:i},[e.createElementVNode("span",Kl,e.toDisplayString(e.unref(a)),1),e.createElementVNode("span",Yl,e.toDisplayString(t.title),1),e.createElementVNode("span",Xl,e.toDisplayString(o.value?"▾":"▸"),1)]),e.withDirectives(e.createElementVNode("div",jl,[e.renderSlot(d.$slots,"default",{},void 0,!0)],512),[[e.vShow,o.value]])],2))}}),me=ee(Jl,[["__scopeId","data-v-2ba57031"]]),Zl={class:"position-grid"},Ql={class:"pd-field"},_l={class:"pd-field"},ea={class:"pd-field"},ta={class:"pd-field"},na=e.defineComponent({__name:"PositionSizeGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},setup(t){const l=t;function o(n){return l.searching?l.matchedKeys?.has(n)??!0:!0}return(n,a)=>(e.openBlock(),e.createBlock(me,{title:"位置与尺寸",icon:"Location","default-expanded":"","group-key":"position-size"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:a[4]||(a[4]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Zl,[e.withDirectives(e.createElementVNode("div",Ql,[a[5]||(a[5]=e.createElementVNode("span",{class:"pd-label"},"X",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":a[0]||(a[0]=i=>t.element.options.left=i),min:0,step:.01},null,512),[[e.vModelText,t.element.options.left,void 0,{number:!0}]])],512),[[e.vShow,o("ps-left")]]),e.withDirectives(e.createElementVNode("div",_l,[a[6]||(a[6]=e.createElementVNode("span",{class:"pd-label"},"Y",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":a[1]||(a[1]=i=>t.element.options.top=i),min:0,step:.01},null,512),[[e.vModelText,t.element.options.top,void 0,{number:!0}]])],512),[[e.vShow,o("ps-top")]]),e.withDirectives(e.createElementVNode("div",ea,[a[7]||(a[7]=e.createElementVNode("span",{class:"pd-label"},"W",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":a[2]||(a[2]=i=>t.element.options.width=i),min:3.5,step:.01},null,512),[[e.vModelText,t.element.options.width,void 0,{number:!0}]])],512),[[e.vShow,o("ps-width")]]),e.withDirectives(e.createElementVNode("div",ta,[a[8]||(a[8]=e.createElementVNode("span",{class:"pd-label"},"H",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":a[3]||(a[3]=i=>t.element.options.height=i),min:3.5,step:.01},null,512),[[e.vModelText,t.element.options.height,void 0,{number:!0}]])],512),[[e.vShow,o("ps-height")]])])],32)]),_:1}))}}),oa=ee(na,[["__scopeId","data-v-fc2cae86"]]),la=["#000000","#333333","#666666","#999999","#cccccc","#ffffff","#e53935","#fb8c00","#1e88e5","#43a047","#8d6e63","#00acc1"],aa=["aria-expanded","title"],ia={class:"picker-preview"},ra={class:"preset-color-grid"},sa=["title","aria-label","onClick"],da=e.defineComponent({__name:"PresetColorPicker",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:l}){const o=t,n=l,a=e.ref(!1),i=e.ref(),r=e.ref(),s=e.ref(),d=e.ref({}),u=e.ref(0),v=e.ref(0),p=e.ref(0),k=e.ref("#000000"),C=e.ref(!1),D=e.computed({get:()=>o.modelValue||"#000000",set:m=>n("update:modelValue",m)}),w=e.computed(()=>ae(B(u.value,v.value,p.value))),L=e.computed({get:()=>Math.round(u.value),set:m=>z(T(m),v.value,p.value)});e.watch(D,H,{immediate:!0});function I(m){k.value=m.toUpperCase(),H(m),n("update:modelValue",m)}function U(m){const E=m.target.value.trim();K(E)&&(H(E),n("update:modelValue",X(E)))}function H(m){const b=K(m);if(!b)return;const E=M(b.r,b.g,b.b);u.value=E.h,v.value=E.s,p.value=E.v,k.value=X(m).toUpperCase()}function z(m,b,E){u.value=T(m),v.value=q(b),p.value=q(E),k.value=w.value.toUpperCase(),n("update:modelValue",w.value)}function O(m){m.currentTarget.setPointerCapture(m.pointerId),C.value=!0,W(m)}function Y(m){C.value&&W(m)}function j(m){C.value=!1;const b=m.currentTarget;b.hasPointerCapture(m.pointerId)&&b.releasePointerCapture(m.pointerId)}function W(m){const b=s.value;if(!b)return;const E=b.getBoundingClientRect(),N=q((m.clientX-E.left)/E.width),F=q(1-(m.clientY-E.top)/E.height);z(u.value,N,F)}function y(m){const b=m.shiftKey?.1:.02;let E=!0;m.key==="ArrowLeft"?z(u.value,v.value-b,p.value):m.key==="ArrowRight"?z(u.value,v.value+b,p.value):m.key==="ArrowUp"?z(u.value,v.value,p.value+b):m.key==="ArrowDown"?z(u.value,v.value,p.value-b):E=!1,E&&m.preventDefault()}function f(){a.value?c():h()}async function h(){const m=i.value;if(!m)return;H(D.value),a.value=!0,await e.nextTick();const b=m.getBoundingClientRect(),E=190,N=r.value?.offsetHeight??216,F=8,Z=Math.min(b.left,window.innerWidth-E-F),S=b.bottom+6,V=S+N>window.innerHeight-F?Math.max(F,b.top-N-6):S;d.value={left:`${Math.max(F,Z)}px`,top:`${V}px`}}function c(){a.value=!1}function g(m){const b=m.target;i.value?.contains(b)||r.value?.contains(b)||c()}function $(){a.value&&c()}function G(m){m.key==="Escape"&&a.value&&c()}function K(m){const b=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(m.trim());if(!b)return null;const E=b[1],N=E.length===3?E.split("").map(F=>F+F).join(""):E;return{r:Number.parseInt(N.slice(0,2),16),g:Number.parseInt(N.slice(2,4),16),b:Number.parseInt(N.slice(4,6),16)}}function X(m){const b=K(m);return b?ae(b):"#000000"}function ae({r:m,g:b,b:E}){return`#${[m,b,E].map(N=>Math.round(q(N/255)*255).toString(16).padStart(2,"0")).join("")}`}function M(m,b,E){const N=m/255,F=b/255,Z=E/255,S=Math.max(N,F,Z),V=Math.min(N,F,Z),P=S-V;let Q=0;return P!==0&&(S===N?Q=(F-Z)/P%6:S===F?Q=(Z-N)/P+2:Q=(N-F)/P+4,Q*=60,Q<0&&(Q+=360)),{h:Q,s:S===0?0:P/S,v:S}}function B(m,b,E){const N=E*b,F=(m%360+360)%360/60,Z=N*(1-Math.abs(F%2-1)),[S,V,P]=F<1?[N,Z,0]:F<2?[Z,N,0]:F<3?[0,N,Z]:F<4?[0,Z,N]:F<5?[Z,0,N]:[N,0,Z],Q=E-N;return{r:(S+Q)*255,g:(V+Q)*255,b:(P+Q)*255}}function T(m){return((Number.isFinite(m)?m:0)%360+360)%360}function q(m){return Math.min(1,Math.max(0,Number.isFinite(m)?m:0))}return e.onMounted(()=>{document.addEventListener("pointerdown",g,!0),window.addEventListener("scroll",$,!0),window.addEventListener("resize",$),document.addEventListener("keydown",G)}),e.onBeforeUnmount(()=>{document.removeEventListener("pointerdown",g,!0),window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$),document.removeEventListener("keydown",G)}),(m,b)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("button",{ref_key:"triggerRef",ref:i,type:"button",class:"preset-color-trigger","aria-expanded":a.value,"aria-haspopup":"dialog",title:t.modelValue||"自动",onClick:f},[e.createElementVNode("span",{class:"preset-color-swatch",style:e.normalizeStyle({background:D.value})},null,4)],8,aa),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[a.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"panelRef",ref:r,class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:e.normalizeStyle(d.value),onPointerdown:b[2]||(b[2]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",ia,[e.createElementVNode("span",{class:"picker-current",style:e.normalizeStyle({background:w.value})},null,4),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[0]||(b[0]=E=>k.value=E),class:"picker-hex",type:"text",maxlength:"7",spellcheck:"false","aria-label":"颜色值",onInput:U},null,544),[[e.vModelText,k.value]])]),e.createElementVNode("div",{ref_key:"areaRef",ref:s,class:"picker-area",style:e.normalizeStyle({"--picker-hue":`${Math.round(u.value)}deg`}),"aria-label":"自定义颜色",tabindex:"0",onPointerdown:O,onPointermove:Y,onPointerup:j,onPointercancel:j,onKeydown:y},[e.createElementVNode("span",{class:"picker-handle",style:e.normalizeStyle({left:`${v.value*100}%`,top:`${(1-p.value)*100}%`,background:w.value})},null,4)],36),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[1]||(b[1]=E=>L.value=E),class:"picker-hue",type:"range",min:"0",max:"360",step:"1","aria-label":"色相"},null,512),[[e.vModelText,L.value,void 0,{number:!0}]]),b[3]||(b[3]=e.createElementVNode("div",{class:"picker-heading"},"常用颜色",-1)),e.createElementVNode("div",ra,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(la),E=>(e.openBlock(),e.createElementBlock("button",{key:E,type:"button",class:e.normalizeClass(["preset-color-item",{active:E.toLowerCase()===w.value.toLowerCase()}]),style:e.normalizeStyle({background:E}),title:E,"aria-label":E,onClick:N=>I(E)},null,14,sa))),128))])],36)):e.createCommentVNode("",!0)]))],64))}}),fe=ee(da,[["__scopeId","data-v-db3c3d71"]]),ca={class:"pd-field"},ua={class:"pd-field"},ma={class:"pd-field"},pa={class:"pd-radio-group",role:"radiogroup"},fa={class:"pd-radio"},va={class:"pd-radio"},ga={class:"pd-radio"},ha={class:"pd-field"},ba={class:"pd-radio-group",role:"radiogroup"},ya={class:"pd-radio"},ka={class:"pd-radio"},Ea={class:"pd-radio"},wa={class:"color-row"},Va={class:"pd-field"},Na={class:"pd-field"},Ca={class:"pd-field"},Sa={class:"pd-field"},$a={key:1,class:"pd-empty"},Ma=e.defineComponent({__name:"AppearanceGroup",props:{element:{},isTextType:{type:Boolean},matchedKeys:{},searching:{type:Boolean}},setup(t){const l=t;function o(a){return l.searching?l.matchedKeys?.has(a)??!0:!0}const n=e.computed(()=>l.element.printElementType.type==="table");return(a,i)=>(e.openBlock(),e.createBlock(me,{title:"外观",icon:"Brush","default-expanded":"","group-key":"appearance"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:i[12]||(i[12]=e.withModifiers(()=>{},["prevent"]))},[t.isTextType?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.withDirectives(e.createElementVNode("div",ca,[i[13]||(i[13]=e.createElementVNode("span",{class:"pd-label"},"字体大小",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":i[0]||(i[0]=r=>t.element.options.fontSize=r),min:8,max:72,style:{width:"100%"}},null,512),[[e.vModelText,t.element.options.fontSize,void 0,{number:!0}]])],512),[[e.vShow,o("ap-font-size")]]),e.withDirectives(e.createElementVNode("div",ua,[i[15]||(i[15]=e.createElementVNode("span",{class:"pd-label"},"字体粗细",-1)),e.withDirectives(e.createElementVNode("select",{class:"pd-select","onUpdate:modelValue":i[1]||(i[1]=r=>t.element.options.fontWeight=r),style:{width:"100%"}},[...i[14]||(i[14]=[e.createElementVNode("option",{value:"normal"},"正常",-1),e.createElementVNode("option",{value:"bold"},"粗体",-1),e.createElementVNode("option",{value:"bolder"},"更粗",-1),e.createElementVNode("option",{value:"lighter"},"细体",-1)])],512),[[e.vModelSelect,t.element.options.fontWeight]])],512),[[e.vShow,o("ap-font-weight")]]),e.withDirectives(e.createElementVNode("div",ma,[i[19]||(i[19]=e.createElementVNode("span",{class:"pd-label"},"对齐",-1)),e.createElementVNode("div",pa,[e.createElementVNode("label",fa,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[2]||(i[2]=r=>t.element.options.textAlign=r),value:"left"},null,512),[[e.vModelRadio,t.element.options.textAlign]]),i[16]||(i[16]=e.createElementVNode("span",null,"左",-1))]),e.createElementVNode("label",va,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[3]||(i[3]=r=>t.element.options.textAlign=r),value:"center"},null,512),[[e.vModelRadio,t.element.options.textAlign]]),i[17]||(i[17]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",ga,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[4]||(i[4]=r=>t.element.options.textAlign=r),value:"right"},null,512),[[e.vModelRadio,t.element.options.textAlign]]),i[18]||(i[18]=e.createElementVNode("span",null,"右",-1))])])],512),[[e.vShow,o("ap-align")]]),e.withDirectives(e.createElementVNode("div",ha,[i[23]||(i[23]=e.createElementVNode("span",{class:"pd-label"},"垂直对齐",-1)),e.createElementVNode("div",ba,[e.createElementVNode("label",ya,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[5]||(i[5]=r=>t.element.options.verticalAlign=r),value:"top"},null,512),[[e.vModelRadio,t.element.options.verticalAlign]]),i[20]||(i[20]=e.createElementVNode("span",null,"顶",-1))]),e.createElementVNode("label",ka,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[6]||(i[6]=r=>t.element.options.verticalAlign=r),value:"middle"},null,512),[[e.vModelRadio,t.element.options.verticalAlign]]),i[21]||(i[21]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",Ea,[e.withDirectives(e.createElementVNode("input",{type:"radio","onUpdate:modelValue":i[7]||(i[7]=r=>t.element.options.verticalAlign=r),value:"bottom"},null,512),[[e.vModelRadio,t.element.options.verticalAlign]]),i[22]||(i[22]=e.createElementVNode("span",null,"底",-1))])])],512),[[e.vShow,o("ap-vertical-align")]]),e.createElementVNode("div",wa,[e.withDirectives(e.createElementVNode("div",Va,[i[24]||(i[24]=e.createElementVNode("span",{class:"pd-label"},"颜色",-1)),e.createVNode(fe,{modelValue:t.element.options.color,"onUpdate:modelValue":i[8]||(i[8]=r=>t.element.options.color=r)},null,8,["modelValue"])],512),[[e.vShow,o("ap-color")]]),e.withDirectives(e.createElementVNode("div",Na,[i[25]||(i[25]=e.createElementVNode("span",{class:"pd-label"},"背景色",-1)),e.createVNode(fe,{modelValue:t.element.options.backgroundColor,"onUpdate:modelValue":i[9]||(i[9]=r=>t.element.options.backgroundColor=r)},null,8,["modelValue"])],512),[[e.vShow,o("ap-bg-color")]])]),e.withDirectives(e.createElementVNode("div",Ca,[i[26]||(i[26]=e.createElementVNode("span",{class:"pd-label"},"行高",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":i[10]||(i[10]=r=>t.element.options.lineHeight=r),min:0,max:100,style:{width:"100%"}},null,512),[[e.vModelText,t.element.options.lineHeight,void 0,{number:!0}]])],512),[[e.vShow,o("ap-line-height")]]),e.withDirectives(e.createElementVNode("div",Sa,[i[27]||(i[27]=e.createElementVNode("span",{class:"pd-label"},"字间距",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":i[11]||(i[11]=r=>t.element.options.letterSpacing=r),min:0,max:20,step:.5,style:{width:"100%"}},null,512),[[e.vModelText,t.element.options.letterSpacing,void 0,{number:!0}]])],512),[[e.vShow,o("ap-letter-spacing")]])],64)):e.createCommentVNode("",!0),!t.isTextType&&!n.value?(e.openBlock(),e.createElementBlock("p",$a,"当前元素不支持外观设置")):e.createCommentVNode("",!0)],32)]),_:1}))}}),Ba=ee(Ma,[["__scopeId","data-v-8d28f858"]]),Da={class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},xa={class:"pd-dialog-header"},Ta={class:"expression-editor"},za={class:"ee-nav"},La={class:"ee-nav-tabs"},Pa={class:"ee-content"},Aa={class:"ee-content-search"},Ia=["placeholder"],Ra={class:"ee-content-list"},Fa={class:"ee-field-group-icon"},Ua=["onDblclick"],Ha={class:"ee-field-row"},Ga=["checked","onChange"],Oa={class:"ee-item-label"},qa={class:"ee-item-key"},Wa={key:0,class:"pd-empty"},Ka=["onDblclick"],Ya={class:"ee-item-label"},Xa={class:"ee-item-key"},ja={class:"ee-func-group"},Ja=["onDblclick"],Za={class:"ee-item-label"},Qa={class:"ee-item-key"},_a={class:"ee-func-group"},ei=["onDblclick"],ti={class:"ee-item-label"},ni={class:"ee-item-key"},oi={class:"ee-editor"},li={class:"ee-editor-section"},ai={class:"ee-editor-section"},ii={class:"pd-dialog-footer"},ri=e.defineComponent({__name:"ExpressionEditor",props:{modelValue:{type:Boolean},expression:{},fields:{}},emits:["update:modelValue","update:expression"],setup(t,{emit:l}){const o=t,n=l,a=e.computed({get:()=>o.modelValue,set:y=>n("update:modelValue",y)}),i=e.ref("field"),r=e.computed(()=>{switch(i.value){case"field":return"搜索字段...";case"variable":return"搜索变量...";case"function":return"搜索函数...";default:return"搜索..."}}),s=e.ref(""),d=e.computed(()=>Pt(Lt(o.fields??[]),s.value)),u=e.ref(new Set);function v(y){const f=y.fieldKey,h=new Set(u.value);h.has(f)?h.delete(f):h.add(f),u.value=h}e.watch(a,y=>{if(y){I.value=o.expression||"";const f=(o.fields??[]).find(h=>o.expression===h.fieldKey||o.expression===`{${h.fieldKey}}`);f&&(u.value=new Set([f.fieldKey]))}else u.value=new Set});function p(y){j(`{${y.fieldKey}}`)}function k(y){if(u.value.size>0){const f=Array.from(u.value).join(", ");j(`${y.name}(${f})`)}else j(y.template)}function C(y){j(y)}const D=e.computed(()=>{if(!s.value.trim())return O;const y=s.value.trim().toLowerCase();return O.filter(f=>f.label.toLowerCase().includes(y)||f.name.toLowerCase().includes(y))}),w=e.computed(()=>{if(!s.value.trim())return H;const y=s.value.trim().toLowerCase();return H.filter(f=>f.label.toLowerCase().includes(y)||f.name.toLowerCase().includes(y))}),L=e.computed(()=>{if(!s.value.trim())return z;const y=s.value.trim().toLowerCase();return z.filter(f=>f.label.toLowerCase().includes(y)||f.name.toLowerCase().includes(y))}),I=e.ref(o.expression||""),U=e.ref(null);e.watch(()=>o.expression,y=>{I.value=y||""});const H=[{name:"SUM",label:"求和",template:"SUM()"},{name:"AVG",label:"平均值",template:"AVG()"},{name:"COUNT",label:"计数",template:"COUNT()"},{name:"MIN",label:"最小值",template:"MIN()"},{name:"MAX",label:"最大值",template:"MAX()"}],z=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],O=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],Y=e.computed(()=>{if(!I.value.trim())return"(输入表达式后预览)";try{const y={...ue,pageIndex:1,totalPages:1,printDate:new Date().toISOString().split("T")[0],printTime:Date.now()},f=Le(I.value,y);return f==null?"(无法计算)":String(f)}catch{return"(表达式错误)"}});function j(y){const f=U.value;if(!f){I.value+=y;return}const h=f.selectionStart,c=f.selectionEnd,g=I.value.substring(0,h),$=I.value.substring(c);I.value=g+y+$,e.nextTick(()=>{f.focus(),f.selectionStart=f.selectionEnd=h+y.length})}function W(){n("update:expression",I.value),a.value=!1}return(y,f)=>a.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"pd-dialog-overlay",onKeydown:f[8]||(f[8]=e.withKeys(h=>a.value=!1,["esc"]))},[e.createElementVNode("section",Da,[e.createElementVNode("header",xa,[f[9]||(f[9]=e.createElementVNode("strong",{id:"expression-editor-title"},"编辑表达式",-1)),e.createElementVNode("button",{type:"button",class:"pd-close","aria-label":"关闭",onClick:f[0]||(f[0]=h=>a.value=!1)},"×")]),e.createElementVNode("div",Ta,[e.createElementVNode("div",za,[f[10]||(f[10]=e.createElementVNode("div",{class:"ee-nav-title"},"类型",-1)),e.createElementVNode("div",La,[e.createElementVNode("div",{class:e.normalizeClass(["ee-nav-tab",{active:i.value==="field"}]),onClick:f[1]||(f[1]=h=>i.value="field")}," 📁 字段 ",2),e.createElementVNode("div",{class:e.normalizeClass(["ee-nav-tab",{active:i.value==="variable"}]),onClick:f[2]||(f[2]=h=>i.value="variable")}," 🔧 变量 ",2),e.createElementVNode("div",{class:e.normalizeClass(["ee-nav-tab",{active:i.value==="function"}]),onClick:f[3]||(f[3]=h=>i.value="function")}," ⚡ 函数 ",2)])]),e.createElementVNode("div",Pa,[e.createElementVNode("div",Aa,[e.withDirectives(e.createElementVNode("input",{class:"pd-input","onUpdate:modelValue":f[4]||(f[4]=h=>s.value=h),placeholder:r.value},null,8,Ia),[[e.vModelText,s.value]])]),e.createElementVNode("div",Ra,[i.value==="field"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,h=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:h.key||"_top"},[h.key?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["ee-field-group",{"is-list":h.isList}])},[e.createElementVNode("span",Fa,e.toDisplayString(h.isList?"📋":"📁"),1),e.createElementVNode("span",null,e.toDisplayString(h.label),1)],2)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.fields,c=>(e.openBlock(),e.createElementBlock("div",{key:c.fieldKey,class:"ee-list-item ee-field-item",style:e.normalizeStyle({paddingLeft:h.key?"22px":"10px"}),onDblclick:g=>p(c)},[e.createElementVNode("label",Ha,[e.createElementVNode("input",{type:"checkbox",class:"pd-checkbox",checked:u.value.has(c.fieldKey),onChange:g=>v(c),onClick:f[5]||(f[5]=e.withModifiers(()=>{},["stop"]))},null,40,Ga),e.createElementVNode("span",Oa,e.toDisplayString(c.fieldLabel),1),e.createElementVNode("span",qa,e.toDisplayString(c.fieldKey),1)])],44,Ua))),128))],64))),128)),d.value.length===0?(e.openBlock(),e.createElementBlock("p",Wa,"暂无字段")):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),i.value==="variable"?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(D.value,h=>(e.openBlock(),e.createElementBlock("div",{key:h.name,class:"ee-list-item",onDblclick:c=>C(h.template)},[e.createElementVNode("div",Ya,e.toDisplayString(h.label),1),e.createElementVNode("div",Xa,e.toDisplayString(h.name),1)],40,Ka))),128)):e.createCommentVNode("",!0),i.value==="function"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",ja,[f[11]||(f[11]=e.createElementVNode("div",{class:"ee-func-group-title"},"聚合函数",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,h=>(e.openBlock(),e.createElementBlock("div",{key:h.name,class:"ee-list-item",onDblclick:c=>k(h)},[e.createElementVNode("div",Za,e.toDisplayString(h.label),1),e.createElementVNode("div",Qa,e.toDisplayString(h.name),1)],40,Ja))),128))]),e.createElementVNode("div",_a,[f[12]||(f[12]=e.createElementVNode("div",{class:"ee-func-group-title"},"格式化函数",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.value,h=>(e.openBlock(),e.createElementBlock("div",{key:h.name,class:"ee-list-item",onDblclick:c=>C(h.template)},[e.createElementVNode("div",ti,e.toDisplayString(h.label),1),e.createElementVNode("div",ni,e.toDisplayString(h.name),1)],40,ei))),128))])],64)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",oi,[e.createElementVNode("div",li,[f[13]||(f[13]=e.createElementVNode("div",{class:"ee-editor-title"},"表达式编辑",-1)),e.withDirectives(e.createElementVNode("textarea",{ref_key:"textareaRef",ref:U,"onUpdate:modelValue":f[6]||(f[6]=h=>I.value=h),class:"ee-textarea",rows:"6",placeholder:"双击左侧字段/函数插入表达式,如: {fieldKey} 或 SUM(amount)"},null,512),[[e.vModelText,I.value]])]),e.createElementVNode("div",ai,[f[14]||(f[14]=e.createElementVNode("div",{class:"ee-editor-title"},"预览结果",-1)),e.createElementVNode("div",{class:e.normalizeClass(["ee-preview",{"ee-preview-error":Y.value==="(表达式错误)"}])},e.toDisplayString(Y.value),3)]),f[15]||(f[15]=e.createStaticVNode('<div class="ee-help-section" data-v-5edaa764><div class="ee-help-title" data-v-5edaa764>帮助信息</div><div class="ee-help-grid" data-v-5edaa764><div class="ee-help-card ee-help-field" data-v-5edaa764><div class="ee-help-card-title" data-v-5edaa764>字段绑定</div><div class="ee-help-card-content" data-v-5edaa764> 使用 {字段名} 格式<br data-v-5edaa764> 示例: {order.no} </div></div><div class="ee-help-card ee-help-function" data-v-5edaa764><div class="ee-help-card-title" data-v-5edaa764>函数使用</div><div class="ee-help-card-content" data-v-5edaa764> SUM(字段) - 求和<br data-v-5edaa764> AVG(字段) - 平均值<br data-v-5edaa764> COUNT(字段) - 计数 </div></div><div class="ee-help-card ee-help-variable" data-v-5edaa764><div class="ee-help-card-title" data-v-5edaa764>系统变量</div><div class="ee-help-card-content" data-v-5edaa764> {page} - 当前页码<br data-v-5edaa764> {total} - 总页数<br data-v-5edaa764> {row} - 当前行号 </div></div><div class="ee-help-card ee-help-conditional" data-v-5edaa764><div class="ee-help-card-title" data-v-5edaa764>条件判断</div><div class="ee-help-card-content" data-v-5edaa764> IF(条件, 真值, 假值)<br data-v-5edaa764> 示例: IF(amount&gt;1000, &quot;大单&quot;, &quot;小单&quot;) </div></div></div></div>',1))])]),e.createElementVNode("footer",ii,[e.createElementVNode("button",{type:"button",class:"pd-button",onClick:f[7]||(f[7]=h=>a.value=!1)},"取消"),e.createElementVNode("button",{type:"button",class:"pd-button primary",onClick:W},"确定")])])],32)):e.createCommentVNode("",!0)}}),rt=ee(ri,[["__scopeId","data-v-5edaa764"]]),si={class:"pd-field"},di={class:"pd-label"},ci=["value","placeholder"],ui=e.defineComponent({__name:"BindingControl",props:{descriptor:{},modelValue:{},fields:{}},emits:["update:modelValue"],setup(t,{emit:l}){const o=l,n=e.ref(!1);function a(){n.value=!0}return(i,r)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",si,[e.createElementVNode("span",di,e.toDisplayString(t.descriptor.label),1),e.createElementVNode("input",{value:t.modelValue,class:"pd-input",placeholder:t.descriptor.placeholder||"输入内容,支持 {字段} 表达式",onInput:r[0]||(r[0]=s=>o("update:modelValue",s.target.value)),onDblclick:a},null,40,ci)]),e.createVNode(rt,{modelValue:n.value,"onUpdate:modelValue":r[1]||(r[1]=s=>n.value=s),fields:t.fields,expression:t.modelValue,"onUpdate:expression":r[2]||(r[2]=s=>o("update:modelValue",s))},null,8,["modelValue","fields","expression"])],64))}}),mi=ee(ui,[["__scopeId","data-v-135d160a"]]),pi={class:"pd-field"},fi=["value"],vi=["value"],gi={class:"pd-field"},hi={class:"pd-field"},bi={class:"pd-field"},yi={class:"pd-field"},ki={style:{width:"60px"}},Ei=["value","onInput"],wi=e.defineComponent({__name:"TableSettingsGroup",props:{element:{},fields:{}},setup(t){const l=t,o=e.inject(Se,null),n=e.computed(()=>l.fields.filter(r=>r.fieldType==="list").map(r=>({label:r.fieldLabel,value:r.fieldKey})));function a(r){l.element.options.dataSource=r||void 0,o?.recordHistory()}function i(r,s){if(s===void 0)return;const d=l.element.options.tableColWidths,u=o?.maxTableWidth.value??1/0,v=d.reduce((p,k,C)=>C===r?p:p+k,0);if(v+s>u){const p=Math.max(5,Math.round((u-v)*10)/10);alert(`表格总宽不能超过打印范围宽度 ${u}mm,列${r+1} 已调整为 ${p}mm`),d[r]=p}else d[r]=s;Pe(l.element.options),o?.recordHistory()}return(r,s)=>(e.openBlock(),e.createBlock(me,{title:"表格设置",icon:"Grid","default-expanded":"","group-key":"table-settings"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:s[4]||(s[4]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",pi,[s[5]||(s[5]=e.createElementVNode("span",{class:"pd-label"},"列表数据源字段",-1)),e.createElementVNode("select",{value:t.element.options.dataSource,class:"pd-select",style:{width:"100%"},onChange:s[0]||(s[0]=d=>a(d.target.value))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,d=>(e.openBlock(),e.createElementBlock("option",{key:d.value,value:d.value},e.toDisplayString(d.label),9,vi))),128))],40,fi)]),e.createElementVNode("div",gi,[s[6]||(s[6]=e.createElementVNode("span",{class:"pd-label"},"默认字号 (pt)",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":s[1]||(s[1]=d=>t.element.options.tableDefaultFontSize=d),min:5,max:72},null,512),[[e.vModelText,t.element.options.tableDefaultFontSize,void 0,{number:!0}]])]),e.createElementVNode("div",hi,[s[7]||(s[7]=e.createElementVNode("span",{class:"pd-label"},"默认文字颜色",-1)),e.createVNode(fe,{modelValue:t.element.options.tableDefaultColor,"onUpdate:modelValue":s[2]||(s[2]=d=>t.element.options.tableDefaultColor=d)},null,8,["modelValue"])]),e.createElementVNode("div",bi,[s[8]||(s[8]=e.createElementVNode("span",{class:"pd-label"},"默认内边距 (mm)",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":s[3]||(s[3]=d=>t.element.options.tableDefaultPadding=d),min:0,max:10,step:.5},null,512),[[e.vModelText,t.element.options.tableDefaultPadding,void 0,{number:!0}]])]),e.createElementVNode("div",yi,[s[9]||(s[9]=e.createElementVNode("span",{class:"pd-label"},"列宽 (mm)",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.element.options.tableColWidths,(d,u)=>(e.openBlock(),e.createElementBlock("div",{key:u,class:"col-width-row"},[e.createElementVNode("span",ki,"列"+e.toDisplayString(u+1),1),e.createElementVNode("input",{value:d,type:"number",class:"pd-input",min:5,max:200,step:1,onInput:v=>i(u,v.target.valueAsNumber)},null,40,Ei)]))),128))])],32)]),_:1}))}}),Vi=ee(wi,[["__scopeId","data-v-50fbdef9"]]),Ni={class:"border-row"},Ci={class:"pd-field"},Si={class:"pd-field"},$i={class:"pd-field"},Mi=e.defineComponent({__name:"BorderBgGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},setup(t){const l=t;function o(n){return l.searching?l.matchedKeys?.has(n)??!0:!0}return(n,a)=>(e.openBlock(),e.createBlock(me,{title:"边框与背景",icon:"Picture","default-expanded":"","group-key":"border-bg"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:a[3]||(a[3]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Ni,[e.withDirectives(e.createElementVNode("div",Ci,[a[4]||(a[4]=e.createElementVNode("span",{class:"pd-label"},"边框宽度",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":a[0]||(a[0]=i=>t.element.options.borderWidth=i),min:0,max:20,step:.25},null,512),[[e.vModelText,t.element.options.borderWidth,void 0,{number:!0}]])],512),[[e.vShow,o("bb-border-width")]]),e.withDirectives(e.createElementVNode("div",Si,[a[5]||(a[5]=e.createElementVNode("span",{class:"pd-label"},"边框颜色",-1)),e.createVNode(fe,{modelValue:t.element.options.borderColor,"onUpdate:modelValue":a[1]||(a[1]=i=>t.element.options.borderColor=i)},null,8,["modelValue"])],512),[[e.vShow,o("bb-border-color")]])]),e.withDirectives(e.createElementVNode("div",$i,[a[6]||(a[6]=e.createElementVNode("span",{class:"pd-label"},"背景色",-1)),e.createVNode(fe,{modelValue:t.element.options.backgroundColor,"onUpdate:modelValue":a[2]||(a[2]=i=>t.element.options.backgroundColor=i)},null,8,["modelValue"])],512),[[e.vShow,o("bb-bg-color")]])],32)]),_:1}))}}),Bi=ee(Mi,[["__scopeId","data-v-292c1503"]]),Di={class:"advanced-row"},xi={class:"pd-field"},Ti={class:"pd-field"},zi={class:"pd-field"},Li={class:"pd-field"},Pi=e.defineComponent({__name:"AdvancedGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},emits:["delete-element"],setup(t){const l=t;function o(n){return l.searching?l.matchedKeys?.has(n)??!0:!0}return(n,a)=>(e.openBlock(),e.createBlock(me,{title:"高级设置",icon:"Setting","group-key":"advanced"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:a[4]||(a[4]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Di,[e.withDirectives(e.createElementVNode("div",xi,[a[5]||(a[5]=e.createElementVNode("span",{class:"pd-label"},"锁定",-1)),e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"pd-switch","onUpdate:modelValue":a[0]||(a[0]=i=>t.element.options.locked=i)},null,512),[[e.vModelCheckbox,t.element.options.locked]])],512),[[e.vShow,o("ad-locked")]]),e.withDirectives(e.createElementVNode("div",Ti,[a[6]||(a[6]=e.createElementVNode("span",{class:"pd-label"},"每页重复",-1)),e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"pd-switch","onUpdate:modelValue":a[1]||(a[1]=i=>t.element.options.fixed=i)},null,512),[[e.vModelCheckbox,t.element.options.fixed]])],512),[[e.vShow,o("ad-fixed")]])]),e.withDirectives(e.createElementVNode("div",zi,[a[7]||(a[7]=e.createElementVNode("span",{class:"pd-label"},"层级",-1)),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":a[2]||(a[2]=i=>t.element.options.zIndex=i),min:0,max:999,style:{width:"100%"}},null,512),[[e.vModelText,t.element.options.zIndex,void 0,{number:!0}]])],512),[[e.vShow,o("ad-z-index")]]),e.withDirectives(e.createElementVNode("div",Li,[e.createElementVNode("button",{type:"button",class:"pd-button danger",onClick:a[3]||(a[3]=i=>n.$emit("delete-element"))}," 删除元素 ")],512),[[e.vShow,o("ad-delete")]])],32)]),_:1}))}}),Ai=ee(Pi,[["__scopeId","data-v-0a3c93f7"]]),Ii={key:0,class:"pd-field"},Ri=["checked"],Fi={class:"pd-field"},Ui=["checked"],Hi={class:"pd-field"},Gi=["checked"],bt=e.defineComponent({__name:"PaginationGroup",props:{element:{},matchedKeys:{},searching:{type:Boolean}},setup(t){const l=t,o=e.computed(()=>l.element.printElementType.type==="table"),n=e.computed({get:()=>l.element.options.tablePagination?.enabled??!0,set:()=>{}});function a(v){l.element.options.tablePagination={enabled:v}}const i=e.computed({get:()=>l.element.options.pagination?.pageable??!0,set:()=>{}}),r=e.computed({get:()=>l.element.options.pagination?.keepWithNext??!1,set:()=>{}});function s(v){l.element.options.pagination={pageable:v,keepWithNext:r.value}}function d(v){l.element.options.pagination={pageable:i.value,keepWithNext:v}}function u(v){return l.searching?l.matchedKeys?.has(v)??!0:!0}return(v,p)=>(e.openBlock(),e.createBlock(me,{title:"分页配置",icon:"Document","group-key":"pagination"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:p[3]||(p[3]=e.withModifiers(()=>{},["prevent"]))},[o.value?e.withDirectives((e.openBlock(),e.createElementBlock("div",Ii,[p[4]||(p[4]=e.createElementVNode("span",{class:"pd-label"},"启用分页",-1)),e.createElementVNode("input",{type:"checkbox",class:"pd-switch",checked:n.value,onChange:p[0]||(p[0]=k=>a(k.target.checked))},null,40,Ri)],512)),[[e.vShow,u("pg-enabled")]]):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.withDirectives(e.createElementVNode("div",Fi,[p[5]||(p[5]=e.createElementVNode("span",{class:"pd-label"},"参与分页",-1)),e.createElementVNode("input",{type:"checkbox",class:"pd-switch",checked:i.value,onChange:p[1]||(p[1]=k=>s(k.target.checked))},null,40,Ui)],512),[[e.vShow,u("pg-pageable")]]),e.withDirectives(e.createElementVNode("div",Hi,[p[6]||(p[6]=e.createElementVNode("span",{class:"pd-label"},"与下元素同页",-1)),e.createElementVNode("input",{type:"checkbox",class:"pd-switch",checked:r.value,onChange:p[2]||(p[2]=k=>d(k.target.checked))},null,40,Gi)],512),[[e.vShow,u("pg-keep-with-next")]])],64))],32)]),_:1}))}}),Oi={class:"image-content-upload"},qi=["disabled"],Wi=e.defineComponent({__name:"ImageContentUpload",props:{disabled:{type:Boolean}},emits:["success"],setup(t,{emit:l}){const o=t,n=l,a=e.ref(!1),i=e.inject(it,e.computed(()=>{})),r=e.computed(()=>o.disabled||a.value||!i.value);async function s(d){const u=d.target,v=u.files?.[0];if(v){if(!v.type.startsWith("image/")){alert("仅支持上传图片文件"),u.value="";return}if(!i.value){alert("图片上传能力未配置"),u.value="";return}a.value=!0;try{const p=await i.value(v);p?n("success",p):alert("图片上传失败")}catch(p){alert(p instanceof Error?p.message:"图片上传失败")}finally{a.value=!1,u.value=""}}}return(d,u)=>(e.openBlock(),e.createElementBlock("div",Oi,[e.createElementVNode("label",{class:e.normalizeClass(["pd-button small upload-label",{disabled:r.value}])},[u[0]||(u[0]=e.createElementVNode("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[e.createElementVNode("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})],-1)),e.createTextVNode(" "+e.toDisplayString(a.value?"上传中...":"上传图片")+" ",1),e.createElementVNode("input",{class:"visually-hidden",type:"file",accept:"image/*",disabled:r.value,onChange:s},null,40,qi)],2),u[1]||(u[1]=e.createElementVNode("p",{class:"upload-tip"},"支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",-1))]))}}),Ki=ee(Wi,[["__scopeId","data-v-b730e8e6"]]),Yi={class:"pd-field"},Xi=["value"],ji={class:"pd-field"},Ji=["value"],Zi={key:0,class:"pd-field"},Qi=["checked"],_i=e.defineComponent({__name:"TableRowGroup",props:{element:{},selection:{}},setup(t){const l=t,o=e.inject(Se),n=e.computed(()=>l.element.options.tableRows[l.selection.r1]);function a(s){const d=Je(l.element.options.tableRows,l.selection.r1,s);if(d){alert(d);return}o.recordHistory()}function i(s){s!==void 0&&(n.value.height=s,Pe(l.element.options),o.recordHistory())}function r(s){n.value.repeatOnPage=s,o.recordHistory()}return(s,d)=>(e.openBlock(),e.createBlock(me,{title:"行属性",icon:"Grid","default-expanded":"","group-key":"table-row"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:d[3]||(d[3]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Yi,[d[5]||(d[5]=e.createElementVNode("span",{class:"pd-label"},"行类型",-1)),e.createElementVNode("select",{value:n.value.type,class:"pd-select",style:{width:"100%"},onChange:d[0]||(d[0]=u=>a(u.target.value))},[...d[4]||(d[4]=[e.createElementVNode("option",{value:"header"},"标题行",-1),e.createElementVNode("option",{value:"data"},"数据行",-1),e.createElementVNode("option",{value:"subtotal"},"小计行(每页小计)",-1),e.createElementVNode("option",{value:"summary"},"汇总行",-1)])],40,Xi)]),e.createElementVNode("div",ji,[d[6]||(d[6]=e.createElementVNode("span",{class:"pd-label"},"行高 (mm)",-1)),e.createElementVNode("input",{value:n.value.height,type:"number",class:"pd-input",min:3,max:100,step:.5,style:{width:"100%"},onInput:d[1]||(d[1]=u=>i(u.target.valueAsNumber))},null,40,Ji)]),n.value.type==="header"?(e.openBlock(),e.createElementBlock("div",Zi,[d[7]||(d[7]=e.createElementVNode("span",{class:"pd-label"},"每页顶部重复",-1)),e.createElementVNode("input",{checked:n.value.repeatOnPage??!1,type:"checkbox",class:"pd-switch",onInput:d[2]||(d[2]=u=>r(!!u.target.checked))},null,40,Qi)])):e.createCommentVNode("",!0)],32)]),_:1}))}}),er={class:"pd-field"},tr={class:"pd-radio-group",role:"radiogroup"},nr={class:"pd-radio"},or=["checked"],lr={class:"pd-radio"},ar=["checked"],ir={class:"pd-radio"},rr=["checked"],sr={key:0,class:"pd-field"},dr=["value"],cr={key:1,class:"pd-field"},ur=["checked"],mr={key:2,class:"pd-field"},pr=["value"],fr={class:"pd-field"},vr=["value"],gr={class:"pd-field"},hr={class:"pd-radio-group",role:"radiogroup"},br={class:"pd-radio"},yr=["checked"],kr={class:"pd-radio"},Er=["checked"],wr={class:"pd-radio"},Vr=["checked"],Nr={class:"pd-field"},Cr={class:"pd-radio-group",role:"radiogroup"},Sr={class:"pd-radio"},$r=["checked"],Mr={class:"pd-radio"},Br=["checked"],Dr={class:"pd-radio"},xr=["checked"],Tr={class:"cell-style-grid"},zr={class:"pd-field"},Lr=["value"],Pr={class:"pd-field"},Ar=["value"],Ir={class:"pd-field"},Rr=["checked"],Fr={class:"pd-field"},Ur={class:"pd-field"},Hr={class:"border-style-row"},Gr={class:"pd-button-group border-presets"},Or={class:"pd-checkbox-group"},qr={class:"pd-checkbox"},Wr={class:"pd-checkbox"},Kr={class:"pd-checkbox"},Yr={class:"pd-checkbox"},Xr={class:"pd-field"},jr=["value"],Jr={class:"pd-field"},Zr=["checked"],Qr={class:"merge-btns"},_r=["disabled","title"],es=["disabled"],ts=e.defineComponent({__name:"TableCellGroup",props:{element:{},selection:{},fields:{}},setup(t,{expose:l}){const o=t,n=e.inject(Se),a=e.computed(()=>o.element.options.tableRows),i=e.computed(()=>{const h=lt(a.value,o.selection.r1,o.selection.c1);return a.value[h.r].cells[h.c]}),r=e.ref(!1),s=e.ref(""),d=e.computed(()=>i.value.cellType==="barcode"),u=e.computed(()=>i.value.cellType==="qrcode");function v(h){w(c=>{c.align=h})}function p(h){w(c=>{c.valign=h})}function k(h){w(c=>{c.cellType=h==="text"?void 0:h,h!=="barcode"&&(c.barcodeType=void 0,c.showBarcodeText=void 0),h!=="qrcode"&&(c.qrCodeLevel=void 0)})}function C(){s.value=i.value.formatter||"",r.value=!0}function D(h){w(c=>{c.formatter=h||void 0})}function w(h){const c=o.selection;for(let g=c.r1;g<=c.r2;g++)for(let $=c.c1;$<=c.c2;$++){const G=a.value[g].cells[$];G.merged||h(G)}n.recordHistory()}const L=e.ref("solid"),I=e.ref(.75),U=e.ref("#333333"),H=e.ref([]);function z(){return{width:I.value,style:L.value,color:U.value}}function O(h){an(a.value,o.selection,h,z()),n.recordHistory()}function Y(h){const c=h.target,g=new Set(H.value);c.checked?g.add(c.value):g.delete(c.value),H.value=[...g];const $=z();w(G=>{const K={...G.borders??{}};for(const X of["top","right","bottom","left"])g.has(X)?K[X]={...$}:delete K[X];G.borders=K})}const j=e.computed(()=>Nt(a.value,o.selection)),W=e.computed(()=>{const h=o.selection;for(let c=h.r1;c<=h.r2;c++)for(let g=h.c1;g<=h.c2;g++){const $=a.value[c].cells[g];if(!$.merged&&(($.rowspan??1)>1||($.colspan??1)>1))return!0}return!1});function y(){Ct(a.value,o.selection),n.recordHistory()}function f(){St(a.value,o.selection),n.recordHistory()}return l({openFormatterEditor:C}),(h,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(me,{title:"单元格",icon:"Menu","default-expanded":"","group-key":"table-cell"},{default:e.withCtx(()=>[e.createElementVNode("form",{class:"pd-form",onSubmit:c[35]||(c[35]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",er,[c[40]||(c[40]=e.createElementVNode("span",{class:"pd-label"},"单元格类型",-1)),e.createElementVNode("div",tr,[e.createElementVNode("label",nr,[e.createElementVNode("input",{type:"radio",value:"text",checked:(i.value.cellType||"text")==="text",onChange:c[0]||(c[0]=g=>k(g.target.value))},null,40,or),c[37]||(c[37]=e.createElementVNode("span",null,"文本",-1))]),e.createElementVNode("label",lr,[e.createElementVNode("input",{type:"radio",value:"barcode",checked:i.value.cellType==="barcode",onChange:c[1]||(c[1]=g=>k(g.target.value))},null,40,ar),c[38]||(c[38]=e.createElementVNode("span",null,"条形码",-1))]),e.createElementVNode("label",ir,[e.createElementVNode("input",{type:"radio",value:"qrcode",checked:i.value.cellType==="qrcode",onChange:c[2]||(c[2]=g=>k(g.target.value))},null,40,rr),c[39]||(c[39]=e.createElementVNode("span",null,"二维码",-1))])])]),d.value?(e.openBlock(),e.createElementBlock("div",sr,[c[42]||(c[42]=e.createElementVNode("span",{class:"pd-label"},"码制",-1)),e.createElementVNode("select",{value:i.value.barcodeType||"CODE128",class:"pd-select",onChange:c[3]||(c[3]=g=>w($=>{$.barcodeType=g.target.value||void 0}))},[...c[41]||(c[41]=[e.createElementVNode("option",{value:"CODE128"},"CODE128(通用)",-1),e.createElementVNode("option",{value:"EAN13"},"EAN13(商品码)",-1),e.createElementVNode("option",{value:"EAN8"},"EAN8",-1),e.createElementVNode("option",{value:"UPC"},"UPC",-1),e.createElementVNode("option",{value:"CODE39"},"CODE39",-1),e.createElementVNode("option",{value:"ITF14"},"ITF14",-1)])],40,dr)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",cr,[c[43]||(c[43]=e.createElementVNode("span",{class:"pd-label"},"显示文本",-1)),e.createElementVNode("input",{checked:i.value.showBarcodeText!==!1,type:"checkbox",class:"pd-switch",onInput:c[4]||(c[4]=g=>w($=>{$.showBarcodeText=!!g.target.checked}))},null,40,ur)])):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",mr,[c[45]||(c[45]=e.createElementVNode("span",{class:"pd-label"},"纠错级别",-1)),e.createElementVNode("select",{value:i.value.qrCodeLevel||"M",class:"pd-select",onChange:c[5]||(c[5]=g=>w($=>{$.qrCodeLevel=g.target.value||void 0}))},[...c[44]||(c[44]=[e.createElementVNode("option",{value:"L"},"L(最低,容量大)",-1),e.createElementVNode("option",{value:"M"},"M(推荐)",-1),e.createElementVNode("option",{value:"Q"},"Q",-1),e.createElementVNode("option",{value:"H"},"H(最高)",-1)])],40,pr)])):e.createCommentVNode("",!0),e.createElementVNode("div",fr,[c[46]||(c[46]=e.createElementVNode("span",{class:"pd-label"},"内容",-1)),e.createElementVNode("input",{value:i.value.formatter||"",class:"pd-input",placeholder:"输入内容,支持 {字段} 表达式",onInput:c[6]||(c[6]=g=>w($=>{$.formatter=g.target.value||void 0})),onDblclick:C},null,40,vr)]),e.createElementVNode("div",gr,[c[50]||(c[50]=e.createElementVNode("span",{class:"pd-label"},"水平对齐",-1)),e.createElementVNode("div",hr,[e.createElementVNode("label",br,[e.createElementVNode("input",{type:"radio",value:"left",checked:i.value.align==="left",onChange:c[7]||(c[7]=g=>v(g.target.value))},null,40,yr),c[47]||(c[47]=e.createElementVNode("span",null,"左",-1))]),e.createElementVNode("label",kr,[e.createElementVNode("input",{type:"radio",value:"center",checked:i.value.align==="center",onChange:c[8]||(c[8]=g=>v(g.target.value))},null,40,Er),c[48]||(c[48]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",wr,[e.createElementVNode("input",{type:"radio",value:"right",checked:i.value.align==="right",onChange:c[9]||(c[9]=g=>v(g.target.value))},null,40,Vr),c[49]||(c[49]=e.createElementVNode("span",null,"右",-1))])])]),e.createElementVNode("div",Nr,[c[54]||(c[54]=e.createElementVNode("span",{class:"pd-label"},"垂直对齐",-1)),e.createElementVNode("div",Cr,[e.createElementVNode("label",Sr,[e.createElementVNode("input",{type:"radio",value:"top",checked:i.value.valign==="top",onChange:c[10]||(c[10]=g=>p(g.target.value))},null,40,$r),c[51]||(c[51]=e.createElementVNode("span",null,"上",-1))]),e.createElementVNode("label",Mr,[e.createElementVNode("input",{type:"radio",value:"middle",checked:i.value.valign==="middle",onChange:c[11]||(c[11]=g=>p(g.target.value))},null,40,Br),c[52]||(c[52]=e.createElementVNode("span",null,"中",-1))]),e.createElementVNode("label",Dr,[e.createElementVNode("input",{type:"radio",value:"bottom",checked:i.value.valign==="bottom",onChange:c[12]||(c[12]=g=>p(g.target.value))},null,40,xr),c[53]||(c[53]=e.createElementVNode("span",null,"下",-1))])])]),e.createElementVNode("div",Tr,[e.createElementVNode("div",zr,[c[56]||(c[56]=e.createElementVNode("span",{class:"pd-label"},"字体",-1)),e.createElementVNode("select",{value:i.value.fontFamily,class:"pd-select",placeholder:"继承默认",onChange:c[13]||(c[13]=g=>w($=>{$.fontFamily=g.target.value||void 0}))},[...c[55]||(c[55]=[e.createElementVNode("option",{value:"SimSun"},"宋体",-1),e.createElementVNode("option",{value:"SimHei"},"黑体",-1),e.createElementVNode("option",{value:"Microsoft YaHei"},"微软雅黑",-1),e.createElementVNode("option",{value:"KaiTi"},"楷体",-1),e.createElementVNode("option",{value:"FangSong"},"仿宋",-1),e.createElementVNode("option",{value:"Arial"},"Arial",-1)])],40,Lr)]),e.createElementVNode("div",Pr,[c[57]||(c[57]=e.createElementVNode("span",{class:"pd-label"},"字号 (pt)",-1)),e.createElementVNode("input",{value:i.value.fontSize,type:"number",class:"pd-input",min:5,max:72,onInput:c[14]||(c[14]=g=>w($=>{$.fontSize=g.target.valueAsNumber??void 0}))},null,40,Ar)]),e.createElementVNode("div",Ir,[c[58]||(c[58]=e.createElementVNode("span",{class:"pd-label"},"加粗",-1)),e.createElementVNode("input",{checked:i.value.fontWeight==="bold",type:"checkbox",class:"pd-switch",onInput:c[15]||(c[15]=g=>w($=>{$.fontWeight=g.target.checked?"bold":void 0}))},null,40,Rr)]),e.createElementVNode("div",Fr,[c[59]||(c[59]=e.createElementVNode("span",{class:"pd-label"},"文字颜色",-1)),e.createVNode(fe,{"model-value":i.value.color,"onUpdate:modelValue":c[16]||(c[16]=g=>w($=>{$.color=g}))},null,8,["model-value"])]),e.createElementVNode("div",Ur,[c[60]||(c[60]=e.createElementVNode("span",{class:"pd-label"},"背景色",-1)),e.createVNode(fe,{"model-value":i.value.backgroundColor,"onUpdate:modelValue":c[17]||(c[17]=g=>w($=>{$.backgroundColor=g}))},null,8,["model-value"])])]),c[68]||(c[68]=e.createElementVNode("h3",{class:"pd-divider"},"边框",-1)),e.createElementVNode("div",Hr,[e.withDirectives(e.createElementVNode("select",{class:"pd-select","onUpdate:modelValue":c[18]||(c[18]=g=>L.value=g),style:{width:"90px"}},[...c[61]||(c[61]=[e.createElementVNode("option",{value:"solid"},"实线",-1),e.createElementVNode("option",{value:"dashed"},"虚线",-1),e.createElementVNode("option",{value:"dotted"},"点线",-1),e.createElementVNode("option",{value:"double"},"双线",-1)])],512),[[e.vModelSelect,L.value]]),e.withDirectives(e.createElementVNode("input",{type:"number",class:"pd-input","onUpdate:modelValue":c[19]||(c[19]=g=>I.value=g),min:.25,max:5,step:.25,style:{width:"90px"}},null,512),[[e.vModelText,I.value,void 0,{number:!0}]]),e.createVNode(fe,{modelValue:U.value,"onUpdate:modelValue":c[20]||(c[20]=g=>U.value=g)},null,8,["modelValue"])]),e.createElementVNode("div",Gr,[e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[21]||(c[21]=g=>O("all"))},"全部"),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[22]||(c[22]=g=>O("outer"))},"外侧"),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[23]||(c[23]=g=>O("inner"))},"内部"),e.createElementVNode("button",{type:"button",class:"pd-button small",onClick:c[24]||(c[24]=g=>O("none"))},"无")]),e.createElementVNode("div",Or,[e.createElementVNode("label",qr,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":c[25]||(c[25]=g=>H.value=g),value:"top",onChange:c[26]||(c[26]=g=>Y(g))},null,544),[[e.vModelCheckbox,H.value]]),c[62]||(c[62]=e.createElementVNode("span",null,"上",-1))]),e.createElementVNode("label",Wr,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":c[27]||(c[27]=g=>H.value=g),value:"right",onChange:c[28]||(c[28]=g=>Y(g))},null,544),[[e.vModelCheckbox,H.value]]),c[63]||(c[63]=e.createElementVNode("span",null,"右",-1))]),e.createElementVNode("label",Kr,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":c[29]||(c[29]=g=>H.value=g),value:"bottom",onChange:c[30]||(c[30]=g=>Y(g))},null,544),[[e.vModelCheckbox,H.value]]),c[64]||(c[64]=e.createElementVNode("span",null,"下",-1))]),e.createElementVNode("label",Yr,[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":c[31]||(c[31]=g=>H.value=g),value:"left",onChange:c[32]||(c[32]=g=>Y(g))},null,544),[[e.vModelCheckbox,H.value]]),c[65]||(c[65]=e.createElementVNode("span",null,"左",-1))])]),e.createElementVNode("div",Xr,[c[66]||(c[66]=e.createElementVNode("span",{class:"pd-label"},"内边距 (mm)",-1)),e.createElementVNode("input",{value:i.value.padding,type:"number",class:"pd-input",min:0,max:10,step:.5,onInput:c[33]||(c[33]=g=>w($=>{$.padding=g.target.valueAsNumber??void 0}))},null,40,jr)]),e.createElementVNode("div",Jr,[c[67]||(c[67]=e.createElementVNode("span",{class:"pd-label"},"自动换行",-1)),e.createElementVNode("input",{checked:i.value.wordWrap??!0,type:"checkbox",class:"pd-switch",onInput:c[34]||(c[34]=g=>w($=>{$.wordWrap=!!g.target.checked}))},null,40,Zr)]),e.createElementVNode("div",Qr,[e.createElementVNode("button",{type:"button",class:"pd-button small",disabled:!!j.value,title:j.value||"",onClick:y}," 合并单元格 ",8,_r),e.createElementVNode("button",{type:"button",class:"pd-button small",disabled:!W.value,onClick:f},"拆分单元格",8,es)])],32)]),_:1}),e.createVNode(rt,{modelValue:r.value,"onUpdate:modelValue":c[36]||(c[36]=g=>r.value=g),fields:t.fields,expression:s.value,"onUpdate:expression":D},null,8,["modelValue","fields","expression"])],64))}}),ns=ee(ts,[["__scopeId","data-v-23f9c444"]]),os={text:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],longText:[{targetPath:"options.formatter",label:"内容",dataSource:"main"},{targetPath:"options.styler",label:"样式",dataSource:"main"}],barcode:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],qrcode:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],image:[{targetPath:"options.src",label:"内容",dataSource:"main",placeholder:"输入图片路径,支持 /docfiles/... 相对路径、绝对 URL 或 {字段} 表达式"}],table:[]};function At(t,l,o,n){return t==="data"?[{targetPath:`options.tableRows[${l}].cells[${o}].formatter`,label:"内容",dataSource:"list",listField:n,placeholder:"{name}"}]:t==="subtotal"?[{targetPath:`options.tableRows[${l}].cells[${o}].formatter`,label:"内容",dataSource:"subtotal",placeholder:"{MONEY(SUM(amount))}"}]:t==="summary"?[{targetPath:`options.tableRows[${l}].cells[${o}].formatter`,label:"内容",dataSource:"summary",placeholder:"{MONEY(SUM(amount))}"}]:[{targetPath:`options.tableRows[${l}].cells[${o}].formatter`,label:"内容",dataSource:"main",placeholder:"合计: {order.total}"}]}function ls(t){const l=t.printElementType.type,o=os[l]??[],n=[];if(l==="table"){const a=t.options.dataSource;for(const[i,r]of(t.options.tableRows??[]).entries())for(const[s,d]of r.cells.entries())d.merged||n.push(...At(r.type,i,s,a))}return[...o,...n]}const as={key:0,class:"prop-collapsed"},is={class:"prop-head"},rs={class:"pd-tabs prop-tabs"},ss={class:"pd-tab-bar",role:"tablist"},ds={class:"pd-tab-pane",role:"tabpanel"},cs={class:"property-content"},us={key:1,class:"pd-empty"},ms={class:"pd-tab-pane",role:"tabpanel"},ps={class:"pd-field"},fs=["value"],vs=["value"],gs={key:0,class:"pd-field"},hs={class:"custom-size-grid"},bs=["value"],ys=["value"],ks={class:"pd-field"},Es={class:"pd-radio-group",role:"radiogroup"},ws={class:"pd-radio"},Vs=["checked"],Ns={class:"pd-radio"},Cs=["checked"],Ss={class:"margin-grid"},$s={class:"pd-field"},Ms=["value"],Bs={class:"pd-field"},Ds=["value"],xs={class:"pd-field"},Ts=["value"],zs={class:"pd-field"},Ls=["value"],Ps={class:"pd-field"},As=["value"],Is={class:"pd-field"},Rs=["value"],Fs={class:"pd-field"},Us=["value"],Hs=e.defineComponent({__name:"PropertyPanel",props:{element:{},templateData:{},fields:{},activeTab:{},tableSelection:{},recordHistory:{type:Function},collapsed:{type:Boolean}},emits:["delete-element","update:templateData","update:activeTab","toggle-collapse"],setup(t,{emit:l}){const o=t,n=l,a=Ze,i=e.ref(""),r=e.computed(()=>o.element?["text","longText"].includes(o.element.printElementType.type):!1),s=e.computed(()=>o.element?o.element.printElementType.type==="image":!1),d=e.computed(()=>!o.element||o.element.printElementType.type!=="table"?!1:!!o.tableSelection&&o.tableSelection.elementId===o.element.id),u=e.computed(()=>o.element?o.element.printElementType.type==="table":!1),v=e.computed(()=>Gl(i.value)),p=e.computed(()=>v.value.groups),k=e.computed(()=>v.value.itemKeys),C=e.computed(()=>!!i.value.trim()),D=e.computed(()=>{if(!o.element)return[];if(o.element.printElementType.type==="table"&&o.tableSelection){const{r1:S,c1:V}=o.tableSelection,P=o.element.options.tableRows;if(P&&P[S]){const Q=P[S],le=o.element.options.fields?.[0]?.dataSource;return At(Q.type,S,V,le)}}return ls(o.element)});function w(S){return S.split(".").flatMap(V=>{const P=V.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!P)return[V];const Q=P[1],le=[...P[2].matchAll(/\[(\d+)\]/g)].map(de=>Number(de[1]));return[Q,...le]})}function L(S){return o.element?w(S).reduce((Q,le)=>Q==null?"":Q[le],o.element)??"":""}function I(S,V){if(!o.element)return;const P=w(S),Q=P.pop(),le=P.reduce((de,pe)=>((de[pe]===void 0||de[pe]===null)&&(de[pe]={}),de[pe]),o.element);le[Q]=V||void 0,o.recordHistory?.()}function U(S){i.value=S}function H(S){o.element&&I("options.src",S)}const z=e.computed(()=>o.templateData?.paperSize||"A4"),O=e.computed(()=>o.templateData?.orientation||"portrait"),Y=e.computed(()=>o.templateData?.margins.top??10),j=e.computed(()=>o.templateData?.margins.bottom??10),W=e.computed(()=>o.templateData?.margins.left??10),y=e.computed(()=>o.templateData?.margins.right??10),f=e.computed(()=>o.templateData?.header.height??10),h=e.computed(()=>o.templateData?.footer.height??10),c=e.computed(()=>o.templateData?.firstPageOverlay.height??0),g=e.computed(()=>o.templateData?.customWidth??210),$=e.computed(()=>o.templateData?.customHeight??297);function G(S){o.templateData&&n("update:templateData",{...o.templateData,...S})}function K(S){if(S==="CUSTOM"){G({paperSize:"CUSTOM"});return}a[S]&&G({paperSize:S})}function X(S){G({orientation:String(S)})}function ae(S){S!==void 0&&G({customWidth:S})}function M(S){S!==void 0&&G({customHeight:S})}function B(S){S!==void 0&&G({margins:{...o.templateData.margins,top:S}})}function T(S){S!==void 0&&G({margins:{...o.templateData.margins,bottom:S}})}function q(S){S!==void 0&&G({margins:{...o.templateData.margins,left:S}})}function m(S){S!==void 0&&G({margins:{...o.templateData.margins,right:S}})}function b(S){S!==void 0&&G({header:{...o.templateData.header,height:S}})}function E(S){S!==void 0&&G({footer:{...o.templateData.footer,height:S}})}function N(S){S!==void 0&&G({firstPageOverlay:{...o.templateData.firstPageOverlay,height:S}})}const F=e.computed(()=>o.activeTab||"page");function Z(S){n("update:activeTab",S),n("toggle-collapse")}return(S,V)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["property-panel",{collapsed:t.collapsed}])},[t.collapsed?(e.openBlock(),e.createElementBlock("div",as,[e.createElementVNode("button",{class:"pc-btn",title:"展开属性台",onClick:V[0]||(V[0]=P=>Z(F.value))},"«"),e.createElementVNode("button",{class:e.normalizeClass(["pc-btn",{on:F.value==="element"}]),title:"元素属性",onClick:V[1]||(V[1]=P=>Z("element"))},"▦",2),e.createElementVNode("button",{class:e.normalizeClass(["pc-btn",{on:F.value==="page"}]),title:"页面属性",onClick:V[2]||(V[2]=P=>Z("page"))},"▤",2)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",is,[V[20]||(V[20]=e.createElementVNode("span",{class:"prop-title"},"属性台",-1)),e.createElementVNode("button",{class:"collapse-btn",title:"收起属性台",onClick:V[3]||(V[3]=P=>S.$emit("toggle-collapse"))},"»")]),e.createElementVNode("div",rs,[e.createElementVNode("div",ss,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:(t.activeTab||"page")==="element"}]),onClick:V[4]||(V[4]=P=>S.$emit("update:activeTab","element"))},"元素属性",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["pd-tab",{active:(t.activeTab||"page")==="page"}]),onClick:V[5]||(V[5]=P=>S.$emit("update:activeTab","page"))},"页面属性",2)]),e.withDirectives(e.createElementVNode("div",ds,[t.element?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(Wl,{onSearch:U}),e.createElementVNode("div",cs,[p.value.includes("position-size")&&!d.value?(e.openBlock(),e.createBlock(oa,{key:0,element:t.element,"matched-keys":k.value,searching:C.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),p.value.includes("appearance")?(e.openBlock(),e.createBlock(Ba,{key:1,element:t.element,"is-text-type":r.value,"matched-keys":k.value,searching:C.value},null,8,["element","is-text-type","matched-keys","searching"])):e.createCommentVNode("",!0),p.value.includes("binding")?(e.openBlock(),e.createBlock(me,{key:2,title:"内容",icon:"Document","default-expanded":"","group-key":"binding"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,P=>(e.openBlock(),e.createBlock(mi,{key:P.targetPath,descriptor:P,fields:t.fields,"model-value":L(P.targetPath),"onUpdate:modelValue":Q=>I(P.targetPath,Q)},null,8,["descriptor","fields","model-value","onUpdate:modelValue"]))),128)),s.value?(e.openBlock(),e.createBlock(Ki,{key:0,onSuccess:H})):e.createCommentVNode("",!0)]),_:1})):e.createCommentVNode("",!0),u.value&&t.tableSelection&&t.tableSelection.elementId===t.element.id?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createVNode(_i,{element:t.element,selection:t.tableSelection},null,8,["element","selection"]),e.createVNode(ns,{element:t.element,selection:t.tableSelection,fields:t.fields},null,8,["element","selection","fields"])],64)):e.createCommentVNode("",!0),u.value&&p.value.includes("content")?(e.openBlock(),e.createBlock(Vi,{key:4,element:t.element,fields:t.fields},null,8,["element","fields"])):e.createCommentVNode("",!0),p.value.includes("border-bg")?(e.openBlock(),e.createBlock(Bi,{key:5,element:t.element,"matched-keys":k.value,searching:C.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),p.value.includes("pagination")&&u.value?(e.openBlock(),e.createBlock(bt,{key:6,element:t.element,"matched-keys":k.value,searching:C.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),p.value.includes("pagination")&&!u.value?(e.openBlock(),e.createBlock(bt,{key:7,element:t.element,"matched-keys":k.value,searching:C.value},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0),p.value.includes("advanced")?(e.openBlock(),e.createBlock(Ai,{key:8,element:t.element,"matched-keys":k.value,searching:C.value,onDeleteElement:V[6]||(V[6]=P=>S.$emit("delete-element"))},null,8,["element","matched-keys","searching"])):e.createCommentVNode("",!0)])],64)):(e.openBlock(),e.createElementBlock("p",us,"请在画布中选择一个元素"))],512),[[e.vShow,(t.activeTab||"page")==="element"]]),e.withDirectives(e.createElementVNode("div",ms,[e.createElementVNode("form",{class:"pd-form",onSubmit:V[19]||(V[19]=e.withModifiers(()=>{},["prevent"]))},[V[35]||(V[35]=e.createElementVNode("h3",{class:"pd-divider"},"纸张设置",-1)),e.createElementVNode("div",ps,[V[22]||(V[22]=e.createElementVNode("span",{class:"pd-label"},"纸张尺寸",-1)),e.createElementVNode("select",{value:z.value,class:"pd-select",onChange:V[7]||(V[7]=P=>K(P.target.value)),style:{width:"100%"}},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(a),(P,Q)=>(e.openBlock(),e.createElementBlock("option",{key:Q,value:Q},e.toDisplayString(Q),9,vs))),128)),V[21]||(V[21]=e.createElementVNode("option",{value:"CUSTOM"},"自定义",-1))],40,fs)]),z.value==="CUSTOM"?(e.openBlock(),e.createElementBlock("div",gs,[V[24]||(V[24]=e.createElementVNode("span",{class:"pd-label"},"自定义宽高 (mm)",-1)),e.createElementVNode("div",hs,[e.createElementVNode("input",{value:g.value,type:"number",class:"pd-input",onInput:V[8]||(V[8]=P=>ae(P.target.valueAsNumber)),min:25,max:2e3,step:1,style:{width:"100%"}},null,40,bs),V[23]||(V[23]=e.createElementVNode("span",{class:"custom-size-x"},"×",-1)),e.createElementVNode("input",{value:$.value,type:"number",class:"pd-input",onInput:V[9]||(V[9]=P=>M(P.target.valueAsNumber)),min:25,max:2e3,step:1,style:{width:"100%"}},null,40,ys)])])):e.createCommentVNode("",!0),e.createElementVNode("div",ks,[V[27]||(V[27]=e.createElementVNode("span",{class:"pd-label"},"方向",-1)),e.createElementVNode("div",Es,[e.createElementVNode("label",ws,[e.createElementVNode("input",{type:"radio",value:"portrait",checked:O.value==="portrait",onChange:V[10]||(V[10]=P=>X(P.target.value))},null,40,Vs),V[25]||(V[25]=e.createElementVNode("span",null,"纵向",-1))]),e.createElementVNode("label",Ns,[e.createElementVNode("input",{type:"radio",value:"landscape",checked:O.value==="landscape",onChange:V[11]||(V[11]=P=>X(P.target.value))},null,40,Cs),V[26]||(V[26]=e.createElementVNode("span",null,"横向",-1))])])]),V[36]||(V[36]=e.createElementVNode("h3",{class:"pd-divider"},"页边距 (mm)",-1)),e.createElementVNode("div",Ss,[e.createElementVNode("div",$s,[V[28]||(V[28]=e.createElementVNode("span",{class:"pd-label"},"上",-1)),e.createElementVNode("input",{value:Y.value,type:"number",class:"pd-input",onInput:V[12]||(V[12]=P=>B(P.target.valueAsNumber)),min:0,max:50,step:1,style:{width:"100%"}},null,40,Ms)]),e.createElementVNode("div",Bs,[V[29]||(V[29]=e.createElementVNode("span",{class:"pd-label"},"下",-1)),e.createElementVNode("input",{value:j.value,type:"number",class:"pd-input",onInput:V[13]||(V[13]=P=>T(P.target.valueAsNumber)),min:0,max:50,step:1,style:{width:"100%"}},null,40,Ds)]),e.createElementVNode("div",xs,[V[30]||(V[30]=e.createElementVNode("span",{class:"pd-label"},"左",-1)),e.createElementVNode("input",{value:W.value,type:"number",class:"pd-input",onInput:V[14]||(V[14]=P=>q(P.target.valueAsNumber)),min:0,max:50,step:1,style:{width:"100%"}},null,40,Ts)]),e.createElementVNode("div",zs,[V[31]||(V[31]=e.createElementVNode("span",{class:"pd-label"},"右",-1)),e.createElementVNode("input",{value:y.value,type:"number",class:"pd-input",onInput:V[15]||(V[15]=P=>m(P.target.valueAsNumber)),min:0,max:50,step:1,style:{width:"100%"}},null,40,Ls)])]),V[37]||(V[37]=e.createElementVNode("h3",{class:"pd-divider"},"三区高度 (mm)",-1)),e.createElementVNode("div",Ps,[V[32]||(V[32]=e.createElementVNode("span",{class:"pd-label"},"页眉高度",-1)),e.createElementVNode("input",{value:f.value,type:"number",class:"pd-input",onInput:V[16]||(V[16]=P=>b(P.target.valueAsNumber)),min:0,max:100,step:.1,style:{width:"100%"}},null,40,As)]),e.createElementVNode("div",Is,[V[33]||(V[33]=e.createElementVNode("span",{class:"pd-label"},"页脚高度",-1)),e.createElementVNode("input",{value:h.value,type:"number",class:"pd-input",onInput:V[17]||(V[17]=P=>E(P.target.valueAsNumber)),min:0,max:100,step:.1,style:{width:"100%"}},null,40,Rs)]),e.createElementVNode("div",Fs,[V[34]||(V[34]=e.createElementVNode("span",{class:"pd-label"},"首页叠加高度",-1)),e.createElementVNode("input",{value:c.value,type:"number",class:"pd-input",onInput:V[18]||(V[18]=P=>N(P.target.valueAsNumber)),min:0,max:200,style:{width:"100%"}},null,40,Us)])],32)],512),[[e.vShow,(t.activeTab||"page")==="page"]])])],64))],2))}}),Gs=ee(Hs,[["__scopeId","data-v-3e539040"]]),Os={class:"status-bar"},qs={key:0,class:"status-item coord"},Ws={class:"status-item"},Ks={class:"status-item"},Ys={class:"status-item status-paper"},Xs=e.defineComponent({__name:"StatusBar",props:{coordinate:{},scale:{},elementCount:{},selectedCount:{},paper:{},dirty:{type:Boolean}},setup(t){return(l,o)=>(e.openBlock(),e.createElementBlock("div",Os,[t.coordinate?(e.openBlock(),e.createElementBlock("span",qs," x:"+e.toDisplayString(t.coordinate.x.toFixed(1))+" y:"+e.toDisplayString(t.coordinate.y.toFixed(1))+"mm ",1)):e.createCommentVNode("",!0),e.createElementVNode("span",Ws,"缩放 "+e.toDisplayString(t.scale)+"%",1),e.createElementVNode("span",Ks,"元素 "+e.toDisplayString(t.elementCount)+e.toDisplayString(t.selectedCount?` (选中 ${t.selectedCount})`:""),1),e.createElementVNode("span",{class:e.normalizeClass(["status-dirty",{on:t.dirty}])},[o[0]||(o[0]=e.createElementVNode("span",{class:"dirty-dot"},null,-1)),e.createTextVNode(e.toDisplayString(t.dirty?"未保存":"已保存"),1)],2),e.createElementVNode("span",Ys,e.toDisplayString(t.paper),1)]))}}),js=ee(Xs,[["__scopeId","data-v-eb34e9a7"]]),yt="print-studio:left",kt="print-studio:right";function Et(t,l){try{const o=localStorage.getItem(t);return o===null?l:o==="1"}catch{return l}}function Js(){const t=e.ref(Et(yt,!1)),l=e.ref(Et(kt,!1)),o=e.ref(!1);e.watch(t,r=>{try{localStorage.setItem(yt,r?"1":"0")}catch{}},{flush:"sync"}),e.watch(l,r=>{try{localStorage.setItem(kt,r?"1":"0")}catch{}},{flush:"sync"});function n(){t.value=!t.value}function a(){l.value=!l.value}function i(){o.value=!1}return{leftCollapsed:t,rightCollapsed:l,toggleLeft:n,toggleRight:a,dirty:o,markSaved:i}}const Zs={class:"designer-container"},Qs={class:"designer-body"},_s=e.defineComponent({__name:"PrintDesigner",props:{initialTemplate:{},initialElements:{},fields:{},isEdit:{type:Boolean},requestScreenshot:{type:Function},uploadImage:{type:Function},loadDefaultTemplate:{type:Function}},emits:["back","preview","save"],setup(t,{expose:l,emit:o}){const n=t,a=o,{leftCollapsed:i,rightCollapsed:r,toggleLeft:s,toggleRight:d,dirty:u,markSaved:v}=Js(),{scale:p,showGrid:k,snapToGrid:C,showTableGhostBorder:D,templateData:w,elements:L,fields:I,selectedIds:U,selectedElement:H,select:z,clearSelection:O,selectAll:Y,previewIds:j,setPreview:W,commitPreview:y,hasClipboard:f,copy:h,paste:c,cutSelected:g,canUndo:$,canRedo:G,undo:K,redo:X,alignSelected:ae,groupSelected:M,ungroupSelected:B,deleteSelected:T,dragStart:q,dragStop:m,addElement:b,addFieldElement:E,moveLayer:N,updateTemplateData:F,fitToWindow:Z,getTemplateJson:S,loadTemplate:V,tableSelection:P,setTableSelection:Q,recordHistory:le}=xn({initialTemplate:n.initialTemplate,initialElements:n.initialElements,initialFields:n.fields});e.watch([L,w],()=>{u.value=!0},{deep:!0});const{guides:de,addGuide:pe,moveGuide:ve,removeGuide:Re}=zn(w,le),Fe=e.computed(()=>{const x=w.value,{width:A}=we(x);return A-x.margins.left-x.margins.right});e.provide(Se,{tableSelection:P,setTableSelection:Q,recordHistory:le,maxTableWidth:Fe}),e.provide(xt,U),e.provide(Tt,j),e.provide(it,e.computed(()=>n.uploadImage)),e.watch(H,x=>{(!x||x.printElementType.type!=="table")&&Q(null)});const Ve=e.ref(null),ge=e.ref(!1),be=e.ref(""),Ue=e.ref(.5);async function He(){if(ge.value){ge.value=!1;return}const x=S();if(!x){alert("模板数据为空");return}if(!n.requestScreenshot){alert("截图服务未配置");return}try{const A=await n.requestScreenshot({templateJson:x,printData:ue});be.value&&URL.revokeObjectURL(be.value),be.value=URL.createObjectURL(A),ge.value=!0}catch{alert("截图生成失败")}}const $e=e.ref(null);function Ge(x){$e.value=x}const Oe=e.computed(()=>{const x=w.value,A=we(x),ne=x.orientation==="landscape"?"横向":"纵向";return`${x.paperSize} ${ne} ${Math.round(A.width)}×${Math.round(A.height)}mm`});function R(){const x=Ve.value?.$el;x&&Z(x.clientWidth,x.clientHeight)}function _(x){p.value=Math.min(200,Math.max(50,p.value+x))}function J(x){const A=x.target.tagName;A==="INPUT"||A==="TEXTAREA"||A==="SELECT"||(x.ctrlKey||x.metaKey)&&x.key==="0"&&(x.preventDefault(),R())}e.onMounted(()=>document.addEventListener("keydown",J)),e.onUnmounted(()=>document.removeEventListener("keydown",J));function te(x){const A=w.value.header.height,ne=w.value.footer.height;F(x),x.header.height<A&&re("header"),x.footer.height<ne&&re("footer")}function ce(x,A){w.value={...w.value,[x]:{...w.value[x],height:A}}}function oe(x){F({...w.value}),re(x)}function re(x){const A=Ie(w.value)[x];L.value.some(se=>se.zone===x&&(se.options.top+se.options.height>A.height||se.options.left+se.options.width>A.width))&&alert(`${x==="header"?"页眉":"页脚"}高度已小于区域内元素,请手动调整元素位置`)}function ye(){const x=w.value.firstPageOverlay,A={options:{left:0,top:0,width:50,height:10,title:"首页叠加"},printElementType:{type:"text",title:"首页叠加"}};w.value={...w.value,firstPageOverlay:{...x,elements:[...x.elements,A]}}}const st=z;function Ut(x){const A=L.value.find(ne=>ne.id===x);A&&(A.options.visible=A.options.visible===!1)}function Ht(x){const A=L.value.find(ne=>ne.id===x);A&&(A.options.locked=!A.options.locked)}const Ne=e.ref("page");e.watch(H,x=>{Ne.value=x?"element":"page"});const Gt={text:"formatter",longText:"formatter",barcode:"formatter",qrcode:"formatter"},Ce=e.ref(!1),Me=e.ref(null),qe=e.ref("");function Ot(x){const A=L.value.find(se=>se.id===x);if(!A||(z(x,!1),Ne.value="element",A.options.locked))return;const ne=Gt[A.printElementType.type];ne&&(Me.value={kind:"element",element:A,field:ne},qe.value=A.options[ne]||"",Ce.value=!0)}function qt(x,A,ne){const se=L.value.find(jt=>jt.id===x);if(!se||(z(x,!1),Ne.value="element",se.options.locked))return;const dt=se.options.tableRows??[],ct=lt(dt,A,ne),We=dt[ct.r]?.cells[ct.c];We&&(Me.value={kind:"cell",cell:We},qe.value=We.formatter||"",Ce.value=!0)}function Wt(x){const A=Me.value;A?.kind==="element"?A.element.options[A.field]=x||void 0:A?.kind==="cell"&&(A.cell.formatter=x||void 0),le(),Ce.value=!1,Me.value=null}function Kt(x,A){L.value.push(x),z(x.id,!1),le()}e.watch(()=>n.initialTemplate,x=>{x&&V(x,n.initialElements)}),e.watch(()=>n.initialElements,x=>{x&&!n.initialTemplate&&(w.value={...w.value,elements:x.map(A=>({...A,options:{...A.options},printElementType:{...A.printElementType}}))})}),e.watch(()=>n.fields,x=>{I.value=x||[]}),l({getTemplateJson:S});async function Yt(){if(n.loadDefaultTemplate&&confirm("将覆盖当前画布内容,是否继续?"))try{const x=await n.loadDefaultTemplate();if(!x){alert("未获取到默认布局");return}V(x),alert("默认布局已加载")}catch{alert("加载默认布局失败")}}function Xt(){a("save",JSON.stringify(S())),v()}return(x,A)=>(e.openBlock(),e.createElementBlock("div",Zs,[e.createVNode(Jn,{"is-edit":t.isEdit,"can-undo":e.unref($),"can-redo":e.unref(G),"has-multi-selection":e.unref(U).size>=2,"has-selection":e.unref(U).size>=1,"show-grid":e.unref(k),"snap-to-grid":e.unref(C),"show-table-ghost-border":e.unref(D),"selected-element-has-group":!!e.unref(H)?.options.groupId,"overlay-visible":ge.value,"show-load-default":!!t.loadDefaultTemplate,scale:e.unref(p),"onUpdate:scale":A[0]||(A[0]=ne=>e.isRef(p)?p.value=ne:null),onBack:A[1]||(A[1]=ne=>x.$emit("back")),onPreview:A[2]||(A[2]=ne=>x.$emit("preview")),onSave:Xt,onLoadDefault:Yt,onUndo:e.unref(K),onRedo:e.unref(X),onAlign:A[3]||(A[3]=ne=>e.unref(ae)(ne)),onMoveLayer:e.unref(N),onToggleGrid:A[4]||(A[4]=ne=>k.value=!e.unref(k)),onToggleSnap:A[5]||(A[5]=ne=>C.value=!e.unref(C)),onToggleTableGhostBorder:A[6]||(A[6]=ne=>D.value=!e.unref(D)),onToggleOverlay:He,onGroup:e.unref(M),onUngroup:e.unref(B),onAddOverlayElement:ye,onFitWindow:R,onZoom:_},null,8,["is-edit","can-undo","can-redo","has-multi-selection","has-selection","show-grid","snap-to-grid","show-table-ghost-border","selected-element-has-group","overlay-visible","show-load-default","scale","onUndo","onRedo","onMoveLayer","onGroup","onUngroup"]),e.createElementVNode("div",Qs,[e.createVNode(Do,{fields:e.unref(I),elements:e.unref(L),"selected-ids":e.unref(U),collapsed:e.unref(i),onSelect:e.unref(st),onMoveLayer:e.unref(N),onToggleVisible:Ut,onToggleLocked:Ht,onToggleCollapse:e.unref(s)},null,8,["fields","elements","selected-ids","collapsed","onSelect","onMoveLayer","onToggleCollapse"]),e.createVNode(Fl,{ref_key:"canvasAreaRef",ref:Ve,"template-data":e.unref(w),elements:e.unref(L),scale:e.unref(p)/100,"show-grid":e.unref(k),"snap-to-grid":e.unref(C),"show-table-ghost-border":e.unref(D),"has-clipboard":e.unref(f),guides:e.unref(de),"overlay-visible":ge.value,"screenshot-url":be.value,"overlay-opacity":Ue.value,"selected-element-has-group":!!e.unref(H)?.options.groupId,onSelect:e.unref(st),onDropElement:e.unref(b),onDropField:e.unref(E),onDragStart:e.unref(q),onDragStop:e.unref(m),onDblclickElement:Ot,onDblclickCell:qt,onZoneHeightChange:ce,onZoneHeightCommit:oe,onSelectAll:e.unref(Y),onClearSelection:e.unref(O),onPreview:e.unref(W),onCommitPreview:e.unref(y),onPaste:e.unref(c),onCopy:e.unref(h),onCut:e.unref(g),onDelete:e.unref(T),onMoveLayer:e.unref(N),onCoordinate:Ge,onGroup:e.unref(M),onUngroup:e.unref(B),onAddGuide:e.unref(pe),onGuideMove:e.unref(ve),onGuideRemove:e.unref(Re),onZoom:_,onCloneElement:Kt},null,8,["template-data","elements","scale","show-grid","snap-to-grid","show-table-ghost-border","has-clipboard","guides","overlay-visible","screenshot-url","overlay-opacity","selected-element-has-group","onSelect","onDropElement","onDropField","onDragStart","onDragStop","onSelectAll","onClearSelection","onPreview","onCommitPreview","onPaste","onCopy","onCut","onDelete","onMoveLayer","onGroup","onUngroup","onAddGuide","onGuideMove","onGuideRemove"]),e.createVNode(Gs,{element:e.unref(H),"template-data":e.unref(w),fields:e.unref(I),"table-selection":e.unref(P),"record-history":e.unref(le),collapsed:e.unref(r),"active-tab":Ne.value,"onUpdate:activeTab":A[7]||(A[7]=ne=>Ne.value=ne),onDeleteElement:e.unref(T),"onUpdate:templateData":te,onToggleCollapse:e.unref(d)},null,8,["element","template-data","fields","table-selection","record-history","collapsed","active-tab","onDeleteElement","onToggleCollapse"])]),e.createVNode(js,{coordinate:$e.value,scale:e.unref(p),"element-count":e.unref(L).length,"selected-count":e.unref(U).size,paper:Oe.value,dirty:e.unref(u)},null,8,["coordinate","scale","element-count","selected-count","paper","dirty"]),e.createVNode(rt,{modelValue:Ce.value,"onUpdate:modelValue":A[8]||(A[8]=ne=>Ce.value=ne),fields:e.unref(I),expression:qe.value,"onUpdate:expression":Wt},null,8,["modelValue","fields","expression"])]))}}),ed=ee(_s,[["__scopeId","data-v-9da9f665"]]),je=3.7795275591,ze=3e3;async function It(t,l,o,n){const a=ie.bindData(t,l,o),i=await td(a,n),r=ie.paginate(a,i);return{html:ie.generateHtml(a,r,l,{codeRenderer:n}),pageCount:r.length,pageLayouts:r}}async function td(t,l){const o=ie.getPaperDimensions(t),n=ie.generateHtml(t,[],void 0,{isMeasurementPass:!0,codeRenderer:l}),a=document.createElement("iframe");a.setAttribute("aria-hidden","true"),a.style.cssText=`position:fixed;left:-10000px;top:0;width:${o.width}mm;height:${o.height}mm;border:0;visibility:hidden;pointer-events:none;`,document.body.appendChild(a);try{const i=a.contentWindow,r=a.contentDocument;if(!i||!r)throw new Error("无法创建测量 iframe");r.open(),r.write(n),r.close(),await nd(i);const s=ld(r),d=new Map,u=new Map(t.elements.map(v=>[v.id,v]));for(const v of s){const k=u.get(v.id)?.options?._repeatHeaderCount??0;d.set(v.id,{id:v.id,measuredHeight:v.height,measuredRowHeights:v.rowHeights,repeatHeaderHeight:v.rowHeights&&k>0?v.rowHeights.slice(0,k).reduce((C,D)=>C+D,0):0})}return d}finally{a.remove()}}function nd(t){return new Promise(l=>{let o=!1;const n=()=>{o||(o=!0,l())},a=setTimeout(n,ze),i=async()=>{try{const r=t.document.fonts;r?.ready&&await Promise.race([r.ready,wt(ze)]),await Promise.race([od(t.document),wt(ze)])}catch{}finally{clearTimeout(a),n()}};t.document.readyState==="complete"?i():(t.addEventListener("load",()=>{i()},{once:!0}),setTimeout(n,ze))})}function wt(t){return new Promise((l,o)=>setTimeout(()=>o(new Error("timeout")),t))}function od(t){const l=Array.from(t.images??[]);return Promise.all(l.map(o=>o.complete?Promise.resolve():new Promise(n=>{o.addEventListener("load",()=>n(),{once:!0}),o.addEventListener("error",()=>n(),{once:!0})}))).then(()=>{})}function ld(t){const l=[],o=t.querySelectorAll("[data-measure-id]");for(const n of o){const a=n,i=a.getAttribute("data-measure-id");if(!i)continue;const r=a.offsetHeight,s=a.querySelector("table.print-table");if(s){const d=[],u=s.querySelectorAll("tbody > tr[data-row-index]");for(const v of u)d.push(v.offsetHeight/je);l.push({id:i,height:r/je,rowHeights:d})}else l.push({id:i,height:r/je})}return l}const Rt="http://www.w3.org/2000/svg";function ad(t,l){const o=document.createElementNS(Rt,"svg");return et(o,t,{format:l.barcodeType||"CODE128",width:Math.max(1,(l.barWidth??2)/2),height:30,displayValue:l.showText!==!1,fontSize:l.fontSize??10,margin:0,marginBottom:2}),o.outerHTML}function id(t,l){const o=(l.qrCodeLevel??"M").toUpperCase(),a=tt.create(t,{errorCorrectionLevel:["L","M","Q","H"].includes(o)?o:"M"}).modules,i=a.size,r=4,s=4*r,d=i*r+s*2;let u="";for(let v=0;v<i;v++)for(let p=0;p<i;p++)a.get(p,v)&&(u+=`<rect x="${s+p*r}" y="${s+v*r}" width="${r}" height="${r}" fill="#000"/>`);return`<svg xmlns="${Rt}" viewBox="0 0 ${d} ${d}" width="${d}" height="${d}" shape-rendering="crispEdges">${u}</svg>`}const Ft={render(t,l,o={}){if(!t)throw new Error("empty barcode value");return l==="qrcode"?id(t,o):ad(t,o)}},rd={class:"print-html-preview"},sd={key:0,class:"print-html-preview-error"},dd={key:1,class:"print-html-preview-loading"},cd=e.defineComponent({__name:"PrintHtmlPreview",props:{templateJson:{},printData:{},baseUrl:{}},emits:["rendered","error"],setup(t,{expose:l,emit:o}){const n=t,a=o,i=e.ref(),r=e.ref(!1),s=e.ref("");let d=0;async function u(){if(!n.templateJson){s.value="",r.value=!1;return}const p=++d;r.value=!0,s.value="";try{const{html:k,pageCount:C}=await It(n.templateJson,n.printData,n.baseUrl,Ft);if(p!==d)return;const D=i.value?.contentWindow?.document;D&&(D.open(),D.write(k),D.close()),a("rendered",C)}catch(k){if(p!==d)return;s.value=k instanceof Error?k.message:"未知错误",a("error",s.value)}finally{p===d&&(r.value=!1)}}function v(){const p=i.value?.contentWindow;p&&(p.focus(),p.print())}return e.watch(()=>[n.templateJson,n.printData,n.baseUrl],()=>{u()},{immediate:!0,deep:!0}),e.onBeforeUnmount(()=>{d++}),l({print:v,rerender:u}),(p,k)=>(e.openBlock(),e.createElementBlock("div",rd,[s.value?(e.openBlock(),e.createElementBlock("div",sd,[e.createElementVNode("span",null,"预览渲染失败:"+e.toDisplayString(s.value),1)])):r.value?(e.openBlock(),e.createElementBlock("div",dd,"预览渲染中…")):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("iframe",{ref_key:"iframeRef",ref:i,class:"print-html-preview-iframe",title:"打印预览"},null,512),[[e.vShow,!r.value&&!s.value]])]))}}),ud=ee(cd,[["__scopeId","data-v-1841dcea"]]);exports.DEFAULT_DEMO_DATA=ue;exports.PrintDesigner=ed;exports.PrintHtmlPreview=ud;exports.UPLOAD_IMAGE_KEY=it;exports.browserCodeRenderer=Ft;exports.createDefaultTemplate=zt;exports.getDemoData=Mt;exports.renderHtmlPages=It;exports.toRuntimePool=_e;
4
+ //# sourceMappingURL=index.cjs.map