@worm-vue3-print/common 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/browser-bundle.d.ts +1 -1
- package/dist/common.js +49 -42
- package/dist/core/default-template.d.ts +1 -1
- package/dist/core/format.d.ts +1 -1
- package/dist/core/h.d.ts +1 -1
- package/dist/core/icons.d.ts +1 -1
- package/dist/core/store.d.ts +1 -1
- package/dist/index.cjs +8 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +390 -383
- package/dist/print-designer.d.ts +1 -1
- package/dist/shell/binding.d.ts +1 -1
- package/dist/shell/canvas.d.ts +1 -1
- package/dist/shell/code.d.ts +1 -1
- package/dist/shell/color-picker.d.ts +1 -1
- package/dist/shell/controls.d.ts +1 -1
- package/dist/shell/crop-anchor.d.ts +1 -1
- package/dist/shell/elements.d.ts +1 -1
- package/dist/shell/expression-editor.d.ts +1 -1
- package/dist/shell/flow-list.d.ts +1 -1
- package/dist/shell/font-select.d.ts +1 -1
- package/dist/shell/format-bar.d.ts +1 -1
- package/dist/shell/help-content/changelog.d.ts +1 -1
- package/dist/shell/help-content/faq.d.ts +1 -1
- package/dist/shell/help-content/features.d.ts +1 -1
- package/dist/shell/help-content/getting-started.d.ts +1 -1
- package/dist/shell/help-content/index.d.ts +1 -1
- package/dist/shell/help-content/shortcuts.d.ts +1 -1
- package/dist/shell/help-modal.d.ts +1 -1
- package/dist/shell/page-extras.d.ts +1 -1
- package/dist/shell/panels.d.ts +1 -1
- package/dist/shell/prop-group.d.ts +1 -1
- package/dist/shell/property-panel.d.ts +1 -1
- package/dist/shell/property-search.d.ts +1 -1
- package/dist/shell/ruler.d.ts +1 -1
- package/dist/shell/table-props.d.ts +1 -1
- package/dist/shell/table.d.ts +1 -1
- package/dist/shell/toolbar-overflow.d.ts +1 -1
- package/dist/shell/toolbar.d.ts +1 -1
- package/dist/shell/watermark.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@worm-vue3-print/core/designer"),A=require("@worm-vue3-print/core"),Vo=require("@worm-vue3-print/core/browser"),wn=require("jsbarcode");function a(o,e={},t=[]){return{tag:o,props:e,children:t}}const Sn="http://www.w3.org/2000/svg",pr=new Set(["draggable","contenteditable","spellcheck"]),ur=new Set(["indeterminate"]);function hr(o){return o==="svg"||o==="path"||o==="circle"||o==="rect"||o==="line"||o==="g"}function fe(o,e){if(typeof o=="string"){const s=document.createTextNode(o);return e.appendChild(s),s}if(o instanceof Node)return e.appendChild(o),o;const{tag:t,props:i,children:n}=o,r=hr(t)?document.createElementNS(Sn,t):document.createElement(t);for(const[s,l]of Object.entries(i))if(!(l==null||l===!1))if(s==="class")r.setAttribute("class",String(l));else if(s==="style")typeof l=="string"?r.style.cssText=l:Object.assign(r.style,l);else if(s==="html")r.innerHTML=String(l);else if(s==="text")r.textContent=String(l);else if(s.startsWith("on")&&typeof l=="function")r.addEventListener(s.slice(2).toLowerCase(),l);else if(s==="dataset")for(const[c,u]of Object.entries(l))r.dataset[c]=u;else ur.has(s)?r[s]=!0:typeof l=="boolean"?l&&r.setAttribute(s,pr.has(s)?"true":""):r.setAttribute(s,String(l));for(const s of n)fe(s,r);return e.appendChild(r),r}function Tn(o){for(;o.firstChild;)o.removeChild(o.firstChild)}const fr=Sn;function Rt(){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 No="开启拼版后只能有一个设计页面";function Xo(o){const e=(t,i)=>(t??[]).map(n=>{const r={...n.options};return(n.printElementType?.type??n.type)==="table"&&p.syncTableElementSize(r),{id:n.id||p.generateId(),zone:i,options:r,printElementType:{...n.printElementType}}});return{...o,margins:{...o.margins},header:{height:o.header?.height??10,elements:[]},footer:{height:o.footer?.height??10,elements:[]},guides:[...o.guides??[]],elements:[...e(o.elements??[],"content"),...e(o.header?.elements??[],"header"),...e(o.footer?.elements??[],"footer")]}}function En(o){const e=o.elements,t=i=>e.filter(n=>(n.zone||"content")===i).map(n=>({id:n.id,type:n.printElementType.type,options:{...n.options},printElementType:{...n.printElementType}}));return{unit:"mm",...o,header:{...o.header,elements:t("header")},footer:{...o.footer,elements:t("footer")},elements:t("content"),guides:[...o.guides??[]]}}function Ri(o){const e=(i,n)=>{const r=Xo(p.normalizeTemplateUnits(i));return r.name||(r.name=`页面 ${n+1}`),r};if(!o)return[e(Rt(),0)];const t=Array.isArray(o.pages)?o.pages:[o];return t.length?t.map(e):[e(Rt(),0)]}const pt=o=>JSON.parse(JSON.stringify(o));class kn{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=p.useAlign();group=p.useGroup();constructor(e={}){if(this.pages=Ri(e.initialTemplate),this.fields=e.initialFields??[],e.initialElements?.length){const t=this.pages[0];t.elements=[...t.elements,...e.initialElements]}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e=!0){e&&(this.dirty=!0);for(const t of[...this.listeners])t()}get templateData(){return this.pages[this.activePageIndex]}set templateData(e){this.pages[this.activePageIndex]=e}get elements(){return this.templateData.elements.map(e=>this.live.get(e.id)??e)}get tilingEnabled(){return this.pages.some(e=>e.tiling?.enabled===!0)}switchPage(e){e<0||e>=this.pages.length||(this.activePageIndex=e,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(No);return}this.recordHistory();const e=this.pages[this.activePageIndex]??Rt();this.pages.push(Xo({...Rt(),paperSize:e.paperSize,orientation:e.orientation,customWidth:e.customWidth,customHeight:e.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const e=new Set(this.pages.map(i=>i.name));let t=this.pages.length+1;for(;e.has(`页面 ${t}`);)t++;return`页面 ${t}`}duplicatePage(e){if(this.tilingEnabled){window.alert(No);return}this.recordHistory();const t=pt(this.pages[e]);t.name=`${t.name??`页面 ${e+1}`} 副本`,t.elements=t.elements.map(i=>({...i,id:p.generateId()})),this.pages.splice(e+1,0,t),this.switchPage(e+1),this.emit()}deletePage(e){this.pages.length<=1||(this.recordHistory(),this.pages.splice(e,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(e,t){this.recordHistory(),this.pages[e].name=t,this.emit()}movePage(e,t){if(t<0||t>=this.pages.length||e===t)return;this.recordHistory();const[i]=this.pages.splice(e,1);this.pages.splice(t,0,i),this.activePageIndex=t,this.emit()}onSelectionChanged;setSelection(e){this.selectedIds=e,this.onSelectionChanged?.(),this.emit(!1)}select(e){this.setSelection(new Set(e))}selectOne(e,t=!1){if(t){const i=new Set(this.selectedIds);i.has(e)?i.delete(e):i.add(e),this.setSelection(i)}else this.setSelection(new Set([e]))}clearSelection(){this.setSelection(new Set)}selectElement(e,t=!1){if(t){this.selectOne(e,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,e)))}selectAll(){this.setSelection(new Set(this.elements.map(e=>e.id)))}get selectedElements(){return this.elements.filter(e=>this.selectedIds.has(e.id))}get selectedElement(){const e=this.selectedIds.values().next().value;return e?this.elements.find(t=>t.id===e)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(e){this.tableSelection=e,this.emit(!1)}setPreview(e){this.previewIds=e,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(e,t){const i=this.templateData.guides??[];this.templateData.guides=[...i,{id:p.generateId(),type:e,position:Math.round(t*10)/10}],this.emit()}moveGuide(e,t){const i=this.templateData.guides??[];this.templateData.guides=i.map(n=>n.id===e?{...n,position:Math.round(t*10)/10}:n),this.emit(!1)}removeGuide(e){this.templateData.guides=(this.templateData.guides??[]).filter(t=>t.id!==e),this.emit()}addElement(e,t={},i){const n=p.createRuntimeElement(e,t);return i&&!this.placeAtDropPoint(n,i)||(this.recordHistory(),this.templateData.elements.push(n),this.select(new Set([n.id])),this.emit()),n}addFieldElement(e,t={},i){const n=p.createFieldElement(e);return Object.assign(n.options,t),i&&!this.placeAtDropPoint(n,i)||(this.recordHistory(),this.templateData.elements.push(n),this.select(new Set([n.id])),this.emit()),n}placeAtDropPoint(e,t){const i=this.templateData,n=p.zoneFromPaperPoint(i,t.x,t.y);if(n!=="content"&&!p.ZONE_ALLOWED_TYPES.includes(e.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const r=p.getZoneRects(i)[n];return e.zone=n,e.options.left=t.x-r.left,e.options.top=t.y-r.top,n!=="content"&&p.clampToZone(e,r),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(e=>!this.selectedIds.has(e.id)),this.selectedIds=new Set,this.emit())}livePatch(e,t){const i=this.templateData.elements.find(r=>r.id===e);if(!i)return;const n=this.live.get(e)??i;this.live.set(e,{...n,options:{...n.options,...t}})}commitLive(){if(!this.live.size)return;this.recordHistory();const e=this.templateData.elements;for(const[t,i]of this.live){const n=e.find(r=>r.id===t);n&&Object.assign(n.options,i.options)}this.live.clear(),this.emit()}dragIds(e){const t=this.templateData.elements.find(i=>i.id===e);return!t||t.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,e))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(e=>[e.id,this.geoSig(e)]))}dragStop(){const e=this.dragBefore;if(!e)return;this.dragBefore=null;let t=!1;for(const i of this.elements){const n=e.get(i.id);!n||n===this.geoSig(i)||p.finalizeElementZone(i,this.templateData).rejected&&(t=!0)}t&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(e){return`${e.zone||"content"}:${e.options.left},${e.options.top},${e.options.width},${e.options.height}`}updateElement(e,t,i=!0){i&&this.recordHistory();const n=this.templateData.elements.find(r=>r.id===e);n&&(Object.assign(n.options,t),n.printElementType.type==="table"&&p.syncTableElementSize(n.options),this.emit())}updateTemplateData(e){this.recordHistory(),Object.assign(this.templateData,e),this.emit()}moveLayer(e){if(!this.selectedIds.size)return;this.recordHistory();const t=this.templateData.elements,i=t.filter(r=>this.selectedIds.has(r.id)),n=t.filter(r=>!this.selectedIds.has(r.id));if(e==="top")this.templateData.elements=[...n,...i];else if(e==="bottom")this.templateData.elements=[...i,...n];else{const r=t.findIndex(c=>this.selectedIds.has(c.id)),s=e==="up"?r+1:r-1;if(s<0||s>=t.length)return;const l=[...t];[l[r],l[s]]=[l[s],l[r]],this.templateData.elements=l}this.emit()}alignSelected(e){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(t=>this.selectedIds.has(t.id)),e),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=pt(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(e=10){if(!this.clipboard.length)return;this.recordHistory();const t=new Map;for(const r of this.clipboard){const s=r.options.groupId;s&&t.set(s,(t.get(s)??0)+1)}const i=new Map;for(const[r,s]of t)i.set(r,s>=2?p.generateGroupId():void 0);const n=this.templateData.elements;for(const r of this.clipboard){const s=pt(r);s.id=p.generateId(),s.options.left+=e,s.options.top+=e,s.options.groupId=s.options.groupId?i.get(s.options.groupId):void 0,n.push(s)}this.emit()}duplicateSelected(){if(this.copy(),!this.clipboard.length)return;this.paste(15);const e=this.templateData.elements;this.selectOne(e[e.length-this.clipboard.length].id)}get hasClipboard(){return this.clipboard.length>0}moveSelected(e,t){const i=this.selectedElements.filter(n=>!n.options.locked);if(i.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const n of i)n.options.left+=e,n.options.top+=t;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(e){this.recordHistory(),this.templateData.elements.push(e),this.selectedIds=new Set([e.id]),this.emit()}recordHistory(){this.undoStack.push({pages:pt(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 e=this.undoStack.pop();e&&(this.redoStack.push({pages:pt(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}redo(){const e=this.redoStack.pop();e&&(this.undoStack.push({pages:pt(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(e,t=p.MIN_SCALE_PERCENT){this.scale=Math.max(t,Math.round(e)),this.emit(!1)}getTemplateJson(){const e=this.pages.map(En),t=e.length===1?e[0]:{version:1,pages:e};return JSON.stringify(t)}loadTemplate(e){this.pages=Ri(e),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return p.getPaperDimensions(this.templateData)}}const Qe=Symbol("mixed"),Eo=new Set(["text","longText"]),mr=["top","right","bottom","left"],gr={on:!0,off:!1,mixed:Qe};function zi(o){const e=p.resolveBorderEdgeStates(o),t={};for(const i of mr)t[i]=gr[e[i]];return t}const br=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class xr{constructor(e){this.store=e}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(e=>this.store.selectedIds.has(e.id)&&!e.options.locked)}get tableElement(){const e=this.store.tableSelection;return e?this.store.elements.find(t=>t.id===e.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 e=this.store.tableSelection,t=this.tableElement?.options.tableRows;if(!e||!t)return[];const i=[];for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const s=t[n]?.cells[r];s&&!s.merged&&i.push(s)}return i}get textTargets(){return this.selectedElements.filter(e=>Eo.has(e.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(e=>e.options)}pick(e){if(!e.length)return;const t=e[0];return e.every(i=>i===t)?t:Qe}hasToken(e,t){return(e??"").split(/\s+/).includes(t)}get values(){const e=this.styleTargets;if(!e.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 t=e.map(n=>n.fontWeight==="bold"||n.fontWeight==="bolder"),i=e.map(n=>n.textDecoration);return{fontFamily:this.pick(e.map(n=>n.fontFamily)),fontSize:this.pick(e.map(n=>n.fontSize)),color:this.pick(e.map(n=>n.color)),backgroundColor:this.pick(e.map(n=>n.backgroundColor)),textAlign:this.pick(e.map(n=>this.context==="cells"?n.align:n.textAlign)),verticalAlign:this.pick(e.map(n=>this.context==="cells"?n.valign:n.verticalAlign)),bold:t.every(Boolean)?!0:t.some(Boolean)?Qe:!1,underline:i.map(n=>this.hasToken(n,"underline")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"underline"))?Qe:!1,strike:i.map(n=>this.hasToken(n,"line-through")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"line-through"))?Qe:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(e){const t=this.targetCells;t.length&&(t.forEach(e),this.commit())}applyStyle(e){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in e&&(l.fontFamily=e.fontFamily),"fontSize"in e&&(l.fontSize=e.fontSize),"color"in e&&(l.color=e.color),"backgroundColor"in e&&(l.backgroundColor=e.backgroundColor),"textAlign"in e&&(l.align=e.textAlign),"verticalAlign"in e&&(l.valign=e.verticalAlign)});return}const t=this.textTargets,i=this.selectedElements,r=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in e),s="backgroundColor"in e;!(t.length&&r)&&!(i.length&&s)||(t.forEach(l=>{const c=l.options;"fontFamily"in e&&(c.fontFamily=e.fontFamily),"fontSize"in e&&(c.fontSize=e.fontSize),"color"in e&&(c.color=e.color),"textAlign"in e&&(c.textAlign=e.textAlign),"verticalAlign"in e&&(c.verticalAlign=e.verticalAlign)}),s&&i.forEach(l=>{l.options.backgroundColor=e.backgroundColor}),this.commit())}toggleBold(){if(this.context==="cells"){const i=this.values.bold!==!0;this.writeCells(n=>{n.fontWeight=i?"bold":void 0});return}const e=this.values.bold!==!0,t=this.textTargets;t.length&&(t.forEach(i=>{i.options.fontWeight=e?"bold":"normal"}),this.commit())}toggleDecoration(e){if(this.context==="cells")return;const t=this.textTargets;if(!t.length)return;const i=this.values[e==="underline"?"underline":"strike"]!==!0;t.forEach(n=>{const r=(n.options.textDecoration??"").split(/\s+/).filter(Boolean),s=r.indexOf(e);i&&s<0&&r.push(e),!i&&s>=0&&r.splice(s,1),n.options.textDecoration=r.length?r.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 e=this.store.tableSelection,t=this.tableElement?.options.tableRows;if(!e||!t)return;const i=`cells:${e.elementId}:${e.r1}:${e.c1}:${e.r2}:${e.c2}`;if(i===this.borderDraftKey)return;if(this.borderDraftKey=i,p.resolveCellGroupMode(t,e).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const n=p.resolveCellBorderDisplay(t,e);if(n.style===void 0&&n.width===void 0&&n.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:n.style==="mixed",width:n.width==="mixed",color:n.color==="mixed"},this.borderMixed.style?this.borderStyle=null:n.style===void 0?this.borderStyle="solid":n.style==="none"?this.borderStyle=null:this.borderStyle=n.style,this.borderWidth=this.borderMixed.width?void 0:typeof n.width=="number"?n.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof n.color=="string"?n.color:"#333333"}borderSpec(){const e=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:e,color:this.borderColor??"#333333"}}setBorderWidth(e){this.borderWidth=e,this.borderMixed.width=!1}setBorderColor(e){this.borderColor=e,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(e){const t=this.borderStyle===e?null:e;this.borderMixed.style=!1,this.borderStyle=t,t===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(e,t){const i=this.selectedElements;i.length&&(i.forEach(n=>{p.applyElementBorderPreset(n.options,e,t)}),this.commit())}applyCellBorderPreset(e,t){const i=this.store.tableSelection,n=this.tableElement?.options.tableRows;!i||!n||(p.applyBorderPreset(n,{r1:i.r1,c1:i.c1,r2:i.r2,c2:i.c2},e,t),this.commit())}applyCellBorderEdges(e,t,i){this.writeCells(n=>{for(const r of e)p.setCellBorderEdge(n,r,i?t:null)})}get cellEdges(){if(this.context!=="cells")return null;const e=this.targetCells;return e.length?zi(e.map(t=>t.borders)):null}toggleCellEdge(e,t){const i=this.cellEdges?.[e]!==!0;this.applyCellBorderEdges([e],t,i)}get elementEdges(){if(this.context!=="elements")return null;const e=this.selectedElements;return e.length?zi(e.map(t=>p.elementVisibleBorders(t.options))):null}toggleElementEdge(e,t){const i=this.selectedElements;if(!i.length)return;const n=this.elementEdges?.[e]!==!0;i.forEach(r=>p.setElementBorderEdgeVisible(r.options,e,n,t)),this.commit()}applyBorderPreset(e){const t=this.borderStyle===null;if(this.context==="cells"){const i=t&&!this.borderMixed.style;this.applyCellBorderPreset(i?"none":e,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(t||e==="none"?"none":"all",this.borderSpec())}applyEdge(e){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([e],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(e);return}this.context==="cells"?(this.toggleCellEdge(e,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(e,this.borderSpec())}clearElementEdge(e){const t=this.selectedElements;t.length&&(t.forEach(i=>p.setElementBorderEdgeVisible(i.options,e,!1)),this.commit())}edgeOn(e){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[e]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(e){if(!e)return;const t={};for(const i of p.ELEMENT_BORDER_SIDES){const n=e[i];n&&(t[i]={...n})}return t}pickPainterSource(e=!1){const t=this.selectedElements[0];if(!t)return!1;const i=t.options,n=t.printElementType.type;return this.painterSnapshot={text:Eo.has(n)?Object.fromEntries(br.map(r=>[r,i[r]])):null,backgroundColor:i.backgroundColor,border:p.acceptsElementBorder(n)?{borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:this.clonePainterBorders(i.borders)}:null},this.painterSource=t.id,this.painterActive=!0,this.painterLocked=e,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(e){const t=this.painterSnapshot;if(!t||e.options.locked||e.id===this.painterSource)return!1;const i=e.options,n=e.printElementType.type;return t.text&&Eo.has(n)&&Object.assign(i,t.text),i.backgroundColor=t.backgroundColor,t.border&&p.acceptsElementBorder(n)&&(i.borderWidth=t.border.borderWidth,i.borderStyle=t.border.borderStyle,i.borderColor=t.border.borderColor,i.borders=this.clonePainterBorders(t.border.borders)),!0}painterSyncSelection(){if(!this.painterActive||!this.painterSnapshot)return;const e=this.selectedElements;if(!e.length){this.cancelPainter();return}let t=!1;e.forEach(i=>{t=this.applyPainter(i)||t}),t&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(e){if(e.key!=="Escape"||!this.painterActive)return;const t=e.target?.tagName;t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||this.cancelPainter()}}function Pi(o,e){(e==null||e>o.length)&&(e=o.length);for(var t=0,i=Array(e);t<e;t++)i[t]=o[t];return i}function vr(o){if(Array.isArray(o))return o}function yr(o,e){var t=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(t!=null){var i,n,r,s,l=[],c=!0,u=!1;try{if(r=(t=t.call(o)).next,e!==0)for(;!(c=(i=r.call(t)).done)&&(l.push(i.value),l.length!==e);c=!0);}catch(h){u=!0,n=h}finally{try{if(!c&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(u)throw n}}return l}}function wr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sr(o,e){return vr(o)||yr(o,e)||Tr(o,e)||wr()}function Tr(o,e){if(o){if(typeof o=="string")return Pi(o,e);var t={}.toString.call(o).slice(8,-1);return t==="Object"&&o.constructor&&(t=o.constructor.name),t==="Map"||t==="Set"?Array.from(o):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Pi(o,e):void 0}}const Cn=Object.entries,Fi=Object.setPrototypeOf,Er=Object.isFrozen,kr=Object.getPrototypeOf,Cr=Object.getOwnPropertyDescriptor;let re=Object.freeze,se=Object.seal,ft=Object.create,An=typeof Reflect<"u"&&Reflect,$o=An.apply,Bo=An.construct;re||(re=function(e){return e});se||(se=function(e){return e});$o||($o=function(e,t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return e.apply(t,n)});Bo||(Bo=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return new e(...i)});const Xe=ie(Array.prototype.forEach),Ar=ie(Array.prototype.lastIndexOf),Li=ie(Array.prototype.pop),Tt=ie(Array.prototype.push),Dr=ie(Array.prototype.splice),gt=Array.isArray,Mt=ie(String.prototype.toLowerCase),ko=ie(String.prototype.toString),Ii=ie(String.prototype.match),Et=ie(String.prototype.replace),Oi=ie(String.prototype.indexOf),Mr=ie(String.prototype.trim),_r=ie(Number.prototype.toString),Rr=ie(Boolean.prototype.toString),Ni=typeof BigInt>"u"?null:ie(BigInt.prototype.toString),$i=typeof Symbol>"u"?null:ie(Symbol.prototype.toString),be=ie(Object.prototype.hasOwnProperty),kt=ie(Object.prototype.toString),le=ie(RegExp.prototype.test),Ye=zr(TypeError);function ie(o){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return $o(o,e,i)}}function zr(o){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return Bo(o,t)}}function $(o,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mt;if(Fi&&Fi(o,null),!gt(e))return o;let i=e.length;for(;i--;){let n=e[i];if(typeof n=="string"){const r=t(n);r!==n&&(Er(e)||(e[i]=r),n=r)}o[n]=!0}return o}function Pr(o){for(let e=0;e<o.length;e++)be(o,e)||(o[e]=null);return o}function ke(o){const e=ft(null);for(const i of Cn(o)){var t=Sr(i,2);const n=t[0],r=t[1];be(o,n)&&(gt(r)?e[n]=Pr(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=ke(r):e[n]=r)}return e}function Fr(o){switch(typeof o){case"string":return o;case"number":return _r(o);case"boolean":return Rr(o);case"bigint":return Ni?Ni(o):"0";case"symbol":return $i?$i(o):"Symbol()";case"undefined":return kt(o);case"function":case"object":{if(o===null)return kt(o);const e=o,t=_e(e,"toString");if(typeof t=="function"){const i=t(e);return typeof i=="string"?i:kt(i)}return kt(o)}default:return kt(o)}}function _e(o,e){for(;o!==null;){const i=Cr(o,e);if(i){if(i.get)return ie(i.get);if(typeof i.value=="function")return ie(i.value)}o=kr(o)}function t(){return null}return t}function Lr(o){try{return le(o,""),!0}catch{return!1}}const Bi=re(["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"]),Co=re(["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"]),Ao=re(["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"]),Ir=re(["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"]),Do=re(["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"]),Or=re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Hi=re(["#text"]),Wi=re(["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"]),Mo=re(["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"]),Ui=re(["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"]),Xt=re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Nr=se(/{{[\w\W]*|^[\w\W]*}}/g),$r=se(/<%[\w\W]*|^[\w\W]*%>/g),Br=se(/\${[\w\W]*/g),Hr=se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Wr=se(/^aria-[\-\w]+$/),Gi=se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ur=se(/^(?:\w+script|data):/i),Gr=se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),qr=se(/^html$/i),Kr=se(/^[a-z][.\w]*(-[.\w]+)+$/i),qi=se(/<[/\w!]/g),Ki=se(/<[/\w]/g),jr=se(/<\/no(script|embed|frames)/i),Yr=se(/\/>/i),Ee={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Dn=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Vr=re($({},Dn)),Xr=(function(){const o={};return Xe(Dn,e=>{o[e]=se(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),re(o)})(),Zr=function(){return typeof window>"u"?null:window},Qr=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(i=t.getAttribute(n));const r="dompurify"+(i?"#"+i:"");try{return e.createPolicy(r,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},ji=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Be=function(e,t,i,n){return be(e,t)&>(e[t])?$(n.base?ke(n.base):{},e[t],n.transform):i},_o=function(e,t,i){const n=be(e,t)?e[t]:void 0;return n&&typeof n=="object"?ke(n):i()};function Mn(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zr();const e=E=>Mn(E);if(e.version="3.4.14",e.removed=[],!o||!o.document||o.document.nodeType!==Ee.document||!o.Element)return e.isSupported=!1,e;let t=o.document;const i=t,n=i.currentScript;o.DocumentFragment;const r=o.HTMLTemplateElement,s=o.Node,l=o.Element,c=o.NodeFilter,u=o.NamedNodeMap;u===void 0&&(o.NamedNodeMap||o.MozNamedAttrMap),o.HTMLFormElement;const h=o.DOMParser,m=o.trustedTypes,g=l.prototype,v=_e(g,"cloneNode"),b=_e(g,"remove"),w=_e(g,"nextSibling"),T=_e(g,"childNodes"),k=_e(g,"parentNode"),z=_e(g,"shadowRoot"),W=_e(g,"attributes"),P=s&&s.prototype?_e(s.prototype,"nodeType"):null,ne=s&&s.prototype?_e(s.prototype,"nodeName"):null,ye=s&&s.prototype?_e(s.prototype,"ownerDocument"):null,Y=function(d){return P?P(d):d.nodeType},F=function(d){return ne?ne(d):d.nodeName};if(typeof r=="function"){const E=t.createElement("template");E.content&&E.content.ownerDocument&&(t=E.content.ownerDocument)}let M,G="",V,ce=!1,Z=0;const y=function(){if(Z>0)throw Ye('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.')},H=function(d){y(),Z++;try{return M.createHTML(d)}finally{Z--}},ae=function(d){y(),Z++;try{return M.createScriptURL(d)}finally{Z--}},Fe=function(){return ce||(V=Qr(m,n),ce=!0),V},L=t,ee=L.implementation,Ge=L.createNodeIterator,pe=L.createDocumentFragment,qe=L.getElementsByTagName,ot=i.importNode;let U=ji();e.isSupported=typeof Cn=="function"&&typeof k=="function"&&ee&&ee.createHTMLDocument!==void 0;const co=Nr,Ft=$r,Lt=Br,po=Hr,Ke=Wr,we=Ur,Se=Gr,uo=Kr;let It=Gi,q=null;const xt=$({},[...Bi,...Co,...Ao,...Do,...Hi]);let K=null;const it=$({},[...Wi,...Mo,...Ui,...Xt]);let ue=Object.seal(ft(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}})),Te=null,Ot=null;const N=Object.seal(ft(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let vt=!0,nt=!0,x=!1,O=!0,Q=!1,te=!0,De=!1,yt=!1,Nt=null,$t=null,ho=!1,rt=!1,Bt=!1,Ht=!1,li=!0,di=!1;const ci="user-content-";let fo=!0,mo=!1,at={},st=null;const pi=$({},["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 ui=null;const hi=$({},["audio","video","img","source","image","track"]);let fi=null;const mi=$({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Wt="http://www.w3.org/1998/Math/MathML",Ut="http://www.w3.org/2000/svg",Re="http://www.w3.org/1999/xhtml";let lt=Re,go=!1,bo=null;const Vn=$({},[Wt,Ut,Re],ko),gi=re(["mi","mo","mn","ms","mtext"]);let xo=$({},gi);const bi=re(["annotation-xml"]);let vo=$({},bi);const Xn=$({},["title","style","font","a","script"]);let wt=null;const Zn=["application/xhtml+xml","text/html"],Qn="text/html";let oe=null,dt=null;const Jn=t.createElement("form"),xi=function(d){return d instanceof RegExp||d instanceof Function},yo=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(dt&&dt===d)return;(!d||typeof d!="object")&&(d={}),d=ke(d),wt=Zn.indexOf(d.PARSER_MEDIA_TYPE)===-1?Qn:d.PARSER_MEDIA_TYPE,oe=wt==="application/xhtml+xml"?ko:Mt,q=Be(d,"ALLOWED_TAGS",xt,{transform:oe}),K=Be(d,"ALLOWED_ATTR",it,{transform:oe}),bo=Be(d,"ALLOWED_NAMESPACES",Vn,{transform:ko}),fi=Be(d,"ADD_URI_SAFE_ATTR",mi,{transform:oe,base:mi}),ui=Be(d,"ADD_DATA_URI_TAGS",hi,{transform:oe,base:hi}),st=Be(d,"FORBID_CONTENTS",pi,{transform:oe}),Te=Be(d,"FORBID_TAGS",ke({}),{transform:oe}),Ot=Be(d,"FORBID_ATTR",ke({}),{transform:oe}),at=be(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?ke(d.USE_PROFILES):d.USE_PROFILES:!1,vt=d.ALLOW_ARIA_ATTR!==!1,nt=d.ALLOW_DATA_ATTR!==!1,x=d.ALLOW_UNKNOWN_PROTOCOLS||!1,O=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Q=d.SAFE_FOR_TEMPLATES||!1,te=d.SAFE_FOR_XML!==!1,De=d.WHOLE_DOCUMENT||!1,rt=d.RETURN_DOM||!1,Bt=d.RETURN_DOM_FRAGMENT||!1,Ht=d.RETURN_TRUSTED_TYPE||!1,ho=d.FORCE_BODY||!1,li=d.SANITIZE_DOM!==!1,di=d.SANITIZE_NAMED_PROPS||!1,fo=d.KEEP_CONTENT!==!1,mo=d.IN_PLACE||!1,It=Lr(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:Gi,lt=typeof d.NAMESPACE=="string"?d.NAMESPACE:Re,xo=_o(d,"MATHML_TEXT_INTEGRATION_POINTS",()=>$({},gi)),vo=_o(d,"HTML_INTEGRATION_POINTS",()=>$({},bi));const f=_o(d,"CUSTOM_ELEMENT_HANDLING",()=>ft(null));if(ue=ft(null),be(f,"tagNameCheck")&&xi(f.tagNameCheck)&&(ue.tagNameCheck=f.tagNameCheck),be(f,"attributeNameCheck")&&xi(f.attributeNameCheck)&&(ue.attributeNameCheck=f.attributeNameCheck),be(f,"allowCustomizedBuiltInElements")&&typeof f.allowCustomizedBuiltInElements=="boolean"&&(ue.allowCustomizedBuiltInElements=f.allowCustomizedBuiltInElements),se(ue),Q&&(nt=!1),Bt&&(rt=!0),at&&(q=$({},Hi),K=ft(null),at.html===!0&&($(q,Bi),$(K,Wi)),at.svg===!0&&($(q,Co),$(K,Mo),$(K,Xt)),at.svgFilters===!0&&($(q,Ao),$(K,Mo),$(K,Xt)),at.mathMl===!0&&($(q,Do),$(K,Ui),$(K,Xt))),N.tagCheck=null,N.attributeCheck=null,be(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?N.tagCheck=d.ADD_TAGS:gt(d.ADD_TAGS)&&(q===xt&&(q=ke(q)),$(q,d.ADD_TAGS,oe))),be(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?N.attributeCheck=d.ADD_ATTR:gt(d.ADD_ATTR)&&(K===it&&(K=ke(K)),$(K,d.ADD_ATTR,oe))),be(d,"ADD_FORBID_CONTENTS")&>(d.ADD_FORBID_CONTENTS)&&(st===pi&&(st=ke(st)),$(st,d.ADD_FORBID_CONTENTS,oe)),fo&&(q["#text"]=!0),De&&$(q,["html","head","body"]),q.table&&($(q,["tbody"]),delete Te.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ye('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ye('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const S=M;M=d.TRUSTED_TYPES_POLICY;try{G=H("")}catch(C){throw M=S,C}}else d.TRUSTED_TYPES_POLICY===null?(M=void 0,G=""):(M===void 0&&(M=Fe()),M&&typeof G=="string"&&(G=H("")));re&&re(d),dt=d},vi=$({},[...Co,...Ao,...Ir]),yi=$({},[...Do,...Or]),er=function(d,f,S){return f.namespaceURI===Re?d==="svg":f.namespaceURI===Wt?d==="svg"&&(S==="annotation-xml"||xo[S]):!!vi[d]},tr=function(d,f,S){return f.namespaceURI===Re?d==="math":f.namespaceURI===Ut?d==="math"&&vo[S]:!!yi[d]},or=function(d,f,S){return f.namespaceURI===Ut&&!vo[S]||f.namespaceURI===Wt&&!xo[S]?!1:!yi[d]&&(Xn[d]||!vi[d])},ir=function(d){let f=k(d);(!f||!f.tagName)&&(f={namespaceURI:lt,tagName:"template"});const S=Mt(d.tagName),C=Mt(f.tagName);return bo[d.namespaceURI]?d.namespaceURI===Ut?er(S,f,C):d.namespaceURI===Wt?tr(S,f,C):d.namespaceURI===Re?or(S,f,C):!!(wt==="application/xhtml+xml"&&bo[d.namespaceURI]):!1},$e=function(d){Tt(e.removed,{element:d});try{k(d).removeChild(d)}catch{if(b(d),!k(d))throw Ye("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},wi=function(d,f,S){try{d.removeAttributeNode(f)}catch{try{d.removeAttribute(S)}catch{}}},Gt=function(d){qt(d);const f=T(d);if(f){const C=[];Xe(f,D=>{Tt(C,D)}),Xe(C,D=>{try{b(D)}catch{}})}const S=W(d);if(S)for(let C=S.length-1;C>=0;--C){const D=S[C],R=D&&D.name;typeof R=="string"&&wi(d,D,R)}},je=function(d,f,S){if(!S)try{S=f.getAttributeNode(d)}catch{S=null}Tt(e.removed,{attribute:S||null,from:f});try{S?f.removeAttributeNode(S):f.removeAttribute(d)}catch{try{f.removeAttribute(d)}catch{}}if(d==="is")if(rt||Bt)try{$e(f)}catch{}else try{f.setAttribute(d,"")}catch{}},nr=function(d){const f=W(d);if(f)for(let S=f.length-1;S>=0;--S){const C=f[S],D=C&&C.name;typeof D!="string"||K[oe(D)]||wi(d,C,D)}},qt=function(d){const f=[d];for(;f.length>0;){const S=f.pop();Y(S)===Ee.element&&nr(S);const D=T(S);if(D)for(let R=D.length-1;R>=0;--R)f.push(D[R])}},Si=function(d,f){return te?d==="patchsrc"?!0:d==="for"&&f!=="label"&&f!=="output":!1},rr=function(d){if(!te)return;const f=[d];for(;f.length>0;){const S=f.pop(),C=Y(S);if(C===Ee.processingInstruction||C===Ee.comment&&le(Ki,S.data)){try{b(S)}catch{}continue}if(C===Ee.element){const R=S,j=oe(F(S));try{R.hasAttribute&&R.hasAttribute("patchsrc")&&R.removeAttribute("patchsrc"),R.hasAttribute&&R.hasAttribute("for")&&Si("for",j)&&R.removeAttribute("for")}catch{}}const D=T(S);if(D)for(let R=D.length-1;R>=0;--R)f.push(D[R])}},Ti=function(d){let f=null,S=null;if(ho)d="<remove></remove>"+d;else{const R=Ii(d,/^[\r\n\t ]+/);S=R&&R[0]}wt==="application/xhtml+xml"&<===Re&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");const C=M?H(d):d;if(lt===Re)try{f=new h().parseFromString(C,wt)}catch{}if(!f||!f.documentElement){f=ee.createDocument(lt,"template",null);try{f.documentElement.innerHTML=go?G:C}catch{}}const D=f.body||f.documentElement;return d&&S&&D.insertBefore(t.createTextNode(S),D.childNodes[0]||null),lt===Re?qe.call(f,De?"html":"body")[0]:De?f.documentElement:D},Ei=function(d){const f=ye?ye(d):d.ownerDocument;return Ge.call(f||d,d,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Kt=function(d){return d=Et(d,co," "),d=Et(d,Ft," "),d=Et(d,Lt," "),d},wo=function(d){var f;d.normalize();const S=ye?ye(d):d.ownerDocument,C=Ge.call(S||d,d,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let D=C.nextNode();for(;D;)D.data=Kt(D.data),D=C.nextNode();const R=(f=d.querySelectorAll)===null||f===void 0?void 0:f.call(d,"template");R&&Xe(R,j=>{ct(j.content)&&wo(j.content)})},jt=function(d){const f=ne?ne(d):null;return typeof f!="string"||oe(f)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==W(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==P(d)||d.childNodes!==T(d)},ct=function(d){if(!P||typeof d!="object"||d===null)return!1;try{return P(d)===Ee.documentFragment}catch{return!1}},St=function(d){if(!P||typeof d!="object"||d===null)return!1;try{return typeof P(d)=="number"}catch{return!1}};function ze(E,d,f){E.length!==0&&Xe(E,S=>{S.call(e,d,f,dt)})}const ar=function(d,f){return!!(te&&d.hasChildNodes()&&!St(d.firstElementChild)&&le(qi,d.textContent)&&le(qi,d.innerHTML)||te&&d.namespaceURI===Re&&Vr[f]&&(St(d.firstElementChild)||typeof d.textContent=="string"&&le(Xr[f],d.textContent))||d.nodeType===Ee.processingInstruction||te&&d.nodeType===Ee.comment&&le(Ki,d.data))},Yt=function(d,f){if(d instanceof RegExp)return le(d,f);if(d instanceof Function){for(var S=arguments.length,C=new Array(S>2?S-2:0),D=2;D<S;D++)C[D-2]=arguments[D];return!!d(f,...C)}return!1},sr=function(d,f,S){if(!Te[f]&&Mi(f)&&Yt(ue.tagNameCheck,f))return!1;if(fo&&!st[f]){const C=k(d),D=T(d);if(D&&C){const R=D.length;for(let j=R-1;j>=0;--j){const X=d===S?v(D[j],!0):D[j];C.insertBefore(X,w(d))}}}return $e(d),!0},ki=function(d,f,S,C){return d.length===0?f:f===S||f===C?ke(f):f},Ci=function(d,f){return d===f||k(d)!==null?!1:(mo&&qt(d),!0)},Ai=function(d,f){if(ze(U.beforeSanitizeElements,d,null),Ci(d,f))return!0;if(jt(d))return $e(d),!0;const S=oe(F(d));if(q=ki(U.uponSanitizeElement,q,xt,Nt),ze(U.uponSanitizeElement,d,{tagName:S,allowedTags:q}),Ci(d,f))return!0;if(ar(d,S))return $e(d),!0;if(Te[S]||!(N.tagCheck instanceof Function&&N.tagCheck(S))&&!q[S]){const D=sr(d,S,f);return D===!1&&ze(U.afterSanitizeElements,d,null),D}if(Y(d)===Ee.element&&!ir(d)||(S==="noscript"||S==="noembed"||S==="noframes")&&le(jr,d.innerHTML))return $e(d),!0;if(Q&&d.nodeType===Ee.text){const D=Kt(d.textContent);d.textContent!==D&&(Tt(e.removed,{element:d.cloneNode()}),d.textContent=D)}return ze(U.afterSanitizeElements,d,null),!1},Di=function(d,f,S){if(Ot[f]||Si(f,d)||li&&(f==="id"||f==="name")&&(S in t||S in Jn))return!1;const C=K[f]||N.attributeCheck instanceof Function&&N.attributeCheck(f,d);return nt&&le(po,f)||vt&&le(Ke,f)?!0:C?fi[f]||le(It,Et(S,Se,""))||(f==="src"||f==="xlink:href"||f==="href")&&d!=="script"&&Oi(S,"data:")===0&&ui[d]||x&&!le(we,Et(S,Se,""))?!0:!S:Mi(d)&&Yt(ue.tagNameCheck,d)&&Yt(ue.attributeNameCheck,f,d)||f==="is"&&ue.allowCustomizedBuiltInElements&&Yt(ue.tagNameCheck,S)},lr=$({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Mi=function(d){return!lr[Mt(d)]&&le(uo,d)},dr=function(d,f,S,C){if(M&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!S)switch(m.getAttributeType(d,f)){case"TrustedHTML":return H(C);case"TrustedScriptURL":return ae(C)}return C},cr=function(d,f,S,C){try{S?d.setAttributeNS(S,f,C):d.setAttribute(f,C),jt(d)?$e(d):Li(e.removed)}catch{je(f,d)}},_i=function(d){ze(U.beforeSanitizeAttributes,d,null);const f=d.attributes;if(!f||jt(d))return;K=ki(U.uponSanitizeAttribute,K,it,$t);const S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:K,forceKeepAttr:void 0};let C=f.length;const D=oe(d.nodeName);for(;C--;){const R=f[C],j=R.name,X=R.namespaceURI,me=R.value,ge=oe(j),To=me;let he=j==="value"?To:Mr(To);if(S.attrName=ge,S.attrValue=he,S.keepAttr=!0,S.forceKeepAttr=void 0,ze(U.uponSanitizeAttribute,d,S),he=S.attrValue,di&&(ge==="id"||ge==="name")&&Oi(he,ci)!==0&&(je(j,d,R),he=ci+he),te&&le(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,he)){je(j,d,R);continue}if(ge==="attributename"&&Ii(he,"href")){je(j,d,R);continue}if(!S.forceKeepAttr){if(!S.keepAttr){je(j,d,R);continue}if(!O&&le(Yr,he)){je(j,d,R);continue}if(Q&&(he=Kt(he)),!Di(D,ge,he)){je(j,d,R);continue}he=dr(D,ge,X,he),he!==To&&cr(d,j,X,he)}}ze(U.afterSanitizeAttributes,d,null)},Vt=function(d){let f=null;const S=Ei(d);for(ze(U.beforeSanitizeShadowDOM,d,null);f=S.nextNode();)if(ze(U.uponSanitizeShadowNode,f,null),Ai(f,d),_i(f),ct(f.content)&&Vt(f.content),Y(f)===Ee.element){const C=z(f);ct(C)&&(So(C),Vt(C))}ze(U.afterSanitizeShadowDOM,d,null)},So=function(d){const f=[{node:d,shadow:null}];for(;f.length>0;){const S=f.pop();if(S.shadow){Vt(S.shadow);continue}const C=S.node,R=Y(C)===Ee.element,j=T(C);if(j)for(let X=j.length-1;X>=0;--X)f.push({node:j[X],shadow:null});if(R){const X=ne?ne(C):null;if(typeof X=="string"&&oe(X)==="template"){const me=C.content;ct(me)&&f.push({node:me,shadow:null})}}if(R){const X=z(C);ct(X)&&f.push({node:null,shadow:X},{node:X,shadow:null})}}};return e.sanitize=function(E){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=null,S=null,C=null,D=null;if(go=!E,go&&(E="<!-->"),typeof E!="string"&&!St(E)&&(E=Fr(E),typeof E!="string"))throw Ye("dirty is not a string, aborting");if(!e.isSupported)return E;yt?(q=Nt,K=$t):yo(d),(U.uponSanitizeElement.length>0||U.uponSanitizeAttribute.length>0)&&(q=ke(q)),U.uponSanitizeAttribute.length>0&&(K=ke(K)),e.removed=[];const R=mo&&typeof E!="string"&&St(E);if(R){rr(E);const me=F(E);if(typeof me=="string"){const ge=oe(me);if(!q[ge]||Te[ge])throw Gt(E),Ye("root node is forbidden and cannot be sanitized in-place")}if(jt(E))throw Gt(E),Ye("root node is clobbered and cannot be sanitized in-place");try{So(E)}catch(ge){throw Gt(E),ge}}else if(St(E))f=Ti("<!---->"),S=f.ownerDocument.importNode(E,!0),S.nodeType===Ee.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?f=S:f.appendChild(S),So(S);else{if(!rt&&!Q&&!De&&E.indexOf("<")===-1)return M&&Ht?H(E):E;if(f=Ti(E),!f)return rt?null:Ht?G:""}f&&ho&&$e(f.firstChild);const j=R?E:f;try{const me=Ei(j);for(;C=me.nextNode();)Ai(C,j),_i(C),ct(C.content)&&Vt(C.content)}catch(me){throw R&&(Gt(E),Xe(e.removed,ge=>{ge.element&&qt(ge.element)})),me}if(R)return Xe(e.removed,me=>{me.element&&qt(me.element)}),Q&&wo(E),E;if(rt){if(Q&&wo(f),Bt)for(D=pe.call(f.ownerDocument);f.firstChild;)D.appendChild(f.firstChild);else D=f;return(K.shadowroot||K.shadowrootmode)&&(D=ot.call(i,D,!0)),D}let X=De?f.outerHTML:f.innerHTML;return De&&q["!doctype"]&&f.ownerDocument&&f.ownerDocument.doctype&&f.ownerDocument.doctype.name&&le(qr,f.ownerDocument.doctype.name)&&(X="<!DOCTYPE "+f.ownerDocument.doctype.name+`>
|
|
3
|
-
`+X),Q&&(X=Kt(X)),M&&Ht?H(X):X},e.setConfig=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yo(E),yt=!0,Nt=q,$t=K},e.clearConfig=function(){dt=null,yt=!1,Nt=null,$t=null,M=V,G=""},e.isValidAttribute=function(E,d,f){dt||yo({});const S=oe(E),C=oe(d);return Di(S,C,f)},e.addHook=function(E,d){typeof d=="function"&&be(U,E)&&Tt(U[E],d)},e.removeHook=function(E,d){if(be(U,E)){if(d!==void 0){const f=Ar(U[E],d);return f===-1?void 0:Dr(U[E],f,1)[0]}return Li(U[E])}},e.removeHooks=function(E){be(U,E)&&(U[E]=[])},e.removeAllHooks=function(){U=ji()},e}var Jr=Mn();const ea={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ta(o){const e=o.options;return String(e.testData||e.formatter||e.title||"")||"条码"}function oa(o){return a("div",{class:"print-qrcode",dataset:{codeId:o.id,codeKind:"qrcode"}})}function ia(o){const e=o.options;return a("div",{class:"print-barcode",dataset:{codeId:o.id,codeKind:"barcode"}},[a("svg",{preserveAspectRatio:ea[String(e.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function na(o){const e=(o.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(t=>!Number.isFinite(t))?null:{width:e[2],height:e[3]}}function ra(o,e){const t=o.options,i=p.barcodeUnitsPerModule(t.barWidth),n=p.barcodeQuietZoneModules(t.barQuietZone),r=s=>{wn(e,ta(o),{format:String(t.barcodeType||"CODE128"),width:i,height:s*i,displayValue:!t.hideTitle,fontSize:(t.fontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*i,margin:0,marginLeft:n*i,marginRight:n*i,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*i});const l=na(e);return l?{widthUnits:l.width,heightUnits:l.height}:null};try{const s=p.layoutBarcodeSize({barHeightMm:t.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(t.width,t.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(t.height,t.maxHeight),dpi:t.printerDpi,barWidth:t.barWidth,measure:r});e.style.width=s.size?`${s.size.widthMm}mm`:"",e.style.height=s.size?`${s.size.heightMm}mm`:""}catch{e.replaceChildren();return}e.setAttribute("shape-rendering","crispEdges")}function aa(o,e){const t=o.options,i=String(t.testData||t.formatter||t.title||"")||"二维码";e.replaceChildren();try{const n=Vo.browserCodeRenderer.render(i,"qrcode",{qrCodeLevel:String(t.qrCodeLevel??"M"),qrQuietZone:typeof t.qrQuietZone=="number"?t.qrQuietZone:void 0}),r=document.createElement("img");r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,r.alt="qrcode",r.style.width="100%",r.style.height="100%",r.style.objectFit=String(t.fit||"contain"),r.style.maxWidth=t.maxWidth?`${t.maxWidth}mm`:"100%",r.style.maxHeight=t.maxHeight?`${t.maxHeight}mm`:"100%",e.appendChild(r)}catch{}}function sa(o,e){for(const t of Array.from(o.querySelectorAll("[data-code-kind]"))){const i=t.dataset.codeId,n=e.find(r=>r.id===i);if(n)if(t.dataset.codeKind==="barcode"){const r=t.querySelector("svg");r&&ra(n,r)}else aa(n,t)}}const la={header:"题",data:"数",subtotal:"小",summary:"汇"},da=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],eo=3.7795275591,ca=.1,Ho=o=>JSON.parse(JSON.stringify(o)),Yi=new WeakMap;function Ne(o){let e=Yi.get(o);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},Yi.set(o,e)),e}function Pt(o,e){return o.templateData.elements.find(t=>t.id===e)??null}function pa(o,e){const t=o.tableSelection;return!t||t.elementId!==e.id?null:o.selectedElement?.id!==e.id?(o.tableSelection=null,null):t}function _n(o,e,t){const i=Pt(o,t.id);if(!i)return null;const n=t.options;return{store:o,fire:e,el:t,real:i,options:n,rows:n.tableRows??[],colWidths:n.tableColWidths??[],isSelected:o.selectedIds.has(t.id),selection:pa(o,t),maxTableWidth:Rn(o)}}function Rn(o){return o.paperSize.width-o.templateData.margins.left-o.templateData.margins.right}function Zo(o){return o.options.tableDefaultFontSize??10}function zn(o){return o.options.tableDefaultColor??"#333333"}function ua(o,e){let t=0;for(let i=0;i<e;i++)t+=o.rows[i].height;return t}function ha(o,e){return Ne(o.store).layouts.get(o.el.id)?.[e]?.top??ua(o,e)}function fa(o,e){return Ne(o.store).layouts.get(o.el.id)?.[e]?.height??o.rows[e]?.height??0}function ma(o){const e=o.options.dataSource;if(e&&Array.isArray(p.DEFAULT_DEMO_DATA[e]))return p.DEFAULT_DEMO_DATA[e];for(const t of Object.values(p.DEFAULT_DEMO_DATA))if(Array.isArray(t))return t}function Pn(o){return o.cellType==="barcode"||o.cellType==="qrcode"}function Fn(o,e){return Pn(e)?p.resolveBarcodeDesignValue(e.formatter,ma(o)):e.formatter||""}function ga(o,e){const t={designMode:!0,showGhostBorder:o.store.showTableGhostBorder};return{fontFamily:A.resolveCanvasFontFamily(e.fontFamily??o.options.tableDefaultFontFamily),textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??Zo(o))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??zn(o),backgroundColor:e.backgroundColor??"transparent",borderTop:p.resolveCellBorderCss(e.borders?.top,t),borderRight:p.resolveCellBorderCss(e.borders?.right,t),borderBottom:p.resolveCellBorderCss(e.borders?.bottom,t),borderLeft:p.resolveCellBorderCss(e.borders?.left,t),padding:(e.padding??o.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"pre-wrap":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function ba(o,e,t){const i=o.selection;return[!!i&&e>=i.r1&&e<=i.r2&&t>=i.c1&&t<=i.c2?"cell-selected":"",o.rows[e]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Ln(o){return p.resolveCellTextFit(o)}function xa(o){return Ln(o)!=="autoHeight"}function va(o,e){return e.fontSize??Zo(o)}function ro(o,e,t){return p.cellFitCapMm(o.rows,e,t,o.options.tableDefaultPadding??1)}function ya(o,e,t){return p.cellFitWidthMm(o.colWidths,e,t,o.options.tableDefaultPadding??1)}function wa(o,e,t){return{maxHeight:ro(o,t,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function Sa(o,e,t){const i={fitBase:String(va(o,e)),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize)),fitMm:String(ro(o,t,e))};return Ln(e)==="shrink"&&(i.fit="shrink"),i}function Ta(o){const e=(o.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(t=>!Number.isFinite(t))?null:{width:e[2],height:e[3]}}const Ea={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ka(o,e,t,i){const n=document.createElement("div");n.className="cell-barcode";const r=document.createElementNS(fr,"svg");n.appendChild(r);const s=Fn(o,i);if(i.cellType==="barcode"){r.setAttribute("preserveAspectRatio",Ea[i.fit||"contain"]??"xMidYMid meet");const l=p.barcodeUnitsPerModule(i.barWidth),c=p.barcodeQuietZoneModules(i.barQuietZone),u=g=>{wn(r,s,{format:i.barcodeType||"CODE128",width:l,height:g*l,displayValue:i.showBarcodeText!==!1,fontSize:(i.barFontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*l,margin:0,marginLeft:c*l,marginRight:c*l,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*l});const v=Ta(r);return v?{widthUnits:v.width,heightUnits:v.height}:null};let h=null;try{h=p.layoutBarcodeSize({barHeightMm:i.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(ya(o,t,i),i.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(ro(o,e,i),i.maxHeight),dpi:i.printerDpi,barWidth:i.barWidth,measure:u})}catch{h=null}if(!h){r.style.display="none";const g=document.createElement("span");return g.className="cell-barcode-fallback",g.textContent=s||"条码",n.appendChild(g),n}const m=h.size;return m?(r.style.width=`${m.widthMm}mm`,r.style.height=`${m.heightMm}mm`):(r.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",r.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%"),r.setAttribute("shape-rendering","crispEdges"),n}if(r.style.display="none",!s)return n;try{const l=Vo.browserCodeRenderer.render(s,"qrcode",{qrCodeLevel:String(i.qrCodeLevel||"M"),qrQuietZone:typeof i.qrQuietZone=="number"?i.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=i.fit||"contain",i.objectPosition&&(c.style.objectPosition=i.objectPosition),c.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",c.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%",n.appendChild(c)}catch{}return n}function Vi(){const o=document.createElement("div");return o.className="image-placeholder",o.textContent="图片",o}function Ca(o){const e=o.formatter||"";return e?e.includes("{")?p.evaluateTemplate(e,p.DEFAULT_DEMO_DATA):e:""}function Aa(o,e,t){const i=document.createElement("div");i.className="cell-image";const n=p.cellImageBoxMm(t.fit,ro(o,e,t));n!==void 0&&(i.style.height=`${n}mm`);const r=Ca(t);if(!r)return i.appendChild(Vi()),i;const s=document.createElement("img");s.setAttribute("src",r),n!==void 0&&(s.style.width="100%",s.style.height="100%"),s.style.objectFit=t.fit||"contain";for(const[l,c]of Object.entries(p.cropStyleDeclarations(t.fit,t.fitScale,t.objectPosition)))s.style[l]=c;return s.style.maxWidth=t.maxWidth?`${t.maxWidth}mm`:"100%",s.style.maxHeight=t.maxHeight?`${t.maxHeight}mm`:"100%",s.addEventListener("error",()=>{s.remove(),i.appendChild(Vi())},{once:!0}),i.appendChild(s),i}function Da(o,e,t,i,n){if(Pn(n))return ka(o,t,i,n);if(n.cellType==="image")return Aa(o,t,n);const r=Fn(o,n),s=()=>e.type==="data"?a("span",{class:"data-placeholder",text:r}):r;return xa(n)?a("div",{class:"cell-fit",style:wa(o,n,t),dataset:Sa(o,n,t)},[s()]):s()}function oo(o,e,t){const i={elementId:o.el.id,...p.normalizeSelection(o.rows,e,t)};o.store.setTableSelection(i),o.fire("table-selection-change",{elementId:o.el.id,selection:i})}function Ma(o,e,t,i,n){if(n.button!==0||(o.fire("table-cell-mousedown",{elementId:o.el.id,r:e,c:t,cellId:i,event:n}),!o.isSelected))return;n.stopPropagation();const r=Ne(o.store);n.shiftKey&&o.selection?oo(o,{r:o.selection.r1,c:o.selection.c1},{r:e,c:t}):(r.anchor={r:e,c:t},oo(o,{r:e,c:t},{r:e,c:t})),document.addEventListener("mouseup",()=>{Ne(o.store).anchor=null},{once:!0})}function _a(o,e,t){const i=Ne(o.store).anchor;i&&oo(o,i,{r:e,c:t})}function In(o,e){const t=Ne(o);t.menu?.visible&&(t.menu.visible=!1,e("table-menu-close",{elementId:t.menuElId}),o.emit(!1))}function Ra(o,e,t,i){i.preventDefault(),i.stopPropagation(),o.isSelected||o.store.selectOne(o.el.id);const n=o.selection;n&&e>=n.r1&&e<=n.r2&&t>=n.c1&&t<=n.c2||oo(o,{r:e,c:t},{r:e,c:t});const s=Ne(o.store);s.menuElId=o.el.id,s.menu&&(s.menu.x=i.clientX,s.menu.y=i.clientY,s.menu.visible=!0),o.fire("table-cell-contextmenu",{elementId:o.el.id,r:e,c:t,clientX:i.clientX,clientY:i.clientY}),o.store.emit(!1),document.addEventListener("mousedown",()=>In(o.store,o.fire),{once:!0})}function Xi(o,e,t){const i=o.reduce((n,r)=>n+r,0)+(o[e]??0);return i>t?`插入后表格总宽 ${Math.round(i*10)/10}mm 超过打印范围宽度 ${t}mm,请先缩小列宽`:null}function za(o,e){const t=o.real.options.tableRows??[],i=o.real.options.tableColWidths??[],n=e(Ho(t),Ho(i));return n?(window.alert(n),!1):(o.store.recordHistory(),e(t,i),o.store.setTableSelection(null),p.syncTableElementSize(o.real.options),o.store.emit(),!0)}function Le(o,e,t){In(o.store,o.fire);const i=o.selection;if(!i)return;let n=null;switch(e){case"insert-row-above":n=r=>(p.insertRow(r,i.r1,"above"),null);break;case"insert-row-below":n=r=>(p.insertRow(r,i.r2,"below"),null);break;case"delete-row":n=r=>p.deleteRow(r,i.r1);break;case"insert-col-left":n=(r,s)=>{const l=Xi(s,i.c1,o.maxTableWidth);return l||(p.insertCol(r,s,i.c1,"left"),null)};break;case"insert-col-right":n=(r,s)=>{const l=Xi(s,i.c2,o.maxTableWidth);return l||(p.insertCol(r,s,i.c2,"right"),null)};break;case"delete-col":n=(r,s)=>p.deleteCol(r,s,i.c1);break;case"merge":n=r=>(p.mergeCells(r,i),null);break;case"split":n=r=>(p.splitCells(r,i),null);break;case"set-row-type":n=r=>t?p.setRowType(r,i.r1,t):"未指定行类型";break}n&&za(o,n)&&o.fire(`table-${e}`,{elementId:o.el.id,...t?{type:t}:{}})}function Pa(o){const e=o.selection;if(!e)return!1;for(let t=e.r1;t<=e.r2;t++)for(let i=e.c1;i<=e.c2;i++){const n=o.rows[t]?.cells[i];if(n&&!n.merged&&((n.rowspan??1)>1||(n.colspan??1)>1))return!0}return!1}function Zi(o,e){const t=o.selection;return t?t.r1!==t.r2?"行类型仅支持单行设置":p.setRowType(Ho(o.rows),t.r1,e):"未选择单元格"}function Ie(o,e,t={}){return a("div",{class:`menu-item${t.disabled?" disabled":""}${t.active?" active":""}`,title:t.title||"",text:o,onClick:()=>{t.disabled||e()}})}const Ro=()=>a("div",{class:"menu-divider"});function Fa(o,e,t){const i=Ne(o);if(i.menu=t,!t.visible||!i.menuElId)return"";const n=Pt(o,i.menuElId);if(!n||n.printElementType.type!=="table")return"";const r=_n(o,e,n);if(!r)return"";const s=r.selection?p.canMergeReason(r.rows,r.selection):"未选择单元格",l=r.selection?r.rows[r.selection.r1]?.type??null:null;return a("div",{class:"table-ctx-menu",style:{left:t.x+"px",top:t.y+"px"},onMousedown:c=>c.stopPropagation()},[Ie("在上方插入行",()=>Le(r,"insert-row-above")),Ie("在下方插入行",()=>Le(r,"insert-row-below")),Ie("删除行",()=>Le(r,"delete-row"),{disabled:r.rows.length<=1}),Ro(),Ie("在左侧插入列",()=>Le(r,"insert-col-left")),Ie("在右侧插入列",()=>Le(r,"insert-col-right")),Ie("删除列",()=>Le(r,"delete-col"),{disabled:r.colWidths.length<=1}),Ro(),Ie("合并单元格",()=>Le(r,"merge"),{disabled:!!s,title:s||""}),Ie("拆分单元格",()=>Le(r,"split"),{disabled:!Pa(r)}),Ro(),a("div",{class:"menu-group-title",text:"行类型"}),...da.map(c=>Ie(c.label,()=>Le(r,"set-row-type",c.value),{disabled:!!Zi(r,c.value),title:Zi(r,c.value)||"",active:l===c.value}))])}let et=null;function On(){et&&(document.removeEventListener("mousemove",Qo),document.removeEventListener("mouseup",Jo),et.handle.classList.remove("dragging"),et=null)}function La(o,e){const t=o.closest(".hiprint-printPaper");return(t&&t.offsetWidth>0?t.getBoundingClientRect().width/t.offsetWidth:0)||(e.scale||100)/100}function Ia(o,e,t){if(t.button!==0)return;const i=t.currentTarget,n=i.closest(".print-table");if(!n)return;On();const r=o.real.options.tableColWidths??[];et={store:o.store,fire:o.fire,elId:o.real.id,boundary:e,startX:t.clientX,startWidth:r[e-1]??0,scale:La(n,o.store),root:n,wrapper:i.closest(".print-element"),handle:i},i.classList.add("dragging"),o.store.recordHistory(),document.addEventListener("mousemove",Qo),document.addEventListener("mouseup",Jo)}function Qo(o){const e=et;if(!e)return;const t=Pt(e.store,e.elId),i=t?.options.tableColWidths;if(!t||!i)return;const n=(o.clientX-e.startX)/(e.scale*eo),r=e.boundary-1;i[r]=p.clampResizedColumnWidth(i,r,e.startWidth+n,Rn(e.store)),p.syncTableElementSize(t.options),i.forEach((s,l)=>{const c=e.root.querySelector(`colgroup col:nth-child(${l+1})`);c&&(c.style.width=`${s}mm`)}),e.root.querySelectorAll(".col-resize-handle").forEach((s,l)=>{s.style.left=`${i.slice(0,l+1).reduce((c,u)=>c+u,0)}mm`}),e.wrapper&&(e.wrapper.style.width=`${t.options.width}mm`,e.wrapper.style.height=`${t.options.height}mm`)}function Jo(){document.removeEventListener("mousemove",Qo),document.removeEventListener("mouseup",Jo);const o=et;if(!o)return;et=null,o.handle.classList.remove("dragging");const e=Pt(o.store,o.elId);e&&p.syncTableElementSize(e.options),o.store.emit(),o.fire("table-col-resize-end",{elementId:o.elId})}function Oa(o,e,t){const i=t.querySelector("table");if(!i)return;const n=i.offsetHeight;if(n<=0)return;const r=Pt(o,e);if(!r)return;let s=!1;const l=n/eo;Math.abs(l-(r.options.height??0))>ca&&(r.options.height=Math.round(l*100)/100,s=!0);const c=i.offsetTop,u=Array.from(i.rows).map(m=>({top:(m.offsetTop-c)/eo,height:m.offsetHeight/eo})),h=Ne(o);Na(h.layouts.get(e),u)||(h.layouts.set(e,u),s=!0),s&&o.emit(!1)}function Na(o,e){return!o||o.length!==e.length?!1:e.every((t,i)=>{const n=o[i];return Math.round(t.top*10)===Math.round(n.top*10)&&Math.round(t.height*10)===Math.round(n.height*10)})}function $a(o,e){const t=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!t.isConnected)return;const i=t.parentElement;i&&Oa(o,e,i)}),t}function Ba(o){return o.isSelected&&!o.real.options.locked&&o.colWidths.length>=1}function Ha(o){return Array.from({length:o.colWidths.length},(e,t)=>t+1)}function Wa(o,e){return o.colWidths.slice(0,e).reduce((t,i)=>t+i,0)}function Ua(o,e,t){const i=_n(e,t,o);if(!i)return a("div",{class:"print-table"});const n=[a("table",{style:{fontSize:`${Zo(i)}pt`,color:zn(i)}},[a("colgroup",{},i.colWidths.map(r=>a("col",{style:{width:r+"mm"}}))),a("tbody",{},i.rows.map((r,s)=>a("tr",{style:{height:r.height+"mm"}},r.cells.map((l,c)=>l.merged?"":a("td",{rowspan:l.rowspan||1,colspan:l.colspan||1,class:ba(i,s,c),style:ga(i,l),onMousedown:u=>Ma(i,s,c,l.id,u),onMouseenter:()=>_a(i,s,c),onContextmenu:u=>Ra(i,s,c,u)},[Da(i,r,s,c,l)])).filter(Boolean))))])];return Ba(i)&&n.push(a("div",{class:"col-resize-layer"},Ha(i).map(r=>a("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${r}`,style:{left:Wa(i,r)+"mm"},onMousedown:s=>{s.stopPropagation(),s.preventDefault(),Ia(i,r,s)}})))),i.isSelected&&n.push(a("div",{class:"row-badges"},i.rows.map((r,s)=>a("span",{class:"row-badge",style:{top:ha(i,s)+"mm",height:fa(i,s)+"mm"},text:la[r.type]})))),n.push($a(e,o.id)),a("div",{class:"print-table design-mode",dataset:{tableId:o.id},onContextmenu:r=>r.preventDefault()},n)}const Ga=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function Wo(o){return Array.isArray(o)&&o.length>0?o:[]}function qa(o,e){const t=p.detectFlowListKey(o,e)??(e?Object.keys(e).find(n=>Array.isArray(e[n])):void 0);if(t)return Wo(e?.[t]);const i=p.detectFlowListKey(o,p.DEFAULT_DEMO_DATA);return i?Wo(p.DEFAULT_DEMO_DATA[i]):[]}function Ka(o,e){const t=o.options,i=typeof t.formatter=="string"?t.formatter:"",n=Wo(e)[0],r=qa(i,n);if(r.length===0)return[...Ga];if(!i)return r.map(c=>String(c?.name??JSON.stringify(c)));const s=n??{},l=p.detectFlowListKey(i,s)??Object.keys(s).find(c=>Array.isArray(s[c]));return r.map(c=>{try{return p.evaluateTemplate(i,{...s,...c,...l?{[l]:c}:{}})}catch{return i}})}function ja(o,e){const t=o.options,i=p.resolveFlowColumns(t.flowColumns),n=p.resolveFlowGapX(t.flowGapX),r=p.resolveFlowRowHeight(t.flowRowHeight),s={display:"grid",gridTemplateColumns:`repeat(${i},minmax(0,1fr))`,columnGap:`${n}mm`,gridAutoRows:`minmax(${r}mm,auto)`,width:"100%",height:"100%",overflow:"hidden",fontSize:`${t.fontSize||12}pt`,fontWeight:t.fontWeight||"normal",color:t.color||"#333",boxSizing:"border-box"};return t.fontFamily&&(s.fontFamily=String(t.fontFamily)),t.backgroundColor&&(s.backgroundColor=String(t.backgroundColor)),a("div",{class:"print-flowlist",style:s},Ka(o,e).map(l=>a("div",{class:"print-flow-cell",text:l})))}const Qi={top:"flex-start",middle:"center",bottom:"flex-end"},Ya={left:"flex-start",center:"center",right:"flex-end"};function Va(o,e){const t=o.options,i=p.resolveElementBorder(o.printElementType.type,t),n={};if(i?.all&&(n.border=`${i.all.borderWidth} ${i.all.borderStyle} ${i.all.borderColor}`),i)for(const r of p.ELEMENT_BORDER_SIDES){const s=i.edges[r];s&&(n[`border${r.charAt(0).toUpperCase()}${r.slice(1)}`]=`${s.borderWidth} ${s.borderStyle} ${s.borderColor}`)}return{position:"absolute",left:`${t.left}mm`,top:`${t.top}mm`,width:`${t.width}mm`,height:`${t.height}mm`,zIndex:String(t.zIndex||"auto"),...n,...Xa(o,e)}}function Xa(o,e){if(e?.has(o.id))return{};const t=p.resolveElementRotation(o.printElementType.type,o.options);return t===void 0?{}:{rotate:`${t}deg`}}function Ji(o){const e=o.options,t=o.printElementType.type==="longText",i=p.resolveElementTextFit(o.printElementType.type,e),n=e.fontSize||12,r=i==="autoHeight",s={fontSize:`${n}pt`,fontWeight:e.fontWeight||"normal",fontFamily:A.resolveCanvasFontFamily(e.fontFamily),color:e.color||"#333",backgroundColor:e.backgroundColor||"transparent",textAlign:e.textAlign||"left",...e.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:e.lineHeight?`${e.lineHeight}pt`:t?"1.5":"normal",letterSpacing:e.letterSpacing?`${e.letterSpacing}pt`:"normal",width:"100%",height:r?"auto":"100%",boxSizing:"border-box",overflow:r?"visible":"hidden",...t?{wordBreak:"break-all",textIndent:e.longTextIndent?`${e.longTextIndent}em`:"0"}:{textDecoration:e.textDecoration||"none",padding:`${e.contentPaddingTop||0}pt ${e.contentPaddingRight||0}pt ${e.contentPaddingBottom||0}pt ${e.contentPaddingLeft||0}pt`}};p.resolveElementNowrap(e)&&(s.whiteSpace="nowrap",s.textOverflow="ellipsis");const l=p.resolveElementWhiteSpace(e);return l&&(s.whiteSpace=l),e.verticalAlign&&(s.display="flex",e.textAlign==="justify"?(s.flexDirection="column",s.justifyContent=Qi[e.verticalAlign]??"flex-start"):(s.alignItems=Qi[e.verticalAlign]??"flex-start",s.justifyContent=Ya[e.textAlign||"left"]??"flex-start")),{style:s,fit:i}}function Za(o){const e=o.options,t=`${e.borderWidth||.75}pt`,i=e.borderStyle||"solid",n=e.borderColor||"#333";return o.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${t} ${i} ${n}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${t} ${i} ${n}`,boxSizing:"border-box"}}function Qa(o){const e=o.options;return{width:"100%",height:"100%",borderWidth:`${e.borderWidth||1}pt`,borderStyle:e.borderStyle||"solid",borderColor:e.borderColor||"#333",backgroundColor:e.backgroundColor||"transparent",borderRadius:o.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Ja(o){const e=o.options;return{objectFit:e.fit||"contain",...p.cropStyleDeclarations(e.fit,e.fitScale,e.objectPosition),maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function en(o){const e=o.options,t={fitBase:String(e.fontSize||12),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize))};return p.resolveElementTextFit(o.printElementType.type,e)==="shrink"&&(t.fit="shrink"),t}function es(o,e,t){const i=o.printElementType.type,n=o.options;switch(i){case"text":{const{style:r}=Ji(o);return a("div",{class:"print-text",style:r,dataset:en(o),text:String(n.testData||n.formatter||"")||"文本"})}case"longText":{const{style:r}=Ji(o);return a("div",{class:"print-longtext",style:r,dataset:en(o),text:String(n.formatter||"")||"长文本内容"})}case"hline":case"vline":return a("div",{class:"print-line",style:Za(o)});case"rect":case"oval":return a("div",{class:"print-shape",style:Qa(o)});case"image":{const r=String(n.src??""),s=r.includes("{")?p.evaluateTemplate(r,p.DEFAULT_DEMO_DATA):r;return a("div",{class:"print-image"},[s?a("img",{src:s,style:Ja(o)}):a("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return oa(o);case"barcode":return ia(o);case"html":{const r=String(n.formatter??""),s=r?Jr.sanitize(p.evaluateTemplate(r,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return a("div",{class:"print-html",html:s})}case"pageNumber":return a("div",{class:"page-number-element",style:{fontSize:`${n.fontSize||12}pt`,fontWeight:n.fontWeight||"normal",fontFamily:A.resolveCanvasFontFamily(n.fontFamily),color:n.color||"#333",textAlign:n.textAlign||"left",...n.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:n.title||"{pageIndex}/{totalPages}"});case"table":return t?Ua(o,t.store,t.fire):a("div",{class:"print-table"});case"flowList":return ja(o);default:return a("div",{text:i})}}function Nn(o){return`x:${Math.round(o.left)} y:${Math.round(o.top)} ${Math.round(o.width)}×${Math.round(o.height)}mm`}function ts(o,e,t){const i=o.store,n=i.selectedIds.has(e.id),r=i.previewIds.has(e.id),s=e.options,l=e.zone||"content",c=[es(e,!0,{store:i,fire:o.fire})];return i.draggingIds.has(e.id)&&c.push(a("div",{class:"drag-preview"})),n&&(c.push(a("div",{class:"resize-handles"},p.RESIZE_POINTS.map(u=>a("div",{class:`resize-handle handle-${u}`,dataset:{point:u,elId:e.id},onMousedown:h=>o.fire("resize-start",{event:h,id:e.id,point:u})})))),c.push(a("div",{class:"selected-indicator"},[a("div",{class:"position-label",text:Nn(s)})]))),a("div",{class:["print-element",`type-${e.printElementType.type}`,`zone-${l}`,n?"selected":"",r?"previewed":"",i.draggingIds.has(e.id)?"drag-ghost":"","design-mode",s.locked?"locked":"",s.visible===!1?"hidden":""].filter(Boolean).join(" "),style:Va(e,t),dataset:{elId:e.id},onMousedown:u=>o.fire("element-mousedown",{event:u,id:e.id}),onContextmenu:u=>{u.preventDefault(),u.stopPropagation(),o.fire("contextmenu",{event:u,id:e.id})}},c)}function Uo(o,e){const t=o.margins,i=o.header?.height??10,n=o.footer?.height??10,r=e.width-t.left-t.right;return{header:{left:t.left,top:t.top,width:r,height:i},content:{left:t.left,top:t.top+i,width:r,height:e.height-t.top-t.bottom-i-n},footer:{left:t.left,top:e.height-t.bottom-n,width:r,height:n}}}const os='<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 tn(o,e){return o.type==="vertical"?{left:`${o.position}mm`,top:"0",height:`${e.height}mm`,borderLeftColor:o.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${o.position}mm`,left:"0",width:`${e.width}mm`,borderTopColor:o.color||"var(--pd-accent-secondary, #f56c6c)"}}function is(o,e){const t=A.resolveWatermarkLayout(o.watermark,[],e);return t?a("div",{class:"watermark-layer",style:{opacity:String(t.opacity)}},t.tiles.map(i=>a("svg",{class:"watermark-tile",width:`${i.widthMm}mm`,height:`${i.heightMm}mm`,viewBox:`0 0 ${t.tileWidthPx} ${t.tileHeightPx}`,style:{left:`${i.leftMm}mm`,top:`${i.topMm}mm`}},[a("text",{x:String(t.tileWidthPx/2),y:String(t.tileHeightPx/2),"font-size":String(t.fontSizePx),fill:t.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${t.rotate},${t.tileWidthPx/2},${t.tileHeightPx/2})`,text:t.text})]))):""}function zo(o,e,t,i,n,r){const s=o.store,l=[];t!=="content"&&l.push(a("span",{class:"zone-label",text:t==="header"?"页眉":"页脚"}));const c=t==="content"?A.collectFollowMemberIds(n):void 0;if(l.push(...n.map(u=>ts(o,u,c))),t!=="content"){const u=t==="header"?"bottom":"top";l.push(a("div",{class:`zone-resize-handle handle-${u}`,dataset:{zone:t},onMousedown:h=>o.fire("zone-resize",{event:h,zone:t})},[e.zoneResizing===t?a("div",{class:"zone-height-tip",text:`${(t==="header"?s.templateData.header.height:s.templateData.footer.height).toFixed(1)}mm`}):""]))}return a("div",{class:`zone-layer zone-${t} design-mode`,style:{position:"absolute",left:`${i.left}mm`,top:`${i.top}mm`,width:`${i.width}mm`,height:`${i.height}mm`},dataset:{zone:t,paperWidth:String(r.width),paperHeight:String(r.height)}},l.filter(Boolean))}function ns(o,e){const t=o.store,i=t.templateData,n=A.getPaperDimensions(i),r=(t.scale||100)/100,s=Uo(i,n),l=m=>t.elements.filter(g=>(g.zone||"content")===m),c=a("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${i.margins.top}mm ${i.margins.right}mm ${i.margins.bottom}mm ${i.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${n.height}mm`}},[t.showGrid?a("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(os)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...i.watermark&&Object.keys(i.watermark).length?[is(i,n)]:[],zo(o,e,"header",s.header,l("header"),n),zo(o,e,"content",s.content,l("content"),n),zo(o,e,"footer",s.footer,l("footer"),n),...t.adsorbGuides.map(m=>a("div",{class:`adsorb-guide guide-${m.type}`,style:tn(m,n)})),...(i.guides??[]).map(m=>a("div",{class:`manual-guide guide-${m.type}`,style:{...tn(m,n),"--guide-hit":`${8/r}px`},dataset:{guideId:String(m.id??"")},onMousedown:g=>o.fire("guide-mousedown",{event:g,id:m.id}),onDblclick:g=>{g.preventDefault(),o.fire("guide-remove",m.id)}}))].filter(Boolean)),u=a("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${n.width}mm`,minHeight:`${n.height}mm`,background:i.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(${r})`,transformOrigin:"0 0"}},[...i.designBackground?.src?[a("div",{class:"design-background",style:{width:`${n.width}mm`,height:`${n.height}mm`,left:"0",top:"0",transform:i.designBackground.rotation?`rotate(${i.designBackground.rotation}deg)`:""}},[a("img",{src:i.designBackground.src,draggable:!1,alt:""})])]:[],c]),h=[a("div",{class:"canvas-scroll"},[a("div",{class:"paper-wrapper",style:{width:`${A.mmToPx(n.width)*r}px`,height:`${A.mmToPx(n.height)*r}px`,position:"relative"}},[u])])];if(t.showRuler&&h.push(a("div",{class:"ruler-overlay",style:{transform:`translate(${e.scrollX}px, ${e.scrollY}px)`}},[a("div",{class:"ruler-corner"}),a("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${e.geom.viewW}px`,height:"20px"},onMousedown:m=>o.fire("ruler-mousedown",{event:m,orientation:"horizontal"})}),a("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${e.geom.viewH}px`},onMousedown:m=>o.fire("ruler-mousedown",{event:m,orientation:"vertical"})})])),e.guidePreview&&h.push(a("div",{class:`ruler-guide-preview guide-${e.guidePreview.type}`,style:e.guidePreview.type==="vertical"?{left:`${e.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${e.guidePreview.position}px`,left:"0",width:"100%"}})),e.marquee.visible&&h.push(a("div",{class:"marquee-selection",style:{left:`${e.marquee.x}px`,top:`${e.marquee.y}px`,width:`${e.marquee.w}px`,height:`${e.marquee.h}px`}})),e.contextMenu.visible){const m=e.contextMenu;h.push(a("div",{class:"context-menu",style:{left:`${e.contextMenu.x+e.contextMenu.flipX}px`,top:`${e.contextMenu.y+e.contextMenu.flipY}px`}},e.contextMenu.targetId?[Me(o,m,"复制","copy"),Me(o,m,"剪切","cut"),Me(o,m,"粘贴","paste",!t.hasClipboard),Me(o,m,"删除","delete"),a("div",{class:"context-menu-sep"}),Me(o,m,"置顶","move-layer",!1,"top"),Me(o,m,"上移","move-layer",!1,"up"),Me(o,m,"下移","move-layer",!1,"down"),Me(o,m,"置底","move-layer",!1,"bottom")]:[Me(o,m,"粘贴","paste-at",!t.hasClipboard),Me(o,m,"全选","select-all"),Me(o,m,"取消选择","clear-selection")]))}return a("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:m=>m.preventDefault(),onDrop:m=>o.fire("drop",m),onMousedown:m=>o.fire("canvas-mousedown",m),onMousemove:m=>o.fire("canvas-mousemove",m),onMouseleave:()=>o.fire("canvas-mouseleave"),onWheel:m=>o.fire("wheel",m),onScroll:m=>o.fire("scroll",m),onContextmenu:m=>{m.preventDefault(),o.fire("canvas-contextmenu",m)}},h.filter(Boolean))}function Me(o,e,t,i,n=!1,r){return a("div",{class:`context-menu-item${n?" disabled":""}`,text:t,onClick:()=>{e.visible=!1,n||o.fire(i,r),o.repaint()}})}const rs={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" />',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 ve(o,e=15,t){const i=rs[o];return i?`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}"${t?` class="${t}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i}</svg>`:""}let Je=null;function ei(o){const e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(o.trim());if(!e)return null;const t=e[1],i=t.length===3?t.split("").map(n=>n+n).join(""):t;return{r:Number.parseInt(i.slice(0,2),16),g:Number.parseInt(i.slice(2,4),16),b:Number.parseInt(i.slice(4,6),16)}}function ti(o){const e=ei(o);return e?$n(e):"#000000"}function $n({r:o,g:e,b:t}){return`#${[o,e,t].map(i=>Math.round(zt(i/255)*255).toString(16).padStart(2,"0")).join("")}`}function as(o,e,t){const i=o/255,n=e/255,r=t/255,s=Math.max(i,n,r),l=Math.min(i,n,r),c=s-l;let u=0;return c!==0&&(s===i?u=(n-r)/c%6:s===n?u=(r-i)/c+2:u=(i-n)/c+4,u*=60,u<0&&(u+=360)),{h:u,s:s===0?0:c/s,v:s}}function ss(o,e,t){const i=t*e,n=(o%360+360)%360/60,r=i*(1-Math.abs(n%2-1)),[s,l,c]=n<1?[i,r,0]:n<2?[r,i,0]:n<3?[0,i,r]:n<4?[0,r,i]:n<5?[r,0,i]:[i,0,r],u=t-i;return{r:(s+u)*255,g:(l+u)*255,b:(c+u)*255}}function ls(o){return((Number.isFinite(o)?o:0)%360+360)%360}function zt(o){return Math.min(1,Math.max(0,Number.isFinite(o)?o:0))}function ds(o){const e=o.title??"颜色选择";return a("button",{type:"button",class:`preset-color-trigger${o.triggerClass?` ${o.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:e,onClick:t=>{const i=t.currentTarget??t.target,n=i.getRootNode();if(!!Je&&Je.root===n&&Je.title===e&&Je.trigger===i){_t();return}_t(),cs(i,o)}},[a("span",{class:"preset-color-swatch",style:o.value?{background:o.value}:{background:"transparent"}})])}function _t(){const o=Je;o&&(Je=null,o.teardowns.forEach(e=>e()),o.trigger.setAttribute("aria-expanded","false"),o.panel.remove())}function cs(o,e){const t=o.getRootNode(),i=t instanceof ShadowRoot?t:document.body,n={root:t,title:e.title??"颜色选择",trigger:o,panel:null,clearable:e.clearable!==!1,onChange:e.onChange,model:e.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:[]};e.value&&ii(n,e.value)?n.hexText=ti(e.value).toUpperCase():n.hexText=e.value?String(e.value):"",n.panel=fe(fs(n),i),n.current=n.panel.querySelector(".picker-current"),n.hex=n.panel.querySelector(".picker-hex"),n.area=n.panel.querySelector(".picker-area"),n.handle=n.panel.querySelector(".picker-handle"),n.hueRange=n.panel.querySelector(".picker-hue"),n.clearBtn=n.panel.querySelector(".picker-clear"),n.items=Array.from(n.panel.querySelectorAll(".preset-color-item")).map((r,s)=>({el:r,color:p.PRESET_COLORS[s]})),ao(n),ps(n),us(n),Je=n,o.setAttribute("aria-expanded","true")}function ps(o){const e=o.trigger.getBoundingClientRect(),t=190,i=o.panel.offsetHeight||216,n=8,r=Math.max(n,Math.min(e.left,window.innerWidth-t-n)),s=e.bottom+6,l=s+i>window.innerHeight-n?Math.max(n,e.top-i-6):s;o.panel.style.left=`${r}px`,o.panel.style.top=`${l}px`}function us(o){const e=n=>{const r=hs(n);r.includes(o.trigger)||r.includes(o.panel)||_t()},t=n=>{n.key==="Escape"&&_t()},i=()=>_t();document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",t),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),o.root.addEventListener("scroll",i,!0),o.teardowns.push(()=>document.removeEventListener("pointerdown",e,!0),()=>document.removeEventListener("keydown",t),()=>window.removeEventListener("scroll",i,!0),()=>window.removeEventListener("resize",i),()=>o.root.removeEventListener("scroll",i,!0))}function hs(o){const e=typeof o.composedPath=="function"?o.composedPath():[];return e.length?e:[o.target]}function fs(o){return a("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:e=>e.stopPropagation()},[a("div",{class:"picker-preview"},[a("span",{class:"picker-current"}),a("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:e=>gs(o,e.target.value)})]),a("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>bs(o,e),onKeydown:e=>xs(o,e)},[a("span",{class:"picker-handle"})]),a("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>vs(o,Number(e.target.value)),onChange:()=>ni(o)}),a("div",{class:"picker-heading"},[a("span",{text:"常用颜色"}),o.clearable?a("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>io(o,void 0)},[a("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[a("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),a("div",{class:"preset-color-grid"},p.PRESET_COLORS.map(e=>a("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>ms(o,e)})))])}function oi(o){return $n(ss(o.hue,o.saturation,o.value_))}function ao(o){const e=oi(o);o.hex.value!==o.hexText&&(o.hex.value=o.hexText),o.current.className=o.model?"picker-current":"picker-current is-empty",o.model?o.current.style.background=e:o.current.style.removeProperty("background"),o.area.style.setProperty("--picker-hue",`${Math.round(o.hue)}deg`),o.handle.style.left=`${o.saturation*100}%`,o.handle.style.top=`${(1-o.value_)*100}%`,o.handle.style.background=e;const t=String(Math.round(o.hue));o.hueRange.value!==t&&(o.hueRange.value=t),o.clearBtn&&(o.clearBtn.disabled=!o.model);for(const i of o.items)i.el.className=o.model&&i.color.toLowerCase()===o.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function ii(o,e){const t=ei(e);if(!t)return!1;const i=as(t.r,t.g,t.b);return o.hue=i.h,o.saturation=i.s,o.value_=i.v,o.hexText=ti(e).toUpperCase(),!0}function mt(o,e,t,i){o.hue=ls(e),o.saturation=zt(t),o.value_=zt(i),o.hexText=oi(o).toUpperCase(),ao(o)}function ni(o){const e=oi(o);o.model=e,ao(o),o.onChange(e)}function io(o,e){o.model=e,e||(o.hexText=""),ao(o),o.onChange(e)}function ms(o,e){ii(o,e),io(o,e)}function gs(o,e){const t=e.trim();if(!t){o.clearable&&io(o,void 0);return}ei(t)&&(ii(o,t),io(o,ti(t)))}function bs(o,e){o.dragging=!0,on(o,e);const t=n=>{o.dragging&&on(o,n)},i=()=>{o.dragging&&(o.dragging=!1,document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i),ni(o))};document.addEventListener("pointermove",t),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)}function on(o,e){const t=o.area.getBoundingClientRect();if(!t.width||!t.height)return;const i=zt((e.clientX-t.left)/t.width),n=zt(1-(e.clientY-t.top)/t.height);mt(o,o.hue,i,n)}function xs(o,e){const t=e.shiftKey?.1:.02;let i=!0;e.key==="ArrowLeft"?mt(o,o.hue,o.saturation-t,o.value_):e.key==="ArrowRight"?mt(o,o.hue,o.saturation+t,o.value_):e.key==="ArrowUp"?mt(o,o.hue,o.saturation,o.value_+t):e.key==="ArrowDown"?mt(o,o.hue,o.saturation,o.value_-t):i=!1,i&&(e.preventDefault(),ni(o))}function vs(o,e){mt(o,e,o.saturation,o.value_)}function J(o,e,t,i){return a("button",{class:`tb-btn tb-icon${i.on?" on":""}${i.danger?" danger":""}`,type:"button",disabled:!!i.disabled,dataset:{tip:i.tip,...i.test?{test:i.test}:{}},onClick:()=>o.fire(t,i.arg),html:ve(e)})}function no(o,e,t,i){const n=o.state.openDd===e,r=()=>{o.state.openDd=n?null:e,o.repaint()};return a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${n?" on":""}`,disabled:!!t.disabled,dataset:{test:t.testId??e,tip:t.tip},onClick:r,html:`${t.icon?ve(t.icon):""}${t.text?`<span class="${t.textClass??"tb-btn-text"}">${t.text}</span>`:""}${ve("ChevronDown",12,`tb-dd-arrow${n?" up":""}`)}`}),n?a("div",{class:`tb-dd-panel${t.panelClass?` ${t.panelClass}`:""}`},i):""].filter(Boolean))}function I(o){const e=o.step??1,t=String(e),i=t.indexOf("."),n=i===-1?0:t.length-i-1,r=m=>Number.isFinite(m)?Number(m.toFixed(n)):0,s=m=>{let g=r(m);return o.min!==void 0&&g<o.min&&(g=o.min),o.max!==void 0&&g>o.max&&(g=o.max),g},l=o.value===void 0||o.value===null||!Number.isFinite(o.value)?void 0:r(o.value),c=l??o.min??0,u=m=>{m!==l&&o.onCommit(m)},h=a("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:o.min,max:o.max,step:e,placeholder:o.placeholder,disabled:!!o.disabled,onChange:m=>{const g=m.target,v=(g.value??"").trim();if(v===""){l!==void 0&&(g.value=String(l));return}const b=Number(v);if(!Number.isFinite(b)){g.value=l===void 0?"":String(l);return}const w=s(b);g.value=String(w),u(w)}});return a("div",{class:"pd-stepper"},[a("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!o.disabled||c<=(o.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>u(s(c-e))}),h,a("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!o.disabled||c>=(o.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>u(s(c+e))})])}function B(o,e,t,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),i??""]),e,t?a("p",{class:"pd-hint",text:t}):""].filter(Boolean))}const Go=o=>a("button",{class:"pd-help",type:"button","data-tip":o,"aria-label":"字段说明"});function Ce(o,e,t,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[o,Go(t)]),i??""]),e])}function tt(o){const e=o.base?.[o.propKey],t=o.target?.[o.propKey]!==e,i=o.force===!0||t,n=o.tipOverride??(o.tipValue===void 0?"恢复默认值":`恢复默认值(${o.tipValue}${o.tipUnit?" "+o.tipUnit:""})`),r=o.force?`${n}(应用到全部选中格)`:n;return a("button",{type:"button",class:`pd-reset-btn${t&&!o.force?" is-dirty":""}`,"data-tip":r,"aria-label":r,html:ve("RotateCcw",13),onClick:()=>{i&&(o.write?o.write(e):o.target[o.propKey]=e,o.onReset?.())}})}const Pe=o=>a("h3",{class:"pd-divider",text:o});function Ae(o,e,t="颜色选择",i){return ds({value:o,title:t,triggerClass:i,onChange:n=>e(n)})}function Ue(o,e,t,i,n=!1){return a("div",{class:`pd-radio-group${n?" pd-radio-group--2col":""}`,role:"radiogroup"},e.map(r=>a("label",{class:"pd-radio"},[a("input",{type:"radio",name:o,value:r.value,checked:t===r.value,onChange:()=>i(r.value)}),a("span",{text:r.label})])))}function Bn(o,e,t,i={}){const n=document.createElement("select");n.className=i.className??"pd-select",i.width&&(n.style.width=i.width);for(const r of e){const s=document.createElement("option");s.value=r.value,s.textContent=r.label,r.disabled&&(s.disabled=!0),n.appendChild(s)}return n.value=o,e.some(r=>r.value===o)||(n.selectedIndex=-1),n.addEventListener("change",()=>t(n.value)),n}function ys(o){const e=window.innerHeight;for(let t=o.parentElement;t&&t!==document.body;t=t.parentElement){const i=getComputedStyle(t).overflowY;if(i==="auto"||i==="scroll"||i==="hidden"||i==="clip"){const n=t.getBoundingClientRect();return{top:Math.max(0,n.top),bottom:Math.min(e,n.bottom)}}}return{top:0,bottom:e}}function so(o){const e=A.normalizeFontCatalog(o.fonts),t=o.placeholder??"默认",i=`font-select-list-${o.id}`,n=F=>{const M=F?.trim();return M?A.findFontOption(e,M)?.label??M:""},r=F=>{const M=A.normalizeFontQuery(F);return e.find(V=>V.label&&A.normalizeFontQuery(V.label)===M)?.family??F},s=()=>{const F=o.value?.trim();return F?A.findFontOption(e,F)?"":F:""},l=F=>{const M=(o.value??"").trim(),G=(Z,y,H,ae)=>({kind:Z,key:y,label:H,value:ae,selected:(ae??"")===M}),V=F.trim();if(!V){const Z=[G("clear","__clear__",t)],y=s();y&&Z.push(G("unknown","__unknown__",`${y}(未知)`,y));for(const H of e)Z.push(G("font",H.family,A.fontOptionLabel(H),H.family));return Z}const ce=A.filterFontOptions(e,V).map(Z=>G("font",Z.family,A.fontOptionLabel(Z),Z.family));if(!ce.length){const Z=r(V);ce.push(G("free","__free__",`使用「${Z}」`,Z))}return ce},c=document.createElement("div");c.className="font-select";const u=document.createElement("input");u.className="pd-input font-select-input",u.type="text",u.setAttribute("role","combobox"),u.setAttribute("aria-autocomplete","list"),u.setAttribute("aria-controls",i),u.autocomplete="off",u.placeholder=t,u.disabled=!!o.disabled,u.value=n(o.value);const h=document.createElement("ul");h.id=i,h.className="font-select-list",h.setAttribute("role","listbox");const m=o.state.fontOpen?.id===o.id?o.state.fontOpen:null,g={open:!!m&&!o.disabled,query:m?.query??"",highlighted:m?.highlighted??-1};g.open&&(u.value=g.query);const v=()=>{o.state.fontOpen=g.open?{id:o.id,query:g.query,highlighted:g.highlighted}:null};v();const b=()=>{const F=(o.value??"").trim();return l(g.query).findIndex(M=>(M.value??"")===F)},w=()=>{const F=u.getBoundingClientRect(),M=ys(u);h.classList.toggle("is-up",p.resolveOverlayPlacement({triggerTop:F.top,triggerBottom:F.bottom,overlayHeight:h.getBoundingClientRect().height,boundaryTop:M.top,boundaryBottom:M.bottom})==="up")},T=()=>{if(!g.open){h.isConnected&&h.remove(),u.setAttribute("aria-expanded","false"),u.setAttribute("aria-activedescendant","");return}h.isConnected||c.appendChild(h);const F=l(g.query);h.replaceChildren(...F.map((M,G)=>{const V=document.createElement("li");return V.id=`${i}-${G}`,V.className="font-select-option"+(G===g.highlighted?" is-active":"")+(M.kind==="unknown"||M.kind==="free"?" is-muted":""),V.setAttribute("role","option"),V.setAttribute("aria-selected",String(M.selected)),V.textContent=M.label,V.addEventListener("mousedown",ce=>{ce.preventDefault(),ye(M)}),V})),u.setAttribute("aria-expanded","true"),u.setAttribute("aria-activedescendant",g.highlighted>=0?`${i}-${g.highlighted}`:""),w()},k=()=>{g.open||o.disabled||(g.open=!0,g.query="",g.highlighted=b(),v(),T())},z=()=>{g.open||k()},W=()=>{g.open=!0,g.query=u.value,g.highlighted=l(g.query).length?0:-1,v(),T()},P=F=>{if(!g.open){k();return}const M=l(g.query).length-1;if(M<0)return;g.highlighted=Math.min(Math.max(g.highlighted+F,0),M),v(),T(),h.children[g.highlighted]?.scrollIntoView?.({block:"nearest"})},ne=()=>{if(!g.open)return;const F=l(g.query)[g.highlighted];if(F){ye(F);return}const M=g.query.trim();if(M){const G=r(M);ye({value:G})}},ye=F=>{g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(F.value),T(),o.onChange(F.value)},Y=()=>{g.open&&(g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(o.value),T())};return u.addEventListener("focus",k),u.addEventListener("click",z),u.addEventListener("input",W),u.addEventListener("blur",Y),u.addEventListener("keydown",F=>{const M=F;M.key==="ArrowDown"?(M.preventDefault(),P(1)):M.key==="ArrowUp"?(M.preventDefault(),P(-1)):M.key==="Enter"?(M.preventDefault(),ne()):M.key==="Escape"&&(M.preventDefault(),Y())}),c.append(u),T(),g.open&&(u.focus(),u.setSelectionRange(g.query.length,g.query.length)),c}const ws=[{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"}],Ss={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function He(o,e,t,i,n={}){return a("button",{type:"button",class:`ft-cell-btn${n.on?" on":""}`,dataset:{test:o,tip:e},disabled:!!n.disabled,onClick:i,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${t}</svg>`})}const ut='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',nn='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function Ts(o){const e=o.format;e.syncBorderDraft();const t=e.values,i=!e.fontEditable,n=i||e.context==="cells",r=e.context==="none",s=e.context==="cells",l=!e.painterActive&&(e.context==="none"||e.context==="cells"||!e.painterCapturable),c=e.painterActive?"退出格式刷(Esc)":e.context==="cells"?"格式刷(表格单元格暂不支持)":e.context==="none"?"格式刷(需选中元素)":e.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",u=g=>i?`${g}(需选中文本元素)`:g,h=[a("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[a("div",{class:"ft-border-grid"},[He("preset-none","无边框",`${ut}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),He("preset-all","所有边框",`${nn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("all")),He("preset-outer","外侧边框",nn,()=>e.applyBorderPreset("outer")),He("preset-inner",s?"内部边框":"内部边框(仅表格单元格可用)",`${ut}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("inner"),{disabled:!s}),He("edge-top","上边框",`${ut}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),He("edge-bottom","下边框",`${ut}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),He("edge-left","左边框",`${ut}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),He("edge-right","右边框",`${ut}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>e.applyEdge("right"),{on:e.edgeOn("right")})]),a("div",{class:"ft-style-row"},ws.map(g=>a("button",{type:"button",class:`ft-style-btn${e.borderStyle===g.key?" on":""}`,dataset:{test:`style-${g.key}`,tip:e.borderStyle===g.key?`${g.label}(再点一次取消,线型=无)`:g.label},onClick:()=>{e.toggleBorderStyle(g.key),o.repaint()}},[a("span",{class:"ft-style-line",style:{borderTop:g.preview}})]))),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"粗细"}),a("div",{class:"ft-line-width"},[I({value:e.borderWidth,min:.25,max:5,step:.25,placeholder:e.borderMixed.width?"混合":void 0,onCommit:g=>{e.setBorderWidth(g),o.repaint()}})])]),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"颜色"}),Ae(e.borderColor,g=>{e.setBorderColor(g),o.repaint()},"边框颜色")]),e.borderMixedAny?a("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],m=[a("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[a("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([g,v,b])=>a("button",{type:"button",class:`ft-cell-btn${t.textAlign===g?" on":""}`,dataset:{test:`align-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({textAlign:g}),html:ve(b)}))),a("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([g,v,b])=>a("button",{type:"button",class:`ft-cell-btn${t.verticalAlign===g?" on":""}`,dataset:{test:`valign-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({verticalAlign:g}),html:ve(b)})))])];return a("div",{class:"format-toolbar"},[a("div",{class:"tb-ou ft-group",dataset:{unit:"painter"}},[a("button",{type:"button",class:`ft-btn${e.painterActive?" on":""}`,dataset:{test:"format-painter",tip:c},disabled:l,onClick:()=>{e.painterActive?e.cancelPainter():e.pickPainterSource(!1),o.repaint()},onDblclick:()=>{e.pickPainterSource(!0),o.repaint()},html:ve("Paintbrush")})]),a("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[a("div",{class:"ft-font"},[so({id:"ft-font",state:o.state,fonts:o.host.fonts,value:typeof t.fontFamily=="string"?t.fontFamily:void 0,placeholder:t.fontFamily===Qe?"混合":"默认",disabled:i,onChange:g=>e.applyStyle({fontFamily:g})})]),a("div",{class:"ft-size",dataset:{test:"font-size"}},[I({value:typeof t.fontSize=="number"?t.fontSize:void 0,min:5,max:72,disabled:i,placeholder:t.fontSize===Qe?"混合":"默认",onCommit:g=>e.applyStyle({fontSize:g})})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>e.toggleBold()],["underline","Underline","下划线",()=>e.toggleUnderline()],["strike","Strikethrough","删除线",()=>e.toggleStrike()]].map(([g,v,b,w])=>a("button",{type:"button",class:`ft-btn${t[g]===!0?" on":""}`,dataset:{test:g,tip:u(b)},disabled:g==="bold"?i:n,onClick:w,html:ve(v)}))]),a("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[a("span",{class:`ft-color-btn${i?" dim":""}`,title:`字体颜色${i?"(需选中或混选文本元素)":""}`},[Ae(typeof t.color=="string"?t.color:void 0,g=>e.applyStyle({color:g})),a("span",{class:"ft-glyph",text:"A"})]),a("span",{class:`ft-color-btn${r?" dim":""}`,title:"背景色"},[Ae(typeof t.backgroundColor=="string"?t.backgroundColor:void 0,g=>e.applyStyle({backgroundColor:g})),a("span",{class:"ft-glyph",html:ve("PaintBucket",14)})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[no(o,"align",{icon:Ss[String(t.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:i?"对齐(需选中文本元素或单元格)":"对齐",disabled:i,testId:"align-dd"},m)]),a("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[no(o,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:r?"边框(需选中元素)":"边框",disabled:r,testId:"border"},h)])])}const Es=[{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:"<>"}],ks={text:"T",longText:"¶",table:"⊞",flowList:"⊟",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function Cs(o){const e=o.state;if(e.leftCollapsed)return a("div",{class:"left-panel collapsed"},[a("div",{class:"left-collapsed"},[rn("»","展开素材台",()=>{e.leftCollapsed=!1,o.repaint()}),...[["elements","元素","▦"],["fields","字段","⊛"],["layers","图层","≡"]].map(([i,n,r])=>a("button",{type:"button",class:`lc-btn${e.leftTab===i?" on":""}`,title:n,text:r,onClick:()=>{e.leftTab=i,e.leftCollapsed=!1,o.repaint()}}))])]);const t=(i,n)=>a("div",{class:"pd-tab-pane",role:"tabpanel",style:e.leftTab===i?"":{display:"none"}},n);return a("div",{class:"left-panel"},[a("div",{class:"left-head"},[a("span",{class:"left-title",text:"素材台"}),rn("«","收起素材台",()=>{e.leftCollapsed=!0,o.repaint()})]),a("div",{class:"pd-tabs left-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([i,n])=>a("button",{type:"button",class:`pd-tab${e.leftTab===i?" active":""}`,text:n,onClick:()=>{e.leftTab=i,o.repaint()}}))]),t("elements",As()),t("fields",[Ds(o)]),t("layers",[Ms(o)])])])}function rn(o,e,t){return a("button",{type:"button",class:"collapse-btn",title:e,text:o,onClick:t})}function As(){return[a("div",{class:"panel-title",text:"拖拽元素到画布"}),...Es.map(o=>a("div",{class:"material-card",draggable:!0,dataset:{test:`material-${o.type}`},onDragstart:e=>e.dataTransfer?.setData("elementType",o.type)},[a("span",{class:"material-icon",text:o.icon}),a("span",{class:"material-label",text:o.label})]))]}function Ds(o){const e=o.state,t=p.groupFields(o.store.fields),i=(e.fieldSearch??"").trim().toLowerCase(),n=i?t.map(r=>({...r,fields:r.fields.filter(s=>`${s.fieldLabel}${s.fieldKey}`.toLowerCase().includes(i))})).filter(r=>r.fields.length):t;return a("div",{class:"field-tree-panel"},[a("div",{class:"panel-title",text:"业务字段"}),a("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:e.fieldSearch??"",onInput:r=>{e.fieldSearch=r.target.value},onChange:()=>o.repaint()}),a("div",{class:"tree-container"},n.flatMap(r=>{const s=e.collapsedGroups.has(r.key)&&!i,l=r.key?a("div",{class:`field-group-header${r.isList?" is-list":""}`,onClick:()=>{s?e.collapsedGroups.delete(r.key):e.collapsedGroups.add(r.key),o.repaint()}},[a("span",{class:"expand-icon",text:s?"▶":"▼"}),a("span",{class:"node-icon",text:r.isList?"📋":"📁"}),a("span",{class:"group-label",text:r.label,"data-tip":r.label})]):"",c=s?[]:r.fields.map(u=>a("div",{class:"field-row",draggable:!0,"data-tip":`${u.fieldLabel} (${u.fieldKey})`,style:{paddingLeft:`${r.key?22:8}px`},onDragstart:h=>{h.dataTransfer?.setData("fieldKey",u.fieldKey)}},[a("span",{class:"node-icon",text:"📄"}),a("span",{class:"node-meta"},[a("span",{class:"node-label",text:u.fieldLabel}),a("span",{class:"node-key",text:`(${u.fieldKey})`})])]));return[l,a("div",{},c.filter(Boolean))].filter(Boolean)})),n.length===0?a("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function Ms(o){const e=o.store,t=[...e.elements].sort((l,c)=>(c.options.zIndex??0)-(l.options.zIndex??0)),i=e.elements.filter(l=>e.selectedIds.has(l.id)),n=i.length>=2,r=i.some(l=>!!l.options.groupId),s=l=>l.zone==="header"?"页眉":l.zone==="footer"?"页脚":"";return a("div",{class:"layer-panel"},[a("div",{class:"panel-title",text:"图层"}),...t.map(l=>a("div",{class:`layer-item${e.selectedIds.has(l.id)?" active":""}`,onClick:c=>e.selectElement(l.id,c.ctrlKey||c.metaKey)},[a("span",{class:"layer-icon",text:ks[l.printElementType.type]||"?"}),a("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),s(l)?a("span",{class:"layer-zone",text:s(l)}):"",a("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))),t.length?a("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,c,u])=>a("button",{type:"button",class:"pd-button small",title:c,html:ve(u,14),onClick:()=>o.fire("move-layer",l)}))]):"",n||r?a("div",{class:"layer-actions"},[n?a("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:ve("Group",14),onClick:()=>o.fire("group")}):"",r?a("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:ve("Ungroup",14),onClick:()=>o.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function _s(o){const e=o.store,t=o.state,i=e.pages.length>1,n=e.pages[e.activePageIndex]?.name||`页面 ${e.activePageIndex+1}`,r=e.tilingEnabled;return a("div",{class:"page-tabs"},[a("div",{class:"page-tabs-list"},e.pages.map((l,c)=>t.renamingPage===c?a("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:t.renameText??"",onInput:u=>{t.renameText=u.target.value},onBlur:()=>s(),onKeydown:u=>{const h=u;if(h.key==="Enter"){s();return}h.key==="Escape"&&(t.renamingPage=null,o.repaint())}}):a("button",{type:"button",class:`page-tab${c===e.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${c+1}`,onClick:()=>e.switchPage(c),onDblclick:()=>{t.renamingPage=c,t.renameText=l.name??"",o.repaint()}}))),a("div",{class:"page-tabs-actions"},[a("button",{type:"button",dataset:{test:"add-page",tip:r?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:r,text:"+",onClick:()=>o.fire("add-page")}),a("button",{type:"button",dataset:{test:"duplicate-page",tip:r?"拼版模板仅允许一个设计页面":`复制当前页「${n}」`},disabled:r,text:"⧉",onClick:()=>o.fire("duplicate-page")}),a("button",{type:"button",dataset:{test:"delete-page",tip:i?`删除当前页「${n}」`:"仅多页面模板可删除页面"},disabled:!i,text:"✕",onClick:()=>o.fire("delete-page")}),a("button",{type:"button",dataset:{test:"move-left",tip:`前移「${n}」`},disabled:e.activePageIndex<=0,text:"←",onClick:()=>o.fire("move-page",-1)}),a("button",{type:"button",dataset:{test:"move-right",tip:`后移「${n}」`},disabled:e.activePageIndex>=e.pages.length-1,text:"→",onClick:()=>o.fire("move-page",1)})])]);function s(){const l=(t.renameText??"").trim();t.renamingPage!==null&&l&&e.renamePage(t.renamingPage,l),t.renamingPage=null,o.repaint()}}function Rs(o){const e=o.store,t=e.templateData,i=p.getPaperDimensions(t),n=t.orientation==="landscape"?"横向":"纵向",r=p.PAPER_PRESETS[t.paperSize]?.label??t.paperSize,s=t.outputRotation,l=`${r} ${n} ${Math.round(i.width)}×${Math.round(i.height)}mm${s?`(旋转${s}°)`:""}`;return a("div",{class:"status-bar"},[a("span",{class:"status-item coord",dataset:{coord:""},style:{display:"none"}}),a("span",{class:"status-item",text:`缩放 ${e.scale}%`}),a("span",{class:"status-item",text:`元素 ${e.elements.length}${e.selectedIds.size?` (选中 ${e.selectedIds.size})`:""}`}),a("span",{class:`status-dirty${e.dirty?" on":""}`},[a("span",{class:"dirty-dot"}),e.dirty?"未保存":"已保存"]),a("span",{class:"status-item status-paper",text:l})])}const zs=Object.keys(p.PAPER_PRESETS).filter(o=>o!=="CUSTOM"&&!p.PAPER_PRESETS[o]?.continuous);function Ps(o){const e=document.createElement("label");e.className="pd-button small upload-label";const t=document.createTextNode("上传背景图"),i=document.createElement("input");i.className="visually-hidden",i.type="file",i.accept="image/*",e.append(t,i);const n=r=>{e.className=`pd-button small upload-label${r?" disabled":""}`,i.disabled=r};return i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;if(!r.type.startsWith("image/")){alert("仅支持上传图片文件"),i.value="";return}const s=o.host.uploadDesignBackground;if(!s){alert("设计背景上传能力未配置"),i.value="";return}n(!0),t.textContent="上传中...";try{const l=await s(r);l?o.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{t.textContent="上传背景图",n(!o.host.uploadDesignBackground),i.value=""}}),o.host.uploadDesignBackground||n(!0),e}function Fs(o){const t=o.store.templateData.designBackground,i=t?.rotation??0;return a("div",{class:"design-background-config"},[Pe("设计背景"),a("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),t?.src?[a("div",{class:"design-background-path",title:t.src,text:t.src}),a("div",{class:"design-background-actions"},[a("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(i+90)%360}°)`,onClick:()=>o.store.updateTemplateData({designBackground:{...t,rotation:(i+90)%360}})}),a("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>o.store.updateTemplateData({designBackground:void 0})})])]:Ps(o)].flat())}function Ls(o){const e=o.store,t=e.templateData,i=t.tiling,n={...A.TILE_DEFAULTS,...i??{},enabled:i?.enabled??!1,sheetMargin:{...A.TILE_DEFAULTS.sheetMargin,...i?.sheetMargin??{}}},r=p.isContinuousPaperSize(t.paperSize),s=b=>e.updateTemplateData({tiling:{...n,...b}}),l=b=>tt({target:n,base:A.TILE_DEFAULTS,propKey:b,write:()=>s({[b]:A.TILE_DEFAULTS[b]})}),c=b=>tt({target:n.sheetMargin,base:A.TILE_DEFAULTS.sheetMargin,propKey:b,write:()=>u(b,A.TILE_DEFAULTS.sheetMargin[b])}),u=(b,w)=>s({sheetMargin:{...n.sheetMargin,[b]:w??0}}),h={...t,tiling:n},m=A.validateTiling(h),g=Math.max(A.computeMaxColumns(h),1);let v="";if(!m.length)try{const b=A.computeTileLayout(h),w=A.resolveSheetMm(h),T=n.sheetPaperSize==="CUSTOM"?"自定义":n.sheetPaperSize??"A4",k=n.sheetPaperSize==="CUSTOM"?"":n.sheetOrientation==="landscape"?" 横向":" 纵向";v=`目标纸 ${T}${k} ${w.width}×${w.height}mm · ${b.columns} 列 × ${b.rows} 行 = 每张 ${b.perSheet} 格 · 每格 ${b.tile.width}×${b.tile.height}mm`}catch{v=""}return a("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[Pe("拼版打印"),a("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),a("div",{class:"pd-field"},[a("label",{class:"tiling-switch"},[a("input",{type:"checkbox",checked:n.enabled===!0,disabled:r,onChange:b=>{if(!b.target.checked){s({enabled:!1});return}s({...A.TILE_DEFAULTS,columns:Math.min(A.TILE_DEFAULTS.columns,Math.max(g,1))})}}),a("span",{text:"启用拼版"})]),r?a("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),n.enabled&&!r?[B("目标纸张",a("select",{class:"pd-select",style:{width:"100%"},onChange:b=>{const w=b.target.value;if(w!=="CUSTOM"){s({sheetPaperSize:w});return}const T=A.resolveSheetMm(h);s({sheetPaperSize:"CUSTOM",sheetCustomWidth:n.sheetCustomWidth??T.width,sheetCustomHeight:n.sheetCustomHeight??T.height})}},[...zs.map(b=>a("option",{value:b,text:p.PAPER_PRESETS[b]?.label??b,selected:(n.sheetPaperSize??"A4")===b})),a("option",{value:"CUSTOM",text:"自定义",selected:n.sheetPaperSize==="CUSTOM"})]),void 0,l("sheetPaperSize")),n.sheetPaperSize==="CUSTOM"?B("目标纸宽高 (mm)",a("div",{class:"custom-size-grid"},[I({value:Number(n.sheetCustomWidth??0),min:25,max:2e3,onCommit:b=>s({sheetCustomWidth:b})}),a("span",{class:"custom-size-x",text:"×"}),I({value:Number(n.sheetCustomHeight??0),min:25,max:2e3,onCommit:b=>s({sheetCustomHeight:b})})])):B("目标纸方向",Ue("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.sheetOrientation==="landscape"?"landscape":"portrait",b=>s({sheetOrientation:b})),void 0,l("sheetOrientation")),Pe("拼版留白 (mm)"),a("div",{class:"margin-grid"},[B("上",I({value:n.sheetMargin.top??0,min:0,max:100,onCommit:b=>u("top",b)}),void 0,c("top")),B("下",I({value:n.sheetMargin.bottom??0,min:0,max:100,onCommit:b=>u("bottom",b)}),void 0,c("bottom")),B("左",I({value:n.sheetMargin.left??0,min:0,max:100,onCommit:b=>u("left",b)}),void 0,c("left")),B("右",I({value:n.sheetMargin.right??0,min:0,max:100,onCommit:b=>u("right",b)}),void 0,c("right"))]),Pe("格间距与列数"),B("横向间距",I({value:n.gapX??0,min:0,max:50,onCommit:b=>s({gapX:b??0})}),void 0,l("gapX")),B("纵向间距",I({value:n.gapY??0,min:0,max:50,onCommit:b=>s({gapY:b??0})}),void 0,l("gapY")),B("列数",I({value:n.columns??1,min:1,max:g,onCommit:b=>s({columns:b||1})})),...m.map(b=>a("p",{class:"pd-hint tiling-error",text:b.message})),!m.length&&v?a("p",{class:"pd-hint tiling-summary",text:v}):""]:""].flat().filter(Boolean))}const Is=new Set(p.PROPERTY_REGISTRY.map(o=>o.group)),Os={"table-settings":"content"},an=new Map;function ri(o){const e=o??"";let t=an.get(e);if(!t){const{groups:i,itemKeys:n}=p.searchProperties(e);t={groups:i,keys:n,searching:!!e.trim()},an.set(e,t)}return t}function ai(o){const e=Os[o]??o;return Is.has(e)?e:""}function Ns(o,e){const t=ri(o.state.propSearch);if(!t.searching)return!0;const i=ai(e);return!i||t.groups.includes(i)}function $s(o,e){const t=ri(o.state.propSearch);return!t.searching||t.keys.has(e)}function Hn(o,e){const t=o.props.style??{};return o.props.style={...t,display:e?"":"none"},o}function _(o,e,t){const i=t.props.dataset??{};return t.props.dataset={...i,propKey:e},Hn(t,$s(o,e))}function Bs(o,e,t){const i=ai(e);if(!i)return t;const n=t.props.dataset??{};return t.props.dataset={...n,propGroup:i},Hn(t,Ns(o,e))}function Wn(o,e){const t=ri(e);for(const i of Array.from(o.querySelectorAll("[data-prop-group]"))){const n=ai(i.dataset.propGroup??"");i.style.display=!t.searching||!n||t.groups.includes(n)?"":"none"}for(const i of Array.from(o.querySelectorAll("[data-prop-key]")))i.style.display=!t.searching||t.keys.has(i.dataset.propKey??"")?"":"none"}function Hs(o){return a("div",{class:"property-search"},[a("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:o.state.propSearch??"",onInput:e=>{const t=e.target,i=t.value;o.state.propSearch=i,Wn(t.getRootNode(),i)}})])}const Ws={Document:"≡",Brush:"◧",Setting:"⚙"};function Us(o,e){try{const t=window.localStorage.getItem(`property-group-${o}`);return t===null?e:t==="true"}catch{return e}}function Gs(o,e){try{window.localStorage.setItem(`property-group-${o}`,String(e))}catch{}}function xe(o,e,t,i,n,r=!0){const s=Us(e,r);return Bs(o,e,a("div",{class:`property-group${s?" is-expanded":""}`},[a("div",{class:"group-header",onClick:()=>{Gs(e,!s),o.repaint()}},[a("span",{class:"group-icon",text:Ws[i]||"•"}),a("span",{class:"group-title",text:t}),a("span",{class:"expand-icon",text:s?"▾":"▸"})]),a("div",{class:"group-content",style:s?"":{display:"none"}},n.filter(Boolean))]))}function lo(o){return a("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},o.filter(Boolean))}function Un(o){return o.split(".").flatMap(e=>{const t=e.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!t)return[e];const i=t[1],n=[...t[2].matchAll(/\[(\d+)\]/g)].map(r=>Number(r[1]));return[i,...n]})}function sn(o,e){return Un(e).reduce((n,r)=>n==null?"":n[r],o)??""}function si(o,e,t,i){const n=Un(t),r=n.pop(),s=n.reduce((l,c)=>((l[c]===void 0||l[c]===null)&&(l[c]={}),l[c]),e);s[r]=i||void 0,o.recordHistory(),o.emit()}function qs(o,e){const t=o.store;if(e.printElementType.type==="table"&&t.tableSelection?.elementId===e.id){const{r1:i,c1:n}=t.tableSelection,r=(e.options.tableRows??[])[i];if(r)return p.getTableCellBindings(r.type,i,n,e.options.fields?.[0]?.dataSource)}return p.getElementBindings(e)}function Ks(o,e){const t=document.createElement("label");t.className="pd-button small upload-label",fe(a("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[a("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),t);const i=document.createTextNode("上传图片"),n=document.createElement("input");n.className="visually-hidden",n.type="file",n.accept="image/*",t.append(i,n);const r=c=>{t.className=`pd-button small upload-label${c?" disabled":""}`,n.disabled=c};n.addEventListener("change",async()=>{const c=n.files?.[0];if(!c)return;if(!c.type.startsWith("image/")){alert("仅支持上传图片文件"),n.value="";return}const u=o.host.uploadImage;if(!u){alert("图片上传能力未配置"),n.value="";return}r(!0),i.textContent="上传中...";try{const h=await u(c);h?si(o.store,e,"options.src",h):alert("图片上传失败")}catch(h){alert(h instanceof Error?h.message:"图片上传失败")}finally{i.textContent="上传图片",r(!o.host.uploadImage),n.value=""}}),o.host.uploadImage||r(!0);const s=document.createElement("div");s.className="image-content-upload";const l=document.createElement("p");return l.className="upload-tip",l.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",s.append(t,l),s}function js(o,e){const t=i=>o.fire("open-expression",{elementId:e.id,targetPath:i.targetPath,value:sn(e,i.targetPath)});return xe(o,"binding","内容","Document",[...qs(o,e).map(i=>B(i.label,a("input",{class:"pd-input",type:"text",value:sn(e,i.targetPath),placeholder:i.placeholder||"输入内容,支持 {字段} 表达式",onChange:n=>si(o.store,e,i.targetPath,n.target.value),onDblclick:()=>t(i)}))),e.printElementType.type==="image"?Ks(o,e):""].filter(Boolean))}const Ct=new Map;function Zt(o){return`${Math.round(o*1e4)/1e4}%`}function Gn(o,e){const t=p.parseCropAnchor(e.value),i=t.kind==="custom",n=t.kind==="axes"?t.x:50,r=t.kind==="axes"?t.y:50,s=p.resolveCropPreview(e.src),l=Ct.get(s.src),c={widthMm:e.widthMm,heightMm:e.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:e.fit,scalePct:e.scale},u=p.resolveCropTravel(c),h=p.cropWindow(c,n,r),m=document.createElement("select");m.className="pd-select",m.style.width="100%";for(const w of p.cropPresetOptions(u,n,r)){const T=document.createElement("option");T.value=w.value,T.textContent=w.label,m.appendChild(T)}if(i){const w=document.createElement("option");w.value="custom",w.textContent="自定义(保留原值)",m.appendChild(w)}m.value=i?"custom":`${n},${r}`,m.selectedIndex<0&&(m.selectedIndex=i?m.options.length-1:0),m.addEventListener("change",()=>{if(m.value==="custom")return;const[w,T]=m.value.split(",").map(Number);e.onCommit(p.buildCropAnchor(w,T))});const g=p.propertyTip(e.fieldKey),v=[a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[e.label,Go(g)]),e.resetAnchor??""].filter(Boolean)),m])];v.push(a("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[p.CROP_SCALE_LABEL,Go(p.propertyTip("ap-img-fit-scale"))]),e.resetScale??""].filter(Boolean)),I({value:e.scale,min:p.CROP_SCALE_MIN,max:p.CROP_SCALE_MAX,step:5,placeholder:"默认 100",onCommit:w=>e.onScaleCommit(w>p.CROP_SCALE_MIN?w:void 0)})]));for(const w of p.cropAxisFields(u,n,r))v.push(a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label",text:w.label}),I({value:w.value,min:0,max:100,step:1,onCommit:T=>e.onCommit(p.buildCropAnchor(w.name==="horizontal"?T:n,w.name==="vertical"?T:r))})]));const b=p.cropAxisNote(u,i);return b&&v.push(a("p",{class:"pd-crop-note",text:b})),s.isSample&&v.push(a("p",{class:"pd-crop-note",text:p.CROP_SAMPLE_NOTE})),v.push(a("div",{class:"pd-crop-preview"},[a("img",{class:"pd-crop-thumb",src:s.src,alt:s.isSample?"示例图":"原图",onLoad:w=>{const T=w.target;if(!(T.naturalWidth>0&&T.naturalHeight>0))return;const k=Ct.get(s.src);k&&k.width===T.naturalWidth&&k.height===T.naturalHeight||(Ct.set(s.src,{width:T.naturalWidth,height:T.naturalHeight}),o.repaint())},onError:()=>{Ct.has(s.src)&&(Ct.delete(s.src),o.repaint())}}),h?a("div",{class:"pd-crop-win",style:{left:Zt(h.leftPct),top:Zt(h.topPct),width:Zt(h.widthPct),height:Zt(h.heightPct)}}):""])),a("div",{class:e.containerClass??"pd-crop-anchor"},v)}const Ze=o=>Number(o??0),qo=o=>o||void 0;function bt(o,e,t,i,n){return a("div",{class:"pd-field"},[a("span",{class:"pd-label",...i?{title:i}:{}},[a("span",{class:"pd-label-t",text:o}),n??""].filter(Boolean)),a("input",{class:"pd-switch",type:"checkbox",checked:e,onChange:r=>t(r.target.checked)})])}function qn(o,e,t,i,n=!1,r){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),""].filter(Boolean)),a("select",{class:"pd-select",...n?{style:{width:"100%"}}:{},onChange:s=>i(s.target.value)},t.map(s=>a("option",{value:s.value,text:s.label,selected:s.value===e})))])}function At(o,e,t,i,n={}){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),n.reset??""].filter(Boolean)),Bn(e,t,i,{className:"pd-select",...n.full?{width:"100%"}:{}})])}const Dt=o=>a("p",{class:"pd-hint",text:o}),Ys="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",Vs=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],Xs=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Zs=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],Qs=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],Js={value:"__multi__",label:"多选",disabled:!0};function el(o,e){const t=o.store,i=t.tableSelection,n=e.options.tableRows??[],r=i?n[i.r1]:void 0;if(!i||!r)return xe(o,"table-row","行属性","Grid",[]);const s=l=>t.updateElement(e.id,l);return xe(o,"table-row","行属性","Grid",[lo([qn("行类型",r.type,Vs,l=>{const c=p.setRowType(n,i.r1,l);if(c){window.alert(c);return}s({tableRows:n})},!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"行高 (mm)"}),I({value:r.height,min:3,max:100,step:.5,onCommit:l=>{r.height=l,s({tableRows:n})}})]),r.type==="header"?bt("表头每页重复",r.repeatOnPage??!1,l=>{p.setHeaderRepeat(n,l),s({tableRows:n})},Ys):""])])}function tl(o,e){const t=o.store,i=e.options,n=h=>t.updateElement(e.id,h),r=i.tableColWidths??[],s=t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right,l=t.fields.filter(h=>h.fieldType==="list").map(h=>({value:h.fieldKey,label:h.fieldLabel})),c=p.createDefaultOptions("table"),u=h=>tt({target:i,base:c,propKey:h,write:()=>n({[h]:c[h]})});return xe(o,"table-settings","表格设置","Grid",[lo([qn("列表数据源字段",i.dataSource??"",l,h=>n({dataSource:h||void 0}),!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字体"}),u("tableDefaultFontFamily")]),so({id:"table-default-font",state:o.state,fonts:o.host.fonts,value:i.tableDefaultFontFamily,placeholder:"默认",onChange:h=>n({tableDefaultFontFamily:h||void 0})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字号 (pt)"}),u("tableDefaultFontSize")]),I({value:Ze(i.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:h=>n({tableDefaultFontSize:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认文字颜色"}),u("tableDefaultColor")]),Ae(i.tableDefaultColor,h=>n({tableDefaultColor:h}),"默认文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),u("tableDefaultPadding")]),I({value:Ze(i.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:h=>n({tableDefaultPadding:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"列宽 (mm)"}),...r.map((h,m)=>a("div",{class:"col-width-row"},[a("span",{style:{width:"60px"},text:`列${m+1}`}),I({value:h,min:5,max:200,onCommit:g=>{const v=r.reduce((b,w,T)=>T===m?b:b+w,0);if(v+g>s){const b=Math.max(5,Math.round((s-v)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${s}mm,列${m+1} 已调整为 ${b}mm`),r[m]=b}else r[m]=g;n({tableColWidths:r})}})]))])])])}function ol(o,e){const t=o.store,i=e.options,n=e.printElementType.type==="table",r=l=>t.updateElement(e.id,l),s=[];if(n)s.push(_(o,"pg-enabled",bt("启用分页",i.tablePagination?.enabled??!0,l=>r({tablePagination:{enabled:l}}))));else{const l=i.pagination?.pageable??!0,c=i.pagination?.keepWithNext??!1;s.push(_(o,"pg-pageable",bt("参与分页",l,u=>r({pagination:{pageable:u,keepWithNext:c}})))),s.push(_(o,"pg-keep-with-next",bt("与下元素同页",c,u=>r({pagination:{pageable:l,keepWithNext:u}}))))}return xe(o,"pagination","分页配置","Document",[lo(s)],!1)}const Po=new WeakMap,ln=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function il(o,e){const t=o.store,i=t.tableSelection,n=e.options.tableRows??[];if(!i)return xe(o,"table-cell","单元格","Menu",[]);const r=p.findMainCell(n,i.r1,i.c1),s=n[r.r]?.cells[r.c];if(!s)return xe(o,"table-cell","单元格","Menu",[]);const l=()=>p.collectWritableCells(n,i),c=p.resolveCellGroupMode(n,i),u=c.count,h=c.mode==="multi",m=`${e.id}:${i.r1}:${i.c1}:${i.r2}:${i.c2}`,g=Po.get(t),v=g?.key===m?g:{key:m,border:{},values:{},edges:{}};g?.key!==m&&Po.set(t,v);const b=x=>{Po.set(t,{key:m,border:x.border??v.border,values:x.values??v.values,edges:x.edges??v.edges})},w=(x,O)=>{b({border:{...v.border,[x]:O}}),o.repaint()},T=(x,O)=>{l().forEach(x),h&&O&&b({values:{...v.values,...O}}),t.updateElement(e.id,{tableRows:n})},k=(x,O)=>{T(Q=>{Q[x]=O},{[x]:O})},z=x=>h?v.values[x]:s[x],W=x=>h&&x in v.values,P=h?{width:void 0,style:void 0,color:void 0}:p.resolveCellBorderDisplay(n,i),ne=!h&&l().some(x=>!!x.borders&&!!(x.borders.top||x.borders.right||x.borders.bottom||x.borders.left)),ye=!h&&!ne,Y={width:ye?0:typeof P.width=="number"?P.width:p.DEFAULT_BORDER.width,style:ye?"none":typeof P.style=="string"&&P.style!=="mixed"?P.style:p.DEFAULT_BORDER.style,color:typeof P.color=="string"&&P.color!=="mixed"?P.color:p.DEFAULT_BORDER.color,...v.border},F="__mixed__",M={style:!h&&P.style==="mixed",width:!h&&P.width==="mixed",color:!h&&P.color==="mixed"},G=M.style&&!("style"in v.border),V=M.width&&!("width"in v.border),ce=M.color&&!("color"in v.border),Z=G||V||ce,y=G?F:Y.style,H=V?void 0:Y.width,ae=ce?void 0:Y.color,Fe=x=>{const O={style:x};x!=="none"&&H===0?O.width=p.DEFAULT_BORDER.width:x==="none"&&!ne&&(O.width=0),b({border:{...v.border,...O}}),o.repaint()},L=()=>({...Y}),ee=h?ln.reduce((x,O)=>(x[O.value]=v.edges[O.value]?"on":"off",x),{}):p.resolveBorderEdgeStates(l().map(x=>x.borders)),Ge=h?"cellType"in v.values?v.values.cellType??"text":p.resolveSharedCellType(n,i):s.cellType??"text",pe=Ge==="barcode",qe=Ge==="qrcode",ot=Ge==="image",U=Ge==="text",co=pe&&!!z("printerDpi"),Ft=p.barcodeBarWidthRecommendText(z("printerDpi"),z("barWidth")),Lt=h?v.values.textFit:p.resolveCellTextFit(s),po=h?"cellType"in v.values?v.values.cellType??"text":"":s.cellType||"text",Ke=x=>h?[Js,...x]:x,we=x=>h?"多选":x,Se=(x,O)=>h?v.values[x]:O,uo=h?z("barcodeType")??"__multi__":s.barcodeType||"CODE128",It=h?W("printerDpi")?z("printerDpi")?String(z("printerDpi")):"":"__multi__":s.printerDpi?String(s.printerDpi):"",q=h?z("qrCodeLevel")??"__multi__":s.qrCodeLevel||"M",xt=h?z("fit")??"__multi__":s.fit||"contain",K=Lt??"__multi__",it=p.canMergeReason(n,i);let ue=!1;for(let x=i.r1;x<=i.r2&&!ue;x++)for(let O=i.c1;O<=i.c2&&!ue;O++){const Q=n[x]?.cells[O];Q&&!Q.merged&&((Q.rowspan??1)>1||(Q.colspan??1)>1)&&(ue=!0)}const Te=(x,O,Q,te={},De)=>a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:x}),De??""].filter(Boolean)),I({value:O,...te,onCommit:yt=>k(Q,qo(yt))})]),Ot="恢复默认值(跟随表格默认)",N=x=>tt({target:s,base:{},propKey:x,tipOverride:Ot,force:h,write:()=>k(x,void 0)}),vt=e.options.tableDefaultPadding??1,nt={width:p.cellFitWidthMm(e.options.tableColWidths??[],r.c,s,vt),height:p.cellFitCapMm(n,r.r,s,vt)};return xe(o,"table-cell","单元格","Menu",[lo([h?Dt(`已选 ${u} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"单元格类型"}),Ue("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],po,x=>{const O=x==="text"?void 0:x,Q={cellType:x};x!=="barcode"&&Object.assign(Q,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),x!=="qrcode"&&Object.assign(Q,{qrCodeLevel:void 0,qrQuietZone:void 0}),T(te=>{te.cellType=O,x!=="barcode"&&(te.barcodeType=void 0,te.showBarcodeText=void 0,te.printerDpi=void 0,te.barQuietZone=void 0,te.barHeight=void 0),x!=="qrcode"&&(te.qrCodeLevel=void 0,te.qrQuietZone=void 0)},Q)})]),pe?At("码制",uo,Ke(Xs),x=>{x!=="__multi__"&&k("barcodeType",x||void 0)}):"",pe?bt("显示文本",h?v.values.showBarcodeText===!0:s.showBarcodeText!==!1,x=>k("showBarcodeText",x),void 0,N("showBarcodeText")):"",pe?Te("条宽(倍率)",Se("barWidth",s.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:we("")},N("barWidth")):"",pe?Dt((co?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Ft?`。${Ft}`:"")):"",pe?Ce("静区 (模块)",I({value:Se("barQuietZone",s.barQuietZone),min:0,max:20,placeholder:we("默认 10"),onCommit:x=>k("barQuietZone",x)}),p.propertyTip("cd-bar-quiet-zone"),N("barQuietZone")):"",pe?Ce("条高 (mm)",I({value:Se("barHeight",s.barHeight),min:1,max:100,placeholder:we("默认 30 模块"),onCommit:x=>k("barHeight",x??void 0)}),p.propertyTip("cd-bar-height"),N("barHeight")):"",pe?Te("文本字号(相对条高,条高为 30)",Se("barFontSize",s.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:we("默认 10")},N("barFontSize")):"",pe?At("打印机分辨率",It,Ke([{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)"}]),x=>{if(x==="__multi__")return;const O=Number(x);k("printerDpi",O>0?O:void 0)},{reset:N("printerDpi")}):"",pe?Dt("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",qe?At("纠错级别",q,Ke(Zs),x=>{x!=="__multi__"&&k("qrCodeLevel",x||void 0)},{reset:N("qrCodeLevel")}):"",qe?Ce("静区 (模块)",I({value:Se("qrQuietZone",s.qrQuietZone),min:0,max:8,placeholder:we("默认 0"),onCommit:x=>k("qrQuietZone",x)}),p.propertyTip("cd-quiet-zone"),N("qrQuietZone")):"",pe?Dt("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",qe||ot?At("缩放模式",xt,Ke(p.IMAGE_FIT_OPTIONS),x=>{x!=="__multi__"&&k("fit",x)},{reset:N("fit")}):"",ot&&!h&&s.fit==="cover"?Gn(o,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(s.formatter),fit:s.fit,containerClass:"pd-cell-anchor",widthMm:nt.width,heightMm:nt.height,scale:s.fitScale,value:s.objectPosition,onCommit:x=>k("objectPosition",x),onScaleCommit:x=>k("fitScale",x),resetAnchor:N("objectPosition"),resetScale:N("fitScale")}):"",pe||qe||ot?Te("最大宽度 (mm)",Se("maxWidth",Ze(s.maxWidth)),"maxWidth",{min:0,max:200,placeholder:we("默认")},N("maxWidth")):"",pe||qe||ot?Te("最大高度 (mm)",Se("maxHeight",Ze(s.maxHeight)),"maxHeight",{min:0,max:200,placeholder:we("默认")},N("maxHeight")):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"内容"}),a("input",{class:"pd-input",type:"text",value:h?z("formatter")??"":s.formatter||"",placeholder:h?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:x=>k("formatter",x.target.value||void 0),onDblclick:()=>o.fire("table-cell-dblclick",{elementId:e.id,r:r.r,c:r.c,cellId:s.id})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"水平对齐"}),N("align")]),Ue("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],h?v.values.align??"":s.align||"left",x=>k("align",x))]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"垂直对齐"}),N("valign")]),Ue("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],h?v.values.valign??"":s.valign||"top",x=>k("valign",x))]),a("div",{class:"cell-style-grid"},[a("div",{class:"pd-field cell-font-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"字体"}),N("fontFamily")]),so({id:"cell-font",state:o.state,fonts:o.host.fonts,value:h?z("fontFamily"):s.fontFamily,placeholder:we("继承默认"),onChange:x=>k("fontFamily",x)})]),Te("字号 (pt)",Se("fontSize",Ze(s.fontSize)),"fontSize",{min:0,max:72,placeholder:we("默认")},N("fontSize")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"加粗"}),N("fontWeight")]),a("input",{class:"pd-switch",type:"checkbox",checked:h?v.values.fontWeight==="bold":s.fontWeight==="bold",onChange:x=>k("fontWeight",x.target.checked?"bold":void 0)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"文字颜色"}),N("color")]),Ae(h?z("color"):s.color,x=>k("color",x),"文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"背景色"}),N("backgroundColor")]),Ae(h?z("backgroundColor"):s.backgroundColor,x=>k("backgroundColor",x),"背景颜色")])]),Pe("边框"),a("div",{class:"border-style-row"},[Bn(y,[...G?[{value:F,label:"混合",disabled:!0}]:[],...p.BORDER_LINE_STYLES],x=>{x!==F&&Fe(x)},{width:"90px"}),a("div",{style:{width:"112px",flexShrink:"0"}},[I({value:H,min:.25,max:5,step:.25,placeholder:h?"多选":V?"混合":void 0,onCommit:x=>w("width",x)})]),Ae(ae,x=>w("color",x),"边框颜色")]),a("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([x,O])=>a("button",{type:"button",class:"pd-button small",text:O,onClick:()=>{p.applyBorderPreset(n,i,Y.style==="none"?"none":x,L()),t.updateElement(e.id,{tableRows:n})}}))),a("div",{class:"pd-checkbox-group"},ln.map(x=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",value:x.value,checked:ee[x.value]==="on",indeterminate:ee[x.value]==="mixed",onChange:O=>{const te=O.target.checked&&Y.style!=="none";h&&b({edges:{...v.edges,[x.value]:te}}),T(De=>{p.setCellBorderEdge(De,x.value,te?L():null)})}}),a("span",{text:x.label})]))),Dt(h?p.CELL_BORDER_APPLY_HINT_MULTI:Z?p.CELL_BORDER_APPLY_HINT_MIXED:p.CELL_BORDER_APPLY_HINT),Te("内边距 (mm)",Se("padding",Ze(s.padding)),"padding",{min:0,max:10,step:.5,placeholder:we("默认")},N("padding")),bt("自动换行",h?v.values.wordWrap===!0:s.wordWrap??!0,x=>k("wordWrap",x),void 0,N("wordWrap")),U?At("文字溢出",K,Ke(Qs),x=>{x!=="__multi__"&&k("textFit",x)},{full:!0,reset:N("textFit")}):"",U&&Lt==="shrink"?Te("最小字号 (pt)",Se("shrinkMinFontSize",Ze(s.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:we("默认 6")},N("shrinkMinFontSize")):"",a("div",{class:"merge-btns"},[a("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!it,title:it||"",onClick:()=>{p.mergeCells(n,i),t.updateElement(e.id,{tableRows:n})}}),a("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!ue,onClick:()=>{p.splitCells(n,i),t.updateElement(e.id,{tableRows:n})}})])])])}const Fo=A.WATERMARK_DENSITY_PRESETS;function Ko(o){const e=o.trim();return e?/[{}]/.test(e)||/^[A-Za-z_$][\w$]*\s*\(/.test(e)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(e):!1}function nl(o){return o?o.mode==="binding"?o.binding??"":o.content??"":""}function rl(o){const e=o.store.templateData.watermark,t=nl(e),i=e?.mode==="binding"||t!==""&&Ko(t),n=(()=>{const u=e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,h=e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight;for(const[m,g]of Object.entries(Fo))if(g.width===u&&g.height===h)return m;return"custom"})(),r=u=>{const h={testData:e?.testData??"",rotate:e?.rotate??A.WATERMARK_DEFAULTS.rotate,color:e?.color||A.WATERMARK_DEFAULTS.color,opacity:e?.opacity??A.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight,timestamp:e?.timestamp,format:e?.format};o.store.updateTemplateData({watermark:{...h,...u}})},s=()=>o.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:t}),l={rotate:e?.rotate??A.WATERMARK_DEFAULTS.rotate,color:e?.color||A.WATERMARK_DEFAULTS.color,opacity:e?.opacity??A.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight},c=u=>tt({target:l,base:A.WATERMARK_DEFAULTS,propKey:u,write:()=>r({[u]:A.WATERMARK_DEFAULTS[u]})});return a("div",{class:"watermark-config"},[Pe("水印"),a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},[a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"水印表达式"}),a("input",{class:"pd-input",type:"text",value:t,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:u=>{const h=u.target.value;r(Ko(h)?{mode:"binding",binding:h,content:""}:{mode:"fixed",content:h,binding:""})},onDblclick:s}),a("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:s})]),i?B("测试值",a("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:u=>r({testData:u.target.value})})):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),a("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??A.WATERMARK_DEFAULTS.rotate),onChange:u=>r({rotate:Number(u.target.value)})}),a("span",{class:"pd-hint",text:`${e?.rotate??A.WATERMARK_DEFAULTS.rotate}°`})]),B("颜色",Ae(e?.color||A.WATERMARK_DEFAULTS.color,u=>r({color:u}),"水印颜色"),void 0,c("color")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),a("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??A.WATERMARK_DEFAULTS.opacity),onChange:u=>r({opacity:Number(u.target.value)})}),a("span",{class:"pd-hint",text:(e?.opacity??A.WATERMARK_DEFAULTS.opacity).toFixed(2)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"密度"}),a("select",{class:"pd-select",style:{width:"100%"},onChange:u=>{const h=u.target.value,m=Fo[h];m&&r({tileWidth:m.width,tileHeight:m.height})}},[...Object.entries(Fo).map(([u,h])=>a("option",{value:u,text:`${h.label}(${h.width}×${h.height})`,selected:n===u})),a("option",{value:"custom",text:"自定义",selected:n==="custom"})])]),n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),a("input",{type:"number",class:"pd-input",min:A.WATERMARK_DEFAULTS.minTileWidth,step:10,value:String(e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth),onChange:u=>r({tileWidth:Number(u.target.value)})})]):"",n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),a("input",{type:"number",class:"pd-input",min:A.WATERMARK_DEFAULTS.minTileHeight,step:10,value:String(e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight),onChange:u=>r({tileHeight:Number(u.target.value)})})]):""].filter(Boolean))])}function de(o,e,t,i,n={},r){return B(e,I({value:t,...n,onCommit:i}),void 0,r)}function We(o,e,t,i,n,r,s){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>n(l.value));for(const c of i){const u=document.createElement("option");u.value=c.value,u.textContent=c.label,l.appendChild(u)}return l.value=t,i.some(c=>c.value===t)||(l.selectedIndex=-1),r?Ce(e,l,r,s):B(e,l,void 0,s)}function ht(o,e,t,i,n){return B(e,a("input",{type:"checkbox",class:"pd-switch",checked:t,onChange:r=>i(r.target.checked)}),void 0,n)}const al=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],sl=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function ll(o,e){const t=o.store,i=e.options,n=e.printElementType.type,r=y=>t.updateElement(e.id,y),s=n==="text"||n==="longText",l=n==="barcode"||n==="qrcode",c=n==="table",u=c&&t.tableSelection?.elementId===e.id,h=u&&p.resolveCellGroupMode(e.options.tableRows??[],t.tableSelection).mode==="multi",m=[];u||m.push(xe(o,"position-size","位置与尺寸","Location",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"position-grid"},[_(o,"ps-left",de(o,"X",i.left,y=>r({left:y}),{min:0})),_(o,"ps-top",de(o,"Y",i.top,y=>r({top:y}),{min:0})),_(o,"ps-width",de(o,"W",i.width,y=>r({width:y}),{min:4})),_(o,"ps-height",de(o,"H",i.height,y=>r({height:y}),{min:4}))])])]));const g=p.createDefaultOptions(n),v=(y,H)=>{const ae=p.propertyDefault(H);return tt({target:i,base:g,propKey:y,tipValue:ae?.value,tipUnit:ae?.unit,write:()=>r({[y]:g[y]})})},b=typeof i.rotate=="number"&&Number.isFinite(i.rotate)&&i.rotate!==0?p.normalizeRotationAngle(i.rotate):void 0,w=y=>r({rotate:y===void 0||y===0?void 0:p.normalizeRotationAngle(y)}),T=p.isFreeAngleEditable(n,i),k=p.isRotationExcludedType(n)||p.collectFollowMemberIds(t.elements).has(e.id),z=k?"":_(o,"ap-rotate",Ce("旋转 (°)",a("div",{class:"pd-rotate-row"},[a("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>w((b??0)-90)}),a("div",{class:"pd-rotate-stepper"},[I({value:b,min:0,max:359,placeholder:"0",disabled:!T,onCommit:y=>w(y)})]),a("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>w((b??0)+90)})]),p.propertyTip("ap-rotate"),v("rotate","ap-rotate"))),W=k||T?"":a("p",{class:"pd-hint pd-rotate-note",text:p.CODE_OBLIQUE_NOTE});if(m.push(xe(o,"appearance","外观","Brush",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},s?[_(o,"ap-font-family",B("字体",so({id:"prop-font",state:o.state,fonts:o.host.fonts,value:typeof i.fontFamily=="string"?i.fontFamily:void 0,placeholder:"默认",onChange:y=>r({fontFamily:y})}),void 0,v("fontFamily","ap-font-family"))),_(o,"ap-font-size",de(o,"字体大小",i.fontSize,y=>r({fontSize:y}),{min:8,max:72},v("fontSize","ap-font-size"))),_(o,"ap-font-weight",We(o,"字体粗细",String(i.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],y=>r({fontWeight:y}),void 0,v("fontWeight","ap-font-weight"))),_(o,"ap-align",B("对齐",Ue("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],i.textAlign||"left",y=>r({textAlign:y})),void 0,v("textAlign","ap-align"))),_(o,"ap-vertical-align",B("垂直对齐",Ue("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],i.verticalAlign||"top",y=>r({verticalAlign:y})),void 0,v("verticalAlign","ap-vertical-align"))),a("div",{class:"color-row"},[_(o,"ap-color",B("颜色",Ae(i.color,y=>r({color:y}),"字体颜色"),void 0,v("color","ap-color"))),_(o,"ap-bg-color",B("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","ap-bg-color")))]),_(o,"ap-line-height",de(o,"行高",i.lineHeight,y=>r({lineHeight:y||void 0}),{min:0,max:100},v("lineHeight","ap-line-height"))),_(o,"ap-letter-spacing",de(o,"字间距",i.letterSpacing,y=>r({letterSpacing:y||void 0}),{min:0,max:20,step:.5},v("letterSpacing","ap-letter-spacing"))),_(o,"ap-text-fit",We(o,"文字溢出",p.resolveElementTextFit(n,i),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],y=>r({textFit:y}),void 0,v("textFit","ap-text-fit"))),i.textFit==="shrink"?_(o,"ap-shrink-min",B("最小字号 (pt)",I({value:i.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:y=>r({shrinkMinFontSize:y||void 0})}),void 0,v("shrinkMinFontSize","ap-shrink-min"))):"",n==="longText"?_(o,"ap-long-text-indent",Ce("首行缩进 (字符)",I({value:i.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:y=>r({longTextIndent:y||void 0})}),p.propertyTip("ap-long-text-indent"),v("longTextIndent","ap-long-text-indent"))):"",_(o,"ap-word-wrap",ht(o,"自动换行",i.wordWrap!==!1,y=>r({wordWrap:y?void 0:!1}),v("wordWrap","ap-word-wrap"))),_(o,"ap-keep-line-breaks",ht(o,"保留换行符",i.keepLineBreaks===!0,y=>r({keepLineBreaks:y?!0:void 0}),v("keepLineBreaks","ap-keep-line-breaks"))),z,W]:[n==="image"?_(o,"ap-img-fit",We(o,"缩放模式",String(i.fit??"contain"),p.IMAGE_FIT_OPTIONS,y=>r({fit:y}),p.propertyTip("ap-img-fit"),v("fit","ap-img-fit"))):"",n==="image"&&i.fit==="cover"?_(o,"ap-img-object-position",Gn(o,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(i.src),widthMm:Number(i.width)||0,heightMm:Number(i.height)||0,fit:i.fit,scale:i.fitScale,value:i.objectPosition===void 0?void 0:String(i.objectPosition),onCommit:y=>r({objectPosition:y}),onScaleCommit:y=>r({fitScale:y}),resetAnchor:v("objectPosition","ap-img-object-position"),resetScale:v("fitScale","ap-img-fit-scale")})):"",z,W,n==="flowList"?a("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),l){const y=n==="barcode",H=String(i.barcodeType||"CODE128").toUpperCase(),ae=i.printerDpi?String(i.printerDpi):"",Fe=p.barcodeBarWidthRecommendText(i.printerDpi,i.barWidth);m.push(xe(o,"code","条码设置","Postcard",[a("form",{class:"pd-form",onSubmit:L=>L.preventDefault()},[y?[_(o,"cd-type",We(o,"码制",H,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],L=>r({barcodeType:L==="CODE128"?void 0:L}))),_(o,"cd-dpi",We(o,"打印机分辨率",ae,[{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)"}],L=>r({printerDpi:Number(L)>0?Number(L):void 0}),void 0,v("printerDpi","cd-dpi"))),_(o,"cd-dpi",a("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),_(o,"cd-bar-width",de(o,"条宽(倍率)",i.barWidth??2,L=>r({barWidth:L}),{min:2,max:8,step:.5},v("barWidth","cd-bar-width"))),_(o,"cd-bar-width",a("p",{class:"pd-hint",text:(ae?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Fe?`。${Fe}`:"")})),_(o,"cd-bar-quiet-zone",Ce("静区 (模块)",I({value:i.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:L=>r({barQuietZone:L})}),p.propertyTip("cd-bar-quiet-zone"),v("barQuietZone","cd-bar-quiet-zone"))),_(o,"cd-bar-height",Ce("条高 (mm)",I({value:i.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:L=>r({barHeight:L??void 0})}),p.propertyTip("cd-bar-height"),v("barHeight","cd-bar-height"))),_(o,"cd-show-text",ht(o,"显示文本",i.hideTitle!==!0,L=>r({hideTitle:L?void 0:!0}),v("hideTitle","cd-show-text"))),_(o,"cd-font-size",B("文本字号(相对条高,条高为 30)",I({value:i.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:L=>r({fontSize:L||void 0})}),void 0,v("fontSize","cd-font-size")))]:[_(o,"cd-ec-level",We(o,"纠错级别",String(i.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],L=>r({qrCodeLevel:L}),void 0,v("qrCodeLevel","cd-ec-level"))),_(o,"cd-quiet-zone",Ce("静区 (模块)",I({value:i.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:L=>r({qrQuietZone:L})}),p.propertyTip("cd-quiet-zone"),v("qrQuietZone","cd-quiet-zone")))],Pe("自定义设置"),y?a("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",y?"":_(o,"cd-fit",We(o,"缩放模式",String(i.fit||"contain"),p.IMAGE_FIT_OPTIONS,L=>r({fit:L||void 0}),void 0,v("fit","cd-fit"))),_(o,"cd-max-width",B("最大宽度 (mm)",I({value:i.maxWidth,min:1,max:200,placeholder:"默认",onCommit:L=>r({maxWidth:L||void 0})}),void 0,v("maxWidth","cd-max-width"))),_(o,"cd-max-height",B("最大高度 (mm)",I({value:i.maxHeight,min:1,max:200,placeholder:"默认",onCommit:L=>r({maxHeight:L||void 0})}),void 0,v("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(h||m.push(js(o,e)),u&&(m.push(el(o,e)),m.push(il(o,e))),c&&m.push(tl(o,e)),n==="flowList"){const y=p.resolveFlowColumns(i.flowColumns),H=p.resolveFlowRowHeight(i.flowRowHeight),ae=p.resolveFlowGapX(i.flowGapX),Fe=p.resolveFlowMaxSpan(i.flowMaxSpan,y),L=p.suggestFlowColumns(i.width??0,ae,i.fontSize??12);m.push(xe(o,"flowList","流式列表","Grid3x3",[a("form",{class:"pd-form",onSubmit:ee=>ee.preventDefault()},[_(o,"fl-columns",Ce("每行列数",I({value:y,min:1,max:12,onCommit:ee=>r({flowColumns:p.resolveFlowColumns(ee),flowMaxSpan:p.resolveFlowMaxSpan(i.flowMaxSpan,p.resolveFlowColumns(ee))})}),p.propertyTip("fl-columns"))),_(o,"fl-row-height",Ce("行高 (mm)",I({value:H,min:3,max:100,step:.5,onCommit:ee=>r({flowRowHeight:p.resolveFlowRowHeight(ee)})}),p.propertyTip("fl-row-height"))),_(o,"fl-gap-x",Ce("单元横向间距 (mm)",I({value:ae,min:0,max:50,step:.5,onCommit:ee=>r({flowGapX:p.resolveFlowGapX(ee)})}),p.propertyTip("fl-gap-x"))),_(o,"fl-auto-span",ht(o,"内容过长时跨列",i.flowAutoSpan===!0,ee=>{r(ee?{flowAutoSpan:ee,flowMaxSpan:Fe}:{flowAutoSpan:ee})})),i.flowAutoSpan===!0?_(o,"fl-max-span",Ce("最多跨几列",I({value:Fe,min:1,max:y,onCommit:ee=>r({flowMaxSpan:p.resolveFlowMaxSpan(ee,y)})}),p.propertyTip("fl-max-span"))):"",y>L?a("p",{class:"pd-hint",text:`按当前字号与框宽,${y} 列偏挤(可放约 ${L} 列)。数值保持不变,出纸按 ${y} 列排。`}):""].flat().filter(Boolean))]))}const P=()=>({borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:i.borders}),ne=y=>{const H=P();p.applyElementBorderPreset(H,y,p.effectiveElementBorderSpec(H)),r(H)},ye=y=>{const H=P();p.setElementBorderEdgeVisible(H,y,!p.elementBorderEdgeVisible(H,y)),r(H)},Y=p.resolveElementBorderDisplay(i),F=Y.style==="mixed",M=typeof Y.width=="number"?Y.width:void 0,G=F||Y.style===void 0?"":Y.style,V=typeof Y.color=="string"?Y.color:void 0,ce=(y,H)=>{const ae=P();p.setElementBorderField(ae,y,H),r(ae)},Z=F?[{value:"",label:"混合"},...p.BORDER_LINE_STYLES]:[...p.BORDER_LINE_STYLES];return m.push(xe(o,"border-bg","边框与背景","Picture",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[_(o,"bb-border-style",We(o,"线型",G,Z,y=>ce("borderStyle",y))),a("div",{class:"border-row"},[_(o,"bb-border-width",de(o,"边框宽度",M,y=>ce("borderWidth",y),{min:0,max:20,step:.25,placeholder:Y.width==="mixed"?"混合":void 0},v("borderWidth","bb-border-width"))),_(o,"bb-border-color",B("边框颜色",Ae(V,y=>ce("borderColor",y),"边框颜色"),void 0,v("borderColor","bb-border-color")))]),...p.acceptsElementBorder(n)?[a("div",{class:"pd-button-group border-presets"},al.map(y=>a("button",{type:"button",class:"pd-button small",text:y.label,disabled:y.value==="inner",onClick:()=>ne(y.value)}))),a("div",{class:"pd-checkbox-group"},sl.map(y=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",checked:p.elementBorderEdgeVisible(i,y.value),onChange:()=>ye(y.value)}),a("span",{text:y.label})]))),a("p",{class:"pd-hint",text:p.ELEMENT_BORDER_APPLY_HINT})]:[],_(o,"bb-bg-color",B("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","bb-bg-color")))])])),m.push(ol(o,e)),m.push(xe(o,"advanced","高级设置","Setting",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"advanced-row"},[_(o,"ad-locked",ht(o,"锁定",!!i.locked,y=>r({locked:y}),v("locked","ad-locked"))),_(o,"ad-fixed",ht(o,"每页重复",!!i.fixed,y=>r({fixed:y}),v("fixed","ad-fixed")))]),_(o,"ad-z-index",de(o,"层级",i.zIndex,y=>r({zIndex:y}),{min:0,max:999},v("zIndex","ad-z-index"))),_(o,"ad-delete",a("div",{class:"pd-field"},[a("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>t.deleteSelected()})]))])],!1)),a("div",{class:"property-content"},m)}function dl(o){const e=o.store,t=e.templateData,i=c=>e.updateTemplateData(c),n=c=>{const u=t.tiling,h=m=>m===90||m===270;if(u?.enabled&&h(c)!==h(t.outputRotation)){const m=A.computeMaxColumns({...t,outputRotation:c});i({outputRotation:c,tiling:{...u,columns:Math.max(m,1)}});return}i({outputRotation:c})},r=[];for(const[c,u]of Object.entries(p.PAPER_PRESETS)){const h=u.group??"其他";let m=r.find(g=>g.group===h);m||(m={group:h,items:[]},r.push(m)),m.items.push({key:c,label:u.label??c})}const s=!p.PAPER_PRESETS[t.paperSize],l=p.isContinuousPaperSize(t.paperSize);return a("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[Pe("纸张设置"),B("纸张尺寸",a("select",{class:"pd-select",style:{width:"100%"},onChange:c=>i({paperSize:c.target.value})},[...r.map(c=>a("optgroup",{label:c.group},c.items.map(u=>a("option",{value:u.key,text:u.label,selected:t.paperSize===u.key})))),a("option",{value:"CUSTOM",text:"自定义宽高",selected:s})])),l||s?B(l?"纸宽 (mm)":"自定义宽高 (mm)",a("div",{class:"custom-size-grid"},[I({value:Number(t.customWidth??0),min:25,max:2e3,onCommit:c=>i({customWidth:c})}),...s?[a("span",{class:"custom-size-x",text:"×"}),I({value:Number(t.customHeight??0),min:25,max:2e3,onCommit:c=>i({customHeight:c})})]:[]])):"",l?"":B("纸张方向",Ue("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],t.orientation==="landscape"?"landscape":"portrait",c=>i({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":B("内容旋转角度",Ue("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(t.outputRotation??0),c=>n(Number(c)),!0),t.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),B("页面背景色",a("div",{class:"page-bg-row"},[Ae(t.pageBackground,c=>i({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,tt({target:t,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>i({pageBackground:void 0})})),Fs(o),e.pages.length>1?"":Ls(o),Pe("页边距 (mm)"),a("div",{class:"margin-grid"},[de(o,"上",t.margins.top,c=>i({margins:{...t.margins,top:c}}),{min:0,max:50}),de(o,"下",t.margins.bottom,c=>i({margins:{...t.margins,bottom:c}}),{min:0,max:100}),de(o,"左",t.margins.left,c=>i({margins:{...t.margins,left:c}}),{min:0,max:50}),de(o,"右",t.margins.right,c=>i({margins:{...t.margins,right:c}}),{min:0,max:50})]),Pe("页眉/页脚高度 (mm)"),de(o,"页眉高度",t.header.height??10,c=>i({header:{...t.header,height:c}}),{min:0,max:100,step:.1}),de(o,"页脚高度",t.footer.height??10,c=>i({footer:{...t.footer,height:c}}),{min:0,max:100,step:.1}),rl(o)].filter(Boolean))}function cl(o){const e=o.store,t=o.state,i=e.selectedElement;if(t.propCollapsed)return a("div",{class:"property-panel collapsed"},[a("div",{class:"prop-collapsed"},[a("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{t.propCollapsed=!1,o.repaint()}}),...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([r,s,l])=>a("button",{type:"button",class:`pc-btn${t.propTab===r?" on":""}`,title:s,text:l,onClick:()=>{t.propTab=r,t.propCollapsed=!1,o.repaint()}}))])]);const n=i?t.propTab:"page";return a("div",{class:"property-panel"},[a("div",{class:"prop-head"},[a("span",{class:"prop-title",text:"属性台"}),a("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{t.propCollapsed=!0,o.repaint()}})]),a("div",{class:"pd-tabs prop-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[a("button",{type:"button",class:`pd-tab${n==="element"?" active":""}`,text:"元素属性",onClick:()=>{t.propTab="element",o.repaint()}}),a("button",{type:"button",class:`pd-tab${n==="page"?" active":""}`,text:"页面属性",onClick:()=>{t.propTab="page",o.repaint()}})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="element"?"":{display:"none"}},i?[Hs(o),ll(o,i)]:[a("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="page"?"":{display:"none"}},[dl(o)])])])}const Lo=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],dn={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},pl=[{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()"}],ul=[{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()"}],hl=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],fl=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],ml=[{title:"聚合函数",items:pl},{title:"数值运算",items:ul},{title:"格式化函数",items:hl}],gl="(输入表达式后预览)",bl="(无法计算)",jo="(表达式错误)";function cn(o,e){if(!o.trim())return gl;try{const t={...p.DEFAULT_DEMO_DATA,...e??{},...A.resolveSystemVariables()},i=p.evaluateTemplate(o,t);return i==null?bl:String(i)}catch{return jo}}function pn(o,e){const t=e.trim().toLowerCase();return t?o.filter(i=>i.label.toLowerCase().includes(t)||i.name.toLowerCase().includes(t)):o}function xl(o,e){const t=o.substring(0,e),i=t.lastIndexOf("{"),n=i!==-1&&!t.slice(i+1).includes("}"),r=t.lastIndexOf("("),s=r!==-1&&!t.slice(r+1).includes(")");return{insideBlock:n,insideParens:s}}function vl(o,e){const t=/^\{\s*([^{}]+?)\s*\}$/.exec(o.trim());if(!t)return null;const i=t[1]??"";return e.find(n=>n.fieldKey===i)??null}function Io(o,e){return a("div",{class:"ee-field-info"},[a("span",{class:"ee-item-label",text:o}),a("span",{class:"ee-item-key",text:e})])}function Ve(o){return o.currentTarget.getRootNode()}function Qt(o,e,t){const i=[];return t.forEach((n,r)=>{i.push(n),r<t.length-1&&i.push(a("br"))}),a("div",{class:`ee-help-card ${o}`},[a("div",{class:"ee-help-card-title",text:e}),a("div",{class:"ee-help-card-content"},i)])}function yl(){return a("div",{class:"ee-help-section"},[a("div",{class:"ee-help-title",text:"帮助信息"}),a("div",{class:"ee-help-grid"},[Qt("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),Qt("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Qt("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Qt("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function wl(o,e){const t={activeTab:"field",searchText:"",expression:e.value||"",binding:e.binding},i=(b,w)=>b.querySelector(w),n=b=>{const w=i(b,".ee-preview");if(!w)return;const T=cn(t.expression,o.demoData);w.textContent=T,w.classList.toggle("ee-preview-error",T===jo)},r=()=>{if(t.activeTab==="variable")return pn(fl,t.searchText).map(T=>a("div",{class:"ee-list-item",onDblclick:k=>{const{insideParens:z}=l(k);c(Ve(k),z?T.template.replace(/^\{|\}$/g,""):T.template)}},[Io(T.label,T.template)]));if(t.activeTab==="function")return ml.map(T=>a("div",{class:"ee-func-group"},[a("div",{class:"ee-func-group-title",text:T.title}),...pn(T.items,t.searchText).map(k=>a("div",{class:"ee-list-item",onDblclick:z=>{const{insideBlock:W}=l(z),P=W?k.template:`{${k.template}}`;c(Ve(z),P,P.indexOf("(")+1)}},[Io(k.label,`${k.name}()`)]))]));const b=p.filterGroups(p.groupFields(o.fields??[]),t.searchText);if(!b.length)return[a("p",{class:"pd-empty",text:"暂无字段"})];const w=[];for(const T of b){T.key&&w.push(a("div",{class:`ee-field-group${T.isList?" is-list":""}`},[a("span",{class:"ee-field-group-icon",text:T.isList?"📋":"📁"}),a("span",{text:T.label})]));for(const k of T.fields)w.push(a("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:T.key?"22px":"10px"},onDblclick:z=>{const{insideParens:W}=l(z);c(Ve(z),W?k.fieldKey:`{${k.fieldKey}}`)}},[Io(k.fieldLabel,k.fieldKey)]))}return w},s=b=>{Array.from(b.querySelectorAll(".ee-nav-tab")).forEach((W,P)=>W.classList.toggle("active",Lo[P]?.key===t.activeTab));const T=i(b,".ee-content-search .pd-input");if(T){const W=dn[t.activeTab];T.placeholder!==W&&(T.placeholder=W),T.value!==t.searchText&&(T.value=t.searchText)}const k=i(b,".ee-textarea");k&&k.value!==t.expression&&(k.value=t.expression);const z=i(b,".ee-content-list");if(z){Tn(z);for(const W of r())fe(W,z)}n(b)},l=b=>{const T=i(Ve(b),".ee-textarea")?.selectionStart??t.expression.length;return xl(t.expression,T)},c=(b,w,T=w.length)=>{const k=i(b,".ee-textarea");if(!k){t.expression+=w,n(b);return}const z=k.selectionStart??t.expression.length,W=k.selectionEnd??z;t.expression=t.expression.substring(0,z)+w+t.expression.substring(W);const P=z+T;k.value=t.expression,k.focus(),k.selectionStart=k.selectionEnd=P,n(b)},u=()=>{const b=t.expression;if(t.binding===void 0){o.onApply({formatter:b}),o.onClose();return}const w=vl(b,o.fields??[]);o.onApply(w?{formatter:b,binding:w.fieldKey,title:w.fieldLabel}:{formatter:b}),o.onClose()},h=a("div",{class:"ee-nav"},[a("div",{class:"ee-nav-title",text:"类型"}),a("div",{class:"ee-nav-tabs"},Lo.map((b,w)=>a("div",{class:`ee-nav-tab${t.activeTab===b.key?" active":""}`,text:b.text,onClick:T=>{t.activeTab=Lo[w].key,s(Ve(T))}})))]),m=a("div",{class:"ee-content"},[a("div",{class:"ee-content-search"},[a("input",{class:"pd-input",placeholder:dn[t.activeTab],onInput:b=>{t.searchText=b.target.value,s(Ve(b))}})]),a("div",{class:"ee-content-list"},r())]),g=cn(t.expression,o.demoData),v=a("div",{class:"ee-editor"},[a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"表达式编辑"}),a("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,或直接输入静态内容",text:t.expression,onInput:b=>{t.expression=b.target.value,n(Ve(b))}})]),a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"预览结果"}),a("div",{class:`ee-preview${g===jo?" ee-preview-error":""}`,text:g})]),yl()]);return a("div",{class:"pd-dialog-overlay",onKeydown:b=>{b.key==="Escape"&&o.onClose()}},[a("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[a("header",{class:"pd-dialog-header"},[a("strong",{id:"expression-editor-title",text:"编辑表达式"}),a("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>o.onClose()})]),a("div",{class:"expression-editor"},[h,m,v]),a("footer",{class:"pd-dialog-footer"},[a("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>o.onClose()}),a("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>u()})])])])}const Sl={id:"getting-started",title:"快速入门",content:`
|
|
3
|
+
`+X),Q&&(X=Kt(X)),M&&Ht?H(X):X},e.setConfig=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yo(E),yt=!0,Nt=q,$t=K},e.clearConfig=function(){dt=null,yt=!1,Nt=null,$t=null,M=V,G=""},e.isValidAttribute=function(E,d,f){dt||yo({});const S=oe(E),C=oe(d);return Di(S,C,f)},e.addHook=function(E,d){typeof d=="function"&&be(U,E)&&Tt(U[E],d)},e.removeHook=function(E,d){if(be(U,E)){if(d!==void 0){const f=Ar(U[E],d);return f===-1?void 0:Dr(U[E],f,1)[0]}return Li(U[E])}},e.removeHooks=function(E){be(U,E)&&(U[E]=[])},e.removeAllHooks=function(){U=ji()},e}var Jr=Mn();const ea={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ta(o){const e=o.options;return p.resolveBarcodeDesignValue(e.formatter,void 0,String(e.testData||e.title||""))||"条码"}function oa(o){return a("div",{class:"print-qrcode",dataset:{codeId:o.id,codeKind:"qrcode"}})}function ia(o){const e=o.options;return a("div",{class:"print-barcode",dataset:{codeId:o.id,codeKind:"barcode"}},[a("svg",{preserveAspectRatio:ea[String(e.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function na(o){const e=(o.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(t=>!Number.isFinite(t))?null:{width:e[2],height:e[3]}}function ra(o,e){const t=o.options,i=p.barcodeUnitsPerModule(t.barWidth),n=p.barcodeQuietZoneModules(t.barQuietZone),r=s=>{wn(e,ta(o),{format:String(t.barcodeType||"CODE128"),width:i,height:s*i,displayValue:!t.hideTitle,fontSize:(t.fontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*i,margin:0,marginLeft:n*i,marginRight:n*i,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*i});const l=na(e);return l?{widthUnits:l.width,heightUnits:l.height}:null};try{const s=p.layoutBarcodeSize({barHeightMm:t.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(t.width,t.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(t.height,t.maxHeight),dpi:t.printerDpi,barWidth:t.barWidth,measure:r});e.style.width=s.size?`${s.size.widthMm}mm`:"",e.style.height=s.size?`${s.size.heightMm}mm`:""}catch{e.replaceChildren();return}e.setAttribute("shape-rendering","crispEdges")}function aa(o,e){const t=o.options,i=p.resolveBarcodeDesignValue(t.formatter,void 0,String(t.testData||t.title||""))||"二维码";e.replaceChildren();try{const n=Vo.browserCodeRenderer.render(i,"qrcode",{qrCodeLevel:String(t.qrCodeLevel??"M"),qrQuietZone:typeof t.qrQuietZone=="number"?t.qrQuietZone:void 0}),r=document.createElement("img");r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,r.alt="qrcode",r.style.width="100%",r.style.height="100%",r.style.objectFit=String(t.fit||"contain"),r.style.maxWidth=t.maxWidth?`${t.maxWidth}mm`:"100%",r.style.maxHeight=t.maxHeight?`${t.maxHeight}mm`:"100%",e.appendChild(r)}catch{}}function sa(o,e){for(const t of Array.from(o.querySelectorAll("[data-code-kind]"))){const i=t.dataset.codeId,n=e.find(r=>r.id===i);if(n)if(t.dataset.codeKind==="barcode"){const r=t.querySelector("svg");r&&ra(n,r)}else aa(n,t)}}const la={header:"题",data:"数",subtotal:"小",summary:"汇"},da=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],eo=3.7795275591,ca=.1,Ho=o=>JSON.parse(JSON.stringify(o)),Yi=new WeakMap;function Ne(o){let e=Yi.get(o);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},Yi.set(o,e)),e}function Pt(o,e){return o.templateData.elements.find(t=>t.id===e)??null}function pa(o,e){const t=o.tableSelection;return!t||t.elementId!==e.id?null:o.selectedElement?.id!==e.id?(o.tableSelection=null,null):t}function _n(o,e,t){const i=Pt(o,t.id);if(!i)return null;const n=t.options;return{store:o,fire:e,el:t,real:i,options:n,rows:n.tableRows??[],colWidths:n.tableColWidths??[],isSelected:o.selectedIds.has(t.id),selection:pa(o,t),maxTableWidth:Rn(o)}}function Rn(o){return o.paperSize.width-o.templateData.margins.left-o.templateData.margins.right}function Zo(o){return o.options.tableDefaultFontSize??10}function zn(o){return o.options.tableDefaultColor??"#333333"}function ua(o,e){let t=0;for(let i=0;i<e;i++)t+=o.rows[i].height;return t}function ha(o,e){return Ne(o.store).layouts.get(o.el.id)?.[e]?.top??ua(o,e)}function fa(o,e){return Ne(o.store).layouts.get(o.el.id)?.[e]?.height??o.rows[e]?.height??0}function ma(o){const e=o.options.dataSource;if(e&&Array.isArray(p.DEFAULT_DEMO_DATA[e]))return p.DEFAULT_DEMO_DATA[e];for(const t of Object.values(p.DEFAULT_DEMO_DATA))if(Array.isArray(t))return t}function Pn(o){return o.cellType==="barcode"||o.cellType==="qrcode"}function Fn(o,e){return Pn(e)?p.resolveBarcodeDesignValue(e.formatter,ma(o)):e.formatter||""}function ga(o,e){const t={designMode:!0,showGhostBorder:o.store.showTableGhostBorder};return{fontFamily:A.resolveCanvasFontFamily(e.fontFamily??o.options.tableDefaultFontFamily),textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??Zo(o))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??zn(o),backgroundColor:e.backgroundColor??"transparent",borderTop:p.resolveCellBorderCss(e.borders?.top,t),borderRight:p.resolveCellBorderCss(e.borders?.right,t),borderBottom:p.resolveCellBorderCss(e.borders?.bottom,t),borderLeft:p.resolveCellBorderCss(e.borders?.left,t),padding:(e.padding??o.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"pre-wrap":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function ba(o,e,t){const i=o.selection;return[!!i&&e>=i.r1&&e<=i.r2&&t>=i.c1&&t<=i.c2?"cell-selected":"",o.rows[e]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Ln(o){return p.resolveCellTextFit(o)}function xa(o){return Ln(o)!=="autoHeight"}function va(o,e){return e.fontSize??Zo(o)}function ro(o,e,t){return p.cellFitCapMm(o.rows,e,t,o.options.tableDefaultPadding??1)}function ya(o,e,t){return p.cellFitWidthMm(o.colWidths,e,t,o.options.tableDefaultPadding??1)}function wa(o,e,t){return{maxHeight:ro(o,t,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function Sa(o,e,t){const i={fitBase:String(va(o,e)),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize)),fitMm:String(ro(o,t,e))};return Ln(e)==="shrink"&&(i.fit="shrink"),i}function Ta(o){const e=(o.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(t=>!Number.isFinite(t))?null:{width:e[2],height:e[3]}}const Ea={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ka(o,e,t,i){const n=document.createElement("div");n.className="cell-barcode";const r=document.createElementNS(fr,"svg");n.appendChild(r);const s=Fn(o,i);if(i.cellType==="barcode"){r.setAttribute("preserveAspectRatio",Ea[i.fit||"contain"]??"xMidYMid meet");const l=p.barcodeUnitsPerModule(i.barWidth),c=p.barcodeQuietZoneModules(i.barQuietZone),u=g=>{wn(r,s,{format:i.barcodeType||"CODE128",width:l,height:g*l,displayValue:i.showBarcodeText!==!1,fontSize:(i.barFontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*l,margin:0,marginLeft:c*l,marginRight:c*l,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*l});const v=Ta(r);return v?{widthUnits:v.width,heightUnits:v.height}:null};let h=null;try{h=p.layoutBarcodeSize({barHeightMm:i.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(ya(o,t,i),i.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(ro(o,e,i),i.maxHeight),dpi:i.printerDpi,barWidth:i.barWidth,measure:u})}catch{h=null}if(!h){r.style.display="none";const g=document.createElement("span");return g.className="cell-barcode-fallback",g.textContent=s||"条码",n.appendChild(g),n}const m=h.size;return m?(r.style.width=`${m.widthMm}mm`,r.style.height=`${m.heightMm}mm`):(r.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",r.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%"),r.setAttribute("shape-rendering","crispEdges"),n}if(r.style.display="none",!s)return n;try{const l=Vo.browserCodeRenderer.render(s,"qrcode",{qrCodeLevel:String(i.qrCodeLevel||"M"),qrQuietZone:typeof i.qrQuietZone=="number"?i.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=i.fit||"contain",i.objectPosition&&(c.style.objectPosition=i.objectPosition),c.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",c.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%",n.appendChild(c)}catch{}return n}function Vi(){const o=document.createElement("div");return o.className="image-placeholder",o.textContent="图片",o}function Ca(o){const e=o.formatter||"";return e?e.includes("{")?p.evaluateTemplate(e,p.DEFAULT_DEMO_DATA):e:""}function Aa(o,e,t){const i=document.createElement("div");i.className="cell-image";const n=p.cellImageBoxMm(t.fit,ro(o,e,t));n!==void 0&&(i.style.height=`${n}mm`);const r=Ca(t);if(!r)return i.appendChild(Vi()),i;const s=document.createElement("img");s.setAttribute("src",r),n!==void 0&&(s.style.width="100%",s.style.height="100%"),s.style.objectFit=t.fit||"contain";for(const[l,c]of Object.entries(p.cropStyleDeclarations(t.fit,t.fitScale,t.objectPosition)))s.style[l]=c;return s.style.maxWidth=t.maxWidth?`${t.maxWidth}mm`:"100%",s.style.maxHeight=t.maxHeight?`${t.maxHeight}mm`:"100%",s.addEventListener("error",()=>{s.remove(),i.appendChild(Vi())},{once:!0}),i.appendChild(s),i}function Da(o,e,t,i,n){if(Pn(n))return ka(o,t,i,n);if(n.cellType==="image")return Aa(o,t,n);const r=Fn(o,n),s=()=>e.type==="data"?a("span",{class:"data-placeholder",text:r}):r;return xa(n)?a("div",{class:"cell-fit",style:wa(o,n,t),dataset:Sa(o,n,t)},[s()]):s()}function oo(o,e,t){const i={elementId:o.el.id,...p.normalizeSelection(o.rows,e,t)};o.store.setTableSelection(i),o.fire("table-selection-change",{elementId:o.el.id,selection:i})}function Ma(o,e,t,i,n){if(n.button!==0||(o.fire("table-cell-mousedown",{elementId:o.el.id,r:e,c:t,cellId:i,event:n}),!o.isSelected))return;n.stopPropagation();const r=Ne(o.store);n.shiftKey&&o.selection?oo(o,{r:o.selection.r1,c:o.selection.c1},{r:e,c:t}):(r.anchor={r:e,c:t},oo(o,{r:e,c:t},{r:e,c:t})),document.addEventListener("mouseup",()=>{Ne(o.store).anchor=null},{once:!0})}function _a(o,e,t){const i=Ne(o.store).anchor;i&&oo(o,i,{r:e,c:t})}function In(o,e){const t=Ne(o);t.menu?.visible&&(t.menu.visible=!1,e("table-menu-close",{elementId:t.menuElId}),o.emit(!1))}function Ra(o,e,t,i){i.preventDefault(),i.stopPropagation(),o.isSelected||o.store.selectOne(o.el.id);const n=o.selection;n&&e>=n.r1&&e<=n.r2&&t>=n.c1&&t<=n.c2||oo(o,{r:e,c:t},{r:e,c:t});const s=Ne(o.store);s.menuElId=o.el.id,s.menu&&(s.menu.x=i.clientX,s.menu.y=i.clientY,s.menu.visible=!0),o.fire("table-cell-contextmenu",{elementId:o.el.id,r:e,c:t,clientX:i.clientX,clientY:i.clientY}),o.store.emit(!1),document.addEventListener("mousedown",()=>In(o.store,o.fire),{once:!0})}function Xi(o,e,t){const i=o.reduce((n,r)=>n+r,0)+(o[e]??0);return i>t?`插入后表格总宽 ${Math.round(i*10)/10}mm 超过打印范围宽度 ${t}mm,请先缩小列宽`:null}function za(o,e){const t=o.real.options.tableRows??[],i=o.real.options.tableColWidths??[],n=e(Ho(t),Ho(i));return n?(window.alert(n),!1):(o.store.recordHistory(),e(t,i),o.store.setTableSelection(null),p.syncTableElementSize(o.real.options),o.store.emit(),!0)}function Le(o,e,t){In(o.store,o.fire);const i=o.selection;if(!i)return;let n=null;switch(e){case"insert-row-above":n=r=>(p.insertRow(r,i.r1,"above"),null);break;case"insert-row-below":n=r=>(p.insertRow(r,i.r2,"below"),null);break;case"delete-row":n=r=>p.deleteRow(r,i.r1);break;case"insert-col-left":n=(r,s)=>{const l=Xi(s,i.c1,o.maxTableWidth);return l||(p.insertCol(r,s,i.c1,"left"),null)};break;case"insert-col-right":n=(r,s)=>{const l=Xi(s,i.c2,o.maxTableWidth);return l||(p.insertCol(r,s,i.c2,"right"),null)};break;case"delete-col":n=(r,s)=>p.deleteCol(r,s,i.c1);break;case"merge":n=r=>(p.mergeCells(r,i),null);break;case"split":n=r=>(p.splitCells(r,i),null);break;case"set-row-type":n=r=>t?p.setRowType(r,i.r1,t):"未指定行类型";break}n&&za(o,n)&&o.fire(`table-${e}`,{elementId:o.el.id,...t?{type:t}:{}})}function Pa(o){const e=o.selection;if(!e)return!1;for(let t=e.r1;t<=e.r2;t++)for(let i=e.c1;i<=e.c2;i++){const n=o.rows[t]?.cells[i];if(n&&!n.merged&&((n.rowspan??1)>1||(n.colspan??1)>1))return!0}return!1}function Zi(o,e){const t=o.selection;return t?t.r1!==t.r2?"行类型仅支持单行设置":p.setRowType(Ho(o.rows),t.r1,e):"未选择单元格"}function Ie(o,e,t={}){return a("div",{class:`menu-item${t.disabled?" disabled":""}${t.active?" active":""}`,title:t.title||"",text:o,onClick:()=>{t.disabled||e()}})}const Ro=()=>a("div",{class:"menu-divider"});function Fa(o,e,t){const i=Ne(o);if(i.menu=t,!t.visible||!i.menuElId)return"";const n=Pt(o,i.menuElId);if(!n||n.printElementType.type!=="table")return"";const r=_n(o,e,n);if(!r)return"";const s=r.selection?p.canMergeReason(r.rows,r.selection):"未选择单元格",l=r.selection?r.rows[r.selection.r1]?.type??null:null;return a("div",{class:"table-ctx-menu",style:{left:t.x+"px",top:t.y+"px"},onMousedown:c=>c.stopPropagation()},[Ie("在上方插入行",()=>Le(r,"insert-row-above")),Ie("在下方插入行",()=>Le(r,"insert-row-below")),Ie("删除行",()=>Le(r,"delete-row"),{disabled:r.rows.length<=1}),Ro(),Ie("在左侧插入列",()=>Le(r,"insert-col-left")),Ie("在右侧插入列",()=>Le(r,"insert-col-right")),Ie("删除列",()=>Le(r,"delete-col"),{disabled:r.colWidths.length<=1}),Ro(),Ie("合并单元格",()=>Le(r,"merge"),{disabled:!!s,title:s||""}),Ie("拆分单元格",()=>Le(r,"split"),{disabled:!Pa(r)}),Ro(),a("div",{class:"menu-group-title",text:"行类型"}),...da.map(c=>Ie(c.label,()=>Le(r,"set-row-type",c.value),{disabled:!!Zi(r,c.value),title:Zi(r,c.value)||"",active:l===c.value}))])}let et=null;function On(){et&&(document.removeEventListener("mousemove",Qo),document.removeEventListener("mouseup",Jo),et.handle.classList.remove("dragging"),et=null)}function La(o,e){const t=o.closest(".hiprint-printPaper");return(t&&t.offsetWidth>0?t.getBoundingClientRect().width/t.offsetWidth:0)||(e.scale||100)/100}function Ia(o,e,t){if(t.button!==0)return;const i=t.currentTarget,n=i.closest(".print-table");if(!n)return;On();const r=o.real.options.tableColWidths??[];et={store:o.store,fire:o.fire,elId:o.real.id,boundary:e,startX:t.clientX,startWidth:r[e-1]??0,scale:La(n,o.store),root:n,wrapper:i.closest(".print-element"),handle:i},i.classList.add("dragging"),o.store.recordHistory(),document.addEventListener("mousemove",Qo),document.addEventListener("mouseup",Jo)}function Qo(o){const e=et;if(!e)return;const t=Pt(e.store,e.elId),i=t?.options.tableColWidths;if(!t||!i)return;const n=(o.clientX-e.startX)/(e.scale*eo),r=e.boundary-1;i[r]=p.clampResizedColumnWidth(i,r,e.startWidth+n,Rn(e.store)),p.syncTableElementSize(t.options),i.forEach((s,l)=>{const c=e.root.querySelector(`colgroup col:nth-child(${l+1})`);c&&(c.style.width=`${s}mm`)}),e.root.querySelectorAll(".col-resize-handle").forEach((s,l)=>{s.style.left=`${i.slice(0,l+1).reduce((c,u)=>c+u,0)}mm`}),e.wrapper&&(e.wrapper.style.width=`${t.options.width}mm`,e.wrapper.style.height=`${t.options.height}mm`)}function Jo(){document.removeEventListener("mousemove",Qo),document.removeEventListener("mouseup",Jo);const o=et;if(!o)return;et=null,o.handle.classList.remove("dragging");const e=Pt(o.store,o.elId);e&&p.syncTableElementSize(e.options),o.store.emit(),o.fire("table-col-resize-end",{elementId:o.elId})}function Oa(o,e,t){const i=t.querySelector("table");if(!i)return;const n=i.offsetHeight;if(n<=0)return;const r=Pt(o,e);if(!r)return;let s=!1;const l=n/eo;Math.abs(l-(r.options.height??0))>ca&&(r.options.height=Math.round(l*100)/100,s=!0);const c=i.offsetTop,u=Array.from(i.rows).map(m=>({top:(m.offsetTop-c)/eo,height:m.offsetHeight/eo})),h=Ne(o);Na(h.layouts.get(e),u)||(h.layouts.set(e,u),s=!0),s&&o.emit(!1)}function Na(o,e){return!o||o.length!==e.length?!1:e.every((t,i)=>{const n=o[i];return Math.round(t.top*10)===Math.round(n.top*10)&&Math.round(t.height*10)===Math.round(n.height*10)})}function $a(o,e){const t=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!t.isConnected)return;const i=t.parentElement;i&&Oa(o,e,i)}),t}function Ba(o){return o.isSelected&&!o.real.options.locked&&o.colWidths.length>=1}function Ha(o){return Array.from({length:o.colWidths.length},(e,t)=>t+1)}function Wa(o,e){return o.colWidths.slice(0,e).reduce((t,i)=>t+i,0)}function Ua(o,e,t){const i=_n(e,t,o);if(!i)return a("div",{class:"print-table"});const n=[a("table",{style:{fontSize:`${Zo(i)}pt`,color:zn(i)}},[a("colgroup",{},i.colWidths.map(r=>a("col",{style:{width:r+"mm"}}))),a("tbody",{},i.rows.map((r,s)=>a("tr",{style:{height:r.height+"mm"}},r.cells.map((l,c)=>l.merged?"":a("td",{rowspan:l.rowspan||1,colspan:l.colspan||1,class:ba(i,s,c),style:ga(i,l),onMousedown:u=>Ma(i,s,c,l.id,u),onMouseenter:()=>_a(i,s,c),onContextmenu:u=>Ra(i,s,c,u)},[Da(i,r,s,c,l)])).filter(Boolean))))])];return Ba(i)&&n.push(a("div",{class:"col-resize-layer"},Ha(i).map(r=>a("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${r}`,style:{left:Wa(i,r)+"mm"},onMousedown:s=>{s.stopPropagation(),s.preventDefault(),Ia(i,r,s)}})))),i.isSelected&&n.push(a("div",{class:"row-badges"},i.rows.map((r,s)=>a("span",{class:"row-badge",style:{top:ha(i,s)+"mm",height:fa(i,s)+"mm"},text:la[r.type]})))),n.push($a(e,o.id)),a("div",{class:"print-table design-mode",dataset:{tableId:o.id},onContextmenu:r=>r.preventDefault()},n)}const Ga=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function Wo(o){return Array.isArray(o)&&o.length>0?o:[]}function qa(o,e){const t=p.detectFlowListKey(o,e)??(e?Object.keys(e).find(n=>Array.isArray(e[n])):void 0);if(t)return Wo(e?.[t]);const i=p.detectFlowListKey(o,p.DEFAULT_DEMO_DATA);return i?Wo(p.DEFAULT_DEMO_DATA[i]):[]}function Ka(o,e){const t=o.options,i=typeof t.formatter=="string"?t.formatter:"",n=Wo(e)[0],r=qa(i,n);if(r.length===0)return[...Ga];if(!i)return r.map(c=>String(c?.name??JSON.stringify(c)));const s=n??{},l=p.detectFlowListKey(i,s)??Object.keys(s).find(c=>Array.isArray(s[c]));return r.map(c=>{try{return p.evaluateTemplate(i,{...s,...c,...l?{[l]:c}:{}})}catch{return i}})}function ja(o,e){const t=o.options,i=p.resolveFlowColumns(t.flowColumns),n=p.resolveFlowGapX(t.flowGapX),r=p.resolveFlowRowHeight(t.flowRowHeight),s={display:"grid",gridTemplateColumns:`repeat(${i},minmax(0,1fr))`,columnGap:`${n}mm`,gridAutoRows:`minmax(${r}mm,auto)`,width:"100%",height:"100%",overflow:"hidden",fontSize:`${t.fontSize||12}pt`,fontWeight:t.fontWeight||"normal",color:t.color||"#333",boxSizing:"border-box"};return t.fontFamily&&(s.fontFamily=String(t.fontFamily)),t.backgroundColor&&(s.backgroundColor=String(t.backgroundColor)),a("div",{class:"print-flowlist",style:s},Ka(o,e).map(l=>a("div",{class:"print-flow-cell",text:l})))}const Qi={top:"flex-start",middle:"center",bottom:"flex-end"},Ya={left:"flex-start",center:"center",right:"flex-end"};function Va(o,e){const t=o.options,i=p.resolveElementBorder(o.printElementType.type,t),n={};if(i?.all&&(n.border=`${i.all.borderWidth} ${i.all.borderStyle} ${i.all.borderColor}`),i)for(const r of p.ELEMENT_BORDER_SIDES){const s=i.edges[r];s&&(n[`border${r.charAt(0).toUpperCase()}${r.slice(1)}`]=`${s.borderWidth} ${s.borderStyle} ${s.borderColor}`)}return{position:"absolute",left:`${t.left}mm`,top:`${t.top}mm`,width:`${t.width}mm`,height:`${t.height}mm`,zIndex:String(t.zIndex||"auto"),...n,...Xa(o,e)}}function Xa(o,e){if(e?.has(o.id))return{};const t=p.resolveElementRotation(o.printElementType.type,o.options);return t===void 0?{}:{rotate:`${t}deg`}}function Ji(o){const e=o.options,t=o.printElementType.type==="longText",i=p.resolveElementTextFit(o.printElementType.type,e),n=e.fontSize||12,r=i==="autoHeight",s={fontSize:`${n}pt`,fontWeight:e.fontWeight||"normal",fontFamily:A.resolveCanvasFontFamily(e.fontFamily),color:e.color||"#333",backgroundColor:e.backgroundColor||"transparent",textAlign:e.textAlign||"left",...e.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:e.lineHeight?`${e.lineHeight}pt`:t?"1.5":"normal",letterSpacing:e.letterSpacing?`${e.letterSpacing}pt`:"normal",width:"100%",height:r?"auto":"100%",boxSizing:"border-box",overflow:r?"visible":"hidden",...t?{wordBreak:"break-all",textIndent:e.longTextIndent?`${e.longTextIndent}em`:"0"}:{textDecoration:e.textDecoration||"none",padding:`${e.contentPaddingTop||0}pt ${e.contentPaddingRight||0}pt ${e.contentPaddingBottom||0}pt ${e.contentPaddingLeft||0}pt`}};p.resolveElementNowrap(e)&&(s.whiteSpace="nowrap",s.textOverflow="ellipsis");const l=p.resolveElementWhiteSpace(e);return l&&(s.whiteSpace=l),e.verticalAlign&&(s.display="flex",e.textAlign==="justify"?(s.flexDirection="column",s.justifyContent=Qi[e.verticalAlign]??"flex-start"):(s.alignItems=Qi[e.verticalAlign]??"flex-start",s.justifyContent=Ya[e.textAlign||"left"]??"flex-start")),{style:s,fit:i}}function Za(o){const e=o.options,t=`${e.borderWidth||.75}pt`,i=e.borderStyle||"solid",n=e.borderColor||"#333";return o.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${t} ${i} ${n}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${t} ${i} ${n}`,boxSizing:"border-box"}}function Qa(o){const e=o.options;return{width:"100%",height:"100%",borderWidth:`${e.borderWidth||1}pt`,borderStyle:e.borderStyle||"solid",borderColor:e.borderColor||"#333",backgroundColor:e.backgroundColor||"transparent",borderRadius:o.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Ja(o){const e=o.options;return{objectFit:e.fit||"contain",...p.cropStyleDeclarations(e.fit,e.fitScale,e.objectPosition),maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function en(o){const e=o.options,t={fitBase:String(e.fontSize||12),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize))};return p.resolveElementTextFit(o.printElementType.type,e)==="shrink"&&(t.fit="shrink"),t}function es(o,e,t){const i=o.printElementType.type,n=o.options;switch(i){case"text":{const{style:r}=Ji(o);return a("div",{class:"print-text",style:r,dataset:en(o),text:String(n.testData||n.formatter||"")||"文本"})}case"longText":{const{style:r}=Ji(o);return a("div",{class:"print-longtext",style:r,dataset:en(o),text:String(n.formatter||"")||"长文本内容"})}case"hline":case"vline":return a("div",{class:"print-line",style:Za(o)});case"rect":case"oval":return a("div",{class:"print-shape",style:Qa(o)});case"image":{const r=String(n.src??""),s=r.includes("{")?p.evaluateTemplate(r,p.DEFAULT_DEMO_DATA):r;return a("div",{class:"print-image"},[s?a("img",{src:s,style:Ja(o)}):a("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return oa(o);case"barcode":return ia(o);case"html":{const r=String(n.formatter??""),s=r?Jr.sanitize(p.evaluateTemplate(r,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return a("div",{class:"print-html",html:s})}case"pageNumber":return a("div",{class:"page-number-element",style:{fontSize:`${n.fontSize||12}pt`,fontWeight:n.fontWeight||"normal",fontFamily:A.resolveCanvasFontFamily(n.fontFamily),color:n.color||"#333",textAlign:n.textAlign||"left",...n.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:n.title||"{pageIndex}/{totalPages}"});case"table":return t?Ua(o,t.store,t.fire):a("div",{class:"print-table"});case"flowList":return ja(o);default:return a("div",{text:i})}}function Nn(o){return`x:${Math.round(o.left)} y:${Math.round(o.top)} ${Math.round(o.width)}×${Math.round(o.height)}mm`}function ts(o,e,t){const i=o.store,n=i.selectedIds.has(e.id),r=i.previewIds.has(e.id),s=e.options,l=e.zone||"content",c=[es(e,!0,{store:i,fire:o.fire})];return i.draggingIds.has(e.id)&&c.push(a("div",{class:"drag-preview"})),n&&(c.push(a("div",{class:"resize-handles"},p.RESIZE_POINTS.map(u=>a("div",{class:`resize-handle handle-${u}`,dataset:{point:u,elId:e.id},onMousedown:h=>o.fire("resize-start",{event:h,id:e.id,point:u})})))),c.push(a("div",{class:"selected-indicator"},[a("div",{class:"position-label",text:Nn(s)})]))),a("div",{class:["print-element",`type-${e.printElementType.type}`,`zone-${l}`,n?"selected":"",r?"previewed":"",i.draggingIds.has(e.id)?"drag-ghost":"","design-mode",s.locked?"locked":"",s.visible===!1?"hidden":""].filter(Boolean).join(" "),style:Va(e,t),dataset:{elId:e.id},onMousedown:u=>o.fire("element-mousedown",{event:u,id:e.id}),onContextmenu:u=>{u.preventDefault(),u.stopPropagation(),o.fire("contextmenu",{event:u,id:e.id})}},c)}function Uo(o,e){const t=o.margins,i=o.header?.height??10,n=o.footer?.height??10,r=e.width-t.left-t.right;return{header:{left:t.left,top:t.top,width:r,height:i},content:{left:t.left,top:t.top+i,width:r,height:e.height-t.top-t.bottom-i-n},footer:{left:t.left,top:e.height-t.bottom-n,width:r,height:n}}}const os='<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 tn(o,e){return o.type==="vertical"?{left:`${o.position}mm`,top:"0",height:`${e.height}mm`,borderLeftColor:o.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${o.position}mm`,left:"0",width:`${e.width}mm`,borderTopColor:o.color||"var(--pd-accent-secondary, #f56c6c)"}}function is(o,e){const t=A.resolveWatermarkLayout(o.watermark,[],e);return t?a("div",{class:"watermark-layer",style:{opacity:String(t.opacity)}},t.tiles.map(i=>a("svg",{class:"watermark-tile",width:`${i.widthMm}mm`,height:`${i.heightMm}mm`,viewBox:`0 0 ${t.tileWidthPx} ${t.tileHeightPx}`,style:{left:`${i.leftMm}mm`,top:`${i.topMm}mm`}},[a("text",{x:String(t.tileWidthPx/2),y:String(t.tileHeightPx/2),"font-size":String(t.fontSizePx),fill:t.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${t.rotate},${t.tileWidthPx/2},${t.tileHeightPx/2})`,text:t.text})]))):""}function zo(o,e,t,i,n,r){const s=o.store,l=[];t!=="content"&&l.push(a("span",{class:"zone-label",text:t==="header"?"页眉":"页脚"}));const c=t==="content"?A.collectFollowMemberIds(n):void 0;if(l.push(...n.map(u=>ts(o,u,c))),t!=="content"){const u=t==="header"?"bottom":"top";l.push(a("div",{class:`zone-resize-handle handle-${u}`,dataset:{zone:t},onMousedown:h=>o.fire("zone-resize",{event:h,zone:t})},[e.zoneResizing===t?a("div",{class:"zone-height-tip",text:`${(t==="header"?s.templateData.header.height:s.templateData.footer.height).toFixed(1)}mm`}):""]))}return a("div",{class:`zone-layer zone-${t} design-mode`,style:{position:"absolute",left:`${i.left}mm`,top:`${i.top}mm`,width:`${i.width}mm`,height:`${i.height}mm`},dataset:{zone:t,paperWidth:String(r.width),paperHeight:String(r.height)}},l.filter(Boolean))}function ns(o,e){const t=o.store,i=t.templateData,n=A.getPaperDimensions(i),r=(t.scale||100)/100,s=Uo(i,n),l=m=>t.elements.filter(g=>(g.zone||"content")===m),c=a("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${i.margins.top}mm ${i.margins.right}mm ${i.margins.bottom}mm ${i.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${n.height}mm`}},[t.showGrid?a("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(os)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...i.watermark&&Object.keys(i.watermark).length?[is(i,n)]:[],zo(o,e,"header",s.header,l("header"),n),zo(o,e,"content",s.content,l("content"),n),zo(o,e,"footer",s.footer,l("footer"),n),...t.adsorbGuides.map(m=>a("div",{class:`adsorb-guide guide-${m.type}`,style:tn(m,n)})),...(i.guides??[]).map(m=>a("div",{class:`manual-guide guide-${m.type}`,style:{...tn(m,n),"--guide-hit":`${8/r}px`},dataset:{guideId:String(m.id??"")},onMousedown:g=>o.fire("guide-mousedown",{event:g,id:m.id}),onDblclick:g=>{g.preventDefault(),o.fire("guide-remove",m.id)}}))].filter(Boolean)),u=a("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${n.width}mm`,minHeight:`${n.height}mm`,background:i.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(${r})`,transformOrigin:"0 0"}},[...i.designBackground?.src?[a("div",{class:"design-background",style:{width:`${n.width}mm`,height:`${n.height}mm`,left:"0",top:"0",transform:i.designBackground.rotation?`rotate(${i.designBackground.rotation}deg)`:""}},[a("img",{src:i.designBackground.src,draggable:!1,alt:""})])]:[],c]),h=[a("div",{class:"canvas-scroll"},[a("div",{class:"paper-wrapper",style:{width:`${A.mmToPx(n.width)*r}px`,height:`${A.mmToPx(n.height)*r}px`,position:"relative"}},[u])])];if(t.showRuler&&h.push(a("div",{class:"ruler-overlay",style:{transform:`translate(${e.scrollX}px, ${e.scrollY}px)`}},[a("div",{class:"ruler-corner"}),a("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${e.geom.viewW}px`,height:"20px"},onMousedown:m=>o.fire("ruler-mousedown",{event:m,orientation:"horizontal"})}),a("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${e.geom.viewH}px`},onMousedown:m=>o.fire("ruler-mousedown",{event:m,orientation:"vertical"})})])),e.guidePreview&&h.push(a("div",{class:`ruler-guide-preview guide-${e.guidePreview.type}`,style:e.guidePreview.type==="vertical"?{left:`${e.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${e.guidePreview.position}px`,left:"0",width:"100%"}})),e.marquee.visible&&h.push(a("div",{class:"marquee-selection",style:{left:`${e.marquee.x}px`,top:`${e.marquee.y}px`,width:`${e.marquee.w}px`,height:`${e.marquee.h}px`}})),e.contextMenu.visible){const m=e.contextMenu;h.push(a("div",{class:"context-menu",style:{left:`${e.contextMenu.x+e.contextMenu.flipX}px`,top:`${e.contextMenu.y+e.contextMenu.flipY}px`}},e.contextMenu.targetId?[Me(o,m,"复制","copy"),Me(o,m,"剪切","cut"),Me(o,m,"粘贴","paste",!t.hasClipboard),Me(o,m,"删除","delete"),a("div",{class:"context-menu-sep"}),Me(o,m,"置顶","move-layer",!1,"top"),Me(o,m,"上移","move-layer",!1,"up"),Me(o,m,"下移","move-layer",!1,"down"),Me(o,m,"置底","move-layer",!1,"bottom")]:[Me(o,m,"粘贴","paste-at",!t.hasClipboard),Me(o,m,"全选","select-all"),Me(o,m,"取消选择","clear-selection")]))}return a("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:m=>m.preventDefault(),onDrop:m=>o.fire("drop",m),onMousedown:m=>o.fire("canvas-mousedown",m),onMousemove:m=>o.fire("canvas-mousemove",m),onMouseleave:()=>o.fire("canvas-mouseleave"),onWheel:m=>o.fire("wheel",m),onScroll:m=>o.fire("scroll",m),onContextmenu:m=>{m.preventDefault(),o.fire("canvas-contextmenu",m)}},h.filter(Boolean))}function Me(o,e,t,i,n=!1,r){return a("div",{class:`context-menu-item${n?" disabled":""}`,text:t,onClick:()=>{e.visible=!1,n||o.fire(i,r),o.repaint()}})}const rs={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" />',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 ve(o,e=15,t){const i=rs[o];return i?`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}"${t?` class="${t}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i}</svg>`:""}let Je=null;function ei(o){const e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(o.trim());if(!e)return null;const t=e[1],i=t.length===3?t.split("").map(n=>n+n).join(""):t;return{r:Number.parseInt(i.slice(0,2),16),g:Number.parseInt(i.slice(2,4),16),b:Number.parseInt(i.slice(4,6),16)}}function ti(o){const e=ei(o);return e?$n(e):"#000000"}function $n({r:o,g:e,b:t}){return`#${[o,e,t].map(i=>Math.round(zt(i/255)*255).toString(16).padStart(2,"0")).join("")}`}function as(o,e,t){const i=o/255,n=e/255,r=t/255,s=Math.max(i,n,r),l=Math.min(i,n,r),c=s-l;let u=0;return c!==0&&(s===i?u=(n-r)/c%6:s===n?u=(r-i)/c+2:u=(i-n)/c+4,u*=60,u<0&&(u+=360)),{h:u,s:s===0?0:c/s,v:s}}function ss(o,e,t){const i=t*e,n=(o%360+360)%360/60,r=i*(1-Math.abs(n%2-1)),[s,l,c]=n<1?[i,r,0]:n<2?[r,i,0]:n<3?[0,i,r]:n<4?[0,r,i]:n<5?[r,0,i]:[i,0,r],u=t-i;return{r:(s+u)*255,g:(l+u)*255,b:(c+u)*255}}function ls(o){return((Number.isFinite(o)?o:0)%360+360)%360}function zt(o){return Math.min(1,Math.max(0,Number.isFinite(o)?o:0))}function ds(o){const e=o.title??"颜色选择";return a("button",{type:"button",class:`preset-color-trigger${o.triggerClass?` ${o.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:e,onClick:t=>{const i=t.currentTarget??t.target,n=i.getRootNode();if(!!Je&&Je.root===n&&Je.title===e&&Je.trigger===i){_t();return}_t(),cs(i,o)}},[a("span",{class:"preset-color-swatch",style:o.value?{background:o.value}:{background:"transparent"}})])}function _t(){const o=Je;o&&(Je=null,o.teardowns.forEach(e=>e()),o.trigger.setAttribute("aria-expanded","false"),o.panel.remove())}function cs(o,e){const t=o.getRootNode(),i=t instanceof ShadowRoot?t:document.body,n={root:t,title:e.title??"颜色选择",trigger:o,panel:null,clearable:e.clearable!==!1,onChange:e.onChange,model:e.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:[]};e.value&&ii(n,e.value)?n.hexText=ti(e.value).toUpperCase():n.hexText=e.value?String(e.value):"",n.panel=fe(fs(n),i),n.current=n.panel.querySelector(".picker-current"),n.hex=n.panel.querySelector(".picker-hex"),n.area=n.panel.querySelector(".picker-area"),n.handle=n.panel.querySelector(".picker-handle"),n.hueRange=n.panel.querySelector(".picker-hue"),n.clearBtn=n.panel.querySelector(".picker-clear"),n.items=Array.from(n.panel.querySelectorAll(".preset-color-item")).map((r,s)=>({el:r,color:p.PRESET_COLORS[s]})),ao(n),ps(n),us(n),Je=n,o.setAttribute("aria-expanded","true")}function ps(o){const e=o.trigger.getBoundingClientRect(),t=190,i=o.panel.offsetHeight||216,n=8,r=Math.max(n,Math.min(e.left,window.innerWidth-t-n)),s=e.bottom+6,l=s+i>window.innerHeight-n?Math.max(n,e.top-i-6):s;o.panel.style.left=`${r}px`,o.panel.style.top=`${l}px`}function us(o){const e=n=>{const r=hs(n);r.includes(o.trigger)||r.includes(o.panel)||_t()},t=n=>{n.key==="Escape"&&_t()},i=()=>_t();document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",t),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),o.root.addEventListener("scroll",i,!0),o.teardowns.push(()=>document.removeEventListener("pointerdown",e,!0),()=>document.removeEventListener("keydown",t),()=>window.removeEventListener("scroll",i,!0),()=>window.removeEventListener("resize",i),()=>o.root.removeEventListener("scroll",i,!0))}function hs(o){const e=typeof o.composedPath=="function"?o.composedPath():[];return e.length?e:[o.target]}function fs(o){return a("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:e=>e.stopPropagation()},[a("div",{class:"picker-preview"},[a("span",{class:"picker-current"}),a("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:e=>gs(o,e.target.value)})]),a("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>bs(o,e),onKeydown:e=>xs(o,e)},[a("span",{class:"picker-handle"})]),a("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>vs(o,Number(e.target.value)),onChange:()=>ni(o)}),a("div",{class:"picker-heading"},[a("span",{text:"常用颜色"}),o.clearable?a("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>io(o,void 0)},[a("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[a("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),a("div",{class:"preset-color-grid"},p.PRESET_COLORS.map(e=>a("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>ms(o,e)})))])}function oi(o){return $n(ss(o.hue,o.saturation,o.value_))}function ao(o){const e=oi(o);o.hex.value!==o.hexText&&(o.hex.value=o.hexText),o.current.className=o.model?"picker-current":"picker-current is-empty",o.model?o.current.style.background=e:o.current.style.removeProperty("background"),o.area.style.setProperty("--picker-hue",`${Math.round(o.hue)}deg`),o.handle.style.left=`${o.saturation*100}%`,o.handle.style.top=`${(1-o.value_)*100}%`,o.handle.style.background=e;const t=String(Math.round(o.hue));o.hueRange.value!==t&&(o.hueRange.value=t),o.clearBtn&&(o.clearBtn.disabled=!o.model);for(const i of o.items)i.el.className=o.model&&i.color.toLowerCase()===o.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function ii(o,e){const t=ei(e);if(!t)return!1;const i=as(t.r,t.g,t.b);return o.hue=i.h,o.saturation=i.s,o.value_=i.v,o.hexText=ti(e).toUpperCase(),!0}function mt(o,e,t,i){o.hue=ls(e),o.saturation=zt(t),o.value_=zt(i),o.hexText=oi(o).toUpperCase(),ao(o)}function ni(o){const e=oi(o);o.model=e,ao(o),o.onChange(e)}function io(o,e){o.model=e,e||(o.hexText=""),ao(o),o.onChange(e)}function ms(o,e){ii(o,e),io(o,e)}function gs(o,e){const t=e.trim();if(!t){o.clearable&&io(o,void 0);return}ei(t)&&(ii(o,t),io(o,ti(t)))}function bs(o,e){o.dragging=!0,on(o,e);const t=n=>{o.dragging&&on(o,n)},i=()=>{o.dragging&&(o.dragging=!1,document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i),ni(o))};document.addEventListener("pointermove",t),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)}function on(o,e){const t=o.area.getBoundingClientRect();if(!t.width||!t.height)return;const i=zt((e.clientX-t.left)/t.width),n=zt(1-(e.clientY-t.top)/t.height);mt(o,o.hue,i,n)}function xs(o,e){const t=e.shiftKey?.1:.02;let i=!0;e.key==="ArrowLeft"?mt(o,o.hue,o.saturation-t,o.value_):e.key==="ArrowRight"?mt(o,o.hue,o.saturation+t,o.value_):e.key==="ArrowUp"?mt(o,o.hue,o.saturation,o.value_+t):e.key==="ArrowDown"?mt(o,o.hue,o.saturation,o.value_-t):i=!1,i&&(e.preventDefault(),ni(o))}function vs(o,e){mt(o,e,o.saturation,o.value_)}function J(o,e,t,i){return a("button",{class:`tb-btn tb-icon${i.on?" on":""}${i.danger?" danger":""}`,type:"button",disabled:!!i.disabled,dataset:{tip:i.tip,...i.test?{test:i.test}:{}},onClick:()=>o.fire(t,i.arg),html:ve(e)})}function no(o,e,t,i){const n=o.state.openDd===e,r=()=>{o.state.openDd=n?null:e,o.repaint()};return a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${n?" on":""}`,disabled:!!t.disabled,dataset:{test:t.testId??e,tip:t.tip},onClick:r,html:`${t.icon?ve(t.icon):""}${t.text?`<span class="${t.textClass??"tb-btn-text"}">${t.text}</span>`:""}${ve("ChevronDown",12,`tb-dd-arrow${n?" up":""}`)}`}),n?a("div",{class:`tb-dd-panel${t.panelClass?` ${t.panelClass}`:""}`},i):""].filter(Boolean))}function I(o){const e=o.step??1,t=String(e),i=t.indexOf("."),n=i===-1?0:t.length-i-1,r=m=>Number.isFinite(m)?Number(m.toFixed(n)):0,s=m=>{let g=r(m);return o.min!==void 0&&g<o.min&&(g=o.min),o.max!==void 0&&g>o.max&&(g=o.max),g},l=o.value===void 0||o.value===null||!Number.isFinite(o.value)?void 0:r(o.value),c=l??o.min??0,u=m=>{m!==l&&o.onCommit(m)},h=a("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:o.min,max:o.max,step:e,placeholder:o.placeholder,disabled:!!o.disabled,onChange:m=>{const g=m.target,v=(g.value??"").trim();if(v===""){l!==void 0&&(g.value=String(l));return}const b=Number(v);if(!Number.isFinite(b)){g.value=l===void 0?"":String(l);return}const w=s(b);g.value=String(w),u(w)}});return a("div",{class:"pd-stepper"},[a("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!o.disabled||c<=(o.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>u(s(c-e))}),h,a("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!o.disabled||c>=(o.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>u(s(c+e))})])}function B(o,e,t,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),i??""]),e,t?a("p",{class:"pd-hint",text:t}):""].filter(Boolean))}const Go=o=>a("button",{class:"pd-help",type:"button","data-tip":o,"aria-label":"字段说明"});function Ce(o,e,t,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[o,Go(t)]),i??""]),e])}function tt(o){const e=o.base?.[o.propKey],t=o.target?.[o.propKey]!==e,i=o.force===!0||t,n=o.tipOverride??(o.tipValue===void 0?"恢复默认值":`恢复默认值(${o.tipValue}${o.tipUnit?" "+o.tipUnit:""})`),r=o.force?`${n}(应用到全部选中格)`:n;return a("button",{type:"button",class:`pd-reset-btn${t&&!o.force?" is-dirty":""}`,"data-tip":r,"aria-label":r,html:ve("RotateCcw",13),onClick:()=>{i&&(o.write?o.write(e):o.target[o.propKey]=e,o.onReset?.())}})}const Pe=o=>a("h3",{class:"pd-divider",text:o});function Ae(o,e,t="颜色选择",i){return ds({value:o,title:t,triggerClass:i,onChange:n=>e(n)})}function Ue(o,e,t,i,n=!1){return a("div",{class:`pd-radio-group${n?" pd-radio-group--2col":""}`,role:"radiogroup"},e.map(r=>a("label",{class:"pd-radio"},[a("input",{type:"radio",name:o,value:r.value,checked:t===r.value,onChange:()=>i(r.value)}),a("span",{text:r.label})])))}function Bn(o,e,t,i={}){const n=document.createElement("select");n.className=i.className??"pd-select",i.width&&(n.style.width=i.width);for(const r of e){const s=document.createElement("option");s.value=r.value,s.textContent=r.label,r.disabled&&(s.disabled=!0),n.appendChild(s)}return n.value=o,e.some(r=>r.value===o)||(n.selectedIndex=-1),n.addEventListener("change",()=>t(n.value)),n}function ys(o){const e=window.innerHeight;for(let t=o.parentElement;t&&t!==document.body;t=t.parentElement){const i=getComputedStyle(t).overflowY;if(i==="auto"||i==="scroll"||i==="hidden"||i==="clip"){const n=t.getBoundingClientRect();return{top:Math.max(0,n.top),bottom:Math.min(e,n.bottom)}}}return{top:0,bottom:e}}function so(o){const e=A.normalizeFontCatalog(o.fonts),t=o.placeholder??"默认",i=`font-select-list-${o.id}`,n=F=>{const M=F?.trim();return M?A.findFontOption(e,M)?.label??M:""},r=F=>{const M=A.normalizeFontQuery(F);return e.find(V=>V.label&&A.normalizeFontQuery(V.label)===M)?.family??F},s=()=>{const F=o.value?.trim();return F?A.findFontOption(e,F)?"":F:""},l=F=>{const M=(o.value??"").trim(),G=(Z,y,H,ae)=>({kind:Z,key:y,label:H,value:ae,selected:(ae??"")===M}),V=F.trim();if(!V){const Z=[G("clear","__clear__",t)],y=s();y&&Z.push(G("unknown","__unknown__",`${y}(未知)`,y));for(const H of e)Z.push(G("font",H.family,A.fontOptionLabel(H),H.family));return Z}const ce=A.filterFontOptions(e,V).map(Z=>G("font",Z.family,A.fontOptionLabel(Z),Z.family));if(!ce.length){const Z=r(V);ce.push(G("free","__free__",`使用「${Z}」`,Z))}return ce},c=document.createElement("div");c.className="font-select";const u=document.createElement("input");u.className="pd-input font-select-input",u.type="text",u.setAttribute("role","combobox"),u.setAttribute("aria-autocomplete","list"),u.setAttribute("aria-controls",i),u.autocomplete="off",u.placeholder=t,u.disabled=!!o.disabled,u.value=n(o.value);const h=document.createElement("ul");h.id=i,h.className="font-select-list",h.setAttribute("role","listbox");const m=o.state.fontOpen?.id===o.id?o.state.fontOpen:null,g={open:!!m&&!o.disabled,query:m?.query??"",highlighted:m?.highlighted??-1};g.open&&(u.value=g.query);const v=()=>{o.state.fontOpen=g.open?{id:o.id,query:g.query,highlighted:g.highlighted}:null};v();const b=()=>{const F=(o.value??"").trim();return l(g.query).findIndex(M=>(M.value??"")===F)},w=()=>{const F=u.getBoundingClientRect(),M=ys(u);h.classList.toggle("is-up",p.resolveOverlayPlacement({triggerTop:F.top,triggerBottom:F.bottom,overlayHeight:h.getBoundingClientRect().height,boundaryTop:M.top,boundaryBottom:M.bottom})==="up")},T=()=>{if(!g.open){h.isConnected&&h.remove(),u.setAttribute("aria-expanded","false"),u.setAttribute("aria-activedescendant","");return}h.isConnected||c.appendChild(h);const F=l(g.query);h.replaceChildren(...F.map((M,G)=>{const V=document.createElement("li");return V.id=`${i}-${G}`,V.className="font-select-option"+(G===g.highlighted?" is-active":"")+(M.kind==="unknown"||M.kind==="free"?" is-muted":""),V.setAttribute("role","option"),V.setAttribute("aria-selected",String(M.selected)),V.textContent=M.label,V.addEventListener("mousedown",ce=>{ce.preventDefault(),ye(M)}),V})),u.setAttribute("aria-expanded","true"),u.setAttribute("aria-activedescendant",g.highlighted>=0?`${i}-${g.highlighted}`:""),w()},k=()=>{g.open||o.disabled||(g.open=!0,g.query="",g.highlighted=b(),v(),T())},z=()=>{g.open||k()},W=()=>{g.open=!0,g.query=u.value,g.highlighted=l(g.query).length?0:-1,v(),T()},P=F=>{if(!g.open){k();return}const M=l(g.query).length-1;if(M<0)return;g.highlighted=Math.min(Math.max(g.highlighted+F,0),M),v(),T(),h.children[g.highlighted]?.scrollIntoView?.({block:"nearest"})},ne=()=>{if(!g.open)return;const F=l(g.query)[g.highlighted];if(F){ye(F);return}const M=g.query.trim();if(M){const G=r(M);ye({value:G})}},ye=F=>{g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(F.value),T(),o.onChange(F.value)},Y=()=>{g.open&&(g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(o.value),T())};return u.addEventListener("focus",k),u.addEventListener("click",z),u.addEventListener("input",W),u.addEventListener("blur",Y),u.addEventListener("keydown",F=>{const M=F;M.key==="ArrowDown"?(M.preventDefault(),P(1)):M.key==="ArrowUp"?(M.preventDefault(),P(-1)):M.key==="Enter"?(M.preventDefault(),ne()):M.key==="Escape"&&(M.preventDefault(),Y())}),c.append(u),T(),g.open&&(u.focus(),u.setSelectionRange(g.query.length,g.query.length)),c}const ws=[{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"}],Ss={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function He(o,e,t,i,n={}){return a("button",{type:"button",class:`ft-cell-btn${n.on?" on":""}`,dataset:{test:o,tip:e},disabled:!!n.disabled,onClick:i,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${t}</svg>`})}const ut='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',nn='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function Ts(o){const e=o.format;e.syncBorderDraft();const t=e.values,i=!e.fontEditable,n=i||e.context==="cells",r=e.context==="none",s=e.context==="cells",l=!e.painterActive&&(e.context==="none"||e.context==="cells"||!e.painterCapturable),c=e.painterActive?"退出格式刷(Esc)":e.context==="cells"?"格式刷(表格单元格暂不支持)":e.context==="none"?"格式刷(需选中元素)":e.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",u=g=>i?`${g}(需选中文本元素)`:g,h=[a("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[a("div",{class:"ft-border-grid"},[He("preset-none","无边框",`${ut}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),He("preset-all","所有边框",`${nn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("all")),He("preset-outer","外侧边框",nn,()=>e.applyBorderPreset("outer")),He("preset-inner",s?"内部边框":"内部边框(仅表格单元格可用)",`${ut}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("inner"),{disabled:!s}),He("edge-top","上边框",`${ut}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),He("edge-bottom","下边框",`${ut}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),He("edge-left","左边框",`${ut}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),He("edge-right","右边框",`${ut}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>e.applyEdge("right"),{on:e.edgeOn("right")})]),a("div",{class:"ft-style-row"},ws.map(g=>a("button",{type:"button",class:`ft-style-btn${e.borderStyle===g.key?" on":""}`,dataset:{test:`style-${g.key}`,tip:e.borderStyle===g.key?`${g.label}(再点一次取消,线型=无)`:g.label},onClick:()=>{e.toggleBorderStyle(g.key),o.repaint()}},[a("span",{class:"ft-style-line",style:{borderTop:g.preview}})]))),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"粗细"}),a("div",{class:"ft-line-width"},[I({value:e.borderWidth,min:.25,max:5,step:.25,placeholder:e.borderMixed.width?"混合":void 0,onCommit:g=>{e.setBorderWidth(g),o.repaint()}})])]),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"颜色"}),Ae(e.borderColor,g=>{e.setBorderColor(g),o.repaint()},"边框颜色")]),e.borderMixedAny?a("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],m=[a("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[a("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([g,v,b])=>a("button",{type:"button",class:`ft-cell-btn${t.textAlign===g?" on":""}`,dataset:{test:`align-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({textAlign:g}),html:ve(b)}))),a("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([g,v,b])=>a("button",{type:"button",class:`ft-cell-btn${t.verticalAlign===g?" on":""}`,dataset:{test:`valign-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({verticalAlign:g}),html:ve(b)})))])];return a("div",{class:"format-toolbar"},[a("div",{class:"tb-ou ft-group",dataset:{unit:"painter"}},[a("button",{type:"button",class:`ft-btn${e.painterActive?" on":""}`,dataset:{test:"format-painter",tip:c},disabled:l,onClick:()=>{e.painterActive?e.cancelPainter():e.pickPainterSource(!1),o.repaint()},onDblclick:()=>{e.pickPainterSource(!0),o.repaint()},html:ve("Paintbrush")})]),a("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[a("div",{class:"ft-font"},[so({id:"ft-font",state:o.state,fonts:o.host.fonts,value:typeof t.fontFamily=="string"?t.fontFamily:void 0,placeholder:t.fontFamily===Qe?"混合":"默认",disabled:i,onChange:g=>e.applyStyle({fontFamily:g})})]),a("div",{class:"ft-size",dataset:{test:"font-size"}},[I({value:typeof t.fontSize=="number"?t.fontSize:void 0,min:5,max:72,disabled:i,placeholder:t.fontSize===Qe?"混合":"默认",onCommit:g=>e.applyStyle({fontSize:g})})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>e.toggleBold()],["underline","Underline","下划线",()=>e.toggleUnderline()],["strike","Strikethrough","删除线",()=>e.toggleStrike()]].map(([g,v,b,w])=>a("button",{type:"button",class:`ft-btn${t[g]===!0?" on":""}`,dataset:{test:g,tip:u(b)},disabled:g==="bold"?i:n,onClick:w,html:ve(v)}))]),a("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[a("span",{class:`ft-color-btn${i?" dim":""}`,title:`字体颜色${i?"(需选中或混选文本元素)":""}`},[Ae(typeof t.color=="string"?t.color:void 0,g=>e.applyStyle({color:g})),a("span",{class:"ft-glyph",text:"A"})]),a("span",{class:`ft-color-btn${r?" dim":""}`,title:"背景色"},[Ae(typeof t.backgroundColor=="string"?t.backgroundColor:void 0,g=>e.applyStyle({backgroundColor:g})),a("span",{class:"ft-glyph",html:ve("PaintBucket",14)})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[no(o,"align",{icon:Ss[String(t.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:i?"对齐(需选中文本元素或单元格)":"对齐",disabled:i,testId:"align-dd"},m)]),a("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[no(o,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:r?"边框(需选中元素)":"边框",disabled:r,testId:"border"},h)])])}const Es=[{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:"<>"}],ks={text:"T",longText:"¶",table:"⊞",flowList:"⊟",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function Cs(o){const e=o.state;if(e.leftCollapsed)return a("div",{class:"left-panel collapsed"},[a("div",{class:"left-collapsed"},[rn("»","展开素材台",()=>{e.leftCollapsed=!1,o.repaint()}),...[["elements","元素","▦"],["fields","字段","⊛"],["layers","图层","≡"]].map(([i,n,r])=>a("button",{type:"button",class:`lc-btn${e.leftTab===i?" on":""}`,title:n,text:r,onClick:()=>{e.leftTab=i,e.leftCollapsed=!1,o.repaint()}}))])]);const t=(i,n)=>a("div",{class:"pd-tab-pane",role:"tabpanel",style:e.leftTab===i?"":{display:"none"}},n);return a("div",{class:"left-panel"},[a("div",{class:"left-head"},[a("span",{class:"left-title",text:"素材台"}),rn("«","收起素材台",()=>{e.leftCollapsed=!0,o.repaint()})]),a("div",{class:"pd-tabs left-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([i,n])=>a("button",{type:"button",class:`pd-tab${e.leftTab===i?" active":""}`,text:n,onClick:()=>{e.leftTab=i,o.repaint()}}))]),t("elements",As()),t("fields",[Ds(o)]),t("layers",[Ms(o)])])])}function rn(o,e,t){return a("button",{type:"button",class:"collapse-btn",title:e,text:o,onClick:t})}function As(){return[a("div",{class:"panel-title",text:"拖拽元素到画布"}),...Es.map(o=>a("div",{class:"material-card",draggable:!0,dataset:{test:`material-${o.type}`},onDragstart:e=>e.dataTransfer?.setData("elementType",o.type)},[a("span",{class:"material-icon",text:o.icon}),a("span",{class:"material-label",text:o.label})]))]}function Ds(o){const e=o.state,t=p.groupFields(o.store.fields),i=(e.fieldSearch??"").trim().toLowerCase(),n=i?t.map(r=>({...r,fields:r.fields.filter(s=>`${s.fieldLabel}${s.fieldKey}`.toLowerCase().includes(i))})).filter(r=>r.fields.length):t;return a("div",{class:"field-tree-panel"},[a("div",{class:"panel-title",text:"业务字段"}),a("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:e.fieldSearch??"",onInput:r=>{e.fieldSearch=r.target.value},onChange:()=>o.repaint()}),a("div",{class:"tree-container"},n.flatMap(r=>{const s=e.collapsedGroups.has(r.key)&&!i,l=r.key?a("div",{class:`field-group-header${r.isList?" is-list":""}`,onClick:()=>{s?e.collapsedGroups.delete(r.key):e.collapsedGroups.add(r.key),o.repaint()}},[a("span",{class:"expand-icon",text:s?"▶":"▼"}),a("span",{class:"node-icon",text:r.isList?"📋":"📁"}),a("span",{class:"group-label",text:r.label,"data-tip":r.label})]):"",c=s?[]:r.fields.map(u=>a("div",{class:"field-row",draggable:!0,"data-tip":`${u.fieldLabel} (${u.fieldKey})`,style:{paddingLeft:`${r.key?22:8}px`},onDragstart:h=>{h.dataTransfer?.setData("fieldKey",u.fieldKey)}},[a("span",{class:"node-icon",text:"📄"}),a("span",{class:"node-meta"},[a("span",{class:"node-label",text:u.fieldLabel}),a("span",{class:"node-key",text:`(${u.fieldKey})`})])]));return[l,a("div",{},c.filter(Boolean))].filter(Boolean)})),n.length===0?a("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function Ms(o){const e=o.store,t=[...e.elements].sort((l,c)=>(c.options.zIndex??0)-(l.options.zIndex??0)),i=e.elements.filter(l=>e.selectedIds.has(l.id)),n=i.length>=2,r=i.some(l=>!!l.options.groupId),s=l=>l.zone==="header"?"页眉":l.zone==="footer"?"页脚":"";return a("div",{class:"layer-panel"},[a("div",{class:"panel-title",text:"图层"}),...t.map(l=>a("div",{class:`layer-item${e.selectedIds.has(l.id)?" active":""}`,onClick:c=>e.selectElement(l.id,c.ctrlKey||c.metaKey)},[a("span",{class:"layer-icon",text:ks[l.printElementType.type]||"?"}),a("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),s(l)?a("span",{class:"layer-zone",text:s(l)}):"",a("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))),t.length?a("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,c,u])=>a("button",{type:"button",class:"pd-button small",title:c,html:ve(u,14),onClick:()=>o.fire("move-layer",l)}))]):"",n||r?a("div",{class:"layer-actions"},[n?a("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:ve("Group",14),onClick:()=>o.fire("group")}):"",r?a("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:ve("Ungroup",14),onClick:()=>o.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function _s(o){const e=o.store,t=o.state,i=e.pages.length>1,n=e.pages[e.activePageIndex]?.name||`页面 ${e.activePageIndex+1}`,r=e.tilingEnabled;return a("div",{class:"page-tabs"},[a("div",{class:"page-tabs-list"},e.pages.map((l,c)=>t.renamingPage===c?a("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:t.renameText??"",onInput:u=>{t.renameText=u.target.value},onBlur:()=>s(),onKeydown:u=>{const h=u;if(h.key==="Enter"){s();return}h.key==="Escape"&&(t.renamingPage=null,o.repaint())}}):a("button",{type:"button",class:`page-tab${c===e.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${c+1}`,onClick:()=>e.switchPage(c),onDblclick:()=>{t.renamingPage=c,t.renameText=l.name??"",o.repaint()}}))),a("div",{class:"page-tabs-actions"},[a("button",{type:"button",dataset:{test:"add-page",tip:r?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:r,text:"+",onClick:()=>o.fire("add-page")}),a("button",{type:"button",dataset:{test:"duplicate-page",tip:r?"拼版模板仅允许一个设计页面":`复制当前页「${n}」`},disabled:r,text:"⧉",onClick:()=>o.fire("duplicate-page")}),a("button",{type:"button",dataset:{test:"delete-page",tip:i?`删除当前页「${n}」`:"仅多页面模板可删除页面"},disabled:!i,text:"✕",onClick:()=>o.fire("delete-page")}),a("button",{type:"button",dataset:{test:"move-left",tip:`前移「${n}」`},disabled:e.activePageIndex<=0,text:"←",onClick:()=>o.fire("move-page",-1)}),a("button",{type:"button",dataset:{test:"move-right",tip:`后移「${n}」`},disabled:e.activePageIndex>=e.pages.length-1,text:"→",onClick:()=>o.fire("move-page",1)})])]);function s(){const l=(t.renameText??"").trim();t.renamingPage!==null&&l&&e.renamePage(t.renamingPage,l),t.renamingPage=null,o.repaint()}}function Rs(o){const e=o.store,t=e.templateData,i=p.getPaperDimensions(t),n=t.orientation==="landscape"?"横向":"纵向",r=p.PAPER_PRESETS[t.paperSize]?.label??t.paperSize,s=t.outputRotation,l=`${r} ${n} ${Math.round(i.width)}×${Math.round(i.height)}mm${s?`(旋转${s}°)`:""}`;return a("div",{class:"status-bar"},[a("span",{class:"status-item coord",dataset:{coord:""},style:{display:"none"}}),a("span",{class:"status-item",text:`缩放 ${e.scale}%`}),a("span",{class:"status-item",text:`元素 ${e.elements.length}${e.selectedIds.size?` (选中 ${e.selectedIds.size})`:""}`}),a("span",{class:`status-dirty${e.dirty?" on":""}`},[a("span",{class:"dirty-dot"}),e.dirty?"未保存":"已保存"]),a("span",{class:"status-item status-paper",text:l})])}const zs=Object.keys(p.PAPER_PRESETS).filter(o=>o!=="CUSTOM"&&!p.PAPER_PRESETS[o]?.continuous);function Ps(o){const e=document.createElement("label");e.className="pd-button small upload-label";const t=document.createTextNode("上传背景图"),i=document.createElement("input");i.className="visually-hidden",i.type="file",i.accept="image/*",e.append(t,i);const n=r=>{e.className=`pd-button small upload-label${r?" disabled":""}`,i.disabled=r};return i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;if(!r.type.startsWith("image/")){alert("仅支持上传图片文件"),i.value="";return}const s=o.host.uploadDesignBackground;if(!s){alert("设计背景上传能力未配置"),i.value="";return}n(!0),t.textContent="上传中...";try{const l=await s(r);l?o.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{t.textContent="上传背景图",n(!o.host.uploadDesignBackground),i.value=""}}),o.host.uploadDesignBackground||n(!0),e}function Fs(o){const t=o.store.templateData.designBackground,i=t?.rotation??0;return a("div",{class:"design-background-config"},[Pe("设计背景"),a("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),t?.src?[a("div",{class:"design-background-path",title:t.src,text:t.src}),a("div",{class:"design-background-actions"},[a("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(i+90)%360}°)`,onClick:()=>o.store.updateTemplateData({designBackground:{...t,rotation:(i+90)%360}})}),a("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>o.store.updateTemplateData({designBackground:void 0})})])]:Ps(o)].flat())}function Ls(o){const e=o.store,t=e.templateData,i=t.tiling,n={...A.TILE_DEFAULTS,...i??{},enabled:i?.enabled??!1,sheetMargin:{...A.TILE_DEFAULTS.sheetMargin,...i?.sheetMargin??{}}},r=p.isContinuousPaperSize(t.paperSize),s=b=>e.updateTemplateData({tiling:{...n,...b}}),l=b=>tt({target:n,base:A.TILE_DEFAULTS,propKey:b,write:()=>s({[b]:A.TILE_DEFAULTS[b]})}),c=b=>tt({target:n.sheetMargin,base:A.TILE_DEFAULTS.sheetMargin,propKey:b,write:()=>u(b,A.TILE_DEFAULTS.sheetMargin[b])}),u=(b,w)=>s({sheetMargin:{...n.sheetMargin,[b]:w??0}}),h={...t,tiling:n},m=A.validateTiling(h),g=Math.max(A.computeMaxColumns(h),1);let v="";if(!m.length)try{const b=A.computeTileLayout(h),w=A.resolveSheetMm(h),T=n.sheetPaperSize==="CUSTOM"?"自定义":n.sheetPaperSize??"A4",k=n.sheetPaperSize==="CUSTOM"?"":n.sheetOrientation==="landscape"?" 横向":" 纵向";v=`目标纸 ${T}${k} ${w.width}×${w.height}mm · ${b.columns} 列 × ${b.rows} 行 = 每张 ${b.perSheet} 格 · 每格 ${b.tile.width}×${b.tile.height}mm`}catch{v=""}return a("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[Pe("拼版打印"),a("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),a("div",{class:"pd-field"},[a("label",{class:"tiling-switch"},[a("input",{type:"checkbox",checked:n.enabled===!0,disabled:r,onChange:b=>{if(!b.target.checked){s({enabled:!1});return}s({...A.TILE_DEFAULTS,columns:Math.min(A.TILE_DEFAULTS.columns,Math.max(g,1))})}}),a("span",{text:"启用拼版"})]),r?a("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),n.enabled&&!r?[B("目标纸张",a("select",{class:"pd-select",style:{width:"100%"},onChange:b=>{const w=b.target.value;if(w!=="CUSTOM"){s({sheetPaperSize:w});return}const T=A.resolveSheetMm(h);s({sheetPaperSize:"CUSTOM",sheetCustomWidth:n.sheetCustomWidth??T.width,sheetCustomHeight:n.sheetCustomHeight??T.height})}},[...zs.map(b=>a("option",{value:b,text:p.PAPER_PRESETS[b]?.label??b,selected:(n.sheetPaperSize??"A4")===b})),a("option",{value:"CUSTOM",text:"自定义",selected:n.sheetPaperSize==="CUSTOM"})]),void 0,l("sheetPaperSize")),n.sheetPaperSize==="CUSTOM"?B("目标纸宽高 (mm)",a("div",{class:"custom-size-grid"},[I({value:Number(n.sheetCustomWidth??0),min:25,max:2e3,onCommit:b=>s({sheetCustomWidth:b})}),a("span",{class:"custom-size-x",text:"×"}),I({value:Number(n.sheetCustomHeight??0),min:25,max:2e3,onCommit:b=>s({sheetCustomHeight:b})})])):B("目标纸方向",Ue("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.sheetOrientation==="landscape"?"landscape":"portrait",b=>s({sheetOrientation:b})),void 0,l("sheetOrientation")),Pe("拼版留白 (mm)"),a("div",{class:"margin-grid"},[B("上",I({value:n.sheetMargin.top??0,min:0,max:100,onCommit:b=>u("top",b)}),void 0,c("top")),B("下",I({value:n.sheetMargin.bottom??0,min:0,max:100,onCommit:b=>u("bottom",b)}),void 0,c("bottom")),B("左",I({value:n.sheetMargin.left??0,min:0,max:100,onCommit:b=>u("left",b)}),void 0,c("left")),B("右",I({value:n.sheetMargin.right??0,min:0,max:100,onCommit:b=>u("right",b)}),void 0,c("right"))]),Pe("格间距与列数"),B("横向间距",I({value:n.gapX??0,min:0,max:50,onCommit:b=>s({gapX:b??0})}),void 0,l("gapX")),B("纵向间距",I({value:n.gapY??0,min:0,max:50,onCommit:b=>s({gapY:b??0})}),void 0,l("gapY")),B("列数",I({value:n.columns??1,min:1,max:g,onCommit:b=>s({columns:b||1})})),...m.map(b=>a("p",{class:"pd-hint tiling-error",text:b.message})),!m.length&&v?a("p",{class:"pd-hint tiling-summary",text:v}):""]:""].flat().filter(Boolean))}const Is=new Set(p.PROPERTY_REGISTRY.map(o=>o.group)),Os={"table-settings":"content"},an=new Map;function ri(o){const e=o??"";let t=an.get(e);if(!t){const{groups:i,itemKeys:n}=p.searchProperties(e);t={groups:i,keys:n,searching:!!e.trim()},an.set(e,t)}return t}function ai(o){const e=Os[o]??o;return Is.has(e)?e:""}function Ns(o,e){const t=ri(o.state.propSearch);if(!t.searching)return!0;const i=ai(e);return!i||t.groups.includes(i)}function $s(o,e){const t=ri(o.state.propSearch);return!t.searching||t.keys.has(e)}function Hn(o,e){const t=o.props.style??{};return o.props.style={...t,display:e?"":"none"},o}function _(o,e,t){const i=t.props.dataset??{};return t.props.dataset={...i,propKey:e},Hn(t,$s(o,e))}function Bs(o,e,t){const i=ai(e);if(!i)return t;const n=t.props.dataset??{};return t.props.dataset={...n,propGroup:i},Hn(t,Ns(o,e))}function Wn(o,e){const t=ri(e);for(const i of Array.from(o.querySelectorAll("[data-prop-group]"))){const n=ai(i.dataset.propGroup??"");i.style.display=!t.searching||!n||t.groups.includes(n)?"":"none"}for(const i of Array.from(o.querySelectorAll("[data-prop-key]")))i.style.display=!t.searching||t.keys.has(i.dataset.propKey??"")?"":"none"}function Hs(o){return a("div",{class:"property-search"},[a("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:o.state.propSearch??"",onInput:e=>{const t=e.target,i=t.value;o.state.propSearch=i,Wn(t.getRootNode(),i)}})])}const Ws={Document:"≡",Brush:"◧",Setting:"⚙"};function Us(o,e){try{const t=window.localStorage.getItem(`property-group-${o}`);return t===null?e:t==="true"}catch{return e}}function Gs(o,e){try{window.localStorage.setItem(`property-group-${o}`,String(e))}catch{}}function xe(o,e,t,i,n,r=!0){const s=Us(e,r);return Bs(o,e,a("div",{class:`property-group${s?" is-expanded":""}`},[a("div",{class:"group-header",onClick:()=>{Gs(e,!s),o.repaint()}},[a("span",{class:"group-icon",text:Ws[i]||"•"}),a("span",{class:"group-title",text:t}),a("span",{class:"expand-icon",text:s?"▾":"▸"})]),a("div",{class:"group-content",style:s?"":{display:"none"}},n.filter(Boolean))]))}function lo(o){return a("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},o.filter(Boolean))}function Un(o){return o.split(".").flatMap(e=>{const t=e.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!t)return[e];const i=t[1],n=[...t[2].matchAll(/\[(\d+)\]/g)].map(r=>Number(r[1]));return[i,...n]})}function sn(o,e){return Un(e).reduce((n,r)=>n==null?"":n[r],o)??""}function si(o,e,t,i){const n=Un(t),r=n.pop(),s=n.reduce((l,c)=>((l[c]===void 0||l[c]===null)&&(l[c]={}),l[c]),e);s[r]=i||void 0,o.recordHistory(),o.emit()}function qs(o,e){const t=o.store;if(e.printElementType.type==="table"&&t.tableSelection?.elementId===e.id){const{r1:i,c1:n}=t.tableSelection,r=(e.options.tableRows??[])[i];if(r)return p.getTableCellBindings(r.type,i,n,e.options.fields?.[0]?.dataSource)}return p.getElementBindings(e)}function Ks(o,e){const t=document.createElement("label");t.className="pd-button small upload-label",fe(a("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[a("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),t);const i=document.createTextNode("上传图片"),n=document.createElement("input");n.className="visually-hidden",n.type="file",n.accept="image/*",t.append(i,n);const r=c=>{t.className=`pd-button small upload-label${c?" disabled":""}`,n.disabled=c};n.addEventListener("change",async()=>{const c=n.files?.[0];if(!c)return;if(!c.type.startsWith("image/")){alert("仅支持上传图片文件"),n.value="";return}const u=o.host.uploadImage;if(!u){alert("图片上传能力未配置"),n.value="";return}r(!0),i.textContent="上传中...";try{const h=await u(c);h?si(o.store,e,"options.src",h):alert("图片上传失败")}catch(h){alert(h instanceof Error?h.message:"图片上传失败")}finally{i.textContent="上传图片",r(!o.host.uploadImage),n.value=""}}),o.host.uploadImage||r(!0);const s=document.createElement("div");s.className="image-content-upload";const l=document.createElement("p");return l.className="upload-tip",l.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",s.append(t,l),s}function js(o,e){const t=i=>o.fire("open-expression",{elementId:e.id,targetPath:i.targetPath,value:sn(e,i.targetPath)});return xe(o,"binding","内容","Document",[...qs(o,e).map(i=>B(i.label,a("input",{class:"pd-input",type:"text",value:sn(e,i.targetPath),placeholder:i.placeholder||"输入内容,支持 {字段} 表达式",onChange:n=>si(o.store,e,i.targetPath,n.target.value),onDblclick:()=>t(i)}))),e.printElementType.type==="image"?Ks(o,e):""].filter(Boolean))}const Ct=new Map;function Zt(o){return`${Math.round(o*1e4)/1e4}%`}function Gn(o,e){const t=p.parseCropAnchor(e.value),i=t.kind==="custom",n=t.kind==="axes"?t.x:50,r=t.kind==="axes"?t.y:50,s=p.resolveCropPreview(e.src),l=Ct.get(s.src),c={widthMm:e.widthMm,heightMm:e.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:e.fit,scalePct:e.scale},u=p.resolveCropTravel(c),h=p.cropWindow(c,n,r),m=document.createElement("select");m.className="pd-select",m.style.width="100%";for(const w of p.cropPresetOptions(u,n,r)){const T=document.createElement("option");T.value=w.value,T.textContent=w.label,m.appendChild(T)}if(i){const w=document.createElement("option");w.value="custom",w.textContent="自定义(保留原值)",m.appendChild(w)}m.value=i?"custom":`${n},${r}`,m.selectedIndex<0&&(m.selectedIndex=i?m.options.length-1:0),m.addEventListener("change",()=>{if(m.value==="custom")return;const[w,T]=m.value.split(",").map(Number);e.onCommit(p.buildCropAnchor(w,T))});const g=p.propertyTip(e.fieldKey),v=[a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[e.label,Go(g)]),e.resetAnchor??""].filter(Boolean)),m])];v.push(a("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[p.CROP_SCALE_LABEL,Go(p.propertyTip("ap-img-fit-scale"))]),e.resetScale??""].filter(Boolean)),I({value:e.scale,min:p.CROP_SCALE_MIN,max:p.CROP_SCALE_MAX,step:5,placeholder:"默认 100",onCommit:w=>e.onScaleCommit(w>p.CROP_SCALE_MIN?w:void 0)})]));for(const w of p.cropAxisFields(u,n,r))v.push(a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label",text:w.label}),I({value:w.value,min:0,max:100,step:1,onCommit:T=>e.onCommit(p.buildCropAnchor(w.name==="horizontal"?T:n,w.name==="vertical"?T:r))})]));const b=p.cropAxisNote(u,i);return b&&v.push(a("p",{class:"pd-crop-note",text:b})),s.isSample&&v.push(a("p",{class:"pd-crop-note",text:p.CROP_SAMPLE_NOTE})),v.push(a("div",{class:"pd-crop-preview"},[a("img",{class:"pd-crop-thumb",src:s.src,alt:s.isSample?"示例图":"原图",onLoad:w=>{const T=w.target;if(!(T.naturalWidth>0&&T.naturalHeight>0))return;const k=Ct.get(s.src);k&&k.width===T.naturalWidth&&k.height===T.naturalHeight||(Ct.set(s.src,{width:T.naturalWidth,height:T.naturalHeight}),o.repaint())},onError:()=>{Ct.has(s.src)&&(Ct.delete(s.src),o.repaint())}}),h?a("div",{class:"pd-crop-win",style:{left:Zt(h.leftPct),top:Zt(h.topPct),width:Zt(h.widthPct),height:Zt(h.heightPct)}}):""])),a("div",{class:e.containerClass??"pd-crop-anchor"},v)}const Ze=o=>Number(o??0),qo=o=>o||void 0;function bt(o,e,t,i,n){return a("div",{class:"pd-field"},[a("span",{class:"pd-label",...i?{title:i}:{}},[a("span",{class:"pd-label-t",text:o}),n??""].filter(Boolean)),a("input",{class:"pd-switch",type:"checkbox",checked:e,onChange:r=>t(r.target.checked)})])}function qn(o,e,t,i,n=!1,r){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),""].filter(Boolean)),a("select",{class:"pd-select",...n?{style:{width:"100%"}}:{},onChange:s=>i(s.target.value)},t.map(s=>a("option",{value:s.value,text:s.label,selected:s.value===e})))])}function At(o,e,t,i,n={}){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),n.reset??""].filter(Boolean)),Bn(e,t,i,{className:"pd-select",...n.full?{width:"100%"}:{}})])}const Dt=o=>a("p",{class:"pd-hint",text:o}),Ys="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",Vs=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],Xs=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Zs=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],Qs=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],Js={value:"__multi__",label:"多选",disabled:!0};function el(o,e){const t=o.store,i=t.tableSelection,n=e.options.tableRows??[],r=i?n[i.r1]:void 0;if(!i||!r)return xe(o,"table-row","行属性","Grid",[]);const s=l=>t.updateElement(e.id,l);return xe(o,"table-row","行属性","Grid",[lo([qn("行类型",r.type,Vs,l=>{const c=p.setRowType(n,i.r1,l);if(c){window.alert(c);return}s({tableRows:n})},!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"行高 (mm)"}),I({value:r.height,min:3,max:100,step:.5,onCommit:l=>{r.height=l,s({tableRows:n})}})]),r.type==="header"?bt("表头每页重复",r.repeatOnPage??!1,l=>{p.setHeaderRepeat(n,l),s({tableRows:n})},Ys):""])])}function tl(o,e){const t=o.store,i=e.options,n=h=>t.updateElement(e.id,h),r=i.tableColWidths??[],s=t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right,l=t.fields.filter(h=>h.fieldType==="list").map(h=>({value:h.fieldKey,label:h.fieldLabel})),c=p.createDefaultOptions("table"),u=h=>tt({target:i,base:c,propKey:h,write:()=>n({[h]:c[h]})});return xe(o,"table-settings","表格设置","Grid",[lo([qn("列表数据源字段",i.dataSource??"",l,h=>n({dataSource:h||void 0}),!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字体"}),u("tableDefaultFontFamily")]),so({id:"table-default-font",state:o.state,fonts:o.host.fonts,value:i.tableDefaultFontFamily,placeholder:"默认",onChange:h=>n({tableDefaultFontFamily:h||void 0})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字号 (pt)"}),u("tableDefaultFontSize")]),I({value:Ze(i.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:h=>n({tableDefaultFontSize:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认文字颜色"}),u("tableDefaultColor")]),Ae(i.tableDefaultColor,h=>n({tableDefaultColor:h}),"默认文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),u("tableDefaultPadding")]),I({value:Ze(i.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:h=>n({tableDefaultPadding:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"列宽 (mm)"}),...r.map((h,m)=>a("div",{class:"col-width-row"},[a("span",{style:{width:"60px"},text:`列${m+1}`}),I({value:h,min:5,max:200,onCommit:g=>{const v=r.reduce((b,w,T)=>T===m?b:b+w,0);if(v+g>s){const b=Math.max(5,Math.round((s-v)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${s}mm,列${m+1} 已调整为 ${b}mm`),r[m]=b}else r[m]=g;n({tableColWidths:r})}})]))])])])}function ol(o,e){const t=o.store,i=e.options,n=e.printElementType.type==="table",r=l=>t.updateElement(e.id,l),s=[];if(n)s.push(_(o,"pg-enabled",bt("启用分页",i.tablePagination?.enabled??!0,l=>r({tablePagination:{enabled:l}}))));else{const l=i.pagination?.pageable??!0,c=i.pagination?.keepWithNext??!1;s.push(_(o,"pg-pageable",bt("参与分页",l,u=>r({pagination:{pageable:u,keepWithNext:c}})))),s.push(_(o,"pg-keep-with-next",bt("与下元素同页",c,u=>r({pagination:{pageable:l,keepWithNext:u}}))))}return xe(o,"pagination","分页配置","Document",[lo(s)],!1)}const Po=new WeakMap,ln=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function il(o,e){const t=o.store,i=t.tableSelection,n=e.options.tableRows??[];if(!i)return xe(o,"table-cell","单元格","Menu",[]);const r=p.findMainCell(n,i.r1,i.c1),s=n[r.r]?.cells[r.c];if(!s)return xe(o,"table-cell","单元格","Menu",[]);const l=()=>p.collectWritableCells(n,i),c=p.resolveCellGroupMode(n,i),u=c.count,h=c.mode==="multi",m=`${e.id}:${i.r1}:${i.c1}:${i.r2}:${i.c2}`,g=Po.get(t),v=g?.key===m?g:{key:m,border:{},values:{},edges:{}};g?.key!==m&&Po.set(t,v);const b=x=>{Po.set(t,{key:m,border:x.border??v.border,values:x.values??v.values,edges:x.edges??v.edges})},w=(x,O)=>{b({border:{...v.border,[x]:O}}),o.repaint()},T=(x,O)=>{l().forEach(x),h&&O&&b({values:{...v.values,...O}}),t.updateElement(e.id,{tableRows:n})},k=(x,O)=>{T(Q=>{Q[x]=O},{[x]:O})},z=x=>h?v.values[x]:s[x],W=x=>h&&x in v.values,P=h?{width:void 0,style:void 0,color:void 0}:p.resolveCellBorderDisplay(n,i),ne=!h&&l().some(x=>!!x.borders&&!!(x.borders.top||x.borders.right||x.borders.bottom||x.borders.left)),ye=!h&&!ne,Y={width:ye?0:typeof P.width=="number"?P.width:p.DEFAULT_BORDER.width,style:ye?"none":typeof P.style=="string"&&P.style!=="mixed"?P.style:p.DEFAULT_BORDER.style,color:typeof P.color=="string"&&P.color!=="mixed"?P.color:p.DEFAULT_BORDER.color,...v.border},F="__mixed__",M={style:!h&&P.style==="mixed",width:!h&&P.width==="mixed",color:!h&&P.color==="mixed"},G=M.style&&!("style"in v.border),V=M.width&&!("width"in v.border),ce=M.color&&!("color"in v.border),Z=G||V||ce,y=G?F:Y.style,H=V?void 0:Y.width,ae=ce?void 0:Y.color,Fe=x=>{const O={style:x};x!=="none"&&H===0?O.width=p.DEFAULT_BORDER.width:x==="none"&&!ne&&(O.width=0),b({border:{...v.border,...O}}),o.repaint()},L=()=>({...Y}),ee=h?ln.reduce((x,O)=>(x[O.value]=v.edges[O.value]?"on":"off",x),{}):p.resolveBorderEdgeStates(l().map(x=>x.borders)),Ge=h?"cellType"in v.values?v.values.cellType??"text":p.resolveSharedCellType(n,i):s.cellType??"text",pe=Ge==="barcode",qe=Ge==="qrcode",ot=Ge==="image",U=Ge==="text",co=pe&&!!z("printerDpi"),Ft=p.barcodeBarWidthRecommendText(z("printerDpi"),z("barWidth")),Lt=h?v.values.textFit:p.resolveCellTextFit(s),po=h?"cellType"in v.values?v.values.cellType??"text":"":s.cellType||"text",Ke=x=>h?[Js,...x]:x,we=x=>h?"多选":x,Se=(x,O)=>h?v.values[x]:O,uo=h?z("barcodeType")??"__multi__":s.barcodeType||"CODE128",It=h?W("printerDpi")?z("printerDpi")?String(z("printerDpi")):"":"__multi__":s.printerDpi?String(s.printerDpi):"",q=h?z("qrCodeLevel")??"__multi__":s.qrCodeLevel||"M",xt=h?z("fit")??"__multi__":s.fit||"contain",K=Lt??"__multi__",it=p.canMergeReason(n,i);let ue=!1;for(let x=i.r1;x<=i.r2&&!ue;x++)for(let O=i.c1;O<=i.c2&&!ue;O++){const Q=n[x]?.cells[O];Q&&!Q.merged&&((Q.rowspan??1)>1||(Q.colspan??1)>1)&&(ue=!0)}const Te=(x,O,Q,te={},De)=>a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:x}),De??""].filter(Boolean)),I({value:O,...te,onCommit:yt=>k(Q,qo(yt))})]),Ot="恢复默认值(跟随表格默认)",N=x=>tt({target:s,base:{},propKey:x,tipOverride:Ot,force:h,write:()=>k(x,void 0)}),vt=e.options.tableDefaultPadding??1,nt={width:p.cellFitWidthMm(e.options.tableColWidths??[],r.c,s,vt),height:p.cellFitCapMm(n,r.r,s,vt)};return xe(o,"table-cell","单元格","Menu",[lo([h?Dt(`已选 ${u} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"单元格类型"}),Ue("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],po,x=>{const O=x==="text"?void 0:x,Q={cellType:x};x!=="barcode"&&Object.assign(Q,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),x!=="qrcode"&&Object.assign(Q,{qrCodeLevel:void 0,qrQuietZone:void 0}),T(te=>{te.cellType=O,x!=="barcode"&&(te.barcodeType=void 0,te.showBarcodeText=void 0,te.printerDpi=void 0,te.barQuietZone=void 0,te.barHeight=void 0),x!=="qrcode"&&(te.qrCodeLevel=void 0,te.qrQuietZone=void 0)},Q)})]),pe?At("码制",uo,Ke(Xs),x=>{x!=="__multi__"&&k("barcodeType",x||void 0)}):"",pe?bt("显示文本",h?v.values.showBarcodeText===!0:s.showBarcodeText!==!1,x=>k("showBarcodeText",x),void 0,N("showBarcodeText")):"",pe?Te("条宽(倍率)",Se("barWidth",s.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:we("")},N("barWidth")):"",pe?Dt((co?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Ft?`。${Ft}`:"")):"",pe?Ce("静区 (模块)",I({value:Se("barQuietZone",s.barQuietZone),min:0,max:20,placeholder:we("默认 10"),onCommit:x=>k("barQuietZone",x)}),p.propertyTip("cd-bar-quiet-zone"),N("barQuietZone")):"",pe?Ce("条高 (mm)",I({value:Se("barHeight",s.barHeight),min:1,max:100,placeholder:we("默认 30 模块"),onCommit:x=>k("barHeight",x??void 0)}),p.propertyTip("cd-bar-height"),N("barHeight")):"",pe?Te("文本字号(相对条高,条高为 30)",Se("barFontSize",s.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:we("默认 10")},N("barFontSize")):"",pe?At("打印机分辨率",It,Ke([{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)"}]),x=>{if(x==="__multi__")return;const O=Number(x);k("printerDpi",O>0?O:void 0)},{reset:N("printerDpi")}):"",pe?Dt("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",qe?At("纠错级别",q,Ke(Zs),x=>{x!=="__multi__"&&k("qrCodeLevel",x||void 0)},{reset:N("qrCodeLevel")}):"",qe?Ce("静区 (模块)",I({value:Se("qrQuietZone",s.qrQuietZone),min:0,max:8,placeholder:we("默认 0"),onCommit:x=>k("qrQuietZone",x)}),p.propertyTip("cd-quiet-zone"),N("qrQuietZone")):"",pe?Dt("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",qe||ot?At("缩放模式",xt,Ke(p.IMAGE_FIT_OPTIONS),x=>{x!=="__multi__"&&k("fit",x)},{reset:N("fit")}):"",ot&&!h&&s.fit==="cover"?Gn(o,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(s.formatter),fit:s.fit,containerClass:"pd-cell-anchor",widthMm:nt.width,heightMm:nt.height,scale:s.fitScale,value:s.objectPosition,onCommit:x=>k("objectPosition",x),onScaleCommit:x=>k("fitScale",x),resetAnchor:N("objectPosition"),resetScale:N("fitScale")}):"",pe||qe||ot?Te("最大宽度 (mm)",Se("maxWidth",Ze(s.maxWidth)),"maxWidth",{min:0,max:200,placeholder:we("默认")},N("maxWidth")):"",pe||qe||ot?Te("最大高度 (mm)",Se("maxHeight",Ze(s.maxHeight)),"maxHeight",{min:0,max:200,placeholder:we("默认")},N("maxHeight")):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"内容"}),a("input",{class:"pd-input",type:"text",value:h?z("formatter")??"":s.formatter||"",placeholder:h?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:x=>k("formatter",x.target.value||void 0),onDblclick:()=>o.fire("table-cell-dblclick",{elementId:e.id,r:r.r,c:r.c,cellId:s.id})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"水平对齐"}),N("align")]),Ue("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],h?v.values.align??"":s.align||"left",x=>k("align",x))]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"垂直对齐"}),N("valign")]),Ue("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],h?v.values.valign??"":s.valign||"top",x=>k("valign",x))]),a("div",{class:"cell-style-grid"},[a("div",{class:"pd-field cell-font-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"字体"}),N("fontFamily")]),so({id:"cell-font",state:o.state,fonts:o.host.fonts,value:h?z("fontFamily"):s.fontFamily,placeholder:we("继承默认"),onChange:x=>k("fontFamily",x)})]),Te("字号 (pt)",Se("fontSize",Ze(s.fontSize)),"fontSize",{min:0,max:72,placeholder:we("默认")},N("fontSize")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"加粗"}),N("fontWeight")]),a("input",{class:"pd-switch",type:"checkbox",checked:h?v.values.fontWeight==="bold":s.fontWeight==="bold",onChange:x=>k("fontWeight",x.target.checked?"bold":void 0)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"文字颜色"}),N("color")]),Ae(h?z("color"):s.color,x=>k("color",x),"文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"背景色"}),N("backgroundColor")]),Ae(h?z("backgroundColor"):s.backgroundColor,x=>k("backgroundColor",x),"背景颜色")])]),Pe("边框"),a("div",{class:"border-style-row"},[Bn(y,[...G?[{value:F,label:"混合",disabled:!0}]:[],...p.BORDER_LINE_STYLES],x=>{x!==F&&Fe(x)},{width:"90px"}),a("div",{style:{width:"112px",flexShrink:"0"}},[I({value:H,min:.25,max:5,step:.25,placeholder:h?"多选":V?"混合":void 0,onCommit:x=>w("width",x)})]),Ae(ae,x=>w("color",x),"边框颜色")]),a("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([x,O])=>a("button",{type:"button",class:"pd-button small",text:O,onClick:()=>{p.applyBorderPreset(n,i,Y.style==="none"?"none":x,L()),t.updateElement(e.id,{tableRows:n})}}))),a("div",{class:"pd-checkbox-group"},ln.map(x=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",value:x.value,checked:ee[x.value]==="on",indeterminate:ee[x.value]==="mixed",onChange:O=>{const te=O.target.checked&&Y.style!=="none";h&&b({edges:{...v.edges,[x.value]:te}}),T(De=>{p.setCellBorderEdge(De,x.value,te?L():null)})}}),a("span",{text:x.label})]))),Dt(h?p.CELL_BORDER_APPLY_HINT_MULTI:Z?p.CELL_BORDER_APPLY_HINT_MIXED:p.CELL_BORDER_APPLY_HINT),Te("内边距 (mm)",Se("padding",Ze(s.padding)),"padding",{min:0,max:10,step:.5,placeholder:we("默认")},N("padding")),bt("自动换行",h?v.values.wordWrap===!0:s.wordWrap??!0,x=>k("wordWrap",x),void 0,N("wordWrap")),U?At("文字溢出",K,Ke(Qs),x=>{x!=="__multi__"&&k("textFit",x)},{full:!0,reset:N("textFit")}):"",U&&Lt==="shrink"?Te("最小字号 (pt)",Se("shrinkMinFontSize",Ze(s.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:we("默认 6")},N("shrinkMinFontSize")):"",a("div",{class:"merge-btns"},[a("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!it,title:it||"",onClick:()=>{p.mergeCells(n,i),t.updateElement(e.id,{tableRows:n})}}),a("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!ue,onClick:()=>{p.splitCells(n,i),t.updateElement(e.id,{tableRows:n})}})])])])}const Fo=A.WATERMARK_DENSITY_PRESETS;function Ko(o){const e=o.trim();return e?/[{}]/.test(e)||/^[A-Za-z_$][\w$]*\s*\(/.test(e)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(e):!1}function nl(o){return o?o.mode==="binding"?o.binding??"":o.content??"":""}function rl(o){const e=o.store.templateData.watermark,t=nl(e),i=e?.mode==="binding"||t!==""&&Ko(t),n=(()=>{const u=e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,h=e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight;for(const[m,g]of Object.entries(Fo))if(g.width===u&&g.height===h)return m;return"custom"})(),r=u=>{const h={testData:e?.testData??"",rotate:e?.rotate??A.WATERMARK_DEFAULTS.rotate,color:e?.color||A.WATERMARK_DEFAULTS.color,opacity:e?.opacity??A.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight,timestamp:e?.timestamp,format:e?.format};o.store.updateTemplateData({watermark:{...h,...u}})},s=()=>o.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:t}),l={rotate:e?.rotate??A.WATERMARK_DEFAULTS.rotate,color:e?.color||A.WATERMARK_DEFAULTS.color,opacity:e?.opacity??A.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight},c=u=>tt({target:l,base:A.WATERMARK_DEFAULTS,propKey:u,write:()=>r({[u]:A.WATERMARK_DEFAULTS[u]})});return a("div",{class:"watermark-config"},[Pe("水印"),a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},[a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"水印表达式"}),a("input",{class:"pd-input",type:"text",value:t,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:u=>{const h=u.target.value;r(Ko(h)?{mode:"binding",binding:h,content:""}:{mode:"fixed",content:h,binding:""})},onDblclick:s}),a("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:s})]),i?B("测试值",a("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:u=>r({testData:u.target.value})})):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),a("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??A.WATERMARK_DEFAULTS.rotate),onChange:u=>r({rotate:Number(u.target.value)})}),a("span",{class:"pd-hint",text:`${e?.rotate??A.WATERMARK_DEFAULTS.rotate}°`})]),B("颜色",Ae(e?.color||A.WATERMARK_DEFAULTS.color,u=>r({color:u}),"水印颜色"),void 0,c("color")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),a("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??A.WATERMARK_DEFAULTS.opacity),onChange:u=>r({opacity:Number(u.target.value)})}),a("span",{class:"pd-hint",text:(e?.opacity??A.WATERMARK_DEFAULTS.opacity).toFixed(2)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"密度"}),a("select",{class:"pd-select",style:{width:"100%"},onChange:u=>{const h=u.target.value,m=Fo[h];m&&r({tileWidth:m.width,tileHeight:m.height})}},[...Object.entries(Fo).map(([u,h])=>a("option",{value:u,text:`${h.label}(${h.width}×${h.height})`,selected:n===u})),a("option",{value:"custom",text:"自定义",selected:n==="custom"})])]),n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),a("input",{type:"number",class:"pd-input",min:A.WATERMARK_DEFAULTS.minTileWidth,step:10,value:String(e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth),onChange:u=>r({tileWidth:Number(u.target.value)})})]):"",n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),a("input",{type:"number",class:"pd-input",min:A.WATERMARK_DEFAULTS.minTileHeight,step:10,value:String(e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight),onChange:u=>r({tileHeight:Number(u.target.value)})})]):""].filter(Boolean))])}function de(o,e,t,i,n={},r){return B(e,I({value:t,...n,onCommit:i}),void 0,r)}function We(o,e,t,i,n,r,s){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>n(l.value));for(const c of i){const u=document.createElement("option");u.value=c.value,u.textContent=c.label,l.appendChild(u)}return l.value=t,i.some(c=>c.value===t)||(l.selectedIndex=-1),r?Ce(e,l,r,s):B(e,l,void 0,s)}function ht(o,e,t,i,n){return B(e,a("input",{type:"checkbox",class:"pd-switch",checked:t,onChange:r=>i(r.target.checked)}),void 0,n)}const al=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],sl=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function ll(o,e){const t=o.store,i=e.options,n=e.printElementType.type,r=y=>t.updateElement(e.id,y),s=n==="text"||n==="longText",l=n==="barcode"||n==="qrcode",c=n==="table",u=c&&t.tableSelection?.elementId===e.id,h=u&&p.resolveCellGroupMode(e.options.tableRows??[],t.tableSelection).mode==="multi",m=[];u||m.push(xe(o,"position-size","位置与尺寸","Location",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"position-grid"},[_(o,"ps-left",de(o,"X",i.left,y=>r({left:y}),{min:0})),_(o,"ps-top",de(o,"Y",i.top,y=>r({top:y}),{min:0})),_(o,"ps-width",de(o,"W",i.width,y=>r({width:y}),{min:4})),_(o,"ps-height",de(o,"H",i.height,y=>r({height:y}),{min:4}))])])]));const g=p.createDefaultOptions(n),v=(y,H)=>{const ae=p.propertyDefault(H);return tt({target:i,base:g,propKey:y,tipValue:ae?.value,tipUnit:ae?.unit,write:()=>r({[y]:g[y]})})},b=typeof i.rotate=="number"&&Number.isFinite(i.rotate)&&i.rotate!==0?p.normalizeRotationAngle(i.rotate):void 0,w=y=>r({rotate:y===void 0||y===0?void 0:p.normalizeRotationAngle(y)}),T=p.isFreeAngleEditable(n,i),k=p.isRotationExcludedType(n)||p.collectFollowMemberIds(t.elements).has(e.id),z=k?"":_(o,"ap-rotate",Ce("旋转 (°)",a("div",{class:"pd-rotate-row"},[a("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>w((b??0)-90)}),a("div",{class:"pd-rotate-stepper"},[I({value:b,min:0,max:359,placeholder:"0",disabled:!T,onCommit:y=>w(y)})]),a("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>w((b??0)+90)})]),p.propertyTip("ap-rotate"),v("rotate","ap-rotate"))),W=k||T?"":a("p",{class:"pd-hint pd-rotate-note",text:p.CODE_OBLIQUE_NOTE});if(m.push(xe(o,"appearance","外观","Brush",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},s?[_(o,"ap-font-family",B("字体",so({id:"prop-font",state:o.state,fonts:o.host.fonts,value:typeof i.fontFamily=="string"?i.fontFamily:void 0,placeholder:"默认",onChange:y=>r({fontFamily:y})}),void 0,v("fontFamily","ap-font-family"))),_(o,"ap-font-size",de(o,"字体大小",i.fontSize,y=>r({fontSize:y}),{min:8,max:72},v("fontSize","ap-font-size"))),_(o,"ap-font-weight",We(o,"字体粗细",String(i.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],y=>r({fontWeight:y}),void 0,v("fontWeight","ap-font-weight"))),_(o,"ap-align",B("对齐",Ue("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],i.textAlign||"left",y=>r({textAlign:y})),void 0,v("textAlign","ap-align"))),_(o,"ap-vertical-align",B("垂直对齐",Ue("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],i.verticalAlign||"top",y=>r({verticalAlign:y})),void 0,v("verticalAlign","ap-vertical-align"))),a("div",{class:"color-row"},[_(o,"ap-color",B("颜色",Ae(i.color,y=>r({color:y}),"字体颜色"),void 0,v("color","ap-color"))),_(o,"ap-bg-color",B("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","ap-bg-color")))]),_(o,"ap-line-height",de(o,"行高",i.lineHeight,y=>r({lineHeight:y||void 0}),{min:0,max:100},v("lineHeight","ap-line-height"))),_(o,"ap-letter-spacing",de(o,"字间距",i.letterSpacing,y=>r({letterSpacing:y||void 0}),{min:0,max:20,step:.5},v("letterSpacing","ap-letter-spacing"))),_(o,"ap-text-fit",We(o,"文字溢出",p.resolveElementTextFit(n,i),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],y=>r({textFit:y}),void 0,v("textFit","ap-text-fit"))),i.textFit==="shrink"?_(o,"ap-shrink-min",B("最小字号 (pt)",I({value:i.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:y=>r({shrinkMinFontSize:y||void 0})}),void 0,v("shrinkMinFontSize","ap-shrink-min"))):"",n==="longText"?_(o,"ap-long-text-indent",Ce("首行缩进 (字符)",I({value:i.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:y=>r({longTextIndent:y||void 0})}),p.propertyTip("ap-long-text-indent"),v("longTextIndent","ap-long-text-indent"))):"",_(o,"ap-word-wrap",ht(o,"自动换行",i.wordWrap!==!1,y=>r({wordWrap:y?void 0:!1}),v("wordWrap","ap-word-wrap"))),_(o,"ap-keep-line-breaks",ht(o,"保留换行符",i.keepLineBreaks===!0,y=>r({keepLineBreaks:y?!0:void 0}),v("keepLineBreaks","ap-keep-line-breaks"))),z,W]:[n==="image"?_(o,"ap-img-fit",We(o,"缩放模式",String(i.fit??"contain"),p.IMAGE_FIT_OPTIONS,y=>r({fit:y}),p.propertyTip("ap-img-fit"),v("fit","ap-img-fit"))):"",n==="image"&&i.fit==="cover"?_(o,"ap-img-object-position",Gn(o,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(i.src),widthMm:Number(i.width)||0,heightMm:Number(i.height)||0,fit:i.fit,scale:i.fitScale,value:i.objectPosition===void 0?void 0:String(i.objectPosition),onCommit:y=>r({objectPosition:y}),onScaleCommit:y=>r({fitScale:y}),resetAnchor:v("objectPosition","ap-img-object-position"),resetScale:v("fitScale","ap-img-fit-scale")})):"",z,W,n==="flowList"?a("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),l){const y=n==="barcode",H=String(i.barcodeType||"CODE128").toUpperCase(),ae=i.printerDpi?String(i.printerDpi):"",Fe=p.barcodeBarWidthRecommendText(i.printerDpi,i.barWidth);m.push(xe(o,"code","条码设置","Postcard",[a("form",{class:"pd-form",onSubmit:L=>L.preventDefault()},[y?[_(o,"cd-type",We(o,"码制",H,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],L=>r({barcodeType:L==="CODE128"?void 0:L}))),_(o,"cd-dpi",We(o,"打印机分辨率",ae,[{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)"}],L=>r({printerDpi:Number(L)>0?Number(L):void 0}),void 0,v("printerDpi","cd-dpi"))),_(o,"cd-dpi",a("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),_(o,"cd-bar-width",de(o,"条宽(倍率)",i.barWidth??2,L=>r({barWidth:L}),{min:2,max:8,step:.5},v("barWidth","cd-bar-width"))),_(o,"cd-bar-width",a("p",{class:"pd-hint",text:(ae?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Fe?`。${Fe}`:"")})),_(o,"cd-bar-quiet-zone",Ce("静区 (模块)",I({value:i.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:L=>r({barQuietZone:L})}),p.propertyTip("cd-bar-quiet-zone"),v("barQuietZone","cd-bar-quiet-zone"))),_(o,"cd-bar-height",Ce("条高 (mm)",I({value:i.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:L=>r({barHeight:L??void 0})}),p.propertyTip("cd-bar-height"),v("barHeight","cd-bar-height"))),_(o,"cd-show-text",ht(o,"显示文本",i.hideTitle!==!0,L=>r({hideTitle:L?void 0:!0}),v("hideTitle","cd-show-text"))),_(o,"cd-font-size",B("文本字号(相对条高,条高为 30)",I({value:i.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:L=>r({fontSize:L||void 0})}),void 0,v("fontSize","cd-font-size")))]:[_(o,"cd-ec-level",We(o,"纠错级别",String(i.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],L=>r({qrCodeLevel:L}),void 0,v("qrCodeLevel","cd-ec-level"))),_(o,"cd-quiet-zone",Ce("静区 (模块)",I({value:i.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:L=>r({qrQuietZone:L})}),p.propertyTip("cd-quiet-zone"),v("qrQuietZone","cd-quiet-zone")))],Pe("自定义设置"),y?a("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",y?"":_(o,"cd-fit",We(o,"缩放模式",String(i.fit||"contain"),p.IMAGE_FIT_OPTIONS,L=>r({fit:L||void 0}),void 0,v("fit","cd-fit"))),_(o,"cd-max-width",B("最大宽度 (mm)",I({value:i.maxWidth,min:1,max:200,placeholder:"默认",onCommit:L=>r({maxWidth:L||void 0})}),void 0,v("maxWidth","cd-max-width"))),_(o,"cd-max-height",B("最大高度 (mm)",I({value:i.maxHeight,min:1,max:200,placeholder:"默认",onCommit:L=>r({maxHeight:L||void 0})}),void 0,v("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(h||m.push(js(o,e)),u&&(m.push(el(o,e)),m.push(il(o,e))),c&&m.push(tl(o,e)),n==="flowList"){const y=p.resolveFlowColumns(i.flowColumns),H=p.resolveFlowRowHeight(i.flowRowHeight),ae=p.resolveFlowGapX(i.flowGapX),Fe=p.resolveFlowMaxSpan(i.flowMaxSpan,y),L=p.suggestFlowColumns(i.width??0,ae,i.fontSize??12);m.push(xe(o,"flowList","流式列表","Grid3x3",[a("form",{class:"pd-form",onSubmit:ee=>ee.preventDefault()},[_(o,"fl-columns",Ce("每行列数",I({value:y,min:1,max:12,onCommit:ee=>r({flowColumns:p.resolveFlowColumns(ee),flowMaxSpan:p.resolveFlowMaxSpan(i.flowMaxSpan,p.resolveFlowColumns(ee))})}),p.propertyTip("fl-columns"))),_(o,"fl-row-height",Ce("行高 (mm)",I({value:H,min:3,max:100,step:.5,onCommit:ee=>r({flowRowHeight:p.resolveFlowRowHeight(ee)})}),p.propertyTip("fl-row-height"))),_(o,"fl-gap-x",Ce("单元横向间距 (mm)",I({value:ae,min:0,max:50,step:.5,onCommit:ee=>r({flowGapX:p.resolveFlowGapX(ee)})}),p.propertyTip("fl-gap-x"))),_(o,"fl-auto-span",ht(o,"内容过长时跨列",i.flowAutoSpan===!0,ee=>{r(ee?{flowAutoSpan:ee,flowMaxSpan:Fe}:{flowAutoSpan:ee})})),i.flowAutoSpan===!0?_(o,"fl-max-span",Ce("最多跨几列",I({value:Fe,min:1,max:y,onCommit:ee=>r({flowMaxSpan:p.resolveFlowMaxSpan(ee,y)})}),p.propertyTip("fl-max-span"))):"",y>L?a("p",{class:"pd-hint",text:`按当前字号与框宽,${y} 列偏挤(可放约 ${L} 列)。数值保持不变,出纸按 ${y} 列排。`}):""].flat().filter(Boolean))]))}const P=()=>({borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:i.borders}),ne=y=>{const H=P();p.applyElementBorderPreset(H,y,p.effectiveElementBorderSpec(H)),r(H)},ye=y=>{const H=P();p.setElementBorderEdgeVisible(H,y,!p.elementBorderEdgeVisible(H,y)),r(H)},Y=p.resolveElementBorderDisplay(i),F=Y.style==="mixed",M=typeof Y.width=="number"?Y.width:void 0,G=F||Y.style===void 0?"":Y.style,V=typeof Y.color=="string"?Y.color:void 0,ce=(y,H)=>{const ae=P();p.setElementBorderField(ae,y,H),r(ae)},Z=F?[{value:"",label:"混合"},...p.BORDER_LINE_STYLES]:[...p.BORDER_LINE_STYLES];return m.push(xe(o,"border-bg","边框与背景","Picture",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[_(o,"bb-border-style",We(o,"线型",G,Z,y=>ce("borderStyle",y))),a("div",{class:"border-row"},[_(o,"bb-border-width",de(o,"边框宽度",M,y=>ce("borderWidth",y),{min:0,max:20,step:.25,placeholder:Y.width==="mixed"?"混合":void 0},v("borderWidth","bb-border-width"))),_(o,"bb-border-color",B("边框颜色",Ae(V,y=>ce("borderColor",y),"边框颜色"),void 0,v("borderColor","bb-border-color")))]),...p.acceptsElementBorder(n)?[a("div",{class:"pd-button-group border-presets"},al.map(y=>a("button",{type:"button",class:"pd-button small",text:y.label,disabled:y.value==="inner",onClick:()=>ne(y.value)}))),a("div",{class:"pd-checkbox-group"},sl.map(y=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",checked:p.elementBorderEdgeVisible(i,y.value),onChange:()=>ye(y.value)}),a("span",{text:y.label})]))),a("p",{class:"pd-hint",text:p.ELEMENT_BORDER_APPLY_HINT})]:[],_(o,"bb-bg-color",B("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","bb-bg-color")))])])),m.push(ol(o,e)),m.push(xe(o,"advanced","高级设置","Setting",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"advanced-row"},[_(o,"ad-locked",ht(o,"锁定",!!i.locked,y=>r({locked:y}),v("locked","ad-locked"))),_(o,"ad-fixed",ht(o,"每页重复",!!i.fixed,y=>r({fixed:y}),v("fixed","ad-fixed")))]),_(o,"ad-z-index",de(o,"层级",i.zIndex,y=>r({zIndex:y}),{min:0,max:999},v("zIndex","ad-z-index"))),_(o,"ad-delete",a("div",{class:"pd-field"},[a("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>t.deleteSelected()})]))])],!1)),a("div",{class:"property-content"},m)}function dl(o){const e=o.store,t=e.templateData,i=c=>e.updateTemplateData(c),n=c=>{const u=t.tiling,h=m=>m===90||m===270;if(u?.enabled&&h(c)!==h(t.outputRotation)){const m=A.computeMaxColumns({...t,outputRotation:c});i({outputRotation:c,tiling:{...u,columns:Math.max(m,1)}});return}i({outputRotation:c})},r=[];for(const[c,u]of Object.entries(p.PAPER_PRESETS)){const h=u.group??"其他";let m=r.find(g=>g.group===h);m||(m={group:h,items:[]},r.push(m)),m.items.push({key:c,label:u.label??c})}const s=!p.PAPER_PRESETS[t.paperSize],l=p.isContinuousPaperSize(t.paperSize);return a("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[Pe("纸张设置"),B("纸张尺寸",a("select",{class:"pd-select",style:{width:"100%"},onChange:c=>i({paperSize:c.target.value})},[...r.map(c=>a("optgroup",{label:c.group},c.items.map(u=>a("option",{value:u.key,text:u.label,selected:t.paperSize===u.key})))),a("option",{value:"CUSTOM",text:"自定义宽高",selected:s})])),l||s?B(l?"纸宽 (mm)":"自定义宽高 (mm)",a("div",{class:"custom-size-grid"},[I({value:Number(t.customWidth??0),min:25,max:2e3,onCommit:c=>i({customWidth:c})}),...s?[a("span",{class:"custom-size-x",text:"×"}),I({value:Number(t.customHeight??0),min:25,max:2e3,onCommit:c=>i({customHeight:c})})]:[]])):"",l?"":B("纸张方向",Ue("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],t.orientation==="landscape"?"landscape":"portrait",c=>i({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":B("内容旋转角度",Ue("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(t.outputRotation??0),c=>n(Number(c)),!0),t.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),B("页面背景色",a("div",{class:"page-bg-row"},[Ae(t.pageBackground,c=>i({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,tt({target:t,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>i({pageBackground:void 0})})),Fs(o),e.pages.length>1?"":Ls(o),Pe("页边距 (mm)"),a("div",{class:"margin-grid"},[de(o,"上",t.margins.top,c=>i({margins:{...t.margins,top:c}}),{min:0,max:50}),de(o,"下",t.margins.bottom,c=>i({margins:{...t.margins,bottom:c}}),{min:0,max:100}),de(o,"左",t.margins.left,c=>i({margins:{...t.margins,left:c}}),{min:0,max:50}),de(o,"右",t.margins.right,c=>i({margins:{...t.margins,right:c}}),{min:0,max:50})]),Pe("页眉/页脚高度 (mm)"),de(o,"页眉高度",t.header.height??10,c=>i({header:{...t.header,height:c}}),{min:0,max:100,step:.1}),de(o,"页脚高度",t.footer.height??10,c=>i({footer:{...t.footer,height:c}}),{min:0,max:100,step:.1}),rl(o)].filter(Boolean))}function cl(o){const e=o.store,t=o.state,i=e.selectedElement;if(t.propCollapsed)return a("div",{class:"property-panel collapsed"},[a("div",{class:"prop-collapsed"},[a("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{t.propCollapsed=!1,o.repaint()}}),...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([r,s,l])=>a("button",{type:"button",class:`pc-btn${t.propTab===r?" on":""}`,title:s,text:l,onClick:()=>{t.propTab=r,t.propCollapsed=!1,o.repaint()}}))])]);const n=i?t.propTab:"page";return a("div",{class:"property-panel"},[a("div",{class:"prop-head"},[a("span",{class:"prop-title",text:"属性台"}),a("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{t.propCollapsed=!0,o.repaint()}})]),a("div",{class:"pd-tabs prop-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[a("button",{type:"button",class:`pd-tab${n==="element"?" active":""}`,text:"元素属性",onClick:()=>{t.propTab="element",o.repaint()}}),a("button",{type:"button",class:`pd-tab${n==="page"?" active":""}`,text:"页面属性",onClick:()=>{t.propTab="page",o.repaint()}})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="element"?"":{display:"none"}},i?[Hs(o),ll(o,i)]:[a("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="page"?"":{display:"none"}},[dl(o)])])])}const Lo=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],dn={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},pl=[{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()"}],ul=[{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()"}],hl=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],fl=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],ml=[{title:"聚合函数",items:pl},{title:"数值运算",items:ul},{title:"格式化函数",items:hl}],gl="(输入表达式后预览)",bl="(无法计算)",jo="(表达式错误)";function cn(o,e){if(!o.trim())return gl;try{const t={...p.DEFAULT_DEMO_DATA,...e??{},...A.resolveSystemVariables()},i=p.evaluateTemplate(o,t);return i==null?bl:String(i)}catch{return jo}}function pn(o,e){const t=e.trim().toLowerCase();return t?o.filter(i=>i.label.toLowerCase().includes(t)||i.name.toLowerCase().includes(t)):o}function xl(o,e){const t=o.substring(0,e),i=t.lastIndexOf("{"),n=i!==-1&&!t.slice(i+1).includes("}"),r=t.lastIndexOf("("),s=r!==-1&&!t.slice(r+1).includes(")");return{insideBlock:n,insideParens:s}}function vl(o,e){const t=/^\{\s*([^{}]+?)\s*\}$/.exec(o.trim());if(!t)return null;const i=t[1]??"";return e.find(n=>n.fieldKey===i)??null}function Io(o,e){return a("div",{class:"ee-field-info"},[a("span",{class:"ee-item-label",text:o}),a("span",{class:"ee-item-key",text:e})])}function Ve(o){return o.currentTarget.getRootNode()}function Qt(o,e,t){const i=[];return t.forEach((n,r)=>{i.push(n),r<t.length-1&&i.push(a("br"))}),a("div",{class:`ee-help-card ${o}`},[a("div",{class:"ee-help-card-title",text:e}),a("div",{class:"ee-help-card-content"},i)])}function yl(){return a("div",{class:"ee-help-section"},[a("div",{class:"ee-help-title",text:"帮助信息"}),a("div",{class:"ee-help-grid"},[Qt("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),Qt("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Qt("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Qt("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function wl(o,e){const t={activeTab:"field",searchText:"",expression:e.value||"",binding:e.binding},i=(b,w)=>b.querySelector(w),n=b=>{const w=i(b,".ee-preview");if(!w)return;const T=cn(t.expression,o.demoData);w.textContent=T,w.classList.toggle("ee-preview-error",T===jo)},r=()=>{if(t.activeTab==="variable")return pn(fl,t.searchText).map(T=>a("div",{class:"ee-list-item",onDblclick:k=>{const{insideParens:z}=l(k);c(Ve(k),z?T.template.replace(/^\{|\}$/g,""):T.template)}},[Io(T.label,T.template)]));if(t.activeTab==="function")return ml.map(T=>a("div",{class:"ee-func-group"},[a("div",{class:"ee-func-group-title",text:T.title}),...pn(T.items,t.searchText).map(k=>a("div",{class:"ee-list-item",onDblclick:z=>{const{insideBlock:W}=l(z),P=W?k.template:`{${k.template}}`;c(Ve(z),P,P.indexOf("(")+1)}},[Io(k.label,`${k.name}()`)]))]));const b=p.filterGroups(p.groupFields(o.fields??[]),t.searchText);if(!b.length)return[a("p",{class:"pd-empty",text:"暂无字段"})];const w=[];for(const T of b){T.key&&w.push(a("div",{class:`ee-field-group${T.isList?" is-list":""}`},[a("span",{class:"ee-field-group-icon",text:T.isList?"📋":"📁"}),a("span",{text:T.label})]));for(const k of T.fields)w.push(a("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:T.key?"22px":"10px"},onDblclick:z=>{const{insideParens:W}=l(z);c(Ve(z),W?k.fieldKey:`{${k.fieldKey}}`)}},[Io(k.fieldLabel,k.fieldKey)]))}return w},s=b=>{Array.from(b.querySelectorAll(".ee-nav-tab")).forEach((W,P)=>W.classList.toggle("active",Lo[P]?.key===t.activeTab));const T=i(b,".ee-content-search .pd-input");if(T){const W=dn[t.activeTab];T.placeholder!==W&&(T.placeholder=W),T.value!==t.searchText&&(T.value=t.searchText)}const k=i(b,".ee-textarea");k&&k.value!==t.expression&&(k.value=t.expression);const z=i(b,".ee-content-list");if(z){Tn(z);for(const W of r())fe(W,z)}n(b)},l=b=>{const T=i(Ve(b),".ee-textarea")?.selectionStart??t.expression.length;return xl(t.expression,T)},c=(b,w,T=w.length)=>{const k=i(b,".ee-textarea");if(!k){t.expression+=w,n(b);return}const z=k.selectionStart??t.expression.length,W=k.selectionEnd??z;t.expression=t.expression.substring(0,z)+w+t.expression.substring(W);const P=z+T;k.value=t.expression,k.focus(),k.selectionStart=k.selectionEnd=P,n(b)},u=()=>{const b=t.expression;if(t.binding===void 0){o.onApply({formatter:b}),o.onClose();return}const w=vl(b,o.fields??[]);o.onApply(w?{formatter:b,binding:w.fieldKey,title:w.fieldLabel}:{formatter:b}),o.onClose()},h=a("div",{class:"ee-nav"},[a("div",{class:"ee-nav-title",text:"类型"}),a("div",{class:"ee-nav-tabs"},Lo.map((b,w)=>a("div",{class:`ee-nav-tab${t.activeTab===b.key?" active":""}`,text:b.text,onClick:T=>{t.activeTab=Lo[w].key,s(Ve(T))}})))]),m=a("div",{class:"ee-content"},[a("div",{class:"ee-content-search"},[a("input",{class:"pd-input",placeholder:dn[t.activeTab],onInput:b=>{t.searchText=b.target.value,s(Ve(b))}})]),a("div",{class:"ee-content-list"},r())]),g=cn(t.expression,o.demoData),v=a("div",{class:"ee-editor"},[a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"表达式编辑"}),a("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,或直接输入静态内容",text:t.expression,onInput:b=>{t.expression=b.target.value,n(Ve(b))}})]),a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"预览结果"}),a("div",{class:`ee-preview${g===jo?" ee-preview-error":""}`,text:g})]),yl()]);return a("div",{class:"pd-dialog-overlay",onKeydown:b=>{b.key==="Escape"&&o.onClose()}},[a("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[a("header",{class:"pd-dialog-header"},[a("strong",{id:"expression-editor-title",text:"编辑表达式"}),a("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>o.onClose()})]),a("div",{class:"expression-editor"},[h,m,v]),a("footer",{class:"pd-dialog-footer"},[a("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>o.onClose()}),a("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>u()})])])])}const Sl={id:"getting-started",title:"快速入门",content:`
|
|
4
4
|
<h2>界面布局</h2>
|
|
5
5
|
<p>打印模板设计器采用三栏布局:</p>
|
|
6
6
|
<ul>
|
|
@@ -416,6 +416,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
416
416
|
<p><strong>提示</strong>:水印配置保存在模板 JSON 的 <code>watermark</code> 字段中,仅对当前模板生效。</p>
|
|
417
417
|
</blockquote>
|
|
418
418
|
`},Cl={id:"changelog",title:"更新记录",content:`
|
|
419
|
+
<h2>V1.4.1<small>(2026-10-28)</small></h2>
|
|
420
|
+
|
|
421
|
+
<h3>修复</h3>
|
|
422
|
+
<ul>
|
|
423
|
+
<li><strong>条码 / 二维码设计态不再被示例码值遮住</strong>:新增条码/二维码时自带的示例码值此前排在「内容」之前,作者填了 {字段} 内容后画布仍然一直显示示例码。现在先按内容里的 {字段} 用示例数据求值(与表格单元格同口径),取不到值才显示预制示例码。只影响设计器里的展示,出纸不变。</li>
|
|
424
|
+
</ul>
|
|
425
|
+
|
|
419
426
|
<h2>V1.4.0<small>(2026-10-28)</small></h2>
|
|
420
427
|
|
|
421
428
|
<h3>新增</h3>
|