@worm-vue3-print/common 1.4.3 → 1.4.5

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 (43) hide show
  1. package/README.md +2 -2
  2. package/dist/browser-bundle.d.ts +1 -1
  3. package/dist/common.css +1 -1
  4. package/dist/common.js +114 -81
  5. package/dist/core/default-template.d.ts +1 -1
  6. package/dist/core/format.d.ts +1 -1
  7. package/dist/core/h.d.ts +1 -1
  8. package/dist/core/icons.d.ts +1 -1
  9. package/dist/core/store.d.ts +1 -1
  10. package/dist/index.cjs +31 -10
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.js +2873 -2731
  13. package/dist/print-designer.d.ts +1 -1
  14. package/dist/shell/binding.d.ts +1 -1
  15. package/dist/shell/canvas.d.ts +1 -1
  16. package/dist/shell/code.d.ts +1 -1
  17. package/dist/shell/color-picker.d.ts +1 -1
  18. package/dist/shell/controls.d.ts +1 -1
  19. package/dist/shell/crop-anchor.d.ts +1 -1
  20. package/dist/shell/elements.d.ts +1 -1
  21. package/dist/shell/expression-editor.d.ts +1 -1
  22. package/dist/shell/flow-list.d.ts +3 -2
  23. package/dist/shell/font-select.d.ts +1 -1
  24. package/dist/shell/format-bar.d.ts +1 -1
  25. package/dist/shell/help-content/changelog.d.ts +1 -1
  26. package/dist/shell/help-content/faq.d.ts +1 -1
  27. package/dist/shell/help-content/features.d.ts +1 -1
  28. package/dist/shell/help-content/getting-started.d.ts +1 -1
  29. package/dist/shell/help-content/index.d.ts +1 -1
  30. package/dist/shell/help-content/shortcuts.d.ts +1 -1
  31. package/dist/shell/help-modal.d.ts +1 -1
  32. package/dist/shell/page-extras.d.ts +1 -1
  33. package/dist/shell/panels.d.ts +1 -1
  34. package/dist/shell/prop-group.d.ts +1 -1
  35. package/dist/shell/property-panel.d.ts +1 -1
  36. package/dist/shell/property-search.d.ts +1 -1
  37. package/dist/shell/ruler.d.ts +1 -1
  38. package/dist/shell/table-props.d.ts +1 -1
  39. package/dist/shell/table.d.ts +1 -1
  40. package/dist/shell/toolbar-overflow.d.ts +1 -1
  41. package/dist/shell/toolbar.d.ts +1 -1
  42. package/dist/shell/watermark.d.ts +1 -1
  43. package/package.json +2 -2
package/dist/common.js CHANGED
@@ -1,12 +1,12 @@
1
- (function(wt){typeof define=="function"&&define.amd?define(wt):wt()})((function(){"use strict";function wt(e){return e/2.83464566929}function vr(e){return e*(25.4/96)}function Lt(e){return e*(96/25.4)}const Bs=6,Ff=1,zf=["clip","shrink","autoHeight"];function Hs(e){return typeof e=="string"&&zf.includes(e)?e:void 0}const Bf={text:"clip",longText:"autoHeight",flowList:"clip"};function wr(e,t){return Hs(t?.textFit)??Bf[e]??"clip"}function Us(e){if(e?.keepLineBreaks===!0&&e.wordWrap!==!1)return"pre-wrap"}function qs(e){return e?.wordWrap===!1?"nowrap":void 0}function ii(e){return Hs(e?.textFit)??(e?.wordWrap===!1?"clip":"autoHeight")}function Cn(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?Bs:Math.max(e,Ff)}function ai(e){return Math.round(e*100)/100}function Hf(e){return Math.floor(e*100)/100}function Uf(e,t,n,r){return`${e}#${t}#${n}:${r}`}function qf(e){const t=e.indexOf("#");if(t<0)return;const n=e.lastIndexOf("#"),r=e.slice(t+1,n);if(r!=="b"&&r!=="st"&&r!=="sm")return;const[o,i]=e.slice(n+1).split(":").map(Number);if(!(!Number.isFinite(o)||!Number.isFinite(i)))return{elementId:e.slice(0,t),kind:r,rowIndex:o,colIndex:i}}function Ws(e,t){return(e||"contain")==="cover"?t:void 0}function si(e,t,n,r=1){const o=Math.max(n?.colspan??1,1);let i=0;for(let c=0;c<o;c++)i+=e[t+c]??0;if(i<=0)return 0;const a=n?.padding??r,l=(wt(n?.borders?.left?.width??0)+wt(n?.borders?.right?.width??0))/2;return Math.max(i-a*2-l,.5)}function An(e,t,n,r=1){const o=Math.max(n?.rowspan??1,1);let i=0;for(let c=0;c<o;c++)i+=e[t+c]?.height??8;const a=n?.padding??r,l=(wt(n?.borders?.top?.width??0)+wt(n?.borders?.bottom?.width??0))/2;return Math.max(i-a*2-l,.5)}const li=1,js=12,Wf=3,jf=100,Gf=0,Yf=50,Gs=25.4/72;function Vf(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)))}function ut(e){return Vf(e,li,js,4)}function xt(e){return typeof e!="number"||!Number.isFinite(e)?4:Math.min(Yf,Math.max(Gf,e))}function On(e){return typeof e!="number"||!Number.isFinite(e)?8:Math.min(jf,Math.max(Wf,e))}function Qt(e,t){const n=ut(t),r=Math.min(2,n);return typeof e!="number"||!Number.isFinite(e)?r:Math.min(n,Math.max(1,Math.round(e)))}function Kf(e,t,n){const r=ut(t),o=xt(n),i=e-o*(r-1);return i<=0?0:i/r}function Xf(e,t,n){const r=Math.max(1,Math.floor(n));return e*r+t*(r-1)}function Ys(e,t){if(!e)return 0;const n=typeof t=="number"&&Number.isFinite(t)&&t>0?t*Gs:12*Gs;let r=0;for(const o of e){if(o===" "){r+=.28;continue}const i=o.codePointAt(0)??0;i>=12288&&i<=12351||i>=13312&&i<=19903||i>=19968&&i<=40959||i>=63744&&i<=64255||i>=65280&&i<=65376||i>=65504&&i<=65510||i>=131072?r+=1:/^[0-9A-Z]$/.test(o)?r+=.6:/^[a-z]$/.test(o)?r+=.5:/^[\u0020-\u007f]$/.test(o)?r+=.4:r+=.75}return r*n}function Zf(e,t){if(!t.autoSpan)return 1;const n=Qt(t.maxSpan,t.columns);if(n<=1||t.colUnitMm<=0)return 1;const r=Ys(e,t.fontSizePt);for(let o=1;o<=n;o++)if(r<=Xf(t.colUnitMm,t.gapX,o))return o;return n}function Jf(e,t){const n=ut(t.columns),r=xt(t.gapX),o=Kf(t.width,n,r),i=Qt(t.maxSpan,n),a=[];let l=[],c=0;for(const s of e){const d=String(s??""),p=Zf(d,{...t,columns:n,gapX:r,maxSpan:i,colUnitMm:o});l.length>0&&c+p>n&&(a.push({cells:l}),l=[],c=0),l.push({text:d,span:p}),c+=p}return l.length>0&&a.push({cells:l}),a}function xr(e,t){if(typeof e!="string"||!e.includes("{")||!t)return;const n=new Set;for(const r of e.matchAll(/\{([^{}]*)\}/g))for(const o of(r[1]??"").split(/[^A-Za-z0-9_\u4e00-\u9fa5.]/)){const i=o.split(".")[0];i&&!/^\d/.test(i)&&n.add(i)}for(const r of n)if(Array.isArray(t[r]))return r}function Qf(e,t,n){const r=xt(t),o=Ys("一",n);if(o<=0||e<=0)return li;const i=Math.floor((e+r)/(o+r));return Math.min(js,Math.max(li,i))}const Vs=e=>`${Math.round(e*1e3)/1e3}mm`;function eh(e){const t=ut(e.columns),n=xt(e.gapX),r=On(e.rowHeight);return["display:grid",`grid-template-columns:repeat(${t},minmax(0,1fr))`,`column-gap:${Vs(n)}`,`grid-auto-rows:minmax(${Vs(r)},auto)`].join(";")}const In=25.4,Ks=10;function ci(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):Ks}const Et=30,Er=10,di=2,Xs=0,th=.25,ui=.254;function nh(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return null;const t=e/In;for(let n=2;n<=8;n+=.5){const r=Math.max(1,Math.round(Sr(n)*t)),o=r/t;if(o>=ui-1e-9)return{barWidth:n,dotsPerModule:r,moduleWidthMm:o}}return null}function Zs(e,t){const n=nh(e);if(!n)return"";const r=s=>String(Number(s.toFixed(3))),o=`按 ${e}dpi 推荐条宽倍率 ${n.barWidth}(每模块 ${n.dotsPerModule} 个打印点 = ${r(n.moduleWidthMm)}mm,取达到 ${r(ui)}mm 下限的最小档)`,i=Sr(t??2),a=Math.max(1,Math.round(i*e/In)),l=a/(e/In),c=l>=ui-1e-9?`当前倍率 ${t??2} 折算为 ${a} 点 / ${r(l)}mm,已达标`:`当前倍率 ${t??2} 只有 ${a} 点 / ${r(l)}mm,低于下限`;return`${o};${c}。这里只提示,不会替你改值`}function Pn(e){const t=typeof e=="number"&&Number.isFinite(e)?e:2;return Math.max(1,t/2)}function Sr(e){return Pn(e)*th}function rh(e){const{barHeightMm:t,moduleWidthMm:n,boxHeightMm:r,textModules:o}=e,i=typeof t=="number"&&Number.isFinite(t)&&t>0,a=typeof n=="number"&&Number.isFinite(n)&&n>0;if(!i||!a)return Et;const l=Math.max(1,Math.round(t/n));if(!(typeof r=="number"&&Number.isFinite(r)&&r>0))return l;const s=typeof o=="number"&&Number.isFinite(o)&&o>0?o:0,d=Math.floor((r-s*n)/n);return Math.max(1,Math.min(l,d))}function Js(e,t,n){const r=Math.max(1,Math.round(e*n)),o=Math.floor(t*n);if(o<1)return null;const i=Math.min(r,o);return{dotsPerModule:i,preferredDots:r,moduleWidthMm:i/n}}function oh(e){const t=Sr(e.barWidth),n=Math.max(1,Math.ceil(e.unitWidth)),r=e.boxWidthMm>0?e.boxWidthMm/n:Number.POSITIVE_INFINITY,o=e.dpi;if(typeof o=="number"&&Number.isFinite(o)&&o>0){const i=Js(t,r,o/In);if(i)return i.moduleWidthMm}return Math.min(t,r)}function en(e,t){const n=typeof e=="number"&&e>0?e:Number.POSITIVE_INFINITY,r=typeof t=="number"&&t>0?Math.min(n,t):n;return Number.isFinite(r)?r:0}function ih(e){const t=Math.max(1,Math.ceil(e.unitWidth)),n=Math.max(1,Math.ceil(e.unitHeight)),r=Sr(e.barWidth),o=Math.min(e.boxWidthMm>0?e.boxWidthMm/t:Number.POSITIVE_INFINITY,e.boxHeightMm>0?e.boxHeightMm/n:Number.POSITIVE_INFINITY),i=e.dpi;if(typeof i=="number"&&Number.isFinite(i)&&i>0){const l=Js(r,o,i/In);if(l)return{moduleWidthMm:l.moduleWidthMm,widthMm:t*l.moduleWidthMm,heightMm:n*l.moduleWidthMm,dotsPerModule:l.dotsPerModule,scaledDown:l.dotsPerModule<l.preferredDots}}const a=Math.min(r,o);return{moduleWidthMm:a,widthMm:t*a,heightMm:n*a,dotsPerModule:null,scaledDown:a<r}}function pi(e){const t=Pn(e.barWidth),n=c=>ih({unitWidth:c.widthUnits/t,unitHeight:c.heightUnits/t,boxWidthMm:e.boxWidthMm,boxHeightMm:e.boxHeightMm,dpi:e.dpi,barWidth:e.barWidth}),r=e.measure(Et);if(!r)return{barHeightModules:Et,size:null};if(!(typeof e.barHeightMm=="number"&&Number.isFinite(e.barHeightMm)&&e.barHeightMm>0))return{barHeightModules:Et,size:n(r)};const i=Math.max(0,r.heightUnits/t-Et),a=rh({barHeightMm:e.barHeightMm,moduleWidthMm:oh({unitWidth:r.widthUnits/t,boxWidthMm:e.boxWidthMm,dpi:e.dpi,barWidth:e.barWidth}),boxHeightMm:e.boxHeightMm,textModules:i});if(a===Et)return{barHeightModules:a,size:n(r)};const l=e.measure(a);return l?{barHeightModules:a,size:n(l)}:{barHeightModules:Et,size:null}}const _r=["top","right","bottom","left"],Qs=new Set(["rect","oval","hline","vline","table"]);function fi(e){return!!e&&!Qs.has(e)}const ah=new Set(["solid","dashed","dotted","double"]);function el(e,t,n){return typeof e!="number"||!Number.isFinite(e)||e<=0||t==="none"?null:{borderWidth:`${e}pt`,borderStyle:typeof t=="string"&&ah.has(t)?t:"solid",borderColor:n||"#000"}}function tl(e,t){if(!e||Qs.has(e))return null;const n=el(t?.borderWidth,t?.borderStyle,t?.borderColor),r={},o=t?.borders;if(o)for(const i of _r){const a=o[i];if(!a)continue;const l=el(a.width,a.style,a.color);l&&(r[i]=l)}return!n&&Object.keys(r).length===0?null:{all:n,edges:r}}const sh=/[;"'<>\\(){}\[\]@!#]/,lh=64,Dn=100,nl=400;function ch(e){const t=(e??"").trim();return!t||t.length>lh||sh.test(t)?"":t}function rl(e,t){if((e||"contain")!=="cover"||typeof t!="number"||!Number.isFinite(t))return;const n=Math.round(t);if(!(n<=Dn))return Math.min(n,nl)}function hi(e,t,n){const r=ch(n),o={};r&&(o.objectPosition=r);const i=rl(e,t);return i!==void 0&&(o.transform=`scale(${Number((i/100).toFixed(2))})`,o.transformOrigin=r||"50% 50%"),o}function Rn(e){return typeof e!="number"||!Number.isFinite(e)?0:(e%360+360)%360}function ol(e,t,n){const r=e.width,o=t,i=Rn(n);let a,l;if(i===0||i===180)a=r,l=o;else if(i===90||i===270)a=o,l=r;else{const c=i*Math.PI/180;a=r*Math.abs(Math.cos(c))+o*Math.abs(Math.sin(c)),l=r*Math.abs(Math.sin(c))+o*Math.abs(Math.cos(c))}return{left:e.left-(a-r)/2,top:e.top-(l-o)/2,width:a,height:l}}const il=385,al=new Set(["table","flowList"]);function dh(e){return al.has(e)}const uh="条码与二维码仅支持 90° 步进;任意角度需 385dpi 以上打印头";function ph(e,t){if(e!=="barcode"&&e!=="qrcode")return!0;const n=t?.printerDpi;return typeof n=="number"&&n>0&&n>=il}function gi(e,t,n){const r=t?.rotate;if(typeof r!="number"||!Number.isFinite(r))return;const o=Rn(r);if(o!==0&&!al.has(e)){if(e==="barcode"||e==="qrcode"){if(o===90||o===180||o===270)return o;const i=t?.printerDpi;if(typeof i=="number"&&i>0&&i<il){const a=Rn(Math.round(o/90)*90);return a===0?void 0:a}}return o}}const Nt={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},DOT_FULL:{width:241,height:279.4},DOT_HALF:{width:241,height:139.7},DOT_THIRD:{width:241,height:93.1},LABEL_80X60:{width:80,height:60},LABEL_60X40:{width:60,height:40},LABEL_40X30:{width:40,height:30},THERMAL_57:{width:57,height:297},THERMAL_80:{width:80,height:297},THERMAL_110:{width:110,height:297},CUSTOM:{width:210,height:297},CONTINUOUS:{width:80,height:297}},fh=new Set(["CONTINUOUS","THERMAL_57","THERMAL_80","THERMAL_110"]);function tn(e){return fh.has(e)}function Ze(e){const t=tn(e.paperSize),n=e.paperSize==="CUSTOM"||t?{width:e.customWidth??Nt[e.paperSize].width,height:e.customHeight??Nt[e.paperSize].height}:Nt[e.paperSize];return e.orientation==="landscape"&&!t?{width:n.height,height:n.width}:{...n}}function nn(e){if(tn(e.paperSize))return Ze(e);const n=Ze(e);return e.outputRotation===90||e.outputRotation===270?{width:n.height,height:n.width}:n}function mi(e){return tn(e.paperSize)?0:e.outputRotation??0}function tt(e){return tn(e.paperSize)}function Mr(e){return e.options?.pagination??e.pagination}function hh(e){return e.options?.tablePagination??e.tablePagination}const gh=2;function rn(e){return e.type==="table"||e.printElementType?.type==="table"}function mh(e){return e.type||e.printElementType?.type||"text"}function sl(e){return gi(mh(e),e.options)}function $n(e,t){const n=t.get(e.id)?.measuredHeight??e.options?.height??0,r=e.options?.top??0,o=sl(e);if(o===void 0)return{height:n,shift:0,top:r,rot:void 0};const i=ol({left:e.options?.left??0,top:r,width:e.options?.width??100},n,o);return{height:i.height,shift:r-i.top,top:i.top,rot:o}}function bh(e,t){const n=e.options?.left??0,r=e.options?.tableColWidths??[],o=rn(e)&&r.length>0?r.reduce((c,s)=>c+s,0):e.options?.width??0,i=sl(e);if(i===void 0)return{left:n,width:o};const a=t.get(e.id)?.measuredHeight??e.options?.height??0,l=ol({left:n,top:e.options?.top??0,width:o},a,i);return{left:l.left,width:l.width}}function bi(e){const t=e.options??{},n=t.top??0,o=(t.tableRows??[]).reduce((a,l)=>a+(l.height??0),0),i=Math.max(t.height??0,o);return n+i}function ll(e){return(t,n)=>{const r=t.options?.top??0,o=n.options?.top??0;if(r!==o)return r-o;const i=t.options?.zIndex??0,a=n.options?.zIndex??0;return i!==a?i-a:(e.get(t.id)??0)-(e.get(n.id)??0)}}function cl(e){const t=e.filter(a=>typeof a.id=="string").map(a=>a),n=new Map;t.forEach((a,l)=>n.set(a.id,l));const r=[...t].sort(ll(n)),o=new Set;for(const a of r)rn(a)||a.options?.groupId&&o.add(a.id);const i=new Set;for(const a of dl(r,o).values())for(const l of a)i.add(l);return i}function dl(e,t){const n=new Map;let r=null,o=-1,i=0,a=0;for(const l of e){if(rn(l)){r=l.id,o=bi(l);const p=l.options?.left??0,u=l.options?.tableColWidths??[],f=u.length>0?u.reduce((g,m)=>g+m,0):l.options?.width??0;i=p,a=p+f,n.set(l.id,[]);continue}if(t?.has(l.id)||!r||(l.options?.top??0)<o)continue;const s=l.options?.left??0;s+(l.options?.width??0)<=i||s>=a||n.get(r).push(l.id)}return n}function yh(e,t,n,r){const o=bi(e);let i=o;for(const a of t){const l=n.elements.find(c=>c.id===a);l&&(i=Math.max(i,(l.options?.top??0)+(l.options?.height??0)))}return Math.max(i-o,0)}function vh(e,t){return Math.max(e.options?.height??0,t.get(e.id)?.measuredHeight??0)}const wh=25.4/72;function on(e){const t=e.options??{},n=t.left??0;if((e.type||e.printElementType?.type||"text")==="vline"){const i=(t.borderWidth??.75)*wh/2+.05;return[n-i,n+i]}return[n,n+(t.width??100)]}function ul(e,t){return e[0]<t[1]&&t[0]<e[1]}function pl(e,t){return[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function xh(e,t,n){const r=new Map;for(const p of n.values()){if(p.length<2)continue;const u={anchorId:p[0].id,ids:p.map(f=>f.id),forceFirstPage:p.some(f=>Mr(f)?.pageable===!1),band:p.map(on).reduce(pl)};for(const f of p)r.set(f.id,u)}const o=e.filter(p=>!rn(p)&&!p.options?.groupId&&Mr(p)?.pageable!==!1),i=new Map;o.forEach(p=>i.set(p.id,p.id));const a=p=>{let u=p;for(;i.get(u)!==u;)u=i.get(u);let f=p;for(;i.get(f)!==u;){const g=i.get(f);i.set(f,u),f=g}return u},l=(p,u)=>{const f=a(p),g=a(u);f!==g&&i.set(g,f)},c=[];for(const p of o){const u=p.options?.top??0;for(let m=c.length-1;m>=0;m--)c[m].bottom<=u&&c.splice(m,1);const f=u+vh(p,t),g=on(p);for(const m of c)m.bottom>u&&ul(m.x,g)&&l(p.id,m.id);c.push({id:p.id,top:u,bottom:f,x:g})}const s=new Map(o.map(p=>[p.id,p])),d=new Map;for(const p of o){const u=a(p.id),f=d.get(u);f?f.push(p.id):d.set(u,[p.id])}for(const p of d.values()){if(p.length<2)continue;const u={anchorId:p[0],ids:p,forceFirstPage:!1,band:p.map(f=>on(s.get(f))).reduce(pl)};for(const f of p)r.set(f,u)}return r}function yi(e,t){const n=Ze(e),{top:r,bottom:o}=e.margins,i=e.header?.height??0,a=e.footer?.height??0,l=tt(e),c=l?Number.POSITIVE_INFINITY:n.height-r-o-i-a;if(!l&&c<=0)throw new Error(`页面可用高度不足: paper=${n.height}mm, margins=${r+o}mm, header=${i}mm, footer=${a}mm`);const s=new Map;e.elements.forEach((R,F)=>s.set(R.id,F));const d=[...e.elements].sort(ll(s)),p=new Set,u=new Map;for(const R of d){if(rn(R))continue;const F=R.options?.groupId;if(!F)continue;p.add(R.id);const W=u.get(F);W?W.push(R):u.set(F,[R])}const f=dl(d,p),g=new Map;for(const[R,F]of f)for(const W of F)g.set(W,R);const m=new Map;for(const R of d)m.set(R.id,R);const y=xh(d,t,u),v=[];let w=[],_=[],M=!1;function N(){return c-gh}function L(R){let F=0;for(const W of _)ul(R,[W.x0,W.x1])&&(F+=W.height);return Math.max(0,F)}function P(R){return N()-L(R)}function k(R,F){_.push({x0:R[0],x1:R[1],height:F})}function S(R,F=on(R)){return M?C(F):R.options?.top??0}function C(R){return Math.max(0,N()-P(R))}let O=!1,D=[];function I(R,F,W){W<=0||D.push(`元素 ${R.id} 旋转 ${F}° 后顶部超出页首 ${Math.round(W*100)/100}mm,打印将被裁切`)}function x(){v.push(O||D.length>0?{pageIndex:v.length,sections:[...w],...O?{overflow:!0}:{},...D.length>0?{warnings:[...D]}:{}}:{pageIndex:v.length,sections:[...w]})}function j(R){R>c&&(O=!0)}function te(R=!1){if(w.length===0){O=O||R;return}x(),w=[],_=[],M=!0,O=!1,D=[]}let fe=0;for(;fe<d.length;){const R=d[fe];if(g.has(R.id)){fe++;continue}const F=y.get(R.id);if(F&&F.anchorId!==R.id){fe++;continue}if(Mr(R)?.pageable===!1||F?.forceFirstPage){if(F){let W=Number.POSITIVE_INFINITY,V;for(const Y of F.ids){const K=m.get(Y);if(!K)continue;const ne=$n(K,t);W=Math.min(W,ne.top),ne.rot!==void 0&&(V={el:K,rot:ne.rot})}V&&I(V.el,V.rot,-W);for(const Y of F.ids)w.push({elementId:Y,type:"element",renderTop:m.get(Y)?.options?.top??0})}else{const W=$n(R,t);W.rot!==void 0&&I(R,W.rot,-W.top),w.push({elementId:R.id,type:"element",renderTop:S(R)})}fe++;continue}rn(R)?fe=ye(R,t,fe):F?fe=Xe(F,fe):fe=de(R,t,d,fe)}return w.length>0&&x(),v.length===0&&v.push({pageIndex:0,sections:[]}),G(),v;function G(){if(l)return;const R=e.margins.left;for(const F of v){const W=[];for(const V of F.sections){if(V.type==="flow-group")continue;const Y=m.get(V.elementId);if(!Y)continue;const{left:K,width:ne}=bh(Y,t),Q=R+K,se=Q+ne-n.width,he=-Q;se>.01?W.push(`元素 ${Y.id} 超出纸面右侧 ${Math.round(se*100)/100}mm,打印将被裁切`):he>.01&&W.push(`元素 ${Y.id} 超出纸面左侧 ${Math.round(he*100)/100}mm,打印将被裁切`)}W.length>0&&(F.warnings=[...F.warnings??[],...W])}}function de(R,F,W,V){const Y=on(R),K=$n(R,F),ne=K.height,Q=()=>{const se=S(R,Y),he=M?se+K.shift:se,_e=he-(R.options?.top??0);j(K.top+_e+K.height),K.rot!==void 0&&!M&&I(R,K.rot,-K.top),w.push({elementId:R.id,type:"element",renderTop:he}),k(Y,ne)};if(ne<=P(Y)){if(Q(),Mr(R)?.keepWithNext&&V+1<W.length){const se=W[V+1],he=$n(se,F).height;if(ne+he>N())return V+1;he>P(Y)&&(w.pop(),_.pop(),te(),Q())}return V+1}return te(),Q(),V+1}function Xe(R,F){const W=R.ids.map(_e=>m.get(_e)).filter(_e=>!!_e);let V=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,K;for(const _e of W){const X=$n(_e,t);V=Math.min(V,X.top),Y=Math.max(Y,X.top+X.height),X.rot!==void 0&&(K={el:_e,rot:X.rot})}const ne=Math.max(Y-V,0),Q=R.band,se=()=>{const _e=M?C(Q)-V:0;j(V+_e+ne),K&&!M&&I(K.el,K.rot,-V);for(const X of W)w.push({elementId:X.id,type:"element",renderTop:(X.options?.top??0)+_e});k(Q,ne)};return ne<=P(Q)?(se(),F+1):(te((M?0:V)+ne>c),se(),F+1)}function ye(R,F,W){const V=R.options??{},Y=V._renderRows??[],K=F.get(R.id)?.measuredRowHeights??[],ne=(V._subtotalTemplates?.length??0)>0,Q=(V._summaryRows?.length??0)>0,se=ne?fl(Y,K,"subtotal"):0,he=Q?fl(Y,K,"summary"):0,_e=pe=>ne&&pe.type==="subtotal"||Q&&pe.type==="summary",X=Y.filter(pe=>!_e(pe)),vt=K.filter((pe,ve)=>!_e(Y[ve]));V._renderRows=X;const ee=Math.min(X.length,vt.length),lt=V._repeatHeaderCount??0,Me=F.get(R.id)?.repeatHeaderHeight??K.slice(0,lt).reduce((pe,ve)=>pe+ve,0),Ae=N(),Ee=on(R);if(Me>Ae)throw new Error(`表格 ${R.id} 的重复表头高度 (${Me.toFixed(1)}mm) 超过页面可用高度 (${Ae.toFixed(1)}mm),请减少重复表头行`);if(ee===0)return w.push({elementId:R.id,type:"table-slice",startRow:0,endRow:0,summary:he>0,renderTop:S(R,Ee)}),k(Ee,he),Fe(R,F,Ee),W+1;const It=vt.slice(0,ee).reduce((pe,ve)=>pe+ve,0)+se+he;if(hh(R)?.enabled===!1)return It>P(Ee)&&w.length>0&&te(),w.push({elementId:R.id,type:"table-slice",startRow:0,endRow:ee,subtotal:se>0,summary:he>0,renderTop:S(R,Ee)}),k(Ee,It),Fe(R,F,Ee),W+1;const Pt=Eh(X,ee);let T=0,J=!0,ue=S(R,Ee),le=0;const ze=()=>P(Ee)-le,Dt=(pe,ve)=>{w.push({elementId:R.id,type:"table-slice",startRow:T,endRow:pe,subtotal:se>0,...!J&&ve?{repeatHeader:!0}:{},renderTop:ue}),k(Ee,le),le=0};for(const pe of Pt){const ve=vt.slice(pe.start,pe.end).reduce((mr,Rt)=>mr+Rt,0);if(ve+se<=ze()){le+=ve;continue}pe.start>T&&(Dt(pe.start,lt>0),J=!1,T=pe.start),te(),ue=S(R,Ee),le=0,J||(le+=Me),le+=ve}if(T<ee&&Dt(ee,lt>0),he>0)if(he<=ze()){const pe=w.length-1,ve=w[pe];ve&&ve.type==="table-slice"&&ve.elementId===R.id?(w[pe]={...ve,summary:!0},k(Ee,he)):(te(),w.push({elementId:R.id,type:"table-slice",startRow:ee,endRow:ee,summary:!0,renderTop:0}),k(Ee,he))}else te(),w.push({elementId:R.id,type:"table-slice",startRow:ee,endRow:ee,summary:!0,renderTop:0}),k(Ee,he);return Fe(R,F,Ee),W+1}function Fe(R,F,W){const V=f.get(R.id)??[];if(V.length===0)return;const Y=yh(R,V,e),K=R.options??{};if(Y<=P(W)){const ne=w.length-1,Q=w[ne];if(Q&&Q.type==="table-slice"&&Q.elementId===R.id){w[ne]={...Q,type:"flow-group",followElementIds:V,groupTop:Q.renderTop??K.top??0},k(W,Y);return}}te(),w.push({elementId:R.id,type:"flow-group",startRow:0,endRow:0,followElementIds:V,groupTop:0}),k(W,Y)}}function Eh(e,t){const n=[];let r=0,o=1;for(let i=0;i<t;i++){for(const a of e[i]?.cells??[])!a.merged&&(a.rowspan??1)>1&&(o=Math.max(o,i+a.rowspan));i+1>=o&&(n.push({start:r,end:i+1}),r=i+1,o=r+1)}return n}function fl(e,t,n){let r=0;for(let o=0;o<e.length;o++)e[o]?.type===n&&(r+=t[o]??0);return r}const Tr=25,hl=5;function Sh(e){return Math.max(Tr,e)}function gl(e,t,n=1.1){const r=t>0?e*n:e/n;return Sh(Math.round(r))}function _h(e,t,n,r,o=.9){if(n<=0||r<=0)return 100;const i=Math.min(e/n,t/r)*o,a=Math.round(i*100);return Math.max(hl,a)}const Mh=2;function ml(e){const t=e.gap??Mh,n=[...e.units].sort((i,a)=>i.order-a.order);if(e.available<=0)return{movedIds:[],overflowRemains:!1};if(n.some(i=>i.width<=0))return{movedIds:[],overflowRemains:!1};const r=i=>{const a=n.filter(c=>!i.has(c.id));return e.pinned+a.reduce((c,s)=>c+s.width+t,0)+(i.size>0?e.moreTriggerWidth+t:0)<=e.available};if(r(new Set))return{movedIds:[],overflowRemains:!1};const o=new Set;for(const i of n)if(o.add(i.id),r(o))return{movedIds:[...o],overflowRemains:!1};return{movedIds:[...o],overflowRemains:!0}}function Th(e){const t=e.gap??4,n=e.boundaryBottom-e.triggerBottom-t,r=e.triggerTop-e.boundaryTop-t;return n>=e.overlayHeight?"down":r>n?"up":"down"}function kh(){let e=0;return function(){return e+=1,`cell-${Date.now().toString(36)}-${e}`}}function Ch(){let e=0;return function(){return e+=1,`row-${Date.now().toString(36)}-${e}`}}const Ah=kh(),Oh=Ch(),St={width:.75,style:"solid",color:"#333333"};function vi(e){return JSON.parse(JSON.stringify(e))}function wi(e){return{id:Ah(),borders:{top:{...St},right:{...St},bottom:{...St},left:{...St}},...e}}function Ih(){const e=[50,50,50],t=(r,o)=>({id:Oh(),type:r,height:8,...o!==void 0?{repeatOnPage:o}:{},cells:e.map(()=>wi())}),n=t("header",!0);return n.cells.forEach((r,o)=>{r.formatter=`列${o+1}`,r.align="center",r.fontWeight="bold"}),{rows:[n,t("data"),t("subtotal"),t("summary")],colWidths:e}}function xi(e,t,n){if(!e[t].cells[n].merged)return{r:t,c:n};for(let r=t;r>=0;r--)for(let o=n;o>=0;o--){const i=e[r].cells[o];if(i.merged)continue;const a=i.rowspan??1,l=i.colspan??1;if(r+a-1>=t&&o+l-1>=n)return{r,c:o}}return{r:t,c:n}}function Ft(e,t,n){const r=xi(e,t,n),o=e[r.r].cells[r.c];return{r1:r.r,c1:r.c,r2:r.r+(o.rowspan??1)-1,c2:r.c+(o.colspan??1)-1}}function bl(e,t,n){let r={r1:Math.min(t.r,n.r),c1:Math.min(t.c,n.c),r2:Math.max(t.r,n.r),c2:Math.max(t.c,n.c)};for(;;){let o=!1;for(let i=r.r1;i<=r.r2;i++)for(let a=r.c1;a<=r.c2;a++){const l=Ft(e,i,a),c={r1:Math.min(r.r1,l.r1),c1:Math.min(r.c1,l.c1),r2:Math.max(r.r2,l.r2),c2:Math.max(r.c2,l.c2)};(c.r1!==r.r1||c.c1!==r.c1||c.r2!==r.r2||c.c2!==r.c2)&&(r=c,o=!0)}if(!o)return r}}function yl(e,t){if((t.r2-t.r1+1)*(t.c2-t.c1+1)<2)return"至少选择 2 个单元格";const r=new Set;for(let i=t.r1;i<=t.r2;i++)r.add(e[i].type);if(r.size>1)return"合并区域不能跨越不同类型的行";const o=bl(e,{r:t.r1,c:t.c1},{r:t.r2,c:t.c2});return o.r1!==t.r1||o.c1!==t.c1||o.r2!==t.r2||o.c2!==t.c2?"选区与已有合并区域部分重叠":null}function vl(e,t){const n=e[t.r1].cells[t.c1],r=[];for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=e[o].cells[i];a.formatter&&r.push(a.formatter),!(o===t.r1&&i===t.c1)&&(a.merged=!0,a.rowspan=1,a.colspan=1,a.formatter="")}n.rowspan=t.r2-t.r1+1,n.colspan=t.c2-t.c1+1,n.formatter=r.join(" ")}function wl(e,t){for(let n=t.r1;n<=t.r2;n++)for(let r=t.c1;r<=t.c2;r++){const o=e[n].cells[r];if(!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1)){const i=Ft(e,n,r),a=o;for(let l=i.r1;l<=i.r2;l++)for(let c=i.c1;c<=i.c2;c++){const s=e[l].cells[c];s.merged=!1,s.rowspan=1,s.colspan=1,Ph(a,s)}o.rowspan=1,o.colspan=1}}}function Ph(e,t){e!==t&&(t.align=e.align,t.valign=e.valign,t.fontSize=e.fontSize,t.fontFamily=e.fontFamily,t.fontWeight=e.fontWeight,t.color=e.color,t.backgroundColor=e.backgroundColor,t.borders=e.borders?vi(e.borders):void 0,t.padding=e.padding,t.wordWrap=e.wordWrap)}function xl(e,t,n){const r=n==="above"?t:t+1,o=e[t],i=o.cells.length,a=o.type==="data"?"header":o.type,l={id:`row-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,type:a,height:o.height,...a==="header"?{repeatOnPage:[e[r-1],e[r]].find(c=>c?.type==="header")?.repeatOnPage===!0}:{},cells:Array.from({length:i},()=>wi())};for(let c=0;c<i;c++)if(r>0&&r<e.length){const s=Ft(e,r-1,c);if(s.r1<r&&s.r2>=r){const d=e[s.r1].cells[s.c1];d.rowspan=(d.rowspan??1)+1,l.cells[c].merged=!0}}e.splice(r,0,l)}function Dh(e,t){if(e.length<=1)return"不能删除最后一行";const n=e[t],r=n.cells.length;for(let o=0;o<r;o++){const i=n.cells[o];if(!i.merged&&(i.rowspan??1)>1){const a=e[t+1].cells[o];Object.assign(a,vi(i),{id:a.id}),a.rowspan=(i.rowspan??1)-1,a.merged=!1}else if(i.merged){const a=Ft(e,t,o);if(a.r1<t&&a.c1===o){const l=e[a.r1].cells[a.c1];l.rowspan=(l.rowspan??1)-1}}}return e.splice(t,1),null}function El(e,t,n,r){const o=r==="left"?n:n+1;t.splice(o,0,t[n]);for(const i of e){const a=wi();if(o>0&&o<i.cells.length){const l=e.indexOf(i),c=Ft(e,l,o-1);if(c.c1<o&&c.c2>=o){const s=e[c.r1].cells[c.c1];l===c.r1&&(s.colspan=(s.colspan??1)+1),a.merged=!0}}i.cells.splice(o,0,a)}}function Rh(e,t,n){if(t.length<=1)return"不能删除最后一列";for(let r=0;r<e.length;r++){const o=e[r].cells[n];if(!o.merged&&(o.colspan??1)>1){const i=e[r].cells[n+1];Object.assign(i,vi(o),{id:i.id}),i.colspan=(o.colspan??1)-1,i.merged=!1}else if(o.merged){const i=Ft(e,r,n);if(i.c1<n&&i.r1===r){const a=e[i.r1].cells[i.c1];a.colspan=(a.colspan??1)-1}}}for(const r of e)r.cells.splice(n,1);return t.splice(n,1),null}function Ei(e,t,n){if(n==="data"){const r=e.findIndex((o,i)=>o.type==="data"&&i!==t);if(r>=0)return`数据行已存在(第 ${r+1} 行),全表最多一行`}if(n==="header"){for(let r=0;r<t;r++)if(e[r].type!=="header")return"标题行必须从表格顶部连续设置"}if(n==="subtotal"||n==="summary"){const r=e.findIndex(o=>o.type==="data");if(r<0)return"请先设置数据行,小计/汇总行必须位于数据行之后";if(t<r)return"小计/汇总行必须位于数据行之后"}if(n==="subtotal"&&e.slice(0,t).some(r=>r.type==="summary"))return"小计行必须位于汇总行之前";if(n==="summary"&&e.slice(t+1).some(r=>r.type==="subtotal"))return"汇总行必须位于小计行之后";if(e[t].type==="header"&&n!=="header"){for(let r=t+1;r<e.length;r++)if(e[r].type==="header")return"取消该标题行会导致标题行不连续,请先调整后续标题行"}if(e[t].type=n,n==="header"){const r=[e[t-1],e[t+1]].find(o=>o?.type==="header");e[t].repeatOnPage=e[t].repeatOnPage!==void 0?e[t].repeatOnPage===!0:r?.repeatOnPage===!0}else delete e[t].repeatOnPage;return null}function $h(e,t){for(const n of e){if(n.type!=="header")break;n.repeatOnPage=t}}function Sl(e,t,n,r){for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=e[o].cells[i];if(a.merged)continue;if(n==="none"){delete a.borders;continue}const l=Ft(e,o,i),c=l.r1===t.r1,s=l.r2===t.r2,d=l.c1===t.c1,p=l.c2===t.c2,u={...a.borders??{}};n==="all"?(u.top={...r},u.bottom={...r},u.left={...r},u.right={...r}):n==="outer"?(c&&(u.top={...r}),s&&(u.bottom={...r}),d&&(u.left={...r}),p&&(u.right={...r})):n==="inner"&&(c||(u.top={...r}),s||(u.bottom={...r}),d||(u.left={...r}),p||(u.right={...r})),a.borders=u}}const Lh="线型 / 宽度 / 颜色是待应用规格:选中格已有的边框规格一致时会填进这三行;四边不一致的项显示「混合」,一条边都没有时显示「无 / 0」。改完点「全部 / 外侧 / 内部」或勾选上、下、左、右某条边才会写入选中的单元格;「无」是清除边框",Nh="多选时不回显单格边框:线型 / 宽度 / 颜色按当前设置作为批写规格,点「全部 / 外侧 / 内部」或勾选某条边后写入所有选中格;「无」是清除边框",Fh="当前单元格四边边框规格不一致:带「混合」的项不谎报,未改项在点「全部 / 外侧 / 内部」或勾选单边时按缺省档(实线 0.75pt)写入,改任一项即按该值批写";function _l(e,t,n){const r={...e.borders??{}};n?r[t]={...n}:delete r[t],e.borders=r.top||r.right||r.bottom||r.left?r:void 0}function kr(e,t){const n=[];for(let r=t.r1;r<=t.r2;r++)for(let o=t.c1;o<=t.c2;o++){const i=e[r]?.cells[o];i&&!i.merged&&n.push(i)}return n}function Si(e,t){const n=kr(e,t).length;return{mode:n>1?"multi":"single",count:n}}function zh(e,t){const n=kr(e,t);if(!n.length)return null;const r=n[0].cellType??"text";return n.every(o=>(o.cellType??"text")===r)?r:null}function Ml(e,t){const n=[];for(const o of kr(e,t))for(const i of["top","right","bottom","left"]){const a=o.borders?.[i];a&&n.push(a)}const r=o=>{if(!n.length)return;const i=o(n[0]);return n.every(a=>o(a)===i)?i:"mixed"};return{width:r(o=>o.width),style:r(o=>o.style),color:r(o=>o.color)}}const Bh="1px dashed rgba(0,0,0,0.18)";function Cr(e,t={}){return e&&e.style!=="none"?`${e.width}pt ${e.style} ${e.color}`:t.designMode&&t.showGhostBorder!==!1?Bh:"none"}function Ln(e){const t=(e.tableColWidths??[]).reduce((r,o)=>r+o,0),n=(e.tableRows??[]).reduce((r,o)=>r+o.height,0);e.width=Math.round(t*100)/100,e.height=Math.round(n*100)/100}const Tl=5;function Hh(e,t,n,r){const o=e.reduce((l,c,s)=>s===t?l:l+c,0),i=r===1/0?1/0:Math.max(Tl,r-o),a=Math.round(n*10)/10;return Math.min(Math.max(a,Tl),i)}const Uh=["html"];function qh(e){return!!e&&Uh.includes(e)}function an(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function _i(e){const t={left:7,top:17.6,width:42.3,height:7.1};switch(e){case"text":return{...t,formatter:"文本",fontSize:12,textAlign:"left",height:5.3};case"image":return{...t,width:28.2,height:28.2,fit:"contain"};case"longText":return{...t,width:141.1,height:28.2,fontSize:12,lineHeight:18};case"table":{const{rows:n,colWidths:r}=Ih(),o=r.reduce((a,l)=>a+l,0),i=n.reduce((a,l)=>a+l.height,0);return{...t,width:o,height:i,tableMode:"dynamic",tableRows:n,tableColWidths:r,tableDefaultFontSize:10,tableDefaultColor:"#333333",tableDefaultPadding:1,fields:[],tablePagination:{enabled:!0}}}case"flowList":return{...t,width:141.1,height:21.2,fontSize:12,formatter:"{name} {spec}",flowColumns:4,flowRowHeight:8,flowGapX:4,flowAutoSpan:!1,flowMaxSpan:2};case"hline":return{...t,width:70.6,height:1.8,borderWidth:.75};case"vline":return{...t,width:1.8,height:35.3,borderWidth:.75};case"rect":return{...t,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"oval":return{...t,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"barcode":return{...t,width:56.4,height:14.1,title:"条形码",barcodeType:"code128",testData:"12345678"};case"qrcode":return{...t,width:28.2,height:28.2,title:"二维码",testData:"qrcode"};case"html":return{...t,width:28.2,height:28.2};default:return t}}function Mi(e,t){const n={text:{title:"文本"},image:{title:"图片"},longText:{title:"长文"},table:{title:"表格"},flowList:{title:"流式列表"},hline:{title:"横线"},vline:{title:"竖线"},rect:{title:"矩形"},oval:{title:"椭圆"},barcode:{title:"条形码"},qrcode:{title:"二维码"},html:{title:"HTML"},pageNumber:{title:"页码"}};return{id:an(),options:{..._i(e),...t},printElementType:{type:e,title:n[e]?.title||e}}}const Wh=["left","top","width","height"];function jh(e){return e.type??e.printElementType?.type}function Gh(e){const t=n=>(n??[]).filter(r=>!qh(jh(r)));return{...e,elements:t(e.elements),header:e.header?{...e.header,elements:t(e.header.elements)}:e.header,footer:e.footer?{...e.footer,elements:t(e.footer.elements)}:e.footer}}function Yh(e){const t={...e.options};for(const n of Wh){const r=t[n];typeof r=="number"&&Number.isFinite(r)&&(t[n]=Vh(wt(r)))}return{...e,options:t}}function Vh(e){return Math.round(e*100)/100}function Kh(e){const t={...e};delete t.firstPageOverlay;const n=Gh(t);if(n.unit==="mm")return n;const r=n,o=i=>i?.map(Yh)??[];return{...r,unit:"mm",elements:o(r.elements),header:r.header?{...r.header,elements:o(r.header.elements)}:r.header,footer:r.footer?{...r.footer,elements:o(r.footer.elements)}:r.footer}}const Ti="标签纸",nt={A4:{width:210,height:297,label:"A4 210×297mm",group:"常用纸张"},A3:{width:297,height:420,label:"A3 297×420mm",group:"常用纸张"},A5:{width:148,height:210,label:"A5 148×210mm",group:"常用纸张"},Letter:{width:216,height:279,label:"Letter 216×279mm",group:"常用纸张"},Legal:{width:216,height:356,label:"Legal 216×356mm",group:"常用纸张"},DOT_FULL:{width:241,height:279.4,label:"全等分 241×279.4mm",group:"针式打印纸"},DOT_HALF:{width:241,height:139.7,label:"二等分 241×139.7mm",group:"针式打印纸"},DOT_THIRD:{width:241,height:93.1,label:"三等分 241×93.1mm",group:"针式打印纸"},LABEL_80X60:{width:80,height:60,label:"80×60mm",group:Ti},LABEL_60X40:{width:60,height:40,label:"60×40mm",group:Ti},LABEL_40X30:{width:40,height:30,label:"40×30mm",group:Ti},THERMAL_57:{width:57,height:297,continuous:!0,label:"57mm",group:"小票纸"},THERMAL_80:{width:80,height:297,continuous:!0,label:"80mm",group:"小票纸"},THERMAL_110:{width:110,height:297,continuous:!0,label:"110mm",group:"小票纸"},CONTINUOUS:{width:80,height:297,continuous:!0,label:"连续纸(自定义宽度)",group:"连续纸"}};function ki(e){return!!e&&nt[e]?.continuous===!0}function _t(e){const t=ki(e.paperSize);let n;if(e.paperSize==="CUSTOM"||t){const r=nt[e.paperSize];n={width:e.customWidth??r?.width??210,height:e.customHeight??r?.height??297}}else{const r=nt[e.paperSize]||nt.A4;n={width:r.width,height:r.height}}return e.orientation==="landscape"&&!t?{width:n.height,height:n.width}:n}const Ci=.75,Xh="线型 / 宽度 / 颜色即时生效,这三行显示的就是当前生效规格:已有边框时任改一行都会按新规格铺满四边并清掉单边覆盖;上、下、左、右只给选中的边加框,撤掉一边会把它其余三边落成单边;「无」清除边框,「内部」仅表格单元格可用",Nn=["top","right","bottom","left"];function kl(e){const t={};for(const n of Nn){const r=e.map(o=>!!o?.[n]);t[n]=r.length>0&&r.every(Boolean)?"on":r.some(Boolean)?"mixed":"off"}return t}const Ai=[{value:"none",label:"无"},{value:"solid",label:"实线"},{value:"dashed",label:"虚线"},{value:"dotted",label:"点线"},{value:"double",label:"双线"}],Zh=new Set(["solid","dashed","dotted","double"]),sn="none";function Fn(e,t){const n=e.borders?.[t];if(n&&n.style!==sn&&typeof n.width=="number"&&Number.isFinite(n.width)&&n.width>0)return!0;const r=e.borderWidth;return e.borderStyle!==sn&&typeof r=="number"&&Number.isFinite(r)&&r>0}function Jh(e){const t={};for(const n of Nn)Fn(e,n)&&(t[n]=e.borders?.[n]??{width:e.borderWidth});return t}function Qh(e){const t=e.borderWidth;return{width:typeof t=="number"&&Number.isFinite(t)&&t>0?t:Ci,style:e.borderStyle||"solid",color:e.borderColor||"#333333"}}function Cl(e,t,n){if(t!=="inner"){if(e.borders=void 0,t==="none"){e.borderWidth=0;return}e.borderWidth=n.width,e.borderStyle=n.style,e.borderColor=n.color}}function Al(e){return Nn.some(t=>Fn(e,t))}function Oi(e,t){if(!e.length)return;const n=e[0]?.[t];return e.every(r=>r[t]===n)?n:"mixed"}function eg(e){if(!e)return;const t=typeof e.style=="string"&&Zh.has(e.style)?e.style:"solid";return{width:e.width,style:e.style===void 0?void 0:t,color:e.color}}function tg(e){const t=Nn.map(r=>e.borders?.[r]).filter(r=>typeof r?.width=="number"&&Number.isFinite(r.width)&&r.width>0).map(r=>eg(r));if(!t.length)return;const n=Oi(t,"style");return{width:Oi(t,"width"),style:n===void 0?"solid":n,color:Oi(t,"color")}}function Ol(e){const t=e.borderWidth,n=typeof t=="number"&&Number.isFinite(t),r=tg(e),o=n&&t>0;if(r&&!o)return r;const i=o?e.borderStyle||"solid":sn;return n?{width:t,style:i,color:e.borderColor}:{width:void 0,style:i,color:void 0}}function Il(e){const t=Ol(e);return{width:typeof t.width=="number"&&t.width>0?t.width:Ci,style:typeof t.style=="string"&&t.style!==sn?t.style:"solid",color:typeof t.color=="string"?t.color:"#333333"}}function ng(e,t){e.borderWidth=t.width,e.borderStyle=t.style,e.borderColor=t.color,e.borders=void 0}function rg(e,t,n){if(t==="borderStyle"&&n===sn){const r=Al(e);e.borderStyle=sn,r&&(e.borderWidth=0,e.borders=void 0);return}if(!Al(e)){if(t==="borderStyle"){e.borderStyle=n,e.borderWidth=Ci;return}Object.assign(e,{[t]:n});return}if(t==="borderWidth"&&(typeof n!="number"||!(n>0))){e.borderWidth=typeof n=="number"&&n<0?0:n,e.borders=void 0;return}ng(e,Qh({...e,[t]:n}))}function Ii(e,t,n,r){if(n!==Fn(e,t)){if(!n){const o=e.borderWidth;if(typeof o!="number"||!(o>0)){Pl(e,t,null);return}const i={};for(const a of Nn){if(a===t)continue;const l=e.borders?.[a];i[a]={width:l?.width??o,...l?.style!==void 0?{style:l.style}:e.borderStyle!==void 0?{style:e.borderStyle}:{},...l?.color!==void 0?{color:l.color}:e.borderColor!==void 0?{color:e.borderColor}:{}}}e.borders=i,e.borderWidth=0;return}Pl(e,t,r??Il(e))}}function Pl(e,t,n){const r={...e.borders??{}};n?r[t]={width:n.width,style:n.style,color:n.color}:delete r[t],e.borders=r}const Dl=96/25.4,Rl=1,og=8,ig=210;function Pi(e,t){if(!e||typeof e!="object")return;if(Array.isArray(e)){for(const r of e)Pi(r,t);return}const n=e;typeof n.printerDpi=="number"&&n.printerDpi>0&&t.add(n.printerDpi);for(const r of Object.keys(n)){if(r==="printerDpi")continue;const o=n[r];o&&typeof o=="object"&&Pi(o,t)}}function ag(e){if(!e)return null;const t=new Set;return Pi(e,t),t.size?Math.max(...t):null}function sg(e){const t=e?.pages?.[0]??e;return t?_t(t).width*Dl:ig*Dl}function lg(e,t){return e<=0||t<=0?Rl:Math.min(og,Math.max(Rl,Math.floor(e/t)))}function cg(e,t,n){const r=[];return e&&r.push({key:"dots",value:e/96,label:`点阵 ${e}dpi`,tip:`1 屏幕像素 = 1 个打印点(${e}dpi ÷ 96dpi)。条与间隙按纸面逐点显示,不会在屏幕上糊成一片`}),r.push({key:"fit",value:lg(t,n),label:"适配",tip:"按容器宽放大到放得下整页的最大整数倍"},{key:"100",value:1,label:"100%",tip:"按 CSS 真实尺寸显示(1mm = 3.78 屏幕像素),热敏点距在此档不可分辨"},{key:"200",value:2,label:"200%",tip:"整数倍放大,避免非整数缩放带来的半像素边"},{key:"400",value:4,label:"400%",tip:"整数倍放大,避免非整数缩放带来的半像素边"}),r}function $l(e){return"100"}function dg(e,t){return!e||t==="dots"?"":`条码看不清?切「点阵 ${e}dpi」档(1 屏幕像素 = 1 打印点)`}const Ll="print-preview-zoom-guard";function ug(e,t){if(!e?.documentElement)return;let n=e.getElementById(Ll);n||(n=e.createElement("style"),n.id=Ll,(e.head??e.documentElement).appendChild(n)),n.textContent=`html{zoom:${t}}@media print{html{zoom:1 !important}}`}function pg(e,t,n){return e.some(r=>r.key===t)?t:$l()}function fg(e,t){return e.find(n=>n.key===t)?.value??1}const Nl=["text","image","hline","vline","rect","oval","barcode","qrcode"];function hg(e){return _t(e)}function Di(e){const t=hg(e),n=e.margins,r=e.header.height,o=e.footer.height,i=t.width-n.left-n.right,a=t.height-n.top-n.bottom-r-o,l=(c,s,d,p)=>({left:c,top:s,width:d,height:p});return{header:l(n.left,n.top,i,r),content:l(n.left,n.top+r,i,a),footer:l(n.left,t.height-n.bottom-o,i,o)}}function Fl(e,t,n){const r=Di(e);return r.footer.height>0&&n>=r.footer.top?"footer":r.header.height>0&&n<r.header.top+r.header.height?"header":"content"}function Ri(e,t){const n=e.options;n.width=Math.min(n.width,t.width),n.height=Math.min(n.height,t.height),n.left=Math.min(Math.max(0,n.left),t.width-n.width),n.top=Math.min(Math.max(0,n.top),t.height-n.height)}function gg(e,t){const n=Di(t),r=e.zone||"content",o=n[r],i=o.left+e.options.left+e.options.width/2,a=o.top+e.options.top+e.options.height/2;let l=Fl(t,i,a),c=!1;if(l!=="content"&&!Nl.includes(e.printElementType.type)&&(l="content",c=!0),l!==r){const s=n[l];e.options.left=o.left+e.options.left-s.left,e.options.top=o.top+e.options.top-s.top,e.zone=l}return l!=="content"?Ri(e,n[l]):c&&Ri(e,n.content),{rejected:c}}const $i=22,Li=[1,2,5,10,20,50,100,200,500,1e3];function mg(e,t=64){const n=e*3.7795275590551185;for(const r of Li)if(r*n>=t)return r;return Li[Li.length-1]}function bg(e){const t=Math.floor(Math.log10(e)+1e-9),n=e/10**t;return n===5||n===1&&e>=10?e/5:n===2?e/2:null}function yg(e){return Math.round(e*1e3)/1e3}function vg(e,t,n){if(t<e||n<=0)return[];const o=bg(n)??n,i=Math.ceil(e/o-1e-9)*o,a=Math.floor((t-i)/o+1e-9),l=[];for(let c=0;c<=a;c++){const s=yg(i+c*o);Math.abs(s/n-Math.round(s/n))<1e-6?l.push({mm:s,major:!0,label:String(s)}):l.push({mm:s,major:!1})}return l}const zl=["#000000","#333333","#666666","#999999","#cccccc","#ffffff","#e53935","#fb8c00","#1e88e5","#43a047","#8d6e63","#00acc1"],Ar=[{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-family",keywords:["字体","字体名","字体族","fontfamily"]},{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"]},{key:"ap-text-fit",keywords:["溢出","溢出显示","截断","自动缩小","自适应行高","textfit","overflow"]},{key:"ap-shrink-min",keywords:["最小字号","缩放下限","shrinkminfontsize"],default:Bs,defaultUnit:"pt"},{key:"ap-word-wrap",keywords:["自动换行","不换行","wordwrap"]},{key:"ap-keep-line-breaks",keywords:["保留换行符","换行符","手动换行","保留空格","连续空格","行首空格","keeplinebreaks"]},{key:"ap-long-text-indent",keywords:["首行缩进","缩进","indent","longtextindent","两字符","段首"],tip:"长文本每段首行空出的宽度,单位「字符」:填 2 即缩进两个汉字宽(中文排版惯例),按 em 落纸——字号被「自动缩小」压小时缩进同步变窄。仅长文本元素生效,写在普通文本上不生效"},{key:"ap-img-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover","填充","裁剪","剪裁","锚点"],tip:"图片在元素框内的缩放方式:包含=完整显示、可能留白;剪裁=铺满框并按「裁剪锚点」取一块;拉伸=填满框会变形;原始尺寸与缩小不放大。画布与三条出纸链路同一口径(缺省包含)"},{key:"ap-img-object-position",keywords:["裁剪锚点","剪裁锚点","锚点","objectposition","object-position","对齐点","上移","头顶"],tip:"取位(仅「剪裁」档有这一行):剪裁把图等比铺满元素框,多出来的那一条边按这里选的位置取舍。先选位置档(贴边/居中/贴另一头),再按百分比微调,0 贴左/贴顶,100 挪到另一头,水平与垂直各自独立;缺省取正中间(保住证件照头顶就选顶部)。其余缩放模式图比框小或刚好铺满,没有可裁的边,所以不出本行"},{key:"ap-img-fit-scale",keywords:["放大比例","剪裁放大","放大倍数","取景","裁切范围","fitscale","zoom"],default:Dn,defaultUnit:"%",tip:"剪裁放大:等比铺满之后把画面再推大这么多,两轴才真的各多出一条边可裁——图与框同比例时不放大就什么都裁不掉。100=不放大(缺省),上限 400;超出框的部分由元素框裁掉。锚点选中的那一点既是取位的钉住点、也是放大的中心,两者共用同一个值。仅「剪裁」档生效,其余缩放模式不出本行"},{key:"ap-rotate",keywords:["旋转","角度","rotate","angle","顺时针","逆时针","90度","直角"],tip:"元素绕自身中心旋转的角度(度,0~359):出纸时按旋转后外接盒分页与结算,底部放不下自动移页,超出纸面左右缘或顶部会被裁切并给出纸提示。表格、流式列表与表格下方跟随区的元素不支持旋转(这三类不出本行);条码与二维码的任意角度需 385dpi 以上打印头,低分辨率打印机只按 90° 步进出纸"}]},{group:"flow-list",groupLabel:"流式列表",items:[{key:"fl-columns",keywords:["每行列数","列数","栏数","几列","flowcolumns"],tip:"一行排几个单元,必须由你指定——不随内容自动算列数。填的列数乘单元宽放不下元素框时只给提示、不改你的数,出纸按你填的排"},{key:"fl-row-height",keywords:["行高","每行高度","单元高度","flowrowheight"],tip:"每个单元行的最低高度(毫米),与表格行高同一口径:内容比它高时这一行会撑高,不会裁字"},{key:"fl-gap-x",keywords:["单元间距","横向间距","格间距","列间距","flowgapx"],tip:"相邻单元之间的横向留白(毫米);纵向不留缝,行与行的距离由行高承担"},{key:"fl-auto-span",keywords:["自适应","跨列","内容过长","占两列","自动换行","flowsautspan","flowautospan"],tip:"单元内容比一列还宽时,让它占掉两个或更多列位;当前行剩不够放就把整个单元挪到下一行行首(绝不把词切两半)。默认关——开着时出纸栏数由字号与框宽决定"},{key:"fl-max-span",keywords:["最多跨几列","跨列上限","flowmaxspan"],tip:"跨列的列数上限,最大只能等于「每行列数」:把每行列数改小时,这里会被一并顶回去"}]},{group:"code",groupLabel:"条码设置",items:[{key:"cd-type",keywords:["码制","条码类型","条形码类型","barcodetype","code128","ean13","code39","itf14"]},{key:"cd-dpi",keywords:["打印机分辨率","dpi","打印点","点阵对齐","203","300"]},{key:"cd-bar-width",keywords:["条宽","条粗细","barwidth","模块宽"]},{key:"cd-bar-quiet-zone",keywords:["条码静区","条码白边","条形码留白","条码空白边","barquietzone"],default:Ks,defaultUnit:"模块",tip:"条形码左右两端的空白格数(1 格 = 1 条宽):缺省 10,正是一维码码制要求的下限;数值越小白边越窄、同样的框内条越粗(可放大)。填 0 即不留白边,但静区参与「条→空→条」跳变,紧邻文字或表格线时可能扫不出,需实打验证"},{key:"cd-bar-height",keywords:["条高","条码高度","条区高度","条码多高","barheight"],default:Et,defaultUnit:"模块",tip:"黑白条本体的目标高度(mm,不含下方文字):折算粒度就是每模块物理宽,所以只能精确到它的整数倍。条宽优先——可用框高装不下时期望条高让位,绝不把条宽挤窄(热敏出纸清晰度靠条宽)。与「最大高度」分工不同:那条限的是整图(含文字)的上限"},{key:"cd-show-text",keywords:["显示文本","条码文本","显示数字"]},{key:"cd-font-size",keywords:["条码字号","文本字号"],default:Er,defaultUnit:"模块"},{key:"cd-ec-level",keywords:["纠错级别","容错","qrcodelevel"]},{key:"cd-quiet-zone",keywords:["静区","静区宽度","白边","空白边","留白","铺满","quietzone"],default:Xs,defaultUnit:"模块",tip:"二维码四周留出的空白格数:0 即不留白边、码面等比铺满元素框(此时靠框外的白纸充当静区);数值越大白边越宽、码面在框内越小(缺省 0,需 ISO/IEC 18004 推荐静区时填 4)"},{key:"cd-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover"]},{key:"cd-max-width",keywords:["最大宽度","最大宽","maxwidth"]},{key:"cd-max-height",keywords:["最大高度","最大高","maxheight"]}]},{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-style",keywords:["线型","边框线型","实线","虚线","点线","双线","borderstyle"]},{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 Oe(e){for(const t of Ar){const n=t.items.find(r=>r.key===e);if(n)return n.tip??""}return""}function wg(e,t){const n=e.trim().toLowerCase();return n?t.some(r=>r.toLowerCase().includes(n)):!0}function xg(e){const t=[],n=new Set;for(const r of Ar){const o=r.items.filter(i=>wg(e,[...i.keywords,r.groupLabel]));if(o.length>0){t.push(r.group);for(const i of o)n.add(i.key)}}return{groups:t,itemKeys:n}}function Eg(e){for(const t of Ar)for(const n of t.items)if(n.key===e&&n.default!==void 0)return{value:n.default,unit:n.defaultUnit}}const Sg=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),_g=new Set(["new","function","class","this","delete","typeof","void","in","of","var","let","const","return","if","while","for"]);function Ni(e){const t=[];let n=0;const r=e.length;for(;n<r;){const o=e[n];if(/\s/.test(o)){n++;continue}if(/[0-9]/.test(o)||o==="."&&n+1<r&&/[0-9]/.test(e[n+1])){let l=n;for(;l<r&&/[0-9.]/.test(e[l]);)l++;t.push({type:"num",value:e.slice(n,l),position:n}),n=l;continue}if(o==="'"||o==='"'){let l=n+1,c="";for(;l<r&&e[l]!==o;)e[l]==="\\"&&l+1<r?(c+=e[l+1],l+=2):(c+=e[l],l++);if(l>=r)throw new Error("字符串未闭合");t.push({type:"str",value:c,position:n}),n=l+1;continue}if(/[A-Za-z_$]/.test(o)){let l=n;for(;l<r&&/[A-Za-z0-9_$]/.test(e[l]);)l++;const c=e.slice(n,l);if(_g.has(c))throw new Error(`不允许使用关键字: ${c}`);if(Sg.has(c))throw new Error(`禁止访问: ${c}`);c==="true"||c==="false"?t.push({type:"bool",value:c,position:n}):t.push({type:"ident",value:c,position:n}),n=l;continue}const i=e.slice(n,n+3);if(i==="==="||i==="!=="){t.push({type:"punc",value:i,position:n}),n+=3;continue}const a=e.slice(n,n+2);if(a==="=>")throw new Error("不允许函数定义");if(["==","!=","<=",">=","&&","||"].includes(a)){t.push({type:"punc",value:a,position:n}),n+=2;continue}if(o==="=")throw new Error("不允许赋值");if(o===";")throw new Error("不允许多条语句");if("+-*/%()[]{},:.?!<>".includes(o)){t.push({type:"punc",value:o,position:n}),n++;continue}throw new Error(`非法字符: ${o}`)}return t}function Fi(e){return new Mg(e).parse()}class Mg{constructor(t){this.pos=0,this.tokens=t}parse(){const t=this.parseTernary();if(this.pos<this.tokens.length)throw new Error(`表达式存在多余内容: ${this.tokens[this.pos].value}`);return t}peek(){return this.tokens[this.pos]}next(){const t=this.tokens[this.pos++];if(!t)throw new Error("表达式意外结束");return t}eatPunc(t){const n=this.peek();return n&&n.type==="punc"&&n.value===t?(this.pos++,!0):!1}expectPunc(t){if(!this.eatPunc(t)){const n=this.peek()?.position??0;throw new Error(`位置 ${n}: 期望 "${t}"`)}}parseTernary(){const t=this.parseLogicalOr();if(this.eatPunc("?")){const n=this.parseTernary();this.expectPunc(":");const r=this.parseTernary();return{type:"ternary",cond:t,consequent:n,alternate:r}}return t}parseLogicalOr(){let t=this.parseLogicalAnd();for(;this.eatPunc("||");){const n=this.parseLogicalAnd();t={type:"binary",op:"||",left:t,right:n}}return t}parseLogicalAnd(){let t=this.parseEquality();for(;this.eatPunc("&&");){const n=this.parseEquality();t={type:"binary",op:"&&",left:t,right:n}}return t}parseEquality(){let t=this.parseRelational();for(;;){const n=this.peek();if(n?.type==="punc"&&["==","!=","===","!=="].includes(n.value)){this.pos++;const r=this.parseRelational();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseRelational(){let t=this.parseAdditive();for(;;){const n=this.peek();if(n?.type==="punc"&&["<",">","<=",">="].includes(n.value)){this.pos++;const r=this.parseAdditive();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseAdditive(){let t=this.parseMultiplicative();for(;;){const n=this.peek();if(n?.type==="punc"&&(n.value==="+"||n.value==="-")){this.pos++;const r=this.parseMultiplicative();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseMultiplicative(){let t=this.parseUnary();for(;;){const n=this.peek();if(n?.type==="punc"&&["*","/","%"].includes(n.value)){this.pos++;const r=this.parseUnary();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseUnary(){const t=this.peek();if(t?.type==="punc"&&["!","-","+"].includes(t.value)){this.pos++;const n=this.parseUnary();return{type:"unary",op:t.value,arg:n,prefix:!0}}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.eatPunc(".")){const n=this.next();if(n.type!=="ident")throw new Error(`位置 ${n.position}: 成员访问需要属性名`);t={type:"member",object:t,property:n.value,computed:!1}}else if(this.eatPunc("[")){const n=this.parseTernary();this.expectPunc("]"),n.type==="str"?t={type:"member",object:t,property:n.value,computed:!1}:t={type:"member",object:t,property:n.name??String(n.value),computed:!0}}else if(this.peek()?.type==="punc"&&this.peek()?.value==="("&&(t.type==="ident"||t.type==="member")){this.pos++;const n=this.parseArgs();t={type:"call",callee:t,args:n}}else return t}parseArgs(){const t=[];if(this.eatPunc(")"))return t;for(;;){if(t.push(this.parseTernary()),this.eatPunc(")"))return t;this.expectPunc(",")}}parsePrimary(){const t=this.next();if(t.type==="num"){const n=Number(t.value);if(isNaN(n))throw new Error(`非法数字: ${t.value}`);return{type:"num",value:n}}if(t.type==="str")return{type:"str",value:t.value};if(t.type==="bool")return{type:"bool",value:t.value==="true"};if(t.type==="ident")return{type:"ident",name:t.value};if(t.value==="("){const n=this.parseTernary();return this.expectPunc(")"),n}if(t.value==="["){const n=[];if(!this.eatPunc("]"))for(;n.push(this.parseTernary()),!this.eatPunc("]");)this.expectPunc(",");return{type:"array",elements:n}}if(t.value==="{"){const n=[];if(!this.eatPunc("}"))for(;;){const r=this.next();if(r.type!=="ident"&&r.type!=="str")throw new Error(`位置 ${r.position}: 对象键必须是标识符或字符串`);if(this.expectPunc(":"),n.push({key:r.value,value:this.parseTernary()}),this.eatPunc("}"))break;this.expectPunc(",")}return{type:"object",properties:n}}throw new Error(`位置 ${t.position}: 意外的符号: ${t.value}`)}}const Bl=20,Tg=8;function Ue(e,t=0){if(typeof e=="number")return Number.isFinite(e)?e:t;if(typeof e=="string"){const n=e.trim();if(n==="")return t;const r=Number(n);return Number.isFinite(r)?r:t}return e==null?t:typeof e=="boolean"?e?1:0:t}function kg(e){if(typeof e=="number")return Number.isFinite(e);if(typeof e=="string"){const t=e.trim();return t!==""&&Number.isFinite(Number(t))}return!1}function ln(e){return!Number.isFinite(e)||Number.isInteger(e)||Math.abs(e)>=1e15?e:Number(e.toPrecision(12))}function cn(e){if(!Number.isFinite(e)||Number.isInteger(e))return 0;const t=String(e);if(t.includes("e")||t.includes("E"))return 0;const n=t.indexOf(".");return n===-1?0:t.length-n-1}function zi(e,t){if(!Number.isFinite(e))return 0;const n=Math.min(Math.max(t,0),12);if(n===0)return Math.round(e);const r=10**n,o=e*r;return!Number.isFinite(o)||Math.abs(o)>=1e15?ln(e):Math.round(o)/r}function Bi(e,t){const n=Ue(e),r=Ue(t),o=n+r;return zi(o,Math.max(cn(n),cn(r)))}function Hi(e,t){const n=Ue(e),r=Ue(t),o=n-r;return zi(o,Math.max(cn(n),cn(r)))}function Hl(e,t){const n=Ue(e),r=Ue(t),o=n*r;return zi(o,cn(n)+cn(r))}function Ul(e,t){const n=Ue(e),r=Ue(t);return r===0?0:ln(n/r)}function Cg(e,t){const n=Ue(e),r=Ue(t);return r===0?0:ln(n%r)}function Ag(e){if(e==null)return 2;const t=Math.trunc(Ue(e,2));return Number.isFinite(t)?Math.min(Math.max(t,-Bl),Bl):2}function Or(e,t,n){const r=Ue(e,0),o=Ag(t);if(r===0)return 0;if(Math.abs(r)>=1e21)return ln(r);const i=Math.max(o,0)+Tg,a=r.toFixed(i);if(!/^-?\d+(\.\d+)?$/.test(a))return ln(r);const l=a.startsWith("-"),c=a.replace("-","").replace(".","");let s=BigInt(c||"0");l&&(s=-s);const d=10n**BigInt(i-o),p=s<0n?-1n:1n,u=s<0n?-s:s;let f=u/d;const g=u%d,m=2n*g;n==="up"?g!==0n&&(f+=1n):n!=="down"&&m>=d&&(m>d||n==="half-up"||f%2n===1n)&&(f+=1n);const y=p*f;return ln(o>=0?Number(y)/10**o:Number(y)*10**-o)}const Ui={Math,Number,String,Boolean,parseInt,parseFloat,isNaN,true:!0,false:!1,null:null,undefined:void 0},Og=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),Ig=new Set(["Number","String","Boolean","parseInt","parseFloat","isNaN"]);function Ie(e,t,n={}){switch(e.type){case"num":return e.value;case"str":return e.value;case"bool":return e.value;case"ident":return Pg(e.name,t);case"binary":return Dg(e,t,n);case"unary":return Rg(e,t,n);case"ternary":return Ie(e.cond,t,n)?Ie(e.consequent,t,n):Ie(e.alternate,t,n);case"member":return Ng(e,t,n);case"call":return Fg(e,t,n);case"array":return e.elements.map(r=>Ie(r,t,n));case"object":return Object.fromEntries(e.properties.map(r=>[r.key,Ie(r.value,t,n)]))}}function Pg(e,t,n){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];if(Object.prototype.hasOwnProperty.call(Ui,e))return Ui[e];throw new Error(`未定义的标识符: ${e}`)}function Dg(e,t,n){const r=Ie(e.left,t,n),o=Ie(e.right,t,n);switch(e.op){case"+":return Lg(r,o)?Bi(r,o):$g(r,o);case"-":return Hi(r,o);case"*":return Hl(r,o);case"/":return Ul(r,o);case"%":return Cg(r,o);case"<":return r<o;case">":return r>o;case"<=":return r<=o;case">=":return r>=o;case"==":return r==o;case"!=":return r!=o;case"===":return r===o;case"!==":return r!==o;case"&&":return r&&o;case"||":return r||o;default:throw new Error(`未知运算符: ${e.op}`)}}function Rg(e,t,n){const r=Ie(e.arg,t,n);switch(e.op){case"-":return Hi(0,r);case"+":return Ue(r);case"!":return!r;default:throw new Error(`未知一元运算符: ${e.op}`)}}function $g(e,t){return`${e==null?"":String(e)}${t==null?"":String(t)}`}function Lg(e,t){const n=ql(e),r=ql(t);return n==="other"||r==="other"?!1:n==="num"||r==="num"}function ql(e){return e==null||e===""?"neutral":kg(e)?"num":"other"}function Ng(e,t,n){const r=Ie(e.object,t,n);if(r==null)throw new Error("无法访问空值的属性");if(Og.has(e.property))throw new Error(`禁止访问属性: ${e.property}`);return r[e.property]}function Fg(e,t,n){if(e.callee.type==="ident"&&Ig.has(e.callee.name)){const o=Ui[e.callee.name],i=e.args.map(a=>Ie(a,t,n));return o(...i)}if(e.callee.type==="member"&&e.callee.object.type==="ident"&&e.callee.object.name==="Math"){const o=Math[e.callee.property];if(typeof o!="function")throw new Error(`Math.${e.callee.property} 不是方法`);const i=e.args.map(a=>Ie(a,t,n));return o(...i)}let r;if(e.callee.type==="ident")r=e.callee.name;else if(e.callee.type==="member")throw new Error("不支持方法调用,请使用顶级函数");if(r&&n[r]){const o=e.args.map(i=>Ie(i,t,n));return n[r](...o)}throw r&&Object.prototype.hasOwnProperty.call(t,r)?new Error(`${r} 不是函数`):new Error(`不允许调用: ${r??"表达式"}`)}function zg(e){const t=[];let n=0;const r=e.length;for(;n<r;){if(e[n]==="{"){let i=1,a=n+1;for(;a<r&&i>0;)e[a]==="{"?i++:e[a]==="}"&&i--,a++;if(i!==0)throw new Error(`位置 ${n}: 花括号未闭合`);const l=e.slice(n+1,a-1);if(l.trim()==="")throw new Error(`位置 ${n}: 空表达式`);const c=Ni(l),s=Fi(c);t.push({type:"expr",expression:s}),n=a;continue}let o=n;for(;o<r&&e[o]!=="{";)e[o]==="\\"&&o+1<r&&(e[o+1]==="{"||e[o+1]==="}")?o+=2:o++;t.push({type:"text",value:e.slice(n,o).replace(/\\([{}])/g,"$1")}),n=o}return{type:"template",parts:t}}function Bg(e,t,n={}){let r="";for(const o of e.parts)if(o.type==="text")r+=o.value;else{const i=Ie(o.expression,t,n);r+=String(i??"")}return r}function Wl(e,t={}){const n=zg(e);return r=>Bg(n,r,t)}function zn(e,t){if(e==null||t==null)return;if(typeof e=="object"&&t in e)return e[t];const n=t.split(".");let r=e;for(const o of n){if(r==null)return;r=r[o]}return r}function jl(e){const t=Number(e);if(isNaN(t))return String(e);const n=t<0?"-":"",r=Math.abs(t),[o,i]=r.toFixed(2).split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,",");return`${n}${a}.${i}`}function Gl(e,t){let n;if(e instanceof Date)n=e;else if(typeof e=="number")n=new Date(e);else if(typeof e=="string")n=new Date(e);else return String(e);if(isNaN(n.getTime()))return String(e);const r=o=>String(o).padStart(2,"0");return t.replace("YYYY",String(n.getFullYear())).replace("MM",r(n.getMonth()+1)).replace("DD",r(n.getDate())).replace("HH",r(n.getHours())).replace("mm",r(n.getMinutes())).replace("ss",r(n.getSeconds()))}const qi=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],Hg=["","拾","佰","仟"],Ug=["","万","亿","万亿","亿亿"];function qg(e){let t="",n=!1;for(let r=3;r>=0;r--){const o=Math.floor(e/10**r)%10;if(o===0){t&&(n=!0);continue}n&&(t+="零",n=!1),t+=qi[o]+Hg[r]}return t}function Yl(e){const t=Number(e);if(isNaN(t))return String(e);if(t===0)return"零元整";const n=t<0?"负":"",[r,o]=Math.abs(t).toFixed(2).split("."),i=Math.ceil(r.length/4);let a="",l=!1;for(let d=i-1;d>=0;d--){const p=r.length-d*4,u=parseInt(r.slice(Math.max(0,p-4),p),10);if(u===0){a&&(l=!0);continue}a&&(l||u<1e3)&&(a+="零"),l=!1,a+=qg(u)+(Ug[d]??"")}a=`${a||"零"}元`;const c=parseInt(o[0],10),s=parseInt(o[1],10);return c===0&&s===0?a+="整":(c===0?a+="零":a+=qi[c]+"角",s>0&&(a+=qi[s]+"分")),n+a}function Vl(e,t,n){return e?t:n}function Wi(e,t){return e.reduce((n,r)=>n+(Number(zn(r,t))||0),0)}function Kl(e,t){return e.length===0?0:Wi(e,t)/e.length}function Xl(e,t){return e.length}function Zl(e,t){return e.length===0?0:Math.min(...e.map(n=>Number(zn(n,t))||0))}function Jl(e,t){return e.length===0?0:Math.max(...e.map(n=>Number(zn(n,t))||0))}function Ql(...e){return e.reduce((t,n)=>Bi(t,n),0)}function ec(...e){return e.length===0?0:e.slice(1).reduce((t,n)=>Hi(t,n),Bi(e[0],0))}function tc(...e){return e.length===0?0:e.reduce((t,n)=>Hl(t,n),1)}function nc(e,t){return Ul(e,t)}function rc(e,t){return Or(e,t,"half-up")}function Ir(e,t){return Or(e,t,"up")}function Pr(e,t){return Or(e,t,"down")}function oc(e,t){return Or(e,t,"half-even")}class Wg{constructor(){this.functions={}}registerFunction(t,n){this.functions[t]=n}evaluate(t,n){const r=Ni(t),o=Fi(r);return Ie(o,n,this.functions)}render(t,n){return Wl(t,this.functions)(n)}}const ji=new Wg,jg={MONEY:jl,DATE:Gl,UPPER:Yl,IF:Vl,CONCAT:(...e)=>e.filter(t=>t!=null).map(String).join(""),IFEMPTY:(e,t)=>e!=null&&e!==""?String(e):t,LEN:e=>String(e).length,ADD:Ql,SUB:ec,MUL:tc,DIV:nc,ROUND:rc,ROUNDUP:Ir,CEIL:Ir,ROUNDDOWN:Pr,FLOOR:Pr,ROUNDBANK:oc};for(const[e,t]of Object.entries(jg))ji.registerFunction(e,t);function Gg(e,t,n){switch(e.toUpperCase()){case"SUM":return Wi(n,t);case"AVG":return Kl(n,t);case"COUNT":return Xl(n);case"MIN":return Zl(n,t);case"MAX":return Jl(n,t);default:return 0}}function Yg(e,t){return ji.evaluate(e,t)}function Mt(e,t){if(!e)return"";if(!e.includes("{"))return e;const n=Array.isArray(t.rows)?t.rows:[],r=e.replace(/\{([^}]+)\}/g,(o,i)=>{let a=i.trim();return a=a.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(l,c,s)=>{const d=s.trim().replace(/^['"]|['"]$/g,"");return String(Gg(c,d,n))}),`{${a}}`});try{return ji.render(r,t)}catch{return e}}function ic(e,t,n,r){const o={...$r(),...t??{}},i=JSON.parse(JSON.stringify(e));i.header?.elements&&(i.header.elements=i.header.elements.map(l=>Gi(l,o,n))),i.footer?.elements&&(i.footer.elements=i.footer.elements.map(l=>Gi(l,o,n))),i.elements=i.elements.map(l=>Gi(l,o,n));const a=r??n;if(a&&i.fonts?.length){const l=a.replace(/\/+$/,"");i.fonts=i.fonts.map(c=>({...c,files:(c.files??[]).map(s=>({...s,url:s.url?.startsWith("/")&&!s.url.startsWith("//")?l+s.url:s.url}))}))}return i}function Gi(e,t,n){const r={...e,options:{...e.options}};if(!(r.type==="flowList"||r.printElementType?.type==="flowList")&&typeof r.options.formatter=="string"){const a=r.options.formatter;Hn(a)?r.options.rawFormatter=a:r.options.formatter=Mt(a,t)}if((r.type==="image"||r.printElementType?.type==="image")&&typeof r.options.src=="string"){let a=r.options.src;a.includes("{")&&(a=Mt(a,t)),a&&n&&a.startsWith("/")&&(a=n.replace(/\/+$/,"")+a),r.options.src=a}return(r.type==="table"||r.printElementType?.type==="table")&&Kg(r,t),(r.type==="flowList"||r.printElementType?.type==="flowList")&&Vg(r,t),r}function Vg(e,t){const n=typeof e.options.formatter=="string"?e.options.formatter:"",r={...e.options,dataSource:e.options.dataSource??xr(n,t)},{list:o,key:i}=ac(r,t),a=c=>i?{...t,...c,[i]:c}:{...t,...c},l=o.map(c=>n?Hn(n)?n:Mt(n,a(c)):String(c??""));e.options._flowItems=l,e.options._flowRawFormatter=Hn(n)?n:void 0}function ac(e,t){const n=e.dataSource??e.fields?.[0]?.dataSource??e.fields?.[0]?.field;if(n&&Array.isArray(t[n]))return{list:t[n],key:n};for(const[r,o]of Object.entries(t))if(Array.isArray(o))return{list:o,key:r};return{list:[],key:n}}function Kg(e,t){const n=e.options,r=n.tableRows;if(!Array.isArray(r)||r.length===0)return;const o=n.tableMode??"dynamic",{list:i,key:a}=o==="dynamic"?ac(n,t):{list:[],key:void 0},l=g=>a?{...t,...g,[a]:g}:{...t,...g},c=a?i.map(g=>({...g,[a]:g})):i,s=[],d=[],p=[],u=[];let f=-1;for(const g of r){if(o==="dynamic"&&g.type==="data"){for(const m of i){f<0&&(f=s.length);const y=l(m);s.push(Rr(g,v=>Dr(v,y))),d.push(y)}continue}if(o==="dynamic"&&g.type==="subtotal"){const m=Rr(g,y=>Dr(y,{rows:c,...t}),!0);p.push(m),s.push(m);continue}if(o==="dynamic"&&g.type==="summary"){const m=Rr(g,y=>Dr(y,{rows:c,...t}));u.push(m),s.push(m);continue}s.push(Rr(g,m=>Dr(m,t)))}n._renderRows=s,n._repeatHeaderCount=Xg(r),n._dataRowCtx=d,n._dataStartIdx=f<0?s.length:f,n._subtotalTemplates=p,n._summaryRows=u,n._mainData=t}function Dr(e,t){const n=e.formatter;return n?Hn(n)?n:Mt(n,t):""}function Rr(e,t,n=!1){return{type:e.type,height:e.height??8,cells:e.cells.map(r=>({content:r.merged?"":t(r),...(n||Hn(r.formatter))&&!r.merged?{rawFormatter:r.formatter??""}:{},cellType:r.cellType,barcodeType:r.barcodeType,qrCodeLevel:r.qrCodeLevel,qrQuietZone:r.qrQuietZone,barQuietZone:r.barQuietZone,barHeight:r.barHeight,barWidth:r.barWidth,barFontSize:r.barFontSize,showBarcodeText:r.showBarcodeText,printerDpi:r.printerDpi,fit:r.fit,objectPosition:r.objectPosition,fitScale:r.fitScale,maxWidth:r.maxWidth,maxHeight:r.maxHeight,rowspan:r.rowspan??1,colspan:r.colspan??1,merged:r.merged===!0,align:r.align,valign:r.valign,fontSize:r.fontSize,fontFamily:r.fontFamily,fontWeight:r.fontWeight,color:r.color,backgroundColor:r.backgroundColor,borders:r.borders,padding:r.padding,wordWrap:r.wordWrap,textFit:r.textFit,shrinkMinFontSize:r.shrinkMinFontSize}))}}function Xg(e){const t=Zg(e);return t===0||!e.slice(0,t).some(r=>r.repeatOnPage===!0)?0:Qg(e,t)}function Zg(e){let t=0;for(const n of e){if(n?.type!=="header")break;t++}return t}function Jg(e,t){for(let n=0;n<t;n++)for(const r of e[n]?.cells??[])if(!r?.merged&&n+(r?.rowspan??1)>t)return!1;return!0}function Qg(e,t){for(let n=t;n>=1;n--)if(Jg(e,n))return n;return 1}const Bn=e=>String(e).padStart(2,"0");function $r(e=new Date,t={}){return{printDate:`${e.getFullYear()}-${Bn(e.getMonth()+1)}-${Bn(e.getDate())}`,printTime:`${Bn(e.getHours())}:${Bn(e.getMinutes())}:${Bn(e.getSeconds())}`,pageIndex:t.pageIndex??1,totalPages:t.totalPages??1}}function Hn(e){return typeof e=="string"&&/\b(pageIndex|totalPages)\b/.test(e)}function Yi(e,t=new Date){const{printDate:n,printTime:r}=$r(t);return e.replace(/\{printDate\}/g,n).replace(/\{printTime\}/g,r)}function Un(e){const t=[];for(const n of e??[]){const r=n?.family?.trim();if(!r)continue;const o=`"${r.replace(/"/g,"")}"`;for(const i of n.files??[]){const a=i?.url?.trim();if(!a)continue;const l=Number.isFinite(i.weight)?Number(i.weight):400,c=i.style==="italic"?"italic":"normal";t.push(`@font-face{font-family:${o};src:url("${a}")${em(a)};font-weight:${l};font-style:${c};font-display:block;}`)}}return t.length?`${t.join("")}
2
- `:""}function em(e){const t=e.split(/[?#]/)[0].toLowerCase();return t.endsWith(".woff2")?' format("woff2")':t.endsWith(".woff")?' format("woff")':t.endsWith(".ttf")?' format("truetype")':t.endsWith(".otf")?' format("opentype")':""}const Vi=['"Microsoft YaHei"','"PingFang SC"','"Helvetica Neue"',"Arial","sans-serif"];function Ki(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Xi(e){const t=e?.trim();return t?[t.includes(",")?t:`"${t.replace(/"/g,"")}"`,...Vi].join(", "):Vi.join(", ")}function Zi(e){return e?Xi(e):"inherit"}function tm(e){const t=[],n=new Set;for(const r of e??[]){const o=r?.family?.trim();if(!o)continue;const i=o.toLowerCase();if(n.has(i))continue;n.add(i);const a=r?.label?.trim();t.push(a?{family:o,label:a}:{family:o})}return t}function sc(e,t){const n=t?.trim().toLowerCase();if(n)return e.find(r=>r.family.trim().toLowerCase()===n)}function lc(e){return e.label?`${e.label}(${e.family})`:e.family}function qn(e){return e.toLowerCase().replace(/\s+/g,"")}function cc(e,t){if(e===t)return 0;if(e.startsWith(t))return 1;if(e.includes(t))return 2;let n=0;for(const r of e)if(r===t[n]&&n++,n===t.length)return 3;return-1}function nm(e,t){const n=cc(qn(e.family),t);if(!e.label)return n;const r=cc(qn(e.label),t);return n<0?r:r<0?n:Math.min(n,r)}function rm(e,t){const n=qn(t.trim());return n?e.map((r,o)=>({font:r,index:o,rank:nm(r,n)})).filter(r=>r.rank>=0).sort((r,o)=>r.rank-o.rank||r.index-o.index).map(r=>r.font):[...e]}function U(e){return`${e}mm`}function Ji(e,t){const n=nn(e);return t&&t>0&&tt(e)?{width:n.width,height:t}:n}function dc(e,t){const n=Ze(e);return t&&t>0&&tt(e)?{width:n.width,height:t}:n}function uc(){return`
1
+ (function(kt){typeof define=="function"&&define.amd?define(kt):kt()})((function(){"use strict";function kt(e){return e/2.83464566929}function Cr(e){return e*(25.4/96)}function zt(e){return e*(96/25.4)}const Ks=6,Zf=1,Jf=["clip","shrink","autoHeight"];function Zs(e){return typeof e=="string"&&Jf.includes(e)?e:void 0}const Qf={text:"clip",longText:"autoHeight",flowList:"clip"};function Ar(e,t){return Zs(t?.textFit)??Qf[e]??"clip"}function Js(e){if(e?.keepLineBreaks===!0&&e.wordWrap!==!1)return"pre-wrap"}function Qs(e){return e?.wordWrap===!1?"nowrap":void 0}function gi(e){return Zs(e?.textFit)??(e?.wordWrap===!1?"clip":"autoHeight")}function $n(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?Ks:Math.max(e,Zf)}function mi(e){return Math.round(e*100)/100}function eh(e){return Math.floor(e*100)/100}function th(e,t,n,r){return`${e}#${t}#${n}:${r}`}function nh(e){const t=e.indexOf("#");if(t<0)return;const n=e.lastIndexOf("#"),r=e.slice(t+1,n);if(r!=="b"&&r!=="st"&&r!=="sm")return;const[o,i]=e.slice(n+1).split(":").map(Number);if(!(!Number.isFinite(o)||!Number.isFinite(i)))return{elementId:e.slice(0,t),kind:r,rowIndex:o,colIndex:i}}function el(e,t){return(e||"contain")==="cover"?t:void 0}function bi(e,t,n,r=1){const o=Math.max(n?.colspan??1,1);let i=0;for(let c=0;c<o;c++)i+=e[t+c]??0;if(i<=0)return 0;const a=n?.padding??r,l=(kt(n?.borders?.left?.width??0)+kt(n?.borders?.right?.width??0))/2;return Math.max(i-a*2-l,.5)}function Ln(e,t,n,r=1){const o=Math.max(n?.rowspan??1,1);let i=0;for(let c=0;c<o;c++)i+=e[t+c]?.height??8;const a=n?.padding??r,l=(kt(n?.borders?.top?.width??0)+kt(n?.borders?.bottom?.width??0))/2;return Math.max(i-a*2-l,.5)}const yi=1,tl=12,rh=3,oh=100,ih=0,ah=50;function Bt(e){return e==="dynamic"?"dynamic":"fixed"}function sn(e){const t=n=>{const r=e[n];return typeof r=="number"&&Number.isFinite(r)&&r>0?r:0};return{top:t("flowPaddingTop"),right:t("flowPaddingRight"),bottom:t("flowPaddingBottom"),left:t("flowPaddingLeft")}}function nl(e,t){return Math.max(0,e-t.left-t.right)}const rl=25.4/72;function sh(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)))}function Qe(e){return sh(e,yi,tl,4)}function rt(e){return typeof e!="number"||!Number.isFinite(e)?4:Math.min(ah,Math.max(ih,e))}function Ct(e){return typeof e!="number"||!Number.isFinite(e)?8:Math.min(oh,Math.max(rh,e))}function Ht(e,t){const n=Qe(t),r=Math.min(2,n);return typeof e!="number"||!Number.isFinite(e)?r:Math.min(n,Math.max(1,Math.round(e)))}function lh(e,t,n){const r=Qe(t),o=rt(n),i=e-o*(r-1);return i<=0?0:i/r}function ch(e,t,n){const r=Math.max(1,Math.floor(n));return e*r+t*(r-1)}function ol(e,t){if(!e)return 0;const n=typeof t=="number"&&Number.isFinite(t)&&t>0?t*rl:12*rl;let r=0;for(const o of e){if(o===" "){r+=.28;continue}const i=o.codePointAt(0)??0;i>=12288&&i<=12351||i>=13312&&i<=19903||i>=19968&&i<=40959||i>=63744&&i<=64255||i>=65280&&i<=65376||i>=65504&&i<=65510||i>=131072?r+=1:/^[0-9A-Z]$/.test(o)?r+=.6:/^[a-z]$/.test(o)?r+=.5:/^[\u0020-\u007f]$/.test(o)?r+=.4:r+=.75}return r*n}function dh(e,t){if(!t.autoSpan)return 1;const n=Ht(t.maxSpan,t.columns);if(n<=1||t.colUnitMm<=0)return 1;const r=ol(e,t.fontSizePt);for(let o=1;o<=n;o++)if(r<=ch(t.colUnitMm,t.gapX,o))return o;return n}function vi(e,t){const n=Qe(t.columns),r=rt(t.gapX),o=lh(t.width,n,r),i=Ht(t.maxSpan,n),a=[];let l=[],c=0;for(const s of e){const d=String(s??""),p=dh(d,{...t,columns:n,gapX:r,maxSpan:i,colUnitMm:o});l.length>0&&c+p>n&&(a.push({cells:l}),l=[],c=0),l.push({text:d,span:p}),c+=p}return l.length>0&&a.push({cells:l}),a}function Or(e,t){if(typeof e!="string"||!e.includes("{")||!t)return;const n=new Set;for(const r of e.matchAll(/\{([^{}]*)\}/g))for(const o of(r[1]??"").split(/[^A-Za-z0-9_\u4e00-\u9fa5.]/)){const i=o.split(".")[0];i&&!/^\d/.test(i)&&n.add(i)}for(const r of n)if(Array.isArray(t[r]))return r}function uh(e,t,n){const r=rt(t),o=ol("一",n);if(o<=0||e<=0)return yi;const i=Math.floor((e+r)/(o+r));return Math.min(tl,Math.max(yi,i))}const il=e=>`${Math.round(e*1e3)/1e3}mm`;function ph(e){const t=Qe(e.columns),n=rt(e.gapX),r=Ct(e.rowHeight);return["display:grid",`grid-template-columns:repeat(${t},minmax(0,1fr))`,`column-gap:${il(n)}`,`grid-auto-rows:minmax(${il(r)},auto)`].join(";")}const Nn=25.4,al=10;function wi(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):al}const At=30,Ir=10,xi=2,sl=0,fh=.25,Ei=.254;function hh(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return null;const t=e/Nn;for(let n=2;n<=8;n+=.5){const r=Math.max(1,Math.round(Pr(n)*t)),o=r/t;if(o>=Ei-1e-9)return{barWidth:n,dotsPerModule:r,moduleWidthMm:o}}return null}function ll(e,t){const n=hh(e);if(!n)return"";const r=s=>String(Number(s.toFixed(3))),o=`按 ${e}dpi 推荐条宽倍率 ${n.barWidth}(每模块 ${n.dotsPerModule} 个打印点 = ${r(n.moduleWidthMm)}mm,取达到 ${r(Ei)}mm 下限的最小档)`,i=Pr(t??2),a=Math.max(1,Math.round(i*e/Nn)),l=a/(e/Nn),c=l>=Ei-1e-9?`当前倍率 ${t??2} 折算为 ${a} 点 / ${r(l)}mm,已达标`:`当前倍率 ${t??2} 只有 ${a} 点 / ${r(l)}mm,低于下限`;return`${o};${c}。这里只提示,不会替你改值`}function Fn(e){const t=typeof e=="number"&&Number.isFinite(e)?e:2;return Math.max(1,t/2)}function Pr(e){return Fn(e)*fh}function gh(e){const{barHeightMm:t,moduleWidthMm:n,boxHeightMm:r,textModules:o}=e,i=typeof t=="number"&&Number.isFinite(t)&&t>0,a=typeof n=="number"&&Number.isFinite(n)&&n>0;if(!i||!a)return At;const l=Math.max(1,Math.round(t/n));if(!(typeof r=="number"&&Number.isFinite(r)&&r>0))return l;const s=typeof o=="number"&&Number.isFinite(o)&&o>0?o:0,d=Math.floor((r-s*n)/n);return Math.max(1,Math.min(l,d))}function cl(e,t,n){const r=Math.max(1,Math.round(e*n)),o=Math.floor(t*n);if(o<1)return null;const i=Math.min(r,o);return{dotsPerModule:i,preferredDots:r,moduleWidthMm:i/n}}function mh(e){const t=Pr(e.barWidth),n=Math.max(1,Math.ceil(e.unitWidth)),r=e.boxWidthMm>0?e.boxWidthMm/n:Number.POSITIVE_INFINITY,o=e.dpi;if(typeof o=="number"&&Number.isFinite(o)&&o>0){const i=cl(t,r,o/Nn);if(i)return i.moduleWidthMm}return Math.min(t,r)}function ln(e,t){const n=typeof e=="number"&&e>0?e:Number.POSITIVE_INFINITY,r=typeof t=="number"&&t>0?Math.min(n,t):n;return Number.isFinite(r)?r:0}function bh(e){const t=Math.max(1,Math.ceil(e.unitWidth)),n=Math.max(1,Math.ceil(e.unitHeight)),r=Pr(e.barWidth),o=Math.min(e.boxWidthMm>0?e.boxWidthMm/t:Number.POSITIVE_INFINITY,e.boxHeightMm>0?e.boxHeightMm/n:Number.POSITIVE_INFINITY),i=e.dpi;if(typeof i=="number"&&Number.isFinite(i)&&i>0){const l=cl(r,o,i/Nn);if(l)return{moduleWidthMm:l.moduleWidthMm,widthMm:t*l.moduleWidthMm,heightMm:n*l.moduleWidthMm,dotsPerModule:l.dotsPerModule,scaledDown:l.dotsPerModule<l.preferredDots}}const a=Math.min(r,o);return{moduleWidthMm:a,widthMm:t*a,heightMm:n*a,dotsPerModule:null,scaledDown:a<r}}function Si(e){const t=Fn(e.barWidth),n=c=>bh({unitWidth:c.widthUnits/t,unitHeight:c.heightUnits/t,boxWidthMm:e.boxWidthMm,boxHeightMm:e.boxHeightMm,dpi:e.dpi,barWidth:e.barWidth}),r=e.measure(At);if(!r)return{barHeightModules:At,size:null};if(!(typeof e.barHeightMm=="number"&&Number.isFinite(e.barHeightMm)&&e.barHeightMm>0))return{barHeightModules:At,size:n(r)};const i=Math.max(0,r.heightUnits/t-At),a=gh({barHeightMm:e.barHeightMm,moduleWidthMm:mh({unitWidth:r.widthUnits/t,boxWidthMm:e.boxWidthMm,dpi:e.dpi,barWidth:e.barWidth}),boxHeightMm:e.boxHeightMm,textModules:i});if(a===At)return{barHeightModules:a,size:n(r)};const l=e.measure(a);return l?{barHeightModules:a,size:n(l)}:{barHeightModules:At,size:null}}const zn=["top","right","bottom","left"],dl=new Set(["rect","oval","hline","vline","table"]);function _i(e){return!!e&&!dl.has(e)}const yh=new Set(["solid","dashed","dotted","double"]);function ul(e,t,n){return typeof e!="number"||!Number.isFinite(e)||e<=0||t==="none"?null:{borderWidth:`${e}pt`,borderStyle:typeof t=="string"&&yh.has(t)?t:"solid",borderColor:n||"#000"}}function Rr(e,t){if(!e||dl.has(e))return null;const n=ul(t?.borderWidth,t?.borderStyle,t?.borderColor),r={},o=t?.borders;if(o)for(const i of zn){const a=o[i];if(!a)continue;const l=ul(a.width,a.style,a.color);l&&(r[i]=l)}return!n&&Object.keys(r).length===0?null:{all:n,edges:r}}const vh=/[;"'<>\\(){}\[\]@!#]/,wh=64,Bn=100,pl=400;function xh(e){const t=(e??"").trim();return!t||t.length>wh||vh.test(t)?"":t}function fl(e,t){if((e||"contain")!=="cover"||typeof t!="number"||!Number.isFinite(t))return;const n=Math.round(t);if(!(n<=Bn))return Math.min(n,pl)}function Mi(e,t,n){const r=xh(n),o={};r&&(o.objectPosition=r);const i=fl(e,t);return i!==void 0&&(o.transform=`scale(${Number((i/100).toFixed(2))})`,o.transformOrigin=r||"50% 50%"),o}function Hn(e){return typeof e!="number"||!Number.isFinite(e)?0:(e%360+360)%360}function hl(e,t,n){const r=e.width,o=t,i=Hn(n);let a,l;if(i===0||i===180)a=r,l=o;else if(i===90||i===270)a=o,l=r;else{const c=i*Math.PI/180;a=r*Math.abs(Math.cos(c))+o*Math.abs(Math.sin(c)),l=r*Math.abs(Math.sin(c))+o*Math.abs(Math.cos(c))}return{left:e.left-(a-r)/2,top:e.top-(l-o)/2,width:a,height:l}}const gl=385,ml=new Set(["table","flowList"]);function Eh(e){return ml.has(e)}const Sh="条码与二维码仅支持 90° 步进;任意角度需 385dpi 以上打印头";function _h(e,t){if(e!=="barcode"&&e!=="qrcode")return!0;const n=t?.printerDpi;return typeof n=="number"&&n>0&&n>=gl}function Ti(e,t,n){const r=t?.rotate;if(typeof r!="number"||!Number.isFinite(r))return;const o=Hn(r);if(o!==0&&!ml.has(e)){if(e==="barcode"||e==="qrcode"){if(o===90||o===180||o===270)return o;const i=t?.printerDpi;if(typeof i=="number"&&i>0&&i<gl){const a=Hn(Math.round(o/90)*90);return a===0?void 0:a}}return o}}const Ut={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},DOT_FULL:{width:241,height:279.4},DOT_HALF:{width:241,height:139.7},DOT_THIRD:{width:241,height:93.1},LABEL_80X60:{width:80,height:60},LABEL_60X40:{width:60,height:40},LABEL_40X30:{width:40,height:30},THERMAL_57:{width:57,height:297},THERMAL_80:{width:80,height:297},THERMAL_110:{width:110,height:297},CUSTOM:{width:210,height:297},CONTINUOUS:{width:80,height:297}},Mh=new Set(["CONTINUOUS","THERMAL_57","THERMAL_80","THERMAL_110"]);function cn(e){return Mh.has(e)}function et(e){const t=cn(e.paperSize),n=e.paperSize==="CUSTOM"||t?{width:e.customWidth??Ut[e.paperSize].width,height:e.customHeight??Ut[e.paperSize].height}:Ut[e.paperSize];return e.orientation==="landscape"&&!t?{width:n.height,height:n.width}:{...n}}function dn(e){if(cn(e.paperSize))return et(e);const n=et(e);return e.outputRotation===90||e.outputRotation===270?{width:n.height,height:n.width}:n}function ki(e){return cn(e.paperSize)?0:e.outputRotation??0}function ct(e){return cn(e.paperSize)}function Dr(e){return e.options?.pagination??e.pagination}function Th(e){return e.options?.tablePagination??e.tablePagination}const kh=2;function $r(e){return e.type==="table"||e.printElementType?.type==="table"}function Un(e){return(e.type||e.printElementType?.type||"text")==="flowList"&&Bt(e.options?.flowLayoutMode)==="dynamic"}function Ci(e){return $r(e)||Un(e)}function bl(e){return e.type||e.printElementType?.type||"text"}function yl(e){return Ti(bl(e),e.options)}function qn(e,t){const n=t.get(e.id)?.measuredHeight??e.options?.height??0,r=e.options?.top??0,o=yl(e);if(o===void 0)return{height:n,shift:0,top:r,rot:void 0};const i=hl({left:e.options?.left??0,top:r,width:e.options?.width??100},n,o);return{height:i.height,shift:r-i.top,top:i.top,rot:o}}function Ch(e,t){const n=e.options?.left??0,r=e.options?.tableColWidths??[],o=$r(e)&&r.length>0?r.reduce((c,s)=>c+s,0):e.options?.width??0,i=yl(e);if(i===void 0)return{left:n,width:o};const a=t.get(e.id)?.measuredHeight??e.options?.height??0,l=hl({left:n,top:e.options?.top??0,width:o},a,i);return{left:l.left,width:l.width}}function Ah(e){const t=e.options??{},n=t.top??0,o=(t.tableRows??[]).reduce((a,l)=>a+(l.height??0),0),i=Math.max(t.height??0,o);return n+i}function Ai(e){if(Un(e)){const t=e.options??{};return(t.top??0)+Math.max(t.height??0,0)}return Ah(e)}function vl(e){return(t,n)=>{const r=t.options?.top??0,o=n.options?.top??0;if(r!==o)return r-o;const i=t.options?.zIndex??0,a=n.options?.zIndex??0;return i!==a?i-a:(e.get(t.id)??0)-(e.get(n.id)??0)}}function wl(e){const t=e.filter(a=>typeof a.id=="string").map(a=>a),n=new Map;t.forEach((a,l)=>n.set(a.id,l));const r=[...t].sort(vl(n)),o=new Set;for(const a of r)Ci(a)||a.options?.groupId&&o.add(a.id);const i=new Set;for(const a of xl(r,o).values())for(const l of a)i.add(l);return i}function xl(e,t){const n=new Map;let r=null,o=-1,i=0,a=0;for(const l of e){if(Ci(l)){r=l.id,o=Ai(l);const p=l.options?.left??0,u=l.options?.tableColWidths??[],f=u.length>0?u.reduce((m,g)=>m+g,0):l.options?.width??0;i=p,a=p+f,n.set(l.id,[]);continue}if(t?.has(l.id)||!r||(l.options?.top??0)<o)continue;const s=l.options?.left??0;s+(l.options?.width??0)<=i||s>=a||n.get(r).push(l.id)}return n}function Oh(e,t,n,r){const o=Ai(e);let i=o;for(const a of t){const l=n.elements.find(c=>c.id===a);l&&(i=Math.max(i,(l.options?.top??0)+(l.options?.height??0)))}return Math.max(i-o,0)}function Ih(e,t){return Math.max(e.options?.height??0,t.get(e.id)?.measuredHeight??0)}const El=25.4/72;function qt(e){const t=e.options??{},n=t.left??0;if((e.type||e.printElementType?.type||"text")==="vline"){const i=(t.borderWidth??.75)*El/2+.05;return[n-i,n+i]}return[n,n+(t.width??100)]}function Sl(e,t){return e[0]<t[1]&&t[0]<e[1]}function _l(e,t){return[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function Ph(e,t,n){const r=new Map;for(const p of n.values()){if(p.length<2)continue;const u={anchorId:p[0].id,ids:p.map(f=>f.id),forceFirstPage:p.some(f=>Dr(f)?.pageable===!1),band:p.map(qt).reduce(_l)};for(const f of p)r.set(f.id,u)}const o=e.filter(p=>!$r(p)&&!Un(p)&&!p.options?.groupId&&Dr(p)?.pageable!==!1),i=new Map;o.forEach(p=>i.set(p.id,p.id));const a=p=>{let u=p;for(;i.get(u)!==u;)u=i.get(u);let f=p;for(;i.get(f)!==u;){const m=i.get(f);i.set(f,u),f=m}return u},l=(p,u)=>{const f=a(p),m=a(u);f!==m&&i.set(m,f)},c=[];for(const p of o){const u=p.options?.top??0;for(let g=c.length-1;g>=0;g--)c[g].bottom<=u&&c.splice(g,1);const f=u+Ih(p,t),m=qt(p);for(const g of c)g.bottom>u&&Sl(g.x,m)&&l(p.id,g.id);c.push({id:p.id,top:u,bottom:f,x:m})}const s=new Map(o.map(p=>[p.id,p])),d=new Map;for(const p of o){const u=a(p.id),f=d.get(u);f?f.push(p.id):d.set(u,[p.id])}for(const p of d.values()){if(p.length<2)continue;const u={anchorId:p[0],ids:p,forceFirstPage:!1,band:p.map(f=>qt(s.get(f))).reduce(_l)};for(const f of p)r.set(f,u)}return r}function Oi(e,t){const n=et(e),{top:r,bottom:o}=e.margins,i=e.header?.height??0,a=e.footer?.height??0,l=ct(e),c=l?Number.POSITIVE_INFINITY:n.height-r-o-i-a;if(!l&&c<=0)throw new Error(`页面可用高度不足: paper=${n.height}mm, margins=${r+o}mm, header=${i}mm, footer=${a}mm`);const s=new Map;e.elements.forEach((O,z)=>s.set(O.id,z));const d=[...e.elements].sort(vl(s)),p=new Set,u=new Map;for(const O of d){if(Ci(O))continue;const z=O.options?.groupId;if(!z)continue;p.add(O.id);const q=u.get(z);q?q.push(O):u.set(z,[O])}const f=xl(d,p),m=new Map;for(const[O,z]of f)for(const q of z)m.set(q,O);const g=new Set,b=O=>{for(const z of O)g.add(z)},v=new Map;for(const O of d)v.set(O.id,O);const w=Ph(d,t,u),_=[];let M=[],N=[],R=!1;function D(){return c-kh}function I(O){let z=0;for(const q of N)Sl(O,[q.x0,q.x1])&&(z+=q.height);return Math.max(0,z)}function S(O){return D()-I(O)}function C(O,z){N.push({x0:O[0],x1:O[1],height:z})}function k(O,z=qt(O)){return R?$(z):O.options?.top??0}function $(O){return Math.max(0,D()-S(O))}let P=!1,x=[];function Y(O,z,q){q<=0||x.push(`元素 ${O.id} 旋转 ${z}° 后顶部超出页首 ${Math.round(q*100)/100}mm,打印将被裁切`)}function le(){_.push(P||x.length>0?{pageIndex:_.length,sections:[...M],...P?{overflow:!0}:{},...x.length>0?{warnings:[...x]}:{}}:{pageIndex:_.length,sections:[...M]})}function De(O){O>c&&(P=!0)}function G(O=!1){if(M.length===0){P=P||O;return}le(),M=[],N=[],R=!0,P=!1,x=[]}let me=0;for(;me<d.length;){const O=d[me];if(m.has(O.id)&&g.has(O.id)){me++;continue}const z=w.get(O.id);if(z&&z.anchorId!==O.id){me++;continue}if(Dr(O)?.pageable===!1||z?.forceFirstPage){if(z){let q=Number.POSITIVE_INFINITY,W;for(const X of z.ids){const ee=v.get(X);if(!ee)continue;const ce=qn(ee,t);q=Math.min(q,ce.top),ce.rot!==void 0&&(W={el:ee,rot:ce.rot})}W&&Y(W.el,W.rot,-q);for(const X of z.ids)M.push({elementId:X,type:"element",renderTop:v.get(X)?.options?.top??0})}else{const q=qn(O,t);q.rot!==void 0&&Y(O,q.rot,-q.top),M.push({elementId:O.id,type:"element",renderTop:k(O)})}me++;continue}$r(O)?me=te(O,t,me):Un(O)?me=ne(O,t,me):z?me=Ie(z,me):me=ue(O,t,d,me)}return M.length>0&&le(),_.length===0&&_.push({pageIndex:0,sections:[]}),Be(),_;function Be(){if(l)return;const O=e.margins.left;for(const z of _){const q=[];for(const W of z.sections){if(W.type==="flow-group")continue;const X=v.get(W.elementId);if(!X)continue;const{left:ee,width:ce}=Ch(X,t),pe=O+ee,Z=pe+ce-n.width,de=-pe;Z>.01?q.push(`元素 ${X.id} 超出纸面右侧 ${Math.round(Z*100)/100}mm,打印将被裁切`):de>.01&&q.push(`元素 ${X.id} 超出纸面左侧 ${Math.round(de*100)/100}mm,打印将被裁切`)}q.length>0&&(z.warnings=[...z.warnings??[],...q])}}function ue(O,z,q,W){const X=qt(O),ee=qn(O,z),ce=ee.height,pe=()=>{const Z=k(O,X),de=R?Z+ee.shift:Z,J=de-(O.options?.top??0);De(ee.top+J+ee.height),ee.rot!==void 0&&!R&&Y(O,ee.rot,-ee.top),M.push({elementId:O.id,type:"element",renderTop:de}),C(X,ce)};if(ce<=S(X)){if(pe(),Dr(O)?.keepWithNext&&W+1<q.length){const Z=q[W+1],de=qn(Z,z).height;if(ce+de>D())return W+1;de>S(X)&&(M.pop(),N.pop(),G(),pe())}return W+1}return G(),pe(),W+1}function Ie(O,z){const q=O.ids.map(J=>v.get(J)).filter(J=>!!J);let W=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,ee;for(const J of q){const xe=qn(J,t);W=Math.min(W,xe.top),X=Math.max(X,xe.top+xe.height),xe.rot!==void 0&&(ee={el:J,rot:xe.rot})}const ce=Math.max(X-W,0),pe=O.band,Z=()=>{const J=R?$(pe)-W:0;De(W+J+ce),ee&&!R&&Y(ee.el,ee.rot,-W);for(const xe of q)M.push({elementId:xe.id,type:"element",renderTop:(xe.options?.top??0)+J});C(pe,ce)};return ce<=S(pe)?(Z(),z+1):(G((R?0:W)+ce>c),Z(),z+1)}function te(O,z,q){const W=O.options??{},X=W._renderRows??[],ee=z.get(O.id)?.measuredRowHeights??[],ce=(W._subtotalTemplates?.length??0)>0,pe=(W._summaryRows?.length??0)>0,Z=ce?Ml(X,ee,"subtotal"):0,de=pe?Ml(X,ee,"summary"):0,J=fe=>ce&&fe.type==="subtotal"||pe&&fe.type==="summary",xe=X.filter(fe=>!J(fe)),be=ee.filter((fe,Se)=>!J(X[Se]));W._renderRows=xe;const he=Math.min(xe.length,be.length),Ae=W._repeatHeaderCount??0,se=z.get(O.id)?.repeatHeaderHeight??ee.slice(0,Ae).reduce((fe,Se)=>fe+Se,0),lt=D(),j=qt(O);if(se>lt)throw new Error(`表格 ${O.id} 的重复表头高度 (${se.toFixed(1)}mm) 超过页面可用高度 (${lt.toFixed(1)}mm),请减少重复表头行`);if(he===0)return M.push({elementId:O.id,type:"table-slice",startRow:0,endRow:0,summary:de>0,renderTop:k(O,j)}),C(j,de),tt(O,z,j),q+1;const nt=be.slice(0,he).reduce((fe,Se)=>fe+Se,0)+Z+de;if(Th(O)?.enabled===!1)return nt>S(j)&&M.length>0&&G(),M.push({elementId:O.id,type:"table-slice",startRow:0,endRow:he,subtotal:Z>0,summary:de>0,renderTop:k(O,j)}),C(j,nt),tt(O,z,j),q+1;const T=Rh(xe,he);let B=0,oe=!0,Ee=k(O,j),$e=0;const Tt=()=>S(j)-$e,Cn=(fe,Se)=>{M.push({elementId:O.id,type:"table-slice",startRow:B,endRow:fe,subtotal:Z>0,...!oe&&Se?{repeatHeader:!0}:{},renderTop:Ee}),C(j,$e),$e=0};for(const fe of T){const Se=be.slice(fe.start,fe.end).reduce((An,ai)=>An+ai,0);if(Se+Z<=Tt()){$e+=Se;continue}fe.start>B&&(Cn(fe.start,Ae>0),oe=!1,B=fe.start),G(),Ee=k(O,j),$e=0,oe||($e+=se),$e+=Se}if(B<he&&Cn(he,Ae>0),de>0)if(de<=Tt()){const fe=M.length-1,Se=M[fe];Se&&Se.type==="table-slice"&&Se.elementId===O.id?(M[fe]={...Se,summary:!0},C(j,de)):(G(),M.push({elementId:O.id,type:"table-slice",startRow:he,endRow:he,summary:!0,renderTop:0}),C(j,de))}else G(),M.push({elementId:O.id,type:"table-slice",startRow:he,endRow:he,summary:!0,renderTop:0}),C(j,de);return tt(O,z,j),q+1}function ne(O,z,q){const W=O.options??{},X=z.get(O.id)?.measuredFlowRowHeights??[],ce=(Array.isArray(W._flowRows)?W._flowRows:[]).length,pe=Ct(W.flowRowHeight);if(ce===0)return q+1;const Z=sn(W),de=Rr(bl(O),W),J=B=>{if(!B)return 0;const oe=Number.parseFloat(B.borderWidth);return Number.isFinite(oe)?oe*El:0},xe=B=>{const oe=de?.edges?.[B];return J(oe||(de?.all??void 0))},be=Z.top+Z.bottom+xe("top")+xe("bottom"),he=qt(O);let Ae=0,se=k(O,he),lt=R?0:se,j=0;const Nt=()=>(R?S(he):D()-lt)-j-be,nt=B=>{M.push({elementId:O.id,type:"flow-list-slice",startFlowRow:Ae,endFlowRow:B,renderTop:se});const oe=R?se:I(he),Ee=se+be+j;C(he,Math.max(0,Ee-oe)),j=0};let T=0;for(;T<ce;){const B=X[T]??pe;if(B<=Nt()){j+=B,T++;continue}if(B+be>D()){T>Ae&&(nt(T),Ae=T),M.length>0&&G(),se=k(O,he),lt=R?0:se,j=B,De(se+be+j),T++;continue}if(M.length===0&&j===0&&!R){j+=B,De(se+be+j),T++;continue}T>Ae&&(nt(T),Ae=T),G(),se=k(O,he),lt=R?0:se}return Ae<ce&&nt(ce),tt(O,z,he),q+1}function tt(O,z,q){const W=f.get(O.id)??[];if(W.length===0)return;const X=Oh(O,W,e),ee=O.options??{};if(X<=S(q)){const ce=M.length-1,pe=M[ce];if(pe&&(pe.type==="table-slice"||pe.type==="flow-list-slice")&&pe.elementId===O.id){M[ce]={...pe,type:"flow-group",followElementIds:W,groupTop:pe.renderTop??ee.top??0},C(q,X),b(W);return}}G(),M.push({elementId:O.id,type:"flow-group",startRow:0,endRow:0,...Un(O)?{startFlowRow:0,endFlowRow:0}:{},followElementIds:W,groupTop:0}),C(q,X),b(W)}}function Rh(e,t){const n=[];let r=0,o=1;for(let i=0;i<t;i++){for(const a of e[i]?.cells??[])!a.merged&&(a.rowspan??1)>1&&(o=Math.max(o,i+a.rowspan));i+1>=o&&(n.push({start:r,end:i+1}),r=i+1,o=r+1)}return n}function Ml(e,t,n){let r=0;for(let o=0;o<e.length;o++)e[o]?.type===n&&(r+=t[o]??0);return r}const Lr=25,Tl=5;function Dh(e){return Math.max(Lr,e)}function kl(e,t,n=1.1){const r=t>0?e*n:e/n;return Dh(Math.round(r))}function $h(e,t,n,r,o=.9){if(n<=0||r<=0)return 100;const i=Math.min(e/n,t/r)*o,a=Math.round(i*100);return Math.max(Tl,a)}const Lh=2;function Cl(e){const t=e.gap??Lh,n=[...e.units].sort((i,a)=>i.order-a.order);if(e.available<=0)return{movedIds:[],overflowRemains:!1};if(n.some(i=>i.width<=0))return{movedIds:[],overflowRemains:!1};const r=i=>{const a=n.filter(c=>!i.has(c.id));return e.pinned+a.reduce((c,s)=>c+s.width+t,0)+(i.size>0?e.moreTriggerWidth+t:0)<=e.available};if(r(new Set))return{movedIds:[],overflowRemains:!1};const o=new Set;for(const i of n)if(o.add(i.id),r(o))return{movedIds:[...o],overflowRemains:!1};return{movedIds:[...o],overflowRemains:!0}}function Nh(e){const t=e.gap??4,n=e.boundaryBottom-e.triggerBottom-t,r=e.triggerTop-e.boundaryTop-t;return n>=e.overlayHeight?"down":r>n?"up":"down"}function Fh(){let e=0;return function(){return e+=1,`cell-${Date.now().toString(36)}-${e}`}}function zh(){let e=0;return function(){return e+=1,`row-${Date.now().toString(36)}-${e}`}}const Bh=Fh(),Hh=zh(),Ot={width:.75,style:"solid",color:"#333333"};function Ii(e){return JSON.parse(JSON.stringify(e))}function Pi(e){return{id:Bh(),borders:{top:{...Ot},right:{...Ot},bottom:{...Ot},left:{...Ot}},...e}}function Uh(){const e=[50,50,50],t=(r,o)=>({id:Hh(),type:r,height:8,...o!==void 0?{repeatOnPage:o}:{},cells:e.map(()=>Pi())}),n=t("header",!0);return n.cells.forEach((r,o)=>{r.formatter=`列${o+1}`,r.align="center",r.fontWeight="bold"}),{rows:[n,t("data"),t("subtotal"),t("summary")],colWidths:e}}function Wn(e,t,n){if(!e[t].cells[n].merged)return{r:t,c:n};for(let r=t;r>=0;r--)for(let o=n;o>=0;o--){const i=e[r].cells[o];if(i.merged)continue;const a=i.rowspan??1,l=i.colspan??1;if(r+a-1>=t&&o+l-1>=n)return{r,c:o}}return{r:t,c:n}}function Wt(e,t,n){const r=Wn(e,t,n),o=e[r.r].cells[r.c];return{r1:r.r,c1:r.c,r2:r.r+(o.rowspan??1)-1,c2:r.c+(o.colspan??1)-1}}function Al(e,t,n){let r={r1:Math.min(t.r,n.r),c1:Math.min(t.c,n.c),r2:Math.max(t.r,n.r),c2:Math.max(t.c,n.c)};for(;;){let o=!1;for(let i=r.r1;i<=r.r2;i++)for(let a=r.c1;a<=r.c2;a++){const l=Wt(e,i,a),c={r1:Math.min(r.r1,l.r1),c1:Math.min(r.c1,l.c1),r2:Math.max(r.r2,l.r2),c2:Math.max(r.c2,l.c2)};(c.r1!==r.r1||c.c1!==r.c1||c.r2!==r.r2||c.c2!==r.c2)&&(r=c,o=!0)}if(!o)return r}}function Ol(e,t){if((t.r2-t.r1+1)*(t.c2-t.c1+1)<2)return"至少选择 2 个单元格";const r=new Set;for(let i=t.r1;i<=t.r2;i++)r.add(e[i].type);if(r.size>1)return"合并区域不能跨越不同类型的行";if(t.r2>t.r1&&r.has("data"))return"数据行将按列表展开,纵向合并请使用单元格属性「按值合并」";const o=Al(e,{r:t.r1,c:t.c1},{r:t.r2,c:t.c2});return o.r1!==t.r1||o.c1!==t.c1||o.r2!==t.r2||o.c2!==t.c2?"选区与已有合并区域部分重叠":null}function Il(e,t){const n=e[t.r1].cells[t.c1],r=[];for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=e[o].cells[i];a.formatter&&r.push(a.formatter),!(o===t.r1&&i===t.c1)&&(a.merged=!0,a.rowspan=1,a.colspan=1,a.formatter="")}n.rowspan=t.r2-t.r1+1,n.colspan=t.c2-t.c1+1,n.formatter=r.join(" ")}function Pl(e,t){for(let n=t.r1;n<=t.r2;n++)for(let r=t.c1;r<=t.c2;r++){const o=e[n].cells[r];if(!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1)){const i=Wt(e,n,r),a=o;for(let l=i.r1;l<=i.r2;l++)for(let c=i.c1;c<=i.c2;c++){const s=e[l].cells[c];s.merged=!1,s.rowspan=1,s.colspan=1,qh(a,s)}o.rowspan=1,o.colspan=1}}}function qh(e,t){e!==t&&(t.align=e.align,t.valign=e.valign,t.fontSize=e.fontSize,t.fontFamily=e.fontFamily,t.fontWeight=e.fontWeight,t.color=e.color,t.backgroundColor=e.backgroundColor,t.borders=e.borders?Ii(e.borders):void 0,t.padding=e.padding,t.wordWrap=e.wordWrap)}function Rl(e,t,n){const r=n==="above"?t:t+1,o=e[t],i=o.cells.length,a=o.type==="data"?"header":o.type,l={id:`row-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,type:a,height:o.height,...a==="header"?{repeatOnPage:[e[r-1],e[r]].find(c=>c?.type==="header")?.repeatOnPage===!0}:{},cells:Array.from({length:i},()=>Pi())};for(let c=0;c<i;c++)if(r>0&&r<e.length){const s=Wt(e,r-1,c);if(s.r1<r&&s.r2>=r){const d=e[s.r1].cells[s.c1];d.rowspan=(d.rowspan??1)+1,l.cells[c].merged=!0}}e.splice(r,0,l)}function Wh(e,t){if(e.length<=1)return"不能删除最后一行";const n=e[t],r=n.cells.length;for(let o=0;o<r;o++){const i=n.cells[o];if(!i.merged&&(i.rowspan??1)>1){const a=e[t+1].cells[o];Object.assign(a,Ii(i),{id:a.id}),a.rowspan=(i.rowspan??1)-1,a.merged=!1}else if(i.merged){const a=Wt(e,t,o);if(a.r1<t&&a.c1===o){const l=e[a.r1].cells[a.c1];l.rowspan=(l.rowspan??1)-1}}}return e.splice(t,1),null}function Dl(e,t,n,r){const o=r==="left"?n:n+1;t.splice(o,0,t[n]);for(const i of e){const a=Pi();if(o>0&&o<i.cells.length){const l=e.indexOf(i),c=Wt(e,l,o-1);if(c.c1<o&&c.c2>=o){const s=e[c.r1].cells[c.c1];l===c.r1&&(s.colspan=(s.colspan??1)+1),a.merged=!0}}i.cells.splice(o,0,a)}}function jh(e,t,n){if(t.length<=1)return"不能删除最后一列";for(let r=0;r<e.length;r++){const o=e[r].cells[n];if(!o.merged&&(o.colspan??1)>1){const i=e[r].cells[n+1];Object.assign(i,Ii(o),{id:i.id}),i.colspan=(o.colspan??1)-1,i.merged=!1}else if(o.merged){const i=Wt(e,r,n);if(i.c1<n&&i.r1===r){const a=e[i.r1].cells[i.c1];a.colspan=(a.colspan??1)-1}}}for(const r of e)r.cells.splice(n,1);return t.splice(n,1),null}function Ri(e,t,n){if(n==="data"){const r=e.findIndex((o,i)=>o.type==="data"&&i!==t);if(r>=0)return`数据行已存在(第 ${r+1} 行),全表最多一行`}if(n==="header"){for(let r=0;r<t;r++)if(e[r].type!=="header")return"标题行必须从表格顶部连续设置"}if(n==="subtotal"||n==="summary"){const r=e.findIndex(o=>o.type==="data");if(r<0)return"请先设置数据行,小计/汇总行必须位于数据行之后";if(t<r)return"小计/汇总行必须位于数据行之后"}if(n==="subtotal"&&e.slice(0,t).some(r=>r.type==="summary"))return"小计行必须位于汇总行之前";if(n==="summary"&&e.slice(t+1).some(r=>r.type==="subtotal"))return"汇总行必须位于小计行之后";if(e[t].type==="header"&&n!=="header"){for(let r=t+1;r<e.length;r++)if(e[r].type==="header")return"取消该标题行会导致标题行不连续,请先调整后续标题行"}if(e[t].type=n,n==="header"){const r=[e[t-1],e[t+1]].find(o=>o?.type==="header");e[t].repeatOnPage=e[t].repeatOnPage!==void 0?e[t].repeatOnPage===!0:r?.repeatOnPage===!0}else delete e[t].repeatOnPage;return null}function Gh(e,t){for(const n of e){if(n.type!=="header")break;n.repeatOnPage=t}}function $l(e,t,n,r){for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=e[o].cells[i];if(a.merged)continue;if(n==="none"){delete a.borders;continue}const l=Wt(e,o,i),c=l.r1===t.r1,s=l.r2===t.r2,d=l.c1===t.c1,p=l.c2===t.c2,u={...a.borders??{}};n==="all"?(u.top={...r},u.bottom={...r},u.left={...r},u.right={...r}):n==="outer"?(c&&(u.top={...r}),s&&(u.bottom={...r}),d&&(u.left={...r}),p&&(u.right={...r})):n==="inner"&&(c||(u.top={...r}),s||(u.bottom={...r}),d||(u.left={...r}),p||(u.right={...r})),a.borders=u}}const Vh="线型 / 宽度 / 颜色是待应用规格:选中格已有的边框规格一致时会填进这三行;四边不一致的项显示「混合」,一条边都没有时显示「无 / 0」。改完点「全部 / 外侧 / 内部」或勾选上、下、左、右某条边才会写入选中的单元格;「无」是清除边框",Yh="多选时不回显单格边框:线型 / 宽度 / 颜色按当前设置作为批写规格,点「全部 / 外侧 / 内部」或勾选某条边后写入所有选中格;「无」是清除边框",Xh="当前单元格四边边框规格不一致:带「混合」的项不谎报,未改项在点「全部 / 外侧 / 内部」或勾选单边时按缺省档(实线 0.75pt)写入,改任一项即按该值批写";function Ll(e,t,n){const r={...e.borders??{}};n?r[t]={...n}:delete r[t],e.borders=r.top||r.right||r.bottom||r.left?r:void 0}function Nr(e,t){const n=[];for(let r=t.r1;r<=t.r2;r++)for(let o=t.c1;o<=t.c2;o++){const i=e[r]?.cells[o];i&&!i.merged&&n.push(i)}return n}function Di(e,t){const n=Nr(e,t).length;return{mode:n>1?"multi":"single",count:n}}function Kh(e,t){const n=Nr(e,t);if(!n.length)return null;const r=n[0].cellType??"text";return n.every(o=>(o.cellType??"text")===r)?r:null}function Nl(e,t){const n=[];for(const o of Nr(e,t))for(const i of["top","right","bottom","left"]){const a=o.borders?.[i];a&&n.push(a)}const r=o=>{if(!n.length)return;const i=o(n[0]);return n.every(a=>o(a)===i)?i:"mixed"};return{width:r(o=>o.width),style:r(o=>o.style),color:r(o=>o.color)}}const Zh="1px dashed rgba(0,0,0,0.18)";function Fr(e,t={}){return e&&e.style!=="none"?`${e.width}pt ${e.style} ${e.color}`:t.designMode&&t.showGhostBorder!==!1?Zh:"none"}function jn(e){const t=(e.tableColWidths??[]).reduce((r,o)=>r+o,0),n=(e.tableRows??[]).reduce((r,o)=>r+o.height,0);e.width=Math.round(t*100)/100,e.height=Math.round(n*100)/100}const Fl=5;function Jh(e,t,n,r){const o=e.reduce((l,c,s)=>s===t?l:l+c,0),i=r===1/0?1/0:Math.max(Fl,r-o),a=Math.round(n*10)/10;return Math.min(Math.max(a,Fl),i)}const Qh=["html"];function eg(e){return!!e&&Qh.includes(e)}function un(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function $i(e){const t={left:7,top:17.6,width:42.3,height:7.1};switch(e){case"text":return{...t,formatter:"文本",fontSize:12,textAlign:"left",height:5.3};case"image":return{...t,width:28.2,height:28.2,fit:"contain"};case"longText":return{...t,width:141.1,height:28.2,fontSize:12,lineHeight:18};case"table":{const{rows:n,colWidths:r}=Uh(),o=r.reduce((a,l)=>a+l,0),i=n.reduce((a,l)=>a+l.height,0);return{...t,width:o,height:i,tableMode:"dynamic",tableRows:n,tableColWidths:r,tableDefaultFontSize:10,tableDefaultColor:"#333333",tableDefaultPadding:1,fields:[],tablePagination:{enabled:!0}}}case"flowList":return{...t,width:141.1,height:21.2,fontSize:12,formatter:"{name} {spec}",flowColumns:4,flowRowHeight:8,flowGapX:4,flowAutoSpan:!1,flowMaxSpan:2,flowLayoutMode:"fixed",flowPaddingTop:0,flowPaddingRight:0,flowPaddingBottom:0,flowPaddingLeft:0};case"hline":return{...t,width:70.6,height:1.8,borderWidth:.75};case"vline":return{...t,width:1.8,height:35.3,borderWidth:.75};case"rect":return{...t,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"oval":return{...t,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"barcode":return{...t,width:56.4,height:14.1,title:"条形码",barcodeType:"code128",testData:"12345678"};case"qrcode":return{...t,width:28.2,height:28.2,title:"二维码",testData:"qrcode"};case"html":return{...t,width:28.2,height:28.2};default:return t}}function Li(e,t){const n={text:{title:"文本"},image:{title:"图片"},longText:{title:"长文"},table:{title:"表格"},flowList:{title:"流式列表"},hline:{title:"横线"},vline:{title:"竖线"},rect:{title:"矩形"},oval:{title:"椭圆"},barcode:{title:"条形码"},qrcode:{title:"二维码"},html:{title:"HTML"},pageNumber:{title:"页码"}};return{id:un(),options:{...$i(e),...t},printElementType:{type:e,title:n[e]?.title||e}}}const tg=["left","top","width","height"];function ng(e){return e.type??e.printElementType?.type}function rg(e){const t=n=>(n??[]).filter(r=>!eg(ng(r)));return{...e,elements:t(e.elements),header:e.header?{...e.header,elements:t(e.header.elements)}:e.header,footer:e.footer?{...e.footer,elements:t(e.footer.elements)}:e.footer}}function og(e){const t={...e.options};for(const n of tg){const r=t[n];typeof r=="number"&&Number.isFinite(r)&&(t[n]=ig(kt(r)))}return{...e,options:t}}function ig(e){return Math.round(e*100)/100}function ag(e){const t={...e};delete t.firstPageOverlay;const n=rg(t);if(n.unit==="mm")return n;const r=n,o=i=>i?.map(og)??[];return{...r,unit:"mm",elements:o(r.elements),header:r.header?{...r.header,elements:o(r.header.elements)}:r.header,footer:r.footer?{...r.footer,elements:o(r.footer.elements)}:r.footer}}const Ni="标签纸",dt={A4:{width:210,height:297,label:"A4 210×297mm",group:"常用纸张"},A3:{width:297,height:420,label:"A3 297×420mm",group:"常用纸张"},A5:{width:148,height:210,label:"A5 148×210mm",group:"常用纸张"},Letter:{width:216,height:279,label:"Letter 216×279mm",group:"常用纸张"},Legal:{width:216,height:356,label:"Legal 216×356mm",group:"常用纸张"},DOT_FULL:{width:241,height:279.4,label:"全等分 241×279.4mm",group:"针式打印纸"},DOT_HALF:{width:241,height:139.7,label:"二等分 241×139.7mm",group:"针式打印纸"},DOT_THIRD:{width:241,height:93.1,label:"三等分 241×93.1mm",group:"针式打印纸"},LABEL_80X60:{width:80,height:60,label:"80×60mm",group:Ni},LABEL_60X40:{width:60,height:40,label:"60×40mm",group:Ni},LABEL_40X30:{width:40,height:30,label:"40×30mm",group:Ni},THERMAL_57:{width:57,height:297,continuous:!0,label:"57mm",group:"小票纸"},THERMAL_80:{width:80,height:297,continuous:!0,label:"80mm",group:"小票纸"},THERMAL_110:{width:110,height:297,continuous:!0,label:"110mm",group:"小票纸"},CONTINUOUS:{width:80,height:297,continuous:!0,label:"连续纸(自定义宽度)",group:"连续纸"}};function Fi(e){return!!e&&dt[e]?.continuous===!0}function It(e){const t=Fi(e.paperSize);let n;if(e.paperSize==="CUSTOM"||t){const r=dt[e.paperSize];n={width:e.customWidth??r?.width??210,height:e.customHeight??r?.height??297}}else{const r=dt[e.paperSize]||dt.A4;n={width:r.width,height:r.height}}return e.orientation==="landscape"&&!t?{width:n.height,height:n.width}:n}const zi=.75,sg="线型 / 宽度 / 颜色即时生效,这三行显示的就是当前生效规格:已有边框时任改一行都会按新规格铺满四边并清掉单边覆盖;上、下、左、右只给选中的边加框,撤掉一边会把它其余三边落成单边;「无」清除边框,「内部」仅表格单元格可用",Gn=["top","right","bottom","left"];function zl(e){const t={};for(const n of Gn){const r=e.map(o=>!!o?.[n]);t[n]=r.length>0&&r.every(Boolean)?"on":r.some(Boolean)?"mixed":"off"}return t}const Bi=[{value:"none",label:"无"},{value:"solid",label:"实线"},{value:"dashed",label:"虚线"},{value:"dotted",label:"点线"},{value:"double",label:"双线"}],lg=new Set(["solid","dashed","dotted","double"]),pn="none";function Vn(e,t){const n=e.borders?.[t];if(n&&n.style!==pn&&typeof n.width=="number"&&Number.isFinite(n.width)&&n.width>0)return!0;const r=e.borderWidth;return e.borderStyle!==pn&&typeof r=="number"&&Number.isFinite(r)&&r>0}function cg(e){const t={};for(const n of Gn)Vn(e,n)&&(t[n]=e.borders?.[n]??{width:e.borderWidth});return t}function dg(e){const t=e.borderWidth;return{width:typeof t=="number"&&Number.isFinite(t)&&t>0?t:zi,style:e.borderStyle||"solid",color:e.borderColor||"#333333"}}function Bl(e,t,n){if(t!=="inner"){if(e.borders=void 0,t==="none"){e.borderWidth=0;return}e.borderWidth=n.width,e.borderStyle=n.style,e.borderColor=n.color}}function Hl(e){return Gn.some(t=>Vn(e,t))}function Hi(e,t){if(!e.length)return;const n=e[0]?.[t];return e.every(r=>r[t]===n)?n:"mixed"}function ug(e){if(!e)return;const t=typeof e.style=="string"&&lg.has(e.style)?e.style:"solid";return{width:e.width,style:e.style===void 0?void 0:t,color:e.color}}function pg(e){const t=Gn.map(r=>e.borders?.[r]).filter(r=>typeof r?.width=="number"&&Number.isFinite(r.width)&&r.width>0).map(r=>ug(r));if(!t.length)return;const n=Hi(t,"style");return{width:Hi(t,"width"),style:n===void 0?"solid":n,color:Hi(t,"color")}}function Ul(e){const t=e.borderWidth,n=typeof t=="number"&&Number.isFinite(t),r=pg(e),o=n&&t>0;if(r&&!o)return r;const i=o?e.borderStyle||"solid":pn;return n?{width:t,style:i,color:e.borderColor}:{width:void 0,style:i,color:void 0}}function ql(e){const t=Ul(e);return{width:typeof t.width=="number"&&t.width>0?t.width:zi,style:typeof t.style=="string"&&t.style!==pn?t.style:"solid",color:typeof t.color=="string"?t.color:"#333333"}}function fg(e,t){e.borderWidth=t.width,e.borderStyle=t.style,e.borderColor=t.color,e.borders=void 0}function hg(e,t,n){if(t==="borderStyle"&&n===pn){const r=Hl(e);e.borderStyle=pn,r&&(e.borderWidth=0,e.borders=void 0);return}if(!Hl(e)){if(t==="borderStyle"){e.borderStyle=n,e.borderWidth=zi;return}Object.assign(e,{[t]:n});return}if(t==="borderWidth"&&(typeof n!="number"||!(n>0))){e.borderWidth=typeof n=="number"&&n<0?0:n,e.borders=void 0;return}fg(e,dg({...e,[t]:n}))}function Ui(e,t,n,r){if(n!==Vn(e,t)){if(!n){const o=e.borderWidth;if(typeof o!="number"||!(o>0)){Wl(e,t,null);return}const i={};for(const a of Gn){if(a===t)continue;const l=e.borders?.[a];i[a]={width:l?.width??o,...l?.style!==void 0?{style:l.style}:e.borderStyle!==void 0?{style:e.borderStyle}:{},...l?.color!==void 0?{color:l.color}:e.borderColor!==void 0?{color:e.borderColor}:{}}}e.borders=i,e.borderWidth=0;return}Wl(e,t,r??ql(e))}}function Wl(e,t,n){const r={...e.borders??{}};n?r[t]={width:n.width,style:n.style,color:n.color}:delete r[t],e.borders=r}const jl=96/25.4,Gl=1,gg=8,mg=210;function qi(e,t){if(!e||typeof e!="object")return;if(Array.isArray(e)){for(const r of e)qi(r,t);return}const n=e;typeof n.printerDpi=="number"&&n.printerDpi>0&&t.add(n.printerDpi);for(const r of Object.keys(n)){if(r==="printerDpi")continue;const o=n[r];o&&typeof o=="object"&&qi(o,t)}}function bg(e){if(!e)return null;const t=new Set;return qi(e,t),t.size?Math.max(...t):null}function yg(e){const t=e?.pages?.[0]??e;return t?It(t).width*jl:mg*jl}function vg(e,t){return e<=0||t<=0?Gl:Math.min(gg,Math.max(Gl,Math.floor(e/t)))}function wg(e,t,n){const r=[];return e&&r.push({key:"dots",value:e/96,label:`点阵 ${e}dpi`,tip:`1 屏幕像素 = 1 个打印点(${e}dpi ÷ 96dpi)。条与间隙按纸面逐点显示,不会在屏幕上糊成一片`}),r.push({key:"fit",value:vg(t,n),label:"适配",tip:"按容器宽放大到放得下整页的最大整数倍"},{key:"100",value:1,label:"100%",tip:"按 CSS 真实尺寸显示(1mm = 3.78 屏幕像素),热敏点距在此档不可分辨"},{key:"200",value:2,label:"200%",tip:"整数倍放大,避免非整数缩放带来的半像素边"},{key:"400",value:4,label:"400%",tip:"整数倍放大,避免非整数缩放带来的半像素边"}),r}function Vl(e){return"100"}function xg(e,t){return!e||t==="dots"?"":`条码看不清?切「点阵 ${e}dpi」档(1 屏幕像素 = 1 打印点)`}const Yl="print-preview-zoom-guard";function Eg(e,t){if(!e?.documentElement)return;let n=e.getElementById(Yl);n||(n=e.createElement("style"),n.id=Yl,(e.head??e.documentElement).appendChild(n)),n.textContent=`html{zoom:${t}}@media print{html{zoom:1 !important}}`}function Sg(e,t,n){return e.some(r=>r.key===t)?t:Vl()}function _g(e,t){return e.find(n=>n.key===t)?.value??1}const Xl=["text","image","hline","vline","rect","oval","barcode","qrcode"];function Mg(e){return It(e)}function Wi(e){const t=Mg(e),n=e.margins,r=e.header.height,o=e.footer.height,i=t.width-n.left-n.right,a=t.height-n.top-n.bottom-r-o,l=(c,s,d,p)=>({left:c,top:s,width:d,height:p});return{header:l(n.left,n.top,i,r),content:l(n.left,n.top+r,i,a),footer:l(n.left,t.height-n.bottom-o,i,o)}}function Kl(e,t,n){const r=Wi(e);return r.footer.height>0&&n>=r.footer.top?"footer":r.header.height>0&&n<r.header.top+r.header.height?"header":"content"}function ji(e,t){const n=e.options;n.width=Math.min(n.width,t.width),n.height=Math.min(n.height,t.height),n.left=Math.min(Math.max(0,n.left),t.width-n.width),n.top=Math.min(Math.max(0,n.top),t.height-n.height)}function Tg(e,t){const n=Wi(t),r=e.zone||"content",o=n[r],i=o.left+e.options.left+e.options.width/2,a=o.top+e.options.top+e.options.height/2;let l=Kl(t,i,a),c=!1;if(l!=="content"&&!Xl.includes(e.printElementType.type)&&(l="content",c=!0),l!==r){const s=n[l];e.options.left=o.left+e.options.left-s.left,e.options.top=o.top+e.options.top-s.top,e.zone=l}return l!=="content"?ji(e,n[l]):c&&ji(e,n.content),{rejected:c}}const Gi=22,Vi=[1,2,5,10,20,50,100,200,500,1e3];function kg(e,t=64){const n=e*3.7795275590551185;for(const r of Vi)if(r*n>=t)return r;return Vi[Vi.length-1]}function Cg(e){const t=Math.floor(Math.log10(e)+1e-9),n=e/10**t;return n===5||n===1&&e>=10?e/5:n===2?e/2:null}function Ag(e){return Math.round(e*1e3)/1e3}function Og(e,t,n){if(t<e||n<=0)return[];const o=Cg(n)??n,i=Math.ceil(e/o-1e-9)*o,a=Math.floor((t-i)/o+1e-9),l=[];for(let c=0;c<=a;c++){const s=Ag(i+c*o);Math.abs(s/n-Math.round(s/n))<1e-6?l.push({mm:s,major:!0,label:String(s)}):l.push({mm:s,major:!1})}return l}const Zl=["#000000","#333333","#666666","#999999","#cccccc","#ffffff","#e53935","#fb8c00","#1e88e5","#43a047","#8d6e63","#00acc1"],zr=[{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-family",keywords:["字体","字体名","字体族","fontfamily"]},{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"]},{key:"ap-text-fit",keywords:["溢出","溢出显示","截断","自动缩小","自适应行高","textfit","overflow"]},{key:"ap-shrink-min",keywords:["最小字号","缩放下限","shrinkminfontsize"],default:Ks,defaultUnit:"pt"},{key:"ap-word-wrap",keywords:["自动换行","不换行","wordwrap"]},{key:"ap-keep-line-breaks",keywords:["保留换行符","换行符","手动换行","保留空格","连续空格","行首空格","keeplinebreaks"]},{key:"ap-long-text-indent",keywords:["首行缩进","缩进","indent","longtextindent","两字符","段首"],tip:"长文本每段首行空出的宽度,单位「字符」:填 2 即缩进两个汉字宽(中文排版惯例),按 em 落纸——字号被「自动缩小」压小时缩进同步变窄。仅长文本元素生效,写在普通文本上不生效"},{key:"ap-img-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover","填充","裁剪","剪裁","锚点"],tip:"图片在元素框内的缩放方式:包含=完整显示、可能留白;剪裁=铺满框并按「裁剪锚点」取一块;拉伸=填满框会变形;原始尺寸与缩小不放大。画布与三条出纸链路同一口径(缺省包含)"},{key:"ap-img-object-position",keywords:["裁剪锚点","剪裁锚点","锚点","objectposition","object-position","对齐点","上移","头顶"],tip:"取位(仅「剪裁」档有这一行):剪裁把图等比铺满元素框,多出来的那一条边按这里选的位置取舍。先选位置档(贴边/居中/贴另一头),再按百分比微调,0 贴左/贴顶,100 挪到另一头,水平与垂直各自独立;缺省取正中间(保住证件照头顶就选顶部)。其余缩放模式图比框小或刚好铺满,没有可裁的边,所以不出本行"},{key:"ap-img-fit-scale",keywords:["放大比例","剪裁放大","放大倍数","取景","裁切范围","fitscale","zoom"],default:Bn,defaultUnit:"%",tip:"剪裁放大:等比铺满之后把画面再推大这么多,两轴才真的各多出一条边可裁——图与框同比例时不放大就什么都裁不掉。100=不放大(缺省),上限 400;超出框的部分由元素框裁掉。锚点选中的那一点既是取位的钉住点、也是放大的中心,两者共用同一个值。仅「剪裁」档生效,其余缩放模式不出本行"},{key:"ap-rotate",keywords:["旋转","角度","rotate","angle","顺时针","逆时针","90度","直角"],tip:"元素绕自身中心旋转的角度(度,0~359):出纸时按旋转后外接盒分页与结算,底部放不下自动移页,超出纸面左右缘或顶部会被裁切并给出纸提示。表格、流式列表与表格下方跟随区的元素不支持旋转(这三类不出本行);条码与二维码的任意角度需 385dpi 以上打印头,低分辨率打印机只按 90° 步进出纸"}]},{group:"flow-list",groupLabel:"流式列表",items:[{key:"fl-columns",keywords:["每行列数","列数","栏数","几列","flowcolumns"],tip:"一行排几个单元,必须由你指定——不随内容自动算列数。填的列数乘单元宽放不下元素框时只给提示、不改你的数,出纸按你填的排"},{key:"fl-row-height",keywords:["行高","每行高度","单元高度","flowrowheight"],tip:"每个单元行的最低高度(毫米),与表格行高同一口径:内容比它高时这一行会撑高,不会裁字"},{key:"fl-gap-x",keywords:["单元间距","横向间距","格间距","列间距","flowgapx"],tip:"相邻单元之间的横向留白(毫米);纵向不留缝,行与行的距离由行高承担"},{key:"fl-auto-span",keywords:["自适应","跨列","内容过长","占两列","自动换行","flowsautspan","flowautospan"],tip:"单元内容比一列还宽时,让它占掉两个或更多列位;当前行剩不够放就把整个单元挪到下一行行首(绝不把词切两半)。默认关——开着时出纸栏数由字号与框宽决定"},{key:"fl-max-span",keywords:["最多跨几列","跨列上限","flowmaxspan"],tip:"跨列的列数上限,最大只能等于「每行列数」:把每行列数改小时,这里会被一并顶回去"},{key:"fl-layout-mode",default:"fixed",keywords:["布局模式","容器模式","固定高度","动态分页","自动高度","flowlayoutmode"],tip:"容器高度由谁决定:固定高度=维持设计高度、一框一页,超高裁切(存量模板默认值,输出不变);动态分页=容器高度由内容撑开,内容满页后按行续页,每一页都画完整边框,元素下方的跟随区与表格同一套规则"},{key:"fl-padding-top",keywords:["上内边距","内边距","顶边距","flowpaddingtop"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器顶部与第一行内容之间的留白(毫米),仅动态模式生效;每页切片都按它留白并计入分页预算,负值与非法值按 0 处理"},{key:"fl-padding-right",keywords:["右内边距","内边距","右边距","flowpaddingright"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器右侧与内容之间的留白(毫米),会压缩参与列宽估算的内容宽度,仅动态模式生效"},{key:"fl-padding-bottom",keywords:["下内边距","内边距","底边距","flowpaddingbottom"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器底部与最后一行内容之间的留白(毫米),每页切片都按它留白并计入分页预算,仅动态模式生效"},{key:"fl-padding-left",keywords:["左内边距","内边距","左边距","flowpaddingleft"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器左侧与内容之间的留白(毫米),会压缩参与列宽估算的内容宽度,仅动态模式生效"}]},{group:"code",groupLabel:"条码设置",items:[{key:"cd-type",keywords:["码制","条码类型","条形码类型","barcodetype","code128","ean13","code39","itf14"]},{key:"cd-dpi",keywords:["打印机分辨率","dpi","打印点","点阵对齐","203","300"]},{key:"cd-bar-width",keywords:["条宽","条粗细","barwidth","模块宽"]},{key:"cd-bar-quiet-zone",keywords:["条码静区","条码白边","条形码留白","条码空白边","barquietzone"],default:al,defaultUnit:"模块",tip:"条形码左右两端的空白格数(1 格 = 1 条宽):缺省 10,正是一维码码制要求的下限;数值越小白边越窄、同样的框内条越粗(可放大)。填 0 即不留白边,但静区参与「条→空→条」跳变,紧邻文字或表格线时可能扫不出,需实打验证"},{key:"cd-bar-height",keywords:["条高","条码高度","条区高度","条码多高","barheight"],default:At,defaultUnit:"模块",tip:"黑白条本体的目标高度(mm,不含下方文字):折算粒度就是每模块物理宽,所以只能精确到它的整数倍。条宽优先——可用框高装不下时期望条高让位,绝不把条宽挤窄(热敏出纸清晰度靠条宽)。与「最大高度」分工不同:那条限的是整图(含文字)的上限"},{key:"cd-show-text",keywords:["显示文本","条码文本","显示数字"]},{key:"cd-font-size",keywords:["条码字号","文本字号"],default:Ir,defaultUnit:"模块"},{key:"cd-ec-level",keywords:["纠错级别","容错","qrcodelevel"]},{key:"cd-quiet-zone",keywords:["静区","静区宽度","白边","空白边","留白","铺满","quietzone"],default:sl,defaultUnit:"模块",tip:"二维码四周留出的空白格数:0 即不留白边、码面等比铺满元素框(此时靠框外的白纸充当静区);数值越大白边越宽、码面在框内越小(缺省 0,需 ISO/IEC 18004 推荐静区时填 4)"},{key:"cd-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover"]},{key:"cd-max-width",keywords:["最大宽度","最大宽","maxwidth"]},{key:"cd-max-height",keywords:["最大高度","最大高","maxheight"]}]},{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-style",keywords:["线型","边框线型","实线","虚线","点线","双线","borderstyle"]},{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 Me(e){for(const t of zr){const n=t.items.find(r=>r.key===e);if(n)return n.tip??""}return""}function Ig(e,t){const n=e.trim().toLowerCase();return n?t.some(r=>r.toLowerCase().includes(n)):!0}function Pg(e){const t=[],n=new Set;for(const r of zr){const o=r.items.filter(i=>Ig(e,[...i.keywords,r.groupLabel]));if(o.length>0){t.push(r.group);for(const i of o)n.add(i.key)}}return{groups:t,itemKeys:n}}function Rg(e){for(const t of zr)for(const n of t.items)if(n.key===e&&n.default!==void 0)return{value:n.default,unit:n.defaultUnit}}const Dg=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),$g=new Set(["new","function","class","this","delete","typeof","void","in","of","var","let","const","return","if","while","for"]);function Yi(e){const t=[];let n=0;const r=e.length;for(;n<r;){const o=e[n];if(/\s/.test(o)){n++;continue}if(/[0-9]/.test(o)||o==="."&&n+1<r&&/[0-9]/.test(e[n+1])){let l=n;for(;l<r&&/[0-9.]/.test(e[l]);)l++;t.push({type:"num",value:e.slice(n,l),position:n}),n=l;continue}if(o==="'"||o==='"'){let l=n+1,c="";for(;l<r&&e[l]!==o;)e[l]==="\\"&&l+1<r?(c+=e[l+1],l+=2):(c+=e[l],l++);if(l>=r)throw new Error("字符串未闭合");t.push({type:"str",value:c,position:n}),n=l+1;continue}if(/[A-Za-z_$]/.test(o)){let l=n;for(;l<r&&/[A-Za-z0-9_$]/.test(e[l]);)l++;const c=e.slice(n,l);if($g.has(c))throw new Error(`不允许使用关键字: ${c}`);if(Dg.has(c))throw new Error(`禁止访问: ${c}`);c==="true"||c==="false"?t.push({type:"bool",value:c,position:n}):t.push({type:"ident",value:c,position:n}),n=l;continue}const i=e.slice(n,n+3);if(i==="==="||i==="!=="){t.push({type:"punc",value:i,position:n}),n+=3;continue}const a=e.slice(n,n+2);if(a==="=>")throw new Error("不允许函数定义");if(["==","!=","<=",">=","&&","||"].includes(a)){t.push({type:"punc",value:a,position:n}),n+=2;continue}if(o==="=")throw new Error("不允许赋值");if(o===";")throw new Error("不允许多条语句");if("+-*/%()[]{},:.?!<>".includes(o)){t.push({type:"punc",value:o,position:n}),n++;continue}throw new Error(`非法字符: ${o}`)}return t}function Xi(e){return new Lg(e).parse()}class Lg{constructor(t){this.pos=0,this.tokens=t}parse(){const t=this.parseTernary();if(this.pos<this.tokens.length)throw new Error(`表达式存在多余内容: ${this.tokens[this.pos].value}`);return t}peek(){return this.tokens[this.pos]}next(){const t=this.tokens[this.pos++];if(!t)throw new Error("表达式意外结束");return t}eatPunc(t){const n=this.peek();return n&&n.type==="punc"&&n.value===t?(this.pos++,!0):!1}expectPunc(t){if(!this.eatPunc(t)){const n=this.peek()?.position??0;throw new Error(`位置 ${n}: 期望 "${t}"`)}}parseTernary(){const t=this.parseLogicalOr();if(this.eatPunc("?")){const n=this.parseTernary();this.expectPunc(":");const r=this.parseTernary();return{type:"ternary",cond:t,consequent:n,alternate:r}}return t}parseLogicalOr(){let t=this.parseLogicalAnd();for(;this.eatPunc("||");){const n=this.parseLogicalAnd();t={type:"binary",op:"||",left:t,right:n}}return t}parseLogicalAnd(){let t=this.parseEquality();for(;this.eatPunc("&&");){const n=this.parseEquality();t={type:"binary",op:"&&",left:t,right:n}}return t}parseEquality(){let t=this.parseRelational();for(;;){const n=this.peek();if(n?.type==="punc"&&["==","!=","===","!=="].includes(n.value)){this.pos++;const r=this.parseRelational();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseRelational(){let t=this.parseAdditive();for(;;){const n=this.peek();if(n?.type==="punc"&&["<",">","<=",">="].includes(n.value)){this.pos++;const r=this.parseAdditive();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseAdditive(){let t=this.parseMultiplicative();for(;;){const n=this.peek();if(n?.type==="punc"&&(n.value==="+"||n.value==="-")){this.pos++;const r=this.parseMultiplicative();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseMultiplicative(){let t=this.parseUnary();for(;;){const n=this.peek();if(n?.type==="punc"&&["*","/","%"].includes(n.value)){this.pos++;const r=this.parseUnary();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseUnary(){const t=this.peek();if(t?.type==="punc"&&["!","-","+"].includes(t.value)){this.pos++;const n=this.parseUnary();return{type:"unary",op:t.value,arg:n,prefix:!0}}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.eatPunc(".")){const n=this.next();if(n.type!=="ident")throw new Error(`位置 ${n.position}: 成员访问需要属性名`);t={type:"member",object:t,property:n.value,computed:!1}}else if(this.eatPunc("[")){const n=this.parseTernary();this.expectPunc("]"),n.type==="str"?t={type:"member",object:t,property:n.value,computed:!1}:t={type:"member",object:t,property:n.name??String(n.value),computed:!0}}else if(this.peek()?.type==="punc"&&this.peek()?.value==="("&&(t.type==="ident"||t.type==="member")){this.pos++;const n=this.parseArgs();t={type:"call",callee:t,args:n}}else return t}parseArgs(){const t=[];if(this.eatPunc(")"))return t;for(;;){if(t.push(this.parseTernary()),this.eatPunc(")"))return t;this.expectPunc(",")}}parsePrimary(){const t=this.next();if(t.type==="num"){const n=Number(t.value);if(isNaN(n))throw new Error(`非法数字: ${t.value}`);return{type:"num",value:n}}if(t.type==="str")return{type:"str",value:t.value};if(t.type==="bool")return{type:"bool",value:t.value==="true"};if(t.type==="ident")return{type:"ident",name:t.value};if(t.value==="("){const n=this.parseTernary();return this.expectPunc(")"),n}if(t.value==="["){const n=[];if(!this.eatPunc("]"))for(;n.push(this.parseTernary()),!this.eatPunc("]");)this.expectPunc(",");return{type:"array",elements:n}}if(t.value==="{"){const n=[];if(!this.eatPunc("}"))for(;;){const r=this.next();if(r.type!=="ident"&&r.type!=="str")throw new Error(`位置 ${r.position}: 对象键必须是标识符或字符串`);if(this.expectPunc(":"),n.push({key:r.value,value:this.parseTernary()}),this.eatPunc("}"))break;this.expectPunc(",")}return{type:"object",properties:n}}throw new Error(`位置 ${t.position}: 意外的符号: ${t.value}`)}}const Jl=20,Ng=8;function Ge(e,t=0){if(typeof e=="number")return Number.isFinite(e)?e:t;if(typeof e=="string"){const n=e.trim();if(n==="")return t;const r=Number(n);return Number.isFinite(r)?r:t}return e==null?t:typeof e=="boolean"?e?1:0:t}function Fg(e){if(typeof e=="number")return Number.isFinite(e);if(typeof e=="string"){const t=e.trim();return t!==""&&Number.isFinite(Number(t))}return!1}function fn(e){return!Number.isFinite(e)||Number.isInteger(e)||Math.abs(e)>=1e15?e:Number(e.toPrecision(12))}function hn(e){if(!Number.isFinite(e)||Number.isInteger(e))return 0;const t=String(e);if(t.includes("e")||t.includes("E"))return 0;const n=t.indexOf(".");return n===-1?0:t.length-n-1}function Ki(e,t){if(!Number.isFinite(e))return 0;const n=Math.min(Math.max(t,0),12);if(n===0)return Math.round(e);const r=10**n,o=e*r;return!Number.isFinite(o)||Math.abs(o)>=1e15?fn(e):Math.round(o)/r}function Zi(e,t){const n=Ge(e),r=Ge(t),o=n+r;return Ki(o,Math.max(hn(n),hn(r)))}function Ji(e,t){const n=Ge(e),r=Ge(t),o=n-r;return Ki(o,Math.max(hn(n),hn(r)))}function Ql(e,t){const n=Ge(e),r=Ge(t),o=n*r;return Ki(o,hn(n)+hn(r))}function ec(e,t){const n=Ge(e),r=Ge(t);return r===0?0:fn(n/r)}function zg(e,t){const n=Ge(e),r=Ge(t);return r===0?0:fn(n%r)}function Bg(e){if(e==null)return 2;const t=Math.trunc(Ge(e,2));return Number.isFinite(t)?Math.min(Math.max(t,-Jl),Jl):2}function Br(e,t,n){const r=Ge(e,0),o=Bg(t);if(r===0)return 0;if(Math.abs(r)>=1e21)return fn(r);const i=Math.max(o,0)+Ng,a=r.toFixed(i);if(!/^-?\d+(\.\d+)?$/.test(a))return fn(r);const l=a.startsWith("-"),c=a.replace("-","").replace(".","");let s=BigInt(c||"0");l&&(s=-s);const d=10n**BigInt(i-o),p=s<0n?-1n:1n,u=s<0n?-s:s;let f=u/d;const m=u%d,g=2n*m;n==="up"?m!==0n&&(f+=1n):n!=="down"&&g>=d&&(g>d||n==="half-up"||f%2n===1n)&&(f+=1n);const b=p*f;return fn(o>=0?Number(b)/10**o:Number(b)*10**-o)}const Qi={Math,Number,String,Boolean,parseInt,parseFloat,isNaN,true:!0,false:!1,null:null,undefined:void 0},Hg=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),Ug=new Set(["Number","String","Boolean","parseInt","parseFloat","isNaN"]);function Le(e,t,n={}){switch(e.type){case"num":return e.value;case"str":return e.value;case"bool":return e.value;case"ident":return qg(e.name,t);case"binary":return Wg(e,t,n);case"unary":return jg(e,t,n);case"ternary":return Le(e.cond,t,n)?Le(e.consequent,t,n):Le(e.alternate,t,n);case"member":return Yg(e,t,n);case"call":return Xg(e,t,n);case"array":return e.elements.map(r=>Le(r,t,n));case"object":return Object.fromEntries(e.properties.map(r=>[r.key,Le(r.value,t,n)]))}}function qg(e,t,n){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];if(Object.prototype.hasOwnProperty.call(Qi,e))return Qi[e];throw new Error(`未定义的标识符: ${e}`)}function Wg(e,t,n){const r=Le(e.left,t,n),o=Le(e.right,t,n);switch(e.op){case"+":return Vg(r,o)?Zi(r,o):Gg(r,o);case"-":return Ji(r,o);case"*":return Ql(r,o);case"/":return ec(r,o);case"%":return zg(r,o);case"<":return r<o;case">":return r>o;case"<=":return r<=o;case">=":return r>=o;case"==":return r==o;case"!=":return r!=o;case"===":return r===o;case"!==":return r!==o;case"&&":return r&&o;case"||":return r||o;default:throw new Error(`未知运算符: ${e.op}`)}}function jg(e,t,n){const r=Le(e.arg,t,n);switch(e.op){case"-":return Ji(0,r);case"+":return Ge(r);case"!":return!r;default:throw new Error(`未知一元运算符: ${e.op}`)}}function Gg(e,t){return`${e==null?"":String(e)}${t==null?"":String(t)}`}function Vg(e,t){const n=tc(e),r=tc(t);return n==="other"||r==="other"?!1:n==="num"||r==="num"}function tc(e){return e==null||e===""?"neutral":Fg(e)?"num":"other"}function Yg(e,t,n){const r=Le(e.object,t,n);if(r==null)throw new Error("无法访问空值的属性");if(Hg.has(e.property))throw new Error(`禁止访问属性: ${e.property}`);return r[e.property]}function Xg(e,t,n){if(e.callee.type==="ident"&&Ug.has(e.callee.name)){const o=Qi[e.callee.name],i=e.args.map(a=>Le(a,t,n));return o(...i)}if(e.callee.type==="member"&&e.callee.object.type==="ident"&&e.callee.object.name==="Math"){const o=Math[e.callee.property];if(typeof o!="function")throw new Error(`Math.${e.callee.property} 不是方法`);const i=e.args.map(a=>Le(a,t,n));return o(...i)}let r;if(e.callee.type==="ident")r=e.callee.name;else if(e.callee.type==="member")throw new Error("不支持方法调用,请使用顶级函数");if(r&&n[r]){const o=e.args.map(i=>Le(i,t,n));return n[r](...o)}throw r&&Object.prototype.hasOwnProperty.call(t,r)?new Error(`${r} 不是函数`):new Error(`不允许调用: ${r??"表达式"}`)}function Kg(e){const t=[];let n=0;const r=e.length;for(;n<r;){if(e[n]==="{"){let i=1,a=n+1;for(;a<r&&i>0;)e[a]==="{"?i++:e[a]==="}"&&i--,a++;if(i!==0)throw new Error(`位置 ${n}: 花括号未闭合`);const l=e.slice(n+1,a-1);if(l.trim()==="")throw new Error(`位置 ${n}: 空表达式`);const c=Yi(l),s=Xi(c);t.push({type:"expr",expression:s}),n=a;continue}let o=n;for(;o<r&&e[o]!=="{";)e[o]==="\\"&&o+1<r&&(e[o+1]==="{"||e[o+1]==="}")?o+=2:o++;t.push({type:"text",value:e.slice(n,o).replace(/\\([{}])/g,"$1")}),n=o}return{type:"template",parts:t}}function Zg(e,t,n={}){let r="";for(const o of e.parts)if(o.type==="text")r+=o.value;else{const i=Le(o.expression,t,n);r+=String(i??"")}return r}function nc(e,t={}){const n=Kg(e);return r=>Zg(n,r,t)}function Yn(e,t){if(e==null||t==null)return;if(typeof e=="object"&&t in e)return e[t];const n=t.split(".");let r=e;for(const o of n){if(r==null)return;r=r[o]}return r}function rc(e){const t=Number(e);if(isNaN(t))return String(e);const n=t<0?"-":"",r=Math.abs(t),[o,i]=r.toFixed(2).split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,",");return`${n}${a}.${i}`}function oc(e,t){let n;if(e instanceof Date)n=e;else if(typeof e=="number")n=new Date(e);else if(typeof e=="string")n=new Date(e);else return String(e);if(isNaN(n.getTime()))return String(e);const r=o=>String(o).padStart(2,"0");return t.replace("YYYY",String(n.getFullYear())).replace("MM",r(n.getMonth()+1)).replace("DD",r(n.getDate())).replace("HH",r(n.getHours())).replace("mm",r(n.getMinutes())).replace("ss",r(n.getSeconds()))}const ea=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],Jg=["","拾","佰","仟"],Qg=["","万","亿","万亿","亿亿"];function em(e){let t="",n=!1;for(let r=3;r>=0;r--){const o=Math.floor(e/10**r)%10;if(o===0){t&&(n=!0);continue}n&&(t+="零",n=!1),t+=ea[o]+Jg[r]}return t}function ic(e){const t=Number(e);if(isNaN(t))return String(e);if(t===0)return"零元整";const n=t<0?"负":"",[r,o]=Math.abs(t).toFixed(2).split("."),i=Math.ceil(r.length/4);let a="",l=!1;for(let d=i-1;d>=0;d--){const p=r.length-d*4,u=parseInt(r.slice(Math.max(0,p-4),p),10);if(u===0){a&&(l=!0);continue}a&&(l||u<1e3)&&(a+="零"),l=!1,a+=em(u)+(Qg[d]??"")}a=`${a||"零"}元`;const c=parseInt(o[0],10),s=parseInt(o[1],10);return c===0&&s===0?a+="整":(c===0?a+="零":a+=ea[c]+"角",s>0&&(a+=ea[s]+"分")),n+a}function ac(e,t,n){return e?t:n}function ta(e,t){return e.reduce((n,r)=>n+(Number(Yn(r,t))||0),0)}function sc(e,t){return e.length===0?0:ta(e,t)/e.length}function lc(e,t){return e.length}function cc(e,t){return e.length===0?0:Math.min(...e.map(n=>Number(Yn(n,t))||0))}function dc(e,t){return e.length===0?0:Math.max(...e.map(n=>Number(Yn(n,t))||0))}function uc(...e){return e.reduce((t,n)=>Zi(t,n),0)}function pc(...e){return e.length===0?0:e.slice(1).reduce((t,n)=>Ji(t,n),Zi(e[0],0))}function fc(...e){return e.length===0?0:e.reduce((t,n)=>Ql(t,n),1)}function hc(e,t){return ec(e,t)}function gc(e,t){return Br(e,t,"half-up")}function Hr(e,t){return Br(e,t,"up")}function Ur(e,t){return Br(e,t,"down")}function mc(e,t){return Br(e,t,"half-even")}class tm{constructor(){this.functions={}}registerFunction(t,n){this.functions[t]=n}evaluate(t,n){const r=Yi(t),o=Xi(r);return Le(o,n,this.functions)}render(t,n){return nc(t,this.functions)(n)}}const na=new tm,nm={MONEY:rc,DATE:oc,UPPER:ic,IF:ac,CONCAT:(...e)=>e.filter(t=>t!=null).map(String).join(""),IFEMPTY:(e,t)=>e!=null&&e!==""?String(e):t,LEN:e=>String(e).length,ADD:uc,SUB:pc,MUL:fc,DIV:hc,ROUND:gc,ROUNDUP:Hr,CEIL:Hr,ROUNDDOWN:Ur,FLOOR:Ur,ROUNDBANK:mc};for(const[e,t]of Object.entries(nm))na.registerFunction(e,t);function rm(e,t,n){switch(e.toUpperCase()){case"SUM":return ta(n,t);case"AVG":return sc(n,t);case"COUNT":return lc(n);case"MIN":return cc(n,t);case"MAX":return dc(n,t);default:return 0}}function om(e,t){return na.evaluate(e,t)}function Pt(e,t){if(!e)return"";if(!e.includes("{"))return e;const n=Array.isArray(t.rows)?t.rows:[],r=e.replace(/\{([^}]+)\}/g,(o,i)=>{let a=i.trim();return a=a.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(l,c,s)=>{const d=s.trim().replace(/^['"]|['"]$/g,"");return String(rm(c,d,n))}),`{${a}}`});try{return na.render(r,t)}catch{return e}}function bc(e,t,n,r){const o={...jr(),...t??{}},i=JSON.parse(JSON.stringify(e));i.header?.elements&&(i.header.elements=i.header.elements.map(l=>ra(l,o,n))),i.footer?.elements&&(i.footer.elements=i.footer.elements.map(l=>ra(l,o,n))),i.elements=i.elements.map(l=>ra(l,o,n));const a=r??n;if(a&&i.fonts?.length){const l=a.replace(/\/+$/,"");i.fonts=i.fonts.map(c=>({...c,files:(c.files??[]).map(s=>({...s,url:s.url?.startsWith("/")&&!s.url.startsWith("//")?l+s.url:s.url}))}))}return i}function ra(e,t,n){const r={...e,options:{...e.options}};if(!(r.type==="flowList"||r.printElementType?.type==="flowList")&&typeof r.options.formatter=="string"){const a=r.options.formatter;Kn(a)?r.options.rawFormatter=a:r.options.formatter=Pt(a,t)}if((r.type==="image"||r.printElementType?.type==="image")&&typeof r.options.src=="string"){let a=r.options.src;a.includes("{")&&(a=Pt(a,t)),a&&n&&a.startsWith("/")&&(a=n.replace(/\/+$/,"")+a),r.options.src=a}return(r.type==="table"||r.printElementType?.type==="table")&&am(r,t),(r.type==="flowList"||r.printElementType?.type==="flowList")&&im(r,t),r}function im(e,t){const n=typeof e.options.formatter=="string"?e.options.formatter:"",r={...e.options,dataSource:e.options.dataSource??Or(n,t)},{list:o,key:i}=yc(r,t),a=c=>i?{...t,...c,[i]:c}:{...t,...c},l=o.map(c=>n?Kn(n)?n:Pt(n,a(c)):String(c??""));if(e.options._flowItems=l,e.options._flowRawFormatter=Kn(n)?n:void 0,Bt(e.options.flowLayoutMode)==="dynamic"){const c=nl(e.options.width??0,sn(e.options)),s=l.length>0?l:String(e.options.testData??"").split(/\r?\n/).map(d=>d.trim()).filter(Boolean);e.options._flowRows=vi(s,{width:c,columns:Qe(e.options.flowColumns),gapX:rt(e.options.flowGapX),fontSizePt:e.options.fontSize??12,autoSpan:e.options.flowAutoSpan===!0,maxSpan:Ht(e.options.flowMaxSpan,e.options.flowColumns)})}}function yc(e,t){const n=e.dataSource??e.fields?.[0]?.dataSource??e.fields?.[0]?.field;if(n&&Array.isArray(t[n]))return{list:t[n],key:n};for(const[r,o]of Object.entries(t))if(Array.isArray(o))return{list:o,key:r};return{list:[],key:n}}function am(e,t){const n=e.options,r=n.tableRows;if(!Array.isArray(r)||r.length===0)return;const o=n.tableMode??"dynamic",{list:i,key:a}=o==="dynamic"?yc(n,t):{list:[],key:void 0},l=m=>a?{...t,...m,[a]:m}:{...t,...m},c=a?i.map(m=>({...m,[a]:m})):i,s=[],d=[],p=[],u=[];let f=-1;for(const m of r){if(o==="dynamic"&&m.type==="data"){sm(m.cells);for(const g of i){f<0&&(f=s.length);const b=l(g);s.push(Wr(m,v=>qr(v,b))),d.push(b)}continue}if(o==="dynamic"&&m.type==="subtotal"){const g=Wr(m,b=>qr(b,{rows:c,...t}),!0);p.push(g),s.push(g);continue}if(o==="dynamic"&&m.type==="summary"){const g=Wr(m,b=>qr(b,{rows:c,...t}));u.push(g),s.push(g);continue}s.push(Wr(m,g=>qr(g,t)))}n._renderRows=s,n._repeatHeaderCount=lm(r),n._dataRowCtx=d,n._dataStartIdx=f<0?s.length:f,n._subtotalTemplates=p,n._summaryRows=u,n._mainData=t}function sm(e){const t=new Set;e.forEach((n,r)=>{if(!n||n.merged)return;const o=Math.max(n.colspan??1,1);for(let i=1;i<o;i++)t.add(r+i)}),e.forEach((n,r)=>{n.rowspan&&(n.rowspan=1),n.merged&&!t.has(r)&&(n.merged=!1)})}function qr(e,t){const n=e.formatter;return n?Kn(n)?n:Pt(n,t):""}function Wr(e,t,n=!1){return{type:e.type,height:e.height??8,cells:e.cells.map(r=>({content:r.merged?"":t(r),...(n||Kn(r.formatter))&&!r.merged?{rawFormatter:r.formatter??""}:{},cellType:r.cellType,barcodeType:r.barcodeType,qrCodeLevel:r.qrCodeLevel,qrQuietZone:r.qrQuietZone,barQuietZone:r.barQuietZone,barHeight:r.barHeight,barWidth:r.barWidth,barFontSize:r.barFontSize,showBarcodeText:r.showBarcodeText,printerDpi:r.printerDpi,fit:r.fit,objectPosition:r.objectPosition,fitScale:r.fitScale,maxWidth:r.maxWidth,maxHeight:r.maxHeight,rowspan:r.rowspan??1,colspan:r.colspan??1,merged:r.merged===!0,...r.mergeSameValue===!0?{mergeSameValue:!0}:{},align:r.align,valign:r.valign,fontSize:r.fontSize,fontFamily:r.fontFamily,fontWeight:r.fontWeight,color:r.color,backgroundColor:r.backgroundColor,borders:r.borders,padding:r.padding,wordWrap:r.wordWrap,textFit:r.textFit,shrinkMinFontSize:r.shrinkMinFontSize}))}}function lm(e){const t=cm(e);return t===0||!e.slice(0,t).some(r=>r.repeatOnPage===!0)?0:um(e,t)}function cm(e){let t=0;for(const n of e){if(n?.type!=="header")break;t++}return t}function dm(e,t){for(let n=0;n<t;n++)for(const r of e[n]?.cells??[])if(!r?.merged&&n+(r?.rowspan??1)>t)return!1;return!0}function um(e,t){for(let n=t;n>=1;n--)if(dm(e,n))return n;return 1}const Xn=e=>String(e).padStart(2,"0");function jr(e=new Date,t={}){return{printDate:`${e.getFullYear()}-${Xn(e.getMonth()+1)}-${Xn(e.getDate())}`,printTime:`${Xn(e.getHours())}:${Xn(e.getMinutes())}:${Xn(e.getSeconds())}`,pageIndex:t.pageIndex??1,totalPages:t.totalPages??1}}function Kn(e){return typeof e=="string"&&/\b(pageIndex|totalPages)\b/.test(e)}function oa(e,t=new Date){const{printDate:n,printTime:r}=jr(t);return e.replace(/\{printDate\}/g,n).replace(/\{printTime\}/g,r)}function Zn(e){const t=[];for(const n of e??[]){const r=n?.family?.trim();if(!r)continue;const o=`"${r.replace(/"/g,"")}"`;for(const i of n.files??[]){const a=i?.url?.trim();if(!a)continue;const l=Number.isFinite(i.weight)?Number(i.weight):400,c=i.style==="italic"?"italic":"normal";t.push(`@font-face{font-family:${o};src:url("${a}")${pm(a)};font-weight:${l};font-style:${c};font-display:block;}`)}}return t.length?`${t.join("")}
2
+ `:""}function pm(e){const t=e.split(/[?#]/)[0].toLowerCase();return t.endsWith(".woff2")?' format("woff2")':t.endsWith(".woff")?' format("woff")':t.endsWith(".ttf")?' format("truetype")':t.endsWith(".otf")?' format("opentype")':""}const ia=['"Microsoft YaHei"','"PingFang SC"','"Helvetica Neue"',"Arial","sans-serif"];function aa(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function sa(e){const t=e?.trim();return t?[t.includes(",")?t:`"${t.replace(/"/g,"")}"`,...ia].join(", "):ia.join(", ")}function la(e){return e?sa(e):"inherit"}function fm(e){const t=[],n=new Set;for(const r of e??[]){const o=r?.family?.trim();if(!o)continue;const i=o.toLowerCase();if(n.has(i))continue;n.add(i);const a=r?.label?.trim();t.push(a?{family:o,label:a}:{family:o})}return t}function vc(e,t){const n=t?.trim().toLowerCase();if(n)return e.find(r=>r.family.trim().toLowerCase()===n)}function wc(e){return e.label?`${e.label}(${e.family})`:e.family}function Jn(e){return e.toLowerCase().replace(/\s+/g,"")}function xc(e,t){if(e===t)return 0;if(e.startsWith(t))return 1;if(e.includes(t))return 2;let n=0;for(const r of e)if(r===t[n]&&n++,n===t.length)return 3;return-1}function hm(e,t){const n=xc(Jn(e.family),t);if(!e.label)return n;const r=xc(Jn(e.label),t);return n<0?r:r<0?n:Math.min(n,r)}function gm(e,t){const n=Jn(t.trim());return n?e.map((r,o)=>({font:r,index:o,rank:hm(r,n)})).filter(r=>r.rank>=0).sort((r,o)=>r.rank-o.rank||r.index-o.index).map(r=>r.font):[...e]}function V(e){return`${e}mm`}function ca(e,t){const n=dn(e);return t&&t>0&&ct(e)?{width:n.width,height:t}:n}function Ec(e,t){const n=et(e);return t&&t>0&&ct(e)?{width:n.width,height:t}:n}function Sc(){return`
3
3
  /* ── 全局重置 ── */
4
4
  * { margin: 0; padding: 0; box-sizing: border-box; }
5
5
 
6
6
  /* 打印必须保留元素背景色(Chromium 默认剔除背景,需显式声明) */
7
7
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
8
8
 
9
- body { font-family: ${Vi.join(", ")}; }
9
+ body { font-family: ${ia.join(", ")}; }
10
10
 
11
11
  /* ── 屏幕预览:灰底 + 纸张阴影/页间距;打印时去除 ── */
12
12
  @media screen {
@@ -17,7 +17,7 @@ body { font-family: ${Vi.join(", ")}; }
17
17
  body { background: #fff; }
18
18
  .print-page { margin: 0; box-shadow: none; }
19
19
  }
20
- `}function pc(){return`
20
+ `}function _c(){return`
21
21
  /* ── 水印层:覆盖整页、位于所有内容之下(显式矢量瓦片,禁止用 CSS 平铺背景:
22
22
  Chromium 会把它编译成 PDF 平铺图案,出纸链路的 RIP 会忽略图案矩阵导致水印放大/错位) ── */
23
23
  .watermark-layer {
@@ -35,7 +35,7 @@ body { font-family: ${Vi.join(", ")}; }
35
35
  position: absolute;
36
36
  pointer-events: none;
37
37
  }
38
- `}function fc(){return`
38
+ `}function Mc(){return`
39
39
  /* ── 元素通用定位 ── */
40
40
  .print-element {
41
41
  position: absolute;
@@ -71,28 +71,28 @@ body { font-family: ${Vi.join(", ")}; }
71
71
  height: auto;
72
72
  overflow: visible;
73
73
  }
74
- `}function hc(e){return`
74
+ `}function Tc(e){return`
75
75
  /* ── 打印纸张:浏览器原生打印按此尺寸分页(Playwright page.pdf 以显式宽高为准,无副作用) ── */
76
- @page { size: ${U(e.width)} ${U(e.height)}; margin: 0; }
77
- `}function gc(e,t,n){const r=`
76
+ @page { size: ${V(e.width)} ${V(e.height)}; margin: 0; }
77
+ `}function kc(e,t,n){const r=`
78
78
  /* ── 出纸转子:设计稿整页旋转 ${n}° 填入出纸纸张 ── */
79
79
  .print-page-rotor {
80
80
  position: absolute;
81
81
  top: 0;
82
82
  left: 0;
83
- width: ${U(e.width)};
84
- height: ${U(e.height)};
85
- padding: ${U(t.top)} ${U(t.right)} ${U(t.bottom)} ${U(t.left)};
83
+ width: ${V(e.width)};
84
+ height: ${V(e.height)};
85
+ padding: ${V(t.top)} ${V(t.right)} ${V(t.bottom)} ${V(t.left)};
86
86
  box-sizing: border-box;
87
87
  transform-origin: 0 0;
88
- }`;if(n===0)return r.trim();const i={90:`translate(${U(e.height)}, 0mm) rotate(90deg)`,180:`translate(${U(e.width)}, ${U(e.height)}) rotate(180deg)`,270:`translate(0mm, ${U(e.width)}) rotate(270deg)`}[n];return[r.trim(),`.print-page-rotor-${n} {
88
+ }`;if(n===0)return r.trim();const i={90:`translate(${V(e.height)}, 0mm) rotate(90deg)`,180:`translate(${V(e.width)}, ${V(e.height)}) rotate(180deg)`,270:`translate(0mm, ${V(e.width)}) rotate(270deg)`}[n];return[r.trim(),`.print-page-rotor-${n} {
89
89
  transform: ${i};
90
90
  }`].join(`
91
- `)}function mc(e,t,n,r){const{top:o,right:i,bottom:a,left:l}=e.margins,c=r?"0":`${U(o)} ${U(i)} ${U(a)} ${U(l)}`;return`
91
+ `)}function Cc(e,t,n,r){const{top:o,right:i,bottom:a,left:l}=e.margins,c=r?"0":`${V(o)} ${V(i)} ${V(a)} ${V(l)}`;return`
92
92
  /* ── 纸张页面 ── */
93
93
  ${n} {
94
- width: ${U(t.width)};
95
- min-height: ${U(t.height)};
94
+ width: ${V(t.width)};
95
+ min-height: ${V(t.height)};
96
96
  background: ${e.pageBackground??"#fff"};
97
97
  padding: ${c};
98
98
  position: relative;
@@ -102,11 +102,11 @@ ${n} {
102
102
  .print-page:last-child {
103
103
  page-break-after: auto;
104
104
  }
105
- `}function bc(e,t,n){const{right:r,left:o}=e.margins,{bottom:i}=e.margins,a=e.header?.height??0,l=e.footer?.height??0,c=t.width-o-r;return`
105
+ `}function Ac(e,t,n){const{right:r,left:o}=e.margins,{bottom:i}=e.margins,a=e.header?.height??0,l=e.footer?.height??0,c=t.width-o-r;return`
106
106
  /* ── 页眉 ── */
107
107
  ${n}.page-header {
108
- width: ${U(c)};
109
- height: ${U(a)};
108
+ width: ${V(c)};
109
+ height: ${V(a)};
110
110
  position: relative;
111
111
  }
112
112
 
@@ -115,33 +115,33 @@ ${n}.page-header {
115
115
  与设计器 CanvasPaper 的三区几何一致。
116
116
  绝对定位的包含块是 padding box 外缘(= 纸面),left 须显式补左边距。 */
117
117
  ${n}.page-footer {
118
- width: ${U(c)};
119
- height: ${U(l)};
118
+ width: ${V(c)};
119
+ height: ${V(l)};
120
120
  position: absolute;
121
- top: ${U(t.height-i-l)};
122
- left: ${U(o)};
121
+ top: ${V(t.height-i-l)};
122
+ left: ${V(o)};
123
123
  }
124
124
 
125
125
  /* ── 内容区 ── */
126
126
  ${n}.content-area {
127
- width: ${U(c)};
127
+ width: ${V(c)};
128
128
  position: relative;
129
129
  overflow: visible;
130
130
  }
131
- `}function om(){return[uc(),pc(),fc()].join("").trim()}function im(e,t){return hc(Ji(e,t)).trim()}function am(e,t,n){const r=mi(e),o=r!==0,i=Ji(e,n),a=dc(e,n),l=t?`${t}.print-page`:".print-page",c=t?`${t} `:"";return[mc(e,i,l,o),bc(e,a,c),...o?[gc(a,e.margins,r)]:[]].join("").trim()}function Wn(e,t){const n=mi(e),r=n!==0,o=Ji(e,t),i=dc(e,t);return[hc(o),uc(),mc(e,o,".print-page",r),pc(),bc(e,i,""),fc(),...r?[gc(i,e.margins,n)]:[]].join("").trim()}const Qi=".print-copy:not(:last-child){break-after:page;page-break-after:always;}";function sm(e,t){if(!tt(e))return`${Wn(e)}
132
- ${Qi}`;const{bottom:n}=e.margins,r=e.footer?.height??0,o=Ze(e).width,i=Wn(e,t[0]?.heightMm),a=t.map((l,c)=>{const s=l.heightMm,d=[`@page copy${c} { size: ${U(o)} ${s?U(s):"auto"}; margin: 0; }`,`.print-copy-${c} { page: copy${c}; }`];return s&&(d.push(`.print-copy-${c} .print-page { min-height: ${U(s)}; }`),d.push(`.print-copy-${c} .page-footer { top: ${U(s-n-r)}; }`)),d.join(`
131
+ `}function mm(){return[Sc(),_c(),Mc()].join("").trim()}function bm(e,t){return Tc(ca(e,t)).trim()}function ym(e,t,n){const r=ki(e),o=r!==0,i=ca(e,n),a=Ec(e,n),l=t?`${t}.print-page`:".print-page",c=t?`${t} `:"";return[Cc(e,i,l,o),Ac(e,a,c),...o?[kc(a,e.margins,r)]:[]].join("").trim()}function Qn(e,t){const n=ki(e),r=n!==0,o=ca(e,t),i=Ec(e,t);return[Tc(o),Sc(),Cc(e,o,".print-page",r),_c(),Ac(e,i,""),Mc(),...r?[kc(i,e.margins,n)]:[]].join("").trim()}const da=".print-copy:not(:last-child){break-after:page;page-break-after:always;}";function vm(e,t){if(!ct(e))return`${Qn(e)}
132
+ ${da}`;const{bottom:n}=e.margins,r=e.footer?.height??0,o=et(e).width,i=Qn(e,t[0]?.heightMm),a=t.map((l,c)=>{const s=l.heightMm,d=[`@page copy${c} { size: ${V(o)} ${s?V(s):"auto"}; margin: 0; }`,`.print-copy-${c} { page: copy${c}; }`];return s&&(d.push(`.print-copy-${c} .print-page { min-height: ${V(s)}; }`),d.push(`.print-copy-${c} .page-footer { top: ${V(s-n-r)}; }`)),d.join(`
133
133
  `)}).join(`
134
134
  `);return`${i}
135
135
  ${a}
136
- ${Qi}`}function lm(e){return`
136
+ ${da}`}function wm(e){return`
137
137
  /* ── 拼版纸张:@page 尺寸 = 目标纸。服务端/客户端链路以 paperMm 显式定尺寸、不看这里,
138
138
  但浏览器链路只看 @page,故这条是硬需求 ── */
139
- @page { size: ${U(e.sheet.width)} ${U(e.sheet.height)}; margin: 0; }
139
+ @page { size: ${V(e.sheet.width)} ${V(e.sheet.height)}; margin: 0; }
140
140
 
141
141
  /* ── 一张目标纸 ── */
142
142
  .print-sheet {
143
- width: ${U(e.sheet.width)};
144
- height: ${U(e.sheet.height)};
143
+ width: ${V(e.sheet.width)};
144
+ height: ${V(e.sheet.height)};
145
145
  position: relative;
146
146
  overflow: hidden;
147
147
  break-after: page;
@@ -152,8 +152,8 @@ ${Qi}`}function lm(e){return`
152
152
  /* ── 一格:绝对定位,位置由 tilePosition() 以行内 style 给出 ── */
153
153
  .print-tile {
154
154
  position: absolute;
155
- width: ${U(e.tile.width)};
156
- height: ${U(e.tile.height)};
155
+ width: ${V(e.tile.width)};
156
+ height: ${V(e.tile.height)};
157
157
  overflow: hidden;
158
158
  }
159
159
  /* 防御性声明:绝对定位 + overflow:hidden 容器内的后代不产生分页点,当前布局下无实际作用;
@@ -166,12 +166,12 @@ ${Qi}`}function lm(e){return`
166
166
  否则设计器预览错位 3.17mm、与出纸不一致 */
167
167
  .print-tile > .print-page { margin: 0; box-shadow: none; }
168
168
  }
169
- `}function ea(e,t,n,r,o){const i=["position:absolute",`left:${U(e)}`,`top:${U(t)}`,`width:${U(n)}`];return r!==void 0&&r>0&&i.push(`height:${U(r)}`),o!==void 0&&i.push(`z-index:${o}`),i.join(";")+";"}const yc=25.4/96,ae={color:"#cccccc",opacity:.15,rotate:-30,tileWidth:260,tileHeight:180,minTileWidth:140,minTileHeight:100,fontSize:16},cm={dense:{width:200,height:120,label:"密"},medium:{width:260,height:180,label:"中(默认)"},loose:{width:340,height:260,label:"疏"}};function vc(e,t,n){const r=typeof e=="number"&&Number.isFinite(e)?e:t;return Math.max(n,Math.round(r))}function dm(e){return{width:vc(e?.tileWidth,ae.tileWidth,ae.minTileWidth),height:vc(e?.tileHeight,ae.tileHeight,ae.minTileHeight)}}function um(e){return e?!e.mode||e.mode==="fixed"?!!e.content&&e.content.trim().length>0:!!e.binding&&e.binding.trim().length>0:!1}function pm(e,t,n){if(!e)return"";let r="";if(!e.mode||e.mode==="fixed")r=e.content??"";else if(typeof e.binding=="string"&&e.binding.trim()){const o=e.binding.trim(),i=Array.isArray(t)?t[0]??{}:t??{},a={...$r(),...n,...i};let l;if(o.includes("{"))l=Mt(o,a);else{try{l=Yg(o,a)}catch{l=void 0}(l==null||typeof l=="object")&&(l=zn(i,o))}l!=null&&typeof l!="object"&&String(l)!==o?r=String(l):r=e.testData??`[${e.binding}]`}return e.timestamp&&r&&(r=`${r} ${fm(e.format)}`),r}function jn(e){return String(e).padStart(2,"0")}function fm(e){const t=e&&e.trim()?e:"YYYY-MM-DD HH:mm",n=new Date,r={YYYY:String(n.getFullYear()),MM:jn(n.getMonth()+1),DD:jn(n.getDate()),HH:jn(n.getHours()),mm:jn(n.getMinutes()),ss:jn(n.getSeconds())};return t.replace(/YYYY|MM|DD|HH|mm|ss/g,o=>r[o]??o)}function Lr(e){return Math.round(e*1e4)/1e4}function hm(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function wc(e,t,n,r){if(!um(e))return null;const o=pm(e,t,r);if(!o)return null;const i=dm(e),a=Lr(i.width*yc),l=Lr(i.height*yc),c={width:Math.max(0,Number.isFinite(n?.width)?n.width:0),height:Math.max(0,Number.isFinite(n?.height)?n.height:0)},s=Math.max(1,Math.ceil(c.width/a)),d=Math.max(1,Math.ceil(c.height/l)),p=[];for(let u=0;u<d;u++)for(let f=0;f<s;f++)p.push({leftMm:Lr(f*a),topMm:Lr(u*l),widthMm:a,heightMm:l});return{text:o,color:e?.color||ae.color,rotate:e?.rotate??ae.rotate,opacity:e?.opacity??ae.opacity,fontSizePx:ae.fontSize,tileWidthPx:i.width,tileHeightPx:i.height,tileWidthMm:a,tileHeightMm:l,columns:s,rows:d,tiles:p}}function gm(e,t){const n=e.tileWidthPx,r=e.tileHeightPx,o=n/2,i=r/2;return`<svg class="watermark-tile" style="${`left:${t.leftMm}mm;top:${t.topMm}mm;width:${t.widthMm}mm;height:${t.heightMm}mm`}" viewBox="0 0 ${n} ${r}" xmlns="http://www.w3.org/2000/svg"><text x="${o}" y="${i}" font-size="${e.fontSizePx}" fill="${e.color}" text-anchor="middle" dominant-baseline="middle" transform="rotate(${e.rotate},${o},${i})">${hm(e.text)}</text></svg>`}function xc(e,t,n,r){const o=wc(e,t,n,r);if(!o)return"";const i=o.tiles.map(a=>gm(o,a)).join(`
169
+ `}function Gr(e,t,n,r,o){const i=["position:absolute",`left:${V(e)}`,`top:${V(t)}`,`width:${V(n)}`];return r!==void 0&&r>0&&i.push(`height:${V(r)}`),o!==void 0&&i.push(`z-index:${o}`),i.join(";")+";"}const Oc=25.4/96,ae={color:"#cccccc",opacity:.15,rotate:-30,tileWidth:260,tileHeight:180,minTileWidth:140,minTileHeight:100,fontSize:16},xm={dense:{width:200,height:120,label:"密"},medium:{width:260,height:180,label:"中(默认)"},loose:{width:340,height:260,label:"疏"}};function Ic(e,t,n){const r=typeof e=="number"&&Number.isFinite(e)?e:t;return Math.max(n,Math.round(r))}function Em(e){return{width:Ic(e?.tileWidth,ae.tileWidth,ae.minTileWidth),height:Ic(e?.tileHeight,ae.tileHeight,ae.minTileHeight)}}function Sm(e){return e?!e.mode||e.mode==="fixed"?!!e.content&&e.content.trim().length>0:!!e.binding&&e.binding.trim().length>0:!1}function _m(e,t,n){if(!e)return"";let r="";if(!e.mode||e.mode==="fixed")r=e.content??"";else if(typeof e.binding=="string"&&e.binding.trim()){const o=e.binding.trim(),i=Array.isArray(t)?t[0]??{}:t??{},a={...jr(),...n,...i};let l;if(o.includes("{"))l=Pt(o,a);else{try{l=om(o,a)}catch{l=void 0}(l==null||typeof l=="object")&&(l=Yn(i,o))}l!=null&&typeof l!="object"&&String(l)!==o?r=String(l):r=e.testData??`[${e.binding}]`}return e.timestamp&&r&&(r=`${r} ${Mm(e.format)}`),r}function er(e){return String(e).padStart(2,"0")}function Mm(e){const t=e&&e.trim()?e:"YYYY-MM-DD HH:mm",n=new Date,r={YYYY:String(n.getFullYear()),MM:er(n.getMonth()+1),DD:er(n.getDate()),HH:er(n.getHours()),mm:er(n.getMinutes()),ss:er(n.getSeconds())};return t.replace(/YYYY|MM|DD|HH|mm|ss/g,o=>r[o]??o)}function Vr(e){return Math.round(e*1e4)/1e4}function Tm(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Pc(e,t,n,r){if(!Sm(e))return null;const o=_m(e,t,r);if(!o)return null;const i=Em(e),a=Vr(i.width*Oc),l=Vr(i.height*Oc),c={width:Math.max(0,Number.isFinite(n?.width)?n.width:0),height:Math.max(0,Number.isFinite(n?.height)?n.height:0)},s=Math.max(1,Math.ceil(c.width/a)),d=Math.max(1,Math.ceil(c.height/l)),p=[];for(let u=0;u<d;u++)for(let f=0;f<s;f++)p.push({leftMm:Vr(f*a),topMm:Vr(u*l),widthMm:a,heightMm:l});return{text:o,color:e?.color||ae.color,rotate:e?.rotate??ae.rotate,opacity:e?.opacity??ae.opacity,fontSizePx:ae.fontSize,tileWidthPx:i.width,tileHeightPx:i.height,tileWidthMm:a,tileHeightMm:l,columns:s,rows:d,tiles:p}}function km(e,t){const n=e.tileWidthPx,r=e.tileHeightPx,o=n/2,i=r/2;return`<svg class="watermark-tile" style="${`left:${t.leftMm}mm;top:${t.topMm}mm;width:${t.widthMm}mm;height:${t.heightMm}mm`}" viewBox="0 0 ${n} ${r}" xmlns="http://www.w3.org/2000/svg"><text x="${o}" y="${i}" font-size="${e.fontSizePx}" fill="${e.color}" text-anchor="middle" dominant-baseline="middle" transform="rotate(${e.rotate},${o},${i})">${Tm(e.text)}</text></svg>`}function Rc(e,t,n,r){const o=Pc(e,t,n,r);if(!o)return"";const i=o.tiles.map(a=>km(o,a)).join(`
170
170
  `);return`
171
171
  <div class="watermark-layer" style="opacity:${o.opacity}">
172
172
  ${i}
173
- </div>`}function ta(e){return{...e.data??{},pageIndex:e.pageIndex,totalPages:e.totalPages}}function mm(e){return Array.isArray(e)?e[0]??{}:e??{}}function Nr(e,t,n,r){const o=Un(e.fonts)+Wn(e,r?.pageHeightMm),i=r?.isMeasurementPass===!0,a=i?1:t.length,l={codeRenderer:r?.codeRenderer,pageHeightMm:r?.pageHeightMm};return i?bm(e,o,l,n):ym(e,t,o,a,l,n)}function bm(e,t,n,r){const i=sa(e).width-e.margins.left-e.margins.right,a=e.elements.map(s=>Br(s,!0,void 0,void 0,n)).join(`
174
- `),l=ia(e.header?.elements??[],i,0,0,n);let c=`<!DOCTYPE html>
173
+ </div>`}const Dc=(e,t)=>`${e}:${t}`;function Cm(e,t,n){if(n-t<2)return;const r=new Set;for(let i=t;i<n;i++){const a=e[i];a?.type==="data"&&a.cells.forEach((l,c)=>{l?.mergeSameValue===!0&&r.add(c)})}if(r.size===0)return;const o={rowspan:new Map,merged:new Set};for(const i of r){let a=!1;for(let c=t;c<n&&!a;c++)e[c]?.cells[i]?.rawFormatter&&(a=!0);if(a)continue;let l=t;for(;l<n;){if(!Am(e[l],i)){l++;continue}const c=e[l].cells[i].content;let s=l;for(;s+1<n&&Om(e[s+1],i,c);)s++;if(s>l){o.rowspan.set(Dc(l,i),s-l+1);for(let d=l+1;d<=s;d++)o.merged.add(Dc(d,i))}l=s+1}}return o.rowspan.size>0?o:void 0}function Am(e,t){if(!e||e.type!=="data")return!1;const n=e.cells[t];return!n||n.merged||n.mergeSameValue!==!0?!1:(n.content??"").trim()!==""}function Om(e,t,n){if(!e||e.type!=="data")return!1;const r=e.cells[t];return!r||r.merged||r.mergeSameValue!==!0?!1:r.content===n}function ua(e){return{...e.data??{},pageIndex:e.pageIndex,totalPages:e.totalPages}}function Im(e){return Array.isArray(e)?e[0]??{}:e??{}}function Yr(e,t,n,r){const o=Zn(e.fonts)+Qn(e,r?.pageHeightMm),i=r?.isMeasurementPass===!0,a=i?1:t.length,l={codeRenderer:r?.codeRenderer,pageHeightMm:r?.pageHeightMm};return i?Pm(e,o,l,n):Rm(e,t,o,a,l,n)}function Pm(e,t,n,r){const i=ba(e).width-e.margins.left-e.margins.right,a=e.elements.map(s=>Zr(s,!0,void 0,void 0,n)).join(`
174
+ `),l=ga(e.header?.elements??[],i,0,0,n);let c=`<!DOCTYPE html>
175
175
  <html lang="zh-CN">
176
176
  <head>
177
177
  <meta charset="UTF-8">
@@ -179,15 +179,15 @@ ${i}
179
179
  </head>
180
180
  <body class="measure-mode">
181
181
  <section class="print-page" data-measure-page="0">
182
- ${xc(e.watermark,r,sa(e))}
182
+ ${Rc(e.watermark,r,ba(e))}
183
183
  <div class="page-header">${l}</div>
184
184
  <div class="content-area" style="height:auto;overflow:visible;">
185
185
  ${a}
186
186
  </div>
187
187
  </section>
188
188
  </body>
189
- </html>`;return c=Yi(c),c}function Fr(e,t,n,r,o){const i=o?.pageOffset??0,a=o?.totalPages??t.length,l=t.map(c=>{const s=c.pageIndex+1+i;return vm(e,c,s,a,r,n,o?.pageClass)}).join(`
190
- `);return Yi(l)}function zr(e,t,n){const r=`<!DOCTYPE html>
189
+ </html>`;return c=oa(c),c}function Xr(e,t,n,r,o){const i=o?.pageOffset??0,a=o?.totalPages??t.length,l=t.map(c=>{const s=c.pageIndex+1+i;return Dm(e,c,s,a,r,n,o?.pageClass)}).join(`
190
+ `);return oa(l)}function Kr(e,t,n){const r=`<!DOCTYPE html>
191
191
  <html lang="zh-CN">
192
192
  <head>
193
193
  <meta charset="UTF-8">
@@ -196,68 +196,80 @@ ${i}
196
196
  <body${n?` class="${n}"`:""}>
197
197
  ${t}
198
198
  </body>
199
- </html>`;return Yi(r)}function ym(e,t,n,r,o,i){const a=Fr(e,t,i??{},o);return zr(n,a,tt(e)?"continuous":void 0)}function vm(e,t,n,r,o,i,a){const l=sa(e),c={width:l.width,height:o.pageHeightMm&&o.pageHeightMm>0?o.pageHeightMm:l.height},s=l.width-e.margins.left-e.margins.right,d={pageIndex:n,totalPages:r,data:mm(i)},p=wm(e,d),u={...o,pageVars:d},f=ia(p.header?.elements??[],s,n,r,u),g=ia(p.footer?.elements??[],s,n,r,u);let m=t.sections.map(_=>Em(_,p,u)).join(`
200
- `);m=m.replace(/\{pageIndex\}/g,String(n)),m=m.replace(/\{totalPages\}/g,String(r));const y=`
201
- ${xc(e.watermark,i,c,{pageIndex:n,totalPages:r})}
199
+ </html>`;return oa(r)}function Rm(e,t,n,r,o,i){const a=Xr(e,t,i??{},o);return Kr(n,a,ct(e)?"continuous":void 0)}function Dm(e,t,n,r,o,i,a){const l=ba(e),c={width:l.width,height:o.pageHeightMm&&o.pageHeightMm>0?o.pageHeightMm:l.height},s=l.width-e.margins.left-e.margins.right,d={pageIndex:n,totalPages:r,data:Im(i)},p=$m(e,d),u={...o,pageVars:d},f=ga(p.header?.elements??[],s,n,r,u),m=ga(p.footer?.elements??[],s,n,r,u);let g=t.sections.map(_=>Nm(_,p,u)).join(`
200
+ `);g=g.replace(/\{pageIndex\}/g,String(n)),g=g.replace(/\{totalPages\}/g,String(r));const b=`
201
+ ${Rc(e.watermark,i,c,{pageIndex:n,totalPages:r})}
202
202
  <div class="page-header">${f}</div>
203
203
  <div class="content-area">
204
- ${m}
204
+ ${g}
205
205
  </div>
206
- <div class="page-footer">${g}</div>`,v=mi(e),w=v!==0?`<div class="print-page-rotor print-page-rotor-${v}">${y}</div>`:y;return`<section class="print-page${a?` ${a}`:""}" data-page="${n}">
206
+ <div class="page-footer">${m}</div>`,v=ki(e),w=v!==0?`<div class="print-page-rotor print-page-rotor-${v}">${b}</div>`:b;return`<section class="print-page${a?` ${a}`:""}" data-page="${n}">
207
207
  ${w}
208
- </section>`}function wm(e,t){if(!xm(e))return e;const n=ta(t),r=i=>{const a=i.options?.rawFormatter;return typeof a!="string"?i:{...i,options:{...i.options,formatter:Mt(a,n)}}},o=i=>i&&{...i,elements:(i.elements??[]).map(r)};return{...e,elements:e.elements.map(r),header:o(e.header),footer:o(e.footer)}}function xm(e){return[e.elements,e.header?.elements,e.footer?.elements].some(n=>(n??[]).some(r=>typeof r.options?.rawFormatter=="string"))}function na(e,t){const n=e.rawFormatter;return typeof n=="string"&&n!==""&&t?.pageVars?Mt(n,ta(t.pageVars)):e.content}function Em(e,t,n){const r=aa(t,e.elementId);return r?e.type==="table-slice"?Om(r,e,n):e.type==="flow-group"?Im(r,e,t,n):Br(r,!1,void 0,e.renderTop,n):`<!-- element not found: ${e.elementId} -->`}const Ec={top:"flex-start",middle:"center",bottom:"flex-end"},Sm={left:"flex-start",center:"center",right:"flex-end"};function ra(e,t){const n=[],r=e._fitFontSize===void 0?e.fontSize:ai(e._fitFontSize);return r&&n.push(`font-size:${r}pt`),e.fontFamily&&n.push(`font-family:${Ki(Xi(e.fontFamily))}`),e.fontWeight&&n.push(`font-weight:${e.fontWeight}`),e.color&&n.push(`color:${e.color}`),e.backgroundColor&&n.push(`background-color:${e.backgroundColor}`),e.lineHeight?n.push(`line-height:${e.lineHeight}pt`):t&&n.push(`line-height:${t}`),e.letterSpacing&&n.push(`letter-spacing:${e.letterSpacing}pt`),e.verticalAlign&&(e.textAlign==="justify"?n.push(`display:flex;flex-direction:column;justify-content:${Ec[e.verticalAlign]??"flex-start"}`):(n.push(`display:flex;align-items:${Ec[e.verticalAlign]??"flex-start"}`),n.push(`justify-content:${Sm[e.textAlign??"left"]??"flex-start"}`))),e.textAlign&&n.push(`text-align:${e.textAlign}`),e.textAlign==="justify"&&n.push("text-align-last:justify"),n.length?n.join(";")+";":""}function _m(e){return e.longTextIndent?`text-indent:${e.longTextIndent}em;`:""}function Sc(e){const t=Us(e);return t?`white-space:${t};`:""}function _c(e,t,n){return Object.entries(hi(e,t,n)).map(([r,o])=>`${r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}:${Ki(o)};`).join("")}function Mc(e,t){const n=qs(t)?"white-space:nowrap;text-overflow:ellipsis;":"";return e==="autoHeight"?`overflow:visible;${n}`:n}function Mm(e,t,n,r){if(e!=="shrink")return"";const o=Cn(r.shrinkMinFontSize);return` data-fit="shrink" data-fit-key="${rt(t)}" data-fit-base="${n}" data-fit-min="${o}"`}function Br(e,t,n,r,o){const i=e.options??{},a=i.left??0,l=r??i.top??0,c=i.width??100,s=i.height??void 0,d=e.type||e.printElementType?.type||"text",p=wr(d,i),f=n??ea(a,l,c,p==="autoHeight"?void 0:s,i.zIndex),g=tl(d,i);let m=f;if(g?.all&&(m+=`border:${g.all.borderWidth} ${g.all.borderStyle} ${g.all.borderColor};`),g)for(const w of _r){const _=g.edges[w];_&&(m+=`border-${w}:${_.borderWidth} ${_.borderStyle} ${_.borderColor};`)}if(!t&&n===void 0){const w=gi(d,i);w!==void 0&&(m+=`rotate:${w}deg;`)}const y=t?` data-measure-id="${e.id}"`:"",v=Mm(p,e.id,i.fontSize??12,i);switch(d){case"table":return Am(e,t,y,o);case"image":return`<div class="print-element" style="${m}"${y}>
209
- <img src="${rt(i.src??"")}" style="width:100%;height:100%;object-fit:${i.fit||"contain"};${_c(i.fit,i.fitScale,i.objectPosition)}" />
210
- </div>`;case"barcode":case"qrcode":{const w=String(i.formatter??i.testData??"").trim();return`<div class="print-element" style="${m}"${y}>
211
- ${Tc(w,d,i,{fallback:`<span>${rt(w)}</span>`,codeRenderer:o?.codeRenderer,fit:i.fit,maxWidth:i.maxWidth,maxHeight:i.maxHeight,printerDpi:i.printerDpi,targetWidthMm:i.width,targetHeightMm:i.height})}
212
- </div>`}case"hline":return`<div class="print-element" style="${m};border-top:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};height:0;"${y}></div>`;case"vline":return`<div class="print-element" style="${m};border-left:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};width:0;"${y}></div>`;case"rect":return`<div class="print-element" style="${m};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};"${y}></div>`;case"oval":return`<div class="print-element" style="${m};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};border-radius:50%;"${y}></div>`;case"longText":return`<div class="print-element" style="${m}${ra(i,"1.5")}${_m(i)}${Sc(i)}${Mc(p,i)}"${y}${v}>${rt(i.formatter??i.testData??"")}</div>`;case"flowList":{const w=ut(i.flowColumns),_=xt(i.flowGapX),M=On(i.flowRowHeight),N=Qt(i.flowMaxSpan,w),L=Array.isArray(i._flowItems)?i._flowItems:void 0,P=L&&L.length>0?L:String(i.testData??"").split(/\r?\n/).map(C=>C.trim()).filter(Boolean),k={width:c,columns:w,gapX:_,rowHeight:M,maxSpan:N,fontSizePt:i.fontSize??12,autoSpan:i.flowAutoSpan===!0},S=Jf(P,k).flatMap(C=>C.cells).map(C=>`<div class="print-flow-cell"${C.span>1?` style="grid-column:span ${C.span};"`:""}>${rt(C.text)}</div>`).join(`
213
- `);return`<div class="print-element" style="${m}${ra(i)}overflow:hidden;${eh(k)};"${y}${v}>
214
- ${S}
215
- </div>`}case"html":return`<div class="print-element" style="${m}"${y}>${i.testData??i.title??""}</div>`;default:return`<div class="print-element" style="${m}${ra(i)}${Sc(i)}${Mc(p,i)}"${y}${v}>${rt(i.formatter??i.testData??"")}</div>`}}function Tc(e,t,n,r){if(!e||!r.codeRenderer)return r.fallback;const{fallback:o,codeRenderer:i,fit:a,maxWidth:l,maxHeight:c}=r,s=t==="barcode";try{const d=i.render(e,t,{barcodeType:n.barcodeType,qrCodeLevel:n.qrCodeLevel!=null?String(n.qrCodeLevel):void 0,qrQuietZone:typeof n.qrQuietZone=="number"?n.qrQuietZone:void 0,barQuietZone:typeof n.barQuietZone=="number"?n.barQuietZone:void 0,barHeightMm:typeof n.barHeight=="number"?n.barHeight:void 0,showText:n.hideTitle!==void 0?!n.hideTitle:n.showBarcodeText,barWidth:typeof n.barWidth=="number"?n.barWidth:void 0,fontSize:typeof(n.barFontSize??n.fontSize)=="number"?n.barFontSize??n.fontSize:void 0,printerDpi:s?r.printerDpi:void 0,targetWidthMm:s?en(r.targetWidthMm,l):void 0,targetHeightMm:s?en(r.targetHeightMm,c):void 0});if(s&&/^<svg[\s>]/i.test(d))return Tm(d);const p=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(d)}`,u=[];u.push("width:100%","height:100%","max-width:100%","max-height:100%","display:block","margin:auto"),u.push(`object-fit:${a||"contain"}`),l&&u.push(`max-width:${l}mm`),c&&u.push(`max-height:${c}mm`);const f=u.join(";");return`<img src="${p}" style="${f}" />`}catch{return o}}function Tm(e){return`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${e.replace(/<svg\b/,'<svg style="display:block"')}</div>`}function km(e,t){const n=[],r=e.fittedFontSize??e.fontSize??t.tableDefaultFontSize,o=e.color??t.tableDefaultColor,i=e.padding??t.tableDefaultPadding??1,a=e.fontFamily??t.tableDefaultFontFamily;r&&n.push(`font-size:${r}pt`),a&&n.push(`font-family:${Ki(Xi(a))}`),e.fontWeight&&n.push(`font-weight:${e.fontWeight}`),o&&n.push(`color:${o}`),e.backgroundColor&&n.push(`background-color:${e.backgroundColor}`),n.push(`text-align:${e.align??"left"}`),e.align==="justify"&&n.push("text-align-last:justify"),n.push(`vertical-align:${e.valign??"middle"}`),n.push(`padding:${i}mm`),n.push(e.wordWrap===!1?"white-space:nowrap;overflow:hidden":"white-space:pre-wrap;word-break:normal;overflow-wrap:break-word");const l=e.borders??{};for(const c of["top","right","bottom","left"]){const s=l[c];n.push(s?`border-${c}:${s.width}pt ${s.style} ${s.color}`:`border-${c}:none`)}return n.join(";")}function zt(e,t,n,r,o,i,a={elementId:"",kind:"b"},l){const c=[],s=r.tableDefaultPadding??1;for(let d=t;d<n;d++){const p=e[d];if(!p)continue;const u=o?` data-row-index="${d}"`:"",f=p.cells.map((g,m)=>({cell:g,ci:m})).filter(({cell:g})=>!g.merged).map(({cell:g,ci:m})=>{const y=l===void 0?g.rowspan??1:Math.max(1,Math.min(g.rowspan??1,l-d)),v=`${y>1?` rowspan="${y}"`:""}${g.colspan>1?` colspan="${g.colspan}"`:""}`,w=m;let _;if(g.cellType==="barcode"||g.cellType==="qrcode"){const M=na(g,i);_=`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${Tc(M,g.cellType,g,{fallback:rt(M),codeRenderer:i?.codeRenderer,fit:g.fit,maxWidth:g.maxWidth,maxHeight:g.maxHeight,printerDpi:g.printerDpi,targetWidthMm:si(r.tableColWidths??[],m,g,s),targetHeightMm:An(e,d,g,s)})}</div>`}else if(g.cellType==="image"){const M=g.fit||"contain",N=g.maxWidth?`max-width:${g.maxWidth}mm;`:"max-width:100%;",L=g.maxHeight?`max-height:${g.maxHeight}mm;`:"max-height:100%;",P=Ws(M,An(e,d,g,s)),k=P===void 0?"height:100%":`height:${P}mm`,S=P===void 0?"":"width:100%;height:100%;";_=`<div style="width:100%;${k};display:flex;align-items:center;justify-content:center;overflow:hidden;"><img src="${rt(na(g,i))}" style="${S}object-fit:${M};${_c(M,g.fitScale,g.objectPosition)}${N}${L}display:block;" /></div>`}else _=Cm(e,d,w,g,r,a,s,i);return`<td${v} style="${km(g,r)}">${_}</td>`}).join("");c.push(`<tr${u} style="height:${p.height}mm;">${f}</tr>`)}return c.join(`
216
- `)}function Cm(e,t,n,r,o,i,a,l){const c=ii(r),s=rt(na(r,l));if(c==="autoHeight")return s;const d=An(e,t,r,a),p=r.wordWrap===!1,u=[`max-height:${d}mm`,"overflow:hidden",...p?["white-space:nowrap","text-overflow:ellipsis"]:[]].join(";"),f=c==="shrink"&&i.elementId?` data-fit="shrink" data-fit-key="${rt(Uf(i.elementId,i.kind,t,n))}" data-fit-base="${r.fontSize??o.tableDefaultFontSize??12}" data-fit-min="${Cn(r.shrinkMinFontSize)}" data-fit-mm="${d}"`:"";return`<div class="cell-fit" style="${u}"${f}>${s}</div>`}function oa(e,t){const r=e.options.tableColWidths??[],o=r.map(a=>`<col style="width:${a}mm;">`).join(""),i=r.reduce((a,l)=>a+l,0);return`<table class="print-table" data-element-id="${e.id}" style="border-collapse:collapse;table-layout:fixed;width:${i}mm;">
208
+ </section>`}function $m(e,t){if(!Lm(e))return e;const n=ua(t),r=i=>{const a=i.options?.rawFormatter;return typeof a!="string"?i:{...i,options:{...i.options,formatter:Pt(a,n)}}},o=i=>i&&{...i,elements:(i.elements??[]).map(r)};return{...e,elements:e.elements.map(r),header:o(e.header),footer:o(e.footer)}}function Lm(e){return[e.elements,e.header?.elements,e.footer?.elements].some(n=>(n??[]).some(r=>typeof r.options?.rawFormatter=="string"))}function pa(e,t){const n=e.rawFormatter;return typeof n=="string"&&n!==""&&t?.pageVars?Pt(n,ua(t.pageVars)):e.content}function Nm(e,t,n){const r=ma(t,e.elementId);return r?e.type==="table-slice"?Vm(r,e,n):e.type==="flow-list-slice"?Um(r,e):e.type==="flow-group"?Ym(r,e,t,n):Zr(r,!1,void 0,e.renderTop,n):`<!-- element not found: ${e.elementId} -->`}const $c={top:"flex-start",middle:"center",bottom:"flex-end"},Fm={left:"flex-start",center:"center",right:"flex-end"};function tr(e,t){const n=[],r=e._fitFontSize===void 0?e.fontSize:mi(e._fitFontSize);return r&&n.push(`font-size:${r}pt`),e.fontFamily&&n.push(`font-family:${aa(sa(e.fontFamily))}`),e.fontWeight&&n.push(`font-weight:${e.fontWeight}`),e.color&&n.push(`color:${e.color}`),e.backgroundColor&&n.push(`background-color:${e.backgroundColor}`),e.lineHeight?n.push(`line-height:${e.lineHeight}pt`):t&&n.push(`line-height:${t}`),e.letterSpacing&&n.push(`letter-spacing:${e.letterSpacing}pt`),e.verticalAlign&&(e.textAlign==="justify"?n.push(`display:flex;flex-direction:column;justify-content:${$c[e.verticalAlign]??"flex-start"}`):(n.push(`display:flex;align-items:${$c[e.verticalAlign]??"flex-start"}`),n.push(`justify-content:${Fm[e.textAlign??"left"]??"flex-start"}`))),e.textAlign&&n.push(`text-align:${e.textAlign}`),e.textAlign==="justify"&&n.push("text-align-last:justify"),n.length?n.join(";")+";":""}function zm(e){return e.longTextIndent?`text-indent:${e.longTextIndent}em;`:""}function Lc(e){const t=Js(e);return t?`white-space:${t};`:""}function Nc(e,t,n){return Object.entries(Mi(e,t,n)).map(([r,o])=>`${r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}:${aa(o)};`).join("")}function Fc(e,t){const n=Qs(t)?"white-space:nowrap;text-overflow:ellipsis;":"";return e==="autoHeight"?`overflow:visible;${n}`:n}function Bm(e,t,n,r){if(e!=="shrink")return"";const o=$n(r.shrinkMinFontSize);return` data-fit="shrink" data-fit-key="${ot(t)}" data-fit-base="${n}" data-fit-min="${o}"`}function Zr(e,t,n,r,o){const i=e.options??{},a=i.left??0,l=r??i.top??0,c=i.width??100,s=i.height??void 0,d=e.type||e.printElementType?.type||"text",p=Ar(d,i),u=d==="flowList"&&Bt(i.flowLayoutMode)==="dynamic",m=n??Gr(a,l,c,p==="autoHeight"||u?void 0:s,i.zIndex),g=Rr(d,i);let b=m;if(g?.all&&(b+=`border:${g.all.borderWidth} ${g.all.borderStyle} ${g.all.borderColor};`),g)for(const _ of zn){const M=g.edges[_];M&&(b+=`border-${_}:${M.borderWidth} ${M.borderStyle} ${M.borderColor};`)}if(!t&&n===void 0){const _=Ti(d,i);_!==void 0&&(b+=`rotate:${_}deg;`)}const v=t?` data-measure-id="${e.id}"`:"",w=Bm(p,e.id,i.fontSize??12,i);switch(d){case"table":return Gm(e,t,v,o);case"image":return`<div class="print-element" style="${b}"${v}>
209
+ <img src="${ot(i.src??"")}" style="width:100%;height:100%;object-fit:${i.fit||"contain"};${Nc(i.fit,i.fitScale,i.objectPosition)}" />
210
+ </div>`;case"barcode":case"qrcode":{const _=String(i.formatter??i.testData??"").trim();return`<div class="print-element" style="${b}"${v}>
211
+ ${Bc(_,d,i,{fallback:`<span>${ot(_)}</span>`,codeRenderer:o?.codeRenderer,fit:i.fit,maxWidth:i.maxWidth,maxHeight:i.maxHeight,printerDpi:i.printerDpi,targetWidthMm:i.width,targetHeightMm:i.height})}
212
+ </div>`}case"hline":return`<div class="print-element" style="${b};border-top:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};height:0;"${v}></div>`;case"vline":return`<div class="print-element" style="${b};border-left:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};width:0;"${v}></div>`;case"rect":return`<div class="print-element" style="${b};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};"${v}></div>`;case"oval":return`<div class="print-element" style="${b};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};border-radius:50%;"${v}></div>`;case"longText":return`<div class="print-element" style="${b}${tr(i,"1.5")}${zm(i)}${Lc(i)}${Fc(p,i)}"${v}${w}>${ot(i.formatter??i.testData??"")}</div>`;case"flowList":{const _=Qe(i.flowColumns),M=rt(i.flowGapX),N=Ct(i.flowRowHeight),R=Ht(i.flowMaxSpan,_),D=Array.isArray(i._flowItems)?i._flowItems:void 0,I=D&&D.length>0?D:String(i.testData??"").split(/\r?\n/).map(k=>k.trim()).filter(Boolean),S={width:c,columns:_,gapX:M,rowHeight:N,maxSpan:R,fontSizePt:i.fontSize??12,autoSpan:i.flowAutoSpan===!0};if(u){const k=sn(i),$=Array.isArray(i._flowRows)?i._flowRows:vi(I,{...S,width:nl(c,k)});return`<div class="print-element" style="${b}${tr(i)}display:block;box-sizing:border-box;height:auto;overflow:visible;padding:${ut(k.top)} ${ut(k.right)} ${ut(k.bottom)} ${ut(k.left)};"${v}${w}>
213
+ ${fa($,_,M,N)}
214
+ </div>`}const C=vi(I,S).flatMap(k=>k.cells).map(k=>`<div class="print-flow-cell"${k.span>1?` style="grid-column:span ${k.span};"`:""}>${ot(k.text)}</div>`).join(`
215
+ `);return`<div class="print-element" style="${b}${tr(i)}overflow:hidden;${ph(S)};"${v}${w}>
216
+ ${C}
217
+ </div>`}case"html":return`<div class="print-element" style="${b}"${v}>${i.testData??i.title??""}</div>`;default:return`<div class="print-element" style="${b}${tr(i)}${Lc(i)}${Fc(p,i)}"${v}${w}>${ot(i.formatter??i.testData??"")}</div>`}}function ut(e){return`${Math.round(e*1e3)/1e3}mm`}function Hm(e,t,n){return["display:grid",`grid-template-columns:repeat(${e},minmax(0,1fr))`,`column-gap:${ut(t)}`,`min-height:${ut(n)}`].join(";")}function fa(e,t,n,r,o=0){return e.map((i,a)=>{const l=i.cells.map(c=>`<div class="print-flow-cell"${c.span>1?` style="grid-column:span ${c.span};"`:""}>${ot(c.text)}</div>`).join(`
218
+ `);return`<div class="print-flow-row" data-flow-row-index="${o+a}" style="${Hm(t,n,r)};">
219
+ ${l}
220
+ </div>`}).join(`
221
+ `)}function zc(e,t){let n="";const r=Rr(e,t);if(r?.all&&(n+=`border:${r.all.borderWidth} ${r.all.borderStyle} ${r.all.borderColor};`),r)for(const i of zn){const a=r.edges[i];a&&(n+=`border-${i}:${a.borderWidth} ${a.borderStyle} ${a.borderColor};`)}const o=sn(t);return n+=`${tr(t)}display:block;box-sizing:border-box;height:auto;overflow:visible;padding:${ut(o.top)} ${ut(o.right)} ${ut(o.bottom)} ${ut(o.left)};`,n}function Um(e,t,n){const r=e.options??{},o=Array.isArray(r._flowRows)?r._flowRows:[],i=t.startFlowRow??0,a=t.endFlowRow??o.length;if(i>=a)return"";const l=e.type||e.printElementType?.type||"flowList",c=Gr(r.left??0,t.renderTop??r.top??0,r.width??100,void 0,r.zIndex),s=Qe(r.flowColumns),d=rt(r.flowGapX),p=Ct(r.flowRowHeight);return`<div class="print-flowlist-slice" style="${c}${zc(l,r)}">
222
+ ${fa(o.slice(i,a),s,d,p,i)}
223
+ </div>`}function Bc(e,t,n,r){if(!e||!r.codeRenderer)return r.fallback;const{fallback:o,codeRenderer:i,fit:a,maxWidth:l,maxHeight:c}=r,s=t==="barcode";try{const d=i.render(e,t,{barcodeType:n.barcodeType,qrCodeLevel:n.qrCodeLevel!=null?String(n.qrCodeLevel):void 0,qrQuietZone:typeof n.qrQuietZone=="number"?n.qrQuietZone:void 0,barQuietZone:typeof n.barQuietZone=="number"?n.barQuietZone:void 0,barHeightMm:typeof n.barHeight=="number"?n.barHeight:void 0,showText:n.hideTitle!==void 0?!n.hideTitle:n.showBarcodeText,barWidth:typeof n.barWidth=="number"?n.barWidth:void 0,fontSize:typeof(n.barFontSize??n.fontSize)=="number"?n.barFontSize??n.fontSize:void 0,printerDpi:s?r.printerDpi:void 0,targetWidthMm:s?ln(r.targetWidthMm,l):void 0,targetHeightMm:s?ln(r.targetHeightMm,c):void 0});if(s&&/^<svg[\s>]/i.test(d))return qm(d);const p=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(d)}`,u=[];u.push("width:100%","height:100%","max-width:100%","max-height:100%","display:block","margin:auto"),u.push(`object-fit:${a||"contain"}`),l&&u.push(`max-width:${l}mm`),c&&u.push(`max-height:${c}mm`);const f=u.join(";");return`<img src="${p}" style="${f}" />`}catch{return o}}function qm(e){return`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${e.replace(/<svg\b/,'<svg style="display:block"')}</div>`}function Wm(e,t){const n=[],r=e.fittedFontSize??e.fontSize??t.tableDefaultFontSize,o=e.color??t.tableDefaultColor,i=e.padding??t.tableDefaultPadding??1,a=e.fontFamily??t.tableDefaultFontFamily;r&&n.push(`font-size:${r}pt`),a&&n.push(`font-family:${aa(sa(a))}`),e.fontWeight&&n.push(`font-weight:${e.fontWeight}`),o&&n.push(`color:${o}`),e.backgroundColor&&n.push(`background-color:${e.backgroundColor}`),n.push(`text-align:${e.align??"left"}`),e.align==="justify"&&n.push("text-align-last:justify"),n.push(`vertical-align:${e.valign??"middle"}`),n.push(`padding:${i}mm`),n.push(e.wordWrap===!1?"white-space:nowrap;overflow:hidden":"white-space:pre-wrap;word-break:normal;overflow-wrap:break-word");const l=e.borders??{};for(const c of["top","right","bottom","left"]){const s=l[c];n.push(s?`border-${c}:${s.width}pt ${s.style} ${s.color}`:`border-${c}:none`)}return n.join(";")}function jt(e,t,n,r,o,i,a={elementId:"",kind:"b"},l){const c=[],s=r.tableDefaultPadding??1,d=Cm(e,t,n);for(let p=t;p<n;p++){const u=e[p];if(!u)continue;const f=o?` data-row-index="${p}"`:"",m=u.cells.map((g,b)=>({cell:g,ci:b})).filter(({cell:g,ci:b})=>!g.merged&&!d?.merged.has(`${p}:${b}`)).map(({cell:g,ci:b})=>{const v=d?.rowspan.get(`${p}:${b}`),w=v??(l===void 0?g.rowspan??1:Math.max(1,Math.min(g.rowspan??1,l-p))),_=v===void 0?g:{...g,rowspan:v},M=`${w>1?` rowspan="${w}"`:""}${g.colspan>1?` colspan="${g.colspan}"`:""}`,N=b;let R;if(g.cellType==="barcode"||g.cellType==="qrcode"){const D=pa(g,i);R=`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${Bc(D,g.cellType,g,{fallback:ot(D),codeRenderer:i?.codeRenderer,fit:g.fit,maxWidth:g.maxWidth,maxHeight:g.maxHeight,printerDpi:g.printerDpi,targetWidthMm:bi(r.tableColWidths??[],b,g,s),targetHeightMm:Ln(e,p,_,s)})}</div>`}else if(g.cellType==="image"){const D=g.fit||"contain",I=g.maxWidth?`max-width:${g.maxWidth}mm;`:"max-width:100%;",S=g.maxHeight?`max-height:${g.maxHeight}mm;`:"max-height:100%;",C=el(D,Ln(e,p,_,s)),k=C===void 0?"height:100%":`height:${C}mm`,$=C===void 0?"":"width:100%;height:100%;";R=`<div style="width:100%;${k};display:flex;align-items:center;justify-content:center;overflow:hidden;"><img src="${ot(pa(g,i))}" style="${$}object-fit:${D};${Nc(D,g.fitScale,g.objectPosition)}${I}${S}display:block;" /></div>`}else R=jm(e,p,N,_,r,a,s,i);return`<td${M} style="${Wm(g,r)}">${R}</td>`}).join("");c.push(`<tr${f} style="height:${u.height}mm;">${m}</tr>`)}return c.join(`
224
+ `)}function jm(e,t,n,r,o,i,a,l){const c=gi(r),s=ot(pa(r,l));if(c==="autoHeight")return s;const d=Ln(e,t,r,a),p=r.wordWrap===!1,u=[`max-height:${d}mm`,"overflow:hidden",...p?["white-space:nowrap","text-overflow:ellipsis"]:[]].join(";"),f=c==="shrink"&&i.elementId?` data-fit="shrink" data-fit-key="${ot(th(i.elementId,i.kind,t,n))}" data-fit-base="${r.fontSize??o.tableDefaultFontSize??12}" data-fit-min="${$n(r.shrinkMinFontSize)}" data-fit-mm="${d}"`:"";return`<div class="cell-fit" style="${u}"${f}>${s}</div>`}function ha(e,t){const r=e.options.tableColWidths??[],o=r.map(a=>`<col style="width:${a}mm;">`).join(""),i=r.reduce((a,l)=>a+l,0);return`<table class="print-table" data-element-id="${e.id}" style="border-collapse:collapse;table-layout:fixed;width:${i}mm;">
217
225
  <colgroup>${o}</colgroup>
218
226
  <tbody>${t}</tbody>
219
- </table>`}function Am(e,t,n,r){const o=e.options,i=ea(o.left??0,o.top??0,o.width??100,void 0,o.zIndex),a=o._renderRows??[],l=zt(a,0,a.length,o,t,r,{elementId:e.id,kind:"b"});return`<div class="print-element" style="${i};overflow:visible;"${n}>
220
- ${oa(e,l)}
221
- </div>`}function Om(e,t,n){const r=e.options,o=ea(r.left??0,t.renderTop??r.top??0,r.width??100,void 0,r.zIndex),i=r._renderRows??[],a=t.startRow??0,l=t.endRow??i.length,c=r._repeatHeaderCount??0,s=t.repeatHeader&&c>0?zt(i,0,c,r,!1,n,{elementId:e.id,kind:"b"},c):"",d=zt(i,a,l,r,!1,n,{elementId:e.id,kind:"b"}),p=t.subtotal?kc(e,t,r,n):"",u=t.summary?Cc(e,r,n):"";return`<div class="print-element" style="${o};overflow:visible;">
222
- ${oa(e,`${s}
227
+ </table>`}function Gm(e,t,n,r){const o=e.options,i=Gr(o.left??0,o.top??0,o.width??100,void 0,o.zIndex),a=o._renderRows??[],l=jt(a,0,a.length,o,t,r,{elementId:e.id,kind:"b"});return`<div class="print-element" style="${i};overflow:visible;"${n}>
228
+ ${ha(e,l)}
229
+ </div>`}function Vm(e,t,n){const r=e.options,o=Gr(r.left??0,t.renderTop??r.top??0,r.width??100,void 0,r.zIndex),i=r._renderRows??[],a=t.startRow??0,l=t.endRow??i.length,c=r._repeatHeaderCount??0,s=t.repeatHeader&&c>0?jt(i,0,c,r,!1,n,{elementId:e.id,kind:"b"},c):"",d=jt(i,a,l,r,!1,n,{elementId:e.id,kind:"b"}),p=t.subtotal?Hc(e,t,r,n):"",u=t.summary?Uc(e,r,n):"";return`<div class="print-element" style="${o};overflow:visible;">
230
+ ${ha(e,`${s}
223
231
  ${d}${p}${u}`)}
224
- </div>`}function kc(e,t,n,r){const o=n._subtotalTemplates??[];if(o.length===0)return"";const i=n._dataRowCtx??[],a=n._dataStartIdx??0,l=n._mainData??{},c=n._renderRows?.length??0,s=t.startRow??0,d=t.endRow??c,p=Math.max(s,a),u=Math.max(d,p),f=u>a?i.slice(Math.max(p-a,0),u-a):[],g=r?.pageVars?ta(r.pageVars):{},m=o.map(y=>({...y,cells:y.cells.map(v=>v.rawFormatter?{...v,content:Mt(v.rawFormatter,{rows:f,...l,...g}),rawFormatter:""}:v)}));return zt(m,0,m.length,n,!1,r,{elementId:e.id,kind:"st"})}function Cc(e,t,n){const r=t._summaryRows??[];return r.length===0?"":zt(r,0,r.length,t,!1,n,{elementId:e.id,kind:"sm"})}function Im(e,t,n,r){const o=e.options??{},i=o.left??0,a=o.width??100,l=t.groupTop??o.top??0,c=bi(e),s=typeof o.zIndex=="number"?`z-index:${o.zIndex};`:"",d=`position:absolute;left:${U(i)};top:${U(l)};width:${U(a)};overflow:visible;${s}`,p=t.startRow??0,u=t.endRow??0;let f="";if(u>p||t.subtotal||t.summary){const w=o._renderRows??[],_=o._repeatHeaderCount??0,M=t.repeatHeader&&_>0?zt(w,0,_,o,!1,r,{elementId:e.id,kind:"b"},_):"",N=zt(w,p,u,o,!1,r,{elementId:e.id,kind:"b"}),L=t.subtotal?kc(e,t,o,r):"",P=t.summary?Cc(e,o,r):"";f=`<div class="flow-slice" style="position:relative;width:${U(a)};overflow:visible;">
225
- ${oa(e,`${M}
226
- ${N}${L}${P}`)}
227
- </div>`}const g=t.followElementIds??[],m=g.reduce((w,_)=>{const M=aa(n,_);return M?Math.max(w,(M.options?.top??0)+(M.options?.height??0)):w},c),y=g.map(w=>{const _=aa(n,w);if(!_)return"";const M=_.options?.top??0,N=_.options?.left??0,L=_.options?.width??a,P=_.options?.height??0,k=_.options?.zIndex,S=_.type||_.printElementType?.type||"text",C=S==="rect"||S==="oval"||S==="image"||S==="vline",O=["position:absolute",`left:${U(N-i)}`,`top:${U(M-c)}`,`width:${U(L)}`,...C&&P>0?[`height:${U(P)}`]:[],...typeof k=="number"?[`z-index:${k}`]:[],"overflow:visible"].join(";")+";";return Br(_,!1,O,void 0,r)}).join(`
228
- `),v=g.length>0?`<div class="flow-follow" style="position:relative;width:${U(a)};height:${U(Math.max(m-c,0))};overflow:visible;">
229
- ${y}
230
- </div>`:"";return`<div class="flow-group" style="${d}">
232
+ </div>`}function Hc(e,t,n,r){const o=n._subtotalTemplates??[];if(o.length===0)return"";const i=n._dataRowCtx??[],a=n._dataStartIdx??0,l=n._mainData??{},c=n._renderRows?.length??0,s=t.startRow??0,d=t.endRow??c,p=Math.max(s,a),u=Math.max(d,p),f=u>a?i.slice(Math.max(p-a,0),u-a):[],m=r?.pageVars?ua(r.pageVars):{},g=o.map(b=>({...b,cells:b.cells.map(v=>v.rawFormatter?{...v,content:Pt(v.rawFormatter,{rows:f,...l,...m}),rawFormatter:""}:v)}));return jt(g,0,g.length,n,!1,r,{elementId:e.id,kind:"st"})}function Uc(e,t,n){const r=t._summaryRows??[];return r.length===0?"":jt(r,0,r.length,t,!1,n,{elementId:e.id,kind:"sm"})}function Ym(e,t,n,r){const o=e.options??{},a=(e.type||e.printElementType?.type||"text")==="flowList"&&Bt(o.flowLayoutMode)==="dynamic",l=o.left??0,c=o.width??100,s=t.groupTop??o.top??0,d=Ai(e),p=typeof o.zIndex=="number"?`z-index:${o.zIndex};`:"",u=`position:absolute;left:${V(l)};top:${V(s)};width:${V(c)};overflow:visible;${p}`;let f="";if(a)f=Xm(e,t);else{const w=t.startRow??0,_=t.endRow??0;if(_>w||t.subtotal||t.summary){const M=o._renderRows??[],N=o._repeatHeaderCount??0,R=t.repeatHeader&&N>0?jt(M,0,N,o,!1,r,{elementId:e.id,kind:"b"},N):"",D=jt(M,w,_,o,!1,r,{elementId:e.id,kind:"b"}),I=t.subtotal?Hc(e,t,o,r):"",S=t.summary?Uc(e,o,r):"";f=`<div class="flow-slice" style="position:relative;width:${V(c)};overflow:visible;">
233
+ ${ha(e,`${R}
234
+ ${D}${I}${S}`)}
235
+ </div>`}}const m=t.followElementIds??[],g=m.reduce((w,_)=>{const M=ma(n,_);return M?Math.max(w,(M.options?.top??0)+(M.options?.height??0)):w},d),b=m.map(w=>{const _=ma(n,w);if(!_)return"";const M=_.options?.top??0,N=_.options?.left??0,R=_.options?.width??c,D=_.options?.height??0,I=_.options?.zIndex,S=_.type||_.printElementType?.type||"text",C=S==="rect"||S==="oval"||S==="image"||S==="vline",k=["position:absolute",`left:${V(N-l)}`,`top:${V(M-d)}`,`width:${V(R)}`,...C&&D>0?[`height:${V(D)}`]:[],...typeof I=="number"?[`z-index:${I}`]:[],"overflow:visible"].join(";")+";";return Zr(_,!1,k,void 0,r)}).join(`
236
+ `),v=m.length>0?`<div class="flow-follow" style="position:relative;width:${V(c)};height:${V(Math.max(g-d,0))};overflow:visible;">
237
+ ${b}
238
+ </div>`:"";return`<div class="flow-group" style="${u}">
231
239
  ${f}
232
240
  ${v}
233
- </div>`}function ia(e,t,n,r,o){return e.map(i=>{let a=Pm(i,o);return n!==void 0&&(a=a.replace(/\{pageIndex\}/g,String(n))),r!==void 0&&(a=a.replace(/\{totalPages\}/g,String(r))),a}).join(`
234
- `)}function Pm(e,t){return Br(e,!1,void 0,void 0,t)}function aa(e,t){return e.elements.find(n=>n.id===t)}function sa(e){return Ze(e)}function rt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Dm=25.4;function Rm(e,t){const n=e.margins?.bottom??0,r=e.footer?.height??0,o=Math.max(t,0)+r+n;return Math.max(Dm,Math.round(o*100)/100)}const Ac=3.7795275591;function la(e){return e/Ac}function Hr(e){return Math.round(e*Ac)}class Gn extends Error{constructor(t,n,r){super(n),this.name="PrintFailure",this.code=t,this.cause=r}}function $m(e,t,n){if(e instanceof Gn)return e;const r=e instanceof Error?e.message:String(e);return new Gn(t,`${n}:${r}`,e)}async function Ur(e,t,n,r){let o;try{return await Promise.race([e,new Promise((i,a)=>{o=setTimeout(()=>a(new Gn(n,r)),t)})])}finally{o&&clearTimeout(o)}}function qr(e){return typeof e=="number"&&e>0?e:void 0}function Lm(e){return qr(e.paperHeightMm)??qr(e.override?.height)}function Nm(e){const t=qr(e.override?.width)??e.paperMm.width,n=qr(e.override?.height);return e.continuous?n?{paperMm:{width:t,height:n},heightSource:"config"}:{paperMm:{width:t,height:e.paperMm.height},heightSource:"derived"}:{paperMm:{width:t,height:n??e.paperMm.height},heightSource:"config"}}function Oc(e){return{width:Hr(e.width),height:Hr(e.height)}}function Ic(e,t){const n=new Map(t.elements.map(o=>[o.id,o])),r=new Map;for(const o of e){const a=n.get(o.id)?.options?._repeatHeaderCount??0,l=o.rowHeightsPx?.map(la);r.set(o.id,{id:o.id,measuredHeight:la(o.heightPx),measuredRowHeights:l,repeatHeaderHeight:l&&l.length>0&&a>0?l.slice(0,a).reduce((c,s)=>c+s,0):0})}return r}const Fm={b:"_renderRows",st:"_subtotalTemplates",sm:"_summaryRows"};function Pc(e,t){if(!t||t.length===0)return;const n=new Map,r=o=>{for(const i of o??[])n.set(i.id,i)};r(e.elements),r(e.header?.elements),r(e.footer?.elements);for(const o of t){const i=qf(o.key);if(!i){const s=n.get(o.key);s&&(s.options._fitFontSize=ai(o.fontSizePt));continue}const c=n.get(i.elementId)?.options?.[Fm[i.kind]]?.[i.rowIndex]?.cells?.[i.colIndex];c&&(c.fittedFontSize=ai(o.fontSizePt))}}function Dc(e,t,n={}){return JSON.stringify([e,t,n.barcodeType??null,n.qrCodeLevel??null,n.showText??null,n.barWidth??null,n.fontSize??null,n.qrQuietZone??null,n.barQuietZone??null,n.barHeightMm??null])}function zm(e){return{render(t,n,r){const o=e.get(Dc(t,n,r));if(!o)throw new Error(`码值未渲染:${t}`);return o}}}function Bm(e){const t=new Map;return{renderer:{render(n,r,o={}){const i=Dc(n,r,o),a=e?.get(i);if(a)return a;throw t.set(i,{key:i,value:n,cellType:r,opts:o}),new Error("collect")}},takeSpecs(){const n=[...t.values()];return t.clear(),n}}}function Hm(...e){const t=new Map;for(const n of e)for(const[r,o]of n)t.set(r,o);return t}const Um={waitReady:"window",readMeasurements:"document",readContentBottom:"document",renderCodes:"none",applyTextFit:"document"},qm=3e4,Wm=5e3;function jm(e,t){return{async withSession(n,r){const o=await e.createDriver(),i=Date.now()+(n.timeoutMs??qm),a=n.readinessMs??Wm,l=()=>Math.max(1,i-Date.now()),c=(f,g,m)=>$m(f,g,m);let s=!1;const d=async()=>{if(!s){if(o.requiresExecutor===!1){s=!0;return}throw new Gn("INTERNAL","缺少 core DOM 执行器产物")}},p=async(f,g)=>{await o.open(g),await o.setContent(f),s=!1,await d(),await o.evaluate("waitReady",[a])},u={async renderCodes(f){if(f.length===0)return new Map;const g=l();return Ur((async()=>{try{await d();const m=await o.evaluate("renderCodes",[f]);return new Map(Object.entries(m))}catch(m){throw c(m,"INTERNAL","码值渲染失败")}})(),g,"RENDER_TIMEOUT",`码值渲染超过 ${g}ms`)},async measure(f,g){const m=l();return Ur((async()=>{try{await p(f,g);const y=await o.evaluate("applyTextFit")??[];return{measurements:await o.evaluate("readMeasurements"),fits:y}}catch(y){throw c(y,"MEASURE_FAILED","测量失败")}})(),m,"RENDER_TIMEOUT",`测量超过 ${m}ms`)},async probeContentBottom(f,g){const m=l();return Ur((async()=>{try{return await p(f,g),await o.evaluate("readContentBottom")}catch(y){throw c(y,"MEASURE_FAILED","连续纸探针失败")}})(),m,"RENDER_TIMEOUT",`连续纸探针超过 ${m}ms`)},async toPdf(f,g,m){if(!o.pdf)throw new Gn("UNSUPPORTED_RUNTIME","当前宿主不支持生成 PDF");const y=l();return Ur((async()=>{try{return await p(f,m),await o.pdf(f,g)}catch(v){throw c(v,"PDF_FAILED","PDF 生成失败")}})(),y,"RENDER_TIMEOUT",`PDF 生成超过 ${y}ms`)}};try{return await r(u)}finally{try{await o.close()}catch{}}}}}const Rc=500;function Gm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $c(e){if(e===void 0)return{mode:"single",data:{}};if(!Array.isArray(e))return{mode:"single",data:e};if(e.length===0)throw new Error("批量打印数据必须是非空对象数组");if(e.length>Rc)throw new Error(`批量打印最多支持 ${Rc} 份,当前 ${e.length} 份`);for(let t=0;t<e.length;t++)if(!Gm(e[t]))throw new Error(`批量打印数据第 ${t+1} 项必须是对象`);return{mode:"batch",dataList:e}}function Ym(e){const t=e[0].bound,n=tt(t),r=e.map((a,l)=>{const c=n?`print-copy print-copy-${l}`:"print-copy",s=Fr(a.bound,a.pageLayouts,a.data,{codeRenderer:a.codeRenderer,pageHeightMm:a.derivedHeightMm});return`<section class="${c}">
241
+ </div>`}function Xm(e,t){const n=e.options??{},r=Array.isArray(n._flowRows)?n._flowRows:[],o=t.startFlowRow??0,i=t.endFlowRow??0;if(o>=i)return"";const a=e.type||e.printElementType?.type||"flowList",l=Qe(n.flowColumns),c=rt(n.flowGapX),s=Ct(n.flowRowHeight);return`<div class="flow-slice" style="position:relative;width:${V(n.width??100)};overflow:visible;">
242
+ <div class="print-flowlist-slice" style="position:relative;width:${V(n.width??100)};${zc(a,n)}">
243
+ ${fa(r.slice(o,i),l,c,s,o)}
244
+ </div>
245
+ </div>`}function ga(e,t,n,r,o){return e.map(i=>{let a=Km(i,o);return n!==void 0&&(a=a.replace(/\{pageIndex\}/g,String(n))),r!==void 0&&(a=a.replace(/\{totalPages\}/g,String(r))),a}).join(`
246
+ `)}function Km(e,t){return Zr(e,!1,void 0,void 0,t)}function ma(e,t){return e.elements.find(n=>n.id===t)}function ba(e){return et(e)}function ot(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Zm=25.4;function Jm(e,t){const n=e.margins?.bottom??0,r=e.footer?.height??0,o=Math.max(t,0)+r+n;return Math.max(Zm,Math.round(o*100)/100)}const qc=3.7795275591;function ya(e){return e/qc}function Jr(e){return Math.round(e*qc)}class nr extends Error{constructor(t,n,r){super(n),this.name="PrintFailure",this.code=t,this.cause=r}}function Qm(e,t,n){if(e instanceof nr)return e;const r=e instanceof Error?e.message:String(e);return new nr(t,`${n}:${r}`,e)}async function Qr(e,t,n,r){let o;try{return await Promise.race([e,new Promise((i,a)=>{o=setTimeout(()=>a(new nr(n,r)),t)})])}finally{o&&clearTimeout(o)}}function eo(e){return typeof e=="number"&&e>0?e:void 0}function e0(e){return eo(e.paperHeightMm)??eo(e.override?.height)}function t0(e){const t=eo(e.override?.width)??e.paperMm.width,n=eo(e.override?.height);return e.continuous?n?{paperMm:{width:t,height:n},heightSource:"config"}:{paperMm:{width:t,height:e.paperMm.height},heightSource:"derived"}:{paperMm:{width:t,height:n??e.paperMm.height},heightSource:"config"}}function Wc(e){return{width:Jr(e.width),height:Jr(e.height)}}function n0(e){return(e?.type??e?.printElementType?.type)!=="flowList"?!1:Bt(e?.options?.flowLayoutMode)==="dynamic"}function jc(e,t){const n=new Map(t.elements.map(o=>[o.id,o])),r=new Map;for(const o of e){const i=n.get(o.id),a=i?.options?._repeatHeaderCount??0,l=o.rowHeightsPx?.map(ya),c=n0(i);r.set(o.id,{id:o.id,measuredHeight:ya(o.heightPx),...c?{measuredFlowRowHeights:l}:{measuredRowHeights:l},repeatHeaderHeight:l&&l.length>0&&a>0?l.slice(0,a).reduce((s,d)=>s+d,0):0})}return r}const r0={b:"_renderRows",st:"_subtotalTemplates",sm:"_summaryRows"};function Gc(e,t){if(!t||t.length===0)return;const n=new Map,r=o=>{for(const i of o??[])n.set(i.id,i)};r(e.elements),r(e.header?.elements),r(e.footer?.elements);for(const o of t){const i=nh(o.key);if(!i){const s=n.get(o.key);s&&(s.options._fitFontSize=mi(o.fontSizePt));continue}const c=n.get(i.elementId)?.options?.[r0[i.kind]]?.[i.rowIndex]?.cells?.[i.colIndex];c&&(c.fittedFontSize=mi(o.fontSizePt))}}function Vc(e,t,n={}){return JSON.stringify([e,t,n.barcodeType??null,n.qrCodeLevel??null,n.showText??null,n.barWidth??null,n.fontSize??null,n.qrQuietZone??null,n.barQuietZone??null,n.barHeightMm??null])}function o0(e){return{render(t,n,r){const o=e.get(Vc(t,n,r));if(!o)throw new Error(`码值未渲染:${t}`);return o}}}function i0(e){const t=new Map;return{renderer:{render(n,r,o={}){const i=Vc(n,r,o),a=e?.get(i);if(a)return a;throw t.set(i,{key:i,value:n,cellType:r,opts:o}),new Error("collect")}},takeSpecs(){const n=[...t.values()];return t.clear(),n}}}function a0(...e){const t=new Map;for(const n of e)for(const[r,o]of n)t.set(r,o);return t}const s0={waitReady:"window",readMeasurements:"document",readContentBottom:"document",renderCodes:"none",applyTextFit:"document"},l0=3e4,c0=5e3;function d0(e,t){return{async withSession(n,r){const o=await e.createDriver(),i=Date.now()+(n.timeoutMs??l0),a=n.readinessMs??c0,l=()=>Math.max(1,i-Date.now()),c=(f,m,g)=>Qm(f,m,g);let s=!1;const d=async()=>{if(!s){if(o.requiresExecutor===!1){s=!0;return}throw new nr("INTERNAL","缺少 core DOM 执行器产物")}},p=async(f,m)=>{await o.open(m),await o.setContent(f),s=!1,await d(),await o.evaluate("waitReady",[a])},u={async renderCodes(f){if(f.length===0)return new Map;const m=l();return Qr((async()=>{try{await d();const g=await o.evaluate("renderCodes",[f]);return new Map(Object.entries(g))}catch(g){throw c(g,"INTERNAL","码值渲染失败")}})(),m,"RENDER_TIMEOUT",`码值渲染超过 ${m}ms`)},async measure(f,m){const g=l();return Qr((async()=>{try{await p(f,m);const b=await o.evaluate("applyTextFit")??[];return{measurements:await o.evaluate("readMeasurements"),fits:b}}catch(b){throw c(b,"MEASURE_FAILED","测量失败")}})(),g,"RENDER_TIMEOUT",`测量超过 ${g}ms`)},async probeContentBottom(f,m){const g=l();return Qr((async()=>{try{return await p(f,m),await o.evaluate("readContentBottom")}catch(b){throw c(b,"MEASURE_FAILED","连续纸探针失败")}})(),g,"RENDER_TIMEOUT",`连续纸探针超过 ${g}ms`)},async toPdf(f,m,g){if(!o.pdf)throw new nr("UNSUPPORTED_RUNTIME","当前宿主不支持生成 PDF");const b=l();return Qr((async()=>{try{return await p(f,g),await o.pdf(f,m)}catch(v){throw c(v,"PDF_FAILED","PDF 生成失败")}})(),b,"RENDER_TIMEOUT",`PDF 生成超过 ${b}ms`)}};try{return await r(u)}finally{try{await o.close()}catch{}}}}}const Yc=500;function u0(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xc(e){if(e===void 0)return{mode:"single",data:{}};if(!Array.isArray(e))return{mode:"single",data:e};if(e.length===0)throw new Error("批量打印数据必须是非空对象数组");if(e.length>Yc)throw new Error(`批量打印最多支持 ${Yc} 份,当前 ${e.length} 份`);for(let t=0;t<e.length;t++)if(!u0(e[t]))throw new Error(`批量打印数据第 ${t+1} 项必须是对象`);return{mode:"batch",dataList:e}}function p0(e){const t=e[0].bound,n=ct(t),r=e.map((a,l)=>{const c=n?`print-copy print-copy-${l}`:"print-copy",s=Xr(a.bound,a.pageLayouts,a.data,{codeRenderer:a.codeRenderer,pageHeightMm:a.derivedHeightMm});return`<section class="${c}">
235
247
  ${s}
236
248
  </section>`}).join(`
237
- `),o=n?sm(t,e.map(a=>({heightMm:a.derivedHeightMm}))):`${Wn(t)}
238
- .print-copy:not(:last-child){break-after:page;page-break-after:always;}`,i=Un(t.fonts)+o;return{html:zr(i,r,n?"continuous":void 0),pageCount:e.reduce((a,l)=>a+l.pageLayouts.length,0),copyPaperMm:e.map(a=>a.paperMm)}}const ot={enabled:!0,sheetPaperSize:"A4",sheetOrientation:"portrait",sheetMargin:{top:10,right:10,bottom:10,left:10},gapX:2,gapY:2,columns:2};class Vm extends Error{constructor(t,n){super(n),this.name="TilingError",this.code=t}}function Bt(e){return Math.round(e*10)/10}function Lc(e,t){const n=e.outputRotation;return n===90||n===270?`(内容旋转 ${n}°,每格 ${t.width}×${t.height}mm)`:""}function Wr(e){const t=e.tiling;return{...ot,...t,sheetMargin:{...ot.sheetMargin,...t?.sheetMargin??{}}}}function Yn(e,t){const n=Wr(e),r=t?.paperOverride;if(r&&typeof r.width=="number"&&r.width>0&&typeof r.height=="number"&&r.height>0)return{width:r.width,height:r.height};if(n.sheetPaperSize==="CUSTOM")return{width:n.sheetCustomWidth??Nt.A4.width,height:n.sheetCustomHeight??Nt.A4.height};const o=n.sheetPaperSize??"A4",i=Nt[o]??Nt.A4;return n.sheetOrientation==="landscape"?{width:i.height,height:i.width}:{...i}}function Nc(e,t){return{w:e.width-t.left-t.right,h:e.height-t.top-t.bottom}}function ca(e,t,n){return Math.max(0,Math.floor((e+n)/(t+n)))}function Fc(e,t){const n=da(e,t);if(n.length)throw new Vm(n[0].code,n[0].message);const r=Wr(e),o=Yn(e,t),i=nn(e),a=Nc(o,r.sheetMargin),l=Math.floor((a.h+r.gapY)/(i.height+r.gapY));return{tile:{width:i.width,height:i.height},sheet:o,columns:r.columns,rows:l,perSheet:r.columns*l,maxColumns:ca(a.w,i.width,r.gapX),margin:{...r.sheetMargin},gapX:r.gapX,gapY:r.gapY}}function Km(e,t){const n=t%e.perSheet,r=n%e.columns,o=Math.floor(n/e.columns);return{left:Bt(e.margin.left+r*(e.tile.width+e.gapX)),top:Bt(e.margin.top+o*(e.tile.height+e.gapY))}}function zc(e,t){const n=Wr(e),r=Yn(e,t),o=nn(e),i=r.width-n.sheetMargin.left-n.sheetMargin.right;return ca(i,o.width,n.gapX)}function da(e,t){const n=[],r=Wr(e);tt(e)&&n.push({code:"CONTINUOUS_UNSUPPORTED",message:"连续纸不支持拼版打印,请将模板纸张改为固定纸张或关闭拼版"});const o=r.sheetPaperSize,i=tn(o??"");i&&n.push({code:"SHEET_CONTINUOUS",message:"拼版目标纸张不能是连续纸"});const a=r.sheetPaperSize==="CUSTOM"&&!((r.sheetCustomWidth??0)>0&&(r.sheetCustomHeight??0)>0);if(a&&n.push({code:"SHEET_SIZE_INVALID",message:"拼版自定义纸张宽高必须是大于 0 的数值(mm)"}),a||i)return n;const l=Yn(e,t),c=nn(e),s=Nc(l,r.sheetMargin),d=Bt(r.sheetMargin.left+r.sheetMargin.right);if(!Number.isInteger(r.columns)||r.columns<1)return n.push({code:"COLUMNS_INVALID",message:"拼版列数必须是大于 0 的整数"}),n;const p=ca(s.w,c.width,r.gapX);if(r.columns>p){const u=Bt(r.columns*c.width+(r.columns-1)*r.gapX);n.push({code:"COLUMNS_OVERFLOW",message:"拼版列数 "+r.columns+" 超出纸面可用宽度:"+Bt(l.width)+"mm − 左右留白 "+d+"mm = "+Bt(s.w)+"mm,最多可放 "+p+" 列;当前 "+r.columns+" 列 "+c.width+"mm 标签含间距需要 "+u+"mm"+Lc(e,c)})}return Math.floor((s.h+r.gapY)/(c.height+r.gapY))<1&&n.push({code:"LABEL_TOO_TALL",message:"标签高度 "+c.height+"mm 超出纸面可用高度 "+Bt(s.h)+"mm,拼版每张 0 行;请缩小标签高度或改用横向纸"+Lc(e,c)}),n}function Xm(e){const t=[],n=new Set;for(const r of e)for(const o of r.warnings??[])n.has(o)||(n.add(o),t.push(o));return t}function Zm(e){const t=Array.isArray(e.pages)?e.pages:[e],n=[];for(const r of t)try{n.push(...yi(r,new Map))}catch{}return Xm(n)}function Jm(e){const{copies:t,layout:n}=e,r=t[0].bound,o=[];for(let a=0;a<t.length;a+=n.perSheet){const l=t.slice(a,a+n.perSheet).map((c,s)=>{const d=Km(n,s),p=Fr(c.bound,c.pageLayouts,c.data,{codeRenderer:c.codeRenderer});return`<div class="print-tile" style="left:${d.left}mm;top:${d.top}mm">
249
+ `),o=n?vm(t,e.map(a=>({heightMm:a.derivedHeightMm}))):`${Qn(t)}
250
+ .print-copy:not(:last-child){break-after:page;page-break-after:always;}`,i=Zn(t.fonts)+o;return{html:Kr(i,r,n?"continuous":void 0),pageCount:e.reduce((a,l)=>a+l.pageLayouts.length,0),copyPaperMm:e.map(a=>a.paperMm)}}const pt={enabled:!0,sheetPaperSize:"A4",sheetOrientation:"portrait",sheetMargin:{top:10,right:10,bottom:10,left:10},gapX:2,gapY:2,columns:2};class f0 extends Error{constructor(t,n){super(n),this.name="TilingError",this.code=t}}function Gt(e){return Math.round(e*10)/10}function Kc(e,t){const n=e.outputRotation;return n===90||n===270?`(内容旋转 ${n}°,每格 ${t.width}×${t.height}mm)`:""}function to(e){const t=e.tiling;return{...pt,...t,sheetMargin:{...pt.sheetMargin,...t?.sheetMargin??{}}}}function rr(e,t){const n=to(e),r=t?.paperOverride;if(r&&typeof r.width=="number"&&r.width>0&&typeof r.height=="number"&&r.height>0)return{width:r.width,height:r.height};if(n.sheetPaperSize==="CUSTOM")return{width:n.sheetCustomWidth??Ut.A4.width,height:n.sheetCustomHeight??Ut.A4.height};const o=n.sheetPaperSize??"A4",i=Ut[o]??Ut.A4;return n.sheetOrientation==="landscape"?{width:i.height,height:i.width}:{...i}}function Zc(e,t){return{w:e.width-t.left-t.right,h:e.height-t.top-t.bottom}}function va(e,t,n){return Math.max(0,Math.floor((e+n)/(t+n)))}function Jc(e,t){const n=wa(e,t);if(n.length)throw new f0(n[0].code,n[0].message);const r=to(e),o=rr(e,t),i=dn(e),a=Zc(o,r.sheetMargin),l=Math.floor((a.h+r.gapY)/(i.height+r.gapY));return{tile:{width:i.width,height:i.height},sheet:o,columns:r.columns,rows:l,perSheet:r.columns*l,maxColumns:va(a.w,i.width,r.gapX),margin:{...r.sheetMargin},gapX:r.gapX,gapY:r.gapY}}function h0(e,t){const n=t%e.perSheet,r=n%e.columns,o=Math.floor(n/e.columns);return{left:Gt(e.margin.left+r*(e.tile.width+e.gapX)),top:Gt(e.margin.top+o*(e.tile.height+e.gapY))}}function Qc(e,t){const n=to(e),r=rr(e,t),o=dn(e),i=r.width-n.sheetMargin.left-n.sheetMargin.right;return va(i,o.width,n.gapX)}function wa(e,t){const n=[],r=to(e);ct(e)&&n.push({code:"CONTINUOUS_UNSUPPORTED",message:"连续纸不支持拼版打印,请将模板纸张改为固定纸张或关闭拼版"});const o=r.sheetPaperSize,i=cn(o??"");i&&n.push({code:"SHEET_CONTINUOUS",message:"拼版目标纸张不能是连续纸"});const a=r.sheetPaperSize==="CUSTOM"&&!((r.sheetCustomWidth??0)>0&&(r.sheetCustomHeight??0)>0);if(a&&n.push({code:"SHEET_SIZE_INVALID",message:"拼版自定义纸张宽高必须是大于 0 的数值(mm)"}),a||i)return n;const l=rr(e,t),c=dn(e),s=Zc(l,r.sheetMargin),d=Gt(r.sheetMargin.left+r.sheetMargin.right);if(!Number.isInteger(r.columns)||r.columns<1)return n.push({code:"COLUMNS_INVALID",message:"拼版列数必须是大于 0 的整数"}),n;const p=va(s.w,c.width,r.gapX);if(r.columns>p){const u=Gt(r.columns*c.width+(r.columns-1)*r.gapX);n.push({code:"COLUMNS_OVERFLOW",message:"拼版列数 "+r.columns+" 超出纸面可用宽度:"+Gt(l.width)+"mm − 左右留白 "+d+"mm = "+Gt(s.w)+"mm,最多可放 "+p+" 列;当前 "+r.columns+" 列 "+c.width+"mm 标签含间距需要 "+u+"mm"+Kc(e,c)})}return Math.floor((s.h+r.gapY)/(c.height+r.gapY))<1&&n.push({code:"LABEL_TOO_TALL",message:"标签高度 "+c.height+"mm 超出纸面可用高度 "+Gt(s.h)+"mm,拼版每张 0 行;请缩小标签高度或改用横向纸"+Kc(e,c)}),n}function g0(e){const t=[],n=new Set;for(const r of e)for(const o of r.warnings??[])n.has(o)||(n.add(o),t.push(o));return t}function m0(e){const t=Array.isArray(e.pages)?e.pages:[e],n=[];for(const r of t)try{n.push(...Oi(r,new Map))}catch{}return g0(n)}function b0(e){const{copies:t,layout:n}=e,r=t[0].bound,o=[];for(let a=0;a<t.length;a+=n.perSheet){const l=t.slice(a,a+n.perSheet).map((c,s)=>{const d=h0(n,s),p=Xr(c.bound,c.pageLayouts,c.data,{codeRenderer:c.codeRenderer});return`<div class="print-tile" style="left:${d.left}mm;top:${d.top}mm">
239
251
  ${p}
240
252
  </div>`}).join(`
241
253
  `);o.push(`<section class="print-sheet">
242
254
  ${l}
243
- </section>`)}const i=Un(r.fonts)+Wn(r)+`
244
- `+lm(n);return{html:zr(i,o.join(`
245
- `)),sheetCount:o.length,perSheet:n.perSheet}}function ua(e,t){return e.name?`第 ${t+1} 页「${e.name}」`:`第 ${t+1} 页`}function pa(e){const t=Qm(e)?e.pages:[e];if(t.length===0)throw new Error("多页面模板至少需要一页");if(t.length===1)return t;const n=Ze(t[0]);return t.forEach((r,o)=>{if(tt(r))throw new Error(`多页面模板不支持连续纸(${ua(r,o)})`);if(r.tiling?.enabled===!0)throw new Error(`多页面模板不支持标签拼版(${ua(r,o)})`);const i=Ze(r);if(i.width!==n.width||i.height!==n.height)throw new Error(`多页面模板各页纸张尺寸必须一致(${ua(r,o)} ${i.width}×${i.height}mm 与首页 ${n.width}×${n.height}mm 不同)`)}),t}function Qm(e){return Array.isArray(e.pages)}function e0(e){const t=new Set,n=[];for(const r of e)for(const o of r.fonts??[]){const i=o.family;t.has(i)||(t.add(i),n.push(o))}return n}function t0(e){if(e.length===0)throw new Error("多页面模板至少需要一份数据");const t=e[0].boundPages,n=Un(e0(t))+[im(t[0]),om(),...t.map((l,c)=>am(l,`.mt-${c}`)),...e.length>1?[Qi]:[]].join(`
255
+ </section>`)}const i=Zn(r.fonts)+Qn(r)+`
256
+ `+wm(n);return{html:Kr(i,o.join(`
257
+ `)),sheetCount:o.length,perSheet:n.perSheet}}function xa(e,t){return e.name?`第 ${t+1} 页「${e.name}」`:`第 ${t+1} 页`}function Ea(e){const t=y0(e)?e.pages:[e];if(t.length===0)throw new Error("多页面模板至少需要一页");if(t.length===1)return t;const n=et(t[0]);return t.forEach((r,o)=>{if(ct(r))throw new Error(`多页面模板不支持连续纸(${xa(r,o)})`);if(r.tiling?.enabled===!0)throw new Error(`多页面模板不支持标签拼版(${xa(r,o)})`);const i=et(r);if(i.width!==n.width||i.height!==n.height)throw new Error(`多页面模板各页纸张尺寸必须一致(${xa(r,o)} ${i.width}×${i.height}mm 与首页 ${n.width}×${n.height}mm 不同)`)}),t}function y0(e){return Array.isArray(e.pages)}function v0(e){const t=new Set,n=[];for(const r of e)for(const o of r.fonts??[]){const i=o.family;t.has(i)||(t.add(i),n.push(o))}return n}function w0(e){if(e.length===0)throw new Error("多页面模板至少需要一份数据");const t=e[0].boundPages,n=Zn(v0(t))+[bm(t[0]),mm(),...t.map((l,c)=>ym(l,`.mt-${c}`)),...e.length>1?[da]:[]].join(`
246
258
 
247
- `),r=e.map(l=>{const c=l.layoutsPerPage.reduce((u,f)=>u+f.length,0);let s=0;const p=l.layoutsPerPage.map((u,f)=>{const g=Fr(l.boundPages[f],u,l.data,{codeRenderer:l.codeRenderers?.[f]},{pageOffset:s,totalPages:c,pageClass:`mt-${f}`});return s+=u.length,g}).join(`
259
+ `),r=e.map(l=>{const c=l.layoutsPerPage.reduce((u,f)=>u+f.length,0);let s=0;const p=l.layoutsPerPage.map((u,f)=>{const m=Xr(l.boundPages[f],u,l.data,{codeRenderer:l.codeRenderers?.[f]},{pageOffset:s,totalPages:c,pageClass:`mt-${f}`});return s+=u.length,m}).join(`
248
260
  `);return e.length>1?`<section class="print-copy">
249
261
  ${p}
250
262
  </section>`:p}).join(`
251
- `),o=e.reduce((l,c)=>l+c.layoutsPerPage.reduce((s,d)=>s+d.length,0),0),i=[];let a=0;for(const l of e)for(const c of l.layoutsPerPage)for(const s of c)i.push({...s,pageIndex:a++});return{html:zr(n,r),pageCount:o,pageLayouts:i}}async function n0(e,t){return t.withSession(e,n=>r0(e,n))}async function r0(e,t){const n=pa(e.templateJson);if(n.length>1){const c=$c(e.printData),s=c.mode==="batch"?c.dataList:[c.data],d=[];for(let u=0;u<s.length;u++)try{d.push(await i0(e,t,s[u]))}catch(f){const g=f instanceof Error?f.message:String(f);throw new Error(`第 ${u+1} 份渲染失败:${g}`)}const p=t0(d);return{html:p.html,pageCount:p.pageCount,paperMm:nn(n[0]),continuous:!1,heightSource:"config",pageLayouts:p.pageLayouts,copies:d.length}}const r=n[0]!==e.templateJson?{...e,templateJson:n[0]}:e,o=n[0],i=$c(r.printData);if(i.mode==="single"){const c=await Hc(r,t,i.data);return o.tiling?.enabled===!0?Bc(r,[{bound:c.bound,pageLayouts:c.pageLayouts,data:i.data,codeRenderer:c.codeRenderer,derivedHeightMm:c.derivedHeightMm,paperMm:c.paperMm,heightSource:c.heightSource}]):o0(c)}const a=[];for(let c=0;c<i.dataList.length;c++)try{const s=await Hc(r,t,i.dataList[c]);a.push({bound:s.bound,pageLayouts:s.pageLayouts,data:i.dataList[c],codeRenderer:s.codeRenderer,derivedHeightMm:s.derivedHeightMm,paperMm:s.paperMm,heightSource:s.heightSource})}catch(s){const d=s instanceof Error?s.message:String(s);throw new Error(`第 ${c+1} 份渲染失败:${d}`)}if(o.tiling?.enabled===!0)return Bc(r,a);const l=Ym(a);return{html:l.html,pageCount:l.pageCount,paperMm:a[0].paperMm,continuous:tt(a[0].bound),heightSource:a[0].heightSource,pageLayouts:a.flatMap(c=>c.pageLayouts),copies:a.length,copyPaperMm:l.copyPaperMm}}function o0(e){return{html:e.html,pageCount:e.pageCount,paperMm:e.paperMm,continuous:e.continuous,heightSource:e.heightSource,pageLayouts:e.pageLayouts,copies:1}}function Bc(e,t){const n=t[0].bound,r=Fc(n,{paperOverride:e.paperOverride});t.forEach((i,a)=>{const l=i.pageLayouts[0]?.overflow===!0;if(i.pageLayouts.length!==1||l){const c=l?"内容超出纸张高度":`渲染出 ${i.pageLayouts.length} 页`;throw new Error(`拼版要求每份标签恰好 1 页,第 ${a+1} 份${c};请缩小内容或调整标签纸张高度`)}});const o=Jm({copies:t.map(i=>({bound:i.bound,pageLayouts:i.pageLayouts,data:i.data,codeRenderer:i.codeRenderer})),layout:r});return{html:o.html,pageCount:o.sheetCount,paperMm:{width:r.sheet.width,height:r.sheet.height},continuous:!1,heightSource:"config",pageLayouts:t.flatMap(i=>i.pageLayouts),copies:t.length}}async function Hc(e,t,n){const r=ic(e.templateJson,n,e.baseUrl,e.fontBaseUrl),o=tt(r),i=Ze(r),a=Oc(i),l=Lm({paperHeightMm:e.paperHeightMm,override:e.paperOverride}),c=await jr({bound:r,job:e,session:t,data:n,pageLayouts:[],isMeasurementPass:!0}),s=await t.measure(c.html,a);Pc(r,s.fits);const d=yi(r,Ic(s.measurements,r)),p=await jr({bound:r,job:e,session:t,data:n,pageLayouts:d,isMeasurementPass:!1,baseMap:c.map});let u=p.html,f;if(o){if(l&&l>0)f=l;else{const w=await t.probeContentBottom(u,a);f=Rm(r,la(w))}u=Nr(r,d,n,{codeRenderer:p.codeRenderer,pageHeightMm:f})}const g=o&&l?{...e.paperOverride,height:l}:e.paperOverride,m=nn(r),{paperMm:y,heightSource:v}=Nm({paperMm:{width:m.width,height:f??m.height},continuous:o,override:g});return{html:u,pageCount:d.length,paperMm:y,continuous:o,heightSource:v,pageLayouts:d,copies:1,bound:r,codeRenderer:p.codeRenderer,derivedHeightMm:f}}async function i0(e,t,n){const r=pa(e.templateJson),o=Oc(Ze(r[0])),i=[],a=[],l=[];for(const c of r){const s=ic(c,n,e.baseUrl,e.fontBaseUrl),d=await jr({bound:s,job:e,session:t,data:n,pageLayouts:[],isMeasurementPass:!0}),p=await t.measure(d.html,o);Pc(s,p.fits);const u=yi(s,Ic(p.measurements,s)),f=await jr({bound:s,job:e,session:t,data:n,pageLayouts:u,isMeasurementPass:!1,baseMap:d.map});i.push(s),a.push(u),l.push(f.codeRenderer)}return{boundPages:i,layoutsPerPage:a,data:n,codeRenderers:l}}async function jr(e){const t=e.baseMap??new Map;if(e.job.codeRenderer)return{html:Nr(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:e.job.codeRenderer}),codeRenderer:e.job.codeRenderer,map:t};const n=Bm(t),r=Nr(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:n.renderer}),o=n.takeSpecs(),i=o.length>0?await e.session.renderCodes(o):new Map,a=Hm(t,i),l=a.size>0?zm(a):void 0;return o.length===0?{html:r,codeRenderer:l,map:a}:{html:Nr(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:l}),codeRenderer:l,map:a}}class a0{constructor(t){this.functions={},t?.functions&&(this.functions={...t.functions})}registerFunction(t,n){this.functions[t]=n}evaluate(t,n){const r=Ni(t),o=Fi(r);return Ie(o,n,this.functions)}render(t,n){return Wl(t,this.functions)(n)}}const Uc=new a0,s0={MONEY:jl,CONCAT:(...e)=>e.filter(t=>t!=null).join(""),IF:Vl,FORMAT:e=>typeof e!="number"?String(e):e.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}),SUBSTR:(e,t,n)=>String(e).slice(t,n?t+n:void 0),LEN:e=>String(e).length,ADD:Ql,SUB:ec,MUL:tc,DIV:nc,ROUND:rc,ROUNDUP:Ir,CEIL:Ir,ROUNDDOWN:Pr,FLOOR:Pr,ROUNDBANK:oc,NOW:()=>new Date().toISOString().split("T")[0],IFEMPTY:(e,t)=>e!=null&&e!==""?String(e):t,PAD:(e,t,n)=>String(e).padStart(t,n),REPLACE:(e,t,n)=>String(e).replace(new RegExp(t,"g"),n),JSON:e=>JSON.stringify(e,null,2),DATE:Gl,UPPER:Yl};for(const[e,t]of Object.entries(s0))Uc.registerFunction(e,t);function l0(e,t,n){switch(e.toUpperCase()){case"SUM":return Wi(n,t);case"AVG":return Kl(n,t);case"COUNT":return Xl(n);case"MIN":return Zl(n,t);case"MAX":return Jl(n,t);default:return 0}}function dn(e,t){if(!e)return"";if(!e.includes("{"))return e;const n=Array.isArray(t.rows)?t.rows:[];let r=e.replace(/\{([^}]+)\}/g,(o,i)=>{let a=i.trim();return a=a.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(l,c,s)=>{const d=s.trim().replace(/^['"]|['"]$/g,"");return String(l0(c,d,n))}),`{${a}}`});try{return Uc.render(r,t)}catch{return e}}const it={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级"}]},Gr={left:0,center:50,right:100},Yr={top:0,center:50,bottom:100};function un(e){return Number.isFinite(e)?Math.round(Math.min(100,Math.max(0,e))):50}function qc(e){return Math.round(e*100)/100}function Wc(e,t){const n=un(e),r=un(t);if(!(n===50&&r===50))return`${n}% ${r}%`}function c0(e){return/^\d+(?:\.\d+)?%$/.test(e)?parseFloat(e):void 0}function d0(e){const t=(e??"").trim();if(!t)return{kind:"empty"};const n=t.toLowerCase().split(/\s+/);let r,o;for(let i=0;i<n.length;i++){const a=n[i],l=c0(a);if(i===0)if(a in Gr)r=Gr[a];else if(l!==void 0)r=l;else if(a in Yr)o=Yr[a];else return{kind:"custom",raw:e};else if(a in Yr&&o===void 0)o=Yr[a];else if(l!==void 0&&r===void 0)r=l;else if(l!==void 0&&o===void 0)o=l;else if(a in Gr&&r===void 0)r=Gr[a];else return{kind:"custom",raw:e}}return{kind:"axes",x:un(r??50),y:un(o??50)}}const jc=25.4/96;function Gc(e){const{widthMm:t,heightMm:n,naturalWidth:r,naturalHeight:o}=e;if(!r||!o||!t||!n)return null;const i=t/r,a=n/o,l=(rl(e.fit,e.scalePct)??Dn)/100;switch(e.fit||"contain"){case"fill":return{w:t,h:n};case"cover":{const c=Math.max(i,a)*l;return{w:r*c,h:o*c}}case"none":return{w:r*jc,h:o*jc};case"scale-down":{const c=Math.min(1,Math.min(i,a));return{w:r*c,h:o*c}}default:{const c=Math.min(i,a);return{w:r*c,h:o*c}}}}function u0(e){const t=Gc(e);return t?{x:qc(Math.abs(e.widthMm-t.w)),y:qc(Math.abs(e.heightMm-t.h))}:{x:null,y:null}}function p0(e,t,n){const r=Gc(e);if(!r)return null;const o=Math.min(1,e.widthMm/r.w),i=Math.min(1,e.heightMm/r.h);return{leftPct:(1-o)*un(t),topPct:(1-i)*un(n),widthPct:o*100,heightPct:i*100}}function Yc(e){const t=String(e??"");return t?t.includes("{")?String(dn(t,it)):t:""}const Vc={vertical:[{value:0,label:"顶部"},{value:50,label:"居中"},{value:100,label:"底部"}],horizontal:[{value:0,label:"左侧"},{value:50,label:"居中"},{value:100,label:"右侧"}]},f0=[{x:0,y:0,label:"左上"},{x:50,y:0,label:"上中"},{x:100,y:0,label:"右上"},{x:0,y:50,label:"左中"},{x:50,y:50,label:"居中"},{x:100,y:50,label:"右中"},{x:0,y:100,label:"左下"},{x:50,y:100,label:"下中"},{x:100,y:100,label:"右下"}],fa=[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"剪裁(等比铺满后裁边)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],h0="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+PHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNmZmZmZmYiLz48cGF0aCBkPSJNNDAgMFYxMjBNODAgMFYxMjBNMCA0MEgxMjBNMCA4MEgxMjAiIHN0cm9rZT0iI2VlZjFmNiIgc3Ryb2tlLXdpZHRoPSIxIi8+PGNpcmNsZSBjeD0iMjAiIGN5PSIyMCIgcj0iMy41IiBmaWxsPSIjOGI5NWE1Ii8+PGNpcmNsZSBjeD0iMTAwIiBjeT0iMjAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iMTAwIiByPSIzLjUiIGZpbGw9IiM4Yjk1YTUiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSIxMDAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iMjAiIHI9IjciIGZpbGw9IiNjMDM5MmIiLz48Y2lyY2xlIGN4PSI2MCIgY3k9IjEwMCIgcj0iNyIgZmlsbD0iIzFmNGZhMyIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iNjAiIHI9IjciIGZpbGw9IiMyYzdhNGEiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSI2MCIgcj0iNyIgZmlsbD0iI2UwN2EyMCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjE0IiBmaWxsPSJub25lIiBzdHJva2U9IiMyZjNhNGEiIHN0cm9rZS13aWR0aD0iNCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjYiIGZpbGw9IiMyZjNhNGEiLz48L3N2Zz4=",g0="图片还没设置,上面按内置示例图演示取位;换上真图后档位与可挪量按真图重算";function m0(e){const t=String(e??"").trim();return!t||t.includes("{")||t.includes("}")?{src:h0,isSample:!0}:{src:t,isSample:!1}}function Kc(e){return e==="vertical"?"垂直位置 (%)":"水平位置 (%)"}const b0="放大比例 (%)";function y0(e,t=!1){if(t)return"已保留模板里的原值;改动下面任一项就整体替换成新的取位";const{x:n,y:r}=e;return n===null||r===null?"":n>0&&r>0?`水平可挪 ${n}mm、垂直可挪 ${r}mm:0 贴左/贴顶,100 贴右/贴底`:n>0?`水平可挪 ${n}mm;垂直这一轴已贴满,挪不动`:r>0?`垂直可挪 ${r}mm;水平这一轴已贴满,挪不动`:"这个缩放下图与框正好一样大,两轴都没有可挪的余量"}function v0(e,t,n){return[{name:"horizontal",label:Kc("horizontal"),value:t,travelMm:e.x},{name:"vertical",label:Kc("vertical"),value:n,travelMm:e.y}]}function w0(e,t,n){const r=e.x!==null&&e.x>0,o=e.y!==null&&e.y>0;return o&&!r?Vc.vertical.map(i=>({value:`${t},${i.value}`,label:i.label})):r&&!o?Vc.horizontal.map(i=>({value:`${i.value},${n}`,label:i.label})):f0.map(i=>({value:`${i.x},${i.y}`,label:i.label}))}function Xc(e){const t=[...e].sort((a,l)=>(a.sortOrder??0)-(l.sortOrder??0)),n=new Map,r=[];for(const a of t){const l=a.fieldKey.indexOf(".");if(l===-1)continue;const c=a.fieldKey.slice(0,l);let s=n.get(c);s||(s={key:c,label:c,isList:!1,fields:[]},n.set(c,s),r.push(c)),s.fields.push(a)}const o=[],i=[];for(const a of t){if(a.fieldKey.includes("."))continue;const l=n.get(a.fieldKey);l?(l.label=a.fieldLabel,l.isList=a.fieldType==="list"):i.push(a)}i.length&&o.push({key:"",label:"",isList:!1,fields:i});for(const a of r)o.push(n.get(a));return o}function x0(e,t){const n=t.trim().toLowerCase();return n?e.map(r=>({...r,fields:r.fields.filter(o=>o.fieldLabel.toLowerCase().includes(n)||o.fieldKey.toLowerCase().includes(n))})).filter(r=>r.fields.length>0):e}async function Zc(e){if(!e)return!1;const t=typeof navigator>"u"?void 0:navigator;if(t?.clipboard?.writeText)try{return await t.clipboard.writeText(e),!0}catch{}if(typeof document>"u")return!1;const n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.top="-1000px",n.style.opacity="0",document.body.appendChild(n);try{return n.select(),typeof document.execCommand=="function"&&document.execCommand("copy")}catch{return!1}finally{n.remove()}}const E0={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:[],flowList:[{targetPath:"options.formatter",label:"单元模板",dataSource:"main",placeholder:"{drugs.name} {drugs.spec}"}]};function Jc(e,t,n,r){return e==="data"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"list",listField:r,placeholder:"{name}"}]:e==="subtotal"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"subtotal",placeholder:"{MONEY(SUM(amount))}"}]:e==="summary"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"summary",placeholder:"{MONEY(SUM(amount))}"}]:[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"main",placeholder:"合计: {order.total}"}]}function S0(e){const t=e.printElementType.type,n=E0[t]??[],r=[];if(t==="table"){const o=e.options.dataSource;for(const[i,a]of(e.options.tableRows??[]).entries())for(const[l,c]of a.cells.entries())c.merged||r.push(...Jc(a.type,i,l,o))}return[...n,...r]}function _0(e){return Mi("text",{formatter:`{${e.fieldKey}}`,title:e.fieldLabel})}function M0(e){const t=e.fieldLabel||e.fieldKey;return Mi("text",{formatter:t,title:t})}function Qc(e){let t=it;for(const n of e.split(".")){if(t==null)return;t=Array.isArray(t)?t[0]?.[n]:t[n]}return t}function ha(e,t,n="1234567890128"){const r=t?.[0];return(e??"").replace(/\{([^{}]+)\}/g,(i,a)=>{const l=a.trim(),c=l.includes(".")?Qc(l):r?.[l]??Qc(l);return c==null?"":String(c)}).trim()||n}const Vr={left:"#3b82f6",center:"#10b981",right:"#f59e0b",top:"#3b82f6",middle:"#10b981",bottom:"#f59e0b"};function ed(e){return e==="vCenter"?Vr.center:e==="hCenter"?Vr.middle:Vr[e]??Vr.left}function T0(e,t,n,r={}){const o=r.adsorbMin??1,i=r.adsorbLineMin??2,a=r.showAdsorbLine??!0;let l=e.left,c=e.top;const s=[],d={left:e.left,right:e.left+e.width,vCenter:e.left+e.width/2,top:e.top,bottom:e.top+e.height,hCenter:e.top+e.height/2};let p=1/0;for(const f of t){if(f.id===e.id)continue;const g={left:f.left,right:f.left+f.width,vCenter:f.left+f.width/2,top:f.top,bottom:f.top+f.height,hCenter:f.top+f.height/2},m=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],y=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[v,w]of m){const _=Math.abs(d[v]-g[w]);_<=o&&_<p&&(p=_,l=e.left+(g[w]-d[v]))}for(const[v,w]of y){const _=Math.abs(d[v]-g[w]);_<=o&&_<p&&(p=_,c=e.top+(g[w]-d[v]))}}if(n){const f={left:l,right:l+e.width,vCenter:l+e.width/2,top:c,bottom:c+e.height,hCenter:c+e.height/2},g=["left","vCenter","right"];for(const y of n.vertical)for(const v of g){const w=Math.abs(f[v]-y);w<=o&&w<p&&(p=w,l=e.left+(y-f[v]))}const m=["top","hCenter","bottom"];for(const y of n.horizontal)for(const v of m){const w=Math.abs(f[v]-y);w<=o&&w<p&&(p=w,c=e.top+(y-f[v]))}}const u={left:l,right:l+e.width,vCenter:l+e.width/2,top:c,bottom:c+e.height,hCenter:c+e.height/2};if(a){const f=new Set;for(const g of t){if(g.id===e.id)continue;const m={left:g.left,right:g.left+g.width,vCenter:g.left+g.width/2,top:g.top,bottom:g.top+g.height,hCenter:g.top+g.height/2},y=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],v=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[w,_]of y)if(Math.abs(u[w]-m[_])<=i){const N=`v:${m[_]}`;f.has(N)||(f.add(N),s.push({type:"vertical",position:m[_],id:g.id,color:ed(w)}))}for(const[w,_]of v)if(Math.abs(u[w]-m[_])<=i){const N=`h:${m[_]}`;f.has(N)||(f.add(N),s.push({type:"horizontal",position:m[_],id:g.id,color:ed(w)}))}}}if(n){for(const f of n.vertical)s.some(g=>g.type==="vertical"&&g.position===f)||s.push({type:"vertical",position:f});for(const f of n.horizontal)s.some(g=>g.type==="horizontal"&&g.position===f)||s.push({type:"horizontal",position:f})}return{left:l,top:c,lines:s}}function k0(){function e(t,n){if(t.length<2)return;const r={minLeft:Math.min(...t.map(o=>o.options.left)),maxRight:Math.max(...t.map(o=>o.options.left+o.options.width)),minTop:Math.min(...t.map(o=>o.options.top)),maxBottom:Math.max(...t.map(o=>o.options.top+o.options.height))};switch(n){case"left":t.forEach(o=>{o.options.left=r.minLeft});break;case"right":t.forEach(o=>{o.options.left=r.maxRight-o.options.width});break;case"top":t.forEach(o=>{o.options.top=r.minTop});break;case"bottom":t.forEach(o=>{o.options.top=r.maxBottom-o.options.height});break;case"vertical":{const o=r.minLeft+(r.maxRight-r.minLeft)/2;t.forEach(i=>{i.options.left=o-i.options.width/2});break}case"horizontal":{const o=r.minTop+(r.maxBottom-r.minTop)/2;t.forEach(i=>{i.options.top=o-i.options.height/2});break}case"distributeHor":{const o=[...t].sort((c,s)=>c.options.left-s.options.left),i=o.reduce((c,s)=>c+s.options.width,0),a=(r.maxRight-r.minLeft-i)/(o.length-1);let l=r.minLeft;o.forEach(c=>{c.options.left=l,l+=c.options.width+a});break}case"distributeVer":{const o=[...t].sort((c,s)=>c.options.top-s.options.top),i=o.reduce((c,s)=>c+s.options.height,0),a=(r.maxBottom-r.minTop-i)/(o.length-1);let l=r.minTop;o.forEach(c=>{c.options.top=l,l+=c.options.height+a});break}}}return{align:e}}function td(){return`grp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function C0(){function e(r,o){if(r.filter(l=>o.has(l.id)).length<2)return r;const a=td();return r.map(l=>o.has(l.id)?{...l,options:{...l.options,groupId:a}}:l)}function t(r,o){const i=r.filter(l=>o.has(l.id)),a=new Set(i.map(l=>l.options.groupId).filter(Boolean));return r.map(l=>l.options.groupId&&a.has(l.options.groupId)?{...l,options:{...l.options,groupId:void 0}}:l)}function n(r,o){const i=r.find(l=>l.id===o);if(!i?.options.groupId)return new Set([o]);const a=new Set;for(const l of r)l.options.groupId===i.options.groupId&&a.add(l.id);return a}return{group:e,ungroup:t,getGroupedIds:n}}const A0=["nw","n","ne","e","se","s","sw","w"];function O0(e,t,n,r,o,i){let{left:a,top:l,width:c,height:s}=t;switch(e){case"e":c=Math.max(o,t.width+n);break;case"w":c=Math.max(o,t.width-n),a=t.left+t.width-c;break;case"s":s=Math.max(i,t.height+r);break;case"n":s=Math.max(i,t.height-r),l=t.top+t.height-s;break;case"se":c=Math.max(o,t.width+n),s=Math.max(i,t.height+r);break;case"sw":c=Math.max(o,t.width-n),a=t.left+t.width-c,s=Math.max(i,t.height+r);break;case"ne":c=Math.max(o,t.width+n),s=Math.max(i,t.height-r),l=t.top+t.height-s;break;case"nw":c=Math.max(o,t.width-n),a=t.left+t.width-c,s=Math.max(i,t.height-r),l=t.top+t.height-s;break}return{left:a,top:l,width:c,height:s}}function nd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Kr={},Vn={},Xr={},rd;function qe(){if(rd)return Xr;rd=1,Object.defineProperty(Xr,"__esModule",{value:!0});function e(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}var t=function n(r,o){e(this,n),this.data=r,this.text=o.text||r,this.options=o};return Xr.default=t,Xr}var od;function I0(){if(od)return Vn;od=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.CODE39=void 0;var e=(function(){function m(y,v){for(var w=0;w<v.length;w++){var _=v[w];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(y,_.key,_)}}return function(y,v,w){return v&&m(y.prototype,v),w&&m(y,w),y}})(),t=qe(),n=r(t);function r(m){return m&&m.__esModule?m:{default:m}}function o(m,y){if(!(m instanceof y))throw new TypeError("Cannot call a class as a function")}function i(m,y){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y&&(typeof y=="object"||typeof y=="function")?y:m}function a(m,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);m.prototype=Object.create(y&&y.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(m,y):m.__proto__=y)}var l=(function(m){a(y,m);function y(v,w){return o(this,y),v=v.toUpperCase(),w.mod43&&(v+=u(g(v))),i(this,(y.__proto__||Object.getPrototypeOf(y)).call(this,v,w))}return e(y,[{key:"encode",value:function(){for(var w=d("*"),_=0;_<this.data.length;_++)w+=d(this.data[_])+"0";return w+=d("*"),{data:w,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),y})(n.default),c=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],s=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function d(m){return p(f(m))}function p(m){return s[m].toString(2)}function u(m){return c[m]}function f(m){return c.indexOf(m)}function g(m){for(var y=0,v=0;v<m.length;v++)y+=f(m[v]);return y=y%43,y}return Vn.CODE39=l,Vn}var Je={},Zr={},Jr={},me={},id;function Kn(){if(id)return me;id=1,Object.defineProperty(me,"__esModule",{value:!0});var e;function t(c,s,d){return s in c?Object.defineProperty(c,s,{value:d,enumerable:!0,configurable:!0,writable:!0}):c[s]=d,c}var n=me.SET_A=0,r=me.SET_B=1,o=me.SET_C=2;me.SHIFT=98;var i=me.START_A=103,a=me.START_B=104,l=me.START_C=105;return me.MODULO=103,me.STOP=106,me.FNC1=207,me.SET_BY_CODE=(e={},t(e,i,n),t(e,a,r),t(e,l,o),e),me.SWAP={101:n,100:r,99:o},me.A_START_CHAR="Ð",me.B_START_CHAR="Ñ",me.C_START_CHAR="Ò",me.A_CHARS="[\0-_È-Ï]",me.B_CHARS="[ -È-Ï]",me.C_CHARS="(Ï*[0-9]{2}Ï*)",me.BARS=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011],me}var ad;function Qr(){if(ad)return Jr;ad=1,Object.defineProperty(Jr,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=qe(),n=o(t),r=Kn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){i(this,d);var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p.substring(1),u));return f.bytes=p.split("").map(function(g){return g.charCodeAt(0)}),f}return e(d,[{key:"valid",value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:"encode",value:function(){var u=this.bytes,f=u.shift()-105,g=r.SET_BY_CODE[f];if(g===void 0)throw new RangeError("The encoding does not start with a start character.");this.shouldEncodeAsEan128()===!0&&u.unshift(r.FNC1);var m=d.next(u,1,g);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:d.getBar(f)+m.result+d.getBar((m.checksum+f)%r.MODULO)+d.getBar(r.STOP)}}},{key:"shouldEncodeAsEan128",value:function(){var u=this.options.ean128||!1;return typeof u=="string"&&(u=u.toLowerCase()==="true"),u}}],[{key:"getBar",value:function(u){return r.BARS[u]?r.BARS[u].toString():""}},{key:"correctIndex",value:function(u,f){if(f===r.SET_A){var g=u.shift();return g<32?g+64:g-32}else return f===r.SET_B?u.shift()-32:(u.shift()-48)*10+u.shift()-48}},{key:"next",value:function(u,f,g){if(!u.length)return{result:"",checksum:0};var m=void 0,y=void 0;if(u[0]>=200){y=u.shift()-105;var v=r.SWAP[y];v!==void 0?m=d.next(u,f+1,v):((g===r.SET_A||g===r.SET_B)&&y===r.SHIFT&&(u[0]=g===r.SET_A?u[0]>95?u[0]-96:u[0]:u[0]<32?u[0]+96:u[0]),m=d.next(u,f+1,g))}else y=d.correctIndex(u,g),m=d.next(u,f+1,g);var w=d.getBar(y),_=y*f;return{result:w+m.result,checksum:_+m.checksum}}}]),d})(n.default);return Jr.default=c,Jr}var eo={},sd;function P0(){if(sd)return eo;sd=1,Object.defineProperty(eo,"__esModule",{value:!0});var e=Kn(),t=function(l){return l.match(new RegExp("^"+e.A_CHARS+"*"))[0].length},n=function(l){return l.match(new RegExp("^"+e.B_CHARS+"*"))[0].length},r=function(l){return l.match(new RegExp("^"+e.C_CHARS+"*"))[0]};function o(a,l){var c=l?e.A_CHARS:e.B_CHARS,s=a.match(new RegExp("^("+c+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(s)return s[1]+"Ì"+i(a.substring(s[1].length));var d=a.match(new RegExp("^"+c+"+"))[0];return d.length===a.length?a:d+String.fromCharCode(l?205:206)+o(a.substring(d.length),!l)}function i(a){var l=r(a),c=l.length;if(c===a.length)return a;a=a.substring(c);var s=t(a)>=n(a);return l+String.fromCharCode(s?206:205)+o(a,s)}return eo.default=function(a){var l=void 0,c=r(a).length;if(c>=2)l=e.C_START_CHAR+i(a);else{var s=t(a)>n(a);l=(s?e.A_START_CHAR:e.B_START_CHAR)+o(a,s)}return l.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,p){return"Ë"+p})},eo}var ld;function D0(){if(ld)return Zr;ld=1,Object.defineProperty(Zr,"__esModule",{value:!0});var e=Qr(),t=o(e),n=P0(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){if(i(this,d),/^[\x00-\x7F\xC8-\xD3]+$/.test(p))var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,(0,r.default)(p),u));else var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u));return a(f)}return d})(t.default);return Zr.default=c,Zr}var to={},cd;function R0(){if(cd)return to;cd=1,Object.defineProperty(to,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=Qr(),n=o(t),r=Kn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.A_START_CHAR+p,u))}return e(d,[{key:"valid",value:function(){return new RegExp("^"+r.A_CHARS+"+$").test(this.data)}}]),d})(n.default);return to.default=c,to}var no={},dd;function $0(){if(dd)return no;dd=1,Object.defineProperty(no,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=Qr(),n=o(t),r=Kn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.B_START_CHAR+p,u))}return e(d,[{key:"valid",value:function(){return new RegExp("^"+r.B_CHARS+"+$").test(this.data)}}]),d})(n.default);return no.default=c,no}var ro={},ud;function L0(){if(ud)return ro;ud=1,Object.defineProperty(ro,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=Qr(),n=o(t),r=Kn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.C_START_CHAR+p,u))}return e(d,[{key:"valid",value:function(){return new RegExp("^"+r.C_CHARS+"+$").test(this.data)}}]),d})(n.default);return ro.default=c,ro}var pd;function N0(){if(pd)return Je;pd=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.CODE128C=Je.CODE128B=Je.CODE128A=Je.CODE128=void 0;var e=D0(),t=c(e),n=R0(),r=c(n),o=$0(),i=c(o),a=L0(),l=c(a);function c(s){return s&&s.__esModule?s:{default:s}}return Je.CODE128=t.default,Je.CODE128A=r.default,Je.CODE128B=i.default,Je.CODE128C=l.default,Je}var Pe={},oo={},pt={},fd;function Xn(){return fd||(fd=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.SIDE_BIN="101",pt.MIDDLE_BIN="01010",pt.BINARIES={L:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],G:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],R:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],O:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],E:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"]},pt.EAN2_STRUCTURE=["LL","LG","GL","GG"],pt.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],pt.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),pt}var io={},ao={},hd;function Zn(){if(hd)return ao;hd=1,Object.defineProperty(ao,"__esModule",{value:!0});var e=Xn(),t=function(r,o,i){var a=r.split("").map(function(c,s){return e.BINARIES[o[s]]}).map(function(c,s){return c?c[r[s]]:""});if(i){var l=r.length-1;a=a.map(function(c,s){return s<l?c+i:c})}return a.join("")};return ao.default=t,ao}var gd;function md(){if(gd)return io;gd=1,Object.defineProperty(io,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})(),t=Xn(),n=Zn(),r=a(n),o=qe(),i=a(o);function a(p){return p&&p.__esModule?p:{default:p}}function l(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function c(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function s(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var d=(function(p){s(u,p);function u(f,g){l(this,u);var m=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g));return m.fontSize=!g.flat&&g.fontSize>g.width*10?g.width*10:g.fontSize,m.guardHeight=g.height+m.fontSize/2+g.textMargin,m}return e(u,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(g,m){return this.text.substr(g,m)}},{key:"leftEncode",value:function(g,m){return(0,r.default)(g,m)}},{key:"rightText",value:function(g,m){return this.text.substr(g,m)}},{key:"rightEncode",value:function(g,m){return(0,r.default)(g,m)}},{key:"encodeGuarded",value:function(){var g={fontSize:this.fontSize},m={height:this.guardHeight};return[{data:t.SIDE_BIN,options:m},{data:this.leftEncode(),text:this.leftText(),options:g},{data:t.MIDDLE_BIN,options:m},{data:this.rightEncode(),text:this.rightText(),options:g},{data:t.SIDE_BIN,options:m}]}},{key:"encodeFlat",value:function(){var g=[t.SIDE_BIN,this.leftEncode(),t.MIDDLE_BIN,this.rightEncode(),t.SIDE_BIN];return{data:g.join(""),text:this.text}}}]),u})(i.default);return io.default=d,io}var bd;function F0(){if(bd)return oo;bd=1,Object.defineProperty(oo,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})(),t=function p(u,f,g){u===null&&(u=Function.prototype);var m=Object.getOwnPropertyDescriptor(u,f);if(m===void 0){var y=Object.getPrototypeOf(u);return y===null?void 0:p(y,f,g)}else{if("value"in m)return m.value;var v=m.get;return v===void 0?void 0:v.call(g)}},n=Xn(),r=md(),o=i(r);function i(p){return p&&p.__esModule?p:{default:p}}function a(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function l(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function c(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var s=function(u){var f=u.substr(0,12).split("").map(function(g){return+g}).reduce(function(g,m,y){return y%2?g+m*3:g+m},0);return(10-f%10)%10},d=(function(p){c(u,p);function u(f,g){a(this,u),f.search(/^[0-9]{12}$/)!==-1&&(f+=s(f));var m=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g));return m.lastChar=g.lastChar,m}return e(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===s(this.data)}},{key:"leftText",value:function(){return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var g=this.data.substr(1,6),m=n.EAN13_STRUCTURE[this.data[0]];return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftEncode",this).call(this,g,m)}},{key:"rightText",value:function(){return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var g=this.data.substr(7,6);return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightEncode",this).call(this,g,"RRRRRR")}},{key:"encodeGuarded",value:function(){var g=t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(g.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(g.push({data:"00"}),g.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),g}}]),u})(o.default);return oo.default=d,oo}var so={},yd;function z0(){if(yd)return so;yd=1,Object.defineProperty(so,"__esModule",{value:!0});var e=(function(){function d(p,u){for(var f=0;f<u.length;f++){var g=u[f];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(p,g.key,g)}}return function(p,u,f){return u&&d(p.prototype,u),f&&d(p,f),p}})(),t=function d(p,u,f){p===null&&(p=Function.prototype);var g=Object.getOwnPropertyDescriptor(p,u);if(g===void 0){var m=Object.getPrototypeOf(p);return m===null?void 0:d(m,u,f)}else{if("value"in g)return g.value;var y=g.get;return y===void 0?void 0:y.call(f)}},n=md(),r=o(n);function o(d){return d&&d.__esModule?d:{default:d}}function i(d,p){if(!(d instanceof p))throw new TypeError("Cannot call a class as a function")}function a(d,p){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p&&(typeof p=="object"||typeof p=="function")?p:d}function l(d,p){if(typeof p!="function"&&p!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof p);d.prototype=Object.create(p&&p.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),p&&(Object.setPrototypeOf?Object.setPrototypeOf(d,p):d.__proto__=p)}var c=function(p){var u=p.substr(0,7).split("").map(function(f){return+f}).reduce(function(f,g,m){return m%2?f+g:f+g*3},0);return(10-u%10)%10},s=(function(d){l(p,d);function p(u,f){return i(this,p),u.search(/^[0-9]{7}$/)!==-1&&(u+=c(u)),a(this,(p.__proto__||Object.getPrototypeOf(p)).call(this,u,f))}return e(p,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===c(this.data)}},{key:"leftText",value:function(){return t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"leftText",this).call(this,0,4)}},{key:"leftEncode",value:function(){var f=this.data.substr(0,4);return t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"leftEncode",this).call(this,f,"LLLL")}},{key:"rightText",value:function(){return t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"rightText",this).call(this,4,4)}},{key:"rightEncode",value:function(){var f=this.data.substr(4,4);return t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"rightEncode",this).call(this,f,"RRRR")}}]),p})(r.default);return so.default=s,so}var lo={},vd;function B0(){if(vd)return lo;vd=1,Object.defineProperty(lo,"__esModule",{value:!0});var e=(function(){function u(f,g){for(var m=0;m<g.length;m++){var y=g[m];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(f,y.key,y)}}return function(f,g,m){return g&&u(f.prototype,g),m&&u(f,m),f}})(),t=Xn(),n=Zn(),r=a(n),o=qe(),i=a(o);function a(u){return u&&u.__esModule?u:{default:u}}function l(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function c(u,f){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f&&(typeof f=="object"||typeof f=="function")?f:u}function s(u,f){if(typeof f!="function"&&f!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof f);u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),f&&(Object.setPrototypeOf?Object.setPrototypeOf(u,f):u.__proto__=f)}var d=function(f){var g=f.split("").map(function(m){return+m}).reduce(function(m,y,v){return v%2?m+y*9:m+y*3},0);return g%10},p=(function(u){s(f,u);function f(g,m){return l(this,f),c(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,g,m))}return e(f,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var m=t.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,r.default)(this.data,m,"01"),text:this.text}}}]),f})(i.default);return lo.default=p,lo}var co={},wd;function H0(){if(wd)return co;wd=1,Object.defineProperty(co,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})(),t=Xn(),n=Zn(),r=a(n),o=qe(),i=a(o);function a(p){return p&&p.__esModule?p:{default:p}}function l(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function c(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function s(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var d=(function(p){s(u,p);function u(f,g){return l(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g))}return e(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var g=t.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,r.default)(this.data,g,"01"),text:this.text}}}]),u})(i.default);return co.default=d,co}var Jn={},xd;function Ed(){if(xd)return Jn;xd=1,Object.defineProperty(Jn,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})();Jn.checksum=d;var t=Zn(),n=i(t),r=qe(),o=i(r);function i(p){return p&&p.__esModule?p:{default:p}}function a(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function l(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function c(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var s=(function(p){c(u,p);function u(f,g){a(this,u),f.search(/^[0-9]{11}$/)!==-1&&(f+=d(f));var m=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g));return m.displayValue=g.displayValue,g.fontSize>g.width*10?m.fontSize=g.width*10:m.fontSize=g.fontSize,m.guardHeight=g.height+m.fontSize/2+g.textMargin,m}return e(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==d(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var g="";return g+="101",g+=(0,n.default)(this.data.substr(0,6),"LLLLLL"),g+="01010",g+=(0,n.default)(this.data.substr(6,6),"RRRRRR"),g+="101",{data:g,text:this.text}}},{key:"guardedEncoding",value:function(){var g=[];return this.displayValue&&g.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),g.push({data:"101"+(0,n.default)(this.data[0],"L"),options:{height:this.guardHeight}}),g.push({data:(0,n.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),g.push({data:"01010",options:{height:this.guardHeight}}),g.push({data:(0,n.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),g.push({data:(0,n.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&g.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),g}}]),u})(o.default);function d(p){var u=0,f;for(f=1;f<11;f+=2)u+=parseInt(p[f]);for(f=0;f<11;f+=2)u+=parseInt(p[f])*3;return(10-u%10)%10}return Jn.default=s,Jn}var uo={},Sd;function U0(){if(Sd)return uo;Sd=1,Object.defineProperty(uo,"__esModule",{value:!0});var e=(function(){function g(m,y){for(var v=0;v<y.length;v++){var w=y[v];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(m,w.key,w)}}return function(m,y,v){return y&&g(m.prototype,y),v&&g(m,v),m}})(),t=Zn(),n=a(t),r=qe(),o=a(r),i=Ed();function a(g){return g&&g.__esModule?g:{default:g}}function l(g,m){if(!(g instanceof m))throw new TypeError("Cannot call a class as a function")}function c(g,m){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:g}function s(g,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);g.prototype=Object.create(m&&m.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(g,m):g.__proto__=m)}var d=["XX00000XXX","XX10000XXX","XX20000XXX","XXX00000XX","XXXX00000X","XXXXX00005","XXXXX00006","XXXXX00007","XXXXX00008","XXXXX00009"],p=[["EEEOOO","OOOEEE"],["EEOEOO","OOEOEE"],["EEOOEO","OOEEOE"],["EEOOOE","OOEEEO"],["EOEEOO","OEOOEE"],["EOOEEO","OEEOOE"],["EOOOEE","OEEEOO"],["EOEOEO","OEOEOE"],["EOEOOE","OEOEEO"],["EOOEOE","OEEOEO"]],u=(function(g){s(m,g);function m(y,v){l(this,m);var w=c(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,y,v));if(w.isValid=!1,y.search(/^[0-9]{6}$/)!==-1)w.middleDigits=y,w.upcA=f(y,"0"),w.text=v.text||""+w.upcA[0]+y+w.upcA[w.upcA.length-1],w.isValid=!0;else if(y.search(/^[01][0-9]{7}$/)!==-1)if(w.middleDigits=y.substring(1,y.length-1),w.upcA=f(w.middleDigits,y[0]),w.upcA[w.upcA.length-1]===y[y.length-1])w.isValid=!0;else return c(w);else return c(w);return w.displayValue=v.displayValue,v.fontSize>v.width*10?w.fontSize=v.width*10:w.fontSize=v.fontSize,w.guardHeight=v.height+w.fontSize/2+v.textMargin,w}return e(m,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var v="";return v+="101",v+=this.encodeMiddleDigits(),v+="010101",{data:v,text:this.text}}},{key:"guardedEncoding",value:function(){var v=[];return this.displayValue&&v.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),v.push({data:"101",options:{height:this.guardHeight}}),v.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),v.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&v.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),v}},{key:"encodeMiddleDigits",value:function(){var v=this.upcA[0],w=this.upcA[this.upcA.length-1],_=p[parseInt(w)][parseInt(v)];return(0,n.default)(this.middleDigits,_)}}]),m})(o.default);function f(g,m){for(var y=parseInt(g[g.length-1]),v=d[y],w="",_=0,M=0;M<v.length;M++){var N=v[M];N==="X"?w+=g[_++]:w+=N}return w=""+m+w,""+w+(0,i.checksum)(w)}return uo.default=u,uo}var _d;function q0(){if(_d)return Pe;_d=1,Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.UPCE=Pe.UPC=Pe.EAN2=Pe.EAN5=Pe.EAN8=Pe.EAN13=void 0;var e=F0(),t=u(e),n=z0(),r=u(n),o=B0(),i=u(o),a=H0(),l=u(a),c=Ed(),s=u(c),d=U0(),p=u(d);function u(f){return f&&f.__esModule?f:{default:f}}return Pe.EAN13=t.default,Pe.EAN8=r.default,Pe.EAN5=i.default,Pe.EAN2=l.default,Pe.UPC=s.default,Pe.UPCE=p.default,Pe}var Ht={},po={},pn={},Md;function W0(){return Md||(Md=1,Object.defineProperty(pn,"__esModule",{value:!0}),pn.START_BIN="1010",pn.END_BIN="11101",pn.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),pn}var Td;function kd(){if(Td)return po;Td=1,Object.defineProperty(po,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=W0(),n=qe(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return e(d,[{key:"valid",value:function(){return this.data.search(/^([0-9]{2})+$/)!==-1}},{key:"encode",value:function(){var u=this,f=this.data.match(/.{2}/g).map(function(g){return u.encodePair(g)}).join("");return{data:t.START_BIN+f+t.END_BIN,text:this.text}}},{key:"encodePair",value:function(u){var f=t.BINARIES[u[1]];return t.BINARIES[u[0]].split("").map(function(g,m){return(g==="1"?"111":"1")+(f[m]==="1"?"000":"0")}).join("")}}]),d})(r.default);return po.default=c,po}var fo={},Cd;function j0(){if(Cd)return fo;Cd=1,Object.defineProperty(fo,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=kd(),n=r(t);function r(s){return s&&s.__esModule?s:{default:s}}function o(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function i(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function a(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var l=function(d){var p=d.substr(0,13).split("").map(function(u){return parseInt(u,10)}).reduce(function(u,f,g){return u+f*(3-g%2*2)},0);return Math.ceil(p/10)*10-p},c=(function(s){a(d,s);function d(p,u){return o(this,d),p.search(/^[0-9]{13}$/)!==-1&&(p+=l(p)),i(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return e(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===l(this.data)}}]),d})(n.default);return fo.default=c,fo}var Ad;function G0(){if(Ad)return Ht;Ad=1,Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.ITF14=Ht.ITF=void 0;var e=kd(),t=o(e),n=j0(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return Ht.ITF=t.default,Ht.ITF14=r.default,Ht}var We={},ho={},Od;function Qn(){if(Od)return ho;Od=1,Object.defineProperty(ho,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=qe(),n=r(t);function r(s){return s&&s.__esModule?s:{default:s}}function o(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function i(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function a(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var l=(function(s){a(d,s);function d(p,u){return o(this,d),i(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return e(d,[{key:"encode",value:function(){for(var u="110",f=0;f<this.data.length;f++){var g=parseInt(this.data[f]),m=g.toString(2);m=c(m,4-m.length);for(var y=0;y<m.length;y++)u+=m[y]=="0"?"100":"110"}return u+="1001",{data:u,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),d})(n.default);function c(s,d){for(var p=0;p<d;p++)s="0"+s;return s}return ho.default=l,ho}var go={},er={},Id;function mo(){if(Id)return er;Id=1,Object.defineProperty(er,"__esModule",{value:!0}),er.mod10=e,er.mod11=t;function e(n){for(var r=0,o=0;o<n.length;o++){var i=parseInt(n[o]);(o+n.length)%2===0?r+=i:r+=i*2%10+Math.floor(i*2/10)}return(10-r%10)%10}function t(n){for(var r=0,o=[2,3,4,5,6,7],i=0;i<n.length;i++){var a=parseInt(n[n.length-1-i]);r+=o[i%o.length]*a}return(11-r%11)%11}return er}var Pd;function Y0(){if(Pd)return go;Pd=1,Object.defineProperty(go,"__esModule",{value:!0});var e=Qn(),t=r(e),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d+(0,n.mod10)(d),p))}return s})(t.default);return go.default=l,go}var bo={},Dd;function V0(){if(Dd)return bo;Dd=1,Object.defineProperty(bo,"__esModule",{value:!0});var e=Qn(),t=r(e),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d+(0,n.mod11)(d),p))}return s})(t.default);return bo.default=l,bo}var yo={},Rd;function K0(){if(Rd)return yo;Rd=1,Object.defineProperty(yo,"__esModule",{value:!0});var e=Qn(),t=r(e),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),d+=(0,n.mod10)(d),d+=(0,n.mod10)(d),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return s})(t.default);return yo.default=l,yo}var vo={},$d;function X0(){if($d)return vo;$d=1,Object.defineProperty(vo,"__esModule",{value:!0});var e=Qn(),t=r(e),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),d+=(0,n.mod11)(d),d+=(0,n.mod10)(d),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return s})(t.default);return vo.default=l,vo}var Ld;function Z0(){if(Ld)return We;Ld=1,Object.defineProperty(We,"__esModule",{value:!0}),We.MSI1110=We.MSI1010=We.MSI11=We.MSI10=We.MSI=void 0;var e=Qn(),t=d(e),n=Y0(),r=d(n),o=V0(),i=d(o),a=K0(),l=d(a),c=X0(),s=d(c);function d(p){return p&&p.__esModule?p:{default:p}}return We.MSI=t.default,We.MSI10=r.default,We.MSI11=i.default,We.MSI1010=l.default,We.MSI1110=s.default,We}var tr={},Nd;function J0(){if(Nd)return tr;Nd=1,Object.defineProperty(tr,"__esModule",{value:!0}),tr.pharmacode=void 0;var e=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),t=qe(),n=r(t);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){o(this,s);var u=i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p));return u.number=parseInt(d,10),u}return e(s,[{key:"encode",value:function(){for(var p=this.number,u="";!isNaN(p)&&p!=0;)p%2===0?(u="11100"+u,p=(p-2)/2):(u="100"+u,p=(p-1)/2);return u=u.slice(0,-2),{data:u,text:this.text}}},{key:"valid",value:function(){return this.number>=3&&this.number<=131070}}]),s})(n.default);return tr.pharmacode=l,tr}var nr={},Fd;function Q0(){if(Fd)return nr;Fd=1,Object.defineProperty(nr,"__esModule",{value:!0}),nr.codabar=void 0;var e=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),t=qe(),n=r(t);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){o(this,s),d.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(d="A"+d+"A");var u=i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d.toUpperCase(),p));return u.text=u.options.text||u.text.replace(/[A-D]/g,""),u}return e(s,[{key:"valid",value:function(){return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)!==-1}},{key:"encode",value:function(){for(var p=[],u=this.getEncodings(),f=0;f<this.data.length;f++)p.push(u[this.data.charAt(f)]),f!==this.data.length-1&&p.push("0");return{text:this.text,data:p.join("")}}},{key:"getEncodings",value:function(){return{0:"101010011",1:"101011001",2:"101001011",3:"110010101",4:"101101001",5:"110101001",6:"100101011",7:"100101101",8:"100110101",9:"110100101","-":"101001101",$:"101100101",":":"1101011011","/":"1101101011",".":"1101101101","+":"1011011011",A:"1011001001",B:"1001001011",C:"1010010011",D:"1010011001"}}}]),s})(n.default);return nr.codabar=l,nr}var Ut={},wo={},fn={},zd;function eb(){return zd||(zd=1,Object.defineProperty(fn,"__esModule",{value:!0}),fn.SYMBOLS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],fn.BINARIES=["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010","101011110"],fn.MULTI_SYMBOLS={"\0":["(%)","U"],"":["($)","A"],"":["($)","B"],"":["($)","C"],"":["($)","D"],"":["($)","E"],"":["($)","F"],"\x07":["($)","G"],"\b":["($)","H"]," ":["($)","I"],"\n":["($)","J"],"\v":["($)","K"],"\f":["($)","L"],"\r":["($)","M"],"":["($)","N"],"":["($)","O"],"":["($)","P"],"":["($)","Q"],"":["($)","R"],"":["($)","S"],"":["($)","T"],"":["($)","U"],"":["($)","V"],"":["($)","W"],"":["($)","X"],"":["($)","Y"],"":["($)","Z"],"\x1B":["(%)","A"],"":["(%)","B"],"":["(%)","C"],"":["(%)","D"],"":["(%)","E"],"!":["(/)","A"],'"':["(/)","B"],"#":["(/)","C"],"&":["(/)","F"],"'":["(/)","G"],"(":["(/)","H"],")":["(/)","I"],"*":["(/)","J"],",":["(/)","L"],":":["(/)","Z"],";":["(%)","F"],"<":["(%)","G"],"=":["(%)","H"],">":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),fn}var Bd;function Hd(){if(Bd)return wo;Bd=1,Object.defineProperty(wo,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=eb(),n=qe(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return e(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var u=this.data.split("").flatMap(function(y){return t.MULTI_SYMBOLS[y]||y}),f=u.map(function(y){return d.getEncoding(y)}).join(""),g=d.checksum(u,20),m=d.checksum(u.concat(g),15);return{text:this.text,data:d.getEncoding("ÿ")+f+d.getEncoding(g)+d.getEncoding(m)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(u){return t.BINARIES[d.symbolValue(u)]}},{key:"getSymbol",value:function(u){return t.SYMBOLS[u]}},{key:"symbolValue",value:function(u){return t.SYMBOLS.indexOf(u)}},{key:"checksum",value:function(u,f){var g=u.slice().reverse().reduce(function(m,y,v){var w=v%f+1;return m+d.symbolValue(y)*w},0);return d.getSymbol(g%47)}}]),d})(r.default);return wo.default=c,wo}var xo={},Ud;function tb(){if(Ud)return xo;Ud=1,Object.defineProperty(xo,"__esModule",{value:!0});var e=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),t=Hd(),n=r(t);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return e(s,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),s})(n.default);return xo.default=l,xo}var qd;function nb(){if(qd)return Ut;qd=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.CODE93FullASCII=Ut.CODE93=void 0;var e=Hd(),t=o(e),n=tb(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return Ut.CODE93=t.default,Ut.CODE93FullASCII=r.default,Ut}var rr={},Wd;function rb(){if(Wd)return rr;Wd=1,Object.defineProperty(rr,"__esModule",{value:!0}),rr.GenericBarcode=void 0;var e=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),t=qe(),n=r(t);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return e(s,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),s})(n.default);return rr.GenericBarcode=l,rr}var jd;function ob(){if(jd)return Kr;jd=1,Object.defineProperty(Kr,"__esModule",{value:!0});var e=I0(),t=N0(),n=q0(),r=G0(),o=Z0(),i=J0(),a=Q0(),l=nb(),c=rb();return Kr.default={CODE39:e.CODE39,CODE128:t.CODE128,CODE128A:t.CODE128A,CODE128B:t.CODE128B,CODE128C:t.CODE128C,EAN13:n.EAN13,EAN8:n.EAN8,EAN5:n.EAN5,EAN2:n.EAN2,UPC:n.UPC,UPCE:n.UPCE,ITF14:r.ITF14,ITF:r.ITF,MSI:o.MSI,MSI10:o.MSI10,MSI11:o.MSI11,MSI1010:o.MSI1010,MSI1110:o.MSI1110,pharmacode:i.pharmacode,codabar:a.codabar,CODE93:l.CODE93,CODE93FullASCII:l.CODE93FullASCII,GenericBarcode:c.GenericBarcode},Kr}var Eo={},Gd;function So(){if(Gd)return Eo;Gd=1,Object.defineProperty(Eo,"__esModule",{value:!0});var e=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t};return Eo.default=function(t,n){return e({},t,n)},Eo}var _o={},Yd;function ib(){if(Yd)return _o;Yd=1,Object.defineProperty(_o,"__esModule",{value:!0}),_o.default=e;function e(t){var n=[];function r(o){if(Array.isArray(o))for(var i=0;i<o.length;i++)r(o[i]);else o.text=o.text||"",o.data=o.data||"",n.push(o)}return r(t),n}return _o}var Mo={},Vd;function ab(){if(Vd)return Mo;Vd=1,Object.defineProperty(Mo,"__esModule",{value:!0}),Mo.default=e;function e(t){return t.marginTop=t.marginTop||t.margin,t.marginBottom=t.marginBottom||t.margin,t.marginRight=t.marginRight||t.margin,t.marginLeft=t.marginLeft||t.margin,t}return Mo}var To={},ko={},Co={},Kd;function Xd(){if(Kd)return Co;Kd=1,Object.defineProperty(Co,"__esModule",{value:!0}),Co.default=e;function e(t){var n=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var r in n)n.hasOwnProperty(r)&&(r=n[r],typeof t[r]=="string"&&(t[r]=parseInt(t[r],10)));return typeof t.displayValue=="string"&&(t.displayValue=t.displayValue!="false"),t}return Co}var Ao={},Zd;function Jd(){if(Zd)return Ao;Zd=1,Object.defineProperty(Ao,"__esModule",{value:!0});var e={width:2,height:100,format:"auto",displayValue:!0,fontOptions:"",font:"monospace",text:void 0,textAlign:"center",textPosition:"bottom",textMargin:2,fontSize:20,background:"#ffffff",lineColor:"#000000",margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}};return Ao.default=e,Ao}var Qd;function sb(){if(Qd)return ko;Qd=1,Object.defineProperty(ko,"__esModule",{value:!0});var e=Xd(),t=o(e),n=Jd(),r=o(n);function o(a){return a&&a.__esModule?a:{default:a}}function i(a){var l={};for(var c in r.default)r.default.hasOwnProperty(c)&&(a.hasAttribute("jsbarcode-"+c.toLowerCase())&&(l[c]=a.getAttribute("jsbarcode-"+c.toLowerCase())),a.hasAttribute("data-"+c.toLowerCase())&&(l[c]=a.getAttribute("data-"+c.toLowerCase())));return l.value=a.getAttribute("jsbarcode-value")||a.getAttribute("data-value"),l=(0,t.default)(l),l}return ko.default=i,ko}var Oo={},Io={},je={},eu;function tu(){if(eu)return je;eu=1,Object.defineProperty(je,"__esModule",{value:!0}),je.getTotalWidthOfEncodings=je.calculateEncodingAttributes=je.getBarcodePadding=je.getEncodingHeight=je.getMaximumHeightOfEncodings=void 0;var e=So(),t=n(e);function n(s){return s&&s.__esModule?s:{default:s}}function r(s,d){return d.height+(d.displayValue&&s.text.length>0?d.fontSize+d.textMargin:0)+d.marginTop+d.marginBottom}function o(s,d,p){if(p.displayValue&&d<s){if(p.textAlign=="center")return Math.floor((s-d)/2);if(p.textAlign=="left")return 0;if(p.textAlign=="right")return Math.floor(s-d)}return 0}function i(s,d,p){for(var u=0;u<s.length;u++){var f=s[u],g=(0,t.default)(d,f.options),m;g.displayValue?m=c(f.text,g,p):m=0;var y=f.data.length*g.width;f.width=Math.ceil(Math.max(m,y)),f.height=r(f,g),f.barcodePadding=o(m,y,g)}}function a(s){for(var d=0,p=0;p<s.length;p++)d+=s[p].width;return d}function l(s){for(var d=0,p=0;p<s.length;p++)s[p].height>d&&(d=s[p].height);return d}function c(s,d,p){var u;if(p)u=p;else if(typeof document<"u")u=document.createElement("canvas").getContext("2d");else return 0;u.font=d.fontOptions+" "+d.fontSize+"px "+d.font;var f=u.measureText(s);if(!f)return 0;var g=f.width;return g}return je.getMaximumHeightOfEncodings=l,je.getEncodingHeight=r,je.getBarcodePadding=o,je.calculateEncodingAttributes=i,je.getTotalWidthOfEncodings=a,je}var nu;function lb(){if(nu)return Io;nu=1,Object.defineProperty(Io,"__esModule",{value:!0});var e=(function(){function l(c,s){for(var d=0;d<s.length;d++){var p=s[d];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(c,p.key,p)}}return function(c,s,d){return s&&l(c.prototype,s),d&&l(c,d),c}})(),t=So(),n=o(t),r=tu();function o(l){return l&&l.__esModule?l:{default:l}}function i(l,c){if(!(l instanceof c))throw new TypeError("Cannot call a class as a function")}var a=(function(){function l(c,s,d){i(this,l),this.canvas=c,this.encodings=s,this.options=d}return e(l,[{key:"render",value:function(){if(!this.canvas.getContext)throw new Error("The browser does not support canvas.");this.prepareCanvas();for(var s=0;s<this.encodings.length;s++){var d=(0,n.default)(this.options,this.encodings[s].options);this.drawCanvasBarcode(d,this.encodings[s]),this.drawCanvasText(d,this.encodings[s]),this.moveCanvasDrawing(this.encodings[s])}this.restoreCanvas()}},{key:"prepareCanvas",value:function(){var s=this.canvas.getContext("2d");s.save(),(0,r.calculateEncodingAttributes)(this.encodings,this.options,s);var d=(0,r.getTotalWidthOfEncodings)(this.encodings),p=(0,r.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=d+this.options.marginLeft+this.options.marginRight,this.canvas.height=p,s.clearRect(0,0,this.canvas.width,this.canvas.height),this.options.background&&(s.fillStyle=this.options.background,s.fillRect(0,0,this.canvas.width,this.canvas.height)),s.translate(this.options.marginLeft,0)}},{key:"drawCanvasBarcode",value:function(s,d){var p=this.canvas.getContext("2d"),u=d.data,f;s.textPosition=="top"?f=s.marginTop+s.fontSize+s.textMargin:f=s.marginTop,p.fillStyle=s.lineColor;for(var g=0;g<u.length;g++){var m=g*s.width+d.barcodePadding;u[g]==="1"?p.fillRect(m,f,s.width,s.height):u[g]&&p.fillRect(m,f,s.width,s.height*u[g])}}},{key:"drawCanvasText",value:function(s,d){var p=this.canvas.getContext("2d"),u=s.fontOptions+" "+s.fontSize+"px "+s.font;if(s.displayValue){var f,g;s.textPosition=="top"?g=s.marginTop+s.fontSize-s.textMargin:g=s.height+s.textMargin+s.marginTop+s.fontSize,p.font=u,s.textAlign=="left"||d.barcodePadding>0?(f=0,p.textAlign="left"):s.textAlign=="right"?(f=d.width-1,p.textAlign="right"):(f=d.width/2,p.textAlign="center"),p.fillText(d.text,f,g)}}},{key:"moveCanvasDrawing",value:function(s){var d=this.canvas.getContext("2d");d.translate(s.width,0)}},{key:"restoreCanvas",value:function(){var s=this.canvas.getContext("2d");s.restore()}}]),l})();return Io.default=a,Io}var Po={},ru;function cb(){if(ru)return Po;ru=1,Object.defineProperty(Po,"__esModule",{value:!0});var e=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),t=So(),n=o(t),r=tu();function o(c){return c&&c.__esModule?c:{default:c}}function i(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}var a="http://www.w3.org/2000/svg",l=(function(){function c(s,d,p){i(this,c),this.svg=s,this.encodings=d,this.options=p,this.document=p.xmlDocument||document}return e(c,[{key:"render",value:function(){var d=this.options.marginLeft;this.prepareSVG();for(var p=0;p<this.encodings.length;p++){var u=this.encodings[p],f=(0,n.default)(this.options,u.options),g=this.createGroup(d,f.marginTop,this.svg);this.setGroupOptions(g,f),this.drawSvgBarcode(g,f,u),this.drawSVGText(g,f,u),d+=u.width}}},{key:"prepareSVG",value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,r.calculateEncodingAttributes)(this.encodings,this.options);var d=(0,r.getTotalWidthOfEncodings)(this.encodings),p=(0,r.getMaximumHeightOfEncodings)(this.encodings),u=d+this.options.marginLeft+this.options.marginRight;this.setSvgAttributes(u,p),this.options.background&&this.drawRect(0,0,u,p,this.svg).setAttribute("fill",this.options.background)}},{key:"drawSvgBarcode",value:function(d,p,u){var f=u.data,g;p.textPosition=="top"?g=p.fontSize+p.textMargin:g=0;for(var m=0,y=0,v=0;v<f.length;v++)y=v*p.width+u.barcodePadding,f[v]==="1"?m++:m>0&&(this.drawRect(y-p.width*m,g,p.width*m,p.height,d),m=0);m>0&&this.drawRect(y-p.width*(m-1),g,p.width*m,p.height,d)}},{key:"drawSVGText",value:function(d,p,u){var f=this.document.createElementNS(a,"text");if(p.displayValue){var g,m;f.setAttribute("font-family",p.font),f.setAttribute("font-size",p.fontSize),p.fontOptions.includes("bold")&&f.setAttribute("font-weight","bold"),p.fontOptions.includes("italic")&&f.setAttribute("font-style","italic"),p.textPosition=="top"?m=p.fontSize-p.textMargin:m=p.height+p.textMargin+p.fontSize,p.textAlign=="left"||u.barcodePadding>0?(g=0,f.setAttribute("text-anchor","start")):p.textAlign=="right"?(g=u.width-1,f.setAttribute("text-anchor","end")):(g=u.width/2,f.setAttribute("text-anchor","middle")),f.setAttribute("x",g),f.setAttribute("y",m),f.appendChild(this.document.createTextNode(u.text)),d.appendChild(f)}}},{key:"setSvgAttributes",value:function(d,p){var u=this.svg;u.setAttribute("width",d+"px"),u.setAttribute("height",p+"px"),u.setAttribute("x","0px"),u.setAttribute("y","0px"),u.setAttribute("viewBox","0 0 "+d+" "+p),u.setAttribute("xmlns",a),u.setAttribute("version","1.1")}},{key:"createGroup",value:function(d,p,u){var f=this.document.createElementNS(a,"g");return f.setAttribute("transform","translate("+d+", "+p+")"),u.appendChild(f),f}},{key:"setGroupOptions",value:function(d,p){d.setAttribute("fill",p.lineColor)}},{key:"drawRect",value:function(d,p,u,f,g){var m=this.document.createElementNS(a,"rect");return m.setAttribute("x",d),m.setAttribute("y",p),m.setAttribute("width",u),m.setAttribute("height",f),g.appendChild(m),m}}]),c})();return Po.default=l,Po}var Do={},ou;function db(){if(ou)return Do;ou=1,Object.defineProperty(Do,"__esModule",{value:!0});var e=(function(){function r(o,i){for(var a=0;a<i.length;a++){var l=i[a];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}return function(o,i,a){return i&&r(o.prototype,i),a&&r(o,a),o}})();function t(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o,i,a){t(this,r),this.object=o,this.encodings=i,this.options=a}return e(r,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),r})();return Do.default=n,Do}var iu;function ub(){if(iu)return Oo;iu=1,Object.defineProperty(Oo,"__esModule",{value:!0});var e=lb(),t=a(e),n=cb(),r=a(n),o=db(),i=a(o);function a(l){return l&&l.__esModule?l:{default:l}}return Oo.default={CanvasRenderer:t.default,SVGRenderer:r.default,ObjectRenderer:i.default},Oo}var hn={},au;function su(){if(au)return hn;au=1,Object.defineProperty(hn,"__esModule",{value:!0});function e(a,l){if(!(a instanceof l))throw new TypeError("Cannot call a class as a function")}function t(a,l){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return l&&(typeof l=="object"||typeof l=="function")?l:a}function n(a,l){if(typeof l!="function"&&l!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof l);a.prototype=Object.create(l&&l.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),l&&(Object.setPrototypeOf?Object.setPrototypeOf(a,l):a.__proto__=l)}var r=(function(a){n(l,a);function l(c,s){e(this,l);var d=t(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return d.name="InvalidInputException",d.symbology=c,d.input=s,d.message='"'+d.input+'" is not a valid input for '+d.symbology,d}return l})(Error),o=(function(a){n(l,a);function l(){e(this,l);var c=t(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return c.name="InvalidElementException",c.message="Not supported type to render on",c}return l})(Error),i=(function(a){n(l,a);function l(){e(this,l);var c=t(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return c.name="NoElementException",c.message="No element to render on.",c}return l})(Error);return hn.InvalidInputException=r,hn.InvalidElementException=o,hn.NoElementException=i,hn}var lu;function pb(){if(lu)return To;lu=1,Object.defineProperty(To,"__esModule",{value:!0});var e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},t=sb(),n=a(t),r=ub(),o=a(r),i=su();function a(d){return d&&d.__esModule?d:{default:d}}function l(d){if(typeof d=="string")return c(d);if(Array.isArray(d)){for(var p=[],u=0;u<d.length;u++)p.push(l(d[u]));return p}else{if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLImageElement)return s(d);if(d&&d.nodeName&&d.nodeName.toLowerCase()==="svg"||typeof SVGElement<"u"&&d instanceof SVGElement)return{element:d,options:(0,n.default)(d),renderer:o.default.SVGRenderer};if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement)return{element:d,options:(0,n.default)(d),renderer:o.default.CanvasRenderer};if(d&&d.getContext)return{element:d,renderer:o.default.CanvasRenderer};if(d&&(typeof d>"u"?"undefined":e(d))==="object"&&!d.nodeName)return{element:d,renderer:o.default.ObjectRenderer};throw new i.InvalidElementException}}function c(d){var p=document.querySelectorAll(d);if(p.length!==0){for(var u=[],f=0;f<p.length;f++)u.push(l(p[f]));return u}}function s(d){var p=document.createElement("canvas");return{element:p,options:(0,n.default)(d),renderer:o.default.CanvasRenderer,afterRender:function(){d.setAttribute("src",p.toDataURL())}}}return To.default=l,To}var Ro={},cu;function fb(){if(cu)return Ro;cu=1,Object.defineProperty(Ro,"__esModule",{value:!0});var e=(function(){function r(o,i){for(var a=0;a<i.length;a++){var l=i[a];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}return function(o,i,a){return i&&r(o.prototype,i),a&&r(o,a),o}})();function t(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o){t(this,r),this.api=o}return e(r,[{key:"handleCatch",value:function(i){if(i.name==="InvalidInputException")if(this.api._options.valid!==this.api._defaults.valid)this.api._options.valid(!1);else throw i.message;else throw i;this.api.render=function(){}}},{key:"wrapBarcodeCall",value:function(i){try{var a=i.apply(void 0,arguments);return this.api._options.valid(!0),a}catch(l){return this.handleCatch(l),this.api}}}]),r})();return Ro.default=n,Ro}var ga,du;function hb(){if(du)return ga;du=1;var e=ob(),t=v(e),n=So(),r=v(n),o=ib(),i=v(o),a=ab(),l=v(a),c=pb(),s=v(c),d=Xd(),p=v(d),u=fb(),f=v(u),g=su(),m=Jd(),y=v(m);function v(S){return S&&S.__esModule?S:{default:S}}var w=function(){},_=function(C,O,D){var I=new w;if(typeof C>"u")throw Error("No element to render on was provided.");return I._renderProperties=(0,s.default)(C),I._encodings=[],I._options=y.default,I._errorHandler=new f.default(I),typeof O<"u"&&(D=D||{},D.format||(D.format=P()),I.options(D)[D.format](O,D).render()),I};_.getModule=function(S){return t.default[S]};for(var M in t.default)t.default.hasOwnProperty(M)&&N(t.default,M);function N(S,C){w.prototype[C]=w.prototype[C.toUpperCase()]=w.prototype[C.toLowerCase()]=function(O,D){var I=this;return I._errorHandler.wrapBarcodeCall(function(){D.text=typeof D.text>"u"?void 0:""+D.text;var x=(0,r.default)(I._options,D);x=(0,p.default)(x);var j=S[C],te=L(O,j,x);return I._encodings.push(te),I})}}function L(S,C,O){S=""+S;var D=new C(S,O);if(!D.valid())throw new g.InvalidInputException(D.constructor.name,S);var I=D.encode();I=(0,i.default)(I);for(var x=0;x<I.length;x++)I[x].options=(0,r.default)(O,I[x].options);return I}function P(){return t.default.CODE128?"CODE128":Object.keys(t.default)[0]}w.prototype.options=function(S){return this._options=(0,r.default)(this._options,S),this},w.prototype.blank=function(S){var C=new Array(S+1).join("0");return this._encodings.push({data:C}),this},w.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var S;for(var C in this._renderProperties){S=this._renderProperties[C];var O=(0,r.default)(this._options,S.options);O.format=="auto"&&(O.format=P()),this._errorHandler.wrapBarcodeCall(function(){var D=O.value,I=t.default[O.format.toUpperCase()],x=L(D,I,O);k(S,x,O)})}}},w.prototype.render=function(){if(!this._renderProperties)throw new g.NoElementException;if(Array.isArray(this._renderProperties))for(var S=0;S<this._renderProperties.length;S++)k(this._renderProperties[S],this._encodings,this._options);else k(this._renderProperties,this._encodings,this._options);return this},w.prototype._defaults=y.default;function k(S,C,O){C=(0,i.default)(C);for(var D=0;D<C.length;D++)C[D].options=(0,r.default)(O,C[D].options),(0,l.default)(C[D].options);(0,l.default)(O);var I=S.renderer,x=new I(S.element,C,O);x.render(),S.afterRender&&S.afterRender()}return typeof window<"u"&&(window.JsBarcode=_),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(S,C){var O=[];return jQuery(this).each(function(){O.push(this)}),_(O,S,C)}),ga=_,ga}var gb=hb();const ma=nd(gb);var gn={},ba,uu;function mb(){return uu||(uu=1,ba=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ba}var ya={},Tt={},pu;function qt(){if(pu)return Tt;pu=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Tt.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},Tt.getSymbolTotalCodewords=function(r){return t[r]},Tt.getBCHDigit=function(n){let r=0;for(;n!==0;)r++,n>>>=1;return r},Tt.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');e=r},Tt.isKanjiModeEnabled=function(){return typeof e<"u"},Tt.toSJIS=function(r){return e(r)},Tt}var va={},fu;function wa(){return fu||(fu=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,o){if(e.isValid(r))return r;try{return t(r)}catch{return o}}})(va)),va}var xa,hu;function bb(){if(hu)return xa;hu=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let r=0;r<n;r++)this.putBit((t>>>n-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},xa=e,xa}var Ea,gu;function yb(){if(gu)return Ea;gu=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,n,r,o){const i=t*this.size+n;this.data[i]=r,o&&(this.reservedBit[i]=!0)},e.prototype.get=function(t,n){return this.data[t*this.size+n]},e.prototype.xor=function(t,n,r){this.data[t*this.size+n]^=r},e.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]},Ea=e,Ea}var Sa={},mu;function vb(){return mu||(mu=1,(function(e){const t=qt().getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const o=Math.floor(r/7)+2,i=t(r),a=i===145?26:Math.ceil((i-13)/(2*o-2))*2,l=[i-7];for(let c=1;c<o-1;c++)l[c]=l[c-1]-a;return l.push(6),l.reverse()},e.getPositions=function(r){const o=[],i=e.getRowColCoords(r),a=i.length;for(let l=0;l<a;l++)for(let c=0;c<a;c++)l===0&&c===0||l===0&&c===a-1||l===a-1&&c===0||o.push([i[l],i[c]]);return o}})(Sa)),Sa}var _a={},bu;function wb(){if(bu)return _a;bu=1;const e=qt().getSymbolSize,t=7;return _a.getPositions=function(r){const o=e(r);return[[0,0],[o-t,0],[0,o-t]]},_a}var Ma={},yu;function xb(){return yu||(yu=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const i=o.size;let a=0,l=0,c=0,s=null,d=null;for(let p=0;p<i;p++){l=c=0,s=d=null;for(let u=0;u<i;u++){let f=o.get(p,u);f===s?l++:(l>=5&&(a+=t.N1+(l-5)),s=f,l=1),f=o.get(u,p),f===d?c++:(c>=5&&(a+=t.N1+(c-5)),d=f,c=1)}l>=5&&(a+=t.N1+(l-5)),c>=5&&(a+=t.N1+(c-5))}return a},e.getPenaltyN2=function(o){const i=o.size;let a=0;for(let l=0;l<i-1;l++)for(let c=0;c<i-1;c++){const s=o.get(l,c)+o.get(l,c+1)+o.get(l+1,c)+o.get(l+1,c+1);(s===4||s===0)&&a++}return a*t.N2},e.getPenaltyN3=function(o){const i=o.size;let a=0,l=0,c=0;for(let s=0;s<i;s++){l=c=0;for(let d=0;d<i;d++)l=l<<1&2047|o.get(s,d),d>=10&&(l===1488||l===93)&&a++,c=c<<1&2047|o.get(d,s),d>=10&&(c===1488||c===93)&&a++}return a*t.N3},e.getPenaltyN4=function(o){let i=0;const a=o.data.length;for(let c=0;c<a;c++)i+=o.data[c];return Math.abs(Math.ceil(i*100/a/5)-10)*t.N4};function n(r,o,i){switch(r){case e.Patterns.PATTERN000:return(o+i)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return i%3===0;case e.Patterns.PATTERN011:return(o+i)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(i/3))%2===0;case e.Patterns.PATTERN101:return o*i%2+o*i%3===0;case e.Patterns.PATTERN110:return(o*i%2+o*i%3)%2===0;case e.Patterns.PATTERN111:return(o*i%3+(o+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(o,i){const a=i.size;for(let l=0;l<a;l++)for(let c=0;c<a;c++)i.isReserved(c,l)||i.xor(c,l,n(o,c,l))},e.getBestMask=function(o,i){const a=Object.keys(e.Patterns).length;let l=0,c=1/0;for(let s=0;s<a;s++){i(s),e.applyMask(s,o);const d=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(s,o),d<c&&(c=d,l=s)}return l}})(Ma)),Ma}var $o={},vu;function wu(){if(vu)return $o;vu=1;const e=wa(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return $o.getBlocksCount=function(o,i){switch(i){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},$o.getTotalCodewordsCount=function(o,i){switch(i){case e.L:return n[(o-1)*4+0];case e.M:return n[(o-1)*4+1];case e.Q:return n[(o-1)*4+2];case e.H:return n[(o-1)*4+3];default:return}},$o}var Ta={},or={},xu;function Eb(){if(xu)return or;xu=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let r=1;for(let o=0;o<255;o++)e[o]=r,t[r]=o,r<<=1,r&256&&(r^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),or.log=function(r){if(r<1)throw new Error("log("+r+")");return t[r]},or.exp=function(r){return e[r]},or.mul=function(r,o){return r===0||o===0?0:e[t[r]+t[o]]},or}var Eu;function Sb(){return Eu||(Eu=1,(function(e){const t=Eb();e.mul=function(r,o){const i=new Uint8Array(r.length+o.length-1);for(let a=0;a<r.length;a++)for(let l=0;l<o.length;l++)i[a+l]^=t.mul(r[a],o[l]);return i},e.mod=function(r,o){let i=new Uint8Array(r);for(;i.length-o.length>=0;){const a=i[0];for(let c=0;c<o.length;c++)i[c]^=t.mul(o[c],a);let l=0;for(;l<i.length&&i[l]===0;)l++;i=i.slice(l)}return i},e.generateECPolynomial=function(r){let o=new Uint8Array([1]);for(let i=0;i<r;i++)o=e.mul(o,new Uint8Array([1,t.exp(i)]));return o}})(Ta)),Ta}var ka,Su;function _b(){if(Su)return ka;Su=1;const e=Sb();function t(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(r){this.degree=r,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(r.length+this.degree);o.set(r);const i=e.mod(o,this.genPoly),a=this.degree-i.length;if(a>0){const l=new Uint8Array(this.degree);return l.set(i,a),l}return i},ka=t,ka}var Ca={},Aa={},Oa={},_u;function Mu(){return _u||(_u=1,Oa.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Oa}var at={},Tu;function ku(){if(Tu)return at;Tu=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
252
- ]))+`;at.KANJI=new RegExp(n,"g"),at.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),at.BYTE=new RegExp(r,"g"),at.NUMERIC=new RegExp(e,"g"),at.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),i=new RegExp("^"+e+"$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return at.testKanji=function(c){return o.test(c)},at.testNumeric=function(c){return i.test(c)},at.testAlphanumeric=function(c){return a.test(c)},at}var Cu;function Wt(){return Cu||(Cu=1,(function(e){const t=Mu(),n=ku();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(i,a){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!t.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?i.ccBits[0]:a<27?i.ccBits[1]:i.ccBits[2]},e.getBestModeForData=function(i){return n.testNumeric(i)?e.NUMERIC:n.testAlphanumeric(i)?e.ALPHANUMERIC:n.testKanji(i)?e.KANJI:e.BYTE},e.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},e.isValid=function(i){return i&&i.bit&&i.ccBits};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(i,a){if(e.isValid(i))return i;try{return r(i)}catch{return a}}})(Aa)),Aa}var Au;function Mb(){return Au||(Au=1,(function(e){const t=qt(),n=wu(),r=wa(),o=Wt(),i=Mu(),a=7973,l=t.getBCHDigit(a);function c(u,f,g){for(let m=1;m<=40;m++)if(f<=e.getCapacity(m,g,u))return m}function s(u,f){return o.getCharCountIndicator(u,f)+4}function d(u,f){let g=0;return u.forEach(function(m){const y=s(m.mode,f);g+=y+m.getBitsLength()}),g}function p(u,f){for(let g=1;g<=40;g++)if(d(u,g)<=e.getCapacity(g,f,o.MIXED))return g}e.from=function(f,g){return i.isValid(f)?parseInt(f,10):g},e.getCapacity=function(f,g,m){if(!i.isValid(f))throw new Error("Invalid QR Code version");typeof m>"u"&&(m=o.BYTE);const y=t.getSymbolTotalCodewords(f),v=n.getTotalCodewordsCount(f,g),w=(y-v)*8;if(m===o.MIXED)return w;const _=w-s(m,f);switch(m){case o.NUMERIC:return Math.floor(_/10*3);case o.ALPHANUMERIC:return Math.floor(_/11*2);case o.KANJI:return Math.floor(_/13);case o.BYTE:default:return Math.floor(_/8)}},e.getBestVersionForData=function(f,g){let m;const y=r.from(g,r.M);if(Array.isArray(f)){if(f.length>1)return p(f,y);if(f.length===0)return 1;m=f[0]}else m=f;return c(m.mode,m.getLength(),y)},e.getEncodedBits=function(f){if(!i.isValid(f)||f<7)throw new Error("Invalid QR Code version");let g=f<<12;for(;t.getBCHDigit(g)-l>=0;)g^=a<<t.getBCHDigit(g)-l;return f<<12|g}})(Ca)),Ca}var Ia={},Ou;function Tb(){if(Ou)return Ia;Ou=1;const e=qt(),t=1335,n=21522,r=e.getBCHDigit(t);return Ia.getEncodedBits=function(i,a){const l=i.bit<<3|a;let c=l<<10;for(;e.getBCHDigit(c)-r>=0;)c^=t<<e.getBCHDigit(c)-r;return(l<<10|c)^n},Ia}var Pa={},Da,Iu;function kb(){if(Iu)return Da;Iu=1;const e=Wt();function t(n){this.mode=e.NUMERIC,this.data=n.toString()}return t.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(r){let o,i,a;for(o=0;o+3<=this.data.length;o+=3)i=this.data.substr(o,3),a=parseInt(i,10),r.put(a,10);const l=this.data.length-o;l>0&&(i=this.data.substr(o),a=parseInt(i,10),r.put(a,l*3+1))},Da=t,Da}var Ra,Pu;function Cb(){if(Pu)return Ra;Pu=1;const e=Wt(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(r){this.mode=e.ALPHANUMERIC,this.data=r}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let i;for(i=0;i+2<=this.data.length;i+=2){let a=t.indexOf(this.data[i])*45;a+=t.indexOf(this.data[i+1]),o.put(a,11)}this.data.length%2&&o.put(t.indexOf(this.data[i]),6)},Ra=n,Ra}var $a,Du;function Ab(){if(Du)return $a;Du=1;const e=Wt();function t(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return t.getBitsLength=function(r){return r*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(n){for(let r=0,o=this.data.length;r<o;r++)n.put(this.data[r],8)},$a=t,$a}var La,Ru;function Ob(){if(Ru)return La;Ru=1;const e=Wt(),t=qt();function n(r){this.mode=e.KANJI,this.data=r}return n.getBitsLength=function(o){return o*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let o;for(o=0;o<this.data.length;o++){let i=t.toSJIS(this.data[o]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
253
- Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},La=n,La}var Na={exports:{}},$u;function Ib(){return $u||($u=1,(function(e){var t={single_source_shortest_paths:function(n,r,o){var i={},a={};a[r]=0;var l=t.PriorityQueue.make();l.push(r,0);for(var c,s,d,p,u,f,g,m,y;!l.empty();){c=l.pop(),s=c.value,p=c.cost,u=n[s]||{};for(d in u)u.hasOwnProperty(d)&&(f=u[d],g=p+f,m=a[d],y=typeof a[d]>"u",(y||m>g)&&(a[d]=g,l.push(d,g),i[d]=s))}if(typeof o<"u"&&typeof a[o]>"u"){var v=["Could not find a path from ",r," to ",o,"."].join("");throw new Error(v)}return i},extract_shortest_path_from_predecessor_list:function(n,r){for(var o=[],i=r;i;)o.push(i),n[i],i=n[i];return o.reverse(),o},find_path:function(n,r,o){var i=t.single_source_shortest_paths(n,r,o);return t.extract_shortest_path_from_predecessor_list(i,o)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,o={},i;n=n||{};for(i in r)r.hasOwnProperty(i)&&(o[i]=r[i]);return o.queue=[],o.sorter=n.sorter||r.default_sorter,o},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var o={value:n,cost:r};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Na)),Na.exports}var Lu;function Pb(){return Lu||(Lu=1,(function(e){const t=Wt(),n=kb(),r=Cb(),o=Ab(),i=Ob(),a=ku(),l=qt(),c=Ib();function s(v){return unescape(encodeURIComponent(v)).length}function d(v,w,_){const M=[];let N;for(;(N=v.exec(_))!==null;)M.push({data:N[0],index:N.index,mode:w,length:N[0].length});return M}function p(v){const w=d(a.NUMERIC,t.NUMERIC,v),_=d(a.ALPHANUMERIC,t.ALPHANUMERIC,v);let M,N;return l.isKanjiModeEnabled()?(M=d(a.BYTE,t.BYTE,v),N=d(a.KANJI,t.KANJI,v)):(M=d(a.BYTE_KANJI,t.BYTE,v),N=[]),w.concat(_,M,N).sort(function(P,k){return P.index-k.index}).map(function(P){return{data:P.data,mode:P.mode,length:P.length}})}function u(v,w){switch(w){case t.NUMERIC:return n.getBitsLength(v);case t.ALPHANUMERIC:return r.getBitsLength(v);case t.KANJI:return i.getBitsLength(v);case t.BYTE:return o.getBitsLength(v)}}function f(v){return v.reduce(function(w,_){const M=w.length-1>=0?w[w.length-1]:null;return M&&M.mode===_.mode?(w[w.length-1].data+=_.data,w):(w.push(_),w)},[])}function g(v){const w=[];for(let _=0;_<v.length;_++){const M=v[_];switch(M.mode){case t.NUMERIC:w.push([M,{data:M.data,mode:t.ALPHANUMERIC,length:M.length},{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.ALPHANUMERIC:w.push([M,{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.KANJI:w.push([M,{data:M.data,mode:t.BYTE,length:s(M.data)}]);break;case t.BYTE:w.push([{data:M.data,mode:t.BYTE,length:s(M.data)}])}}return w}function m(v,w){const _={},M={start:{}};let N=["start"];for(let L=0;L<v.length;L++){const P=v[L],k=[];for(let S=0;S<P.length;S++){const C=P[S],O=""+L+S;k.push(O),_[O]={node:C,lastCount:0},M[O]={};for(let D=0;D<N.length;D++){const I=N[D];_[I]&&_[I].node.mode===C.mode?(M[I][O]=u(_[I].lastCount+C.length,C.mode)-u(_[I].lastCount,C.mode),_[I].lastCount+=C.length):(_[I]&&(_[I].lastCount=C.length),M[I][O]=u(C.length,C.mode)+4+t.getCharCountIndicator(C.mode,w))}}N=k}for(let L=0;L<N.length;L++)M[N[L]].end=0;return{map:M,table:_}}function y(v,w){let _;const M=t.getBestModeForData(v);if(_=t.from(w,M),_!==t.BYTE&&_.bit<M.bit)throw new Error('"'+v+'" cannot be encoded with mode '+t.toString(_)+`.
254
- Suggested mode is: `+t.toString(M));switch(_===t.KANJI&&!l.isKanjiModeEnabled()&&(_=t.BYTE),_){case t.NUMERIC:return new n(v);case t.ALPHANUMERIC:return new r(v);case t.KANJI:return new i(v);case t.BYTE:return new o(v)}}e.fromArray=function(w){return w.reduce(function(_,M){return typeof M=="string"?_.push(y(M,null)):M.data&&_.push(y(M.data,M.mode)),_},[])},e.fromString=function(w,_){const M=p(w,l.isKanjiModeEnabled()),N=g(M),L=m(N,_),P=c.find_path(L.map,"start","end"),k=[];for(let S=1;S<P.length-1;S++)k.push(L.table[P[S]].node);return e.fromArray(f(k))},e.rawSplit=function(w){return e.fromArray(p(w,l.isKanjiModeEnabled()))}})(Pa)),Pa}var Nu;function Db(){if(Nu)return ya;Nu=1;const e=qt(),t=wa(),n=bb(),r=yb(),o=vb(),i=wb(),a=xb(),l=wu(),c=_b(),s=Mb(),d=Tb(),p=Wt(),u=Pb();function f(L,P){const k=L.size,S=i.getPositions(P);for(let C=0;C<S.length;C++){const O=S[C][0],D=S[C][1];for(let I=-1;I<=7;I++)if(!(O+I<=-1||k<=O+I))for(let x=-1;x<=7;x++)D+x<=-1||k<=D+x||(I>=0&&I<=6&&(x===0||x===6)||x>=0&&x<=6&&(I===0||I===6)||I>=2&&I<=4&&x>=2&&x<=4?L.set(O+I,D+x,!0,!0):L.set(O+I,D+x,!1,!0))}}function g(L){const P=L.size;for(let k=8;k<P-8;k++){const S=k%2===0;L.set(k,6,S,!0),L.set(6,k,S,!0)}}function m(L,P){const k=o.getPositions(P);for(let S=0;S<k.length;S++){const C=k[S][0],O=k[S][1];for(let D=-2;D<=2;D++)for(let I=-2;I<=2;I++)D===-2||D===2||I===-2||I===2||D===0&&I===0?L.set(C+D,O+I,!0,!0):L.set(C+D,O+I,!1,!0)}}function y(L,P){const k=L.size,S=s.getEncodedBits(P);let C,O,D;for(let I=0;I<18;I++)C=Math.floor(I/3),O=I%3+k-8-3,D=(S>>I&1)===1,L.set(C,O,D,!0),L.set(O,C,D,!0)}function v(L,P,k){const S=L.size,C=d.getEncodedBits(P,k);let O,D;for(O=0;O<15;O++)D=(C>>O&1)===1,O<6?L.set(O,8,D,!0):O<8?L.set(O+1,8,D,!0):L.set(S-15+O,8,D,!0),O<8?L.set(8,S-O-1,D,!0):O<9?L.set(8,15-O-1+1,D,!0):L.set(8,15-O-1,D,!0);L.set(S-8,8,1,!0)}function w(L,P){const k=L.size;let S=-1,C=k-1,O=7,D=0;for(let I=k-1;I>0;I-=2)for(I===6&&I--;;){for(let x=0;x<2;x++)if(!L.isReserved(C,I-x)){let j=!1;D<P.length&&(j=(P[D]>>>O&1)===1),L.set(C,I-x,j),O--,O===-1&&(D++,O=7)}if(C+=S,C<0||k<=C){C-=S,S=-S;break}}}function _(L,P,k){const S=new n;k.forEach(function(x){S.put(x.mode.bit,4),S.put(x.getLength(),p.getCharCountIndicator(x.mode,L)),x.write(S)});const C=e.getSymbolTotalCodewords(L),O=l.getTotalCodewordsCount(L,P),D=(C-O)*8;for(S.getLengthInBits()+4<=D&&S.put(0,4);S.getLengthInBits()%8!==0;)S.putBit(0);const I=(D-S.getLengthInBits())/8;for(let x=0;x<I;x++)S.put(x%2?17:236,8);return M(S,L,P)}function M(L,P,k){const S=e.getSymbolTotalCodewords(P),C=l.getTotalCodewordsCount(P,k),O=S-C,D=l.getBlocksCount(P,k),I=S%D,x=D-I,j=Math.floor(S/D),te=Math.floor(O/D),fe=te+1,G=j-te,de=new c(G);let Xe=0;const ye=new Array(D),Fe=new Array(D);let R=0;const F=new Uint8Array(L.buffer);for(let ne=0;ne<D;ne++){const Q=ne<x?te:fe;ye[ne]=F.slice(Xe,Xe+Q),Fe[ne]=de.encode(ye[ne]),Xe+=Q,R=Math.max(R,Q)}const W=new Uint8Array(S);let V=0,Y,K;for(Y=0;Y<R;Y++)for(K=0;K<D;K++)Y<ye[K].length&&(W[V++]=ye[K][Y]);for(Y=0;Y<G;Y++)for(K=0;K<D;K++)W[V++]=Fe[K][Y];return W}function N(L,P,k,S){let C;if(Array.isArray(L))C=u.fromArray(L);else if(typeof L=="string"){let j=P;if(!j){const te=u.rawSplit(L);j=s.getBestVersionForData(te,k)}C=u.fromString(L,j||40)}else throw new Error("Invalid data");const O=s.getBestVersionForData(C,k);if(!O)throw new Error("The amount of data is too big to be stored in a QR Code");if(!P)P=O;else if(P<O)throw new Error(`
263
+ `),o=e.reduce((l,c)=>l+c.layoutsPerPage.reduce((s,d)=>s+d.length,0),0),i=[];let a=0;for(const l of e)for(const c of l.layoutsPerPage)for(const s of c)i.push({...s,pageIndex:a++});return{html:Kr(n,r),pageCount:o,pageLayouts:i}}async function x0(e,t){return t.withSession(e,n=>E0(e,n))}async function E0(e,t){const n=Ea(e.templateJson);if(n.length>1){const c=Xc(e.printData),s=c.mode==="batch"?c.dataList:[c.data],d=[];for(let u=0;u<s.length;u++)try{d.push(await _0(e,t,s[u]))}catch(f){const m=f instanceof Error?f.message:String(f);throw new Error(`第 ${u+1} 份渲染失败:${m}`)}const p=w0(d);return{html:p.html,pageCount:p.pageCount,paperMm:dn(n[0]),continuous:!1,heightSource:"config",pageLayouts:p.pageLayouts,copies:d.length}}const r=n[0]!==e.templateJson?{...e,templateJson:n[0]}:e,o=n[0],i=Xc(r.printData);if(i.mode==="single"){const c=await td(r,t,i.data);return o.tiling?.enabled===!0?ed(r,[{bound:c.bound,pageLayouts:c.pageLayouts,data:i.data,codeRenderer:c.codeRenderer,derivedHeightMm:c.derivedHeightMm,paperMm:c.paperMm,heightSource:c.heightSource}]):S0(c)}const a=[];for(let c=0;c<i.dataList.length;c++)try{const s=await td(r,t,i.dataList[c]);a.push({bound:s.bound,pageLayouts:s.pageLayouts,data:i.dataList[c],codeRenderer:s.codeRenderer,derivedHeightMm:s.derivedHeightMm,paperMm:s.paperMm,heightSource:s.heightSource})}catch(s){const d=s instanceof Error?s.message:String(s);throw new Error(`第 ${c+1} 份渲染失败:${d}`)}if(o.tiling?.enabled===!0)return ed(r,a);const l=p0(a);return{html:l.html,pageCount:l.pageCount,paperMm:a[0].paperMm,continuous:ct(a[0].bound),heightSource:a[0].heightSource,pageLayouts:a.flatMap(c=>c.pageLayouts),copies:a.length,copyPaperMm:l.copyPaperMm}}function S0(e){return{html:e.html,pageCount:e.pageCount,paperMm:e.paperMm,continuous:e.continuous,heightSource:e.heightSource,pageLayouts:e.pageLayouts,copies:1}}function ed(e,t){const n=t[0].bound,r=Jc(n,{paperOverride:e.paperOverride});t.forEach((i,a)=>{const l=i.pageLayouts[0]?.overflow===!0;if(i.pageLayouts.length!==1||l){const c=l?"内容超出纸张高度":`渲染出 ${i.pageLayouts.length} 页`;throw new Error(`拼版要求每份标签恰好 1 页,第 ${a+1} 份${c};请缩小内容或调整标签纸张高度`)}});const o=b0({copies:t.map(i=>({bound:i.bound,pageLayouts:i.pageLayouts,data:i.data,codeRenderer:i.codeRenderer})),layout:r});return{html:o.html,pageCount:o.sheetCount,paperMm:{width:r.sheet.width,height:r.sheet.height},continuous:!1,heightSource:"config",pageLayouts:t.flatMap(i=>i.pageLayouts),copies:t.length}}async function td(e,t,n){const r=bc(e.templateJson,n,e.baseUrl,e.fontBaseUrl),o=ct(r),i=et(r),a=Wc(i),l=e0({paperHeightMm:e.paperHeightMm,override:e.paperOverride}),c=await no({bound:r,job:e,session:t,data:n,pageLayouts:[],isMeasurementPass:!0}),s=await t.measure(c.html,a);Gc(r,s.fits);const d=Oi(r,jc(s.measurements,r)),p=await no({bound:r,job:e,session:t,data:n,pageLayouts:d,isMeasurementPass:!1,baseMap:c.map});let u=p.html,f;if(o){if(l&&l>0)f=l;else{const w=await t.probeContentBottom(u,a);f=Jm(r,ya(w))}u=Yr(r,d,n,{codeRenderer:p.codeRenderer,pageHeightMm:f})}const m=o&&l?{...e.paperOverride,height:l}:e.paperOverride,g=dn(r),{paperMm:b,heightSource:v}=t0({paperMm:{width:g.width,height:f??g.height},continuous:o,override:m});return{html:u,pageCount:d.length,paperMm:b,continuous:o,heightSource:v,pageLayouts:d,copies:1,bound:r,codeRenderer:p.codeRenderer,derivedHeightMm:f}}async function _0(e,t,n){const r=Ea(e.templateJson),o=Wc(et(r[0])),i=[],a=[],l=[];for(const c of r){const s=bc(c,n,e.baseUrl,e.fontBaseUrl),d=await no({bound:s,job:e,session:t,data:n,pageLayouts:[],isMeasurementPass:!0}),p=await t.measure(d.html,o);Gc(s,p.fits);const u=Oi(s,jc(p.measurements,s)),f=await no({bound:s,job:e,session:t,data:n,pageLayouts:u,isMeasurementPass:!1,baseMap:d.map});i.push(s),a.push(u),l.push(f.codeRenderer)}return{boundPages:i,layoutsPerPage:a,data:n,codeRenderers:l}}async function no(e){const t=e.baseMap??new Map;if(e.job.codeRenderer)return{html:Yr(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:e.job.codeRenderer}),codeRenderer:e.job.codeRenderer,map:t};const n=i0(t),r=Yr(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:n.renderer}),o=n.takeSpecs(),i=o.length>0?await e.session.renderCodes(o):new Map,a=a0(t,i),l=a.size>0?o0(a):void 0;return o.length===0?{html:r,codeRenderer:l,map:a}:{html:Yr(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:l}),codeRenderer:l,map:a}}class M0{constructor(t){this.functions={},t?.functions&&(this.functions={...t.functions})}registerFunction(t,n){this.functions[t]=n}evaluate(t,n){const r=Yi(t),o=Xi(r);return Le(o,n,this.functions)}render(t,n){return nc(t,this.functions)(n)}}const nd=new M0,T0={MONEY:rc,CONCAT:(...e)=>e.filter(t=>t!=null).join(""),IF:ac,FORMAT:e=>typeof e!="number"?String(e):e.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}),SUBSTR:(e,t,n)=>String(e).slice(t,n?t+n:void 0),LEN:e=>String(e).length,ADD:uc,SUB:pc,MUL:fc,DIV:hc,ROUND:gc,ROUNDUP:Hr,CEIL:Hr,ROUNDDOWN:Ur,FLOOR:Ur,ROUNDBANK:mc,NOW:()=>new Date().toISOString().split("T")[0],IFEMPTY:(e,t)=>e!=null&&e!==""?String(e):t,PAD:(e,t,n)=>String(e).padStart(t,n),REPLACE:(e,t,n)=>String(e).replace(new RegExp(t,"g"),n),JSON:e=>JSON.stringify(e,null,2),DATE:oc,UPPER:ic};for(const[e,t]of Object.entries(T0))nd.registerFunction(e,t);function k0(e,t,n){switch(e.toUpperCase()){case"SUM":return ta(n,t);case"AVG":return sc(n,t);case"COUNT":return lc(n);case"MIN":return cc(n,t);case"MAX":return dc(n,t);default:return 0}}function gn(e,t){if(!e)return"";if(!e.includes("{"))return e;const n=Array.isArray(t.rows)?t.rows:[];let r=e.replace(/\{([^}]+)\}/g,(o,i)=>{let a=i.trim();return a=a.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(l,c,s)=>{const d=s.trim().replace(/^['"]|['"]$/g,"");return String(k0(c,d,n))}),`{${a}}`});try{return nd.render(r,t)}catch{return e}}const ft={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级"}]},ro={left:0,center:50,right:100},oo={top:0,center:50,bottom:100};function mn(e){return Number.isFinite(e)?Math.round(Math.min(100,Math.max(0,e))):50}function rd(e){return Math.round(e*100)/100}function od(e,t){const n=mn(e),r=mn(t);if(!(n===50&&r===50))return`${n}% ${r}%`}function C0(e){return/^\d+(?:\.\d+)?%$/.test(e)?parseFloat(e):void 0}function A0(e){const t=(e??"").trim();if(!t)return{kind:"empty"};const n=t.toLowerCase().split(/\s+/);let r,o;for(let i=0;i<n.length;i++){const a=n[i],l=C0(a);if(i===0)if(a in ro)r=ro[a];else if(l!==void 0)r=l;else if(a in oo)o=oo[a];else return{kind:"custom",raw:e};else if(a in oo&&o===void 0)o=oo[a];else if(l!==void 0&&r===void 0)r=l;else if(l!==void 0&&o===void 0)o=l;else if(a in ro&&r===void 0)r=ro[a];else return{kind:"custom",raw:e}}return{kind:"axes",x:mn(r??50),y:mn(o??50)}}const id=25.4/96;function ad(e){const{widthMm:t,heightMm:n,naturalWidth:r,naturalHeight:o}=e;if(!r||!o||!t||!n)return null;const i=t/r,a=n/o,l=(fl(e.fit,e.scalePct)??Bn)/100;switch(e.fit||"contain"){case"fill":return{w:t,h:n};case"cover":{const c=Math.max(i,a)*l;return{w:r*c,h:o*c}}case"none":return{w:r*id,h:o*id};case"scale-down":{const c=Math.min(1,Math.min(i,a));return{w:r*c,h:o*c}}default:{const c=Math.min(i,a);return{w:r*c,h:o*c}}}}function O0(e){const t=ad(e);return t?{x:rd(Math.abs(e.widthMm-t.w)),y:rd(Math.abs(e.heightMm-t.h))}:{x:null,y:null}}function I0(e,t,n){const r=ad(e);if(!r)return null;const o=Math.min(1,e.widthMm/r.w),i=Math.min(1,e.heightMm/r.h);return{leftPct:(1-o)*mn(t),topPct:(1-i)*mn(n),widthPct:o*100,heightPct:i*100}}function sd(e){const t=String(e??"");return t?t.includes("{")?String(gn(t,ft)):t:""}const ld={vertical:[{value:0,label:"顶部"},{value:50,label:"居中"},{value:100,label:"底部"}],horizontal:[{value:0,label:"左侧"},{value:50,label:"居中"},{value:100,label:"右侧"}]},P0=[{x:0,y:0,label:"左上"},{x:50,y:0,label:"上中"},{x:100,y:0,label:"右上"},{x:0,y:50,label:"左中"},{x:50,y:50,label:"居中"},{x:100,y:50,label:"右中"},{x:0,y:100,label:"左下"},{x:50,y:100,label:"下中"},{x:100,y:100,label:"右下"}],Sa=[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"剪裁(等比铺满后裁边)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],R0="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+PHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNmZmZmZmYiLz48cGF0aCBkPSJNNDAgMFYxMjBNODAgMFYxMjBNMCA0MEgxMjBNMCA4MEgxMjAiIHN0cm9rZT0iI2VlZjFmNiIgc3Ryb2tlLXdpZHRoPSIxIi8+PGNpcmNsZSBjeD0iMjAiIGN5PSIyMCIgcj0iMy41IiBmaWxsPSIjOGI5NWE1Ii8+PGNpcmNsZSBjeD0iMTAwIiBjeT0iMjAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iMTAwIiByPSIzLjUiIGZpbGw9IiM4Yjk1YTUiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSIxMDAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iMjAiIHI9IjciIGZpbGw9IiNjMDM5MmIiLz48Y2lyY2xlIGN4PSI2MCIgY3k9IjEwMCIgcj0iNyIgZmlsbD0iIzFmNGZhMyIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iNjAiIHI9IjciIGZpbGw9IiMyYzdhNGEiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSI2MCIgcj0iNyIgZmlsbD0iI2UwN2EyMCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjE0IiBmaWxsPSJub25lIiBzdHJva2U9IiMyZjNhNGEiIHN0cm9rZS13aWR0aD0iNCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjYiIGZpbGw9IiMyZjNhNGEiLz48L3N2Zz4=",D0="图片还没设置,上面按内置示例图演示取位;换上真图后档位与可挪量按真图重算";function $0(e){const t=String(e??"").trim();return!t||t.includes("{")||t.includes("}")?{src:R0,isSample:!0}:{src:t,isSample:!1}}function cd(e){return e==="vertical"?"垂直位置 (%)":"水平位置 (%)"}const L0="放大比例 (%)";function N0(e,t=!1){if(t)return"已保留模板里的原值;改动下面任一项就整体替换成新的取位";const{x:n,y:r}=e;return n===null||r===null?"":n>0&&r>0?`水平可挪 ${n}mm、垂直可挪 ${r}mm:0 贴左/贴顶,100 贴右/贴底`:n>0?`水平可挪 ${n}mm;垂直这一轴已贴满,挪不动`:r>0?`垂直可挪 ${r}mm;水平这一轴已贴满,挪不动`:"这个缩放下图与框正好一样大,两轴都没有可挪的余量"}function F0(e,t,n){return[{name:"horizontal",label:cd("horizontal"),value:t,travelMm:e.x},{name:"vertical",label:cd("vertical"),value:n,travelMm:e.y}]}function z0(e,t,n){const r=e.x!==null&&e.x>0,o=e.y!==null&&e.y>0;return o&&!r?ld.vertical.map(i=>({value:`${t},${i.value}`,label:i.label})):r&&!o?ld.horizontal.map(i=>({value:`${i.value},${n}`,label:i.label})):P0.map(i=>({value:`${i.x},${i.y}`,label:i.label}))}function dd(e){const t=[...e].sort((a,l)=>(a.sortOrder??0)-(l.sortOrder??0)),n=new Map,r=[];for(const a of t){const l=a.fieldKey.indexOf(".");if(l===-1)continue;const c=a.fieldKey.slice(0,l);let s=n.get(c);s||(s={key:c,label:c,isList:!1,fields:[]},n.set(c,s),r.push(c)),s.fields.push(a)}const o=[],i=[];for(const a of t){if(a.fieldKey.includes("."))continue;const l=n.get(a.fieldKey);l?(l.label=a.fieldLabel,l.isList=a.fieldType==="list"):i.push(a)}i.length&&o.push({key:"",label:"",isList:!1,fields:i});for(const a of r)o.push(n.get(a));return o}function B0(e,t){const n=t.trim().toLowerCase();return n?e.map(r=>({...r,fields:r.fields.filter(o=>o.fieldLabel.toLowerCase().includes(n)||o.fieldKey.toLowerCase().includes(n))})).filter(r=>r.fields.length>0):e}async function ud(e){if(!e)return!1;const t=typeof navigator>"u"?void 0:navigator;if(t?.clipboard?.writeText)try{return await t.clipboard.writeText(e),!0}catch{}if(typeof document>"u")return!1;const n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.top="-1000px",n.style.opacity="0",document.body.appendChild(n);try{return n.select(),typeof document.execCommand=="function"&&document.execCommand("copy")}catch{return!1}finally{n.remove()}}const H0={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:[],flowList:[{targetPath:"options.formatter",label:"单元模板",dataSource:"main",placeholder:"{drugs.name} {drugs.spec}"}]};function pd(e,t,n,r){return e==="data"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"list",listField:r,placeholder:"{name}"}]:e==="subtotal"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"subtotal",placeholder:"{MONEY(SUM(amount))}"}]:e==="summary"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"summary",placeholder:"{MONEY(SUM(amount))}"}]:[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"main",placeholder:"合计: {order.total}"}]}function U0(e){const t=e.printElementType.type,n=H0[t]??[],r=[];if(t==="table"){const o=e.options.dataSource;for(const[i,a]of(e.options.tableRows??[]).entries())for(const[l,c]of a.cells.entries())c.merged||r.push(...pd(a.type,i,l,o))}return[...n,...r]}function q0(e){return Li("text",{formatter:`{${e.fieldKey}}`,title:e.fieldLabel})}function W0(e){const t=e.fieldLabel||e.fieldKey;return Li("text",{formatter:t,title:t})}function fd(e){let t=ft;for(const n of e.split(".")){if(t==null)return;t=Array.isArray(t)?t[0]?.[n]:t[n]}return t}function _a(e,t,n="1234567890128"){const r=t?.[0];return(e??"").replace(/\{([^{}]+)\}/g,(i,a)=>{const l=a.trim(),c=l.includes(".")?fd(l):r?.[l]??fd(l);return c==null?"":String(c)}).trim()||n}const io={left:"#3b82f6",center:"#10b981",right:"#f59e0b",top:"#3b82f6",middle:"#10b981",bottom:"#f59e0b"};function hd(e){return e==="vCenter"?io.center:e==="hCenter"?io.middle:io[e]??io.left}function j0(e,t,n,r={}){const o=r.adsorbMin??1,i=r.adsorbLineMin??2,a=r.showAdsorbLine??!0;let l=e.left,c=e.top;const s=[],d={left:e.left,right:e.left+e.width,vCenter:e.left+e.width/2,top:e.top,bottom:e.top+e.height,hCenter:e.top+e.height/2};let p=1/0;for(const f of t){if(f.id===e.id)continue;const m={left:f.left,right:f.left+f.width,vCenter:f.left+f.width/2,top:f.top,bottom:f.top+f.height,hCenter:f.top+f.height/2},g=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],b=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[v,w]of g){const _=Math.abs(d[v]-m[w]);_<=o&&_<p&&(p=_,l=e.left+(m[w]-d[v]))}for(const[v,w]of b){const _=Math.abs(d[v]-m[w]);_<=o&&_<p&&(p=_,c=e.top+(m[w]-d[v]))}}if(n){const f={left:l,right:l+e.width,vCenter:l+e.width/2,top:c,bottom:c+e.height,hCenter:c+e.height/2},m=["left","vCenter","right"];for(const b of n.vertical)for(const v of m){const w=Math.abs(f[v]-b);w<=o&&w<p&&(p=w,l=e.left+(b-f[v]))}const g=["top","hCenter","bottom"];for(const b of n.horizontal)for(const v of g){const w=Math.abs(f[v]-b);w<=o&&w<p&&(p=w,c=e.top+(b-f[v]))}}const u={left:l,right:l+e.width,vCenter:l+e.width/2,top:c,bottom:c+e.height,hCenter:c+e.height/2};if(a){const f=new Set;for(const m of t){if(m.id===e.id)continue;const g={left:m.left,right:m.left+m.width,vCenter:m.left+m.width/2,top:m.top,bottom:m.top+m.height,hCenter:m.top+m.height/2},b=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],v=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[w,_]of b)if(Math.abs(u[w]-g[_])<=i){const N=`v:${g[_]}`;f.has(N)||(f.add(N),s.push({type:"vertical",position:g[_],id:m.id,color:hd(w)}))}for(const[w,_]of v)if(Math.abs(u[w]-g[_])<=i){const N=`h:${g[_]}`;f.has(N)||(f.add(N),s.push({type:"horizontal",position:g[_],id:m.id,color:hd(w)}))}}}if(n){for(const f of n.vertical)s.some(m=>m.type==="vertical"&&m.position===f)||s.push({type:"vertical",position:f});for(const f of n.horizontal)s.some(m=>m.type==="horizontal"&&m.position===f)||s.push({type:"horizontal",position:f})}return{left:l,top:c,lines:s}}function G0(){function e(t,n){if(t.length<2)return;const r={minLeft:Math.min(...t.map(o=>o.options.left)),maxRight:Math.max(...t.map(o=>o.options.left+o.options.width)),minTop:Math.min(...t.map(o=>o.options.top)),maxBottom:Math.max(...t.map(o=>o.options.top+o.options.height))};switch(n){case"left":t.forEach(o=>{o.options.left=r.minLeft});break;case"right":t.forEach(o=>{o.options.left=r.maxRight-o.options.width});break;case"top":t.forEach(o=>{o.options.top=r.minTop});break;case"bottom":t.forEach(o=>{o.options.top=r.maxBottom-o.options.height});break;case"vertical":{const o=r.minLeft+(r.maxRight-r.minLeft)/2;t.forEach(i=>{i.options.left=o-i.options.width/2});break}case"horizontal":{const o=r.minTop+(r.maxBottom-r.minTop)/2;t.forEach(i=>{i.options.top=o-i.options.height/2});break}case"distributeHor":{const o=[...t].sort((c,s)=>c.options.left-s.options.left),i=o.reduce((c,s)=>c+s.options.width,0),a=(r.maxRight-r.minLeft-i)/(o.length-1);let l=r.minLeft;o.forEach(c=>{c.options.left=l,l+=c.options.width+a});break}case"distributeVer":{const o=[...t].sort((c,s)=>c.options.top-s.options.top),i=o.reduce((c,s)=>c+s.options.height,0),a=(r.maxBottom-r.minTop-i)/(o.length-1);let l=r.minTop;o.forEach(c=>{c.options.top=l,l+=c.options.height+a});break}}}return{align:e}}function gd(){return`grp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function V0(){function e(r,o){if(r.filter(l=>o.has(l.id)).length<2)return r;const a=gd();return r.map(l=>o.has(l.id)?{...l,options:{...l.options,groupId:a}}:l)}function t(r,o){const i=r.filter(l=>o.has(l.id)),a=new Set(i.map(l=>l.options.groupId).filter(Boolean));return r.map(l=>l.options.groupId&&a.has(l.options.groupId)?{...l,options:{...l.options,groupId:void 0}}:l)}function n(r,o){const i=r.find(l=>l.id===o);if(!i?.options.groupId)return new Set([o]);const a=new Set;for(const l of r)l.options.groupId===i.options.groupId&&a.add(l.id);return a}return{group:e,ungroup:t,getGroupedIds:n}}const Y0=["nw","n","ne","e","se","s","sw","w"];function X0(e,t,n,r,o,i){let{left:a,top:l,width:c,height:s}=t;switch(e){case"e":c=Math.max(o,t.width+n);break;case"w":c=Math.max(o,t.width-n),a=t.left+t.width-c;break;case"s":s=Math.max(i,t.height+r);break;case"n":s=Math.max(i,t.height-r),l=t.top+t.height-s;break;case"se":c=Math.max(o,t.width+n),s=Math.max(i,t.height+r);break;case"sw":c=Math.max(o,t.width-n),a=t.left+t.width-c,s=Math.max(i,t.height+r);break;case"ne":c=Math.max(o,t.width+n),s=Math.max(i,t.height-r),l=t.top+t.height-s;break;case"nw":c=Math.max(o,t.width-n),a=t.left+t.width-c,s=Math.max(i,t.height-r),l=t.top+t.height-s;break}return{left:a,top:l,width:c,height:s}}function md(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ao={},or={},so={},bd;function Ve(){if(bd)return so;bd=1,Object.defineProperty(so,"__esModule",{value:!0});function e(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}var t=function n(r,o){e(this,n),this.data=r,this.text=o.text||r,this.options=o};return so.default=t,so}var yd;function K0(){if(yd)return or;yd=1,Object.defineProperty(or,"__esModule",{value:!0}),or.CODE39=void 0;var e=(function(){function g(b,v){for(var w=0;w<v.length;w++){var _=v[w];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(b,_.key,_)}}return function(b,v,w){return v&&g(b.prototype,v),w&&g(b,w),b}})(),t=Ve(),n=r(t);function r(g){return g&&g.__esModule?g:{default:g}}function o(g,b){if(!(g instanceof b))throw new TypeError("Cannot call a class as a function")}function i(g,b){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:g}function a(g,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);g.prototype=Object.create(b&&b.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(g,b):g.__proto__=b)}var l=(function(g){a(b,g);function b(v,w){return o(this,b),v=v.toUpperCase(),w.mod43&&(v+=u(m(v))),i(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,v,w))}return e(b,[{key:"encode",value:function(){for(var w=d("*"),_=0;_<this.data.length;_++)w+=d(this.data[_])+"0";return w+=d("*"),{data:w,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),b})(n.default),c=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],s=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function d(g){return p(f(g))}function p(g){return s[g].toString(2)}function u(g){return c[g]}function f(g){return c.indexOf(g)}function m(g){for(var b=0,v=0;v<g.length;v++)b+=f(g[v]);return b=b%43,b}return or.CODE39=l,or}var it={},lo={},co={},ve={},vd;function ir(){if(vd)return ve;vd=1,Object.defineProperty(ve,"__esModule",{value:!0});var e;function t(c,s,d){return s in c?Object.defineProperty(c,s,{value:d,enumerable:!0,configurable:!0,writable:!0}):c[s]=d,c}var n=ve.SET_A=0,r=ve.SET_B=1,o=ve.SET_C=2;ve.SHIFT=98;var i=ve.START_A=103,a=ve.START_B=104,l=ve.START_C=105;return ve.MODULO=103,ve.STOP=106,ve.FNC1=207,ve.SET_BY_CODE=(e={},t(e,i,n),t(e,a,r),t(e,l,o),e),ve.SWAP={101:n,100:r,99:o},ve.A_START_CHAR="Ð",ve.B_START_CHAR="Ñ",ve.C_START_CHAR="Ò",ve.A_CHARS="[\0-_È-Ï]",ve.B_CHARS="[ -È-Ï]",ve.C_CHARS="(Ï*[0-9]{2}Ï*)",ve.BARS=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011],ve}var wd;function uo(){if(wd)return co;wd=1,Object.defineProperty(co,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=Ve(),n=o(t),r=ir();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){i(this,d);var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p.substring(1),u));return f.bytes=p.split("").map(function(m){return m.charCodeAt(0)}),f}return e(d,[{key:"valid",value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:"encode",value:function(){var u=this.bytes,f=u.shift()-105,m=r.SET_BY_CODE[f];if(m===void 0)throw new RangeError("The encoding does not start with a start character.");this.shouldEncodeAsEan128()===!0&&u.unshift(r.FNC1);var g=d.next(u,1,m);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:d.getBar(f)+g.result+d.getBar((g.checksum+f)%r.MODULO)+d.getBar(r.STOP)}}},{key:"shouldEncodeAsEan128",value:function(){var u=this.options.ean128||!1;return typeof u=="string"&&(u=u.toLowerCase()==="true"),u}}],[{key:"getBar",value:function(u){return r.BARS[u]?r.BARS[u].toString():""}},{key:"correctIndex",value:function(u,f){if(f===r.SET_A){var m=u.shift();return m<32?m+64:m-32}else return f===r.SET_B?u.shift()-32:(u.shift()-48)*10+u.shift()-48}},{key:"next",value:function(u,f,m){if(!u.length)return{result:"",checksum:0};var g=void 0,b=void 0;if(u[0]>=200){b=u.shift()-105;var v=r.SWAP[b];v!==void 0?g=d.next(u,f+1,v):((m===r.SET_A||m===r.SET_B)&&b===r.SHIFT&&(u[0]=m===r.SET_A?u[0]>95?u[0]-96:u[0]:u[0]<32?u[0]+96:u[0]),g=d.next(u,f+1,m))}else b=d.correctIndex(u,m),g=d.next(u,f+1,m);var w=d.getBar(b),_=b*f;return{result:w+g.result,checksum:_+g.checksum}}}]),d})(n.default);return co.default=c,co}var po={},xd;function Z0(){if(xd)return po;xd=1,Object.defineProperty(po,"__esModule",{value:!0});var e=ir(),t=function(l){return l.match(new RegExp("^"+e.A_CHARS+"*"))[0].length},n=function(l){return l.match(new RegExp("^"+e.B_CHARS+"*"))[0].length},r=function(l){return l.match(new RegExp("^"+e.C_CHARS+"*"))[0]};function o(a,l){var c=l?e.A_CHARS:e.B_CHARS,s=a.match(new RegExp("^("+c+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(s)return s[1]+"Ì"+i(a.substring(s[1].length));var d=a.match(new RegExp("^"+c+"+"))[0];return d.length===a.length?a:d+String.fromCharCode(l?205:206)+o(a.substring(d.length),!l)}function i(a){var l=r(a),c=l.length;if(c===a.length)return a;a=a.substring(c);var s=t(a)>=n(a);return l+String.fromCharCode(s?206:205)+o(a,s)}return po.default=function(a){var l=void 0,c=r(a).length;if(c>=2)l=e.C_START_CHAR+i(a);else{var s=t(a)>n(a);l=(s?e.A_START_CHAR:e.B_START_CHAR)+o(a,s)}return l.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,p){return"Ë"+p})},po}var Ed;function J0(){if(Ed)return lo;Ed=1,Object.defineProperty(lo,"__esModule",{value:!0});var e=uo(),t=o(e),n=Z0(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){if(i(this,d),/^[\x00-\x7F\xC8-\xD3]+$/.test(p))var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,(0,r.default)(p),u));else var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u));return a(f)}return d})(t.default);return lo.default=c,lo}var fo={},Sd;function Q0(){if(Sd)return fo;Sd=1,Object.defineProperty(fo,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=uo(),n=o(t),r=ir();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.A_START_CHAR+p,u))}return e(d,[{key:"valid",value:function(){return new RegExp("^"+r.A_CHARS+"+$").test(this.data)}}]),d})(n.default);return fo.default=c,fo}var ho={},_d;function eb(){if(_d)return ho;_d=1,Object.defineProperty(ho,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=uo(),n=o(t),r=ir();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.B_START_CHAR+p,u))}return e(d,[{key:"valid",value:function(){return new RegExp("^"+r.B_CHARS+"+$").test(this.data)}}]),d})(n.default);return ho.default=c,ho}var go={},Md;function tb(){if(Md)return go;Md=1,Object.defineProperty(go,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=uo(),n=o(t),r=ir();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.C_START_CHAR+p,u))}return e(d,[{key:"valid",value:function(){return new RegExp("^"+r.C_CHARS+"+$").test(this.data)}}]),d})(n.default);return go.default=c,go}var Td;function nb(){if(Td)return it;Td=1,Object.defineProperty(it,"__esModule",{value:!0}),it.CODE128C=it.CODE128B=it.CODE128A=it.CODE128=void 0;var e=J0(),t=c(e),n=Q0(),r=c(n),o=eb(),i=c(o),a=tb(),l=c(a);function c(s){return s&&s.__esModule?s:{default:s}}return it.CODE128=t.default,it.CODE128A=r.default,it.CODE128B=i.default,it.CODE128C=l.default,it}var Ne={},mo={},wt={},kd;function ar(){return kd||(kd=1,Object.defineProperty(wt,"__esModule",{value:!0}),wt.SIDE_BIN="101",wt.MIDDLE_BIN="01010",wt.BINARIES={L:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],G:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],R:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],O:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],E:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"]},wt.EAN2_STRUCTURE=["LL","LG","GL","GG"],wt.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],wt.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),wt}var bo={},yo={},Cd;function sr(){if(Cd)return yo;Cd=1,Object.defineProperty(yo,"__esModule",{value:!0});var e=ar(),t=function(r,o,i){var a=r.split("").map(function(c,s){return e.BINARIES[o[s]]}).map(function(c,s){return c?c[r[s]]:""});if(i){var l=r.length-1;a=a.map(function(c,s){return s<l?c+i:c})}return a.join("")};return yo.default=t,yo}var Ad;function Od(){if(Ad)return bo;Ad=1,Object.defineProperty(bo,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var m=0;m<f.length;m++){var g=f[m];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(u,g.key,g)}}return function(u,f,m){return f&&p(u.prototype,f),m&&p(u,m),u}})(),t=ar(),n=sr(),r=a(n),o=Ve(),i=a(o);function a(p){return p&&p.__esModule?p:{default:p}}function l(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function c(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function s(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var d=(function(p){s(u,p);function u(f,m){l(this,u);var g=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,m));return g.fontSize=!m.flat&&m.fontSize>m.width*10?m.width*10:m.fontSize,g.guardHeight=m.height+g.fontSize/2+m.textMargin,g}return e(u,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(m,g){return this.text.substr(m,g)}},{key:"leftEncode",value:function(m,g){return(0,r.default)(m,g)}},{key:"rightText",value:function(m,g){return this.text.substr(m,g)}},{key:"rightEncode",value:function(m,g){return(0,r.default)(m,g)}},{key:"encodeGuarded",value:function(){var m={fontSize:this.fontSize},g={height:this.guardHeight};return[{data:t.SIDE_BIN,options:g},{data:this.leftEncode(),text:this.leftText(),options:m},{data:t.MIDDLE_BIN,options:g},{data:this.rightEncode(),text:this.rightText(),options:m},{data:t.SIDE_BIN,options:g}]}},{key:"encodeFlat",value:function(){var m=[t.SIDE_BIN,this.leftEncode(),t.MIDDLE_BIN,this.rightEncode(),t.SIDE_BIN];return{data:m.join(""),text:this.text}}}]),u})(i.default);return bo.default=d,bo}var Id;function rb(){if(Id)return mo;Id=1,Object.defineProperty(mo,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var m=0;m<f.length;m++){var g=f[m];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(u,g.key,g)}}return function(u,f,m){return f&&p(u.prototype,f),m&&p(u,m),u}})(),t=function p(u,f,m){u===null&&(u=Function.prototype);var g=Object.getOwnPropertyDescriptor(u,f);if(g===void 0){var b=Object.getPrototypeOf(u);return b===null?void 0:p(b,f,m)}else{if("value"in g)return g.value;var v=g.get;return v===void 0?void 0:v.call(m)}},n=ar(),r=Od(),o=i(r);function i(p){return p&&p.__esModule?p:{default:p}}function a(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function l(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function c(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var s=function(u){var f=u.substr(0,12).split("").map(function(m){return+m}).reduce(function(m,g,b){return b%2?m+g*3:m+g},0);return(10-f%10)%10},d=(function(p){c(u,p);function u(f,m){a(this,u),f.search(/^[0-9]{12}$/)!==-1&&(f+=s(f));var g=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,m));return g.lastChar=m.lastChar,g}return e(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===s(this.data)}},{key:"leftText",value:function(){return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var m=this.data.substr(1,6),g=n.EAN13_STRUCTURE[this.data[0]];return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftEncode",this).call(this,m,g)}},{key:"rightText",value:function(){return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var m=this.data.substr(7,6);return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightEncode",this).call(this,m,"RRRRRR")}},{key:"encodeGuarded",value:function(){var m=t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(m.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(m.push({data:"00"}),m.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),m}}]),u})(o.default);return mo.default=d,mo}var vo={},Pd;function ob(){if(Pd)return vo;Pd=1,Object.defineProperty(vo,"__esModule",{value:!0});var e=(function(){function d(p,u){for(var f=0;f<u.length;f++){var m=u[f];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(p,m.key,m)}}return function(p,u,f){return u&&d(p.prototype,u),f&&d(p,f),p}})(),t=function d(p,u,f){p===null&&(p=Function.prototype);var m=Object.getOwnPropertyDescriptor(p,u);if(m===void 0){var g=Object.getPrototypeOf(p);return g===null?void 0:d(g,u,f)}else{if("value"in m)return m.value;var b=m.get;return b===void 0?void 0:b.call(f)}},n=Od(),r=o(n);function o(d){return d&&d.__esModule?d:{default:d}}function i(d,p){if(!(d instanceof p))throw new TypeError("Cannot call a class as a function")}function a(d,p){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p&&(typeof p=="object"||typeof p=="function")?p:d}function l(d,p){if(typeof p!="function"&&p!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof p);d.prototype=Object.create(p&&p.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),p&&(Object.setPrototypeOf?Object.setPrototypeOf(d,p):d.__proto__=p)}var c=function(p){var u=p.substr(0,7).split("").map(function(f){return+f}).reduce(function(f,m,g){return g%2?f+m:f+m*3},0);return(10-u%10)%10},s=(function(d){l(p,d);function p(u,f){return i(this,p),u.search(/^[0-9]{7}$/)!==-1&&(u+=c(u)),a(this,(p.__proto__||Object.getPrototypeOf(p)).call(this,u,f))}return e(p,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===c(this.data)}},{key:"leftText",value:function(){return t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"leftText",this).call(this,0,4)}},{key:"leftEncode",value:function(){var f=this.data.substr(0,4);return t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"leftEncode",this).call(this,f,"LLLL")}},{key:"rightText",value:function(){return t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"rightText",this).call(this,4,4)}},{key:"rightEncode",value:function(){var f=this.data.substr(4,4);return t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"rightEncode",this).call(this,f,"RRRR")}}]),p})(r.default);return vo.default=s,vo}var wo={},Rd;function ib(){if(Rd)return wo;Rd=1,Object.defineProperty(wo,"__esModule",{value:!0});var e=(function(){function u(f,m){for(var g=0;g<m.length;g++){var b=m[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(f,b.key,b)}}return function(f,m,g){return m&&u(f.prototype,m),g&&u(f,g),f}})(),t=ar(),n=sr(),r=a(n),o=Ve(),i=a(o);function a(u){return u&&u.__esModule?u:{default:u}}function l(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function c(u,f){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f&&(typeof f=="object"||typeof f=="function")?f:u}function s(u,f){if(typeof f!="function"&&f!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof f);u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),f&&(Object.setPrototypeOf?Object.setPrototypeOf(u,f):u.__proto__=f)}var d=function(f){var m=f.split("").map(function(g){return+g}).reduce(function(g,b,v){return v%2?g+b*9:g+b*3},0);return m%10},p=(function(u){s(f,u);function f(m,g){return l(this,f),c(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,m,g))}return e(f,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var g=t.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,r.default)(this.data,g,"01"),text:this.text}}}]),f})(i.default);return wo.default=p,wo}var xo={},Dd;function ab(){if(Dd)return xo;Dd=1,Object.defineProperty(xo,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var m=0;m<f.length;m++){var g=f[m];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(u,g.key,g)}}return function(u,f,m){return f&&p(u.prototype,f),m&&p(u,m),u}})(),t=ar(),n=sr(),r=a(n),o=Ve(),i=a(o);function a(p){return p&&p.__esModule?p:{default:p}}function l(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function c(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function s(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var d=(function(p){s(u,p);function u(f,m){return l(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,m))}return e(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var m=t.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,r.default)(this.data,m,"01"),text:this.text}}}]),u})(i.default);return xo.default=d,xo}var lr={},$d;function Ld(){if($d)return lr;$d=1,Object.defineProperty(lr,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var m=0;m<f.length;m++){var g=f[m];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(u,g.key,g)}}return function(u,f,m){return f&&p(u.prototype,f),m&&p(u,m),u}})();lr.checksum=d;var t=sr(),n=i(t),r=Ve(),o=i(r);function i(p){return p&&p.__esModule?p:{default:p}}function a(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function l(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function c(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var s=(function(p){c(u,p);function u(f,m){a(this,u),f.search(/^[0-9]{11}$/)!==-1&&(f+=d(f));var g=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,m));return g.displayValue=m.displayValue,m.fontSize>m.width*10?g.fontSize=m.width*10:g.fontSize=m.fontSize,g.guardHeight=m.height+g.fontSize/2+m.textMargin,g}return e(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==d(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var m="";return m+="101",m+=(0,n.default)(this.data.substr(0,6),"LLLLLL"),m+="01010",m+=(0,n.default)(this.data.substr(6,6),"RRRRRR"),m+="101",{data:m,text:this.text}}},{key:"guardedEncoding",value:function(){var m=[];return this.displayValue&&m.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),m.push({data:"101"+(0,n.default)(this.data[0],"L"),options:{height:this.guardHeight}}),m.push({data:(0,n.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),m.push({data:"01010",options:{height:this.guardHeight}}),m.push({data:(0,n.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),m.push({data:(0,n.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&m.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),m}}]),u})(o.default);function d(p){var u=0,f;for(f=1;f<11;f+=2)u+=parseInt(p[f]);for(f=0;f<11;f+=2)u+=parseInt(p[f])*3;return(10-u%10)%10}return lr.default=s,lr}var Eo={},Nd;function sb(){if(Nd)return Eo;Nd=1,Object.defineProperty(Eo,"__esModule",{value:!0});var e=(function(){function m(g,b){for(var v=0;v<b.length;v++){var w=b[v];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(g,w.key,w)}}return function(g,b,v){return b&&m(g.prototype,b),v&&m(g,v),g}})(),t=sr(),n=a(t),r=Ve(),o=a(r),i=Ld();function a(m){return m&&m.__esModule?m:{default:m}}function l(m,g){if(!(m instanceof g))throw new TypeError("Cannot call a class as a function")}function c(m,g){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:m}function s(m,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);m.prototype=Object.create(g&&g.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(m,g):m.__proto__=g)}var d=["XX00000XXX","XX10000XXX","XX20000XXX","XXX00000XX","XXXX00000X","XXXXX00005","XXXXX00006","XXXXX00007","XXXXX00008","XXXXX00009"],p=[["EEEOOO","OOOEEE"],["EEOEOO","OOEOEE"],["EEOOEO","OOEEOE"],["EEOOOE","OOEEEO"],["EOEEOO","OEOOEE"],["EOOEEO","OEEOOE"],["EOOOEE","OEEEOO"],["EOEOEO","OEOEOE"],["EOEOOE","OEOEEO"],["EOOEOE","OEEOEO"]],u=(function(m){s(g,m);function g(b,v){l(this,g);var w=c(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,b,v));if(w.isValid=!1,b.search(/^[0-9]{6}$/)!==-1)w.middleDigits=b,w.upcA=f(b,"0"),w.text=v.text||""+w.upcA[0]+b+w.upcA[w.upcA.length-1],w.isValid=!0;else if(b.search(/^[01][0-9]{7}$/)!==-1)if(w.middleDigits=b.substring(1,b.length-1),w.upcA=f(w.middleDigits,b[0]),w.upcA[w.upcA.length-1]===b[b.length-1])w.isValid=!0;else return c(w);else return c(w);return w.displayValue=v.displayValue,v.fontSize>v.width*10?w.fontSize=v.width*10:w.fontSize=v.fontSize,w.guardHeight=v.height+w.fontSize/2+v.textMargin,w}return e(g,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var v="";return v+="101",v+=this.encodeMiddleDigits(),v+="010101",{data:v,text:this.text}}},{key:"guardedEncoding",value:function(){var v=[];return this.displayValue&&v.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),v.push({data:"101",options:{height:this.guardHeight}}),v.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),v.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&v.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),v}},{key:"encodeMiddleDigits",value:function(){var v=this.upcA[0],w=this.upcA[this.upcA.length-1],_=p[parseInt(w)][parseInt(v)];return(0,n.default)(this.middleDigits,_)}}]),g})(o.default);function f(m,g){for(var b=parseInt(m[m.length-1]),v=d[b],w="",_=0,M=0;M<v.length;M++){var N=v[M];N==="X"?w+=m[_++]:w+=N}return w=""+g+w,""+w+(0,i.checksum)(w)}return Eo.default=u,Eo}var Fd;function lb(){if(Fd)return Ne;Fd=1,Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.UPCE=Ne.UPC=Ne.EAN2=Ne.EAN5=Ne.EAN8=Ne.EAN13=void 0;var e=rb(),t=u(e),n=ob(),r=u(n),o=ib(),i=u(o),a=ab(),l=u(a),c=Ld(),s=u(c),d=sb(),p=u(d);function u(f){return f&&f.__esModule?f:{default:f}}return Ne.EAN13=t.default,Ne.EAN8=r.default,Ne.EAN5=i.default,Ne.EAN2=l.default,Ne.UPC=s.default,Ne.UPCE=p.default,Ne}var Vt={},So={},bn={},zd;function cb(){return zd||(zd=1,Object.defineProperty(bn,"__esModule",{value:!0}),bn.START_BIN="1010",bn.END_BIN="11101",bn.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),bn}var Bd;function Hd(){if(Bd)return So;Bd=1,Object.defineProperty(So,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=cb(),n=Ve(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return e(d,[{key:"valid",value:function(){return this.data.search(/^([0-9]{2})+$/)!==-1}},{key:"encode",value:function(){var u=this,f=this.data.match(/.{2}/g).map(function(m){return u.encodePair(m)}).join("");return{data:t.START_BIN+f+t.END_BIN,text:this.text}}},{key:"encodePair",value:function(u){var f=t.BINARIES[u[1]];return t.BINARIES[u[0]].split("").map(function(m,g){return(m==="1"?"111":"1")+(f[g]==="1"?"000":"0")}).join("")}}]),d})(r.default);return So.default=c,So}var _o={},Ud;function db(){if(Ud)return _o;Ud=1,Object.defineProperty(_o,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=Hd(),n=r(t);function r(s){return s&&s.__esModule?s:{default:s}}function o(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function i(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function a(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var l=function(d){var p=d.substr(0,13).split("").map(function(u){return parseInt(u,10)}).reduce(function(u,f,m){return u+f*(3-m%2*2)},0);return Math.ceil(p/10)*10-p},c=(function(s){a(d,s);function d(p,u){return o(this,d),p.search(/^[0-9]{13}$/)!==-1&&(p+=l(p)),i(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return e(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===l(this.data)}}]),d})(n.default);return _o.default=c,_o}var qd;function ub(){if(qd)return Vt;qd=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.ITF14=Vt.ITF=void 0;var e=Hd(),t=o(e),n=db(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return Vt.ITF=t.default,Vt.ITF14=r.default,Vt}var Ye={},Mo={},Wd;function cr(){if(Wd)return Mo;Wd=1,Object.defineProperty(Mo,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=Ve(),n=r(t);function r(s){return s&&s.__esModule?s:{default:s}}function o(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function i(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function a(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var l=(function(s){a(d,s);function d(p,u){return o(this,d),i(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return e(d,[{key:"encode",value:function(){for(var u="110",f=0;f<this.data.length;f++){var m=parseInt(this.data[f]),g=m.toString(2);g=c(g,4-g.length);for(var b=0;b<g.length;b++)u+=g[b]=="0"?"100":"110"}return u+="1001",{data:u,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),d})(n.default);function c(s,d){for(var p=0;p<d;p++)s="0"+s;return s}return Mo.default=l,Mo}var To={},dr={},jd;function ko(){if(jd)return dr;jd=1,Object.defineProperty(dr,"__esModule",{value:!0}),dr.mod10=e,dr.mod11=t;function e(n){for(var r=0,o=0;o<n.length;o++){var i=parseInt(n[o]);(o+n.length)%2===0?r+=i:r+=i*2%10+Math.floor(i*2/10)}return(10-r%10)%10}function t(n){for(var r=0,o=[2,3,4,5,6,7],i=0;i<n.length;i++){var a=parseInt(n[n.length-1-i]);r+=o[i%o.length]*a}return(11-r%11)%11}return dr}var Gd;function pb(){if(Gd)return To;Gd=1,Object.defineProperty(To,"__esModule",{value:!0});var e=cr(),t=r(e),n=ko();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d+(0,n.mod10)(d),p))}return s})(t.default);return To.default=l,To}var Co={},Vd;function fb(){if(Vd)return Co;Vd=1,Object.defineProperty(Co,"__esModule",{value:!0});var e=cr(),t=r(e),n=ko();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d+(0,n.mod11)(d),p))}return s})(t.default);return Co.default=l,Co}var Ao={},Yd;function hb(){if(Yd)return Ao;Yd=1,Object.defineProperty(Ao,"__esModule",{value:!0});var e=cr(),t=r(e),n=ko();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),d+=(0,n.mod10)(d),d+=(0,n.mod10)(d),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return s})(t.default);return Ao.default=l,Ao}var Oo={},Xd;function gb(){if(Xd)return Oo;Xd=1,Object.defineProperty(Oo,"__esModule",{value:!0});var e=cr(),t=r(e),n=ko();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),d+=(0,n.mod11)(d),d+=(0,n.mod10)(d),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return s})(t.default);return Oo.default=l,Oo}var Kd;function mb(){if(Kd)return Ye;Kd=1,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.MSI1110=Ye.MSI1010=Ye.MSI11=Ye.MSI10=Ye.MSI=void 0;var e=cr(),t=d(e),n=pb(),r=d(n),o=fb(),i=d(o),a=hb(),l=d(a),c=gb(),s=d(c);function d(p){return p&&p.__esModule?p:{default:p}}return Ye.MSI=t.default,Ye.MSI10=r.default,Ye.MSI11=i.default,Ye.MSI1010=l.default,Ye.MSI1110=s.default,Ye}var ur={},Zd;function bb(){if(Zd)return ur;Zd=1,Object.defineProperty(ur,"__esModule",{value:!0}),ur.pharmacode=void 0;var e=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),t=Ve(),n=r(t);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){o(this,s);var u=i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p));return u.number=parseInt(d,10),u}return e(s,[{key:"encode",value:function(){for(var p=this.number,u="";!isNaN(p)&&p!=0;)p%2===0?(u="11100"+u,p=(p-2)/2):(u="100"+u,p=(p-1)/2);return u=u.slice(0,-2),{data:u,text:this.text}}},{key:"valid",value:function(){return this.number>=3&&this.number<=131070}}]),s})(n.default);return ur.pharmacode=l,ur}var pr={},Jd;function yb(){if(Jd)return pr;Jd=1,Object.defineProperty(pr,"__esModule",{value:!0}),pr.codabar=void 0;var e=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),t=Ve(),n=r(t);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){o(this,s),d.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(d="A"+d+"A");var u=i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d.toUpperCase(),p));return u.text=u.options.text||u.text.replace(/[A-D]/g,""),u}return e(s,[{key:"valid",value:function(){return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)!==-1}},{key:"encode",value:function(){for(var p=[],u=this.getEncodings(),f=0;f<this.data.length;f++)p.push(u[this.data.charAt(f)]),f!==this.data.length-1&&p.push("0");return{text:this.text,data:p.join("")}}},{key:"getEncodings",value:function(){return{0:"101010011",1:"101011001",2:"101001011",3:"110010101",4:"101101001",5:"110101001",6:"100101011",7:"100101101",8:"100110101",9:"110100101","-":"101001101",$:"101100101",":":"1101011011","/":"1101101011",".":"1101101101","+":"1011011011",A:"1011001001",B:"1001001011",C:"1010010011",D:"1010011001"}}}]),s})(n.default);return pr.codabar=l,pr}var Yt={},Io={},yn={},Qd;function vb(){return Qd||(Qd=1,Object.defineProperty(yn,"__esModule",{value:!0}),yn.SYMBOLS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],yn.BINARIES=["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010","101011110"],yn.MULTI_SYMBOLS={"\0":["(%)","U"],"":["($)","A"],"":["($)","B"],"":["($)","C"],"":["($)","D"],"":["($)","E"],"":["($)","F"],"\x07":["($)","G"],"\b":["($)","H"]," ":["($)","I"],"\n":["($)","J"],"\v":["($)","K"],"\f":["($)","L"],"\r":["($)","M"],"":["($)","N"],"":["($)","O"],"":["($)","P"],"":["($)","Q"],"":["($)","R"],"":["($)","S"],"":["($)","T"],"":["($)","U"],"":["($)","V"],"":["($)","W"],"":["($)","X"],"":["($)","Y"],"":["($)","Z"],"\x1B":["(%)","A"],"":["(%)","B"],"":["(%)","C"],"":["(%)","D"],"":["(%)","E"],"!":["(/)","A"],'"':["(/)","B"],"#":["(/)","C"],"&":["(/)","F"],"'":["(/)","G"],"(":["(/)","H"],")":["(/)","I"],"*":["(/)","J"],",":["(/)","L"],":":["(/)","Z"],";":["(%)","F"],"<":["(%)","G"],"=":["(%)","H"],">":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),yn}var eu;function tu(){if(eu)return Io;eu=1,Object.defineProperty(Io,"__esModule",{value:!0});var e=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),t=vb(),n=Ve(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return e(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var u=this.data.split("").flatMap(function(b){return t.MULTI_SYMBOLS[b]||b}),f=u.map(function(b){return d.getEncoding(b)}).join(""),m=d.checksum(u,20),g=d.checksum(u.concat(m),15);return{text:this.text,data:d.getEncoding("ÿ")+f+d.getEncoding(m)+d.getEncoding(g)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(u){return t.BINARIES[d.symbolValue(u)]}},{key:"getSymbol",value:function(u){return t.SYMBOLS[u]}},{key:"symbolValue",value:function(u){return t.SYMBOLS.indexOf(u)}},{key:"checksum",value:function(u,f){var m=u.slice().reverse().reduce(function(g,b,v){var w=v%f+1;return g+d.symbolValue(b)*w},0);return d.getSymbol(m%47)}}]),d})(r.default);return Io.default=c,Io}var Po={},nu;function wb(){if(nu)return Po;nu=1,Object.defineProperty(Po,"__esModule",{value:!0});var e=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),t=tu(),n=r(t);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return e(s,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),s})(n.default);return Po.default=l,Po}var ru;function xb(){if(ru)return Yt;ru=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.CODE93FullASCII=Yt.CODE93=void 0;var e=tu(),t=o(e),n=wb(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return Yt.CODE93=t.default,Yt.CODE93FullASCII=r.default,Yt}var fr={},ou;function Eb(){if(ou)return fr;ou=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.GenericBarcode=void 0;var e=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),t=Ve(),n=r(t);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return e(s,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),s})(n.default);return fr.GenericBarcode=l,fr}var iu;function Sb(){if(iu)return ao;iu=1,Object.defineProperty(ao,"__esModule",{value:!0});var e=K0(),t=nb(),n=lb(),r=ub(),o=mb(),i=bb(),a=yb(),l=xb(),c=Eb();return ao.default={CODE39:e.CODE39,CODE128:t.CODE128,CODE128A:t.CODE128A,CODE128B:t.CODE128B,CODE128C:t.CODE128C,EAN13:n.EAN13,EAN8:n.EAN8,EAN5:n.EAN5,EAN2:n.EAN2,UPC:n.UPC,UPCE:n.UPCE,ITF14:r.ITF14,ITF:r.ITF,MSI:o.MSI,MSI10:o.MSI10,MSI11:o.MSI11,MSI1010:o.MSI1010,MSI1110:o.MSI1110,pharmacode:i.pharmacode,codabar:a.codabar,CODE93:l.CODE93,CODE93FullASCII:l.CODE93FullASCII,GenericBarcode:c.GenericBarcode},ao}var Ro={},au;function Do(){if(au)return Ro;au=1,Object.defineProperty(Ro,"__esModule",{value:!0});var e=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t};return Ro.default=function(t,n){return e({},t,n)},Ro}var $o={},su;function _b(){if(su)return $o;su=1,Object.defineProperty($o,"__esModule",{value:!0}),$o.default=e;function e(t){var n=[];function r(o){if(Array.isArray(o))for(var i=0;i<o.length;i++)r(o[i]);else o.text=o.text||"",o.data=o.data||"",n.push(o)}return r(t),n}return $o}var Lo={},lu;function Mb(){if(lu)return Lo;lu=1,Object.defineProperty(Lo,"__esModule",{value:!0}),Lo.default=e;function e(t){return t.marginTop=t.marginTop||t.margin,t.marginBottom=t.marginBottom||t.margin,t.marginRight=t.marginRight||t.margin,t.marginLeft=t.marginLeft||t.margin,t}return Lo}var No={},Fo={},zo={},cu;function du(){if(cu)return zo;cu=1,Object.defineProperty(zo,"__esModule",{value:!0}),zo.default=e;function e(t){var n=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var r in n)n.hasOwnProperty(r)&&(r=n[r],typeof t[r]=="string"&&(t[r]=parseInt(t[r],10)));return typeof t.displayValue=="string"&&(t.displayValue=t.displayValue!="false"),t}return zo}var Bo={},uu;function pu(){if(uu)return Bo;uu=1,Object.defineProperty(Bo,"__esModule",{value:!0});var e={width:2,height:100,format:"auto",displayValue:!0,fontOptions:"",font:"monospace",text:void 0,textAlign:"center",textPosition:"bottom",textMargin:2,fontSize:20,background:"#ffffff",lineColor:"#000000",margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}};return Bo.default=e,Bo}var fu;function Tb(){if(fu)return Fo;fu=1,Object.defineProperty(Fo,"__esModule",{value:!0});var e=du(),t=o(e),n=pu(),r=o(n);function o(a){return a&&a.__esModule?a:{default:a}}function i(a){var l={};for(var c in r.default)r.default.hasOwnProperty(c)&&(a.hasAttribute("jsbarcode-"+c.toLowerCase())&&(l[c]=a.getAttribute("jsbarcode-"+c.toLowerCase())),a.hasAttribute("data-"+c.toLowerCase())&&(l[c]=a.getAttribute("data-"+c.toLowerCase())));return l.value=a.getAttribute("jsbarcode-value")||a.getAttribute("data-value"),l=(0,t.default)(l),l}return Fo.default=i,Fo}var Ho={},Uo={},Xe={},hu;function gu(){if(hu)return Xe;hu=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.getTotalWidthOfEncodings=Xe.calculateEncodingAttributes=Xe.getBarcodePadding=Xe.getEncodingHeight=Xe.getMaximumHeightOfEncodings=void 0;var e=Do(),t=n(e);function n(s){return s&&s.__esModule?s:{default:s}}function r(s,d){return d.height+(d.displayValue&&s.text.length>0?d.fontSize+d.textMargin:0)+d.marginTop+d.marginBottom}function o(s,d,p){if(p.displayValue&&d<s){if(p.textAlign=="center")return Math.floor((s-d)/2);if(p.textAlign=="left")return 0;if(p.textAlign=="right")return Math.floor(s-d)}return 0}function i(s,d,p){for(var u=0;u<s.length;u++){var f=s[u],m=(0,t.default)(d,f.options),g;m.displayValue?g=c(f.text,m,p):g=0;var b=f.data.length*m.width;f.width=Math.ceil(Math.max(g,b)),f.height=r(f,m),f.barcodePadding=o(g,b,m)}}function a(s){for(var d=0,p=0;p<s.length;p++)d+=s[p].width;return d}function l(s){for(var d=0,p=0;p<s.length;p++)s[p].height>d&&(d=s[p].height);return d}function c(s,d,p){var u;if(p)u=p;else if(typeof document<"u")u=document.createElement("canvas").getContext("2d");else return 0;u.font=d.fontOptions+" "+d.fontSize+"px "+d.font;var f=u.measureText(s);if(!f)return 0;var m=f.width;return m}return Xe.getMaximumHeightOfEncodings=l,Xe.getEncodingHeight=r,Xe.getBarcodePadding=o,Xe.calculateEncodingAttributes=i,Xe.getTotalWidthOfEncodings=a,Xe}var mu;function kb(){if(mu)return Uo;mu=1,Object.defineProperty(Uo,"__esModule",{value:!0});var e=(function(){function l(c,s){for(var d=0;d<s.length;d++){var p=s[d];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(c,p.key,p)}}return function(c,s,d){return s&&l(c.prototype,s),d&&l(c,d),c}})(),t=Do(),n=o(t),r=gu();function o(l){return l&&l.__esModule?l:{default:l}}function i(l,c){if(!(l instanceof c))throw new TypeError("Cannot call a class as a function")}var a=(function(){function l(c,s,d){i(this,l),this.canvas=c,this.encodings=s,this.options=d}return e(l,[{key:"render",value:function(){if(!this.canvas.getContext)throw new Error("The browser does not support canvas.");this.prepareCanvas();for(var s=0;s<this.encodings.length;s++){var d=(0,n.default)(this.options,this.encodings[s].options);this.drawCanvasBarcode(d,this.encodings[s]),this.drawCanvasText(d,this.encodings[s]),this.moveCanvasDrawing(this.encodings[s])}this.restoreCanvas()}},{key:"prepareCanvas",value:function(){var s=this.canvas.getContext("2d");s.save(),(0,r.calculateEncodingAttributes)(this.encodings,this.options,s);var d=(0,r.getTotalWidthOfEncodings)(this.encodings),p=(0,r.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=d+this.options.marginLeft+this.options.marginRight,this.canvas.height=p,s.clearRect(0,0,this.canvas.width,this.canvas.height),this.options.background&&(s.fillStyle=this.options.background,s.fillRect(0,0,this.canvas.width,this.canvas.height)),s.translate(this.options.marginLeft,0)}},{key:"drawCanvasBarcode",value:function(s,d){var p=this.canvas.getContext("2d"),u=d.data,f;s.textPosition=="top"?f=s.marginTop+s.fontSize+s.textMargin:f=s.marginTop,p.fillStyle=s.lineColor;for(var m=0;m<u.length;m++){var g=m*s.width+d.barcodePadding;u[m]==="1"?p.fillRect(g,f,s.width,s.height):u[m]&&p.fillRect(g,f,s.width,s.height*u[m])}}},{key:"drawCanvasText",value:function(s,d){var p=this.canvas.getContext("2d"),u=s.fontOptions+" "+s.fontSize+"px "+s.font;if(s.displayValue){var f,m;s.textPosition=="top"?m=s.marginTop+s.fontSize-s.textMargin:m=s.height+s.textMargin+s.marginTop+s.fontSize,p.font=u,s.textAlign=="left"||d.barcodePadding>0?(f=0,p.textAlign="left"):s.textAlign=="right"?(f=d.width-1,p.textAlign="right"):(f=d.width/2,p.textAlign="center"),p.fillText(d.text,f,m)}}},{key:"moveCanvasDrawing",value:function(s){var d=this.canvas.getContext("2d");d.translate(s.width,0)}},{key:"restoreCanvas",value:function(){var s=this.canvas.getContext("2d");s.restore()}}]),l})();return Uo.default=a,Uo}var qo={},bu;function Cb(){if(bu)return qo;bu=1,Object.defineProperty(qo,"__esModule",{value:!0});var e=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),t=Do(),n=o(t),r=gu();function o(c){return c&&c.__esModule?c:{default:c}}function i(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}var a="http://www.w3.org/2000/svg",l=(function(){function c(s,d,p){i(this,c),this.svg=s,this.encodings=d,this.options=p,this.document=p.xmlDocument||document}return e(c,[{key:"render",value:function(){var d=this.options.marginLeft;this.prepareSVG();for(var p=0;p<this.encodings.length;p++){var u=this.encodings[p],f=(0,n.default)(this.options,u.options),m=this.createGroup(d,f.marginTop,this.svg);this.setGroupOptions(m,f),this.drawSvgBarcode(m,f,u),this.drawSVGText(m,f,u),d+=u.width}}},{key:"prepareSVG",value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,r.calculateEncodingAttributes)(this.encodings,this.options);var d=(0,r.getTotalWidthOfEncodings)(this.encodings),p=(0,r.getMaximumHeightOfEncodings)(this.encodings),u=d+this.options.marginLeft+this.options.marginRight;this.setSvgAttributes(u,p),this.options.background&&this.drawRect(0,0,u,p,this.svg).setAttribute("fill",this.options.background)}},{key:"drawSvgBarcode",value:function(d,p,u){var f=u.data,m;p.textPosition=="top"?m=p.fontSize+p.textMargin:m=0;for(var g=0,b=0,v=0;v<f.length;v++)b=v*p.width+u.barcodePadding,f[v]==="1"?g++:g>0&&(this.drawRect(b-p.width*g,m,p.width*g,p.height,d),g=0);g>0&&this.drawRect(b-p.width*(g-1),m,p.width*g,p.height,d)}},{key:"drawSVGText",value:function(d,p,u){var f=this.document.createElementNS(a,"text");if(p.displayValue){var m,g;f.setAttribute("font-family",p.font),f.setAttribute("font-size",p.fontSize),p.fontOptions.includes("bold")&&f.setAttribute("font-weight","bold"),p.fontOptions.includes("italic")&&f.setAttribute("font-style","italic"),p.textPosition=="top"?g=p.fontSize-p.textMargin:g=p.height+p.textMargin+p.fontSize,p.textAlign=="left"||u.barcodePadding>0?(m=0,f.setAttribute("text-anchor","start")):p.textAlign=="right"?(m=u.width-1,f.setAttribute("text-anchor","end")):(m=u.width/2,f.setAttribute("text-anchor","middle")),f.setAttribute("x",m),f.setAttribute("y",g),f.appendChild(this.document.createTextNode(u.text)),d.appendChild(f)}}},{key:"setSvgAttributes",value:function(d,p){var u=this.svg;u.setAttribute("width",d+"px"),u.setAttribute("height",p+"px"),u.setAttribute("x","0px"),u.setAttribute("y","0px"),u.setAttribute("viewBox","0 0 "+d+" "+p),u.setAttribute("xmlns",a),u.setAttribute("version","1.1")}},{key:"createGroup",value:function(d,p,u){var f=this.document.createElementNS(a,"g");return f.setAttribute("transform","translate("+d+", "+p+")"),u.appendChild(f),f}},{key:"setGroupOptions",value:function(d,p){d.setAttribute("fill",p.lineColor)}},{key:"drawRect",value:function(d,p,u,f,m){var g=this.document.createElementNS(a,"rect");return g.setAttribute("x",d),g.setAttribute("y",p),g.setAttribute("width",u),g.setAttribute("height",f),m.appendChild(g),g}}]),c})();return qo.default=l,qo}var Wo={},yu;function Ab(){if(yu)return Wo;yu=1,Object.defineProperty(Wo,"__esModule",{value:!0});var e=(function(){function r(o,i){for(var a=0;a<i.length;a++){var l=i[a];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}return function(o,i,a){return i&&r(o.prototype,i),a&&r(o,a),o}})();function t(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o,i,a){t(this,r),this.object=o,this.encodings=i,this.options=a}return e(r,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),r})();return Wo.default=n,Wo}var vu;function Ob(){if(vu)return Ho;vu=1,Object.defineProperty(Ho,"__esModule",{value:!0});var e=kb(),t=a(e),n=Cb(),r=a(n),o=Ab(),i=a(o);function a(l){return l&&l.__esModule?l:{default:l}}return Ho.default={CanvasRenderer:t.default,SVGRenderer:r.default,ObjectRenderer:i.default},Ho}var vn={},wu;function xu(){if(wu)return vn;wu=1,Object.defineProperty(vn,"__esModule",{value:!0});function e(a,l){if(!(a instanceof l))throw new TypeError("Cannot call a class as a function")}function t(a,l){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return l&&(typeof l=="object"||typeof l=="function")?l:a}function n(a,l){if(typeof l!="function"&&l!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof l);a.prototype=Object.create(l&&l.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),l&&(Object.setPrototypeOf?Object.setPrototypeOf(a,l):a.__proto__=l)}var r=(function(a){n(l,a);function l(c,s){e(this,l);var d=t(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return d.name="InvalidInputException",d.symbology=c,d.input=s,d.message='"'+d.input+'" is not a valid input for '+d.symbology,d}return l})(Error),o=(function(a){n(l,a);function l(){e(this,l);var c=t(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return c.name="InvalidElementException",c.message="Not supported type to render on",c}return l})(Error),i=(function(a){n(l,a);function l(){e(this,l);var c=t(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return c.name="NoElementException",c.message="No element to render on.",c}return l})(Error);return vn.InvalidInputException=r,vn.InvalidElementException=o,vn.NoElementException=i,vn}var Eu;function Ib(){if(Eu)return No;Eu=1,Object.defineProperty(No,"__esModule",{value:!0});var e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},t=Tb(),n=a(t),r=Ob(),o=a(r),i=xu();function a(d){return d&&d.__esModule?d:{default:d}}function l(d){if(typeof d=="string")return c(d);if(Array.isArray(d)){for(var p=[],u=0;u<d.length;u++)p.push(l(d[u]));return p}else{if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLImageElement)return s(d);if(d&&d.nodeName&&d.nodeName.toLowerCase()==="svg"||typeof SVGElement<"u"&&d instanceof SVGElement)return{element:d,options:(0,n.default)(d),renderer:o.default.SVGRenderer};if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement)return{element:d,options:(0,n.default)(d),renderer:o.default.CanvasRenderer};if(d&&d.getContext)return{element:d,renderer:o.default.CanvasRenderer};if(d&&(typeof d>"u"?"undefined":e(d))==="object"&&!d.nodeName)return{element:d,renderer:o.default.ObjectRenderer};throw new i.InvalidElementException}}function c(d){var p=document.querySelectorAll(d);if(p.length!==0){for(var u=[],f=0;f<p.length;f++)u.push(l(p[f]));return u}}function s(d){var p=document.createElement("canvas");return{element:p,options:(0,n.default)(d),renderer:o.default.CanvasRenderer,afterRender:function(){d.setAttribute("src",p.toDataURL())}}}return No.default=l,No}var jo={},Su;function Pb(){if(Su)return jo;Su=1,Object.defineProperty(jo,"__esModule",{value:!0});var e=(function(){function r(o,i){for(var a=0;a<i.length;a++){var l=i[a];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}return function(o,i,a){return i&&r(o.prototype,i),a&&r(o,a),o}})();function t(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o){t(this,r),this.api=o}return e(r,[{key:"handleCatch",value:function(i){if(i.name==="InvalidInputException")if(this.api._options.valid!==this.api._defaults.valid)this.api._options.valid(!1);else throw i.message;else throw i;this.api.render=function(){}}},{key:"wrapBarcodeCall",value:function(i){try{var a=i.apply(void 0,arguments);return this.api._options.valid(!0),a}catch(l){return this.handleCatch(l),this.api}}}]),r})();return jo.default=n,jo}var Ma,_u;function Rb(){if(_u)return Ma;_u=1;var e=Sb(),t=v(e),n=Do(),r=v(n),o=_b(),i=v(o),a=Mb(),l=v(a),c=Ib(),s=v(c),d=du(),p=v(d),u=Pb(),f=v(u),m=xu(),g=pu(),b=v(g);function v(S){return S&&S.__esModule?S:{default:S}}var w=function(){},_=function(C,k,$){var P=new w;if(typeof C>"u")throw Error("No element to render on was provided.");return P._renderProperties=(0,s.default)(C),P._encodings=[],P._options=b.default,P._errorHandler=new f.default(P),typeof k<"u"&&($=$||{},$.format||($.format=D()),P.options($)[$.format](k,$).render()),P};_.getModule=function(S){return t.default[S]};for(var M in t.default)t.default.hasOwnProperty(M)&&N(t.default,M);function N(S,C){w.prototype[C]=w.prototype[C.toUpperCase()]=w.prototype[C.toLowerCase()]=function(k,$){var P=this;return P._errorHandler.wrapBarcodeCall(function(){$.text=typeof $.text>"u"?void 0:""+$.text;var x=(0,r.default)(P._options,$);x=(0,p.default)(x);var Y=S[C],le=R(k,Y,x);return P._encodings.push(le),P})}}function R(S,C,k){S=""+S;var $=new C(S,k);if(!$.valid())throw new m.InvalidInputException($.constructor.name,S);var P=$.encode();P=(0,i.default)(P);for(var x=0;x<P.length;x++)P[x].options=(0,r.default)(k,P[x].options);return P}function D(){return t.default.CODE128?"CODE128":Object.keys(t.default)[0]}w.prototype.options=function(S){return this._options=(0,r.default)(this._options,S),this},w.prototype.blank=function(S){var C=new Array(S+1).join("0");return this._encodings.push({data:C}),this},w.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var S;for(var C in this._renderProperties){S=this._renderProperties[C];var k=(0,r.default)(this._options,S.options);k.format=="auto"&&(k.format=D()),this._errorHandler.wrapBarcodeCall(function(){var $=k.value,P=t.default[k.format.toUpperCase()],x=R($,P,k);I(S,x,k)})}}},w.prototype.render=function(){if(!this._renderProperties)throw new m.NoElementException;if(Array.isArray(this._renderProperties))for(var S=0;S<this._renderProperties.length;S++)I(this._renderProperties[S],this._encodings,this._options);else I(this._renderProperties,this._encodings,this._options);return this},w.prototype._defaults=b.default;function I(S,C,k){C=(0,i.default)(C);for(var $=0;$<C.length;$++)C[$].options=(0,r.default)(k,C[$].options),(0,l.default)(C[$].options);(0,l.default)(k);var P=S.renderer,x=new P(S.element,C,k);x.render(),S.afterRender&&S.afterRender()}return typeof window<"u"&&(window.JsBarcode=_),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(S,C){var k=[];return jQuery(this).each(function(){k.push(this)}),_(k,S,C)}),Ma=_,Ma}var Db=Rb();const Ta=md(Db);var wn={},ka,Mu;function $b(){return Mu||(Mu=1,ka=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ka}var Ca={},Rt={},Tu;function Xt(){if(Tu)return Rt;Tu=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Rt.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},Rt.getSymbolTotalCodewords=function(r){return t[r]},Rt.getBCHDigit=function(n){let r=0;for(;n!==0;)r++,n>>>=1;return r},Rt.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');e=r},Rt.isKanjiModeEnabled=function(){return typeof e<"u"},Rt.toSJIS=function(r){return e(r)},Rt}var Aa={},ku;function Oa(){return ku||(ku=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,o){if(e.isValid(r))return r;try{return t(r)}catch{return o}}})(Aa)),Aa}var Ia,Cu;function Lb(){if(Cu)return Ia;Cu=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let r=0;r<n;r++)this.putBit((t>>>n-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},Ia=e,Ia}var Pa,Au;function Nb(){if(Au)return Pa;Au=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,n,r,o){const i=t*this.size+n;this.data[i]=r,o&&(this.reservedBit[i]=!0)},e.prototype.get=function(t,n){return this.data[t*this.size+n]},e.prototype.xor=function(t,n,r){this.data[t*this.size+n]^=r},e.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]},Pa=e,Pa}var Ra={},Ou;function Fb(){return Ou||(Ou=1,(function(e){const t=Xt().getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const o=Math.floor(r/7)+2,i=t(r),a=i===145?26:Math.ceil((i-13)/(2*o-2))*2,l=[i-7];for(let c=1;c<o-1;c++)l[c]=l[c-1]-a;return l.push(6),l.reverse()},e.getPositions=function(r){const o=[],i=e.getRowColCoords(r),a=i.length;for(let l=0;l<a;l++)for(let c=0;c<a;c++)l===0&&c===0||l===0&&c===a-1||l===a-1&&c===0||o.push([i[l],i[c]]);return o}})(Ra)),Ra}var Da={},Iu;function zb(){if(Iu)return Da;Iu=1;const e=Xt().getSymbolSize,t=7;return Da.getPositions=function(r){const o=e(r);return[[0,0],[o-t,0],[0,o-t]]},Da}var $a={},Pu;function Bb(){return Pu||(Pu=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const i=o.size;let a=0,l=0,c=0,s=null,d=null;for(let p=0;p<i;p++){l=c=0,s=d=null;for(let u=0;u<i;u++){let f=o.get(p,u);f===s?l++:(l>=5&&(a+=t.N1+(l-5)),s=f,l=1),f=o.get(u,p),f===d?c++:(c>=5&&(a+=t.N1+(c-5)),d=f,c=1)}l>=5&&(a+=t.N1+(l-5)),c>=5&&(a+=t.N1+(c-5))}return a},e.getPenaltyN2=function(o){const i=o.size;let a=0;for(let l=0;l<i-1;l++)for(let c=0;c<i-1;c++){const s=o.get(l,c)+o.get(l,c+1)+o.get(l+1,c)+o.get(l+1,c+1);(s===4||s===0)&&a++}return a*t.N2},e.getPenaltyN3=function(o){const i=o.size;let a=0,l=0,c=0;for(let s=0;s<i;s++){l=c=0;for(let d=0;d<i;d++)l=l<<1&2047|o.get(s,d),d>=10&&(l===1488||l===93)&&a++,c=c<<1&2047|o.get(d,s),d>=10&&(c===1488||c===93)&&a++}return a*t.N3},e.getPenaltyN4=function(o){let i=0;const a=o.data.length;for(let c=0;c<a;c++)i+=o.data[c];return Math.abs(Math.ceil(i*100/a/5)-10)*t.N4};function n(r,o,i){switch(r){case e.Patterns.PATTERN000:return(o+i)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return i%3===0;case e.Patterns.PATTERN011:return(o+i)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(i/3))%2===0;case e.Patterns.PATTERN101:return o*i%2+o*i%3===0;case e.Patterns.PATTERN110:return(o*i%2+o*i%3)%2===0;case e.Patterns.PATTERN111:return(o*i%3+(o+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(o,i){const a=i.size;for(let l=0;l<a;l++)for(let c=0;c<a;c++)i.isReserved(c,l)||i.xor(c,l,n(o,c,l))},e.getBestMask=function(o,i){const a=Object.keys(e.Patterns).length;let l=0,c=1/0;for(let s=0;s<a;s++){i(s),e.applyMask(s,o);const d=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(s,o),d<c&&(c=d,l=s)}return l}})($a)),$a}var Go={},Ru;function Du(){if(Ru)return Go;Ru=1;const e=Oa(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Go.getBlocksCount=function(o,i){switch(i){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},Go.getTotalCodewordsCount=function(o,i){switch(i){case e.L:return n[(o-1)*4+0];case e.M:return n[(o-1)*4+1];case e.Q:return n[(o-1)*4+2];case e.H:return n[(o-1)*4+3];default:return}},Go}var La={},hr={},$u;function Hb(){if($u)return hr;$u=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let r=1;for(let o=0;o<255;o++)e[o]=r,t[r]=o,r<<=1,r&256&&(r^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),hr.log=function(r){if(r<1)throw new Error("log("+r+")");return t[r]},hr.exp=function(r){return e[r]},hr.mul=function(r,o){return r===0||o===0?0:e[t[r]+t[o]]},hr}var Lu;function Ub(){return Lu||(Lu=1,(function(e){const t=Hb();e.mul=function(r,o){const i=new Uint8Array(r.length+o.length-1);for(let a=0;a<r.length;a++)for(let l=0;l<o.length;l++)i[a+l]^=t.mul(r[a],o[l]);return i},e.mod=function(r,o){let i=new Uint8Array(r);for(;i.length-o.length>=0;){const a=i[0];for(let c=0;c<o.length;c++)i[c]^=t.mul(o[c],a);let l=0;for(;l<i.length&&i[l]===0;)l++;i=i.slice(l)}return i},e.generateECPolynomial=function(r){let o=new Uint8Array([1]);for(let i=0;i<r;i++)o=e.mul(o,new Uint8Array([1,t.exp(i)]));return o}})(La)),La}var Na,Nu;function qb(){if(Nu)return Na;Nu=1;const e=Ub();function t(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(r){this.degree=r,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(r.length+this.degree);o.set(r);const i=e.mod(o,this.genPoly),a=this.degree-i.length;if(a>0){const l=new Uint8Array(this.degree);return l.set(i,a),l}return i},Na=t,Na}var Fa={},za={},Ba={},Fu;function zu(){return Fu||(Fu=1,Ba.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Ba}var ht={},Bu;function Hu(){if(Bu)return ht;Bu=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
264
+ ]))+`;ht.KANJI=new RegExp(n,"g"),ht.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),ht.BYTE=new RegExp(r,"g"),ht.NUMERIC=new RegExp(e,"g"),ht.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),i=new RegExp("^"+e+"$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return ht.testKanji=function(c){return o.test(c)},ht.testNumeric=function(c){return i.test(c)},ht.testAlphanumeric=function(c){return a.test(c)},ht}var Uu;function Kt(){return Uu||(Uu=1,(function(e){const t=zu(),n=Hu();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(i,a){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!t.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?i.ccBits[0]:a<27?i.ccBits[1]:i.ccBits[2]},e.getBestModeForData=function(i){return n.testNumeric(i)?e.NUMERIC:n.testAlphanumeric(i)?e.ALPHANUMERIC:n.testKanji(i)?e.KANJI:e.BYTE},e.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},e.isValid=function(i){return i&&i.bit&&i.ccBits};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(i,a){if(e.isValid(i))return i;try{return r(i)}catch{return a}}})(za)),za}var qu;function Wb(){return qu||(qu=1,(function(e){const t=Xt(),n=Du(),r=Oa(),o=Kt(),i=zu(),a=7973,l=t.getBCHDigit(a);function c(u,f,m){for(let g=1;g<=40;g++)if(f<=e.getCapacity(g,m,u))return g}function s(u,f){return o.getCharCountIndicator(u,f)+4}function d(u,f){let m=0;return u.forEach(function(g){const b=s(g.mode,f);m+=b+g.getBitsLength()}),m}function p(u,f){for(let m=1;m<=40;m++)if(d(u,m)<=e.getCapacity(m,f,o.MIXED))return m}e.from=function(f,m){return i.isValid(f)?parseInt(f,10):m},e.getCapacity=function(f,m,g){if(!i.isValid(f))throw new Error("Invalid QR Code version");typeof g>"u"&&(g=o.BYTE);const b=t.getSymbolTotalCodewords(f),v=n.getTotalCodewordsCount(f,m),w=(b-v)*8;if(g===o.MIXED)return w;const _=w-s(g,f);switch(g){case o.NUMERIC:return Math.floor(_/10*3);case o.ALPHANUMERIC:return Math.floor(_/11*2);case o.KANJI:return Math.floor(_/13);case o.BYTE:default:return Math.floor(_/8)}},e.getBestVersionForData=function(f,m){let g;const b=r.from(m,r.M);if(Array.isArray(f)){if(f.length>1)return p(f,b);if(f.length===0)return 1;g=f[0]}else g=f;return c(g.mode,g.getLength(),b)},e.getEncodedBits=function(f){if(!i.isValid(f)||f<7)throw new Error("Invalid QR Code version");let m=f<<12;for(;t.getBCHDigit(m)-l>=0;)m^=a<<t.getBCHDigit(m)-l;return f<<12|m}})(Fa)),Fa}var Ha={},Wu;function jb(){if(Wu)return Ha;Wu=1;const e=Xt(),t=1335,n=21522,r=e.getBCHDigit(t);return Ha.getEncodedBits=function(i,a){const l=i.bit<<3|a;let c=l<<10;for(;e.getBCHDigit(c)-r>=0;)c^=t<<e.getBCHDigit(c)-r;return(l<<10|c)^n},Ha}var Ua={},qa,ju;function Gb(){if(ju)return qa;ju=1;const e=Kt();function t(n){this.mode=e.NUMERIC,this.data=n.toString()}return t.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(r){let o,i,a;for(o=0;o+3<=this.data.length;o+=3)i=this.data.substr(o,3),a=parseInt(i,10),r.put(a,10);const l=this.data.length-o;l>0&&(i=this.data.substr(o),a=parseInt(i,10),r.put(a,l*3+1))},qa=t,qa}var Wa,Gu;function Vb(){if(Gu)return Wa;Gu=1;const e=Kt(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(r){this.mode=e.ALPHANUMERIC,this.data=r}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let i;for(i=0;i+2<=this.data.length;i+=2){let a=t.indexOf(this.data[i])*45;a+=t.indexOf(this.data[i+1]),o.put(a,11)}this.data.length%2&&o.put(t.indexOf(this.data[i]),6)},Wa=n,Wa}var ja,Vu;function Yb(){if(Vu)return ja;Vu=1;const e=Kt();function t(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return t.getBitsLength=function(r){return r*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(n){for(let r=0,o=this.data.length;r<o;r++)n.put(this.data[r],8)},ja=t,ja}var Ga,Yu;function Xb(){if(Yu)return Ga;Yu=1;const e=Kt(),t=Xt();function n(r){this.mode=e.KANJI,this.data=r}return n.getBitsLength=function(o){return o*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let o;for(o=0;o<this.data.length;o++){let i=t.toSJIS(this.data[o]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
265
+ Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},Ga=n,Ga}var Va={exports:{}},Xu;function Kb(){return Xu||(Xu=1,(function(e){var t={single_source_shortest_paths:function(n,r,o){var i={},a={};a[r]=0;var l=t.PriorityQueue.make();l.push(r,0);for(var c,s,d,p,u,f,m,g,b;!l.empty();){c=l.pop(),s=c.value,p=c.cost,u=n[s]||{};for(d in u)u.hasOwnProperty(d)&&(f=u[d],m=p+f,g=a[d],b=typeof a[d]>"u",(b||g>m)&&(a[d]=m,l.push(d,m),i[d]=s))}if(typeof o<"u"&&typeof a[o]>"u"){var v=["Could not find a path from ",r," to ",o,"."].join("");throw new Error(v)}return i},extract_shortest_path_from_predecessor_list:function(n,r){for(var o=[],i=r;i;)o.push(i),n[i],i=n[i];return o.reverse(),o},find_path:function(n,r,o){var i=t.single_source_shortest_paths(n,r,o);return t.extract_shortest_path_from_predecessor_list(i,o)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,o={},i;n=n||{};for(i in r)r.hasOwnProperty(i)&&(o[i]=r[i]);return o.queue=[],o.sorter=n.sorter||r.default_sorter,o},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var o={value:n,cost:r};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Va)),Va.exports}var Ku;function Zb(){return Ku||(Ku=1,(function(e){const t=Kt(),n=Gb(),r=Vb(),o=Yb(),i=Xb(),a=Hu(),l=Xt(),c=Kb();function s(v){return unescape(encodeURIComponent(v)).length}function d(v,w,_){const M=[];let N;for(;(N=v.exec(_))!==null;)M.push({data:N[0],index:N.index,mode:w,length:N[0].length});return M}function p(v){const w=d(a.NUMERIC,t.NUMERIC,v),_=d(a.ALPHANUMERIC,t.ALPHANUMERIC,v);let M,N;return l.isKanjiModeEnabled()?(M=d(a.BYTE,t.BYTE,v),N=d(a.KANJI,t.KANJI,v)):(M=d(a.BYTE_KANJI,t.BYTE,v),N=[]),w.concat(_,M,N).sort(function(D,I){return D.index-I.index}).map(function(D){return{data:D.data,mode:D.mode,length:D.length}})}function u(v,w){switch(w){case t.NUMERIC:return n.getBitsLength(v);case t.ALPHANUMERIC:return r.getBitsLength(v);case t.KANJI:return i.getBitsLength(v);case t.BYTE:return o.getBitsLength(v)}}function f(v){return v.reduce(function(w,_){const M=w.length-1>=0?w[w.length-1]:null;return M&&M.mode===_.mode?(w[w.length-1].data+=_.data,w):(w.push(_),w)},[])}function m(v){const w=[];for(let _=0;_<v.length;_++){const M=v[_];switch(M.mode){case t.NUMERIC:w.push([M,{data:M.data,mode:t.ALPHANUMERIC,length:M.length},{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.ALPHANUMERIC:w.push([M,{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.KANJI:w.push([M,{data:M.data,mode:t.BYTE,length:s(M.data)}]);break;case t.BYTE:w.push([{data:M.data,mode:t.BYTE,length:s(M.data)}])}}return w}function g(v,w){const _={},M={start:{}};let N=["start"];for(let R=0;R<v.length;R++){const D=v[R],I=[];for(let S=0;S<D.length;S++){const C=D[S],k=""+R+S;I.push(k),_[k]={node:C,lastCount:0},M[k]={};for(let $=0;$<N.length;$++){const P=N[$];_[P]&&_[P].node.mode===C.mode?(M[P][k]=u(_[P].lastCount+C.length,C.mode)-u(_[P].lastCount,C.mode),_[P].lastCount+=C.length):(_[P]&&(_[P].lastCount=C.length),M[P][k]=u(C.length,C.mode)+4+t.getCharCountIndicator(C.mode,w))}}N=I}for(let R=0;R<N.length;R++)M[N[R]].end=0;return{map:M,table:_}}function b(v,w){let _;const M=t.getBestModeForData(v);if(_=t.from(w,M),_!==t.BYTE&&_.bit<M.bit)throw new Error('"'+v+'" cannot be encoded with mode '+t.toString(_)+`.
266
+ Suggested mode is: `+t.toString(M));switch(_===t.KANJI&&!l.isKanjiModeEnabled()&&(_=t.BYTE),_){case t.NUMERIC:return new n(v);case t.ALPHANUMERIC:return new r(v);case t.KANJI:return new i(v);case t.BYTE:return new o(v)}}e.fromArray=function(w){return w.reduce(function(_,M){return typeof M=="string"?_.push(b(M,null)):M.data&&_.push(b(M.data,M.mode)),_},[])},e.fromString=function(w,_){const M=p(w,l.isKanjiModeEnabled()),N=m(M),R=g(N,_),D=c.find_path(R.map,"start","end"),I=[];for(let S=1;S<D.length-1;S++)I.push(R.table[D[S]].node);return e.fromArray(f(I))},e.rawSplit=function(w){return e.fromArray(p(w,l.isKanjiModeEnabled()))}})(Ua)),Ua}var Zu;function Jb(){if(Zu)return Ca;Zu=1;const e=Xt(),t=Oa(),n=Lb(),r=Nb(),o=Fb(),i=zb(),a=Bb(),l=Du(),c=qb(),s=Wb(),d=jb(),p=Kt(),u=Zb();function f(R,D){const I=R.size,S=i.getPositions(D);for(let C=0;C<S.length;C++){const k=S[C][0],$=S[C][1];for(let P=-1;P<=7;P++)if(!(k+P<=-1||I<=k+P))for(let x=-1;x<=7;x++)$+x<=-1||I<=$+x||(P>=0&&P<=6&&(x===0||x===6)||x>=0&&x<=6&&(P===0||P===6)||P>=2&&P<=4&&x>=2&&x<=4?R.set(k+P,$+x,!0,!0):R.set(k+P,$+x,!1,!0))}}function m(R){const D=R.size;for(let I=8;I<D-8;I++){const S=I%2===0;R.set(I,6,S,!0),R.set(6,I,S,!0)}}function g(R,D){const I=o.getPositions(D);for(let S=0;S<I.length;S++){const C=I[S][0],k=I[S][1];for(let $=-2;$<=2;$++)for(let P=-2;P<=2;P++)$===-2||$===2||P===-2||P===2||$===0&&P===0?R.set(C+$,k+P,!0,!0):R.set(C+$,k+P,!1,!0)}}function b(R,D){const I=R.size,S=s.getEncodedBits(D);let C,k,$;for(let P=0;P<18;P++)C=Math.floor(P/3),k=P%3+I-8-3,$=(S>>P&1)===1,R.set(C,k,$,!0),R.set(k,C,$,!0)}function v(R,D,I){const S=R.size,C=d.getEncodedBits(D,I);let k,$;for(k=0;k<15;k++)$=(C>>k&1)===1,k<6?R.set(k,8,$,!0):k<8?R.set(k+1,8,$,!0):R.set(S-15+k,8,$,!0),k<8?R.set(8,S-k-1,$,!0):k<9?R.set(8,15-k-1+1,$,!0):R.set(8,15-k-1,$,!0);R.set(S-8,8,1,!0)}function w(R,D){const I=R.size;let S=-1,C=I-1,k=7,$=0;for(let P=I-1;P>0;P-=2)for(P===6&&P--;;){for(let x=0;x<2;x++)if(!R.isReserved(C,P-x)){let Y=!1;$<D.length&&(Y=(D[$]>>>k&1)===1),R.set(C,P-x,Y),k--,k===-1&&($++,k=7)}if(C+=S,C<0||I<=C){C-=S,S=-S;break}}}function _(R,D,I){const S=new n;I.forEach(function(x){S.put(x.mode.bit,4),S.put(x.getLength(),p.getCharCountIndicator(x.mode,R)),x.write(S)});const C=e.getSymbolTotalCodewords(R),k=l.getTotalCodewordsCount(R,D),$=(C-k)*8;for(S.getLengthInBits()+4<=$&&S.put(0,4);S.getLengthInBits()%8!==0;)S.putBit(0);const P=($-S.getLengthInBits())/8;for(let x=0;x<P;x++)S.put(x%2?17:236,8);return M(S,R,D)}function M(R,D,I){const S=e.getSymbolTotalCodewords(D),C=l.getTotalCodewordsCount(D,I),k=S-C,$=l.getBlocksCount(D,I),P=S%$,x=$-P,Y=Math.floor(S/$),le=Math.floor(k/$),De=le+1,G=Y-le,me=new c(G);let Be=0;const ue=new Array($),Ie=new Array($);let te=0;const ne=new Uint8Array(R.buffer);for(let W=0;W<$;W++){const X=W<x?le:De;ue[W]=ne.slice(Be,Be+X),Ie[W]=me.encode(ue[W]),Be+=X,te=Math.max(te,X)}const tt=new Uint8Array(S);let O=0,z,q;for(z=0;z<te;z++)for(q=0;q<$;q++)z<ue[q].length&&(tt[O++]=ue[q][z]);for(z=0;z<G;z++)for(q=0;q<$;q++)tt[O++]=Ie[q][z];return tt}function N(R,D,I,S){let C;if(Array.isArray(R))C=u.fromArray(R);else if(typeof R=="string"){let Y=D;if(!Y){const le=u.rawSplit(R);Y=s.getBestVersionForData(le,I)}C=u.fromString(R,Y||40)}else throw new Error("Invalid data");const k=s.getBestVersionForData(C,I);if(!k)throw new Error("The amount of data is too big to be stored in a QR Code");if(!D)D=k;else if(D<k)throw new Error(`
255
267
  The chosen QR Code version cannot contain this amount of data.
256
- Minimum version required to store current data is: `+O+`.
257
- `);const D=_(P,k,C),I=e.getSymbolSize(P),x=new r(I);return f(x,P),g(x),m(x,P),v(x,k,0),P>=7&&y(x,P),w(x,D),isNaN(S)&&(S=a.getBestMask(x,v.bind(null,x,k))),a.applyMask(S,x),v(x,k,S),{modules:x,version:P,errorCorrectionLevel:k,maskPattern:S,segments:C}}return ya.create=function(P,k){if(typeof P>"u"||P==="")throw new Error("No input text");let S=t.M,C,O;return typeof k<"u"&&(S=t.from(k.errorCorrectionLevel,t.M),C=s.from(k.version),O=a.from(k.maskPattern),k.toSJISFunc&&e.setToSJISFunction(k.toSJISFunc)),N(P,C,S,O)},ya}var Fa={},za={},Fu;function zu(){return Fu||(Fu=1,(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(i){return[i,i]}))),r.length===6&&r.push("F","F");const o=parseInt(r.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const o=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,i=r.width&&r.width>=21?r.width:void 0,a=r.scale||4;return{width:i,scale:i?4:a,margin:o,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,o){return o.width&&o.width>=r+o.margin*2?o.width/(r+o.margin*2):o.scale},e.getImageWidth=function(r,o){const i=e.getScale(r,o);return Math.floor((r+o.margin*2)*i)},e.qrToImageData=function(r,o,i){const a=o.modules.size,l=o.modules.data,c=e.getScale(a,i),s=Math.floor((a+i.margin*2)*c),d=i.margin*c,p=[i.color.light,i.color.dark];for(let u=0;u<s;u++)for(let f=0;f<s;f++){let g=(u*s+f)*4,m=i.color.light;if(u>=d&&f>=d&&u<s-d&&f<s-d){const y=Math.floor((u-d)/c),v=Math.floor((f-d)/c);m=p[l[y*a+v]?1:0]}r[g++]=m.r,r[g++]=m.g,r[g++]=m.b,r[g]=m.a}}})(za)),za}var Bu;function Rb(){return Bu||(Bu=1,(function(e){const t=zu();function n(o,i,a){o.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=a,i.width=a,i.style.height=a+"px",i.style.width=a+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(i,a,l){let c=l,s=a;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),a||(s=r()),c=t.getOptions(c);const d=t.getImageWidth(i.modules.size,c),p=s.getContext("2d"),u=p.createImageData(d,d);return t.qrToImageData(u.data,i,c),n(p,s,d),p.putImageData(u,0,0),s},e.renderToDataURL=function(i,a,l){let c=l;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),c||(c={});const s=e.render(i,a,c),d=c.type||"image/png",p=c.rendererOpts||{};return s.toDataURL(d,p.quality)}})(Fa)),Fa}var Ba={},Hu;function $b(){if(Hu)return Ba;Hu=1;const e=zu();function t(o,i){const a=o.a/255,l=i+'="'+o.hex+'"';return a<1?l+" "+i+'-opacity="'+a.toFixed(2).slice(1)+'"':l}function n(o,i,a){let l=o+i;return typeof a<"u"&&(l+=" "+a),l}function r(o,i,a){let l="",c=0,s=!1,d=0;for(let p=0;p<o.length;p++){const u=Math.floor(p%i),f=Math.floor(p/i);!u&&!s&&(s=!0),o[p]?(d++,p>0&&u>0&&o[p-1]||(l+=s?n("M",u+a,.5+f+a):n("m",c,0),c=0,s=!1),u+1<i&&o[p+1]||(l+=n("h",d),d=0)):c++}return l}return Ba.render=function(i,a,l){const c=e.getOptions(a),s=i.modules.size,d=i.modules.data,p=s+c.margin*2,u=c.color.light.a?"<path "+t(c.color.light,"fill")+' d="M0 0h'+p+"v"+p+'H0z"/>':"",f="<path "+t(c.color.dark,"stroke")+' d="'+r(d,s,c.margin)+'"/>',g='viewBox="0 0 '+p+" "+p+'"',y='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+g+' shape-rendering="crispEdges">'+u+f+`</svg>
258
- `;return typeof l=="function"&&l(null,y),y},Ba}var Uu;function Lb(){if(Uu)return gn;Uu=1;const e=mb(),t=Db(),n=Rb(),r=$b();function o(i,a,l,c,s){const d=[].slice.call(arguments,1),p=d.length,u=typeof d[p-1]=="function";if(!u&&!e())throw new Error("Callback required as last argument");if(u){if(p<2)throw new Error("Too few arguments provided");p===2?(s=l,l=a,a=c=void 0):p===3&&(a.getContext&&typeof s>"u"?(s=c,c=void 0):(s=c,c=l,l=a,a=void 0))}else{if(p<1)throw new Error("Too few arguments provided");return p===1?(l=a,a=c=void 0):p===2&&!a.getContext&&(c=l,l=a,a=void 0),new Promise(function(f,g){try{const m=t.create(l,c);f(i(m,a,c))}catch(m){g(m)}})}try{const f=t.create(l,c);s(null,i(f,a,c))}catch(f){s(f)}}return gn.create=t.create,gn.toCanvas=o.bind(null,n.render),gn.toDataURL=o.bind(null,n.renderToDataURL),gn.toString=o.bind(null,function(i,a,l){return r.render(i,l)}),gn}var Nb=Lb();const Fb=nd(Nb),qu="http://www.w3.org/2000/svg";function zb(e){const t=e.getAttribute("viewBox");if(!t)return null;const n=t.trim().split(/[\s,]+/).map(Number);return n.length!==4||n.some(r=>!Number.isFinite(r))?null:{width:n[2],height:n[3]}}function Bb(e,t){const n=document.createElementNS(qu,"svg"),r=Pn(t.barWidth),o=ci(t.barQuietZone),i=l=>{ma(n,e,{format:t.barcodeType||"CODE128",width:r,height:l*r,displayValue:t.showText!==!1,fontSize:(t.fontSize??Er)*r,margin:0,marginLeft:o*r,marginRight:o*r,marginTop:0,marginBottom:di*r});const c=zb(n);return c?{widthUnits:c.width,heightUnits:c.height}:null},a=pi({barHeightMm:t.barHeightMm,boxWidthMm:t.targetWidthMm??0,boxHeightMm:t.targetHeightMm??0,dpi:t.printerDpi,barWidth:t.barWidth,measure:i});return a.size&&(n.setAttribute("width",`${a.size.widthMm}mm`),n.setAttribute("height",`${a.size.heightMm}mm`)),n.setAttribute("shape-rendering","crispEdges"),n.outerHTML}function Hb(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):Xs}function Ub(e,t){const n=(t.qrCodeLevel??"M").toUpperCase(),o=Fb.create(e,{errorCorrectionLevel:["L","M","Q","H"].includes(n)?n:"M"}).modules,i=o.size,a=4,l=Hb(t.qrQuietZone)*a,c=i*a+l*2;let s="";for(let d=0;d<i;d++)for(let p=0;p<i;p++)o.get(p,d)&&(s+=`<rect x="${l+p*a}" y="${l+d*a}" width="${a}" height="${a}" fill="#000"/>`);return`<svg xmlns="${qu}" viewBox="0 0 ${c} ${c}" width="${c}" height="${c}" shape-rendering="crispEdges">${s}</svg>`}function Wu(e,t,n={}){if(!e)throw new Error("empty barcode value");return t==="qrcode"?Ub(e,n):Bb(e,n)}const Ha={render(e,t,n={}){return Wu(e,t,n)}},Ua=.5,qb=12;function qa(e,t){const n=e.getAttribute(t);if(n===null||n==="")return;const r=Number(n);return Number.isFinite(r)?r:void 0}function ju(e,t){if(e.scrollWidth>e.clientWidth+Ua)return!0;const n=e.scrollHeight;return t!==void 0?n>t+Ua:n>e.clientHeight+Ua}function Gu(e){if(e.getAttribute("data-fit")!=="shrink")return;const t=Cn(qa(e,"data-fit-min")),n=Math.max(qa(e,"data-fit-base")??t,t),r=qa(e,"data-fit-mm"),o=r!==void 0&&r>0?Lt(r):void 0,i=s=>{const d=Hf(s);return e.style.fontSize=`${d}pt`,e.setAttribute("data-fit-size",String(d)),d},a=i(n);if(!ju(e,o)||n<=t)return a;let l=t,c=n;for(let s=0;s<qb;s++){const d=(l+c)/2;i(d),ju(e,o)?c=d:l=d}return i(l)}function Wb(e){const t=[];return e.querySelectorAll('[data-fit="shrink"]').forEach(n=>{const r=Gu(n),o=n.getAttribute("data-fit-key");r===void 0||!o||t.push({key:o,fontSizePt:r})}),t}const jb="2",Gb=5e3;async function Yb(e,t=Gb){const n=e.document,r=i=>Promise.race([i,new Promise(a=>setTimeout(a,t))]),o=(async()=>{n.readyState!=="complete"&&await r(new Promise(a=>e.addEventListener("load",()=>a(),{once:!0})));const i=n.fonts;i&&(await r(Promise.all(Vb(n).map(a=>i.load(`${a.style} ${a.weight} 16px "${a.family}"`).catch(()=>{})))),i.ready&&await r(i.ready)),await r(Promise.all(Array.from(n.images??[]).map(a=>a.complete?Promise.resolve():new Promise(l=>{a.addEventListener("load",()=>l(),{once:!0}),a.addEventListener("error",()=>l(),{once:!0})}))))})();await r(o)}function Vb(e){const t=[];for(const r of Array.from(e.styleSheets??[])){let o;try{o=r.cssRules}catch{continue}for(const i of Array.from(o??[])){if(i.type!==5)continue;const a=i.style,l=(a.getPropertyValue("font-family")||"").replace(/^["']|["']$/g,"");l&&t.push({family:l,weight:a.getPropertyValue("font-weight")||"400",style:a.getPropertyValue("font-style")||"normal"})}}return t}function Kb(e){const t=[];return e.querySelectorAll("[data-measure-id]").forEach(n=>{const r=n,o=r.getAttribute("data-measure-id");if(!o)return;const i=r.getBoundingClientRect().height,a=r.querySelector("table.print-table");if(!a){t.push({id:o,heightPx:i});return}const l=[];a.querySelectorAll("tbody > tr[data-row-index]").forEach(c=>{l.push(c.getBoundingClientRect().height)}),t.push({id:o,heightPx:i,rowHeightsPx:l})}),t}function Xb(e){const t=e.querySelector(".print-page"),n=e.querySelector(".content-area");if(!t||!n)return 0;const r=t.getBoundingClientRect().top;let o=0;n.querySelectorAll("*").forEach(a=>{const l=a.getBoundingClientRect();l.height>0&&(o=Math.max(o,l.bottom-r))});const i=n.getBoundingClientRect();return i.height>0&&(o=Math.max(o,i.bottom-r)),o}function Zb(e){const t={};for(const n of e)try{t[n.key]=Wu(n.value,n.cellType,n.opts)}catch{}return t}const Jb={version:jb,waitReady:Yb,readMeasurements:Kb,readContentBottom:Xb,renderCodes:Zb,applyTextFit:Wb};function Qb(){return{async createDriver(){const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;left:-10000px;top:0;border:0;visibility:hidden;pointer-events:none;",document.body.appendChild(e);let t=e.contentDocument??document;return{requiresExecutor:!1,async open(n){e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,t=e.contentDocument??document},async setContent(n){t=e.contentDocument??document,t.open(),t.write(n),t.close()},async injectExecutor(n){},async evaluate(n,r){const o=Jb[n],i=r??[],a=Um[n];return a==="window"?o(e.contentWindow,...i):a==="document"?o(t,...i):o(...i)},async close(){e.remove()}}}}}function e1(){return jm(Qb())}async function t1(e,t,n,r,o){const i=await n0({templateJson:e,printData:t,baseUrl:n,fontBaseUrl:o?.fontBaseUrl??"",paperHeightMm:o?.paperHeightMm,codeRenderer:r},e1());return{html:i.html,pageCount:i.pageCount,pageLayouts:i.pageLayouts,paperMm:i.paperMm,continuous:i.continuous,copies:i.copies,copyPaperMm:i.copyPaperMm}}function h(e,t={},n=[]){return{tag:e,props:t,children:n}}const Yu="http://www.w3.org/2000/svg",n1=new Set(["draggable","contenteditable","spellcheck"]),r1=new Set(["indeterminate"]);function o1(e){return e==="svg"||e==="path"||e==="circle"||e==="rect"||e==="line"||e==="g"}function De(e,t){if(typeof e=="string"){const a=document.createTextNode(e);return t.appendChild(a),a}if(e instanceof Node)return t.appendChild(e),e;const{tag:n,props:r,children:o}=e,i=o1(n)?document.createElementNS(Yu,n):document.createElement(n);for(const[a,l]of Object.entries(r))if(!(l==null||l===!1))if(a==="class")i.setAttribute("class",String(l));else if(a==="style")typeof l=="string"?i.style.cssText=l:Object.assign(i.style,l);else if(a==="html")i.innerHTML=String(l);else if(a==="text")i.textContent=String(l);else if(a.startsWith("on")&&typeof l=="function")i.addEventListener(a.slice(2).toLowerCase(),l);else if(a==="dataset")for(const[c,s]of Object.entries(l))i.dataset[c]=s;else r1.has(a)?i[a]=!0:typeof l=="boolean"?l&&i.setAttribute(a,n1.has(a)?"true":""):i.setAttribute(a,String(l));for(const a of o)De(a,i);return t.appendChild(i),i}function Vu(e){for(;e.firstChild;)e.removeChild(e.firstChild)}const i1=Yu;function ir(){return{paperSize:"A4",orientation:"portrait",unit:"mm",margins:{top:10,right:10,bottom:10,left:10},header:{height:10,elements:[]},footer:{height:10,elements:[]},elements:[],watermark:{}}}const Wa="开启拼版后只能有一个设计页面";function ja(e){const t=(n,r)=>(n??[]).map(o=>{const i={...o.options};return(o.printElementType?.type??o.type)==="table"&&Ln(i),{id:o.id||an(),zone:r,options:i,printElementType:{...o.printElementType}}});return{...e,margins:{...e.margins},header:{height:e.header?.height??10,elements:[]},footer:{height:e.footer?.height??10,elements:[]},guides:[...e.guides??[]],elements:[...t(e.elements??[],"content"),...t(e.header?.elements??[],"header"),...t(e.footer?.elements??[],"footer")]}}function Ku(e){const t=e.elements,n=r=>t.filter(o=>(o.zone||"content")===r).map(o=>({id:o.id,type:o.printElementType.type,options:{...o.options},printElementType:{...o.printElementType}}));return{unit:"mm",...e,header:{...e.header,elements:n("header")},footer:{...e.footer,elements:n("footer")},elements:n("content"),guides:[...e.guides??[]]}}function Xu(e){const t=(r,o)=>{const i=ja(Kh(r));return i.name||(i.name=`页面 ${o+1}`),i};if(!e)return[t(ir(),0)];const n=Array.isArray(e.pages)?e.pages:[e];return n.length?n.map(t):[t(ir(),0)]}const mn=e=>JSON.parse(JSON.stringify(e));class Zu{scale=100;showRuler=!0;showGrid=!0;snapToGrid=!1;showTableGhostBorder=!0;dirty=!1;pages;activePageIndex=0;fields;selectedIds=new Set;previewIds=new Set;tableSelection=null;draggingIds=new Set;adsorbGuides=[];live=new Map;clipboard=[];moveSessionActive=!1;moveTimer=null;dragBefore=null;undoStack=[];redoStack=[];listeners=new Set;align=k0();group=C0();constructor(t={}){if(this.pages=Xu(t.initialTemplate),this.fields=t.initialFields??[],t.initialElements?.length){const n=this.pages[0];n.elements=[...n.elements,...t.initialElements]}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t=!0){t&&(this.dirty=!0);for(const n of[...this.listeners])n()}get templateData(){return this.pages[this.activePageIndex]}set templateData(t){this.pages[this.activePageIndex]=t}get elements(){return this.templateData.elements.map(t=>this.live.get(t.id)??t)}get tilingEnabled(){return this.pages.some(t=>t.tiling?.enabled===!0)}switchPage(t){t<0||t>=this.pages.length||(this.activePageIndex=t,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(Wa);return}this.recordHistory();const t=this.pages[this.activePageIndex]??ir();this.pages.push(ja({...ir(),paperSize:t.paperSize,orientation:t.orientation,customWidth:t.customWidth,customHeight:t.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const t=new Set(this.pages.map(r=>r.name));let n=this.pages.length+1;for(;t.has(`页面 ${n}`);)n++;return`页面 ${n}`}duplicatePage(t){if(this.tilingEnabled){window.alert(Wa);return}this.recordHistory();const n=mn(this.pages[t]);n.name=`${n.name??`页面 ${t+1}`} 副本`,n.elements=n.elements.map(r=>({...r,id:an()})),this.pages.splice(t+1,0,n),this.switchPage(t+1),this.emit()}deletePage(t){this.pages.length<=1||(this.recordHistory(),this.pages.splice(t,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(t,n){this.recordHistory(),this.pages[t].name=n,this.emit()}movePage(t,n){if(n<0||n>=this.pages.length||t===n)return;this.recordHistory();const[r]=this.pages.splice(t,1);this.pages.splice(n,0,r),this.activePageIndex=n,this.emit()}onSelectionChanged;setSelection(t){this.selectedIds=t,this.onSelectionChanged?.(),this.emit(!1)}select(t){this.setSelection(new Set(t))}selectOne(t,n=!1){if(n){const r=new Set(this.selectedIds);r.has(t)?r.delete(t):r.add(t),this.setSelection(r)}else this.setSelection(new Set([t]))}clearSelection(){this.setSelection(new Set)}selectElement(t,n=!1){if(n){this.selectOne(t,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,t)))}selectAll(){this.setSelection(new Set(this.elements.map(t=>t.id)))}get selectedElements(){return this.elements.filter(t=>this.selectedIds.has(t.id))}get selectedElement(){const t=this.selectedIds.values().next().value;return t?this.elements.find(n=>n.id===t)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(t){this.tableSelection=t,this.emit(!1)}setPreview(t){this.previewIds=t,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(t,n){const r=this.templateData.guides??[];this.templateData.guides=[...r,{id:an(),type:t,position:Math.round(n*10)/10}],this.emit()}moveGuide(t,n){const r=this.templateData.guides??[];this.templateData.guides=r.map(o=>o.id===t?{...o,position:Math.round(n*10)/10}:o),this.emit(!1)}removeGuide(t){this.templateData.guides=(this.templateData.guides??[]).filter(n=>n.id!==t),this.emit()}addElement(t,n={},r){const o=Mi(t,n);return r&&!this.placeAtDropPoint(o,r)||(this.recordHistory(),this.templateData.elements.push(o),this.select(new Set([o.id])),this.emit()),o}addFieldElement(t,n={},r,o=!1){const i=o?M0(t):_0(t);return Object.assign(i.options,n),r&&!this.placeAtDropPoint(i,r)||(this.recordHistory(),this.templateData.elements.push(i),this.select(new Set([i.id])),this.emit()),i}placeAtDropPoint(t,n){const r=this.templateData,o=Fl(r,n.x,n.y);if(o!=="content"&&!Nl.includes(t.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const i=Di(r)[o];return t.zone=o,t.options.left=n.x-i.left,t.options.top=n.y-i.top,o!=="content"&&Ri(t,i),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(t=>!this.selectedIds.has(t.id)),this.selectedIds=new Set,this.emit())}livePatch(t,n){const r=this.templateData.elements.find(i=>i.id===t);if(!r)return;const o=this.live.get(t)??r;this.live.set(t,{...o,options:{...o.options,...n}})}commitLive(){if(!this.live.size)return;this.recordHistory();const t=this.templateData.elements;for(const[n,r]of this.live){const o=t.find(i=>i.id===n);o&&Object.assign(o.options,r.options)}this.live.clear(),this.emit()}dragIds(t){const n=this.templateData.elements.find(r=>r.id===t);return!n||n.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,t))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(t=>[t.id,this.geoSig(t)]))}dragStop(){const t=this.dragBefore;if(!t)return;this.dragBefore=null;let n=!1;for(const r of this.elements){const o=t.get(r.id);!o||o===this.geoSig(r)||gg(r,this.templateData).rejected&&(n=!0)}n&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(t){return`${t.zone||"content"}:${t.options.left},${t.options.top},${t.options.width},${t.options.height}`}updateElement(t,n,r=!0){r&&this.recordHistory();const o=this.templateData.elements.find(i=>i.id===t);o&&(Object.assign(o.options,n),o.printElementType.type==="table"&&Ln(o.options),this.emit())}updateTemplateData(t){this.recordHistory(),Object.assign(this.templateData,t),this.emit()}moveLayer(t){if(!this.selectedIds.size)return;this.recordHistory();const n=this.templateData.elements,r=n.filter(i=>this.selectedIds.has(i.id)),o=n.filter(i=>!this.selectedIds.has(i.id));if(t==="top")this.templateData.elements=[...o,...r];else if(t==="bottom")this.templateData.elements=[...r,...o];else{const i=n.findIndex(c=>this.selectedIds.has(c.id)),a=t==="up"?i+1:i-1;if(a<0||a>=n.length)return;const l=[...n];[l[i],l[a]]=[l[a],l[i]],this.templateData.elements=l}this.emit()}alignSelected(t){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(n=>this.selectedIds.has(n.id)),t),this.emit())}groupSelected(){this.selectedIds.size<2||(this.recordHistory(),this.templateData.elements=this.group.group(this.elements,this.selectedIds),this.emit())}ungroupSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.group.ungroup(this.elements,this.selectedIds),this.emit())}copy(){this.clipboard=mn(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(t=10){if(!this.clipboard.length)return;this.recordHistory();const n=new Map;for(const i of this.clipboard){const a=i.options.groupId;a&&n.set(a,(n.get(a)??0)+1)}const r=new Map;for(const[i,a]of n)r.set(i,a>=2?td():void 0);const o=this.templateData.elements;for(const i of this.clipboard){const a=mn(i);a.id=an(),a.options.left+=t,a.options.top+=t,a.options.groupId=a.options.groupId?r.get(a.options.groupId):void 0,o.push(a)}this.emit()}duplicateSelected(){if(this.copy(),!this.clipboard.length)return;this.paste(15);const t=this.templateData.elements;this.selectOne(t[t.length-this.clipboard.length].id)}get hasClipboard(){return this.clipboard.length>0}moveSelected(t,n){const r=this.selectedElements.filter(o=>!o.options.locked);if(r.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const o of r)o.options.left+=t,o.options.top+=n;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(t){this.recordHistory(),this.templateData.elements.push(t),this.selectedIds=new Set([t.id]),this.emit()}recordHistory(){this.undoStack.push({pages:mn(this.pages),activePageIndex:this.activePageIndex}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack=[]}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}undo(){const t=this.undoStack.pop();t&&(this.redoStack.push({pages:mn(this.pages),activePageIndex:this.activePageIndex}),this.pages=t.pages,this.activePageIndex=Math.min(t.activePageIndex,t.pages.length-1),this.resetSelection(),this.emit())}redo(){const t=this.redoStack.pop();t&&(this.undoStack.push({pages:mn(this.pages),activePageIndex:this.activePageIndex}),this.pages=t.pages,this.activePageIndex=Math.min(t.activePageIndex,t.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(t,n=Tr){this.scale=Math.max(n,Math.round(t)),this.emit(!1)}getTemplateJson(){const t=this.pages.map(Ku),n=t.length===1?t[0]:{version:1,pages:t};return JSON.stringify(n)}loadTemplate(t){this.pages=Xu(t),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return _t(this.templateData)}}const jt=Symbol("mixed"),Ga=new Set(["text","longText"]),a1=["top","right","bottom","left"],s1={on:!0,off:!1,mixed:jt};function Ju(e){const t=kl(e),n={};for(const r of a1)n[r]=s1[t[r]];return n}const l1=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class c1{constructor(t){this.store=t}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(t=>this.store.selectedIds.has(t.id)&&!t.options.locked)}get tableElement(){const t=this.store.tableSelection;return t?this.store.elements.find(n=>n.id===t.elementId)??null:null}get context(){return this.store.tableSelection&&this.tableElement?"cells":this.selectedElements.length>0||this.store.selectedIds.size>0?"elements":"none"}get targetCells(){const t=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!t||!n)return[];const r=[];for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=n[o]?.cells[i];a&&!a.merged&&r.push(a)}return r}get textTargets(){return this.selectedElements.filter(t=>Ga.has(t.printElementType.type))}get fontEditable(){return this.context==="cells"?this.targetCells.length>0:this.context!=="elements"?!1:this.selectedElements.length>0&&this.textTargets.length===this.selectedElements.length}get styleTargets(){return this.context==="cells"?this.targetCells:this.textTargets.map(t=>t.options)}pick(t){if(!t.length)return;const n=t[0];return t.every(r=>r===n)?n:jt}hasToken(t,n){return(t??"").split(/\s+/).includes(n)}get values(){const t=this.styleTargets;if(!t.length)return{fontFamily:void 0,fontSize:void 0,color:void 0,backgroundColor:void 0,textAlign:void 0,verticalAlign:void 0,bold:!1,underline:!1,strike:!1};const n=t.map(o=>o.fontWeight==="bold"||o.fontWeight==="bolder"),r=t.map(o=>o.textDecoration);return{fontFamily:this.pick(t.map(o=>o.fontFamily)),fontSize:this.pick(t.map(o=>o.fontSize)),color:this.pick(t.map(o=>o.color)),backgroundColor:this.pick(t.map(o=>o.backgroundColor)),textAlign:this.pick(t.map(o=>this.context==="cells"?o.align:o.textAlign)),verticalAlign:this.pick(t.map(o=>this.context==="cells"?o.valign:o.verticalAlign)),bold:n.every(Boolean)?!0:n.some(Boolean)?jt:!1,underline:r.map(o=>this.hasToken(o,"underline")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"underline"))?jt:!1,strike:r.map(o=>this.hasToken(o,"line-through")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"line-through"))?jt:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(t){const n=this.targetCells;n.length&&(n.forEach(t),this.commit())}applyStyle(t){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in t&&(l.fontFamily=t.fontFamily),"fontSize"in t&&(l.fontSize=t.fontSize),"color"in t&&(l.color=t.color),"backgroundColor"in t&&(l.backgroundColor=t.backgroundColor),"textAlign"in t&&(l.align=t.textAlign),"verticalAlign"in t&&(l.valign=t.verticalAlign)});return}const n=this.textTargets,r=this.selectedElements,i=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in t),a="backgroundColor"in t;!(n.length&&i)&&!(r.length&&a)||(n.forEach(l=>{const c=l.options;"fontFamily"in t&&(c.fontFamily=t.fontFamily),"fontSize"in t&&(c.fontSize=t.fontSize),"color"in t&&(c.color=t.color),"textAlign"in t&&(c.textAlign=t.textAlign),"verticalAlign"in t&&(c.verticalAlign=t.verticalAlign)}),a&&r.forEach(l=>{l.options.backgroundColor=t.backgroundColor}),this.commit())}toggleBold(){if(this.context==="cells"){const r=this.values.bold!==!0;this.writeCells(o=>{o.fontWeight=r?"bold":void 0});return}const t=this.values.bold!==!0,n=this.textTargets;n.length&&(n.forEach(r=>{r.options.fontWeight=t?"bold":"normal"}),this.commit())}toggleDecoration(t){if(this.context==="cells")return;const n=this.textTargets;if(!n.length)return;const r=this.values[t==="underline"?"underline":"strike"]!==!0;n.forEach(o=>{const i=(o.options.textDecoration??"").split(/\s+/).filter(Boolean),a=i.indexOf(t);r&&a<0&&i.push(t),!r&&a>=0&&i.splice(a,1),o.options.textDecoration=i.length?i.join(" "):void 0}),this.commit()}toggleUnderline(){this.toggleDecoration("underline")}toggleStrike(){this.toggleDecoration("line-through")}syncBorderDraft(){if(this.context!=="cells"){this.borderDraftKey&&(this.borderDraftKey="",this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1});return}const t=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!t||!n)return;const r=`cells:${t.elementId}:${t.r1}:${t.c1}:${t.r2}:${t.c2}`;if(r===this.borderDraftKey)return;if(this.borderDraftKey=r,Si(n,t).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const o=Ml(n,t);if(o.style===void 0&&o.width===void 0&&o.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:o.style==="mixed",width:o.width==="mixed",color:o.color==="mixed"},this.borderMixed.style?this.borderStyle=null:o.style===void 0?this.borderStyle="solid":o.style==="none"?this.borderStyle=null:this.borderStyle=o.style,this.borderWidth=this.borderMixed.width?void 0:typeof o.width=="number"?o.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof o.color=="string"?o.color:"#333333"}borderSpec(){const t=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:t,color:this.borderColor??"#333333"}}setBorderWidth(t){this.borderWidth=t,this.borderMixed.width=!1}setBorderColor(t){this.borderColor=t,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(t){const n=this.borderStyle===t?null:t;this.borderMixed.style=!1,this.borderStyle=n,n===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(t,n){const r=this.selectedElements;r.length&&(r.forEach(o=>{Cl(o.options,t,n)}),this.commit())}applyCellBorderPreset(t,n){const r=this.store.tableSelection,o=this.tableElement?.options.tableRows;!r||!o||(Sl(o,{r1:r.r1,c1:r.c1,r2:r.r2,c2:r.c2},t,n),this.commit())}applyCellBorderEdges(t,n,r){this.writeCells(o=>{for(const i of t)_l(o,i,r?n:null)})}get cellEdges(){if(this.context!=="cells")return null;const t=this.targetCells;return t.length?Ju(t.map(n=>n.borders)):null}toggleCellEdge(t,n){const r=this.cellEdges?.[t]!==!0;this.applyCellBorderEdges([t],n,r)}get elementEdges(){if(this.context!=="elements")return null;const t=this.selectedElements;return t.length?Ju(t.map(n=>Jh(n.options))):null}toggleElementEdge(t,n){const r=this.selectedElements;if(!r.length)return;const o=this.elementEdges?.[t]!==!0;r.forEach(i=>Ii(i.options,t,o,n)),this.commit()}applyBorderPreset(t){const n=this.borderStyle===null;if(this.context==="cells"){const r=n&&!this.borderMixed.style;this.applyCellBorderPreset(r?"none":t,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(n||t==="none"?"none":"all",this.borderSpec())}applyEdge(t){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([t],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(t);return}this.context==="cells"?(this.toggleCellEdge(t,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(t,this.borderSpec())}clearElementEdge(t){const n=this.selectedElements;n.length&&(n.forEach(r=>Ii(r.options,t,!1)),this.commit())}edgeOn(t){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[t]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(t){if(!t)return;const n={};for(const r of _r){const o=t[r];o&&(n[r]={...o})}return n}pickPainterSource(t=!1){const n=this.selectedElements[0];if(!n)return!1;const r=n.options,o=n.printElementType.type;return this.painterSnapshot={text:Ga.has(o)?Object.fromEntries(l1.map(i=>[i,r[i]])):null,backgroundColor:r.backgroundColor,border:fi(o)?{borderWidth:r.borderWidth,borderStyle:r.borderStyle,borderColor:r.borderColor,borders:this.clonePainterBorders(r.borders)}:null},this.painterSource=n.id,this.painterActive=!0,this.painterLocked=t,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(t){const n=this.painterSnapshot;if(!n||t.options.locked||t.id===this.painterSource)return!1;const r=t.options,o=t.printElementType.type;return n.text&&Ga.has(o)&&Object.assign(r,n.text),r.backgroundColor=n.backgroundColor,n.border&&fi(o)&&(r.borderWidth=n.border.borderWidth,r.borderStyle=n.border.borderStyle,r.borderColor=n.border.borderColor,r.borders=this.clonePainterBorders(n.border.borders)),!0}painterSyncSelection(){if(!this.painterActive||!this.painterSnapshot)return;const t=this.selectedElements;if(!t.length){this.cancelPainter();return}let n=!1;t.forEach(r=>{n=this.applyPainter(r)||n}),n&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(t){if(t.key!=="Escape"||!this.painterActive)return;const n=t.target?.tagName;n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||this.cancelPainter()}}function Qu(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d1(e){if(Array.isArray(e))return e}function u1(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,a,l=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){s=!0,o=d}finally{try{if(!c&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return l}}function p1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
259
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function f1(e,t){return d1(e)||u1(e,t)||h1(e,t)||p1()}function h1(e,t){if(e){if(typeof e=="string")return Qu(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qu(e,t):void 0}}const ep=Object.entries,tp=Object.setPrototypeOf,g1=Object.isFrozen,m1=Object.getPrototypeOf,b1=Object.getOwnPropertyDescriptor;let Se=Object.freeze,Te=Object.seal,bn=Object.create,np=typeof Reflect<"u"&&Reflect,Ya=np.apply,Va=np.construct;Se||(Se=function(t){return t}),Te||(Te=function(t){return t}),Ya||(Ya=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return t.apply(n,o)}),Va||(Va=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});const Gt=xe(Array.prototype.forEach),y1=xe(Array.prototype.lastIndexOf),rp=xe(Array.prototype.pop),ar=xe(Array.prototype.push),v1=xe(Array.prototype.splice),yn=Array.isArray,sr=xe(String.prototype.toLowerCase),Ka=xe(String.prototype.toString),op=xe(String.prototype.match),lr=xe(String.prototype.replace),ip=xe(String.prototype.indexOf),w1=xe(String.prototype.trim),x1=xe(Number.prototype.toString),E1=xe(Boolean.prototype.toString),ap=typeof BigInt>"u"?null:xe(BigInt.prototype.toString),sp=typeof Symbol>"u"?null:xe(Symbol.prototype.toString),Le=xe(Object.prototype.hasOwnProperty),cr=xe(Object.prototype.toString),ke=xe(RegExp.prototype.test),Yt=S1(TypeError);function xe(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Ya(e,t,r)}}function S1(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Va(e,n)}}function oe(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:sr;if(tp&&tp(e,null),!yn(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(g1(t)||(t[r]=i),o=i)}e[o]=!0}return e}function _1(e){for(let t=0;t<e.length;t++)Le(e,t)||(e[t]=null);return e}function Ge(e){const t=bn(null);for(const r of ep(e)){var n=f1(r,2);const o=n[0],i=n[1];Le(e,o)&&(yn(i)?t[o]=_1(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=Ge(i):t[o]=i)}return t}function M1(e){switch(typeof e){case"string":return e;case"number":return x1(e);case"boolean":return E1(e);case"bigint":return ap?ap(e):"0";case"symbol":return sp?sp(e):"Symbol()";case"undefined":return cr(e);case"function":case"object":{if(e===null)return cr(e);const t=e,n=Qe(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:cr(r)}return cr(e)}default:return cr(e)}}function Qe(e,t){for(;e!==null;){const r=b1(e,t);if(r){if(r.get)return xe(r.get);if(typeof r.value=="function")return xe(r.value)}e=m1(e)}function n(){return null}return n}function T1(e){try{return ke(e,""),!0}catch{return!1}}const lp=Se(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Xa=Se(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Za=Se(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),k1=Se(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ja=Se(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),C1=Se(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),cp=Se(["#text"]),dp=Se(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Qa=Se(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),up=Se(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Lo=Se(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),A1=Te(/{{[\w\W]*|^[\w\W]*}}/g),O1=Te(/<%[\w\W]*|^[\w\W]*%>/g),I1=Te(/\${[\w\W]*/g),P1=Te(/^data-[\-\w.\u00B7-\uFFFF]+$/),D1=Te(/^aria-[\-\w]+$/),pp=Te(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),R1=Te(/^(?:\w+script|data):/i),$1=Te(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),L1=Te(/^html$/i),N1=Te(/^[a-z][.\w]*(-[.\w]+)+$/i),fp=Te(/<[/\w!]/g),hp=Te(/<[/\w]/g),F1=Te(/<\/no(script|embed|frames)/i),z1=Te(/\/>/i),Ye={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},gp=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],B1=Se(oe({},gp)),H1=(function(){const e={};return Gt(gp,t=>{e[t]=Te(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),Se(e)})(),U1=function(){return typeof window>"u"?null:window},q1=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},mp=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},kt=function(t,n,r,o){return Le(t,n)&&yn(t[n])?oe(o.base?Ge(o.base):{},t[n],o.transform):r},es=function(t,n,r){const o=Le(t,n)?t[n]:void 0;return o&&typeof o=="object"?Ge(o):r()};function bp(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:U1();const t=$=>bp($);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==Ye.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,a=e.Node,l=e.Element,c=e.NodeFilter,s=e.NamedNodeMap;s===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const d=e.DOMParser,p=e.trustedTypes,u=l.prototype,f=Qe(u,"cloneNode"),g=Qe(u,"remove"),m=Qe(u,"nextSibling"),y=Qe(u,"childNodes"),v=Qe(u,"parentNode"),w=Qe(u,"shadowRoot"),_=Qe(u,"attributes"),M=a&&a.prototype?Qe(a.prototype,"nodeType"):null,N=a&&a.prototype?Qe(a.prototype,"nodeName"):null,L=a&&a.prototype?Qe(a.prototype,"ownerDocument"):null,P=function(b){return M?M(b):b.nodeType},k=function(b){return N?N(b):b.nodeName};if(typeof i=="function"){const $=n.createElement("template");$.content&&$.content.ownerDocument&&(n=$.content.ownerDocument)}let S,C="",O,D=!1,I=0;const x=function(){if(I>0)throw Yt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},j=function(b){x(),I++;try{return S.createHTML(b)}finally{I--}},te=function(b){x(),I++;try{return S.createScriptURL(b)}finally{I--}},fe=function(){return D||(O=q1(p,o),D=!0),O},G=n,de=G.implementation,Xe=G.createNodeIterator,ye=G.createDocumentFragment,Fe=G.getElementsByTagName,R=r.importNode;let F=mp();t.isSupported=typeof ep=="function"&&typeof v=="function"&&de&&de.createHTMLDocument!==void 0;const W=A1,V=O1,Y=I1,K=P1,ne=D1,Q=R1,se=$1,he=N1;let _e=pp,X=null;const vt=oe({},[...lp,...Xa,...Za,...Ja,...cp]);let ee=null;const lt=oe({},[...dp,...Qa,...up,...Lo]);let Me=Object.seal(bn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,Ee=null;const re=Object.seal(bn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let It=!0,Pt=!0,T=!1,J=!0,ue=!1,le=!0,ze=!1,Dt=!1,pe=null,ve=null,mr=!1,Rt=!1,Ko=!1,Xo=!1,gf=!0,mf=!1;const bf="user-content-";let Os=!0,Is=!1,Sn={},_n=null;const yf=oe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let vf=null;const wf=oe({},["audio","video","img","source","image","track"]);let xf=null;const Ef=oe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Zo="http://www.w3.org/1998/Math/MathML",Jo="http://www.w3.org/2000/svg",ct="http://www.w3.org/1999/xhtml";let Mn=ct,Ps=!1,Ds=null;const $w=oe({},[Zo,Jo,ct],Ka),Sf=Se(["mi","mo","mn","ms","mtext"]);let Rs=oe({},Sf);const _f=Se(["annotation-xml"]);let $s=oe({},_f);const Lw=oe({},["title","style","font","a","script"]);let br=null;const Nw=["application/xhtml+xml","text/html"],Fw="text/html";let we=null,Tn=null;const zw=n.createElement("form"),Mf=function(b){return b instanceof RegExp||b instanceof Function},Ls=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Tn&&Tn===b)return;(!b||typeof b!="object")&&(b={}),b=Ge(b),br=Nw.indexOf(b.PARSER_MEDIA_TYPE)===-1?Fw:b.PARSER_MEDIA_TYPE,we=br==="application/xhtml+xml"?Ka:sr,X=kt(b,"ALLOWED_TAGS",vt,{transform:we}),ee=kt(b,"ALLOWED_ATTR",lt,{transform:we}),Ds=kt(b,"ALLOWED_NAMESPACES",$w,{transform:Ka}),xf=kt(b,"ADD_URI_SAFE_ATTR",Ef,{transform:we,base:Ef}),vf=kt(b,"ADD_DATA_URI_TAGS",wf,{transform:we,base:wf}),_n=kt(b,"FORBID_CONTENTS",yf,{transform:we}),Ae=kt(b,"FORBID_TAGS",Ge({}),{transform:we}),Ee=kt(b,"FORBID_ATTR",Ge({}),{transform:we}),Sn=Le(b,"USE_PROFILES")?b.USE_PROFILES&&typeof b.USE_PROFILES=="object"?Ge(b.USE_PROFILES):b.USE_PROFILES:!1,It=b.ALLOW_ARIA_ATTR!==!1,Pt=b.ALLOW_DATA_ATTR!==!1,T=b.ALLOW_UNKNOWN_PROTOCOLS||!1,J=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ue=b.SAFE_FOR_TEMPLATES||!1,le=b.SAFE_FOR_XML!==!1,ze=b.WHOLE_DOCUMENT||!1,Rt=b.RETURN_DOM||!1,Ko=b.RETURN_DOM_FRAGMENT||!1,Xo=b.RETURN_TRUSTED_TYPE||!1,mr=b.FORCE_BODY||!1,gf=b.SANITIZE_DOM!==!1,mf=b.SANITIZE_NAMED_PROPS||!1,Os=b.KEEP_CONTENT!==!1,Is=b.IN_PLACE||!1,_e=T1(b.ALLOWED_URI_REGEXP)?b.ALLOWED_URI_REGEXP:pp,Mn=typeof b.NAMESPACE=="string"?b.NAMESPACE:ct,Rs=es(b,"MATHML_TEXT_INTEGRATION_POINTS",()=>oe({},Sf)),$s=es(b,"HTML_INTEGRATION_POINTS",()=>oe({},_f));const E=es(b,"CUSTOM_ELEMENT_HANDLING",()=>bn(null));if(Me=bn(null),Le(E,"tagNameCheck")&&Mf(E.tagNameCheck)&&(Me.tagNameCheck=E.tagNameCheck),Le(E,"attributeNameCheck")&&Mf(E.attributeNameCheck)&&(Me.attributeNameCheck=E.attributeNameCheck),Le(E,"allowCustomizedBuiltInElements")&&typeof E.allowCustomizedBuiltInElements=="boolean"&&(Me.allowCustomizedBuiltInElements=E.allowCustomizedBuiltInElements),Te(Me),ue&&(Pt=!1),Ko&&(Rt=!0),Sn&&(X=oe({},cp),ee=bn(null),Sn.html===!0&&(oe(X,lp),oe(ee,dp)),Sn.svg===!0&&(oe(X,Xa),oe(ee,Qa),oe(ee,Lo)),Sn.svgFilters===!0&&(oe(X,Za),oe(ee,Qa),oe(ee,Lo)),Sn.mathMl===!0&&(oe(X,Ja),oe(ee,up),oe(ee,Lo))),re.tagCheck=null,re.attributeCheck=null,Le(b,"ADD_TAGS")&&(typeof b.ADD_TAGS=="function"?re.tagCheck=b.ADD_TAGS:yn(b.ADD_TAGS)&&(X===vt&&(X=Ge(X)),oe(X,b.ADD_TAGS,we))),Le(b,"ADD_ATTR")&&(typeof b.ADD_ATTR=="function"?re.attributeCheck=b.ADD_ATTR:yn(b.ADD_ATTR)&&(ee===lt&&(ee=Ge(ee)),oe(ee,b.ADD_ATTR,we))),Le(b,"ADD_FORBID_CONTENTS")&&yn(b.ADD_FORBID_CONTENTS)&&(_n===yf&&(_n=Ge(_n)),oe(_n,b.ADD_FORBID_CONTENTS,we)),Os&&(X["#text"]=!0),ze&&oe(X,["html","head","body"]),X.table&&(oe(X,["tbody"]),delete Ae.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw Yt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Yt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const A=S;S=b.TRUSTED_TYPES_POLICY;try{C=j("")}catch(z){throw S=A,z}}else b.TRUSTED_TYPES_POLICY===null?(S=void 0,C=""):(S===void 0&&(S=fe()),S&&typeof C=="string"&&(C=j("")));Se&&Se(b),Tn=b},Tf=oe({},[...Xa,...Za,...k1]),kf=oe({},[...Ja,...C1]),Bw=function(b,E,A){return E.namespaceURI===ct?b==="svg":E.namespaceURI===Zo?b==="svg"&&(A==="annotation-xml"||Rs[A]):!!Tf[b]},Hw=function(b,E,A){return E.namespaceURI===ct?b==="math":E.namespaceURI===Jo?b==="math"&&$s[A]:!!kf[b]},Uw=function(b,E,A){return E.namespaceURI===Jo&&!$s[A]||E.namespaceURI===Zo&&!Rs[A]?!1:!kf[b]&&(Lw[b]||!Tf[b])},qw=function(b){let E=v(b);(!E||!E.tagName)&&(E={namespaceURI:Mn,tagName:"template"});const A=sr(b.tagName),z=sr(E.tagName);return Ds[b.namespaceURI]?b.namespaceURI===Jo?Bw(A,E,z):b.namespaceURI===Zo?Hw(A,E,z):b.namespaceURI===ct?Uw(A,E,z):!!(br==="application/xhtml+xml"&&Ds[b.namespaceURI]):!1},$t=function(b){ar(t.removed,{element:b});try{v(b).removeChild(b)}catch{if(g(b),!v(b))throw Yt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Cf=function(b,E,A){try{b.removeAttributeNode(E)}catch{try{b.removeAttribute(A)}catch{}}},Qo=function(b){ei(b);const E=y(b);if(E){const z=[];Gt(E,B=>{ar(z,B)}),Gt(z,B=>{try{g(B)}catch{}})}const A=_(b);if(A)for(let z=A.length-1;z>=0;--z){const B=A[z],q=B&&B.name;typeof q=="string"&&Cf(b,B,q)}},Jt=function(b,E,A){if(!A)try{A=E.getAttributeNode(b)}catch{A=null}ar(t.removed,{attribute:A||null,from:E});try{A?E.removeAttributeNode(A):E.removeAttribute(b)}catch{try{E.removeAttribute(b)}catch{}}if(b==="is")if(Rt||Ko)try{$t(E)}catch{}else try{E.setAttribute(b,"")}catch{}},Ww=function(b){const E=_(b);if(E)for(let A=E.length-1;A>=0;--A){const z=E[A],B=z&&z.name;typeof B!="string"||ee[we(B)]||Cf(b,z,B)}},ei=function(b){const E=[b];for(;E.length>0;){const A=E.pop();P(A)===Ye.element&&Ww(A);const B=y(A);if(B)for(let q=B.length-1;q>=0;--q)E.push(B[q])}},Af=function(b,E){return le?b==="patchsrc"?!0:b==="for"&&E!=="label"&&E!=="output":!1},jw=function(b){if(!le)return;const E=[b];for(;E.length>0;){const A=E.pop(),z=P(A);if(z===Ye.processingInstruction||z===Ye.comment&&ke(hp,A.data)){try{g(A)}catch{}continue}if(z===Ye.element){const q=A,ce=we(k(A));try{q.hasAttribute&&q.hasAttribute("patchsrc")&&q.removeAttribute("patchsrc"),q.hasAttribute&&q.hasAttribute("for")&&Af("for",ce)&&q.removeAttribute("for")}catch{}}const B=y(A);if(B)for(let q=B.length-1;q>=0;--q)E.push(B[q])}},Of=function(b){let E=null,A=null;if(mr)b="<remove></remove>"+b;else{const q=op(b,/^[\r\n\t ]+/);A=q&&q[0]}br==="application/xhtml+xml"&&Mn===ct&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");const z=S?j(b):b;if(Mn===ct)try{E=new d().parseFromString(z,br)}catch{}if(!E||!E.documentElement){E=de.createDocument(Mn,"template",null);try{E.documentElement.innerHTML=Ps?C:z}catch{}}const B=E.body||E.documentElement;return b&&A&&B.insertBefore(n.createTextNode(A),B.childNodes[0]||null),Mn===ct?Fe.call(E,ze?"html":"body")[0]:ze?E.documentElement:B},If=function(b){const E=L?L(b):b.ownerDocument;return Xe.call(E||b,b,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ti=function(b){return b=lr(b,W," "),b=lr(b,V," "),b=lr(b,Y," "),b},Ns=function(b){var E;b.normalize();const A=L?L(b):b.ownerDocument,z=Xe.call(A||b,b,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let B=z.nextNode();for(;B;)B.data=ti(B.data),B=z.nextNode();const q=(E=b.querySelectorAll)===null||E===void 0?void 0:E.call(b,"template");q&&Gt(q,ce=>{kn(ce.content)&&Ns(ce.content)})},ni=function(b){const E=N?N(b):null;return typeof E!="string"||we(E)!=="form"?!1:typeof b.nodeName!="string"||typeof b.textContent!="string"||typeof b.removeChild!="function"||b.attributes!==_(b)||typeof b.removeAttribute!="function"||typeof b.setAttribute!="function"||typeof b.namespaceURI!="string"||typeof b.insertBefore!="function"||typeof b.hasChildNodes!="function"||b.nodeType!==M(b)||b.childNodes!==y(b)},kn=function(b){if(!M||typeof b!="object"||b===null)return!1;try{return M(b)===Ye.documentFragment}catch{return!1}},yr=function(b){if(!M||typeof b!="object"||b===null)return!1;try{return typeof M(b)=="number"}catch{return!1}};function dt($,b,E){$.length!==0&&Gt($,A=>{A.call(t,b,E,Tn)})}const Gw=function(b,E){return!!(le&&b.hasChildNodes()&&!yr(b.firstElementChild)&&ke(fp,b.textContent)&&ke(fp,b.innerHTML)||le&&b.namespaceURI===ct&&B1[E]&&(yr(b.firstElementChild)||typeof b.textContent=="string"&&ke(H1[E],b.textContent))||b.nodeType===Ye.processingInstruction||le&&b.nodeType===Ye.comment&&ke(hp,b.data))},ri=function(b,E){if(b instanceof RegExp)return ke(b,E);if(b instanceof Function){for(var A=arguments.length,z=new Array(A>2?A-2:0),B=2;B<A;B++)z[B-2]=arguments[B];return!!b(E,...z)}return!1},Yw=function(b,E,A){if(!Ae[E]&&Lf(E)&&ri(Me.tagNameCheck,E))return!1;if(Os&&!_n[E]){const z=v(b),B=y(b);if(B&&z){const q=B.length;for(let ce=q-1;ce>=0;--ce){const ge=b===A?f(B[ce],!0):B[ce];z.insertBefore(ge,m(b))}}}return $t(b),!0},Pf=function(b,E,A,z){return b.length===0?E:E===A||E===z?Ge(E):E},Df=function(b,E){return b===E||v(b)!==null?!1:(Is&&ei(b),!0)},Rf=function(b,E){if(dt(F.beforeSanitizeElements,b,null),Df(b,E))return!0;if(ni(b))return $t(b),!0;const A=we(k(b));if(X=Pf(F.uponSanitizeElement,X,vt,pe),dt(F.uponSanitizeElement,b,{tagName:A,allowedTags:X}),Df(b,E))return!0;if(Gw(b,A))return $t(b),!0;if(Ae[A]||!(re.tagCheck instanceof Function&&re.tagCheck(A))&&!X[A]){const B=Yw(b,A,E);return B===!1&&dt(F.afterSanitizeElements,b,null),B}if(P(b)===Ye.element&&!qw(b)||(A==="noscript"||A==="noembed"||A==="noframes")&&ke(F1,b.innerHTML))return $t(b),!0;if(ue&&b.nodeType===Ye.text){const B=ti(b.textContent);b.textContent!==B&&(ar(t.removed,{element:b.cloneNode()}),b.textContent=B)}return dt(F.afterSanitizeElements,b,null),!1},$f=function(b,E,A){if(Ee[E]||Af(E,b)||gf&&(E==="id"||E==="name")&&(A in n||A in zw))return!1;const z=ee[E]||re.attributeCheck instanceof Function&&re.attributeCheck(E,b);return Pt&&ke(K,E)||It&&ke(ne,E)?!0:z?xf[E]||ke(_e,lr(A,se,""))||(E==="src"||E==="xlink:href"||E==="href")&&b!=="script"&&ip(A,"data:")===0&&vf[b]||T&&!ke(Q,lr(A,se,""))?!0:!A:Lf(b)&&ri(Me.tagNameCheck,b)&&ri(Me.attributeNameCheck,E,b)||E==="is"&&Me.allowCustomizedBuiltInElements&&ri(Me.tagNameCheck,A)},Vw=oe({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Lf=function(b){return!Vw[sr(b)]&&ke(he,b)},Kw=function(b,E,A,z){if(S&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!A)switch(p.getAttributeType(b,E)){case"TrustedHTML":return j(z);case"TrustedScriptURL":return te(z)}return z},Xw=function(b,E,A,z){try{A?b.setAttributeNS(A,E,z):b.setAttribute(E,z),ni(b)?$t(b):rp(t.removed)}catch{Jt(E,b)}},Nf=function(b){dt(F.beforeSanitizeAttributes,b,null);const E=b.attributes;if(!E||ni(b))return;ee=Pf(F.uponSanitizeAttribute,ee,lt,ve);const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ee,forceKeepAttr:void 0};let z=E.length;const B=we(b.nodeName);for(;z--;){const q=E[z],ce=q.name,ge=q.namespaceURI,Be=q.value,He=we(ce),zs=Be;let $e=ce==="value"?zs:w1(zs);if(A.attrName=He,A.attrValue=$e,A.keepAttr=!0,A.forceKeepAttr=void 0,dt(F.uponSanitizeAttribute,b,A),$e=A.attrValue,mf&&(He==="id"||He==="name")&&ip($e,bf)!==0&&(Jt(ce,b,q),$e=bf+$e),le&&ke(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,$e)){Jt(ce,b,q);continue}if(He==="attributename"&&op($e,"href")){Jt(ce,b,q);continue}if(!A.forceKeepAttr){if(!A.keepAttr){Jt(ce,b,q);continue}if(!J&&ke(z1,$e)){Jt(ce,b,q);continue}if(ue&&($e=ti($e)),!$f(B,He,$e)){Jt(ce,b,q);continue}$e=Kw(B,He,ge,$e),$e!==zs&&Xw(b,ce,ge,$e)}}dt(F.afterSanitizeAttributes,b,null)},oi=function(b){let E=null;const A=If(b);for(dt(F.beforeSanitizeShadowDOM,b,null);E=A.nextNode();)if(dt(F.uponSanitizeShadowNode,E,null),Rf(E,b),Nf(E),kn(E.content)&&oi(E.content),P(E)===Ye.element){const z=w(E);kn(z)&&(Fs(z),oi(z))}dt(F.afterSanitizeShadowDOM,b,null)},Fs=function(b){const E=[{node:b,shadow:null}];for(;E.length>0;){const A=E.pop();if(A.shadow){oi(A.shadow);continue}const z=A.node,q=P(z)===Ye.element,ce=y(z);if(ce)for(let ge=ce.length-1;ge>=0;--ge)E.push({node:ce[ge],shadow:null});if(q){const ge=N?N(z):null;if(typeof ge=="string"&&we(ge)==="template"){const Be=z.content;kn(Be)&&E.push({node:Be,shadow:null})}}if(q){const ge=w(z);kn(ge)&&E.push({node:null,shadow:ge},{node:ge,shadow:null})}}};return t.sanitize=function($){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,A=null,z=null,B=null;if(Ps=!$,Ps&&($="<!-->"),typeof $!="string"&&!yr($)&&($=M1($),typeof $!="string"))throw Yt("dirty is not a string, aborting");if(!t.isSupported)return $;Dt?(X=pe,ee=ve):Ls(b),(F.uponSanitizeElement.length>0||F.uponSanitizeAttribute.length>0)&&(X=Ge(X)),F.uponSanitizeAttribute.length>0&&(ee=Ge(ee)),t.removed=[];const q=Is&&typeof $!="string"&&yr($);if(q){jw($);const Be=k($);if(typeof Be=="string"){const He=we(Be);if(!X[He]||Ae[He])throw Qo($),Yt("root node is forbidden and cannot be sanitized in-place")}if(ni($))throw Qo($),Yt("root node is clobbered and cannot be sanitized in-place");try{Fs($)}catch(He){throw Qo($),He}}else if(yr($))E=Of("<!---->"),A=E.ownerDocument.importNode($,!0),A.nodeType===Ye.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?E=A:E.appendChild(A),Fs(A);else{if(!Rt&&!ue&&!ze&&$.indexOf("<")===-1)return S&&Xo?j($):$;if(E=Of($),!E)return Rt?null:Xo?C:""}E&&mr&&$t(E.firstChild);const ce=q?$:E;try{const Be=If(ce);for(;z=Be.nextNode();)Rf(z,ce),Nf(z),kn(z.content)&&oi(z.content)}catch(Be){throw q&&(Qo($),Gt(t.removed,He=>{He.element&&ei(He.element)})),Be}if(q)return Gt(t.removed,Be=>{Be.element&&ei(Be.element)}),ue&&Ns($),$;if(Rt){if(ue&&Ns(E),Ko)for(B=ye.call(E.ownerDocument);E.firstChild;)B.appendChild(E.firstChild);else B=E;return(ee.shadowroot||ee.shadowrootmode)&&(B=R.call(r,B,!0)),B}let ge=ze?E.outerHTML:E.innerHTML;return ze&&X["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&ke(L1,E.ownerDocument.doctype.name)&&(ge="<!DOCTYPE "+E.ownerDocument.doctype.name+`>
260
- `+ge),ue&&(ge=ti(ge)),S&&Xo?j(ge):ge},t.setConfig=function(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ls($),Dt=!0,pe=X,ve=ee},t.clearConfig=function(){Tn=null,Dt=!1,pe=null,ve=null,S=O,C=""},t.isValidAttribute=function($,b,E){Tn||Ls({});const A=we($),z=we(b);return $f(A,z,E)},t.addHook=function($,b){typeof b=="function"&&Le(F,$)&&ar(F[$],b)},t.removeHook=function($,b){if(Le(F,$)){if(b!==void 0){const E=y1(F[$],b);return E===-1?void 0:v1(F[$],E,1)[0]}return rp(F[$])}},t.removeHooks=function($){Le(F,$)&&(F[$]=[])},t.removeAllHooks=function(){F=mp()},t}var W1=bp();const j1={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function G1(e){const t=e.options;return ha(t.formatter,void 0,String(t.testData||t.title||""))||"条码"}function Y1(e){return h("div",{class:"print-qrcode",dataset:{codeId:e.id,codeKind:"qrcode"}})}function V1(e){const t=e.options;return h("div",{class:"print-barcode",dataset:{codeId:e.id,codeKind:"barcode"}},[h("svg",{preserveAspectRatio:j1[String(t.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function K1(e){const t=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return t.length!==4||t.some(n=>!Number.isFinite(n))?null:{width:t[2],height:t[3]}}function X1(e,t){const n=e.options,r=Pn(n.barWidth),o=ci(n.barQuietZone),i=a=>{ma(t,G1(e),{format:String(n.barcodeType||"CODE128"),width:r,height:a*r,displayValue:!n.hideTitle,fontSize:(n.fontSize??Er)*r,margin:0,marginLeft:o*r,marginRight:o*r,marginTop:0,marginBottom:di*r});const l=K1(t);return l?{widthUnits:l.width,heightUnits:l.height}:null};try{const a=pi({barHeightMm:n.barHeight,boxWidthMm:en(n.width,n.maxWidth),boxHeightMm:en(n.height,n.maxHeight),dpi:n.printerDpi,barWidth:n.barWidth,measure:i});t.style.width=a.size?`${a.size.widthMm}mm`:"",t.style.height=a.size?`${a.size.heightMm}mm`:""}catch{t.replaceChildren();return}t.setAttribute("shape-rendering","crispEdges")}function Z1(e,t){const n=e.options,r=ha(n.formatter,void 0,String(n.testData||n.title||""))||"二维码";t.replaceChildren();try{const o=Ha.render(r,"qrcode",{qrCodeLevel:String(n.qrCodeLevel??"M"),qrQuietZone:typeof n.qrQuietZone=="number"?n.qrQuietZone:void 0}),i=document.createElement("img");i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`,i.alt="qrcode",i.style.width="100%",i.style.height="100%",i.style.objectFit=String(n.fit||"contain"),i.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",i.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%",t.appendChild(i)}catch{}}function J1(e,t){for(const n of Array.from(e.querySelectorAll("[data-code-kind]"))){const r=n.dataset.codeId,o=t.find(i=>i.id===r);if(o)if(n.dataset.codeKind==="barcode"){const i=n.querySelector("svg");i&&X1(o,i)}else Z1(o,n)}}const Q1={header:"题",data:"数",subtotal:"小",summary:"汇"},ey=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],No=3.7795275591,ty=.1,ts=e=>JSON.parse(JSON.stringify(e)),yp=new WeakMap;function ft(e){let t=yp.get(e);return t||(t={menu:null,menuElId:null,anchor:null,layouts:new Map},yp.set(e,t)),t}function dr(e,t){return e.templateData.elements.find(n=>n.id===t)??null}function ny(e,t){const n=e.tableSelection;return!n||n.elementId!==t.id?null:e.selectedElement?.id!==t.id?(e.tableSelection=null,null):n}function vp(e,t,n){const r=dr(e,n.id);if(!r)return null;const o=n.options;return{store:e,fire:t,el:n,real:r,options:o,rows:o.tableRows??[],colWidths:o.tableColWidths??[],isSelected:e.selectedIds.has(n.id),selection:ny(e,n),maxTableWidth:wp(e)}}function wp(e){return e.paperSize.width-e.templateData.margins.left-e.templateData.margins.right}function ns(e){return e.options.tableDefaultFontSize??10}function xp(e){return e.options.tableDefaultColor??"#333333"}function ry(e,t){let n=0;for(let r=0;r<t;r++)n+=e.rows[r].height;return n}function oy(e,t){return ft(e.store).layouts.get(e.el.id)?.[t]?.top??ry(e,t)}function iy(e,t){return ft(e.store).layouts.get(e.el.id)?.[t]?.height??e.rows[t]?.height??0}function ay(e){const t=e.options.dataSource;if(t&&Array.isArray(it[t]))return it[t];for(const n of Object.values(it))if(Array.isArray(n))return n}function Ep(e){return e.cellType==="barcode"||e.cellType==="qrcode"}function Sp(e,t){return Ep(t)?ha(t.formatter,ay(e)):t.formatter||""}function sy(e,t){const n={designMode:!0,showGhostBorder:e.store.showTableGhostBorder};return{fontFamily:Zi(t.fontFamily??e.options.tableDefaultFontFamily),textAlign:t.align??"left",...t.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:t.valign??"middle",fontSize:(t.fontSize??ns(e))+"pt",fontWeight:t.fontWeight??"normal",color:t.color??xp(e),backgroundColor:t.backgroundColor??"transparent",borderTop:Cr(t.borders?.top,n),borderRight:Cr(t.borders?.right,n),borderBottom:Cr(t.borders?.bottom,n),borderLeft:Cr(t.borders?.left,n),padding:(t.padding??e.options.tableDefaultPadding??1)+"mm",whiteSpace:t.wordWrap??!0?"pre-wrap":"nowrap",overflow:t.wordWrap??!0?"visible":"hidden"}}function ly(e,t,n){const r=e.selection;return[!!r&&t>=r.r1&&t<=r.r2&&n>=r.c1&&n<=r.c2?"cell-selected":"",e.rows[t]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function _p(e){return ii(e)}function cy(e){return _p(e)!=="autoHeight"}function dy(e,t){return t.fontSize??ns(e)}function Fo(e,t,n){return An(e.rows,t,n,e.options.tableDefaultPadding??1)}function uy(e,t,n){return si(e.colWidths,t,n,e.options.tableDefaultPadding??1)}function py(e,t,n){return{maxHeight:Fo(e,n,t)+"mm",overflow:"hidden",...t.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function fy(e,t,n){const r={fitBase:String(dy(e,t)),fitMin:String(Cn(t.shrinkMinFontSize)),fitMm:String(Fo(e,n,t))};return _p(t)==="shrink"&&(r.fit="shrink"),r}function hy(e){const t=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return t.length!==4||t.some(n=>!Number.isFinite(n))?null:{width:t[2],height:t[3]}}const gy={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function my(e,t,n,r){const o=document.createElement("div");o.className="cell-barcode";const i=document.createElementNS(i1,"svg");o.appendChild(i);const a=Sp(e,r);if(r.cellType==="barcode"){i.setAttribute("preserveAspectRatio",gy[r.fit||"contain"]??"xMidYMid meet");const l=Pn(r.barWidth),c=ci(r.barQuietZone),s=u=>{ma(i,a,{format:r.barcodeType||"CODE128",width:l,height:u*l,displayValue:r.showBarcodeText!==!1,fontSize:(r.barFontSize??Er)*l,margin:0,marginLeft:c*l,marginRight:c*l,marginTop:0,marginBottom:di*l});const f=hy(i);return f?{widthUnits:f.width,heightUnits:f.height}:null};let d=null;try{d=pi({barHeightMm:r.barHeight,boxWidthMm:en(uy(e,n,r),r.maxWidth),boxHeightMm:en(Fo(e,t,r),r.maxHeight),dpi:r.printerDpi,barWidth:r.barWidth,measure:s})}catch{d=null}if(!d){i.style.display="none";const u=document.createElement("span");return u.className="cell-barcode-fallback",u.textContent=a||"条码",o.appendChild(u),o}const p=d.size;return p?(i.style.width=`${p.widthMm}mm`,i.style.height=`${p.heightMm}mm`):(i.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",i.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%"),i.setAttribute("shape-rendering","crispEdges"),o}if(i.style.display="none",!a)return o;try{const l=Ha.render(a,"qrcode",{qrCodeLevel:String(r.qrCodeLevel||"M"),qrQuietZone:typeof r.qrQuietZone=="number"?r.qrQuietZone:void 0}),c=document.createElement("img");c.setAttribute("src",`data:image/svg+xml;charset=utf-8,${encodeURIComponent(l)}`),c.setAttribute("alt","qrcode"),c.style.width="100%",c.style.height="100%",c.style.objectFit=r.fit||"contain",r.objectPosition&&(c.style.objectPosition=r.objectPosition),c.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",c.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%",o.appendChild(c)}catch{}return o}function Mp(){const e=document.createElement("div");return e.className="image-placeholder",e.textContent="图片",e}function by(e){const t=e.formatter||"";return t?t.includes("{")?dn(t,it):t:""}function yy(e,t,n){const r=document.createElement("div");r.className="cell-image";const o=Ws(n.fit,Fo(e,t,n));o!==void 0&&(r.style.height=`${o}mm`);const i=by(n);if(!i)return r.appendChild(Mp()),r;const a=document.createElement("img");a.setAttribute("src",i),o!==void 0&&(a.style.width="100%",a.style.height="100%"),a.style.objectFit=n.fit||"contain";for(const[l,c]of Object.entries(hi(n.fit,n.fitScale,n.objectPosition)))a.style[l]=c;return a.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",a.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%",a.addEventListener("error",()=>{a.remove(),r.appendChild(Mp())},{once:!0}),r.appendChild(a),r}function vy(e,t,n,r,o){if(Ep(o))return my(e,n,r,o);if(o.cellType==="image")return yy(e,n,o);const i=Sp(e,o),a=()=>t.type==="data"?h("span",{class:"data-placeholder",text:i}):i;return cy(o)?h("div",{class:"cell-fit",style:py(e,o,n),dataset:fy(e,o,n)},[a()]):a()}function zo(e,t,n){const r={elementId:e.el.id,...bl(e.rows,t,n)};e.store.setTableSelection(r),e.fire("table-selection-change",{elementId:e.el.id,selection:r})}function wy(e,t,n,r,o){if(o.button!==0||(e.fire("table-cell-mousedown",{elementId:e.el.id,r:t,c:n,cellId:r,event:o}),!e.isSelected))return;o.stopPropagation();const i=ft(e.store);o.shiftKey&&e.selection?zo(e,{r:e.selection.r1,c:e.selection.c1},{r:t,c:n}):(i.anchor={r:t,c:n},zo(e,{r:t,c:n},{r:t,c:n})),document.addEventListener("mouseup",()=>{ft(e.store).anchor=null},{once:!0})}function xy(e,t,n){const r=ft(e.store).anchor;r&&zo(e,r,{r:t,c:n})}function Tp(e,t){const n=ft(e);n.menu?.visible&&(n.menu.visible=!1,t("table-menu-close",{elementId:n.menuElId}),e.emit(!1))}function Ey(e,t,n,r){r.preventDefault(),r.stopPropagation(),e.isSelected||e.store.selectOne(e.el.id);const o=e.selection;o&&t>=o.r1&&t<=o.r2&&n>=o.c1&&n<=o.c2||zo(e,{r:t,c:n},{r:t,c:n});const a=ft(e.store);a.menuElId=e.el.id,a.menu&&(a.menu.x=r.clientX,a.menu.y=r.clientY,a.menu.visible=!0),e.fire("table-cell-contextmenu",{elementId:e.el.id,r:t,c:n,clientX:r.clientX,clientY:r.clientY}),e.store.emit(!1),document.addEventListener("mousedown",()=>Tp(e.store,e.fire),{once:!0})}function kp(e,t,n){const r=e.reduce((o,i)=>o+i,0)+(e[t]??0);return r>n?`插入后表格总宽 ${Math.round(r*10)/10}mm 超过打印范围宽度 ${n}mm,请先缩小列宽`:null}function Sy(e,t){const n=e.real.options.tableRows??[],r=e.real.options.tableColWidths??[],o=t(ts(n),ts(r));return o?(window.alert(o),!1):(e.store.recordHistory(),t(n,r),e.store.setTableSelection(null),Ln(e.real.options),e.store.emit(),!0)}function ht(e,t,n){Tp(e.store,e.fire);const r=e.selection;if(!r)return;let o=null;switch(t){case"insert-row-above":o=i=>(xl(i,r.r1,"above"),null);break;case"insert-row-below":o=i=>(xl(i,r.r2,"below"),null);break;case"delete-row":o=i=>Dh(i,r.r1);break;case"insert-col-left":o=(i,a)=>{const l=kp(a,r.c1,e.maxTableWidth);return l||(El(i,a,r.c1,"left"),null)};break;case"insert-col-right":o=(i,a)=>{const l=kp(a,r.c2,e.maxTableWidth);return l||(El(i,a,r.c2,"right"),null)};break;case"delete-col":o=(i,a)=>Rh(i,a,r.c1);break;case"merge":o=i=>(vl(i,r),null);break;case"split":o=i=>(wl(i,r),null);break;case"set-row-type":o=i=>n?Ei(i,r.r1,n):"未指定行类型";break}o&&Sy(e,o)&&e.fire(`table-${t}`,{elementId:e.el.id,...n?{type:n}:{}})}function _y(e){const t=e.selection;if(!t)return!1;for(let n=t.r1;n<=t.r2;n++)for(let r=t.c1;r<=t.c2;r++){const o=e.rows[n]?.cells[r];if(o&&!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1))return!0}return!1}function Cp(e,t){const n=e.selection;return n?n.r1!==n.r2?"行类型仅支持单行设置":Ei(ts(e.rows),n.r1,t):"未选择单元格"}function gt(e,t,n={}){return h("div",{class:`menu-item${n.disabled?" disabled":""}${n.active?" active":""}`,title:n.title||"",text:e,onClick:()=>{n.disabled||t()}})}const rs=()=>h("div",{class:"menu-divider"});function My(e,t,n){const r=ft(e);if(r.menu=n,!n.visible||!r.menuElId)return"";const o=dr(e,r.menuElId);if(!o||o.printElementType.type!=="table")return"";const i=vp(e,t,o);if(!i)return"";const a=i.selection?yl(i.rows,i.selection):"未选择单元格",l=i.selection?i.rows[i.selection.r1]?.type??null:null;return h("div",{class:"table-ctx-menu",style:{left:n.x+"px",top:n.y+"px"},onMousedown:c=>c.stopPropagation()},[gt("在上方插入行",()=>ht(i,"insert-row-above")),gt("在下方插入行",()=>ht(i,"insert-row-below")),gt("删除行",()=>ht(i,"delete-row"),{disabled:i.rows.length<=1}),rs(),gt("在左侧插入列",()=>ht(i,"insert-col-left")),gt("在右侧插入列",()=>ht(i,"insert-col-right")),gt("删除列",()=>ht(i,"delete-col"),{disabled:i.colWidths.length<=1}),rs(),gt("合并单元格",()=>ht(i,"merge"),{disabled:!!a,title:a||""}),gt("拆分单元格",()=>ht(i,"split"),{disabled:!_y(i)}),rs(),h("div",{class:"menu-group-title",text:"行类型"}),...ey.map(c=>gt(c.label,()=>ht(i,"set-row-type",c.value),{disabled:!!Cp(i,c.value),title:Cp(i,c.value)||"",active:l===c.value}))])}let Vt=null;function Ap(){Vt&&(document.removeEventListener("mousemove",os),document.removeEventListener("mouseup",is),Vt.handle.classList.remove("dragging"),Vt=null)}function Ty(e,t){const n=e.closest(".hiprint-printPaper");return(n&&n.offsetWidth>0?n.getBoundingClientRect().width/n.offsetWidth:0)||(t.scale||100)/100}function ky(e,t,n){if(n.button!==0)return;const r=n.currentTarget,o=r.closest(".print-table");if(!o)return;Ap();const i=e.real.options.tableColWidths??[];Vt={store:e.store,fire:e.fire,elId:e.real.id,boundary:t,startX:n.clientX,startWidth:i[t-1]??0,scale:Ty(o,e.store),root:o,wrapper:r.closest(".print-element"),handle:r},r.classList.add("dragging"),e.store.recordHistory(),document.addEventListener("mousemove",os),document.addEventListener("mouseup",is)}function os(e){const t=Vt;if(!t)return;const n=dr(t.store,t.elId),r=n?.options.tableColWidths;if(!n||!r)return;const o=(e.clientX-t.startX)/(t.scale*No),i=t.boundary-1;r[i]=Hh(r,i,t.startWidth+o,wp(t.store)),Ln(n.options),r.forEach((a,l)=>{const c=t.root.querySelector(`colgroup col:nth-child(${l+1})`);c&&(c.style.width=`${a}mm`)}),t.root.querySelectorAll(".col-resize-handle").forEach((a,l)=>{a.style.left=`${r.slice(0,l+1).reduce((c,s)=>c+s,0)}mm`}),t.wrapper&&(t.wrapper.style.width=`${n.options.width}mm`,t.wrapper.style.height=`${n.options.height}mm`)}function is(){document.removeEventListener("mousemove",os),document.removeEventListener("mouseup",is);const e=Vt;if(!e)return;Vt=null,e.handle.classList.remove("dragging");const t=dr(e.store,e.elId);t&&Ln(t.options),e.store.emit(),e.fire("table-col-resize-end",{elementId:e.elId})}function Cy(e,t,n){const r=n.querySelector("table");if(!r)return;const o=r.offsetHeight;if(o<=0)return;const i=dr(e,t);if(!i)return;let a=!1;const l=o/No;Math.abs(l-(i.options.height??0))>ty&&(i.options.height=Math.round(l*100)/100,a=!0);const c=r.offsetTop,s=Array.from(r.rows).map(p=>({top:(p.offsetTop-c)/No,height:p.offsetHeight/No})),d=ft(e);Ay(d.layouts.get(t),s)||(d.layouts.set(t,s),a=!0),a&&e.emit(!1)}function Ay(e,t){return!e||e.length!==t.length?!1:t.every((n,r)=>{const o=e[r];return Math.round(n.top*10)===Math.round(o.top*10)&&Math.round(n.height*10)===Math.round(o.height*10)})}function Oy(e,t){const n=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!n.isConnected)return;const r=n.parentElement;r&&Cy(e,t,r)}),n}function Iy(e){return e.isSelected&&!e.real.options.locked&&e.colWidths.length>=1}function Py(e){return Array.from({length:e.colWidths.length},(t,n)=>n+1)}function Dy(e,t){return e.colWidths.slice(0,t).reduce((n,r)=>n+r,0)}function Ry(e,t,n){const r=vp(t,n,e);if(!r)return h("div",{class:"print-table"});const o=[h("table",{style:{fontSize:`${ns(r)}pt`,color:xp(r)}},[h("colgroup",{},r.colWidths.map(i=>h("col",{style:{width:i+"mm"}}))),h("tbody",{},r.rows.map((i,a)=>h("tr",{style:{height:i.height+"mm"}},i.cells.map((l,c)=>l.merged?"":h("td",{rowspan:l.rowspan||1,colspan:l.colspan||1,class:ly(r,a,c),style:sy(r,l),onMousedown:s=>wy(r,a,c,l.id,s),onMouseenter:()=>xy(r,a,c),onContextmenu:s=>Ey(r,a,c,s)},[vy(r,i,a,c,l)])).filter(Boolean))))])];return Iy(r)&&o.push(h("div",{class:"col-resize-layer"},Py(r).map(i=>h("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${i}`,style:{left:Dy(r,i)+"mm"},onMousedown:a=>{a.stopPropagation(),a.preventDefault(),ky(r,i,a)}})))),r.isSelected&&o.push(h("div",{class:"row-badges"},r.rows.map((i,a)=>h("span",{class:"row-badge",style:{top:oy(r,a)+"mm",height:iy(r,a)+"mm"},text:Q1[i.type]})))),o.push(Oy(t,e.id)),h("div",{class:"print-table design-mode",dataset:{tableId:e.id},onContextmenu:i=>i.preventDefault()},o)}const $y=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function as(e){return Array.isArray(e)&&e.length>0?e:[]}function Ly(e,t){const n=xr(e,t)??(t?Object.keys(t).find(o=>Array.isArray(t[o])):void 0);if(n)return as(t?.[n]);const r=xr(e,it);return r?as(it[r]):[]}function Ny(e,t){const n=e.options,r=typeof n.formatter=="string"?n.formatter:"",o=as(t)[0],i=Ly(r,o);if(i.length===0)return[...$y];if(!r)return i.map(c=>String(c?.name??JSON.stringify(c)));const a=o??{},l=xr(r,a)??Object.keys(a).find(c=>Array.isArray(a[c]));return i.map(c=>{try{return dn(r,{...a,...c,...l?{[l]:c}:{}})}catch{return r}})}function Fy(e,t){const n=e.options,r=ut(n.flowColumns),o=xt(n.flowGapX),i=On(n.flowRowHeight),a={display:"grid",gridTemplateColumns:`repeat(${r},minmax(0,1fr))`,columnGap:`${o}mm`,gridAutoRows:`minmax(${i}mm,auto)`,width:"100%",height:"100%",overflow:"hidden",fontSize:`${n.fontSize||12}pt`,fontWeight:n.fontWeight||"normal",color:n.color||"#333",boxSizing:"border-box"};return n.fontFamily&&(a.fontFamily=String(n.fontFamily)),n.backgroundColor&&(a.backgroundColor=String(n.backgroundColor)),h("div",{class:"print-flowlist",style:a},Ny(e,t).map(l=>h("div",{class:"print-flow-cell",text:l})))}const Op={top:"flex-start",middle:"center",bottom:"flex-end"},zy={left:"flex-start",center:"center",right:"flex-end"};function By(e,t){const n=e.options,r=tl(e.printElementType.type,n),o={};if(r?.all&&(o.border=`${r.all.borderWidth} ${r.all.borderStyle} ${r.all.borderColor}`),r)for(const i of _r){const a=r.edges[i];a&&(o[`border${i.charAt(0).toUpperCase()}${i.slice(1)}`]=`${a.borderWidth} ${a.borderStyle} ${a.borderColor}`)}return{position:"absolute",left:`${n.left}mm`,top:`${n.top}mm`,width:`${n.width}mm`,height:`${n.height}mm`,zIndex:String(n.zIndex||"auto"),...o,...Hy(e,t)}}function Hy(e,t){if(t?.has(e.id))return{};const n=gi(e.printElementType.type,e.options);return n===void 0?{}:{rotate:`${n}deg`}}function Ip(e){const t=e.options,n=e.printElementType.type==="longText",r=wr(e.printElementType.type,t),o=t.fontSize||12,i=r==="autoHeight",a={fontSize:`${o}pt`,fontWeight:t.fontWeight||"normal",fontFamily:Zi(t.fontFamily),color:t.color||"#333",backgroundColor:t.backgroundColor||"transparent",textAlign:t.textAlign||"left",...t.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:t.lineHeight?`${t.lineHeight}pt`:n?"1.5":"normal",letterSpacing:t.letterSpacing?`${t.letterSpacing}pt`:"normal",width:"100%",height:i?"auto":"100%",boxSizing:"border-box",overflow:i?"visible":"hidden",...n?{wordBreak:"break-all",textIndent:t.longTextIndent?`${t.longTextIndent}em`:"0"}:{textDecoration:t.textDecoration||"none",padding:`${t.contentPaddingTop||0}pt ${t.contentPaddingRight||0}pt ${t.contentPaddingBottom||0}pt ${t.contentPaddingLeft||0}pt`}};qs(t)&&(a.whiteSpace="nowrap",a.textOverflow="ellipsis");const l=Us(t);return l&&(a.whiteSpace=l),t.verticalAlign&&(a.display="flex",t.textAlign==="justify"?(a.flexDirection="column",a.justifyContent=Op[t.verticalAlign]??"flex-start"):(a.alignItems=Op[t.verticalAlign]??"flex-start",a.justifyContent=zy[t.textAlign||"left"]??"flex-start")),{style:a,fit:r}}function Uy(e){const t=e.options,n=`${t.borderWidth||.75}pt`,r=t.borderStyle||"solid",o=t.borderColor||"#333";return e.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${n} ${r} ${o}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${n} ${r} ${o}`,boxSizing:"border-box"}}function qy(e){const t=e.options;return{width:"100%",height:"100%",borderWidth:`${t.borderWidth||1}pt`,borderStyle:t.borderStyle||"solid",borderColor:t.borderColor||"#333",backgroundColor:t.backgroundColor||"transparent",borderRadius:e.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Wy(e){const t=e.options;return{objectFit:t.fit||"contain",...hi(t.fit,t.fitScale,t.objectPosition),maxWidth:t.maxWidth?`${t.maxWidth}mm`:"100%",maxHeight:t.maxHeight?`${t.maxHeight}mm`:"100%"}}function Pp(e){const t=e.options,n={fitBase:String(t.fontSize||12),fitMin:String(Cn(t.shrinkMinFontSize))};return wr(e.printElementType.type,t)==="shrink"&&(n.fit="shrink"),n}function jy(e,t,n){const r=e.printElementType.type,o=e.options;switch(r){case"text":{const{style:i}=Ip(e);return h("div",{class:"print-text",style:i,dataset:Pp(e),text:String(o.testData||o.formatter||"")||"文本"})}case"longText":{const{style:i}=Ip(e);return h("div",{class:"print-longtext",style:i,dataset:Pp(e),text:String(o.formatter||"")||"长文本内容"})}case"hline":case"vline":return h("div",{class:"print-line",style:Uy(e)});case"rect":case"oval":return h("div",{class:"print-shape",style:qy(e)});case"image":{const i=String(o.src??""),a=i.includes("{")?dn(i,it):i;return h("div",{class:"print-image"},[a?h("img",{src:a,style:Wy(e)}):h("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return Y1(e);case"barcode":return V1(e);case"html":{const i=String(o.formatter??""),a=i?W1.sanitize(dn(i,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return h("div",{class:"print-html",html:a})}case"pageNumber":return h("div",{class:"page-number-element",style:{fontSize:`${o.fontSize||12}pt`,fontWeight:o.fontWeight||"normal",fontFamily:Zi(o.fontFamily),color:o.color||"#333",textAlign:o.textAlign||"left",...o.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:o.title||"{pageIndex}/{totalPages}"});case"table":return n?Ry(e,n.store,n.fire):h("div",{class:"print-table"});case"flowList":return Fy(e);default:return h("div",{text:r})}}function Dp(e){return`x:${Math.round(e.left)} y:${Math.round(e.top)} ${Math.round(e.width)}×${Math.round(e.height)}mm`}function Gy(e,t,n){const r=e.store,o=r.selectedIds.has(t.id),i=r.previewIds.has(t.id),a=t.options,l=t.zone||"content",c=[jy(t,!0,{store:r,fire:e.fire})];return r.draggingIds.has(t.id)&&c.push(h("div",{class:"drag-preview"})),o&&(c.push(h("div",{class:"resize-handles"},A0.map(s=>h("div",{class:`resize-handle handle-${s}`,dataset:{point:s,elId:t.id},onMousedown:d=>e.fire("resize-start",{event:d,id:t.id,point:s})})))),c.push(h("div",{class:"selected-indicator"},[h("div",{class:"position-label",text:Dp(a)})]))),h("div",{class:["print-element",`type-${t.printElementType.type}`,`zone-${l}`,o?"selected":"",i?"previewed":"",r.draggingIds.has(t.id)?"drag-ghost":"","design-mode",a.locked?"locked":"",a.visible===!1?"hidden":""].filter(Boolean).join(" "),style:By(t,n),dataset:{elId:t.id},onMousedown:s=>e.fire("element-mousedown",{event:s,id:t.id}),onContextmenu:s=>{s.preventDefault(),s.stopPropagation(),e.fire("contextmenu",{event:s,id:t.id})}},c)}function ss(e,t){const n=e.margins,r=e.header?.height??10,o=e.footer?.height??10,i=t.width-n.left-n.right;return{header:{left:n.left,top:n.top,width:i,height:r},content:{left:n.left,top:n.top+r,width:i,height:t.height-n.top-n.bottom-r-o},footer:{left:n.left,top:t.height-n.bottom-o,width:i,height:o}}}const Yy='<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>';function Rp(e,t){return e.type==="vertical"?{left:`${e.position}mm`,top:"0",height:`${t.height}mm`,borderLeftColor:e.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${e.position}mm`,left:"0",width:`${t.width}mm`,borderTopColor:e.color||"var(--pd-accent-secondary, #f56c6c)"}}function Vy(e,t){const n=wc(e.watermark,[],t);return n?h("div",{class:"watermark-layer",style:{opacity:String(n.opacity)}},n.tiles.map(r=>h("svg",{class:"watermark-tile",width:`${r.widthMm}mm`,height:`${r.heightMm}mm`,viewBox:`0 0 ${n.tileWidthPx} ${n.tileHeightPx}`,style:{left:`${r.leftMm}mm`,top:`${r.topMm}mm`}},[h("text",{x:String(n.tileWidthPx/2),y:String(n.tileHeightPx/2),"font-size":String(n.fontSizePx),fill:n.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${n.rotate},${n.tileWidthPx/2},${n.tileHeightPx/2})`,text:n.text})]))):""}function ls(e,t,n,r,o,i){const a=e.store,l=[];n!=="content"&&l.push(h("span",{class:"zone-label",text:n==="header"?"页眉":"页脚"}));const c=n==="content"?cl(o):void 0;if(l.push(...o.map(s=>Gy(e,s,c))),n!=="content"){const s=n==="header"?"bottom":"top";l.push(h("div",{class:`zone-resize-handle handle-${s}`,dataset:{zone:n},onMousedown:d=>e.fire("zone-resize",{event:d,zone:n})},[t.zoneResizing===n?h("div",{class:"zone-height-tip",text:`${(n==="header"?a.templateData.header.height:a.templateData.footer.height).toFixed(1)}mm`}):""]))}return h("div",{class:`zone-layer zone-${n} design-mode`,style:{position:"absolute",left:`${r.left}mm`,top:`${r.top}mm`,width:`${r.width}mm`,height:`${r.height}mm`},dataset:{zone:n,paperWidth:String(i.width),paperHeight:String(i.height)}},l.filter(Boolean))}function Ky(e){const t=e.currentTarget,n=e.dataTransfer?.types??[],r=n.includes("fieldkey"),o=n.includes("elementtype");if(!r&&!o){t.querySelector(".drop-hint")?.remove();return}r&&(e.ctrlKey||e.metaKey)&&(t.dataset.dropLabelIntent="1");const i=o?"+ 元素":t.dataset.dropLabelIntent?"+ 静态文本":"+ 取值字段";let a=t.querySelector(".drop-hint");a||(a=document.createElement("div"),a.className="drop-hint",t.appendChild(a)),a.textContent=i,a.style.left=`${e.clientX+14}px`,a.style.top=`${e.clientY+18}px`}function $p(e){e&&(e.querySelector(".drop-hint")?.remove(),delete e.dataset.dropLabelIntent)}function Xy(e,t){const n=e.store,r=n.templateData,o=Ze(r),i=(n.scale||100)/100,a=ss(r,o),l=p=>n.elements.filter(u=>(u.zone||"content")===p),c=h("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${r.margins.top}mm ${r.margins.right}mm ${r.margins.bottom}mm ${r.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${o.height}mm`}},[n.showGrid?h("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(Yy)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...r.watermark&&Object.keys(r.watermark).length?[Vy(r,o)]:[],ls(e,t,"header",a.header,l("header"),o),ls(e,t,"content",a.content,l("content"),o),ls(e,t,"footer",a.footer,l("footer"),o),...n.adsorbGuides.map(p=>h("div",{class:`adsorb-guide guide-${p.type}`,style:Rp(p,o)})),...(r.guides??[]).map(p=>h("div",{class:`manual-guide guide-${p.type}`,style:{...Rp(p,o),"--guide-hit":`${8/i}px`},dataset:{guideId:String(p.id??"")},onMousedown:u=>e.fire("guide-mousedown",{event:u,id:p.id}),onDblclick:u=>{u.preventDefault(),e.fire("guide-remove",p.id)}}))].filter(Boolean)),s=h("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${o.width}mm`,minHeight:`${o.height}mm`,background:r.pageBackground||"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))",overflow:"hidden",position:"relative",transform:`scale(${i})`,transformOrigin:"0 0"}},[...r.designBackground?.src?[h("div",{class:"design-background",style:{width:`${o.width}mm`,height:`${o.height}mm`,left:"0",top:"0",transform:r.designBackground.rotation?`rotate(${r.designBackground.rotation}deg)`:""}},[h("img",{src:r.designBackground.src,draggable:!1,alt:""})])]:[],c]),d=[h("div",{class:"canvas-scroll"},[h("div",{class:"paper-wrapper",style:{width:`${Hr(o.width)*i}px`,height:`${Hr(o.height)*i}px`,position:"relative"}},[s])])];if(n.showRuler&&d.push(h("div",{class:"ruler-overlay",style:{transform:`translate(${t.scrollX}px, ${t.scrollY}px)`}},[h("div",{class:"ruler-corner"}),h("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${t.geom.viewW}px`,height:"20px"},onMousedown:p=>e.fire("ruler-mousedown",{event:p,orientation:"horizontal"})}),h("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${t.geom.viewH}px`},onMousedown:p=>e.fire("ruler-mousedown",{event:p,orientation:"vertical"})})])),t.guidePreview&&d.push(h("div",{class:`ruler-guide-preview guide-${t.guidePreview.type}`,style:t.guidePreview.type==="vertical"?{left:`${t.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${t.guidePreview.position}px`,left:"0",width:"100%"}})),t.marquee.visible&&d.push(h("div",{class:"marquee-selection",style:{left:`${t.marquee.x}px`,top:`${t.marquee.y}px`,width:`${t.marquee.w}px`,height:`${t.marquee.h}px`}})),t.contextMenu.visible){const p=t.contextMenu;d.push(h("div",{class:"context-menu",style:{left:`${t.contextMenu.x+t.contextMenu.flipX}px`,top:`${t.contextMenu.y+t.contextMenu.flipY}px`}},t.contextMenu.targetId?[et(e,p,"复制","copy"),et(e,p,"剪切","cut"),et(e,p,"粘贴","paste",!n.hasClipboard),et(e,p,"删除","delete"),h("div",{class:"context-menu-sep"}),et(e,p,"置顶","move-layer",!1,"top"),et(e,p,"上移","move-layer",!1,"up"),et(e,p,"下移","move-layer",!1,"down"),et(e,p,"置底","move-layer",!1,"bottom")]:[et(e,p,"粘贴","paste-at",!n.hasClipboard),et(e,p,"全选","select-all"),et(e,p,"取消选择","clear-selection")]))}return h("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:p=>{const u=p;u.preventDefault(),u.dataTransfer&&(u.dataTransfer.dropEffect="copy"),Ky(u)},onDragleave:p=>{const u=p.currentTarget,f=p.relatedTarget;(!f||!u.contains(f))&&u.querySelector(".drop-hint")?.remove()},onDrop:p=>{const u=p,f=p.currentTarget,g=f.dataset.dropLabelIntent==="1";$p(f),g&&(u.labelIntent=!0),e.fire("drop",u)},onMousedown:p=>e.fire("canvas-mousedown",p),onMousemove:p=>e.fire("canvas-mousemove",p),onMouseleave:()=>e.fire("canvas-mouseleave"),onWheel:p=>e.fire("wheel",p),onScroll:p=>e.fire("scroll",p),onContextmenu:p=>{p.preventDefault(),e.fire("canvas-contextmenu",p)}},d.filter(Boolean))}function et(e,t,n,r,o=!1,i){return h("div",{class:`context-menu-item${o?" disabled":""}`,text:n,onClick:()=>{t.visible=!1,o||e.fire(r,i),e.repaint()}})}const Zy={AlignCenterHorizontal:'<path d="M2 12h20" /><path d="M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4" /><path d="M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4" /><path d="M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1" /><path d="M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1" />',AlignCenterVertical:'<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />',AlignEndHorizontal:'<rect width="6" height="16" x="4" y="2" rx="2" /><rect width="6" height="9" x="14" y="9" rx="2" /><path d="M22 22H2" />',AlignEndVertical:'<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />',AlignHorizontalSpaceBetween:'<rect width="6" height="14" x="3" y="5" rx="2" /><rect width="6" height="10" x="15" y="7" rx="2" /><path d="M3 2v20" /><path d="M21 2v20" />',AlignStartHorizontal:'<rect width="6" height="16" x="4" y="6" rx="2" /><rect width="6" height="9" x="14" y="6" rx="2" /><path d="M22 2H2" />',AlignStartVertical:'<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />',AlignVerticalSpaceBetween:'<rect width="14" height="6" x="5" y="15" rx="2" /><rect width="10" height="6" x="7" y="3" rx="2" /><path d="M2 21h20" /><path d="M2 3h20" />',ArrowDown:'<path d="M12 5v14" /><path d="m19 12-7 7-7-7" />',ArrowDownToLine:'<path d="M12 17V3" /><path d="m6 11 6 6 6-6" /><path d="M19 21H5" />',ArrowUp:'<path d="m5 12 7-7 7 7" /><path d="M12 19V5" />',ArrowUpToLine:'<path d="M5 3h14" /><path d="m18 13-6-6-6 6" /><path d="M12 7v14" />',Bold:'<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" />',Check:'<path d="M20 6 9 17l-5-5" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',ClipboardPaste:'<path d="M11 14h10" /><path d="M16 4h2a2 2 0 0 1 2 2v1.344" /><path d="m17 18 4-4-4-4" /><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /><rect x="8" y="2" width="8" height="4" rx="1" />',Copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',Ellipsis:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',Eye:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />',Grid3x3:'<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /><path d="M9 3v18" /><path d="M15 3v18" />',Group:'<path d="M3 7V5c0-1.1.9-2 2-2h2" /><path d="M17 3h2c1.1 0 2 .9 2 2v2" /><path d="M21 17v2c0 1.1-.9 2-2 2h-2" /><path d="M7 21H5c-1.1 0-2-.9-2-2v-2" /><rect width="7" height="5" x="7" y="7" rx="1" /><rect width="7" height="5" x="10" y="12" rx="1" />',Layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',Maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />',PaintBucket:'<path d="M11 7 6 2" /><path d="M18.992 12H2.041" /><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" /><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" />',Paintbrush:'<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',Strikethrough:'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />',TextAlignCenter:'<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />',TextAlignEnd:'<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />',TextAlignJustify:'<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />',TextAlignStart:'<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />',Trash2:'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',Underline:'<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />',Undo2:'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />',Ungroup:'<rect width="8" height="6" x="5" y="4" rx="1" /><rect width="8" height="6" x="11" y="14" rx="1" />',ZoomIn:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="11" x2="11" y1="8" y2="14" /><line x1="8" x2="14" y1="11" y2="11" />',ZoomOut:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="8" x2="14" y1="11" y2="11" />'};function Re(e,t=15,n){const r=Zy[e];return r?`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}"${n?` class="${n}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`:""}let Kt=null;function cs(e){const t=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return null;const n=t[1],r=n.length===3?n.split("").map(o=>o+o).join(""):n;return{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16)}}function ds(e){const t=cs(e);return t?Lp(t):"#000000"}function Lp({r:e,g:t,b:n}){return`#${[e,t,n].map(r=>Math.round(ur(r/255)*255).toString(16).padStart(2,"0")).join("")}`}function Jy(e,t,n){const r=e/255,o=t/255,i=n/255,a=Math.max(r,o,i),l=Math.min(r,o,i),c=a-l;let s=0;return c!==0&&(a===r?s=(o-i)/c%6:a===o?s=(i-r)/c+2:s=(r-o)/c+4,s*=60,s<0&&(s+=360)),{h:s,s:a===0?0:c/a,v:a}}function Qy(e,t,n){const r=n*t,o=(e%360+360)%360/60,i=r*(1-Math.abs(o%2-1)),[a,l,c]=o<1?[r,i,0]:o<2?[i,r,0]:o<3?[0,r,i]:o<4?[0,i,r]:o<5?[i,0,r]:[r,0,i],s=n-r;return{r:(a+s)*255,g:(l+s)*255,b:(c+s)*255}}function ev(e){return((Number.isFinite(e)?e:0)%360+360)%360}function ur(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:0))}function tv(e){const t=e.title??"颜色选择";return h("button",{type:"button",class:`preset-color-trigger${e.triggerClass?` ${e.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:t,onClick:n=>{const r=n.currentTarget??n.target,o=r.getRootNode();if(!!Kt&&Kt.root===o&&Kt.title===t&&Kt.trigger===r){pr();return}pr(),nv(r,e)}},[h("span",{class:"preset-color-swatch",style:e.value?{background:e.value}:{background:"transparent"}})])}function pr(){const e=Kt;e&&(Kt=null,e.teardowns.forEach(t=>t()),e.trigger.setAttribute("aria-expanded","false"),e.panel.remove())}function nv(e,t){const n=e.getRootNode(),r=n instanceof ShadowRoot?n:document.body,o={root:n,title:t.title??"颜色选择",trigger:e,panel:null,clearable:t.clearable!==!1,onChange:t.onChange,model:t.value||void 0,hue:0,saturation:0,value_:0,hexText:"",dragging:!1,current:null,hex:null,area:null,handle:null,hueRange:null,clearBtn:null,items:[],teardowns:[]};t.value&&ps(o,t.value)?o.hexText=ds(t.value).toUpperCase():o.hexText=t.value?String(t.value):"",o.panel=De(av(o),r),o.current=o.panel.querySelector(".picker-current"),o.hex=o.panel.querySelector(".picker-hex"),o.area=o.panel.querySelector(".picker-area"),o.handle=o.panel.querySelector(".picker-handle"),o.hueRange=o.panel.querySelector(".picker-hue"),o.clearBtn=o.panel.querySelector(".picker-clear"),o.items=Array.from(o.panel.querySelectorAll(".preset-color-item")).map((i,a)=>({el:i,color:zl[a]})),Bo(o),rv(o),ov(o),Kt=o,e.setAttribute("aria-expanded","true")}function rv(e){const t=e.trigger.getBoundingClientRect(),n=190,r=e.panel.offsetHeight||216,o=8,i=Math.max(o,Math.min(t.left,window.innerWidth-n-o)),a=t.bottom+6,l=a+r>window.innerHeight-o?Math.max(o,t.top-r-6):a;e.panel.style.left=`${i}px`,e.panel.style.top=`${l}px`}function ov(e){const t=o=>{const i=iv(o);i.includes(e.trigger)||i.includes(e.panel)||pr()},n=o=>{o.key==="Escape"&&pr()},r=()=>pr();document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",n),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),e.root.addEventListener("scroll",r,!0),e.teardowns.push(()=>document.removeEventListener("pointerdown",t,!0),()=>document.removeEventListener("keydown",n),()=>window.removeEventListener("scroll",r,!0),()=>window.removeEventListener("resize",r),()=>e.root.removeEventListener("scroll",r,!0))}function iv(e){const t=typeof e.composedPath=="function"?e.composedPath():[];return t.length?t:[e.target]}function av(e){return h("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:t=>t.stopPropagation()},[h("div",{class:"picker-preview"},[h("span",{class:"picker-current"}),h("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:t=>lv(e,t.target.value)})]),h("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:t=>cv(e,t),onKeydown:t=>dv(e,t)},[h("span",{class:"picker-handle"})]),h("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:t=>uv(e,Number(t.target.value)),onChange:()=>fs(e)}),h("div",{class:"picker-heading"},[h("span",{text:"常用颜色"}),e.clearable?h("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>Ho(e,void 0)},[h("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[h("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),h("div",{class:"preset-color-grid"},zl.map(t=>h("button",{type:"button",class:"preset-color-item",style:{background:t},title:t,"aria-label":t,onClick:()=>sv(e,t)})))])}function us(e){return Lp(Qy(e.hue,e.saturation,e.value_))}function Bo(e){const t=us(e);e.hex.value!==e.hexText&&(e.hex.value=e.hexText),e.current.className=e.model?"picker-current":"picker-current is-empty",e.model?e.current.style.background=t:e.current.style.removeProperty("background"),e.area.style.setProperty("--picker-hue",`${Math.round(e.hue)}deg`),e.handle.style.left=`${e.saturation*100}%`,e.handle.style.top=`${(1-e.value_)*100}%`,e.handle.style.background=t;const n=String(Math.round(e.hue));e.hueRange.value!==n&&(e.hueRange.value=n),e.clearBtn&&(e.clearBtn.disabled=!e.model);for(const r of e.items)r.el.className=e.model&&r.color.toLowerCase()===e.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function ps(e,t){const n=cs(t);if(!n)return!1;const r=Jy(n.r,n.g,n.b);return e.hue=r.h,e.saturation=r.s,e.value_=r.v,e.hexText=ds(t).toUpperCase(),!0}function vn(e,t,n,r){e.hue=ev(t),e.saturation=ur(n),e.value_=ur(r),e.hexText=us(e).toUpperCase(),Bo(e)}function fs(e){const t=us(e);e.model=t,Bo(e),e.onChange(t)}function Ho(e,t){e.model=t,t||(e.hexText=""),Bo(e),e.onChange(t)}function sv(e,t){ps(e,t),Ho(e,t)}function lv(e,t){const n=t.trim();if(!n){e.clearable&&Ho(e,void 0);return}cs(n)&&(ps(e,n),Ho(e,ds(n)))}function cv(e,t){e.dragging=!0,Np(e,t);const n=o=>{e.dragging&&Np(e,o)},r=()=>{e.dragging&&(e.dragging=!1,document.removeEventListener("pointermove",n),document.removeEventListener("pointerup",r),document.removeEventListener("pointercancel",r),fs(e))};document.addEventListener("pointermove",n),document.addEventListener("pointerup",r),document.addEventListener("pointercancel",r)}function Np(e,t){const n=e.area.getBoundingClientRect();if(!n.width||!n.height)return;const r=ur((t.clientX-n.left)/n.width),o=ur(1-(t.clientY-n.top)/n.height);vn(e,e.hue,r,o)}function dv(e,t){const n=t.shiftKey?.1:.02;let r=!0;t.key==="ArrowLeft"?vn(e,e.hue,e.saturation-n,e.value_):t.key==="ArrowRight"?vn(e,e.hue,e.saturation+n,e.value_):t.key==="ArrowUp"?vn(e,e.hue,e.saturation,e.value_+n):t.key==="ArrowDown"?vn(e,e.hue,e.saturation,e.value_-n):r=!1,r&&(t.preventDefault(),fs(e))}function uv(e,t){vn(e,t,e.saturation,e.value_)}function be(e,t,n,r){return h("button",{class:`tb-btn tb-icon${r.on?" on":""}${r.danger?" danger":""}`,type:"button",disabled:!!r.disabled,dataset:{tip:r.tip,...r.test?{test:r.test}:{}},onClick:()=>e.fire(n,r.arg),html:Re(t)})}function Uo(e,t,n,r){const o=e.state.openDd===t,i=()=>{e.state.openDd=o?null:t,e.repaint()};return h("div",{class:"tb-dd"},[h("button",{type:"button",class:`tb-dd-trigger${o?" on":""}`,disabled:!!n.disabled,dataset:{test:n.testId??t,tip:n.tip},onClick:i,html:`${n.icon?Re(n.icon):""}${n.text?`<span class="${n.textClass??"tb-btn-text"}">${n.text}</span>`:""}${Re("ChevronDown",12,`tb-dd-arrow${o?" up":""}`)}`}),o?h("div",{class:`tb-dd-panel${n.panelClass?` ${n.panelClass}`:""}`},r):""].filter(Boolean))}function Z(e){const t=e.step??1,n=String(t),r=n.indexOf("."),o=r===-1?0:n.length-r-1,i=p=>Number.isFinite(p)?Number(p.toFixed(o)):0,a=p=>{let u=i(p);return e.min!==void 0&&u<e.min&&(u=e.min),e.max!==void 0&&u>e.max&&(u=e.max),u},l=e.value===void 0||e.value===null||!Number.isFinite(e.value)?void 0:i(e.value),c=l??e.min??0,s=p=>{p!==l&&e.onCommit(p)},d=h("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:e.min,max:e.max,step:t,placeholder:e.placeholder,disabled:!!e.disabled,onChange:p=>{const u=p.target,f=(u.value??"").trim();if(f===""){l!==void 0&&(u.value=String(l));return}const g=Number(f);if(!Number.isFinite(g)){u.value=l===void 0?"":String(l);return}const m=a(g);u.value=String(m),s(m)}});return h("div",{class:"pd-stepper"},[h("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!e.disabled||c<=(e.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>s(a(c-t))}),d,h("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!e.disabled||c>=(e.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>s(a(c+t))})])}function ie(e,t,n,r){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),r??""]),t,n?h("p",{class:"pd-hint",text:n}):""].filter(Boolean))}const hs=e=>h("button",{class:"pd-help",type:"button","data-tip":e,"aria-label":"字段说明"});function Ve(e,t,n,r){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[e,hs(n)]),r??""]),t])}function Xt(e){const t=e.base?.[e.propKey],n=e.target?.[e.propKey]!==t,r=e.force===!0||n,o=e.tipOverride??(e.tipValue===void 0?"恢复默认值":`恢复默认值(${e.tipValue}${e.tipUnit?" "+e.tipUnit:""})`),i=e.force?`${o}(应用到全部选中格)`:o;return h("button",{type:"button",class:`pd-reset-btn${n&&!e.force?" is-dirty":""}`,"data-tip":i,"aria-label":i,html:Re("RotateCcw",13),onClick:()=>{r&&(e.write?e.write(t):e.target[e.propKey]=t,e.onReset?.())}})}const st=e=>h("h3",{class:"pd-divider",text:e});function Ke(e,t,n="颜色选择",r){return tv({value:e,title:n,triggerClass:r,onChange:o=>t(o)})}function Ct(e,t,n,r,o=!1){return h("div",{class:`pd-radio-group${o?" pd-radio-group--2col":""}`,role:"radiogroup"},t.map(i=>h("label",{class:"pd-radio"},[h("input",{type:"radio",name:e,value:i.value,checked:n===i.value,onChange:()=>r(i.value)}),h("span",{text:i.label})])))}function Fp(e,t,n,r={}){const o=document.createElement("select");o.className=r.className??"pd-select",r.width&&(o.style.width=r.width);for(const i of t){const a=document.createElement("option");a.value=i.value,a.textContent=i.label,i.disabled&&(a.disabled=!0),o.appendChild(a)}return o.value=e,t.some(i=>i.value===e)||(o.selectedIndex=-1),o.addEventListener("change",()=>n(o.value)),o}function pv(e){const t=window.innerHeight;for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement){const r=getComputedStyle(n).overflowY;if(r==="auto"||r==="scroll"||r==="hidden"||r==="clip"){const o=n.getBoundingClientRect();return{top:Math.max(0,o.top),bottom:Math.min(t,o.bottom)}}}return{top:0,bottom:t}}function qo(e){const t=tm(e.fonts),n=e.placeholder??"默认",r=`font-select-list-${e.id}`,o=k=>{const S=k?.trim();return S?sc(t,S)?.label??S:""},i=k=>{const S=qn(k);return t.find(O=>O.label&&qn(O.label)===S)?.family??k},a=()=>{const k=e.value?.trim();return k?sc(t,k)?"":k:""},l=k=>{const S=(e.value??"").trim(),C=(I,x,j,te)=>({kind:I,key:x,label:j,value:te,selected:(te??"")===S}),O=k.trim();if(!O){const I=[C("clear","__clear__",n)],x=a();x&&I.push(C("unknown","__unknown__",`${x}(未知)`,x));for(const j of t)I.push(C("font",j.family,lc(j),j.family));return I}const D=rm(t,O).map(I=>C("font",I.family,lc(I),I.family));if(!D.length){const I=i(O);D.push(C("free","__free__",`使用「${I}」`,I))}return D},c=document.createElement("div");c.className="font-select";const s=document.createElement("input");s.className="pd-input font-select-input",s.type="text",s.setAttribute("role","combobox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-controls",r),s.autocomplete="off",s.placeholder=n,s.disabled=!!e.disabled,s.value=o(e.value);const d=document.createElement("ul");d.id=r,d.className="font-select-list",d.setAttribute("role","listbox");const p=e.state.fontOpen?.id===e.id?e.state.fontOpen:null,u={open:!!p&&!e.disabled,query:p?.query??"",highlighted:p?.highlighted??-1};u.open&&(s.value=u.query);const f=()=>{e.state.fontOpen=u.open?{id:e.id,query:u.query,highlighted:u.highlighted}:null};f();const g=()=>{const k=(e.value??"").trim();return l(u.query).findIndex(S=>(S.value??"")===k)},m=()=>{const k=s.getBoundingClientRect(),S=pv(s);d.classList.toggle("is-up",Th({triggerTop:k.top,triggerBottom:k.bottom,overlayHeight:d.getBoundingClientRect().height,boundaryTop:S.top,boundaryBottom:S.bottom})==="up")},y=()=>{if(!u.open){d.isConnected&&d.remove(),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-activedescendant","");return}d.isConnected||c.appendChild(d);const k=l(u.query);d.replaceChildren(...k.map((S,C)=>{const O=document.createElement("li");return O.id=`${r}-${C}`,O.className="font-select-option"+(C===u.highlighted?" is-active":"")+(S.kind==="unknown"||S.kind==="free"?" is-muted":""),O.setAttribute("role","option"),O.setAttribute("aria-selected",String(S.selected)),O.textContent=S.label,O.addEventListener("mousedown",D=>{D.preventDefault(),L(S)}),O})),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-activedescendant",u.highlighted>=0?`${r}-${u.highlighted}`:""),m()},v=()=>{u.open||e.disabled||(u.open=!0,u.query="",u.highlighted=g(),f(),y())},w=()=>{u.open||v()},_=()=>{u.open=!0,u.query=s.value,u.highlighted=l(u.query).length?0:-1,f(),y()},M=k=>{if(!u.open){v();return}const S=l(u.query).length-1;if(S<0)return;u.highlighted=Math.min(Math.max(u.highlighted+k,0),S),f(),y(),d.children[u.highlighted]?.scrollIntoView?.({block:"nearest"})},N=()=>{if(!u.open)return;const k=l(u.query)[u.highlighted];if(k){L(k);return}const S=u.query.trim();if(S){const C=i(S);L({value:C})}},L=k=>{u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(k.value),y(),e.onChange(k.value)},P=()=>{u.open&&(u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(e.value),y())};return s.addEventListener("focus",v),s.addEventListener("click",w),s.addEventListener("input",_),s.addEventListener("blur",P),s.addEventListener("keydown",k=>{const S=k;S.key==="ArrowDown"?(S.preventDefault(),M(1)):S.key==="ArrowUp"?(S.preventDefault(),M(-1)):S.key==="Enter"?(S.preventDefault(),N()):S.key==="Escape"&&(S.preventDefault(),P())}),c.append(s),y(),u.open&&(s.focus(),s.setSelectionRange(u.query.length,u.query.length)),c}const fv=[{key:"solid",label:"实线",preview:"1.5px solid currentColor"},{key:"dashed",label:"虚线",preview:"1.5px dashed currentColor"},{key:"dotted",label:"点线",preview:"1.5px dotted currentColor"},{key:"double",label:"双线",preview:"3px double currentColor"}],hv={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function At(e,t,n,r,o={}){return h("button",{type:"button",class:`ft-cell-btn${o.on?" on":""}`,dataset:{test:e,tip:t},disabled:!!o.disabled,onClick:r,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${n}</svg>`})}const wn='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',zp='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function gv(e){const t=e.format;t.syncBorderDraft();const n=t.values,r=!t.fontEditable,o=r||t.context==="cells",i=t.context==="none",a=t.context==="cells",l=!t.painterActive&&(t.context==="none"||t.context==="cells"||!t.painterCapturable),c=t.painterActive?"退出格式刷(Esc)":t.context==="cells"?"格式刷(表格单元格暂不支持)":t.context==="none"?"格式刷(需选中元素)":t.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",s=u=>r?`${u}(需选中文本元素)`:u,d=[h("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[h("div",{class:"ft-border-grid"},[At("preset-none","无边框",`${wn}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>t.applyBorderPreset("none")),At("preset-all","所有边框",`${zp}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>t.applyBorderPreset("all")),At("preset-outer","外侧边框",zp,()=>t.applyBorderPreset("outer")),At("preset-inner",a?"内部边框":"内部边框(仅表格单元格可用)",`${wn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>t.applyBorderPreset("inner"),{disabled:!a}),At("edge-top","上边框",`${wn}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>t.applyEdge("top"),{on:t.edgeOn("top")}),At("edge-bottom","下边框",`${wn}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>t.applyEdge("bottom"),{on:t.edgeOn("bottom")}),At("edge-left","左边框",`${wn}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>t.applyEdge("left"),{on:t.edgeOn("left")}),At("edge-right","右边框",`${wn}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>t.applyEdge("right"),{on:t.edgeOn("right")})]),h("div",{class:"ft-style-row"},fv.map(u=>h("button",{type:"button",class:`ft-style-btn${t.borderStyle===u.key?" on":""}`,dataset:{test:`style-${u.key}`,tip:t.borderStyle===u.key?`${u.label}(再点一次取消,线型=无)`:u.label},onClick:()=>{t.toggleBorderStyle(u.key),e.repaint()}},[h("span",{class:"ft-style-line",style:{borderTop:u.preview}})]))),h("div",{class:"ft-border-style-row"},[h("span",{class:"ft-edge-label",text:"粗细"}),h("div",{class:"ft-line-width"},[Z({value:t.borderWidth,min:.25,max:5,step:.25,placeholder:t.borderMixed.width?"混合":void 0,onCommit:u=>{t.setBorderWidth(u),e.repaint()}})])]),h("div",{class:"ft-border-style-row"},[h("span",{class:"ft-edge-label",text:"颜色"}),Ke(t.borderColor,u=>{t.setBorderColor(u),e.repaint()},"边框颜色")]),t.borderMixedAny?h("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],p=[h("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[h("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([u,f,g])=>h("button",{type:"button",class:`ft-cell-btn${n.textAlign===u?" on":""}`,dataset:{test:`align-${u}`,tip:f},disabled:r,onClick:()=>t.applyStyle({textAlign:u}),html:Re(g)}))),h("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([u,f,g])=>h("button",{type:"button",class:`ft-cell-btn${n.verticalAlign===u?" on":""}`,dataset:{test:`valign-${u}`,tip:f},disabled:r,onClick:()=>t.applyStyle({verticalAlign:u}),html:Re(g)})))])];return h("div",{class:"format-toolbar"},[h("div",{class:"tb-ou ft-group",dataset:{unit:"painter"}},[h("button",{type:"button",class:`ft-btn${t.painterActive?" on":""}`,dataset:{test:"format-painter",tip:c},disabled:l,onClick:()=>{t.painterActive?t.cancelPainter():t.pickPainterSource(!1),e.repaint()},onDblclick:()=>{t.pickPainterSource(!0),e.repaint()},html:Re("Paintbrush")})]),h("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[h("div",{class:"ft-font"},[qo({id:"ft-font",state:e.state,fonts:e.host.fonts,value:typeof n.fontFamily=="string"?n.fontFamily:void 0,placeholder:n.fontFamily===jt?"混合":"默认",disabled:r,onChange:u=>t.applyStyle({fontFamily:u})})]),h("div",{class:"ft-size",dataset:{test:"font-size"}},[Z({value:typeof n.fontSize=="number"?n.fontSize:void 0,min:5,max:72,disabled:r,placeholder:n.fontSize===jt?"混合":"默认",onCommit:u=>t.applyStyle({fontSize:u})})])]),h("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>t.toggleBold()],["underline","Underline","下划线",()=>t.toggleUnderline()],["strike","Strikethrough","删除线",()=>t.toggleStrike()]].map(([u,f,g,m])=>h("button",{type:"button",class:`ft-btn${n[u]===!0?" on":""}`,dataset:{test:u,tip:s(g)},disabled:u==="bold"?r:o,onClick:m,html:Re(f)}))]),h("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[h("span",{class:`ft-color-btn${r?" dim":""}`,title:`字体颜色${r?"(需选中或混选文本元素)":""}`},[Ke(typeof n.color=="string"?n.color:void 0,u=>t.applyStyle({color:u})),h("span",{class:"ft-glyph",text:"A"})]),h("span",{class:`ft-color-btn${i?" dim":""}`,title:"背景色"},[Ke(typeof n.backgroundColor=="string"?n.backgroundColor:void 0,u=>t.applyStyle({backgroundColor:u})),h("span",{class:"ft-glyph",html:Re("PaintBucket",14)})])]),h("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[Uo(e,"align",{icon:hv[String(n.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:r?"对齐(需选中文本元素或单元格)":"对齐",disabled:r,testId:"align-dd"},p)]),h("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[Uo(e,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:i?"边框(需选中元素)":"边框",disabled:i,testId:"border"},d)])])}const mv=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"flowList",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:"<>"}],bv={text:"T",longText:"¶",table:"⊞",flowList:"⊟",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function yv(e){const t=e.state;if(t.leftCollapsed)return h("div",{class:"left-panel collapsed"},[h("div",{class:"left-collapsed"},[Bp("»","展开素材台",()=>{t.leftCollapsed=!1,e.repaint()}),...[["elements","元素","▦"],["fields","字段","⊛"],["layers","图层","≡"]].map(([r,o,i])=>h("button",{type:"button",class:`lc-btn${t.leftTab===r?" on":""}`,title:o,text:i,onClick:()=>{t.leftTab=r,t.leftCollapsed=!1,e.repaint()}}))])]);const n=(r,o)=>h("div",{class:"pd-tab-pane",role:"tabpanel",style:t.leftTab===r?"":{display:"none"}},o);return h("div",{class:"left-panel"},[h("div",{class:"left-head"},[h("span",{class:"left-title",text:"素材台"}),Bp("«","收起素材台",()=>{t.leftCollapsed=!0,e.repaint()})]),h("div",{class:"pd-tabs left-tabs"},[h("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([r,o])=>h("button",{type:"button",class:`pd-tab${t.leftTab===r?" active":""}`,text:o,onClick:()=>{t.leftTab=r,e.repaint()}}))]),n("elements",vv()),n("fields",[wv(e)]),n("layers",[xv(e)])])])}function Bp(e,t,n){return h("button",{type:"button",class:"collapse-btn",title:t,text:e,onClick:n})}function vv(){return[h("div",{class:"panel-title",text:"拖拽元素到画布"}),...mv.map(e=>h("div",{class:"material-card",draggable:!0,dataset:{test:`material-${e.type}`},onDragstart:t=>{const n=t.dataTransfer;n?.setData("elementType",e.type),n&&(n.effectAllowed="all")}},[h("span",{class:"material-icon",text:e.icon}),h("span",{class:"material-label",text:e.label})]))]}function wv(e){const t=e.state,n=Xc(e.store.fields),r=(t.fieldSearch??"").trim().toLowerCase(),o=r?n.map(i=>({...i,fields:i.fields.filter(a=>`${a.fieldLabel}${a.fieldKey}`.toLowerCase().includes(r))})).filter(i=>i.fields.length):n;return h("div",{class:"field-tree-panel"},[h("div",{class:"panel-title",text:"业务字段"}),h("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:t.fieldSearch??"",onInput:i=>{t.fieldSearch=i.target.value},onChange:()=>e.repaint()}),h("div",{class:"tree-container"},o.flatMap(i=>{const a=t.collapsedGroups.has(i.key)&&!r,l=i.key?h("div",{class:`field-group-header${i.isList?" is-list":""}`,onClick:()=>{a?t.collapsedGroups.delete(i.key):t.collapsedGroups.add(i.key),e.repaint()}},[h("span",{class:"expand-icon",text:a?"▶":"▼"}),h("span",{class:"node-icon",text:i.isList?"📋":"📁"}),h("span",{class:"group-label",text:i.label,"data-tip":i.label})]):"",c=a?[]:i.fields.map(s=>h("div",{class:"field-row",draggable:!0,"data-tip":`${s.fieldLabel} (${s.fieldKey}) · 单击复制字段名 · 拖动中按住 Ctrl(Mac 为 ⌘)切换为插入字段名`,style:{paddingLeft:`${i.key?22:8}px`},onDragstart:d=>{const p=d.dataTransfer;p?.setData("fieldKey",s.fieldKey),p&&(p.effectAllowed="all")},onClick:()=>{Zc(s.fieldLabel||s.fieldKey).then(d=>{d&&(t.copiedFieldKey=s.fieldKey,e.repaint(),setTimeout(()=>{t.copiedFieldKey===s.fieldKey&&(t.copiedFieldKey="",e.repaint())},1200))})}},[h("span",{class:"node-icon",text:"📄"}),h("span",{class:"node-meta"},[h("span",{class:"node-label",text:s.fieldLabel}),h("span",{class:"node-key",text:`(${s.fieldKey})`})]),t.copiedFieldKey===s.fieldKey?h("span",{class:"copy-hint",text:"已复制"}):""].filter(Boolean)));return[l,h("div",{},c.filter(Boolean))].filter(Boolean)})),o.length===0?h("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function xv(e){const t=e.store,n=[...t.elements].sort((l,c)=>(c.options.zIndex??0)-(l.options.zIndex??0)),r=t.elements.filter(l=>t.selectedIds.has(l.id)),o=r.length>=2,i=r.some(l=>!!l.options.groupId),a=l=>l.zone==="header"?"页眉":l.zone==="footer"?"页脚":"";return h("div",{class:"layer-panel"},[h("div",{class:"panel-title",text:"图层"}),...n.map(l=>h("div",{class:`layer-item${t.selectedIds.has(l.id)?" active":""}`,onClick:c=>t.selectElement(l.id,c.ctrlKey||c.metaKey)},[h("span",{class:"layer-icon",text:bv[l.printElementType.type]||"?"}),h("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),a(l)?h("span",{class:"layer-zone",text:a(l)}):"",h("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))),n.length?h("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,c,s])=>h("button",{type:"button",class:"pd-button small",title:c,html:Re(s,14),onClick:()=>e.fire("move-layer",l)}))]):"",o||i?h("div",{class:"layer-actions"},[o?h("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:Re("Group",14),onClick:()=>e.fire("group")}):"",i?h("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:Re("Ungroup",14),onClick:()=>e.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function Ev(e){const t=e.store,n=e.state,r=t.pages.length>1,o=t.pages[t.activePageIndex]?.name||`页面 ${t.activePageIndex+1}`,i=t.tilingEnabled;return h("div",{class:"page-tabs"},[h("div",{class:"page-tabs-list"},t.pages.map((l,c)=>n.renamingPage===c?h("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:n.renameText??"",onInput:s=>{n.renameText=s.target.value},onBlur:()=>a(),onKeydown:s=>{const d=s;if(d.key==="Enter"){a();return}d.key==="Escape"&&(n.renamingPage=null,e.repaint())}}):h("button",{type:"button",class:`page-tab${c===t.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${c+1}`,onClick:()=>t.switchPage(c),onDblclick:()=>{n.renamingPage=c,n.renameText=l.name??"",e.repaint()}}))),h("div",{class:"page-tabs-actions"},[h("button",{type:"button",dataset:{test:"add-page",tip:i?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:i,text:"+",onClick:()=>e.fire("add-page")}),h("button",{type:"button",dataset:{test:"duplicate-page",tip:i?"拼版模板仅允许一个设计页面":`复制当前页「${o}」`},disabled:i,text:"⧉",onClick:()=>e.fire("duplicate-page")}),h("button",{type:"button",dataset:{test:"delete-page",tip:r?`删除当前页「${o}」`:"仅多页面模板可删除页面"},disabled:!r,text:"✕",onClick:()=>e.fire("delete-page")}),h("button",{type:"button",dataset:{test:"move-left",tip:`前移「${o}」`},disabled:t.activePageIndex<=0,text:"←",onClick:()=>e.fire("move-page",-1)}),h("button",{type:"button",dataset:{test:"move-right",tip:`后移「${o}」`},disabled:t.activePageIndex>=t.pages.length-1,text:"→",onClick:()=>e.fire("move-page",1)})])]);function a(){const l=(n.renameText??"").trim();n.renamingPage!==null&&l&&t.renamePage(n.renamingPage,l),n.renamingPage=null,e.repaint()}}function Sv(e){const t=e.store,n=t.templateData,r=_t(n),o=n.orientation==="landscape"?"横向":"纵向",i=nt[n.paperSize]?.label??n.paperSize,a=n.outputRotation,l=`${i} ${o} ${Math.round(r.width)}×${Math.round(r.height)}mm${a?`(旋转${a}°)`:""}`;return h("div",{class:"status-bar"},[h("span",{class:"status-item coord",dataset:{coord:""},style:{display:"none"}}),h("span",{class:"status-item",text:`缩放 ${t.scale}%`}),h("span",{class:"status-item",text:`元素 ${t.elements.length}${t.selectedIds.size?` (选中 ${t.selectedIds.size})`:""}`}),h("span",{class:`status-dirty${t.dirty?" on":""}`},[h("span",{class:"dirty-dot"}),t.dirty?"未保存":"已保存"]),h("span",{class:"status-item status-paper",text:l})])}const _v=Object.keys(nt).filter(e=>e!=="CUSTOM"&&!nt[e]?.continuous);function Mv(e){const t=document.createElement("label");t.className="pd-button small upload-label";const n=document.createTextNode("上传背景图"),r=document.createElement("input");r.className="visually-hidden",r.type="file",r.accept="image/*",t.append(n,r);const o=i=>{t.className=`pd-button small upload-label${i?" disabled":""}`,r.disabled=i};return r.addEventListener("change",async()=>{const i=r.files?.[0];if(!i)return;if(!i.type.startsWith("image/")){alert("仅支持上传图片文件"),r.value="";return}const a=e.host.uploadDesignBackground;if(!a){alert("设计背景上传能力未配置"),r.value="";return}o(!0),n.textContent="上传中...";try{const l=await a(i);l?e.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{n.textContent="上传背景图",o(!e.host.uploadDesignBackground),r.value=""}}),e.host.uploadDesignBackground||o(!0),t}function Tv(e){const n=e.store.templateData.designBackground,r=n?.rotation??0;return h("div",{class:"design-background-config"},[st("设计背景"),h("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),n?.src?[h("div",{class:"design-background-path",title:n.src,text:n.src}),h("div",{class:"design-background-actions"},[h("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(r+90)%360}°)`,onClick:()=>e.store.updateTemplateData({designBackground:{...n,rotation:(r+90)%360}})}),h("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>e.store.updateTemplateData({designBackground:void 0})})])]:Mv(e)].flat())}function kv(e){const t=e.store,n=t.templateData,r=n.tiling,o={...ot,...r??{},enabled:r?.enabled??!1,sheetMargin:{...ot.sheetMargin,...r?.sheetMargin??{}}},i=ki(n.paperSize),a=g=>t.updateTemplateData({tiling:{...o,...g}}),l=g=>Xt({target:o,base:ot,propKey:g,write:()=>a({[g]:ot[g]})}),c=g=>Xt({target:o.sheetMargin,base:ot.sheetMargin,propKey:g,write:()=>s(g,ot.sheetMargin[g])}),s=(g,m)=>a({sheetMargin:{...o.sheetMargin,[g]:m??0}}),d={...n,tiling:o},p=da(d),u=Math.max(zc(d),1);let f="";if(!p.length)try{const g=Fc(d),m=Yn(d),y=o.sheetPaperSize==="CUSTOM"?"自定义":o.sheetPaperSize??"A4",v=o.sheetPaperSize==="CUSTOM"?"":o.sheetOrientation==="landscape"?" 横向":" 纵向";f=`目标纸 ${y}${v} ${m.width}×${m.height}mm · ${g.columns} 列 × ${g.rows} 行 = 每张 ${g.perSheet} 格 · 每格 ${g.tile.width}×${g.tile.height}mm`}catch{f=""}return h("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[st("拼版打印"),h("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),h("div",{class:"pd-field"},[h("label",{class:"tiling-switch"},[h("input",{type:"checkbox",checked:o.enabled===!0,disabled:i,onChange:g=>{if(!g.target.checked){a({enabled:!1});return}a({...ot,columns:Math.min(ot.columns,Math.max(u,1))})}}),h("span",{text:"启用拼版"})]),i?h("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),o.enabled&&!i?[ie("目标纸张",h("select",{class:"pd-select",style:{width:"100%"},onChange:g=>{const m=g.target.value;if(m!=="CUSTOM"){a({sheetPaperSize:m});return}const y=Yn(d);a({sheetPaperSize:"CUSTOM",sheetCustomWidth:o.sheetCustomWidth??y.width,sheetCustomHeight:o.sheetCustomHeight??y.height})}},[..._v.map(g=>h("option",{value:g,text:nt[g]?.label??g,selected:(o.sheetPaperSize??"A4")===g})),h("option",{value:"CUSTOM",text:"自定义",selected:o.sheetPaperSize==="CUSTOM"})]),void 0,l("sheetPaperSize")),o.sheetPaperSize==="CUSTOM"?ie("目标纸宽高 (mm)",h("div",{class:"custom-size-grid"},[Z({value:Number(o.sheetCustomWidth??0),min:25,max:2e3,onCommit:g=>a({sheetCustomWidth:g})}),h("span",{class:"custom-size-x",text:"×"}),Z({value:Number(o.sheetCustomHeight??0),min:25,max:2e3,onCommit:g=>a({sheetCustomHeight:g})})])):ie("目标纸方向",Ct("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],o.sheetOrientation==="landscape"?"landscape":"portrait",g=>a({sheetOrientation:g})),void 0,l("sheetOrientation")),st("拼版留白 (mm)"),h("div",{class:"margin-grid"},[ie("上",Z({value:o.sheetMargin.top??0,min:0,max:100,onCommit:g=>s("top",g)}),void 0,c("top")),ie("下",Z({value:o.sheetMargin.bottom??0,min:0,max:100,onCommit:g=>s("bottom",g)}),void 0,c("bottom")),ie("左",Z({value:o.sheetMargin.left??0,min:0,max:100,onCommit:g=>s("left",g)}),void 0,c("left")),ie("右",Z({value:o.sheetMargin.right??0,min:0,max:100,onCommit:g=>s("right",g)}),void 0,c("right"))]),st("格间距与列数"),ie("横向间距",Z({value:o.gapX??0,min:0,max:50,onCommit:g=>a({gapX:g??0})}),void 0,l("gapX")),ie("纵向间距",Z({value:o.gapY??0,min:0,max:50,onCommit:g=>a({gapY:g??0})}),void 0,l("gapY")),ie("列数",Z({value:o.columns??1,min:1,max:u,onCommit:g=>a({columns:g||1})})),...p.map(g=>h("p",{class:"pd-hint tiling-error",text:g.message})),!p.length&&f?h("p",{class:"pd-hint tiling-summary",text:f}):""]:""].flat().filter(Boolean))}const Cv=new Set(Ar.map(e=>e.group)),Av={"table-settings":"content"},Hp=new Map;function gs(e){const t=e??"";let n=Hp.get(t);if(!n){const{groups:r,itemKeys:o}=xg(t);n={groups:r,keys:o,searching:!!t.trim()},Hp.set(t,n)}return n}function ms(e){const t=Av[e]??e;return Cv.has(t)?t:""}function Ov(e,t){const n=gs(e.state.propSearch);if(!n.searching)return!0;const r=ms(t);return!r||n.groups.includes(r)}function Iv(e,t){const n=gs(e.state.propSearch);return!n.searching||n.keys.has(t)}function Up(e,t){const n=e.props.style??{};return e.props.style={...n,display:t?"":"none"},e}function H(e,t,n){const r=n.props.dataset??{};return n.props.dataset={...r,propKey:t},Up(n,Iv(e,t))}function Pv(e,t,n){const r=ms(t);if(!r)return n;const o=n.props.dataset??{};return n.props.dataset={...o,propGroup:r},Up(n,Ov(e,t))}function qp(e,t){const n=gs(t);for(const r of Array.from(e.querySelectorAll("[data-prop-group]"))){const o=ms(r.dataset.propGroup??"");r.style.display=!n.searching||!o||n.groups.includes(o)?"":"none"}for(const r of Array.from(e.querySelectorAll("[data-prop-key]")))r.style.display=!n.searching||n.keys.has(r.dataset.propKey??"")?"":"none"}function Dv(e){return h("div",{class:"property-search"},[h("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:e.state.propSearch??"",onInput:t=>{const n=t.target,r=n.value;e.state.propSearch=r,qp(n.getRootNode(),r)}})])}const Rv={Document:"≡",Brush:"◧",Setting:"⚙"};function $v(e,t){try{const n=window.localStorage.getItem(`property-group-${e}`);return n===null?t:n==="true"}catch{return t}}function Lv(e,t){try{window.localStorage.setItem(`property-group-${e}`,String(t))}catch{}}function Ne(e,t,n,r,o,i=!0){const a=$v(t,i);return Pv(e,t,h("div",{class:`property-group${a?" is-expanded":""}`},[h("div",{class:"group-header",onClick:()=>{Lv(t,!a),e.repaint()}},[h("span",{class:"group-icon",text:Rv[r]||"•"}),h("span",{class:"group-title",text:n}),h("span",{class:"expand-icon",text:a?"▾":"▸"})]),h("div",{class:"group-content",style:a?"":{display:"none"}},o.filter(Boolean))]))}function Wo(e){return h("form",{class:"pd-form",onSubmit:t=>t.preventDefault()},e.filter(Boolean))}function Wp(e){return e.split(".").flatMap(t=>{const n=t.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!n)return[t];const r=n[1],o=[...n[2].matchAll(/\[(\d+)\]/g)].map(i=>Number(i[1]));return[r,...o]})}function jp(e,t){return Wp(t).reduce((o,i)=>o==null?"":o[i],e)??""}function bs(e,t,n,r){const o=Wp(n),i=o.pop(),a=o.reduce((l,c)=>((l[c]===void 0||l[c]===null)&&(l[c]={}),l[c]),t);a[i]=r||void 0,e.recordHistory(),e.emit()}function Nv(e,t){const n=e.store;if(t.printElementType.type==="table"&&n.tableSelection?.elementId===t.id){const{r1:r,c1:o}=n.tableSelection,i=(t.options.tableRows??[])[r];if(i)return Jc(i.type,r,o,t.options.fields?.[0]?.dataSource)}return S0(t)}function Fv(e,t){const n=document.createElement("label");n.className="pd-button small upload-label",De(h("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[h("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),n);const r=document.createTextNode("上传图片"),o=document.createElement("input");o.className="visually-hidden",o.type="file",o.accept="image/*",n.append(r,o);const i=c=>{n.className=`pd-button small upload-label${c?" disabled":""}`,o.disabled=c};o.addEventListener("change",async()=>{const c=o.files?.[0];if(!c)return;if(!c.type.startsWith("image/")){alert("仅支持上传图片文件"),o.value="";return}const s=e.host.uploadImage;if(!s){alert("图片上传能力未配置"),o.value="";return}i(!0),r.textContent="上传中...";try{const d=await s(c);d?bs(e.store,t,"options.src",d):alert("图片上传失败")}catch(d){alert(d instanceof Error?d.message:"图片上传失败")}finally{r.textContent="上传图片",i(!e.host.uploadImage),o.value=""}}),e.host.uploadImage||i(!0);const a=document.createElement("div");a.className="image-content-upload";const l=document.createElement("p");return l.className="upload-tip",l.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",a.append(n,l),a}function zv(e,t){const n=r=>e.fire("open-expression",{elementId:t.id,targetPath:r.targetPath,value:jp(t,r.targetPath)});return Ne(e,"binding","内容","Document",[...Nv(e,t).map(r=>ie(r.label,h("input",{class:"pd-input",type:"text",value:jp(t,r.targetPath),placeholder:r.placeholder||"输入内容,支持 {字段} 表达式",onChange:o=>bs(e.store,t,r.targetPath,o.target.value),onDblclick:()=>n(r)}))),t.printElementType.type==="image"?Fv(e,t):""].filter(Boolean))}const fr=new Map;function jo(e){return`${Math.round(e*1e4)/1e4}%`}function Gp(e,t){const n=d0(t.value),r=n.kind==="custom",o=n.kind==="axes"?n.x:50,i=n.kind==="axes"?n.y:50,a=m0(t.src),l=fr.get(a.src),c={widthMm:t.widthMm,heightMm:t.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:t.fit,scalePct:t.scale},s=u0(c),d=p0(c,o,i),p=document.createElement("select");p.className="pd-select",p.style.width="100%";for(const m of w0(s,o,i)){const y=document.createElement("option");y.value=m.value,y.textContent=m.label,p.appendChild(y)}if(r){const m=document.createElement("option");m.value="custom",m.textContent="自定义(保留原值)",p.appendChild(m)}p.value=r?"custom":`${o},${i}`,p.selectedIndex<0&&(p.selectedIndex=r?p.options.length-1:0),p.addEventListener("change",()=>{if(p.value==="custom")return;const[m,y]=p.value.split(",").map(Number);t.onCommit(Wc(m,y))});const u=Oe(t.fieldKey),f=[h("div",{class:"pd-field",dataset:{field:t.fieldKey}},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[t.label,hs(u)]),t.resetAnchor??""].filter(Boolean)),p])];f.push(h("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[b0,hs(Oe("ap-img-fit-scale"))]),t.resetScale??""].filter(Boolean)),Z({value:t.scale,min:Dn,max:nl,step:5,placeholder:"默认 100",onCommit:m=>t.onScaleCommit(m>Dn?m:void 0)})]));for(const m of v0(s,o,i))f.push(h("div",{class:"pd-field",dataset:{field:t.fieldKey}},[h("span",{class:"pd-label",text:m.label}),Z({value:m.value,min:0,max:100,step:1,onCommit:y=>t.onCommit(Wc(m.name==="horizontal"?y:o,m.name==="vertical"?y:i))})]));const g=y0(s,r);return g&&f.push(h("p",{class:"pd-crop-note",text:g})),a.isSample&&f.push(h("p",{class:"pd-crop-note",text:g0})),f.push(h("div",{class:"pd-crop-preview"},[h("img",{class:"pd-crop-thumb",src:a.src,alt:a.isSample?"示例图":"原图",onLoad:m=>{const y=m.target;if(!(y.naturalWidth>0&&y.naturalHeight>0))return;const v=fr.get(a.src);v&&v.width===y.naturalWidth&&v.height===y.naturalHeight||(fr.set(a.src,{width:y.naturalWidth,height:y.naturalHeight}),e.repaint())},onError:()=>{fr.has(a.src)&&(fr.delete(a.src),e.repaint())}}),d?h("div",{class:"pd-crop-win",style:{left:jo(d.leftPct),top:jo(d.topPct),width:jo(d.widthPct),height:jo(d.heightPct)}}):""])),h("div",{class:t.containerClass??"pd-crop-anchor"},f)}const Zt=e=>Number(e??0),ys=e=>e||void 0;function xn(e,t,n,r,o){return h("div",{class:"pd-field"},[h("span",{class:"pd-label",...r?{title:r}:{}},[h("span",{class:"pd-label-t",text:e}),o??""].filter(Boolean)),h("input",{class:"pd-switch",type:"checkbox",checked:t,onChange:i=>n(i.target.checked)})])}function Yp(e,t,n,r,o=!1,i){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),""].filter(Boolean)),h("select",{class:"pd-select",...o?{style:{width:"100%"}}:{},onChange:a=>r(a.target.value)},n.map(a=>h("option",{value:a.value,text:a.label,selected:a.value===t})))])}function hr(e,t,n,r,o={}){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),o.reset??""].filter(Boolean)),Fp(t,n,r,{className:"pd-select",...o.full?{width:"100%"}:{}})])}const gr=e=>h("p",{class:"pd-hint",text:e}),Bv="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",Hv=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],Uv=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],qv=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],Wv=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],jv={value:"__multi__",label:"多选",disabled:!0};function Gv(e,t){const n=e.store,r=n.tableSelection,o=t.options.tableRows??[],i=r?o[r.r1]:void 0;if(!r||!i)return Ne(e,"table-row","行属性","Grid",[]);const a=l=>n.updateElement(t.id,l);return Ne(e,"table-row","行属性","Grid",[Wo([Yp("行类型",i.type,Hv,l=>{const c=Ei(o,r.r1,l);if(c){window.alert(c);return}a({tableRows:o})},!0),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"行高 (mm)"}),Z({value:i.height,min:3,max:100,step:.5,onCommit:l=>{i.height=l,a({tableRows:o})}})]),i.type==="header"?xn("表头每页重复",i.repeatOnPage??!1,l=>{$h(o,l),a({tableRows:o})},Bv):""])])}function Yv(e,t){const n=e.store,r=t.options,o=d=>n.updateElement(t.id,d),i=r.tableColWidths??[],a=n.paperSize.width-n.templateData.margins.left-n.templateData.margins.right,l=n.fields.filter(d=>d.fieldType==="list").map(d=>({value:d.fieldKey,label:d.fieldLabel})),c=_i("table"),s=d=>Xt({target:r,base:c,propKey:d,write:()=>o({[d]:c[d]})});return Ne(e,"table-settings","表格设置","Grid",[Wo([Yp("列表数据源字段",r.dataSource??"",l,d=>o({dataSource:d||void 0}),!0),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认字体"}),s("tableDefaultFontFamily")]),qo({id:"table-default-font",state:e.state,fonts:e.host.fonts,value:r.tableDefaultFontFamily,placeholder:"默认",onChange:d=>o({tableDefaultFontFamily:d||void 0})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认字号 (pt)"}),s("tableDefaultFontSize")]),Z({value:Zt(r.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:d=>o({tableDefaultFontSize:ys(d)})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认文字颜色"}),s("tableDefaultColor")]),Ke(r.tableDefaultColor,d=>o({tableDefaultColor:d}),"默认文字颜色")]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),s("tableDefaultPadding")]),Z({value:Zt(r.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:d=>o({tableDefaultPadding:ys(d)})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"列宽 (mm)"}),...i.map((d,p)=>h("div",{class:"col-width-row"},[h("span",{style:{width:"60px"},text:`列${p+1}`}),Z({value:d,min:5,max:200,onCommit:u=>{const f=i.reduce((g,m,y)=>y===p?g:g+m,0);if(f+u>a){const g=Math.max(5,Math.round((a-f)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${a}mm,列${p+1} 已调整为 ${g}mm`),i[p]=g}else i[p]=u;o({tableColWidths:i})}})]))])])])}function Vv(e,t){const n=e.store,r=t.options,o=t.printElementType.type==="table",i=l=>n.updateElement(t.id,l),a=[];if(o)a.push(H(e,"pg-enabled",xn("启用分页",r.tablePagination?.enabled??!0,l=>i({tablePagination:{enabled:l}}))));else{const l=r.pagination?.pageable??!0,c=r.pagination?.keepWithNext??!1;a.push(H(e,"pg-pageable",xn("参与分页",l,s=>i({pagination:{pageable:s,keepWithNext:c}})))),a.push(H(e,"pg-keep-with-next",xn("与下元素同页",c,s=>i({pagination:{pageable:l,keepWithNext:s}}))))}return Ne(e,"pagination","分页配置","Document",[Wo(a)],!1)}const vs=new WeakMap,Vp=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function Kv(e,t){const n=e.store,r=n.tableSelection,o=t.options.tableRows??[];if(!r)return Ne(e,"table-cell","单元格","Menu",[]);const i=xi(o,r.r1,r.c1),a=o[i.r]?.cells[i.c];if(!a)return Ne(e,"table-cell","单元格","Menu",[]);const l=()=>kr(o,r),c=Si(o,r),s=c.count,d=c.mode==="multi",p=`${t.id}:${r.r1}:${r.c1}:${r.r2}:${r.c2}`,u=vs.get(n),f=u?.key===p?u:{key:p,border:{},values:{},edges:{}};u?.key!==p&&vs.set(n,f);const g=T=>{vs.set(n,{key:p,border:T.border??f.border,values:T.values??f.values,edges:T.edges??f.edges})},m=(T,J)=>{g({border:{...f.border,[T]:J}}),e.repaint()},y=(T,J)=>{l().forEach(T),d&&J&&g({values:{...f.values,...J}}),n.updateElement(t.id,{tableRows:o})},v=(T,J)=>{y(ue=>{ue[T]=J},{[T]:J})},w=T=>d?f.values[T]:a[T],_=T=>d&&T in f.values,M=d?{width:void 0,style:void 0,color:void 0}:Ml(o,r),N=!d&&l().some(T=>!!T.borders&&!!(T.borders.top||T.borders.right||T.borders.bottom||T.borders.left)),L=!d&&!N,P={width:L?0:typeof M.width=="number"?M.width:St.width,style:L?"none":typeof M.style=="string"&&M.style!=="mixed"?M.style:St.style,color:typeof M.color=="string"&&M.color!=="mixed"?M.color:St.color,...f.border},k="__mixed__",S={style:!d&&M.style==="mixed",width:!d&&M.width==="mixed",color:!d&&M.color==="mixed"},C=S.style&&!("style"in f.border),O=S.width&&!("width"in f.border),D=S.color&&!("color"in f.border),I=C||O||D,x=C?k:P.style,j=O?void 0:P.width,te=D?void 0:P.color,fe=T=>{const J={style:T};T!=="none"&&j===0?J.width=St.width:T==="none"&&!N&&(J.width=0),g({border:{...f.border,...J}}),e.repaint()},G=()=>({...P}),de=d?Vp.reduce((T,J)=>(T[J.value]=f.edges[J.value]?"on":"off",T),{}):kl(l().map(T=>T.borders)),Xe=d?"cellType"in f.values?f.values.cellType??"text":zh(o,r):a.cellType??"text",ye=Xe==="barcode",Fe=Xe==="qrcode",R=Xe==="image",F=Xe==="text",W=ye&&!!w("printerDpi"),V=Zs(w("printerDpi"),w("barWidth")),Y=d?f.values.textFit:ii(a),K=d?"cellType"in f.values?f.values.cellType??"text":"":a.cellType||"text",ne=T=>d?[jv,...T]:T,Q=T=>d?"多选":T,se=(T,J)=>d?f.values[T]:J,he=d?w("barcodeType")??"__multi__":a.barcodeType||"CODE128",_e=d?_("printerDpi")?w("printerDpi")?String(w("printerDpi")):"":"__multi__":a.printerDpi?String(a.printerDpi):"",X=d?w("qrCodeLevel")??"__multi__":a.qrCodeLevel||"M",vt=d?w("fit")??"__multi__":a.fit||"contain",ee=Y??"__multi__",lt=yl(o,r);let Me=!1;for(let T=r.r1;T<=r.r2&&!Me;T++)for(let J=r.c1;J<=r.c2&&!Me;J++){const ue=o[T]?.cells[J];ue&&!ue.merged&&((ue.rowspan??1)>1||(ue.colspan??1)>1)&&(Me=!0)}const Ae=(T,J,ue,le={},ze)=>h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:T}),ze??""].filter(Boolean)),Z({value:J,...le,onCommit:Dt=>v(ue,ys(Dt))})]),Ee="恢复默认值(跟随表格默认)",re=T=>Xt({target:a,base:{},propKey:T,tipOverride:Ee,force:d,write:()=>v(T,void 0)}),It=t.options.tableDefaultPadding??1,Pt={width:si(t.options.tableColWidths??[],i.c,a,It),height:An(o,i.r,a,It)};return Ne(e,"table-cell","单元格","Menu",[Wo([d?gr(`已选 ${s} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"单元格类型"}),Ct("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],K,T=>{const J=T==="text"?void 0:T,ue={cellType:T};T!=="barcode"&&Object.assign(ue,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),T!=="qrcode"&&Object.assign(ue,{qrCodeLevel:void 0,qrQuietZone:void 0}),y(le=>{le.cellType=J,T!=="barcode"&&(le.barcodeType=void 0,le.showBarcodeText=void 0,le.printerDpi=void 0,le.barQuietZone=void 0,le.barHeight=void 0),T!=="qrcode"&&(le.qrCodeLevel=void 0,le.qrQuietZone=void 0)},ue)})]),ye?hr("码制",he,ne(Uv),T=>{T!=="__multi__"&&v("barcodeType",T||void 0)}):"",ye?xn("显示文本",d?f.values.showBarcodeText===!0:a.showBarcodeText!==!1,T=>v("showBarcodeText",T),void 0,re("showBarcodeText")):"",ye?Ae("条宽(倍率)",se("barWidth",a.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:Q("")},re("barWidth")):"",ye?gr((W?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(V?`。${V}`:"")):"",ye?Ve("静区 (模块)",Z({value:se("barQuietZone",a.barQuietZone),min:0,max:20,placeholder:Q("默认 10"),onCommit:T=>v("barQuietZone",T)}),Oe("cd-bar-quiet-zone"),re("barQuietZone")):"",ye?Ve("条高 (mm)",Z({value:se("barHeight",a.barHeight),min:1,max:100,placeholder:Q("默认 30 模块"),onCommit:T=>v("barHeight",T??void 0)}),Oe("cd-bar-height"),re("barHeight")):"",ye?Ae("文本字号(相对条高,条高为 30)",se("barFontSize",a.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:Q("默认 10")},re("barFontSize")):"",ye?hr("打印机分辨率",_e,ne([{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}]),T=>{if(T==="__multi__")return;const J=Number(T);v("printerDpi",J>0?J:void 0)},{reset:re("printerDpi")}):"",ye?gr("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",Fe?hr("纠错级别",X,ne(qv),T=>{T!=="__multi__"&&v("qrCodeLevel",T||void 0)},{reset:re("qrCodeLevel")}):"",Fe?Ve("静区 (模块)",Z({value:se("qrQuietZone",a.qrQuietZone),min:0,max:8,placeholder:Q("默认 0"),onCommit:T=>v("qrQuietZone",T)}),Oe("cd-quiet-zone"),re("qrQuietZone")):"",ye?gr("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",Fe||R?hr("缩放模式",vt,ne(fa),T=>{T!=="__multi__"&&v("fit",T)},{reset:re("fit")}):"",R&&!d&&a.fit==="cover"?Gp(e,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:Yc(a.formatter),fit:a.fit,containerClass:"pd-cell-anchor",widthMm:Pt.width,heightMm:Pt.height,scale:a.fitScale,value:a.objectPosition,onCommit:T=>v("objectPosition",T),onScaleCommit:T=>v("fitScale",T),resetAnchor:re("objectPosition"),resetScale:re("fitScale")}):"",ye||Fe||R?Ae("最大宽度 (mm)",se("maxWidth",Zt(a.maxWidth)),"maxWidth",{min:0,max:200,placeholder:Q("默认")},re("maxWidth")):"",ye||Fe||R?Ae("最大高度 (mm)",se("maxHeight",Zt(a.maxHeight)),"maxHeight",{min:0,max:200,placeholder:Q("默认")},re("maxHeight")):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"内容"}),h("input",{class:"pd-input",type:"text",value:d?w("formatter")??"":a.formatter||"",placeholder:d?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:T=>v("formatter",T.target.value||void 0),onDblclick:()=>e.fire("table-cell-dblclick",{elementId:t.id,r:i.r,c:i.c,cellId:a.id})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"水平对齐"}),re("align")]),Ct("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],d?f.values.align??"":a.align||"left",T=>v("align",T))]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"垂直对齐"}),re("valign")]),Ct("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],d?f.values.valign??"":a.valign||"top",T=>v("valign",T))]),h("div",{class:"cell-style-grid"},[h("div",{class:"pd-field cell-font-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"字体"}),re("fontFamily")]),qo({id:"cell-font",state:e.state,fonts:e.host.fonts,value:d?w("fontFamily"):a.fontFamily,placeholder:Q("继承默认"),onChange:T=>v("fontFamily",T)})]),Ae("字号 (pt)",se("fontSize",Zt(a.fontSize)),"fontSize",{min:0,max:72,placeholder:Q("默认")},re("fontSize")),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"加粗"}),re("fontWeight")]),h("input",{class:"pd-switch",type:"checkbox",checked:d?f.values.fontWeight==="bold":a.fontWeight==="bold",onChange:T=>v("fontWeight",T.target.checked?"bold":void 0)})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"文字颜色"}),re("color")]),Ke(d?w("color"):a.color,T=>v("color",T),"文字颜色")]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"背景色"}),re("backgroundColor")]),Ke(d?w("backgroundColor"):a.backgroundColor,T=>v("backgroundColor",T),"背景颜色")])]),st("边框"),h("div",{class:"border-style-row"},[Fp(x,[...C?[{value:k,label:"混合",disabled:!0}]:[],...Ai],T=>{T!==k&&fe(T)},{width:"90px"}),h("div",{style:{width:"112px",flexShrink:"0"}},[Z({value:j,min:.25,max:5,step:.25,placeholder:d?"多选":O?"混合":void 0,onCommit:T=>m("width",T)})]),Ke(te,T=>m("color",T),"边框颜色")]),h("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([T,J])=>h("button",{type:"button",class:"pd-button small",text:J,onClick:()=>{Sl(o,r,P.style==="none"?"none":T,G()),n.updateElement(t.id,{tableRows:o})}}))),h("div",{class:"pd-checkbox-group"},Vp.map(T=>h("label",{class:"pd-checkbox"},[h("input",{type:"checkbox",value:T.value,checked:de[T.value]==="on",indeterminate:de[T.value]==="mixed",onChange:J=>{const le=J.target.checked&&P.style!=="none";d&&g({edges:{...f.edges,[T.value]:le}}),y(ze=>{_l(ze,T.value,le?G():null)})}}),h("span",{text:T.label})]))),gr(d?Nh:I?Fh:Lh),Ae("内边距 (mm)",se("padding",Zt(a.padding)),"padding",{min:0,max:10,step:.5,placeholder:Q("默认")},re("padding")),xn("自动换行",d?f.values.wordWrap===!0:a.wordWrap??!0,T=>v("wordWrap",T),void 0,re("wordWrap")),F?hr("文字溢出",ee,ne(Wv),T=>{T!=="__multi__"&&v("textFit",T)},{full:!0,reset:re("textFit")}):"",F&&Y==="shrink"?Ae("最小字号 (pt)",se("shrinkMinFontSize",Zt(a.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:Q("默认 6")},re("shrinkMinFontSize")):"",h("div",{class:"merge-btns"},[h("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!lt,title:lt||"",onClick:()=>{vl(o,r),n.updateElement(t.id,{tableRows:o})}}),h("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!Me,onClick:()=>{wl(o,r),n.updateElement(t.id,{tableRows:o})}})])])])}const ws=cm;function xs(e){const t=e.trim();return t?/[{}]/.test(t)||/^[A-Za-z_$][\w$]*\s*\(/.test(t)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(t):!1}function Xv(e){return e?e.mode==="binding"?e.binding??"":e.content??"":""}function Zv(e){const t=e.store.templateData.watermark,n=Xv(t),r=t?.mode==="binding"||n!==""&&xs(n),o=(()=>{const s=t?.tileWidth??ae.tileWidth,d=t?.tileHeight??ae.tileHeight;for(const[p,u]of Object.entries(ws))if(u.width===s&&u.height===d)return p;return"custom"})(),i=s=>{const d={testData:t?.testData??"",rotate:t?.rotate??ae.rotate,color:t?.color||ae.color,opacity:t?.opacity??ae.opacity,tileWidth:t?.tileWidth??ae.tileWidth,tileHeight:t?.tileHeight??ae.tileHeight,timestamp:t?.timestamp,format:t?.format};e.store.updateTemplateData({watermark:{...d,...s}})},a=()=>e.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:n}),l={rotate:t?.rotate??ae.rotate,color:t?.color||ae.color,opacity:t?.opacity??ae.opacity,tileWidth:t?.tileWidth??ae.tileWidth,tileHeight:t?.tileHeight??ae.tileHeight},c=s=>Xt({target:l,base:ae,propKey:s,write:()=>i({[s]:ae[s]})});return h("div",{class:"watermark-config"},[st("水印"),h("form",{class:"pd-form",onSubmit:s=>s.preventDefault()},[h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"水印表达式"}),h("input",{class:"pd-input",type:"text",value:n,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:s=>{const d=s.target.value;i(xs(d)?{mode:"binding",binding:d,content:""}:{mode:"fixed",content:d,binding:""})},onDblclick:a}),h("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:a})]),r?ie("测试值",h("input",{class:"pd-input",type:"text",value:t?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:s=>i({testData:s.target.value})})):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),h("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(t?.rotate??ae.rotate),onChange:s=>i({rotate:Number(s.target.value)})}),h("span",{class:"pd-hint",text:`${t?.rotate??ae.rotate}°`})]),ie("颜色",Ke(t?.color||ae.color,s=>i({color:s}),"水印颜色"),void 0,c("color")),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),h("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(t?.opacity??ae.opacity),onChange:s=>i({opacity:Number(s.target.value)})}),h("span",{class:"pd-hint",text:(t?.opacity??ae.opacity).toFixed(2)})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"密度"}),h("select",{class:"pd-select",style:{width:"100%"},onChange:s=>{const d=s.target.value,p=ws[d];p&&i({tileWidth:p.width,tileHeight:p.height})}},[...Object.entries(ws).map(([s,d])=>h("option",{value:s,text:`${d.label}(${d.width}×${d.height})`,selected:o===s})),h("option",{value:"custom",text:"自定义",selected:o==="custom"})])]),o==="custom"?h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),h("input",{type:"number",class:"pd-input",min:ae.minTileWidth,step:10,value:String(t?.tileWidth??ae.tileWidth),onChange:s=>i({tileWidth:Number(s.target.value)})})]):"",o==="custom"?h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),h("input",{type:"number",class:"pd-input",min:ae.minTileHeight,step:10,value:String(t?.tileHeight??ae.tileHeight),onChange:s=>i({tileHeight:Number(s.target.value)})})]):""].filter(Boolean))])}function Ce(e,t,n,r,o={},i){return ie(t,Z({value:n,...o,onCommit:r}),void 0,i)}function Ot(e,t,n,r,o,i,a){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>o(l.value));for(const c of r){const s=document.createElement("option");s.value=c.value,s.textContent=c.label,l.appendChild(s)}return l.value=n,r.some(c=>c.value===n)||(l.selectedIndex=-1),i?Ve(t,l,i,a):ie(t,l,void 0,a)}function En(e,t,n,r,o){return ie(t,h("input",{type:"checkbox",class:"pd-switch",checked:n,onChange:i=>r(i.target.checked)}),void 0,o)}const Jv=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],Qv=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function ew(e,t){const n=e.store,r=t.options,o=t.printElementType.type,i=x=>n.updateElement(t.id,x),a=o==="text"||o==="longText",l=o==="barcode"||o==="qrcode",c=o==="table",s=c&&n.tableSelection?.elementId===t.id,d=s&&Si(t.options.tableRows??[],n.tableSelection).mode==="multi",p=[];d||p.push(zv(e,t)),s||p.push(Ne(e,"position-size","位置与尺寸","Location",[h("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[h("div",{class:"position-grid"},[H(e,"ps-left",Ce(e,"X",r.left,x=>i({left:x}),{min:0})),H(e,"ps-top",Ce(e,"Y",r.top,x=>i({top:x}),{min:0})),H(e,"ps-width",Ce(e,"W",r.width,x=>i({width:x}),{min:4})),H(e,"ps-height",Ce(e,"H",r.height,x=>i({height:x}),{min:4}))])])]));const u=_i(o),f=(x,j)=>{const te=Eg(j);return Xt({target:r,base:u,propKey:x,tipValue:te?.value,tipUnit:te?.unit,write:()=>i({[x]:u[x]})})},g=typeof r.rotate=="number"&&Number.isFinite(r.rotate)&&r.rotate!==0?Rn(r.rotate):void 0,m=x=>i({rotate:x===void 0||x===0?void 0:Rn(x)}),y=ph(o,r),v=dh(o)||cl(n.elements).has(t.id),w=v?"":H(e,"ap-rotate",Ve("旋转 (°)",h("div",{class:"pd-rotate-row"},[h("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>m((g??0)-90)}),h("div",{class:"pd-rotate-stepper"},[Z({value:g,min:0,max:359,placeholder:"0",disabled:!y,onCommit:x=>m(x)})]),h("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>m((g??0)+90)})]),Oe("ap-rotate"),f("rotate","ap-rotate"))),_=v||y?"":h("p",{class:"pd-hint pd-rotate-note",text:uh});if(p.push(Ne(e,"appearance","外观","Brush",[h("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},a?[H(e,"ap-font-family",ie("字体",qo({id:"prop-font",state:e.state,fonts:e.host.fonts,value:typeof r.fontFamily=="string"?r.fontFamily:void 0,placeholder:"默认",onChange:x=>i({fontFamily:x})}),void 0,f("fontFamily","ap-font-family"))),H(e,"ap-font-size",Ce(e,"字体大小",r.fontSize,x=>i({fontSize:x}),{min:8,max:72},f("fontSize","ap-font-size"))),H(e,"ap-font-weight",Ot(e,"字体粗细",String(r.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],x=>i({fontWeight:x}),void 0,f("fontWeight","ap-font-weight"))),H(e,"ap-align",ie("对齐",Ct("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],r.textAlign||"left",x=>i({textAlign:x})),void 0,f("textAlign","ap-align"))),H(e,"ap-vertical-align",ie("垂直对齐",Ct("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],r.verticalAlign||"top",x=>i({verticalAlign:x})),void 0,f("verticalAlign","ap-vertical-align"))),h("div",{class:"color-row"},[H(e,"ap-color",ie("颜色",Ke(r.color,x=>i({color:x}),"字体颜色"),void 0,f("color","ap-color"))),H(e,"ap-bg-color",ie("背景色",Ke(r.backgroundColor,x=>i({backgroundColor:x}),"背景颜色"),void 0,f("backgroundColor","ap-bg-color")))]),H(e,"ap-line-height",Ce(e,"行高",r.lineHeight,x=>i({lineHeight:x||void 0}),{min:0,max:100},f("lineHeight","ap-line-height"))),H(e,"ap-letter-spacing",Ce(e,"字间距",r.letterSpacing,x=>i({letterSpacing:x||void 0}),{min:0,max:20,step:.5},f("letterSpacing","ap-letter-spacing"))),H(e,"ap-text-fit",Ot(e,"文字溢出",wr(o,r),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],x=>i({textFit:x}),void 0,f("textFit","ap-text-fit"))),r.textFit==="shrink"?H(e,"ap-shrink-min",ie("最小字号 (pt)",Z({value:r.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:x=>i({shrinkMinFontSize:x||void 0})}),void 0,f("shrinkMinFontSize","ap-shrink-min"))):"",o==="longText"?H(e,"ap-long-text-indent",Ve("首行缩进 (字符)",Z({value:r.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:x=>i({longTextIndent:x||void 0})}),Oe("ap-long-text-indent"),f("longTextIndent","ap-long-text-indent"))):"",H(e,"ap-word-wrap",En(e,"自动换行",r.wordWrap!==!1,x=>i({wordWrap:x?void 0:!1}),f("wordWrap","ap-word-wrap"))),H(e,"ap-keep-line-breaks",En(e,"保留换行符",r.keepLineBreaks===!0,x=>i({keepLineBreaks:x?!0:void 0}),f("keepLineBreaks","ap-keep-line-breaks"))),w,_]:[o==="image"?H(e,"ap-img-fit",Ot(e,"缩放模式",String(r.fit??"contain"),fa,x=>i({fit:x}),Oe("ap-img-fit"),f("fit","ap-img-fit"))):"",o==="image"&&r.fit==="cover"?H(e,"ap-img-object-position",Gp(e,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:Yc(r.src),widthMm:Number(r.width)||0,heightMm:Number(r.height)||0,fit:r.fit,scale:r.fitScale,value:r.objectPosition===void 0?void 0:String(r.objectPosition),onCommit:x=>i({objectPosition:x}),onScaleCommit:x=>i({fitScale:x}),resetAnchor:f("objectPosition","ap-img-object-position"),resetScale:f("fitScale","ap-img-fit-scale")})):"",w,_,o==="flowList"?h("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),l){const x=o==="barcode",j=String(r.barcodeType||"CODE128").toUpperCase(),te=r.printerDpi?String(r.printerDpi):"",fe=Zs(r.printerDpi,r.barWidth);p.push(Ne(e,"code","条码设置","Postcard",[h("form",{class:"pd-form",onSubmit:G=>G.preventDefault()},[x?[H(e,"cd-type",Ot(e,"码制",j,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],G=>i({barcodeType:G==="CODE128"?void 0:G}))),H(e,"cd-dpi",Ot(e,"打印机分辨率",te,[{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}],G=>i({printerDpi:Number(G)>0?Number(G):void 0}),void 0,f("printerDpi","cd-dpi"))),H(e,"cd-dpi",h("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),H(e,"cd-bar-width",Ce(e,"条宽(倍率)",r.barWidth??2,G=>i({barWidth:G}),{min:2,max:8,step:.5},f("barWidth","cd-bar-width"))),H(e,"cd-bar-width",h("p",{class:"pd-hint",text:(te?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(fe?`。${fe}`:"")})),H(e,"cd-bar-quiet-zone",Ve("静区 (模块)",Z({value:r.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:G=>i({barQuietZone:G})}),Oe("cd-bar-quiet-zone"),f("barQuietZone","cd-bar-quiet-zone"))),H(e,"cd-bar-height",Ve("条高 (mm)",Z({value:r.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:G=>i({barHeight:G??void 0})}),Oe("cd-bar-height"),f("barHeight","cd-bar-height"))),H(e,"cd-show-text",En(e,"显示文本",r.hideTitle!==!0,G=>i({hideTitle:G?void 0:!0}),f("hideTitle","cd-show-text"))),H(e,"cd-font-size",ie("文本字号(相对条高,条高为 30)",Z({value:r.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:G=>i({fontSize:G||void 0})}),void 0,f("fontSize","cd-font-size")))]:[H(e,"cd-ec-level",Ot(e,"纠错级别",String(r.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],G=>i({qrCodeLevel:G}),void 0,f("qrCodeLevel","cd-ec-level"))),H(e,"cd-quiet-zone",Ve("静区 (模块)",Z({value:r.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:G=>i({qrQuietZone:G})}),Oe("cd-quiet-zone"),f("qrQuietZone","cd-quiet-zone")))],st("自定义设置"),x?h("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",x?"":H(e,"cd-fit",Ot(e,"缩放模式",String(r.fit||"contain"),fa,G=>i({fit:G||void 0}),void 0,f("fit","cd-fit"))),H(e,"cd-max-width",ie("最大宽度 (mm)",Z({value:r.maxWidth,min:1,max:200,placeholder:"默认",onCommit:G=>i({maxWidth:G||void 0})}),void 0,f("maxWidth","cd-max-width"))),H(e,"cd-max-height",ie("最大高度 (mm)",Z({value:r.maxHeight,min:1,max:200,placeholder:"默认",onCommit:G=>i({maxHeight:G||void 0})}),void 0,f("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(s&&(p.push(Gv(e,t)),p.push(Kv(e,t))),c&&p.push(Yv(e,t)),o==="flowList"){const x=ut(r.flowColumns),j=On(r.flowRowHeight),te=xt(r.flowGapX),fe=Qt(r.flowMaxSpan,x),G=Qf(r.width??0,te,r.fontSize??12);p.push(Ne(e,"flowList","流式列表","Grid3x3",[h("form",{class:"pd-form",onSubmit:de=>de.preventDefault()},[H(e,"fl-columns",Ve("每行列数",Z({value:x,min:1,max:12,onCommit:de=>i({flowColumns:ut(de),flowMaxSpan:Qt(r.flowMaxSpan,ut(de))})}),Oe("fl-columns"))),H(e,"fl-row-height",Ve("行高 (mm)",Z({value:j,min:3,max:100,step:.5,onCommit:de=>i({flowRowHeight:On(de)})}),Oe("fl-row-height"))),H(e,"fl-gap-x",Ve("单元横向间距 (mm)",Z({value:te,min:0,max:50,step:.5,onCommit:de=>i({flowGapX:xt(de)})}),Oe("fl-gap-x"))),H(e,"fl-auto-span",En(e,"内容过长时跨列",r.flowAutoSpan===!0,de=>{i(de?{flowAutoSpan:de,flowMaxSpan:fe}:{flowAutoSpan:de})})),r.flowAutoSpan===!0?H(e,"fl-max-span",Ve("最多跨几列",Z({value:fe,min:1,max:x,onCommit:de=>i({flowMaxSpan:Qt(de,x)})}),Oe("fl-max-span"))):"",x>G?h("p",{class:"pd-hint",text:`按当前字号与框宽,${x} 列偏挤(可放约 ${G} 列)。数值保持不变,出纸按 ${x} 列排。`}):""].flat().filter(Boolean))]))}const M=()=>({borderWidth:r.borderWidth,borderStyle:r.borderStyle,borderColor:r.borderColor,borders:r.borders}),N=x=>{const j=M();Cl(j,x,Il(j)),i(j)},L=x=>{const j=M();Ii(j,x,!Fn(j,x)),i(j)},P=Ol(r),k=P.style==="mixed",S=typeof P.width=="number"?P.width:void 0,C=k||P.style===void 0?"":P.style,O=typeof P.color=="string"?P.color:void 0,D=(x,j)=>{const te=M();rg(te,x,j),i(te)},I=k?[{value:"",label:"混合"},...Ai]:[...Ai];return p.push(Ne(e,"border-bg","边框与背景","Picture",[h("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[H(e,"bb-border-style",Ot(e,"线型",C,I,x=>D("borderStyle",x))),h("div",{class:"border-row"},[H(e,"bb-border-width",Ce(e,"边框宽度",S,x=>D("borderWidth",x),{min:0,max:20,step:.25,placeholder:P.width==="mixed"?"混合":void 0},f("borderWidth","bb-border-width"))),H(e,"bb-border-color",ie("边框颜色",Ke(O,x=>D("borderColor",x),"边框颜色"),void 0,f("borderColor","bb-border-color")))]),...fi(o)?[h("div",{class:"pd-button-group border-presets"},Jv.map(x=>h("button",{type:"button",class:"pd-button small",text:x.label,disabled:x.value==="inner",onClick:()=>N(x.value)}))),h("div",{class:"pd-checkbox-group"},Qv.map(x=>h("label",{class:"pd-checkbox"},[h("input",{type:"checkbox",checked:Fn(r,x.value),onChange:()=>L(x.value)}),h("span",{text:x.label})]))),h("p",{class:"pd-hint",text:Xh})]:[],H(e,"bb-bg-color",ie("背景色",Ke(r.backgroundColor,x=>i({backgroundColor:x}),"背景颜色"),void 0,f("backgroundColor","bb-bg-color")))])])),p.push(Vv(e,t)),p.push(Ne(e,"advanced","高级设置","Setting",[h("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[h("div",{class:"advanced-row"},[H(e,"ad-locked",En(e,"锁定",!!r.locked,x=>i({locked:x}),f("locked","ad-locked"))),H(e,"ad-fixed",En(e,"每页重复",!!r.fixed,x=>i({fixed:x}),f("fixed","ad-fixed")))]),H(e,"ad-z-index",Ce(e,"层级",r.zIndex,x=>i({zIndex:x}),{min:0,max:999},f("zIndex","ad-z-index"))),H(e,"ad-delete",h("div",{class:"pd-field"},[h("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>n.deleteSelected()})]))])],!1)),h("div",{class:"property-content"},p)}function tw(e){const t=e.store,n=t.templateData,r=c=>t.updateTemplateData(c),o=c=>{const s=n.tiling,d=p=>p===90||p===270;if(s?.enabled&&d(c)!==d(n.outputRotation)){const p=zc({...n,outputRotation:c});r({outputRotation:c,tiling:{...s,columns:Math.max(p,1)}});return}r({outputRotation:c})},i=[];for(const[c,s]of Object.entries(nt)){const d=s.group??"其他";let p=i.find(u=>u.group===d);p||(p={group:d,items:[]},i.push(p)),p.items.push({key:c,label:s.label??c})}const a=!nt[n.paperSize],l=ki(n.paperSize);return h("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[st("纸张设置"),ie("纸张尺寸",h("select",{class:"pd-select",style:{width:"100%"},onChange:c=>r({paperSize:c.target.value})},[...i.map(c=>h("optgroup",{label:c.group},c.items.map(s=>h("option",{value:s.key,text:s.label,selected:n.paperSize===s.key})))),h("option",{value:"CUSTOM",text:"自定义宽高",selected:a})])),l||a?ie(l?"纸宽 (mm)":"自定义宽高 (mm)",h("div",{class:"custom-size-grid"},[Z({value:Number(n.customWidth??0),min:25,max:2e3,onCommit:c=>r({customWidth:c})}),...a?[h("span",{class:"custom-size-x",text:"×"}),Z({value:Number(n.customHeight??0),min:25,max:2e3,onCommit:c=>r({customHeight:c})})]:[]])):"",l?"":ie("纸张方向",Ct("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.orientation==="landscape"?"landscape":"portrait",c=>r({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":ie("内容旋转角度",Ct("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(n.outputRotation??0),c=>o(Number(c)),!0),n.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),ie("页面背景色",h("div",{class:"page-bg-row"},[Ke(n.pageBackground,c=>r({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,Xt({target:n,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>r({pageBackground:void 0})})),Tv(e),t.pages.length>1?"":kv(e),st("页边距 (mm)"),h("div",{class:"margin-grid"},[Ce(e,"上",n.margins.top,c=>r({margins:{...n.margins,top:c}}),{min:0,max:50}),Ce(e,"下",n.margins.bottom,c=>r({margins:{...n.margins,bottom:c}}),{min:0,max:100}),Ce(e,"左",n.margins.left,c=>r({margins:{...n.margins,left:c}}),{min:0,max:50}),Ce(e,"右",n.margins.right,c=>r({margins:{...n.margins,right:c}}),{min:0,max:50})]),st("页眉/页脚高度 (mm)"),Ce(e,"页眉高度",n.header.height??10,c=>r({header:{...n.header,height:c}}),{min:0,max:100,step:.1}),Ce(e,"页脚高度",n.footer.height??10,c=>r({footer:{...n.footer,height:c}}),{min:0,max:100,step:.1}),Zv(e)].filter(Boolean))}function nw(e){const t=e.store,n=e.state,r=t.selectedElement;if(n.propCollapsed)return h("div",{class:"property-panel collapsed"},[h("div",{class:"prop-collapsed"},[h("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{n.propCollapsed=!1,e.repaint()}}),...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([i,a,l])=>h("button",{type:"button",class:`pc-btn${n.propTab===i?" on":""}`,title:a,text:l,onClick:()=>{n.propTab=i,n.propCollapsed=!1,e.repaint()}}))])]);const o=r?n.propTab:"page";return h("div",{class:"property-panel"},[h("div",{class:"prop-head"},[h("span",{class:"prop-title",text:"属性台"}),h("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{n.propCollapsed=!0,e.repaint()}})]),h("div",{class:"pd-tabs prop-tabs"},[h("div",{class:"pd-tab-bar",role:"tablist"},[h("button",{type:"button",class:`pd-tab${o==="element"?" active":""}`,text:"元素属性",onClick:()=>{n.propTab="element",e.repaint()}}),h("button",{type:"button",class:`pd-tab${o==="page"?" active":""}`,text:"页面属性",onClick:()=>{n.propTab="page",e.repaint()}})]),h("div",{class:"pd-tab-pane",role:"tabpanel",style:o==="element"?"":{display:"none"}},r?[Dv(e),ew(e,r)]:[h("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),h("div",{class:"pd-tab-pane",role:"tabpanel",style:o==="page"?"":{display:"none"}},[tw(e)])])])}const Es=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],Kp={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},rw=[{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()"}],ow=[{name:"ADD",label:"相加",template:"ADD()"},{name:"SUB",label:"相减",template:"SUB()"},{name:"MUL",label:"相乘",template:"MUL()"},{name:"DIV",label:"相除",template:"DIV()"},{name:"ROUND",label:"四舍五入",template:"ROUND()"},{name:"ROUNDUP",label:"进一法",template:"ROUNDUP()"},{name:"ROUNDDOWN",label:"去尾法",template:"ROUNDDOWN()"},{name:"ROUNDBANK",label:"四舍六入五成双",template:"ROUNDBANK()"}],iw=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],aw=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],sw=[{title:"聚合函数",items:rw},{title:"数值运算",items:ow},{title:"格式化函数",items:iw}],lw="(输入表达式后预览)",cw="(无法计算)",Ss="(表达式错误)";function Xp(e,t){if(!e.trim())return lw;try{const n={...it,...t??{},...$r()},r=dn(e,n);return r==null?cw:String(r)}catch{return Ss}}function Zp(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.label.toLowerCase().includes(n)||r.name.toLowerCase().includes(n)):e}function dw(e,t){const n=e.substring(0,t),r=n.lastIndexOf("{"),o=r!==-1&&!n.slice(r+1).includes("}"),i=n.lastIndexOf("("),a=i!==-1&&!n.slice(i+1).includes(")");return{insideBlock:o,insideParens:a}}function uw(e,t){const n=/^\{\s*([^{}]+?)\s*\}$/.exec(e.trim());if(!n)return null;const r=n[1]??"";return t.find(o=>o.fieldKey===r)??null}function _s(e,t){return h("div",{class:"ee-field-info"},[h("span",{class:"ee-item-label",text:e}),h("span",{class:"ee-item-key",text:t})])}function mt(e){return e.currentTarget.getRootNode()}function Go(e,t,n){const r=[];return n.forEach((o,i)=>{r.push(o),i<n.length-1&&r.push(h("br"))}),h("div",{class:`ee-help-card ${e}`},[h("div",{class:"ee-help-card-title",text:t}),h("div",{class:"ee-help-card-content"},r)])}function pw(){return h("div",{class:"ee-help-section"},[h("div",{class:"ee-help-title",text:"帮助信息"}),h("div",{class:"ee-help-grid"},[Go("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名称,当静态文本用","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),Go("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Go("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Go("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function fw(e,t){const n={activeTab:"field",searchText:"",expression:t.value||"",binding:t.binding,copiedFieldKey:""},r=(m,y)=>m.querySelector(y),o=m=>{const y=r(m,".ee-preview");if(!y)return;const v=Xp(n.expression,e.demoData);y.textContent=v,y.classList.toggle("ee-preview-error",v===Ss)},i=()=>{if(n.activeTab==="variable")return Zp(aw,n.searchText).map(v=>h("div",{class:"ee-list-item",onDblclick:w=>{const{insideParens:_}=c(w);s(mt(w),_?v.template.replace(/^\{|\}$/g,""):v.template)}},[_s(v.label,v.template)]));if(n.activeTab==="function")return sw.map(v=>h("div",{class:"ee-func-group"},[h("div",{class:"ee-func-group-title",text:v.title}),...Zp(v.items,n.searchText).map(w=>h("div",{class:"ee-list-item",onDblclick:_=>{const{insideBlock:M}=c(_),N=M?w.template:`{${w.template}}`;s(mt(_),N,N.indexOf("(")+1)}},[_s(w.label,`${w.name}()`)]))]));const m=x0(Xc(e.fields??[]),n.searchText);if(!m.length)return[h("p",{class:"pd-empty",text:"暂无字段"})];const y=[];for(const v of m){v.key&&y.push(h("div",{class:`ee-field-group${v.isList?" is-list":""}`},[h("span",{class:"ee-field-group-icon",text:v.isList?"📋":"📁"}),h("span",{text:v.label})]));for(const w of v.fields)y.push(h("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:v.key?"22px":"10px"},onDblclick:_=>{const{insideParens:M}=c(_),N=_;if(N.ctrlKey||N.metaKey){const L=w.fieldLabel||w.fieldKey;s(mt(_),M?`"${L}"`:L);return}s(mt(_),M?w.fieldKey:`{${w.fieldKey}}`)}},[_s(w.fieldLabel,w.fieldKey),h("button",{type:"button",class:`ee-copy-btn${n.copiedFieldKey===w.fieldKey?" is-copied":""}`,"data-tip":n.copiedFieldKey===w.fieldKey?"已复制":`复制字段名「${w.fieldLabel}」`,"aria-label":`复制字段名 ${w.fieldLabel}`,html:Re(n.copiedFieldKey===w.fieldKey?"Check":"Copy",13),onClick:_=>{_.stopPropagation(),l(_,w)},onDblclick:_=>_.stopPropagation()})]))}return y},a=m=>{Array.from(m.querySelectorAll(".ee-nav-tab")).forEach((M,N)=>M.classList.toggle("active",Es[N]?.key===n.activeTab));const v=r(m,".ee-content-search .pd-input");if(v){const M=Kp[n.activeTab];v.placeholder!==M&&(v.placeholder=M),v.value!==n.searchText&&(v.value=n.searchText)}const w=r(m,".ee-textarea");w&&w.value!==n.expression&&(w.value=n.expression);const _=r(m,".ee-content-list");if(_){Vu(_);for(const M of i())De(M,_)}o(m)};function l(m,y){const v=mt(m);Zc(y.fieldLabel||y.fieldKey).then(w=>{w&&(n.copiedFieldKey=y.fieldKey,a(v),setTimeout(()=>{n.copiedFieldKey===y.fieldKey&&(n.copiedFieldKey="",a(v))},1200))})}const c=m=>{const v=r(mt(m),".ee-textarea")?.selectionStart??n.expression.length;return dw(n.expression,v)},s=(m,y,v=y.length)=>{const w=r(m,".ee-textarea");if(!w){n.expression+=y,o(m);return}const _=w.selectionStart??n.expression.length,M=w.selectionEnd??_;n.expression=n.expression.substring(0,_)+y+n.expression.substring(M);const N=_+v;w.value=n.expression,w.focus(),w.selectionStart=w.selectionEnd=N,o(m)},d=()=>{const m=n.expression;if(n.binding===void 0){e.onApply({formatter:m}),e.onClose();return}const y=uw(m,e.fields??[]);e.onApply(y?{formatter:m,binding:y.fieldKey,title:y.fieldLabel}:{formatter:m}),e.onClose()},p=h("div",{class:"ee-nav"},[h("div",{class:"ee-nav-title",text:"类型"}),h("div",{class:"ee-nav-tabs"},Es.map((m,y)=>h("div",{class:`ee-nav-tab${n.activeTab===m.key?" active":""}`,text:m.text,onClick:v=>{n.activeTab=Es[y].key,a(mt(v))}})))]),u=h("div",{class:"ee-content"},[h("div",{class:"ee-content-search"},[h("input",{class:"pd-input",placeholder:Kp[n.activeTab],onInput:m=>{n.searchText=m.target.value,a(mt(m))}})]),h("div",{class:"ee-content-list"},i())]),f=Xp(n.expression,e.demoData),g=h("div",{class:"ee-editor"},[h("div",{class:"ee-editor-section"},[h("div",{class:"ee-editor-title",text:"表达式编辑"}),h("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名,或直接输入静态内容",text:n.expression,onInput:m=>{n.expression=m.target.value,o(mt(m))}})]),h("div",{class:"ee-editor-section"},[h("div",{class:"ee-editor-title",text:"预览结果"}),h("div",{class:`ee-preview${f===Ss?" ee-preview-error":""}`,text:f})]),pw()]);return h("div",{class:"pd-dialog-overlay",onKeydown:m=>{m.key==="Escape"&&e.onClose()}},[h("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[h("header",{class:"pd-dialog-header"},[h("strong",{id:"expression-editor-title",text:"编辑表达式"}),h("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>e.onClose()})]),h("div",{class:"expression-editor"},[p,u,g]),h("footer",{class:"pd-dialog-footer"},[h("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>e.onClose()}),h("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>d()})])])])}const Yo=[{id:"getting-started",title:"快速入门",content:`
268
+ Minimum version required to store current data is: `+k+`.
269
+ `);const $=_(D,I,C),P=e.getSymbolSize(D),x=new r(P);return f(x,D),m(x),g(x,D),v(x,I,0),D>=7&&b(x,D),w(x,$),isNaN(S)&&(S=a.getBestMask(x,v.bind(null,x,I))),a.applyMask(S,x),v(x,I,S),{modules:x,version:D,errorCorrectionLevel:I,maskPattern:S,segments:C}}return Ca.create=function(D,I){if(typeof D>"u"||D==="")throw new Error("No input text");let S=t.M,C,k;return typeof I<"u"&&(S=t.from(I.errorCorrectionLevel,t.M),C=s.from(I.version),k=a.from(I.maskPattern),I.toSJISFunc&&e.setToSJISFunction(I.toSJISFunc)),N(D,C,S,k)},Ca}var Ya={},Xa={},Ju;function Qu(){return Ju||(Ju=1,(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(i){return[i,i]}))),r.length===6&&r.push("F","F");const o=parseInt(r.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const o=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,i=r.width&&r.width>=21?r.width:void 0,a=r.scale||4;return{width:i,scale:i?4:a,margin:o,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,o){return o.width&&o.width>=r+o.margin*2?o.width/(r+o.margin*2):o.scale},e.getImageWidth=function(r,o){const i=e.getScale(r,o);return Math.floor((r+o.margin*2)*i)},e.qrToImageData=function(r,o,i){const a=o.modules.size,l=o.modules.data,c=e.getScale(a,i),s=Math.floor((a+i.margin*2)*c),d=i.margin*c,p=[i.color.light,i.color.dark];for(let u=0;u<s;u++)for(let f=0;f<s;f++){let m=(u*s+f)*4,g=i.color.light;if(u>=d&&f>=d&&u<s-d&&f<s-d){const b=Math.floor((u-d)/c),v=Math.floor((f-d)/c);g=p[l[b*a+v]?1:0]}r[m++]=g.r,r[m++]=g.g,r[m++]=g.b,r[m]=g.a}}})(Xa)),Xa}var ep;function Qb(){return ep||(ep=1,(function(e){const t=Qu();function n(o,i,a){o.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=a,i.width=a,i.style.height=a+"px",i.style.width=a+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(i,a,l){let c=l,s=a;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),a||(s=r()),c=t.getOptions(c);const d=t.getImageWidth(i.modules.size,c),p=s.getContext("2d"),u=p.createImageData(d,d);return t.qrToImageData(u.data,i,c),n(p,s,d),p.putImageData(u,0,0),s},e.renderToDataURL=function(i,a,l){let c=l;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),c||(c={});const s=e.render(i,a,c),d=c.type||"image/png",p=c.rendererOpts||{};return s.toDataURL(d,p.quality)}})(Ya)),Ya}var Ka={},tp;function e1(){if(tp)return Ka;tp=1;const e=Qu();function t(o,i){const a=o.a/255,l=i+'="'+o.hex+'"';return a<1?l+" "+i+'-opacity="'+a.toFixed(2).slice(1)+'"':l}function n(o,i,a){let l=o+i;return typeof a<"u"&&(l+=" "+a),l}function r(o,i,a){let l="",c=0,s=!1,d=0;for(let p=0;p<o.length;p++){const u=Math.floor(p%i),f=Math.floor(p/i);!u&&!s&&(s=!0),o[p]?(d++,p>0&&u>0&&o[p-1]||(l+=s?n("M",u+a,.5+f+a):n("m",c,0),c=0,s=!1),u+1<i&&o[p+1]||(l+=n("h",d),d=0)):c++}return l}return Ka.render=function(i,a,l){const c=e.getOptions(a),s=i.modules.size,d=i.modules.data,p=s+c.margin*2,u=c.color.light.a?"<path "+t(c.color.light,"fill")+' d="M0 0h'+p+"v"+p+'H0z"/>':"",f="<path "+t(c.color.dark,"stroke")+' d="'+r(d,s,c.margin)+'"/>',m='viewBox="0 0 '+p+" "+p+'"',b='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+m+' shape-rendering="crispEdges">'+u+f+`</svg>
270
+ `;return typeof l=="function"&&l(null,b),b},Ka}var np;function t1(){if(np)return wn;np=1;const e=$b(),t=Jb(),n=Qb(),r=e1();function o(i,a,l,c,s){const d=[].slice.call(arguments,1),p=d.length,u=typeof d[p-1]=="function";if(!u&&!e())throw new Error("Callback required as last argument");if(u){if(p<2)throw new Error("Too few arguments provided");p===2?(s=l,l=a,a=c=void 0):p===3&&(a.getContext&&typeof s>"u"?(s=c,c=void 0):(s=c,c=l,l=a,a=void 0))}else{if(p<1)throw new Error("Too few arguments provided");return p===1?(l=a,a=c=void 0):p===2&&!a.getContext&&(c=l,l=a,a=void 0),new Promise(function(f,m){try{const g=t.create(l,c);f(i(g,a,c))}catch(g){m(g)}})}try{const f=t.create(l,c);s(null,i(f,a,c))}catch(f){s(f)}}return wn.create=t.create,wn.toCanvas=o.bind(null,n.render),wn.toDataURL=o.bind(null,n.renderToDataURL),wn.toString=o.bind(null,function(i,a,l){return r.render(i,l)}),wn}var n1=t1();const r1=md(n1),rp="http://www.w3.org/2000/svg";function o1(e){const t=e.getAttribute("viewBox");if(!t)return null;const n=t.trim().split(/[\s,]+/).map(Number);return n.length!==4||n.some(r=>!Number.isFinite(r))?null:{width:n[2],height:n[3]}}function i1(e,t){const n=document.createElementNS(rp,"svg"),r=Fn(t.barWidth),o=wi(t.barQuietZone),i=l=>{Ta(n,e,{format:t.barcodeType||"CODE128",width:r,height:l*r,displayValue:t.showText!==!1,fontSize:(t.fontSize??Ir)*r,margin:0,marginLeft:o*r,marginRight:o*r,marginTop:0,marginBottom:xi*r});const c=o1(n);return c?{widthUnits:c.width,heightUnits:c.height}:null},a=Si({barHeightMm:t.barHeightMm,boxWidthMm:t.targetWidthMm??0,boxHeightMm:t.targetHeightMm??0,dpi:t.printerDpi,barWidth:t.barWidth,measure:i});return a.size&&(n.setAttribute("width",`${a.size.widthMm}mm`),n.setAttribute("height",`${a.size.heightMm}mm`)),n.setAttribute("shape-rendering","crispEdges"),n.outerHTML}function a1(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):sl}function s1(e,t){const n=(t.qrCodeLevel??"M").toUpperCase(),o=r1.create(e,{errorCorrectionLevel:["L","M","Q","H"].includes(n)?n:"M"}).modules,i=o.size,a=4,l=a1(t.qrQuietZone)*a,c=i*a+l*2;let s="";for(let d=0;d<i;d++)for(let p=0;p<i;p++)o.get(p,d)&&(s+=`<rect x="${l+p*a}" y="${l+d*a}" width="${a}" height="${a}" fill="#000"/>`);return`<svg xmlns="${rp}" viewBox="0 0 ${c} ${c}" width="${c}" height="${c}" shape-rendering="crispEdges">${s}</svg>`}function op(e,t,n={}){if(!e)throw new Error("empty barcode value");return t==="qrcode"?s1(e,n):i1(e,n)}const Za={render(e,t,n={}){return op(e,t,n)}},Ja=.5,l1=12;function Qa(e,t){const n=e.getAttribute(t);if(n===null||n==="")return;const r=Number(n);return Number.isFinite(r)?r:void 0}function ip(e,t){if(e.scrollWidth>e.clientWidth+Ja)return!0;const n=e.scrollHeight;return t!==void 0?n>t+Ja:n>e.clientHeight+Ja}function ap(e){if(e.getAttribute("data-fit")!=="shrink")return;const t=$n(Qa(e,"data-fit-min")),n=Math.max(Qa(e,"data-fit-base")??t,t),r=Qa(e,"data-fit-mm"),o=r!==void 0&&r>0?zt(r):void 0,i=s=>{const d=eh(s);return e.style.fontSize=`${d}pt`,e.setAttribute("data-fit-size",String(d)),d},a=i(n);if(!ip(e,o)||n<=t)return a;let l=t,c=n;for(let s=0;s<l1;s++){const d=(l+c)/2;i(d),ip(e,o)?c=d:l=d}return i(l)}function c1(e){const t=[];return e.querySelectorAll('[data-fit="shrink"]').forEach(n=>{const r=ap(n),o=n.getAttribute("data-fit-key");r===void 0||!o||t.push({key:o,fontSizePt:r})}),t}const d1="2",u1=5e3;async function p1(e,t=u1){const n=e.document,r=i=>Promise.race([i,new Promise(a=>setTimeout(a,t))]),o=(async()=>{n.readyState!=="complete"&&await r(new Promise(a=>e.addEventListener("load",()=>a(),{once:!0})));const i=n.fonts;i&&(await r(Promise.all(f1(n).map(a=>i.load(`${a.style} ${a.weight} 16px "${a.family}"`).catch(()=>{})))),i.ready&&await r(i.ready)),await r(Promise.all(Array.from(n.images??[]).map(a=>a.complete?Promise.resolve():new Promise(l=>{a.addEventListener("load",()=>l(),{once:!0}),a.addEventListener("error",()=>l(),{once:!0})}))))})();await r(o)}function f1(e){const t=[];for(const r of Array.from(e.styleSheets??[])){let o;try{o=r.cssRules}catch{continue}for(const i of Array.from(o??[])){if(i.type!==5)continue;const a=i.style,l=(a.getPropertyValue("font-family")||"").replace(/^["']|["']$/g,"");l&&t.push({family:l,weight:a.getPropertyValue("font-weight")||"400",style:a.getPropertyValue("font-style")||"normal"})}}return t}function h1(e){const t=[];return e.querySelectorAll("[data-measure-id]").forEach(n=>{const r=n,o=r.getAttribute("data-measure-id");if(!o)return;const i=r.getBoundingClientRect().height,a=r.querySelector("table.print-table");if(!a){const c=r.querySelectorAll(".print-flow-row[data-flow-row-index]");if(c.length>0){const s=[];c.forEach(d=>s.push(d.getBoundingClientRect().height)),t.push({id:o,heightPx:i,rowHeightsPx:s});return}t.push({id:o,heightPx:i});return}const l=[];a.querySelectorAll("tbody > tr[data-row-index]").forEach(c=>{l.push(c.getBoundingClientRect().height)}),t.push({id:o,heightPx:i,rowHeightsPx:l})}),t}function g1(e){const t=e.querySelector(".print-page"),n=e.querySelector(".content-area");if(!t||!n)return 0;const r=t.getBoundingClientRect().top;let o=0;n.querySelectorAll("*").forEach(a=>{const l=a.getBoundingClientRect();l.height>0&&(o=Math.max(o,l.bottom-r))});const i=n.getBoundingClientRect();return i.height>0&&(o=Math.max(o,i.bottom-r)),o}function m1(e){const t={};for(const n of e)try{t[n.key]=op(n.value,n.cellType,n.opts)}catch{}return t}const b1={version:d1,waitReady:p1,readMeasurements:h1,readContentBottom:g1,renderCodes:m1,applyTextFit:c1};function y1(){return{async createDriver(){const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;left:-10000px;top:0;border:0;visibility:hidden;pointer-events:none;",document.body.appendChild(e);let t=e.contentDocument??document;return{requiresExecutor:!1,async open(n){e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,t=e.contentDocument??document},async setContent(n){t=e.contentDocument??document,t.open(),t.write(n),t.close()},async injectExecutor(n){},async evaluate(n,r){const o=b1[n],i=r??[],a=s0[n];return a==="window"?o(e.contentWindow,...i):a==="document"?o(t,...i):o(...i)},async close(){e.remove()}}}}}function v1(){return d0(y1())}async function w1(e,t,n,r,o){const i=await x0({templateJson:e,printData:t,baseUrl:n,fontBaseUrl:o?.fontBaseUrl??"",paperHeightMm:o?.paperHeightMm,codeRenderer:r},v1());return{html:i.html,pageCount:i.pageCount,pageLayouts:i.pageLayouts,paperMm:i.paperMm,continuous:i.continuous,copies:i.copies,copyPaperMm:i.copyPaperMm}}function h(e,t={},n=[]){return{tag:e,props:t,children:n}}const sp="http://www.w3.org/2000/svg",x1=new Set(["draggable","contenteditable","spellcheck"]),E1=new Set(["indeterminate"]);function S1(e){return e==="svg"||e==="path"||e==="circle"||e==="rect"||e==="line"||e==="g"}function Fe(e,t){if(typeof e=="string"){const a=document.createTextNode(e);return t.appendChild(a),a}if(e instanceof Node)return t.appendChild(e),e;const{tag:n,props:r,children:o}=e,i=S1(n)?document.createElementNS(sp,n):document.createElement(n);for(const[a,l]of Object.entries(r))if(!(l==null||l===!1))if(a==="class")i.setAttribute("class",String(l));else if(a==="style")typeof l=="string"?i.style.cssText=l:Object.assign(i.style,l);else if(a==="html")i.innerHTML=String(l);else if(a==="text")i.textContent=String(l);else if(a.startsWith("on")&&typeof l=="function")i.addEventListener(a.slice(2).toLowerCase(),l);else if(a==="dataset")for(const[c,s]of Object.entries(l))i.dataset[c]=s;else E1.has(a)?i[a]=!0:typeof l=="boolean"?l&&i.setAttribute(a,x1.has(a)?"true":""):i.setAttribute(a,String(l));for(const a of o)Fe(a,i);return t.appendChild(i),i}function lp(e){for(;e.firstChild;)e.removeChild(e.firstChild)}const _1=sp;function gr(){return{paperSize:"A4",orientation:"portrait",unit:"mm",margins:{top:10,right:10,bottom:10,left:10},header:{height:10,elements:[]},footer:{height:10,elements:[]},elements:[],watermark:{}}}const es="开启拼版后只能有一个设计页面";function ts(e){const t=(n,r)=>(n??[]).map(o=>{const i={...o.options};return(o.printElementType?.type??o.type)==="table"&&jn(i),{id:o.id||un(),zone:r,options:i,printElementType:{...o.printElementType}}});return{...e,margins:{...e.margins},header:{height:e.header?.height??10,elements:[]},footer:{height:e.footer?.height??10,elements:[]},guides:[...e.guides??[]],elements:[...t(e.elements??[],"content"),...t(e.header?.elements??[],"header"),...t(e.footer?.elements??[],"footer")]}}function cp(e){const t=e.elements,n=r=>t.filter(o=>(o.zone||"content")===r).map(o=>({id:o.id,type:o.printElementType.type,options:{...o.options},printElementType:{...o.printElementType}}));return{unit:"mm",...e,header:{...e.header,elements:n("header")},footer:{...e.footer,elements:n("footer")},elements:n("content"),guides:[...e.guides??[]]}}function dp(e){const t=(r,o)=>{const i=ts(ag(r));return i.name||(i.name=`页面 ${o+1}`),i};if(!e)return[t(gr(),0)];const n=Array.isArray(e.pages)?e.pages:[e];return n.length?n.map(t):[t(gr(),0)]}const xn=e=>JSON.parse(JSON.stringify(e));class up{scale=100;showRuler=!0;showGrid=!0;snapToGrid=!1;showTableGhostBorder=!0;dirty=!1;pages;activePageIndex=0;fields;selectedIds=new Set;previewIds=new Set;tableSelection=null;draggingIds=new Set;adsorbGuides=[];live=new Map;clipboard=[];moveSessionActive=!1;moveTimer=null;dragBefore=null;undoStack=[];redoStack=[];listeners=new Set;align=G0();group=V0();constructor(t={}){if(this.pages=dp(t.initialTemplate),this.fields=t.initialFields??[],t.initialElements?.length){const n=this.pages[0];n.elements=[...n.elements,...t.initialElements]}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t=!0){t&&(this.dirty=!0);for(const n of[...this.listeners])n()}get templateData(){return this.pages[this.activePageIndex]}set templateData(t){this.pages[this.activePageIndex]=t}get elements(){return this.templateData.elements.map(t=>this.live.get(t.id)??t)}get tilingEnabled(){return this.pages.some(t=>t.tiling?.enabled===!0)}switchPage(t){t<0||t>=this.pages.length||(this.activePageIndex=t,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(es);return}this.recordHistory();const t=this.pages[this.activePageIndex]??gr();this.pages.push(ts({...gr(),paperSize:t.paperSize,orientation:t.orientation,customWidth:t.customWidth,customHeight:t.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const t=new Set(this.pages.map(r=>r.name));let n=this.pages.length+1;for(;t.has(`页面 ${n}`);)n++;return`页面 ${n}`}duplicatePage(t){if(this.tilingEnabled){window.alert(es);return}this.recordHistory();const n=xn(this.pages[t]);n.name=`${n.name??`页面 ${t+1}`} 副本`,n.elements=n.elements.map(r=>({...r,id:un()})),this.pages.splice(t+1,0,n),this.switchPage(t+1),this.emit()}deletePage(t){this.pages.length<=1||(this.recordHistory(),this.pages.splice(t,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(t,n){this.recordHistory(),this.pages[t].name=n,this.emit()}movePage(t,n){if(n<0||n>=this.pages.length||t===n)return;this.recordHistory();const[r]=this.pages.splice(t,1);this.pages.splice(n,0,r),this.activePageIndex=n,this.emit()}onSelectionChanged;setSelection(t){this.selectedIds=t,this.onSelectionChanged?.(),this.emit(!1)}select(t){this.setSelection(new Set(t))}selectOne(t,n=!1){if(n){const r=new Set(this.selectedIds);r.has(t)?r.delete(t):r.add(t),this.setSelection(r)}else this.setSelection(new Set([t]))}clearSelection(){this.setSelection(new Set)}selectElement(t,n=!1){if(n){this.selectOne(t,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,t)))}selectAll(){this.setSelection(new Set(this.elements.map(t=>t.id)))}get selectedElements(){return this.elements.filter(t=>this.selectedIds.has(t.id))}get selectedElement(){const t=this.selectedIds.values().next().value;return t?this.elements.find(n=>n.id===t)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(t){this.tableSelection=t,this.emit(!1)}setPreview(t){this.previewIds=t,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(t,n){const r=this.templateData.guides??[];this.templateData.guides=[...r,{id:un(),type:t,position:Math.round(n*10)/10}],this.emit()}moveGuide(t,n){const r=this.templateData.guides??[];this.templateData.guides=r.map(o=>o.id===t?{...o,position:Math.round(n*10)/10}:o),this.emit(!1)}removeGuide(t){this.templateData.guides=(this.templateData.guides??[]).filter(n=>n.id!==t),this.emit()}addElement(t,n={},r){const o=Li(t,n);return r&&!this.placeAtDropPoint(o,r)||(this.recordHistory(),this.templateData.elements.push(o),this.select(new Set([o.id])),this.emit()),o}addFieldElement(t,n={},r,o=!1){const i=o?W0(t):q0(t);return Object.assign(i.options,n),r&&!this.placeAtDropPoint(i,r)||(this.recordHistory(),this.templateData.elements.push(i),this.select(new Set([i.id])),this.emit()),i}placeAtDropPoint(t,n){const r=this.templateData,o=Kl(r,n.x,n.y);if(o!=="content"&&!Xl.includes(t.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const i=Wi(r)[o];return t.zone=o,t.options.left=n.x-i.left,t.options.top=n.y-i.top,o!=="content"&&ji(t,i),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(t=>!this.selectedIds.has(t.id)),this.selectedIds=new Set,this.emit())}livePatch(t,n){const r=this.templateData.elements.find(i=>i.id===t);if(!r)return;const o=this.live.get(t)??r;this.live.set(t,{...o,options:{...o.options,...n}})}commitLive(){if(!this.live.size)return;this.recordHistory();const t=this.templateData.elements;for(const[n,r]of this.live){const o=t.find(i=>i.id===n);o&&Object.assign(o.options,r.options)}this.live.clear(),this.emit()}dragIds(t){const n=this.templateData.elements.find(r=>r.id===t);return!n||n.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,t))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(t=>[t.id,this.geoSig(t)]))}dragStop(){const t=this.dragBefore;if(!t)return;this.dragBefore=null;let n=!1;for(const r of this.elements){const o=t.get(r.id);!o||o===this.geoSig(r)||Tg(r,this.templateData).rejected&&(n=!0)}n&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(t){return`${t.zone||"content"}:${t.options.left},${t.options.top},${t.options.width},${t.options.height}`}updateElement(t,n,r=!0){r&&this.recordHistory();const o=this.templateData.elements.find(i=>i.id===t);o&&(Object.assign(o.options,n),o.printElementType.type==="table"&&jn(o.options),this.emit())}updateTemplateData(t){this.recordHistory(),Object.assign(this.templateData,t),this.emit()}moveLayer(t){if(!this.selectedIds.size)return;this.recordHistory();const n=this.templateData.elements,r=n.filter(i=>this.selectedIds.has(i.id)),o=n.filter(i=>!this.selectedIds.has(i.id));if(t==="top")this.templateData.elements=[...o,...r];else if(t==="bottom")this.templateData.elements=[...r,...o];else{const i=n.findIndex(c=>this.selectedIds.has(c.id)),a=t==="up"?i+1:i-1;if(a<0||a>=n.length)return;const l=[...n];[l[i],l[a]]=[l[a],l[i]],this.templateData.elements=l}this.emit()}alignSelected(t){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(n=>this.selectedIds.has(n.id)),t),this.emit())}groupSelected(){this.selectedIds.size<2||(this.recordHistory(),this.templateData.elements=this.group.group(this.elements,this.selectedIds),this.emit())}ungroupSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.group.ungroup(this.elements,this.selectedIds),this.emit())}copy(){this.clipboard=xn(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(t=10){if(!this.clipboard.length)return;this.recordHistory();const n=new Map;for(const i of this.clipboard){const a=i.options.groupId;a&&n.set(a,(n.get(a)??0)+1)}const r=new Map;for(const[i,a]of n)r.set(i,a>=2?gd():void 0);const o=this.templateData.elements;for(const i of this.clipboard){const a=xn(i);a.id=un(),a.options.left+=t,a.options.top+=t,a.options.groupId=a.options.groupId?r.get(a.options.groupId):void 0,o.push(a)}this.emit()}duplicateSelected(){if(this.copy(),!this.clipboard.length)return;this.paste(15);const t=this.templateData.elements;this.selectOne(t[t.length-this.clipboard.length].id)}get hasClipboard(){return this.clipboard.length>0}moveSelected(t,n){const r=this.selectedElements.filter(o=>!o.options.locked);if(r.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const o of r)o.options.left+=t,o.options.top+=n;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(t){this.recordHistory(),this.templateData.elements.push(t),this.selectedIds=new Set([t.id]),this.emit()}recordHistory(){this.undoStack.push({pages:xn(this.pages),activePageIndex:this.activePageIndex}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack=[]}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}undo(){const t=this.undoStack.pop();t&&(this.redoStack.push({pages:xn(this.pages),activePageIndex:this.activePageIndex}),this.pages=t.pages,this.activePageIndex=Math.min(t.activePageIndex,t.pages.length-1),this.resetSelection(),this.emit())}redo(){const t=this.redoStack.pop();t&&(this.undoStack.push({pages:xn(this.pages),activePageIndex:this.activePageIndex}),this.pages=t.pages,this.activePageIndex=Math.min(t.activePageIndex,t.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(t,n=Lr){this.scale=Math.max(n,Math.round(t)),this.emit(!1)}getTemplateJson(){const t=this.pages.map(cp),n=t.length===1?t[0]:{version:1,pages:t};return JSON.stringify(n)}loadTemplate(t){this.pages=dp(t),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return It(this.templateData)}}const Zt=Symbol("mixed"),ns=new Set(["text","longText"]),M1=["top","right","bottom","left"],T1={on:!0,off:!1,mixed:Zt};function pp(e){const t=zl(e),n={};for(const r of M1)n[r]=T1[t[r]];return n}const k1=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class C1{constructor(t){this.store=t}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(t=>this.store.selectedIds.has(t.id)&&!t.options.locked)}get tableElement(){const t=this.store.tableSelection;return t?this.store.elements.find(n=>n.id===t.elementId)??null:null}get context(){return this.store.tableSelection&&this.tableElement?"cells":this.selectedElements.length>0||this.store.selectedIds.size>0?"elements":"none"}get targetCells(){const t=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!t||!n)return[];const r=[];for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=n[o]?.cells[i];a&&!a.merged&&r.push(a)}return r}get textTargets(){return this.selectedElements.filter(t=>ns.has(t.printElementType.type))}get fontEditable(){return this.context==="cells"?this.targetCells.length>0:this.context!=="elements"?!1:this.selectedElements.length>0&&this.textTargets.length===this.selectedElements.length}get styleTargets(){return this.context==="cells"?this.targetCells:this.textTargets.map(t=>t.options)}pick(t){if(!t.length)return;const n=t[0];return t.every(r=>r===n)?n:Zt}hasToken(t,n){return(t??"").split(/\s+/).includes(n)}get values(){const t=this.styleTargets;if(!t.length)return{fontFamily:void 0,fontSize:void 0,color:void 0,backgroundColor:void 0,textAlign:void 0,verticalAlign:void 0,bold:!1,underline:!1,strike:!1};const n=t.map(o=>o.fontWeight==="bold"||o.fontWeight==="bolder"),r=t.map(o=>o.textDecoration);return{fontFamily:this.pick(t.map(o=>o.fontFamily)),fontSize:this.pick(t.map(o=>o.fontSize)),color:this.pick(t.map(o=>o.color)),backgroundColor:this.pick(t.map(o=>o.backgroundColor)),textAlign:this.pick(t.map(o=>this.context==="cells"?o.align:o.textAlign)),verticalAlign:this.pick(t.map(o=>this.context==="cells"?o.valign:o.verticalAlign)),bold:n.every(Boolean)?!0:n.some(Boolean)?Zt:!1,underline:r.map(o=>this.hasToken(o,"underline")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"underline"))?Zt:!1,strike:r.map(o=>this.hasToken(o,"line-through")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"line-through"))?Zt:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(t){const n=this.targetCells;n.length&&(n.forEach(t),this.commit())}applyStyle(t){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in t&&(l.fontFamily=t.fontFamily),"fontSize"in t&&(l.fontSize=t.fontSize),"color"in t&&(l.color=t.color),"backgroundColor"in t&&(l.backgroundColor=t.backgroundColor),"textAlign"in t&&(l.align=t.textAlign),"verticalAlign"in t&&(l.valign=t.verticalAlign)});return}const n=this.textTargets,r=this.selectedElements,i=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in t),a="backgroundColor"in t;!(n.length&&i)&&!(r.length&&a)||(n.forEach(l=>{const c=l.options;"fontFamily"in t&&(c.fontFamily=t.fontFamily),"fontSize"in t&&(c.fontSize=t.fontSize),"color"in t&&(c.color=t.color),"textAlign"in t&&(c.textAlign=t.textAlign),"verticalAlign"in t&&(c.verticalAlign=t.verticalAlign)}),a&&r.forEach(l=>{l.options.backgroundColor=t.backgroundColor}),this.commit())}toggleBold(){if(this.context==="cells"){const r=this.values.bold!==!0;this.writeCells(o=>{o.fontWeight=r?"bold":void 0});return}const t=this.values.bold!==!0,n=this.textTargets;n.length&&(n.forEach(r=>{r.options.fontWeight=t?"bold":"normal"}),this.commit())}toggleDecoration(t){if(this.context==="cells")return;const n=this.textTargets;if(!n.length)return;const r=this.values[t==="underline"?"underline":"strike"]!==!0;n.forEach(o=>{const i=(o.options.textDecoration??"").split(/\s+/).filter(Boolean),a=i.indexOf(t);r&&a<0&&i.push(t),!r&&a>=0&&i.splice(a,1),o.options.textDecoration=i.length?i.join(" "):void 0}),this.commit()}toggleUnderline(){this.toggleDecoration("underline")}toggleStrike(){this.toggleDecoration("line-through")}syncBorderDraft(){if(this.context!=="cells"){this.borderDraftKey&&(this.borderDraftKey="",this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1});return}const t=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!t||!n)return;const r=`cells:${t.elementId}:${t.r1}:${t.c1}:${t.r2}:${t.c2}`;if(r===this.borderDraftKey)return;if(this.borderDraftKey=r,Di(n,t).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const o=Nl(n,t);if(o.style===void 0&&o.width===void 0&&o.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:o.style==="mixed",width:o.width==="mixed",color:o.color==="mixed"},this.borderMixed.style?this.borderStyle=null:o.style===void 0?this.borderStyle="solid":o.style==="none"?this.borderStyle=null:this.borderStyle=o.style,this.borderWidth=this.borderMixed.width?void 0:typeof o.width=="number"?o.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof o.color=="string"?o.color:"#333333"}borderSpec(){const t=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:t,color:this.borderColor??"#333333"}}setBorderWidth(t){this.borderWidth=t,this.borderMixed.width=!1}setBorderColor(t){this.borderColor=t,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(t){const n=this.borderStyle===t?null:t;this.borderMixed.style=!1,this.borderStyle=n,n===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(t,n){const r=this.selectedElements;r.length&&(r.forEach(o=>{Bl(o.options,t,n)}),this.commit())}applyCellBorderPreset(t,n){const r=this.store.tableSelection,o=this.tableElement?.options.tableRows;!r||!o||($l(o,{r1:r.r1,c1:r.c1,r2:r.r2,c2:r.c2},t,n),this.commit())}applyCellBorderEdges(t,n,r){this.writeCells(o=>{for(const i of t)Ll(o,i,r?n:null)})}get cellEdges(){if(this.context!=="cells")return null;const t=this.targetCells;return t.length?pp(t.map(n=>n.borders)):null}toggleCellEdge(t,n){const r=this.cellEdges?.[t]!==!0;this.applyCellBorderEdges([t],n,r)}get elementEdges(){if(this.context!=="elements")return null;const t=this.selectedElements;return t.length?pp(t.map(n=>cg(n.options))):null}toggleElementEdge(t,n){const r=this.selectedElements;if(!r.length)return;const o=this.elementEdges?.[t]!==!0;r.forEach(i=>Ui(i.options,t,o,n)),this.commit()}applyBorderPreset(t){const n=this.borderStyle===null;if(this.context==="cells"){const r=n&&!this.borderMixed.style;this.applyCellBorderPreset(r?"none":t,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(n||t==="none"?"none":"all",this.borderSpec())}applyEdge(t){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([t],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(t);return}this.context==="cells"?(this.toggleCellEdge(t,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(t,this.borderSpec())}clearElementEdge(t){const n=this.selectedElements;n.length&&(n.forEach(r=>Ui(r.options,t,!1)),this.commit())}edgeOn(t){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[t]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(t){if(!t)return;const n={};for(const r of zn){const o=t[r];o&&(n[r]={...o})}return n}pickPainterSource(t=!1){const n=this.selectedElements[0];if(!n)return!1;const r=n.options,o=n.printElementType.type;return this.painterSnapshot={text:ns.has(o)?Object.fromEntries(k1.map(i=>[i,r[i]])):null,backgroundColor:r.backgroundColor,border:_i(o)?{borderWidth:r.borderWidth,borderStyle:r.borderStyle,borderColor:r.borderColor,borders:this.clonePainterBorders(r.borders)}:null},this.painterSource=n.id,this.painterActive=!0,this.painterLocked=t,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(t){const n=this.painterSnapshot;if(!n||t.options.locked||t.id===this.painterSource)return!1;const r=t.options,o=t.printElementType.type;return n.text&&ns.has(o)&&Object.assign(r,n.text),r.backgroundColor=n.backgroundColor,n.border&&_i(o)&&(r.borderWidth=n.border.borderWidth,r.borderStyle=n.border.borderStyle,r.borderColor=n.border.borderColor,r.borders=this.clonePainterBorders(n.border.borders)),!0}painterSyncSelection(){if(!this.painterActive||!this.painterSnapshot)return;const t=this.selectedElements;if(!t.length){this.cancelPainter();return}let n=!1;t.forEach(r=>{n=this.applyPainter(r)||n}),n&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(t){if(t.key!=="Escape"||!this.painterActive)return;const n=t.target?.tagName;n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||this.cancelPainter()}}function fp(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function A1(e){if(Array.isArray(e))return e}function O1(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,a,l=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){s=!0,o=d}finally{try{if(!c&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return l}}function I1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
271
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function P1(e,t){return A1(e)||O1(e,t)||R1(e,t)||I1()}function R1(e,t){if(e){if(typeof e=="string")return fp(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fp(e,t):void 0}}const hp=Object.entries,gp=Object.setPrototypeOf,D1=Object.isFrozen,$1=Object.getPrototypeOf,L1=Object.getOwnPropertyDescriptor;let ke=Object.freeze,Ce=Object.seal,En=Object.create,mp=typeof Reflect<"u"&&Reflect,rs=mp.apply,os=mp.construct;ke||(ke=function(t){return t}),Ce||(Ce=function(t){return t}),rs||(rs=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return t.apply(n,o)}),os||(os=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});const Jt=Te(Array.prototype.forEach),N1=Te(Array.prototype.lastIndexOf),bp=Te(Array.prototype.pop),mr=Te(Array.prototype.push),F1=Te(Array.prototype.splice),Sn=Array.isArray,br=Te(String.prototype.toLowerCase),is=Te(String.prototype.toString),yp=Te(String.prototype.match),yr=Te(String.prototype.replace),vp=Te(String.prototype.indexOf),z1=Te(String.prototype.trim),B1=Te(Number.prototype.toString),H1=Te(Boolean.prototype.toString),wp=typeof BigInt>"u"?null:Te(BigInt.prototype.toString),xp=typeof Symbol>"u"?null:Te(Symbol.prototype.toString),Ue=Te(Object.prototype.hasOwnProperty),vr=Te(Object.prototype.toString),Pe=Te(RegExp.prototype.test),Qt=U1(TypeError);function Te(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return rs(e,t,r)}}function U1(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return os(e,n)}}function re(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:br;if(gp&&gp(e,null),!Sn(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(D1(t)||(t[r]=i),o=i)}e[o]=!0}return e}function q1(e){for(let t=0;t<e.length;t++)Ue(e,t)||(e[t]=null);return e}function Ke(e){const t=En(null);for(const r of hp(e)){var n=P1(r,2);const o=n[0],i=n[1];Ue(e,o)&&(Sn(i)?t[o]=q1(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=Ke(i):t[o]=i)}return t}function W1(e){switch(typeof e){case"string":return e;case"number":return B1(e);case"boolean":return H1(e);case"bigint":return wp?wp(e):"0";case"symbol":return xp?xp(e):"Symbol()";case"undefined":return vr(e);case"function":case"object":{if(e===null)return vr(e);const t=e,n=at(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:vr(r)}return vr(e)}default:return vr(e)}}function at(e,t){for(;e!==null;){const r=L1(e,t);if(r){if(r.get)return Te(r.get);if(typeof r.value=="function")return Te(r.value)}e=$1(e)}function n(){return null}return n}function j1(e){try{return Pe(e,""),!0}catch{return!1}}const Ep=ke(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),as=ke(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ss=ke(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),G1=ke(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ls=ke(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),V1=ke(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Sp=ke(["#text"]),_p=ke(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),cs=ke(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Mp=ke(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Vo=ke(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Y1=Ce(/{{[\w\W]*|^[\w\W]*}}/g),X1=Ce(/<%[\w\W]*|^[\w\W]*%>/g),K1=Ce(/\${[\w\W]*/g),Z1=Ce(/^data-[\-\w.\u00B7-\uFFFF]+$/),J1=Ce(/^aria-[\-\w]+$/),Tp=Ce(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Q1=Ce(/^(?:\w+script|data):/i),ey=Ce(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ty=Ce(/^html$/i),ny=Ce(/^[a-z][.\w]*(-[.\w]+)+$/i),kp=Ce(/<[/\w!]/g),Cp=Ce(/<[/\w]/g),ry=Ce(/<\/no(script|embed|frames)/i),oy=Ce(/\/>/i),Ze={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ap=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],iy=ke(re({},Ap)),ay=(function(){const e={};return Jt(Ap,t=>{e[t]=Ce(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),ke(e)})(),sy=function(){return typeof window>"u"?null:window},ly=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Op=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Dt=function(t,n,r,o){return Ue(t,n)&&Sn(t[n])?re(o.base?Ke(o.base):{},t[n],o.transform):r},ds=function(t,n,r){const o=Ue(t,n)?t[n]:void 0;return o&&typeof o=="object"?Ke(o):r()};function Ip(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:sy();const t=L=>Ip(L);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==Ze.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,a=e.Node,l=e.Element,c=e.NodeFilter,s=e.NamedNodeMap;s===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const d=e.DOMParser,p=e.trustedTypes,u=l.prototype,f=at(u,"cloneNode"),m=at(u,"remove"),g=at(u,"nextSibling"),b=at(u,"childNodes"),v=at(u,"parentNode"),w=at(u,"shadowRoot"),_=at(u,"attributes"),M=a&&a.prototype?at(a.prototype,"nodeType"):null,N=a&&a.prototype?at(a.prototype,"nodeName"):null,R=a&&a.prototype?at(a.prototype,"ownerDocument"):null,D=function(y){return M?M(y):y.nodeType},I=function(y){return N?N(y):y.nodeName};if(typeof i=="function"){const L=n.createElement("template");L.content&&L.content.ownerDocument&&(n=L.content.ownerDocument)}let S,C="",k,$=!1,P=0;const x=function(){if(P>0)throw Qt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Y=function(y){x(),P++;try{return S.createHTML(y)}finally{P--}},le=function(y){x(),P++;try{return S.createScriptURL(y)}finally{P--}},De=function(){return $||(k=ly(p,o),$=!0),k},G=n,me=G.implementation,Be=G.createNodeIterator,ue=G.createDocumentFragment,Ie=G.getElementsByTagName,te=r.importNode;let ne=Op();t.isSupported=typeof hp=="function"&&typeof v=="function"&&me&&me.createHTMLDocument!==void 0;const tt=Y1,O=X1,z=K1,q=Z1,W=J1,X=Q1,ee=ey,ce=ny;let pe=Tp,Z=null;const de=re({},[...Ep,...as,...ss,...ls,...Sp]);let J=null;const xe=re({},[..._p,...cs,...Mp,...Vo]);let be=Object.seal(En(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),he=null,Ae=null;const se=Object.seal(En(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let lt=!0,j=!0,Nt=!1,nt=!0,T=!1,B=!0,oe=!1,Ee=!1,$e=null,Tt=null,Cn=!1,fe=!1,Se=!1,An=!1,ai=!0,Af=!1;const Of="user-content-";let Bs=!0,Hs=!1,On={},In=null;const If=re({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Pf=null;const Rf=re({},["audio","video","img","source","image","track"]);let Df=null;const $f=re({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),si="http://www.w3.org/1998/Math/MathML",li="http://www.w3.org/2000/svg",yt="http://www.w3.org/1999/xhtml";let Pn=yt,Us=!1,qs=null;const cx=re({},[si,li,yt],is),Lf=ke(["mi","mo","mn","ms","mtext"]);let Ws=re({},Lf);const Nf=ke(["annotation-xml"]);let js=re({},Nf);const dx=re({},["title","style","font","a","script"]);let Tr=null;const ux=["application/xhtml+xml","text/html"],px="text/html";let _e=null,Rn=null;const fx=n.createElement("form"),Ff=function(y){return y instanceof RegExp||y instanceof Function},Gs=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Rn&&Rn===y)return;(!y||typeof y!="object")&&(y={}),y=Ke(y),Tr=ux.indexOf(y.PARSER_MEDIA_TYPE)===-1?px:y.PARSER_MEDIA_TYPE,_e=Tr==="application/xhtml+xml"?is:br,Z=Dt(y,"ALLOWED_TAGS",de,{transform:_e}),J=Dt(y,"ALLOWED_ATTR",xe,{transform:_e}),qs=Dt(y,"ALLOWED_NAMESPACES",cx,{transform:is}),Df=Dt(y,"ADD_URI_SAFE_ATTR",$f,{transform:_e,base:$f}),Pf=Dt(y,"ADD_DATA_URI_TAGS",Rf,{transform:_e,base:Rf}),In=Dt(y,"FORBID_CONTENTS",If,{transform:_e}),he=Dt(y,"FORBID_TAGS",Ke({}),{transform:_e}),Ae=Dt(y,"FORBID_ATTR",Ke({}),{transform:_e}),On=Ue(y,"USE_PROFILES")?y.USE_PROFILES&&typeof y.USE_PROFILES=="object"?Ke(y.USE_PROFILES):y.USE_PROFILES:!1,lt=y.ALLOW_ARIA_ATTR!==!1,j=y.ALLOW_DATA_ATTR!==!1,Nt=y.ALLOW_UNKNOWN_PROTOCOLS||!1,nt=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,T=y.SAFE_FOR_TEMPLATES||!1,B=y.SAFE_FOR_XML!==!1,oe=y.WHOLE_DOCUMENT||!1,fe=y.RETURN_DOM||!1,Se=y.RETURN_DOM_FRAGMENT||!1,An=y.RETURN_TRUSTED_TYPE||!1,Cn=y.FORCE_BODY||!1,ai=y.SANITIZE_DOM!==!1,Af=y.SANITIZE_NAMED_PROPS||!1,Bs=y.KEEP_CONTENT!==!1,Hs=y.IN_PLACE||!1,pe=j1(y.ALLOWED_URI_REGEXP)?y.ALLOWED_URI_REGEXP:Tp,Pn=typeof y.NAMESPACE=="string"?y.NAMESPACE:yt,Ws=ds(y,"MATHML_TEXT_INTEGRATION_POINTS",()=>re({},Lf)),js=ds(y,"HTML_INTEGRATION_POINTS",()=>re({},Nf));const E=ds(y,"CUSTOM_ELEMENT_HANDLING",()=>En(null));if(be=En(null),Ue(E,"tagNameCheck")&&Ff(E.tagNameCheck)&&(be.tagNameCheck=E.tagNameCheck),Ue(E,"attributeNameCheck")&&Ff(E.attributeNameCheck)&&(be.attributeNameCheck=E.attributeNameCheck),Ue(E,"allowCustomizedBuiltInElements")&&typeof E.allowCustomizedBuiltInElements=="boolean"&&(be.allowCustomizedBuiltInElements=E.allowCustomizedBuiltInElements),Ce(be),T&&(j=!1),Se&&(fe=!0),On&&(Z=re({},Sp),J=En(null),On.html===!0&&(re(Z,Ep),re(J,_p)),On.svg===!0&&(re(Z,as),re(J,cs),re(J,Vo)),On.svgFilters===!0&&(re(Z,ss),re(J,cs),re(J,Vo)),On.mathMl===!0&&(re(Z,ls),re(J,Mp),re(J,Vo))),se.tagCheck=null,se.attributeCheck=null,Ue(y,"ADD_TAGS")&&(typeof y.ADD_TAGS=="function"?se.tagCheck=y.ADD_TAGS:Sn(y.ADD_TAGS)&&(Z===de&&(Z=Ke(Z)),re(Z,y.ADD_TAGS,_e))),Ue(y,"ADD_ATTR")&&(typeof y.ADD_ATTR=="function"?se.attributeCheck=y.ADD_ATTR:Sn(y.ADD_ATTR)&&(J===xe&&(J=Ke(J)),re(J,y.ADD_ATTR,_e))),Ue(y,"ADD_FORBID_CONTENTS")&&Sn(y.ADD_FORBID_CONTENTS)&&(In===If&&(In=Ke(In)),re(In,y.ADD_FORBID_CONTENTS,_e)),Bs&&(Z["#text"]=!0),oe&&re(Z,["html","head","body"]),Z.table&&(re(Z,["tbody"]),delete he.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw Qt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Qt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const A=S;S=y.TRUSTED_TYPES_POLICY;try{C=Y("")}catch(F){throw S=A,F}}else y.TRUSTED_TYPES_POLICY===null?(S=void 0,C=""):(S===void 0&&(S=De()),S&&typeof C=="string"&&(C=Y("")));ke&&ke(y),Rn=y},zf=re({},[...as,...ss,...G1]),Bf=re({},[...ls,...V1]),hx=function(y,E,A){return E.namespaceURI===yt?y==="svg":E.namespaceURI===si?y==="svg"&&(A==="annotation-xml"||Ws[A]):!!zf[y]},gx=function(y,E,A){return E.namespaceURI===yt?y==="math":E.namespaceURI===li?y==="math"&&js[A]:!!Bf[y]},mx=function(y,E,A){return E.namespaceURI===li&&!js[A]||E.namespaceURI===si&&!Ws[A]?!1:!Bf[y]&&(dx[y]||!zf[y])},bx=function(y){let E=v(y);(!E||!E.tagName)&&(E={namespaceURI:Pn,tagName:"template"});const A=br(y.tagName),F=br(E.tagName);return qs[y.namespaceURI]?y.namespaceURI===li?hx(A,E,F):y.namespaceURI===si?gx(A,E,F):y.namespaceURI===yt?mx(A,E,F):!!(Tr==="application/xhtml+xml"&&qs[y.namespaceURI]):!1},Ft=function(y){mr(t.removed,{element:y});try{v(y).removeChild(y)}catch{if(m(y),!v(y))throw Qt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Hf=function(y,E,A){try{y.removeAttributeNode(E)}catch{try{y.removeAttribute(A)}catch{}}},ci=function(y){di(y);const E=b(y);if(E){const F=[];Jt(E,H=>{mr(F,H)}),Jt(F,H=>{try{m(H)}catch{}})}const A=_(y);if(A)for(let F=A.length-1;F>=0;--F){const H=A[F],K=H&&H.name;typeof K=="string"&&Hf(y,H,K)}},an=function(y,E,A){if(!A)try{A=E.getAttributeNode(y)}catch{A=null}mr(t.removed,{attribute:A||null,from:E});try{A?E.removeAttributeNode(A):E.removeAttribute(y)}catch{try{E.removeAttribute(y)}catch{}}if(y==="is")if(fe||Se)try{Ft(E)}catch{}else try{E.setAttribute(y,"")}catch{}},yx=function(y){const E=_(y);if(E)for(let A=E.length-1;A>=0;--A){const F=E[A],H=F&&F.name;typeof H!="string"||J[_e(H)]||Hf(y,F,H)}},di=function(y){const E=[y];for(;E.length>0;){const A=E.pop();D(A)===Ze.element&&yx(A);const H=b(A);if(H)for(let K=H.length-1;K>=0;--K)E.push(H[K])}},Uf=function(y,E){return B?y==="patchsrc"?!0:y==="for"&&E!=="label"&&E!=="output":!1},vx=function(y){if(!B)return;const E=[y];for(;E.length>0;){const A=E.pop(),F=D(A);if(F===Ze.processingInstruction||F===Ze.comment&&Pe(Cp,A.data)){try{m(A)}catch{}continue}if(F===Ze.element){const K=A,ge=_e(I(A));try{K.hasAttribute&&K.hasAttribute("patchsrc")&&K.removeAttribute("patchsrc"),K.hasAttribute&&K.hasAttribute("for")&&Uf("for",ge)&&K.removeAttribute("for")}catch{}}const H=b(A);if(H)for(let K=H.length-1;K>=0;--K)E.push(H[K])}},qf=function(y){let E=null,A=null;if(Cn)y="<remove></remove>"+y;else{const K=yp(y,/^[\r\n\t ]+/);A=K&&K[0]}Tr==="application/xhtml+xml"&&Pn===yt&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const F=S?Y(y):y;if(Pn===yt)try{E=new d().parseFromString(F,Tr)}catch{}if(!E||!E.documentElement){E=me.createDocument(Pn,"template",null);try{E.documentElement.innerHTML=Us?C:F}catch{}}const H=E.body||E.documentElement;return y&&A&&H.insertBefore(n.createTextNode(A),H.childNodes[0]||null),Pn===yt?Ie.call(E,oe?"html":"body")[0]:oe?E.documentElement:H},Wf=function(y){const E=R?R(y):y.ownerDocument;return Be.call(E||y,y,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ui=function(y){return y=yr(y,tt," "),y=yr(y,O," "),y=yr(y,z," "),y},Vs=function(y){var E;y.normalize();const A=R?R(y):y.ownerDocument,F=Be.call(A||y,y,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let H=F.nextNode();for(;H;)H.data=ui(H.data),H=F.nextNode();const K=(E=y.querySelectorAll)===null||E===void 0?void 0:E.call(y,"template");K&&Jt(K,ge=>{Dn(ge.content)&&Vs(ge.content)})},pi=function(y){const E=N?N(y):null;return typeof E!="string"||_e(E)!=="form"?!1:typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||y.attributes!==_(y)||typeof y.removeAttribute!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function"||y.nodeType!==M(y)||y.childNodes!==b(y)},Dn=function(y){if(!M||typeof y!="object"||y===null)return!1;try{return M(y)===Ze.documentFragment}catch{return!1}},kr=function(y){if(!M||typeof y!="object"||y===null)return!1;try{return typeof M(y)=="number"}catch{return!1}};function vt(L,y,E){L.length!==0&&Jt(L,A=>{A.call(t,y,E,Rn)})}const wx=function(y,E){return!!(B&&y.hasChildNodes()&&!kr(y.firstElementChild)&&Pe(kp,y.textContent)&&Pe(kp,y.innerHTML)||B&&y.namespaceURI===yt&&iy[E]&&(kr(y.firstElementChild)||typeof y.textContent=="string"&&Pe(ay[E],y.textContent))||y.nodeType===Ze.processingInstruction||B&&y.nodeType===Ze.comment&&Pe(Cp,y.data))},fi=function(y,E){if(y instanceof RegExp)return Pe(y,E);if(y instanceof Function){for(var A=arguments.length,F=new Array(A>2?A-2:0),H=2;H<A;H++)F[H-2]=arguments[H];return!!y(E,...F)}return!1},xx=function(y,E,A){if(!he[E]&&Xf(E)&&fi(be.tagNameCheck,E))return!1;if(Bs&&!In[E]){const F=v(y),H=b(y);if(H&&F){const K=H.length;for(let ge=K-1;ge>=0;--ge){const ye=y===A?f(H[ge],!0):H[ge];F.insertBefore(ye,g(y))}}}return Ft(y),!0},jf=function(y,E,A,F){return y.length===0?E:E===A||E===F?Ke(E):E},Gf=function(y,E){return y===E||v(y)!==null?!1:(Hs&&di(y),!0)},Vf=function(y,E){if(vt(ne.beforeSanitizeElements,y,null),Gf(y,E))return!0;if(pi(y))return Ft(y),!0;const A=_e(I(y));if(Z=jf(ne.uponSanitizeElement,Z,de,$e),vt(ne.uponSanitizeElement,y,{tagName:A,allowedTags:Z}),Gf(y,E))return!0;if(wx(y,A))return Ft(y),!0;if(he[A]||!(se.tagCheck instanceof Function&&se.tagCheck(A))&&!Z[A]){const H=xx(y,A,E);return H===!1&&vt(ne.afterSanitizeElements,y,null),H}if(D(y)===Ze.element&&!bx(y)||(A==="noscript"||A==="noembed"||A==="noframes")&&Pe(ry,y.innerHTML))return Ft(y),!0;if(T&&y.nodeType===Ze.text){const H=ui(y.textContent);y.textContent!==H&&(mr(t.removed,{element:y.cloneNode()}),y.textContent=H)}return vt(ne.afterSanitizeElements,y,null),!1},Yf=function(y,E,A){if(Ae[E]||Uf(E,y)||ai&&(E==="id"||E==="name")&&(A in n||A in fx))return!1;const F=J[E]||se.attributeCheck instanceof Function&&se.attributeCheck(E,y);return j&&Pe(q,E)||lt&&Pe(W,E)?!0:F?Df[E]||Pe(pe,yr(A,ee,""))||(E==="src"||E==="xlink:href"||E==="href")&&y!=="script"&&vp(A,"data:")===0&&Pf[y]||Nt&&!Pe(X,yr(A,ee,""))?!0:!A:Xf(y)&&fi(be.tagNameCheck,y)&&fi(be.attributeNameCheck,E,y)||E==="is"&&be.allowCustomizedBuiltInElements&&fi(be.tagNameCheck,A)},Ex=re({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Xf=function(y){return!Ex[br(y)]&&Pe(ce,y)},Sx=function(y,E,A,F){if(S&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!A)switch(p.getAttributeType(y,E)){case"TrustedHTML":return Y(F);case"TrustedScriptURL":return le(F)}return F},_x=function(y,E,A,F){try{A?y.setAttributeNS(A,E,F):y.setAttribute(E,F),pi(y)?Ft(y):bp(t.removed)}catch{an(E,y)}},Kf=function(y){vt(ne.beforeSanitizeAttributes,y,null);const E=y.attributes;if(!E||pi(y))return;J=jf(ne.uponSanitizeAttribute,J,xe,Tt);const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J,forceKeepAttr:void 0};let F=E.length;const H=_e(y.nodeName);for(;F--;){const K=E[F],ge=K.name,ye=K.namespaceURI,We=K.value,je=_e(ge),Xs=We;let He=ge==="value"?Xs:z1(Xs);if(A.attrName=je,A.attrValue=He,A.keepAttr=!0,A.forceKeepAttr=void 0,vt(ne.uponSanitizeAttribute,y,A),He=A.attrValue,Af&&(je==="id"||je==="name")&&vp(He,Of)!==0&&(an(ge,y,K),He=Of+He),B&&Pe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,He)){an(ge,y,K);continue}if(je==="attributename"&&yp(He,"href")){an(ge,y,K);continue}if(!A.forceKeepAttr){if(!A.keepAttr){an(ge,y,K);continue}if(!nt&&Pe(oy,He)){an(ge,y,K);continue}if(T&&(He=ui(He)),!Yf(H,je,He)){an(ge,y,K);continue}He=Sx(H,je,ye,He),He!==Xs&&_x(y,ge,ye,He)}}vt(ne.afterSanitizeAttributes,y,null)},hi=function(y){let E=null;const A=Wf(y);for(vt(ne.beforeSanitizeShadowDOM,y,null);E=A.nextNode();)if(vt(ne.uponSanitizeShadowNode,E,null),Vf(E,y),Kf(E),Dn(E.content)&&hi(E.content),D(E)===Ze.element){const F=w(E);Dn(F)&&(Ys(F),hi(F))}vt(ne.afterSanitizeShadowDOM,y,null)},Ys=function(y){const E=[{node:y,shadow:null}];for(;E.length>0;){const A=E.pop();if(A.shadow){hi(A.shadow);continue}const F=A.node,K=D(F)===Ze.element,ge=b(F);if(ge)for(let ye=ge.length-1;ye>=0;--ye)E.push({node:ge[ye],shadow:null});if(K){const ye=N?N(F):null;if(typeof ye=="string"&&_e(ye)==="template"){const We=F.content;Dn(We)&&E.push({node:We,shadow:null})}}if(K){const ye=w(F);Dn(ye)&&E.push({node:null,shadow:ye},{node:ye,shadow:null})}}};return t.sanitize=function(L){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,A=null,F=null,H=null;if(Us=!L,Us&&(L="<!-->"),typeof L!="string"&&!kr(L)&&(L=W1(L),typeof L!="string"))throw Qt("dirty is not a string, aborting");if(!t.isSupported)return L;Ee?(Z=$e,J=Tt):Gs(y),(ne.uponSanitizeElement.length>0||ne.uponSanitizeAttribute.length>0)&&(Z=Ke(Z)),ne.uponSanitizeAttribute.length>0&&(J=Ke(J)),t.removed=[];const K=Hs&&typeof L!="string"&&kr(L);if(K){vx(L);const We=I(L);if(typeof We=="string"){const je=_e(We);if(!Z[je]||he[je])throw ci(L),Qt("root node is forbidden and cannot be sanitized in-place")}if(pi(L))throw ci(L),Qt("root node is clobbered and cannot be sanitized in-place");try{Ys(L)}catch(je){throw ci(L),je}}else if(kr(L))E=qf("<!---->"),A=E.ownerDocument.importNode(L,!0),A.nodeType===Ze.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?E=A:E.appendChild(A),Ys(A);else{if(!fe&&!T&&!oe&&L.indexOf("<")===-1)return S&&An?Y(L):L;if(E=qf(L),!E)return fe?null:An?C:""}E&&Cn&&Ft(E.firstChild);const ge=K?L:E;try{const We=Wf(ge);for(;F=We.nextNode();)Vf(F,ge),Kf(F),Dn(F.content)&&hi(F.content)}catch(We){throw K&&(ci(L),Jt(t.removed,je=>{je.element&&di(je.element)})),We}if(K)return Jt(t.removed,We=>{We.element&&di(We.element)}),T&&Vs(L),L;if(fe){if(T&&Vs(E),Se)for(H=ue.call(E.ownerDocument);E.firstChild;)H.appendChild(E.firstChild);else H=E;return(J.shadowroot||J.shadowrootmode)&&(H=te.call(r,H,!0)),H}let ye=oe?E.outerHTML:E.innerHTML;return oe&&Z["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&Pe(ty,E.ownerDocument.doctype.name)&&(ye="<!DOCTYPE "+E.ownerDocument.doctype.name+`>
272
+ `+ye),T&&(ye=ui(ye)),S&&An?Y(ye):ye},t.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Gs(L),Ee=!0,$e=Z,Tt=J},t.clearConfig=function(){Rn=null,Ee=!1,$e=null,Tt=null,S=k,C=""},t.isValidAttribute=function(L,y,E){Rn||Gs({});const A=_e(L),F=_e(y);return Yf(A,F,E)},t.addHook=function(L,y){typeof y=="function"&&Ue(ne,L)&&mr(ne[L],y)},t.removeHook=function(L,y){if(Ue(ne,L)){if(y!==void 0){const E=N1(ne[L],y);return E===-1?void 0:F1(ne[L],E,1)[0]}return bp(ne[L])}},t.removeHooks=function(L){Ue(ne,L)&&(ne[L]=[])},t.removeAllHooks=function(){ne=Op()},t}var cy=Ip();const dy={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function uy(e){const t=e.options;return _a(t.formatter,void 0,String(t.testData||t.title||""))||"条码"}function py(e){return h("div",{class:"print-qrcode",dataset:{codeId:e.id,codeKind:"qrcode"}})}function fy(e){const t=e.options;return h("div",{class:"print-barcode",dataset:{codeId:e.id,codeKind:"barcode"}},[h("svg",{preserveAspectRatio:dy[String(t.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function hy(e){const t=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return t.length!==4||t.some(n=>!Number.isFinite(n))?null:{width:t[2],height:t[3]}}function gy(e,t){const n=e.options,r=Fn(n.barWidth),o=wi(n.barQuietZone),i=a=>{Ta(t,uy(e),{format:String(n.barcodeType||"CODE128"),width:r,height:a*r,displayValue:!n.hideTitle,fontSize:(n.fontSize??Ir)*r,margin:0,marginLeft:o*r,marginRight:o*r,marginTop:0,marginBottom:xi*r});const l=hy(t);return l?{widthUnits:l.width,heightUnits:l.height}:null};try{const a=Si({barHeightMm:n.barHeight,boxWidthMm:ln(n.width,n.maxWidth),boxHeightMm:ln(n.height,n.maxHeight),dpi:n.printerDpi,barWidth:n.barWidth,measure:i});t.style.width=a.size?`${a.size.widthMm}mm`:"",t.style.height=a.size?`${a.size.heightMm}mm`:""}catch{t.replaceChildren();return}t.setAttribute("shape-rendering","crispEdges")}function my(e,t){const n=e.options,r=_a(n.formatter,void 0,String(n.testData||n.title||""))||"二维码";t.replaceChildren();try{const o=Za.render(r,"qrcode",{qrCodeLevel:String(n.qrCodeLevel??"M"),qrQuietZone:typeof n.qrQuietZone=="number"?n.qrQuietZone:void 0}),i=document.createElement("img");i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`,i.alt="qrcode",i.style.width="100%",i.style.height="100%",i.style.objectFit=String(n.fit||"contain"),i.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",i.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%",t.appendChild(i)}catch{}}function by(e,t){for(const n of Array.from(e.querySelectorAll("[data-code-kind]"))){const r=n.dataset.codeId,o=t.find(i=>i.id===r);if(o)if(n.dataset.codeKind==="barcode"){const i=n.querySelector("svg");i&&gy(o,i)}else my(o,n)}}const yy={header:"题",data:"数",subtotal:"小",summary:"汇"},vy=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],Yo=3.7795275591,wy=.1,us=e=>JSON.parse(JSON.stringify(e)),Pp=new WeakMap;function xt(e){let t=Pp.get(e);return t||(t={menu:null,menuElId:null,anchor:null,layouts:new Map},Pp.set(e,t)),t}function wr(e,t){return e.templateData.elements.find(n=>n.id===t)??null}function xy(e,t){const n=e.tableSelection;return!n||n.elementId!==t.id?null:e.selectedElement?.id!==t.id?(e.tableSelection=null,null):n}function Rp(e,t,n){const r=wr(e,n.id);if(!r)return null;const o=n.options;return{store:e,fire:t,el:n,real:r,options:o,rows:o.tableRows??[],colWidths:o.tableColWidths??[],isSelected:e.selectedIds.has(n.id),selection:xy(e,n),maxTableWidth:Dp(e)}}function Dp(e){return e.paperSize.width-e.templateData.margins.left-e.templateData.margins.right}function ps(e){return e.options.tableDefaultFontSize??10}function $p(e){return e.options.tableDefaultColor??"#333333"}function Ey(e,t){let n=0;for(let r=0;r<t;r++)n+=e.rows[r].height;return n}function Sy(e,t){return xt(e.store).layouts.get(e.el.id)?.[t]?.top??Ey(e,t)}function _y(e,t){return xt(e.store).layouts.get(e.el.id)?.[t]?.height??e.rows[t]?.height??0}function My(e){const t=e.options.dataSource;if(t&&Array.isArray(ft[t]))return ft[t];for(const n of Object.values(ft))if(Array.isArray(n))return n}function Lp(e){return e.cellType==="barcode"||e.cellType==="qrcode"}function Np(e,t){return Lp(t)?_a(t.formatter,My(e)):t.formatter||""}function Ty(e,t){const n={designMode:!0,showGhostBorder:e.store.showTableGhostBorder};return{fontFamily:la(t.fontFamily??e.options.tableDefaultFontFamily),textAlign:t.align??"left",...t.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:t.valign??"middle",fontSize:(t.fontSize??ps(e))+"pt",fontWeight:t.fontWeight??"normal",color:t.color??$p(e),backgroundColor:t.backgroundColor??"transparent",borderTop:Fr(t.borders?.top,n),borderRight:Fr(t.borders?.right,n),borderBottom:Fr(t.borders?.bottom,n),borderLeft:Fr(t.borders?.left,n),padding:(t.padding??e.options.tableDefaultPadding??1)+"mm",whiteSpace:t.wordWrap??!0?"pre-wrap":"nowrap",overflow:t.wordWrap??!0?"visible":"hidden"}}function ky(e,t,n){const r=e.selection;return[!!r&&t>=r.r1&&t<=r.r2&&n>=r.c1&&n<=r.c2?"cell-selected":"",e.rows[t]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Fp(e){return gi(e)}function Cy(e){return Fp(e)!=="autoHeight"}function Ay(e,t){return t.fontSize??ps(e)}function Xo(e,t,n){return Ln(e.rows,t,n,e.options.tableDefaultPadding??1)}function Oy(e,t,n){return bi(e.colWidths,t,n,e.options.tableDefaultPadding??1)}function Iy(e,t,n){return{maxHeight:Xo(e,n,t)+"mm",overflow:"hidden",...t.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function Py(e,t,n){const r={fitBase:String(Ay(e,t)),fitMin:String($n(t.shrinkMinFontSize)),fitMm:String(Xo(e,n,t))};return Fp(t)==="shrink"&&(r.fit="shrink"),r}function Ry(e){const t=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return t.length!==4||t.some(n=>!Number.isFinite(n))?null:{width:t[2],height:t[3]}}const Dy={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function $y(e,t,n,r){const o=document.createElement("div");o.className="cell-barcode";const i=document.createElementNS(_1,"svg");o.appendChild(i);const a=Np(e,r);if(r.cellType==="barcode"){i.setAttribute("preserveAspectRatio",Dy[r.fit||"contain"]??"xMidYMid meet");const l=Fn(r.barWidth),c=wi(r.barQuietZone),s=u=>{Ta(i,a,{format:r.barcodeType||"CODE128",width:l,height:u*l,displayValue:r.showBarcodeText!==!1,fontSize:(r.barFontSize??Ir)*l,margin:0,marginLeft:c*l,marginRight:c*l,marginTop:0,marginBottom:xi*l});const f=Ry(i);return f?{widthUnits:f.width,heightUnits:f.height}:null};let d=null;try{d=Si({barHeightMm:r.barHeight,boxWidthMm:ln(Oy(e,n,r),r.maxWidth),boxHeightMm:ln(Xo(e,t,r),r.maxHeight),dpi:r.printerDpi,barWidth:r.barWidth,measure:s})}catch{d=null}if(!d){i.style.display="none";const u=document.createElement("span");return u.className="cell-barcode-fallback",u.textContent=a||"条码",o.appendChild(u),o}const p=d.size;return p?(i.style.width=`${p.widthMm}mm`,i.style.height=`${p.heightMm}mm`):(i.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",i.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%"),i.setAttribute("shape-rendering","crispEdges"),o}if(i.style.display="none",!a)return o;try{const l=Za.render(a,"qrcode",{qrCodeLevel:String(r.qrCodeLevel||"M"),qrQuietZone:typeof r.qrQuietZone=="number"?r.qrQuietZone:void 0}),c=document.createElement("img");c.setAttribute("src",`data:image/svg+xml;charset=utf-8,${encodeURIComponent(l)}`),c.setAttribute("alt","qrcode"),c.style.width="100%",c.style.height="100%",c.style.objectFit=r.fit||"contain",r.objectPosition&&(c.style.objectPosition=r.objectPosition),c.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",c.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%",o.appendChild(c)}catch{}return o}function zp(){const e=document.createElement("div");return e.className="image-placeholder",e.textContent="图片",e}function Ly(e){const t=e.formatter||"";return t?t.includes("{")?gn(t,ft):t:""}function Ny(e,t,n){const r=document.createElement("div");r.className="cell-image";const o=el(n.fit,Xo(e,t,n));o!==void 0&&(r.style.height=`${o}mm`);const i=Ly(n);if(!i)return r.appendChild(zp()),r;const a=document.createElement("img");a.setAttribute("src",i),o!==void 0&&(a.style.width="100%",a.style.height="100%"),a.style.objectFit=n.fit||"contain";for(const[l,c]of Object.entries(Mi(n.fit,n.fitScale,n.objectPosition)))a.style[l]=c;return a.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",a.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%",a.addEventListener("error",()=>{a.remove(),r.appendChild(zp())},{once:!0}),r.appendChild(a),r}function Fy(e,t,n,r,o){if(Lp(o))return $y(e,n,r,o);if(o.cellType==="image")return Ny(e,n,o);const i=Np(e,o),a=()=>t.type==="data"?h("span",{class:"data-placeholder",text:i}):i;return Cy(o)?h("div",{class:"cell-fit",style:Iy(e,o,n),dataset:Py(e,o,n)},[a()]):a()}function Ko(e,t,n){const r={elementId:e.el.id,...Al(e.rows,t,n)};e.store.setTableSelection(r),e.fire("table-selection-change",{elementId:e.el.id,selection:r})}function zy(e,t,n,r,o){if(o.button!==0||(e.fire("table-cell-mousedown",{elementId:e.el.id,r:t,c:n,cellId:r,event:o}),!e.isSelected))return;o.stopPropagation();const i=xt(e.store);o.shiftKey&&e.selection?Ko(e,{r:e.selection.r1,c:e.selection.c1},{r:t,c:n}):(i.anchor={r:t,c:n},Ko(e,{r:t,c:n},{r:t,c:n})),document.addEventListener("mouseup",()=>{xt(e.store).anchor=null},{once:!0})}function By(e,t,n){const r=xt(e.store).anchor;r&&Ko(e,r,{r:t,c:n})}function fs(e,t){const n=xt(e);n.menu?.visible&&(n.menu.visible=!1,t("table-menu-close",{elementId:n.menuElId}),e.emit(!1))}function Hy(e,t,n,r){r.preventDefault(),r.stopPropagation(),e.isSelected||e.store.selectOne(e.el.id);const o=e.selection;o&&t>=o.r1&&t<=o.r2&&n>=o.c1&&n<=o.c2||Ko(e,{r:t,c:n},{r:t,c:n});const a=xt(e.store);a.menuElId=e.el.id,a.menu&&(a.menu.x=r.clientX,a.menu.y=r.clientY,a.menu.visible=!0),e.fire("table-cell-contextmenu",{elementId:e.el.id,r:t,c:n,clientX:r.clientX,clientY:r.clientY}),e.store.emit(!1),document.addEventListener("mousedown",()=>fs(e.store,e.fire),{once:!0})}function Bp(e,t,n){const r=e.reduce((o,i)=>o+i,0)+(e[t]??0);return r>n?`插入后表格总宽 ${Math.round(r*10)/10}mm 超过打印范围宽度 ${n}mm,请先缩小列宽`:null}function Uy(e,t){const n=e.real.options.tableRows??[],r=e.real.options.tableColWidths??[],o=t(us(n),us(r));return o?(window.alert(o),!1):(e.store.recordHistory(),t(n,r),e.store.setTableSelection(null),jn(e.real.options),e.store.emit(),!0)}function Et(e,t,n){fs(e.store,e.fire);const r=e.selection;if(!r)return;let o=null;switch(t){case"insert-row-above":o=i=>(Rl(i,r.r1,"above"),null);break;case"insert-row-below":o=i=>(Rl(i,r.r2,"below"),null);break;case"delete-row":o=i=>Wh(i,r.r1);break;case"insert-col-left":o=(i,a)=>{const l=Bp(a,r.c1,e.maxTableWidth);return l||(Dl(i,a,r.c1,"left"),null)};break;case"insert-col-right":o=(i,a)=>{const l=Bp(a,r.c2,e.maxTableWidth);return l||(Dl(i,a,r.c2,"right"),null)};break;case"delete-col":o=(i,a)=>jh(i,a,r.c1);break;case"merge":o=i=>(Il(i,r),null);break;case"split":o=i=>(Pl(i,r),null);break;case"set-row-type":o=i=>n?Ri(i,r.r1,n):"未指定行类型";break}o&&Uy(e,o)&&e.fire(`table-${t}`,{elementId:e.el.id,...n?{type:n}:{}})}function qy(e){const t=e.selection;if(!t)return!1;for(let n=t.r1;n<=t.r2;n++)for(let r=t.c1;r<=t.c2;r++){const o=e.rows[n]?.cells[r];if(o&&!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1))return!0}return!1}function Wy(e){const t=e.selection;if(!t)return;const n=Wn(e.rows,t.r1,t.c1),r=!e.rows[n.r]?.cells[n.c]?.mergeSameValue;for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=e.rows[o]?.cells[i];a&&!a.merged&&(a.mergeSameValue=r)}e.store.updateElement(e.el.id,{tableRows:e.rows}),fs(e.store,e.fire)}function Hp(e){const t=e.selection;if(!t)return"未选择单元格";for(let n=t.r1;n<=t.r2;n++)if(e.rows[n]?.type!=="data")return"仅数据行(明细行)支持按值合并";return null}function Up(e,t){const n=e.selection;return n?n.r1!==n.r2?"行类型仅支持单行设置":Ri(us(e.rows),n.r1,t):"未选择单元格"}function gt(e,t,n={}){return h("div",{class:`menu-item${n.disabled?" disabled":""}${n.active?" active":""}`,title:n.title||"",text:e,onClick:()=>{n.disabled||t()}})}const hs=()=>h("div",{class:"menu-divider"});function jy(e,t,n){const r=xt(e);if(r.menu=n,!n.visible||!r.menuElId)return"";const o=wr(e,r.menuElId);if(!o||o.printElementType.type!=="table")return"";const i=Rp(e,t,o);if(!i)return"";const a=i.selection?Ol(i.rows,i.selection):"未选择单元格",l=i.selection?i.rows[i.selection.r1]?.type??null:null;return h("div",{class:"table-ctx-menu",style:{left:n.x+"px",top:n.y+"px"},onMousedown:c=>c.stopPropagation()},[gt("在上方插入行",()=>Et(i,"insert-row-above")),gt("在下方插入行",()=>Et(i,"insert-row-below")),gt("删除行",()=>Et(i,"delete-row"),{disabled:i.rows.length<=1}),hs(),gt("在左侧插入列",()=>Et(i,"insert-col-left")),gt("在右侧插入列",()=>Et(i,"insert-col-right")),gt("删除列",()=>Et(i,"delete-col"),{disabled:i.colWidths.length<=1}),hs(),gt("合并单元格",()=>Et(i,"merge"),{disabled:!!a,title:a||""}),gt("拆分单元格",()=>Et(i,"split"),{disabled:!qy(i)}),gt("按值合并",()=>Wy(i),{disabled:!!Hp(i),title:Hp(i)||"",active:(()=>{const c=i.selection;if(!c)return!1;const s=Wn(i.rows,c.r1,c.c1);return i.rows[s.r]?.cells[s.c]?.mergeSameValue===!0})()}),hs(),h("div",{class:"menu-group-title",text:"行类型"}),...vy.map(c=>gt(c.label,()=>Et(i,"set-row-type",c.value),{disabled:!!Up(i,c.value),title:Up(i,c.value)||"",active:l===c.value}))])}let en=null;function qp(){en&&(document.removeEventListener("mousemove",gs),document.removeEventListener("mouseup",ms),en.handle.classList.remove("dragging"),en=null)}function Gy(e,t){const n=e.closest(".hiprint-printPaper");return(n&&n.offsetWidth>0?n.getBoundingClientRect().width/n.offsetWidth:0)||(t.scale||100)/100}function Vy(e,t,n){if(n.button!==0)return;const r=n.currentTarget,o=r.closest(".print-table");if(!o)return;qp();const i=e.real.options.tableColWidths??[];en={store:e.store,fire:e.fire,elId:e.real.id,boundary:t,startX:n.clientX,startWidth:i[t-1]??0,scale:Gy(o,e.store),root:o,wrapper:r.closest(".print-element"),handle:r},r.classList.add("dragging"),e.store.recordHistory(),document.addEventListener("mousemove",gs),document.addEventListener("mouseup",ms)}function gs(e){const t=en;if(!t)return;const n=wr(t.store,t.elId),r=n?.options.tableColWidths;if(!n||!r)return;const o=(e.clientX-t.startX)/(t.scale*Yo),i=t.boundary-1;r[i]=Jh(r,i,t.startWidth+o,Dp(t.store)),jn(n.options),r.forEach((a,l)=>{const c=t.root.querySelector(`colgroup col:nth-child(${l+1})`);c&&(c.style.width=`${a}mm`)}),t.root.querySelectorAll(".col-resize-handle").forEach((a,l)=>{a.style.left=`${r.slice(0,l+1).reduce((c,s)=>c+s,0)}mm`}),t.wrapper&&(t.wrapper.style.width=`${n.options.width}mm`,t.wrapper.style.height=`${n.options.height}mm`)}function ms(){document.removeEventListener("mousemove",gs),document.removeEventListener("mouseup",ms);const e=en;if(!e)return;en=null,e.handle.classList.remove("dragging");const t=wr(e.store,e.elId);t&&jn(t.options),e.store.emit(),e.fire("table-col-resize-end",{elementId:e.elId})}function Yy(e,t,n){const r=n.querySelector("table");if(!r)return;const o=r.offsetHeight;if(o<=0)return;const i=wr(e,t);if(!i)return;let a=!1;const l=o/Yo;Math.abs(l-(i.options.height??0))>wy&&(i.options.height=Math.round(l*100)/100,a=!0);const c=r.offsetTop,s=Array.from(r.rows).map(p=>({top:(p.offsetTop-c)/Yo,height:p.offsetHeight/Yo})),d=xt(e);Xy(d.layouts.get(t),s)||(d.layouts.set(t,s),a=!0),a&&e.emit(!1)}function Xy(e,t){return!e||e.length!==t.length?!1:t.every((n,r)=>{const o=e[r];return Math.round(n.top*10)===Math.round(o.top*10)&&Math.round(n.height*10)===Math.round(o.height*10)})}function Ky(e,t){const n=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!n.isConnected)return;const r=n.parentElement;r&&Yy(e,t,r)}),n}function Zy(e){return e.isSelected&&!e.real.options.locked&&e.colWidths.length>=1}function Jy(e){return Array.from({length:e.colWidths.length},(t,n)=>n+1)}function Qy(e,t){return e.colWidths.slice(0,t).reduce((n,r)=>n+r,0)}function ev(e,t,n){const r=Rp(t,n,e);if(!r)return h("div",{class:"print-table"});const o=[h("table",{style:{fontSize:`${ps(r)}pt`,color:$p(r)}},[h("colgroup",{},r.colWidths.map(i=>h("col",{style:{width:i+"mm"}}))),h("tbody",{},r.rows.map((i,a)=>h("tr",{style:{height:i.height+"mm"}},i.cells.map((l,c)=>l.merged?"":h("td",{rowspan:l.rowspan||1,colspan:l.colspan||1,class:ky(r,a,c),style:Ty(r,l),onMousedown:s=>zy(r,a,c,l.id,s),onMouseenter:()=>By(r,a,c),onContextmenu:s=>Hy(r,a,c,s)},[Fy(r,i,a,c,l)])).filter(Boolean))))])];return Zy(r)&&o.push(h("div",{class:"col-resize-layer"},Jy(r).map(i=>h("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${i}`,style:{left:Qy(r,i)+"mm"},onMousedown:a=>{a.stopPropagation(),a.preventDefault(),Vy(r,i,a)}})))),r.isSelected&&o.push(h("div",{class:"row-badges"},r.rows.map((i,a)=>h("span",{class:"row-badge",style:{top:Sy(r,a)+"mm",height:_y(r,a)+"mm"},text:yy[i.type]})))),o.push(Ky(t,e.id)),h("div",{class:"print-table design-mode",dataset:{tableId:e.id},onContextmenu:i=>i.preventDefault()},o)}const tv=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function bs(e){return Array.isArray(e)&&e.length>0?e:[]}function nv(e,t){const n=Or(e,t)??(t?Object.keys(t).find(o=>Array.isArray(t[o])):void 0);if(n)return bs(t?.[n]);const r=Or(e,ft);return r?bs(ft[r]):[]}function rv(e,t){const n=e.options,r=typeof n.formatter=="string"?n.formatter:"",o=bs(t)[0],i=nv(r,o);if(i.length===0)return[...tv];if(!r)return i.map(c=>String(c?.name??JSON.stringify(c)));const a=o??{},l=Or(r,a)??Object.keys(a).find(c=>Array.isArray(a[c]));return i.map(c=>{try{return gn(r,{...a,...c,...l?{[l]:c}:{}})}catch{return r}})}const ov=3.7795275591,iv=.1;function av(e,t){return e.templateData.elements.find(n=>n.id===t)??null}function sv(e){const t=e.parentElement;if(!t?.classList.contains("print-element"))return 0;const n=getComputedStyle(t);return(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0)}function lv(e,t,n){const r=n.offsetHeight+sv(n);if(r<=0)return;const o=av(e,t);if(!o)return;const i=r/ov;Math.abs(i-(o.options.height??0))>iv&&(o.options.height=Math.round(i*100)/100,e.emit(!1))}function cv(e,t){const n=document.createComment("pd-flowlist-measure");return requestAnimationFrame(()=>{if(!n.isConnected)return;const r=n.parentElement;r&&lv(e,t,r)}),n}function dv(e,t,n){const r=e.options,o=Qe(r.flowColumns),i=rt(r.flowGapX),a=Ct(r.flowRowHeight),l=Bt(r.flowLayoutMode)==="dynamic",c=sn(r),s={display:"grid",gridTemplateColumns:`repeat(${o},minmax(0,1fr))`,columnGap:`${i}mm`,gridAutoRows:`minmax(${a}mm,auto)`,width:"100%",...l?{padding:`${c.top}mm ${c.right}mm ${c.bottom}mm ${c.left}mm`,height:"auto",overflow:"visible"}:{height:"100%",overflow:"hidden"},fontSize:`${r.fontSize||12}pt`,fontWeight:r.fontWeight||"normal",color:r.color||"#333",boxSizing:"border-box"};r.fontFamily&&(s.fontFamily=String(r.fontFamily)),r.backgroundColor&&(s.backgroundColor=String(r.backgroundColor));const d=rv(e,t).map(p=>h("div",{class:"print-flow-cell",text:p}));return l&&n&&d.push(cv(n,e.id)),h("div",{class:"print-flowlist",style:s},d)}const Wp={top:"flex-start",middle:"center",bottom:"flex-end"},uv={left:"flex-start",center:"center",right:"flex-end"};function pv(e,t){const n=e.options,r=Rr(e.printElementType.type,n),o={};if(r?.all&&(o.border=`${r.all.borderWidth} ${r.all.borderStyle} ${r.all.borderColor}`),r)for(const i of zn){const a=r.edges[i];a&&(o[`border${i.charAt(0).toUpperCase()}${i.slice(1)}`]=`${a.borderWidth} ${a.borderStyle} ${a.borderColor}`)}return{position:"absolute",left:`${n.left}mm`,top:`${n.top}mm`,width:`${n.width}mm`,height:`${n.height}mm`,zIndex:String(n.zIndex||"auto"),...o,...fv(e,t)}}function fv(e,t){if(t?.has(e.id))return{};const n=Ti(e.printElementType.type,e.options);return n===void 0?{}:{rotate:`${n}deg`}}function jp(e){const t=e.options,n=e.printElementType.type==="longText",r=Ar(e.printElementType.type,t),o=t.fontSize||12,i=r==="autoHeight",a={fontSize:`${o}pt`,fontWeight:t.fontWeight||"normal",fontFamily:la(t.fontFamily),color:t.color||"#333",backgroundColor:t.backgroundColor||"transparent",textAlign:t.textAlign||"left",...t.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:t.lineHeight?`${t.lineHeight}pt`:n?"1.5":"normal",letterSpacing:t.letterSpacing?`${t.letterSpacing}pt`:"normal",width:"100%",height:i?"auto":"100%",boxSizing:"border-box",overflow:i?"visible":"hidden",...n?{wordBreak:"break-all",textIndent:t.longTextIndent?`${t.longTextIndent}em`:"0"}:{textDecoration:t.textDecoration||"none",padding:`${t.contentPaddingTop||0}pt ${t.contentPaddingRight||0}pt ${t.contentPaddingBottom||0}pt ${t.contentPaddingLeft||0}pt`}};Qs(t)&&(a.whiteSpace="nowrap",a.textOverflow="ellipsis");const l=Js(t);return l&&(a.whiteSpace=l),t.verticalAlign&&(a.display="flex",t.textAlign==="justify"?(a.flexDirection="column",a.justifyContent=Wp[t.verticalAlign]??"flex-start"):(a.alignItems=Wp[t.verticalAlign]??"flex-start",a.justifyContent=uv[t.textAlign||"left"]??"flex-start")),{style:a,fit:r}}function hv(e){const t=e.options,n=`${t.borderWidth||.75}pt`,r=t.borderStyle||"solid",o=t.borderColor||"#333";return e.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${n} ${r} ${o}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${n} ${r} ${o}`,boxSizing:"border-box"}}function gv(e){const t=e.options;return{width:"100%",height:"100%",borderWidth:`${t.borderWidth||1}pt`,borderStyle:t.borderStyle||"solid",borderColor:t.borderColor||"#333",backgroundColor:t.backgroundColor||"transparent",borderRadius:e.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function mv(e){const t=e.options;return{objectFit:t.fit||"contain",...Mi(t.fit,t.fitScale,t.objectPosition),maxWidth:t.maxWidth?`${t.maxWidth}mm`:"100%",maxHeight:t.maxHeight?`${t.maxHeight}mm`:"100%"}}function Gp(e){const t=e.options,n={fitBase:String(t.fontSize||12),fitMin:String($n(t.shrinkMinFontSize))};return Ar(e.printElementType.type,t)==="shrink"&&(n.fit="shrink"),n}function bv(e,t,n){const r=e.printElementType.type,o=e.options;switch(r){case"text":{const{style:i}=jp(e);return h("div",{class:"print-text",style:i,dataset:Gp(e),text:String(o.testData||o.formatter||"")||"文本"})}case"longText":{const{style:i}=jp(e);return h("div",{class:"print-longtext",style:i,dataset:Gp(e),text:String(o.formatter||"")||"长文本内容"})}case"hline":case"vline":return h("div",{class:"print-line",style:hv(e)});case"rect":case"oval":return h("div",{class:"print-shape",style:gv(e)});case"image":{const i=String(o.src??""),a=i.includes("{")?gn(i,ft):i;return h("div",{class:"print-image"},[a?h("img",{src:a,style:mv(e)}):h("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return py(e);case"barcode":return fy(e);case"html":{const i=String(o.formatter??""),a=i?cy.sanitize(gn(i,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return h("div",{class:"print-html",html:a})}case"pageNumber":return h("div",{class:"page-number-element",style:{fontSize:`${o.fontSize||12}pt`,fontWeight:o.fontWeight||"normal",fontFamily:la(o.fontFamily),color:o.color||"#333",textAlign:o.textAlign||"left",...o.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:o.title||"{pageIndex}/{totalPages}"});case"table":return n?ev(e,n.store,n.fire):h("div",{class:"print-table"});case"flowList":return dv(e,void 0,n?.store);default:return h("div",{text:r})}}function Vp(e){return`x:${Math.round(e.left)} y:${Math.round(e.top)} ${Math.round(e.width)}×${Math.round(e.height)}mm`}function yv(e,t,n){const r=e.store,o=r.selectedIds.has(t.id),i=r.previewIds.has(t.id),a=t.options,l=t.zone||"content",c=[bv(t,!0,{store:r,fire:e.fire})];return r.draggingIds.has(t.id)&&c.push(h("div",{class:"drag-preview"})),o&&(c.push(h("div",{class:"resize-handles"},Y0.map(s=>h("div",{class:`resize-handle handle-${s}`,dataset:{point:s,elId:t.id},onMousedown:d=>e.fire("resize-start",{event:d,id:t.id,point:s})})))),c.push(h("div",{class:"selected-indicator"},[h("div",{class:"position-label",text:Vp(a)})]))),h("div",{class:["print-element",`type-${t.printElementType.type}`,`zone-${l}`,o?"selected":"",i?"previewed":"",r.draggingIds.has(t.id)?"drag-ghost":"","design-mode",a.locked?"locked":"",a.visible===!1?"hidden":""].filter(Boolean).join(" "),style:pv(t,n),dataset:{elId:t.id},onMousedown:s=>e.fire("element-mousedown",{event:s,id:t.id}),onContextmenu:s=>{s.preventDefault(),s.stopPropagation(),e.fire("contextmenu",{event:s,id:t.id})}},c)}function ys(e,t){const n=e.margins,r=e.header?.height??10,o=e.footer?.height??10,i=t.width-n.left-n.right;return{header:{left:n.left,top:n.top,width:i,height:r},content:{left:n.left,top:n.top+r,width:i,height:t.height-n.top-n.bottom-r-o},footer:{left:n.left,top:t.height-n.bottom-o,width:i,height:o}}}const vv='<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>';function Yp(e,t){return e.type==="vertical"?{left:`${e.position}mm`,top:"0",height:`${t.height}mm`,borderLeftColor:e.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${e.position}mm`,left:"0",width:`${t.width}mm`,borderTopColor:e.color||"var(--pd-accent-secondary, #f56c6c)"}}function wv(e,t){const n=Pc(e.watermark,[],t);return n?h("div",{class:"watermark-layer",style:{opacity:String(n.opacity)}},n.tiles.map(r=>h("svg",{class:"watermark-tile",width:`${r.widthMm}mm`,height:`${r.heightMm}mm`,viewBox:`0 0 ${n.tileWidthPx} ${n.tileHeightPx}`,style:{left:`${r.leftMm}mm`,top:`${r.topMm}mm`}},[h("text",{x:String(n.tileWidthPx/2),y:String(n.tileHeightPx/2),"font-size":String(n.fontSizePx),fill:n.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${n.rotate},${n.tileWidthPx/2},${n.tileHeightPx/2})`,text:n.text})]))):""}function vs(e,t,n,r,o,i){const a=e.store,l=[];n!=="content"&&l.push(h("span",{class:"zone-label",text:n==="header"?"页眉":"页脚"}));const c=n==="content"?wl(o):void 0;if(l.push(...o.map(s=>yv(e,s,c))),n!=="content"){const s=n==="header"?"bottom":"top";l.push(h("div",{class:`zone-resize-handle handle-${s}`,dataset:{zone:n},onMousedown:d=>e.fire("zone-resize",{event:d,zone:n})},[t.zoneResizing===n?h("div",{class:"zone-height-tip",text:`${(n==="header"?a.templateData.header.height:a.templateData.footer.height).toFixed(1)}mm`}):""]))}return h("div",{class:`zone-layer zone-${n} design-mode`,style:{position:"absolute",left:`${r.left}mm`,top:`${r.top}mm`,width:`${r.width}mm`,height:`${r.height}mm`},dataset:{zone:n,paperWidth:String(i.width),paperHeight:String(i.height)}},l.filter(Boolean))}function xv(e){const t=e.currentTarget,n=e.dataTransfer?.types??[],r=n.includes("fieldkey"),o=n.includes("elementtype");if(!r&&!o){t.querySelector(".drop-hint")?.remove();return}r&&(e.ctrlKey||e.metaKey)&&(t.dataset.dropLabelIntent="1");const i=o?"+ 元素":t.dataset.dropLabelIntent?"+ 静态文本":"+ 取值字段";let a=t.querySelector(".drop-hint");a||(a=document.createElement("div"),a.className="drop-hint",t.appendChild(a)),a.textContent=i,a.style.left=`${e.clientX+14}px`,a.style.top=`${e.clientY+18}px`}function Xp(e){e&&(e.querySelector(".drop-hint")?.remove(),delete e.dataset.dropLabelIntent)}function Ev(e,t){const n=e.store,r=n.templateData,o=et(r),i=(n.scale||100)/100,a=ys(r,o),l=p=>n.elements.filter(u=>(u.zone||"content")===p),c=h("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${r.margins.top}mm ${r.margins.right}mm ${r.margins.bottom}mm ${r.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${o.height}mm`}},[n.showGrid?h("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(vv)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...r.watermark&&Object.keys(r.watermark).length?[wv(r,o)]:[],vs(e,t,"header",a.header,l("header"),o),vs(e,t,"content",a.content,l("content"),o),vs(e,t,"footer",a.footer,l("footer"),o),...n.adsorbGuides.map(p=>h("div",{class:`adsorb-guide guide-${p.type}`,style:Yp(p,o)})),...(r.guides??[]).map(p=>h("div",{class:`manual-guide guide-${p.type}`,style:{...Yp(p,o),"--guide-hit":`${8/i}px`},dataset:{guideId:String(p.id??"")},onMousedown:u=>e.fire("guide-mousedown",{event:u,id:p.id}),onDblclick:u=>{u.preventDefault(),e.fire("guide-remove",p.id)}}))].filter(Boolean)),s=h("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${o.width}mm`,minHeight:`${o.height}mm`,background:r.pageBackground||"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))",overflow:"hidden",position:"relative",transform:`scale(${i})`,transformOrigin:"0 0"}},[...r.designBackground?.src?[h("div",{class:"design-background",style:{width:`${o.width}mm`,height:`${o.height}mm`,left:"0",top:"0",transform:r.designBackground.rotation?`rotate(${r.designBackground.rotation}deg)`:""}},[h("img",{src:r.designBackground.src,draggable:!1,alt:""})])]:[],c]),d=[h("div",{class:"canvas-scroll"},[h("div",{class:"paper-wrapper",style:{width:`${Jr(o.width)*i}px`,height:`${Jr(o.height)*i}px`,position:"relative"}},[s])])];if(n.showRuler&&d.push(h("div",{class:"ruler-overlay",style:{transform:`translate(${t.scrollX}px, ${t.scrollY}px)`}},[h("div",{class:"ruler-corner"}),h("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${t.geom.viewW}px`,height:"20px"},onMousedown:p=>e.fire("ruler-mousedown",{event:p,orientation:"horizontal"})}),h("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${t.geom.viewH}px`},onMousedown:p=>e.fire("ruler-mousedown",{event:p,orientation:"vertical"})})])),t.guidePreview&&d.push(h("div",{class:`ruler-guide-preview guide-${t.guidePreview.type}`,style:t.guidePreview.type==="vertical"?{left:`${t.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${t.guidePreview.position}px`,left:"0",width:"100%"}})),t.marquee.visible&&d.push(h("div",{class:"marquee-selection",style:{left:`${t.marquee.x}px`,top:`${t.marquee.y}px`,width:`${t.marquee.w}px`,height:`${t.marquee.h}px`}})),t.contextMenu.visible){const p=t.contextMenu;d.push(h("div",{class:"context-menu",style:{left:`${t.contextMenu.x+t.contextMenu.flipX}px`,top:`${t.contextMenu.y+t.contextMenu.flipY}px`}},t.contextMenu.targetId?[st(e,p,"复制","copy"),st(e,p,"剪切","cut"),st(e,p,"粘贴","paste",!n.hasClipboard),st(e,p,"删除","delete"),h("div",{class:"context-menu-sep"}),st(e,p,"置顶","move-layer",!1,"top"),st(e,p,"上移","move-layer",!1,"up"),st(e,p,"下移","move-layer",!1,"down"),st(e,p,"置底","move-layer",!1,"bottom")]:[st(e,p,"粘贴","paste-at",!n.hasClipboard),st(e,p,"全选","select-all"),st(e,p,"取消选择","clear-selection")]))}return h("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:p=>{const u=p;u.preventDefault(),u.dataTransfer&&(u.dataTransfer.dropEffect="copy"),xv(u)},onDragleave:p=>{const u=p.currentTarget,f=p.relatedTarget;(!f||!u.contains(f))&&u.querySelector(".drop-hint")?.remove()},onDrop:p=>{const u=p,f=p.currentTarget,m=f.dataset.dropLabelIntent==="1";Xp(f),m&&(u.labelIntent=!0),e.fire("drop",u)},onMousedown:p=>e.fire("canvas-mousedown",p),onMousemove:p=>e.fire("canvas-mousemove",p),onMouseleave:()=>e.fire("canvas-mouseleave"),onWheel:p=>e.fire("wheel",p),onScroll:p=>e.fire("scroll",p),onContextmenu:p=>{p.preventDefault(),e.fire("canvas-contextmenu",p)}},d.filter(Boolean))}function st(e,t,n,r,o=!1,i){return h("div",{class:`context-menu-item${o?" disabled":""}`,text:n,onClick:()=>{t.visible=!1,o||e.fire(r,i),e.repaint()}})}const Sv={AlignCenterHorizontal:'<path d="M2 12h20" /><path d="M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4" /><path d="M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4" /><path d="M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1" /><path d="M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1" />',AlignCenterVertical:'<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />',AlignEndHorizontal:'<rect width="6" height="16" x="4" y="2" rx="2" /><rect width="6" height="9" x="14" y="9" rx="2" /><path d="M22 22H2" />',AlignEndVertical:'<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />',AlignHorizontalSpaceBetween:'<rect width="6" height="14" x="3" y="5" rx="2" /><rect width="6" height="10" x="15" y="7" rx="2" /><path d="M3 2v20" /><path d="M21 2v20" />',AlignStartHorizontal:'<rect width="6" height="16" x="4" y="6" rx="2" /><rect width="6" height="9" x="14" y="6" rx="2" /><path d="M22 2H2" />',AlignStartVertical:'<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />',AlignVerticalSpaceBetween:'<rect width="14" height="6" x="5" y="15" rx="2" /><rect width="10" height="6" x="7" y="3" rx="2" /><path d="M2 21h20" /><path d="M2 3h20" />',ArrowDown:'<path d="M12 5v14" /><path d="m19 12-7 7-7-7" />',ArrowDownToLine:'<path d="M12 17V3" /><path d="m6 11 6 6 6-6" /><path d="M19 21H5" />',ArrowUp:'<path d="m5 12 7-7 7 7" /><path d="M12 19V5" />',ArrowUpToLine:'<path d="M5 3h14" /><path d="m18 13-6-6-6 6" /><path d="M12 7v14" />',Bold:'<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" />',Check:'<path d="M20 6 9 17l-5-5" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',ClipboardPaste:'<path d="M11 14h10" /><path d="M16 4h2a2 2 0 0 1 2 2v1.344" /><path d="m17 18 4-4-4-4" /><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /><rect x="8" y="2" width="8" height="4" rx="1" />',Copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',Ellipsis:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',Eye:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />',Grid3x3:'<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /><path d="M9 3v18" /><path d="M15 3v18" />',Group:'<path d="M3 7V5c0-1.1.9-2 2-2h2" /><path d="M17 3h2c1.1 0 2 .9 2 2v2" /><path d="M21 17v2c0 1.1-.9 2-2 2h-2" /><path d="M7 21H5c-1.1 0-2-.9-2-2v-2" /><rect width="7" height="5" x="7" y="7" rx="1" /><rect width="7" height="5" x="10" y="12" rx="1" />',Layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',Maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />',PaintBucket:'<path d="M11 7 6 2" /><path d="M18.992 12H2.041" /><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" /><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" />',Paintbrush:'<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',Strikethrough:'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />',TextAlignCenter:'<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />',TextAlignEnd:'<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />',TextAlignJustify:'<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />',TextAlignStart:'<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />',Trash2:'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',Underline:'<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />',Undo2:'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />',Ungroup:'<rect width="8" height="6" x="5" y="4" rx="1" /><rect width="8" height="6" x="11" y="14" rx="1" />',ZoomIn:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="11" x2="11" y1="8" y2="14" /><line x1="8" x2="14" y1="11" y2="11" />',ZoomOut:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="8" x2="14" y1="11" y2="11" />'};function ze(e,t=15,n){const r=Sv[e];return r?`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}"${n?` class="${n}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`:""}let tn=null;function ws(e){const t=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return null;const n=t[1],r=n.length===3?n.split("").map(o=>o+o).join(""):n;return{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16)}}function xs(e){const t=ws(e);return t?Kp(t):"#000000"}function Kp({r:e,g:t,b:n}){return`#${[e,t,n].map(r=>Math.round(xr(r/255)*255).toString(16).padStart(2,"0")).join("")}`}function _v(e,t,n){const r=e/255,o=t/255,i=n/255,a=Math.max(r,o,i),l=Math.min(r,o,i),c=a-l;let s=0;return c!==0&&(a===r?s=(o-i)/c%6:a===o?s=(i-r)/c+2:s=(r-o)/c+4,s*=60,s<0&&(s+=360)),{h:s,s:a===0?0:c/a,v:a}}function Mv(e,t,n){const r=n*t,o=(e%360+360)%360/60,i=r*(1-Math.abs(o%2-1)),[a,l,c]=o<1?[r,i,0]:o<2?[i,r,0]:o<3?[0,r,i]:o<4?[0,i,r]:o<5?[i,0,r]:[r,0,i],s=n-r;return{r:(a+s)*255,g:(l+s)*255,b:(c+s)*255}}function Tv(e){return((Number.isFinite(e)?e:0)%360+360)%360}function xr(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:0))}function kv(e){const t=e.title??"颜色选择";return h("button",{type:"button",class:`preset-color-trigger${e.triggerClass?` ${e.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:t,onClick:n=>{const r=n.currentTarget??n.target,o=r.getRootNode();if(!!tn&&tn.root===o&&tn.title===t&&tn.trigger===r){Er();return}Er(),Cv(r,e)}},[h("span",{class:"preset-color-swatch",style:e.value?{background:e.value}:{background:"transparent"}})])}function Er(){const e=tn;e&&(tn=null,e.teardowns.forEach(t=>t()),e.trigger.setAttribute("aria-expanded","false"),e.panel.remove())}function Cv(e,t){const n=e.getRootNode(),r=n instanceof ShadowRoot?n:document.body,o={root:n,title:t.title??"颜色选择",trigger:e,panel:null,clearable:t.clearable!==!1,onChange:t.onChange,model:t.value||void 0,hue:0,saturation:0,value_:0,hexText:"",dragging:!1,current:null,hex:null,area:null,handle:null,hueRange:null,clearBtn:null,items:[],teardowns:[]};t.value&&Ss(o,t.value)?o.hexText=xs(t.value).toUpperCase():o.hexText=t.value?String(t.value):"",o.panel=Fe(Pv(o),r),o.current=o.panel.querySelector(".picker-current"),o.hex=o.panel.querySelector(".picker-hex"),o.area=o.panel.querySelector(".picker-area"),o.handle=o.panel.querySelector(".picker-handle"),o.hueRange=o.panel.querySelector(".picker-hue"),o.clearBtn=o.panel.querySelector(".picker-clear"),o.items=Array.from(o.panel.querySelectorAll(".preset-color-item")).map((i,a)=>({el:i,color:Zl[a]})),Zo(o),Av(o),Ov(o),tn=o,e.setAttribute("aria-expanded","true")}function Av(e){const t=e.trigger.getBoundingClientRect(),n=190,r=e.panel.offsetHeight||216,o=8,i=Math.max(o,Math.min(t.left,window.innerWidth-n-o)),a=t.bottom+6,l=a+r>window.innerHeight-o?Math.max(o,t.top-r-6):a;e.panel.style.left=`${i}px`,e.panel.style.top=`${l}px`}function Ov(e){const t=o=>{const i=Iv(o);i.includes(e.trigger)||i.includes(e.panel)||Er()},n=o=>{o.key==="Escape"&&Er()},r=()=>Er();document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",n),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),e.root.addEventListener("scroll",r,!0),e.teardowns.push(()=>document.removeEventListener("pointerdown",t,!0),()=>document.removeEventListener("keydown",n),()=>window.removeEventListener("scroll",r,!0),()=>window.removeEventListener("resize",r),()=>e.root.removeEventListener("scroll",r,!0))}function Iv(e){const t=typeof e.composedPath=="function"?e.composedPath():[];return t.length?t:[e.target]}function Pv(e){return h("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:t=>t.stopPropagation()},[h("div",{class:"picker-preview"},[h("span",{class:"picker-current"}),h("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:t=>Dv(e,t.target.value)})]),h("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:t=>$v(e,t),onKeydown:t=>Lv(e,t)},[h("span",{class:"picker-handle"})]),h("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:t=>Nv(e,Number(t.target.value)),onChange:()=>_s(e)}),h("div",{class:"picker-heading"},[h("span",{text:"常用颜色"}),e.clearable?h("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>Jo(e,void 0)},[h("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[h("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),h("div",{class:"preset-color-grid"},Zl.map(t=>h("button",{type:"button",class:"preset-color-item",style:{background:t},title:t,"aria-label":t,onClick:()=>Rv(e,t)})))])}function Es(e){return Kp(Mv(e.hue,e.saturation,e.value_))}function Zo(e){const t=Es(e);e.hex.value!==e.hexText&&(e.hex.value=e.hexText),e.current.className=e.model?"picker-current":"picker-current is-empty",e.model?e.current.style.background=t:e.current.style.removeProperty("background"),e.area.style.setProperty("--picker-hue",`${Math.round(e.hue)}deg`),e.handle.style.left=`${e.saturation*100}%`,e.handle.style.top=`${(1-e.value_)*100}%`,e.handle.style.background=t;const n=String(Math.round(e.hue));e.hueRange.value!==n&&(e.hueRange.value=n),e.clearBtn&&(e.clearBtn.disabled=!e.model);for(const r of e.items)r.el.className=e.model&&r.color.toLowerCase()===e.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function Ss(e,t){const n=ws(t);if(!n)return!1;const r=_v(n.r,n.g,n.b);return e.hue=r.h,e.saturation=r.s,e.value_=r.v,e.hexText=xs(t).toUpperCase(),!0}function _n(e,t,n,r){e.hue=Tv(t),e.saturation=xr(n),e.value_=xr(r),e.hexText=Es(e).toUpperCase(),Zo(e)}function _s(e){const t=Es(e);e.model=t,Zo(e),e.onChange(t)}function Jo(e,t){e.model=t,t||(e.hexText=""),Zo(e),e.onChange(t)}function Rv(e,t){Ss(e,t),Jo(e,t)}function Dv(e,t){const n=t.trim();if(!n){e.clearable&&Jo(e,void 0);return}ws(n)&&(Ss(e,n),Jo(e,xs(n)))}function $v(e,t){e.dragging=!0,Zp(e,t);const n=o=>{e.dragging&&Zp(e,o)},r=()=>{e.dragging&&(e.dragging=!1,document.removeEventListener("pointermove",n),document.removeEventListener("pointerup",r),document.removeEventListener("pointercancel",r),_s(e))};document.addEventListener("pointermove",n),document.addEventListener("pointerup",r),document.addEventListener("pointercancel",r)}function Zp(e,t){const n=e.area.getBoundingClientRect();if(!n.width||!n.height)return;const r=xr((t.clientX-n.left)/n.width),o=xr(1-(t.clientY-n.top)/n.height);_n(e,e.hue,r,o)}function Lv(e,t){const n=t.shiftKey?.1:.02;let r=!0;t.key==="ArrowLeft"?_n(e,e.hue,e.saturation-n,e.value_):t.key==="ArrowRight"?_n(e,e.hue,e.saturation+n,e.value_):t.key==="ArrowUp"?_n(e,e.hue,e.saturation,e.value_+n):t.key==="ArrowDown"?_n(e,e.hue,e.saturation,e.value_-n):r=!1,r&&(t.preventDefault(),_s(e))}function Nv(e,t){_n(e,t,e.saturation,e.value_)}function we(e,t,n,r){return h("button",{class:`tb-btn tb-icon${r.on?" on":""}${r.danger?" danger":""}`,type:"button",disabled:!!r.disabled,dataset:{tip:r.tip,...r.test?{test:r.test}:{}},onClick:()=>e.fire(n,r.arg),html:ze(t)})}function Qo(e,t,n,r){const o=e.state.openDd===t,i=()=>{e.state.openDd=o?null:t,e.repaint()};return h("div",{class:"tb-dd"},[h("button",{type:"button",class:`tb-dd-trigger${o?" on":""}`,disabled:!!n.disabled,dataset:{test:n.testId??t,tip:n.tip},onClick:i,html:`${n.icon?ze(n.icon):""}${n.text?`<span class="${n.textClass??"tb-btn-text"}">${n.text}</span>`:""}${ze("ChevronDown",12,`tb-dd-arrow${o?" up":""}`)}`}),o?h("div",{class:`tb-dd-panel${n.panelClass?` ${n.panelClass}`:""}`},r):""].filter(Boolean))}function Q(e){const t=e.step??1,n=String(t),r=n.indexOf("."),o=r===-1?0:n.length-r-1,i=p=>Number.isFinite(p)?Number(p.toFixed(o)):0,a=p=>{let u=i(p);return e.min!==void 0&&u<e.min&&(u=e.min),e.max!==void 0&&u>e.max&&(u=e.max),u},l=e.value===void 0||e.value===null||!Number.isFinite(e.value)?void 0:i(e.value),c=l??e.min??0,s=p=>{p!==l&&e.onCommit(p)},d=h("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:e.min,max:e.max,step:t,placeholder:e.placeholder,disabled:!!e.disabled,onChange:p=>{const u=p.target,f=(u.value??"").trim();if(f===""){l!==void 0&&(u.value=String(l));return}const m=Number(f);if(!Number.isFinite(m)){u.value=l===void 0?"":String(l);return}const g=a(m);u.value=String(g),s(g)}});return h("div",{class:"pd-stepper"},[h("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!e.disabled||c<=(e.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>s(a(c-t))}),d,h("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!e.disabled||c>=(e.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>s(a(c+t))})])}function ie(e,t,n,r){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),r??""]),t,n?h("p",{class:"pd-hint",text:n}):""].filter(Boolean))}const Ms=e=>h("button",{class:"pd-help",type:"button","data-tip":e,"aria-label":"字段说明"});function Oe(e,t,n,r){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[e,Ms(n)]),r??""]),t])}function nn(e){const t=e.base?.[e.propKey],n=e.target?.[e.propKey]!==t,r=e.force===!0||n,o=e.tipOverride??(e.tipValue===void 0?"恢复默认值":`恢复默认值(${e.tipValue}${e.tipUnit?" "+e.tipUnit:""})`),i=e.force?`${o}(应用到全部选中格)`:o;return h("button",{type:"button",class:`pd-reset-btn${n&&!e.force?" is-dirty":""}`,"data-tip":i,"aria-label":i,html:ze("RotateCcw",13),onClick:()=>{r&&(e.write?e.write(t):e.target[e.propKey]=t,e.onReset?.())}})}const mt=e=>h("h3",{class:"pd-divider",text:e});function Je(e,t,n="颜色选择",r){return kv({value:e,title:n,triggerClass:r,onChange:o=>t(o)})}function $t(e,t,n,r,o=!1){return h("div",{class:`pd-radio-group${o?" pd-radio-group--2col":""}`,role:"radiogroup"},t.map(i=>h("label",{class:"pd-radio"},[h("input",{type:"radio",name:e,value:i.value,checked:n===i.value,onChange:()=>r(i.value)}),h("span",{text:i.label})])))}function Jp(e,t,n,r={}){const o=document.createElement("select");o.className=r.className??"pd-select",r.width&&(o.style.width=r.width);for(const i of t){const a=document.createElement("option");a.value=i.value,a.textContent=i.label,i.disabled&&(a.disabled=!0),o.appendChild(a)}return o.value=e,t.some(i=>i.value===e)||(o.selectedIndex=-1),o.addEventListener("change",()=>n(o.value)),o}function Fv(e){const t=window.innerHeight;for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement){const r=getComputedStyle(n).overflowY;if(r==="auto"||r==="scroll"||r==="hidden"||r==="clip"){const o=n.getBoundingClientRect();return{top:Math.max(0,o.top),bottom:Math.min(t,o.bottom)}}}return{top:0,bottom:t}}function ei(e){const t=fm(e.fonts),n=e.placeholder??"默认",r=`font-select-list-${e.id}`,o=I=>{const S=I?.trim();return S?vc(t,S)?.label??S:""},i=I=>{const S=Jn(I);return t.find(k=>k.label&&Jn(k.label)===S)?.family??I},a=()=>{const I=e.value?.trim();return I?vc(t,I)?"":I:""},l=I=>{const S=(e.value??"").trim(),C=(P,x,Y,le)=>({kind:P,key:x,label:Y,value:le,selected:(le??"")===S}),k=I.trim();if(!k){const P=[C("clear","__clear__",n)],x=a();x&&P.push(C("unknown","__unknown__",`${x}(未知)`,x));for(const Y of t)P.push(C("font",Y.family,wc(Y),Y.family));return P}const $=gm(t,k).map(P=>C("font",P.family,wc(P),P.family));if(!$.length){const P=i(k);$.push(C("free","__free__",`使用「${P}」`,P))}return $},c=document.createElement("div");c.className="font-select";const s=document.createElement("input");s.className="pd-input font-select-input",s.type="text",s.setAttribute("role","combobox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-controls",r),s.autocomplete="off",s.placeholder=n,s.disabled=!!e.disabled,s.value=o(e.value);const d=document.createElement("ul");d.id=r,d.className="font-select-list",d.setAttribute("role","listbox");const p=e.state.fontOpen?.id===e.id?e.state.fontOpen:null,u={open:!!p&&!e.disabled,query:p?.query??"",highlighted:p?.highlighted??-1};u.open&&(s.value=u.query);const f=()=>{e.state.fontOpen=u.open?{id:e.id,query:u.query,highlighted:u.highlighted}:null};f();const m=()=>{const I=(e.value??"").trim();return l(u.query).findIndex(S=>(S.value??"")===I)},g=()=>{const I=s.getBoundingClientRect(),S=Fv(s);d.classList.toggle("is-up",Nh({triggerTop:I.top,triggerBottom:I.bottom,overlayHeight:d.getBoundingClientRect().height,boundaryTop:S.top,boundaryBottom:S.bottom})==="up")},b=()=>{if(!u.open){d.isConnected&&d.remove(),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-activedescendant","");return}d.isConnected||c.appendChild(d);const I=l(u.query);d.replaceChildren(...I.map((S,C)=>{const k=document.createElement("li");return k.id=`${r}-${C}`,k.className="font-select-option"+(C===u.highlighted?" is-active":"")+(S.kind==="unknown"||S.kind==="free"?" is-muted":""),k.setAttribute("role","option"),k.setAttribute("aria-selected",String(S.selected)),k.textContent=S.label,k.addEventListener("mousedown",$=>{$.preventDefault(),R(S)}),k})),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-activedescendant",u.highlighted>=0?`${r}-${u.highlighted}`:""),g()},v=()=>{u.open||e.disabled||(u.open=!0,u.query="",u.highlighted=m(),f(),b())},w=()=>{u.open||v()},_=()=>{u.open=!0,u.query=s.value,u.highlighted=l(u.query).length?0:-1,f(),b()},M=I=>{if(!u.open){v();return}const S=l(u.query).length-1;if(S<0)return;u.highlighted=Math.min(Math.max(u.highlighted+I,0),S),f(),b(),d.children[u.highlighted]?.scrollIntoView?.({block:"nearest"})},N=()=>{if(!u.open)return;const I=l(u.query)[u.highlighted];if(I){R(I);return}const S=u.query.trim();if(S){const C=i(S);R({value:C})}},R=I=>{u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(I.value),b(),e.onChange(I.value)},D=()=>{u.open&&(u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(e.value),b())};return s.addEventListener("focus",v),s.addEventListener("click",w),s.addEventListener("input",_),s.addEventListener("blur",D),s.addEventListener("keydown",I=>{const S=I;S.key==="ArrowDown"?(S.preventDefault(),M(1)):S.key==="ArrowUp"?(S.preventDefault(),M(-1)):S.key==="Enter"?(S.preventDefault(),N()):S.key==="Escape"&&(S.preventDefault(),D())}),c.append(s),b(),u.open&&(s.focus(),s.setSelectionRange(u.query.length,u.query.length)),c}const zv=[{key:"solid",label:"实线",preview:"1.5px solid currentColor"},{key:"dashed",label:"虚线",preview:"1.5px dashed currentColor"},{key:"dotted",label:"点线",preview:"1.5px dotted currentColor"},{key:"double",label:"双线",preview:"3px double currentColor"}],Bv={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function Lt(e,t,n,r,o={}){return h("button",{type:"button",class:`ft-cell-btn${o.on?" on":""}`,dataset:{test:e,tip:t},disabled:!!o.disabled,onClick:r,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${n}</svg>`})}const Mn='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',Qp='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function Hv(e){const t=e.format;t.syncBorderDraft();const n=t.values,r=!t.fontEditable,o=r||t.context==="cells",i=t.context==="none",a=t.context==="cells",l=!t.painterActive&&(t.context==="none"||t.context==="cells"||!t.painterCapturable),c=t.painterActive?"退出格式刷(Esc)":t.context==="cells"?"格式刷(表格单元格暂不支持)":t.context==="none"?"格式刷(需选中元素)":t.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",s=u=>r?`${u}(需选中文本元素)`:u,d=[h("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[h("div",{class:"ft-border-grid"},[Lt("preset-none","无边框",`${Mn}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>t.applyBorderPreset("none")),Lt("preset-all","所有边框",`${Qp}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>t.applyBorderPreset("all")),Lt("preset-outer","外侧边框",Qp,()=>t.applyBorderPreset("outer")),Lt("preset-inner",a?"内部边框":"内部边框(仅表格单元格可用)",`${Mn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>t.applyBorderPreset("inner"),{disabled:!a}),Lt("edge-top","上边框",`${Mn}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>t.applyEdge("top"),{on:t.edgeOn("top")}),Lt("edge-bottom","下边框",`${Mn}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>t.applyEdge("bottom"),{on:t.edgeOn("bottom")}),Lt("edge-left","左边框",`${Mn}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>t.applyEdge("left"),{on:t.edgeOn("left")}),Lt("edge-right","右边框",`${Mn}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>t.applyEdge("right"),{on:t.edgeOn("right")})]),h("div",{class:"ft-style-row"},zv.map(u=>h("button",{type:"button",class:`ft-style-btn${t.borderStyle===u.key?" on":""}`,dataset:{test:`style-${u.key}`,tip:t.borderStyle===u.key?`${u.label}(再点一次取消,线型=无)`:u.label},onClick:()=>{t.toggleBorderStyle(u.key),e.repaint()}},[h("span",{class:"ft-style-line",style:{borderTop:u.preview}})]))),h("div",{class:"ft-border-style-row"},[h("span",{class:"ft-edge-label",text:"粗细"}),h("div",{class:"ft-line-width"},[Q({value:t.borderWidth,min:.25,max:5,step:.25,placeholder:t.borderMixed.width?"混合":void 0,onCommit:u=>{t.setBorderWidth(u),e.repaint()}})])]),h("div",{class:"ft-border-style-row"},[h("span",{class:"ft-edge-label",text:"颜色"}),Je(t.borderColor,u=>{t.setBorderColor(u),e.repaint()},"边框颜色")]),t.borderMixedAny?h("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],p=[h("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[h("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([u,f,m])=>h("button",{type:"button",class:`ft-cell-btn${n.textAlign===u?" on":""}`,dataset:{test:`align-${u}`,tip:f},disabled:r,onClick:()=>t.applyStyle({textAlign:u}),html:ze(m)}))),h("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([u,f,m])=>h("button",{type:"button",class:`ft-cell-btn${n.verticalAlign===u?" on":""}`,dataset:{test:`valign-${u}`,tip:f},disabled:r,onClick:()=>t.applyStyle({verticalAlign:u}),html:ze(m)})))])];return h("div",{class:"format-toolbar"},[h("div",{class:"tb-ou ft-group",dataset:{unit:"painter"}},[h("button",{type:"button",class:`ft-btn${t.painterActive?" on":""}`,dataset:{test:"format-painter",tip:c},disabled:l,onClick:()=>{t.painterActive?t.cancelPainter():t.pickPainterSource(!1),e.repaint()},onDblclick:()=>{t.pickPainterSource(!0),e.repaint()},html:ze("Paintbrush")})]),h("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[h("div",{class:"ft-font"},[ei({id:"ft-font",state:e.state,fonts:e.host.fonts,value:typeof n.fontFamily=="string"?n.fontFamily:void 0,placeholder:n.fontFamily===Zt?"混合":"默认",disabled:r,onChange:u=>t.applyStyle({fontFamily:u})})]),h("div",{class:"ft-size",dataset:{test:"font-size"}},[Q({value:typeof n.fontSize=="number"?n.fontSize:void 0,min:5,max:72,disabled:r,placeholder:n.fontSize===Zt?"混合":"默认",onCommit:u=>t.applyStyle({fontSize:u})})])]),h("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>t.toggleBold()],["underline","Underline","下划线",()=>t.toggleUnderline()],["strike","Strikethrough","删除线",()=>t.toggleStrike()]].map(([u,f,m,g])=>h("button",{type:"button",class:`ft-btn${n[u]===!0?" on":""}`,dataset:{test:u,tip:s(m)},disabled:u==="bold"?r:o,onClick:g,html:ze(f)}))]),h("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[h("span",{class:`ft-color-btn${r?" dim":""}`,title:`字体颜色${r?"(需选中或混选文本元素)":""}`},[Je(typeof n.color=="string"?n.color:void 0,u=>t.applyStyle({color:u})),h("span",{class:"ft-glyph",text:"A"})]),h("span",{class:`ft-color-btn${i?" dim":""}`,title:"背景色"},[Je(typeof n.backgroundColor=="string"?n.backgroundColor:void 0,u=>t.applyStyle({backgroundColor:u})),h("span",{class:"ft-glyph",html:ze("PaintBucket",14)})])]),h("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[Qo(e,"align",{icon:Bv[String(n.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:r?"对齐(需选中文本元素或单元格)":"对齐",disabled:r,testId:"align-dd"},p)]),h("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[Qo(e,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:i?"边框(需选中元素)":"边框",disabled:i,testId:"border"},d)])])}const Uv=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"flowList",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:"<>"}],qv={text:"T",longText:"¶",table:"⊞",flowList:"⊟",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function Wv(e){const t=e.state;if(t.leftCollapsed)return h("div",{class:"left-panel collapsed"},[h("div",{class:"left-collapsed"},[ef("»","展开素材台",()=>{t.leftCollapsed=!1,e.repaint()}),...[["elements","元素","▦"],["fields","字段","⊛"],["layers","图层","≡"]].map(([r,o,i])=>h("button",{type:"button",class:`lc-btn${t.leftTab===r?" on":""}`,title:o,text:i,onClick:()=>{t.leftTab=r,t.leftCollapsed=!1,e.repaint()}}))])]);const n=(r,o)=>h("div",{class:"pd-tab-pane",role:"tabpanel",style:t.leftTab===r?"":{display:"none"}},o);return h("div",{class:"left-panel"},[h("div",{class:"left-head"},[h("span",{class:"left-title",text:"素材台"}),ef("«","收起素材台",()=>{t.leftCollapsed=!0,e.repaint()})]),h("div",{class:"pd-tabs left-tabs"},[h("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([r,o])=>h("button",{type:"button",class:`pd-tab${t.leftTab===r?" active":""}`,text:o,onClick:()=>{t.leftTab=r,e.repaint()}}))]),n("elements",jv()),n("fields",[Gv(e)]),n("layers",[Vv(e)])])])}function ef(e,t,n){return h("button",{type:"button",class:"collapse-btn",title:t,text:e,onClick:n})}function jv(){return[h("div",{class:"panel-title",text:"拖拽元素到画布"}),...Uv.map(e=>h("div",{class:"material-card",draggable:!0,dataset:{test:`material-${e.type}`},onDragstart:t=>{const n=t.dataTransfer;n?.setData("elementType",e.type),n&&(n.effectAllowed="all")}},[h("span",{class:"material-icon",text:e.icon}),h("span",{class:"material-label",text:e.label})]))]}function Gv(e){const t=e.state,n=dd(e.store.fields),r=(t.fieldSearch??"").trim().toLowerCase(),o=r?n.map(i=>({...i,fields:i.fields.filter(a=>`${a.fieldLabel}${a.fieldKey}`.toLowerCase().includes(r))})).filter(i=>i.fields.length):n;return h("div",{class:"field-tree-panel"},[h("div",{class:"panel-title",text:"业务字段"}),h("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:t.fieldSearch??"",onInput:i=>{t.fieldSearch=i.target.value},onChange:()=>e.repaint()}),h("div",{class:"tree-container"},o.flatMap(i=>{const a=t.collapsedGroups.has(i.key)&&!r,l=i.key?h("div",{class:`field-group-header${i.isList?" is-list":""}`,onClick:()=>{a?t.collapsedGroups.delete(i.key):t.collapsedGroups.add(i.key),e.repaint()}},[h("span",{class:"expand-icon",text:a?"▶":"▼"}),h("span",{class:"node-icon",text:i.isList?"📋":"📁"}),h("span",{class:"group-label",text:i.label,"data-tip":i.label})]):"",c=a?[]:i.fields.map(s=>h("div",{class:"field-row",draggable:!0,"data-tip":`${s.fieldLabel} (${s.fieldKey}) · 单击复制字段名 · 拖动中按住 Ctrl(Mac 为 ⌘)切换为插入字段名`,style:{paddingLeft:`${i.key?22:8}px`},onDragstart:d=>{const p=d.dataTransfer;p?.setData("fieldKey",s.fieldKey),p&&(p.effectAllowed="all")},onClick:()=>{ud(s.fieldLabel||s.fieldKey).then(d=>{d&&(t.copiedFieldKey=s.fieldKey,e.repaint(),setTimeout(()=>{t.copiedFieldKey===s.fieldKey&&(t.copiedFieldKey="",e.repaint())},1200))})}},[h("span",{class:"node-icon",text:"📄"}),h("span",{class:"node-meta"},[h("span",{class:"node-label",text:s.fieldLabel}),h("span",{class:"node-key",text:`(${s.fieldKey})`})]),t.copiedFieldKey===s.fieldKey?h("span",{class:"copy-hint",text:"已复制"}):""].filter(Boolean)));return[l,h("div",{},c.filter(Boolean))].filter(Boolean)})),o.length===0?h("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function Vv(e){const t=e.store,n=[...t.elements].sort((l,c)=>(c.options.zIndex??0)-(l.options.zIndex??0)),r=t.elements.filter(l=>t.selectedIds.has(l.id)),o=r.length>=2,i=r.some(l=>!!l.options.groupId),a=l=>l.zone==="header"?"页眉":l.zone==="footer"?"页脚":"";return h("div",{class:"layer-panel"},[h("div",{class:"panel-title",text:"图层"}),...n.map(l=>h("div",{class:`layer-item${t.selectedIds.has(l.id)?" active":""}`,onClick:c=>t.selectElement(l.id,c.ctrlKey||c.metaKey)},[h("span",{class:"layer-icon",text:qv[l.printElementType.type]||"?"}),h("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),a(l)?h("span",{class:"layer-zone",text:a(l)}):"",h("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))),n.length?h("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,c,s])=>h("button",{type:"button",class:"pd-button small",title:c,html:ze(s,14),onClick:()=>e.fire("move-layer",l)}))]):"",o||i?h("div",{class:"layer-actions"},[o?h("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:ze("Group",14),onClick:()=>e.fire("group")}):"",i?h("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:ze("Ungroup",14),onClick:()=>e.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function Yv(e){const t=e.store,n=e.state,r=t.pages.length>1,o=t.pages[t.activePageIndex]?.name||`页面 ${t.activePageIndex+1}`,i=t.tilingEnabled;return h("div",{class:"page-tabs"},[h("div",{class:"page-tabs-list"},t.pages.map((l,c)=>n.renamingPage===c?h("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:n.renameText??"",onInput:s=>{n.renameText=s.target.value},onBlur:()=>a(),onKeydown:s=>{const d=s;if(d.key==="Enter"){a();return}d.key==="Escape"&&(n.renamingPage=null,e.repaint())}}):h("button",{type:"button",class:`page-tab${c===t.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${c+1}`,onClick:()=>t.switchPage(c),onDblclick:()=>{n.renamingPage=c,n.renameText=l.name??"",e.repaint()}}))),h("div",{class:"page-tabs-actions"},[h("button",{type:"button",dataset:{test:"add-page",tip:i?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:i,text:"+",onClick:()=>e.fire("add-page")}),h("button",{type:"button",dataset:{test:"duplicate-page",tip:i?"拼版模板仅允许一个设计页面":`复制当前页「${o}」`},disabled:i,text:"⧉",onClick:()=>e.fire("duplicate-page")}),h("button",{type:"button",dataset:{test:"delete-page",tip:r?`删除当前页「${o}」`:"仅多页面模板可删除页面"},disabled:!r,text:"✕",onClick:()=>e.fire("delete-page")}),h("button",{type:"button",dataset:{test:"move-left",tip:`前移「${o}」`},disabled:t.activePageIndex<=0,text:"←",onClick:()=>e.fire("move-page",-1)}),h("button",{type:"button",dataset:{test:"move-right",tip:`后移「${o}」`},disabled:t.activePageIndex>=t.pages.length-1,text:"→",onClick:()=>e.fire("move-page",1)})])]);function a(){const l=(n.renameText??"").trim();n.renamingPage!==null&&l&&t.renamePage(n.renamingPage,l),n.renamingPage=null,e.repaint()}}function Xv(e){const t=e.store,n=t.templateData,r=It(n),o=n.orientation==="landscape"?"横向":"纵向",i=dt[n.paperSize]?.label??n.paperSize,a=n.outputRotation,l=`${i} ${o} ${Math.round(r.width)}×${Math.round(r.height)}mm${a?`(旋转${a}°)`:""}`;return h("div",{class:"status-bar"},[h("span",{class:"status-item coord",dataset:{coord:""},style:{display:"none"}}),h("span",{class:"status-item",text:`缩放 ${t.scale}%`}),h("span",{class:"status-item",text:`元素 ${t.elements.length}${t.selectedIds.size?` (选中 ${t.selectedIds.size})`:""}`}),h("span",{class:`status-dirty${t.dirty?" on":""}`},[h("span",{class:"dirty-dot"}),t.dirty?"未保存":"已保存"]),h("span",{class:"status-item status-paper",text:l})])}const Kv=Object.keys(dt).filter(e=>e!=="CUSTOM"&&!dt[e]?.continuous);function Zv(e){const t=document.createElement("label");t.className="pd-button small upload-label";const n=document.createTextNode("上传背景图"),r=document.createElement("input");r.className="visually-hidden",r.type="file",r.accept="image/*",t.append(n,r);const o=i=>{t.className=`pd-button small upload-label${i?" disabled":""}`,r.disabled=i};return r.addEventListener("change",async()=>{const i=r.files?.[0];if(!i)return;if(!i.type.startsWith("image/")){alert("仅支持上传图片文件"),r.value="";return}const a=e.host.uploadDesignBackground;if(!a){alert("设计背景上传能力未配置"),r.value="";return}o(!0),n.textContent="上传中...";try{const l=await a(i);l?e.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{n.textContent="上传背景图",o(!e.host.uploadDesignBackground),r.value=""}}),e.host.uploadDesignBackground||o(!0),t}function Jv(e){const n=e.store.templateData.designBackground,r=n?.rotation??0;return h("div",{class:"design-background-config"},[mt("设计背景"),h("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),n?.src?[h("div",{class:"design-background-path",title:n.src,text:n.src}),h("div",{class:"design-background-actions"},[h("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(r+90)%360}°)`,onClick:()=>e.store.updateTemplateData({designBackground:{...n,rotation:(r+90)%360}})}),h("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>e.store.updateTemplateData({designBackground:void 0})})])]:Zv(e)].flat())}function Qv(e){const t=e.store,n=t.templateData,r=n.tiling,o={...pt,...r??{},enabled:r?.enabled??!1,sheetMargin:{...pt.sheetMargin,...r?.sheetMargin??{}}},i=Fi(n.paperSize),a=m=>t.updateTemplateData({tiling:{...o,...m}}),l=m=>nn({target:o,base:pt,propKey:m,write:()=>a({[m]:pt[m]})}),c=m=>nn({target:o.sheetMargin,base:pt.sheetMargin,propKey:m,write:()=>s(m,pt.sheetMargin[m])}),s=(m,g)=>a({sheetMargin:{...o.sheetMargin,[m]:g??0}}),d={...n,tiling:o},p=wa(d),u=Math.max(Qc(d),1);let f="";if(!p.length)try{const m=Jc(d),g=rr(d),b=o.sheetPaperSize==="CUSTOM"?"自定义":o.sheetPaperSize??"A4",v=o.sheetPaperSize==="CUSTOM"?"":o.sheetOrientation==="landscape"?" 横向":" 纵向";f=`目标纸 ${b}${v} ${g.width}×${g.height}mm · ${m.columns} 列 × ${m.rows} 行 = 每张 ${m.perSheet} 格 · 每格 ${m.tile.width}×${m.tile.height}mm`}catch{f=""}return h("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[mt("拼版打印"),h("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),h("div",{class:"pd-field"},[h("label",{class:"tiling-switch"},[h("input",{type:"checkbox",checked:o.enabled===!0,disabled:i,onChange:m=>{if(!m.target.checked){a({enabled:!1});return}a({...pt,columns:Math.min(pt.columns,Math.max(u,1))})}}),h("span",{text:"启用拼版"})]),i?h("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),o.enabled&&!i?[ie("目标纸张",h("select",{class:"pd-select",style:{width:"100%"},onChange:m=>{const g=m.target.value;if(g!=="CUSTOM"){a({sheetPaperSize:g});return}const b=rr(d);a({sheetPaperSize:"CUSTOM",sheetCustomWidth:o.sheetCustomWidth??b.width,sheetCustomHeight:o.sheetCustomHeight??b.height})}},[...Kv.map(m=>h("option",{value:m,text:dt[m]?.label??m,selected:(o.sheetPaperSize??"A4")===m})),h("option",{value:"CUSTOM",text:"自定义",selected:o.sheetPaperSize==="CUSTOM"})]),void 0,l("sheetPaperSize")),o.sheetPaperSize==="CUSTOM"?ie("目标纸宽高 (mm)",h("div",{class:"custom-size-grid"},[Q({value:Number(o.sheetCustomWidth??0),min:25,max:2e3,onCommit:m=>a({sheetCustomWidth:m})}),h("span",{class:"custom-size-x",text:"×"}),Q({value:Number(o.sheetCustomHeight??0),min:25,max:2e3,onCommit:m=>a({sheetCustomHeight:m})})])):ie("目标纸方向",$t("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],o.sheetOrientation==="landscape"?"landscape":"portrait",m=>a({sheetOrientation:m})),void 0,l("sheetOrientation")),mt("拼版留白 (mm)"),h("div",{class:"margin-grid"},[ie("上",Q({value:o.sheetMargin.top??0,min:0,max:100,onCommit:m=>s("top",m)}),void 0,c("top")),ie("下",Q({value:o.sheetMargin.bottom??0,min:0,max:100,onCommit:m=>s("bottom",m)}),void 0,c("bottom")),ie("左",Q({value:o.sheetMargin.left??0,min:0,max:100,onCommit:m=>s("left",m)}),void 0,c("left")),ie("右",Q({value:o.sheetMargin.right??0,min:0,max:100,onCommit:m=>s("right",m)}),void 0,c("right"))]),mt("格间距与列数"),ie("横向间距",Q({value:o.gapX??0,min:0,max:50,onCommit:m=>a({gapX:m??0})}),void 0,l("gapX")),ie("纵向间距",Q({value:o.gapY??0,min:0,max:50,onCommit:m=>a({gapY:m??0})}),void 0,l("gapY")),ie("列数",Q({value:o.columns??1,min:1,max:u,onCommit:m=>a({columns:m||1})})),...p.map(m=>h("p",{class:"pd-hint tiling-error",text:m.message})),!p.length&&f?h("p",{class:"pd-hint tiling-summary",text:f}):""]:""].flat().filter(Boolean))}const ew=new Set(zr.map(e=>e.group)),tw={"table-settings":"content"},tf=new Map;function Ts(e){const t=e??"";let n=tf.get(t);if(!n){const{groups:r,itemKeys:o}=Pg(t);n={groups:r,keys:o,searching:!!t.trim()},tf.set(t,n)}return n}function ks(e){const t=tw[e]??e;return ew.has(t)?t:""}function nw(e,t){const n=Ts(e.state.propSearch);if(!n.searching)return!0;const r=ks(t);return!r||n.groups.includes(r)}function rw(e,t){const n=Ts(e.state.propSearch);return!n.searching||n.keys.has(t)}function nf(e,t){const n=e.props.style??{};return e.props.style={...n,display:t?"":"none"},e}function U(e,t,n){const r=n.props.dataset??{};return n.props.dataset={...r,propKey:t},nf(n,rw(e,t))}function ow(e,t,n){const r=ks(t);if(!r)return n;const o=n.props.dataset??{};return n.props.dataset={...o,propGroup:r},nf(n,nw(e,t))}function rf(e,t){const n=Ts(t);for(const r of Array.from(e.querySelectorAll("[data-prop-group]"))){const o=ks(r.dataset.propGroup??"");r.style.display=!n.searching||!o||n.groups.includes(o)?"":"none"}for(const r of Array.from(e.querySelectorAll("[data-prop-key]")))r.style.display=!n.searching||n.keys.has(r.dataset.propKey??"")?"":"none"}function iw(e){return h("div",{class:"property-search"},[h("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:e.state.propSearch??"",onInput:t=>{const n=t.target,r=n.value;e.state.propSearch=r,rf(n.getRootNode(),r)}})])}const aw={Document:"≡",Brush:"◧",Setting:"⚙"};function sw(e,t){try{const n=window.localStorage.getItem(`property-group-${e}`);return n===null?t:n==="true"}catch{return t}}function lw(e,t){try{window.localStorage.setItem(`property-group-${e}`,String(t))}catch{}}function qe(e,t,n,r,o,i=!0){const a=sw(t,i);return ow(e,t,h("div",{class:`property-group${a?" is-expanded":""}`},[h("div",{class:"group-header",onClick:()=>{lw(t,!a),e.repaint()}},[h("span",{class:"group-icon",text:aw[r]||"•"}),h("span",{class:"group-title",text:n}),h("span",{class:"expand-icon",text:a?"▾":"▸"})]),h("div",{class:"group-content",style:a?"":{display:"none"}},o.filter(Boolean))]))}function ti(e){return h("form",{class:"pd-form",onSubmit:t=>t.preventDefault()},e.filter(Boolean))}function of(e){return e.split(".").flatMap(t=>{const n=t.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!n)return[t];const r=n[1],o=[...n[2].matchAll(/\[(\d+)\]/g)].map(i=>Number(i[1]));return[r,...o]})}function af(e,t){return of(t).reduce((o,i)=>o==null?"":o[i],e)??""}function Cs(e,t,n,r){const o=of(n),i=o.pop(),a=o.reduce((l,c)=>((l[c]===void 0||l[c]===null)&&(l[c]={}),l[c]),t);a[i]=r||void 0,e.recordHistory(),e.emit()}function cw(e,t){const n=e.store;if(t.printElementType.type==="table"&&n.tableSelection?.elementId===t.id){const{r1:r,c1:o}=n.tableSelection,i=(t.options.tableRows??[])[r];if(i)return pd(i.type,r,o,t.options.fields?.[0]?.dataSource)}return U0(t)}function dw(e,t){const n=document.createElement("label");n.className="pd-button small upload-label",Fe(h("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[h("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),n);const r=document.createTextNode("上传图片"),o=document.createElement("input");o.className="visually-hidden",o.type="file",o.accept="image/*",n.append(r,o);const i=c=>{n.className=`pd-button small upload-label${c?" disabled":""}`,o.disabled=c};o.addEventListener("change",async()=>{const c=o.files?.[0];if(!c)return;if(!c.type.startsWith("image/")){alert("仅支持上传图片文件"),o.value="";return}const s=e.host.uploadImage;if(!s){alert("图片上传能力未配置"),o.value="";return}i(!0),r.textContent="上传中...";try{const d=await s(c);d?Cs(e.store,t,"options.src",d):alert("图片上传失败")}catch(d){alert(d instanceof Error?d.message:"图片上传失败")}finally{r.textContent="上传图片",i(!e.host.uploadImage),o.value=""}}),e.host.uploadImage||i(!0);const a=document.createElement("div");a.className="image-content-upload";const l=document.createElement("p");return l.className="upload-tip",l.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",a.append(n,l),a}function uw(e,t){const n=r=>e.fire("open-expression",{elementId:t.id,targetPath:r.targetPath,value:af(t,r.targetPath)});return qe(e,"binding","内容","Document",[...cw(e,t).map(r=>ie(r.label,h("input",{class:"pd-input",type:"text",value:af(t,r.targetPath),placeholder:r.placeholder||"输入内容,支持 {字段} 表达式",onChange:o=>Cs(e.store,t,r.targetPath,o.target.value),onDblclick:()=>n(r)}))),t.printElementType.type==="image"?dw(e,t):""].filter(Boolean))}const Sr=new Map;function ni(e){return`${Math.round(e*1e4)/1e4}%`}function sf(e,t){const n=A0(t.value),r=n.kind==="custom",o=n.kind==="axes"?n.x:50,i=n.kind==="axes"?n.y:50,a=$0(t.src),l=Sr.get(a.src),c={widthMm:t.widthMm,heightMm:t.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:t.fit,scalePct:t.scale},s=O0(c),d=I0(c,o,i),p=document.createElement("select");p.className="pd-select",p.style.width="100%";for(const g of z0(s,o,i)){const b=document.createElement("option");b.value=g.value,b.textContent=g.label,p.appendChild(b)}if(r){const g=document.createElement("option");g.value="custom",g.textContent="自定义(保留原值)",p.appendChild(g)}p.value=r?"custom":`${o},${i}`,p.selectedIndex<0&&(p.selectedIndex=r?p.options.length-1:0),p.addEventListener("change",()=>{if(p.value==="custom")return;const[g,b]=p.value.split(",").map(Number);t.onCommit(od(g,b))});const u=Me(t.fieldKey),f=[h("div",{class:"pd-field",dataset:{field:t.fieldKey}},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[t.label,Ms(u)]),t.resetAnchor??""].filter(Boolean)),p])];f.push(h("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[L0,Ms(Me("ap-img-fit-scale"))]),t.resetScale??""].filter(Boolean)),Q({value:t.scale,min:Bn,max:pl,step:5,placeholder:"默认 100",onCommit:g=>t.onScaleCommit(g>Bn?g:void 0)})]));for(const g of F0(s,o,i))f.push(h("div",{class:"pd-field",dataset:{field:t.fieldKey}},[h("span",{class:"pd-label",text:g.label}),Q({value:g.value,min:0,max:100,step:1,onCommit:b=>t.onCommit(od(g.name==="horizontal"?b:o,g.name==="vertical"?b:i))})]));const m=N0(s,r);return m&&f.push(h("p",{class:"pd-crop-note",text:m})),a.isSample&&f.push(h("p",{class:"pd-crop-note",text:D0})),f.push(h("div",{class:"pd-crop-preview"},[h("img",{class:"pd-crop-thumb",src:a.src,alt:a.isSample?"示例图":"原图",onLoad:g=>{const b=g.target;if(!(b.naturalWidth>0&&b.naturalHeight>0))return;const v=Sr.get(a.src);v&&v.width===b.naturalWidth&&v.height===b.naturalHeight||(Sr.set(a.src,{width:b.naturalWidth,height:b.naturalHeight}),e.repaint())},onError:()=>{Sr.has(a.src)&&(Sr.delete(a.src),e.repaint())}}),d?h("div",{class:"pd-crop-win",style:{left:ni(d.leftPct),top:ni(d.topPct),width:ni(d.widthPct),height:ni(d.heightPct)}}):""])),h("div",{class:t.containerClass??"pd-crop-anchor"},f)}const rn=e=>Number(e??0),As=e=>e||void 0;function on(e,t,n,r,o,i){return h("div",{class:"pd-field"},[h("span",{class:"pd-label",...r?{title:r}:{}},[h("span",{class:"pd-label-t",text:e}),o??""].filter(Boolean)),h("input",{class:"pd-switch",type:"checkbox",checked:t,...i?{disabled:!0}:{},onChange:a=>n(a.target.checked)})])}function lf(e,t,n,r,o=!1,i){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),""].filter(Boolean)),h("select",{class:"pd-select",...o?{style:{width:"100%"}}:{},onChange:a=>r(a.target.value)},n.map(a=>h("option",{value:a.value,text:a.label,selected:a.value===t})))])}function _r(e,t,n,r,o={}){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),o.reset??""].filter(Boolean)),Jp(t,n,r,{className:"pd-select",...o.full?{width:"100%"}:{}})])}const Tn=e=>h("p",{class:"pd-hint",text:e}),pw="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",fw=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],hw=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],gw=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],mw=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],bw={value:"__multi__",label:"多选",disabled:!0};function yw(e,t){const n=e.store,r=n.tableSelection,o=t.options.tableRows??[],i=r?o[r.r1]:void 0;if(!r||!i)return qe(e,"table-row","行属性","Grid",[]);const a=l=>n.updateElement(t.id,l);return qe(e,"table-row","行属性","Grid",[ti([lf("行类型",i.type,fw,l=>{const c=Ri(o,r.r1,l);if(c){window.alert(c);return}a({tableRows:o})},!0),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"行高 (mm)"}),Q({value:i.height,min:3,max:100,step:.5,onCommit:l=>{i.height=l,a({tableRows:o})}})]),i.type==="header"?on("表头每页重复",i.repeatOnPage??!1,l=>{Gh(o,l),a({tableRows:o})},pw):""])])}function vw(e,t){const n=e.store,r=t.options,o=d=>n.updateElement(t.id,d),i=r.tableColWidths??[],a=n.paperSize.width-n.templateData.margins.left-n.templateData.margins.right,l=n.fields.filter(d=>d.fieldType==="list").map(d=>({value:d.fieldKey,label:d.fieldLabel})),c=$i("table"),s=d=>nn({target:r,base:c,propKey:d,write:()=>o({[d]:c[d]})});return qe(e,"table-settings","表格设置","Grid",[ti([lf("列表数据源字段",r.dataSource??"",l,d=>o({dataSource:d||void 0}),!0),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认字体"}),s("tableDefaultFontFamily")]),ei({id:"table-default-font",state:e.state,fonts:e.host.fonts,value:r.tableDefaultFontFamily,placeholder:"默认",onChange:d=>o({tableDefaultFontFamily:d||void 0})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认字号 (pt)"}),s("tableDefaultFontSize")]),Q({value:rn(r.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:d=>o({tableDefaultFontSize:As(d)})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认文字颜色"}),s("tableDefaultColor")]),Je(r.tableDefaultColor,d=>o({tableDefaultColor:d}),"默认文字颜色")]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),s("tableDefaultPadding")]),Q({value:rn(r.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:d=>o({tableDefaultPadding:As(d)})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"列宽 (mm)"}),...i.map((d,p)=>h("div",{class:"col-width-row"},[h("span",{style:{width:"60px"},text:`列${p+1}`}),Q({value:d,min:5,max:200,onCommit:u=>{const f=i.reduce((m,g,b)=>b===p?m:m+g,0);if(f+u>a){const m=Math.max(5,Math.round((a-f)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${a}mm,列${p+1} 已调整为 ${m}mm`),i[p]=m}else i[p]=u;o({tableColWidths:i})}})]))])])])}function ww(e,t){const n=e.store,r=t.options,o=t.printElementType.type==="table",i=l=>n.updateElement(t.id,l),a=[];if(o)a.push(U(e,"pg-enabled",on("启用分页",r.tablePagination?.enabled??!0,l=>i({tablePagination:{enabled:l}}))));else{const l=r.pagination?.pageable??!0,c=r.pagination?.keepWithNext??!1;a.push(U(e,"pg-pageable",on("参与分页",l,s=>i({pagination:{pageable:s,keepWithNext:c}})))),a.push(U(e,"pg-keep-with-next",on("与下元素同页",c,s=>i({pagination:{pageable:l,keepWithNext:s}}))))}return qe(e,"pagination","分页配置","Document",[ti(a)],!1)}const Os=new WeakMap,cf=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function xw(e,t){const n=e.store,r=n.tableSelection,o=t.options.tableRows??[];if(!r)return qe(e,"table-cell","单元格","Menu",[]);const i=Wn(o,r.r1,r.c1),a=o[i.r]?.cells[i.c];if(!a)return qe(e,"table-cell","单元格","Menu",[]);const l=()=>Nr(o,r),c=Di(o,r),s=c.count,d=c.mode==="multi",p=`${t.id}:${r.r1}:${r.c1}:${r.r2}:${r.c2}`,u=Os.get(n),f=u?.key===p?u:{key:p,border:{},values:{},edges:{}};u?.key!==p&&Os.set(n,f);const m=T=>{Os.set(n,{key:p,border:T.border??f.border,values:T.values??f.values,edges:T.edges??f.edges})},g=(T,B)=>{m({border:{...f.border,[T]:B}}),e.repaint()},b=(T,B)=>{l().forEach(T),d&&B&&m({values:{...f.values,...B}}),n.updateElement(t.id,{tableRows:o})},v=(T,B)=>{b(oe=>{oe[T]=B},{[T]:B})},w=T=>d?f.values[T]:a[T],_=T=>d&&T in f.values,M=d?{width:void 0,style:void 0,color:void 0}:Nl(o,r),N=!d&&l().some(T=>!!T.borders&&!!(T.borders.top||T.borders.right||T.borders.bottom||T.borders.left)),R=!d&&!N,D={width:R?0:typeof M.width=="number"?M.width:Ot.width,style:R?"none":typeof M.style=="string"&&M.style!=="mixed"?M.style:Ot.style,color:typeof M.color=="string"&&M.color!=="mixed"?M.color:Ot.color,...f.border},I="__mixed__",S={style:!d&&M.style==="mixed",width:!d&&M.width==="mixed",color:!d&&M.color==="mixed"},C=S.style&&!("style"in f.border),k=S.width&&!("width"in f.border),$=S.color&&!("color"in f.border),P=C||k||$,x=C?I:D.style,Y=k?void 0:D.width,le=$?void 0:D.color,De=T=>{const B={style:T};T!=="none"&&Y===0?B.width=Ot.width:T==="none"&&!N&&(B.width=0),m({border:{...f.border,...B}}),e.repaint()},G=()=>({...D}),me=d?cf.reduce((T,B)=>(T[B.value]=f.edges[B.value]?"on":"off",T),{}):zl(l().map(T=>T.borders)),Be=d?"cellType"in f.values?f.values.cellType??"text":Kh(o,r):a.cellType??"text",ue=Be==="barcode",Ie=Be==="qrcode",te=Be==="image",ne=Be==="text",tt=ue&&!!w("printerDpi"),O=ll(w("printerDpi"),w("barWidth")),z=d?f.values.textFit:gi(a),q=d?"cellType"in f.values?f.values.cellType??"text":"":a.cellType||"text",W=T=>d?[bw,...T]:T,X=T=>d?"多选":T,ee=(T,B)=>d?f.values[T]:B,ce=d?w("barcodeType")??"__multi__":a.barcodeType||"CODE128",pe=d?_("printerDpi")?w("printerDpi")?String(w("printerDpi")):"":"__multi__":a.printerDpi?String(a.printerDpi):"",Z=d?w("qrCodeLevel")??"__multi__":a.qrCodeLevel||"M",de=d?w("fit")??"__multi__":a.fit||"contain",J=z??"__multi__",xe=Ol(o,r);let be=!0;for(let T=r.r1;T<=r.r2;T++)if(o[T]?.type!=="data"){be=!1;break}const he=be?"":"仅数据行(明细行)支持按值合并";let Ae=!1;for(let T=r.r1;T<=r.r2&&!Ae;T++)for(let B=r.c1;B<=r.c2&&!Ae;B++){const oe=o[T]?.cells[B];oe&&!oe.merged&&((oe.rowspan??1)>1||(oe.colspan??1)>1)&&(Ae=!0)}const se=(T,B,oe,Ee={},$e)=>h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:T}),$e??""].filter(Boolean)),Q({value:B,...Ee,onCommit:Tt=>v(oe,As(Tt))})]),lt="恢复默认值(跟随表格默认)",j=T=>nn({target:a,base:{},propKey:T,tipOverride:lt,force:d,write:()=>v(T,void 0)}),Nt=t.options.tableDefaultPadding??1,nt={width:bi(t.options.tableColWidths??[],i.c,a,Nt),height:Ln(o,i.r,a,Nt)};return qe(e,"table-cell","单元格","Menu",[ti([d?Tn(`已选 ${s} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"单元格类型"}),$t("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],q,T=>{const B=T==="text"?void 0:T,oe={cellType:T};T!=="barcode"&&Object.assign(oe,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),T!=="qrcode"&&Object.assign(oe,{qrCodeLevel:void 0,qrQuietZone:void 0}),b(Ee=>{Ee.cellType=B,T!=="barcode"&&(Ee.barcodeType=void 0,Ee.showBarcodeText=void 0,Ee.printerDpi=void 0,Ee.barQuietZone=void 0,Ee.barHeight=void 0),T!=="qrcode"&&(Ee.qrCodeLevel=void 0,Ee.qrQuietZone=void 0)},oe)})]),ue?_r("码制",ce,W(hw),T=>{T!=="__multi__"&&v("barcodeType",T||void 0)}):"",ue?on("显示文本",d?f.values.showBarcodeText===!0:a.showBarcodeText!==!1,T=>v("showBarcodeText",T),void 0,j("showBarcodeText")):"",ue?se("条宽(倍率)",ee("barWidth",a.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:X("")},j("barWidth")):"",ue?Tn((tt?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(O?`。${O}`:"")):"",ue?Oe("静区 (模块)",Q({value:ee("barQuietZone",a.barQuietZone),min:0,max:20,placeholder:X("默认 10"),onCommit:T=>v("barQuietZone",T)}),Me("cd-bar-quiet-zone"),j("barQuietZone")):"",ue?Oe("条高 (mm)",Q({value:ee("barHeight",a.barHeight),min:1,max:100,placeholder:X("默认 30 模块"),onCommit:T=>v("barHeight",T??void 0)}),Me("cd-bar-height"),j("barHeight")):"",ue?se("文本字号(相对条高,条高为 30)",ee("barFontSize",a.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:X("默认 10")},j("barFontSize")):"",ue?_r("打印机分辨率",pe,W([{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}]),T=>{if(T==="__multi__")return;const B=Number(T);v("printerDpi",B>0?B:void 0)},{reset:j("printerDpi")}):"",ue?Tn("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",Ie?_r("纠错级别",Z,W(gw),T=>{T!=="__multi__"&&v("qrCodeLevel",T||void 0)},{reset:j("qrCodeLevel")}):"",Ie?Oe("静区 (模块)",Q({value:ee("qrQuietZone",a.qrQuietZone),min:0,max:8,placeholder:X("默认 0"),onCommit:T=>v("qrQuietZone",T)}),Me("cd-quiet-zone"),j("qrQuietZone")):"",ue?Tn("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",Ie||te?_r("缩放模式",de,W(Sa),T=>{T!=="__multi__"&&v("fit",T)},{reset:j("fit")}):"",te&&!d&&a.fit==="cover"?sf(e,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:sd(a.formatter),fit:a.fit,containerClass:"pd-cell-anchor",widthMm:nt.width,heightMm:nt.height,scale:a.fitScale,value:a.objectPosition,onCommit:T=>v("objectPosition",T),onScaleCommit:T=>v("fitScale",T),resetAnchor:j("objectPosition"),resetScale:j("fitScale")}):"",ue||Ie||te?se("最大宽度 (mm)",ee("maxWidth",rn(a.maxWidth)),"maxWidth",{min:0,max:200,placeholder:X("默认")},j("maxWidth")):"",ue||Ie||te?se("最大高度 (mm)",ee("maxHeight",rn(a.maxHeight)),"maxHeight",{min:0,max:200,placeholder:X("默认")},j("maxHeight")):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"内容"}),h("input",{class:"pd-input",type:"text",value:d?w("formatter")??"":a.formatter||"",placeholder:d?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:T=>v("formatter",T.target.value||void 0),onDblclick:()=>e.fire("table-cell-dblclick",{elementId:t.id,r:i.r,c:i.c,cellId:a.id})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"水平对齐"}),j("align")]),$t("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],d?f.values.align??"":a.align||"left",T=>v("align",T))]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"垂直对齐"}),j("valign")]),$t("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],d?f.values.valign??"":a.valign||"top",T=>v("valign",T))]),h("div",{class:"cell-style-grid"},[h("div",{class:"pd-field cell-font-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"字体"}),j("fontFamily")]),ei({id:"cell-font",state:e.state,fonts:e.host.fonts,value:d?w("fontFamily"):a.fontFamily,placeholder:X("继承默认"),onChange:T=>v("fontFamily",T)})]),se("字号 (pt)",ee("fontSize",rn(a.fontSize)),"fontSize",{min:0,max:72,placeholder:X("默认")},j("fontSize")),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"加粗"}),j("fontWeight")]),h("input",{class:"pd-switch",type:"checkbox",checked:d?f.values.fontWeight==="bold":a.fontWeight==="bold",onChange:T=>v("fontWeight",T.target.checked?"bold":void 0)})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"文字颜色"}),j("color")]),Je(d?w("color"):a.color,T=>v("color",T),"文字颜色")]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"背景色"}),j("backgroundColor")]),Je(d?w("backgroundColor"):a.backgroundColor,T=>v("backgroundColor",T),"背景颜色")])]),mt("边框"),h("div",{class:"border-style-row"},[Jp(x,[...C?[{value:I,label:"混合",disabled:!0}]:[],...Bi],T=>{T!==I&&De(T)},{width:"90px"}),h("div",{style:{width:"112px",flexShrink:"0"}},[Q({value:Y,min:.25,max:5,step:.25,placeholder:d?"多选":k?"混合":void 0,onCommit:T=>g("width",T)})]),Je(le,T=>g("color",T),"边框颜色")]),h("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([T,B])=>h("button",{type:"button",class:"pd-button small",text:B,onClick:()=>{$l(o,r,D.style==="none"?"none":T,G()),n.updateElement(t.id,{tableRows:o})}}))),h("div",{class:"pd-checkbox-group"},cf.map(T=>h("label",{class:"pd-checkbox"},[h("input",{type:"checkbox",value:T.value,checked:me[T.value]==="on",indeterminate:me[T.value]==="mixed",onChange:B=>{const Ee=B.target.checked&&D.style!=="none";d&&m({edges:{...f.edges,[T.value]:Ee}}),b($e=>{Ll($e,T.value,Ee?G():null)})}}),h("span",{text:T.label})]))),Tn(d?Yh:P?Xh:Vh),se("内边距 (mm)",ee("padding",rn(a.padding)),"padding",{min:0,max:10,step:.5,placeholder:X("默认")},j("padding")),on("自动换行",d?f.values.wordWrap===!0:a.wordWrap??!0,T=>v("wordWrap",T),void 0,j("wordWrap")),ne?_r("文字溢出",J,W(mw),T=>{T!=="__multi__"&&v("textFit",T)},{full:!0,reset:j("textFit")}):"",ne&&z==="shrink"?se("最小字号 (pt)",ee("shrinkMinFontSize",rn(a.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:X("默认 6")},j("shrinkMinFontSize")):"",h("div",{class:"merge-card"},[h("div",{class:"merge-card-title",text:"单元格合并"}),h("div",{class:"merge-btns"},[h("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!xe,title:xe||"",onClick:()=>{Il(o,r),n.updateElement(t.id,{tableRows:o})}}),h("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!Ae,onClick:()=>{Pl(o,r),n.updateElement(t.id,{tableRows:o})}})]),h("div",{class:"merge-card-divider"}),on("按值合并",d?f.values.mergeSameValue===!0:a.mergeSameValue===!0,T=>v("mergeSameValue",T),he||void 0,be?j("mergeSameValue"):void 0,!be),Tn("明细相邻行同值时自动纵向合并;跨页时在该页内成段,续页首行重放该值")])])])}const Is=xm;function Ps(e){const t=e.trim();return t?/[{}]/.test(t)||/^[A-Za-z_$][\w$]*\s*\(/.test(t)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(t):!1}function Ew(e){return e?e.mode==="binding"?e.binding??"":e.content??"":""}function Sw(e){const t=e.store.templateData.watermark,n=Ew(t),r=t?.mode==="binding"||n!==""&&Ps(n),o=(()=>{const s=t?.tileWidth??ae.tileWidth,d=t?.tileHeight??ae.tileHeight;for(const[p,u]of Object.entries(Is))if(u.width===s&&u.height===d)return p;return"custom"})(),i=s=>{const d={testData:t?.testData??"",rotate:t?.rotate??ae.rotate,color:t?.color||ae.color,opacity:t?.opacity??ae.opacity,tileWidth:t?.tileWidth??ae.tileWidth,tileHeight:t?.tileHeight??ae.tileHeight,timestamp:t?.timestamp,format:t?.format};e.store.updateTemplateData({watermark:{...d,...s}})},a=()=>e.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:n}),l={rotate:t?.rotate??ae.rotate,color:t?.color||ae.color,opacity:t?.opacity??ae.opacity,tileWidth:t?.tileWidth??ae.tileWidth,tileHeight:t?.tileHeight??ae.tileHeight},c=s=>nn({target:l,base:ae,propKey:s,write:()=>i({[s]:ae[s]})});return h("div",{class:"watermark-config"},[mt("水印"),h("form",{class:"pd-form",onSubmit:s=>s.preventDefault()},[h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"水印表达式"}),h("input",{class:"pd-input",type:"text",value:n,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:s=>{const d=s.target.value;i(Ps(d)?{mode:"binding",binding:d,content:""}:{mode:"fixed",content:d,binding:""})},onDblclick:a}),h("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:a})]),r?ie("测试值",h("input",{class:"pd-input",type:"text",value:t?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:s=>i({testData:s.target.value})})):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),h("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(t?.rotate??ae.rotate),onChange:s=>i({rotate:Number(s.target.value)})}),h("span",{class:"pd-hint",text:`${t?.rotate??ae.rotate}°`})]),ie("颜色",Je(t?.color||ae.color,s=>i({color:s}),"水印颜色"),void 0,c("color")),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),h("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(t?.opacity??ae.opacity),onChange:s=>i({opacity:Number(s.target.value)})}),h("span",{class:"pd-hint",text:(t?.opacity??ae.opacity).toFixed(2)})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"密度"}),h("select",{class:"pd-select",style:{width:"100%"},onChange:s=>{const d=s.target.value,p=Is[d];p&&i({tileWidth:p.width,tileHeight:p.height})}},[...Object.entries(Is).map(([s,d])=>h("option",{value:s,text:`${d.label}(${d.width}×${d.height})`,selected:o===s})),h("option",{value:"custom",text:"自定义",selected:o==="custom"})])]),o==="custom"?h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),h("input",{type:"number",class:"pd-input",min:ae.minTileWidth,step:10,value:String(t?.tileWidth??ae.tileWidth),onChange:s=>i({tileWidth:Number(s.target.value)})})]):"",o==="custom"?h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),h("input",{type:"number",class:"pd-input",min:ae.minTileHeight,step:10,value:String(t?.tileHeight??ae.tileHeight),onChange:s=>i({tileHeight:Number(s.target.value)})})]):""].filter(Boolean))])}function Re(e,t,n,r,o={},i){return ie(t,Q({value:n,...o,onCommit:r}),void 0,i)}function St(e,t,n,r,o,i,a){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>o(l.value));for(const c of r){const s=document.createElement("option");s.value=c.value,s.textContent=c.label,l.appendChild(s)}return l.value=n,r.some(c=>c.value===n)||(l.selectedIndex=-1),i?Oe(t,l,i,a):ie(t,l,void 0,a)}function kn(e,t,n,r,o){return ie(t,h("input",{type:"checkbox",class:"pd-switch",checked:n,onChange:i=>r(i.target.checked)}),void 0,o)}const _w=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],Mw=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function Tw(e,t){const n=e.store,r=t.options,o=t.printElementType.type,i=x=>n.updateElement(t.id,x),a=o==="text"||o==="longText",l=o==="barcode"||o==="qrcode",c=o==="table",s=c&&n.tableSelection?.elementId===t.id,d=s&&Di(t.options.tableRows??[],n.tableSelection).mode==="multi",p=[];d||p.push(uw(e,t)),s||p.push(qe(e,"position-size","位置与尺寸","Location",[h("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[h("div",{class:"position-grid"},[U(e,"ps-left",Re(e,"X",r.left,x=>i({left:x}),{min:0})),U(e,"ps-top",Re(e,"Y",r.top,x=>i({top:x}),{min:0})),U(e,"ps-width",Re(e,"W",r.width,x=>i({width:x}),{min:4})),U(e,"ps-height",Re(e,"H",r.height,x=>i({height:x}),{min:4}))])])]));const u=$i(o),f=(x,Y)=>{const le=Rg(Y);return nn({target:r,base:u,propKey:x,tipValue:le?.value,tipUnit:le?.unit,write:()=>i({[x]:u[x]})})},m=typeof r.rotate=="number"&&Number.isFinite(r.rotate)&&r.rotate!==0?Hn(r.rotate):void 0,g=x=>i({rotate:x===void 0||x===0?void 0:Hn(x)}),b=_h(o,r),v=Eh(o)||wl(n.elements).has(t.id),w=v?"":U(e,"ap-rotate",Oe("旋转 (°)",h("div",{class:"pd-rotate-row"},[h("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>g((m??0)-90)}),h("div",{class:"pd-rotate-stepper"},[Q({value:m,min:0,max:359,placeholder:"0",disabled:!b,onCommit:x=>g(x)})]),h("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>g((m??0)+90)})]),Me("ap-rotate"),f("rotate","ap-rotate"))),_=v||b?"":h("p",{class:"pd-hint pd-rotate-note",text:Sh});if(p.push(qe(e,"appearance","外观","Brush",[h("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},a?[U(e,"ap-font-family",ie("字体",ei({id:"prop-font",state:e.state,fonts:e.host.fonts,value:typeof r.fontFamily=="string"?r.fontFamily:void 0,placeholder:"默认",onChange:x=>i({fontFamily:x})}),void 0,f("fontFamily","ap-font-family"))),U(e,"ap-font-size",Re(e,"字体大小",r.fontSize,x=>i({fontSize:x}),{min:8,max:72},f("fontSize","ap-font-size"))),U(e,"ap-font-weight",St(e,"字体粗细",String(r.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],x=>i({fontWeight:x}),void 0,f("fontWeight","ap-font-weight"))),U(e,"ap-align",ie("对齐",$t("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],r.textAlign||"left",x=>i({textAlign:x})),void 0,f("textAlign","ap-align"))),U(e,"ap-vertical-align",ie("垂直对齐",$t("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],r.verticalAlign||"top",x=>i({verticalAlign:x})),void 0,f("verticalAlign","ap-vertical-align"))),h("div",{class:"color-row"},[U(e,"ap-color",ie("颜色",Je(r.color,x=>i({color:x}),"字体颜色"),void 0,f("color","ap-color"))),U(e,"ap-bg-color",ie("背景色",Je(r.backgroundColor,x=>i({backgroundColor:x}),"背景颜色"),void 0,f("backgroundColor","ap-bg-color")))]),U(e,"ap-line-height",Re(e,"行高",r.lineHeight,x=>i({lineHeight:x||void 0}),{min:0,max:100},f("lineHeight","ap-line-height"))),U(e,"ap-letter-spacing",Re(e,"字间距",r.letterSpacing,x=>i({letterSpacing:x||void 0}),{min:0,max:20,step:.5},f("letterSpacing","ap-letter-spacing"))),U(e,"ap-text-fit",St(e,"文字溢出",Ar(o,r),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],x=>i({textFit:x}),void 0,f("textFit","ap-text-fit"))),r.textFit==="shrink"?U(e,"ap-shrink-min",ie("最小字号 (pt)",Q({value:r.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:x=>i({shrinkMinFontSize:x||void 0})}),void 0,f("shrinkMinFontSize","ap-shrink-min"))):"",o==="longText"?U(e,"ap-long-text-indent",Oe("首行缩进 (字符)",Q({value:r.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:x=>i({longTextIndent:x||void 0})}),Me("ap-long-text-indent"),f("longTextIndent","ap-long-text-indent"))):"",U(e,"ap-word-wrap",kn(e,"自动换行",r.wordWrap!==!1,x=>i({wordWrap:x?void 0:!1}),f("wordWrap","ap-word-wrap"))),U(e,"ap-keep-line-breaks",kn(e,"保留换行符",r.keepLineBreaks===!0,x=>i({keepLineBreaks:x?!0:void 0}),f("keepLineBreaks","ap-keep-line-breaks"))),w,_]:[o==="image"?U(e,"ap-img-fit",St(e,"缩放模式",String(r.fit??"contain"),Sa,x=>i({fit:x}),Me("ap-img-fit"),f("fit","ap-img-fit"))):"",o==="image"&&r.fit==="cover"?U(e,"ap-img-object-position",sf(e,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:sd(r.src),widthMm:Number(r.width)||0,heightMm:Number(r.height)||0,fit:r.fit,scale:r.fitScale,value:r.objectPosition===void 0?void 0:String(r.objectPosition),onCommit:x=>i({objectPosition:x}),onScaleCommit:x=>i({fitScale:x}),resetAnchor:f("objectPosition","ap-img-object-position"),resetScale:f("fitScale","ap-img-fit-scale")})):"",w,_,o==="flowList"?h("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),l){const x=o==="barcode",Y=String(r.barcodeType||"CODE128").toUpperCase(),le=r.printerDpi?String(r.printerDpi):"",De=ll(r.printerDpi,r.barWidth);p.push(qe(e,"code","条码设置","Postcard",[h("form",{class:"pd-form",onSubmit:G=>G.preventDefault()},[x?[U(e,"cd-type",St(e,"码制",Y,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],G=>i({barcodeType:G==="CODE128"?void 0:G}))),U(e,"cd-dpi",St(e,"打印机分辨率",le,[{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}],G=>i({printerDpi:Number(G)>0?Number(G):void 0}),void 0,f("printerDpi","cd-dpi"))),U(e,"cd-dpi",h("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),U(e,"cd-bar-width",Re(e,"条宽(倍率)",r.barWidth??2,G=>i({barWidth:G}),{min:2,max:8,step:.5},f("barWidth","cd-bar-width"))),U(e,"cd-bar-width",h("p",{class:"pd-hint",text:(le?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(De?`。${De}`:"")})),U(e,"cd-bar-quiet-zone",Oe("静区 (模块)",Q({value:r.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:G=>i({barQuietZone:G})}),Me("cd-bar-quiet-zone"),f("barQuietZone","cd-bar-quiet-zone"))),U(e,"cd-bar-height",Oe("条高 (mm)",Q({value:r.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:G=>i({barHeight:G??void 0})}),Me("cd-bar-height"),f("barHeight","cd-bar-height"))),U(e,"cd-show-text",kn(e,"显示文本",r.hideTitle!==!0,G=>i({hideTitle:G?void 0:!0}),f("hideTitle","cd-show-text"))),U(e,"cd-font-size",ie("文本字号(相对条高,条高为 30)",Q({value:r.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:G=>i({fontSize:G||void 0})}),void 0,f("fontSize","cd-font-size")))]:[U(e,"cd-ec-level",St(e,"纠错级别",String(r.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],G=>i({qrCodeLevel:G}),void 0,f("qrCodeLevel","cd-ec-level"))),U(e,"cd-quiet-zone",Oe("静区 (模块)",Q({value:r.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:G=>i({qrQuietZone:G})}),Me("cd-quiet-zone"),f("qrQuietZone","cd-quiet-zone")))],mt("自定义设置"),x?h("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",x?"":U(e,"cd-fit",St(e,"缩放模式",String(r.fit||"contain"),Sa,G=>i({fit:G||void 0}),void 0,f("fit","cd-fit"))),U(e,"cd-max-width",ie("最大宽度 (mm)",Q({value:r.maxWidth,min:1,max:200,placeholder:"默认",onCommit:G=>i({maxWidth:G||void 0})}),void 0,f("maxWidth","cd-max-width"))),U(e,"cd-max-height",ie("最大高度 (mm)",Q({value:r.maxHeight,min:1,max:200,placeholder:"默认",onCommit:G=>i({maxHeight:G||void 0})}),void 0,f("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(s&&(p.push(yw(e,t)),p.push(xw(e,t))),c&&p.push(vw(e,t)),o==="flowList"){const x=Qe(r.flowColumns),Y=Ct(r.flowRowHeight),le=rt(r.flowGapX),De=Ht(r.flowMaxSpan,x),G=uh(r.width??0,le,r.fontSize??12),me=Bt(r.flowLayoutMode),Be=me==="dynamic",ue=sn(r),Ie=(te,ne)=>{i({[te]:typeof ne=="number"&&Number.isFinite(ne)&&ne>0?ne:0})};p.push(qe(e,"flowList","流式列表","Grid3x3",[h("form",{class:"pd-form",onSubmit:te=>te.preventDefault()},[U(e,"fl-layout-mode",St(e,"布局模式",me,[{value:"fixed",label:"固定高度"},{value:"dynamic",label:"动态分页"}],te=>i({flowLayoutMode:te==="dynamic"?"dynamic":"fixed"}),Me("fl-layout-mode"))),...Be?[U(e,"fl-padding-top",Oe("上内边距 (mm)",Q({value:ue.top,min:0,max:100,step:.5,onCommit:te=>Ie("flowPaddingTop",te)}),Me("fl-padding-top"))),U(e,"fl-padding-right",Oe("右内边距 (mm)",Q({value:ue.right,min:0,max:100,step:.5,onCommit:te=>Ie("flowPaddingRight",te)}),Me("fl-padding-right"))),U(e,"fl-padding-bottom",Oe("下内边距 (mm)",Q({value:ue.bottom,min:0,max:100,step:.5,onCommit:te=>Ie("flowPaddingBottom",te)}),Me("fl-padding-bottom"))),U(e,"fl-padding-left",Oe("左内边距 (mm)",Q({value:ue.left,min:0,max:100,step:.5,onCommit:te=>Ie("flowPaddingLeft",te)}),Me("fl-padding-left")))]:[],U(e,"fl-columns",Oe("每行列数",Q({value:x,min:1,max:12,onCommit:te=>i({flowColumns:Qe(te),flowMaxSpan:Ht(r.flowMaxSpan,Qe(te))})}),Me("fl-columns"))),U(e,"fl-row-height",Oe("行高 (mm)",Q({value:Y,min:3,max:100,step:.5,onCommit:te=>i({flowRowHeight:Ct(te)})}),Me("fl-row-height"))),U(e,"fl-gap-x",Oe("单元横向间距 (mm)",Q({value:le,min:0,max:50,step:.5,onCommit:te=>i({flowGapX:rt(te)})}),Me("fl-gap-x"))),U(e,"fl-auto-span",kn(e,"内容过长时跨列",r.flowAutoSpan===!0,te=>{i(te?{flowAutoSpan:te,flowMaxSpan:De}:{flowAutoSpan:te})})),r.flowAutoSpan===!0?U(e,"fl-max-span",Oe("最多跨几列",Q({value:De,min:1,max:x,onCommit:te=>i({flowMaxSpan:Ht(te,x)})}),Me("fl-max-span"))):"",x>G?h("p",{class:"pd-hint",text:`按当前字号与框宽,${x} 列偏挤(可放约 ${G} 列)。数值保持不变,出纸按 ${x} 列排。`}):""].flat().filter(Boolean))]))}const M=()=>({borderWidth:r.borderWidth,borderStyle:r.borderStyle,borderColor:r.borderColor,borders:r.borders}),N=x=>{const Y=M();Bl(Y,x,ql(Y)),i(Y)},R=x=>{const Y=M();Ui(Y,x,!Vn(Y,x)),i(Y)},D=Ul(r),I=D.style==="mixed",S=typeof D.width=="number"?D.width:void 0,C=I||D.style===void 0?"":D.style,k=typeof D.color=="string"?D.color:void 0,$=(x,Y)=>{const le=M();hg(le,x,Y),i(le)},P=I?[{value:"",label:"混合"},...Bi]:[...Bi];return p.push(qe(e,"border-bg","边框与背景","Picture",[h("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[U(e,"bb-border-style",St(e,"线型",C,P,x=>$("borderStyle",x))),h("div",{class:"border-row"},[U(e,"bb-border-width",Re(e,"边框宽度",S,x=>$("borderWidth",x),{min:0,max:20,step:.25,placeholder:D.width==="mixed"?"混合":void 0},f("borderWidth","bb-border-width"))),U(e,"bb-border-color",ie("边框颜色",Je(k,x=>$("borderColor",x),"边框颜色"),void 0,f("borderColor","bb-border-color")))]),..._i(o)?[h("div",{class:"pd-button-group border-presets"},_w.map(x=>h("button",{type:"button",class:"pd-button small",text:x.label,disabled:x.value==="inner",onClick:()=>N(x.value)}))),h("div",{class:"pd-checkbox-group"},Mw.map(x=>h("label",{class:"pd-checkbox"},[h("input",{type:"checkbox",checked:Vn(r,x.value),onChange:()=>R(x.value)}),h("span",{text:x.label})]))),h("p",{class:"pd-hint",text:sg})]:[],U(e,"bb-bg-color",ie("背景色",Je(r.backgroundColor,x=>i({backgroundColor:x}),"背景颜色"),void 0,f("backgroundColor","bb-bg-color")))])])),p.push(ww(e,t)),p.push(qe(e,"advanced","高级设置","Setting",[h("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[h("div",{class:"advanced-row"},[U(e,"ad-locked",kn(e,"锁定",!!r.locked,x=>i({locked:x}),f("locked","ad-locked"))),U(e,"ad-fixed",kn(e,"每页重复",!!r.fixed,x=>i({fixed:x}),f("fixed","ad-fixed")))]),U(e,"ad-z-index",Re(e,"层级",r.zIndex,x=>i({zIndex:x}),{min:0,max:999},f("zIndex","ad-z-index"))),U(e,"ad-delete",h("div",{class:"pd-field"},[h("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>n.deleteSelected()})]))])],!1)),h("div",{class:"property-content"},p)}function kw(e){const t=e.store,n=t.templateData,r=c=>t.updateTemplateData(c),o=c=>{const s=n.tiling,d=p=>p===90||p===270;if(s?.enabled&&d(c)!==d(n.outputRotation)){const p=Qc({...n,outputRotation:c});r({outputRotation:c,tiling:{...s,columns:Math.max(p,1)}});return}r({outputRotation:c})},i=[];for(const[c,s]of Object.entries(dt)){const d=s.group??"其他";let p=i.find(u=>u.group===d);p||(p={group:d,items:[]},i.push(p)),p.items.push({key:c,label:s.label??c})}const a=!dt[n.paperSize],l=Fi(n.paperSize);return h("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[mt("纸张设置"),ie("纸张尺寸",h("select",{class:"pd-select",style:{width:"100%"},onChange:c=>r({paperSize:c.target.value})},[...i.map(c=>h("optgroup",{label:c.group},c.items.map(s=>h("option",{value:s.key,text:s.label,selected:n.paperSize===s.key})))),h("option",{value:"CUSTOM",text:"自定义宽高",selected:a})])),l||a?ie(l?"纸宽 (mm)":"自定义宽高 (mm)",h("div",{class:"custom-size-grid"},[Q({value:Number(n.customWidth??0),min:25,max:2e3,onCommit:c=>r({customWidth:c})}),...a?[h("span",{class:"custom-size-x",text:"×"}),Q({value:Number(n.customHeight??0),min:25,max:2e3,onCommit:c=>r({customHeight:c})})]:[]])):"",l?"":ie("纸张方向",$t("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.orientation==="landscape"?"landscape":"portrait",c=>r({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":ie("内容旋转角度",$t("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(n.outputRotation??0),c=>o(Number(c)),!0),n.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),ie("页面背景色",h("div",{class:"page-bg-row"},[Je(n.pageBackground,c=>r({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,nn({target:n,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>r({pageBackground:void 0})})),Jv(e),t.pages.length>1?"":Qv(e),mt("页边距 (mm)"),h("div",{class:"margin-grid"},[Re(e,"上",n.margins.top,c=>r({margins:{...n.margins,top:c}}),{min:0,max:50}),Re(e,"下",n.margins.bottom,c=>r({margins:{...n.margins,bottom:c}}),{min:0,max:100}),Re(e,"左",n.margins.left,c=>r({margins:{...n.margins,left:c}}),{min:0,max:50}),Re(e,"右",n.margins.right,c=>r({margins:{...n.margins,right:c}}),{min:0,max:50})]),mt("页眉/页脚高度 (mm)"),Re(e,"页眉高度",n.header.height??10,c=>r({header:{...n.header,height:c}}),{min:0,max:100,step:.1}),Re(e,"页脚高度",n.footer.height??10,c=>r({footer:{...n.footer,height:c}}),{min:0,max:100,step:.1}),Sw(e)].filter(Boolean))}function Cw(e){const t=e.store,n=e.state,r=t.selectedElement;if(n.propCollapsed)return h("div",{class:"property-panel collapsed"},[h("div",{class:"prop-collapsed"},[h("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{n.propCollapsed=!1,e.repaint()}}),...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([i,a,l])=>h("button",{type:"button",class:`pc-btn${n.propTab===i?" on":""}`,title:a,text:l,onClick:()=>{n.propTab=i,n.propCollapsed=!1,e.repaint()}}))])]);const o=r?n.propTab:"page";return h("div",{class:"property-panel"},[h("div",{class:"prop-head"},[h("span",{class:"prop-title",text:"属性台"}),h("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{n.propCollapsed=!0,e.repaint()}})]),h("div",{class:"pd-tabs prop-tabs"},[h("div",{class:"pd-tab-bar",role:"tablist"},[h("button",{type:"button",class:`pd-tab${o==="element"?" active":""}`,text:"元素属性",onClick:()=>{n.propTab="element",e.repaint()}}),h("button",{type:"button",class:`pd-tab${o==="page"?" active":""}`,text:"页面属性",onClick:()=>{n.propTab="page",e.repaint()}})]),h("div",{class:"pd-tab-pane",role:"tabpanel",style:o==="element"?"":{display:"none"}},r?[iw(e),Tw(e,r)]:[h("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),h("div",{class:"pd-tab-pane",role:"tabpanel",style:o==="page"?"":{display:"none"}},[kw(e)])])])}const Rs=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],df={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},Aw=[{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()"}],Ow=[{name:"ADD",label:"相加",template:"ADD()"},{name:"SUB",label:"相减",template:"SUB()"},{name:"MUL",label:"相乘",template:"MUL()"},{name:"DIV",label:"相除",template:"DIV()"},{name:"ROUND",label:"四舍五入",template:"ROUND()"},{name:"ROUNDUP",label:"进一法",template:"ROUNDUP()"},{name:"ROUNDDOWN",label:"去尾法",template:"ROUNDDOWN()"},{name:"ROUNDBANK",label:"四舍六入五成双",template:"ROUNDBANK()"}],Iw=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],Pw=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],Rw=[{title:"聚合函数",items:Aw},{title:"数值运算",items:Ow},{title:"格式化函数",items:Iw}],Dw="(输入表达式后预览)",$w="(无法计算)",Ds="(表达式错误)";function uf(e,t){if(!e.trim())return Dw;try{const n={...ft,...t??{},...jr()},r=gn(e,n);return r==null?$w:String(r)}catch{return Ds}}function pf(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.label.toLowerCase().includes(n)||r.name.toLowerCase().includes(n)):e}function Lw(e,t){const n=e.substring(0,t),r=n.lastIndexOf("{"),o=r!==-1&&!n.slice(r+1).includes("}"),i=n.lastIndexOf("("),a=i!==-1&&!n.slice(i+1).includes(")");return{insideBlock:o,insideParens:a}}function Nw(e,t){const n=/^\{\s*([^{}]+?)\s*\}$/.exec(e.trim());if(!n)return null;const r=n[1]??"";return t.find(o=>o.fieldKey===r)??null}function $s(e,t){return h("div",{class:"ee-field-info"},[h("span",{class:"ee-item-label",text:e}),h("span",{class:"ee-item-key",text:t})])}function _t(e){return e.currentTarget.getRootNode()}function ri(e,t,n){const r=[];return n.forEach((o,i)=>{r.push(o),i<n.length-1&&r.push(h("br"))}),h("div",{class:`ee-help-card ${e}`},[h("div",{class:"ee-help-card-title",text:t}),h("div",{class:"ee-help-card-content"},r)])}function Fw(){return h("div",{class:"ee-help-section"},[h("div",{class:"ee-help-title",text:"帮助信息"}),h("div",{class:"ee-help-grid"},[ri("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名称,当静态文本用","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),ri("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),ri("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),ri("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function zw(e,t){const n={activeTab:"field",searchText:"",expression:t.value||"",binding:t.binding,copiedFieldKey:""},r=(g,b)=>g.querySelector(b),o=g=>{const b=r(g,".ee-preview");if(!b)return;const v=uf(n.expression,e.demoData);b.textContent=v,b.classList.toggle("ee-preview-error",v===Ds)},i=()=>{if(n.activeTab==="variable")return pf(Pw,n.searchText).map(v=>h("div",{class:"ee-list-item",onDblclick:w=>{const{insideParens:_}=c(w);s(_t(w),_?v.template.replace(/^\{|\}$/g,""):v.template)}},[$s(v.label,v.template)]));if(n.activeTab==="function")return Rw.map(v=>h("div",{class:"ee-func-group"},[h("div",{class:"ee-func-group-title",text:v.title}),...pf(v.items,n.searchText).map(w=>h("div",{class:"ee-list-item",onDblclick:_=>{const{insideBlock:M}=c(_),N=M?w.template:`{${w.template}}`;s(_t(_),N,N.indexOf("(")+1)}},[$s(w.label,`${w.name}()`)]))]));const g=B0(dd(e.fields??[]),n.searchText);if(!g.length)return[h("p",{class:"pd-empty",text:"暂无字段"})];const b=[];for(const v of g){v.key&&b.push(h("div",{class:`ee-field-group${v.isList?" is-list":""}`},[h("span",{class:"ee-field-group-icon",text:v.isList?"📋":"📁"}),h("span",{text:v.label})]));for(const w of v.fields)b.push(h("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:v.key?"22px":"10px"},onDblclick:_=>{const{insideParens:M}=c(_),N=_;if(N.ctrlKey||N.metaKey){const R=w.fieldLabel||w.fieldKey;s(_t(_),M?`"${R}"`:R);return}s(_t(_),M?w.fieldKey:`{${w.fieldKey}}`)}},[$s(w.fieldLabel,w.fieldKey),h("button",{type:"button",class:`ee-copy-btn${n.copiedFieldKey===w.fieldKey?" is-copied":""}`,"data-tip":n.copiedFieldKey===w.fieldKey?"已复制":`复制字段名「${w.fieldLabel}」`,"aria-label":`复制字段名 ${w.fieldLabel}`,html:ze(n.copiedFieldKey===w.fieldKey?"Check":"Copy",13),onClick:_=>{_.stopPropagation(),l(_,w)},onDblclick:_=>_.stopPropagation()})]))}return b},a=g=>{Array.from(g.querySelectorAll(".ee-nav-tab")).forEach((M,N)=>M.classList.toggle("active",Rs[N]?.key===n.activeTab));const v=r(g,".ee-content-search .pd-input");if(v){const M=df[n.activeTab];v.placeholder!==M&&(v.placeholder=M),v.value!==n.searchText&&(v.value=n.searchText)}const w=r(g,".ee-textarea");w&&w.value!==n.expression&&(w.value=n.expression);const _=r(g,".ee-content-list");if(_){lp(_);for(const M of i())Fe(M,_)}o(g)};function l(g,b){const v=_t(g);ud(b.fieldLabel||b.fieldKey).then(w=>{w&&(n.copiedFieldKey=b.fieldKey,a(v),setTimeout(()=>{n.copiedFieldKey===b.fieldKey&&(n.copiedFieldKey="",a(v))},1200))})}const c=g=>{const v=r(_t(g),".ee-textarea")?.selectionStart??n.expression.length;return Lw(n.expression,v)},s=(g,b,v=b.length)=>{const w=r(g,".ee-textarea");if(!w){n.expression+=b,o(g);return}const _=w.selectionStart??n.expression.length,M=w.selectionEnd??_;n.expression=n.expression.substring(0,_)+b+n.expression.substring(M);const N=_+v;w.value=n.expression,w.focus(),w.selectionStart=w.selectionEnd=N,o(g)},d=()=>{const g=n.expression;if(n.binding===void 0){e.onApply({formatter:g}),e.onClose();return}const b=Nw(g,e.fields??[]);e.onApply(b?{formatter:g,binding:b.fieldKey,title:b.fieldLabel}:{formatter:g}),e.onClose()},p=h("div",{class:"ee-nav"},[h("div",{class:"ee-nav-title",text:"类型"}),h("div",{class:"ee-nav-tabs"},Rs.map((g,b)=>h("div",{class:`ee-nav-tab${n.activeTab===g.key?" active":""}`,text:g.text,onClick:v=>{n.activeTab=Rs[b].key,a(_t(v))}})))]),u=h("div",{class:"ee-content"},[h("div",{class:"ee-content-search"},[h("input",{class:"pd-input",placeholder:df[n.activeTab],onInput:g=>{n.searchText=g.target.value,a(_t(g))}})]),h("div",{class:"ee-content-list"},i())]),f=uf(n.expression,e.demoData),m=h("div",{class:"ee-editor"},[h("div",{class:"ee-editor-section"},[h("div",{class:"ee-editor-title",text:"表达式编辑"}),h("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名,或直接输入静态内容",text:n.expression,onInput:g=>{n.expression=g.target.value,o(_t(g))}})]),h("div",{class:"ee-editor-section"},[h("div",{class:"ee-editor-title",text:"预览结果"}),h("div",{class:`ee-preview${f===Ds?" ee-preview-error":""}`,text:f})]),Fw()]);return h("div",{class:"pd-dialog-overlay",onKeydown:g=>{g.key==="Escape"&&e.onClose()}},[h("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[h("header",{class:"pd-dialog-header"},[h("strong",{id:"expression-editor-title",text:"编辑表达式"}),h("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>e.onClose()})]),h("div",{class:"expression-editor"},[p,u,m]),h("footer",{class:"pd-dialog-footer"},[h("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>e.onClose()}),h("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>d()})])])])}const oi=[{id:"getting-started",title:"快速入门",content:`
261
273
  <h2>界面布局</h2>
262
274
  <p>打印模板设计器采用三栏布局:</p>
263
275
  <ul>
@@ -673,6 +685,27 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
673
685
  <p><strong>提示</strong>:水印配置保存在模板 JSON 的 <code>watermark</code> 字段中,仅对当前模板生效。</p>
674
686
  </blockquote>
675
687
  `},{id:"changelog",title:"更新记录",content:`
688
+ <h2>V1.4.5<small>(2026-11-04)</small></h2>
689
+
690
+ <h3>新增</h3>
691
+ <ul>
692
+ <li><strong>正式版发布</strong>:core / canvas / common / skills 四包均以 dist-tag <code>latest=1.4.5</code> 发布,可直接通过 <code>@latest</code> 安装;MCP 唯一链路、技能 npx 安装器、动态分页流式列表与表格按值合并等 V1.4.4 预览能力全部转正。</li>
693
+ </ul>
694
+
695
+ <h2>V1.4.4<small>(2026-11-04)</small></h2>
696
+
697
+ <h3>新增</h3>
698
+ <ul>
699
+ <li><strong>表格明细行按值纵向合并</strong>:数据行模板格打开「按值合并」后,相邻明细行该列文本相同即自动纵向合并(批次/类别/单位等重复值列),不再逐行重复显示。归并按页计算,跨页的合并段在页尾断开、下一页首行重新显示该值,分页与明细行数完全不受影响。空值与含页码的列不参与,各列独立归并,建议数据先按该列排序。</li>
700
+ <li><strong>流式列表支持动态分页容器</strong>:属性台「布局模式」选「动态」后,列表高度由内容撑开,满页后按真实文本行整行续页,文本与跨列单元不会拆行;可另设四边内边距,参与分页预算。缺省「固定」,旧模板无需迁移。本期动态块内仅支持文本。</li>
701
+ </ul>
702
+
703
+ <h3>修复</h3>
704
+ <ul>
705
+ <li><strong>明细行横向合并不再被归一误伤</strong>:数据行内单行横向合并(跨列)保持原有列数;dynamic 展开时模板上的纵向跨度不再逐行复制,表格不再错位。</li>
706
+ <li><strong>空条码在设计态显示可编码的示例值</strong>:内容与示例值都为空时,画布此前显示文字「条码」,画不出码面;现回退显示示例值 12345678,呈现真实条码图样。仅影响设计态,出纸不变。</li>
707
+ </ul>
708
+
676
709
  <h2>V1.4.3<small>(2026-11-01)</small></h2>
677
710
 
678
711
  <h3>修复</h3>
@@ -1046,6 +1079,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1046
1079
  <blockquote>
1047
1080
  <p>完整更新记录请查阅仓库 <code>docs/中文/CHANGELOG.md</code> 与 <code>docs/en/CHANGELOG.en.md</code>。</p>
1048
1081
  </blockquote>
1049
- `}],Jp="worm-print-help-tab",hw="getting-started";function Qp(e){return Yo.some(t=>t.id===e)?String(e):""}function gw(e){let t=null;try{t=window.localStorage.getItem(Jp)}catch{t=null}return Qp(t)||Qp(e)||hw}function mw(e){const t=gw(e.initialTab),n=(r,o)=>{const i=r.currentTarget,a=i.closest(".help-modal");if(!a)return;for(const c of Array.from(a.querySelectorAll(".help-tab")))c.classList.toggle("active",c===i);const l=a.querySelector(".help-content");l&&(l.innerHTML=Yo.find(c=>c.id===o)?.content??"");try{window.localStorage.setItem(Jp,o)}catch{}};return h("div",{class:"help-modal-overlay",tabindex:"-1",onClick:r=>{r.target===r.currentTarget&&e.onClose()},onKeydown:r=>{r.key==="Escape"&&e.onClose()}},[h("div",{class:"help-modal"},[h("div",{class:"help-modal-header"},[h("div",{class:"help-modal-title-wrap"},[h("h2",{class:"help-modal-title",text:"帮助文档"}),h("span",{class:"help-modal-project",text:"worm-vue3-print"})]),h("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>e.onClose()})]),h("div",{class:"help-modal-body"},[h("div",{class:"help-modal-sidebar"},Yo.map(r=>h("button",{type:"button",class:`help-tab${r.id===t?" active":""}`,text:r.title,onClick:o=>n(o,r.id)}))),h("div",{class:"help-modal-content"},[h("div",{class:"help-content",html:Yo.find(r=>r.id===t)?.content??""})])])])])}function bw(e,t){const n=De(mw(t),e),r=o=>{o.key==="Escape"&&t.onClose()};return document.addEventListener("keydown",r),n.focus?.(),()=>{document.removeEventListener("keydown",r),n.remove()}}const yw=2,vw=74,Ms=[{id:"clipboard",order:1,label:"剪贴板"},{id:"painter",order:2,label:"格式刷"},{id:"zoom",order:3,label:"缩放"},{id:"arrange-view",order:4,label:"排列 / 视图"},{id:"border",order:5,label:"边框"},{id:"color",order:6,label:"颜色"},{id:"align",order:7,label:"对齐"},{id:"style",order:8,label:"文字样式"},{id:"font",order:9,label:"字体与字号"}];function ww(e){const t=!!e.state.openMore,n=Ms.slice().sort((r,o)=>r.order-o.order).map(r=>h("div",{class:"tb-more-item",dataset:{unit:r.id},style:{display:"none"}},[h("div",{class:"tb-menu-label",text:r.label}),h("div",{class:"tb-more-slot",id:`tb-more-slot-${r.id}`,dataset:{unit:r.id}})]));return h("div",{class:"tb-group tb-more-group",style:{display:"none"}},[h("div",{class:"tb-dd"},[h("button",{type:"button",class:`tb-dd-trigger${t?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{e.state.openMore=!t,e.repaint()},html:`${Re("Ellipsis",15)}<span class="tb-btn-text">更多</span>${Re("ChevronDown",12,"tb-dd-arrow")}`}),h("div",{class:`tb-dd-panel tb-more-panel${t?"":" is-hidden"}`},[h("div",{class:"tb-menu tb-more-menu"},n)])])])}const ef=new WeakMap;function tf(e){const t=e.querySelector(".designer-toolbar");if(!t)return{movedIds:[],overflowRemains:!1};const n=getComputedStyle(t),r=Number.parseFloat(n.gap)||yw,o=Number.parseFloat(n.paddingLeft)||0,i=Number.parseFloat(n.paddingRight)||0,a=new Map;for(const m of Array.from(t.querySelectorAll(".tb-ou[data-unit]"))){const y=m.parentElement;y&&!y.classList.contains("tb-more-slot")&&ef.set(m,{parent:y,next:m.nextSibling}),a.set(m.dataset.unit,m)}for(const m of a.values()){const y=ef.get(m);!y||m.parentElement===y.parent||(y.next?.parentElement===y.parent?y.parent.insertBefore(m,y.next):y.parent.appendChild(m))}let l=0;for(const m of Array.from(t.children)){if(m.classList.contains("tb-spacer")||m.classList.contains("tb-more-group"))continue;const y=Math.max(m.offsetWidth,m.scrollWidth);y<=0||(l+=y+r)}const c=new Map;for(const[m,y]of a){const v=y.offsetWidth;v>0&&c.set(m,v)}const s=Ms.map(m=>({id:m.id,order:m.order,width:c.get(m.id)??0})),d=s.reduce((m,y)=>m-y.width-r,l),p=t.clientWidth-o-i,{movedIds:u,overflowRemains:f}=ml({available:p,pinned:d,moreTriggerWidth:vw,gap:r,units:s});for(const m of Ms){const y=t.querySelector(`.tb-more-item[data-unit="${m.id}"]`),v=t.querySelector(`#tb-more-slot-${m.id}`),w=a.get(m.id);if(!y||!v||!w)continue;const _=u.includes(m.id);_&&w.parentElement!==v&&v.appendChild(w),y.style.display=_?"":"none"}const g=t.querySelector(".tb-more-group");return g&&(g.style.display=u.length>0?"":"none"),t.classList.toggle("is-tight",f),{movedIds:u,overflowRemains:f}}function xw(e,t){const n=e.store,r=n.selectedIds.size>0,o=n.selectedIds.size>1,i=n.selectedElement,a=!r,l=e.isEdit?"编辑模板":"新建模板",c=[h("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[h("div",{class:"tb-menu-label",text:"对齐 / 分布"}),h("div",{class:"tb-menu-grid"},[be(e,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!o}),be(e,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!o}),be(e,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!o}),be(e,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!o}),be(e,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!o}),be(e,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!o}),be(e,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!o}),be(e,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!o})]),h("div",{class:"tb-menu-label",text:"层级"}),h("div",{class:"tb-menu-grid"},[be(e,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!r}),be(e,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!r}),be(e,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!r}),be(e,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!r})]),h("div",{class:"tb-menu-label",text:"组合"}),h("div",{class:"tb-menu-grid"},[be(e,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!o}),be(e,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!i?.options?.groupId})])])],s=[h("div",{class:"tb-menu tb-menu-rows",dataset:{test:"view-panel"}},[d("标尺",n.showRuler,"toggle-ruler","显示/隐藏标尺"),d("网格",n.showGrid,"toggle-grid","显示/隐藏网格背景"),d("虚框",n.showTableGhostBorder,"toggle-table-ghost-border","显示/隐藏无边框表格的虚拟虚线"),d("吸附",n.snapToGrid,"toggle-snap","开启/关闭元素吸附到网格")])];function d(p,u,f,g){return h("button",{type:"button",class:`tb-btn tb-menu-row${u?" on":""}`,dataset:{tip:g},onClick:()=>e.fire(f)},[h("span",{class:"dot"}),p])}return h("div",{class:"designer-toolbar"},[h("div",{class:"tb-group tb-brand"},[h("span",{class:"tb-mark","aria-hidden":"true",html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="3" width="14" height="18" rx="2.5" /><line x1="8.5" y1="8.5" x2="15.5" y2="8.5" /><line x1="8.5" y1="12.5" x2="15.5" y2="12.5" /><line x1="8.5" y1="16.5" x2="12.5" y2="16.5" /></svg>'}),h("div",{class:"tb-title"},[h("span",{class:"tb-title-name",text:l}),h("span",{class:"tb-title-sub",text:"打印模板设计器"})])]),h("div",{class:"tb-group"},[be(e,"Undo2","undo",{tip:"撤销",disabled:!n.canUndo}),be(e,"Redo2","redo",{tip:"重做",disabled:!n.canRedo})]),t,h("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[Uo(e,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),Uo(e,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},s)]),h("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[be(e,"Maximize","fit-window",{tip:"适应窗口"}),be(e,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),h("span",{class:"tb-zoom",text:`${n.scale}%`}),be(e,"ZoomIn","zoom",{arg:10,tip:"放大"})]),h("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[be(e,"Copy","copy",{tip:a?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:a,test:"copy"}),be(e,"ClipboardPaste","paste",{tip:a?"粘贴 (Ctrl+V),需选中元素":n.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:a||!n.hasClipboard,test:"paste"}),be(e,"Trash2","delete",{tip:a?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:a,danger:!0,test:"delete"})]),ww(e),h("div",{class:"tb-spacer"}),e.showHelp?h("div",{class:"tb-group"},[h("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>e.fire("help")},[h("span",{class:"help-icon",text:"?"})])]):"",h("div",{class:"tb-group"},[h("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>e.fire("preview")}),h("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>e.fire("save")})])].filter(Boolean))}function Ts(e,t,n){for(const r of t){const o=e.getPropertyValue(r).trim();if(o)return o}return n}function Ew(e,t){const n=t.orientation==="horizontal",r=t.geom,o=n?r.viewW:r.viewH;e.style.width=`${n?o:$i}px`,e.style.height=`${n?$i:o}px`;const i=e.getContext("2d");if(!i)return;const a=window.devicePixelRatio||1,l=Math.max(0,Math.round(o)),c=$i;e.width=(n?l:c)*a,e.height=(n?c:l)*a,i.setTransform(a,0,0,a,0,0);const s=getComputedStyle(e),d=Ts(s,["--pd-ruler-bg"],"#F8F9FC"),p=Ts(s,["--pd-ruler"],"#9AA1AF"),u=Ts(s,["--pd-ruler-cursor","--pd-accent"],"#165DFF");i.fillStyle=d,i.fillRect(0,0,n?l:c,n?c:l);const f=t.scale>0?t.scale:r.paperScale>0?r.paperScale:1,g=Lt(1)*f;if(g<=0)return;const m={ctx:i,horizontal:n,viewportPx:o,thickness:c,originPx:n?r.originX:r.originY,pxPerMM:g,paperLengthMM:t.paperLengthMM},y=-m.originPx/g,v=(l-m.originPx)/g,w=mg(f),_=vg(y,v,w);rf(m,_,p,!0),rf(m,_,p,!1),of(m,0,u),of(m,t.paperLengthMM,u);const M=t.cursorPx??null;if(M!==null&&M>=0&&M<=l){if(i.strokeStyle=u,i.lineWidth=1.5,i.beginPath(),n){const N=Math.round(M)+.5;i.moveTo(N,0),i.lineTo(N,c)}else{const N=Math.round(M)+.5;i.moveTo(0,N),i.lineTo(c,N)}i.stroke()}}function nf(e,t){return Math.round(e.originPx+t*e.pxPerMM)+.5}function rf(e,t,n,r){const{ctx:o,horizontal:i,paperLengthMM:a}=e;o.strokeStyle=n,o.fillStyle=n,o.globalAlpha=r?.32:1,o.lineWidth=1,o.font="9px ui-monospace, Menlo, monospace",o.textBaseline="top";for(const l of t){if((l.mm<0||l.mm>a)!==r)continue;const s=nf(e,l.mm),d=l.major?8:4;o.beginPath(),i?(o.moveTo(s,0),o.lineTo(s,d)):(o.moveTo(0,s),o.lineTo(d,s)),o.stroke(),l.major&&l.label&&(i?o.fillText(l.label,s+2,11):(o.save(),o.translate(11,s+2),o.rotate(-Math.PI/2),o.fillText(l.label,0,0),o.restore()))}o.globalAlpha=1}function of(e,t,n){const{ctx:r,horizontal:o,thickness:i,viewportPx:a}=e,l=nf(e,t);l<=0||l>=a||(r.strokeStyle=n,r.globalAlpha=.55,r.lineWidth=1,r.beginPath(),o?(r.moveTo(l,0),r.lineTo(l,i)):(r.moveTo(0,l),r.lineTo(i,l)),r.stroke(),r.globalAlpha=1)}const Sw=':host{display:block;width:100%;height:100%}:host{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative;justify-content:space-between;gap:6px}.pd-label-t{display:inline-flex;align-items:center;gap:4px;min-width:0}.pd-reset-btn{flex:none;width:15px;height:15px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-faint, #b4b9c4);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:color .14s ease,border-color .14s ease,background .14s ease}.pd-reset-btn.is-dirty{color:var(--pd-text, #2a2e37)}.pd-reset-btn:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-hover-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-wrap:anywhere;pointer-events:none}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select{position:relative}.font-select-input{display:block;width:100%}.font-select-list{position:absolute;top:calc(100% + 4px);left:0;width:100%;min-width:150px;z-index:200;margin:0;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));list-style:none}.font-select-list.is-up{top:auto;bottom:calc(100% + 4px)}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-meta{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;column-gap:4px;row-gap:1px}.node-label{flex:1 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{flex:0 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--pd-text-muted, #909399)}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.copy-hint{flex-shrink:0;margin-left:auto;font-size:11px;color:var(--pd-accent, #165DFF);white-space:nowrap}.left-panel{width:224px;min-width:224px;background:var(--pd-sidebar, #ffffff);border-right:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.left-panel.collapsed{width:36px;min-width:36px;border-right:1px solid var(--pd-border-soft, #e9ecf2)}.left-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.lc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.lc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.lc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.left-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.left-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.left-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.left-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.left-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.panel-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:2px 2px 8px;margin-bottom:10px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{display:flex;align-items:center;gap:10px;padding:8px 10px;margin-bottom:7px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;background:var(--pd-field-bg, #f4f6fa);cursor:grab;-webkit-user-select:none;user-select:none;transition:border-color .14s ease,background .14s ease,transform .14s ease,box-shadow .14s ease}.material-card:hover{border-color:#165dff73;background:var(--pd-surface, #ffffff);transform:translateY(-1px);box-shadow:var(--pd-shadow-sm, 0 1px 2px rgba(23, 32, 60, .05))}.material-card:active{cursor:grabbing;transform:translateY(0)}.material-icon{width:30px;height:24px;border:1px dashed var(--pd-border, #d9dde6);border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--pd-accent, #165DFF);background:var(--pd-surface, #ffffff);flex-shrink:0;transition:border-color .14s ease,background .14s ease}.material-card:hover .material-icon{border-style:solid;border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.material-label{font-size:12.5px;color:var(--pd-text, #2a2e37)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.drop-hint{position:fixed;z-index:10002;pointer-events:none;padding:2px 8px;border-radius:10px;background:var(--pd-accent, #165dff);color:#fff;font-size:12px;line-height:18px;white-space:nowrap;box-shadow:0 2px 8px #0000002e}.context-menu{position:fixed;background:var(--pd-surface, #ffffff);border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 10px 28px rgba(23, 32, 60, .12));padding:5px;z-index:10001;min-width:132px}.context-menu-item{padding:7px 12px;border-radius:5px;font-size:12.5px;cursor:pointer;color:var(--pd-text, #2a2e37);-webkit-user-select:none;user-select:none;transition:background .12s ease,color .12s ease}.context-menu-item:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.context-menu-item.disabled{color:var(--pd-text-faint, #b4b9c4);cursor:not-allowed}.context-menu-item.disabled:hover{background:transparent;color:var(--pd-text-faint, #b4b9c4)}.context-menu-sep{height:1px;background:var(--pd-border-soft, #e9ecf2);margin:5px 8px}.ruler-overlay{position:absolute;inset:0;pointer-events:none;z-index:60}.ruler-corner{position:absolute;top:0;left:0;width:22px;height:22px;background:var(--pd-ruler-bg, #f8f9fc);box-shadow:1px 1px 0 var(--pd-border-soft, #e9ecf2);z-index:2}.ruler-overlay .pd-ruler.is-horizontal{top:0;left:22px}.ruler-overlay .pd-ruler.is-vertical{top:22px;left:0}.ruler-guide-preview{position:fixed;pointer-events:none;z-index:9997}.ruler-guide-preview.guide-vertical{width:0;border-left:1px dashed var(--pd-accent, #165dff)}.ruler-guide-preview.guide-horizontal{height:0;border-top:1px dashed var(--pd-accent, #165dff)}.property-search{padding:0 0 10px;background:transparent}.property-group{border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;margin-bottom:10px;background:var(--pd-surface, #ffffff);overflow:hidden;transition:border-color .14s ease,box-shadow .14s ease}.property-group:last-child{margin-bottom:2px}.property-group.is-expanded{border-color:var(--pd-border-soft, #e9ecf2)}.group-header{display:flex;align-items:center;padding:9px 12px;cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--pd-field-bg, #f4f6fa);transition:background .14s ease}.group-header:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.property-group.is-expanded .group-header{border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.group-icon{margin-right:8px;color:var(--pd-accent, #165DFF)}.group-title{flex:1;font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.3px}.expand-icon{color:var(--pd-text-muted, #8b909c);font-size:10px}.group-content{padding:10px 12px 12px;background:var(--pd-surface, #ffffff)}.position-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-field-item{display:flex;align-items:center;gap:6px}.ee-field-item .ee-field-info{flex:1;min-width:0}.ee-copy-btn{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-muted);cursor:pointer;transition:color .15s,background .15s,border-color .15s}.ee-copy-btn:hover{background:var(--pd-surface, white);border-color:var(--pd-border);color:var(--pd-accent)}.ee-copy-btn.is-copied{color:var(--pd-success, #16a34a)}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.image-content-upload{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-top:4px}.upload-tip{margin:0;font-size:11px;color:var(--pd-text-muted, #909399)}.cell-style-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}.cell-font-field{grid-column:1 / -1;padding-bottom:8px}.border-style-row{display:flex;gap:6px;margin-bottom:8px}.border-presets{margin-bottom:8px}.merge-btns{margin-top:8px;display:flex;gap:8px}.watermark-config{padding:0 4px}.pd-hint{margin-left:8px;font-size:12px;color:#909399;min-width:32px}.design-background-config{padding:0 4px}.design-background-tip{margin:2px 0 6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #909399)}.design-background-path{margin-bottom:6px;padding:4px 6px;font-size:11px;color:var(--pd-text-regular, #606266);background:var(--pd-fill-light, #f5f7fa);border-radius:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-background-actions{display:flex;gap:6px}.upload-label{cursor:pointer}.upload-label.disabled{opacity:.6;cursor:not-allowed}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.tiling-config{padding:0 4px}.tiling-switch{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}.tiling-error{color:#f56c6c}.tiling-summary{color:var(--pd-text-regular, #606266)}.property-panel{width:280px;min-width:280px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-dirty{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;color:var(--pd-text-muted, #8b909c)}.status-dirty.on{color:var(--pd-accent-secondary, #f56c6c)}.dirty-dot{width:7px;height:7px;border-radius:50%;background:var(--pd-ink-green, #67c23a)}.status-dirty.on .dirty-dot{background:var(--pd-accent-secondary, #f56c6c);box-shadow:0 0 0 3px #f56c6c24;animation:dirty-pulse-a91952ff 1.6s ease-in-out infinite}@keyframes dirty-pulse-a91952ff{0%,to{box-shadow:0 0 0 2px #f56c6c1f}50%{box-shadow:0 0 0 4px #f56c6c0d}}@media(prefers-reduced-motion:reduce){.status-dirty.on .dirty-dot{animation:none}}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.print-html-preview-warn{position:absolute;top:8px;left:12px;z-index:2;max-width:62%;padding:4px 8px;border:1px solid #e6a23c;border-radius:4px;background:#faecd1f0;color:#b88230;font-size:12px;line-height:1.5}.print-html-preview-zoom{position:absolute;top:8px;right:12px;z-index:2;display:flex;align-items:center;gap:4px;padding:3px 4px;border:1px solid var(--pd-border-soft, #ebeef5);border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #00000014}.print-html-preview-zoom-btn{padding:2px 7px;border:0;border-radius:4px;background:transparent;color:var(--pd-text-muted, #909399);font-size:11px;line-height:18px;cursor:pointer;transition:color .14s ease,background .14s ease}.print-html-preview-zoom-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.print-html-preview-zoom-btn.active{background:var(--pd-accent, #165DFF);color:#fff;font-weight:600}.print-html-preview-zoom-note{padding-right:4px;color:var(--pd-text-muted, #909399);font-size:11px}.print-html-preview-zoom-hint{color:#b88230;font-size:11px}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}.page-tabs [data-tip]:after,.field-tree-panel [data-tip]:after{content:none}',Vo=20,_w=".page-tabs, .field-tree-panel, .pd-dialog-overlay",Mw=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),Tw={text:"formatter",longText:"formatter",flowList:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},af="print-studio:left",sf="print-studio:right";function lf(e){try{return localStorage.getItem(e)==="1"}catch{return!1}}function cf(e,t){try{localStorage.setItem(e,t?"1":"0")}catch{}}class bt extends HTMLElement{root;store;format;unsub=null;state={leftTab:"elements",leftCollapsed:!1,propTab:"page",propCollapsed:!1,openDd:null,openMore:!1,collapsedGroups:new Set,renamingPage:null};geom={originX:0,originY:0,viewW:0,viewH:0,paperScale:1};static active=null;docKeydown=null;docDragend=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};marquee={visible:!1,x:0,y:0,w:0,h:0};menu={visible:!1,x:0,y:0,flipX:0,flipY:0,targetId:null};guidePreview=null;zoneResizing=null;tableMenu={visible:!1,x:0,y:0};exprTarget=null;exprMountedFor=null;helpVisible=!1;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";uploadImage;uploadDesignBackground;_fonts;set fonts(t){this._fonts=t,this.applyFontFace(),this.repaint()}get fonts(){return this._fonts}fontFaceStyle=null;docFontFaceStyle=null;constructor(){super(),this.root=this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=Sw,this.root.appendChild(t),De(h("div",{class:"designer-container",dataset:{test:"designer-container"}}),this.root)}set template(t){this.applyTemplate(t)}get template(){return this.store?.getTemplateJson()}set fields(t){this.store.fields=(typeof t=="string"?JSON.parse(t):t)??[],this.repaint()}set isEdit(t){this.setAttribute("is-edit",String(t)),this.repaint()}set showHelp(t){this.setAttribute("show-help",String(t)),t||this.closeHelp(),this.repaint()}static get observedAttributes(){return["template","fields","name","fonts"]}attributeChangedCallback(t,n,r){if(!r)return;if(t==="name"){this.repaint();return}let o;try{o=JSON.parse(r)}catch{return}t==="template"?this.applyTemplate(o):t==="fields"?(this.store.fields=o,this.repaint()):t==="fonts"&&Array.isArray(o)&&(this.fonts=o)}connectedCallback(){if(this.store){this.applyFontFace(),this.attachDocKeys();return}const t={},n=this.getAttribute("template");if(n)try{t.initialTemplate=JSON.parse(n)}catch{}const r=this.getAttribute("fields");if(r)try{t.initialFields=JSON.parse(r)}catch{}this.store=new Zu(t),this.format=new c1(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.bindPointer(),this.bindKeys(),this.attachDocKeys(),this.applyFontFace(),this.repaint(),requestAnimationFrame(()=>this.measureRuler())}readChrome(){this.state.leftCollapsed=lf(af),this.state.propCollapsed=lf(sf),this.chromeKey=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`}persistChrome(){const t=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`;t!==this.chromeKey&&(this.chromeKey=t,cf(af,this.state.leftCollapsed),cf(sf,this.state.propCollapsed))}disconnectedCallback(){this.unsub?.(),this.unsub=null,this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,bt.active===this&&(bt.active=null),Ap(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null)}applyFontFace(){const t=Un(this._fonts);if(!t){this.fontFaceStyle?.remove(),this.fontFaceStyle=null,this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null;return}this.fontFaceStyle||(this.fontFaceStyle=document.createElement("style"),this.root.appendChild(this.fontFaceStyle)),this.fontFaceStyle.textContent=t,this.docFontFaceStyle||(this.docFontFaceStyle=document.createElement("style"),this.ownerDocument.head.appendChild(this.docFontFaceStyle)),this.docFontFaceStyle.textContent=t}templateJsonWithFonts(){const t=JSON.parse(this.store.getTemplateJson()),n=this.fonts;if(!n?.length)return t;if(Array.isArray(t.pages)){const r=t;return{...r,pages:r.pages.map(o=>({...o,fonts:[...n]}))}}return{...t,fonts:[...n]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(t){this.applyTemplate(t)}save(){const t=this.validateTemplate();if(t.length){window.alert(t[0].message),this.state.propTab="page",this.repaint();return}const n=this.getGeometryWarnings();n.length&&window.alert(`出纸提示(不影响保存):
1082
+ `}],ff="worm-print-help-tab",Bw="getting-started";function hf(e){return oi.some(t=>t.id===e)?String(e):""}function Hw(e){let t=null;try{t=window.localStorage.getItem(ff)}catch{t=null}return hf(t)||hf(e)||Bw}function Uw(e){const t=Hw(e.initialTab),n=(r,o)=>{const i=r.currentTarget,a=i.closest(".help-modal");if(!a)return;for(const c of Array.from(a.querySelectorAll(".help-tab")))c.classList.toggle("active",c===i);const l=a.querySelector(".help-content");l&&(l.innerHTML=oi.find(c=>c.id===o)?.content??"");try{window.localStorage.setItem(ff,o)}catch{}};return h("div",{class:"help-modal-overlay",tabindex:"-1",onClick:r=>{r.target===r.currentTarget&&e.onClose()},onKeydown:r=>{r.key==="Escape"&&e.onClose()}},[h("div",{class:"help-modal"},[h("div",{class:"help-modal-header"},[h("div",{class:"help-modal-title-wrap"},[h("h2",{class:"help-modal-title",text:"帮助文档"}),h("span",{class:"help-modal-project",text:"worm-vue3-print"})]),h("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>e.onClose()})]),h("div",{class:"help-modal-body"},[h("div",{class:"help-modal-sidebar"},oi.map(r=>h("button",{type:"button",class:`help-tab${r.id===t?" active":""}`,text:r.title,onClick:o=>n(o,r.id)}))),h("div",{class:"help-modal-content"},[h("div",{class:"help-content",html:oi.find(r=>r.id===t)?.content??""})])])])])}function qw(e,t){const n=Fe(Uw(t),e),r=o=>{o.key==="Escape"&&t.onClose()};return document.addEventListener("keydown",r),n.focus?.(),()=>{document.removeEventListener("keydown",r),n.remove()}}const Ww=2,jw=74,Ls=[{id:"clipboard",order:1,label:"剪贴板"},{id:"painter",order:2,label:"格式刷"},{id:"zoom",order:3,label:"缩放"},{id:"arrange-view",order:4,label:"排列 / 视图"},{id:"border",order:5,label:"边框"},{id:"color",order:6,label:"颜色"},{id:"align",order:7,label:"对齐"},{id:"style",order:8,label:"文字样式"},{id:"font",order:9,label:"字体与字号"}];function Gw(e){const t=!!e.state.openMore,n=Ls.slice().sort((r,o)=>r.order-o.order).map(r=>h("div",{class:"tb-more-item",dataset:{unit:r.id},style:{display:"none"}},[h("div",{class:"tb-menu-label",text:r.label}),h("div",{class:"tb-more-slot",id:`tb-more-slot-${r.id}`,dataset:{unit:r.id}})]));return h("div",{class:"tb-group tb-more-group",style:{display:"none"}},[h("div",{class:"tb-dd"},[h("button",{type:"button",class:`tb-dd-trigger${t?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{e.state.openMore=!t,e.repaint()},html:`${ze("Ellipsis",15)}<span class="tb-btn-text">更多</span>${ze("ChevronDown",12,"tb-dd-arrow")}`}),h("div",{class:`tb-dd-panel tb-more-panel${t?"":" is-hidden"}`},[h("div",{class:"tb-menu tb-more-menu"},n)])])])}const gf=new WeakMap;function mf(e){const t=e.querySelector(".designer-toolbar");if(!t)return{movedIds:[],overflowRemains:!1};const n=getComputedStyle(t),r=Number.parseFloat(n.gap)||Ww,o=Number.parseFloat(n.paddingLeft)||0,i=Number.parseFloat(n.paddingRight)||0,a=new Map;for(const g of Array.from(t.querySelectorAll(".tb-ou[data-unit]"))){const b=g.parentElement;b&&!b.classList.contains("tb-more-slot")&&gf.set(g,{parent:b,next:g.nextSibling}),a.set(g.dataset.unit,g)}for(const g of a.values()){const b=gf.get(g);!b||g.parentElement===b.parent||(b.next?.parentElement===b.parent?b.parent.insertBefore(g,b.next):b.parent.appendChild(g))}let l=0;for(const g of Array.from(t.children)){if(g.classList.contains("tb-spacer")||g.classList.contains("tb-more-group"))continue;const b=Math.max(g.offsetWidth,g.scrollWidth);b<=0||(l+=b+r)}const c=new Map;for(const[g,b]of a){const v=b.offsetWidth;v>0&&c.set(g,v)}const s=Ls.map(g=>({id:g.id,order:g.order,width:c.get(g.id)??0})),d=s.reduce((g,b)=>g-b.width-r,l),p=t.clientWidth-o-i,{movedIds:u,overflowRemains:f}=Cl({available:p,pinned:d,moreTriggerWidth:jw,gap:r,units:s});for(const g of Ls){const b=t.querySelector(`.tb-more-item[data-unit="${g.id}"]`),v=t.querySelector(`#tb-more-slot-${g.id}`),w=a.get(g.id);if(!b||!v||!w)continue;const _=u.includes(g.id);_&&w.parentElement!==v&&v.appendChild(w),b.style.display=_?"":"none"}const m=t.querySelector(".tb-more-group");return m&&(m.style.display=u.length>0?"":"none"),t.classList.toggle("is-tight",f),{movedIds:u,overflowRemains:f}}function Vw(e,t){const n=e.store,r=n.selectedIds.size>0,o=n.selectedIds.size>1,i=n.selectedElement,a=!r,l=e.isEdit?"编辑模板":"新建模板",c=[h("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[h("div",{class:"tb-menu-label",text:"对齐 / 分布"}),h("div",{class:"tb-menu-grid"},[we(e,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!o}),we(e,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!o}),we(e,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!o}),we(e,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!o}),we(e,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!o}),we(e,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!o}),we(e,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!o}),we(e,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!o})]),h("div",{class:"tb-menu-label",text:"层级"}),h("div",{class:"tb-menu-grid"},[we(e,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!r}),we(e,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!r}),we(e,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!r}),we(e,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!r})]),h("div",{class:"tb-menu-label",text:"组合"}),h("div",{class:"tb-menu-grid"},[we(e,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!o}),we(e,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!i?.options?.groupId})])])],s=[h("div",{class:"tb-menu tb-menu-rows",dataset:{test:"view-panel"}},[d("标尺",n.showRuler,"toggle-ruler","显示/隐藏标尺"),d("网格",n.showGrid,"toggle-grid","显示/隐藏网格背景"),d("虚框",n.showTableGhostBorder,"toggle-table-ghost-border","显示/隐藏无边框表格的虚拟虚线"),d("吸附",n.snapToGrid,"toggle-snap","开启/关闭元素吸附到网格")])];function d(p,u,f,m){return h("button",{type:"button",class:`tb-btn tb-menu-row${u?" on":""}`,dataset:{tip:m},onClick:()=>e.fire(f)},[h("span",{class:"dot"}),p])}return h("div",{class:"designer-toolbar"},[h("div",{class:"tb-group tb-brand"},[h("span",{class:"tb-mark","aria-hidden":"true",html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="3" width="14" height="18" rx="2.5" /><line x1="8.5" y1="8.5" x2="15.5" y2="8.5" /><line x1="8.5" y1="12.5" x2="15.5" y2="12.5" /><line x1="8.5" y1="16.5" x2="12.5" y2="16.5" /></svg>'}),h("div",{class:"tb-title"},[h("span",{class:"tb-title-name",text:l}),h("span",{class:"tb-title-sub",text:"打印模板设计器"})])]),h("div",{class:"tb-group"},[we(e,"Undo2","undo",{tip:"撤销",disabled:!n.canUndo}),we(e,"Redo2","redo",{tip:"重做",disabled:!n.canRedo})]),t,h("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[Qo(e,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),Qo(e,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},s)]),h("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[we(e,"Maximize","fit-window",{tip:"适应窗口"}),we(e,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),h("span",{class:"tb-zoom",text:`${n.scale}%`}),we(e,"ZoomIn","zoom",{arg:10,tip:"放大"})]),h("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[we(e,"Copy","copy",{tip:a?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:a,test:"copy"}),we(e,"ClipboardPaste","paste",{tip:a?"粘贴 (Ctrl+V),需选中元素":n.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:a||!n.hasClipboard,test:"paste"}),we(e,"Trash2","delete",{tip:a?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:a,danger:!0,test:"delete"})]),Gw(e),h("div",{class:"tb-spacer"}),e.showHelp?h("div",{class:"tb-group"},[h("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>e.fire("help")},[h("span",{class:"help-icon",text:"?"})])]):"",h("div",{class:"tb-group"},[h("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>e.fire("preview")}),h("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>e.fire("save")})])].filter(Boolean))}function Ns(e,t,n){for(const r of t){const o=e.getPropertyValue(r).trim();if(o)return o}return n}function Yw(e,t){const n=t.orientation==="horizontal",r=t.geom,o=n?r.viewW:r.viewH;e.style.width=`${n?o:Gi}px`,e.style.height=`${n?Gi:o}px`;const i=e.getContext("2d");if(!i)return;const a=window.devicePixelRatio||1,l=Math.max(0,Math.round(o)),c=Gi;e.width=(n?l:c)*a,e.height=(n?c:l)*a,i.setTransform(a,0,0,a,0,0);const s=getComputedStyle(e),d=Ns(s,["--pd-ruler-bg"],"#F8F9FC"),p=Ns(s,["--pd-ruler"],"#9AA1AF"),u=Ns(s,["--pd-ruler-cursor","--pd-accent"],"#165DFF");i.fillStyle=d,i.fillRect(0,0,n?l:c,n?c:l);const f=t.scale>0?t.scale:r.paperScale>0?r.paperScale:1,m=zt(1)*f;if(m<=0)return;const g={ctx:i,horizontal:n,viewportPx:o,thickness:c,originPx:n?r.originX:r.originY,pxPerMM:m,paperLengthMM:t.paperLengthMM},b=-g.originPx/m,v=(l-g.originPx)/m,w=kg(f),_=Og(b,v,w);yf(g,_,p,!0),yf(g,_,p,!1),vf(g,0,u),vf(g,t.paperLengthMM,u);const M=t.cursorPx??null;if(M!==null&&M>=0&&M<=l){if(i.strokeStyle=u,i.lineWidth=1.5,i.beginPath(),n){const N=Math.round(M)+.5;i.moveTo(N,0),i.lineTo(N,c)}else{const N=Math.round(M)+.5;i.moveTo(0,N),i.lineTo(c,N)}i.stroke()}}function bf(e,t){return Math.round(e.originPx+t*e.pxPerMM)+.5}function yf(e,t,n,r){const{ctx:o,horizontal:i,paperLengthMM:a}=e;o.strokeStyle=n,o.fillStyle=n,o.globalAlpha=r?.32:1,o.lineWidth=1,o.font="9px ui-monospace, Menlo, monospace",o.textBaseline="top";for(const l of t){if((l.mm<0||l.mm>a)!==r)continue;const s=bf(e,l.mm),d=l.major?8:4;o.beginPath(),i?(o.moveTo(s,0),o.lineTo(s,d)):(o.moveTo(0,s),o.lineTo(d,s)),o.stroke(),l.major&&l.label&&(i?o.fillText(l.label,s+2,11):(o.save(),o.translate(11,s+2),o.rotate(-Math.PI/2),o.fillText(l.label,0,0),o.restore()))}o.globalAlpha=1}function vf(e,t,n){const{ctx:r,horizontal:o,thickness:i,viewportPx:a}=e,l=bf(e,t);l<=0||l>=a||(r.strokeStyle=n,r.globalAlpha=.55,r.lineWidth=1,r.beginPath(),o?(r.moveTo(l,0),r.lineTo(l,i)):(r.moveTo(0,l),r.lineTo(i,l)),r.stroke(),r.globalAlpha=1)}const Xw=':host{display:block;width:100%;height:100%}:host{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative;justify-content:space-between;gap:6px}.pd-label-t{display:inline-flex;align-items:center;gap:4px;min-width:0}.pd-reset-btn{flex:none;width:15px;height:15px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-faint, #b4b9c4);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:color .14s ease,border-color .14s ease,background .14s ease}.pd-reset-btn.is-dirty{color:var(--pd-text, #2a2e37)}.pd-reset-btn:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-hover-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-wrap:anywhere;pointer-events:none}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select{position:relative}.font-select-input{display:block;width:100%}.font-select-list{position:absolute;top:calc(100% + 4px);left:0;width:100%;min-width:150px;z-index:200;margin:0;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));list-style:none}.font-select-list.is-up{top:auto;bottom:calc(100% + 4px)}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-meta{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;column-gap:4px;row-gap:1px}.node-label{flex:1 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{flex:0 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--pd-text-muted, #909399)}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.copy-hint{flex-shrink:0;margin-left:auto;font-size:11px;color:var(--pd-accent, #165DFF);white-space:nowrap}.left-panel{width:224px;min-width:224px;background:var(--pd-sidebar, #ffffff);border-right:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.left-panel.collapsed{width:36px;min-width:36px;border-right:1px solid var(--pd-border-soft, #e9ecf2)}.left-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.lc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.lc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.lc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.left-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.left-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.left-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.left-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.left-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.panel-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:2px 2px 8px;margin-bottom:10px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{display:flex;align-items:center;gap:10px;padding:8px 10px;margin-bottom:7px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;background:var(--pd-field-bg, #f4f6fa);cursor:grab;-webkit-user-select:none;user-select:none;transition:border-color .14s ease,background .14s ease,transform .14s ease,box-shadow .14s ease}.material-card:hover{border-color:#165dff73;background:var(--pd-surface, #ffffff);transform:translateY(-1px);box-shadow:var(--pd-shadow-sm, 0 1px 2px rgba(23, 32, 60, .05))}.material-card:active{cursor:grabbing;transform:translateY(0)}.material-icon{width:30px;height:24px;border:1px dashed var(--pd-border, #d9dde6);border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--pd-accent, #165DFF);background:var(--pd-surface, #ffffff);flex-shrink:0;transition:border-color .14s ease,background .14s ease}.material-card:hover .material-icon{border-style:solid;border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.material-label{font-size:12.5px;color:var(--pd-text, #2a2e37)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.drop-hint{position:fixed;z-index:10002;pointer-events:none;padding:2px 8px;border-radius:10px;background:var(--pd-accent, #165dff);color:#fff;font-size:12px;line-height:18px;white-space:nowrap;box-shadow:0 2px 8px #0000002e}.context-menu{position:fixed;background:var(--pd-surface, #ffffff);border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 10px 28px rgba(23, 32, 60, .12));padding:5px;z-index:10001;min-width:132px}.context-menu-item{padding:7px 12px;border-radius:5px;font-size:12.5px;cursor:pointer;color:var(--pd-text, #2a2e37);-webkit-user-select:none;user-select:none;transition:background .12s ease,color .12s ease}.context-menu-item:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.context-menu-item.disabled{color:var(--pd-text-faint, #b4b9c4);cursor:not-allowed}.context-menu-item.disabled:hover{background:transparent;color:var(--pd-text-faint, #b4b9c4)}.context-menu-sep{height:1px;background:var(--pd-border-soft, #e9ecf2);margin:5px 8px}.ruler-overlay{position:absolute;inset:0;pointer-events:none;z-index:60}.ruler-corner{position:absolute;top:0;left:0;width:22px;height:22px;background:var(--pd-ruler-bg, #f8f9fc);box-shadow:1px 1px 0 var(--pd-border-soft, #e9ecf2);z-index:2}.ruler-overlay .pd-ruler.is-horizontal{top:0;left:22px}.ruler-overlay .pd-ruler.is-vertical{top:22px;left:0}.ruler-guide-preview{position:fixed;pointer-events:none;z-index:9997}.ruler-guide-preview.guide-vertical{width:0;border-left:1px dashed var(--pd-accent, #165dff)}.ruler-guide-preview.guide-horizontal{height:0;border-top:1px dashed var(--pd-accent, #165dff)}.property-search{padding:0 0 10px;background:transparent}.property-group{border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;margin-bottom:10px;background:var(--pd-surface, #ffffff);overflow:hidden;transition:border-color .14s ease,box-shadow .14s ease}.property-group:last-child{margin-bottom:2px}.property-group.is-expanded{border-color:var(--pd-border-soft, #e9ecf2)}.group-header{display:flex;align-items:center;padding:9px 12px;cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--pd-field-bg, #f4f6fa);transition:background .14s ease}.group-header:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.property-group.is-expanded .group-header{border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.group-icon{margin-right:8px;color:var(--pd-accent, #165DFF)}.group-title{flex:1;font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.3px}.expand-icon{color:var(--pd-text-muted, #8b909c);font-size:10px}.group-content{padding:10px 12px 12px;background:var(--pd-surface, #ffffff)}.position-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-field-item{display:flex;align-items:center;gap:6px}.ee-field-item .ee-field-info{flex:1;min-width:0}.ee-copy-btn{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-muted);cursor:pointer;transition:color .15s,background .15s,border-color .15s}.ee-copy-btn:hover{background:var(--pd-surface, white);border-color:var(--pd-border);color:var(--pd-accent)}.ee-copy-btn.is-copied{color:var(--pd-success, #16a34a)}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.image-content-upload{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-top:4px}.upload-tip{margin:0;font-size:11px;color:var(--pd-text-muted, #909399)}.cell-style-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}.cell-font-field{grid-column:1 / -1;padding-bottom:8px}.border-style-row{display:flex;gap:6px;margin-bottom:8px}.border-presets{margin-bottom:8px}.merge-btns{display:flex;gap:8px}.merge-card{margin-top:8px;padding:8px;border:1px solid var(--pd-border, #dcdfe6);border-radius:6px}.merge-card-title{font-size:12px;font-weight:600;color:var(--pd-text, #303133);margin-bottom:8px}.merge-card-divider{height:1px;background:var(--pd-menu-divider, #ebeef5);margin:8px 0}.merge-card-hint{margin-top:6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #8b909c)}.watermark-config{padding:0 4px}.pd-hint{margin-left:8px;font-size:12px;color:#909399;min-width:32px}.design-background-config{padding:0 4px}.design-background-tip{margin:2px 0 6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #909399)}.design-background-path{margin-bottom:6px;padding:4px 6px;font-size:11px;color:var(--pd-text-regular, #606266);background:var(--pd-fill-light, #f5f7fa);border-radius:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-background-actions{display:flex;gap:6px}.upload-label{cursor:pointer}.upload-label.disabled{opacity:.6;cursor:not-allowed}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.tiling-config{padding:0 4px}.tiling-switch{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}.tiling-error{color:#f56c6c}.tiling-summary{color:var(--pd-text-regular, #606266)}.property-panel{width:280px;min-width:280px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-dirty{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;color:var(--pd-text-muted, #8b909c)}.status-dirty.on{color:var(--pd-accent-secondary, #f56c6c)}.dirty-dot{width:7px;height:7px;border-radius:50%;background:var(--pd-ink-green, #67c23a)}.status-dirty.on .dirty-dot{background:var(--pd-accent-secondary, #f56c6c);box-shadow:0 0 0 3px #f56c6c24;animation:dirty-pulse-a91952ff 1.6s ease-in-out infinite}@keyframes dirty-pulse-a91952ff{0%,to{box-shadow:0 0 0 2px #f56c6c1f}50%{box-shadow:0 0 0 4px #f56c6c0d}}@media(prefers-reduced-motion:reduce){.status-dirty.on .dirty-dot{animation:none}}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.print-html-preview-warn{position:absolute;top:8px;left:12px;z-index:2;max-width:62%;padding:4px 8px;border:1px solid #e6a23c;border-radius:4px;background:#faecd1f0;color:#b88230;font-size:12px;line-height:1.5}.print-html-preview-zoom{position:absolute;top:8px;right:12px;z-index:2;display:flex;align-items:center;gap:4px;padding:3px 4px;border:1px solid var(--pd-border-soft, #ebeef5);border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #00000014}.print-html-preview-zoom-btn{padding:2px 7px;border:0;border-radius:4px;background:transparent;color:var(--pd-text-muted, #909399);font-size:11px;line-height:18px;cursor:pointer;transition:color .14s ease,background .14s ease}.print-html-preview-zoom-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.print-html-preview-zoom-btn.active{background:var(--pd-accent, #165DFF);color:#fff;font-weight:600}.print-html-preview-zoom-note{padding-right:4px;color:var(--pd-text-muted, #909399);font-size:11px}.print-html-preview-zoom-hint{color:#b88230;font-size:11px}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}.page-tabs [data-tip]:after,.field-tree-panel [data-tip]:after{content:none}',ii=20,Kw=".page-tabs, .field-tree-panel, .pd-dialog-overlay",Zw=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),Jw={text:"formatter",longText:"formatter",flowList:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},wf="print-studio:left",xf="print-studio:right";function Ef(e){try{return localStorage.getItem(e)==="1"}catch{return!1}}function Sf(e,t){try{localStorage.setItem(e,t?"1":"0")}catch{}}class Mt extends HTMLElement{root;store;format;unsub=null;state={leftTab:"elements",leftCollapsed:!1,propTab:"page",propCollapsed:!1,openDd:null,openMore:!1,collapsedGroups:new Set,renamingPage:null};geom={originX:0,originY:0,viewW:0,viewH:0,paperScale:1};static active=null;docKeydown=null;docDragend=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};marquee={visible:!1,x:0,y:0,w:0,h:0};menu={visible:!1,x:0,y:0,flipX:0,flipY:0,targetId:null};guidePreview=null;zoneResizing=null;tableMenu={visible:!1,x:0,y:0};exprTarget=null;exprMountedFor=null;helpVisible=!1;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";uploadImage;uploadDesignBackground;_fonts;set fonts(t){this._fonts=t,this.applyFontFace(),this.repaint()}get fonts(){return this._fonts}fontFaceStyle=null;docFontFaceStyle=null;constructor(){super(),this.root=this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=Xw,this.root.appendChild(t),Fe(h("div",{class:"designer-container",dataset:{test:"designer-container"}}),this.root)}set template(t){this.applyTemplate(t)}get template(){return this.store?.getTemplateJson()}set fields(t){this.store.fields=(typeof t=="string"?JSON.parse(t):t)??[],this.repaint()}set isEdit(t){this.setAttribute("is-edit",String(t)),this.repaint()}set showHelp(t){this.setAttribute("show-help",String(t)),t||this.closeHelp(),this.repaint()}static get observedAttributes(){return["template","fields","name","fonts"]}attributeChangedCallback(t,n,r){if(!r)return;if(t==="name"){this.repaint();return}let o;try{o=JSON.parse(r)}catch{return}t==="template"?this.applyTemplate(o):t==="fields"?(this.store.fields=o,this.repaint()):t==="fonts"&&Array.isArray(o)&&(this.fonts=o)}connectedCallback(){if(this.store){this.applyFontFace(),this.attachDocKeys();return}const t={},n=this.getAttribute("template");if(n)try{t.initialTemplate=JSON.parse(n)}catch{}const r=this.getAttribute("fields");if(r)try{t.initialFields=JSON.parse(r)}catch{}this.store=new up(t),this.format=new C1(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.bindPointer(),this.bindKeys(),this.attachDocKeys(),this.applyFontFace(),this.repaint(),requestAnimationFrame(()=>this.measureRuler())}readChrome(){this.state.leftCollapsed=Ef(wf),this.state.propCollapsed=Ef(xf),this.chromeKey=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`}persistChrome(){const t=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`;t!==this.chromeKey&&(this.chromeKey=t,Sf(wf,this.state.leftCollapsed),Sf(xf,this.state.propCollapsed))}disconnectedCallback(){this.unsub?.(),this.unsub=null,this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,Mt.active===this&&(Mt.active=null),qp(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null)}applyFontFace(){const t=Zn(this._fonts);if(!t){this.fontFaceStyle?.remove(),this.fontFaceStyle=null,this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null;return}this.fontFaceStyle||(this.fontFaceStyle=document.createElement("style"),this.root.appendChild(this.fontFaceStyle)),this.fontFaceStyle.textContent=t,this.docFontFaceStyle||(this.docFontFaceStyle=document.createElement("style"),this.ownerDocument.head.appendChild(this.docFontFaceStyle)),this.docFontFaceStyle.textContent=t}templateJsonWithFonts(){const t=JSON.parse(this.store.getTemplateJson()),n=this.fonts;if(!n?.length)return t;if(Array.isArray(t.pages)){const r=t;return{...r,pages:r.pages.map(o=>({...o,fonts:[...n]}))}}return{...t,fonts:[...n]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(t){this.applyTemplate(t)}save(){const t=this.validateTemplate();if(t.length){window.alert(t[0].message),this.state.propTab="page",this.repaint();return}const n=this.getGeometryWarnings();n.length&&window.alert(`出纸提示(不影响保存):
1050
1083
  ${n.join(`
1051
- `)}`);const r=this.templateJsonWithFonts();if(Array.isArray(r.pages))try{pa(r)}catch(i){window.alert(i instanceof Error?i.message:String(i));return}const o=JSON.stringify(r);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent("save",{detail:o,bubbles:!0,composed:!0}))}validateTemplate(){const t=this.store.templateData;return t.tiling?.enabled===!0?da(t):[]}getGeometryWarnings(){return Zm(this.store.templateData)}applyTemplate(t){if(!t)return;const n=typeof t=="string"?JSON.parse(t):t;this.store?this.store.loadTemplate(n):this.setAttribute("template",JSON.stringify(n))}openExpression(t){this.exprTarget=t,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const t=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){t.forEach(r=>r.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;t.forEach(r=>r.remove());const n=this.exprTarget;De(fw({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:r=>this.applyExpression(n,r)},n),this.root),this.exprMountedFor=n}openHelp(){this.helpVisible=!0,this.syncHelp()}closeHelp(){this.helpVisible&&(this.helpVisible=!1,this.syncHelp())}syncHelp(){const t=this.helpVisible&&this.getAttribute("show-help")!=="false";if(t&&!this.unmountHelp)this.unmountHelp=bw(this.root,{onClose:()=>this.closeHelp()});else if(!t&&this.unmountHelp){const n=this.unmountHelp;this.unmountHelp=null,n()}}applyExpression(t,n){const r=n.formatter??"",o=t.targetPath;if(o.startsWith("options.")){if(o.includes("[")){const a=this.store.elements.find(l=>l.id===t.elementId);a&&bs(this.store,a,o,r);return}const i={[o.slice(8)]:r||void 0};n.title!==void 0&&(i.title=n.title),this.store.updateElement(t.elementId,i);return}if(o==="watermark.content"){const i={...this.store.templateData.watermark};xs(r)?Object.assign(i,{mode:"binding",binding:r,content:""}):Object.assign(i,{mode:"fixed",content:r,binding:""}),this.store.updateTemplateData({watermark:i})}}dblEditElement(t){const n=this.store.elements.find(o=>o.id===t);if(!n||(this.store.selectOne(t),this.state.propTab="element",n.options.locked))return;const r=Tw[n.printElementType.type];r&&this.openExpression({elementId:n.id,targetPath:`options.${r}`,value:String(n.options[r]??"")})}dblEditCell(t){const n=this.store.elements.find(l=>l.id===t.elementId);if(!n||(this.store.selectOne(n.id),this.state.propTab="element",n.options.locked))return;const r=n.options.tableRows??[],o=xi(r,t.r,t.c),a=r[o.r]?.cells[o.c];a&&this.openExpression({elementId:n.id,targetPath:`options.tableRows[${o.r}].cells[${o.c}].formatter`,value:a.formatter??""})}get ctx(){return{store:this.store,format:this.format,state:this.state,repaint:()=>this.repaint(),fire:(t,n)=>this.fire(t,n),showHelp:this.getAttribute("show-help")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts}}}canvasUi(){return{geom:this.geom,marquee:this.marquee,contextMenu:this.menu,guidePreview:this.guidePreview,zoneResizing:this.zoneResizing,scrollX:this.scrollPos.x,scrollY:this.scrollPos.y}}repaint(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.paint()}))}paint(){if(!this.store)return;const t=[...this.store.selectedIds].join(",");t!==this.lastSelKey&&(this.lastSelKey=t,this.state.propTab=t?"element":"page");const n=this.root.querySelector(".designer-container");n.classList.toggle("format-painting",this.format.painterActive),Vu(n);const r=this.ctx;De(xw(r,gv(r)),n),De(Ev(r),n),De(h("div",{class:"designer-body"},[yv(r),Xy(r,this.canvasUi()),nw(r)]),n),De(Sv(r),n),tf(n),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>tf(n)),this.toolbarRo.observe(n));const o=My(this.store,(i,a)=>this.fire(i,a),this.tableMenu);o&&De(o,n),J1(this.root,this.store.elements),qp(this.root,this.state.propSearch),this.applyShrinkFit(),this.syncRulers(),this.persistChrome()}applyShrinkFit(){for(const t of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))Gu(t);for(const t of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(t.getAttribute("data-fit")==="shrink")continue;t.removeAttribute("data-fit-size");const n=t.getAttribute("data-fit-base");n?t.style.fontSize=`${n}pt`:t.style.removeProperty("font-size")}}measureRuler(){const t=this.root.querySelector(".canvas-area"),n=this.root.querySelector(".hiprint-printPaper");if(!t||!n)return;const r=t.getBoundingClientRect(),o=n.getBoundingClientRect(),i=(this.store.scale||100)/100,a=o.width/Lt(this.store.paperSize.width);this.geom={paperScale:Math.abs(a-i)<.002?i:a,originX:o.left-r.left-Vo+this.scrollPos.x,originY:o.top-r.top-Vo+this.scrollPos.y,viewW:t.clientWidth-Vo,viewH:t.clientHeight-Vo},this.observeCanvasArea()}observeCanvasArea(){const t=this.root.querySelector(".canvas-area");!t||typeof ResizeObserver>"u"||this.roArea===t||(this.roArea=t,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(t))}syncRulers(){this.measureRuler();const t=this.store.templateData,n=_t(t),r=this.geom.paperScale;for(const o of Array.from(this.root.querySelectorAll(".pd-ruler"))){const i=o.dataset.ruler==="vertical"?"vertical":"horizontal";Ew(o,{orientation:i,geom:this.geom,scale:r,paperLengthMM:i==="horizontal"?n.width:n.height})}}patchElementDom(){for(const r of this.store.elements){const o=this.root.querySelector(`[data-el-id="${CSS.escape(r.id)}"]`);o&&(o.style.left=`${r.options.left}mm`,o.style.top=`${r.options.top}mm`,o.style.width=`${r.options.width}mm`,o.style.height=`${r.options.height}mm`)}const t=this.root.querySelector(".position-label"),n=this.store.selectedElement;t&&n&&!this.drag&&(t.textContent=Dp(n.options))}fire(t,n){const r=this.store;switch(t){case"undo":r.undo();break;case"redo":r.redo();break;case"align":r.alignSelected(n);break;case"move-layer":r.moveLayer(n);break;case"group":r.groupSelected();break;case"ungroup":r.ungroupSelected();break;case"copy":r.copy();break;case"cut":r.cutSelected();break;case"paste":r.paste();break;case"paste-at":r.paste();break;case"delete":r.deleteSelected();break;case"delete-page":r.deletePage(r.activePageIndex);break;case"add-page":r.addPage();break;case"duplicate-page":r.duplicatePage(r.activePageIndex);break;case"move-page":r.movePage(r.activePageIndex,r.activePageIndex+n);break;case"select-all":r.selectAll();break;case"clear-selection":r.clearSelection();break;case"toggle-ruler":r.showRuler=!r.showRuler,this.repaint();break;case"toggle-grid":r.showGrid=!r.showGrid,this.repaint();break;case"toggle-snap":r.snapToGrid=!r.snapToGrid,this.repaint();break;case"toggle-table-ghost-border":r.showTableGhostBorder=!r.showTableGhostBorder,this.repaint();break;case"fit-window":this.fitToWindow();break;case"zoom":this.zoomByStep(n>0?1:-1);break;case"preview":this.dispatchEvent(new CustomEvent("preview",{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent("help",{bubbles:!0,composed:!0})),this.openHelp();break;case"guide-remove":r.removeGuide(n);break;case"resize-start":this.beginResize(n);break;case"element-mousedown":{const o=n;o.event.button===0&&this.isDoubleTap(`el:${o.id}`,o.event)&&this.fire("element-dblclick",{event:o.event,id:o.id}),this.beginDrag(o);break}case"table-cell-mousedown":{const o=n;this.isDoubleTap(`cell:${o.elementId}:${o.r}:${o.c}`,o.event)&&(this.taps.delete(`el:${o.elementId}`),this.fire("table-cell-dblclick",{elementId:o.elementId,r:o.r,c:o.c,cellId:o.cellId}));break}case"zone-resize":this.beginZoneResize(n);break;case"guide-mousedown":this.beginGuideDrag(n);break;case"ruler-mousedown":this.beginRulerGuide(n);break;case"canvas-mousedown":this.onCanvasMouseDown(n);break;case"canvas-mousemove":this.onCanvasMouseMove(n);break;case"canvas-mouseleave":this.clearCoord();break;case"canvas-contextmenu":this.onContextMenu(n);break;case"contextmenu":this.onElementContextMenu(n);break;case"element-dblclick":{const{id:o}=n;this.dblEditElement(o),this.dispatchEvent(new CustomEvent("dblclick-element",{detail:o,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const o=n;this.dblEditCell(o),this.dispatchEvent(new CustomEvent("dblclick-cell",{detail:{elementId:o.elementId,r:o.r,c:o.c,cellId:o.cellId},bubbles:!0,composed:!0}));break}case"open-expression":this.openExpression(n);break;case"drop":this.onDrop(n);break;case"wheel":this.onWheel(n);break;case"scroll":this.onScroll();break}}onDrop(t){t.preventDefault();const n=t.dataTransfer,r=n?.getData("elementType"),o=n?.getData("fieldKey"),i=this.pointToPaperMm(t);if(!i)return;const a={x:i.left,y:i.top};if(r)this.store.addElement(r,{},a);else if(o){const l=this.store.fields.find(c=>c.fieldKey===o);l&&this.store.addFieldElement(l,{},a,t.ctrlKey||t.metaKey||t.labelIntent===!0)}}pointToPaperMm(t){const n=this.root.querySelector(".hiprint-printPaper");if(!n)return null;const r=n.getBoundingClientRect(),o=(this.store.scale||100)/100,i=vr((t.clientX-r.left)/o),a=vr((t.clientY-r.top)/o);return i<0||a<0?null:{left:i,top:a}}onCanvasMouseDown(t){const n=t.target;(n===this.root.querySelector(".canvas-area")||["canvas-scroll","hiprint-printPaper","hiprint-printPaper-content","zone-layer","grid-bg","watermark-layer"].some(o=>n.classList.contains(o)))&&(this.menu.visible=!1,this.state.openDd&&(this.state.openDd=null,this.repaint()),this.state.openMore&&(this.state.openMore=!1,this.repaint()),t.button===0&&(this.store.clearSelection(),this.startMarquee(t)))}onCanvasMouseMove(t){const n=this.pointToPaperMm(t),r=this.root.querySelector("[data-coord]");if(r){if(!n){r.style.display="none";return}r.style.display="",r.textContent=`x:${(n.left-this.store.templateData.margins.left).toFixed(1)} y:${(n.top-this.store.templateData.margins.top).toFixed(1)}mm`}}clearCoord(){const t=this.root.querySelector("[data-coord]");t&&(t.textContent="")}onContextMenu(t){this.openMenu(t,null)}onElementContextMenu(t){this.store.selectedIds.has(t.id)||this.store.selectOne(t.id),this.openMenu(t.event,t.id)}openMenu(t,n){this.menu.x=t.clientX,this.menu.y=t.clientY,this.menu.targetId=n,this.menu.visible=!0,this.menu.flipX=0,this.menu.flipY=0,this.repaint(),requestAnimationFrame(()=>{const r=this.root.querySelector(".context-menu");if(!r)return;const o=r.getBoundingClientRect();this.menu.flipX=o.right>window.innerWidth?window.innerWidth-o.right-8:0,this.menu.flipY=o.bottom>window.innerHeight?window.innerHeight-o.bottom-8:0,this.paint()})}startMarquee(t){const n={x:t.clientX,y:t.clientY},r=i=>{this.marquee={visible:!0,x:Math.min(n.x,i.clientX),y:Math.min(n.y,i.clientY),w:Math.abs(i.clientX-n.x),h:Math.abs(i.clientY-n.y)},this.paint()},o=()=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o);const i={...this.marquee};if(this.marquee={visible:!1,x:0,y:0,w:0,h:0},i.w>2&&i.h>2){const a=this.store.elements.filter(l=>{const c=this.root.querySelector(`[data-el-id="${CSS.escape(l.id)}"]`);if(!c)return!1;const s=c.getBoundingClientRect();return s.left<i.x+i.w&&s.right>i.x&&s.top<i.y+i.h&&s.bottom>i.y});this.store.select(new Set(a.map(l=>l.id)))}else this.repaint()};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)}taps=new Map;isDoubleTap(t,n){const r=this.taps.get(t);return this.taps.set(t,{t:n.timeStamp,x:n.clientX,y:n.clientY}),!r||n.timeStamp-r.t>=500||Math.abs(n.clientX-r.x)>6||Math.abs(n.clientY-r.y)>6?!1:(this.taps.delete(t),!0)}beginDrag(t){const n=t.event;if(n.button!==0)return;const r=this.store;n.stopPropagation();const o=r.elements.find(l=>l.id===t.id);if(!o||(r.selectElement(o.id,n.ctrlKey||n.metaKey),o.options.locked))return;const i=n.altKey?[o.id]:r.dragIds(o.id),a=new Map;for(const l of i){const c=r.elements.find(s=>s.id===l);c&&a.set(l,{left:c.options.left,top:c.options.top})}this.drag={ids:i,primary:o.id,altKey:n.altKey,movedPositions:new Map,startX:n.clientX,startY:n.clientY,origin:a,zone:o.zone||"content",moved:!1},r.draggingIds=new Set(i),r.dragStart(),this.syncDragGhost()}syncDragGhost(){const t=this.store.draggingIds;for(const n of Array.from(this.root.querySelectorAll(".print-element"))){const r=t.has(n.dataset.elId??"");n.classList.toggle("drag-ghost",r);const o=n.querySelector(":scope > .drag-preview");r&&!o?De(h("div",{class:"drag-preview"}),n):!r&&o&&o.remove()}}finishAltClone(t){const n=this.store;n.adsorbGuides=[];const r=n.elements.find(a=>a.id===t.primary),o=t.movedPositions.get(t.primary);if(n.discardLive(),!r||!o)return;const i=JSON.parse(JSON.stringify(r));i.id=an(),i.options.left=o.left,i.options.top=o.top,i.options.groupId=void 0,n.cloneElement(i)}flashSnapIndicator(t,n){const r=this.root.querySelector(".hiprint-printPaper-content");r&&(r.querySelector(".snap-indicator")?.remove(),De(h("div",{class:"snap-indicator",style:{left:`${t}mm`,top:`${n}mm`}}),r),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{r.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(t){const n=t.event;n.stopPropagation();const r=this.store.elements.find(o=>o.id===t.id);!r||r.options.locked||(this.resize={id:t.id,point:t.point,startX:n.clientX,startY:n.clientY,origin:{left:r.options.left,top:r.options.top,width:r.options.width,height:r.options.height}},this.store.dragStart())}beginZoneResize(t){t.event.stopPropagation(),t.event.preventDefault(),this.zoneResizing=t.zone;const n=t.event.clientY,r=this.store.templateData,o=t.zone==="header"?r.header.height:r.footer.height,i=(this.store.scale||100)/100,a=c=>{const s=vr((c.clientY-n)/i),d=Math.max(0,Math.round((o+(t.zone==="header"?s:-s))*10)/10);t.zone==="header"?this.store.updateTemplateData({header:{...r.header,height:d}}):this.store.updateTemplateData({footer:{...r.footer,height:d}}),this.paint()},l=()=>{window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",l),this.zoneResizing=null,this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",a),window.addEventListener("mouseup",l)}beginGuideDrag(t){const n=(this.store.templateData.guides??[]).find(d=>d.id===t.id);if(!n)return;const r=_t(this.store.templateData),o=n.type==="vertical"?r.width:r.height,i=t.event.clientX,a=t.event.clientY,l=(this.store.scale||100)/100,c=d=>{const p=vr((n.type==="vertical"?d.clientX-i:d.clientY-a)/l);this.store.moveGuide(n.id,Math.min(o,Math.max(0,n.position+p))),this.paint()},s=()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",s),this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",s)}beginRulerGuide(t){const n=t.orientation==="horizontal"?"vertical":"horizontal",r=i=>{this.guidePreview={type:n,position:n==="vertical"?i.clientX:i.clientY},this.paint()},o=i=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o);const a=this.rulerPointToMM(i,n);this.guidePreview=null,a!==null?this.store.addGuide(n,a):this.repaint()};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)}rulerPointToMM(t,n){const r=this.root.querySelector(".hiprint-printPaper");if(!r)return null;const o=r.getBoundingClientRect(),i=Lt(1)*(this.geom.paperScale||1),a=n==="vertical"?(t.clientX-o.left)/i:(t.clientY-o.top)/i,l=_t(this.store.templateData),c=n==="vertical"?l.width:l.height;return a<0||a>c?null:a}applyZoom(t,n,r,o){const i=this.root.querySelector(".canvas-area");if(!i)return;const a=Math.round(this.store.scale),l=Math.max(o,Math.round(t));if(l===a)return;const c=getComputedStyle(i),s=parseFloat(c.paddingLeft)||0,d=parseFloat(c.paddingTop)||0,p=i.scrollLeft+n-s,u=i.scrollTop+r-d,f=l/a;this.store.setScale(l,o),i.scrollLeft=p*f-n+s,i.scrollTop=u*f-r+d}zoomByStep(t){const n=this.root.querySelector(".canvas-area");n&&this.applyZoom(gl(this.store.scale,t),n.clientWidth/2,n.clientHeight/2,Tr)}fitToWindow(){const t=this.root.querySelector(".canvas-area");if(!t)return;const n=getComputedStyle(t),r=(parseFloat(n.paddingLeft)||0)+(parseFloat(n.paddingRight)||0),o=(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0),i=_t(this.store.templateData),a=_h(t.clientWidth-r,t.clientHeight-o,Lt(i.width),Lt(i.height));this.applyZoom(a,t.clientWidth/2,t.clientHeight/2,hl)}onWheel(t){if(!t.ctrlKey&&!t.metaKey)return;t.preventDefault();const n=this.root.querySelector(".canvas-area");if(!n)return;const r=Math.round(this.store.scale),o=gl(r,t.deltaY>0?-1:1);if(o===r)return;const i=n.getBoundingClientRect();this.applyZoom(o,t.clientX-i.left,t.clientY-i.top,Tr)}onScroll(){const t=this.root.querySelector(".canvas-area");t&&(this.scrollPos={x:t.scrollLeft,y:t.scrollTop},this.syncRulers())}bindPointer(){window.addEventListener("mousemove",t=>{const n=this.store;if(!n)return;const o=((n.scale||100)/100||1)*Lt(1),i=(a,l)=>({dx:a/o,dy:l/o});if(this.drag){const{dx:a,dy:l}=i(t.clientX-this.drag.startX,t.clientY-this.drag.startY);(Math.abs(a)>.05||Math.abs(l)>.05)&&(this.drag.moved=!0);const c=n.elements.find(g=>g.id===this.drag.primary),s=c&&{id:c.id,left:(this.drag.origin.get(c.id)?.left??0)+a,top:(this.drag.origin.get(c.id)?.top??0)+l,width:c.options.width,height:c.options.height};let d=null;if(s&&n.snapToGrid!==!1){const g=n.elements.filter(v=>!this.drag.ids.includes(v.id)&&(v.zone||"content")===this.drag.zone).map(v=>({id:v.id,left:v.options.left,top:v.options.top,width:v.options.width,height:v.options.height})),m=ss(n.templateData,n.paperSize)[this.drag.zone],y=T0(s,g,this.manualGuides());d={left:y.left,top:y.top},n.adsorbGuides=(y.lines??[]).filter(v=>v.position>=0&&v.position<=(v.type==="vertical"?m.width:m.height)),(d.left!==s.left||d.top!==s.top)&&this.flashSnapIndicator(d.left+s.width/2,d.top+s.height/2)}else n.adsorbGuides=[];const p=c?this.drag.origin.get(c.id):void 0,u=d&&p?d.left-p.left:a,f=d&&p?d.top-p.top:l;for(const g of this.drag.ids){const m=this.drag.origin.get(g);if(!m)continue;const y={left:m.left+u,top:m.top+f};this.drag.movedPositions.set(g,y),n.livePatch(g,y)}this.patchElementDom(),n.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:a,dy:l}=i(t.clientX-this.resize.startX,t.clientY-this.resize.startY),c=O0(this.resize.point,this.resize.origin,a,l,3.5,3.5);n.livePatch(this.resize.id,c),this.patchElementDom()}}),window.addEventListener("mouseup",()=>{const t=!!this.drag,n=this.drag;if(n?.moved&&n.altKey){this.finishAltClone(n),this.store.dragStop(),this.drag=null,this.store.draggingIds=new Set,this.repaint();return}this.drag?.moved||this.resize?(this.store.adsorbGuides=[],this.store.commitLive(),this.store.dragStop(),this.drag=null,this.resize=null,this.store.draggingIds=new Set,this.repaint()):(this.drag=null,this.store.dragStop(),t&&(this.store.draggingIds=new Set,this.syncDragGhost()))}),this.addEventListener("pointerdown",t=>{const n=t.composedPath(),r=n.some(i=>i.classList?.contains("tb-dd"));this.state.openDd&&!r&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!r&&(this.state.openMore=!1,this.repaint());const o=n.some(i=>i.classList?.contains("context-menu"));this.menu.visible&&!o&&(this.menu.visible=!1,this.repaint())}),this.root.addEventListener("mouseover",t=>{const r=t.target?.closest?.("[data-tip]");!r||!r.closest(_w)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(r),300))}),this.root.addEventListener("mouseout",t=>{const n=t,r=n.target?.closest?.("[data-tip]");r&&n.relatedTarget?.closest?.("[data-tip]")!==r&&this.hideHoverTip()})}showHoverTip(t){const n=t.dataset.tip;if(!n)return;this.hideHoverTip();const r=t.getBoundingClientRect(),o=r.left+r.width/2;this.hoverTipEl=De(h("div",{class:"pd-hover-tip",style:{left:`${o}px`,top:`${r.bottom+6}px`},text:n}),this.root);const i=this.hoverTipEl.offsetWidth/2;if(!i)return;const a=i+8,l=Math.max(window.innerWidth-i-8,a);this.hoverTipEl.style.left=`${Math.min(Math.max(o,a),l)}px`}hideHoverTip(){this.hoverTipTimer&&(clearTimeout(this.hoverTipTimer),this.hoverTipTimer=null),this.hoverTipEl?.remove(),this.hoverTipEl=null}manualGuides(){const t=[],n=[];for(const r of this.store.templateData.guides??[])r.type==="vertical"?t.push(r.position):n.push(r.position);return{vertical:t,horizontal:n}}paintGuidesOnly(){const t=this.root.querySelector(".hiprint-printPaper-content");if(!t)return;for(const r of Array.from(t.querySelectorAll(".adsorb-guide")))r.remove();const n=this.store.paperSize;ss(this.store.templateData,n);for(const r of this.store.adsorbGuides){const o=document.createElement("div");o.className=`adsorb-guide guide-${r.type}`,r.type==="vertical"?o.style.cssText=`left:${r.position}mm;top:0;height:${n.height}mm;border-left-color:${r.color||"var(--pd-accent-secondary, #f56c6c)"}`:o.style.cssText=`top:${r.position}mm;left:0;width:${n.width}mm;border-top-color:${r.color||"var(--pd-accent-secondary, #f56c6c)"}`,t.appendChild(o)}}bindKeys(){this.setAttribute("tabindex","0");const t=()=>{bt.active=this};this.addEventListener("pointerdown",t),this.addEventListener("focusin",t),bt.active||(bt.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=t=>this.onGlobalKeydown(t),document.addEventListener("keydown",this.docKeydown),this.docDragend=()=>$p(this.root?.querySelector(".canvas-area")),document.addEventListener("dragend",this.docDragend,!0))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null,this.docDragend&&(document.removeEventListener("dragend",this.docDragend,!0),this.docDragend=null))}onGlobalKeydown(t){const n=this.store;if(!n||bt.active!==this)return;const o=t.composedPath()[0]?.tagName;if(o==="INPUT"||o==="TEXTAREA"||o==="SELECT")return;if(this.format.handlePainterKeydown(t),t.key.startsWith("Arrow")){t.preventDefault();const a=t.shiftKey?10:t.ctrlKey?.5:1,l=t.key==="ArrowLeft"?-a:t.key==="ArrowRight"?a:0,c=t.key==="ArrowUp"?-a:t.key==="ArrowDown"?a:0;n.moveSelected(l,c);return}if(t.key==="Delete"||t.key==="Backspace"){t.preventDefault(),n.deleteSelected();return}if(!(t.ctrlKey||t.metaKey))return;const i=t.key.toLowerCase();Mw.has(i)&&(t.preventDefault(),i==="z"?t.shiftKey?n.redo():n.undo():i==="y"?n.redo():i==="a"?n.selectAll():i==="c"?n.copy():i==="x"?n.cutSelected():i==="v"?n.paste():i==="d"?n.duplicateSelected():i==="g"?t.shiftKey?n.ungroupSelected():n.groupSelected():i==="1"?n.resetZoom():i==="l"?n.alignSelected("left"):i==="r"?n.alignSelected("right"):i==="e"?n.alignSelected("vertical"):i==="t"?n.alignSelected("top"):i==="b"?n.alignSelected("bottom"):i==="0"&&this.fire("fit-window"))}}function df(e="print-designer"){return customElements.get(e)||customElements.define(e,bt),e}function kw(){return df()}const Cw=Object.freeze(Object.defineProperty({__proto__:null,DesignerStore:Zu,PrintDesignerElement:bt,TILING_SINGLE_PAGE_TIP:Wa,createDefaultTemplate:ir,definePrintDesigner:df,registerAll:kw,serializePage:Ku,toRuntimePool:ja},Symbol.toStringTag,{value:"Module"})),Aw=17521,Ow=20,ks={PRINTERS_LIST:"printers.list",PRINT_SUBMIT:"print.submit",PRINT_SUBMIT_HTML:"print.submitHtml"};let Cs=0;function Iw(){return Cs=(Cs+1)%Number.MAX_SAFE_INTEGER,`${Date.now().toString(36)}-${Cs.toString(36)}`}function uf(e,t){const n={id:Iw(),type:e,payload:t};return JSON.stringify(n)}function pf(e){let t;try{t=JSON.parse(e)}catch{return{malformed:!0}}if(typeof t!="object"||t===null)return{malformed:!0};const n=t;if(typeof n.id!="string"||typeof n.ok!="boolean")return{malformed:!0};if(n.ok)return{id:n.id,ok:!0,payload:n.payload??{}};const r=n.error;return!r||typeof r.code!="string"||typeof r.message!="string"?{malformed:!0}:{id:n.id,ok:!1,error:{code:r.code,message:r.message}}}class yt extends Error{constructor(t,n){super(n),this.name="WormPrintError",this.code=t}}class ff extends Error{constructor(t){super(t),this.code="UNAUTHORIZED",this.name="AuthRejectedError"}}class Pw{constructor(t={}){this.ws=null,this.status_="disconnected",this.hello=null,this.pendings=new Map,this.statusCbs=new Set,this.manualClose=!1,this.reconnectTimer=null,this.reconnectAttempts=0,this.opts=t,this.ctor=t.WebSocketCtor??WebSocket,this.defaultTimeout=t.timeoutMs??15e3}get status(){return this.status_}onStatus(t){return this.statusCbs.add(t),()=>this.statusCbs.delete(t)}setToken(t){this.opts={...this.opts,token:t}}async connect(t){if(this.status_==="connected"&&this.hello)return this.hello;this.setStatus("connecting");const n=this.opts.ports??Array.from({length:Ow},(r,o)=>Aw+o);for(const r of n){if(t?.aborted)throw new yt("CLIENT_NOT_RUNNING","连接已取消");try{return this.hello=await this.tryPort(r,t),this.manualClose=!1,this.reconnectAttempts=0,this.setStatus("connected"),this.hello}catch(o){if(o instanceof ff)throw this.setStatus("disconnected"),new yt("UNAUTHORIZED",o.message||"配对 token 无效或来源未授权")}}throw this.setStatus("disconnected"),new yt("CLIENT_NOT_RUNNING","未发现运行中的打印客户端(已探测默认端口区间),请确认客户端已启动")}request(t,n,r){if(this.status_!=="connected"||!this.ws)return Promise.reject(new yt("CLIENT_NOT_RUNNING","打印客户端未连接"));const o=uf(t,n),i=JSON.parse(o);return new Promise((a,l)=>{const c=setTimeout(()=>{this.pendings.delete(i.id),l(new yt("CLIENT_TIMEOUT",`请求 ${t} 超时未响应`))},r??this.defaultTimeout);this.pendings.set(i.id,{resolve:a,reject:l,timer:c}),this.ws.send(o)})}close(){this.manualClose=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.ws?.close(),this.failAllPendings(new yt("CLIENT_NOT_RUNNING","连接已关闭")),this.setStatus("disconnected")}buildUrl(t){const n=new URL(`ws://127.0.0.1:${t}`);return this.opts.token&&n.searchParams.set("token",this.opts.token),n.toString().replace(/\/$/,"")}tryPort(t,n){return new Promise((r,o)=>{const i=new this.ctor(this.buildUrl(t));this.ws=i;let a=!1;const l=()=>{a||(a=!0,o(new Error("aborted")))};n?.addEventListener("abort",l,{once:!0}),i.onopen=()=>{i.send(uf("hello",{}))},i.onmessage=c=>{const s=pf(String(c.data));if(!("malformed"in s))if(s.ok&&Dw(s.payload)){if(a)return;a=!0,this.bindLifecycle(i),r(s.payload)}else if(!s.ok&&s.error.code==="UNAUTHORIZED"){if(a)return;a=!0,o(new ff(s.error.message))}else a||(a=!0,o(new Error("握手失败")))},i.onerror=()=>{a||(a=!0,o(new Error("连接错误")))},i.onclose=()=>{a||(a=!0,o(new Error("连接关闭")))}})}bindLifecycle(t){t.onmessage=n=>{const r=pf(String(n.data));if("malformed"in r)return;const o=this.pendings.get(r.id);o&&(this.pendings.delete(r.id),clearTimeout(o.timer),r.ok?o.resolve(r.payload):o.reject(new yt(r.error.code,r.error.message)))},t.onclose=()=>{this.failAllPendings(new yt("CLIENT_NOT_RUNNING","与客户端的连接中断")),this.hello=null,this.ws=null,this.manualClose||this.scheduleReconnect()},t.onerror=()=>{}}scheduleReconnect(){this.setStatus("connecting");const t=Math.min(1e3*2**this.reconnectAttempts++,1e4);this.reconnectTimer=setTimeout(()=>{this.connect().catch(()=>this.scheduleReconnect())},t)}failAllPendings(t){for(const[,n]of this.pendings)clearTimeout(n.timer),n.reject(t);this.pendings.clear()}setStatus(t){if(this.status_!==t){this.status_=t;for(const n of this.statusCbs)n(t)}}}function Dw(e){return typeof e=="object"&&e!==null&&e.app==="worm-print-client"}const hf="worm-print-client:token";class As{constructor(t={}){const r={token:t.token??As.loadStoredToken()??void 0,timeoutMs:t.timeoutMs,WebSocketCtor:t.WebSocketCtor};this.transport=new Pw(r)}get status(){return this.transport.status}connect(t){return this.transport.connect(t)}onStatusChange(t){return this.transport.onStatus(t)}async listPrinters(){return(await this.transport.request(ks.PRINTERS_LIST,{})).printers}print(t,n,r={},o){const{baseUrl:i,fontBaseUrl:a,timeoutMs:l,...c}=r,s={templateJson:t,printData:n,baseUrl:i,fontBaseUrl:a,print:c};return typeof o=="string"&&o.trim().length>0&&(s.templateName=o),this.transport.request(ks.PRINT_SUBMIT,s,l)}printHtml(t,n={},r){const{timeoutMs:o,...i}=n,a={html:t.html,paperMm:t.paperMm,continuous:t.continuous,pageCount:t.pageCount,print:i};return typeof r=="string"&&r.trim().length>0&&(a.templateName=r),this.transport.request(ks.PRINT_SUBMIT_HTML,a,o)}pair(t){localStorage.setItem(hf,t),this.transport.setToken(t)}static loadStoredToken(){try{return localStorage.getItem(hf)}catch{return null}}close(){this.transport.close()}}const Rw={...Cw,renderHtmlPages:t1,browserCodeRenderer:Ha,PrintClient:As,WormPrintError:yt,getPaperDimensions:Ze,isContinuousPaperSize:tn,getByPath:zn,resolvePrinterDpi:ag,paperWidthPx:sg,zoomPresets:cg,defaultZoomKey:$l,resolveZoomKey:pg,zoomValueOf:fg,viewZoomHint:dg,applyPreviewViewZoom:ug,resolveToolbarOverflow:ml};globalThis.WormPrintCommon??=Rw}));
1084
+ `)}`);const r=this.templateJsonWithFonts();if(Array.isArray(r.pages))try{Ea(r)}catch(i){window.alert(i instanceof Error?i.message:String(i));return}const o=JSON.stringify(r);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent("save",{detail:o,bubbles:!0,composed:!0}))}validateTemplate(){const t=this.store.templateData;return t.tiling?.enabled===!0?wa(t):[]}getGeometryWarnings(){return m0(this.store.templateData)}applyTemplate(t){if(!t)return;const n=typeof t=="string"?JSON.parse(t):t;this.store?this.store.loadTemplate(n):this.setAttribute("template",JSON.stringify(n))}openExpression(t){this.exprTarget=t,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const t=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){t.forEach(r=>r.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;t.forEach(r=>r.remove());const n=this.exprTarget;Fe(zw({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:r=>this.applyExpression(n,r)},n),this.root),this.exprMountedFor=n}openHelp(){this.helpVisible=!0,this.syncHelp()}closeHelp(){this.helpVisible&&(this.helpVisible=!1,this.syncHelp())}syncHelp(){const t=this.helpVisible&&this.getAttribute("show-help")!=="false";if(t&&!this.unmountHelp)this.unmountHelp=qw(this.root,{onClose:()=>this.closeHelp()});else if(!t&&this.unmountHelp){const n=this.unmountHelp;this.unmountHelp=null,n()}}applyExpression(t,n){const r=n.formatter??"",o=t.targetPath;if(o.startsWith("options.")){if(o.includes("[")){const a=this.store.elements.find(l=>l.id===t.elementId);a&&Cs(this.store,a,o,r);return}const i={[o.slice(8)]:r||void 0};n.title!==void 0&&(i.title=n.title),this.store.updateElement(t.elementId,i);return}if(o==="watermark.content"){const i={...this.store.templateData.watermark};Ps(r)?Object.assign(i,{mode:"binding",binding:r,content:""}):Object.assign(i,{mode:"fixed",content:r,binding:""}),this.store.updateTemplateData({watermark:i})}}dblEditElement(t){const n=this.store.elements.find(o=>o.id===t);if(!n||(this.store.selectOne(t),this.state.propTab="element",n.options.locked))return;const r=Jw[n.printElementType.type];r&&this.openExpression({elementId:n.id,targetPath:`options.${r}`,value:String(n.options[r]??"")})}dblEditCell(t){const n=this.store.elements.find(l=>l.id===t.elementId);if(!n||(this.store.selectOne(n.id),this.state.propTab="element",n.options.locked))return;const r=n.options.tableRows??[],o=Wn(r,t.r,t.c),a=r[o.r]?.cells[o.c];a&&this.openExpression({elementId:n.id,targetPath:`options.tableRows[${o.r}].cells[${o.c}].formatter`,value:a.formatter??""})}get ctx(){return{store:this.store,format:this.format,state:this.state,repaint:()=>this.repaint(),fire:(t,n)=>this.fire(t,n),showHelp:this.getAttribute("show-help")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts}}}canvasUi(){return{geom:this.geom,marquee:this.marquee,contextMenu:this.menu,guidePreview:this.guidePreview,zoneResizing:this.zoneResizing,scrollX:this.scrollPos.x,scrollY:this.scrollPos.y}}repaint(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.paint()}))}paint(){if(!this.store)return;const t=[...this.store.selectedIds].join(",");t!==this.lastSelKey&&(this.lastSelKey=t,this.state.propTab=t?"element":"page");const n=this.root.querySelector(".designer-container");n.classList.toggle("format-painting",this.format.painterActive),lp(n);const r=this.ctx;Fe(Vw(r,Hv(r)),n),Fe(Yv(r),n),Fe(h("div",{class:"designer-body"},[Wv(r),Ev(r,this.canvasUi()),Cw(r)]),n),Fe(Xv(r),n),mf(n),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>mf(n)),this.toolbarRo.observe(n));const o=jy(this.store,(i,a)=>this.fire(i,a),this.tableMenu);o&&Fe(o,n),by(this.root,this.store.elements),rf(this.root,this.state.propSearch),this.applyShrinkFit(),this.syncRulers(),this.persistChrome()}applyShrinkFit(){for(const t of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))ap(t);for(const t of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(t.getAttribute("data-fit")==="shrink")continue;t.removeAttribute("data-fit-size");const n=t.getAttribute("data-fit-base");n?t.style.fontSize=`${n}pt`:t.style.removeProperty("font-size")}}measureRuler(){const t=this.root.querySelector(".canvas-area"),n=this.root.querySelector(".hiprint-printPaper");if(!t||!n)return;const r=t.getBoundingClientRect(),o=n.getBoundingClientRect(),i=(this.store.scale||100)/100,a=o.width/zt(this.store.paperSize.width);this.geom={paperScale:Math.abs(a-i)<.002?i:a,originX:o.left-r.left-ii+this.scrollPos.x,originY:o.top-r.top-ii+this.scrollPos.y,viewW:t.clientWidth-ii,viewH:t.clientHeight-ii},this.observeCanvasArea()}observeCanvasArea(){const t=this.root.querySelector(".canvas-area");!t||typeof ResizeObserver>"u"||this.roArea===t||(this.roArea=t,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(t))}syncRulers(){this.measureRuler();const t=this.store.templateData,n=It(t),r=this.geom.paperScale;for(const o of Array.from(this.root.querySelectorAll(".pd-ruler"))){const i=o.dataset.ruler==="vertical"?"vertical":"horizontal";Yw(o,{orientation:i,geom:this.geom,scale:r,paperLengthMM:i==="horizontal"?n.width:n.height})}}patchElementDom(){for(const r of this.store.elements){const o=this.root.querySelector(`[data-el-id="${CSS.escape(r.id)}"]`);o&&(o.style.left=`${r.options.left}mm`,o.style.top=`${r.options.top}mm`,o.style.width=`${r.options.width}mm`,o.style.height=`${r.options.height}mm`)}const t=this.root.querySelector(".position-label"),n=this.store.selectedElement;t&&n&&!this.drag&&(t.textContent=Vp(n.options))}fire(t,n){const r=this.store;switch(t){case"undo":r.undo();break;case"redo":r.redo();break;case"align":r.alignSelected(n);break;case"move-layer":r.moveLayer(n);break;case"group":r.groupSelected();break;case"ungroup":r.ungroupSelected();break;case"copy":r.copy();break;case"cut":r.cutSelected();break;case"paste":r.paste();break;case"paste-at":r.paste();break;case"delete":r.deleteSelected();break;case"delete-page":r.deletePage(r.activePageIndex);break;case"add-page":r.addPage();break;case"duplicate-page":r.duplicatePage(r.activePageIndex);break;case"move-page":r.movePage(r.activePageIndex,r.activePageIndex+n);break;case"select-all":r.selectAll();break;case"clear-selection":r.clearSelection();break;case"toggle-ruler":r.showRuler=!r.showRuler,this.repaint();break;case"toggle-grid":r.showGrid=!r.showGrid,this.repaint();break;case"toggle-snap":r.snapToGrid=!r.snapToGrid,this.repaint();break;case"toggle-table-ghost-border":r.showTableGhostBorder=!r.showTableGhostBorder,this.repaint();break;case"fit-window":this.fitToWindow();break;case"zoom":this.zoomByStep(n>0?1:-1);break;case"preview":this.dispatchEvent(new CustomEvent("preview",{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent("help",{bubbles:!0,composed:!0})),this.openHelp();break;case"guide-remove":r.removeGuide(n);break;case"resize-start":this.beginResize(n);break;case"element-mousedown":{const o=n;o.event.button===0&&this.isDoubleTap(`el:${o.id}`,o.event)&&this.fire("element-dblclick",{event:o.event,id:o.id}),this.beginDrag(o);break}case"table-cell-mousedown":{const o=n;this.isDoubleTap(`cell:${o.elementId}:${o.r}:${o.c}`,o.event)&&(this.taps.delete(`el:${o.elementId}`),this.fire("table-cell-dblclick",{elementId:o.elementId,r:o.r,c:o.c,cellId:o.cellId}));break}case"zone-resize":this.beginZoneResize(n);break;case"guide-mousedown":this.beginGuideDrag(n);break;case"ruler-mousedown":this.beginRulerGuide(n);break;case"canvas-mousedown":this.onCanvasMouseDown(n);break;case"canvas-mousemove":this.onCanvasMouseMove(n);break;case"canvas-mouseleave":this.clearCoord();break;case"canvas-contextmenu":this.onContextMenu(n);break;case"contextmenu":this.onElementContextMenu(n);break;case"element-dblclick":{const{id:o}=n;this.dblEditElement(o),this.dispatchEvent(new CustomEvent("dblclick-element",{detail:o,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const o=n;this.dblEditCell(o),this.dispatchEvent(new CustomEvent("dblclick-cell",{detail:{elementId:o.elementId,r:o.r,c:o.c,cellId:o.cellId},bubbles:!0,composed:!0}));break}case"open-expression":this.openExpression(n);break;case"drop":this.onDrop(n);break;case"wheel":this.onWheel(n);break;case"scroll":this.onScroll();break}}onDrop(t){t.preventDefault();const n=t.dataTransfer,r=n?.getData("elementType"),o=n?.getData("fieldKey"),i=this.pointToPaperMm(t);if(!i)return;const a={x:i.left,y:i.top};if(r)this.store.addElement(r,{},a);else if(o){const l=this.store.fields.find(c=>c.fieldKey===o);l&&this.store.addFieldElement(l,{},a,t.ctrlKey||t.metaKey||t.labelIntent===!0)}}pointToPaperMm(t){const n=this.root.querySelector(".hiprint-printPaper");if(!n)return null;const r=n.getBoundingClientRect(),o=(this.store.scale||100)/100,i=Cr((t.clientX-r.left)/o),a=Cr((t.clientY-r.top)/o);return i<0||a<0?null:{left:i,top:a}}onCanvasMouseDown(t){const n=t.target;(n===this.root.querySelector(".canvas-area")||["canvas-scroll","hiprint-printPaper","hiprint-printPaper-content","zone-layer","grid-bg","watermark-layer"].some(o=>n.classList.contains(o)))&&(this.menu.visible=!1,this.state.openDd&&(this.state.openDd=null,this.repaint()),this.state.openMore&&(this.state.openMore=!1,this.repaint()),t.button===0&&(this.store.clearSelection(),this.startMarquee(t)))}onCanvasMouseMove(t){const n=this.pointToPaperMm(t),r=this.root.querySelector("[data-coord]");if(r){if(!n){r.style.display="none";return}r.style.display="",r.textContent=`x:${(n.left-this.store.templateData.margins.left).toFixed(1)} y:${(n.top-this.store.templateData.margins.top).toFixed(1)}mm`}}clearCoord(){const t=this.root.querySelector("[data-coord]");t&&(t.textContent="")}onContextMenu(t){this.openMenu(t,null)}onElementContextMenu(t){this.store.selectedIds.has(t.id)||this.store.selectOne(t.id),this.openMenu(t.event,t.id)}openMenu(t,n){this.menu.x=t.clientX,this.menu.y=t.clientY,this.menu.targetId=n,this.menu.visible=!0,this.menu.flipX=0,this.menu.flipY=0,this.repaint(),requestAnimationFrame(()=>{const r=this.root.querySelector(".context-menu");if(!r)return;const o=r.getBoundingClientRect();this.menu.flipX=o.right>window.innerWidth?window.innerWidth-o.right-8:0,this.menu.flipY=o.bottom>window.innerHeight?window.innerHeight-o.bottom-8:0,this.paint()})}startMarquee(t){const n={x:t.clientX,y:t.clientY},r=i=>{this.marquee={visible:!0,x:Math.min(n.x,i.clientX),y:Math.min(n.y,i.clientY),w:Math.abs(i.clientX-n.x),h:Math.abs(i.clientY-n.y)},this.paint()},o=()=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o);const i={...this.marquee};if(this.marquee={visible:!1,x:0,y:0,w:0,h:0},i.w>2&&i.h>2){const a=this.store.elements.filter(l=>{const c=this.root.querySelector(`[data-el-id="${CSS.escape(l.id)}"]`);if(!c)return!1;const s=c.getBoundingClientRect();return s.left<i.x+i.w&&s.right>i.x&&s.top<i.y+i.h&&s.bottom>i.y});this.store.select(new Set(a.map(l=>l.id)))}else this.repaint()};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)}taps=new Map;isDoubleTap(t,n){const r=this.taps.get(t);return this.taps.set(t,{t:n.timeStamp,x:n.clientX,y:n.clientY}),!r||n.timeStamp-r.t>=500||Math.abs(n.clientX-r.x)>6||Math.abs(n.clientY-r.y)>6?!1:(this.taps.delete(t),!0)}beginDrag(t){const n=t.event;if(n.button!==0)return;const r=this.store;n.stopPropagation();const o=r.elements.find(l=>l.id===t.id);if(!o||(r.selectElement(o.id,n.ctrlKey||n.metaKey),o.options.locked))return;const i=n.altKey?[o.id]:r.dragIds(o.id),a=new Map;for(const l of i){const c=r.elements.find(s=>s.id===l);c&&a.set(l,{left:c.options.left,top:c.options.top})}this.drag={ids:i,primary:o.id,altKey:n.altKey,movedPositions:new Map,startX:n.clientX,startY:n.clientY,origin:a,zone:o.zone||"content",moved:!1},r.draggingIds=new Set(i),r.dragStart(),this.syncDragGhost()}syncDragGhost(){const t=this.store.draggingIds;for(const n of Array.from(this.root.querySelectorAll(".print-element"))){const r=t.has(n.dataset.elId??"");n.classList.toggle("drag-ghost",r);const o=n.querySelector(":scope > .drag-preview");r&&!o?Fe(h("div",{class:"drag-preview"}),n):!r&&o&&o.remove()}}finishAltClone(t){const n=this.store;n.adsorbGuides=[];const r=n.elements.find(a=>a.id===t.primary),o=t.movedPositions.get(t.primary);if(n.discardLive(),!r||!o)return;const i=JSON.parse(JSON.stringify(r));i.id=un(),i.options.left=o.left,i.options.top=o.top,i.options.groupId=void 0,n.cloneElement(i)}flashSnapIndicator(t,n){const r=this.root.querySelector(".hiprint-printPaper-content");r&&(r.querySelector(".snap-indicator")?.remove(),Fe(h("div",{class:"snap-indicator",style:{left:`${t}mm`,top:`${n}mm`}}),r),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{r.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(t){const n=t.event;n.stopPropagation();const r=this.store.elements.find(o=>o.id===t.id);!r||r.options.locked||(this.resize={id:t.id,point:t.point,startX:n.clientX,startY:n.clientY,origin:{left:r.options.left,top:r.options.top,width:r.options.width,height:r.options.height}},this.store.dragStart())}beginZoneResize(t){t.event.stopPropagation(),t.event.preventDefault(),this.zoneResizing=t.zone;const n=t.event.clientY,r=this.store.templateData,o=t.zone==="header"?r.header.height:r.footer.height,i=(this.store.scale||100)/100,a=c=>{const s=Cr((c.clientY-n)/i),d=Math.max(0,Math.round((o+(t.zone==="header"?s:-s))*10)/10);t.zone==="header"?this.store.updateTemplateData({header:{...r.header,height:d}}):this.store.updateTemplateData({footer:{...r.footer,height:d}}),this.paint()},l=()=>{window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",l),this.zoneResizing=null,this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",a),window.addEventListener("mouseup",l)}beginGuideDrag(t){const n=(this.store.templateData.guides??[]).find(d=>d.id===t.id);if(!n)return;const r=It(this.store.templateData),o=n.type==="vertical"?r.width:r.height,i=t.event.clientX,a=t.event.clientY,l=(this.store.scale||100)/100,c=d=>{const p=Cr((n.type==="vertical"?d.clientX-i:d.clientY-a)/l);this.store.moveGuide(n.id,Math.min(o,Math.max(0,n.position+p))),this.paint()},s=()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",s),this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",s)}beginRulerGuide(t){const n=t.orientation==="horizontal"?"vertical":"horizontal",r=i=>{this.guidePreview={type:n,position:n==="vertical"?i.clientX:i.clientY},this.paint()},o=i=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o);const a=this.rulerPointToMM(i,n);this.guidePreview=null,a!==null?this.store.addGuide(n,a):this.repaint()};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)}rulerPointToMM(t,n){const r=this.root.querySelector(".hiprint-printPaper");if(!r)return null;const o=r.getBoundingClientRect(),i=zt(1)*(this.geom.paperScale||1),a=n==="vertical"?(t.clientX-o.left)/i:(t.clientY-o.top)/i,l=It(this.store.templateData),c=n==="vertical"?l.width:l.height;return a<0||a>c?null:a}applyZoom(t,n,r,o){const i=this.root.querySelector(".canvas-area");if(!i)return;const a=Math.round(this.store.scale),l=Math.max(o,Math.round(t));if(l===a)return;const c=getComputedStyle(i),s=parseFloat(c.paddingLeft)||0,d=parseFloat(c.paddingTop)||0,p=i.scrollLeft+n-s,u=i.scrollTop+r-d,f=l/a;this.store.setScale(l,o),i.scrollLeft=p*f-n+s,i.scrollTop=u*f-r+d}zoomByStep(t){const n=this.root.querySelector(".canvas-area");n&&this.applyZoom(kl(this.store.scale,t),n.clientWidth/2,n.clientHeight/2,Lr)}fitToWindow(){const t=this.root.querySelector(".canvas-area");if(!t)return;const n=getComputedStyle(t),r=(parseFloat(n.paddingLeft)||0)+(parseFloat(n.paddingRight)||0),o=(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0),i=It(this.store.templateData),a=$h(t.clientWidth-r,t.clientHeight-o,zt(i.width),zt(i.height));this.applyZoom(a,t.clientWidth/2,t.clientHeight/2,Tl)}onWheel(t){if(!t.ctrlKey&&!t.metaKey)return;t.preventDefault();const n=this.root.querySelector(".canvas-area");if(!n)return;const r=Math.round(this.store.scale),o=kl(r,t.deltaY>0?-1:1);if(o===r)return;const i=n.getBoundingClientRect();this.applyZoom(o,t.clientX-i.left,t.clientY-i.top,Lr)}onScroll(){const t=this.root.querySelector(".canvas-area");t&&(this.scrollPos={x:t.scrollLeft,y:t.scrollTop},this.syncRulers())}bindPointer(){window.addEventListener("mousemove",t=>{const n=this.store;if(!n)return;const o=((n.scale||100)/100||1)*zt(1),i=(a,l)=>({dx:a/o,dy:l/o});if(this.drag){const{dx:a,dy:l}=i(t.clientX-this.drag.startX,t.clientY-this.drag.startY);(Math.abs(a)>.05||Math.abs(l)>.05)&&(this.drag.moved=!0);const c=n.elements.find(m=>m.id===this.drag.primary),s=c&&{id:c.id,left:(this.drag.origin.get(c.id)?.left??0)+a,top:(this.drag.origin.get(c.id)?.top??0)+l,width:c.options.width,height:c.options.height};let d=null;if(s&&n.snapToGrid!==!1){const m=n.elements.filter(v=>!this.drag.ids.includes(v.id)&&(v.zone||"content")===this.drag.zone).map(v=>({id:v.id,left:v.options.left,top:v.options.top,width:v.options.width,height:v.options.height})),g=ys(n.templateData,n.paperSize)[this.drag.zone],b=j0(s,m,this.manualGuides());d={left:b.left,top:b.top},n.adsorbGuides=(b.lines??[]).filter(v=>v.position>=0&&v.position<=(v.type==="vertical"?g.width:g.height)),(d.left!==s.left||d.top!==s.top)&&this.flashSnapIndicator(d.left+s.width/2,d.top+s.height/2)}else n.adsorbGuides=[];const p=c?this.drag.origin.get(c.id):void 0,u=d&&p?d.left-p.left:a,f=d&&p?d.top-p.top:l;for(const m of this.drag.ids){const g=this.drag.origin.get(m);if(!g)continue;const b={left:g.left+u,top:g.top+f};this.drag.movedPositions.set(m,b),n.livePatch(m,b)}this.patchElementDom(),n.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:a,dy:l}=i(t.clientX-this.resize.startX,t.clientY-this.resize.startY),c=X0(this.resize.point,this.resize.origin,a,l,3.5,3.5);n.livePatch(this.resize.id,c),this.patchElementDom()}}),window.addEventListener("mouseup",()=>{const t=!!this.drag,n=this.drag;if(n?.moved&&n.altKey){this.finishAltClone(n),this.store.dragStop(),this.drag=null,this.store.draggingIds=new Set,this.repaint();return}this.drag?.moved||this.resize?(this.store.adsorbGuides=[],this.store.commitLive(),this.store.dragStop(),this.drag=null,this.resize=null,this.store.draggingIds=new Set,this.repaint()):(this.drag=null,this.store.dragStop(),t&&(this.store.draggingIds=new Set,this.syncDragGhost()))}),this.addEventListener("pointerdown",t=>{const n=t.composedPath(),r=n.some(i=>i.classList?.contains("tb-dd"));this.state.openDd&&!r&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!r&&(this.state.openMore=!1,this.repaint());const o=n.some(i=>i.classList?.contains("context-menu"));this.menu.visible&&!o&&(this.menu.visible=!1,this.repaint())}),this.root.addEventListener("mouseover",t=>{const r=t.target?.closest?.("[data-tip]");!r||!r.closest(Kw)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(r),300))}),this.root.addEventListener("mouseout",t=>{const n=t,r=n.target?.closest?.("[data-tip]");r&&n.relatedTarget?.closest?.("[data-tip]")!==r&&this.hideHoverTip()})}showHoverTip(t){const n=t.dataset.tip;if(!n)return;this.hideHoverTip();const r=t.getBoundingClientRect(),o=r.left+r.width/2;this.hoverTipEl=Fe(h("div",{class:"pd-hover-tip",style:{left:`${o}px`,top:`${r.bottom+6}px`},text:n}),this.root);const i=this.hoverTipEl.offsetWidth/2;if(!i)return;const a=i+8,l=Math.max(window.innerWidth-i-8,a);this.hoverTipEl.style.left=`${Math.min(Math.max(o,a),l)}px`}hideHoverTip(){this.hoverTipTimer&&(clearTimeout(this.hoverTipTimer),this.hoverTipTimer=null),this.hoverTipEl?.remove(),this.hoverTipEl=null}manualGuides(){const t=[],n=[];for(const r of this.store.templateData.guides??[])r.type==="vertical"?t.push(r.position):n.push(r.position);return{vertical:t,horizontal:n}}paintGuidesOnly(){const t=this.root.querySelector(".hiprint-printPaper-content");if(!t)return;for(const r of Array.from(t.querySelectorAll(".adsorb-guide")))r.remove();const n=this.store.paperSize;ys(this.store.templateData,n);for(const r of this.store.adsorbGuides){const o=document.createElement("div");o.className=`adsorb-guide guide-${r.type}`,r.type==="vertical"?o.style.cssText=`left:${r.position}mm;top:0;height:${n.height}mm;border-left-color:${r.color||"var(--pd-accent-secondary, #f56c6c)"}`:o.style.cssText=`top:${r.position}mm;left:0;width:${n.width}mm;border-top-color:${r.color||"var(--pd-accent-secondary, #f56c6c)"}`,t.appendChild(o)}}bindKeys(){this.setAttribute("tabindex","0");const t=()=>{Mt.active=this};this.addEventListener("pointerdown",t),this.addEventListener("focusin",t),Mt.active||(Mt.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=t=>this.onGlobalKeydown(t),document.addEventListener("keydown",this.docKeydown),this.docDragend=()=>Xp(this.root?.querySelector(".canvas-area")),document.addEventListener("dragend",this.docDragend,!0))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null,this.docDragend&&(document.removeEventListener("dragend",this.docDragend,!0),this.docDragend=null))}onGlobalKeydown(t){const n=this.store;if(!n||Mt.active!==this)return;const o=t.composedPath()[0]?.tagName;if(o==="INPUT"||o==="TEXTAREA"||o==="SELECT")return;if(this.format.handlePainterKeydown(t),t.key.startsWith("Arrow")){t.preventDefault();const a=t.shiftKey?10:t.ctrlKey?.5:1,l=t.key==="ArrowLeft"?-a:t.key==="ArrowRight"?a:0,c=t.key==="ArrowUp"?-a:t.key==="ArrowDown"?a:0;n.moveSelected(l,c);return}if(t.key==="Delete"||t.key==="Backspace"){t.preventDefault(),n.deleteSelected();return}if(!(t.ctrlKey||t.metaKey))return;const i=t.key.toLowerCase();Zw.has(i)&&(t.preventDefault(),i==="z"?t.shiftKey?n.redo():n.undo():i==="y"?n.redo():i==="a"?n.selectAll():i==="c"?n.copy():i==="x"?n.cutSelected():i==="v"?n.paste():i==="d"?n.duplicateSelected():i==="g"?t.shiftKey?n.ungroupSelected():n.groupSelected():i==="1"?n.resetZoom():i==="l"?n.alignSelected("left"):i==="r"?n.alignSelected("right"):i==="e"?n.alignSelected("vertical"):i==="t"?n.alignSelected("top"):i==="b"?n.alignSelected("bottom"):i==="0"&&this.fire("fit-window"))}}function _f(e="print-designer"){return customElements.get(e)||customElements.define(e,Mt),e}function Qw(){return _f()}const ex=Object.freeze(Object.defineProperty({__proto__:null,DesignerStore:up,PrintDesignerElement:Mt,TILING_SINGLE_PAGE_TIP:es,createDefaultTemplate:gr,definePrintDesigner:_f,registerAll:Qw,serializePage:cp,toRuntimePool:ts},Symbol.toStringTag,{value:"Module"})),tx=17521,nx=20,Mr={PRINTERS_LIST:"printers.list",PRINT_SUBMIT:"print.submit",PRINT_SUBMIT_HTML:"print.submitHtml",TEMPLATE_ATTACH:"template.attach",TEMPLATE_DETACH:"template.detach"};let Fs=0;function rx(){return Fs=(Fs+1)%Number.MAX_SAFE_INTEGER,`${Date.now().toString(36)}-${Fs.toString(36)}`}function Mf(e,t){const n={id:rx(),type:e,payload:t};return JSON.stringify(n)}function Tf(e){let t;try{t=JSON.parse(e)}catch{return{malformed:!0}}if(typeof t!="object"||t===null)return{malformed:!0};const n=t;if(typeof n.id!="string"||typeof n.ok!="boolean")return{malformed:!0};if(n.ok)return{id:n.id,ok:!0,payload:n.payload??{}};const r=n.error;return!r||typeof r.code!="string"||typeof r.message!="string"?{malformed:!0}:{id:n.id,ok:!1,error:{code:r.code,message:r.message}}}function ox(e){if(typeof e!="object"||e===null)return!1;const t=e;return!("ok"in t)&&typeof t.id=="string"&&typeof t.type=="string"&&typeof t.payload=="object"&&t.payload!==null}class bt extends Error{constructor(t,n){super(n),this.name="WormPrintError",this.code=t}}function ix(e){return e instanceof bt||e&&typeof e=="object"&&typeof e.code=="string"?e.code:"INTERNAL"}class kf extends Error{constructor(t){super(t),this.code="UNAUTHORIZED",this.name="AuthRejectedError"}}class ax{constructor(t={}){this.ws=null,this.status_="disconnected",this.hello=null,this.pendings=new Map,this.statusCbs=new Set,this.requestHandler=null,this.manualClose=!1,this.reconnectTimer=null,this.reconnectAttempts=0,this.opts=t,this.ctor=t.WebSocketCtor??WebSocket,this.defaultTimeout=t.timeoutMs??15e3}get status(){return this.status_}onStatus(t){return this.statusCbs.add(t),()=>this.statusCbs.delete(t)}setRequestHandler(t){this.requestHandler=t}setToken(t){this.opts={...this.opts,token:t}}async connect(t){if(this.status_==="connected"&&this.hello)return this.hello;this.setStatus("connecting");const n=this.opts.ports??Array.from({length:nx},(r,o)=>tx+o);for(const r of n){if(t?.aborted)throw new bt("CLIENT_NOT_RUNNING","连接已取消");try{return this.hello=await this.tryPort(r,t),this.manualClose=!1,this.reconnectAttempts=0,this.setStatus("connected"),this.hello}catch(o){if(o instanceof kf)throw this.setStatus("disconnected"),new bt("UNAUTHORIZED",o.message||"配对 token 无效或来源未授权")}}throw this.setStatus("disconnected"),new bt("CLIENT_NOT_RUNNING","未发现运行中的打印客户端(已探测默认端口区间),请确认客户端已启动")}request(t,n,r){if(this.status_!=="connected"||!this.ws)return Promise.reject(new bt("CLIENT_NOT_RUNNING","打印客户端未连接"));const o=Mf(t,n),i=JSON.parse(o);return new Promise((a,l)=>{const c=setTimeout(()=>{this.pendings.delete(i.id),l(new bt("CLIENT_TIMEOUT",`请求 ${t} 超时未响应`))},r??this.defaultTimeout);this.pendings.set(i.id,{resolve:a,reject:l,timer:c}),this.ws.send(o)})}close(){this.manualClose=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.ws?.close(),this.failAllPendings(new bt("CLIENT_NOT_RUNNING","连接已关闭")),this.setStatus("disconnected")}buildUrl(t){const n=new URL(`ws://127.0.0.1:${t}`);return this.opts.token&&n.searchParams.set("token",this.opts.token),n.toString().replace(/\/$/,"")}tryPort(t,n){return new Promise((r,o)=>{const i=new this.ctor(this.buildUrl(t));this.ws=i;let a=!1;const l=()=>{a||(a=!0,o(new Error("aborted")))};n?.addEventListener("abort",l,{once:!0}),i.onopen=()=>{i.send(Mf("hello",{}))},i.onmessage=c=>{const s=Tf(String(c.data));if(!("malformed"in s))if(s.ok&&sx(s.payload)){if(a)return;a=!0,this.bindLifecycle(i),r(s.payload)}else if(!s.ok&&s.error.code==="UNAUTHORIZED"){if(a)return;a=!0,o(new kf(s.error.message))}else a||(a=!0,o(new Error("握手失败")))},i.onerror=()=>{a||(a=!0,o(new Error("连接错误")))},i.onclose=()=>{a||(a=!0,o(new Error("连接关闭")))}})}bindLifecycle(t){t.onmessage=n=>{this.handleIncoming(t,String(n.data))},t.onclose=()=>{this.failAllPendings(new bt("CLIENT_NOT_RUNNING","与客户端的连接中断")),this.hello=null,this.ws=null,this.manualClose||this.scheduleReconnect()},t.onerror=()=>{}}handleIncoming(t,n){let r;try{r=JSON.parse(n)}catch{return}if(ox(r)){this.dispatchServerRequest(t,r);return}const o=Tf(n);if("malformed"in o)return;const i=this.pendings.get(o.id);i&&(this.pendings.delete(o.id),clearTimeout(i.timer),o.ok?i.resolve(o.payload):i.reject(new bt(o.error.code,o.error.message)))}dispatchServerRequest(t,n){const r=this.requestHandler;if(!r){this.safeSend(t,n.id,!1,void 0,"INVALID_REQUEST","桌面端请求未注册处理器");return}Promise.resolve().then(()=>r(n.type,n.payload)).then(o=>this.safeSend(t,n.id,!0,o??{})).catch(o=>{const i=ix(o),a=o instanceof Error?o.message:String(o);this.safeSend(t,n.id,!1,void 0,i,a)})}safeSend(t,n,r,o,i,a){t.readyState===1&&t.send(JSON.stringify(r?{id:n,ok:r,payload:o}:{id:n,ok:r,error:{code:i??"INTERNAL",message:a??"内部错误"}}))}scheduleReconnect(){this.setStatus("connecting");const t=Math.min(1e3*2**this.reconnectAttempts++,1e4);this.reconnectTimer=setTimeout(()=>{this.connect().catch(()=>this.scheduleReconnect())},t)}failAllPendings(t){for(const[,n]of this.pendings)clearTimeout(n.timer),n.reject(t);this.pendings.clear()}setStatus(t){if(this.status_!==t){this.status_=t;for(const n of this.statusCbs)n(t)}}}function sx(e){return typeof e=="object"&&e!==null&&e.app==="worm-print-client"}const Cf="worm-print-client:token";class zs{constructor(t={}){const r={token:t.token??zs.loadStoredToken()??void 0,timeoutMs:t.timeoutMs,WebSocketCtor:t.WebSocketCtor};this.transport=new ax(r)}get status(){return this.transport.status}connect(t){return this.transport.connect(t)}onStatusChange(t){return this.transport.onStatus(t)}setRequestHandler(t){this.transport.setRequestHandler(t)}async listPrinters(){return(await this.transport.request(Mr.PRINTERS_LIST,{})).printers}request(t,n,r){return this.transport.request(t,n,r)}attachTemplate(t){return this.request(Mr.TEMPLATE_ATTACH,t)}detachTemplate(t){return this.request(Mr.TEMPLATE_DETACH,{sessionId:t})}print(t,n,r={},o){const{baseUrl:i,fontBaseUrl:a,timeoutMs:l,...c}=r,s={templateJson:t,printData:n,baseUrl:i,fontBaseUrl:a,print:c};return typeof o=="string"&&o.trim().length>0&&(s.templateName=o),this.transport.request(Mr.PRINT_SUBMIT,s,l)}printHtml(t,n={},r){const{timeoutMs:o,...i}=n,a={html:t.html,paperMm:t.paperMm,continuous:t.continuous,pageCount:t.pageCount,print:i};return typeof r=="string"&&r.trim().length>0&&(a.templateName=r),this.transport.request(Mr.PRINT_SUBMIT_HTML,a,o)}pair(t){localStorage.setItem(Cf,t),this.transport.setToken(t)}static loadStoredToken(){try{return localStorage.getItem(Cf)}catch{return null}}close(){this.transport.close()}}const lx={...ex,renderHtmlPages:w1,browserCodeRenderer:Za,PrintClient:zs,WormPrintError:bt,getPaperDimensions:et,isContinuousPaperSize:cn,getByPath:Yn,resolvePrinterDpi:bg,paperWidthPx:yg,zoomPresets:wg,defaultZoomKey:Vl,resolveZoomKey:Sg,zoomValueOf:_g,viewZoomHint:xg,applyPreviewViewZoom:Eg,resolveToolbarOverflow:Cl};globalThis.WormPrintCommon??=lx}));