@bireturn/word-editor 1.0.5 → 1.0.6

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.
@@ -1,2 +1,2 @@
1
- (function(G,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-virtual-scroller"),require("lucide-vue-next")):typeof define=="function"&&define.amd?define(["exports","vue","vue-virtual-scroller","lucide-vue-next"],e):(G=typeof globalThis<"u"?globalThis:G||self,e(G.WordEditor={},G.Vue,G.VueVirtualScroller,G.LucideVueNext))})(this,function(G,e,ke,C){"use strict";var io=Object.defineProperty;var ro=(G,e,ke)=>e in G?io(G,e,{enumerable:!0,configurable:!0,writable:!0,value:ke}):G[e]=ke;var O=(G,e,ke)=>ro(G,typeof e!="symbol"?e+"":e,ke);const bt={class:"we-vt-context-menu--option-wrapper modern-menu-wrapper"},_t=["onMouseenter","onMouseleave"],wt=["onClick"],xt={class:"we-vt-context-menu--link-content menu-label"},Et={key:0,class:"we-vt-context-menu--submenu modern-submenu"},Ct=["onClick"],Bt={class:"we-vt-context-menu--link-content submenu-label"},Mt={__name:"ContextMenu",props:{e:{type:Object,default:()=>({})},row:{type:Object,default:()=>({})},menuConfig:{type:Object,default:()=>({body:{}})}},emits:["close","menuClick"],setup(n,{emit:t}){const o=t,a=n,i=e.computed(()=>{var z,F;return{left:`${(z=a.e)==null?void 0:z.pageX}px`,top:`${(F=a.e)==null?void 0:F.pageY}px`}}),c=e.ref([]),y=e.ref(null);let s=null;const m=e.ref(),f=(z,F,u)=>{if(z.children&&z.children.length>0){F&&F.preventDefault()&&F.stopPropagation();return}z.disabled||(u?o("menuClick",{...z,parent:u.code},a.row):o("menuClick",z,a.row)),F&&F.preventDefault()&&F.stopPropagation()},M=z=>{let F=z.target;for(;F&&F!=m.value;)F=F.parentNode;F!=m.value&&o("close")},I=(z,F)=>{z.currentTarget.classList.add("link--active"),s&&(clearTimeout(s),s=null),F.children&&F.children.length>0?y.value=F.code:s=setTimeout(()=>{y.value=null},100)},$=(z,F)=>{z.currentTarget.classList.remove("link--active"),F.children&&F.children.length>0&&(s=setTimeout(()=>{y.value===F.code&&(y.value=null)},300))},_=z=>{s&&(clearTimeout(s),s=null),z.currentTarget.classList.add("link--active")},v=z=>{z.currentTarget.classList.remove("link--active")},J=z=>{const F=z.code||"",u=(z.name||"").toLowerCase(),S={"add-current":C.Navigation,"add-next":C.ArrowDown,"add-child":C.PlusCircle,paste:C.Clipboard,delete:C.Trash2,copy:C.Copy,cut:C.Move,edit:C.Edit,export_part_section:C.Layers,export_part_chapter:C.FileDown,export_full:C.Download,pdf:C.FileText,word:C.Type,excel:C.Grid,txt:C.FileText,view:C.Eye,preview:C.Eye,expand:C.Plus,collapse:C.Minus,"sort-asc":C.SortAsc,"sort-desc":C.SortDesc,filter:C.Filter,search:C.Search,permission:C.ShieldCheck,share:C.Share,lock:C.Lock,unlock:C.Globe,info:C.Info,settings:C.Settings,history:C.History,refresh:C.RotateCcw,save:C.Save,upload:C.Upload,download:C.Download,more:C.MoreHorizontal};return S[F]?S[F]:u.includes("添加")||u.includes("add")?u.includes("当前")||u.includes("current")?C.Navigation:u.includes("下")||u.includes("next")?C.ArrowDown:u.includes("子")||u.includes("child")?C.PlusCircle:C.Plus:u.includes("导出")||u.includes("export")?u.includes("节")||u.includes("section")?C.Layers:u.includes("章")||u.includes("chapter")?C.FileDown:C.Download:u.includes("粘贴")||u.includes("paste")?C.Clipboard:u.includes("删除")||u.includes("delete")?C.Trash2:u.includes("pdf")?C.FileText:u.includes("word")?C.Type:C.MoreHorizontal};return e.onMounted(()=>{var z,F,u,S,H,A,P;(z=a.menuConfig)!=null&&z.visibleMethod&&typeof((F=a.menuConfig)==null?void 0:F.visibleMethod)=="function"&&((H=a.menuConfig)==null||H.visibleMethod({options:(S=(u=a.menuConfig)==null?void 0:u.body)==null?void 0:S.options,row:a.row})),c.value=(((P=(A=a.menuConfig)==null?void 0:A.body)==null?void 0:P.options)||[]).flat(),document.addEventListener("click",M,!0)}),e.onUnmounted(()=>{document.removeEventListener("click",M,!0)}),(z,F)=>(e.openBlock(),e.createElementBlock("div",{class:"we-vt-table--context-menu-wrapper virtual-table-menu modern-virtual-menu",ref_key:"contextMenuRef",ref:m,style:e.normalizeStyle([{display:"inline-block"},i.value])},[e.createElementVNode("ul",bt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,u=>(e.openBlock(),e.createElementBlock("li",{class:e.normalizeClass({"link--disabled":u.disabled,"has-children":u.children&&u.children.length>0,"modern-menu-item":!0}),key:u.code,onMouseenter:S=>I(S,u),onMouseleave:S=>$(S,u)},[e.createElementVNode("a",{class:"we-vt-context-menu--link modern-menu-link",onClick:S=>f(u,S)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(J(u)),{size:16,class:"menu-icon"})),e.createElementVNode("span",xt,e.toDisplayString(u.name),1),u.children&&u.children.length>0?(e.openBlock(),e.createBlock(e.unref(C.ChevronRight),{key:0,size:14,class:"submenu-arrow"})):e.createCommentVNode("",!0)],8,wt),u.children&&u.children.length>0&&y.value===u.code?(e.openBlock(),e.createElementBlock("ul",Et,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.children,S=>(e.openBlock(),e.createElementBlock("li",{key:S.code,class:e.normalizeClass({"link--disabled":S.disabled,"modern-submenu-item":!0}),onMouseenter:_,onMouseleave:v},[e.createElementVNode("a",{class:"we-vt-context-menu--link modern-submenu-link",onClick:H=>f(S,H,u)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(J(S)),{size:14,class:"submenu-icon"})),e.createElementVNode("span",Bt,e.toDisplayString(S.name),1)],8,Ct)],34))),128))])):e.createCommentVNode("",!0)],42,_t))),128))])],4))}},Xe=Symbol("component_container");function St(n,t,o){const a=e.h(n,{...t},o),i=document.createElement("div");return document.body.appendChild(i),a[Xe]=i,e.render(a,i),a.component}function It(n){var o;const t=n.vnode[Xe];e.render(null,t),t!=null&&t.checkVisibility&&(t!=null&&t.checkVisibility())&&((o=document.body)==null||o.removeChild(t))}let Ye;const Ft=n=>{Ye=St(Mt,n,null)},Tt=function(n){const t=n.onClose;return n.onClose=()=>{t&&t.call(),It(Ye)},Ft(n),n};function At(n,t,o){const a=(o==null?void 0:o.keyField)||(o==null?void 0:o.rowField)||"node_id",i=(o==null?void 0:o.parentField)||"parent_id",c=(o==null?void 0:o.parentField)||"order";if(!(n!=null&&n.length))return n;const y={};n.forEach(M=>{const I=M[i];y[I]||(y[I]=[]),y[I].push(M)});function s(M){const I=y[M]||[];I.sort((_,v)=>_[c]&&v[c]?_[c]-v[c]:0);const $=[];return I.forEach(_=>{$.push(_),$.push(...s(_[a]))}),$}let m=[];if(Array.isArray(t))m=t;else{const M=new Set(n.map(_=>_[a])),I=n.filter(_=>!M.has(_[i]));if(I.length===0)throw new Error("无法确定根节点:可能存在循环引用或数据不完整");const $={};I.forEach(_=>{const v=_[i];$[v]=($[v]||0)+1}),m=Object.entries($).map(([_])=>_)}let f=[];return m.forEach(M=>{f=f.concat(s(M))}),f}function Ze(n,t,o){let a;for(;n&&n.nodeType&&n!==document;){if(n.className&&n.className.split&&n.className.split(" ").indexOf(t)>-1)return a=n,a;if(n===o)return null;n=n.parentNode}return a}function Pt(n){return typeof n=="function"||Object.prototype.toString.call(n)==="[object Object]"&&!e.isVNode(n)}const Lt=e.defineComponent({name:"VirtualTable",props:{data:{type:Array,required:!0,default:()=>[]},rowConfig:{type:Object,default:()=>({keyField:"node_id"})},editConfig:{type:Object,default:null},treeConfig:{type:Object,default:null},menuConfig:{type:Object,default:()=>({body:{}})},showHeader:{type:Boolean,default:!0},rowClassName:{type:Function,default:null},pageConfig:{type:Object,default:()=>({enabled:!1,pageHeight:842,pageWidth:595,margin:40,gap:10,showPageHeader:!0,showPageBorder:!1,pageBorderPadding:5,pageBorderStyle:"1px solid #000",headerHeight:0,footerHeight:0,showPageNumber:!0})},pageData:{type:Object,default:null}},emits:["current-change","menu-click","edit-activated","edit-closed","scroll-end","selection-change"],setup(n,{emit:t,slots:o,expose:a}){var kt;const i=e.getCurrentInstance(),c=e.ref(),y=e.ref(!1),s=e.ref(null),m=e.ref(null),f=e.ref([]);let M=new Map;const I=new Map;e.ref(0);const $=e.ref([]);e.ref([]);const _=e.ref(new Set),v=e.ref(new Set),J=e.ref(null),z=2,F=new WeakMap,u=e.ref(null),S=e.ref(""),H=new Set,A=e.computed(()=>{try{return Array.isArray(f.value)?f.value:[]}catch{return[]}}),P=l=>{var p,h,g;if(!l)return 30;if(l.height)return l.height;const r=`${l.content_type}_${((p=l.content)==null?void 0:p.length)||0}_${((h=l.title)==null?void 0:h.length)||0}_${l._editing?1:0}`;if(F.has(l)){const x=F.get(l);if(x.key===r)return x.height}let d=30;switch(l.content_type){case"image":d=150;break;case"table-row":d=l.rowHeight||35;break;case"table":const w=((l.content||"").match(/<tr/g)||[]).length;d=Math.max(100,w*35+30);break;case"flowchart":d=200;break;default:{const k=(l.content||"").length,b=(l.title||"").length,E=k+b,T=((g=(l.content||"").match(/[\u4e00-\u9fa5]/g))==null?void 0:g.length)||0,R=E-T,B=T*12+R*6,L=Math.max(1,Math.ceil(B/760));d=Math.max(20,L*18),l._editing&&(d+=20);break}}return F.set(l,{key:r,height:d}),d},W=e.computed(()=>{if(A.value.length===0)return 30;const l=A.value.slice(0,Math.min(100,A.value.length));if(l.length===0)return 30;const r=l.reduce((p,h)=>p+P(h),0)/l.length,d=Math.max(20,Math.floor(r*.6));return Math.min(d,60)});let Y;const Ge=(l,r)=>{t("menu-click",{menu:l,row:r}),Y==null||Y.onClose(),Y=null},j=l=>{var d,p,h,g,x;if(!((h=(p=(d=n.menuConfig)==null?void 0:d.body)==null?void 0:p.options)!=null&&h.length))return;Y==null||Y.onClose(),Y=null;let r=l.target;for(;r&&(r!=null&&r.getAttribute)&&!(r!=null&&r.getAttribute("data-id"))&&r!==((g=c.value)==null?void 0:g.$el);)r=r.parentNode;if((x=r==null?void 0:r.getAttribute)!=null&&x.call(r,"data-id")){const w=r.getAttribute("data-id"),k=ge(w);k&&(Y=Tt({e:l,row:k,menuConfig:n.menuConfig,onMenuClick:Ge}),l.preventDefault(),l.stopPropagation())}},ie=l=>{var d,p,h;if(!s.value)return;let r=l.target;for(;r&&(r!=null&&r.getAttribute)&&!(r!=null&&r.getAttribute("data-id"))&&r!==((d=c.value)==null?void 0:d.$el);)if(r=r.parentNode,r!=null&&r.classList&&["el-popper","ck-body-wrapper"].some(g=>r.classList.contains(g)))return;((p=r==null?void 0:r.getAttribute)==null?void 0:p.call(r,"data-id"))!=((h=s.value)==null?void 0:h.node_id)&&(s.value._editing=!1,t("edit-closed",{row:s.value,column:{},$table:i==null?void 0:i.exposed}),s.value=null)};((kt=n.editConfig)==null?void 0:kt.trigger)==="dblclick"&&e.watch(()=>s.value,l=>{document.removeEventListener("click",ie,!0),l&&setTimeout(()=>{document.addEventListener("click",ie,!0)},200)});const ce=l=>JSON.stringify(l.map(r=>{var d;return{id:r[n.rowConfig.keyField],content:((d=r.content)==null?void 0:d.length)||0,type:r.content_type,editing:r._editing}})),de=()=>{if(!n.pageConfig.enabled){$.value=[{items:f.value,startIndex:0,endIndex:f.value.length}];return}if(n.pageData&&Object.keys(n.pageData).length){const l=[],r=n.rowConfig.keyField||"node_id",d=new Map;f.value.forEach(h=>{d.set(String(h[r]),h)}),Object.keys(n.pageData).sort((h,g)=>parseInt(h)-parseInt(g)).forEach(h=>{const g=n.pageData[h],x=[];g.forEach(w=>{const k=d.get(String(w));k&&x.push(k)}),x.length>0&&l.push({items:x,pageNumber:parseInt(h),height:x.reduce((w,k)=>w+P(k),0)})}),$.value=l}else{const{pageHeight:l,margin:r,headerHeight:d=0,footerHeight:p=0}=n.pageConfig,g=Math.max(100,l-r*2-d-p-20),x=[];let w=[],k=0,b=0,E=1;f.value.forEach((T,R)=>{const B=P(T);(T.layer||0)<=2&&w.length>0?(x.push({items:[...w],startIndex:b,endIndex:R,height:k,pageNumber:E++}),w=[T],k=B,b=R):k+B>g&&w.length>0?(x.push({items:[...w],startIndex:b,endIndex:R,height:k,pageNumber:E++}),w=[T],k=Math.min(B,g),b=R):(w.push(T),k+=B)}),w.length>0&&x.push({items:w,startIndex:b,endIndex:f.value.length,height:k,pageNumber:E}),$.value=x}},Te=()=>{try{const l=Array.isArray(n.data)?n.data:[],r=ce(l);if(!(r!==S.value)&&f.value.length>0)return;S.value=r;const p=(n.treeConfig?At(l,void 0,n.treeConfig):l).map((g,x)=>{const w=g[n.rowConfig.keyField],k=I.get(w);if(!k||k.content!==g.content||k.content_type!==g.content_type){H.add(w);const b={...g,index:x,_editing:g._editing||!1,_original:(k==null?void 0:k._original)||{...g}};return I.set(w,b),b}return k.index=x,k});f.value=p,de();const h=new Set(p.map(g=>g[n.rowConfig.keyField]));for(const[g]of I)h.has(g)||(I.delete(g),H.delete(g))}catch{f.value=[],$.value=[],I.clear(),H.clear()}};e.watch(()=>n.data,(l,r)=>{try{if(!Array.isArray(l))return;e.nextTick(()=>{if(Te(),n.pageConfig.enabled){v.value.clear(),_.value.clear();for(let d=0;d<Math.min(3,$.value.length);d++)v.value.add(d);e.nextTick(()=>{ee()})}})}catch{}},{deep:!1,immediate:!1}),e.watch(()=>n.pageData,()=>{if(n.pageConfig.enabled){de(),v.value.clear(),_.value.clear();for(let l=0;l<Math.min(3,$.value.length);l++)v.value.add(l);e.nextTick(()=>{ee()})}},{deep:!0}),e.watch(()=>n.pageConfig,()=>{if(n.pageConfig.enabled){de(),v.value.clear(),_.value.clear();for(let l=0;l<Math.min(3,$.value.length);l++)v.value.add(l);e.nextTick(()=>{ee()})}},{deep:!0}),e.watch(m,()=>t("current-change",{row:m.value}));let me=null;const Q=()=>{window.ResizeObserver&&(me=new ResizeObserver(l=>{var r,d;for(const p of l){const h=(r=p.target.dataset)==null?void 0:r.id;if(!h)continue;const g=ge(h);if(!g)continue;const x=p.contentRect.height,w=((d=F.get(g))==null?void 0:d.height)||0;if(Math.abs(w-x)>5){const k=F.get(g)||{};F.set(g,{...k,height:x}),requestAnimationFrame(()=>{var E;const b=p.target.__vueParentComponent;(E=b==null?void 0:b.proxy)!=null&&E.updateSize&&b.proxy.updateSize()})}}}),e.nextTick(()=>{var d;const l=(d=c.value)==null?void 0:d.$el;if(!l)return;l.querySelectorAll("[data-id]").forEach(p=>{p.dataset.id&&me.observe(p)})}))},le=()=>{u.value&&(u.value.disconnect(),u.value=null),me&&(me.disconnect(),me=null)},ee=()=>{n.pageConfig.enabled&&(J.value&&J.value.disconnect(),J.value=new IntersectionObserver(l=>{l.forEach(r=>{const d=parseInt(r.target.dataset.pageIndex);if(r.isIntersecting){_.value.add(d);for(let p=Math.max(0,d-z);p<=Math.min($.value.length-1,d+z);p++)v.value.add(p)}else _.value.delete(d),setTimeout(()=>{_.value.has(d)||Array.from(_.value).some(h=>Math.abs(h-d)<=z*2)||v.value.delete(d)},3e3)})},{root:null,rootMargin:"100px",threshold:.01}),e.nextTick(()=>{const l=document.querySelector(".a4-pages-container");l&&l.querySelectorAll(".a4-page-placeholder").forEach(d=>{J.value.observe(d)})}))};e.onMounted(()=>{Te(),e.nextTick(()=>{var l;if(Q(),fe.setup(),ee(),((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&(document.addEventListener("selectionchange",ft),document.addEventListener("mouseup",ut)),n.pageConfig.enabled)for(let r=0;r<Math.min(3,$.value.length);r++)v.value.add(r)}),y.value=!0}),e.onUnmounted(()=>{var l;le(),fe.cleanup(),J.value&&(J.value.disconnect(),J.value=null),((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&(document.removeEventListener("selectionchange",ft),document.removeEventListener("mouseup",ut)),ye&&clearTimeout(ye),M=new Map,I.clear(),v.value.clear(),_.value.clear()});const fe={handlers:new Map,setup(){e.nextTick(()=>{var r;const l=(r=c.value)==null?void 0:r.$el;l&&(l.addEventListener("click",this.handleClick.bind(this),{passive:!0}),l.addEventListener("dblclick",this.handleDblClick.bind(this),{passive:!0}))})},handleClick(l){const r=l.target.closest("[data-id]");if(!r)return;const d=r.dataset.id,p=ge(d);p&&He(p)},handleDblClick(l){var h;if(!((h=n.editConfig)!=null&&h.trigger)==="dblclick")return;const r=l.target.closest("[data-id]");if(!r)return;const d=r.dataset.id,p=ge(d);p&&Ae(p)},cleanup(){var r,d;const l=(d=(r=c.value)==null?void 0:r.$el)==null?void 0:d.querySelector(".virtual-table-wrapper");l&&(l.removeEventListener("click",this.handleClick),l.removeEventListener("dblclick",this.handleDblClick))}},ne=l=>{He(l)},q=l=>Ae(l);let ue=null,be;const se=({row:l,column:r},d,p)=>{var x,w;const h=p||d.target,g=Ze(h,"virtual-table-cell",(x=c.value)==null?void 0:x.$el);ue===g&&be&&(clearTimeout(be),ue=null),((w=s.value)==null?void 0:w[n.rowConfig.keyField])!=(l==null?void 0:l[n.rowConfig.keyField])&&setTimeout(()=>{var b,E;s.value=l;let k=(b=h==null?void 0:h.getAttribute)==null?void 0:b.call(h,"field");if(!k){try{const T=document.getSelection();let R=T==null?void 0:T.anchorNode;R&&R.nodeType===3&&(R=R.parentElement);const B=(E=R==null?void 0:R.closest)==null?void 0:E.call(R,"[field]");B&&(k=B.getAttribute("field"))}catch{}if(!k&&(d!=null&&d.composedPath)){for(const T of d.composedPath())if(T!=null&&T.getAttribute&&T.getAttribute("field")){k=T.getAttribute("field");break}}}t("edit-activated",{row:l,column:{...r,field:k},$table:i==null?void 0:i.exposed})},200)},he=({row:l,column:r},d,p)=>{var g;const h=p||d.target;ue=Ze(h,"virtual-table-cell",(g=c.value)==null?void 0:g.$el),be&&clearTimeout(be),be=setTimeout(()=>{var k,b,E,T,R;const x=l.content_type;let w=(k=h==null?void 0:h.getAttribute)==null?void 0:k.call(h,"field");if(!w){try{const B=document.getSelection();let L=B==null?void 0:B.anchorNode;L&&L.nodeType===3&&(L=L.parentElement);const U=(b=L==null?void 0:L.closest)==null?void 0:b.call(L,"[field]");U&&(w=U.getAttribute("field"))}catch{}if(!w&&(d!=null&&d.composedPath)){for(const B of d.composedPath())if(B!=null&&B.getAttribute&&B.getAttribute("field")){w=B.getAttribute("field");break}}}if(x!=="table"){if(x==="text"){let B=null,L=null;if((E=h==null?void 0:h.getAttribute)!=null&&E.call(h,"field")?B=h:(T=h==null?void 0:h.closest)!=null&&T.call(h,"[field]")&&(B=h.closest("[field]")),B&&(L=B.textContent),w&&L!==void 0&&L!==null){L=L.trim();const U=((R=l[w])==null?void 0:R.trim())||"";L!==U&&(l[w]=L)}}}t("edit-closed",{row:l,column:{...r,field:w},$table:i==null?void 0:i.exposed})},50)};let D=null,ye=null;const Ee=l=>{var r;((r=n.editConfig)==null?void 0:r.trigger)==="contenteditable"&&ht("focusin",l)},De=l=>{var r,d,p,h,g;if(((r=n.editConfig)==null?void 0:r.trigger)==="contenteditable")if(D!=null&&D.cellEl){let x=D.fieldEl;!x&&D.field&&(x=(p=(d=D.cellEl)==null?void 0:d.querySelector)==null?void 0:p.call(d,`[field="${D.field}"]`)),x||(x=((g=(h=D.cellEl).querySelector)==null?void 0:g.call(h,"[field]"))||D.cellEl),he(D,{target:x},x),D=null}else ht("focusout",l)},ht=(l,r)=>{var d,p,h,g,x,w;try{const k=document.getSelection();let b=k==null?void 0:k.anchorNode;b&&b.nodeType===3&&(b=b.parentElement);const E=(d=b==null?void 0:b.closest)==null?void 0:d.call(b,".virtual-table-cell"),T=(p=b==null?void 0:b.closest)==null?void 0:p.call(b,".virtual-table-row");if(!E||!T)return;const R=T.getAttribute("data-id"),B=E.getAttribute("data-prop"),L=ge(R),U=Ce.value.find(Z=>`${Z.prop}`==`${B}`)||{},V=((h=b==null?void 0:b.closest)==null?void 0:h.call(b,"[field]"))||null,N=((g=V==null?void 0:V.getAttribute)==null?void 0:g.call(V,"field"))||void 0;l==="focusin"?(D={row:L,column:U,cellEl:E,rowEl:T,fieldEl:V,field:N},se({row:L,column:U},r,V||((x=b==null?void 0:b.closest)==null?void 0:x.call(b,"[field]")))):he({row:L,column:U},r,V||((w=b==null?void 0:b.closest)==null?void 0:w.call(b,"[field]")))}catch{}},ft=()=>{var l;((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&(ye&&clearTimeout(ye),ye=setTimeout(()=>{var r,d,p,h,g,x,w,k,b,E,T,R,B,L;try{const U=document.getSelection();if(U.rangeCount===0)return;const V=U.getRangeAt(0);let N=V.startContainer;N.nodeType===3&&(N=N.parentElement);const Z=(r=N==null?void 0:N.closest)==null?void 0:r.call(N,".virtual-table-cell"),X=(d=N==null?void 0:N.closest)==null?void 0:d.call(N,".virtual-table-row");if(!Z||!X)return;const Be=X.getAttribute("data-id"),Me=Z.getAttribute("data-prop"),ae=ge(Be),te=Ce.value.find(K=>`${K.prop}`==`${Me}`)||{};if(!D||((p=D.row)==null?void 0:p[n.rowConfig.keyField])!==(ae==null?void 0:ae[n.rowConfig.keyField])||((h=D.column)==null?void 0:h.prop)!==(te==null?void 0:te.prop)){if(D){let K=D.fieldEl;!K&&D.field&&(K=(x=(g=D.cellEl)==null?void 0:g.querySelector)==null?void 0:x.call(g,`[field="${D.field}"]`)),K||(K=((k=(w=D.cellEl)==null?void 0:w.querySelector)==null?void 0:k.call(w,"[field]"))||D.cellEl),he(D,{target:K},K)}D={row:ae,column:te,cellEl:Z,rowEl:X,fieldEl:((b=N==null?void 0:N.closest)==null?void 0:b.call(N,"[field]"))||null,field:((R=(T=((E=N==null?void 0:N.closest)==null?void 0:E.call(N,"[field]"))||null)==null?void 0:T.getAttribute)==null?void 0:R.call(T,"field"))||void 0},se({row:ae,column:te},{target:Z},Z)}if(U.toString()){const K=V.endContainer.nodeType===3?V.endContainer.parentElement:V.endContainer,_e=(B=K==null?void 0:K.closest)==null?void 0:B.call(K,".virtual-table-cell"),ve=(L=K==null?void 0:K.closest)==null?void 0:L.call(K,".virtual-table-row")}}catch{}},50))},ut=()=>{var l;((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&setTimeout(()=>{var p,h,g,x;const r=document.getSelection();if(!r)return;const d=r.toString();if(d){const w=r.rangeCount>0?r.getRangeAt(0):null;let k=null,b=null;try{if(w){let E=w.startContainer;(E==null?void 0:E.nodeType)===3&&(E=E.parentElement);const T=(p=E==null?void 0:E.closest)==null?void 0:p.call(E,".virtual-table-cell"),R=(h=E==null?void 0:E.closest)==null?void 0:h.call(E,".virtual-table-row");k=T&&R?{rowId:R.getAttribute("data-id"),prop:T.getAttribute("data-prop")}:null;let B=w.endContainer;(B==null?void 0:B.nodeType)===3&&(B=B.parentElement);const L=(g=B==null?void 0:B.closest)==null?void 0:g.call(B,".virtual-table-cell"),U=(x=B==null?void 0:B.closest)==null?void 0:x.call(B,".virtual-table-row");b=L&&U?{rowId:U.getAttribute("data-id"),prop:L.getAttribute("data-prop")}:null}}catch{}t("selection-change",{text:d,selection:r,range:w,start:k,end:b})}},10)},Vn=l=>(l==null?void 0:l._editing)===!0,vn=l=>l!=null&&l.parent_id?M.get(l.parent_id):null,jn=l=>{var d;const r=f.value.findIndex(p=>p[n.rowConfig.keyField]==l[n.rowConfig.keyField]);return r<1?null:((d=f.value[r-1])==null?void 0:d.layer)===l.layer?f.value[r-1]:null},Kn=l=>{const r=f.value.findIndex(d=>d[n.rowConfig.keyField]==l[n.rowConfig.keyField]);return r>=f.value.length-1?null:f.value[r+1]},ge=l=>{if(!l)return null;let r=I.get(l);return r||(typeof l=="number"?I.get(`${l}`):typeof l=="string"&&/^\d+$/.test(l)?I.get(Number(l)):null)};let Re=null;const qn=l=>{Re&&cancelAnimationFrame(Re),Re=requestAnimationFrame(()=>{var p;const r=n.rowConfig.keyField,d=l[r];if(n.pageConfig.enabled){let h=-1;for(let g=0;g<$.value.length;g++)if($.value[g].items.some(k=>k[r]===d)){h=g;break}if(h!==-1){for(let g=Math.max(0,h-1);g<=Math.min($.value.length-1,h+1);g++)v.value.has(g)||v.value.add(g);e.nextTick(()=>{const g=document.querySelector(".a4-pages-container");if(!g)return;const x=(w=0)=>{const k=g.querySelector(`[data-id="${d}"]`);if(k){let b=0,E=k;for(;E&&E!==g;)b+=E.offsetTop,E=E.offsetParent;const T=g.clientHeight;let R=b-T*.3;R=Math.max(0,R);const B=g.scrollTop,L=Math.abs(R-B),U=V=>{const N=g.scrollTop,Z=V-N,X=Math.min(800,Math.max(300,L*.5)),Be=performance.now(),Me=te=>te<.5?4*te*te*te:1-Math.pow(-2*te+2,3)/2,ae=te=>{const Pe=te-Be,K=Math.min(Pe/X,1),_e=Me(K),ve=N+Z*_e;g.scrollTop=ve,K<1?requestAnimationFrame(ae):setTimeout(()=>{g.scrollTop=V},50)};requestAnimationFrame(ae)};L>3e3?g.scrollTo({top:R,behavior:"instant"}):U(R),k.classList.add("row--highlight"),setTimeout(()=>{k.classList.remove("row--highlight")},1500)}else w<10&&setTimeout(()=>x(w+1),150)};setTimeout(x,200)})}}else{const h=f.value.findIndex(g=>g[r]===d);h!==-1&&((p=c.value)!=null&&p.scrollToItem)&&c.value.scrollToItem(h)}Re=null})},He=l=>{if(l){if(!y.value){setTimeout(()=>He(l),200);return}m.value=l,m.value!==s.value&&s.value&&(s.value._editing=!1,setTimeout(()=>{s.value=null},200))}},Ae=(l,r)=>new Promise(d=>{var p,h;if(!((p=n==null?void 0:n.editConfig)!=null&&p.beforeEditMethod&&typeof((h=n==null?void 0:n.editConfig)==null?void 0:h.beforeEditMethod)=="function"&&!n.editConfig.beforeEditMethod({row:l}))){if(!l||!y.value){setTimeout(()=>Ae(l),200);return}l!==s.value&&(f.value.forEach(g=>{g._editing&&t("edit-closed",{row:g,column:{field:r},$table:i==null?void 0:i.exposed}),g._editing=!1}),l._editing=!0,setTimeout(()=>{s.value=l,t("edit-activated",{row:l,column:{field:r},$table:i==null?void 0:i.exposed}),d(!0)}))}}),Un=l=>Ae(l),Je=()=>{if(de(),n.pageConfig.enabled){const l=Array.from(_.value);if(l.length>0){const r=Math.min(...l);for(let d=Math.max(0,r-1);d<=Math.min($.value.length-1,r+2);d++)v.value.add(d)}else for(let r=0;r<Math.min(3,$.value.length);r++)v.value.add(r);e.nextTick(()=>{ee()})}e.nextTick(()=>{!n.pageConfig.enabled&&c.value&&c.value.$forceUpdate&&c.value.$forceUpdate()})},Wn=(l,r)=>new Promise(d=>{let p=-1;if(r==-1){const h=ge(l.parent_id);for(p=f.value.findIndex(g=>g[n.rowConfig.keyField]==h[n.rowConfig.keyField])+1;f.value[p].parent_id==h[n.rowConfig.keyField];)p+=1}else p=f.value.findIndex(h=>h[n.rowConfig.keyField]==r[n.rowConfig.keyField]);M.set(l.node_id,l),I.set(l[n.rowConfig.keyField],l),f.value.splice(p,0,l),Je(),d({row:l})}),Gn=(l,r)=>new Promise(d=>{const p=f.value.findIndex(h=>h[n.rowConfig.keyField]==r[n.rowConfig.keyField])+1;M.set(l.node_id,l),I.set(l[n.rowConfig.keyField],l),f.value.splice(p,0,l),Je(),d({row:l})}),gt=l=>{const r=f.value.findIndex(d=>d[n.rowConfig.keyField]==l[n.rowConfig.keyField]||d===l);if(r>-1){const d=l[n.rowConfig.keyField];M.delete(l.node_id),I.delete(d),f.value.splice(r,1),Je()}},Jn=(l,r)=>{if(!l||!l[n.rowConfig.keyField])return!1;const d=l._original;return d?r?l[r]!==d[r]:Object.keys(d).some(p=>d[p]!==l[p]):!1},Xn=l=>l&&l[n.rowConfig.keyField]&&!l._original,Yn=(l,r)=>{l&&l[n.rowConfig.keyField]&&(r&&Object.assign(l,r),l._original={...l,_editing:void 0,_X_ROW_CHILD:void 0,_original:void 0})},Zn=l=>{if(l&&l[n.rowConfig.keyField]){const r=ge(l[n.rowConfig.keyField]);r._original?Object.assign(r,r._original):gt(r)}},Qn=()=>{},eo=()=>{m.value={}},pt=l=>{var d,p,h;let r=f.value.findIndex(g=>g[n.rowConfig.keyField]==l[n.rowConfig.keyField]);if(r>-1&&n.treeConfig){const g=((d=n.treeConfig)==null?void 0:d.keyField)||((p=n.treeConfig)==null?void 0:p.rowField)||"node_id",x=((h=n.treeConfig)==null?void 0:h.parentField)||"parent_id",w=[],k=new Map;k.set(l[g],!0);for(let b=r+1;b<f.value.length;b++){const E=f.value[b];if(E&&k.has(E[x]))w.push(E),k.set(E[g]);else break}return w}return[]};a({isEditByRow:Vn,getParentRow:vn,getSiblingRow:jn,getNextRow:Kn,getRowById:ge,scrollToRow:qn,setCurrentRow:He,setEditRow:Ae,setEditCell:Un,insertAt:Wn,insertNextAt:Gn,isUpdateByRow:Jn,isInsertByRow:Xn,reloadRow:Yn,revertData:Zn,remove:gt,setAllTreeExpand:Qn,clearCurrentRow:eo,getAllChilds:pt});const Ce=e.computed(()=>o.default().filter(l=>{var r;return((r=l.type)==null?void 0:r.name)==="VirtualTableColumn"}).map(l=>{var r,d,p;return{prop:(r=l.props)==null?void 0:r.prop,title:(d=l.props)==null?void 0:d.title,width:(p=l.props)==null?void 0:p.width,slots:l.children}})),Oe=l=>{try{return l===0?{width:"0px"}:l?{flex:/^\d+$/.test(l)?`0 0 ${l}px`:`0 0 ${l}`}:{flex:"1 1 100%"}}catch(r){return console.warn("[VirtualTable] computeColumnWidth error:",r),{flex:"1 1 100%"}}},mt=e.computed(()=>{var l;return(l=n.treeConfig)!=null&&l.childCurrent&&m.value?pt(m.value).map(r=>r[n.rowConfig.keyField]):[]}),yt=e.ref({viewStartIndex:0,viewEndIndex:0,visibleStartIndex:0,visibleEndIndex:0});let Ne=null,Ve=null;const to=(l,r)=>{Ne&&cancelAnimationFrame(Ne),Ne=requestAnimationFrame(()=>{t("scroll-end",{...yt.value}),Ne=null})},no=(l,r,d,p)=>{Ve&&cancelAnimationFrame(Ve),Ve=requestAnimationFrame(()=>{yt.value={viewStartIndex:l,viewEndIndex:r,visibleStartIndex:d,visibleEndIndex:p},Ve=null})},oo=(l,r)=>{var L,U;const{pageHeight:d,margin:p,showPageBorder:h,pageBorderPadding:g,pageBorderStyle:x,showPageHeader:w,headerHeight:k=0,footerHeight:b=0,showPageNumber:E}=n.pageConfig,T=l.pageNumber||r+1,B=Math.max(100,d-p*2-k-b-20);return v.value.has(r)?e.createVNode(e.Fragment,null,[w!==!1&&(o["page-header"]||k>0)?e.createVNode("div",{class:"a4-page-header",style:{minHeight:`${Math.max(k,1)}px`}},[(L=o["page-header"])==null?void 0:L.call(o,{pageNumber:T,pageIndex:r,totalPages:$.value.length})]):null,r===0&&n.showHeader?e.createVNode("div",{class:"a4-table-header"},[e.createVNode("div",{class:"virtual-table-header we-vt-table--header we-vt-table--header-wrapper"},[Ce.value.map(V=>{var N,Z,X;return e.createVNode("div",{class:"we-vt-header--column",key:V.prop,style:Oe(V.width)},[e.createVNode("div",{class:"we-vt-cell"},[(N=V.slots)!=null&&N.header?(X=(Z=V.slots)==null?void 0:Z.header)==null?void 0:X.call(Z,{column:V}):V.title])])})])]):null,e.createVNode("div",{class:"a4-page-content",style:{minHeight:`${B}px`,...h?{border:x,padding:`${g}px`}:{}}},[l.items.map(V=>{var N,Z;return e.createVNode("div",{key:V[n.rowConfig.keyField],"data-id":V[n.rowConfig.keyField],class:{"virtual-table-row":!0,"we-vt-body--row":!0,"row--current":V[n.rowConfig.keyField]===((N=m.value)==null?void 0:N[n.rowConfig.keyField])||((Z=n.treeConfig)==null?void 0:Z.childCurrent)&&mt.value.includes(V[n.rowConfig.keyField])},style:{width:"100%"},onClick:()=>ne(V),onDblclick:()=>q(V)},[Ce.value.map(X=>{var Be,Me,ae,te,Pe,K,_e;return e.createVNode("div",{key:X.prop,class:"virtual-table-cell we-vt-cell",style:Oe(X.width),"data-prop":X.prop},[V._editing&&((Be=n.editConfig)==null?void 0:Be.trigger)==="dblclick"?((Me=X.slots)==null?void 0:Me.edit)&&((te=(ae=X.slots)==null?void 0:ae.edit)==null?void 0:te.call(ae,{row:V,column:X})):((Pe=X.slots)==null?void 0:Pe.default)&&((_e=(K=X.slots)==null?void 0:K.default)==null?void 0:_e.call(K,{row:V,column:X}))])})])})]),o["page-footer"]?(U=o["page-footer"])==null?void 0:U.call(o,{pageNumber:T,pageIndex:r,totalPages:$.value.length}):e.createVNode("div",{class:"a4-page-footer",contenteditable:"false",style:{height:`${Math.max(b||0,20)}px`}},[E!==!1?e.createVNode("span",{class:"page-number",contenteditable:"false"},[T,e.createTextVNode(" / "),$.value.length]):null])]):e.createVNode("div",{class:"a4-page-loading"},[e.createVNode("div",{class:"loading-spinner"},null),e.createVNode("div",{class:"loading-text"},[e.createTextVNode("加载中...")])])},lo=()=>{var x;const{pageHeight:l,pageWidth:r,margin:d,gap:p,showPageBorder:h,pageBorderPadding:g}=n.pageConfig;return e.createVNode("div",{class:"virtual-table we-vt-table we-vt-table--render-default border--none"},[e.createVNode("div",{class:"a4-pages-container",contenteditable:((x=n.editConfig)==null?void 0:x.trigger)==="contenteditable"?"true":void 0,onContextmenu:j,onFocusin:Ee,onFocusout:De},[$.value.map((w,k)=>{const b=v.value.has(k);return e.createVNode("div",{key:`page-${k}`,class:b?"a4-page":"a4-page-placeholder","data-page-index":k,style:{width:`${r}px`,minHeight:`${l}px`,marginBottom:`${p}px`,padding:b?`${h?d-g:d}px`:"0",boxSizing:"border-box",position:"relative"}},[oo(w,k)])})])])},ao=()=>{var l;return e.createVNode("div",{class:"virtual-table we-vt-table we-vt-table--render-default border--none"},[n.showHeader?e.createVNode("div",{class:"virtual-table-header we-vt-table--header we-vt-table--header-wrapper"},[Ce.value.map(r=>{var d,p,h;return e.createVNode("div",{class:"we-vt-header--column",key:r.prop,style:Oe(r.width)},[e.createVNode("div",{class:"we-vt-cell"},[(d=r.slots)!=null&&d.header?(h=(p=r.slots)==null?void 0:p.header)==null?void 0:h.call(p,{column:r}):r.title]),e.createVNode("div",{class:"we-vt-resizable is--line"},null)])})]):void 0,e.createVNode(ke.DynamicScroller,{ref:c,items:A.value,minItemSize:W.value,keyField:n.rowConfig.keyField,emitUpdate:!1,buffer:300,class:"virtual-table-wrapper",contenteditable:((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"?"true":void 0,onContextmenu:j,onScrollend:to,onUpdate:no,onFocusin:Ee,onFocusout:De},{default:({item:r,index:d,active:p})=>{var g,x,w;let h;return e.createVNode(ke.DynamicScrollerItem,{key:r[n.rowConfig.keyField],item:r,active:p,sizeDependencies:[(g=r.content)==null?void 0:g.length,r._editing,r.content_type],"data-id":r[n.rowConfig.keyField],"data-index":d,"data-active":p,class:{"virtual-table-row":!0,"we-vt-body--row":!0,"row--current":r[n.rowConfig.keyField]===((x=m.value)==null?void 0:x[n.rowConfig.keyField])||((w=n.treeConfig)==null?void 0:w.childCurrent)&&mt.value.includes(r[n.rowConfig.keyField])}},Pt(h=Ce.value.map(k=>{var b,E,T,R,B,L,U;return e.createVNode("div",{key:k.prop,class:"virtual-table-cell we-vt-cell",style:Oe(k.width),"data-prop":k.prop},[r._editing&&((b=n.editConfig)==null?void 0:b.trigger)==="dblclick"?((E=k.slots)==null?void 0:E.edit)&&((R=(T=k.slots)==null?void 0:T.edit)==null?void 0:R.call(T,{row:r,column:k})):((B=k.slots)==null?void 0:B.default)&&((U=(L=k.slots)==null?void 0:L.default)==null?void 0:U.call(L,{row:r,column:k}))])}))?h:{default:()=>[h]})}})])};return()=>n.pageConfig.enabled?lo():ao()}}),we=(n,t)=>{const o=n.__vccOpts||n;for(const[a,i]of t)o[a]=i;return o},$t=we(Lt,[["__scopeId","data-v-3756d9b0"]]),zt={name:"VirtualTableColumn",props:{prop:String,label:String,width:[String,Number]}};function Dt(n,t,o,a,i,c){return e.renderSlot(n.$slots,"default")}const Rt=we(zt,[["render",Dt]]),Ht={class:"catalog-node"},Ot=["title"],Nt={class:"catalog-node__text"},Vt={key:0,class:"catalog-node__children"},vt=we({__name:"CatalogNode",props:{item:{type:Object,required:!0},depth:{type:Number,default:0},activeId:{type:String,default:""}},emits:["navigate"],setup(n,{emit:t}){const o=n,a=t,i=e.ref(!0),c=e.computed(()=>o.item.children&&o.item.children.length>0);function y(s){s.stopPropagation(),i.value=!i.value}return(s,m)=>{const f=e.resolveComponent("CatalogNode",!0);return e.openBlock(),e.createElementBlock("div",Ht,[e.createElementVNode("div",{class:e.normalizeClass(["catalog-node__label",{"is-active":n.activeId===n.item.nodeId}]),style:e.normalizeStyle({paddingLeft:10+n.depth*14+"px"}),title:n.item.name,onClick:m[0]||(m[0]=M=>a("navigate",n.item))},[e.createElementVNode("span",{class:"catalog-node__toggle",onClick:y},[c.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.value?e.unref(C.ChevronDown):e.unref(C.ChevronRight)),{key:0,size:14})):e.createCommentVNode("",!0)]),e.createElementVNode("span",Nt,e.toDisplayString(n.item.name||"(无标题)"),1)],14,Ot),c.value&&i.value?(e.openBlock(),e.createElementBlock("div",Vt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.item.children,M=>(e.openBlock(),e.createBlock(f,{key:M.nodeId,item:M,depth:n.depth+1,"active-id":n.activeId,onNavigate:m[1]||(m[1]=I=>a("navigate",I))},null,8,["item","depth","active-id"]))),128))])):e.createCommentVNode("",!0)])}}},[["__scopeId","data-v-ac882917"]]),jt={key:0,class:"catalog catalog--collapsed"},Kt={key:1,class:"catalog"},qt={class:"catalog__header"},Ut={class:"catalog__title"},Wt={class:"catalog__body"},Gt={key:0,class:"catalog__empty"},Jt=we({__name:"index",props:{items:{type:Array,default:()=>[]}},emits:["navigate"],setup(n,{emit:t}){const o=t,a=e.ref(!1),i=e.ref("");function c(y){i.value=y.nodeId,o("navigate",y)}return(y,s)=>a.value?(e.openBlock(),e.createElementBlock("div",jt,[e.createElementVNode("button",{class:"catalog__icon-btn",title:"展开目录",onClick:s[0]||(s[0]=m=>a.value=!1)},[e.createVNode(e.unref(C.PanelLeftOpen),{size:18})])])):(e.openBlock(),e.createElementBlock("div",Kt,[e.createElementVNode("div",qt,[e.createElementVNode("span",Ut,[e.createVNode(e.unref(C.ListTree),{size:16}),s[2]||(s[2]=e.createTextVNode(" 目录 ",-1))]),e.createElementVNode("button",{class:"catalog__icon-btn",title:"收起目录",onClick:s[1]||(s[1]=m=>a.value=!0)},[e.createVNode(e.unref(C.PanelLeftClose),{size:18})])]),e.createElementVNode("div",Wt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.items,m=>(e.openBlock(),e.createBlock(vt,{key:m.nodeId,item:m,"active-id":i.value,onNavigate:c},null,8,["item","active-id"]))),128)),n.items.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Gt," 暂无目录 "))])]))}},[["__scopeId","data-v-8becafa1"]]),Xt={first:1,second:2,third:3,fourth:4,fifth:5,sixth:6};function Yt(n){return n.blockType!=="title"||!n.level?0:Xt[n.level]||1}function Zt(n){const t=[];for(const i of n||[]){const c=Yt(i);c&&t.push({id:i.node_id,nodeId:i.node_id,name:(i.content||"").trim(),level:c,children:[]})}if(!t.length)return[];const o=(i,c)=>{const y=c.children[c.children.length-1];y&&i.level>y.level?o(i,y):c.children.push(i)},a=[];for(const i of t){const c=a[a.length-1];c&&i.level>c.level?o(i,c):a.push(i)}return a}const Qt={first:0,second:1,third:2,fourth:3,fifth:4,sixth:5,seventh:6,eighth:7};function Le(n,t){let o="",a=n;const i=t?65:97;for(;a>0;){const c=(a-1)%26;o=String.fromCharCode(i+c)+o,a=Math.floor((a-1)/26)}return o}const Qe=[n=>n.toString(),n=>Le(n,!0),n=>`(${n})`,n=>`(${Le(n,!1)})`,n=>`${n})`,n=>`${Le(n,!1)})`,n=>`<${n}>`,n=>`<${Le(n,!1)}>`];function en(){const n=new Array(8).fill(0);return{next(t,o){const a=Qt[t];if(a==null)return"";n[a]++;for(let c=a+1;c<n.length;c++)n[c]=0;if(o!=null&&o!=="")return`${o} `;const i=Qe[Math.min(a,Qe.length-1)];return`${i(n[a])}. `}}}const Se=14,et=760,tt=756,tn={left:"left",center:"center",right:"right",alignment:"justify",justify:"justify"};function nt(n){const t=[];let o=!1;const a=i=>{if(o){if(i&&i.value!=null&&/^[\n200B]+$/.test(i.value)){t.push(i);return}o=!1,t.push({...i,_coverBreakBefore:!0})}else t.push(i)};for(const i of n||[]){if(i&&i.type==="pageBreak"){o=!0;continue}if(i&&i.type==="area"){const c=nt(i.valueList||[]),y=(i.areaId||"").includes("cover");for(const s of c)a(s);y&&(o=!0)}else a(i)}return t}function Ie(n){const t=nt(n),o=[];let a=[],i=0,c=null;const y=m=>{a.length&&(o.push({type:"paragraph",elements:[...a],rowFlex:m}),a=[])},s=()=>{if(i===0)return;const m=c;y(m);for(let f=1;f<i;f++)o.push({type:"paragraph",elements:[],rowFlex:m});i=0,c=null};for(const m of t||[])if(m.type==="table")s(),y(),o.push({type:"table",el:m});else if(m.type==="title")s(),y(),o.push({type:"title",el:m});else if(m.type==="list"){s(),y();const f=[];let M=[];for(const I of m.valueList||[])I.value===`
2
- `||I.value==="​"?(f.push([...M]),M=[]):M.push(I);(M.length||f.length===0)&&f.push([...M]),o.push({type:"list",listType:m.listType||"ul",listStyle:m.listStyle||"disc",items:f})}else if(m.listId){s(),y();const f=m.value==="​"||m.value===""?[]:[m];o.push({type:"list",listType:m.listType||"ul",listStyle:m.listStyle||"disc",items:[f]})}else m.value!=null&&/^[\n200B]+$/.test(m.value)?(i+=m.value.length,m.rowFlex&&(c=m.rowFlex)):(s(),a.push(m));return s(),y(),o}function xe(n){const t=n.filter(f=>f.type==="image").reduce((f,M)=>f+(M.height||M.width||0),0),o=n.filter(f=>f.type!=="image").map(f=>f.value||"").join("");if(!o)return t||20;const a=n.reduce((f,M)=>Math.max(f,M.size||0),0)||14,i=a+6,c=(o.match(/[一-龥]/g)||[]).length,y=o.length-c,s=c*a+y*(a*.5),m=Math.max(1,Math.ceil(s/et));return t+Math.max(i,m*i)}function nn(n){if(!n||!n.length)return[[]];const t=[];let o=[];for(const a of n)a.type==="image"&&(a.width||0)>=et?(o.length&&(t.push(o),o=[]),t.push([a])):o.push(a);return o.length&&t.push(o),t.length?t:[[]]}function ot(n){if(n.length===0)return[];const t=new Array(n.length).fill(0);n.forEach((c,y)=>{(c.tdList||[]).forEach(s=>{const m=s.rowspan||1;if(m>1){const f=Math.min(y+m-1,n.length-1);t[y]=Math.max(t[y],f);for(let M=1;M<m&&y+M<n.length;M++)t[y+M]=Math.max(t[y+M],f)}})});const o=[];let a=0,i=0;for(let c=0;c<n.length;c++)i=Math.max(i,t[c]),i<=c&&(o.push(n.slice(a,c+1)),a=c+1,i=0);return a<n.length&&o.push(n.slice(a)),o}function je(n){const t=(n==null?void 0:n.width)||0;return!t||t<=tt?1:tt/t}function lt(n){var c,y;const t=n.elements||[],o=((c=t.find(s=>s.rowFlex))==null?void 0:c.rowFlex)||n.rowFlex,a={textAlign:tn[o]||"left"},i=(y=t.find(s=>s.rowMargin))==null?void 0:y.rowMargin;return i&&(a.lineHeight=i),a}function on(n){var c;const t=Ie(n.value);let o=0,a=0,i=!1;for(const y of t)if(y.type==="paragraph"){if(!y.elements.length)continue;o++;for(const s of y.elements)(s.type==="image"||s.type==="table")&&(i=!0),a+=(s.value||"").length}else y.type==="list"?(o+=((c=y.items)==null?void 0:c.length)||1,i=!0):(o++,i=!0);return o>1||a>30||i?"top":n.verticalAlign||"middle"}function oe(n){const t={};n.font&&(t.fontFamily=n.font),t.fontSize=(n.size||Se)+"px",n.bold!=null&&(t.fontWeight=n.bold?"bold":"normal"),n.italic!=null&&(t.fontStyle=n.italic?"italic":"normal"),n.color&&(t.color=n.color),n.highlight&&n.highlight!=="rgb(255, 255, 255)"&&n.highlight!=="#ffffff"&&(t.backgroundColor=n.highlight);const o=[n.underline&&"underline",n.strikeout&&"line-through"].filter(Boolean).join(" ");return o&&(t.textDecoration=o),n.letterSpacing&&(t.letterSpacing=n.letterSpacing+"px"),t}const ln=5;function at(n,t=!1){var a,i;let o=0;for(const c of n)if(c.type==="table"){const y=((a=c.el)==null?void 0:a.trList)||[];o+=y.reduce((s,m)=>s+(m.height||m.minHeight||35),0)}else if(c.type==="title")o+=xe(c.titleValueList||((i=c.el)==null?void 0:i.valueList)||[]);else if(c.type==="paragraph")o+=xe(c.elements||[]);else if(c.type==="list"){const y=Math.round(18),s=(c.items||[]).reduce((m,f)=>m+(f.length?xe(f):y),0);o+=Math.max(s,y)}return o+(t&&o>0?ln:0)}const an={key:0,class:"empty-line"},rn=["href"],sn=["src"],cn=["checked"],dn=["checked"],hn={key:4,class:"ctrl-input"},fn=["checked"],un=["checked"],gn={key:0},pn=["colspan","rowspan"],mn={key:0},yn=["src"],kn=["href"],bn=["checked"],_n=["checked"],wn=["checked"],Ke=we({__name:"DocBlock",props:{block:{type:Object,required:!0},isHeaderFooter:{type:Boolean,default:!1}},setup(n){const t=n,o=e.inject("bindTableObserver",null),a=e.computed(()=>t.isHeaderFooter?0:t.block.indentPx??0);return(i,c)=>{var y;return n.block.blockType==="title"?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["doc-title",`doc-title--${n.block.level}`]),style:e.normalizeStyle({paddingLeft:a.value?a.value+"px":void 0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.titleValueList||[],(s,m)=>(e.openBlock(),e.createElementBlock("span",{key:m,style:e.normalizeStyle(e.unref(oe)(s))},e.toDisplayString(s.value),5))),128))],6)):n.block.blockType==="paragraph"?(e.openBlock(),e.createElementBlock("p",{key:1,class:"doc-para",style:e.normalizeStyle({...e.unref(lt)(n.block),paddingLeft:a.value?a.value+"px":void 0})},[n.block.elements.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",an," ")),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.elements,(s,m)=>{var f,M,I,$,_,v,J,z,F,u,S,H,A;return e.openBlock(),e.createElementBlock(e.Fragment,{key:m},[!s.type||s.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(oe)(s))},e.toDisplayString(s.value),5)):s.type==="hyperlink"?(e.openBlock(),e.createElementBlock("a",{key:1,href:s.url,class:"doc-link",target:"_blank",rel:"noopener"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.valueList||[],(P,W)=>(e.openBlock(),e.createElementBlock("span",{key:W,style:e.normalizeStyle(e.unref(oe)(P))},e.toDisplayString(P.value),5))),128))],8,rn)):s.type==="image"?(e.openBlock(),e.createElementBlock("img",{key:2,src:s.value,class:"doc-image",style:e.normalizeStyle({width:s.width?s.width+"px":"auto",height:s.height?s.height+"px":"auto"})},null,12,sn)):s.type==="control"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[((f=s.control)==null?void 0:f.type)==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({fontSize:(s.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.control.value||[],(P,W)=>(e.openBlock(),e.createElementBlock("span",{key:W,style:e.normalizeStyle(e.unref(oe)(P))},e.toDisplayString(P.value),5))),128))],4)):((M=s.control)==null?void 0:M.type)==="input"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"ctrl-input",style:e.normalizeStyle({minWidth:(s.control.minWidth||60)+"px",fontSize:(s.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.control.value||[],(P,W)=>(e.openBlock(),e.createElementBlock("span",{key:W},e.toDisplayString(P.value),1))),128))],4)):((I=s.control)==null?void 0:I.type)==="radio"?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((_=($=s.control.extension)==null?void 0:$.elementAttributes)==null?void 0:_.layout)==="vertical"}]),style:e.normalizeStyle({fontSize:(s.control.size||e.unref(Se))+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.control.valueSets||[],(P,W)=>(e.openBlock(),e.createElementBlock("label",{key:W,class:"ctrl-option"},[e.createElementVNode("input",{type:"radio",disabled:"",checked:s.control.code===P.code},null,8,cn),e.createTextVNode(" "+e.toDisplayString(P.value),1)]))),128))],6)):((v=s.control)==null?void 0:v.type)==="checkbox"?(e.openBlock(),e.createElementBlock("span",{key:3,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((z=(J=s.control.extension)==null?void 0:J.elementAttributes)==null?void 0:z.layout)==="vertical"}]),style:e.normalizeStyle({fontSize:(s.control.size||e.unref(Se))+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.control.valueSets||[],(P,W)=>(e.openBlock(),e.createElementBlock("label",{key:W,class:"ctrl-option"},[e.createElementVNode("input",{type:"checkbox",disabled:"",checked:(s.control.code||"").split(",").includes(P.code)},null,8,dn),e.createTextVNode(" "+e.toDisplayString(P.value),1)]))),128))],6)):((F=s.control)==null?void 0:F.type)==="select"?(e.openBlock(),e.createElementBlock("span",hn,e.toDisplayString(((S=(u=s.control.value)==null?void 0:u[0])==null?void 0:S.value)||s.control.placeholder||""),1)):e.createCommentVNode("",!0)],64)):s.type==="checkbox"?(e.openBlock(),e.createElementBlock("input",{key:4,type:"checkbox",checked:!!((H=s.checkbox)!=null&&H.value),disabled:"",class:"el-check"},null,8,fn)):s.type==="radio"?(e.openBlock(),e.createElementBlock("input",{key:5,type:"radio",checked:!!((A=s.radio)!=null&&A.value),disabled:"",class:"el-check"},null,8,un)):s.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:6,style:e.normalizeStyle(e.unref(oe)(s))},e.toDisplayString(s.value),5)):s.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:7,style:e.normalizeStyle(e.unref(oe)(s))},e.toDisplayString(s.value),5)):s.type==="tab"?(e.openBlock(),e.createElementBlock("span",{key:8,class:"doc-tab",style:e.normalizeStyle({width:(s.size||e.unref(Se))+"px"})},null,4)):e.createCommentVNode("",!0)],64)}),128))],4)):n.block.blockType==="list"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.block.listType==="ol"?"ol":"ul"),{key:2,class:"doc-list",style:e.normalizeStyle({listStyleType:n.block.listStyle==="decimal"?"decimal":n.block.listStyle==="lower-alpha"?"lower-alpha":"disc",paddingLeft:a.value?a.value+24+"px":void 0})},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.items,(s,m)=>(e.openBlock(),e.createElementBlock("li",{key:m,class:"doc-list-item"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s,(f,M)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:M},[!f.type||f.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(oe)(f))},e.toDisplayString(f.value),5)):f.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:1,style:e.normalizeStyle(e.unref(oe)(f))},e.toDisplayString(f.value),5)):f.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:2,style:e.normalizeStyle(e.unref(oe)(f))},e.toDisplayString(f.value),5)):e.createCommentVNode("",!0)],64))),128))]))),128))]),_:1},8,["style"])):n.block.blockType==="table-row-group"?(e.openBlock(),e.createElementBlock("div",{key:3,class:e.normalizeClass(["doc-table-row-wrap",{"is-first":n.block.isFirst,"is-last":n.block.isLast,"is-page-break":n.block.isPageBreak}]),style:e.normalizeStyle({display:n.block.tableRowFlex?"flex":void 0,justifyContent:n.block.tableRowFlex==="right"?"flex-end":n.block.tableRowFlex==="center"?"center":n.block.tableRowFlex==="left"?"flex-start":void 0,paddingLeft:a.value?a.value+"px":void 0})},[e.createElementVNode("div",{style:e.normalizeStyle({overflow:n.block.sliceHeight!=null?"hidden":void 0,height:n.block.sliceHeight!=null?(n.block.isLast?n.block.sliceHeight+1:n.block.sliceHeight)+"px":void 0,width:n.block.tableEl.width?"max-content":"100%"})},[e.createElementVNode("table",{ref:n.block._baseKey&&e.unref(o)?s=>e.unref(o)(s,n.block._baseKey):void 0,class:e.normalizeClass(["doc-table",{"doc-table--no-border":n.block.tableEl.borderType==="empty"}]),style:e.normalizeStyle({width:n.block.tableEl.width?n.block.tableEl.width*e.unref(je)(n.block.tableEl)+"px":"100%",transform:n.block.sliceOffset?`translateY(-${n.block.sliceOffset}px)`:void 0})},[(y=n.block.tableEl.colgroup)!=null&&y.length?(e.openBlock(),e.createElementBlock("colgroup",gn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.tableEl.colgroup,(s,m)=>(e.openBlock(),e.createElementBlock("col",{key:m,style:e.normalizeStyle({width:s.width*e.unref(je)(n.block.tableEl)+"px"})},null,4))),128))])):e.createCommentVNode("",!0),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.trGroup,(s,m)=>(e.openBlock(),e.createElementBlock("tr",{key:m,style:e.normalizeStyle({height:(s.height||s.minHeight||30)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.tdList||[],(f,M)=>(e.openBlock(),e.createElementBlock("td",{key:M,colspan:f.colspan||1,rowspan:f.rowspan||1,style:e.normalizeStyle({backgroundColor:f.backgroundColor||void 0,verticalAlign:e.unref(on)(f),width:f.width?f.width*e.unref(je)(n.block.tableEl)+"px":void 0,height:f.height?f.height+"px":void 0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Ie)(f.value),(I,$)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:$},[I.type==="paragraph"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"cell-para",style:e.normalizeStyle(e.unref(lt)(I))},[I.elements.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",mn," ")),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.elements,(_,v)=>{var J,z,F,u,S,H,A;return e.openBlock(),e.createElementBlock(e.Fragment,{key:v},[!_.type||_.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(oe)(_))},e.toDisplayString(_.value),5)):_.type==="image"?(e.openBlock(),e.createElementBlock("img",{key:1,src:_.value,class:"doc-image",style:e.normalizeStyle({width:_.width?_.width+"px":"auto",height:_.height?_.height+"px":"auto"})},null,12,yn)):_.type==="hyperlink"?(e.openBlock(),e.createElementBlock("a",{key:2,href:_.url,class:"doc-link",target:"_blank"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.valueList||[],(P,W)=>(e.openBlock(),e.createElementBlock("span",{key:W,style:e.normalizeStyle(e.unref(oe)(P))},e.toDisplayString(P.value),5))),128))],8,kn)):_.type==="control"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[((J=_.control)==null?void 0:J.type)==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({fontSize:(_.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.control.value||[],(P,W)=>(e.openBlock(),e.createElementBlock("span",{key:W,style:e.normalizeStyle(e.unref(oe)(P))},e.toDisplayString(P.value),5))),128))],4)):((z=_.control)==null?void 0:z.type)==="input"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"ctrl-input",style:e.normalizeStyle({fontSize:(_.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.control.value||[],(P,W)=>(e.openBlock(),e.createElementBlock("span",{key:W},e.toDisplayString(P.value),1))),128))],4)):((F=_.control)==null?void 0:F.type)==="radio"?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((S=(u=_.control.extension)==null?void 0:u.elementAttributes)==null?void 0:S.layout)==="vertical"}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.control.valueSets||[],(P,W)=>(e.openBlock(),e.createElementBlock("label",{key:W,class:"ctrl-option"},[e.createElementVNode("input",{type:"radio",disabled:"",checked:_.control.code===P.code},null,8,bn),e.createTextVNode(e.toDisplayString(P.value),1)]))),128))],2)):e.createCommentVNode("",!0)],64)):_.type==="checkbox"?(e.openBlock(),e.createElementBlock("input",{key:4,type:"checkbox",checked:!!((H=_.checkbox)!=null&&H.value),disabled:"",class:"el-check"},null,8,_n)):_.type==="radio"?(e.openBlock(),e.createElementBlock("input",{key:5,type:"radio",checked:!!((A=_.radio)!=null&&A.value),disabled:"",class:"el-check"},null,8,wn)):_.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:6,style:e.normalizeStyle(e.unref(oe)(_))},e.toDisplayString(_.value),5)):_.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:7,style:e.normalizeStyle(e.unref(oe)(_))},e.toDisplayString(_.value),5)):_.type==="tab"?(e.openBlock(),e.createElementBlock("span",{key:8,class:"doc-tab",style:e.normalizeStyle({width:(_.size||e.unref(Se))+"px"})},null,4)):e.createCommentVNode("",!0)],64)}),128))],4)):e.createCommentVNode("",!0)],64))),128))],12,pn))),128))],4))),128))])],6)],4)],6)):e.createCommentVNode("",!0)}}},[["__scopeId","data-v-27e51e18"]]),xn={class:"editor-layout word-editor-scope"},En={class:"editor-container"},Cn={key:0,class:"editor-loading"},Bn={class:"doc-header"},Mn={class:"doc-footer"},Sn={class:"doc-page-number"},In=1123,Fn=50,Tn=20,An=we({__name:"index",props:{data:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1}},setup(n){const t=n,o=e.computed(()=>{const u=t.data;return u?!Array.isArray(u)&&u.main?u.main:Array.isArray(u)?u:[]:[]}),a=e.ref(null),i=e.ref({});let c=null;e.onMounted(()=>{c=new ResizeObserver(u=>{const S={};for(const H of u){const A=H.target._rowKey;if(!A)continue;const P=Math.round(H.contentRect.height);P>(i.value[A]||0)&&(S[A]=P)}Object.keys(S).length&&(i.value={...i.value,...S})})}),e.onUnmounted(()=>{c==null||c.disconnect(),c=null});function y(u,S){!u||!c||(u._rowKey=S,c.observe(u))}e.provide("bindTableObserver",y);const s=e.computed(()=>Math.max(100,In-Fn*2-I.value-$.value-Tn)),m=e.computed(()=>{const u=Ie(o.value),S=[],H=s.value;let A=0;const P=en(),W={first:0,second:1,third:2,fourth:3,fifth:4,sixth:5,seventh:6,eighth:7};let Y=-1;const Ge=j=>{var ie,ce,de;return!!((ie=j.el)!=null&&ie._coverBreakBefore||(de=(ce=j.elements)==null?void 0:ce[0])!=null&&de._coverBreakBefore)};return u.forEach((j,ie)=>{var de,Te,me;const ce=Ge(j);if(ce&&(A=0),j.type==="title"){const re=j.el.valueList||[],Q=P.next(j.el.level,(de=j.el.extension)==null?void 0:de.startIndex),le=re.some(q=>{var ue;return(ue=q.extension)==null?void 0:ue.isIndex});let ee=re;if(!le&&Q){const q=re[0]||{};ee=[{value:Q,size:q.size,bold:q.bold,italic:q.italic,color:q.color,font:q.font,extension:{isIndex:!0}},...re]}const fe=ee.map(q=>q.value||"").join(""),ne=xe(ee);A=A+ne>H&&A>0?ne:A+ne,Y=W[j.el.level]??0,S.push({node_id:`blk_${ie}_0`,layer:ce?1:100,blockType:"title",level:j.el.level,titleEl:j.el,titleValueList:ee,content_type:"text",content:fe,height:ne,indentPx:Y*20})}else if(j.type==="paragraph"){const re=nn(j.elements),Q=Y>=0?(Y+1)*20:0;re.forEach((le,ee)=>{const fe=le.map(q=>q.value||"").join(""),ne=xe(le);A=A+ne>H&&A>0?ne:A+ne,S.push({node_id:`blk_${ie}_${ee}`,layer:ce&&ee===0?1:100,blockType:"paragraph",elements:le,rowFlex:j.rowFlex,content_type:"text",content:fe,height:ne,indentPx:Q})})}else if(j.type==="table"){const re=!!((Te=j.el.extension)!=null&&Te.isTitleTable),Q=((me=j.el.extension)==null?void 0:me.elementType)==="signOff",le=re||Q?0:Y>=0?(Y+1)*20:0,ee=ot(j.el.trList||[]),fe=ee.length;ee.forEach((ne,q)=>{const ue=`blk_${ie}_${q}`,be=ne.reduce((he,D)=>he+(D.height||D.minHeight||35),0),se=Math.max(be,i.value[ue]||0);if(se>H){const he=Math.ceil(se/H);for(let D=0;D<he;D++){const ye=D*H,Ee=Math.min(H,se-ye),De=D>0||A>0;A=Ee,S.push({node_id:`blk_${ie}_${q}_s${D}`,layer:ce&&q===0&&D===0?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:se,trGroup:ne,tableEl:j.el,tableRowFlex:j.el.rowFlex||null,isFirst:q===0&&D===0,isLast:q===fe-1&&D===he-1,isPageBreak:De,sliceOffset:ye,sliceHeight:Ee,_baseKey:D===0?ue:void 0,height:Ee,indentPx:le})}}else{const he=q>0&&A+se>H;A=A+se>H?se:A+se,S.push({node_id:`blk_${ie}_${q}`,layer:ce&&q===0?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:se,trGroup:ne,tableEl:j.el,tableRowFlex:j.el.rowFlex||null,isFirst:q===0,isLast:q===fe-1,isPageBreak:he,indentPx:le})}})}else if(j.type==="list"){const re=Math.round(18);let Q=0;for(const le of j.items)Q+=le.length?xe(le):re;Q=Math.max(Q,re),A=A+Q>H&&A>0?Q:A+Q,S.push({node_id:`blk_${ie}_0`,layer:ce?1:100,blockType:"list",listType:j.listType,listStyle:j.listStyle,items:j.items,height:Q,indentPx:Y>=0?(Y+1)*20:0})}}),S}),f=e.computed(()=>{var S;const u=(S=t.data)==null?void 0:S.header;return u!=null&&u.length?Ie(u):[]}),M=e.computed(()=>{var S;const u=(S=t.data)==null?void 0:S.footer;return u!=null&&u.length?Ie(u):[]}),I=e.computed(()=>at(f.value,!0)),$=e.computed(()=>at(M.value,!0)),_=e.computed(()=>f.value.length>0),v=e.computed(()=>M.value.length>0);function J(u){var S,H,A,P;return{blockType:u.type,elements:u.elements,rowFlex:u.rowFlex,level:(S=u.el)==null?void 0:S.level,titleValueList:((H=u.el)==null?void 0:H.titleValueList)||u.titleValueList||((A=u.el)==null?void 0:A.valueList),listType:u.listType,listStyle:u.listStyle,items:u.items,indentPx:0,trGroup:(P=u.el)!=null&&P.trList?ot(u.el.trList).flat():void 0,tableEl:u.el,isFirst:!0,isLast:!0}}const z=e.computed(()=>Zt(m.value));function F(u){var S;(S=a.value)==null||S.scrollToRow({node_id:u.nodeId})}return(u,S)=>(e.openBlock(),e.createElementBlock("div",xn,[e.createVNode(Jt,{items:z.value,onNavigate:F},null,8,["items"]),e.createElementVNode("div",En,[n.loading?(e.openBlock(),e.createElementBlock("div",Cn," 加载中… ")):(e.openBlock(),e.createBlock(e.unref($t),{key:1,ref_key:"virtualTableRef",ref:a,"show-header":!1,"row-config":{keyField:"node_id"},"page-config":{enabled:!0,pageHeight:1123,pageWidth:860,margin:50,gap:16,showPageHeader:_.value,showPageBorder:!0,pageBorderPadding:5,pageBorderStyle:"1px solid #333",headerHeight:I.value,footerHeight:$.value,showPageNumber:!0},data:m.value},e.createSlots({default:e.withCtx(()=>[e.createVNode(e.unref(Rt),null,{default:e.withCtx(({row:H})=>[e.createVNode(Ke,{block:H},null,8,["block"])]),_:1})]),_:2},[_.value?{name:"page-header",fn:e.withCtx(()=>[e.createElementVNode("div",Bn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(H,A)=>(e.openBlock(),e.createBlock(Ke,{key:A,block:J(H),"is-header-footer":!0},null,8,["block"]))),128))])]),key:"0"}:void 0,v.value?{name:"page-footer",fn:e.withCtx(({pageNumber:H,totalPages:A})=>[e.createElementVNode("div",Mn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,(P,W)=>(e.openBlock(),e.createBlock(Ke,{key:W,block:J(P),"is-header-footer":!0},null,8,["block"]))),128)),e.createElementVNode("div",Sn,e.toDisplayString(H)+" / "+e.toDisplayString(A),1)])]),key:"1"}:void 0]),1032,["page-config","data"]))])]))}},[["__scopeId","data-v-f3f51b5c"]]),it="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function $e(n=10){const t=crypto.getRandomValues(new Uint8Array(n));return Array.from(t).map(o=>it[o%it.length]).join("")}class ze{constructor(t){O(this,"data");this.data=e.reactive({id:$e(),version:1,sections:[this.createEmptySection()],pageWidth:595,pageHeight:842,marginTop:72,marginBottom:72,marginLeft:90,marginRight:90,...t})}createEmptySection(){return{id:$e(),paragraphs:[this.createEmptyParagraph()]}}createEmptyParagraph(t){return{id:$e(),type:"paragraph",format:t??{},children:[]}}createTextElement(t,o){return{id:$e(),type:"text",value:t,format:o??{}}}getSectionCount(){return this.data.sections.length}getParagraphCount(t=0){var o;return((o=this.data.sections[t])==null?void 0:o.paragraphs.length)??0}getAllParagraphs(){const t=[];return this.data.sections.forEach((o,a)=>{o.paragraphs.forEach((i,c)=>{t.push({paragraph:i,sectionIndex:a,paragraphIndex:c})})}),t}getParagraphAt(t,o){var a;return((a=this.data.sections[t])==null?void 0:a.paragraphs[o])??null}getElementAt(t){const o=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);return(o==null?void 0:o.children[t.elementIndex])??null}insertText(t,o,a){const i=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);if(!i)return;const c=i.children[t.elementIndex];if(c&&c.type==="text")c.value=c.value.slice(0,t.offset)+o+c.value.slice(t.offset);else{const y=this.createTextElement(o,a);i.children.splice(t.elementIndex,0,y)}this.bumpVersion()}deleteAt(t,o){const a=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);if(!a)return;const i=a.children[t.elementIndex];!i||i.type!=="text"||(i.value=i.value.slice(0,t.offset)+i.value.slice(t.offset+o),i.value===""&&a.children.splice(t.elementIndex,1),this.bumpVersion())}insertParagraph(t,o,a){const i=this.data.sections[t];if(!i)throw new Error(`Section ${t} not found`);const c=this.createEmptyParagraph(a);return i.paragraphs.splice(o+1,0,c),this.bumpVersion(),c}mergeParagraphs(t,o){const a=this.data.sections[t];if(!a)return;const i=a.paragraphs[o],c=a.paragraphs[o+1];!i||!c||(i.children.push(...c.children),a.paragraphs.splice(o+1,1),this.bumpVersion())}updateParagraphFormat(t,o,a){const i=this.getParagraphAt(t,o);i&&(i.format={...i.format,...a},this.bumpVersion())}updateElementFormat(t,o){const a=this.getElementAt(t);a&&(a.format={...a.format,...o},this.bumpVersion())}updateRangeFormat(t,o,a){const i=this.getAllParagraphs();let c=!1;for(const{paragraph:y,sectionIndex:s,paragraphIndex:m}of i){const f=s===t.sectionIndex&&m===t.paragraphIndex,M=s===o.sectionIndex&&m===o.paragraphIndex;if(f&&(c=!0),c)for(let I=0;I<y.children.length;I++){const $=y.children[I];if(!(f&&I<t.elementIndex)){if(M&&I>o.elementIndex)break;$.format={...$.format,...a}}}if(M)break}this.bumpVersion()}bumpVersion(){this.data.version++}toJSON(){return JSON.stringify(this.data,null,2)}static fromJSON(t){const o=JSON.parse(t),a=new ze;return Object.assign(a.data,o),a}}function pe(n=0,t=0,o=0,a=0){return{sectionIndex:n,paragraphIndex:t,elementIndex:o,offset:a}}function rt(n,t){return n.sectionIndex===t.sectionIndex&&n.paragraphIndex===t.paragraphIndex&&n.elementIndex===t.elementIndex&&n.offset===t.offset}class qe{constructor(t){O(this,"_selection",e.reactive({anchor:pe(),focus:pe(),isCollapsed:!0}));O(this,"_docModel");O(this,"hasSelection",e.computed(()=>!this._selection.isCollapsed));this._docModel=t}get selection(){return this._selection}setCursor(t){this._selection.anchor={...t},this._selection.focus={...t},this._selection.isCollapsed=!0}setSelection(t,o){this._selection.anchor={...t},this._selection.focus={...o},this._selection.isCollapsed=rt(t,o)}collapse(t=!0){t?this._selection.anchor={...this._selection.focus}:this._selection.focus={...this._selection.anchor},this._selection.isCollapsed=!0}selectAll(){const t=this._docModel.data.sections,o=t[t.length-1],a=o==null?void 0:o.paragraphs[o.paragraphs.length-1],i=a==null?void 0:a.children[a.children.length-1],c=(i==null?void 0:i.type)==="text"?i.value.length:0;this._selection.anchor=pe(0,0,0,0),this._selection.focus=pe(t.length-1,((o==null?void 0:o.paragraphs.length)??1)-1,((a==null?void 0:a.children.length)??0)===0?0:((a==null?void 0:a.children.length)??1)-1,c),this._selection.isCollapsed=!1}moveForward(t=!1){const o=this._selection.focus,a=this._docModel.getParagraphAt(o.sectionIndex,o.paragraphIndex);if(!a)return;const i=a.children[o.elementIndex];if((i==null?void 0:i.type)==="text"&&o.offset<i.value.length){const y={...o,offset:o.offset+1};this._applyMove(y,t);return}if(o.elementIndex<a.children.length-1){const y={...o,elementIndex:o.elementIndex+1,offset:0};this._applyMove(y,t);return}const c=this._getNextParagraphPoint(o);c&&this._applyMove(c,t)}moveBackward(t=!1){const o=this._selection.focus;if(o.offset>0){const i={...o,offset:o.offset-1};this._applyMove(i,t);return}if(o.elementIndex>0){const i=this._docModel.getParagraphAt(o.sectionIndex,o.paragraphIndex),c=i==null?void 0:i.children[o.elementIndex-1],y=(c==null?void 0:c.type)==="text"?c.value.length:0,s={...o,elementIndex:o.elementIndex-1,offset:y};this._applyMove(s,t);return}const a=this._getPrevParagraphPoint(o);a&&this._applyMove(a,t)}_applyMove(t,o){o?(this._selection.focus=t,this._selection.isCollapsed=rt(this._selection.anchor,t)):(this._selection.anchor={...t},this._selection.focus={...t},this._selection.isCollapsed=!0)}_getNextParagraphPoint(t){const o=this._docModel.data.sections[t.sectionIndex];return o?t.paragraphIndex<o.paragraphs.length-1?pe(t.sectionIndex,t.paragraphIndex+1,0,0):t.sectionIndex<this._docModel.data.sections.length-1?pe(t.sectionIndex+1,0,0,0):null:null}_getPrevParagraphPoint(t){if(t.paragraphIndex>0){const o=this._docModel.getParagraphAt(t.sectionIndex,t.paragraphIndex-1);if(!o)return null;const a=o.children.length-1,i=o.children[a],c=(i==null?void 0:i.type)==="text"?i.value.length:0;return pe(t.sectionIndex,t.paragraphIndex-1,Math.max(a,0),c)}if(t.sectionIndex>0){const o=this._docModel.data.sections[t.sectionIndex-1];if(!o)return null;const a=o.paragraphs.length-1,i=o.paragraphs[a],c=((i==null?void 0:i.children.length)??0)-1,y=i==null?void 0:i.children[c],s=(y==null?void 0:y.type)==="text"?y.value.length:0;return pe(t.sectionIndex-1,a,Math.max(c,0),s)}return null}static domToModelPoint(t,o){let a=t instanceof Element?t:t.parentElement;for(;a;){const i=a.getAttribute("data-si"),c=a.getAttribute("data-pi"),y=a.getAttribute("data-ei");if(i!==null&&c!==null&&y!==null)return{sectionIndex:parseInt(i),paragraphIndex:parseInt(c),elementIndex:parseInt(y),offset:o};a=a.parentElement}return null}}const Pn=200;class Ln{constructor(){O(this,"_undoStack",[]);O(this,"_redoStack",[])}get canUndo(){return this._undoStack.length>0}get canRedo(){return this._redoStack.length>0}push(t){var a,i;this._redoStack=[];const o=this._undoStack[this._undoStack.length-1];if(o&&((a=t.canMergeWith)!=null&&a.call(t,o))){(i=o.merge)==null||i.call(o,t);return}this._undoStack.push(t),this._undoStack.length>Pn&&this._undoStack.shift()}undo(){const t=this._undoStack.pop();return t?(t.undo(),this._redoStack.push(t),!0):!1}redo(){const t=this._redoStack.pop();return t?(t.execute(),this._undoStack.push(t),!0):!1}clear(){this._undoStack=[],this._redoStack=[]}}class $n{constructor(t,o,a,i,c){O(this,"name","insertText");O(this,"_point");O(this,"_text");O(this,"_format");this.docModel=t,this.selectionManager=o,this._point={...a},this._text=i,this._format=c}execute(){this.docModel.insertText(this._point,this._text,this._format),this.selectionManager.setCursor({...this._point,offset:this._point.offset+this._text.length})}undo(){this.docModel.deleteAt(this._point,this._text.length),this.selectionManager.setCursor(this._point)}canMergeWith(t){if(t.name!=="insertText")return!1;const o=t;return o._point.sectionIndex===this._point.sectionIndex&&o._point.paragraphIndex===this._point.paragraphIndex&&o._point.elementIndex===this._point.elementIndex&&o._point.offset===this._point.offset+this._text.length}merge(t){const o=t;this._text+=o._text}}class zn{constructor(t,o){O(this,"name","insertParagraph");O(this,"_insertedParagraphId",null);this.docModel=t,this.selectionManager=o}execute(){var m,f;const{focus:t}=this.selectionManager.selection,{sectionIndex:o,paragraphIndex:a}=t,i=this.docModel.getParagraphAt(o,a);if(!i)return;const c=t.elementIndex,y=i.children.splice(c),s=this.docModel.createEmptyParagraph(i.format);s.children.push(...y),this._insertedParagraphId=s.id,this.docModel.data.sections[o].paragraphs.splice(a+1,0,s),(f=(m=this.docModel).bumpVersion)==null||f.call(m),this.selectionManager.setCursor({sectionIndex:o,paragraphIndex:a+1,elementIndex:0,offset:0})}undo(){const{focus:t}=this.selectionManager.selection,{sectionIndex:o,paragraphIndex:a}=t;a!==0&&(this.docModel.mergeParagraphs(o,a-1),this.selectionManager.setCursor({sectionIndex:o,paragraphIndex:a-1,elementIndex:0,offset:0}))}}class st{constructor(t,o,a){O(this,"name");O(this,"_deletedText","");this.docModel=t,this.selectionManager=o,this.name=a==="backward"?"deleteBackward":"deleteForward"}execute(){const{focus:t,isCollapsed:o}=this.selectionManager.selection;if(o)if(this.name==="deleteBackward")if(t.offset>0){const a={...t,offset:t.offset-1},i=this.docModel.getElementAt(t);(i==null?void 0:i.type)==="text"&&(this._deletedText=i.value[t.offset-1]??""),this.docModel.deleteAt(a,1),this.selectionManager.setCursor(a)}else(t.paragraphIndex>0||t.elementIndex>0)&&(this.docModel.mergeParagraphs(t.sectionIndex,t.paragraphIndex-1),this.selectionManager.setCursor({...t,paragraphIndex:t.paragraphIndex-1}));else{const a=this.docModel.getElementAt(t);if((a==null?void 0:a.type)==="text"&&t.offset<a.value.length)this._deletedText=a.value[t.offset],this.docModel.deleteAt(t,1);else{const i=this.docModel.data.sections[t.sectionIndex];i&&t.paragraphIndex<i.paragraphs.length-1&&this.docModel.mergeParagraphs(t.sectionIndex,t.paragraphIndex)}}}undo(){if(this._deletedText){const{focus:t}=this.selectionManager.selection;this.docModel.insertText(t,this._deletedText)}}}class Fe{constructor(t,o,a,i){O(this,"name");O(this,"_prevFormat",{});this.docModel=t,this.selectionManager=o,this._value=i,this.name=a}execute(){const{anchor:t,focus:o}=this.selectionManager.selection,a=this._getFormatKey();if(!a)return;const i={};if(this._isToggle()){const c=this._getCurrentValue(a);i[a]=!c}else i[a]=this._value;this.docModel.updateRangeFormat(t,o,i)}undo(){const{anchor:t,focus:o}=this.selectionManager.selection;this.docModel.updateRangeFormat(t,o,this._prevFormat)}_isToggle(){return["bold","italic","underline","strikethrough","superscript","subscript"].includes(this.name)}_getFormatKey(){return{bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",fontSize:"fontSize",fontFamily:"fontFamily",color:"color",backgroundColor:"backgroundColor"}[this.name]??null}_getCurrentValue(t){var i;const{focus:o}=this.selectionManager.selection,a=this.docModel.getElementAt(o);return(i=a==null?void 0:a.format)==null?void 0:i[t]}}class Ue{constructor(t,o,a,i){O(this,"name","textAlign");this.docModel=t,this.selectionManager=o,this._formatKey=a,this._value=i}execute(){const{focus:t}=this.selectionManager.selection,o={};o[this._formatKey]=this._value,this.docModel.updateParagraphFormat(t.sectionIndex,t.paragraphIndex,o)}undo(){}}class Dn{constructor(t,o,a){O(this,"_factories",new Map);this.docModel=t,this.selectionManager=o,this.historyManager=a,this._registerBuiltinCommands()}_registerBuiltinCommands(){this.register("insertText",o=>{const{focus:a}=this.selectionManager.selection;return new $n(this.docModel,this.selectionManager,a,o)}),this.register("insertParagraph",()=>new zn(this.docModel,this.selectionManager)),this.register("deleteBackward",()=>new st(this.docModel,this.selectionManager,"backward")),this.register("deleteForward",()=>new st(this.docModel,this.selectionManager,"forward")),this.register("undo",()=>null),this.register("redo",()=>null),["bold","italic","underline","strikethrough","superscript","subscript"].forEach(o=>{this.register(o,()=>new Fe(this.docModel,this.selectionManager,o))}),this.register("fontSize",o=>new Fe(this.docModel,this.selectionManager,"fontSize",o)),this.register("fontFamily",o=>new Fe(this.docModel,this.selectionManager,"fontFamily",o)),this.register("color",o=>new Fe(this.docModel,this.selectionManager,"color",o)),this.register("backgroundColor",o=>new Fe(this.docModel,this.selectionManager,"backgroundColor",o)),this.register("textAlign",o=>new Ue(this.docModel,this.selectionManager,"textAlign",o)),this.register("lineHeight",o=>new Ue(this.docModel,this.selectionManager,"lineHeight",o)),this.register("heading",o=>new Ue(this.docModel,this.selectionManager,"heading",o)),this.register("selectAll",()=>(this.selectionManager.selectAll(),null)),this.register("setSelection",o=>{if(o){const a=o;this.selectionManager.setSelection(a.anchor,a.focus)}return null})}register(t,o){this._factories.set(t,o)}exec(t,o){if(t==="undo"){this.historyManager.undo();return}if(t==="redo"){this.historyManager.redo();return}const a=this._factories.get(t);if(!a){console.warn(`[CommandManager] 未注册命令: ${t}`);return}const i=a(o);i&&(i.execute(),this.historyManager.push(i))}}class Rn{constructor(t,o){O(this,"_el",null);O(this,"_commandManager");O(this,"_selectionManager");O(this,"_composing",!1);O(this,"_boundKeydown");O(this,"_boundBeforeInput");O(this,"_boundCompositionStart");O(this,"_boundCompositionEnd");O(this,"_boundSelectionChange");this._commandManager=t,this._selectionManager=o,this._boundKeydown=this._onKeydown.bind(this),this._boundBeforeInput=this._onBeforeInput.bind(this),this._boundCompositionStart=()=>{this._composing=!0},this._boundCompositionEnd=this._onCompositionEnd.bind(this),this._boundSelectionChange=this._onSelectionChange.bind(this)}attach(t){this._el=t,t.addEventListener("keydown",this._boundKeydown),t.addEventListener("beforeinput",this._boundBeforeInput),t.addEventListener("compositionstart",this._boundCompositionStart),t.addEventListener("compositionend",this._boundCompositionEnd),document.addEventListener("selectionchange",this._boundSelectionChange)}detach(){this._el&&(this._el.removeEventListener("keydown",this._boundKeydown),this._el.removeEventListener("beforeinput",this._boundBeforeInput),this._el.removeEventListener("compositionstart",this._boundCompositionStart),this._el.removeEventListener("compositionend",this._boundCompositionEnd),document.removeEventListener("selectionchange",this._boundSelectionChange),this._el=null)}_onKeydown(t){const o=t.key,a=t.ctrlKey||t.metaKey,i=t.shiftKey;if(a)switch(o){case"z":t.preventDefault(),i?this._commandManager.exec("redo"):this._commandManager.exec("undo");return;case"b":t.preventDefault(),this._commandManager.exec("bold");return;case"i":t.preventDefault(),this._commandManager.exec("italic");return;case"u":t.preventDefault(),this._commandManager.exec("underline");return;case"a":t.preventDefault(),this._commandManager.exec("selectAll");return}switch(o){case"Enter":t.preventDefault(),this._composing||this._commandManager.exec("insertParagraph");break;case"Backspace":t.preventDefault(),this._composing||this._commandManager.exec("deleteBackward");break;case"Delete":t.preventDefault(),this._composing||this._commandManager.exec("deleteForward");break;case"ArrowLeft":t.preventDefault(),this._selectionManager.moveBackward(i);break;case"ArrowRight":t.preventDefault(),this._selectionManager.moveForward(i);break;case"Tab":t.preventDefault(),this._commandManager.exec("insertText"," ");break}}_onBeforeInput(t){t.preventDefault(),!this._composing&&t.data&&this._commandManager.exec("insertText",t.data)}_onCompositionEnd(t){this._composing=!1,t.data&&this._commandManager.exec("insertText",t.data)}_onSelectionChange(){const t=window.getSelection();if(!t||!this._el)return;const o=t.anchorNode,a=t.focusNode;if(!o||!a||!this._el.contains(o)&&!this._el.contains(a))return;const i=qe.domToModelPoint(o,t.anchorOffset),c=qe.domToModelPoint(a,t.focusOffset);i&&c&&this._selectionManager.setSelection(i,c)}}class ct{constructor(t={}){O(this,"docModel");O(this,"selection");O(this,"history");O(this,"commands");O(this,"input");O(this,"_readonly");O(this,"_plugins",[]);O(this,"_inputEl",null);var o;this._readonly=t.readonly??!1,this.docModel=new ze(t.initialDocument),this.selection=new qe(this.docModel),this.history=new Ln,this.commands=new Dn(this.docModel,this.selection,this.history),this.input=new Rn(this.commands,this.selection),(o=t.plugins)==null||o.forEach(a=>this.use(a))}exec(t,o){if(this._readonly&&!this._isReadCommand(t)){console.warn("[Editor] 只读模式,忽略写操作");return}this.commands.exec(t,o)}mount(t){this._inputEl=t,this._readonly||this.input.attach(t)}unmount(){this.input.detach(),this._inputEl=null}use(t){return this._plugins.find(o=>o.name===t.name)?(console.warn(`[Editor] 插件 ${t.name} 已安装`),this):(t.install(this),this._plugins.push(t),this)}getJSON(){return this.docModel.toJSON()}loadJSON(t){const o=ze.fromJSON(t);Object.assign(this.docModel.data,o.data),this.history.clear()}get isReadonly(){return this._readonly}_isReadCommand(t){return["undo","redo","selectAll","setSelection"].includes(t)}}const We=Symbol("editor");function Hn(n){const t=new ct(n);return e.provide(We,t),e.onUnmounted(()=>{t.unmount()}),t}function On(){const n=e.inject(We);if(!n)throw new Error("[useEditor] 必须在 EditorContainer 组件内使用");return n}const dt=An,Nn={install(n){n.component("EditorContainer",dt)}};G.Editor=ct,G.EditorContainer=dt,G.EditorKey=We,G.createEditor=Hn,G.default=Nn,G.useEditor=On,Object.defineProperties(G,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(J,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-virtual-scroller"),require("lucide-vue-next")):typeof define=="function"&&define.amd?define(["exports","vue","vue-virtual-scroller","lucide-vue-next"],e):(J=typeof globalThis<"u"?globalThis:J||self,e(J.WordEditor={},J.Vue,J.VueVirtualScroller,J.LucideVueNext))})(this,function(J,e,xe,B){"use strict";var io=Object.defineProperty;var ro=(J,e,xe)=>e in J?io(J,e,{enumerable:!0,configurable:!0,writable:!0,value:xe}):J[e]=xe;var O=(J,e,xe)=>ro(J,typeof e!="symbol"?e+"":e,xe);const bt={class:"we-vt-context-menu--option-wrapper modern-menu-wrapper"},_t=["onMouseenter","onMouseleave"],wt=["onClick"],xt={class:"we-vt-context-menu--link-content menu-label"},Et={key:0,class:"we-vt-context-menu--submenu modern-submenu"},Ct=["onClick"],Bt={class:"we-vt-context-menu--link-content submenu-label"},Mt={__name:"ContextMenu",props:{e:{type:Object,default:()=>({})},row:{type:Object,default:()=>({})},menuConfig:{type:Object,default:()=>({body:{}})}},emits:["close","menuClick"],setup(n,{emit:t}){const o=t,a=n,i=e.computed(()=>{var R,T;return{left:`${(R=a.e)==null?void 0:R.pageX}px`,top:`${(T=a.e)==null?void 0:T.pageY}px`}}),c=e.ref([]),y=e.ref(null);let s=null;const m=e.ref(),f=(R,T,u)=>{if(R.children&&R.children.length>0){T&&T.preventDefault()&&T.stopPropagation();return}R.disabled||(u?o("menuClick",{...R,parent:u.code},a.row):o("menuClick",R,a.row)),T&&T.preventDefault()&&T.stopPropagation()},F=R=>{let T=R.target;for(;T&&T!=m.value;)T=T.parentNode;T!=m.value&&o("close")},I=(R,T)=>{R.currentTarget.classList.add("link--active"),s&&(clearTimeout(s),s=null),T.children&&T.children.length>0?y.value=T.code:s=setTimeout(()=>{y.value=null},100)},z=(R,T)=>{R.currentTarget.classList.remove("link--active"),T.children&&T.children.length>0&&(s=setTimeout(()=>{y.value===T.code&&(y.value=null)},300))},_=R=>{s&&(clearTimeout(s),s=null),R.currentTarget.classList.add("link--active")},j=R=>{R.currentTarget.classList.remove("link--active")},X=R=>{const T=R.code||"",u=(R.name||"").toLowerCase(),E={"add-current":B.Navigation,"add-next":B.ArrowDown,"add-child":B.PlusCircle,paste:B.Clipboard,delete:B.Trash2,copy:B.Copy,cut:B.Move,edit:B.Edit,export_part_section:B.Layers,export_part_chapter:B.FileDown,export_full:B.Download,pdf:B.FileText,word:B.Type,excel:B.Grid,txt:B.FileText,view:B.Eye,preview:B.Eye,expand:B.Plus,collapse:B.Minus,"sort-asc":B.SortAsc,"sort-desc":B.SortDesc,filter:B.Filter,search:B.Search,permission:B.ShieldCheck,share:B.Share,lock:B.Lock,unlock:B.Globe,info:B.Info,settings:B.Settings,history:B.History,refresh:B.RotateCcw,save:B.Save,upload:B.Upload,download:B.Download,more:B.MoreHorizontal};return E[T]?E[T]:u.includes("添加")||u.includes("add")?u.includes("当前")||u.includes("current")?B.Navigation:u.includes("下")||u.includes("next")?B.ArrowDown:u.includes("子")||u.includes("child")?B.PlusCircle:B.Plus:u.includes("导出")||u.includes("export")?u.includes("节")||u.includes("section")?B.Layers:u.includes("章")||u.includes("chapter")?B.FileDown:B.Download:u.includes("粘贴")||u.includes("paste")?B.Clipboard:u.includes("删除")||u.includes("delete")?B.Trash2:u.includes("pdf")?B.FileText:u.includes("word")?B.Type:B.MoreHorizontal};return e.onMounted(()=>{var R,T,u,E,P,M,L;(R=a.menuConfig)!=null&&R.visibleMethod&&typeof((T=a.menuConfig)==null?void 0:T.visibleMethod)=="function"&&((P=a.menuConfig)==null||P.visibleMethod({options:(E=(u=a.menuConfig)==null?void 0:u.body)==null?void 0:E.options,row:a.row})),c.value=(((L=(M=a.menuConfig)==null?void 0:M.body)==null?void 0:L.options)||[]).flat(),document.addEventListener("click",F,!0)}),e.onUnmounted(()=>{document.removeEventListener("click",F,!0)}),(R,T)=>(e.openBlock(),e.createElementBlock("div",{class:"we-vt-table--context-menu-wrapper virtual-table-menu modern-virtual-menu",ref_key:"contextMenuRef",ref:m,style:e.normalizeStyle([{display:"inline-block"},i.value])},[e.createElementVNode("ul",bt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,u=>(e.openBlock(),e.createElementBlock("li",{class:e.normalizeClass({"link--disabled":u.disabled,"has-children":u.children&&u.children.length>0,"modern-menu-item":!0}),key:u.code,onMouseenter:E=>I(E,u),onMouseleave:E=>z(E,u)},[e.createElementVNode("a",{class:"we-vt-context-menu--link modern-menu-link",onClick:E=>f(u,E)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(X(u)),{size:16,class:"menu-icon"})),e.createElementVNode("span",xt,e.toDisplayString(u.name),1),u.children&&u.children.length>0?(e.openBlock(),e.createBlock(e.unref(B.ChevronRight),{key:0,size:14,class:"submenu-arrow"})):e.createCommentVNode("",!0)],8,wt),u.children&&u.children.length>0&&y.value===u.code?(e.openBlock(),e.createElementBlock("ul",Et,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.children,E=>(e.openBlock(),e.createElementBlock("li",{key:E.code,class:e.normalizeClass({"link--disabled":E.disabled,"modern-submenu-item":!0}),onMouseenter:_,onMouseleave:j},[e.createElementVNode("a",{class:"we-vt-context-menu--link modern-submenu-link",onClick:P=>f(E,P,u)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(X(E)),{size:14,class:"submenu-icon"})),e.createElementVNode("span",Bt,e.toDisplayString(E.name),1)],8,Ct)],34))),128))])):e.createCommentVNode("",!0)],42,_t))),128))])],4))}},Qe=Symbol("component_container");function St(n,t,o){const a=e.h(n,{...t},o),i=document.createElement("div");return document.body.appendChild(i),a[Qe]=i,e.render(a,i),a.component}function Ft(n){var o;const t=n.vnode[Qe];e.render(null,t),t!=null&&t.checkVisibility&&(t!=null&&t.checkVisibility())&&((o=document.body)==null||o.removeChild(t))}let et;const It=n=>{et=St(Mt,n,null)},Tt=function(n){const t=n.onClose;return n.onClose=()=>{t&&t.call(),Ft(et)},It(n),n};function At(n,t,o){const a=(o==null?void 0:o.keyField)||(o==null?void 0:o.rowField)||"node_id",i=(o==null?void 0:o.parentField)||"parent_id",c=(o==null?void 0:o.parentField)||"order";if(!(n!=null&&n.length))return n;const y={};n.forEach(F=>{const I=F[i];y[I]||(y[I]=[]),y[I].push(F)});function s(F){const I=y[F]||[];I.sort((_,j)=>_[c]&&j[c]?_[c]-j[c]:0);const z=[];return I.forEach(_=>{z.push(_),z.push(...s(_[a]))}),z}let m=[];if(Array.isArray(t))m=t;else{const F=new Set(n.map(_=>_[a])),I=n.filter(_=>!F.has(_[i]));if(I.length===0)throw new Error("无法确定根节点:可能存在循环引用或数据不完整");const z={};I.forEach(_=>{const j=_[i];z[j]=(z[j]||0)+1}),m=Object.entries(z).map(([_])=>_)}let f=[];return m.forEach(F=>{f=f.concat(s(F))}),f}function tt(n,t,o){let a;for(;n&&n.nodeType&&n!==document;){if(n.className&&n.className.split&&n.className.split(" ").indexOf(t)>-1)return a=n,a;if(n===o)return null;n=n.parentNode}return a}function Pt(n){return typeof n=="function"||Object.prototype.toString.call(n)==="[object Object]"&&!e.isVNode(n)}const Lt=e.defineComponent({name:"VirtualTable",props:{data:{type:Array,required:!0,default:()=>[]},rowConfig:{type:Object,default:()=>({keyField:"node_id"})},editConfig:{type:Object,default:null},treeConfig:{type:Object,default:null},menuConfig:{type:Object,default:()=>({body:{}})},showHeader:{type:Boolean,default:!0},rowClassName:{type:Function,default:null},pageConfig:{type:Object,default:()=>({enabled:!1,pageHeight:842,pageWidth:595,margin:40,gap:10,showPageHeader:!0,showPageBorder:!1,pageBorderPadding:5,pageBorderStyle:"1px solid #000",headerHeight:0,footerHeight:0,showPageNumber:!0})},pageData:{type:Object,default:null}},emits:["current-change","menu-click","edit-activated","edit-closed","scroll-end","selection-change"],setup(n,{emit:t,slots:o,expose:a}){var kt;const i=e.getCurrentInstance(),c=e.ref(),y=e.ref(!1),s=e.ref(null),m=e.ref(null),f=e.ref([]);let F=new Map;const I=new Map;e.ref(0);const z=e.ref([]);e.ref([]);const _=e.ref(new Set),j=e.ref(new Set),X=e.ref(null),R=2,T=new WeakMap,u=e.ref(null),E=e.ref(""),P=new Set,M=e.computed(()=>{try{return Array.isArray(f.value)?f.value:[]}catch{return[]}}),L=l=>{var p,h,g;if(!l)return 30;if(l.height)return l.height;const r=`${l.content_type}_${((p=l.content)==null?void 0:p.length)||0}_${((h=l.title)==null?void 0:h.length)||0}_${l._editing?1:0}`;if(T.has(l)){const x=T.get(l);if(x.key===r)return x.height}let d=30;switch(l.content_type){case"image":d=150;break;case"table-row":d=l.rowHeight||35;break;case"table":const w=((l.content||"").match(/<tr/g)||[]).length;d=Math.max(100,w*35+30);break;case"flowchart":d=200;break;default:{const k=(l.content||"").length,b=(l.title||"").length,C=k+b,A=((g=(l.content||"").match(/[\u4e00-\u9fa5]/g))==null?void 0:g.length)||0,D=C-A,S=A*12+D*6,$=Math.max(1,Math.ceil(S/760));d=Math.max(20,$*18),l._editing&&(d+=20);break}}return T.set(l,{key:r,height:d}),d},U=e.computed(()=>{if(M.value.length===0)return 30;const l=M.value.slice(0,Math.min(100,M.value.length));if(l.length===0)return 30;const r=l.reduce((p,h)=>p+L(h),0)/l.length,d=Math.max(20,Math.floor(r*.6));return Math.min(d,60)});let Z;const Xe=(l,r)=>{t("menu-click",{menu:l,row:r}),Z==null||Z.onClose(),Z=null},N=l=>{var d,p,h,g,x;if(!((h=(p=(d=n.menuConfig)==null?void 0:d.body)==null?void 0:p.options)!=null&&h.length))return;Z==null||Z.onClose(),Z=null;let r=l.target;for(;r&&(r!=null&&r.getAttribute)&&!(r!=null&&r.getAttribute("data-id"))&&r!==((g=c.value)==null?void 0:g.$el);)r=r.parentNode;if((x=r==null?void 0:r.getAttribute)!=null&&x.call(r,"data-id")){const w=r.getAttribute("data-id"),k=ke(w);k&&(Z=Tt({e:l,row:k,menuConfig:n.menuConfig,onMenuClick:Xe}),l.preventDefault(),l.stopPropagation())}},ie=l=>{var d,p,h;if(!s.value)return;let r=l.target;for(;r&&(r!=null&&r.getAttribute)&&!(r!=null&&r.getAttribute("data-id"))&&r!==((d=c.value)==null?void 0:d.$el);)if(r=r.parentNode,r!=null&&r.classList&&["el-popper","ck-body-wrapper"].some(g=>r.classList.contains(g)))return;((p=r==null?void 0:r.getAttribute)==null?void 0:p.call(r,"data-id"))!=((h=s.value)==null?void 0:h.node_id)&&(s.value._editing=!1,t("edit-closed",{row:s.value,column:{},$table:i==null?void 0:i.exposed}),s.value=null)};((kt=n.editConfig)==null?void 0:kt.trigger)==="dblclick"&&e.watch(()=>s.value,l=>{document.removeEventListener("click",ie,!0),l&&setTimeout(()=>{document.addEventListener("click",ie,!0)},200)});const de=l=>JSON.stringify(l.map(r=>{var d;return{id:r[n.rowConfig.keyField],content:((d=r.content)==null?void 0:d.length)||0,type:r.content_type,editing:r._editing}})),ge=()=>{if(!n.pageConfig.enabled){z.value=[{items:f.value,startIndex:0,endIndex:f.value.length}];return}if(n.pageData&&Object.keys(n.pageData).length){const l=[],r=n.rowConfig.keyField||"node_id",d=new Map;f.value.forEach(h=>{d.set(String(h[r]),h)}),Object.keys(n.pageData).sort((h,g)=>parseInt(h)-parseInt(g)).forEach(h=>{const g=n.pageData[h],x=[];g.forEach(w=>{const k=d.get(String(w));k&&x.push(k)}),x.length>0&&l.push({items:x,pageNumber:parseInt(h),height:x.reduce((w,k)=>w+L(k),0)})}),z.value=l}else{const{pageHeight:l,margin:r,headerHeight:d=0,footerHeight:p=0}=n.pageConfig,g=Math.max(100,l-r*2-d-p-20),x=[];let w=[],k=0,b=0,C=1;f.value.forEach((A,D)=>{const S=L(A);(A.layer||0)<=2&&w.length>0?(x.push({items:[...w],startIndex:b,endIndex:D,height:k,pageNumber:C++}),w=[A],k=S,b=D):k+S>g&&w.length>0?(x.push({items:[...w],startIndex:b,endIndex:D,height:k,pageNumber:C++}),w=[A],k=Math.min(S,g),b=D):(w.push(A),k+=S)}),w.length>0&&x.push({items:w,startIndex:b,endIndex:f.value.length,height:k,pageNumber:C}),z.value=x}},Pe=()=>{try{const l=Array.isArray(n.data)?n.data:[],r=de(l);if(!(r!==E.value)&&f.value.length>0)return;E.value=r;const p=(n.treeConfig?At(l,void 0,n.treeConfig):l).map((g,x)=>{const w=g[n.rowConfig.keyField],k=I.get(w);if(!k||k.content!==g.content||k.content_type!==g.content_type){P.add(w);const b={...g,index:x,_editing:g._editing||!1,_original:(k==null?void 0:k._original)||{...g}};return I.set(w,b),b}return k.index=x,k});f.value=p,ge();const h=new Set(p.map(g=>g[n.rowConfig.keyField]));for(const[g]of I)h.has(g)||(I.delete(g),P.delete(g))}catch{f.value=[],z.value=[],I.clear(),P.clear()}};e.watch(()=>n.data,(l,r)=>{try{if(!Array.isArray(l))return;e.nextTick(()=>{if(Pe(),n.pageConfig.enabled){j.value.clear(),_.value.clear();for(let d=0;d<Math.min(3,z.value.length);d++)j.value.add(d);e.nextTick(()=>{oe()})}})}catch{}},{deep:!1,immediate:!1}),e.watch(()=>n.pageData,()=>{if(n.pageConfig.enabled){ge(),j.value.clear(),_.value.clear();for(let l=0;l<Math.min(3,z.value.length);l++)j.value.add(l);e.nextTick(()=>{oe()})}},{deep:!0}),e.watch(()=>n.pageConfig,()=>{if(n.pageConfig.enabled){ge(),j.value.clear(),_.value.clear();for(let l=0;l<Math.min(3,z.value.length);l++)j.value.add(l);e.nextTick(()=>{oe()})}},{deep:!0}),e.watch(m,()=>t("current-change",{row:m.value}));let _e=null;const he=()=>{window.ResizeObserver&&(_e=new ResizeObserver(l=>{var r,d;for(const p of l){const h=(r=p.target.dataset)==null?void 0:r.id;if(!h)continue;const g=ke(h);if(!g)continue;const x=p.contentRect.height,w=((d=T.get(g))==null?void 0:d.height)||0;if(Math.abs(w-x)>5){const k=T.get(g)||{};T.set(g,{...k,height:x}),requestAnimationFrame(()=>{var C;const b=p.target.__vueParentComponent;(C=b==null?void 0:b.proxy)!=null&&C.updateSize&&b.proxy.updateSize()})}}}),e.nextTick(()=>{var d;const l=(d=c.value)==null?void 0:d.$el;if(!l)return;l.querySelectorAll("[data-id]").forEach(p=>{p.dataset.id&&_e.observe(p)})}))},ne=()=>{u.value&&(u.value.disconnect(),u.value=null),_e&&(_e.disconnect(),_e=null)},oe=()=>{n.pageConfig.enabled&&(X.value&&X.value.disconnect(),X.value=new IntersectionObserver(l=>{l.forEach(r=>{const d=parseInt(r.target.dataset.pageIndex);if(r.isIntersecting){_.value.add(d);for(let p=Math.max(0,d-R);p<=Math.min(z.value.length-1,d+R);p++)j.value.add(p)}else _.value.delete(d),setTimeout(()=>{_.value.has(d)||Array.from(_.value).some(h=>Math.abs(h-d)<=R*2)||j.value.delete(d)},3e3)})},{root:null,rootMargin:"100px",threshold:.01}),e.nextTick(()=>{const l=document.querySelector(".a4-pages-container");l&&l.querySelectorAll(".a4-page-placeholder").forEach(d=>{X.value.observe(d)})}))};e.onMounted(()=>{Pe(),e.nextTick(()=>{var l;if(he(),ue.setup(),oe(),((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&(document.addEventListener("selectionchange",we),document.addEventListener("mouseup",He)),n.pageConfig.enabled)for(let r=0;r<Math.min(3,z.value.length);r++)j.value.add(r)}),y.value=!0}),e.onUnmounted(()=>{var l;ne(),ue.cleanup(),X.value&&(X.value.disconnect(),X.value=null),((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&(document.removeEventListener("selectionchange",we),document.removeEventListener("mouseup",He)),W&&clearTimeout(W),F=new Map,I.clear(),j.value.clear(),_.value.clear()});const ue={handlers:new Map,setup(){e.nextTick(()=>{var r;const l=(r=c.value)==null?void 0:r.$el;l&&(l.addEventListener("click",this.handleClick.bind(this),{passive:!0}),l.addEventListener("dblclick",this.handleDblClick.bind(this),{passive:!0}))})},handleClick(l){const r=l.target.closest("[data-id]");if(!r)return;const d=r.dataset.id,p=ke(d);p&&Ne(p)},handleDblClick(l){var h;if(!((h=n.editConfig)!=null&&h.trigger)==="dblclick")return;const r=l.target.closest("[data-id]");if(!r)return;const d=r.dataset.id,p=ke(d);p&&Le(p)},cleanup(){var r,d;const l=(d=(r=c.value)==null?void 0:r.$el)==null?void 0:d.querySelector(".virtual-table-wrapper");l&&(l.removeEventListener("click",this.handleClick),l.removeEventListener("dblclick",this.handleDblClick))}},pe=l=>{Ne(l)},re=l=>Le(l);let Q=null,le;const se=({row:l,column:r},d,p)=>{var x,w;const h=p||d.target,g=tt(h,"virtual-table-cell",(x=c.value)==null?void 0:x.$el);Q===g&&le&&(clearTimeout(le),Q=null),((w=s.value)==null?void 0:w[n.rowConfig.keyField])!=(l==null?void 0:l[n.rowConfig.keyField])&&setTimeout(()=>{var b,C;s.value=l;let k=(b=h==null?void 0:h.getAttribute)==null?void 0:b.call(h,"field");if(!k){try{const A=document.getSelection();let D=A==null?void 0:A.anchorNode;D&&D.nodeType===3&&(D=D.parentElement);const S=(C=D==null?void 0:D.closest)==null?void 0:C.call(D,"[field]");S&&(k=S.getAttribute("field"))}catch{}if(!k&&(d!=null&&d.composedPath)){for(const A of d.composedPath())if(A!=null&&A.getAttribute&&A.getAttribute("field")){k=A.getAttribute("field");break}}}t("edit-activated",{row:l,column:{...r,field:k},$table:i==null?void 0:i.exposed})},200)},me=({row:l,column:r},d,p)=>{var g;const h=p||d.target;Q=tt(h,"virtual-table-cell",(g=c.value)==null?void 0:g.$el),le&&clearTimeout(le),le=setTimeout(()=>{var k,b,C,A,D;const x=l.content_type;let w=(k=h==null?void 0:h.getAttribute)==null?void 0:k.call(h,"field");if(!w){try{const S=document.getSelection();let $=S==null?void 0:S.anchorNode;$&&$.nodeType===3&&($=$.parentElement);const q=(b=$==null?void 0:$.closest)==null?void 0:b.call($,"[field]");q&&(w=q.getAttribute("field"))}catch{}if(!w&&(d!=null&&d.composedPath)){for(const S of d.composedPath())if(S!=null&&S.getAttribute&&S.getAttribute("field")){w=S.getAttribute("field");break}}}if(x!=="table"){if(x==="text"){let S=null,$=null;if((C=h==null?void 0:h.getAttribute)!=null&&C.call(h,"field")?S=h:(A=h==null?void 0:h.closest)!=null&&A.call(h,"[field]")&&(S=h.closest("[field]")),S&&($=S.textContent),w&&$!==void 0&&$!==null){$=$.trim();const q=((D=l[w])==null?void 0:D.trim())||"";$!==q&&(l[w]=$)}}}t("edit-closed",{row:l,column:{...r,field:w},$table:i==null?void 0:i.exposed})},50)};let H=null,W=null;const G=l=>{var r;((r=n.editConfig)==null?void 0:r.trigger)==="contenteditable"&&ye("focusin",l)},ee=l=>{var r,d,p,h,g;if(((r=n.editConfig)==null?void 0:r.trigger)==="contenteditable")if(H!=null&&H.cellEl){let x=H.fieldEl;!x&&H.field&&(x=(p=(d=H.cellEl)==null?void 0:d.querySelector)==null?void 0:p.call(d,`[field="${H.field}"]`)),x||(x=((g=(h=H.cellEl).querySelector)==null?void 0:g.call(h,"[field]"))||H.cellEl),me(H,{target:x},x),H=null}else ye("focusout",l)},ye=(l,r)=>{var d,p,h,g,x,w;try{const k=document.getSelection();let b=k==null?void 0:k.anchorNode;b&&b.nodeType===3&&(b=b.parentElement);const C=(d=b==null?void 0:b.closest)==null?void 0:d.call(b,".virtual-table-cell"),A=(p=b==null?void 0:b.closest)==null?void 0:p.call(b,".virtual-table-row");if(!C||!A)return;const D=A.getAttribute("data-id"),S=C.getAttribute("data-prop"),$=ke(D),q=Me.value.find(te=>`${te.prop}`==`${S}`)||{},v=((h=b==null?void 0:b.closest)==null?void 0:h.call(b,"[field]"))||null,V=((g=v==null?void 0:v.getAttribute)==null?void 0:g.call(v,"field"))||void 0;l==="focusin"?(H={row:$,column:q,cellEl:C,rowEl:A,fieldEl:v,field:V},se({row:$,column:q},r,v||((x=b==null?void 0:b.closest)==null?void 0:x.call(b,"[field]")))):me({row:$,column:q},r,v||((w=b==null?void 0:b.closest)==null?void 0:w.call(b,"[field]")))}catch{}},we=()=>{var l;((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&(W&&clearTimeout(W),W=setTimeout(()=>{var r,d,p,h,g,x,w,k,b,C,A,D,S,$;try{const q=document.getSelection();if(q.rangeCount===0)return;const v=q.getRangeAt(0);let V=v.startContainer;V.nodeType===3&&(V=V.parentElement);const te=(r=V==null?void 0:V.closest)==null?void 0:r.call(V,".virtual-table-cell"),Y=(d=V==null?void 0:V.closest)==null?void 0:d.call(V,".virtual-table-row");if(!te||!Y)return;const Se=Y.getAttribute("data-id"),Fe=te.getAttribute("data-prop"),fe=ke(Se),ae=Me.value.find(K=>`${K.prop}`==`${Fe}`)||{};if(!H||((p=H.row)==null?void 0:p[n.rowConfig.keyField])!==(fe==null?void 0:fe[n.rowConfig.keyField])||((h=H.column)==null?void 0:h.prop)!==(ae==null?void 0:ae.prop)){if(H){let K=H.fieldEl;!K&&H.field&&(K=(x=(g=H.cellEl)==null?void 0:g.querySelector)==null?void 0:x.call(g,`[field="${H.field}"]`)),K||(K=((k=(w=H.cellEl)==null?void 0:w.querySelector)==null?void 0:k.call(w,"[field]"))||H.cellEl),me(H,{target:K},K)}H={row:fe,column:ae,cellEl:te,rowEl:Y,fieldEl:((b=V==null?void 0:V.closest)==null?void 0:b.call(V,"[field]"))||null,field:((D=(A=((C=V==null?void 0:V.closest)==null?void 0:C.call(V,"[field]"))||null)==null?void 0:A.getAttribute)==null?void 0:D.call(A,"field"))||void 0},se({row:fe,column:ae},{target:te},te)}if(q.toString()){const K=v.endContainer.nodeType===3?v.endContainer.parentElement:v.endContainer,Ee=(S=K==null?void 0:K.closest)==null?void 0:S.call(K,".virtual-table-cell"),Ke=($=K==null?void 0:K.closest)==null?void 0:$.call(K,".virtual-table-row")}}catch{}},50))},He=()=>{var l;((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"&&setTimeout(()=>{var p,h,g,x;const r=document.getSelection();if(!r)return;const d=r.toString();if(d){const w=r.rangeCount>0?r.getRangeAt(0):null;let k=null,b=null;try{if(w){let C=w.startContainer;(C==null?void 0:C.nodeType)===3&&(C=C.parentElement);const A=(p=C==null?void 0:C.closest)==null?void 0:p.call(C,".virtual-table-cell"),D=(h=C==null?void 0:C.closest)==null?void 0:h.call(C,".virtual-table-row");k=A&&D?{rowId:D.getAttribute("data-id"),prop:A.getAttribute("data-prop")}:null;let S=w.endContainer;(S==null?void 0:S.nodeType)===3&&(S=S.parentElement);const $=(g=S==null?void 0:S.closest)==null?void 0:g.call(S,".virtual-table-cell"),q=(x=S==null?void 0:S.closest)==null?void 0:x.call(S,".virtual-table-row");b=$&&q?{rowId:q.getAttribute("data-id"),prop:$.getAttribute("data-prop")}:null}}catch{}t("selection-change",{text:d,selection:r,range:w,start:k,end:b})}},10)},Vn=l=>(l==null?void 0:l._editing)===!0,vn=l=>l!=null&&l.parent_id?F.get(l.parent_id):null,jn=l=>{var d;const r=f.value.findIndex(p=>p[n.rowConfig.keyField]==l[n.rowConfig.keyField]);return r<1?null:((d=f.value[r-1])==null?void 0:d.layer)===l.layer?f.value[r-1]:null},Kn=l=>{const r=f.value.findIndex(d=>d[n.rowConfig.keyField]==l[n.rowConfig.keyField]);return r>=f.value.length-1?null:f.value[r+1]},ke=l=>{if(!l)return null;let r=I.get(l);return r||(typeof l=="number"?I.get(`${l}`):typeof l=="string"&&/^\d+$/.test(l)?I.get(Number(l)):null)};let Oe=null;const qn=l=>{Oe&&cancelAnimationFrame(Oe),Oe=requestAnimationFrame(()=>{var p;const r=n.rowConfig.keyField,d=l[r];if(n.pageConfig.enabled){let h=-1;for(let g=0;g<z.value.length;g++)if(z.value[g].items.some(k=>k[r]===d)){h=g;break}if(h!==-1){for(let g=Math.max(0,h-1);g<=Math.min(z.value.length-1,h+1);g++)j.value.has(g)||j.value.add(g);e.nextTick(()=>{const g=document.querySelector(".a4-pages-container");if(!g)return;const x=(w=0)=>{const k=g.querySelector(`[data-id="${d}"]`);if(k){let b=0,C=k;for(;C&&C!==g;)b+=C.offsetTop,C=C.offsetParent;const A=g.clientHeight;let D=b-A*.3;D=Math.max(0,D);const S=g.scrollTop,$=Math.abs(D-S),q=v=>{const V=g.scrollTop,te=v-V,Y=Math.min(800,Math.max(300,$*.5)),Se=performance.now(),Fe=ae=>ae<.5?4*ae*ae*ae:1-Math.pow(-2*ae+2,3)/2,fe=ae=>{const $e=ae-Se,K=Math.min($e/Y,1),Ee=Fe(K),Ke=V+te*Ee;g.scrollTop=Ke,K<1?requestAnimationFrame(fe):setTimeout(()=>{g.scrollTop=v},50)};requestAnimationFrame(fe)};$>3e3?g.scrollTo({top:D,behavior:"instant"}):q(D),k.classList.add("row--highlight"),setTimeout(()=>{k.classList.remove("row--highlight")},1500)}else w<10&&setTimeout(()=>x(w+1),150)};setTimeout(x,200)})}}else{const h=f.value.findIndex(g=>g[r]===d);h!==-1&&((p=c.value)!=null&&p.scrollToItem)&&c.value.scrollToItem(h)}Oe=null})},Ne=l=>{if(l){if(!y.value){setTimeout(()=>Ne(l),200);return}m.value=l,m.value!==s.value&&s.value&&(s.value._editing=!1,setTimeout(()=>{s.value=null},200))}},Le=(l,r)=>new Promise(d=>{var p,h;if(!((p=n==null?void 0:n.editConfig)!=null&&p.beforeEditMethod&&typeof((h=n==null?void 0:n.editConfig)==null?void 0:h.beforeEditMethod)=="function"&&!n.editConfig.beforeEditMethod({row:l}))){if(!l||!y.value){setTimeout(()=>Le(l),200);return}l!==s.value&&(f.value.forEach(g=>{g._editing&&t("edit-closed",{row:g,column:{field:r},$table:i==null?void 0:i.exposed}),g._editing=!1}),l._editing=!0,setTimeout(()=>{s.value=l,t("edit-activated",{row:l,column:{field:r},$table:i==null?void 0:i.exposed}),d(!0)}))}}),Un=l=>Le(l),Ze=()=>{if(ge(),n.pageConfig.enabled){const l=Array.from(_.value);if(l.length>0){const r=Math.min(...l);for(let d=Math.max(0,r-1);d<=Math.min(z.value.length-1,r+2);d++)j.value.add(d)}else for(let r=0;r<Math.min(3,z.value.length);r++)j.value.add(r);e.nextTick(()=>{oe()})}e.nextTick(()=>{!n.pageConfig.enabled&&c.value&&c.value.$forceUpdate&&c.value.$forceUpdate()})},Wn=(l,r)=>new Promise(d=>{let p=-1;if(r==-1){const h=ke(l.parent_id);for(p=f.value.findIndex(g=>g[n.rowConfig.keyField]==h[n.rowConfig.keyField])+1;f.value[p].parent_id==h[n.rowConfig.keyField];)p+=1}else p=f.value.findIndex(h=>h[n.rowConfig.keyField]==r[n.rowConfig.keyField]);F.set(l.node_id,l),I.set(l[n.rowConfig.keyField],l),f.value.splice(p,0,l),Ze(),d({row:l})}),Gn=(l,r)=>new Promise(d=>{const p=f.value.findIndex(h=>h[n.rowConfig.keyField]==r[n.rowConfig.keyField])+1;F.set(l.node_id,l),I.set(l[n.rowConfig.keyField],l),f.value.splice(p,0,l),Ze(),d({row:l})}),gt=l=>{const r=f.value.findIndex(d=>d[n.rowConfig.keyField]==l[n.rowConfig.keyField]||d===l);if(r>-1){const d=l[n.rowConfig.keyField];F.delete(l.node_id),I.delete(d),f.value.splice(r,1),Ze()}},Jn=(l,r)=>{if(!l||!l[n.rowConfig.keyField])return!1;const d=l._original;return d?r?l[r]!==d[r]:Object.keys(d).some(p=>d[p]!==l[p]):!1},Xn=l=>l&&l[n.rowConfig.keyField]&&!l._original,Yn=(l,r)=>{l&&l[n.rowConfig.keyField]&&(r&&Object.assign(l,r),l._original={...l,_editing:void 0,_X_ROW_CHILD:void 0,_original:void 0})},Zn=l=>{if(l&&l[n.rowConfig.keyField]){const r=ke(l[n.rowConfig.keyField]);r._original?Object.assign(r,r._original):gt(r)}},Qn=()=>{},eo=()=>{m.value={}},pt=l=>{var d,p,h;let r=f.value.findIndex(g=>g[n.rowConfig.keyField]==l[n.rowConfig.keyField]);if(r>-1&&n.treeConfig){const g=((d=n.treeConfig)==null?void 0:d.keyField)||((p=n.treeConfig)==null?void 0:p.rowField)||"node_id",x=((h=n.treeConfig)==null?void 0:h.parentField)||"parent_id",w=[],k=new Map;k.set(l[g],!0);for(let b=r+1;b<f.value.length;b++){const C=f.value[b];if(C&&k.has(C[x]))w.push(C),k.set(C[g]);else break}return w}return[]};a({isEditByRow:Vn,getParentRow:vn,getSiblingRow:jn,getNextRow:Kn,getRowById:ke,scrollToRow:qn,setCurrentRow:Ne,setEditRow:Le,setEditCell:Un,insertAt:Wn,insertNextAt:Gn,isUpdateByRow:Jn,isInsertByRow:Xn,reloadRow:Yn,revertData:Zn,remove:gt,setAllTreeExpand:Qn,clearCurrentRow:eo,getAllChilds:pt});const Me=e.computed(()=>o.default().filter(l=>{var r;return((r=l.type)==null?void 0:r.name)==="VirtualTableColumn"}).map(l=>{var r,d,p;return{prop:(r=l.props)==null?void 0:r.prop,title:(d=l.props)==null?void 0:d.title,width:(p=l.props)==null?void 0:p.width,slots:l.children}})),Ve=l=>{try{return l===0?{width:"0px"}:l?{flex:/^\d+$/.test(l)?`0 0 ${l}px`:`0 0 ${l}`}:{flex:"1 1 100%"}}catch(r){return console.warn("[VirtualTable] computeColumnWidth error:",r),{flex:"1 1 100%"}}},mt=e.computed(()=>{var l;return(l=n.treeConfig)!=null&&l.childCurrent&&m.value?pt(m.value).map(r=>r[n.rowConfig.keyField]):[]}),yt=e.ref({viewStartIndex:0,viewEndIndex:0,visibleStartIndex:0,visibleEndIndex:0});let ve=null,je=null;const to=(l,r)=>{ve&&cancelAnimationFrame(ve),ve=requestAnimationFrame(()=>{t("scroll-end",{...yt.value}),ve=null})},no=(l,r,d,p)=>{je&&cancelAnimationFrame(je),je=requestAnimationFrame(()=>{yt.value={viewStartIndex:l,viewEndIndex:r,visibleStartIndex:d,visibleEndIndex:p},je=null})},oo=(l,r)=>{var $,q;const{pageHeight:d,margin:p,showPageBorder:h,pageBorderPadding:g,pageBorderStyle:x,showPageHeader:w,headerHeight:k=0,footerHeight:b=0,showPageNumber:C}=n.pageConfig,A=l.pageNumber||r+1,S=Math.max(100,d-p*2-k-b-20);return j.value.has(r)?e.createVNode(e.Fragment,null,[w!==!1&&(o["page-header"]||k>0)?e.createVNode("div",{class:"a4-page-header",style:{minHeight:`${Math.max(k,1)}px`}},[($=o["page-header"])==null?void 0:$.call(o,{pageNumber:A,pageIndex:r,totalPages:z.value.length})]):null,r===0&&n.showHeader?e.createVNode("div",{class:"a4-table-header"},[e.createVNode("div",{class:"virtual-table-header we-vt-table--header we-vt-table--header-wrapper"},[Me.value.map(v=>{var V,te,Y;return e.createVNode("div",{class:"we-vt-header--column",key:v.prop,style:Ve(v.width)},[e.createVNode("div",{class:"we-vt-cell"},[(V=v.slots)!=null&&V.header?(Y=(te=v.slots)==null?void 0:te.header)==null?void 0:Y.call(te,{column:v}):v.title])])})])]):null,e.createVNode("div",{class:"a4-page-content",style:{minHeight:`${S}px`,...h?{border:x,padding:`${g}px`}:{}}},[l.items.map(v=>{var V,te;return e.createVNode("div",{key:v[n.rowConfig.keyField],"data-id":v[n.rowConfig.keyField],class:{"virtual-table-row":!0,"we-vt-body--row":!0,"row--current":v[n.rowConfig.keyField]===((V=m.value)==null?void 0:V[n.rowConfig.keyField])||((te=n.treeConfig)==null?void 0:te.childCurrent)&&mt.value.includes(v[n.rowConfig.keyField])},style:{width:"100%"},onClick:()=>pe(v),onDblclick:()=>re(v)},[Me.value.map(Y=>{var Se,Fe,fe,ae,$e,K,Ee;return e.createVNode("div",{key:Y.prop,class:"virtual-table-cell we-vt-cell",style:Ve(Y.width),"data-prop":Y.prop},[v._editing&&((Se=n.editConfig)==null?void 0:Se.trigger)==="dblclick"?((Fe=Y.slots)==null?void 0:Fe.edit)&&((ae=(fe=Y.slots)==null?void 0:fe.edit)==null?void 0:ae.call(fe,{row:v,column:Y})):(($e=Y.slots)==null?void 0:$e.default)&&((Ee=(K=Y.slots)==null?void 0:K.default)==null?void 0:Ee.call(K,{row:v,column:Y}))])})])})]),o["page-footer"]?(q=o["page-footer"])==null?void 0:q.call(o,{pageNumber:A,pageIndex:r,totalPages:z.value.length}):e.createVNode("div",{class:"a4-page-footer",contenteditable:"false",style:{height:`${Math.max(b||0,20)}px`}},[C!==!1?e.createVNode("span",{class:"page-number",contenteditable:"false"},[A,e.createTextVNode(" / "),z.value.length]):null])]):e.createVNode("div",{class:"a4-page-loading"},[e.createVNode("div",{class:"loading-spinner"},null),e.createVNode("div",{class:"loading-text"},[e.createTextVNode("加载中...")])])},lo=()=>{var x;const{pageHeight:l,pageWidth:r,margin:d,gap:p,showPageBorder:h,pageBorderPadding:g}=n.pageConfig;return e.createVNode("div",{class:"virtual-table we-vt-table we-vt-table--render-default border--none"},[e.createVNode("div",{class:"a4-pages-container",contenteditable:((x=n.editConfig)==null?void 0:x.trigger)==="contenteditable"?"true":void 0,onContextmenu:N,onFocusin:G,onFocusout:ee},[z.value.map((w,k)=>{const b=j.value.has(k);return e.createVNode("div",{key:`page-${k}`,class:b?"a4-page":"a4-page-placeholder","data-page-index":k,style:{width:`${r}px`,minHeight:`${l}px`,marginBottom:`${p}px`,padding:b?`${h?d-g:d}px`:"0",boxSizing:"border-box",position:"relative"}},[oo(w,k)])})])])},ao=()=>{var l;return e.createVNode("div",{class:"virtual-table we-vt-table we-vt-table--render-default border--none"},[n.showHeader?e.createVNode("div",{class:"virtual-table-header we-vt-table--header we-vt-table--header-wrapper"},[Me.value.map(r=>{var d,p,h;return e.createVNode("div",{class:"we-vt-header--column",key:r.prop,style:Ve(r.width)},[e.createVNode("div",{class:"we-vt-cell"},[(d=r.slots)!=null&&d.header?(h=(p=r.slots)==null?void 0:p.header)==null?void 0:h.call(p,{column:r}):r.title]),e.createVNode("div",{class:"we-vt-resizable is--line"},null)])})]):void 0,e.createVNode(xe.DynamicScroller,{ref:c,items:M.value,minItemSize:U.value,keyField:n.rowConfig.keyField,emitUpdate:!1,buffer:300,class:"virtual-table-wrapper",contenteditable:((l=n.editConfig)==null?void 0:l.trigger)==="contenteditable"?"true":void 0,onContextmenu:N,onScrollend:to,onUpdate:no,onFocusin:G,onFocusout:ee},{default:({item:r,index:d,active:p})=>{var g,x,w;let h;return e.createVNode(xe.DynamicScrollerItem,{key:r[n.rowConfig.keyField],item:r,active:p,sizeDependencies:[(g=r.content)==null?void 0:g.length,r._editing,r.content_type],"data-id":r[n.rowConfig.keyField],"data-index":d,"data-active":p,class:{"virtual-table-row":!0,"we-vt-body--row":!0,"row--current":r[n.rowConfig.keyField]===((x=m.value)==null?void 0:x[n.rowConfig.keyField])||((w=n.treeConfig)==null?void 0:w.childCurrent)&&mt.value.includes(r[n.rowConfig.keyField])}},Pt(h=Me.value.map(k=>{var b,C,A,D,S,$,q;return e.createVNode("div",{key:k.prop,class:"virtual-table-cell we-vt-cell",style:Ve(k.width),"data-prop":k.prop},[r._editing&&((b=n.editConfig)==null?void 0:b.trigger)==="dblclick"?((C=k.slots)==null?void 0:C.edit)&&((D=(A=k.slots)==null?void 0:A.edit)==null?void 0:D.call(A,{row:r,column:k})):((S=k.slots)==null?void 0:S.default)&&((q=($=k.slots)==null?void 0:$.default)==null?void 0:q.call($,{row:r,column:k}))])}))?h:{default:()=>[h]})}})])};return()=>n.pageConfig.enabled?lo():ao()}}),Ce=(n,t)=>{const o=n.__vccOpts||n;for(const[a,i]of t)o[a]=i;return o},$t=Ce(Lt,[["__scopeId","data-v-3756d9b0"]]),zt={name:"VirtualTableColumn",props:{prop:String,label:String,width:[String,Number]}};function Rt(n,t,o,a,i,c){return e.renderSlot(n.$slots,"default")}const Dt=Ce(zt,[["render",Rt]]),Ht={class:"catalog-node"},Ot=["title"],Nt={class:"catalog-node__text"},Vt={key:0,class:"catalog-node__children"},vt=Ce({__name:"CatalogNode",props:{item:{type:Object,required:!0},depth:{type:Number,default:0},activeId:{type:String,default:""}},emits:["navigate"],setup(n,{emit:t}){const o=n,a=t,i=e.ref(!0),c=e.computed(()=>o.item.children&&o.item.children.length>0);function y(s){s.stopPropagation(),i.value=!i.value}return(s,m)=>{const f=e.resolveComponent("CatalogNode",!0);return e.openBlock(),e.createElementBlock("div",Ht,[e.createElementVNode("div",{class:e.normalizeClass(["catalog-node__label",{"is-active":n.activeId===n.item.nodeId}]),style:e.normalizeStyle({paddingLeft:10+n.depth*14+"px"}),title:n.item.name,onClick:m[0]||(m[0]=F=>a("navigate",n.item))},[e.createElementVNode("span",{class:"catalog-node__toggle",onClick:y},[c.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.value?e.unref(B.ChevronDown):e.unref(B.ChevronRight)),{key:0,size:14})):e.createCommentVNode("",!0)]),e.createElementVNode("span",Nt,e.toDisplayString(n.item.name||"(无标题)"),1)],14,Ot),c.value&&i.value?(e.openBlock(),e.createElementBlock("div",Vt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.item.children,F=>(e.openBlock(),e.createBlock(f,{key:F.nodeId,item:F,depth:n.depth+1,"active-id":n.activeId,onNavigate:m[1]||(m[1]=I=>a("navigate",I))},null,8,["item","depth","active-id"]))),128))])):e.createCommentVNode("",!0)])}}},[["__scopeId","data-v-ac882917"]]),jt={key:0,class:"catalog catalog--collapsed"},Kt={key:1,class:"catalog"},qt={class:"catalog__header"},Ut={class:"catalog__title"},Wt={class:"catalog__body"},Gt={key:0,class:"catalog__empty"},Jt=Ce({__name:"index",props:{items:{type:Array,default:()=>[]}},emits:["navigate"],setup(n,{emit:t}){const o=t,a=e.ref(!1),i=e.ref("");function c(y){i.value=y.nodeId,o("navigate",y)}return(y,s)=>a.value?(e.openBlock(),e.createElementBlock("div",jt,[e.createElementVNode("button",{class:"catalog__icon-btn",title:"展开目录",onClick:s[0]||(s[0]=m=>a.value=!1)},[e.createVNode(e.unref(B.PanelLeftOpen),{size:18})])])):(e.openBlock(),e.createElementBlock("div",Kt,[e.createElementVNode("div",qt,[e.createElementVNode("span",Ut,[e.createVNode(e.unref(B.ListTree),{size:16}),s[2]||(s[2]=e.createTextVNode(" 目录 ",-1))]),e.createElementVNode("button",{class:"catalog__icon-btn",title:"收起目录",onClick:s[1]||(s[1]=m=>a.value=!0)},[e.createVNode(e.unref(B.PanelLeftClose),{size:18})])]),e.createElementVNode("div",Wt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.items,m=>(e.openBlock(),e.createBlock(vt,{key:m.nodeId,item:m,"active-id":i.value,onNavigate:c},null,8,["item","active-id"]))),128)),n.items.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Gt," 暂无目录 "))])]))}},[["__scopeId","data-v-8becafa1"]]),Xt={first:1,second:2,third:3,fourth:4,fifth:5,sixth:6};function Yt(n){return n.blockType!=="title"||!n.level?0:Xt[n.level]||1}function Zt(n){const t=[];for(const i of n||[]){const c=Yt(i);c&&t.push({id:i.node_id,nodeId:i.node_id,name:(i.content||"").trim(),level:c,children:[]})}if(!t.length)return[];const o=(i,c)=>{const y=c.children[c.children.length-1];y&&i.level>y.level?o(i,y):c.children.push(i)},a=[];for(const i of t){const c=a[a.length-1];c&&i.level>c.level?o(i,c):a.push(i)}return a}const Qt={first:0,second:1,third:2,fourth:3,fifth:4,sixth:5,seventh:6,eighth:7};function ze(n,t){let o="",a=n;const i=t?65:97;for(;a>0;){const c=(a-1)%26;o=String.fromCharCode(i+c)+o,a=Math.floor((a-1)/26)}return o}const nt=[n=>n.toString(),n=>ze(n,!0),n=>`(${n})`,n=>`(${ze(n,!1)})`,n=>`${n})`,n=>`${ze(n,!1)})`,n=>`<${n}>`,n=>`<${ze(n,!1)}>`];function en(){const n=new Array(8).fill(0);return{next(t,o){const a=Qt[t];if(a==null)return"";n[a]++;for(let c=a+1;c<n.length;c++)n[c]=0;if(o!=null&&o!=="")return`${o} `;const i=nt[Math.min(a,nt.length-1)];return`${i(n[a])}. `}}}const Ie=14,ot=760,lt=756,tn={left:"left",center:"center",right:"right",alignment:"justify",justify:"justify"};function at(n){const t=[];let o=!1;const a=i=>{if(o){if(i&&i.value!=null&&/^[\n200B]+$/.test(i.value)){t.push(i);return}o=!1,t.push({...i,_coverBreakBefore:!0})}else t.push(i)};for(const i of n||[]){if(i&&i.type==="pageBreak"){o=!0;continue}if(i&&i.type==="area"){const c=at(i.valueList||[]),y=(i.areaId||"").includes("cover");for(const s of c)a(s);y&&(o=!0)}else a(i)}return t}function Te(n){const t=at(n),o=[];let a=[],i=0,c=null;const y=m=>{a.length&&(o.push({type:"paragraph",elements:[...a],rowFlex:m}),a=[])},s=()=>{if(i===0)return;const m=c;y(m);for(let f=1;f<i;f++)o.push({type:"paragraph",elements:[],rowFlex:m});i=0,c=null};for(const m of t||[])if(m.type==="table")s(),y(),o.push({type:"table",el:m});else if(m.type==="title")s(),y(),o.push({type:"title",el:m});else if(m.type==="list"){s(),y();const f=[];let F=[];for(const I of m.valueList||[])I.value===`
2
+ `||I.value==="​"?(f.push([...F]),F=[]):F.push(I);(F.length||f.length===0)&&f.push([...F]),o.push({type:"list",listType:m.listType||"ul",listStyle:m.listStyle||"disc",items:f})}else if(m.listId){s(),y();const f=m.value==="​"||m.value===""?[]:[m];o.push({type:"list",listType:m.listType||"ul",listStyle:m.listStyle||"disc",items:[f]})}else m.value!=null&&/^[\n200B]+$/.test(m.value)?(i+=m.value.length,m.rowFlex&&(c=m.rowFlex)):(s(),a.push(m));return s(),y(),o}function Be(n){const t=n.filter(f=>f.type==="image").reduce((f,F)=>f+(F.height||F.width||0),0),o=n.filter(f=>f.type!=="image").map(f=>f.value||"").join("");if(!o)return t||20;const a=n.reduce((f,F)=>Math.max(f,F.size||0),0)||14,i=a+6,c=(o.match(/[一-龥]/g)||[]).length,y=o.length-c,s=c*a+y*(a*.5),m=Math.max(1,Math.ceil(s/ot));return t+Math.max(i,m*i)}function nn(n){if(!n||!n.length)return[[]];const t=[];let o=[];for(const a of n)a.type==="image"&&(a.width||0)>=ot?(o.length&&(t.push(o),o=[]),t.push([a])):o.push(a);return o.length&&t.push(o),t.length?t:[[]]}function it(n){if(n.length===0)return[];const t=new Array(n.length).fill(0);n.forEach((c,y)=>{(c.tdList||[]).forEach(s=>{const m=s.rowspan||1;if(m>1){const f=Math.min(y+m-1,n.length-1);t[y]=Math.max(t[y],f);for(let F=1;F<m&&y+F<n.length;F++)t[y+F]=Math.max(t[y+F],f)}})});const o=[];let a=0,i=0;for(let c=0;c<n.length;c++)i=Math.max(i,t[c]),i<=c&&(o.push(n.slice(a,c+1)),a=c+1,i=0);return a<n.length&&o.push(n.slice(a)),o}function qe(n){const t=(n==null?void 0:n.width)||0;return!t||t<=lt?1:lt/t}function rt(n){var c,y;const t=n.elements||[],o=((c=t.find(s=>s.rowFlex))==null?void 0:c.rowFlex)||n.rowFlex,a={textAlign:tn[o]||"left"},i=(y=t.find(s=>s.rowMargin))==null?void 0:y.rowMargin;return i&&(a.lineHeight=i),a}function on(n){var c;const t=Te(n.value);let o=0,a=0,i=!1;for(const y of t)if(y.type==="paragraph"){if(!y.elements.length)continue;o++;for(const s of y.elements)(s.type==="image"||s.type==="table")&&(i=!0),a+=(s.value||"").length}else y.type==="list"?(o+=((c=y.items)==null?void 0:c.length)||1,i=!0):(o++,i=!0);return o>1||a>30||i?"top":n.verticalAlign||"middle"}function ce(n){const t={};n.font&&(t.fontFamily=n.font),t.fontSize=(n.size||Ie)+"px",n.bold!=null&&(t.fontWeight=n.bold?"bold":"normal"),n.italic!=null&&(t.fontStyle=n.italic?"italic":"normal"),n.color&&(t.color=n.color),n.highlight&&n.highlight!=="rgb(255, 255, 255)"&&n.highlight!=="#ffffff"&&(t.backgroundColor=n.highlight);const o=[n.underline&&"underline",n.strikeout&&"line-through"].filter(Boolean).join(" ");return o&&(t.textDecoration=o),n.letterSpacing&&(t.letterSpacing=n.letterSpacing+"px"),t}const ln=5;function st(n,t=!1){var a,i;let o=0;for(const c of n)if(c.type==="table"){const y=((a=c.el)==null?void 0:a.trList)||[];o+=y.reduce((s,m)=>s+(m.height||m.minHeight||35),0)}else if(c.type==="title")o+=Be(c.titleValueList||((i=c.el)==null?void 0:i.valueList)||[]);else if(c.type==="paragraph")o+=Be(c.elements||[]);else if(c.type==="list"){const y=Math.round(18),s=(c.items||[]).reduce((m,f)=>m+(f.length?Be(f):y),0);o+=Math.max(s,y)}return o+(t&&o>0?ln:0)}const an={key:0,class:"empty-line"},rn=["href"],sn=["src"],cn=["checked"],dn=["checked"],hn={key:4,class:"ctrl-input"},fn=["checked"],un=["checked"],gn={key:0},pn=["colspan","rowspan"],mn={key:0},yn=["src"],kn=["href"],bn=["checked"],_n=["checked"],wn=["checked"],Ue=Ce({__name:"DocBlock",props:{block:{type:Object,required:!0},isHeaderFooter:{type:Boolean,default:!1}},setup(n){const t=n,o=e.inject("bindTableObserver",null),a=e.computed(()=>t.isHeaderFooter?0:t.block.indentPx??0);return(i,c)=>{var y;return n.block.blockType==="title"?(e.openBlock(),e.createElementBlock("p",{key:0,class:e.normalizeClass(["doc-title",`doc-title--${n.block.level}`]),style:e.normalizeStyle({paddingLeft:a.value?a.value+"px":void 0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.titleValueList||[],(s,m)=>(e.openBlock(),e.createElementBlock("span",{key:m,style:e.normalizeStyle(e.unref(ce)(s))},e.toDisplayString(s.value),5))),128))],6)):n.block.blockType==="paragraph"?(e.openBlock(),e.createElementBlock("p",{key:1,class:"doc-para",style:e.normalizeStyle({...e.unref(rt)(n.block),paddingLeft:a.value?a.value+"px":void 0})},[n.block.elements.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",an," ")),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.elements,(s,m)=>{var f,F,I,z,_,j,X,R,T,u,E,P,M;return e.openBlock(),e.createElementBlock(e.Fragment,{key:m},[!s.type||s.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(ce)(s))},e.toDisplayString(s.value),5)):s.type==="hyperlink"?(e.openBlock(),e.createElementBlock("a",{key:1,href:s.url,class:"doc-link",target:"_blank",rel:"noopener"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.valueList||[],(L,U)=>(e.openBlock(),e.createElementBlock("span",{key:U,style:e.normalizeStyle(e.unref(ce)(L))},e.toDisplayString(L.value),5))),128))],8,rn)):s.type==="image"?(e.openBlock(),e.createElementBlock("img",{key:2,src:s.value,class:"doc-image",style:e.normalizeStyle({width:s.width?s.width+"px":"auto",height:s.height?s.height+"px":"auto"})},null,12,sn)):s.type==="control"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[((f=s.control)==null?void 0:f.type)==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({fontSize:(s.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.control.value||[],(L,U)=>(e.openBlock(),e.createElementBlock("span",{key:U,style:e.normalizeStyle(e.unref(ce)(L))},e.toDisplayString(L.value),5))),128))],4)):((F=s.control)==null?void 0:F.type)==="input"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"ctrl-input",style:e.normalizeStyle({minWidth:(s.control.minWidth||60)+"px",fontSize:(s.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.control.value||[],(L,U)=>(e.openBlock(),e.createElementBlock("span",{key:U},e.toDisplayString(L.value),1))),128))],4)):((I=s.control)==null?void 0:I.type)==="radio"?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((_=(z=s.control.extension)==null?void 0:z.elementAttributes)==null?void 0:_.layout)==="vertical"}]),style:e.normalizeStyle({fontSize:(s.control.size||e.unref(Ie))+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.control.valueSets||[],(L,U)=>(e.openBlock(),e.createElementBlock("label",{key:U,class:"ctrl-option"},[e.createElementVNode("input",{type:"radio",disabled:"",checked:s.control.code===L.code},null,8,cn),e.createTextVNode(" "+e.toDisplayString(L.value),1)]))),128))],6)):((j=s.control)==null?void 0:j.type)==="checkbox"?(e.openBlock(),e.createElementBlock("span",{key:3,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((R=(X=s.control.extension)==null?void 0:X.elementAttributes)==null?void 0:R.layout)==="vertical"}]),style:e.normalizeStyle({fontSize:(s.control.size||e.unref(Ie))+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.control.valueSets||[],(L,U)=>(e.openBlock(),e.createElementBlock("label",{key:U,class:"ctrl-option"},[e.createElementVNode("input",{type:"checkbox",disabled:"",checked:(s.control.code||"").split(",").includes(L.code)},null,8,dn),e.createTextVNode(" "+e.toDisplayString(L.value),1)]))),128))],6)):((T=s.control)==null?void 0:T.type)==="select"?(e.openBlock(),e.createElementBlock("span",hn,e.toDisplayString(((E=(u=s.control.value)==null?void 0:u[0])==null?void 0:E.value)||s.control.placeholder||""),1)):e.createCommentVNode("",!0)],64)):s.type==="checkbox"?(e.openBlock(),e.createElementBlock("input",{key:4,type:"checkbox",checked:!!((P=s.checkbox)!=null&&P.value),disabled:"",class:"el-check"},null,8,fn)):s.type==="radio"?(e.openBlock(),e.createElementBlock("input",{key:5,type:"radio",checked:!!((M=s.radio)!=null&&M.value),disabled:"",class:"el-check"},null,8,un)):s.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:6,style:e.normalizeStyle(e.unref(ce)(s))},e.toDisplayString(s.value),5)):s.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:7,style:e.normalizeStyle(e.unref(ce)(s))},e.toDisplayString(s.value),5)):s.type==="tab"?(e.openBlock(),e.createElementBlock("span",{key:8,class:"doc-tab",style:e.normalizeStyle({width:(s.size||e.unref(Ie))+"px"})},null,4)):e.createCommentVNode("",!0)],64)}),128))],4)):n.block.blockType==="list"?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.block.listType==="ol"?"ol":"ul"),{key:2,class:"doc-list",style:e.normalizeStyle({listStyleType:n.block.listStyle==="decimal"?"decimal":n.block.listStyle==="lower-alpha"?"lower-alpha":"disc",paddingLeft:a.value?a.value+24+"px":void 0})},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.items,(s,m)=>(e.openBlock(),e.createElementBlock("li",{key:m,class:"doc-list-item"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s,(f,F)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:F},[!f.type||f.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(ce)(f))},e.toDisplayString(f.value),5)):f.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:1,style:e.normalizeStyle(e.unref(ce)(f))},e.toDisplayString(f.value),5)):f.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:2,style:e.normalizeStyle(e.unref(ce)(f))},e.toDisplayString(f.value),5)):e.createCommentVNode("",!0)],64))),128))]))),128))]),_:1},8,["style"])):n.block.blockType==="table-row-group"?(e.openBlock(),e.createElementBlock("div",{key:3,class:e.normalizeClass(["doc-table-row-wrap",{"is-first":n.block.isFirst,"is-last":n.block.isLast,"is-page-break":n.block.isPageBreak}]),style:e.normalizeStyle({display:n.block.tableRowFlex?"flex":void 0,justifyContent:n.block.tableRowFlex==="right"?"flex-end":n.block.tableRowFlex==="center"?"center":n.block.tableRowFlex==="left"?"flex-start":void 0,paddingLeft:a.value?a.value+"px":void 0})},[e.createElementVNode("div",{style:e.normalizeStyle({overflow:n.block.sliceHeight!=null?"hidden":void 0,height:n.block.sliceHeight!=null?(n.block.isLast?n.block.sliceHeight+1:n.block.sliceHeight)+"px":void 0,width:n.block.tableEl.width?"max-content":"100%"})},[e.createElementVNode("table",{ref:n.block._baseKey&&e.unref(o)?s=>e.unref(o)(s,n.block._baseKey):void 0,class:e.normalizeClass(["doc-table",{"doc-table--no-border":n.block.tableEl.borderType==="empty"}]),style:e.normalizeStyle({width:n.block.tableEl.width?n.block.tableEl.width*e.unref(qe)(n.block.tableEl)+"px":"100%",transform:n.block.sliceOffset?`translateY(-${n.block.sliceOffset}px)`:void 0})},[(y=n.block.tableEl.colgroup)!=null&&y.length?(e.openBlock(),e.createElementBlock("colgroup",gn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.tableEl.colgroup,(s,m)=>(e.openBlock(),e.createElementBlock("col",{key:m,style:e.normalizeStyle({width:s.width*e.unref(qe)(n.block.tableEl)+"px"})},null,4))),128))])):e.createCommentVNode("",!0),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.block.trGroup,(s,m)=>(e.openBlock(),e.createElementBlock("tr",{key:m,style:e.normalizeStyle({height:(s.height||s.minHeight||30)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.tdList||[],(f,F)=>(e.openBlock(),e.createElementBlock("td",{key:F,colspan:f.colspan||1,rowspan:f.rowspan||1,style:e.normalizeStyle({backgroundColor:f.backgroundColor||void 0,verticalAlign:e.unref(on)(f),width:f.width?f.width*e.unref(qe)(n.block.tableEl)+"px":void 0,height:f.height?f.height+"px":void 0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(Te)(f.value),(I,z)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:z},[I.type==="paragraph"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"cell-para",style:e.normalizeStyle(e.unref(rt)(I))},[I.elements.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",mn," ")),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.elements,(_,j)=>{var X,R,T,u,E,P,M;return e.openBlock(),e.createElementBlock(e.Fragment,{key:j},[!_.type||_.type==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle(e.unref(ce)(_))},e.toDisplayString(_.value),5)):_.type==="image"?(e.openBlock(),e.createElementBlock("img",{key:1,src:_.value,class:"doc-image",style:e.normalizeStyle({width:_.width?_.width+"px":"auto",height:_.height?_.height+"px":"auto"})},null,12,yn)):_.type==="hyperlink"?(e.openBlock(),e.createElementBlock("a",{key:2,href:_.url,class:"doc-link",target:"_blank"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.valueList||[],(L,U)=>(e.openBlock(),e.createElementBlock("span",{key:U,style:e.normalizeStyle(e.unref(ce)(L))},e.toDisplayString(L.value),5))),128))],8,kn)):_.type==="control"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[((X=_.control)==null?void 0:X.type)==="text"?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({fontSize:(_.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.control.value||[],(L,U)=>(e.openBlock(),e.createElementBlock("span",{key:U,style:e.normalizeStyle(e.unref(ce)(L))},e.toDisplayString(L.value),5))),128))],4)):((R=_.control)==null?void 0:R.type)==="input"?(e.openBlock(),e.createElementBlock("span",{key:1,class:"ctrl-input",style:e.normalizeStyle({fontSize:(_.control.size||12)+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.control.value||[],(L,U)=>(e.openBlock(),e.createElementBlock("span",{key:U},e.toDisplayString(L.value),1))),128))],4)):((T=_.control)==null?void 0:T.type)==="radio"?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(["ctrl-options",{"ctrl-options--vertical":((E=(u=_.control.extension)==null?void 0:u.elementAttributes)==null?void 0:E.layout)==="vertical"}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.control.valueSets||[],(L,U)=>(e.openBlock(),e.createElementBlock("label",{key:U,class:"ctrl-option"},[e.createElementVNode("input",{type:"radio",disabled:"",checked:_.control.code===L.code},null,8,bn),e.createTextVNode(e.toDisplayString(L.value),1)]))),128))],2)):e.createCommentVNode("",!0)],64)):_.type==="checkbox"?(e.openBlock(),e.createElementBlock("input",{key:4,type:"checkbox",checked:!!((P=_.checkbox)!=null&&P.value),disabled:"",class:"el-check"},null,8,_n)):_.type==="radio"?(e.openBlock(),e.createElementBlock("input",{key:5,type:"radio",checked:!!((M=_.radio)!=null&&M.value),disabled:"",class:"el-check"},null,8,wn)):_.type==="superscript"?(e.openBlock(),e.createElementBlock("sup",{key:6,style:e.normalizeStyle(e.unref(ce)(_))},e.toDisplayString(_.value),5)):_.type==="subscript"?(e.openBlock(),e.createElementBlock("sub",{key:7,style:e.normalizeStyle(e.unref(ce)(_))},e.toDisplayString(_.value),5)):_.type==="tab"?(e.openBlock(),e.createElementBlock("span",{key:8,class:"doc-tab",style:e.normalizeStyle({width:(_.size||e.unref(Ie))+"px"})},null,4)):e.createCommentVNode("",!0)],64)}),128))],4)):e.createCommentVNode("",!0)],64))),128))],12,pn))),128))],4))),128))])],6)],4)],6)):e.createCommentVNode("",!0)}}},[["__scopeId","data-v-27e51e18"]]),xn={class:"editor-layout word-editor-scope"},En={class:"editor-container"},Cn={key:0,class:"editor-loading"},Bn={class:"doc-header"},Mn={class:"doc-footer"},Sn={class:"doc-page-number"},Fn=1123,In=50,Tn=20,An=Ce({__name:"index",props:{data:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1}},setup(n){const t=n,o=e.computed(()=>{const u=t.data;return u?!Array.isArray(u)&&u.main?u.main:Array.isArray(u)?u:[]:[]}),a=e.ref(null),i=e.ref({});let c=null;e.onMounted(()=>{c=new ResizeObserver(u=>{const E={};for(const P of u){const M=P.target._rowKey;if(!M)continue;const L=Math.round(P.contentRect.height);L>(i.value[M]||0)&&(E[M]=L)}Object.keys(E).length&&(i.value={...i.value,...E})})}),e.onUnmounted(()=>{c==null||c.disconnect(),c=null});function y(u,E){!u||!c||(u._rowKey=E,c.observe(u))}e.provide("bindTableObserver",y);const s=e.computed(()=>Math.max(100,Fn-In*2-I.value-z.value-Tn)),m=e.computed(()=>{const u=Te(o.value),E=[],P=s.value;let M=0;const L=en(),U={first:0,second:1,third:2,fourth:3,fifth:4,sixth:5,seventh:6,eighth:7};let Z=-1;const Xe=N=>{var ie,de,ge;return!!((ie=N.el)!=null&&ie._coverBreakBefore||(ge=(de=N.elements)==null?void 0:de[0])!=null&&ge._coverBreakBefore)};return u.forEach((N,ie)=>{var ge,Pe,_e,Ye;const de=Xe(N);if(de&&(M=0),N.type==="title"){const he=N.el.valueList||[],ne=L.next(N.el.level,(ge=N.el.extension)==null?void 0:ge.startIndex),oe=he.some(Q=>{var le;return(le=Q.extension)==null?void 0:le.isIndex});let ue=he;if(!oe&&ne){const Q=he[0]||{};ue=[{value:ne,size:Q.size,bold:Q.bold,italic:Q.italic,color:Q.color,font:Q.font,extension:{isIndex:!0}},...he]}const pe=ue.map(Q=>Q.value||"").join(""),re=Be(ue);M=M+re>P&&M>0?re:M+re,Z=U[N.el.level]??0,E.push({node_id:`blk_${ie}_0`,layer:de?1:100,blockType:"title",level:N.el.level,titleEl:N.el,titleValueList:ue,content_type:"text",content:pe,height:re,indentPx:Z*20})}else if(N.type==="paragraph"){const he=nn(N.elements),ne=Z>=0?(Z+1)*20:0;he.forEach((oe,ue)=>{const pe=oe.map(Q=>Q.value||"").join(""),re=Be(oe);M=M+re>P&&M>0?re:M+re,E.push({node_id:`blk_${ie}_${ue}`,layer:de&&ue===0?1:100,blockType:"paragraph",elements:oe,rowFlex:N.rowFlex,content_type:"text",content:pe,height:re,indentPx:ne})})}else if(N.type==="table"){const he=!!((Pe=N.el.extension)!=null&&Pe.isTitleTable),ne=((_e=N.el.extension)==null?void 0:_e.elementType)==="signOff",oe=((Ye=N.el.extension)==null?void 0:Ye.elementType)==="stepTable",ue=ne||oe,pe=he||ne?0:Z>=0?(Z+1)*20:0,re=it(N.el.trList||[]),Q=re.length;if(ue){const le=re.flat(),se=le.reduce((W,G)=>W+(G.height||G.minHeight||35),0),me=`blk_${ie}_0`,H=Math.max(se,i.value[me]||0);if(M>0&&M+H>P&&(M=0),H>P){const W=Math.ceil(H/P);for(let G=0;G<W;G++){const ee=G*P,ye=Math.min(P,H-ee),we=G>0||M>0;M=ye,E.push({node_id:`blk_${ie}_0_s${G}`,layer:de&&G===0?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:H,trGroup:le,tableEl:N.el,tableRowFlex:N.el.rowFlex||null,isFirst:G===0,isLast:G===W-1,isPageBreak:we,sliceOffset:ee,sliceHeight:ye,_baseKey:G===0?me:void 0,height:ye,indentPx:pe})}}else{const W=M>0;M=M+H>P?H:M+H,E.push({node_id:`blk_${ie}_0`,layer:de?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:H,trGroup:le,tableEl:N.el,tableRowFlex:N.el.rowFlex||null,isFirst:!0,isLast:!0,isPageBreak:W,indentPx:pe})}}else re.forEach((le,se)=>{const me=`blk_${ie}_${se}`,H=le.reduce((G,ee)=>G+(ee.height||ee.minHeight||35),0),W=Math.max(H,i.value[me]||0);if(W>P){const G=Math.ceil(W/P);for(let ee=0;ee<G;ee++){const ye=ee*P,we=Math.min(P,W-ye),He=ee>0||M>0;M=we,E.push({node_id:`blk_${ie}_${se}_s${ee}`,layer:de&&se===0&&ee===0?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:W,trGroup:le,tableEl:N.el,tableRowFlex:N.el.rowFlex||null,isFirst:se===0&&ee===0,isLast:se===Q-1&&ee===G-1,isPageBreak:He,sliceOffset:ye,sliceHeight:we,_baseKey:ee===0?me:void 0,height:we,indentPx:pe})}}else{const G=se>0&&M+W>P;M=M+W>P?W:M+W,E.push({node_id:`blk_${ie}_${se}`,layer:de&&se===0?1:100,blockType:"table-row-group",content_type:"table-row",rowHeight:W,trGroup:le,tableEl:N.el,tableRowFlex:N.el.rowFlex||null,isFirst:se===0,isLast:se===Q-1,isPageBreak:G,indentPx:pe})}})}else if(N.type==="list"){const he=Math.round(18);let ne=0;for(const oe of N.items)ne+=oe.length?Be(oe):he;ne=Math.max(ne,he),M=M+ne>P&&M>0?ne:M+ne,E.push({node_id:`blk_${ie}_0`,layer:de?1:100,blockType:"list",listType:N.listType,listStyle:N.listStyle,items:N.items,height:ne,indentPx:Z>=0?(Z+1)*20:0})}}),E}),f=e.computed(()=>{var E;const u=(E=t.data)==null?void 0:E.header;return u!=null&&u.length?Te(u):[]}),F=e.computed(()=>{var E;const u=(E=t.data)==null?void 0:E.footer;return u!=null&&u.length?Te(u):[]}),I=e.computed(()=>st(f.value,!0)),z=e.computed(()=>st(F.value,!0)),_=e.computed(()=>f.value.length>0),j=e.computed(()=>F.value.length>0);function X(u){var P,M,L;const E=u.type==="table";return{blockType:E?"table-row-group":u.type,elements:u.elements,rowFlex:u.rowFlex,level:(P=u.el)==null?void 0:P.level,titleValueList:((M=u.el)==null?void 0:M.valueList)||u.titleValueList,listType:u.listType,listStyle:u.listStyle,items:u.items,indentPx:0,trGroup:E?it(u.el.trList).flat():void 0,tableEl:E?u.el:void 0,isFirst:!0,isLast:!0,tableRowFlex:((L=u.el)==null?void 0:L.rowFlex)||null}}const R=e.computed(()=>Zt(m.value));function T(u){var E;(E=a.value)==null||E.scrollToRow({node_id:u.nodeId})}return(u,E)=>(e.openBlock(),e.createElementBlock("div",xn,[e.createVNode(Jt,{items:R.value,onNavigate:T},null,8,["items"]),e.createElementVNode("div",En,[n.loading?(e.openBlock(),e.createElementBlock("div",Cn," 加载中… ")):(e.openBlock(),e.createBlock(e.unref($t),{key:1,ref_key:"virtualTableRef",ref:a,"show-header":!1,"row-config":{keyField:"node_id"},"page-config":{enabled:!0,pageHeight:1123,pageWidth:860,margin:50,gap:16,showPageHeader:_.value,showPageBorder:!0,pageBorderPadding:5,pageBorderStyle:"1px solid #333",headerHeight:I.value,footerHeight:z.value,showPageNumber:!0},data:m.value},e.createSlots({default:e.withCtx(()=>[e.createVNode(e.unref(Dt),null,{default:e.withCtx(({row:P})=>[e.createVNode(Ue,{block:P},null,8,["block"])]),_:1})]),_:2},[_.value?{name:"page-header",fn:e.withCtx(()=>[e.createElementVNode("div",Bn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(P,M)=>(e.openBlock(),e.createBlock(Ue,{key:M,block:X(P),"is-header-footer":!0},null,8,["block"]))),128))])]),key:"0"}:void 0,j.value?{name:"page-footer",fn:e.withCtx(({pageNumber:P,totalPages:M})=>[e.createElementVNode("div",Mn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.value,(L,U)=>(e.openBlock(),e.createBlock(Ue,{key:U,block:X(L),"is-header-footer":!0},null,8,["block"]))),128)),e.createElementVNode("div",Sn,e.toDisplayString(P)+" / "+e.toDisplayString(M),1)])]),key:"1"}:void 0]),1032,["page-config","data"]))])]))}},[["__scopeId","data-v-ea9b9852"]]),ct="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Re(n=10){const t=crypto.getRandomValues(new Uint8Array(n));return Array.from(t).map(o=>ct[o%ct.length]).join("")}class De{constructor(t){O(this,"data");this.data=e.reactive({id:Re(),version:1,sections:[this.createEmptySection()],pageWidth:595,pageHeight:842,marginTop:72,marginBottom:72,marginLeft:90,marginRight:90,...t})}createEmptySection(){return{id:Re(),paragraphs:[this.createEmptyParagraph()]}}createEmptyParagraph(t){return{id:Re(),type:"paragraph",format:t??{},children:[]}}createTextElement(t,o){return{id:Re(),type:"text",value:t,format:o??{}}}getSectionCount(){return this.data.sections.length}getParagraphCount(t=0){var o;return((o=this.data.sections[t])==null?void 0:o.paragraphs.length)??0}getAllParagraphs(){const t=[];return this.data.sections.forEach((o,a)=>{o.paragraphs.forEach((i,c)=>{t.push({paragraph:i,sectionIndex:a,paragraphIndex:c})})}),t}getParagraphAt(t,o){var a;return((a=this.data.sections[t])==null?void 0:a.paragraphs[o])??null}getElementAt(t){const o=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);return(o==null?void 0:o.children[t.elementIndex])??null}insertText(t,o,a){const i=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);if(!i)return;const c=i.children[t.elementIndex];if(c&&c.type==="text")c.value=c.value.slice(0,t.offset)+o+c.value.slice(t.offset);else{const y=this.createTextElement(o,a);i.children.splice(t.elementIndex,0,y)}this.bumpVersion()}deleteAt(t,o){const a=this.getParagraphAt(t.sectionIndex,t.paragraphIndex);if(!a)return;const i=a.children[t.elementIndex];!i||i.type!=="text"||(i.value=i.value.slice(0,t.offset)+i.value.slice(t.offset+o),i.value===""&&a.children.splice(t.elementIndex,1),this.bumpVersion())}insertParagraph(t,o,a){const i=this.data.sections[t];if(!i)throw new Error(`Section ${t} not found`);const c=this.createEmptyParagraph(a);return i.paragraphs.splice(o+1,0,c),this.bumpVersion(),c}mergeParagraphs(t,o){const a=this.data.sections[t];if(!a)return;const i=a.paragraphs[o],c=a.paragraphs[o+1];!i||!c||(i.children.push(...c.children),a.paragraphs.splice(o+1,1),this.bumpVersion())}updateParagraphFormat(t,o,a){const i=this.getParagraphAt(t,o);i&&(i.format={...i.format,...a},this.bumpVersion())}updateElementFormat(t,o){const a=this.getElementAt(t);a&&(a.format={...a.format,...o},this.bumpVersion())}updateRangeFormat(t,o,a){const i=this.getAllParagraphs();let c=!1;for(const{paragraph:y,sectionIndex:s,paragraphIndex:m}of i){const f=s===t.sectionIndex&&m===t.paragraphIndex,F=s===o.sectionIndex&&m===o.paragraphIndex;if(f&&(c=!0),c)for(let I=0;I<y.children.length;I++){const z=y.children[I];if(!(f&&I<t.elementIndex)){if(F&&I>o.elementIndex)break;z.format={...z.format,...a}}}if(F)break}this.bumpVersion()}bumpVersion(){this.data.version++}toJSON(){return JSON.stringify(this.data,null,2)}static fromJSON(t){const o=JSON.parse(t),a=new De;return Object.assign(a.data,o),a}}function be(n=0,t=0,o=0,a=0){return{sectionIndex:n,paragraphIndex:t,elementIndex:o,offset:a}}function dt(n,t){return n.sectionIndex===t.sectionIndex&&n.paragraphIndex===t.paragraphIndex&&n.elementIndex===t.elementIndex&&n.offset===t.offset}class We{constructor(t){O(this,"_selection",e.reactive({anchor:be(),focus:be(),isCollapsed:!0}));O(this,"_docModel");O(this,"hasSelection",e.computed(()=>!this._selection.isCollapsed));this._docModel=t}get selection(){return this._selection}setCursor(t){this._selection.anchor={...t},this._selection.focus={...t},this._selection.isCollapsed=!0}setSelection(t,o){this._selection.anchor={...t},this._selection.focus={...o},this._selection.isCollapsed=dt(t,o)}collapse(t=!0){t?this._selection.anchor={...this._selection.focus}:this._selection.focus={...this._selection.anchor},this._selection.isCollapsed=!0}selectAll(){const t=this._docModel.data.sections,o=t[t.length-1],a=o==null?void 0:o.paragraphs[o.paragraphs.length-1],i=a==null?void 0:a.children[a.children.length-1],c=(i==null?void 0:i.type)==="text"?i.value.length:0;this._selection.anchor=be(0,0,0,0),this._selection.focus=be(t.length-1,((o==null?void 0:o.paragraphs.length)??1)-1,((a==null?void 0:a.children.length)??0)===0?0:((a==null?void 0:a.children.length)??1)-1,c),this._selection.isCollapsed=!1}moveForward(t=!1){const o=this._selection.focus,a=this._docModel.getParagraphAt(o.sectionIndex,o.paragraphIndex);if(!a)return;const i=a.children[o.elementIndex];if((i==null?void 0:i.type)==="text"&&o.offset<i.value.length){const y={...o,offset:o.offset+1};this._applyMove(y,t);return}if(o.elementIndex<a.children.length-1){const y={...o,elementIndex:o.elementIndex+1,offset:0};this._applyMove(y,t);return}const c=this._getNextParagraphPoint(o);c&&this._applyMove(c,t)}moveBackward(t=!1){const o=this._selection.focus;if(o.offset>0){const i={...o,offset:o.offset-1};this._applyMove(i,t);return}if(o.elementIndex>0){const i=this._docModel.getParagraphAt(o.sectionIndex,o.paragraphIndex),c=i==null?void 0:i.children[o.elementIndex-1],y=(c==null?void 0:c.type)==="text"?c.value.length:0,s={...o,elementIndex:o.elementIndex-1,offset:y};this._applyMove(s,t);return}const a=this._getPrevParagraphPoint(o);a&&this._applyMove(a,t)}_applyMove(t,o){o?(this._selection.focus=t,this._selection.isCollapsed=dt(this._selection.anchor,t)):(this._selection.anchor={...t},this._selection.focus={...t},this._selection.isCollapsed=!0)}_getNextParagraphPoint(t){const o=this._docModel.data.sections[t.sectionIndex];return o?t.paragraphIndex<o.paragraphs.length-1?be(t.sectionIndex,t.paragraphIndex+1,0,0):t.sectionIndex<this._docModel.data.sections.length-1?be(t.sectionIndex+1,0,0,0):null:null}_getPrevParagraphPoint(t){if(t.paragraphIndex>0){const o=this._docModel.getParagraphAt(t.sectionIndex,t.paragraphIndex-1);if(!o)return null;const a=o.children.length-1,i=o.children[a],c=(i==null?void 0:i.type)==="text"?i.value.length:0;return be(t.sectionIndex,t.paragraphIndex-1,Math.max(a,0),c)}if(t.sectionIndex>0){const o=this._docModel.data.sections[t.sectionIndex-1];if(!o)return null;const a=o.paragraphs.length-1,i=o.paragraphs[a],c=((i==null?void 0:i.children.length)??0)-1,y=i==null?void 0:i.children[c],s=(y==null?void 0:y.type)==="text"?y.value.length:0;return be(t.sectionIndex-1,a,Math.max(c,0),s)}return null}static domToModelPoint(t,o){let a=t instanceof Element?t:t.parentElement;for(;a;){const i=a.getAttribute("data-si"),c=a.getAttribute("data-pi"),y=a.getAttribute("data-ei");if(i!==null&&c!==null&&y!==null)return{sectionIndex:parseInt(i),paragraphIndex:parseInt(c),elementIndex:parseInt(y),offset:o};a=a.parentElement}return null}}const Pn=200;class Ln{constructor(){O(this,"_undoStack",[]);O(this,"_redoStack",[])}get canUndo(){return this._undoStack.length>0}get canRedo(){return this._redoStack.length>0}push(t){var a,i;this._redoStack=[];const o=this._undoStack[this._undoStack.length-1];if(o&&((a=t.canMergeWith)!=null&&a.call(t,o))){(i=o.merge)==null||i.call(o,t);return}this._undoStack.push(t),this._undoStack.length>Pn&&this._undoStack.shift()}undo(){const t=this._undoStack.pop();return t?(t.undo(),this._redoStack.push(t),!0):!1}redo(){const t=this._redoStack.pop();return t?(t.execute(),this._undoStack.push(t),!0):!1}clear(){this._undoStack=[],this._redoStack=[]}}class $n{constructor(t,o,a,i,c){O(this,"name","insertText");O(this,"_point");O(this,"_text");O(this,"_format");this.docModel=t,this.selectionManager=o,this._point={...a},this._text=i,this._format=c}execute(){this.docModel.insertText(this._point,this._text,this._format),this.selectionManager.setCursor({...this._point,offset:this._point.offset+this._text.length})}undo(){this.docModel.deleteAt(this._point,this._text.length),this.selectionManager.setCursor(this._point)}canMergeWith(t){if(t.name!=="insertText")return!1;const o=t;return o._point.sectionIndex===this._point.sectionIndex&&o._point.paragraphIndex===this._point.paragraphIndex&&o._point.elementIndex===this._point.elementIndex&&o._point.offset===this._point.offset+this._text.length}merge(t){const o=t;this._text+=o._text}}class zn{constructor(t,o){O(this,"name","insertParagraph");O(this,"_insertedParagraphId",null);this.docModel=t,this.selectionManager=o}execute(){var m,f;const{focus:t}=this.selectionManager.selection,{sectionIndex:o,paragraphIndex:a}=t,i=this.docModel.getParagraphAt(o,a);if(!i)return;const c=t.elementIndex,y=i.children.splice(c),s=this.docModel.createEmptyParagraph(i.format);s.children.push(...y),this._insertedParagraphId=s.id,this.docModel.data.sections[o].paragraphs.splice(a+1,0,s),(f=(m=this.docModel).bumpVersion)==null||f.call(m),this.selectionManager.setCursor({sectionIndex:o,paragraphIndex:a+1,elementIndex:0,offset:0})}undo(){const{focus:t}=this.selectionManager.selection,{sectionIndex:o,paragraphIndex:a}=t;a!==0&&(this.docModel.mergeParagraphs(o,a-1),this.selectionManager.setCursor({sectionIndex:o,paragraphIndex:a-1,elementIndex:0,offset:0}))}}class ht{constructor(t,o,a){O(this,"name");O(this,"_deletedText","");this.docModel=t,this.selectionManager=o,this.name=a==="backward"?"deleteBackward":"deleteForward"}execute(){const{focus:t,isCollapsed:o}=this.selectionManager.selection;if(o)if(this.name==="deleteBackward")if(t.offset>0){const a={...t,offset:t.offset-1},i=this.docModel.getElementAt(t);(i==null?void 0:i.type)==="text"&&(this._deletedText=i.value[t.offset-1]??""),this.docModel.deleteAt(a,1),this.selectionManager.setCursor(a)}else(t.paragraphIndex>0||t.elementIndex>0)&&(this.docModel.mergeParagraphs(t.sectionIndex,t.paragraphIndex-1),this.selectionManager.setCursor({...t,paragraphIndex:t.paragraphIndex-1}));else{const a=this.docModel.getElementAt(t);if((a==null?void 0:a.type)==="text"&&t.offset<a.value.length)this._deletedText=a.value[t.offset],this.docModel.deleteAt(t,1);else{const i=this.docModel.data.sections[t.sectionIndex];i&&t.paragraphIndex<i.paragraphs.length-1&&this.docModel.mergeParagraphs(t.sectionIndex,t.paragraphIndex)}}}undo(){if(this._deletedText){const{focus:t}=this.selectionManager.selection;this.docModel.insertText(t,this._deletedText)}}}class Ae{constructor(t,o,a,i){O(this,"name");O(this,"_prevFormat",{});this.docModel=t,this.selectionManager=o,this._value=i,this.name=a}execute(){const{anchor:t,focus:o}=this.selectionManager.selection,a=this._getFormatKey();if(!a)return;const i={};if(this._isToggle()){const c=this._getCurrentValue(a);i[a]=!c}else i[a]=this._value;this.docModel.updateRangeFormat(t,o,i)}undo(){const{anchor:t,focus:o}=this.selectionManager.selection;this.docModel.updateRangeFormat(t,o,this._prevFormat)}_isToggle(){return["bold","italic","underline","strikethrough","superscript","subscript"].includes(this.name)}_getFormatKey(){return{bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",fontSize:"fontSize",fontFamily:"fontFamily",color:"color",backgroundColor:"backgroundColor"}[this.name]??null}_getCurrentValue(t){var i;const{focus:o}=this.selectionManager.selection,a=this.docModel.getElementAt(o);return(i=a==null?void 0:a.format)==null?void 0:i[t]}}class Ge{constructor(t,o,a,i){O(this,"name","textAlign");this.docModel=t,this.selectionManager=o,this._formatKey=a,this._value=i}execute(){const{focus:t}=this.selectionManager.selection,o={};o[this._formatKey]=this._value,this.docModel.updateParagraphFormat(t.sectionIndex,t.paragraphIndex,o)}undo(){}}class Rn{constructor(t,o,a){O(this,"_factories",new Map);this.docModel=t,this.selectionManager=o,this.historyManager=a,this._registerBuiltinCommands()}_registerBuiltinCommands(){this.register("insertText",o=>{const{focus:a}=this.selectionManager.selection;return new $n(this.docModel,this.selectionManager,a,o)}),this.register("insertParagraph",()=>new zn(this.docModel,this.selectionManager)),this.register("deleteBackward",()=>new ht(this.docModel,this.selectionManager,"backward")),this.register("deleteForward",()=>new ht(this.docModel,this.selectionManager,"forward")),this.register("undo",()=>null),this.register("redo",()=>null),["bold","italic","underline","strikethrough","superscript","subscript"].forEach(o=>{this.register(o,()=>new Ae(this.docModel,this.selectionManager,o))}),this.register("fontSize",o=>new Ae(this.docModel,this.selectionManager,"fontSize",o)),this.register("fontFamily",o=>new Ae(this.docModel,this.selectionManager,"fontFamily",o)),this.register("color",o=>new Ae(this.docModel,this.selectionManager,"color",o)),this.register("backgroundColor",o=>new Ae(this.docModel,this.selectionManager,"backgroundColor",o)),this.register("textAlign",o=>new Ge(this.docModel,this.selectionManager,"textAlign",o)),this.register("lineHeight",o=>new Ge(this.docModel,this.selectionManager,"lineHeight",o)),this.register("heading",o=>new Ge(this.docModel,this.selectionManager,"heading",o)),this.register("selectAll",()=>(this.selectionManager.selectAll(),null)),this.register("setSelection",o=>{if(o){const a=o;this.selectionManager.setSelection(a.anchor,a.focus)}return null})}register(t,o){this._factories.set(t,o)}exec(t,o){if(t==="undo"){this.historyManager.undo();return}if(t==="redo"){this.historyManager.redo();return}const a=this._factories.get(t);if(!a){console.warn(`[CommandManager] 未注册命令: ${t}`);return}const i=a(o);i&&(i.execute(),this.historyManager.push(i))}}class Dn{constructor(t,o){O(this,"_el",null);O(this,"_commandManager");O(this,"_selectionManager");O(this,"_composing",!1);O(this,"_boundKeydown");O(this,"_boundBeforeInput");O(this,"_boundCompositionStart");O(this,"_boundCompositionEnd");O(this,"_boundSelectionChange");this._commandManager=t,this._selectionManager=o,this._boundKeydown=this._onKeydown.bind(this),this._boundBeforeInput=this._onBeforeInput.bind(this),this._boundCompositionStart=()=>{this._composing=!0},this._boundCompositionEnd=this._onCompositionEnd.bind(this),this._boundSelectionChange=this._onSelectionChange.bind(this)}attach(t){this._el=t,t.addEventListener("keydown",this._boundKeydown),t.addEventListener("beforeinput",this._boundBeforeInput),t.addEventListener("compositionstart",this._boundCompositionStart),t.addEventListener("compositionend",this._boundCompositionEnd),document.addEventListener("selectionchange",this._boundSelectionChange)}detach(){this._el&&(this._el.removeEventListener("keydown",this._boundKeydown),this._el.removeEventListener("beforeinput",this._boundBeforeInput),this._el.removeEventListener("compositionstart",this._boundCompositionStart),this._el.removeEventListener("compositionend",this._boundCompositionEnd),document.removeEventListener("selectionchange",this._boundSelectionChange),this._el=null)}_onKeydown(t){const o=t.key,a=t.ctrlKey||t.metaKey,i=t.shiftKey;if(a)switch(o){case"z":t.preventDefault(),i?this._commandManager.exec("redo"):this._commandManager.exec("undo");return;case"b":t.preventDefault(),this._commandManager.exec("bold");return;case"i":t.preventDefault(),this._commandManager.exec("italic");return;case"u":t.preventDefault(),this._commandManager.exec("underline");return;case"a":t.preventDefault(),this._commandManager.exec("selectAll");return}switch(o){case"Enter":t.preventDefault(),this._composing||this._commandManager.exec("insertParagraph");break;case"Backspace":t.preventDefault(),this._composing||this._commandManager.exec("deleteBackward");break;case"Delete":t.preventDefault(),this._composing||this._commandManager.exec("deleteForward");break;case"ArrowLeft":t.preventDefault(),this._selectionManager.moveBackward(i);break;case"ArrowRight":t.preventDefault(),this._selectionManager.moveForward(i);break;case"Tab":t.preventDefault(),this._commandManager.exec("insertText"," ");break}}_onBeforeInput(t){t.preventDefault(),!this._composing&&t.data&&this._commandManager.exec("insertText",t.data)}_onCompositionEnd(t){this._composing=!1,t.data&&this._commandManager.exec("insertText",t.data)}_onSelectionChange(){const t=window.getSelection();if(!t||!this._el)return;const o=t.anchorNode,a=t.focusNode;if(!o||!a||!this._el.contains(o)&&!this._el.contains(a))return;const i=We.domToModelPoint(o,t.anchorOffset),c=We.domToModelPoint(a,t.focusOffset);i&&c&&this._selectionManager.setSelection(i,c)}}class ft{constructor(t={}){O(this,"docModel");O(this,"selection");O(this,"history");O(this,"commands");O(this,"input");O(this,"_readonly");O(this,"_plugins",[]);O(this,"_inputEl",null);var o;this._readonly=t.readonly??!1,this.docModel=new De(t.initialDocument),this.selection=new We(this.docModel),this.history=new Ln,this.commands=new Rn(this.docModel,this.selection,this.history),this.input=new Dn(this.commands,this.selection),(o=t.plugins)==null||o.forEach(a=>this.use(a))}exec(t,o){if(this._readonly&&!this._isReadCommand(t)){console.warn("[Editor] 只读模式,忽略写操作");return}this.commands.exec(t,o)}mount(t){this._inputEl=t,this._readonly||this.input.attach(t)}unmount(){this.input.detach(),this._inputEl=null}use(t){return this._plugins.find(o=>o.name===t.name)?(console.warn(`[Editor] 插件 ${t.name} 已安装`),this):(t.install(this),this._plugins.push(t),this)}getJSON(){return this.docModel.toJSON()}loadJSON(t){const o=De.fromJSON(t);Object.assign(this.docModel.data,o.data),this.history.clear()}get isReadonly(){return this._readonly}_isReadCommand(t){return["undo","redo","selectAll","setSelection"].includes(t)}}const Je=Symbol("editor");function Hn(n){const t=new ft(n);return e.provide(Je,t),e.onUnmounted(()=>{t.unmount()}),t}function On(){const n=e.inject(Je);if(!n)throw new Error("[useEditor] 必须在 EditorContainer 组件内使用");return n}const ut=An,Nn={install(n){n.component("EditorContainer",ut)}};J.Editor=ft,J.EditorContainer=ut,J.EditorKey=Je,J.createEditor=Hn,J.default=Nn,J.useEditor=On,Object.defineProperties(J,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bireturn/word-editor",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "类 Word 的 Web 富文本编辑器,基于canvas-editor的数据结构渲染",
5
5
  "type": "module",
6
6
  "files": [