@eigenpal/docx-editor-vue 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{KeyboardShortcutsDialog-00eb4Ova.js → KeyboardShortcutsDialog-BbuDgglK.js} +14 -4
- package/dist/KeyboardShortcutsDialog-Bct8AJ0i.cjs +1 -0
- package/dist/{MenuBar-DeogoqFP.js → MenuBar-CbONA9-a.js} +571 -522
- package/dist/MenuBar-m0JEaF1X.cjs +4 -0
- package/dist/{TablePropertiesDialog-CBTvM4Xy.js → TablePropertiesDialog-D5MIF3cj.js} +1 -1
- package/dist/{TablePropertiesDialog-BZLpFAkg.cjs → TablePropertiesDialog-JWT68zEO.cjs} +1 -1
- package/dist/components/DocxEditor/types.d.ts +23 -1
- package/dist/components/Toolbar/presets.d.ts +12 -33
- package/dist/composables/useCommentLifecycle.d.ts +6 -1
- package/dist/composables/useCommentManagement.d.ts +18 -1
- package/dist/composables/useHostCallbacks.d.ts +7 -0
- package/dist/composables.cjs +1 -1
- package/dist/composables.js +1 -1
- package/dist/dialogs.cjs +1 -1
- package/dist/dialogs.js +2 -2
- package/dist/docx-editor-vue.css +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +1073 -1027
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +141 -141
- package/dist/{useDragAutoScroll-BT6oPYBj.cjs → useDragAutoScroll-DNMi0p5G.cjs} +1 -1
- package/dist/{useDragAutoScroll-C56F_WS_.js → useDragAutoScroll-DbxuTWI1.js} +37 -37
- package/package.json +4 -4
- package/dist/KeyboardShortcutsDialog-EW9K4wuO.cjs +0 -1
- package/dist/MenuBar-bU4-4dnA.cjs +0 -4
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./KeyboardShortcutsDialog-EW9K4wuO.cjs`),t=require(`./MenuBar-bU4-4dnA.cjs`),n=require(`./_plugin-vue_export-helper-CX7YVcP6.cjs`),r=require(`./zIndex-CH0jZ7U7.cjs`),i=require(`./useDragAutoScroll-BT6oPYBj.cjs`);let a=require(`vue`),o=require(`prosemirror-state`),s=require(`@eigenpal/docx-editor-core/layout-bridge`),c=require(`@eigenpal/docx-editor-core/utils`),l=require(`@eigenpal/docx-editor-core/prosemirror/plugins/selectionTracker`),u=require(`@eigenpal/docx-editor-core/prosemirror/commands/formatting`),d=require(`@eigenpal/docx-editor-core/prosemirror/extensions/nodes/TableExtension`),f=require(`@eigenpal/docx-editor-core/layout-bridge/clickToPositionDom`),p=require(`@eigenpal/docx-editor-core/prosemirror/imageCommit`),m=require(`@eigenpal/docx-editor-core/layout-painter`),h=require(`@eigenpal/docx-editor-core/prosemirror/conversion`),g=require(`@eigenpal/docx-editor-core/prosemirror`),_=require(`@eigenpal/docx-editor-core/utils/units`),v=require(`@eigenpal/docx-editor-core/types/document`),y=require(`@eigenpal/docx-editor-core/prosemirror/plugins`),b=require(`@eigenpal/docx-editor-core/layout-engine`),x=require(`@eigenpal/docx-editor-core/prosemirror/commands/paragraph`),S=require(`@eigenpal/docx-editor-core/prosemirror/styles`),C=require(`@eigenpal/docx-editor-core/prosemirror/commands/pageBreak`),w=require(`@eigenpal/docx-editor-core/prosemirror/applyFormatting`),T=require(`@eigenpal/docx-editor-core/prosemirror/commands`),E=require(`@eigenpal/docx-editor-core/utils/headingCollector`),D=require(`@eigenpal/docx-editor-core/prosemirror/commentOps`),O=require(`@eigenpal/docx-editor-core/prosemirror/commentIdAllocator`),k=require(`@eigenpal/docx-editor-core/prosemirror/utils/extractTrackedChanges`),A=require(`@eigenpal/docx-editor-core/layout-bridge/tableInsertHover`),j=require(`@eigenpal/docx-editor-core/utils/reportIssue`),M=require(`@eigenpal/docx-editor-core/agent`),N=require(`@eigenpal/docx-editor-core/prosemirror/paraText`),P=require(`@eigenpal/docx-editor-core`),F=require(`@eigenpal/docx-editor-core/plugin-api/RenderedDomContext`),ee=require(`@eigenpal/docx-editor-core/prosemirror/queries`);function te(e){let t=window.document.querySelectorAll(`.layout-page-${e}`);if(t.length===0)return null;let n=window.innerHeight/2,r=t[0],i=1/0;for(let e of Array.from(t)){let t=e.getBoundingClientRect(),a=Math.abs((t.top+t.bottom)/2-n);a<i&&(i=a,r=e)}return r}function I(e,t,n){let r=n?Array.from(e.querySelectorAll(`.layout-page-${n} span[data-pm-start][data-pm-end]`)):(0,s.findBodyPmSpans)(e);for(let e of r){let n=Number(e.dataset.pmStart),r=Number(e.dataset.pmEnd);if(!isNaN(n)&&!isNaN(r)&&t>=n&&t<=r)return e}return null}function L(e,t,n){if(!e||!t)return;let r=null;for(let t of(0,s.findBodyPmSpans)(e)){let e=Number(t.dataset.pmStart),i=Number(t.dataset.pmEnd);if(Number.isFinite(e)&&Number.isFinite(i)&&n>=e&&n<=i){r=t;break}}if(r||=e.querySelector(`[data-pm-start="${n}"]`),!r)return;let i=t.getBoundingClientRect(),a=r.getBoundingClientRect();t.scrollTo({top:a.top-i.top+t.scrollTop-48,behavior:`smooth`})}function ne(e,t,n,r){if(!e||!t)return null;let i=(0,s.clickToPositionDom)(e,n,r,1);return i===null||i<0?null:Math.min(i,t.state.doc.content.size)}function re(e,t,n,r){if(!e)return;let i=I(e,t,r);if(!i)return;let a=i.textContent||``,o=Number(i.dataset.pmStart)||0,[s,l]=(0,c.findWordBoundaries)(a,t-o),u=o+s,d=o+l;u<d&&n(u,d)}function R(e,t,n,r){if(!e)return;let i=I(e,t,r);if(!i)return;let a=i.closest(`.layout-paragraph`);if(!a)return;let o=Number(a.dataset.pmStart),s=Number(a.dataset.pmEnd);!isNaN(o)&&!isNaN(s)&&o<s&&n(o,s)}var ie=(0,a.defineComponent)({__name:`DecorationLayer`,props:{getView:{type:Function},getPagesContainer:{type:Function},zoom:{},transactionVersion:{},syncCoordinator:{}},setup(e){let t=e,n=(0,a.ref)(null),r=(0,a.ref)(0),i=null,o=null;function s(){i!==null&&cancelAnimationFrame(i),i=requestAnimationFrame(()=>{i=null;let e=t.getView(),r=t.getPagesContainer(),a=n.value;!e||!r||!a||t.syncCoordinator.isSafeToRender()&&c(e,r,a,t.zoom)})}(0,a.onMounted)(()=>{o=t.syncCoordinator.onRender(()=>{r.value++}),s()}),(0,a.onBeforeUnmount)(()=>{i!==null&&(cancelAnimationFrame(i),i=null),o?.()}),(0,a.watch)(()=>[t.zoom,t.transactionVersion,r.value],()=>s());function c(e,t,n,r){let i=l(e.state);if(i.length===0){n.firstChild&&n.replaceChildren();return}let a=(0,F.createRenderedDomContext)(t,r),o=a.getContainerOffset(),s=document.createDocumentFragment();for(let{decoration:t,from:n,to:r}of i){if(n===r){let r=u(t,e);if(!r)continue;let i=a.getCoordinatesForPosition(n);if(!i)continue;let c=document.createElement(`div`);c.style.cssText=`position:absolute;left:${i.x+o.x}px;top:${i.y+o.y}px;height:${i.height}px;`,c.appendChild(r),s.appendChild(c);continue}let i=d(t);if(!i)continue;let c=a.getRectsForRange(n,r);for(let e of c){let t=document.createElement(`div`);for(let[e,n]of Object.entries(i))e!==`nodeName`&&t.setAttribute(e,n);let n=`position:absolute;left:${e.x+o.x}px;top:${e.y+o.y}px;width:${e.width}px;height:${e.height}px;`;t.style.cssText=n+(i.style??``),s.appendChild(t)}}n.replaceChildren(s)}function l(e){let t=[];for(let n of e.plugins){let r=n.props.decorations;if(!r)continue;let i=r.call(n,e);i&&i.forEachSet(e=>{e.find().forEach(e=>{e.spec?.noOverlay||t.push({decoration:e,from:e.from,to:e.to})})})}return t}function u(e,t){let n=e.type;if(!n)return null;let r=n.toDOM;return typeof r==`function`?r(t,()=>e.from):r instanceof HTMLElement?r.cloneNode(!0):null}function d(e){return e.type?.attrs??null}return(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{ref_key:`overlayRef`,ref:n,class:`paged-editor__decoration-overlay`,"aria-hidden":`true`},null,512))}}),ae=[`data-handle`,`onMousedown`],oe=[`title`],se={key:0,class:`image-overlay__dim`},ce={key:1,class:`image-overlay__dim image-overlay__dim--rotate`},le=4,ue=15,de=(0,a.defineComponent)({__name:`ImageSelectionOverlay`,props:{imageInfo:{},zoom:{},view:{}},emits:[`deselect`,`interact-start`,`interact-end`,`context-menu`],setup(t,{emit:n}){let{t:i}=e.d(),l=t,u=n,d=(0,a.ref)(null),h=(0,a.ref)(!1),g=(0,a.ref)(!1),_=(0,a.ref)(!1),v=(0,a.ref)(0),y=(0,a.ref)(0),b=(0,a.ref)(0),x=(0,a.ref)(null),S=`se`,C=0,w=0,T=0,E=0,D=null,O=null,k=null,A=null;function j(e,t){if(!e)return null;try{let n=e.state.doc.nodeAt(t);return n&&n.type.name===`image`?n:null}catch{return null}}function M(){return d.value?.closest(`.docx-editor-vue__pages-viewport`)?.querySelector(`.docx-editor-vue__pages`)??null}function N(){let e=l.imageInfo;if(!e)return null;if(e.element.isConnected)return e.element;let t=M();if(!t)return null;let n=(0,s.findBodyPmAnchor)(t,e.pmPos);return n?(0,m.findImageElement)(n):null}function P(){let e=N();if(!e||!d.value){x.value=null;return}let t=d.value.offsetParent;if(!t){x.value=null;return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=l.zoom;x.value={left:(r.left-n.left+t.scrollLeft)/i,top:(r.top-n.top+t.scrollTop)/i,width:r.width/i,height:r.height/i}}(0,a.watch)(()=>l.imageInfo,async()=>{await(0,a.nextTick)(),P()},{immediate:!0}),(0,a.watch)(()=>l.zoom,(e,t,n)=>{if(!l.imageInfo)return;let r=0,i=``,a=0,o=0,s=e=>{P();let t=x.value,n=t?`${t.left}|${t.top}|${t.width}|${t.height}`:``;a=n===i?a+1:0,i=n,o+=e,a<2&&o<500&&(r=requestAnimationFrame(()=>s(16)))};r=requestAnimationFrame(()=>s(16)),n(()=>cancelAnimationFrame(r))}),(0,a.watch)(()=>l.imageInfo,(e,t,n)=>{if(!l.imageInfo)return;let r=()=>{O&&cancelAnimationFrame(O),O=requestAnimationFrame(P)},i=d.value?.closest(`.docx-editor-vue__pages-viewport`);i?.addEventListener(`scroll`,r,{passive:!0}),window.addEventListener(`resize`,r,{passive:!0}),n(()=>{i?.removeEventListener(`scroll`,r),window.removeEventListener(`resize`,r),O&&cancelAnimationFrame(O)})},{immediate:!0});let F=(0,a.computed)(()=>h.value?v.value:x.value?.width||0),ee=(0,a.computed)(()=>h.value?y.value:x.value?.height||0),te=(0,a.computed)(()=>{let e=x.value;if(!e)return{position:`absolute`,top:`0px`,left:`0px`,visibility:`hidden`,pointerEvents:`none`};let t=h.value?v.value:e.width,n=h.value?y.value:e.height,i=l.zoom||1;return{position:`absolute`,left:`${e.left*i}px`,top:`${e.top*i}px`,width:`${t}px`,height:`${n}px`,transform:i===1?void 0:`scale(${i})`,transformOrigin:`top left`,zIndex:r.t.imageOverlay,pointerEvents:`auto`}}),I=(0,a.computed)(()=>{let e=F.value,t=ee.value,n=`${e/2-5}px`,r=`${t/2-5}px`,i=`${e-5}px`,a=`${t-5}px`,o=`-5px`;return[{pos:`nw`,style:{left:o,top:o,cursor:`nwse-resize`}},{pos:`n`,style:{left:n,top:o,cursor:`ns-resize`}},{pos:`ne`,style:{left:i,top:o,cursor:`nesw-resize`}},{pos:`e`,style:{left:i,top:r,cursor:`ew-resize`}},{pos:`se`,style:{left:i,top:a,cursor:`nwse-resize`}},{pos:`s`,style:{left:n,top:a,cursor:`ns-resize`}},{pos:`sw`,style:{left:o,top:a,cursor:`nesw-resize`}},{pos:`w`,style:{left:o,top:r,cursor:`ew-resize`}}]}),L=e=>e.length===2;function ne(e,t,n,r,i,a){let o=e.includes(`w`)?-1:+!!e.includes(`e`),s=e.includes(`n`)?-1:+!!e.includes(`s`),c=r+t*o,l=i+n*s;if(L(e)&&a){let e=Math.max(c/r,l/i);c=r*e,l=i*e}return{width:o===0?r:Math.max(20,Math.min(2e3,c)),height:s===0?i:Math.max(20,Math.min(2e3,l))}}function re(e,t){!l.imageInfo||!x.value||(S=t,C=e.clientX,w=e.clientY,T=x.value.width,E=x.value.height,D={...x.value},v.value=Math.round(T),y.value=Math.round(E),h.value=!0,u(`interact-start`),document.addEventListener(`mousemove`,R),document.addEventListener(`mouseup`,ie))}function R(e){let t=l.zoom,n=(e.clientX-C)/t,r=(e.clientY-w)/t,i=!e.shiftKey,a=ne(S,n,r,T,E,i);v.value=Math.round(a.width),y.value=Math.round(a.height);let o=D;o&&(x.value={left:S.includes(`w`)?o.left+(o.width-a.width):o.left,top:S.includes(`n`)?o.top+(o.height-a.height):o.top,width:o.width,height:o.height})}function ie(){document.removeEventListener(`mousemove`,R),document.removeEventListener(`mouseup`,ie),h.value=!1,D=null,u(`interact-end`);let e=l.view,t=l.imageInfo;if(!e||!t){P();return}let n=(0,p.commitImageResize)(e,t.pmPos,v.value,y.value);n!==null&&W(n),(0,a.nextTick)(()=>P())}let de=0,fe=0,pe=0,me=0,z=null,B=null;function he(e){if(!e)return 0;let t=e.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/);return t?parseFloat(t[1]):0}function ge(e,t){let n=/scaleX\(-1\)/.test(e||``),r=/scaleY\(-1\)/.test(e||``),i=[],a=(t%360+360)%360;return a!==0&&i.push(`rotate(${a}deg)`),n&&i.push(`scaleX(-1)`),r&&i.push(`scaleY(-1)`),i.length>0?i.join(` `):null}function V(e,t){return Math.atan2(e-de,-(t-fe))*180/Math.PI}function _e(e){if(!l.imageInfo)return;let t=l.imageInfo.element.getBoundingClientRect();de=t.left+t.width/2,fe=t.top+t.height/2;let n=j(l.view,l.imageInfo.pmPos);z=n&&n.attrs.transform||null,me=he(z),B=l.imageInfo.element.querySelector(`img`),pe=V(e.clientX,e.clientY),b.value=me,_.value=!0,u(`interact-start`),document.addEventListener(`mousemove`,H),document.addEventListener(`mouseup`,ve)}function H(e){let t=V(e.clientX,e.clientY)-pe,n=me+t;e.shiftKey||(n=Math.round(n/ue)*ue),b.value=(n%360+360)%360,B&&(B.style.transform=ge(z,b.value)||``)}function ve(){document.removeEventListener(`mousemove`,H),document.removeEventListener(`mouseup`,ve),_.value=!1,u(`interact-end`);let e=l.view,t=l.imageInfo;try{let n=e&&t?j(e,t.pmPos):null;e&&t&&n&&(e.dispatch(e.state.tr.setNodeMarkup(t.pmPos,void 0,{...n.attrs,transform:ge(n.attrs.transform,b.value)})),W(t.pmPos))}catch{}finally{B&&(B.style.transform=``),B=null,z=null}(0,a.nextTick)(()=>P())}let U=null;function ye(e){if(!l.imageInfo||!x.value)return;let t=e.clientX,n=e.clientY,r=x.value,i=!1,a=e=>{let a=e.clientX-t,o=e.clientY-n;if(!(!i&&Math.sqrt(a*a+o*o)<le)){if(!i){i=!0,g.value=!0,u(`interact-start`),U=document.createElement(`div`),U.style.cssText=`position: fixed; pointer-events: none; z-index: 10000; opacity: 0.5; border: 2px dashed #2563eb; border-radius: 4px; background: rgba(37, 99, 235, 0.1);`;let e=l.zoom;U.style.width=`${r.width*e}px`,U.style.height=`${r.height*e}px`,document.body.appendChild(U)}if(U){let t=l.zoom;U.style.left=`${e.clientX-r.width*t/2}px`,U.style.top=`${e.clientY-r.height*t/2}px`}}},o=e=>{document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o),k=null,A=null,U&&=(U.remove(),null),g.value=!1,i&&(u(`interact-end`),be(e.clientX,e.clientY))};k=a,A=o,document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o)}function be(e,t){let n=l.view,r=l.imageInfo;if(!n||!r)return;let i=j(n,r.pmPos);if(i){if((0,p.isFloatingImage)(i)){let i=(d.value?.closest(`.docx-editor-vue__pages-viewport`))?.querySelectorAll(`.layout-page`);if(!i||i.length===0)return;let a=null;for(let e of i){let n=e.getBoundingClientRect();if(t>=n.top&&t<=n.bottom){a=e.querySelector(`.layout-page-content`);break}}if(a||=i[i.length-1].querySelector(`.layout-page-content`),!a)return;let o=a.getBoundingClientRect(),s=l.zoom,u=(0,c.pixelsToEmu)((e-o.left)/s),f=(0,c.pixelsToEmu)((t-o.top)/s),m=(0,p.commitImageFloatMove)(n,r.pmPos,u,f);m!==null&&W(m)}else{let i=M();if(!i)return;let a=(0,f.clickToPositionDom)(i,e,t,1);if(a==null||a<0)return;let o=(0,p.commitImageInlineMove)(n,r.pmPos,a);o!==null&&W(o)}(0,a.nextTick)(()=>P())}}function W(e){let t=l.view;if(t)try{let n=o.NodeSelection.create(t.state.doc,e);t.dispatch(t.state.tr.setSelection(n))}catch{}}return(0,a.onBeforeUnmount)(()=>{document.removeEventListener(`mousemove`,R),document.removeEventListener(`mouseup`,ie),document.removeEventListener(`mousemove`,H),document.removeEventListener(`mouseup`,ve),k&&document.removeEventListener(`mousemove`,k),A&&document.removeEventListener(`mouseup`,A),U&&=(U.remove(),null),O&&cancelAnimationFrame(O)}),(e,n)=>t.imageInfo?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,ref_key:`overlayRootRef`,ref:d,class:`image-overlay`,style:(0,a.normalizeStyle)(te.value),onMousedown:n[3]||=(0,a.withModifiers)(()=>{},[`stop`])},[n[4]||=(0,a.createElementVNode)(`div`,{class:`image-overlay__border`},null,-1),(0,a.createElementVNode)(`div`,{class:`image-overlay__body`,style:(0,a.normalizeStyle)({cursor:g.value?`grabbing`:`grab`}),onMousedown:n[0]||=(0,a.withModifiers)(e=>ye(e),[`prevent`,`stop`]),onContextmenu:n[1]||=(0,a.withModifiers)(t=>e.$emit(`context-menu`,t),[`prevent`,`stop`])},null,36),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(I.value,e=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:e.pos,class:`image-overlay__handle`,style:(0,a.normalizeStyle)(e.style),"data-handle":e.pos,onMousedown:(0,a.withModifiers)(t=>re(t,e.pos),[`prevent`,`stop`])},null,44,ae))),128)),n[5]||=(0,a.createElementVNode)(`div`,{class:`image-overlay__rotate-line`},null,-1),(0,a.createElementVNode)(`div`,{class:`image-overlay__rotate-handle`,style:(0,a.normalizeStyle)({left:`${F.value/2-7}px`}),title:(0,a.unref)(i)(`imageOverlay.rotate`),onMousedown:n[2]||=(0,a.withModifiers)(e=>_e(e),[`prevent`,`stop`])},null,44,oe),h.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,se,(0,a.toDisplayString)(Math.round(v.value))+` × `+(0,a.toDisplayString)(Math.round(y.value)),1)):(0,a.createCommentVNode)(``,!0),_.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,ce,(0,a.toDisplayString)(Math.round(b.value))+`° `,1)):(0,a.createCommentVNode)(``,!0)],36)):(0,a.createCommentVNode)(``,!0)}}),fe=n.t(de,[[`__scopeId`,`data-v-df7c380c`]]),pe={class:`doc-outline__header`},me={class:`doc-outline__body`},z={key:0,class:`doc-outline__empty`},B=[`onMousedown`],he=(0,a.defineComponent)({__name:`DocumentOutline`,props:{isOpen:{type:Boolean},headings:{}},emits:[`close`,`navigate`],setup(t){return(n,r)=>t.isOpen?((0,a.openBlock)(),(0,a.createElementBlock)(`nav`,{key:0,class:`doc-outline`,role:`navigation`,"aria-label":`Document outline`,onMousedown:r[1]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createElementVNode)(`div`,pe,[(0,a.createElementVNode)(`button`,{class:`doc-outline__back`,title:`Close outline`,"aria-label":`Close outline`,onClick:r[0]||=e=>n.$emit(`close`)},[(0,a.createVNode)(e.p,{name:`arrow_back`,size:20})]),r[2]||=(0,a.createElementVNode)(`span`,{class:`doc-outline__title`},`Document Outline`,-1)]),(0,a.createElementVNode)(`div`,me,[t.headings.length===0?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,z,` No headings found `)):(0,a.createCommentVNode)(``,!0),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(t.headings,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:t,class:`doc-outline__item`,style:(0,a.normalizeStyle)({paddingLeft:12+(e.level-1)*16+`px`}),onMousedown:(0,a.withModifiers)(t=>n.$emit(`navigate`,e.pmPos),[`prevent`])},(0,a.toDisplayString)(e.text||`(untitled)`),45,B))),128))])],32)):(0,a.createCommentVNode)(``,!0)}}),ge=n.t(he,[[`__scopeId`,`data-v-cb2cdc39`]]),V=(0,a.defineComponent)({__name:`PageIndicator`,props:{currentPage:{},totalPages:{},visible:{type:Boolean}},setup(t){let{t:n}=e.d();return(e,r)=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{class:`docx-editor-vue__page-indicator`,style:(0,a.normalizeStyle)({opacity:+!!t.visible}),"aria-live":`polite`,role:`status`},(0,a.toDisplayString)((0,a.unref)(n)(`viewer.pageIndicator`,{current:t.currentPage,total:t.totalPages})),5))}}),_e=n.t(V,[[`__scopeId`,`data-v-d117bf6e`]]),H={class:`hf-editor__label`},ve={class:`hf-editor__actions`,style:{position:`relative`}},U=(0,a.defineComponent)({__name:`InlineHeaderFooterEditor`,props:{isOpen:{type:Boolean},position:{},view:{},targetRect:{}},emits:[`save`,`close`,`remove`],setup(e,{emit:t}){let n=e,r=t,i=(0,a.ref)({}),o=(0,a.ref)(!1);function s(e){let t=n.view;if(!t)return;let{$from:r,from:i}=t.state.selection,a=t.state.storedMarks||r.marks(),o=g.schema.nodes.field.create({fieldType:e,instruction:` ${e} \\* MERGEFORMAT `,fieldKind:`simple`,dirty:!0});t.dispatch(t.state.tr.insert(i,o.mark(a))),t.focus()}function c(){let e=n.targetRect;e&&(i.value={position:`absolute`,top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`,zIndex:`100`,pointerEvents:`none`})}(0,a.watch)(()=>n.isOpen,e=>{e&&(c(),n.view?.focus())}),(0,a.watch)(()=>n.targetRect,()=>{n.isOpen&&c()},{deep:!0});function l(){n.view&&(r(`save`,(0,h.proseDocToBlocks)(n.view.state.doc)),r(`close`))}return(t,n)=>e.isOpen?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`hf-editor`,style:(0,a.normalizeStyle)(i.value)},[(0,a.createElementVNode)(`div`,{class:(0,a.normalizeClass)([`hf-editor__toolbar`,e.position===`footer`?`hf-editor__toolbar--below`:`hf-editor__toolbar--above`]),onMousedown:n[8]||=(0,a.withModifiers)(()=>{},[`stop`]),onContextmenu:n[9]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createElementVNode)(`span`,H,(0,a.toDisplayString)(e.position===`header`?`Header`:`Footer`),1),(0,a.createElementVNode)(`div`,ve,[(0,a.createElementVNode)(`button`,{class:`hf-editor__btn`,title:`Options`,onMousedown:n[0]||=(0,a.withModifiers)(()=>{},[`prevent`]),onClick:n[1]||=e=>o.value=!o.value},` Options ▾ `,32),o.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`hf-editor__dropdown`,onMousedown:n[4]||=(0,a.withModifiers)(()=>{},[`stop`]),onContextmenu:n[5]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createElementVNode)(`button`,{type:`button`,class:`hf-editor__dropdown-item`,onClick:n[2]||=e=>{o.value=!1,s(`PAGE`)}},` Insert current page number `),(0,a.createElementVNode)(`button`,{type:`button`,class:`hf-editor__dropdown-item`,onClick:n[3]||=e=>{o.value=!1,s(`NUMPAGES`)}},` Insert total page count `)],32)):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`button`,{class:`hf-editor__btn`,title:`Remove`,onMousedown:n[6]||=(0,a.withModifiers)(e=>t.$emit(`remove`),[`prevent`])},` Remove `,32),(0,a.createElementVNode)(`button`,{class:`hf-editor__btn hf-editor__btn--primary`,title:`Save`,onMousedown:(0,a.withModifiers)(l,[`prevent`])},` Save `,32),(0,a.createElementVNode)(`button`,{class:`hf-editor__btn`,title:`Cancel`,onMousedown:n[7]||=(0,a.withModifiers)(e=>t.$emit(`close`),[`prevent`])},` Cancel `,32)])],34)],4)):(0,a.createCommentVNode)(``,!0)}}),ye=n.t(U,[[`__scopeId`,`data-v-e93a9f94`]]),be=[`role`],W={key:0,class:`layout-sdt-widget-empty`},xe=[`aria-selected`,`onClick`],G=[`value`],Se=(0,a.defineComponent)({__name:`ContentControlWidgets`,props:{container:{},view:{}},setup(e){function t(e){let t=/^sdt@(\d+)$/.exec(e??``);return t?Number(t[1]):null}let n=e,r=(0,a.ref)(null),i=(0,a.ref)(null);function o(e,t){let i=n.view;if(i)try{i.dispatch((0,g.setContentControlValueTr)(i.state,{tag:e},t)),i.focus()}catch{}r.value=null}function s(e){let r=n.view,i=t(e.dataset.sdtGroupId);if(!(!r||i==null))try{let t=e.dataset.sdtRepeat===`add`?(0,g.addRepeatingSectionItemTr)(r.state,i):(0,g.removeRepeatingSectionItemTr)(r.state,i);r.dispatch(t),r.focus()}catch{}}function c(e){let t=e.target;(t?.closest?.(`.layout-sdt-widget`)||t?.closest?.(`.layout-sdt-repeat-btn`))&&e.preventDefault()}function l(e){let t=n.view,i=e.dataset.sdtTag,a=e.dataset.sdtWidget;if(!t||!i||!a)return;let s=(0,g.findContentControlsInPM)(t.state.doc,{tag:i})[0],c=e.getBoundingClientRect();a===`checkbox`?o(i,{kind:`checkbox`,checked:!s?.checked}):a===`dropdown`?r.value={kind:`dropdown`,tag:i,items:s?.listItems??[],current:s?.text??``,x:c.left,y:c.bottom+2}:a===`date`&&(r.value={kind:`date`,tag:i,current:s?.dateValue??``,x:c.left,y:c.bottom+2})}function u(e){let t=e.target?.closest?.(`.layout-sdt-repeat-btn`);if(t){e.preventDefault(),e.stopPropagation(),s(t);return}let n=e.target?.closest?.(`.layout-sdt-widget`);n&&(e.preventDefault(),e.stopPropagation(),l(n))}function d(e){if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target?.closest?.(`.layout-sdt-widget`);t&&(e.preventDefault(),l(t))}function f(e){r.value&&!i.value?.contains(e.target)&&(r.value=null)}function p(e){e.key===`Escape`&&(r.value=null)}let m=null;(0,a.watch)(()=>n.container,e=>{m&&(m.removeEventListener(`mousedown`,c),m.removeEventListener(`click`,u),m.removeEventListener(`keydown`,d)),m=e??null,m&&(m.addEventListener(`mousedown`,c),m.addEventListener(`click`,u),m.addEventListener(`keydown`,d))},{immediate:!0}),(0,a.watch)(r,e=>{e?(document.addEventListener(`mousedown`,f),document.addEventListener(`keydown`,p),e.kind===`dropdown`&&(0,a.nextTick)(()=>{let e=i.value?.querySelectorAll(`.layout-sdt-widget-option`);e?.length&&([...e].find(e=>e.getAttribute(`aria-selected`)===`true`)??e[0]).focus()})):(document.removeEventListener(`mousedown`,f),document.removeEventListener(`keydown`,p))});function h(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=[...i.value?.querySelectorAll(`.layout-sdt-widget-option`)??[]];if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`ArrowDown`?(n+1)%t.length:(n-1+t.length)%t.length].focus()}(0,a.onBeforeUnmount)(()=>{m&&(m.removeEventListener(`mousedown`,c),m.removeEventListener(`click`,u),m.removeEventListener(`keydown`,d)),document.removeEventListener(`mousedown`,f),document.removeEventListener(`keydown`,p)});function _(e){let t=e.target.value;t&&r.value&&o(r.value.tag,{kind:`date`,date:t})}return(e,t)=>r.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,ref_key:`popupEl`,ref:i,class:`layout-sdt-widget-popup`,role:r.value.kind===`dropdown`?`listbox`:void 0,style:(0,a.normalizeStyle)({position:`fixed`,top:r.value.y+`px`,left:r.value.x+`px`,zIndex:1e3}),onKeydown:h,onMousedown:t[0]||=(0,a.withModifiers)(()=>{},[`prevent`])},[r.value.kind===`dropdown`?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:0},[r.value.items.length===0?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,W,`No options`)):(0,a.createCommentVNode)(``,!0),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(r.value.items,e=>((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:e.value,type:`button`,role:`option`,"aria-selected":e.displayText===r.value.current,class:(0,a.normalizeClass)([`layout-sdt-widget-option`,{"is-selected":e.displayText===r.value.current}]),onClick:t=>o(r.value.tag,{kind:`dropdown`,value:e.value})},(0,a.toDisplayString)(e.displayText),11,xe))),128))],64)):((0,a.openBlock)(),(0,a.createElementBlock)(`input`,{key:1,type:`date`,class:`layout-sdt-widget-date`,value:r.value.current,onChange:_},null,40,G))],44,be)):(0,a.createCommentVNode)(``,!0)}}),K={key:0,class:`docx-editor-vue__title-bar`},Ce={class:`docx-editor-vue__title-bar-left`},we={class:`docx-editor-vue__title-bar-center`},Te={class:`docx-editor-vue__title-bar-right`},Ee=(0,a.defineComponent)({__name:`DocxEditorMenuBar`,props:{showMenuBar:{type:Boolean},documentName:{},documentNameEditable:{type:Boolean,default:!0},renderLogo:{},renderTitleBarRight:{}},emits:[`rename`,`menu-action`,`insert-table`],setup(e,{emit:n}){let r=n;return(n,i)=>e.showMenuBar?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,K,[(0,a.createElementVNode)(`div`,Ce,[e.renderLogo?((0,a.openBlock)(),(0,a.createBlock)((0,a.resolveDynamicComponent)(e.renderLogo),{key:0})):(0,a.createCommentVNode)(``,!0),(0,a.renderSlot)(n.$slots,`title-bar-left`)]),(0,a.createElementVNode)(`div`,we,[(0,a.createVNode)(t.i,{"model-value":e.documentName,editable:e.documentNameEditable,"onUpdate:modelValue":i[0]||=e=>r(`rename`,e)},null,8,[`model-value`,`editable`]),(0,a.createVNode)(t.t,{onAction:i[1]||=e=>r(`menu-action`,e),onInsertTable:i[2]||=(e,t)=>r(`insert-table`,e,t)})]),(0,a.createElementVNode)(`div`,Te,[(0,a.renderSlot)(n.$slots,`title-bar-right`),e.renderTitleBarRight?((0,a.openBlock)(),(0,a.createBlock)((0,a.resolveDynamicComponent)(e.renderTitleBarRight),{key:0})):(0,a.createCommentVNode)(``,!0)])])):(0,a.createCommentVNode)(``,!0)}}),De=[`aria-label`],Oe={class:`wm-header`},q={class:`wm-body`},ke={class:`wm-radio-row`},Ae=[`checked`],J={for:`wm-none`,class:`wm-inline-label`},je={class:`wm-radio-row`},Me=[`checked`],Ne={for:`wm-picture`,class:`wm-inline-label`},Pe={key:0,class:`wm-subform`},Fe={class:`wm-row`},Ie={key:0,class:`wm-row`},Le=[`src`],Re={class:`wm-row`},ze={class:`wm-label`},Be={class:`wm-inline-label`},Ve={class:`wm-radio-row`},He=[`checked`],Ue={for:`wm-text`,class:`wm-inline-label`},We={key:1,class:`wm-subform`},Ge={class:`wm-row`},Ke={class:`wm-label`},qe=[`value`],Je=[`value`],Ye={class:`wm-row`},Xe={class:`wm-label`},Ze={class:`wm-row`},Qe={class:`wm-label`},$e=[`value`],et={class:`wm-row`},tt={class:`wm-label`},nt={class:`wm-inline-label`},rt={class:`wm-row`},it={class:`wm-label`},at={class:`wm-row`},ot={class:`wm-label`},st={class:`wm-inline-label`},ct=[`checked`],lt={class:`wm-inline-label`},ut=[`checked`],dt={class:`wm-inline-label`},ft={class:`wm-footer`},pt=[`disabled`],mt=(0,a.defineComponent)({__name:`WatermarkDialog`,props:{isOpen:{type:Boolean},current:{}},emits:[`close`,`apply`],setup(t,{emit:n}){let r=[`CONFIDENTIAL`,`DRAFT`,`DO NOT COPY`,`SAMPLE`,`URGENT`,`ASAP`],i=[`Calibri`,`Arial`,`Times New Roman`,`Georgia`,`Verdana`,`Courier New`],{t:o}=e.d(),s=t,c=n,l=(0,a.ref)(`none`),u=(0,a.ref)(`CONFIDENTIAL`),d=(0,a.ref)(`Calibri`),f=(0,a.ref)(!0),p=(0,a.ref)(54),m=(0,a.ref)(`#C0C0C0`),h=(0,a.ref)(`diagonal`),g=(0,a.ref)(!0),_=(0,a.ref)(void 0),y=(0,a.ref)(void 0),b=(0,a.ref)(100),x=(0,a.ref)(!0);(0,a.watch)(()=>s.isOpen,e=>{if(!e)return;let t=s.current;t?.kind===`text`?(l.value=`text`,u.value=t.text,d.value=t.font||`Calibri`,f.value=t.fontSize===void 0,t.fontSize!==void 0&&(p.value=t.fontSize),m.value=t.color||`#C0C0C0`,h.value=t.layout,g.value=t.semitransparent):t?.kind===`picture`?(l.value=`picture`,_.value=t.dataUrl,y.value=t.widthEmu!==void 0&&t.heightEmu!==void 0?{widthEmu:t.widthEmu,heightEmu:t.heightEmu}:void 0,b.value=Math.round((t.scale||1)*100),x.value=t.washout):l.value=`none`},{immediate:!0});let S=(0,a.computed)(()=>l.value===`picture`&&!_.value);function C(e){let t=e.target.value;t&&(u.value=t)}function w(e){let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{let e=typeof n.result==`string`?n.result:void 0;if(_.value=e,y.value=void 0,!e)return;let t=new Image;t.onload=()=>{y.value=(0,v.pictureWatermarkDisplayEmu)(t.naturalWidth,t.naturalHeight)},t.src=e},n.readAsDataURL(t)}function T(){c(`close`)}function E(){if(l.value===`none`)c(`apply`,null);else if(l.value===`text`)c(`apply`,{kind:`text`,text:u.value,font:d.value,color:m.value,semitransparent:g.value,layout:h.value,fontSize:f.value?void 0:p.value});else{if(!_.value)return;c(`apply`,{kind:`picture`,dataUrl:_.value,scale:b.value/100,washout:x.value,...y.value??{}})}T()}function D(e){e.key===`Escape`&&T()}return(e,n)=>t.isOpen?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`wm-overlay`,onMousedown:(0,a.withModifiers)(T,[`self`]),onKeydown:D},[(0,a.createElementVNode)(`div`,{class:`wm-dialog`,role:`dialog`,"aria-label":(0,a.unref)(o)(`dialogs.watermark.title`),onMousedown:n[13]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createElementVNode)(`div`,Oe,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.title`)),1),(0,a.createElementVNode)(`div`,q,[(0,a.createElementVNode)(`div`,ke,[(0,a.createElementVNode)(`input`,{id:`wm-none`,type:`radio`,checked:l.value===`none`,onChange:n[0]||=e=>l.value=`none`},null,40,Ae),(0,a.createElementVNode)(`label`,J,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.noWatermark`)),1)]),(0,a.createElementVNode)(`div`,je,[(0,a.createElementVNode)(`input`,{id:`wm-picture`,type:`radio`,checked:l.value===`picture`,onChange:n[1]||=e=>l.value=`picture`},null,40,Me),(0,a.createElementVNode)(`label`,Ne,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.picture`)),1)]),l.value===`picture`?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Pe,[(0,a.createElementVNode)(`div`,Fe,[(0,a.createElementVNode)(`input`,{type:`file`,accept:`image/*`,onChange:w},null,32)]),_.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Ie,[(0,a.createElementVNode)(`img`,{src:_.value,alt:``,class:`wm-preview`},null,8,Le)])):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,Re,[(0,a.createElementVNode)(`span`,ze,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.scale`)),1),(0,a.withDirectives)((0,a.createElementVNode)(`input`,{class:`wm-input wm-input--narrow`,type:`number`,min:`10`,max:`500`,"onUpdate:modelValue":n[2]||=e=>b.value=e},null,512),[[a.vModelText,b.value,void 0,{number:!0}]]),n[14]||=(0,a.createElementVNode)(`span`,{class:`wm-unit`},`%`,-1)]),(0,a.createElementVNode)(`label`,Be,[(0,a.withDirectives)((0,a.createElementVNode)(`input`,{type:`checkbox`,"onUpdate:modelValue":n[3]||=e=>x.value=e},null,512),[[a.vModelCheckbox,x.value]]),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.washout`)),1)])])):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,Ve,[(0,a.createElementVNode)(`input`,{id:`wm-text`,type:`radio`,checked:l.value===`text`,onChange:n[4]||=e=>l.value=`text`},null,40,He),(0,a.createElementVNode)(`label`,Ue,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.text`)),1)]),l.value===`text`?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,We,[(0,a.createElementVNode)(`div`,Ge,[(0,a.createElementVNode)(`span`,Ke,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.presetLabel`)),1),(0,a.createElementVNode)(`select`,{class:`wm-input`,value:r.includes(u.value)?u.value:``,onChange:C},[n[15]||=(0,a.createElementVNode)(`option`,{value:``},`—`,-1),((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(r,e=>(0,a.createElementVNode)(`option`,{key:e,value:e},(0,a.toDisplayString)(e),9,Je)),64))],40,qe)]),(0,a.createElementVNode)(`div`,Ye,[(0,a.createElementVNode)(`span`,Xe,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.textLabel`)),1),(0,a.withDirectives)((0,a.createElementVNode)(`input`,{class:`wm-input`,"onUpdate:modelValue":n[5]||=e=>u.value=e},null,512),[[a.vModelText,u.value]])]),(0,a.createElementVNode)(`div`,Ze,[(0,a.createElementVNode)(`span`,Qe,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.fontLabel`)),1),(0,a.withDirectives)((0,a.createElementVNode)(`select`,{class:`wm-input`,"onUpdate:modelValue":n[6]||=e=>d.value=e},[((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(i,e=>(0,a.createElementVNode)(`option`,{key:e,value:e},(0,a.toDisplayString)(e),9,$e)),64))],512),[[a.vModelSelect,d.value]])]),(0,a.createElementVNode)(`div`,et,[(0,a.createElementVNode)(`span`,tt,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.sizeLabel`)),1),(0,a.createElementVNode)(`label`,nt,[(0,a.withDirectives)((0,a.createElementVNode)(`input`,{type:`checkbox`,"onUpdate:modelValue":n[7]||=e=>f.value=e},null,512),[[a.vModelCheckbox,f.value]]),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.sizeAuto`)),1)]),f.value?(0,a.createCommentVNode)(``,!0):(0,a.withDirectives)(((0,a.openBlock)(),(0,a.createElementBlock)(`input`,{key:0,class:`wm-input wm-input--narrow`,type:`number`,min:`8`,max:`200`,"onUpdate:modelValue":n[8]||=e=>p.value=e},null,512)),[[a.vModelText,p.value,void 0,{number:!0}]])]),(0,a.createElementVNode)(`div`,rt,[(0,a.createElementVNode)(`span`,it,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.colorLabel`)),1),(0,a.withDirectives)((0,a.createElementVNode)(`input`,{type:`color`,"onUpdate:modelValue":n[9]||=e=>m.value=e},null,512),[[a.vModelText,m.value]])]),(0,a.createElementVNode)(`div`,at,[(0,a.createElementVNode)(`span`,ot,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.layoutLabel`)),1),(0,a.createElementVNode)(`label`,st,[(0,a.createElementVNode)(`input`,{type:`radio`,name:`wm-layout`,checked:h.value===`diagonal`,onChange:n[10]||=e=>h.value=`diagonal`},null,40,ct),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.diagonal`)),1)]),(0,a.createElementVNode)(`label`,lt,[(0,a.createElementVNode)(`input`,{type:`radio`,name:`wm-layout`,checked:h.value===`horizontal`,onChange:n[11]||=e=>h.value=`horizontal`},null,40,ut),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.horizontal`)),1)])]),(0,a.createElementVNode)(`label`,dt,[(0,a.withDirectives)((0,a.createElementVNode)(`input`,{type:`checkbox`,"onUpdate:modelValue":n[12]||=e=>g.value=e},null,512),[[a.vModelCheckbox,g.value]]),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.semitransparent`)),1)])])):(0,a.createCommentVNode)(``,!0)]),(0,a.createElementVNode)(`div`,ft,[(0,a.createElementVNode)(`button`,{type:`button`,class:`wm-btn`,onClick:T},(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.cancelButton`)),1),(0,a.createElementVNode)(`button`,{type:`button`,class:(0,a.normalizeClass)([`wm-btn wm-btn--primary`,{"wm-btn--disabled":S.value}]),disabled:S.value,onClick:E},(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.applyButton`)),11,pt)])],40,De)],32)):(0,a.createCommentVNode)(``,!0)}}),ht=n.t(mt,[[`__scopeId`,`data-v-5edfdc47`]]),gt=(0,a.defineComponent)({__name:`DocxEditorDialogs`,props:{view:{},bookmarks:{},selectedImagePmPos:{},sectionProperties:{},scrollVisiblePositionIntoView:{type:Function},showFindReplace:{type:Boolean},showInsertImage:{type:Boolean},showHyperlink:{type:Boolean},showInsertSymbol:{type:Boolean},showImageProperties:{type:Boolean},showPageSetup:{type:Boolean},showWatermark:{type:Boolean},currentWatermark:{},showKeyboardShortcuts:{type:Boolean}},emits:[`update:showFindReplace`,`update:showInsertImage`,`update:showHyperlink`,`update:showInsertSymbol`,`update:showImageProperties`,`update:showPageSetup`,`update:showWatermark`,`update:showKeyboardShortcuts`,`insert-image`,`insert-symbol`,`hyperlink-submit`,`hyperlink-remove`,`page-setup-apply`,`watermark-apply`],setup(t,{emit:n}){let r=n;return(n,i)=>((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createVNode)(e.s,{"is-open":t.showFindReplace,view:t.view,"scroll-visible-position-into-view":t.scrollVisiblePositionIntoView,onClose:i[0]||=e=>r(`update:showFindReplace`,!1)},null,8,[`is-open`,`view`,`scroll-visible-position-into-view`]),(0,a.createVNode)(e.o,{"is-open":t.showInsertImage,onClose:i[1]||=e=>r(`update:showInsertImage`,!1),onInsert:i[2]||=e=>r(`insert-image`,e)},null,8,[`is-open`]),(0,a.createVNode)(e.a,{"is-open":t.showHyperlink,view:t.view,bookmarks:t.bookmarks,onClose:i[3]||=e=>r(`update:showHyperlink`,!1),onSubmit:i[4]||=e=>r(`hyperlink-submit`,e),onRemove:i[5]||=e=>r(`hyperlink-remove`)},null,8,[`is-open`,`view`,`bookmarks`]),(0,a.createVNode)(e.i,{"is-open":t.showInsertSymbol,onClose:i[6]||=e=>r(`update:showInsertSymbol`,!1),onInsert:i[7]||=e=>r(`insert-symbol`,e)},null,8,[`is-open`]),(0,a.createVNode)(e.r,{"is-open":t.showImageProperties,view:t.view,"pm-pos":t.selectedImagePmPos,onClose:i[8]||=e=>r(`update:showImageProperties`,!1)},null,8,[`is-open`,`view`,`pm-pos`]),(0,a.createVNode)(e.n,{"is-open":t.showPageSetup,"section-properties":t.sectionProperties,onClose:i[9]||=e=>r(`update:showPageSetup`,!1),onApply:i[10]||=e=>r(`page-setup-apply`,e)},null,8,[`is-open`,`section-properties`]),(0,a.createVNode)(ht,{"is-open":t.showWatermark,current:t.currentWatermark,onClose:i[11]||=e=>r(`update:showWatermark`,!1),onApply:i[12]||=e=>r(`watermark-apply`,e)},null,8,[`is-open`,`current`]),(0,a.createVNode)(e.t,{"is-open":t.showKeyboardShortcuts,onClose:i[13]||=e=>r(`update:showKeyboardShortcuts`,!1)},null,8,[`is-open`])],64))}}),_t=[`disabled`,`onMousedown`],vt={class:`ctx-menu__label`},yt={key:0,class:`ctx-menu__shortcut`},bt=220,xt=32,St=10,Ct=(0,a.defineComponent)({__name:`TextContextMenu`,props:{isOpen:{type:Boolean},position:{},hasSelection:{type:Boolean},isEditable:{type:Boolean},inTable:{type:Boolean},onImage:{type:Boolean},canMergeCells:{type:Boolean},canSplitCell:{type:Boolean}},emits:[`close`,`action`],setup(e,{emit:t}){let n=e,r=t,i=(0,a.ref)(null),o=(0,a.computed)(()=>{let e=[{id:`cut`,label:`Cut`,action:`cut`,shortcut:`Ctrl+X`,disabled:!n.hasSelection||!n.isEditable},{id:`copy`,label:`Copy`,action:`copy`,shortcut:`Ctrl+C`,disabled:!n.hasSelection},{id:`paste`,label:`Paste`,action:`paste`,shortcut:`Ctrl+V`,disabled:!n.isEditable},{id:`pasteAsPlainText`,label:`Paste as Plain Text`,action:`pasteAsPlainText`,shortcut:`Ctrl+Shift+V`,disabled:!n.isEditable},{id:`div1`,label:``,action:``,divider:!0},{id:`delete`,label:`Delete`,action:`delete`,shortcut:`Del`,disabled:!n.hasSelection||!n.isEditable},{id:`selectAll`,label:`Select All`,action:`selectAll`,shortcut:`Ctrl+A`}];return n.onImage&&n.isEditable&&e.push({id:`div-img`,label:``,action:``,divider:!0},{id:`replaceImage`,label:`Replace image…`,action:`replaceImage`},{id:`imageProperties`,label:`Image properties…`,action:`imageProperties`},{id:`deleteImage`,label:`Delete image`,action:`deleteImage`,shortcut:`Del`}),n.inTable&&n.isEditable&&e.push({id:`div2`,label:``,action:``,divider:!0},{id:`addRowAbove`,label:`Insert row above`,action:`addRowAbove`},{id:`addRowBelow`,label:`Insert row below`,action:`addRowBelow`},{id:`deleteRow`,label:`Delete row`,action:`deleteRow`},{id:`div3`,label:``,action:``,divider:!0},{id:`addColLeft`,label:`Insert column left`,action:`addColumnLeft`},{id:`addColRight`,label:`Insert column right`,action:`addColumnRight`},{id:`deleteCol`,label:`Delete column`,action:`deleteColumn`},{id:`div4`,label:``,action:``,divider:!0},{id:`mergeCells`,label:`Merge cells`,action:`mergeCells`,disabled:!n.canMergeCells},{id:`splitCell`,label:`Split cell`,action:`splitCell`,disabled:!n.canSplitCell}),e}),s=(0,a.computed)(()=>{let e=n.position.x,t=n.position.y,r=o.value.filter(e=>!e.divider).length,i=o.value.filter(e=>e.divider).length,a=r*xt+i*9;return typeof window<`u`&&(e+bt+St>window.innerWidth&&(e=window.innerWidth-bt-St),t+a+St>window.innerHeight&&(t=window.innerHeight-a-St)),{position:`fixed`,left:`${e}px`,top:`${t}px`,zIndex:400}});function c(e){e&&(r(`action`,e),r(`close`))}function l(e){e.key===`Escape`&&r(`close`)}return(0,a.watch)(()=>n.isOpen,e=>{e&&(0,a.nextTick)(()=>i.value?.focus())}),(t,n)=>((0,a.openBlock)(),(0,a.createBlock)(a.Teleport,{to:`body`},[e.isOpen?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`ctx-menu-backdrop`,onMousedown:n[0]||=e=>t.$emit(`close`),onContextmenu:n[1]||=(0,a.withModifiers)(e=>t.$emit(`close`),[`prevent`])},null,32)):(0,a.createCommentVNode)(``,!0),e.isOpen?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:1,ref_key:`menuRef`,ref:i,class:`ctx-menu`,style:(0,a.normalizeStyle)(s.value),onContextmenu:n[2]||=(0,a.withModifiers)(()=>{},[`prevent`]),onKeydown:l},[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.value,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:e.id||t,class:(0,a.normalizeClass)([`ctx-menu__item`,{"ctx-menu__item--disabled":e.disabled,"ctx-menu__item--divider":e.divider}]),disabled:e.disabled,onMousedown:(0,a.withModifiers)(t=>c(e.action),[`prevent`])},[(0,a.createElementVNode)(`span`,vt,(0,a.toDisplayString)(e.label),1),e.shortcut?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,yt,(0,a.toDisplayString)(e.shortcut),1)):(0,a.createCommentVNode)(``,!0)],42,_t))),128))],36)):(0,a.createCommentVNode)(``,!0)]))}}),wt=n.t(Ct,[[`__scopeId`,`data-v-741c4f71`]]),Tt=[`aria-label`],Et={class:`image-ctx-menu__icon`},Dt={class:`image-ctx-menu__label`},Ot={key:1,class:`image-ctx-menu__divider`,role:`separator`},kt=[`data-wrap-type`,`data-current`,`data-disabled`,`disabled`,`title`,`onClick`],At={class:`image-ctx-menu__icon`},jt={class:`image-ctx-menu__label`},Mt=[`aria-label`],Nt=[`disabled`,`onClick`],Pt={class:`image-ctx-menu__label`},Ft={key:0,class:`image-ctx-menu__shortcut`},It={key:0,class:`image-ctx-menu__divider`,role:`separator`},Lt=18,Rt=260,Y=10,zt=(0,a.defineComponent)({__name:`ImageContextMenu`,props:{state:{},textActions:{},canOpenProperties:{type:Boolean,default:!1}},emits:[`close`,`select`,`text-action`,`open-properties`],setup(t,{emit:n}){let r=t,i=n;function o(){i(`open-properties`),i(`close`)}let{t:s}=e.d(),c=(0,a.ref)(null),l=m.IMAGE_LAYOUT_OPTIONS,u=(0,a.computed)(()=>r.state?(0,m.deriveLayoutChoice)(r.state.currentWrapType,r.state.currentCssFloat??null):null),d={inline:`wrap_text`,squareLeft:`format_image_left`,squareRight:`format_image_right`,behind:`flip_to_back`,inFront:`flip_to_front`};function f(e){return d[e]}let p=(0,a.computed)(()=>{if(!r.state)return{};let e=m.IMAGE_LAYOUT_OPTIONS.length*36+16,t=r.state.position.x,n=r.state.position.y;return typeof window<`u`&&(t+Rt>window.innerWidth&&(t=window.innerWidth-Rt-Y),n+e>window.innerHeight&&(n=window.innerHeight-e-Y),t<Y&&(t=Y),n<Y&&(n=Y)),{position:`fixed`,left:`${t}px`,top:`${n}px`,minWidth:`${Rt}px`,zIndex:400}});function h(e){return r.state?(0,m.isImageLayoutOptionEnabled)(e,r.state.currentWrapType):!1}function g(e){h(e)&&(i(`select`,e.choice),i(`close`))}function _(e){e.disabled||(i(`text-action`,e.action),i(`close`))}function v(e){e.preventDefault(),i(`close`)}function y(e){e.key===`Escape`&&(e.preventDefault(),i(`close`))}return(n,r)=>((0,a.openBlock)(),(0,a.createBlock)(a.Teleport,{to:`body`},[t.state&&t.state.open?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`image-ctx-menu-backdrop`,onMousedown:v,onContextmenu:r[0]||=(0,a.withModifiers)(e=>n.$emit(`close`),[`prevent`])},null,32)):(0,a.createCommentVNode)(``,!0),t.state&&t.state.open?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:1,ref_key:`menuRef`,ref:c,class:`image-ctx-menu`,role:`menu`,"aria-label":(0,a.unref)(s)(`imageWrap.menu.ariaLabel`),"data-testid":`image-context-menu`,style:(0,a.normalizeStyle)(p.value),onContextmenu:r[4]||=(0,a.withModifiers)(()=>{},[`prevent`]),onKeydown:y},[t.canOpenProperties?((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:0,type:`button`,role:`menuitem`,class:`image-ctx-menu__item`,"data-action":`open-properties`,onMousedown:r[1]||=(0,a.withModifiers)(()=>{},[`prevent`]),onClick:o},[(0,a.createElementVNode)(`span`,Et,[(0,a.createVNode)(e.p,{name:`settings`,size:Lt})]),(0,a.createElementVNode)(`span`,Dt,(0,a.toDisplayString)((0,a.unref)(s)(`imageWrap.menu.imageProperties`)),1)],32)):(0,a.createCommentVNode)(``,!0),t.canOpenProperties?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Ot)):(0,a.createCommentVNode)(``,!0),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)((0,a.unref)(l),t=>((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:t.choice,type:`button`,role:`menuitem`,class:(0,a.normalizeClass)([`image-ctx-menu__item`,{"image-ctx-menu__item--current":t.choice===u.value}]),"data-wrap-type":t.choice,"data-current":t.choice===u.value?`true`:`false`,"data-disabled":h(t)?`false`:`true`,disabled:!h(t),title:(0,a.unref)(s)(`imageWrap.menuDesc.${t.i18nDescKey}`),onMousedown:r[2]||=(0,a.withModifiers)(()=>{},[`prevent`]),onClick:e=>g(t)},[(0,a.createElementVNode)(`span`,At,[(0,a.createVNode)(e.p,{name:f(t.iconHint),size:Lt},null,8,[`name`])]),(0,a.createElementVNode)(`span`,jt,(0,a.toDisplayString)((0,a.unref)(s)(`imageWrap.menu.${t.i18nLabelKey}`)),1),t.choice===u.value?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,{key:0,class:`image-ctx-menu__current-dot`,"aria-label":(0,a.unref)(s)(`imageWrap.menu.ariaLabel`)},`●`,8,Mt)):(0,a.createCommentVNode)(``,!0)],42,kt))),128)),t.textActions&&t.textActions.length>0?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:2},[r[5]||=(0,a.createElementVNode)(`div`,{class:`image-ctx-menu__divider`,role:`separator`},null,-1),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(t.textActions,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:`${e.action}-${t}`},[(0,a.createElementVNode)(`button`,{type:`button`,role:`menuitem`,class:`image-ctx-menu__item image-ctx-menu__item--text`,disabled:e.disabled,onMousedown:r[3]||=(0,a.withModifiers)(()=>{},[`prevent`]),onClick:t=>_(e)},[(0,a.createElementVNode)(`span`,Pt,(0,a.toDisplayString)(e.label),1),e.shortcut?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,Ft,(0,a.toDisplayString)(e.shortcut),1)):(0,a.createCommentVNode)(``,!0)],40,Nt),e.dividerAfter?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,It)):(0,a.createCommentVNode)(``,!0)],64))),128))],64)):(0,a.createCommentVNode)(``,!0)],44,Tt)):(0,a.createCommentVNode)(``,!0)]))}}),Bt=n.t(zt,[[`__scopeId`,`data-v-5c21ca8c`]]),Vt=(0,a.defineComponent)({__name:`DocxEditorOverlays`,props:{readOnly:{type:Boolean},contextMenu:{},imageContextMenu:{},imageContextMenuTextActions:{},canOpenImageProperties:{type:Boolean}},emits:[`context-menu-action`,`close-context-menu`,`image-wrap-select`,`close-image-context-menu`,`open-image-properties`],setup(e,{emit:t}){let n=t;return(t,r)=>((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createVNode)(wt,{"is-open":e.contextMenu.isOpen,position:e.contextMenu.position,"has-selection":e.contextMenu.hasSelection,"is-editable":!e.readOnly,"in-table":e.contextMenu.inTable,"on-image":e.contextMenu.onImage,"can-merge-cells":e.contextMenu.canMergeCells,"can-split-cell":e.contextMenu.canSplitCell,onAction:r[0]||=e=>n(`context-menu-action`,e),onClose:r[1]||=e=>n(`close-context-menu`)},null,8,[`is-open`,`position`,`has-selection`,`is-editable`,`in-table`,`on-image`,`can-merge-cells`,`can-split-cell`]),(0,a.createVNode)(Bt,{state:e.imageContextMenu,"text-actions":e.imageContextMenuTextActions,"can-open-properties":e.canOpenImageProperties,onClose:r[2]||=e=>n(`close-image-context-menu`),onSelect:r[3]||=e=>n(`image-wrap-select`,e),onTextAction:r[4]||=e=>n(`context-menu-action`,e),onOpenProperties:r[5]||=e=>n(`open-image-properties`)},null,8,[`state`,`text-actions`,`can-open-properties`])],64))}}),Ht=[`href`,`title`],Ut=[`title`],X=[`title`],Wt=[`title`],Gt={class:`docx-hyperlink-popup__edit-row`},Kt=[`placeholder`,`onKeydown`],qt={class:`docx-hyperlink-popup__edit-row`},Jt=[`onKeydown`],Yt=[`disabled`],Xt=(0,a.defineComponent)({__name:`HyperlinkPopup`,props:{data:{},readOnly:{type:Boolean}},emits:[`navigate`,`copy`,`edit`,`remove`,`close`],setup(t,{emit:n}){let{t:r}=e.d(),i=t,o=n,s=(0,a.ref)(!1),c=(0,a.ref)(``),l=(0,a.ref)(``),u=(0,a.ref)(null),d=(0,a.computed)(()=>({left:(i.data?.position.left??0)+`px`,top:(i.data?.position.top??0)+`px`}));(0,a.watch)(()=>i.data?.href,()=>{s.value=!1});let f=null,p=null;function m(){p&&=(clearTimeout(p),null),f&&=(document.removeEventListener(`mousedown`,f),null)}(0,a.watch)(()=>i.data,e=>{m(),e&&(f=e=>{let t=u.value;t&&!t.contains(e.target)&&o(`close`)},p=setTimeout(()=>{f&&document.addEventListener(`mousedown`,f)},0))},{immediate:!0}),(0,a.onBeforeUnmount)(m);function h(){i.data&&(c.value=i.data.displayText,l.value=i.data.href,s.value=!0)}function g(){l.value.trim()&&(o(`edit`,c.value,l.value),s.value=!1)}function _(){i.data&&(o(`copy`,i.data.href),typeof navigator<`u`&&navigator.clipboard&&navigator.clipboard.writeText(i.data.href).catch(()=>{}))}return(e,n)=>t.data?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,ref_key:`popupRef`,ref:u,class:(0,a.normalizeClass)([`docx-hyperlink-popup`,{"docx-hyperlink-popup--edit":s.value}]),style:(0,a.normalizeStyle)(d.value),onMousedown:n[6]||=(0,a.withModifiers)(()=>{},[`stop`])},[s.value?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:1},[(0,a.createElementVNode)(`div`,Gt,[(0,a.withDirectives)((0,a.createElementVNode)(`input`,{class:`docx-hyperlink-popup__input`,placeholder:(0,a.unref)(r)(`hyperlinkPopup.displayTextPlaceholder`),"onUpdate:modelValue":n[2]||=e=>c.value=e,onKeydown:[(0,a.withKeys)((0,a.withModifiers)(g,[`prevent`]),[`enter`]),n[3]||=(0,a.withKeys)(t=>e.$emit(`close`),[`esc`])]},null,40,Kt),[[a.vModelText,c.value]])]),(0,a.createElementVNode)(`div`,qt,[(0,a.withDirectives)((0,a.createElementVNode)(`input`,{class:`docx-hyperlink-popup__input`,placeholder:`https://...`,"onUpdate:modelValue":n[4]||=e=>l.value=e,onKeydown:[(0,a.withKeys)((0,a.withModifiers)(g,[`prevent`]),[`enter`]),n[5]||=(0,a.withKeys)(t=>e.$emit(`close`),[`esc`])]},null,40,Jt),[[a.vModelText,l.value]]),(0,a.createElementVNode)(`button`,{class:`docx-hyperlink-popup__apply`,disabled:!l.value.trim(),onClick:(0,a.withModifiers)(g,[`prevent`])},(0,a.toDisplayString)((0,a.unref)(r)(`common.apply`)),9,Yt)])],64)):((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:0},[n[10]||=(0,a.createStaticVNode)(`<span class="docx-hyperlink-popup__icon" aria-hidden data-v-9d23bb12><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-9d23bb12><circle cx="12" cy="12" r="10" data-v-9d23bb12></circle><path d="M2 12h20" data-v-9d23bb12></path><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" data-v-9d23bb12></path></svg></span>`,1),(0,a.createElementVNode)(`a`,{class:`docx-hyperlink-popup__url`,href:t.data.href,title:t.data.href,onClick:n[0]||=(0,a.withModifiers)(n=>e.$emit(`navigate`,t.data.href),[`prevent`])},(0,a.toDisplayString)(t.data.href),9,Ht),n[11]||=(0,a.createElementVNode)(`span`,{class:`docx-hyperlink-popup__sep`},null,-1),(0,a.createElementVNode)(`button`,{class:`docx-hyperlink-popup__btn`,title:(0,a.unref)(r)(`hyperlinkPopup.copyLink`),onClick:(0,a.withModifiers)(_,[`prevent`])},[...n[7]||=[(0,a.createElementVNode)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,a.createElementVNode)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,a.createElementVNode)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})],-1)]],8,Ut),t.readOnly?(0,a.createCommentVNode)(``,!0):((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:0,class:`docx-hyperlink-popup__btn`,title:(0,a.unref)(r)(`hyperlinkPopup.editLink`),onClick:(0,a.withModifiers)(h,[`prevent`])},[...n[8]||=[(0,a.createElementVNode)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,a.createElementVNode)(`path`,{d:`M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`}),(0,a.createElementVNode)(`path`,{d:`M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z`})],-1)]],8,X)),t.readOnly?(0,a.createCommentVNode)(``,!0):((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:1,class:`docx-hyperlink-popup__btn`,title:(0,a.unref)(r)(`hyperlinkPopup.removeLink`),onClick:n[1]||=(0,a.withModifiers)(t=>e.$emit(`remove`),[`prevent`])},[...n[9]||=[(0,a.createStaticVNode)(`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-9d23bb12><path d="M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" data-v-9d23bb12></path><path d="M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" data-v-9d23bb12></path><line x1="8" y1="2" x2="8" y2="5" data-v-9d23bb12></line><line x1="2" y1="8" x2="5" y2="8" data-v-9d23bb12></line><line x1="16" y1="19" x2="16" y2="22" data-v-9d23bb12></line><line x1="19" y1="16" x2="22" y2="16" data-v-9d23bb12></line></svg>`,1)]],8,Wt))],64))],38)):(0,a.createCommentVNode)(``,!0)}}),Zt=n.t(Xt,[[`__scopeId`,`data-v-9d23bb12`]]);function Qt(e){let t=(0,a.ref)(null);async function n(){await e.nextTick(),e.extractCommentsAndChanges(),e.emit(`ready`)}async function r(t){try{let r=await(0,c.readDocxFileFromInput)(t);if(!r)return;await e.loadBuffer(r.buffer),e.emit(`update:document`,e.getDocument()),e.emit(`rename`,r.name),await n()}catch(t){e.emit(`error`,t instanceof Error?t:Error(`Failed to open document`))}}function i(t){e.onDocumentNameChange?.(t),e.emit(`rename`,t)}async function o(){let t=await e.saveBlob();if(!t)return;let n=(e.documentName()??``).trim()||`document`,r=URL.createObjectURL(t),i=window.document.createElement(`a`);i.href=r,i.download=`${n.replace(/\.docx$/i,``)}.docx`,i.click(),setTimeout(()=>URL.revokeObjectURL(r),0)}async function s(t){await e.loadBuffer(t),e.emit(`update:document`,e.getDocument()),await n()}function l(t){e.loadParsedDocument(t),e.emit(`update:document`,t),n()}async function u(){let t=await e.saveBlob();return t?t.arrayBuffer():null}return{docxInputRef:t,handleDocxFileChange:r,handleDocumentNameChange:i,downloadCurrentDocument:o,emitReadyAfterSidebarStateRefresh:n,loadDocumentBuffer:s,loadDocument:l,save:u}}function $t(e){let t=(0,a.ref)(null);function n(t){let n=e.editorView.value;if(!n)return;let r=e.getCommands(),{empty:i}=n.state.selection,a=t.bookmark?`#${t.bookmark}`:t.url;if(a){if(i&&t.displayText){let e=r.insertHyperlink;e&&e(t.displayText,a,t.tooltip||void 0)(n.state,e=>n.dispatch(e),n)}else{let e=r.setHyperlink;e&&e(a,t.tooltip||void 0)(n.state,e=>n.dispatch(e),n)}n.focus()}}function r(){let t=e.editorView.value;if(!t)return;let n=e.getCommands().removeHyperlink;n&&n()(t.state,e=>t.dispatch(e),t),t.focus()}function i(e){window.open(e,`_blank`,`noopener,noreferrer`),t.value=null}function o(n,r){let i=e.editorView.value;if(!i)return;let a=(0,u.findHyperlinkRangeAt)(i.state);if(!a){t.value=null;return}let o=i.state.schema.marks.hyperlink,{$from:s}=i.state.selection,c=o.create({href:r,tooltip:a.mark.attrs.tooltip}),l=s.marks().filter(e=>e.type!==o),d=i.state.schema.text(n,[...l,c]),f=i.state.tr.replaceWith(a.start,a.end,d);i.dispatch(f.scrollIntoView()),t.value=null,i.focus()}function s(){let n=e.editorView.value;if(!n)return;let r=(0,u.findHyperlinkRangeAt)(n.state,t.value?.href);if(!r){t.value=null;return}let i=n.state.schema.marks.hyperlink,a=n.state.tr.removeMark(r.start,r.end,i);n.dispatch(a.scrollIntoView()),t.value=null,n.focus()}return{hyperlinkPopupData:t,handleHyperlinkSubmit:n,handleHyperlinkRemove:r,handleHyperlinkPopupNavigate:i,handleHyperlinkPopupEdit:o,handleHyperlinkPopupRemove:s}}function en(e){function t(){let t=e.editorView.value;t&&((0,u.clearFormatting)(t.state,t.dispatch,t),t.focus())}function n(t){let n=e.editorView.value;if(!n)return;let r=e.getDocument()?.package?.styles;if(r){let e=(0,S.createStyleResolver)(r).resolveParagraphStyle(t);(0,x.applyStyle)(t,{paragraphFormatting:e.paragraphFormatting,runFormatting:e.runFormatting})(n.state,e=>n.dispatch(e))}else (0,x.applyStyle)(t)(n.state,e=>n.dispatch(e));n.focus()}function r(){let t=e.editorView.value;t&&((0,C.insertPageBreak)(t.state,e=>t.dispatch(e),t),t.focus())}function i(t){let n=e.editorView.value;if(!n)return;let{from:r}=n.state.selection,i=n.state.tr.insertText(t,r);n.dispatch(i.scrollIntoView()),n.focus()}function a(t){let n=e.editorView.value;return n?(0,w.applyFormatting)(n,t):!1}function o(t){let n=e.editorView.value;if(!n)return!1;let r=e.getDocument();return(0,w.setParagraphStyle)(n,t,{styleResolver:r?.package?.styles?(0,S.createStyleResolver)(r.package.styles):null})}return{handleClearFormatting:t,handleApplyStyle:n,handleInsertPageBreak:r,handleInsertSymbol:i,applyFormatting:a,setParagraphStyle:o}}function tn(e){function t(t){let n=e.getDocument();if(!n?.package?.document)return;let r=n.package.document.finalSectionProperties??{};n.package.document.finalSectionProperties={...r,...t},e.stateTick.value++,e.reLayout(),e.emit(`change`,n)}function n(n,r){e.readOnly.value||t({[n]:r})}function r(e){n(`marginLeft`,e)}function i(e){n(`marginRight`,e)}function a(e){n(`marginTop`,e)}function o(e){n(`marginBottom`,e)}function s(t){let n=e.editorView.value;n&&(0,x.setIndentLeft)(t)(n.state,n.dispatch)}function c(t){let n=e.editorView.value;n&&(0,x.setIndentRight)(t)(n.state,n.dispatch)}function l(t){let n=e.editorView.value;n&&(t<0?(0,x.setIndentFirstLine)(-t,!0)(n.state,n.dispatch):(0,x.setIndentFirstLine)(t,!1)(n.state,n.dispatch))}function u(t){let n=e.editorView.value;n&&(0,x.removeTabStop)(t)(n.state,n.dispatch)}return{handlePageSetupApply:t,handleLeftMarginChange:r,handleRightMarginChange:i,handleTopMarginChange:a,handleBottomMarginChange:o,handleIndentLeftChange:s,handleIndentRightChange:c,handleFirstLineIndentChange:l,handleTabStopRemove:u}}function nn(e){let t=(0,a.ref)(!1),n=(0,a.computed)(()=>{e.stateTick.value;let t=e.editorView.value;return t?(0,T.getWatermarkFromState)(t.state)??void 0:void 0});function r(t){if(e.readOnly.value)return;let n=e.editorView.value;n&&((0,T.setWatermark)(t)(n.state,n.dispatch),e.stateTick.value++,n.focus())}return{showWatermark:t,currentWatermark:n,handleWatermarkApply:r}}function rn(e){function t(){if(!e.showOutline.value){let t=e.editorView.value;t&&(e.outlineHeadings.value=(0,E.collectHeadings)(t.state.doc))}e.showOutline.value=!e.showOutline.value}function n(t){let n=e.editorView.value;if(!n)return;let r=n.state.doc.resolve(Math.min(t+1,n.state.doc.content.size)),i=o.TextSelection.near(r);n.dispatch(n.state.tr.setSelection(i).scrollIntoView()),n.focus()}function r(){e.showSidebar.value||e.extractCommentsAndChanges(),e.showSidebar.value=!e.showSidebar.value}function i(t){let n=t.target;n&&(n.closest(`.paged-editor__pages`)||n.closest(`.unified-sidebar`)||n.closest(`.docx-comment-margin-markers`)||(e.activeSidebarItem.value=null))}return{handleToggleOutline:t,handleOutlineNavigate:n,handleToggleSidebar:r,handleEditorScrollMouseDown:i}}function an(e){function t(t){if(t.key===`F1`){t.preventDefault(),e.showKeyboardShortcuts.value=!0;return}e.handleZoomKeyDown(t),(t.ctrlKey||t.metaKey)&&(e.disableFindReplaceShortcuts?.()&&(t.key===`f`||t.key===`h`)||(t.key===`f`||t.key===`h`?(t.preventDefault(),e.showFindReplace.value=!0):t.key===`k`?(t.preventDefault(),e.showHyperlink.value=!0):t.key===`/`&&(t.preventDefault(),e.showKeyboardShortcuts.value=!e.showKeyboardShortcuts.value)))}return(0,a.onMounted)(()=>window.addEventListener(`keydown`,t)),(0,a.onBeforeUnmount)(()=>window.removeEventListener(`keydown`,t)),{handleKeyDown:t}}function on(e){function t(){(0,O.seedCommentAllocator)(e.commentIdAllocator,e.getDocument()?.package?.document?.comments,e.editorView.value)}function n(n,r,i){return t(),(0,D.createComment)(e.commentIdAllocator,n,r,i)}function r(n){let r=e.getDocument(),i=e.editorView.value;if(!r?.package?.document||!i)return null;r.package.document.comments||(r.package.document.comments=[]),t();let a=(0,D.addCommentToRange)(i,n,e.commentIdAllocator);return a?(r.package.document.comments.push(a),e.comments.value=[...r.package.document.comments],e.showSidebar.value=!0,e.emit(`change`,r),e.contentChangeSubscribers.forEach(e=>e(r)),a.id):null}function i(t,r,i){let a=e.getDocument();if(!a?.package?.document?.comments||!a.package.document.comments.some(e=>e.id===t))return null;let o=n(r,i,t);return a.package.document.comments.push(o),e.comments.value=[...a.package.document.comments],e.emit(`change`,a),e.contentChangeSubscribers.forEach(e=>e(a)),o.id}function a(t){let n=e.getDocument();if(!n?.package?.document?.comments)return;let r=n.package.document.comments.find(e=>e.id===t);r&&(r.done=!0,e.comments.value=[...n.package.document.comments],e.emit(`change`,n),e.contentChangeSubscribers.forEach(e=>e(n)))}function o(n){let r=e.editorView.value;if(!r)return!1;t();let i=(0,D.applyProposedChange)(r,n,e.commentIdAllocator);return i&&(e.extractCommentsAndChanges(),e.showSidebar.value=!0),i}function s(e,t){i(e,t,`User`)}function c(t){let n=e.getDocument();if(!n?.package?.document?.comments)return;let r=n.package.document.comments.find(e=>e.id===t);r&&(r.done=!1),e.comments.value=[...n.package.document.comments],e.emit(`change`,n)}function l(t){let n=e.getDocument();n?.package?.document?.comments&&(n.package.document.comments=n.package.document.comments.filter(e=>e.id!==t&&e.parentId!==t),e.comments.value=[...n.package.document.comments],e.emit(`change`,n))}function u(t,n){let r=e.editorView.value;r&&((0,T.acceptChange)(t,n)(r.state,r.dispatch),e.extractCommentsAndChanges(),r.focus())}function d(t,n){let r=e.editorView.value;r&&((0,T.rejectChange)(t,n)(r.state,r.dispatch),e.extractCommentsAndChanges(),r.focus())}function f(t){let n=e.editorView.value;n&&((0,T.acceptChangeById)(t)(n.state,n.dispatch),e.extractCommentsAndChanges(),n.focus())}function p(t){let n=e.editorView.value;n&&((0,T.rejectChangeById)(t)(n.state,n.dispatch),e.extractCommentsAndChanges(),n.focus())}function m(t,r){let i=e.getDocument(),a=e.editorView.value;if(!i?.package?.document||!a)return;i.package.document.comments||(i.package.document.comments=[]);let o=a.state.schema.marks.comment;if(!o)return;let s=null,c=a.state.schema.marks.insertion,l=a.state.schema.marks.deletion;if(a.state.doc.descendants((e,n)=>{if(s!==null)return!1;for(let r of e.marks)if((r.type===c||r.type===l)&&r.attrs.revisionId===t)return s=n,!1;return!0}),s===null)return;let u=n(r,`User`);i.package.document.comments.push(u),e.comments.value=[...i.package.document.comments];let d=s,f=Math.min(d+1,a.state.doc.content.size);a.dispatch(a.state.tr.addMark(d,f,o.create({commentId:u.id}))),e.emit(`change`,i)}return{addComment:r,replyToComment:i,resolveComment:a,proposeChange:o,handleCommentReply:s,handleCommentUnresolve:c,handleCommentDelete:l,handleAcceptChange:u,handleRejectChange:d,handleAcceptChangeById:f,handleRejectChangeById:p,handleTrackedChangeReply:m}}function sn(e){let t=(0,a.ref)(null),n=(0,a.ref)(null),r=(0,a.ref)(null),i=(0,a.ref)(!1);function o(){let t=e.getDocument(),n=e.editorView.value;!t||!n||(e.comments.value=[...t.package?.document?.comments??[]],e.trackedChanges.value=(0,k.extractTrackedChanges)(n.state).entries,!i.value&&(e.comments.value.length>0||e.trackedChanges.value.length>0)&&(e.showSidebar.value=!0,i.value=!0))}function s(){e.stateTick.value;let n=e.editorView.value;if(!n||e.isAddingComment.value||e.readOnly.value){t.value=null;return}let{from:r,to:i}=n.state.selection;if(r===i){t.value=null;return}let a=e.pagesRef.value,o=e.pagesViewportRef.value;if(!a||!o){t.value=null;return}let s=o.getBoundingClientRect(),c=I(a,r);if(!c){t.value=null;return}let l=c.getBoundingClientRect().top-s.top+o.scrollTop,u=a.querySelector(`.layout-page`);if(!u){t.value=null;return}t.value={top:l,left:u.getBoundingClientRect().right-s.left+8}}function c(){e.stateTick.value;let t=e.editorView.value;if(!t)return;let n=t.state.selection.$from,r=[...t.state.storedMarks??[],...n.nodeAfter?.marks??[],...n.nodeBefore?.marks??[],...n.marks()],i=null;for(let t of r){if(t.type.name===`comment`&&t.attrs.commentId!=null){let n=t.attrs.commentId;if(n===O.PENDING_COMMENT_ID||e.resolvedCommentIds.value.has(n))continue;i=`comment-${n}`;break}if((t.type.name===`insertion`||t.type.name===`deletion`)&&t.attrs.revisionId!=null){let n=String(t.attrs.revisionId),r=e.trackedChanges.value.findIndex(e=>String(e.revisionId)===n||String(e.insertionRevisionId??``)===n);if(r>=0){i=`tc-${e.trackedChanges.value[r].revisionId}-${r}`;break}}}i&&(e.showSidebar.value=!0),e.activeSidebarItem.value=i}function l(){let i=e.editorView.value;if(!i)return;let{from:a,to:o}=i.state.selection;if(a===o)return;n.value={from:a,to:o},r.value=t.value?.top??null;let s=i.state.schema.marks.comment;if(s){let e=i.state.tr.addMark(a,o,s.create({commentId:O.PENDING_COMMENT_ID}));i.dispatch(e)}e.showSidebar.value=!0,e.isAddingComment.value=!0,t.value=null}function u(t){let i=e.getDocument(),a=e.editorView.value;if(!i?.package)return;i.package.document.comments||(i.package.document.comments=[]),(0,O.seedCommentAllocator)(e.commentIdAllocator,i.package.document.comments,a);let o=(0,D.createComment)(e.commentIdAllocator,t,`User`);i.package.document.comments.push(o),e.comments.value=[...i.package.document.comments];let s=n.value;if(a&&s&&s.from!==s.to){let e=a.state.schema.marks.comment;if(e){let t=a.state.tr.removeMark(s.from,s.to,e);t=t.addMark(s.from,s.to,e.create({commentId:o.id})),a.dispatch(t)}}n.value=null,r.value=null,e.isAddingComment.value=!1,e.emit(`change`,i)}function d(){let t=e.editorView.value,i=n.value;if(t&&i&&i.from!==i.to){let e=t.state.schema.marks.comment;e&&t.dispatch(t.state.tr.removeMark(i.from,i.to,e))}n.value=null,r.value=null,e.isAddingComment.value=!1}function f(t){e.showSidebar.value=!0}(0,a.watch)([e.stateTick,e.isAddingComment,e.zoom],()=>s()),(0,a.watch)(e.stateTick,()=>c()),(0,a.watch)(e.stateTick,()=>o());let p=null;return(0,a.onMounted)(()=>{p=new ResizeObserver(()=>s()),e.pagesRef.value&&p.observe(e.pagesRef.value),window.addEventListener(`resize`,s)}),(0,a.onBeforeUnmount)(()=>{p?.disconnect(),window.removeEventListener(`resize`,s)}),{floatingCommentBtn:t,pendingCommentRange:n,addCommentYPosition:r,sidebarAutoOpenedRef:i,extractCommentsAndChanges:o,handleAddComment:u,handleCancelAddComment:d,handleStartAddComment:l,handleMarkerClick:f,recomputeFloatingCommentBtn:s,recomputeActiveSidebarItem:c}}function cn(e){let t=(0,a.shallowRef)(null),n=(0,a.ref)(!1),r=(0,a.computed)(()=>{e.stateTick.value;let n=e.editorView.value,r=t.value;if(!n||!r)return null;let i=n.state.doc.nodeAt(r.pmPos);return!i||i.type.name!==`image`?null:{wrapType:i.attrs.wrapType??`inline`,displayMode:i.attrs.displayMode??`inline`,cssFloat:i.attrs.cssFloat??null}});function i(t){let n=e.editorView.value;if(!n)return;let r=n.state.schema.nodes.image;if(!r)return;let i=r.create({src:t.src,alt:t.alt,width:t.width,height:t.height});(0,T.insertImageNode)(n.state,n.dispatch,i,n.state.selection.from),n.focus()}function o(n){let r=e.editorView.value,i=t.value;if(!r||!i)return;let a=(0,m.toolbarValueToLayoutTarget)(n);if(!a)return;let o=r.state.doc.nodeAt(i.pmPos),s=e.getCommands(),c=o?.attrs.wrapType===`inline`&&a!==`inline`?{initialPositionEmu:(0,m.captureInlinePositionEmu)(i.element,e.zoom.value)}:void 0,l=s.setImageWrapType?.(i.pmPos,a,c);l&&(l(r.state,e=>r.dispatch(e),r),r.focus())}function s(n){let r=e.editorView.value,i=t.value;if(!r||!i)return;let a=r.state.doc.nodeAt(i.pmPos);if(!a||a.type.name!==`image`)return;let o=a.attrs.transform||``,s=o.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),c=s?parseFloat(s[1]):0,l=/scaleX\(-1\)/.test(o),u=/scaleY\(-1\)/.test(o);n===`rotateCW`?c=(c+90)%360:n===`rotateCCW`?c=(c-90+360)%360:n===`flipH`?l=!l:n===`flipV`&&(u=!u);let d=[];c!==0&&d.push(`rotate(${c}deg)`),l&&d.push(`scaleX(-1)`),u&&d.push(`scaleY(-1)`);let f=d.length>0?d.join(` `):null,p=r.state.tr.setNodeMarkup(i.pmPos,void 0,{...a.attrs,transform:f});r.dispatch(p.scrollIntoView()),r.focus()}return{selectedImage:t,imageInteracting:n,imageToolbarContext:r,handleInsertImage:i,handleToolbarImageWrap:o,handleImageTransform:s}}function Z(e,t,n){let r=(0,y.makeRevisionInfo)(e.state),i=e.state.schema.marks.insertion;if(!r||!i)return;let a=t.selection.from,o=a-n.nodeSize;o<0||t.addMark(o,a,i.create({revisionId:r.revisionId,author:r.author,date:r.date}))}function Q(e,t){return e.getBlob(t)}function $(e,t){let n=e.state.doc.nodeAt(t);if(!n||n.type.name!==`image`)return;let r=`<img src="${n.attrs.src}" data-pm-image="true" data-width="${n.attrs.width??``}" data-height="${n.attrs.height??``}" data-wrap-type="${n.attrs.wrapType??``}" data-display-mode="${n.attrs.displayMode??``}" data-rid="${n.attrs.rId??``}" />`,i=new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([`[image]`],{type:`text/plain`})});navigator.clipboard.write([i]).catch(()=>{let e=document.createElement(`textarea`);e.value=r,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)})}function ln(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function un(e){return new Promise(t=>{let n=new Image;n.onload=()=>t({width:n.naturalWidth,height:n.naturalHeight}),n.onerror=()=>t({width:200,height:200}),n.src=e})}async function dn(e){try{let t=await navigator.clipboard.read();for(let n of t){let t=n.types.find(e=>e.startsWith(`image/`));if(t){let r=await ln(await Q(n,t)),i=await un(r),a=i.width,o=i.height;a>612&&(o=Math.round(612/a*o),a=612);let s=e.state.schema.nodes.image.create({src:r,width:a,height:o,rId:`rId_img_${Date.now()}`,wrapType:`inline`,displayMode:`inline`}),c=e.state.tr.replaceSelectionWith(s);Z(e,c,s),e.dispatch(c);return}if(n.types.includes(`text/html`)){let t=await(await Q(n,`text/html`)).text(),r=t.match(/<img[^>]+src="([^"]+)"[^>]*>/i);if(r&&r[1]){let n=r[1],i=t.match(/data-width="(\d+)"/),a=t.match(/data-height="(\d+)"/),o=i?Number(i[1]):200,s=a?Number(a[1]):200,c=e.state.schema.nodes.image.create({src:n,width:o||200,height:s||200,rId:`rId_img_${Date.now()}`,wrapType:`inline`,displayMode:`inline`}),l=e.state.tr.replaceSelectionWith(c);Z(e,l,c),e.dispatch(l);return}}if(n.types.includes(`text/plain`)){let t=await(await Q(n,`text/plain`)).text();if(t&&t!==`[image]`){let{from:n}=e.state.selection;e.dispatch(e.state.tr.insertText(t,n))}return}}}catch{let t=await navigator.clipboard?.readText();if(t){let{from:n}=e.state.selection;e.dispatch(e.state.tr.insertText(t,n))}}}function fn(e,t){let n=e.state.doc.nodeAt(t);if(!n||n.type.name!==`image`)return;let r=document.createElement(`input`);r.type=`file`,r.accept=`image/*`,r.onchange=async()=>{let i=r.files?.[0];if(!i)return;let a=await ln(i),o=await un(a),s=n.attrs.width||o.width,c=n.attrs.height||o.height,l=Math.min(s/o.width,c/o.height),u=Math.round(o.width*l),d=Math.round(o.height*l);try{let r=e.state.tr.setNodeMarkup(t,void 0,{...n.attrs,src:a,width:u,height:d,rId:`rId_img_${Date.now()}`});e.dispatch(r)}catch{}},r.click()}function pn(t){let{t:n}=e.d(),r=(0,a.ref)({isOpen:!1,position:{x:0,y:0},hasSelection:!1,inTable:!1,onImage:!1,canMergeCells:!1,canSplitCell:!1}),i=(0,a.ref)(null),s=(0,a.computed)(()=>[{action:`cut`,label:n(`contextMenu.cut`),shortcut:n(`contextMenu.cutShortcut`)},{action:`copy`,label:n(`contextMenu.copy`),shortcut:n(`contextMenu.copyShortcut`)},{action:`paste`,label:n(`contextMenu.paste`),shortcut:n(`contextMenu.pasteShortcut`),dividerAfter:!0},{action:`delete`,label:n(`contextMenu.delete`),shortcut:n(`contextMenu.deleteShortcut`)}]);function c(e){let n=t.editorView.value;if(!n)return;let a=e.target,s=(0,m.findImageElement)(a);if(s){let a=Number(s.dataset.pmStart);if(!isNaN(a)){try{let e=o.NodeSelection.create(n.state.doc,a);n.dispatch(n.state.tr.setSelection(e))}catch{}t.selectedImage.value={element:s,pmPos:a,width:s.offsetWidth,height:s.offsetHeight},t.clearOverlay();let c=n.state.doc.nodeAt(a);if(c&&c.type.name===`image`){let n=c.attrs.wrapType??`inline`,o=c.attrs.cssFloat;i.value={open:!0,position:{x:e.clientX,y:e.clientY},pmPos:a,currentWrapType:n,currentCssFloat:o??null,inlinePositionEmu:n===`inline`?(0,m.captureInlinePositionEmu)(s,t.zoom.value):void 0},r.value.isOpen=!1;return}}}{let{from:r,to:i}=n.state.selection,a=t.resolvePos(e.clientX,e.clientY);if(a!==null&&(a<r||a>i))try{t.setPmSelection(a)}catch{}}let c=(0,d.getTableContext)(n.state),{empty:l}=n.state.selection;i.value&&=null,r.value={isOpen:!0,position:{x:e.clientX,y:e.clientY},hasSelection:!l,inTable:c.isInTable,onImage:!!s,canMergeCells:!!c.hasMultiCellSelection,canSplitCell:!!c.canSplitCell}}function l(e){let n=t.editorView.value,a=t.selectedImage.value;if(!n||!a)return;let o=n.state.doc.nodeAt(a.pmPos);if(!o||o.type.name!==`image`)return;let s=o.attrs.wrapType??`inline`,c=o.attrs.cssFloat;i.value={open:!0,position:{x:e.clientX,y:e.clientY},pmPos:a.pmPos,currentWrapType:s,currentCssFloat:c??null,inlinePositionEmu:s===`inline`?(0,m.captureInlinePositionEmu)(a.element,t.zoom.value):void 0},r.value.isOpen=!1}function u(e){let n=t.editorView.value,r=i.value;if(!n||!r)return;let a=t.getCommands(),o=r.inlinePositionEmu&&e!==`inline`?{initialPositionEmu:r.inlinePositionEmu}:void 0,s=a.setImageWrapType?.(r.pmPos,e,o);s&&(s(n.state,e=>n.dispatch(e),n),n.focus())}function f(e){let n=t.editorView.value;if(!n)return;let r=t.getCommands();switch(e){case`cut`:if(t.selectedImage.value){$(n,t.selectedImage.value.pmPos);let e=t.selectedImage.value.pmPos,r=n.state.doc.nodeAt(e);r&&(n.dispatch(n.state.tr.delete(e,e+r.nodeSize)),t.selectedImage.value=null)}else document.execCommand(`cut`);break;case`copy`:t.selectedImage.value?$(n,t.selectedImage.value.pmPos):document.execCommand(`copy`);break;case`paste`:dn(n);break;case`pasteAsPlainText`:navigator.clipboard.readText().then(e=>{e&&n.dispatch(n.state.tr.insertText(e).scrollIntoView())}).catch(()=>{});break;case`delete`:{let{from:e,to:t}=n.state.selection;e!==t&&n.dispatch(n.state.tr.delete(e,t));break}case`selectAll`:{let e=o.TextSelection.create(n.state.doc,0,n.state.doc.content.size);n.dispatch(n.state.tr.setSelection(e));break}case`imageProperties`:t.selectedImage.value&&(t.showImageProperties.value=!0);break;case`replaceImage`:t.selectedImage.value&&fn(n,t.selectedImage.value.pmPos);break;case`deleteImage`:if(t.selectedImage.value){let e=t.selectedImage.value.pmPos,r=n.state.doc.nodeAt(e);r&&(n.dispatch(n.state.tr.delete(e,e+r.nodeSize)),t.selectedImage.value=null)}break;case`addRowAbove`:case`addRowBelow`:case`deleteRow`:case`addColumnLeft`:case`addColumnRight`:case`deleteColumn`:case`mergeCells`:case`splitCell`:{let t=r[e];t&&t()(n.state,e=>n.dispatch(e),n);break}}n.focus()}return{contextMenu:r,imageContextMenu:i,imageContextMenuTextActions:s,handleContextMenu:c,handleSelectedImageContextMenu:l,handleImageWrapSelect:u,handleContextMenuAction:f}}var mn=500;function hn(e){let t=(0,a.ref)(null),n=null;function r(){n!==null&&(clearTimeout(n),n=null)}let s=(0,a.shallowRef)(null),c=0,l=null,u=0,d=!1,f=null,p=i.t({pagesContainer:e.pagesRef,onScrollExtendSelection:(e,t)=>{if(!d||f===null)return;let n=_(e,t);n!==null&&n!==f&&y(f,n)}}),h=(0,a.ref)({currentPage:1,totalPages:1,visible:!1}),g=null;function _(t,n){return ne(e.pagesRef.value,e.editorView.value,t,n)}function v(){let t=s.value;if(t?.headerFooter&&e.getHfPmView){let n=e.getHfPmView(t.headerFooter);if(n)return n}return e.editorView.value}function y(e,t){let n=v();if(n)try{let r=n.state.doc.resolve(e),i=t===void 0?r:n.state.doc.resolve(t),a=o.TextSelection.between(r,i);n.dispatch(n.state.tr.setSelection(a))}catch{}}function b(t){L(e.pagesRef.value,e.pagesViewportRef.value,t)}function x(t){re(e.pagesRef.value,t,y,s.value?.position)}function S(t){R(e.pagesRef.value,t,y,s.value?.position)}function C(t){let n=e.editorView.value;if(!n)return;let r=null;if(n.state.doc.descendants((e,n)=>r===null?(e.attrs?.bookmarks)?.some(e=>e.name===t)?(r=n,!1):!0:!1),r!==null){b(r);try{y(Math.min(r+1,n.state.doc.content.size))}catch{y(r)}}}function w(i){if(e.readOnly.value||d)return;let a=e.pagesRef.value;if(!a)return;let o=e.pagesViewportRef.value;if(!o)return;let c=(0,A.detectTableInsertHover)({mouseX:i.clientX,mouseY:i.clientY,pagesContainer:a,target:i.target,hfEditMode:s.value?.position??null});if(!c){n===null&&(n=setTimeout(()=>{t.value=null,n=null},A.TABLE_INSERT_HIDE_DELAY_MS));return}let l=o.getBoundingClientRect();t.value={type:c.type,x:c.clientX-l.left,y:c.clientY-l.top,cellPmPos:c.cellPmPos},r()}function T(n){n.preventDefault(),n.stopPropagation();let r=t.value,i=e.editorView.value;if(!r||!i)return;let a=i.state.tr.setSelection(o.TextSelection.create(i.state.doc,r.cellPmPos+1));i.dispatch(a);let s=e.getCommands(),c=r.type===`row`?s.addRowBelow?.():s.addColumnRight?.();c&&(c(i.state,e=>i.dispatch(e),i),t.value=null,i.focus())}function E(t){let n=t.target?.closest(`a[href]`);if(!n)return;t.preventDefault();let r=n.getAttribute(`href`)||``;if(r.startsWith(`#`)){let e=r.slice(1);e&&C(e);return}let i=v();if(i&&i.state.selection.from!==i.state.selection.to)return;let a=e.pagesViewportRef.value;if(!a)return;let o=a.getBoundingClientRect(),s=n.getBoundingClientRect();e.hyperlinkPopupData.value={href:r,displayText:n.textContent||``,tooltip:n.getAttribute(`title`)||void 0,position:{top:s.bottom-o.top+a.scrollTop+4,left:s.left-o.left+a.scrollLeft}}}function D(t){let n=t.target,r=n.closest(`.layout-page-header`),i=n.closest(`.layout-page-footer`),a=r??i;if(!a)return;let o=r?`header`:`footer`,c=e.getDocument();if(!c?.package)return;let l=c.package.document?.sections?.[0]?.properties??c.package.document?.finalSectionProperties??null,u=o===`header`?l?.headerReferences:l?.footerReferences,d=o===`header`?c.package.headers:c.package.footers,f=(u?.find(e=>e.type===`default`)??u?.find(e=>e.type===`first`)??null)?.rId??null,p=f?d?.get(f)??null:null;if(!p){if(!l)return;let t=`default`,n=`rId_new_${o}_${t}`,r={type:o,hdrFtrType:t,content:[{type:`paragraph`,content:[]}]},i=o===`header`?`headers`:`footers`,a=o===`header`?`headerReferences`:`footerReferences`,s=new Map(c.package[i]??[]);s.set(n,r);let u=c.package.relationships,d=new Set;for(let e of u?.values()??[])e.target&&d.add(e.target);let m=1;for(;d.has(`${o}${m}.xml`);)m++;let h=o===`header`?`http://schemas.openxmlformats.org/officeDocument/2006/relationships/header`:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer`,g=new Map(u);g.set(n,{id:n,type:h,target:`${o}${m}.xml`});let _={type:t,rId:n},v=l&&{...l,[a]:[...l[a]??[],_]},y={...c,package:{...c.package,[i]:s,relationships:g,document:c.package.document?{...c.package.document,sections:c.package.document.sections?.map((e,t)=>t===0?{...e,properties:v??e.properties}:e),finalSectionProperties:c.package.document.finalSectionProperties===l?v:c.package.document.finalSectionProperties}:c.package.document}};f=n,p=r,e.setDocument?.(y),e.syncHfPMs?.(),e.reLayout(),e.emit(`change`,y)}let m=e.pagesViewportRef.value;if(!m)return;let h=a.getBoundingClientRect(),g=m.getBoundingClientRect(),_=e.zoom.value||1;s.value={position:o,rId:f,headerFooter:p,targetRect:{top:(h.top-g.top+m.scrollTop)/_,left:(h.left-g.left+m.scrollLeft)/_,width:h.width/_,height:h.height/_}}}function O(t){let n=e.getDocument(),r=s.value;if(!n?.package||!r)return;let i=r.position===`header`?n.package.headers:n.package.footers;if(!i||!r.rId)return;let a=i.get(r.rId);a&&(a.content=t),e.syncHfPMs?.(),e.reLayout(),e.emit(`change`,n)}function k(){let t=e.getDocument(),n=s.value;if(!t?.package||!n||!n.rId){s.value=null;return}let r=n.position===`header`?`headers`:`footers`,i=n.position===`header`?`headerReferences`:`footerReferences`,a=n.rId,o=new Map(t.package[r]??[]);o.delete(a);let c=e=>({...e,[i]:(e[i]??[]).filter(e=>e.rId!==a)}),l=e=>`sectionProperties`in e&&e.sectionProperties?{...e,sectionProperties:c(e.sectionProperties)}:e,u=t.package.document,d={...t,package:{...t.package,[r]:o,document:u&&{...u,content:u.content.map(l),sections:u.sections?.map(e=>({...e,properties:c(e.properties)})),finalSectionProperties:u.finalSectionProperties?c(u.finalSectionProperties):u.finalSectionProperties}}};s.value=null,e.setDocument?.(d),e.syncHfPMs?.(),e.reLayout(),e.emit(`change`,d)}function j(t){if(t.button!==0||e.imageInteracting.value)return;let n=e.editorView.value;if(!n)return;let r=t.target;s.value&&(r.closest(`.layout-page-header`)||r.closest(`.layout-page-footer`)||r.closest(`.hf-editor`)||(s.value=null,n.focus()));let i=v()??n;if(!e.readOnly.value&&e.tableResize.tryStartResize(t,i))return;let a=(0,m.findImageElement)(r);if(a){t.preventDefault(),t.stopPropagation();let n=Number(a.dataset.pmStart);if(!isNaN(n)){try{i.dispatch(i.state.tr.setSelection(o.NodeSelection.create(i.state.doc,n)))}catch{}e.selectedImage.value={element:a,pmPos:n,width:a.offsetWidth,height:a.offsetHeight},e.clearOverlay()}i.focus();return}e.selectedImage.value=null,t.preventDefault();let p=_(t.clientX,t.clientY);if(p===null){i.focus();return}let h=Date.now();if(h-c<mn&&l===p?u++:u=1,c=h,l=p,u===2)x(p);else if(u>=3)S(p),u=0;else{if(t.shiftKey){let{from:e}=i.state.selection;y(e,p)}else y(p);f=p,d=!0}i.focus()}function M(e){if(!d||f===null)return;let t=_(e.clientX,e.clientY);t!==null&&t!==f&&y(f,t),p.updateMousePosition(e.clientX,e.clientY)}function N(){d=!1,p.stopAutoScroll()}function P(){let t=e.pagesViewportRef.value,n=e.layout.value;if(!t||!n||n.pages.length===0)return;let r=t.scrollTop,i=n.pages.length,a=r+t.clientHeight/2,o=24,s=1;for(let e=0;e<n.pages.length;e++){let t=n.pages[e].size.h,r=o+t;if(a<r){s=e+1;break}o=r+24,s=e+2}s=Math.min(s,i),h.value={currentPage:s,totalPages:i,visible:!0},g&&clearTimeout(g),g=setTimeout(()=>{h.value={...h.value,visible:!1}},600)}return(0,a.onMounted)(()=>{window.addEventListener(`mousemove`,M),window.addEventListener(`mouseup`,N),e.pagesViewportRef.value?.addEventListener(`scroll`,P,{passive:!0})}),(0,a.onBeforeUnmount)(()=>{r(),window.removeEventListener(`mousemove`,M),window.removeEventListener(`mouseup`,N),e.pagesViewportRef.value?.removeEventListener(`scroll`,P),g&&clearTimeout(g)}),{tableInsertButton:t,hfEdit:s,scrollPageInfo:h,resolvePos:_,setPmSelection:y,scrollVisiblePositionIntoView:b,navigateToBookmark:C,handlePagesMouseDown:j,handlePagesMouseMove:w,handlePagesClick:E,handlePagesDoubleClick:D,handleTableInsertClick:T,clearTableInsertTimer:r,handleHfSave:O,handleHfRemove:k}}function gn(e){let t=null,n=null,i=null;function c(){let r=e.pagesRef.value;r&&(r.querySelectorAll(`.vue-sel-rect, .vue-caret`).forEach(e=>e.remove()),t!==null&&(clearInterval(t),t=null),n=null)}function l(){i!==null&&cancelAnimationFrame(i),i=requestAnimationFrame(()=>{i=null;let t=e.pagesRef.value,n=e.editorView.value;if(!t||!n||e.isHfEditing?.value)return;let r=n.state.selection;if(r instanceof o.NodeSelection&&r.node.type.name===`image`){let n=(0,s.findBodyPmAnchor)(t,r.from),i=n?(0,m.findImageElement)(n):null;if(i){let t=e.selectedImage.value;(!t||t.element!==i||t.pmPos!==r.from||t.width!==i.offsetWidth||t.height!==i.offsetHeight)&&(e.selectedImage.value={element:i,pmPos:r.from,width:i.offsetWidth,height:i.offsetHeight});return}}e.imageInteracting?.value||(e.selectedImage.value=null)})}function u(){let i=e.pagesRef.value,a=e.editorView.value;if(!i||!a||(c(),e.isHfEditing?.value))return;l(),(0,s.applyCellSelectionHighlight)(i,a.state);let u=a.state.selection;if(u instanceof o.NodeSelection&&u.node.type.name===`image`)return;let{from:d,to:p,empty:m}=u,h=i.scrollTop,g=i.scrollLeft,_=e.zoom.value||1;if(m){let e=(0,f.getCaretPositionFromDom)(i,d,i.getBoundingClientRect());if(e){let a=document.createElement(`div`);a.className=`vue-caret`,a.style.cssText=`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./KeyboardShortcutsDialog-Bct8AJ0i.cjs`),t=require(`./MenuBar-m0JEaF1X.cjs`),n=require(`./_plugin-vue_export-helper-CX7YVcP6.cjs`),r=require(`./zIndex-CH0jZ7U7.cjs`),i=require(`./useDragAutoScroll-DNMi0p5G.cjs`);let a=require(`vue`),o=require(`prosemirror-state`),s=require(`@eigenpal/docx-editor-core/layout-bridge`),c=require(`@eigenpal/docx-editor-core/prosemirror`),l=require(`@eigenpal/docx-editor-core/utils`),u=require(`@eigenpal/docx-editor-core/prosemirror/plugins/selectionTracker`),d=require(`@eigenpal/docx-editor-core/prosemirror/commands/formatting`),f=require(`@eigenpal/docx-editor-core/prosemirror/extensions/nodes/TableExtension`),p=require(`@eigenpal/docx-editor-core/layout-bridge/clickToPositionDom`),m=require(`@eigenpal/docx-editor-core/prosemirror/imageCommit`),h=require(`@eigenpal/docx-editor-core/layout-painter`),g=require(`@eigenpal/docx-editor-core/prosemirror/conversion`),_=require(`@eigenpal/docx-editor-core/utils/units`),v=require(`@eigenpal/docx-editor-core/types/document`),y=require(`@eigenpal/docx-editor-core/prosemirror/plugins`),b=require(`@eigenpal/docx-editor-core/layout-engine`),x=require(`@eigenpal/docx-editor-core/prosemirror/commands/paragraph`),S=require(`@eigenpal/docx-editor-core/prosemirror/styles`),C=require(`@eigenpal/docx-editor-core/prosemirror/commands/pageBreak`),w=require(`@eigenpal/docx-editor-core/prosemirror/applyFormatting`),T=require(`@eigenpal/docx-editor-core/prosemirror/commands`),E=require(`@eigenpal/docx-editor-core/utils/headingCollector`),D=require(`@eigenpal/docx-editor-core/prosemirror/commentOps`),O=require(`@eigenpal/docx-editor-core/prosemirror/commentIdAllocator`),k=require(`@eigenpal/docx-editor-core/prosemirror/utils/extractTrackedChanges`),A=require(`@eigenpal/docx-editor-core/layout-bridge/tableInsertHover`),j=require(`@eigenpal/docx-editor-core/utils/reportIssue`),M=require(`@eigenpal/docx-editor-core/agent`),N=require(`@eigenpal/docx-editor-core/prosemirror/paraText`),P=require(`@eigenpal/docx-editor-core`),F=require(`@eigenpal/docx-editor-core/plugin-api/RenderedDomContext`),ee=require(`@eigenpal/docx-editor-core/prosemirror/queries`);function te(e){let t=window.document.querySelectorAll(`.layout-page-${e}`);if(t.length===0)return null;let n=window.innerHeight/2,r=t[0],i=1/0;for(let e of Array.from(t)){let t=e.getBoundingClientRect(),a=Math.abs((t.top+t.bottom)/2-n);a<i&&(i=a,r=e)}return r}function I(e,t,n){let r=n?Array.from(e.querySelectorAll(`.layout-page-${n} span[data-pm-start][data-pm-end]`)):(0,s.findBodyPmSpans)(e);for(let e of r){let n=Number(e.dataset.pmStart),r=Number(e.dataset.pmEnd);if(!isNaN(n)&&!isNaN(r)&&t>=n&&t<=r)return e}return null}function L(e,t,n){if(!e||!t)return;let r=null;for(let t of(0,s.findBodyPmSpans)(e)){let e=Number(t.dataset.pmStart),i=Number(t.dataset.pmEnd);if(Number.isFinite(e)&&Number.isFinite(i)&&n>=e&&n<=i){r=t;break}}if(r||=e.querySelector(`[data-pm-start="${n}"]`),!r)return;let i=t.getBoundingClientRect(),a=r.getBoundingClientRect();t.scrollTo({top:a.top-i.top+t.scrollTop-48,behavior:`smooth`})}function R(e,t,n,r){if(!e||!t)return null;let i=(0,s.clickToPositionDom)(e,n,r,1);return i===null||i<0?null:Math.min(i,t.state.doc.content.size)}function ne(e,t,n,r){if(!e)return;let i=I(e,t,r);if(!i)return;let a=i.textContent||``,o=Number(i.dataset.pmStart)||0,[s,c]=(0,l.findWordBoundaries)(a,t-o),u=o+s,d=o+c;u<d&&n(u,d)}function z(e,t,n,r){if(!e)return;let i=I(e,t,r);if(!i)return;let a=i.closest(`.layout-paragraph`);if(!a)return;let o=Number(a.dataset.pmStart),s=Number(a.dataset.pmEnd);!isNaN(o)&&!isNaN(s)&&o<s&&n(o,s)}var re=(0,a.defineComponent)({__name:`DecorationLayer`,props:{getView:{type:Function},getPagesContainer:{type:Function},zoom:{},transactionVersion:{},syncCoordinator:{}},setup(e){let t=e,n=(0,a.ref)(null),r=(0,a.ref)(0),i=null,o=null;function s(){i!==null&&cancelAnimationFrame(i),i=requestAnimationFrame(()=>{i=null;let e=t.getView(),r=t.getPagesContainer(),a=n.value;!e||!r||!a||t.syncCoordinator.isSafeToRender()&&c(e,r,a,t.zoom)})}(0,a.onMounted)(()=>{o=t.syncCoordinator.onRender(()=>{r.value++}),s()}),(0,a.onBeforeUnmount)(()=>{i!==null&&(cancelAnimationFrame(i),i=null),o?.()}),(0,a.watch)(()=>[t.zoom,t.transactionVersion,r.value],()=>s());function c(e,t,n,r){let i=l(e.state);if(i.length===0){n.firstChild&&n.replaceChildren();return}let a=(0,F.createRenderedDomContext)(t,r),o=a.getContainerOffset(),s=document.createDocumentFragment();for(let{decoration:t,from:n,to:r}of i){if(n===r){let r=u(t,e);if(!r)continue;let i=a.getCoordinatesForPosition(n);if(!i)continue;let c=document.createElement(`div`);c.style.cssText=`position:absolute;left:${i.x+o.x}px;top:${i.y+o.y}px;height:${i.height}px;`,c.appendChild(r),s.appendChild(c);continue}let i=d(t);if(!i)continue;let c=a.getRectsForRange(n,r);for(let e of c){let t=document.createElement(`div`);for(let[e,n]of Object.entries(i))e!==`nodeName`&&t.setAttribute(e,n);let n=`position:absolute;left:${e.x+o.x}px;top:${e.y+o.y}px;width:${e.width}px;height:${e.height}px;`;t.style.cssText=n+(i.style??``),s.appendChild(t)}}n.replaceChildren(s)}function l(e){let t=[];for(let n of e.plugins){let r=n.props.decorations;if(!r)continue;let i=r.call(n,e);i&&i.forEachSet(e=>{e.find().forEach(e=>{e.spec?.noOverlay||t.push({decoration:e,from:e.from,to:e.to})})})}return t}function u(e,t){let n=e.type;if(!n)return null;let r=n.toDOM;return typeof r==`function`?r(t,()=>e.from):r instanceof HTMLElement?r.cloneNode(!0):null}function d(e){return e.type?.attrs??null}return(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{ref_key:`overlayRef`,ref:n,class:`paged-editor__decoration-overlay`,"aria-hidden":`true`},null,512))}}),B=[`data-handle`,`onMousedown`],ie=[`title`],ae={key:0,class:`image-overlay__dim`},oe={key:1,class:`image-overlay__dim image-overlay__dim--rotate`},se=4,ce=15,le=(0,a.defineComponent)({__name:`ImageSelectionOverlay`,props:{imageInfo:{},zoom:{},view:{}},emits:[`deselect`,`interact-start`,`interact-end`,`context-menu`],setup(t,{emit:n}){let{t:i}=e.d(),c=t,u=n,d=(0,a.ref)(null),f=(0,a.ref)(!1),g=(0,a.ref)(!1),_=(0,a.ref)(!1),v=(0,a.ref)(0),y=(0,a.ref)(0),b=(0,a.ref)(0),x=(0,a.ref)(null),S=`se`,C=0,w=0,T=0,E=0,D=null,O=null,k=null,A=null;function j(e,t){if(!e)return null;try{let n=e.state.doc.nodeAt(t);return n&&n.type.name===`image`?n:null}catch{return null}}function M(){return d.value?.closest(`.docx-editor-vue__pages-viewport`)?.querySelector(`.docx-editor-vue__pages`)??null}function N(){let e=c.imageInfo;if(!e)return null;if(e.element.isConnected)return e.element;let t=M();if(!t)return null;let n=(0,s.findBodyPmAnchor)(t,e.pmPos);return n?(0,h.findImageElement)(n):null}function P(){let e=N();if(!e||!d.value){x.value=null;return}let t=d.value.offsetParent;if(!t){x.value=null;return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=c.zoom;x.value={left:(r.left-n.left+t.scrollLeft)/i,top:(r.top-n.top+t.scrollTop)/i,width:r.width/i,height:r.height/i}}(0,a.watch)(()=>c.imageInfo,async()=>{await(0,a.nextTick)(),P()},{immediate:!0}),(0,a.watch)(()=>c.zoom,(e,t,n)=>{if(!c.imageInfo)return;let r=0,i=``,a=0,o=0,s=e=>{P();let t=x.value,n=t?`${t.left}|${t.top}|${t.width}|${t.height}`:``;a=n===i?a+1:0,i=n,o+=e,a<2&&o<500&&(r=requestAnimationFrame(()=>s(16)))};r=requestAnimationFrame(()=>s(16)),n(()=>cancelAnimationFrame(r))}),(0,a.watch)(()=>c.imageInfo,(e,t,n)=>{if(!c.imageInfo)return;let r=()=>{O&&cancelAnimationFrame(O),O=requestAnimationFrame(P)},i=d.value?.closest(`.docx-editor-vue__pages-viewport`);i?.addEventListener(`scroll`,r,{passive:!0}),window.addEventListener(`resize`,r,{passive:!0}),n(()=>{i?.removeEventListener(`scroll`,r),window.removeEventListener(`resize`,r),O&&cancelAnimationFrame(O)})},{immediate:!0});let F=(0,a.computed)(()=>f.value?v.value:x.value?.width||0),ee=(0,a.computed)(()=>f.value?y.value:x.value?.height||0),te=(0,a.computed)(()=>{let e=x.value;if(!e)return{position:`absolute`,top:`0px`,left:`0px`,visibility:`hidden`,pointerEvents:`none`};let t=f.value?v.value:e.width,n=f.value?y.value:e.height,i=c.zoom||1;return{position:`absolute`,left:`${e.left*i}px`,top:`${e.top*i}px`,width:`${t}px`,height:`${n}px`,transform:i===1?void 0:`scale(${i})`,transformOrigin:`top left`,zIndex:r.t.imageOverlay,pointerEvents:`auto`}}),I=(0,a.computed)(()=>{let e=F.value,t=ee.value,n=`${e/2-5}px`,r=`${t/2-5}px`,i=`${e-5}px`,a=`${t-5}px`,o=`-5px`;return[{pos:`nw`,style:{left:o,top:o,cursor:`nwse-resize`}},{pos:`n`,style:{left:n,top:o,cursor:`ns-resize`}},{pos:`ne`,style:{left:i,top:o,cursor:`nesw-resize`}},{pos:`e`,style:{left:i,top:r,cursor:`ew-resize`}},{pos:`se`,style:{left:i,top:a,cursor:`nwse-resize`}},{pos:`s`,style:{left:n,top:a,cursor:`ns-resize`}},{pos:`sw`,style:{left:o,top:a,cursor:`nesw-resize`}},{pos:`w`,style:{left:o,top:r,cursor:`ew-resize`}}]}),L=e=>e.length===2;function R(e,t,n,r,i,a){let o=e.includes(`w`)?-1:+!!e.includes(`e`),s=e.includes(`n`)?-1:+!!e.includes(`s`),c=r+t*o,l=i+n*s;if(L(e)&&a){let e=Math.max(c/r,l/i);c=r*e,l=i*e}return{width:o===0?r:Math.max(20,Math.min(2e3,c)),height:s===0?i:Math.max(20,Math.min(2e3,l))}}function ne(e,t){!c.imageInfo||!x.value||(S=t,C=e.clientX,w=e.clientY,T=x.value.width,E=x.value.height,D={...x.value},v.value=Math.round(T),y.value=Math.round(E),f.value=!0,u(`interact-start`),document.addEventListener(`mousemove`,z),document.addEventListener(`mouseup`,re))}function z(e){let t=c.zoom,n=(e.clientX-C)/t,r=(e.clientY-w)/t,i=!e.shiftKey,a=R(S,n,r,T,E,i);v.value=Math.round(a.width),y.value=Math.round(a.height);let o=D;o&&(x.value={left:S.includes(`w`)?o.left+(o.width-a.width):o.left,top:S.includes(`n`)?o.top+(o.height-a.height):o.top,width:o.width,height:o.height})}function re(){document.removeEventListener(`mousemove`,z),document.removeEventListener(`mouseup`,re),f.value=!1,D=null,u(`interact-end`);let e=c.view,t=c.imageInfo;if(!e||!t){P();return}let n=(0,m.commitImageResize)(e,t.pmPos,v.value,y.value);n!==null&&ye(n),(0,a.nextTick)(()=>P())}let le=0,ue=0,de=0,fe=0,V=null,H=null;function U(e){if(!e)return 0;let t=e.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/);return t?parseFloat(t[1]):0}function pe(e,t){let n=/scaleX\(-1\)/.test(e||``),r=/scaleY\(-1\)/.test(e||``),i=[],a=(t%360+360)%360;return a!==0&&i.push(`rotate(${a}deg)`),n&&i.push(`scaleX(-1)`),r&&i.push(`scaleY(-1)`),i.length>0?i.join(` `):null}function me(e,t){return Math.atan2(e-le,-(t-ue))*180/Math.PI}function he(e){if(!c.imageInfo)return;let t=c.imageInfo.element.getBoundingClientRect();le=t.left+t.width/2,ue=t.top+t.height/2;let n=j(c.view,c.imageInfo.pmPos);V=n&&n.attrs.transform||null,fe=U(V),H=c.imageInfo.element.querySelector(`img`),de=me(e.clientX,e.clientY),b.value=fe,_.value=!0,u(`interact-start`),document.addEventListener(`mousemove`,W),document.addEventListener(`mouseup`,ge)}function W(e){let t=me(e.clientX,e.clientY)-de,n=fe+t;e.shiftKey||(n=Math.round(n/ce)*ce),b.value=(n%360+360)%360,H&&(H.style.transform=pe(V,b.value)||``)}function ge(){document.removeEventListener(`mousemove`,W),document.removeEventListener(`mouseup`,ge),_.value=!1,u(`interact-end`);let e=c.view,t=c.imageInfo;try{let n=e&&t?j(e,t.pmPos):null;e&&t&&n&&(e.dispatch(e.state.tr.setNodeMarkup(t.pmPos,void 0,{...n.attrs,transform:pe(n.attrs.transform,b.value)})),ye(t.pmPos))}catch{}finally{H&&(H.style.transform=``),H=null,V=null}(0,a.nextTick)(()=>P())}let G=null;function _e(e){if(!c.imageInfo||!x.value)return;let t=e.clientX,n=e.clientY,r=x.value,i=!1,a=e=>{let a=e.clientX-t,o=e.clientY-n;if(!(!i&&Math.sqrt(a*a+o*o)<se)){if(!i){i=!0,g.value=!0,u(`interact-start`),G=document.createElement(`div`),G.style.cssText=`position: fixed; pointer-events: none; z-index: 10000; opacity: 0.5; border: 2px dashed #2563eb; border-radius: 4px; background: rgba(37, 99, 235, 0.1);`;let e=c.zoom;G.style.width=`${r.width*e}px`,G.style.height=`${r.height*e}px`,document.body.appendChild(G)}if(G){let t=c.zoom;G.style.left=`${e.clientX-r.width*t/2}px`,G.style.top=`${e.clientY-r.height*t/2}px`}}},o=e=>{document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o),k=null,A=null,G&&=(G.remove(),null),g.value=!1,i&&(u(`interact-end`),ve(e.clientX,e.clientY))};k=a,A=o,document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o)}function ve(e,t){let n=c.view,r=c.imageInfo;if(!n||!r)return;let i=j(n,r.pmPos);if(i){if((0,m.isFloatingImage)(i)){let i=(d.value?.closest(`.docx-editor-vue__pages-viewport`))?.querySelectorAll(`.layout-page`);if(!i||i.length===0)return;let a=null;for(let e of i){let n=e.getBoundingClientRect();if(t>=n.top&&t<=n.bottom){a=e.querySelector(`.layout-page-content`);break}}if(a||=i[i.length-1].querySelector(`.layout-page-content`),!a)return;let o=a.getBoundingClientRect(),s=c.zoom,u=(0,l.pixelsToEmu)((e-o.left)/s),f=(0,l.pixelsToEmu)((t-o.top)/s),p=(0,m.commitImageFloatMove)(n,r.pmPos,u,f);p!==null&&ye(p)}else{let i=M();if(!i)return;let a=(0,p.clickToPositionDom)(i,e,t,1);if(a==null||a<0)return;let o=(0,m.commitImageInlineMove)(n,r.pmPos,a);o!==null&&ye(o)}(0,a.nextTick)(()=>P())}}function ye(e){let t=c.view;if(t)try{let n=o.NodeSelection.create(t.state.doc,e);t.dispatch(t.state.tr.setSelection(n))}catch{}}return(0,a.onBeforeUnmount)(()=>{document.removeEventListener(`mousemove`,z),document.removeEventListener(`mouseup`,re),document.removeEventListener(`mousemove`,W),document.removeEventListener(`mouseup`,ge),k&&document.removeEventListener(`mousemove`,k),A&&document.removeEventListener(`mouseup`,A),G&&=(G.remove(),null),O&&cancelAnimationFrame(O)}),(e,n)=>t.imageInfo?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,ref_key:`overlayRootRef`,ref:d,class:`image-overlay`,style:(0,a.normalizeStyle)(te.value),onMousedown:n[3]||=(0,a.withModifiers)(()=>{},[`stop`])},[n[4]||=(0,a.createElementVNode)(`div`,{class:`image-overlay__border`},null,-1),(0,a.createElementVNode)(`div`,{class:`image-overlay__body`,style:(0,a.normalizeStyle)({cursor:g.value?`grabbing`:`grab`}),onMousedown:n[0]||=(0,a.withModifiers)(e=>_e(e),[`prevent`,`stop`]),onContextmenu:n[1]||=(0,a.withModifiers)(t=>e.$emit(`context-menu`,t),[`prevent`,`stop`])},null,36),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(I.value,e=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:e.pos,class:`image-overlay__handle`,style:(0,a.normalizeStyle)(e.style),"data-handle":e.pos,onMousedown:(0,a.withModifiers)(t=>ne(t,e.pos),[`prevent`,`stop`])},null,44,B))),128)),n[5]||=(0,a.createElementVNode)(`div`,{class:`image-overlay__rotate-line`},null,-1),(0,a.createElementVNode)(`div`,{class:`image-overlay__rotate-handle`,style:(0,a.normalizeStyle)({left:`${F.value/2-7}px`}),title:(0,a.unref)(i)(`imageOverlay.rotate`),onMousedown:n[2]||=(0,a.withModifiers)(e=>he(e),[`prevent`,`stop`])},null,44,ie),f.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,ae,(0,a.toDisplayString)(Math.round(v.value))+` × `+(0,a.toDisplayString)(Math.round(y.value)),1)):(0,a.createCommentVNode)(``,!0),_.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,oe,(0,a.toDisplayString)(Math.round(b.value))+`° `,1)):(0,a.createCommentVNode)(``,!0)],36)):(0,a.createCommentVNode)(``,!0)}}),ue=n.t(le,[[`__scopeId`,`data-v-df7c380c`]]),de={class:`doc-outline__header`},fe={class:`doc-outline__body`},V={key:0,class:`doc-outline__empty`},H=[`onMousedown`],U=(0,a.defineComponent)({__name:`DocumentOutline`,props:{isOpen:{type:Boolean},headings:{}},emits:[`close`,`navigate`],setup(t){return(n,r)=>t.isOpen?((0,a.openBlock)(),(0,a.createElementBlock)(`nav`,{key:0,class:`doc-outline`,role:`navigation`,"aria-label":`Document outline`,onMousedown:r[1]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createElementVNode)(`div`,de,[(0,a.createElementVNode)(`button`,{class:`doc-outline__back`,title:`Close outline`,"aria-label":`Close outline`,onClick:r[0]||=e=>n.$emit(`close`)},[(0,a.createVNode)(e.p,{name:`arrow_back`,size:20})]),r[2]||=(0,a.createElementVNode)(`span`,{class:`doc-outline__title`},`Document Outline`,-1)]),(0,a.createElementVNode)(`div`,fe,[t.headings.length===0?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,V,` No headings found `)):(0,a.createCommentVNode)(``,!0),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(t.headings,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:t,class:`doc-outline__item`,style:(0,a.normalizeStyle)({paddingLeft:12+(e.level-1)*16+`px`}),onMousedown:(0,a.withModifiers)(t=>n.$emit(`navigate`,e.pmPos),[`prevent`])},(0,a.toDisplayString)(e.text||`(untitled)`),45,H))),128))])],32)):(0,a.createCommentVNode)(``,!0)}}),pe=n.t(U,[[`__scopeId`,`data-v-cb2cdc39`]]),me=(0,a.defineComponent)({__name:`PageIndicator`,props:{currentPage:{},totalPages:{},visible:{type:Boolean}},setup(t){let{t:n}=e.d();return(e,r)=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{class:`docx-editor-vue__page-indicator`,style:(0,a.normalizeStyle)({opacity:+!!t.visible}),"aria-live":`polite`,role:`status`},(0,a.toDisplayString)((0,a.unref)(n)(`viewer.pageIndicator`,{current:t.currentPage,total:t.totalPages})),5))}}),he=n.t(me,[[`__scopeId`,`data-v-d117bf6e`]]),W={class:`hf-editor__label`},ge={class:`hf-editor__actions`,style:{position:`relative`}},G=(0,a.defineComponent)({__name:`InlineHeaderFooterEditor`,props:{isOpen:{type:Boolean},position:{},view:{},targetRect:{}},emits:[`save`,`close`,`remove`],setup(e,{emit:t}){let n=e,r=t,i=(0,a.ref)({}),o=(0,a.ref)(!1);function s(e){let t=n.view;if(!t)return;let{$from:r,from:i}=t.state.selection,a=t.state.storedMarks||r.marks(),o=c.schema.nodes.field.create({fieldType:e,instruction:` ${e} \\* MERGEFORMAT `,fieldKind:`simple`,dirty:!0});t.dispatch(t.state.tr.insert(i,o.mark(a))),t.focus()}function l(){let e=n.targetRect;e&&(i.value={position:`absolute`,top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`,zIndex:`100`,pointerEvents:`none`})}(0,a.watch)(()=>n.isOpen,e=>{e&&(l(),n.view?.focus())}),(0,a.watch)(()=>n.targetRect,()=>{n.isOpen&&l()},{deep:!0});function u(){n.view&&(r(`save`,(0,g.proseDocToBlocks)(n.view.state.doc)),r(`close`))}return(t,n)=>e.isOpen?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`hf-editor`,style:(0,a.normalizeStyle)(i.value)},[(0,a.createElementVNode)(`div`,{class:(0,a.normalizeClass)([`hf-editor__toolbar`,e.position===`footer`?`hf-editor__toolbar--below`:`hf-editor__toolbar--above`]),onMousedown:n[8]||=(0,a.withModifiers)(()=>{},[`stop`]),onContextmenu:n[9]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createElementVNode)(`span`,W,(0,a.toDisplayString)(e.position===`header`?`Header`:`Footer`),1),(0,a.createElementVNode)(`div`,ge,[(0,a.createElementVNode)(`button`,{class:`hf-editor__btn`,title:`Options`,onMousedown:n[0]||=(0,a.withModifiers)(()=>{},[`prevent`]),onClick:n[1]||=e=>o.value=!o.value},` Options ▾ `,32),o.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`hf-editor__dropdown`,onMousedown:n[4]||=(0,a.withModifiers)(()=>{},[`stop`]),onContextmenu:n[5]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createElementVNode)(`button`,{type:`button`,class:`hf-editor__dropdown-item`,onClick:n[2]||=e=>{o.value=!1,s(`PAGE`)}},` Insert current page number `),(0,a.createElementVNode)(`button`,{type:`button`,class:`hf-editor__dropdown-item`,onClick:n[3]||=e=>{o.value=!1,s(`NUMPAGES`)}},` Insert total page count `)],32)):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`button`,{class:`hf-editor__btn`,title:`Remove`,onMousedown:n[6]||=(0,a.withModifiers)(e=>t.$emit(`remove`),[`prevent`])},` Remove `,32),(0,a.createElementVNode)(`button`,{class:`hf-editor__btn hf-editor__btn--primary`,title:`Save`,onMousedown:(0,a.withModifiers)(u,[`prevent`])},` Save `,32),(0,a.createElementVNode)(`button`,{class:`hf-editor__btn`,title:`Cancel`,onMousedown:n[7]||=(0,a.withModifiers)(e=>t.$emit(`close`),[`prevent`])},` Cancel `,32)])],34)],4)):(0,a.createCommentVNode)(``,!0)}}),_e=n.t(G,[[`__scopeId`,`data-v-e93a9f94`]]),ve=[`role`],ye={key:0,class:`layout-sdt-widget-empty`},be=[`aria-selected`,`onClick`],xe=[`value`],Se=(0,a.defineComponent)({__name:`ContentControlWidgets`,props:{container:{},view:{}},setup(e){function t(e){let t=/^sdt@(\d+)$/.exec(e??``);return t?Number(t[1]):null}let n=e,r=(0,a.ref)(null),i=(0,a.ref)(null);function o(e,t){let i=n.view;if(i)try{i.dispatch((0,c.setContentControlValueTr)(i.state,{tag:e},t)),i.focus()}catch{}r.value=null}function s(e){let r=n.view,i=t(e.dataset.sdtGroupId);if(!(!r||i==null))try{let t=e.dataset.sdtRepeat===`add`?(0,c.addRepeatingSectionItemTr)(r.state,i):(0,c.removeRepeatingSectionItemTr)(r.state,i);r.dispatch(t),r.focus()}catch{}}function l(e){let t=e.target;(t?.closest?.(`.layout-sdt-widget`)||t?.closest?.(`.layout-sdt-repeat-btn`))&&e.preventDefault()}function u(e){let t=n.view,i=e.dataset.sdtTag,a=e.dataset.sdtWidget;if(!t||!i||!a)return;let s=(0,c.findContentControlsInPM)(t.state.doc,{tag:i})[0],l=e.getBoundingClientRect();a===`checkbox`?o(i,{kind:`checkbox`,checked:!s?.checked}):a===`dropdown`?r.value={kind:`dropdown`,tag:i,items:s?.listItems??[],current:s?.text??``,x:l.left,y:l.bottom+2}:a===`date`&&(r.value={kind:`date`,tag:i,current:s?.dateValue??``,x:l.left,y:l.bottom+2})}function d(e){let t=e.target?.closest?.(`.layout-sdt-repeat-btn`);if(t){e.preventDefault(),e.stopPropagation(),s(t);return}let n=e.target?.closest?.(`.layout-sdt-widget`);n&&(e.preventDefault(),e.stopPropagation(),u(n))}function f(e){if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target?.closest?.(`.layout-sdt-widget`);t&&(e.preventDefault(),u(t))}function p(e){r.value&&!i.value?.contains(e.target)&&(r.value=null)}function m(e){e.key===`Escape`&&(r.value=null)}let h=null;(0,a.watch)(()=>n.container,e=>{h&&(h.removeEventListener(`mousedown`,l),h.removeEventListener(`click`,d),h.removeEventListener(`keydown`,f)),h=e??null,h&&(h.addEventListener(`mousedown`,l),h.addEventListener(`click`,d),h.addEventListener(`keydown`,f))},{immediate:!0}),(0,a.watch)(r,e=>{e?(document.addEventListener(`mousedown`,p),document.addEventListener(`keydown`,m),e.kind===`dropdown`&&(0,a.nextTick)(()=>{let e=i.value?.querySelectorAll(`.layout-sdt-widget-option`);e?.length&&([...e].find(e=>e.getAttribute(`aria-selected`)===`true`)??e[0]).focus()})):(document.removeEventListener(`mousedown`,p),document.removeEventListener(`keydown`,m))});function g(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=[...i.value?.querySelectorAll(`.layout-sdt-widget-option`)??[]];if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`ArrowDown`?(n+1)%t.length:(n-1+t.length)%t.length].focus()}(0,a.onBeforeUnmount)(()=>{h&&(h.removeEventListener(`mousedown`,l),h.removeEventListener(`click`,d),h.removeEventListener(`keydown`,f)),document.removeEventListener(`mousedown`,p),document.removeEventListener(`keydown`,m)});function _(e){let t=e.target.value;t&&r.value&&o(r.value.tag,{kind:`date`,date:t})}return(e,t)=>r.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,ref_key:`popupEl`,ref:i,class:`layout-sdt-widget-popup`,role:r.value.kind===`dropdown`?`listbox`:void 0,style:(0,a.normalizeStyle)({position:`fixed`,top:r.value.y+`px`,left:r.value.x+`px`,zIndex:1e3}),onKeydown:g,onMousedown:t[0]||=(0,a.withModifiers)(()=>{},[`prevent`])},[r.value.kind===`dropdown`?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:0},[r.value.items.length===0?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,ye,`No options`)):(0,a.createCommentVNode)(``,!0),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(r.value.items,e=>((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:e.value,type:`button`,role:`option`,"aria-selected":e.displayText===r.value.current,class:(0,a.normalizeClass)([`layout-sdt-widget-option`,{"is-selected":e.displayText===r.value.current}]),onClick:t=>o(r.value.tag,{kind:`dropdown`,value:e.value})},(0,a.toDisplayString)(e.displayText),11,be))),128))],64)):((0,a.openBlock)(),(0,a.createElementBlock)(`input`,{key:1,type:`date`,class:`layout-sdt-widget-date`,value:r.value.current,onChange:_},null,40,xe))],44,ve)):(0,a.createCommentVNode)(``,!0)}}),K={key:0,class:`docx-editor-vue__title-bar`},q={class:`docx-editor-vue__title-bar-left`},Ce={class:`docx-editor-vue__title-bar-center`},we={class:`docx-editor-vue__title-bar-right`},Te=(0,a.defineComponent)({__name:`DocxEditorMenuBar`,props:{showMenuBar:{type:Boolean},documentName:{},documentNameEditable:{type:Boolean,default:!0},renderLogo:{},renderTitleBarRight:{}},emits:[`rename`,`menu-action`,`insert-table`],setup(e,{emit:n}){let r=n;return(n,i)=>e.showMenuBar?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,K,[(0,a.createElementVNode)(`div`,q,[e.renderLogo?((0,a.openBlock)(),(0,a.createBlock)((0,a.resolveDynamicComponent)(e.renderLogo),{key:0})):(0,a.createCommentVNode)(``,!0),(0,a.renderSlot)(n.$slots,`title-bar-left`)]),(0,a.createElementVNode)(`div`,Ce,[(0,a.createVNode)(t.i,{"model-value":e.documentName,editable:e.documentNameEditable,"onUpdate:modelValue":i[0]||=e=>r(`rename`,e)},null,8,[`model-value`,`editable`]),(0,a.createVNode)(t.t,{onAction:i[1]||=e=>r(`menu-action`,e),onInsertTable:i[2]||=(e,t)=>r(`insert-table`,e,t)})]),(0,a.createElementVNode)(`div`,we,[(0,a.renderSlot)(n.$slots,`title-bar-right`),e.renderTitleBarRight?((0,a.openBlock)(),(0,a.createBlock)((0,a.resolveDynamicComponent)(e.renderTitleBarRight),{key:0})):(0,a.createCommentVNode)(``,!0)])])):(0,a.createCommentVNode)(``,!0)}}),Ee=[`aria-label`],De={class:`wm-header`},Oe={class:`wm-body`},ke={class:`wm-radio-row`},J=[`checked`],Ae={for:`wm-none`,class:`wm-inline-label`},je={class:`wm-radio-row`},Y=[`checked`],Me={for:`wm-picture`,class:`wm-inline-label`},Ne={key:0,class:`wm-subform`},Pe={class:`wm-row`},Fe={key:0,class:`wm-row`},Ie=[`src`],Le={class:`wm-row`},Re={class:`wm-label`},ze={class:`wm-inline-label`},Be={class:`wm-radio-row`},Ve=[`checked`],He={for:`wm-text`,class:`wm-inline-label`},Ue={key:1,class:`wm-subform`},We={class:`wm-row`},Ge={class:`wm-label`},Ke=[`value`],qe=[`value`],Je={class:`wm-row`},Ye={class:`wm-label`},Xe={class:`wm-row`},Ze={class:`wm-label`},Qe=[`value`],$e={class:`wm-row`},et={class:`wm-label`},tt={class:`wm-inline-label`},nt={class:`wm-row`},rt={class:`wm-label`},it={class:`wm-row`},at={class:`wm-label`},ot={class:`wm-inline-label`},st=[`checked`],ct={class:`wm-inline-label`},lt=[`checked`],ut={class:`wm-inline-label`},dt={class:`wm-footer`},ft=[`disabled`],pt=(0,a.defineComponent)({__name:`WatermarkDialog`,props:{isOpen:{type:Boolean},current:{}},emits:[`close`,`apply`],setup(t,{emit:n}){let r=[`CONFIDENTIAL`,`DRAFT`,`DO NOT COPY`,`SAMPLE`,`URGENT`,`ASAP`],i=[`Calibri`,`Arial`,`Times New Roman`,`Georgia`,`Verdana`,`Courier New`],{t:o}=e.d(),s=t,c=n,l=(0,a.ref)(`none`),u=(0,a.ref)(`CONFIDENTIAL`),d=(0,a.ref)(`Calibri`),f=(0,a.ref)(!0),p=(0,a.ref)(54),m=(0,a.ref)(`#C0C0C0`),h=(0,a.ref)(`diagonal`),g=(0,a.ref)(!0),_=(0,a.ref)(void 0),y=(0,a.ref)(void 0),b=(0,a.ref)(100),x=(0,a.ref)(!0);(0,a.watch)(()=>s.isOpen,e=>{if(!e)return;let t=s.current;t?.kind===`text`?(l.value=`text`,u.value=t.text,d.value=t.font||`Calibri`,f.value=t.fontSize===void 0,t.fontSize!==void 0&&(p.value=t.fontSize),m.value=t.color||`#C0C0C0`,h.value=t.layout,g.value=t.semitransparent):t?.kind===`picture`?(l.value=`picture`,_.value=t.dataUrl,y.value=t.widthEmu!==void 0&&t.heightEmu!==void 0?{widthEmu:t.widthEmu,heightEmu:t.heightEmu}:void 0,b.value=Math.round((t.scale||1)*100),x.value=t.washout):l.value=`none`},{immediate:!0});let S=(0,a.computed)(()=>l.value===`picture`&&!_.value);function C(e){let t=e.target.value;t&&(u.value=t)}function w(e){let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{let e=typeof n.result==`string`?n.result:void 0;if(_.value=e,y.value=void 0,!e)return;let t=new Image;t.onload=()=>{y.value=(0,v.pictureWatermarkDisplayEmu)(t.naturalWidth,t.naturalHeight)},t.src=e},n.readAsDataURL(t)}function T(){c(`close`)}function E(){if(l.value===`none`)c(`apply`,null);else if(l.value===`text`)c(`apply`,{kind:`text`,text:u.value,font:d.value,color:m.value,semitransparent:g.value,layout:h.value,fontSize:f.value?void 0:p.value});else{if(!_.value)return;c(`apply`,{kind:`picture`,dataUrl:_.value,scale:b.value/100,washout:x.value,...y.value??{}})}T()}function D(e){e.key===`Escape`&&T()}return(e,n)=>t.isOpen?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`wm-overlay`,onMousedown:(0,a.withModifiers)(T,[`self`]),onKeydown:D},[(0,a.createElementVNode)(`div`,{class:`wm-dialog`,role:`dialog`,"aria-label":(0,a.unref)(o)(`dialogs.watermark.title`),onMousedown:n[13]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createElementVNode)(`div`,De,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.title`)),1),(0,a.createElementVNode)(`div`,Oe,[(0,a.createElementVNode)(`div`,ke,[(0,a.createElementVNode)(`input`,{id:`wm-none`,type:`radio`,checked:l.value===`none`,onChange:n[0]||=e=>l.value=`none`},null,40,J),(0,a.createElementVNode)(`label`,Ae,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.noWatermark`)),1)]),(0,a.createElementVNode)(`div`,je,[(0,a.createElementVNode)(`input`,{id:`wm-picture`,type:`radio`,checked:l.value===`picture`,onChange:n[1]||=e=>l.value=`picture`},null,40,Y),(0,a.createElementVNode)(`label`,Me,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.picture`)),1)]),l.value===`picture`?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Ne,[(0,a.createElementVNode)(`div`,Pe,[(0,a.createElementVNode)(`input`,{type:`file`,accept:`image/*`,onChange:w},null,32)]),_.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Fe,[(0,a.createElementVNode)(`img`,{src:_.value,alt:``,class:`wm-preview`},null,8,Ie)])):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,Le,[(0,a.createElementVNode)(`span`,Re,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.scale`)),1),(0,a.withDirectives)((0,a.createElementVNode)(`input`,{class:`wm-input wm-input--narrow`,type:`number`,min:`10`,max:`500`,"onUpdate:modelValue":n[2]||=e=>b.value=e},null,512),[[a.vModelText,b.value,void 0,{number:!0}]]),n[14]||=(0,a.createElementVNode)(`span`,{class:`wm-unit`},`%`,-1)]),(0,a.createElementVNode)(`label`,ze,[(0,a.withDirectives)((0,a.createElementVNode)(`input`,{type:`checkbox`,"onUpdate:modelValue":n[3]||=e=>x.value=e},null,512),[[a.vModelCheckbox,x.value]]),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.washout`)),1)])])):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,Be,[(0,a.createElementVNode)(`input`,{id:`wm-text`,type:`radio`,checked:l.value===`text`,onChange:n[4]||=e=>l.value=`text`},null,40,Ve),(0,a.createElementVNode)(`label`,He,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.text`)),1)]),l.value===`text`?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Ue,[(0,a.createElementVNode)(`div`,We,[(0,a.createElementVNode)(`span`,Ge,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.presetLabel`)),1),(0,a.createElementVNode)(`select`,{class:`wm-input`,value:r.includes(u.value)?u.value:``,onChange:C},[n[15]||=(0,a.createElementVNode)(`option`,{value:``},`—`,-1),((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(r,e=>(0,a.createElementVNode)(`option`,{key:e,value:e},(0,a.toDisplayString)(e),9,qe)),64))],40,Ke)]),(0,a.createElementVNode)(`div`,Je,[(0,a.createElementVNode)(`span`,Ye,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.textLabel`)),1),(0,a.withDirectives)((0,a.createElementVNode)(`input`,{class:`wm-input`,"onUpdate:modelValue":n[5]||=e=>u.value=e},null,512),[[a.vModelText,u.value]])]),(0,a.createElementVNode)(`div`,Xe,[(0,a.createElementVNode)(`span`,Ze,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.fontLabel`)),1),(0,a.withDirectives)((0,a.createElementVNode)(`select`,{class:`wm-input`,"onUpdate:modelValue":n[6]||=e=>d.value=e},[((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(i,e=>(0,a.createElementVNode)(`option`,{key:e,value:e},(0,a.toDisplayString)(e),9,Qe)),64))],512),[[a.vModelSelect,d.value]])]),(0,a.createElementVNode)(`div`,$e,[(0,a.createElementVNode)(`span`,et,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.sizeLabel`)),1),(0,a.createElementVNode)(`label`,tt,[(0,a.withDirectives)((0,a.createElementVNode)(`input`,{type:`checkbox`,"onUpdate:modelValue":n[7]||=e=>f.value=e},null,512),[[a.vModelCheckbox,f.value]]),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.sizeAuto`)),1)]),f.value?(0,a.createCommentVNode)(``,!0):(0,a.withDirectives)(((0,a.openBlock)(),(0,a.createElementBlock)(`input`,{key:0,class:`wm-input wm-input--narrow`,type:`number`,min:`8`,max:`200`,"onUpdate:modelValue":n[8]||=e=>p.value=e},null,512)),[[a.vModelText,p.value,void 0,{number:!0}]])]),(0,a.createElementVNode)(`div`,nt,[(0,a.createElementVNode)(`span`,rt,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.colorLabel`)),1),(0,a.withDirectives)((0,a.createElementVNode)(`input`,{type:`color`,"onUpdate:modelValue":n[9]||=e=>m.value=e},null,512),[[a.vModelText,m.value]])]),(0,a.createElementVNode)(`div`,it,[(0,a.createElementVNode)(`span`,at,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.layoutLabel`)),1),(0,a.createElementVNode)(`label`,ot,[(0,a.createElementVNode)(`input`,{type:`radio`,name:`wm-layout`,checked:h.value===`diagonal`,onChange:n[10]||=e=>h.value=`diagonal`},null,40,st),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.diagonal`)),1)]),(0,a.createElementVNode)(`label`,ct,[(0,a.createElementVNode)(`input`,{type:`radio`,name:`wm-layout`,checked:h.value===`horizontal`,onChange:n[11]||=e=>h.value=`horizontal`},null,40,lt),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.horizontal`)),1)])]),(0,a.createElementVNode)(`label`,ut,[(0,a.withDirectives)((0,a.createElementVNode)(`input`,{type:`checkbox`,"onUpdate:modelValue":n[12]||=e=>g.value=e},null,512),[[a.vModelCheckbox,g.value]]),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.semitransparent`)),1)])])):(0,a.createCommentVNode)(``,!0)]),(0,a.createElementVNode)(`div`,dt,[(0,a.createElementVNode)(`button`,{type:`button`,class:`wm-btn`,onClick:T},(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.cancelButton`)),1),(0,a.createElementVNode)(`button`,{type:`button`,class:(0,a.normalizeClass)([`wm-btn wm-btn--primary`,{"wm-btn--disabled":S.value}]),disabled:S.value,onClick:E},(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.applyButton`)),11,ft)])],40,Ee)],32)):(0,a.createCommentVNode)(``,!0)}}),mt=n.t(pt,[[`__scopeId`,`data-v-5edfdc47`]]),ht=(0,a.defineComponent)({__name:`DocxEditorDialogs`,props:{view:{},bookmarks:{},selectedImagePmPos:{},sectionProperties:{},scrollVisiblePositionIntoView:{type:Function},showFindReplace:{type:Boolean},showInsertImage:{type:Boolean},showHyperlink:{type:Boolean},showInsertSymbol:{type:Boolean},showImageProperties:{type:Boolean},showPageSetup:{type:Boolean},showWatermark:{type:Boolean},currentWatermark:{},showKeyboardShortcuts:{type:Boolean}},emits:[`update:showFindReplace`,`update:showInsertImage`,`update:showHyperlink`,`update:showInsertSymbol`,`update:showImageProperties`,`update:showPageSetup`,`update:showWatermark`,`update:showKeyboardShortcuts`,`insert-image`,`insert-symbol`,`hyperlink-submit`,`hyperlink-remove`,`page-setup-apply`,`watermark-apply`],setup(t,{emit:n}){let r=n;return(n,i)=>((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createVNode)(e.s,{"is-open":t.showFindReplace,view:t.view,"scroll-visible-position-into-view":t.scrollVisiblePositionIntoView,onClose:i[0]||=e=>r(`update:showFindReplace`,!1)},null,8,[`is-open`,`view`,`scroll-visible-position-into-view`]),(0,a.createVNode)(e.o,{"is-open":t.showInsertImage,onClose:i[1]||=e=>r(`update:showInsertImage`,!1),onInsert:i[2]||=e=>r(`insert-image`,e)},null,8,[`is-open`]),(0,a.createVNode)(e.a,{"is-open":t.showHyperlink,view:t.view,bookmarks:t.bookmarks,onClose:i[3]||=e=>r(`update:showHyperlink`,!1),onSubmit:i[4]||=e=>r(`hyperlink-submit`,e),onRemove:i[5]||=e=>r(`hyperlink-remove`)},null,8,[`is-open`,`view`,`bookmarks`]),(0,a.createVNode)(e.i,{"is-open":t.showInsertSymbol,onClose:i[6]||=e=>r(`update:showInsertSymbol`,!1),onInsert:i[7]||=e=>r(`insert-symbol`,e)},null,8,[`is-open`]),(0,a.createVNode)(e.r,{"is-open":t.showImageProperties,view:t.view,"pm-pos":t.selectedImagePmPos,onClose:i[8]||=e=>r(`update:showImageProperties`,!1)},null,8,[`is-open`,`view`,`pm-pos`]),(0,a.createVNode)(e.n,{"is-open":t.showPageSetup,"section-properties":t.sectionProperties,onClose:i[9]||=e=>r(`update:showPageSetup`,!1),onApply:i[10]||=e=>r(`page-setup-apply`,e)},null,8,[`is-open`,`section-properties`]),(0,a.createVNode)(mt,{"is-open":t.showWatermark,current:t.currentWatermark,onClose:i[11]||=e=>r(`update:showWatermark`,!1),onApply:i[12]||=e=>r(`watermark-apply`,e)},null,8,[`is-open`,`current`]),(0,a.createVNode)(e.t,{"is-open":t.showKeyboardShortcuts,onClose:i[13]||=e=>r(`update:showKeyboardShortcuts`,!1)},null,8,[`is-open`])],64))}}),gt=[`disabled`,`onMousedown`],_t={class:`ctx-menu__label`},vt={key:0,class:`ctx-menu__shortcut`},yt=220,bt=32,xt=10,St=(0,a.defineComponent)({__name:`TextContextMenu`,props:{isOpen:{type:Boolean},position:{},hasSelection:{type:Boolean},isEditable:{type:Boolean},inTable:{type:Boolean},onImage:{type:Boolean},canMergeCells:{type:Boolean},canSplitCell:{type:Boolean}},emits:[`close`,`action`],setup(t,{emit:n}){let r=t,i=n,{t:o}=e.d(),s=(0,a.ref)(null),c=(0,a.computed)(()=>{let e=[{id:`cut`,label:o(`contextMenu.cut`),action:`cut`,shortcut:o(`contextMenu.cutShortcut`),disabled:!r.hasSelection||!r.isEditable},{id:`copy`,label:o(`contextMenu.copy`),action:`copy`,shortcut:o(`contextMenu.copyShortcut`),disabled:!r.hasSelection},{id:`paste`,label:o(`contextMenu.paste`),action:`paste`,shortcut:o(`contextMenu.pasteShortcut`),disabled:!r.isEditable},{id:`pasteAsPlainText`,label:o(`contextMenu.pastePlainText`),action:`pasteAsPlainText`,shortcut:o(`contextMenu.pastePlainTextShortcut`),disabled:!r.isEditable},{id:`div1`,label:``,action:``,divider:!0},{id:`delete`,label:o(`contextMenu.delete`),action:`delete`,shortcut:o(`contextMenu.deleteShortcut`),disabled:!r.hasSelection||!r.isEditable},{id:`selectAll`,label:o(`contextMenu.selectAll`),action:`selectAll`,shortcut:o(`contextMenu.selectAllShortcut`)}];return r.onImage&&r.isEditable&&e.push({id:`div-img`,label:``,action:``,divider:!0},{id:`replaceImage`,label:o(`imageOverlay.replaceImage`),action:`replaceImage`},{id:`imageProperties`,label:o(`imageWrap.menu.imageProperties`),action:`imageProperties`},{id:`deleteImage`,label:o(`imageOverlay.deleteImage`),action:`deleteImage`,shortcut:o(`contextMenu.deleteShortcut`)}),r.inTable&&r.isEditable&&e.push({id:`div2`,label:``,action:``,divider:!0},{id:`addRowAbove`,label:o(`table.insertRowAbove`),action:`addRowAbove`},{id:`addRowBelow`,label:o(`table.insertRowBelow`),action:`addRowBelow`},{id:`deleteRow`,label:o(`table.deleteRow`),action:`deleteRow`},{id:`div3`,label:``,action:``,divider:!0},{id:`addColLeft`,label:o(`table.insertColumnLeft`),action:`addColumnLeft`},{id:`addColRight`,label:o(`table.insertColumnRight`),action:`addColumnRight`},{id:`deleteCol`,label:o(`table.deleteColumn`),action:`deleteColumn`},{id:`div4`,label:``,action:``,divider:!0},{id:`mergeCells`,label:o(`table.mergeCells`),action:`mergeCells`,disabled:!r.canMergeCells},{id:`splitCell`,label:o(`table.splitCell`),action:`splitCell`,disabled:!r.canSplitCell}),e}),l=(0,a.computed)(()=>{let e=r.position.x,t=r.position.y,n=c.value.filter(e=>!e.divider).length,i=c.value.filter(e=>e.divider).length,a=n*bt+i*9;return typeof window<`u`&&(e+yt+xt>window.innerWidth&&(e=window.innerWidth-yt-xt),t+a+xt>window.innerHeight&&(t=window.innerHeight-a-xt)),{position:`fixed`,left:`${e}px`,top:`${t}px`,zIndex:400}});function u(e){e&&(i(`action`,e),i(`close`))}function d(e){e.key===`Escape`&&i(`close`)}return(0,a.watch)(()=>r.isOpen,e=>{e&&(0,a.nextTick)(()=>s.value?.focus())}),(e,n)=>((0,a.openBlock)(),(0,a.createBlock)(a.Teleport,{to:`body`},[t.isOpen?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`ctx-menu-backdrop`,onMousedown:n[0]||=t=>e.$emit(`close`),onContextmenu:n[1]||=(0,a.withModifiers)(t=>e.$emit(`close`),[`prevent`])},null,32)):(0,a.createCommentVNode)(``,!0),t.isOpen?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:1,ref_key:`menuRef`,ref:s,class:`ctx-menu`,style:(0,a.normalizeStyle)(l.value),onContextmenu:n[2]||=(0,a.withModifiers)(()=>{},[`prevent`]),onKeydown:d},[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(c.value,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:e.id||t,class:(0,a.normalizeClass)([`ctx-menu__item`,{"ctx-menu__item--disabled":e.disabled,"ctx-menu__item--divider":e.divider}]),disabled:e.disabled,onMousedown:(0,a.withModifiers)(t=>u(e.action),[`prevent`])},[(0,a.createElementVNode)(`span`,_t,(0,a.toDisplayString)(e.label),1),e.shortcut?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,vt,(0,a.toDisplayString)(e.shortcut),1)):(0,a.createCommentVNode)(``,!0)],42,gt))),128))],36)):(0,a.createCommentVNode)(``,!0)]))}}),Ct=n.t(St,[[`__scopeId`,`data-v-b2122da6`]]),wt=[`aria-label`],Tt={class:`image-ctx-menu__icon`},Et={class:`image-ctx-menu__label`},Dt={key:1,class:`image-ctx-menu__divider`,role:`separator`},Ot=[`data-wrap-type`,`data-current`,`data-disabled`,`disabled`,`title`,`onClick`],kt={class:`image-ctx-menu__icon`},At={class:`image-ctx-menu__label`},jt=[`aria-label`],Mt=[`disabled`,`onClick`],Nt={class:`image-ctx-menu__label`},Pt={key:0,class:`image-ctx-menu__shortcut`},Ft={key:0,class:`image-ctx-menu__divider`,role:`separator`},It=18,Lt=260,X=10,Rt=(0,a.defineComponent)({__name:`ImageContextMenu`,props:{state:{},textActions:{},canOpenProperties:{type:Boolean,default:!1}},emits:[`close`,`select`,`text-action`,`open-properties`],setup(t,{emit:n}){let r=t,i=n;function o(){i(`open-properties`),i(`close`)}let{t:s}=e.d(),c=(0,a.ref)(null),l=h.IMAGE_LAYOUT_OPTIONS,u=(0,a.computed)(()=>r.state?(0,h.deriveLayoutChoice)(r.state.currentWrapType,r.state.currentCssFloat??null):null),d={inline:`wrap_text`,squareLeft:`format_image_left`,squareRight:`format_image_right`,behind:`flip_to_back`,inFront:`flip_to_front`};function f(e){return d[e]}let p=(0,a.computed)(()=>{if(!r.state)return{};let e=h.IMAGE_LAYOUT_OPTIONS.length*36+16,t=r.state.position.x,n=r.state.position.y;return typeof window<`u`&&(t+Lt>window.innerWidth&&(t=window.innerWidth-Lt-X),n+e>window.innerHeight&&(n=window.innerHeight-e-X),t<X&&(t=X),n<X&&(n=X)),{position:`fixed`,left:`${t}px`,top:`${n}px`,minWidth:`${Lt}px`,zIndex:400}});function m(e){return r.state?(0,h.isImageLayoutOptionEnabled)(e,r.state.currentWrapType):!1}function g(e){m(e)&&(i(`select`,e.choice),i(`close`))}function _(e){e.disabled||(i(`text-action`,e.action),i(`close`))}function v(e){e.preventDefault(),i(`close`)}function y(e){e.key===`Escape`&&(e.preventDefault(),i(`close`))}return(n,r)=>((0,a.openBlock)(),(0,a.createBlock)(a.Teleport,{to:`body`},[t.state&&t.state.open?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`image-ctx-menu-backdrop`,onMousedown:v,onContextmenu:r[0]||=(0,a.withModifiers)(e=>n.$emit(`close`),[`prevent`])},null,32)):(0,a.createCommentVNode)(``,!0),t.state&&t.state.open?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:1,ref_key:`menuRef`,ref:c,class:`image-ctx-menu`,role:`menu`,"aria-label":(0,a.unref)(s)(`imageWrap.menu.ariaLabel`),"data-testid":`image-context-menu`,style:(0,a.normalizeStyle)(p.value),onContextmenu:r[4]||=(0,a.withModifiers)(()=>{},[`prevent`]),onKeydown:y},[t.canOpenProperties?((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:0,type:`button`,role:`menuitem`,class:`image-ctx-menu__item`,"data-action":`open-properties`,onMousedown:r[1]||=(0,a.withModifiers)(()=>{},[`prevent`]),onClick:o},[(0,a.createElementVNode)(`span`,Tt,[(0,a.createVNode)(e.p,{name:`settings`,size:It})]),(0,a.createElementVNode)(`span`,Et,(0,a.toDisplayString)((0,a.unref)(s)(`imageWrap.menu.imageProperties`)),1)],32)):(0,a.createCommentVNode)(``,!0),t.canOpenProperties?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Dt)):(0,a.createCommentVNode)(``,!0),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)((0,a.unref)(l),t=>((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:t.choice,type:`button`,role:`menuitem`,class:(0,a.normalizeClass)([`image-ctx-menu__item`,{"image-ctx-menu__item--current":t.choice===u.value}]),"data-wrap-type":t.choice,"data-current":t.choice===u.value?`true`:`false`,"data-disabled":m(t)?`false`:`true`,disabled:!m(t),title:(0,a.unref)(s)(`imageWrap.menuDesc.${t.i18nDescKey}`),onMousedown:r[2]||=(0,a.withModifiers)(()=>{},[`prevent`]),onClick:e=>g(t)},[(0,a.createElementVNode)(`span`,kt,[(0,a.createVNode)(e.p,{name:f(t.iconHint),size:It},null,8,[`name`])]),(0,a.createElementVNode)(`span`,At,(0,a.toDisplayString)((0,a.unref)(s)(`imageWrap.menu.${t.i18nLabelKey}`)),1),t.choice===u.value?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,{key:0,class:`image-ctx-menu__current-dot`,"aria-label":(0,a.unref)(s)(`imageWrap.menu.ariaLabel`)},`●`,8,jt)):(0,a.createCommentVNode)(``,!0)],42,Ot))),128)),t.textActions&&t.textActions.length>0?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:2},[r[5]||=(0,a.createElementVNode)(`div`,{class:`image-ctx-menu__divider`,role:`separator`},null,-1),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(t.textActions,(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:`${e.action}-${t}`},[(0,a.createElementVNode)(`button`,{type:`button`,role:`menuitem`,class:`image-ctx-menu__item image-ctx-menu__item--text`,disabled:e.disabled,onMousedown:r[3]||=(0,a.withModifiers)(()=>{},[`prevent`]),onClick:t=>_(e)},[(0,a.createElementVNode)(`span`,Nt,(0,a.toDisplayString)(e.label),1),e.shortcut?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,Pt,(0,a.toDisplayString)(e.shortcut),1)):(0,a.createCommentVNode)(``,!0)],40,Mt),e.dividerAfter?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Ft)):(0,a.createCommentVNode)(``,!0)],64))),128))],64)):(0,a.createCommentVNode)(``,!0)],44,wt)):(0,a.createCommentVNode)(``,!0)]))}}),zt=n.t(Rt,[[`__scopeId`,`data-v-5c21ca8c`]]),Bt=(0,a.defineComponent)({__name:`DocxEditorOverlays`,props:{readOnly:{type:Boolean},contextMenu:{},imageContextMenu:{},imageContextMenuTextActions:{},canOpenImageProperties:{type:Boolean}},emits:[`context-menu-action`,`close-context-menu`,`image-wrap-select`,`close-image-context-menu`,`open-image-properties`],setup(e,{emit:t}){let n=t;return(t,r)=>((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createVNode)(Ct,{"is-open":e.contextMenu.isOpen,position:e.contextMenu.position,"has-selection":e.contextMenu.hasSelection,"is-editable":!e.readOnly,"in-table":e.contextMenu.inTable,"on-image":e.contextMenu.onImage,"can-merge-cells":e.contextMenu.canMergeCells,"can-split-cell":e.contextMenu.canSplitCell,onAction:r[0]||=e=>n(`context-menu-action`,e),onClose:r[1]||=e=>n(`close-context-menu`)},null,8,[`is-open`,`position`,`has-selection`,`is-editable`,`in-table`,`on-image`,`can-merge-cells`,`can-split-cell`]),(0,a.createVNode)(zt,{state:e.imageContextMenu,"text-actions":e.imageContextMenuTextActions,"can-open-properties":e.canOpenImageProperties,onClose:r[2]||=e=>n(`close-image-context-menu`),onSelect:r[3]||=e=>n(`image-wrap-select`,e),onTextAction:r[4]||=e=>n(`context-menu-action`,e),onOpenProperties:r[5]||=e=>n(`open-image-properties`)},null,8,[`state`,`text-actions`,`can-open-properties`])],64))}}),Vt=[`href`,`title`],Ht=[`title`],Ut=[`title`],Wt=[`title`],Gt={class:`docx-hyperlink-popup__edit-row`},Z=[`placeholder`,`onKeydown`],Kt={class:`docx-hyperlink-popup__edit-row`},qt=[`onKeydown`],Jt=[`disabled`],Yt=(0,a.defineComponent)({__name:`HyperlinkPopup`,props:{data:{},readOnly:{type:Boolean}},emits:[`navigate`,`copy`,`edit`,`remove`,`close`],setup(t,{emit:n}){let{t:r}=e.d(),i=t,o=n,s=(0,a.ref)(!1),c=(0,a.ref)(``),l=(0,a.ref)(``),u=(0,a.ref)(null),d=(0,a.computed)(()=>({left:(i.data?.position.left??0)+`px`,top:(i.data?.position.top??0)+`px`}));(0,a.watch)(()=>i.data?.href,()=>{s.value=!1});let f=null,p=null;function m(){p&&=(clearTimeout(p),null),f&&=(document.removeEventListener(`mousedown`,f),null)}(0,a.watch)(()=>i.data,e=>{m(),e&&(f=e=>{let t=u.value;t&&!t.contains(e.target)&&o(`close`)},p=setTimeout(()=>{f&&document.addEventListener(`mousedown`,f)},0))},{immediate:!0}),(0,a.onBeforeUnmount)(m);function h(){i.data&&(c.value=i.data.displayText,l.value=i.data.href,s.value=!0)}function g(){l.value.trim()&&(o(`edit`,c.value,l.value),s.value=!1)}function _(){i.data&&(o(`copy`,i.data.href),typeof navigator<`u`&&navigator.clipboard&&navigator.clipboard.writeText(i.data.href).catch(()=>{}))}return(e,n)=>t.data?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,ref_key:`popupRef`,ref:u,class:(0,a.normalizeClass)([`docx-hyperlink-popup`,{"docx-hyperlink-popup--edit":s.value}]),style:(0,a.normalizeStyle)(d.value),onMousedown:n[6]||=(0,a.withModifiers)(()=>{},[`stop`])},[s.value?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:1},[(0,a.createElementVNode)(`div`,Gt,[(0,a.withDirectives)((0,a.createElementVNode)(`input`,{class:`docx-hyperlink-popup__input`,placeholder:(0,a.unref)(r)(`hyperlinkPopup.displayTextPlaceholder`),"onUpdate:modelValue":n[2]||=e=>c.value=e,onKeydown:[(0,a.withKeys)((0,a.withModifiers)(g,[`prevent`]),[`enter`]),n[3]||=(0,a.withKeys)(t=>e.$emit(`close`),[`esc`])]},null,40,Z),[[a.vModelText,c.value]])]),(0,a.createElementVNode)(`div`,Kt,[(0,a.withDirectives)((0,a.createElementVNode)(`input`,{class:`docx-hyperlink-popup__input`,placeholder:`https://...`,"onUpdate:modelValue":n[4]||=e=>l.value=e,onKeydown:[(0,a.withKeys)((0,a.withModifiers)(g,[`prevent`]),[`enter`]),n[5]||=(0,a.withKeys)(t=>e.$emit(`close`),[`esc`])]},null,40,qt),[[a.vModelText,l.value]]),(0,a.createElementVNode)(`button`,{class:`docx-hyperlink-popup__apply`,disabled:!l.value.trim(),onClick:(0,a.withModifiers)(g,[`prevent`])},(0,a.toDisplayString)((0,a.unref)(r)(`common.apply`)),9,Jt)])],64)):((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:0},[n[10]||=(0,a.createStaticVNode)(`<span class="docx-hyperlink-popup__icon" aria-hidden data-v-9d23bb12><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-9d23bb12><circle cx="12" cy="12" r="10" data-v-9d23bb12></circle><path d="M2 12h20" data-v-9d23bb12></path><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" data-v-9d23bb12></path></svg></span>`,1),(0,a.createElementVNode)(`a`,{class:`docx-hyperlink-popup__url`,href:t.data.href,title:t.data.href,onClick:n[0]||=(0,a.withModifiers)(n=>e.$emit(`navigate`,t.data.href),[`prevent`])},(0,a.toDisplayString)(t.data.href),9,Vt),n[11]||=(0,a.createElementVNode)(`span`,{class:`docx-hyperlink-popup__sep`},null,-1),(0,a.createElementVNode)(`button`,{class:`docx-hyperlink-popup__btn`,title:(0,a.unref)(r)(`hyperlinkPopup.copyLink`),onClick:(0,a.withModifiers)(_,[`prevent`])},[...n[7]||=[(0,a.createElementVNode)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,a.createElementVNode)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,a.createElementVNode)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})],-1)]],8,Ht),t.readOnly?(0,a.createCommentVNode)(``,!0):((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:0,class:`docx-hyperlink-popup__btn`,title:(0,a.unref)(r)(`hyperlinkPopup.editLink`),onClick:(0,a.withModifiers)(h,[`prevent`])},[...n[8]||=[(0,a.createElementVNode)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[(0,a.createElementVNode)(`path`,{d:`M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`}),(0,a.createElementVNode)(`path`,{d:`M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z`})],-1)]],8,Ut)),t.readOnly?(0,a.createCommentVNode)(``,!0):((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:1,class:`docx-hyperlink-popup__btn`,title:(0,a.unref)(r)(`hyperlinkPopup.removeLink`),onClick:n[1]||=(0,a.withModifiers)(t=>e.$emit(`remove`),[`prevent`])},[...n[9]||=[(0,a.createStaticVNode)(`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-9d23bb12><path d="M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" data-v-9d23bb12></path><path d="M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" data-v-9d23bb12></path><line x1="8" y1="2" x2="8" y2="5" data-v-9d23bb12></line><line x1="2" y1="8" x2="5" y2="8" data-v-9d23bb12></line><line x1="16" y1="19" x2="16" y2="22" data-v-9d23bb12></line><line x1="19" y1="16" x2="22" y2="16" data-v-9d23bb12></line></svg>`,1)]],8,Wt))],64))],38)):(0,a.createCommentVNode)(``,!0)}}),Xt=n.t(Yt,[[`__scopeId`,`data-v-9d23bb12`]]);function Zt(e){let t=(0,a.ref)(null);async function n(){await e.nextTick(),e.extractCommentsAndChanges(),e.emit(`ready`)}async function r(t){try{let r=await(0,l.readDocxFileFromInput)(t);if(!r)return;await e.loadBuffer(r.buffer),e.emit(`update:document`,e.getDocument()),e.emit(`rename`,r.name),await n()}catch(t){e.emit(`error`,t instanceof Error?t:Error(`Failed to open document`))}}function i(t){e.onDocumentNameChange?.(t),e.emit(`rename`,t)}async function o(){let t=await e.saveBlob();if(!t)return;let n=(e.documentName()??``).trim()||`document`,r=URL.createObjectURL(t),i=window.document.createElement(`a`);i.href=r,i.download=`${n.replace(/\.docx$/i,``)}.docx`,i.click(),setTimeout(()=>URL.revokeObjectURL(r),0)}async function s(t){await e.loadBuffer(t),e.emit(`update:document`,e.getDocument()),await n()}function c(t){e.loadParsedDocument(t),e.emit(`update:document`,t),n()}async function u(){let t=await e.saveBlob();return t?t.arrayBuffer():null}return{docxInputRef:t,handleDocxFileChange:r,handleDocumentNameChange:i,downloadCurrentDocument:o,emitReadyAfterSidebarStateRefresh:n,loadDocumentBuffer:s,loadDocument:c,save:u}}function Qt(e){let t=(0,a.ref)(null);function n(t){let n=e.editorView.value;if(!n)return;let r=e.getCommands(),{empty:i}=n.state.selection,a=t.bookmark?`#${t.bookmark}`:t.url;if(a){if(i&&t.displayText){let e=r.insertHyperlink;e&&e(t.displayText,a,t.tooltip||void 0)(n.state,e=>n.dispatch(e),n)}else{let e=r.setHyperlink;e&&e(a,t.tooltip||void 0)(n.state,e=>n.dispatch(e),n)}n.focus()}}function r(){let t=e.editorView.value;if(!t)return;let n=e.getCommands().removeHyperlink;n&&n()(t.state,e=>t.dispatch(e),t),t.focus()}function i(e){window.open(e,`_blank`,`noopener,noreferrer`),t.value=null}function o(n,r){let i=e.editorView.value;if(!i)return;let a=(0,d.findHyperlinkRangeAt)(i.state);if(!a){t.value=null;return}let o=i.state.schema.marks.hyperlink,{$from:s}=i.state.selection,c=o.create({href:r,tooltip:a.mark.attrs.tooltip}),l=s.marks().filter(e=>e.type!==o),u=i.state.schema.text(n,[...l,c]),f=i.state.tr.replaceWith(a.start,a.end,u);i.dispatch(f.scrollIntoView()),t.value=null,i.focus()}function s(){let n=e.editorView.value;if(!n)return;let r=(0,d.findHyperlinkRangeAt)(n.state,t.value?.href);if(!r){t.value=null;return}let i=n.state.schema.marks.hyperlink,a=n.state.tr.removeMark(r.start,r.end,i);n.dispatch(a.scrollIntoView()),t.value=null,n.focus()}return{hyperlinkPopupData:t,handleHyperlinkSubmit:n,handleHyperlinkRemove:r,handleHyperlinkPopupNavigate:i,handleHyperlinkPopupEdit:o,handleHyperlinkPopupRemove:s}}function $t(e){function t(){let t=e.editorView.value;t&&((0,d.clearFormatting)(t.state,t.dispatch,t),t.focus())}function n(t){let n=e.editorView.value;if(!n)return;let r=e.getDocument()?.package?.styles;if(r){let e=(0,S.createStyleResolver)(r).resolveParagraphStyle(t);(0,x.applyStyle)(t,{paragraphFormatting:e.paragraphFormatting,runFormatting:e.runFormatting})(n.state,e=>n.dispatch(e))}else (0,x.applyStyle)(t)(n.state,e=>n.dispatch(e));n.focus()}function r(){let t=e.editorView.value;t&&((0,C.insertPageBreak)(t.state,e=>t.dispatch(e),t),t.focus())}function i(t){let n=e.editorView.value;if(!n)return;let{from:r}=n.state.selection,i=n.state.tr.insertText(t,r);n.dispatch(i.scrollIntoView()),n.focus()}function a(t){let n=e.editorView.value;return n?(0,w.applyFormatting)(n,t):!1}function o(t){let n=e.editorView.value;if(!n)return!1;let r=e.getDocument();return(0,w.setParagraphStyle)(n,t,{styleResolver:r?.package?.styles?(0,S.createStyleResolver)(r.package.styles):null})}return{handleClearFormatting:t,handleApplyStyle:n,handleInsertPageBreak:r,handleInsertSymbol:i,applyFormatting:a,setParagraphStyle:o}}function en(e){function t(t){let n=e.getDocument();if(!n?.package?.document)return;let r=n.package.document.finalSectionProperties??{};n.package.document.finalSectionProperties={...r,...t},e.stateTick.value++,e.reLayout(),e.emit(`change`,n)}function n(n,r){e.readOnly.value||t({[n]:r})}function r(e){n(`marginLeft`,e)}function i(e){n(`marginRight`,e)}function a(e){n(`marginTop`,e)}function o(e){n(`marginBottom`,e)}function s(t){let n=e.editorView.value;n&&(0,x.setIndentLeft)(t)(n.state,n.dispatch)}function c(t){let n=e.editorView.value;n&&(0,x.setIndentRight)(t)(n.state,n.dispatch)}function l(t){let n=e.editorView.value;n&&(t<0?(0,x.setIndentFirstLine)(-t,!0)(n.state,n.dispatch):(0,x.setIndentFirstLine)(t,!1)(n.state,n.dispatch))}function u(t){let n=e.editorView.value;n&&(0,x.removeTabStop)(t)(n.state,n.dispatch)}return{handlePageSetupApply:t,handleLeftMarginChange:r,handleRightMarginChange:i,handleTopMarginChange:a,handleBottomMarginChange:o,handleIndentLeftChange:s,handleIndentRightChange:c,handleFirstLineIndentChange:l,handleTabStopRemove:u}}function tn(e){let t=(0,a.ref)(!1),n=(0,a.computed)(()=>{e.stateTick.value;let t=e.editorView.value;return t?(0,T.getWatermarkFromState)(t.state)??void 0:void 0});function r(t){if(e.readOnly.value)return;let n=e.editorView.value;n&&((0,T.setWatermark)(t)(n.state,n.dispatch),e.stateTick.value++,n.focus())}return{showWatermark:t,currentWatermark:n,handleWatermarkApply:r}}function nn(e){function t(){if(!e.showOutline.value){let t=e.editorView.value;t&&(e.outlineHeadings.value=(0,E.collectHeadings)(t.state.doc))}e.showOutline.value=!e.showOutline.value}function n(t){let n=e.editorView.value;if(!n)return;let r=n.state.doc.resolve(Math.min(t+1,n.state.doc.content.size)),i=o.TextSelection.near(r);n.dispatch(n.state.tr.setSelection(i).scrollIntoView()),n.focus()}function r(){e.showSidebar.value||e.extractCommentsAndChanges(),e.showSidebar.value=!e.showSidebar.value}function i(t){let n=t.target;n&&(n.closest(`.paged-editor__pages`)||n.closest(`.unified-sidebar`)||n.closest(`.docx-comment-margin-markers`)||(e.activeSidebarItem.value=null))}return{handleToggleOutline:t,handleOutlineNavigate:n,handleToggleSidebar:r,handleEditorScrollMouseDown:i}}function rn(e){function t(t){if(t.key===`F1`){t.preventDefault(),e.showKeyboardShortcuts.value=!0;return}e.handleZoomKeyDown(t),(t.ctrlKey||t.metaKey)&&(e.disableFindReplaceShortcuts?.()&&(t.key===`f`||t.key===`h`)||(t.key===`f`||t.key===`h`?(t.preventDefault(),e.showFindReplace.value=!0):t.key===`k`?(t.preventDefault(),e.showHyperlink.value=!0):t.key===`/`&&(t.preventDefault(),e.showKeyboardShortcuts.value=!e.showKeyboardShortcuts.value)))}return(0,a.onMounted)(()=>window.addEventListener(`keydown`,t)),(0,a.onBeforeUnmount)(()=>window.removeEventListener(`keydown`,t)),{handleKeyDown:t}}function an(e){let t=()=>(0,a.unref)(e.author)??`User`;function n(t){e.comments.value=t,e.commentCallbacks?.onCommentsChange?.(t)}function r(){(0,O.seedCommentAllocator)(e.commentIdAllocator,e.getDocument()?.package?.document?.comments,e.editorView.value)}function i(t,n,i){return r(),(0,D.createComment)(e.commentIdAllocator,t,n,i)}function o(t){let i=e.getDocument(),a=e.editorView.value;if(!i?.package?.document||!a)return null;i.package.document.comments||(i.package.document.comments=[]),r();let o=(0,D.addCommentToRange)(a,t,e.commentIdAllocator);return o?(i.package.document.comments.push(o),n([...i.package.document.comments]),e.showSidebar.value=!0,e.emit(`change`,i),e.contentChangeSubscribers.forEach(e=>e(i)),o.id):null}function s(t,r,a){let o=e.getDocument();if(!o?.package?.document?.comments||!o.package.document.comments.some(e=>e.id===t))return null;let s=i(r,a,t);return o.package.document.comments.push(s),n([...o.package.document.comments]),e.emit(`change`,o),e.contentChangeSubscribers.forEach(e=>e(o)),s.id}function c(t){let r=e.getDocument();if(!r?.package?.document?.comments)return;let i=r.package.document.comments.find(e=>e.id===t);i&&(i.done=!0,n([...r.package.document.comments]),e.emit(`change`,r),e.contentChangeSubscribers.forEach(e=>e(r)))}function l(t){let n=e.editorView.value;if(!n)return!1;r();let i=(0,D.applyProposedChange)(n,t,e.commentIdAllocator);return i&&(e.extractCommentsAndChanges(),e.showSidebar.value=!0),i}function u(n,r){let i=e.getDocument(),a=i?.package?.document?.comments?.find(e=>e.id===n),o=s(n,r,t());if(o==null||!a)return;let c=i?.package?.document?.comments?.find(e=>e.id===o);c&&e.commentCallbacks?.onCommentReply?.(c,a)}function d(t){let n=e.getDocument()?.package?.document?.comments?.find(e=>e.id===t);c(t),n&&e.commentCallbacks?.onCommentResolve?.({...n})}function f(t){let r=e.getDocument();if(!r?.package?.document?.comments)return;let i=r.package.document.comments.find(e=>e.id===t);i&&(i.done=!1),n([...r.package.document.comments]),e.emit(`change`,r)}function p(t){let r=e.getDocument();if(!r?.package?.document?.comments)return;let i=r.package.document.comments.find(e=>e.id===t);r.package.document.comments=r.package.document.comments.filter(e=>e.id!==t&&e.parentId!==t),n([...r.package.document.comments]),i&&e.commentCallbacks?.onCommentDelete?.(i),e.emit(`change`,r)}function m(t,n){let r=e.editorView.value;r&&((0,T.acceptChange)(t,n)(r.state,r.dispatch),e.extractCommentsAndChanges(),r.focus())}function h(t,n){let r=e.editorView.value;r&&((0,T.rejectChange)(t,n)(r.state,r.dispatch),e.extractCommentsAndChanges(),r.focus())}function g(t){let n=e.editorView.value;n&&((0,T.acceptChangeById)(t)(n.state,n.dispatch),e.extractCommentsAndChanges(),n.focus())}function _(t){let n=e.editorView.value;n&&((0,T.rejectChangeById)(t)(n.state,n.dispatch),e.extractCommentsAndChanges(),n.focus())}function v(r,a){let o=e.getDocument(),s=e.editorView.value;if(!o?.package?.document||!s)return;o.package.document.comments||(o.package.document.comments=[]);let c=s.state.schema.marks.comment;if(!c)return;let l=null,u=s.state.schema.marks.insertion,d=s.state.schema.marks.deletion;if(s.state.doc.descendants((e,t)=>{if(l!==null)return!1;for(let n of e.marks)if((n.type===u||n.type===d)&&n.attrs.revisionId===r)return l=t,!1;return!0}),l===null)return;let f=i(a,t());o.package.document.comments.push(f),n([...o.package.document.comments]);let p=l,m=Math.min(p+1,s.state.doc.content.size);s.dispatch(s.state.tr.addMark(p,m,c.create({commentId:f.id}))),e.emit(`change`,o)}return{addComment:o,replyToComment:s,resolveComment:c,proposeChange:l,handleCommentReply:u,handleCommentResolve:d,handleCommentUnresolve:f,handleCommentDelete:p,handleAcceptChange:m,handleRejectChange:h,handleAcceptChangeById:g,handleRejectChangeById:_,handleTrackedChangeReply:v}}function on(e,t){return(0,a.watch)(t,t=>t&&e.onEditorViewReady?.(t),{immediate:!0}),{commentCallbacks:{onCommentAdd:t=>e.onCommentAdd?.(t),onCommentResolve:t=>e.onCommentResolve?.(t),onCommentDelete:t=>e.onCommentDelete?.(t),onCommentReply:(t,n)=>e.onCommentReply?.(t,n),onCommentsChange:t=>e.onCommentsChange?.(t)}}}function sn(e){let t=(0,a.ref)(null),n=(0,a.ref)(null),r=(0,a.ref)(null),i=(0,a.ref)(!1);function o(){let t=e.getDocument(),n=e.editorView.value;!t||!n||(e.comments.value=[...t.package?.document?.comments??[]],e.trackedChanges.value=(0,k.extractTrackedChanges)(n.state).entries,!i.value&&(e.comments.value.length>0||e.trackedChanges.value.length>0)&&(e.showSidebar.value=!0,i.value=!0))}function s(){e.stateTick.value;let n=e.editorView.value;if(!n||e.isAddingComment.value||e.readOnly.value){t.value=null;return}let{from:r,to:i}=n.state.selection;if(r===i){t.value=null;return}let a=e.pagesRef.value,o=e.pagesViewportRef.value;if(!a||!o){t.value=null;return}let s=o.getBoundingClientRect(),c=I(a,r);if(!c){t.value=null;return}let l=c.getBoundingClientRect().top-s.top+o.scrollTop,u=a.querySelector(`.layout-page`);if(!u){t.value=null;return}t.value={top:l,left:u.getBoundingClientRect().right-s.left+8}}function c(){e.stateTick.value;let t=e.editorView.value;if(!t)return;let n=t.state.selection.$from,r=[...t.state.storedMarks??[],...n.nodeAfter?.marks??[],...n.nodeBefore?.marks??[],...n.marks()],i=null;for(let t of r){if(t.type.name===`comment`&&t.attrs.commentId!=null){let n=t.attrs.commentId;if(n===O.PENDING_COMMENT_ID||e.resolvedCommentIds.value.has(n))continue;i=`comment-${n}`;break}if((t.type.name===`insertion`||t.type.name===`deletion`)&&t.attrs.revisionId!=null){let n=String(t.attrs.revisionId),r=e.trackedChanges.value.findIndex(e=>String(e.revisionId)===n||String(e.insertionRevisionId??``)===n);if(r>=0){i=`tc-${e.trackedChanges.value[r].revisionId}-${r}`;break}}}i&&(e.showSidebar.value=!0),e.activeSidebarItem.value=i}function l(){let i=e.editorView.value;if(!i)return;let{from:a,to:o}=i.state.selection;if(a===o)return;n.value={from:a,to:o},r.value=t.value?.top??null;let s=i.state.schema.marks.comment;if(s){let e=i.state.tr.addMark(a,o,s.create({commentId:O.PENDING_COMMENT_ID}));i.dispatch(e)}e.showSidebar.value=!0,e.isAddingComment.value=!0,t.value=null}function u(t){let i=e.getDocument(),o=e.editorView.value;if(!i?.package)return;i.package.document.comments||(i.package.document.comments=[]),(0,O.seedCommentAllocator)(e.commentIdAllocator,i.package.document.comments,o);let s=(0,D.createComment)(e.commentIdAllocator,t,(0,a.unref)(e.author)??`User`);i.package.document.comments.push(s),e.comments.value=[...i.package.document.comments],e.commentCallbacks?.onCommentsChange?.(e.comments.value),e.commentCallbacks?.onCommentAdd?.(s);let c=n.value;if(o&&c&&c.from!==c.to){let e=o.state.schema.marks.comment;if(e){let t=o.state.tr.removeMark(c.from,c.to,e);t=t.addMark(c.from,c.to,e.create({commentId:s.id})),o.dispatch(t)}}n.value=null,r.value=null,e.isAddingComment.value=!1,e.emit(`change`,i)}function d(){let t=e.editorView.value,i=n.value;if(t&&i&&i.from!==i.to){let e=t.state.schema.marks.comment;e&&t.dispatch(t.state.tr.removeMark(i.from,i.to,e))}n.value=null,r.value=null,e.isAddingComment.value=!1}function f(t){e.showSidebar.value=!0}(0,a.watch)([e.stateTick,e.isAddingComment,e.zoom],()=>s()),(0,a.watch)(e.stateTick,()=>c()),(0,a.watch)(e.stateTick,()=>o());let p=null;return(0,a.onMounted)(()=>{p=new ResizeObserver(()=>s()),e.pagesRef.value&&p.observe(e.pagesRef.value),window.addEventListener(`resize`,s)}),(0,a.onBeforeUnmount)(()=>{p?.disconnect(),window.removeEventListener(`resize`,s)}),{floatingCommentBtn:t,pendingCommentRange:n,addCommentYPosition:r,sidebarAutoOpenedRef:i,extractCommentsAndChanges:o,handleAddComment:u,handleCancelAddComment:d,handleStartAddComment:l,handleMarkerClick:f,recomputeFloatingCommentBtn:s,recomputeActiveSidebarItem:c}}function cn(e){let t=(0,a.shallowRef)(null),n=(0,a.ref)(!1),r=(0,a.computed)(()=>{e.stateTick.value;let n=e.editorView.value,r=t.value;if(!n||!r)return null;let i=n.state.doc.nodeAt(r.pmPos);return!i||i.type.name!==`image`?null:{wrapType:i.attrs.wrapType??`inline`,displayMode:i.attrs.displayMode??`inline`,cssFloat:i.attrs.cssFloat??null}});function i(t){let n=e.editorView.value;if(!n)return;let r=n.state.schema.nodes.image;if(!r)return;let i=r.create({src:t.src,alt:t.alt,width:t.width,height:t.height});(0,T.insertImageNode)(n.state,n.dispatch,i,n.state.selection.from),n.focus()}function o(n){let r=e.editorView.value,i=t.value;if(!r||!i)return;let a=(0,h.toolbarValueToLayoutTarget)(n);if(!a)return;let o=r.state.doc.nodeAt(i.pmPos),s=e.getCommands(),c=o?.attrs.wrapType===`inline`&&a!==`inline`?{initialPositionEmu:(0,h.captureInlinePositionEmu)(i.element,e.zoom.value)}:void 0,l=s.setImageWrapType?.(i.pmPos,a,c);l&&(l(r.state,e=>r.dispatch(e),r),r.focus())}function s(n){let r=e.editorView.value,i=t.value;if(!r||!i)return;let a=r.state.doc.nodeAt(i.pmPos);if(!a||a.type.name!==`image`)return;let o=a.attrs.transform||``,s=o.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),c=s?parseFloat(s[1]):0,l=/scaleX\(-1\)/.test(o),u=/scaleY\(-1\)/.test(o);n===`rotateCW`?c=(c+90)%360:n===`rotateCCW`?c=(c-90+360)%360:n===`flipH`?l=!l:n===`flipV`&&(u=!u);let d=[];c!==0&&d.push(`rotate(${c}deg)`),l&&d.push(`scaleX(-1)`),u&&d.push(`scaleY(-1)`);let f=d.length>0?d.join(` `):null,p=r.state.tr.setNodeMarkup(i.pmPos,void 0,{...a.attrs,transform:f});r.dispatch(p.scrollIntoView()),r.focus()}return{selectedImage:t,imageInteracting:n,imageToolbarContext:r,handleInsertImage:i,handleToolbarImageWrap:o,handleImageTransform:s}}function ln(e,t,n){let r=(0,y.makeRevisionInfo)(e.state),i=e.state.schema.marks.insertion;if(!r||!i)return;let a=t.selection.from,o=a-n.nodeSize;o<0||t.addMark(o,a,i.create({revisionId:r.revisionId,author:r.author,date:r.date}))}function un(e,t){return e.getBlob(t)}function dn(e,t){let n=e.state.doc.nodeAt(t);if(!n||n.type.name!==`image`)return;let r=`<img src="${n.attrs.src}" data-pm-image="true" data-width="${n.attrs.width??``}" data-height="${n.attrs.height??``}" data-wrap-type="${n.attrs.wrapType??``}" data-display-mode="${n.attrs.displayMode??``}" data-rid="${n.attrs.rId??``}" />`,i=new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([`[image]`],{type:`text/plain`})});navigator.clipboard.write([i]).catch(()=>{let e=document.createElement(`textarea`);e.value=r,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)})}function Q(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function $(e){return new Promise(t=>{let n=new Image;n.onload=()=>t({width:n.naturalWidth,height:n.naturalHeight}),n.onerror=()=>t({width:200,height:200}),n.src=e})}async function fn(e){try{let t=await navigator.clipboard.read();for(let n of t){let t=n.types.find(e=>e.startsWith(`image/`));if(t){let r=await Q(await un(n,t)),i=await $(r),a=i.width,o=i.height;a>612&&(o=Math.round(612/a*o),a=612);let s=e.state.schema.nodes.image.create({src:r,width:a,height:o,rId:`rId_img_${Date.now()}`,wrapType:`inline`,displayMode:`inline`}),c=e.state.tr.replaceSelectionWith(s);ln(e,c,s),e.dispatch(c);return}if(n.types.includes(`text/html`)){let t=await(await un(n,`text/html`)).text(),r=t.match(/<img[^>]+src="([^"]+)"[^>]*>/i);if(r&&r[1]){let n=r[1],i=t.match(/data-width="(\d+)"/),a=t.match(/data-height="(\d+)"/),o=i?Number(i[1]):200,s=a?Number(a[1]):200,c=e.state.schema.nodes.image.create({src:n,width:o||200,height:s||200,rId:`rId_img_${Date.now()}`,wrapType:`inline`,displayMode:`inline`}),l=e.state.tr.replaceSelectionWith(c);ln(e,l,c),e.dispatch(l);return}}if(n.types.includes(`text/plain`)){let t=await(await un(n,`text/plain`)).text();if(t&&t!==`[image]`){let{from:n}=e.state.selection;e.dispatch(e.state.tr.insertText(t,n))}return}}}catch{let t=await navigator.clipboard?.readText();if(t){let{from:n}=e.state.selection;e.dispatch(e.state.tr.insertText(t,n))}}}function pn(e,t){let n=e.state.doc.nodeAt(t);if(!n||n.type.name!==`image`)return;let r=document.createElement(`input`);r.type=`file`,r.accept=`image/*`,r.onchange=async()=>{let i=r.files?.[0];if(!i)return;let a=await Q(i),o=await $(a),s=n.attrs.width||o.width,c=n.attrs.height||o.height,l=Math.min(s/o.width,c/o.height),u=Math.round(o.width*l),d=Math.round(o.height*l);try{let r=e.state.tr.setNodeMarkup(t,void 0,{...n.attrs,src:a,width:u,height:d,rId:`rId_img_${Date.now()}`});e.dispatch(r)}catch{}},r.click()}function mn(t){let{t:n}=e.d(),r=(0,a.ref)({isOpen:!1,position:{x:0,y:0},hasSelection:!1,inTable:!1,onImage:!1,canMergeCells:!1,canSplitCell:!1}),i=(0,a.ref)(null),s=(0,a.computed)(()=>[{action:`cut`,label:n(`contextMenu.cut`),shortcut:n(`contextMenu.cutShortcut`)},{action:`copy`,label:n(`contextMenu.copy`),shortcut:n(`contextMenu.copyShortcut`)},{action:`paste`,label:n(`contextMenu.paste`),shortcut:n(`contextMenu.pasteShortcut`),dividerAfter:!0},{action:`delete`,label:n(`contextMenu.delete`),shortcut:n(`contextMenu.deleteShortcut`)}]);function c(e){let n=t.editorView.value;if(!n)return;let a=e.target,s=(0,h.findImageElement)(a);if(s){let a=Number(s.dataset.pmStart);if(!isNaN(a)){try{let e=o.NodeSelection.create(n.state.doc,a);n.dispatch(n.state.tr.setSelection(e))}catch{}t.selectedImage.value={element:s,pmPos:a,width:s.offsetWidth,height:s.offsetHeight},t.clearOverlay();let c=n.state.doc.nodeAt(a);if(c&&c.type.name===`image`){let n=c.attrs.wrapType??`inline`,o=c.attrs.cssFloat;i.value={open:!0,position:{x:e.clientX,y:e.clientY},pmPos:a,currentWrapType:n,currentCssFloat:o??null,inlinePositionEmu:n===`inline`?(0,h.captureInlinePositionEmu)(s,t.zoom.value):void 0},r.value.isOpen=!1;return}}}{let{from:r,to:i}=n.state.selection,a=t.resolvePos(e.clientX,e.clientY);if(a!==null&&(a<r||a>i))try{t.setPmSelection(a)}catch{}}let c=(0,f.getTableContext)(n.state),{empty:l}=n.state.selection;i.value&&=null,r.value={isOpen:!0,position:{x:e.clientX,y:e.clientY},hasSelection:!l,inTable:c.isInTable,onImage:!!s,canMergeCells:!!c.hasMultiCellSelection,canSplitCell:!!c.canSplitCell}}function l(e){let n=t.editorView.value,a=t.selectedImage.value;if(!n||!a)return;let o=n.state.doc.nodeAt(a.pmPos);if(!o||o.type.name!==`image`)return;let s=o.attrs.wrapType??`inline`,c=o.attrs.cssFloat;i.value={open:!0,position:{x:e.clientX,y:e.clientY},pmPos:a.pmPos,currentWrapType:s,currentCssFloat:c??null,inlinePositionEmu:s===`inline`?(0,h.captureInlinePositionEmu)(a.element,t.zoom.value):void 0},r.value.isOpen=!1}function u(e){let n=t.editorView.value,r=i.value;if(!n||!r)return;let a=t.getCommands(),o=r.inlinePositionEmu&&e!==`inline`?{initialPositionEmu:r.inlinePositionEmu}:void 0,s=a.setImageWrapType?.(r.pmPos,e,o);s&&(s(n.state,e=>n.dispatch(e),n),n.focus())}function d(e){let n=t.editorView.value;if(!n)return;let r=t.getCommands();switch(e){case`cut`:if(t.selectedImage.value){dn(n,t.selectedImage.value.pmPos);let e=t.selectedImage.value.pmPos,r=n.state.doc.nodeAt(e);r&&(n.dispatch(n.state.tr.delete(e,e+r.nodeSize)),t.selectedImage.value=null)}else document.execCommand(`cut`);break;case`copy`:t.selectedImage.value?dn(n,t.selectedImage.value.pmPos):document.execCommand(`copy`);break;case`paste`:fn(n);break;case`pasteAsPlainText`:navigator.clipboard.readText().then(e=>{e&&n.dispatch(n.state.tr.insertText(e).scrollIntoView())}).catch(()=>{});break;case`delete`:{let{from:e,to:t}=n.state.selection;e!==t&&n.dispatch(n.state.tr.delete(e,t));break}case`selectAll`:{let e=o.TextSelection.create(n.state.doc,0,n.state.doc.content.size);n.dispatch(n.state.tr.setSelection(e));break}case`imageProperties`:t.selectedImage.value&&(t.showImageProperties.value=!0);break;case`replaceImage`:t.selectedImage.value&&pn(n,t.selectedImage.value.pmPos);break;case`deleteImage`:if(t.selectedImage.value){let e=t.selectedImage.value.pmPos,r=n.state.doc.nodeAt(e);r&&(n.dispatch(n.state.tr.delete(e,e+r.nodeSize)),t.selectedImage.value=null)}break;case`addRowAbove`:case`addRowBelow`:case`deleteRow`:case`addColumnLeft`:case`addColumnRight`:case`deleteColumn`:case`mergeCells`:case`splitCell`:{let t=r[e];t&&t()(n.state,e=>n.dispatch(e),n);break}}n.focus()}return{contextMenu:r,imageContextMenu:i,imageContextMenuTextActions:s,handleContextMenu:c,handleSelectedImageContextMenu:l,handleImageWrapSelect:u,handleContextMenuAction:d}}var hn=500;function gn(e){let t=(0,a.ref)(null),n=null;function r(){n!==null&&(clearTimeout(n),n=null)}let s=(0,a.shallowRef)(null),c=0,l=null,u=0,d=!1,f=null,p=i.t({pagesContainer:e.pagesRef,onScrollExtendSelection:(e,t)=>{if(!d||f===null)return;let n=_(e,t);n!==null&&n!==f&&y(f,n)}}),m=(0,a.ref)({currentPage:1,totalPages:1,visible:!1}),g=null;function _(t,n){return R(e.pagesRef.value,e.editorView.value,t,n)}function v(){let t=s.value;if(t?.headerFooter&&e.getHfPmView){let n=e.getHfPmView(t.headerFooter);if(n)return n}return e.editorView.value}function y(e,t){let n=v();if(n)try{let r=n.state.doc.resolve(e),i=t===void 0?r:n.state.doc.resolve(t),a=o.TextSelection.between(r,i);n.dispatch(n.state.tr.setSelection(a))}catch{}}function b(t){L(e.pagesRef.value,e.pagesViewportRef.value,t)}function x(t){ne(e.pagesRef.value,t,y,s.value?.position)}function S(t){z(e.pagesRef.value,t,y,s.value?.position)}function C(t){let n=e.editorView.value;if(!n)return;let r=null;if(n.state.doc.descendants((e,n)=>r===null?(e.attrs?.bookmarks)?.some(e=>e.name===t)?(r=n,!1):!0:!1),r!==null){b(r);try{y(Math.min(r+1,n.state.doc.content.size))}catch{y(r)}}}function w(i){if(e.readOnly.value||d)return;let a=e.pagesRef.value;if(!a)return;let o=e.pagesViewportRef.value;if(!o)return;let c=(0,A.detectTableInsertHover)({mouseX:i.clientX,mouseY:i.clientY,pagesContainer:a,target:i.target,hfEditMode:s.value?.position??null});if(!c){n===null&&(n=setTimeout(()=>{t.value=null,n=null},A.TABLE_INSERT_HIDE_DELAY_MS));return}let l=o.getBoundingClientRect();t.value={type:c.type,x:c.clientX-l.left,y:c.clientY-l.top,cellPmPos:c.cellPmPos},r()}function T(n){n.preventDefault(),n.stopPropagation();let r=t.value,i=e.editorView.value;if(!r||!i)return;let a=i.state.tr.setSelection(o.TextSelection.create(i.state.doc,r.cellPmPos+1));i.dispatch(a);let s=e.getCommands(),c=r.type===`row`?s.addRowBelow?.():s.addColumnRight?.();c&&(c(i.state,e=>i.dispatch(e),i),t.value=null,i.focus())}function E(t){let n=t.target?.closest(`a[href]`);if(!n)return;t.preventDefault();let r=n.getAttribute(`href`)||``;if(r.startsWith(`#`)){let e=r.slice(1);e&&C(e);return}let i=v();if(i&&i.state.selection.from!==i.state.selection.to)return;let a=e.pagesViewportRef.value;if(!a)return;let o=a.getBoundingClientRect(),s=n.getBoundingClientRect();e.hyperlinkPopupData.value={href:r,displayText:n.textContent||``,tooltip:n.getAttribute(`title`)||void 0,position:{top:s.bottom-o.top+a.scrollTop+4,left:s.left-o.left+a.scrollLeft}}}function D(t){let n=t.target,r=n.closest(`.layout-page-header`),i=n.closest(`.layout-page-footer`),a=r??i;if(!a)return;let o=r?`header`:`footer`,c=e.getDocument();if(!c?.package)return;let l=c.package.document?.sections?.[0]?.properties??c.package.document?.finalSectionProperties??null,u=o===`header`?l?.headerReferences:l?.footerReferences,d=o===`header`?c.package.headers:c.package.footers,f=(u?.find(e=>e.type===`default`)??u?.find(e=>e.type===`first`)??null)?.rId??null,p=f?d?.get(f)??null:null;if(!p){if(!l)return;let t=`default`,n=`rId_new_${o}_${t}`,r={type:o,hdrFtrType:t,content:[{type:`paragraph`,content:[]}]},i=o===`header`?`headers`:`footers`,a=o===`header`?`headerReferences`:`footerReferences`,s=new Map(c.package[i]??[]);s.set(n,r);let u=c.package.relationships,d=new Set;for(let e of u?.values()??[])e.target&&d.add(e.target);let m=1;for(;d.has(`${o}${m}.xml`);)m++;let h=o===`header`?`http://schemas.openxmlformats.org/officeDocument/2006/relationships/header`:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer`,g=new Map(u);g.set(n,{id:n,type:h,target:`${o}${m}.xml`});let _={type:t,rId:n},v=l&&{...l,[a]:[...l[a]??[],_]},y={...c,package:{...c.package,[i]:s,relationships:g,document:c.package.document?{...c.package.document,sections:c.package.document.sections?.map((e,t)=>t===0?{...e,properties:v??e.properties}:e),finalSectionProperties:c.package.document.finalSectionProperties===l?v:c.package.document.finalSectionProperties}:c.package.document}};f=n,p=r,e.setDocument?.(y),e.syncHfPMs?.(),e.reLayout(),e.emit(`change`,y)}let m=e.pagesViewportRef.value;if(!m)return;let h=a.getBoundingClientRect(),g=m.getBoundingClientRect(),_=e.zoom.value||1;s.value={position:o,rId:f,headerFooter:p,targetRect:{top:(h.top-g.top+m.scrollTop)/_,left:(h.left-g.left+m.scrollLeft)/_,width:h.width/_,height:h.height/_}}}function O(t){let n=e.getDocument(),r=s.value;if(!n?.package||!r)return;let i=r.position===`header`?n.package.headers:n.package.footers;if(!i||!r.rId)return;let a=i.get(r.rId);a&&(a.content=t),e.syncHfPMs?.(),e.reLayout(),e.emit(`change`,n)}function k(){let t=e.getDocument(),n=s.value;if(!t?.package||!n||!n.rId){s.value=null;return}let r=n.position===`header`?`headers`:`footers`,i=n.position===`header`?`headerReferences`:`footerReferences`,a=n.rId,o=new Map(t.package[r]??[]);o.delete(a);let c=e=>({...e,[i]:(e[i]??[]).filter(e=>e.rId!==a)}),l=e=>`sectionProperties`in e&&e.sectionProperties?{...e,sectionProperties:c(e.sectionProperties)}:e,u=t.package.document,d={...t,package:{...t.package,[r]:o,document:u&&{...u,content:u.content.map(l),sections:u.sections?.map(e=>({...e,properties:c(e.properties)})),finalSectionProperties:u.finalSectionProperties?c(u.finalSectionProperties):u.finalSectionProperties}}};s.value=null,e.setDocument?.(d),e.syncHfPMs?.(),e.reLayout(),e.emit(`change`,d)}function j(t){if(t.button!==0||e.imageInteracting.value)return;let n=e.editorView.value;if(!n)return;let r=t.target;s.value&&(r.closest(`.layout-page-header`)||r.closest(`.layout-page-footer`)||r.closest(`.hf-editor`)||(s.value=null,n.focus()));let i=v()??n;if(!e.readOnly.value&&e.tableResize.tryStartResize(t,i))return;let a=(0,h.findImageElement)(r);if(a){t.preventDefault(),t.stopPropagation();let n=Number(a.dataset.pmStart);if(!isNaN(n)){try{i.dispatch(i.state.tr.setSelection(o.NodeSelection.create(i.state.doc,n)))}catch{}e.selectedImage.value={element:a,pmPos:n,width:a.offsetWidth,height:a.offsetHeight},e.clearOverlay()}i.focus();return}e.selectedImage.value=null,t.preventDefault();let p=_(t.clientX,t.clientY);if(p===null){i.focus();return}let m=Date.now();if(m-c<hn&&l===p?u++:u=1,c=m,l=p,u===2)x(p);else if(u>=3)S(p),u=0;else{if(t.shiftKey){let{from:e}=i.state.selection;y(e,p)}else y(p);f=p,d=!0}i.focus()}function M(e){if(!d||f===null)return;let t=_(e.clientX,e.clientY);t!==null&&t!==f&&y(f,t),p.updateMousePosition(e.clientX,e.clientY)}function N(){d=!1,p.stopAutoScroll()}function P(){let t=e.pagesViewportRef.value,n=e.layout.value;if(!t||!n||n.pages.length===0)return;let r=t.scrollTop,i=n.pages.length,a=r+t.clientHeight/2,o=24,s=1;for(let e=0;e<n.pages.length;e++){let t=n.pages[e].size.h,r=o+t;if(a<r){s=e+1;break}o=r+24,s=e+2}s=Math.min(s,i),m.value={currentPage:s,totalPages:i,visible:!0},g&&clearTimeout(g),g=setTimeout(()=>{m.value={...m.value,visible:!1}},600)}return(0,a.onMounted)(()=>{window.addEventListener(`mousemove`,M),window.addEventListener(`mouseup`,N),e.pagesViewportRef.value?.addEventListener(`scroll`,P,{passive:!0})}),(0,a.onBeforeUnmount)(()=>{r(),window.removeEventListener(`mousemove`,M),window.removeEventListener(`mouseup`,N),e.pagesViewportRef.value?.removeEventListener(`scroll`,P),g&&clearTimeout(g)}),{tableInsertButton:t,hfEdit:s,scrollPageInfo:m,resolvePos:_,setPmSelection:y,scrollVisiblePositionIntoView:b,navigateToBookmark:C,handlePagesMouseDown:j,handlePagesMouseMove:w,handlePagesClick:E,handlePagesDoubleClick:D,handleTableInsertClick:T,clearTableInsertTimer:r,handleHfSave:O,handleHfRemove:k}}function _n(e){let t=null,n=null,i=null;function c(){let r=e.pagesRef.value;r&&(r.querySelectorAll(`.vue-sel-rect, .vue-caret`).forEach(e=>e.remove()),t!==null&&(clearInterval(t),t=null),n=null)}function l(){i!==null&&cancelAnimationFrame(i),i=requestAnimationFrame(()=>{i=null;let t=e.pagesRef.value,n=e.editorView.value;if(!t||!n||e.isHfEditing?.value)return;let r=n.state.selection;if(r instanceof o.NodeSelection&&r.node.type.name===`image`){let n=(0,s.findBodyPmAnchor)(t,r.from),i=n?(0,h.findImageElement)(n):null;if(i){let t=e.selectedImage.value;(!t||t.element!==i||t.pmPos!==r.from||t.width!==i.offsetWidth||t.height!==i.offsetHeight)&&(e.selectedImage.value={element:i,pmPos:r.from,width:i.offsetWidth,height:i.offsetHeight});return}}e.imageInteracting?.value||(e.selectedImage.value=null)})}function u(){let i=e.pagesRef.value,a=e.editorView.value;if(!i||!a||(c(),e.isHfEditing?.value))return;l(),(0,s.applyCellSelectionHighlight)(i,a.state);let u=a.state.selection;if(u instanceof o.NodeSelection&&u.node.type.name===`image`)return;let{from:d,to:f,empty:m}=u,h=i.scrollTop,g=i.scrollLeft,_=e.zoom.value||1;if(m){let e=(0,p.getCaretPositionFromDom)(i,d,i.getBoundingClientRect());if(e){let a=document.createElement(`div`);a.className=`vue-caret`,a.style.cssText=`
|
|
2
2
|
position: absolute;
|
|
3
3
|
left: ${e.x/_+g}px;
|
|
4
4
|
top: ${e.y/_+h}px;
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
7
7
|
background: #000;
|
|
8
8
|
pointer-events: none;
|
|
9
9
|
z-index: ${r.t.selectionOverlay};
|
|
10
|
-
`,i.appendChild(a),n=a;let o=!0;t=setInterval(()=>{o=!o,n&&(n.style.opacity=o?`1`:`0`)},530)}return}let v=(0,
|
|
10
|
+
`,i.appendChild(a),n=a;let o=!0;t=setInterval(()=>{o=!o,n&&(n.style.opacity=o?`1`:`0`)},530)}return}let v=(0,p.getSelectionRectsFromDom)(i,d,f,i.getBoundingClientRect());for(let e of v){let t=document.createElement(`div`);t.className=`vue-sel-rect`,t.style.cssText=`
|
|
11
11
|
position: absolute;
|
|
12
12
|
left: ${e.x/_+g}px;
|
|
13
13
|
top: ${e.y/_+h}px;
|
|
@@ -16,4 +16,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
16
16
|
background: rgba(66, 133, 244, 0.3);
|
|
17
17
|
pointer-events: none;
|
|
18
18
|
z-index: ${r.t.selectionOverlay};
|
|
19
|
-
`,i.appendChild(t)}}return(0,a.onBeforeUnmount)(()=>{i!==null&&cancelAnimationFrame(i),c()}),{clearOverlay:c,updateSelectionOverlay:u}}function _n(e){function t(t){let n=e.editorView.value;if(!n)return;let r=e.getCommands()[t];r&&(r()(n.state,e=>n.dispatch(e),n),n.focus())}function n(t,n){let r=e.editorView.value;if(!r)return;let i=e.getCommands().insertTable;i&&(i(t,n)(r.state,e=>r.dispatch(e),r),r.focus())}function r(n){switch(n){case`open`:e.docxInputRef.value?.click(),e.emit(`menu-action`,`open`);break;case`save`:e.emit(`menu-action`,`save`),e.downloadCurrentDocument();break;case`pageSetup`:e.showPageSetup.value=!0;break;case`watermark`:e.showWatermark.value=!0;break;case`clearFormatting`:e.handleClearFormatting();break;case`insertImage`:e.showInsertImage.value=!0;break;case`insertLink`:e.showHyperlink.value=!0;break;case`insertSymbol`:e.showInsertSymbol.value=!0;break;case`insertPageBreak`:e.handleInsertPageBreak();break;case`insertTOC`:t(`generateTOC`);break;case`outline`:e.handleToggleOutline();break;case`sidebar`:e.handleToggleSidebar();break;case`shortcuts`:e.showKeyboardShortcuts.value=!0;break;case`reportIssue`:(0,j.openReportIssue)();break;case`dirLTR`:t(`setLtr`);break;case`dirRTL`:t(`setRtl`);break}}return{handleMenuAction:r,handleMenuTableInsert:n,execSimpleCommand:t}}function vn(e){async function t(t){e.sidebarAutoOpenedRef.value=!1,await e.loadDocumentBuffer(t)}function n(t){e.sidebarAutoOpenedRef.value=!1,e.loadDocument(t)}(0,a.watch)(e.documentBuffer,e=>{e&&t(e)}),(0,a.watch)(e.document,e=>{e&&n(e)}),(0,a.onMounted)(async()=>{await(0,a.nextTick)();let r=e.documentBuffer(),i=e.document();r?await t(r):i&&n(i)})}function yn(e){function t(){let t=e.pagesRef.value;t&&(0,m.renderAllPagesNow)(t),e.onPrint?.(),window.print()}function n(){t()}function r(){return e.zoom.value}function i(t){if(!Number.isInteger(t)||t<1)return;let n=e.pagesViewportRef.value,r=e.pagesRef.value?.querySelector(`[data-page-number="${t}"]`);if(!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect();n.scrollTo({top:a.top-i.top+n.scrollTop-24,behavior:`smooth`})}function a(t){Number.isFinite(t)&&e.scrollVisiblePositionIntoView(t)}function o(){return e.editorView.value?{getDocument:e.getDocument,getView:()=>e.editorView.value,getState:()=>e.editorView.value?.state??null}:null}function s(){return e.layout.value?.pages.length??0}function c(){let t=e.layout.value,n=e.editorView.value;if(!t||!n)return 0;let r=(0,b.findPageIndexContainingPmPos)(t,n.state.selection.from);return r==null?0:r+1}function l(t){let n=e.editorView.value;if(!n)return!1;let r=(0,N.findParaIdRange)(n.state.doc,t);return r?(e.scrollVisiblePositionIntoView(r.from+1),!0):!1}function u(t,n){return(0,ee.findInDocument)(e.editorView.value,t,n)}function d(){return(0,ee.getSelectionInfo)(e.editorView.value)}function f(){return e.comments.value}function p(t){let n=e.editorView.value;return n?(0,g.findContentControlsInPM)(n.state.doc,t??{}):[]}function h(t){let n=e.editorView.value;if(!n)return!1;let r=(0,g.findContentControlPos)(n.state.doc,t);return r==null?!1:(a(r),!0)}function _(t,n,r){let i=e.editorView.value;if(!i)return!1;try{return i.dispatch((0,g.setContentControlContentTr)(i.state,t,n,r)),!0}catch(e){if(e instanceof M.ContentControlNotFoundError)return!1;throw e}}function v(t,n){let r=e.editorView.value;if(!r)return!1;try{return r.dispatch((0,g.removeContentControlTr)(r.state,t,n)),!0}catch(e){if(e instanceof M.ContentControlNotFoundError)return!1;throw e}}function y(t,n,r){let i=e.editorView.value;if(!i)return!1;try{return i.dispatch((0,g.setContentControlValueTr)(i.state,t,n,r)),!0}catch(e){if(e instanceof M.ContentControlNotFoundError)return!1;throw e}}function x(t){return(0,ee.getPageContent)(e.editorView.value,e.layout.value,t)}function S(t){return e.contentChangeSubscribers.add(t),()=>e.contentChangeSubscribers.delete(t)}function C(t){return e.selectionChangeSubscribers.add(t),()=>e.selectionChangeSubscribers.delete(t)}return{exposed:{getAgent:()=>null,save:e.save,setZoom:e.setZoom,getZoom:r,focus:e.focus,scrollToPage:i,scrollToPosition:a,openPrintPreview:n,print:t,loadDocument:e.loadDocument,loadDocumentBuffer:e.loadDocumentBuffer,destroy:e.destroy,getDocument:e.getDocument,getEditorRef:o,addComment:e.addComment,replyToComment:e.replyToComment,resolveComment:e.resolveComment,proposeChange:e.proposeChange,scrollToParaId:l,findInDocument:u,getSelectionInfo:d,getComments:f,getContentControls:p,scrollToContentControl:h,setContentControlContent:_,removeContentControl:v,setContentControlValue:y,applyFormatting:e.applyFormatting,setParagraphStyle:e.setParagraphStyle,getPageContent:x,getTotalPages:s,getCurrentPage:c,onContentChange:S,onSelectionChange:C}}}function bn(e,t){(0,a.watch)(e,e=>{(0,c.loadFontDefinitions)(e)},{immediate:!0});let n=(0,c.onFontError)(t);(0,a.onBeforeUnmount)(()=>n())}var xn={class:`docx-editor-vue__toolbar-shell`},Sn={key:0,class:`docx-editor-vue__error`},Cn={key:1,class:`docx-editor-vue__loading`},wn={class:`docx-editor-vue__editor-area`},Tn={key:0,class:`docx-editor-vue__vertical-ruler`},En=[`title`],Dn=[`title`,`aria-label`],On=(0,a.defineComponent)({__name:`DocxEditor`,props:{documentBuffer:{default:null},document:{default:null},showToolbar:{type:Boolean,default:!0},showMenuBar:{type:Boolean,default:!0},showRuler:{type:Boolean,default:!0},documentName:{default:``},readOnly:{type:Boolean,default:!1},mode:{default:`editing`},onModeChange:{},i18n:{default:void 0},theme:{default:null},externalPlugins:{default:()=>[]},showZoomControl:{type:Boolean,default:!0},initialZoom:{default:1},toolbarExtra:{type:Function,default:void 0},className:{default:``},style:{type:[Boolean,null,String,Object,Array],default:void 0},showOutline:{type:Boolean,default:!1},showOutlineButton:{type:Boolean,default:!0},fontFamilies:{default:void 0},fonts:{},onPrint:{type:Function,default:void 0},disableFindReplaceShortcuts:{type:Boolean,default:!1},renderLogo:{type:Function,default:void 0},onDocumentNameChange:{type:Function,default:void 0},documentNameEditable:{type:Boolean,default:!0},renderTitleBarRight:{type:Function,default:void 0}},emits:[`change`,`update:document`,`error`,`ready`,`rename`,`menu-action`,`mode-change`],setup(n,{expose:r,emit:u}){let d=n,f=u,p=(0,a.ref)(d.mode),m=(0,a.computed)(()=>d.readOnly||p.value===`viewing`);e.u((0,a.computed)(()=>d.i18n));let{t:h}=e.c((0,a.computed)(()=>d.i18n)),v=(0,a.ref)(null),y=(0,a.ref)(null),b=(0,a.ref)(null),x=(0,a.ref)(0),S=new Set,C=new Set,w=new g.LayoutSelectionGate,T=(0,a.ref)(!1),E=(0,a.ref)(!1),D=(0,a.ref)(!1),k=(0,a.ref)(!1),A=(0,a.ref)(!1),j=(0,a.ref)(!1),M=(0,a.ref)(d.showOutline),N=(0,a.ref)(!1),P=(0,a.ref)(!1),F=(0,a.ref)(!1),I=(0,a.ref)(null),L=(0,a.shallowRef)([]),ne=(0,a.shallowRef)([]),re=(0,a.shallowRef)([]),{zoom:R,zoomPercent:ae,isMinZoom:oe,isMaxZoom:se,setZoom:ce,zoomIn:le,zoomOut:ue,handleWheel:de,handleKeyDown:pe,installShortcuts:me,ZOOM_PRESETS:z}=i.r(d.initialZoom);me();let{editorView:B,isReady:he,parseError:V,layout:H,loadBuffer:ve,loadDocument:U,save:be,focus:W,destroy:xe,getDocument:G,getCommands:K,reLayout:Ce,getHfPmView:we,syncHfPMs:Te,setHfTransactionListener:De,setDocument:Oe}=i.i({hiddenContainer:v,pagesContainer:y,readOnly:m,externalPlugins:d.externalPlugins,syncCoordinator:w,editorMode:p,onChange:e=>{f(`change`,e),f(`update:document`,e),S.forEach(t=>t(e))},onError:e=>f(`error`,e),onSelectionUpdate:()=>{x.value++,qn();let e=(0,ee.getSelectionInfo)(B.value);C.forEach(t=>t(e))}}),q=(0,a.computed)(()=>{x.value;let e=G();if(!e?.package?.document)return null;let t=e.package.document;return t.finalSectionProperties??t.sections?.[0]?.properties??null}),ke=(0,a.computed)(()=>{x.value;let e=B.value,t=e?(0,l.extractSelectionContext)(e.state).paragraphFormatting:{};return{indentLeft:t.indentLeft??0,indentRight:t.indentRight??0,firstLineIndent:t.indentFirstLine??0,hangingIndent:t.hangingIndent??!1,tabStops:t.tabs??null}}),Ae=(0,a.computed)(()=>(x.value,G()?.package?.theme??d.theme??null)),J=(0,a.ref)(null),je=(0,a.ref)([]);function Me(e,t){J.value=(0,s.computeHfCaretRectFromView)(e,t),je.value=(0,s.computeHfSelectionRectsFromView)(e,t)}function Ne(){J.value=null,je.value=[]}bn(()=>d.fonts,e=>f(`error`,e));let Pe=(0,a.computed)(()=>Q.value?.headerFooter?we(Q.value.headerFooter)??null:null);(0,a.onMounted)(()=>{De((e,t)=>{requestAnimationFrame(()=>{let e=Q.value;if(!e)return;Me(t,e.position);let n=te(e.position),r=b.value;if(!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect(),o=R.value||1;Q.value={...e,targetRect:{top:(i.top-a.top+r.scrollTop)/o,left:(i.left-a.left+r.scrollLeft)/o,width:i.width/o,height:i.height/o}}})}),(0,a.watch)(()=>Q.value,e=>{if(!e){Ne();return}let t=B.value;if(t){try{let e=t.state.tr.setSelection(o.TextSelection.create(t.state.doc,0));t.dispatch(e)}catch{}t.dom.blur?.()}Jn.updateSelectionOverlay()});let e=0;function t(){!Q.value||e||(e=requestAnimationFrame(()=>{e=0;let t=Q.value;if(!t?.headerFooter)return;let n=we(t.headerFooter);n&&Me(n,t.position)}))}window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),(0,a.onBeforeUnmount)(()=>{e&&cancelAnimationFrame(e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)})});let Fe=(0,a.computed)(()=>{let e=[];return P.value&&e.push(`translateX(-${c.SIDEBAR_DOCUMENT_SHIFT}px)`),R.value!==1&&e.push(`scale(${R.value})`),{transform:e.length>0?e.join(` `):void 0,transformOrigin:`top center`,transition:`transform 0.2s ease`}}),Ie=(0,a.computed)(()=>({paddingLeft:`20px`,paddingRight:20+(P.value?c.SIDEBAR_DOCUMENT_SHIFT*2:0)+`px`,transition:`padding 0.2s ease`})),Le=(0,a.computed)(()=>{let e=q.value;return(0,_.twipsToPixels)(e?.pageWidth??12240)*R.value}),Re=(0,a.computed)(()=>{let e=new Set;for(let t of L.value)t.parentId==null&&t.done&&e.add(t.id);return e}),ze=(0,a.computed)(()=>{x.value;let e=B.value;if(!e)return[];let t=new Set,n=[];return e.state.doc.descendants(e=>{let r=e.attrs?.bookmarks;if(!r)return!0;for(let e of r){let r=e.name;!r||r.startsWith(`_`)||t.has(r)||(t.add(r),n.push({name:r,label:r}))}return!0}),n.sort((e,t)=>e.name.localeCompare(t.name))}),Be=(0,O.createCommentIdAllocator)(),{floatingCommentBtn:Ve,pendingCommentRange:He,addCommentYPosition:Ue,sidebarAutoOpenedRef:We,extractCommentsAndChanges:Ge,handleAddComment:Ke,handleCancelAddComment:qe,handleStartAddComment:Je,handleMarkerClick:Ye}=sn({editorView:B,getDocument:G,comments:L,trackedChanges:ne,resolvedCommentIds:Re,activeSidebarItem:I,showSidebar:P,isAddingComment:F,readOnly:m,zoom:R,stateTick:x,pagesRef:y,pagesViewportRef:b,emit:f,commentIdAllocator:Be}),{docxInputRef:Xe,handleDocxFileChange:Ze,handleDocumentNameChange:Qe,downloadCurrentDocument:$e,loadDocumentBuffer:et,loadDocument:tt,save:nt}=Qt({loadBuffer:ve,loadParsedDocument:U,getDocument:G,saveBlob:be,extractCommentsAndChanges:Ge,emit:f,documentName:()=>d.documentName,onDocumentNameChange:d.onDocumentNameChange,nextTick:a.nextTick}),{hyperlinkPopupData:rt,handleHyperlinkSubmit:it,handleHyperlinkRemove:at,handleHyperlinkPopupNavigate:ot,handleHyperlinkPopupEdit:st,handleHyperlinkPopupRemove:ct}=$t({editorView:B,getCommands:K}),{handleClearFormatting:lt,handleApplyStyle:ut,handleInsertPageBreak:dt,handleInsertSymbol:ft,applyFormatting:pt,setParagraphStyle:mt}=en({editorView:B,getDocument:G}),{handlePageSetupApply:ht,handleLeftMarginChange:_t,handleRightMarginChange:vt,handleTopMarginChange:yt,handleBottomMarginChange:bt,handleIndentLeftChange:xt,handleIndentRightChange:St,handleFirstLineIndentChange:Ct,handleTabStopRemove:wt}=tn({editorView:B,getDocument:G,readOnly:m,stateTick:x,reLayout:Ce,emit:f}),{showWatermark:Tt,currentWatermark:Et,handleWatermarkApply:Dt}=nn({editorView:B,readOnly:m,stateTick:x}),{handleToggleOutline:Ot,handleOutlineNavigate:kt,handleToggleSidebar:At,handleEditorScrollMouseDown:jt}=rn({editorView:B,showOutline:M,showSidebar:P,outlineHeadings:re,activeSidebarItem:I,extractCommentsAndChanges:Ge});an({showKeyboardShortcuts:N,showFindReplace:T,showHyperlink:D,handleZoomKeyDown:pe,disableFindReplaceShortcuts:()=>d.disableFindReplaceShortcuts});let{addComment:Mt,replyToComment:Nt,resolveComment:Pt,proposeChange:Ft,handleCommentReply:It,handleCommentUnresolve:Lt,handleCommentDelete:Rt,handleAcceptChange:Y,handleRejectChange:zt,handleAcceptChangeById:Bt,handleRejectChangeById:Ht,handleTrackedChangeReply:Ut}=on({editorView:B,getDocument:G,comments:L,trackedChanges:ne,showSidebar:P,isAddingComment:F,pendingCommentRange:He,contentChangeSubscribers:S,extractCommentsAndChanges:Ge,emit:f,commentIdAllocator:Be}),{selectedImage:X,imageInteracting:Wt,imageToolbarContext:Gt,handleInsertImage:Kt,handleToolbarImageWrap:qt,handleImageTransform:Jt}=cn({editorView:B,zoom:R,stateTick:x,getCommands:K}),Yt=i.n(),Xt=null,{tableInsertButton:Z,hfEdit:Q,scrollPageInfo:$,resolvePos:ln,setPmSelection:un,scrollVisiblePositionIntoView:dn,handlePagesMouseDown:fn,handlePagesMouseMove:mn,handlePagesClick:On,handlePagesDoubleClick:kn,handleTableInsertClick:An,clearTableInsertTimer:jn,handleHfSave:Mn,handleHfRemove:Nn}=hn({editorView:B,pagesRef:y,pagesViewportRef:b,selectedImage:X,imageInteracting:Wt,hyperlinkPopupData:rt,readOnly:m,zoom:R,layout:H,tableResize:Yt,getCommands:K,getDocument:G,reLayout:Ce,emit:f,clearOverlay:Kn,syncHfPMs:Te,getHfPmView:we,setDocument:Oe}),{contextMenu:Pn,imageContextMenu:Fn,imageContextMenuTextActions:In,handleContextMenu:Ln,handleSelectedImageContextMenu:Rn,handleImageWrapSelect:zn,handleContextMenuAction:Bn}=pn({editorView:B,selectedImage:X,zoom:R,showImageProperties:A,getCommands:K,clearOverlay:Kn,setPmSelection:un,resolvePos:ln}),{handleMenuAction:Vn,handleMenuTableInsert:Hn}=_n({editorView:B,getCommands:K,docxInputRef:Xe,showPageSetup:j,showWatermark:Tt,showInsertImage:E,showHyperlink:D,showInsertSymbol:k,showKeyboardShortcuts:N,handleClearFormatting:lt,handleInsertPageBreak:dt,handleToggleOutline:Ot,handleToggleSidebar:At,downloadCurrentDocument:$e,emit:f});vn({documentBuffer:()=>d.documentBuffer,document:()=>d.document,loadDocumentBuffer:et,loadDocument:tt,sidebarAutoOpenedRef:We});let Un=()=>B.value,Wn=()=>y.value;(0,a.watch)(()=>d.mode,e=>{e&&e!==p.value&&(p.value=e)}),(0,a.watch)(()=>d.showOutline,e=>{M.value=!!e});function Gn(e){p.value!==e&&(p.value=e,f(`mode-change`,e))}(0,a.onMounted)(()=>{Xt=Yt.install()}),(0,a.onBeforeUnmount)(()=>{Xt?.()});function Kn(){Jn.clearOverlay()}function qn(){Jn.updateSelectionOverlay()}let Jn=gn({editorView:B,pagesRef:y,zoom:R,selectedImage:X,isHfEditing:(0,a.computed)(()=>Q.value!==null),imageInteracting:Wt});(0,a.onBeforeUnmount)(()=>{Kn()});let{exposed:Yn}=yn({editorView:B,layout:H,pagesRef:y,pagesViewportRef:b,zoom:R,comments:L,focus:W,destroy:xe,getDocument:G,setZoom:ce,save:nt,loadDocument:tt,loadDocumentBuffer:et,addComment:Mt,replyToComment:Nt,resolveComment:Pt,proposeChange:Ft,applyFormatting:pt,setParagraphStyle:mt,scrollVisiblePositionIntoView:dn,contentChangeSubscribers:S,selectionChangeSubscribers:C,onPrint:d.onPrint});return r(Yn),(r,i)=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{class:(0,a.normalizeClass)([`docx-editor-vue ep-root paged-editor`,n.className,{"paged-editor--readonly":m.value,"paged-editor--hf-editing":(0,a.unref)(Q)!==null,"paged-editor--editing-header":(0,a.unref)(Q)?.position===`header`,"paged-editor--editing-footer":(0,a.unref)(Q)?.position===`footer`}]),style:(0,a.normalizeStyle)(n.style)},[(0,a.createElementVNode)(`div`,xn,[(0,a.createVNode)(Ee,{"show-menu-bar":n.showMenuBar,"document-name":n.documentName,"document-name-editable":n.documentNameEditable,"render-logo":n.renderLogo,"render-title-bar-right":n.renderTitleBarRight,onRename:(0,a.unref)(Qe),onMenuAction:(0,a.unref)(Vn),onInsertTable:(0,a.unref)(Hn)},{"title-bar-left":(0,a.withCtx)(()=>[(0,a.renderSlot)(r.$slots,`title-bar-left`)]),"title-bar-right":(0,a.withCtx)(()=>[(0,a.renderSlot)(r.$slots,`title-bar-right`)]),_:3},8,[`show-menu-bar`,`document-name`,`document-name-editable`,`render-logo`,`render-title-bar-right`,`onRename`,`onMenuAction`,`onInsertTable`]),n.showToolbar?((0,a.openBlock)(),(0,a.createBlock)(t.x,{key:0,view:(0,a.unref)(B),"get-commands":(0,a.unref)(K),"state-tick":x.value,"zoom-percent":(0,a.unref)(ae),"is-min-zoom":(0,a.unref)(oe),"is-max-zoom":(0,a.unref)(se),"zoom-presets":(0,a.unref)(z),"show-zoom-control":n.showZoomControl,"editor-mode":p.value,"comments-sidebar-open":P.value,"image-context":(0,a.unref)(Gt),theme:Ae.value,"font-families":n.fontFamilies,onInsertLink:i[0]||=e=>D.value=!0,onApplyStyle:(0,a.unref)(ut),onZoomIn:(0,a.unref)(le),onZoomOut:(0,a.unref)(ue),onZoomSet:(0,a.unref)(ce),onToggleSidebar:(0,a.unref)(At),onModeChange:Gn,onImageWrapType:(0,a.unref)(qt),onImageProperties:i[1]||=e=>A.value=!0,onImageTransform:(0,a.unref)(Jt)},(0,a.createSlots)({"table-context":(0,a.withCtx)(()=>[(0,a.createVNode)(t.h,{view:(0,a.unref)(B),"get-commands":(0,a.unref)(K),"state-tick":x.value,theme:Ae.value},null,8,[`view`,`get-commands`,`state-tick`,`theme`])]),_:2},[n.toolbarExtra?{name:`toolbar-extra`,fn:(0,a.withCtx)(()=>[((0,a.openBlock)(),(0,a.createBlock)((0,a.resolveDynamicComponent)(n.toolbarExtra)))]),key:`0`}:{name:`toolbar-extra`,fn:(0,a.withCtx)(()=>[(0,a.renderSlot)(r.$slots,`toolbar-extra`)]),key:`1`}]),1032,[`view`,`get-commands`,`state-tick`,`zoom-percent`,`is-min-zoom`,`is-max-zoom`,`zoom-presets`,`show-zoom-control`,`editor-mode`,`comments-sidebar-open`,`image-context`,`theme`,`font-families`,`onApplyStyle`,`onZoomIn`,`onZoomOut`,`onZoomSet`,`onToggleSidebar`,`onImageWrapType`,`onImageTransform`])):(0,a.createCommentVNode)(``,!0)]),(0,a.createVNode)(gt,{"show-find-replace":T.value,"onUpdate:showFindReplace":i[2]||=e=>T.value=e,"show-insert-image":E.value,"onUpdate:showInsertImage":i[3]||=e=>E.value=e,"show-hyperlink":D.value,"onUpdate:showHyperlink":i[4]||=e=>D.value=e,"show-insert-symbol":k.value,"onUpdate:showInsertSymbol":i[5]||=e=>k.value=e,"show-image-properties":A.value,"onUpdate:showImageProperties":i[6]||=e=>A.value=e,"show-page-setup":j.value,"onUpdate:showPageSetup":i[7]||=e=>j.value=e,"show-watermark":(0,a.unref)(Tt),"onUpdate:showWatermark":i[8]||=e=>(0,a.isRef)(Tt)?Tt.value=e:null,"show-keyboard-shortcuts":N.value,"onUpdate:showKeyboardShortcuts":i[9]||=e=>N.value=e,view:(0,a.unref)(B),bookmarks:ze.value,"selected-image-pm-pos":(0,a.unref)(X)?.pmPos??null,"section-properties":q.value,"current-watermark":(0,a.unref)(Et),"scroll-visible-position-into-view":(0,a.unref)(dn),onInsertImage:(0,a.unref)(Kt),onInsertSymbol:(0,a.unref)(ft),onHyperlinkSubmit:(0,a.unref)(it),onHyperlinkRemove:(0,a.unref)(at),onPageSetupApply:(0,a.unref)(ht),onWatermarkApply:(0,a.unref)(Dt)},null,8,[`show-find-replace`,`show-insert-image`,`show-hyperlink`,`show-insert-symbol`,`show-image-properties`,`show-page-setup`,`show-watermark`,`show-keyboard-shortcuts`,`view`,`bookmarks`,`selected-image-pm-pos`,`section-properties`,`current-watermark`,`scroll-visible-position-into-view`,`onInsertImage`,`onInsertSymbol`,`onHyperlinkSubmit`,`onHyperlinkRemove`,`onPageSetupApply`,`onWatermarkApply`]),(0,a.unref)(V)?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Sn,(0,a.toDisplayString)((0,a.unref)(V)),1)):(0,a.createCommentVNode)(``,!0),!(0,a.unref)(he)&&!(0,a.unref)(V)?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Cn,`Loading...`)):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,{ref_key:`hiddenPmRef`,ref:v,class:`docx-editor-vue__hidden-pm paged-editor__hidden-pm`},null,512),(0,a.createElementVNode)(`div`,{class:`docx-editor-vue__editor-scroll`,onMousedown:i[32]||=(...e)=>(0,a.unref)(jt)&&(0,a.unref)(jt)(...e)},[n.showRuler&&q.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`docx-editor-vue__ruler-row`,style:(0,a.normalizeStyle)(Ie.value)},[(0,a.createVNode)(t.o,{"section-props":q.value,zoom:(0,a.unref)(R),editable:!m.value,"indent-left":ke.value.indentLeft,"indent-right":ke.value.indentRight,"first-line-indent":ke.value.firstLineIndent,"hanging-indent":ke.value.hangingIndent,"tab-stops":ke.value.tabStops,onLeftMarginChange:(0,a.unref)(_t),onRightMarginChange:(0,a.unref)(vt),onIndentLeftChange:(0,a.unref)(xt),onIndentRightChange:(0,a.unref)(St),onFirstLineIndentChange:(0,a.unref)(Ct),onTabStopRemove:(0,a.unref)(wt)},null,8,[`section-props`,`zoom`,`editable`,`indent-left`,`indent-right`,`first-line-indent`,`hanging-indent`,`tab-stops`,`onLeftMarginChange`,`onRightMarginChange`,`onIndentLeftChange`,`onIndentRightChange`,`onFirstLineIndentChange`,`onTabStopRemove`])],4)):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,wn,[(0,a.createElementVNode)(`div`,{ref_key:`pagesViewportRef`,ref:b,class:`docx-editor-vue__pages-viewport`,onMousedown:i[23]||=(...e)=>(0,a.unref)(fn)&&(0,a.unref)(fn)(...e),onMousemove:i[24]||=(...e)=>(0,a.unref)(mn)&&(0,a.unref)(mn)(...e),onClick:i[25]||=(...e)=>(0,a.unref)(On)&&(0,a.unref)(On)(...e),onDblclick:i[26]||=(...e)=>(0,a.unref)(kn)&&(0,a.unref)(kn)(...e),onContextmenu:i[27]||=(0,a.withModifiers)((...e)=>(0,a.unref)(Ln)&&(0,a.unref)(Ln)(...e),[`prevent`]),onWheel:i[28]||=(...e)=>(0,a.unref)(de)&&(0,a.unref)(de)(...e)},[n.showRuler&&q.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Tn,[(0,a.createVNode)(t.a,{"section-props":q.value,zoom:(0,a.unref)(R),editable:!m.value,onTopMarginChange:(0,a.unref)(yt),onBottomMarginChange:(0,a.unref)(bt)},null,8,[`section-props`,`zoom`,`editable`,`onTopMarginChange`,`onBottomMarginChange`])])):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,{ref_key:`pagesRef`,ref:y,class:`docx-editor-vue__pages paged-editor__pages`,style:(0,a.normalizeStyle)(Fe.value)},null,4),m.value?(0,a.createCommentVNode)(``,!0):((0,a.openBlock)(),(0,a.createBlock)(Se,{key:1,container:y.value,view:(0,a.unref)(B)},null,8,[`container`,`view`])),(0,a.createVNode)(ye,{"is-open":(0,a.unref)(Q)!==null,position:(0,a.unref)(Q)?.position??`header`,view:Pe.value,"target-rect":(0,a.unref)(Q)?.targetRect??null,onSave:(0,a.unref)(Mn),onClose:i[10]||=e=>Q.value=null,onRemove:(0,a.unref)(Nn)},null,8,[`is-open`,`position`,`view`,`target-rect`,`onSave`,`onRemove`]),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)((0,a.unref)(Q)?je.value:[],(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:`hf-sel-${t}-${e.top}-${e.left}`,class:`vue-hf-sel-rect`,"aria-hidden":`true`,style:(0,a.normalizeStyle)({position:`fixed`,top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`,background:`rgba(66, 133, 244, 0.25)`,pointerEvents:`none`,zIndex:9998})},null,4))),128)),(0,a.unref)(Q)&&J.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:2,"aria-hidden":`true`,style:(0,a.normalizeStyle)({position:`fixed`,top:`${J.value.top}px`,left:`${J.value.left}px`,width:`2px`,height:`${J.value.height}px`,background:`#4285f4`,pointerEvents:`none`,zIndex:9999,animation:`hf-caret-blink 1.06s steps(1) infinite`})},null,4)):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(fe,{"image-info":(0,a.unref)(X),zoom:(0,a.unref)(R),view:(0,a.unref)(B),onOpenProperties:i[11]||=e=>A.value=!0,onDeselect:i[12]||=e=>X.value=null,onInteractStart:i[13]||=e=>Wt.value=!0,onInteractEnd:i[14]||=e=>Wt.value=!1,onContextMenu:(0,a.unref)(Rn)},null,8,[`image-info`,`zoom`,`view`,`onContextMenu`]),(0,a.createVNode)(ie,{"get-view":Un,"get-pages-container":Wn,zoom:(0,a.unref)(R),"transaction-version":x.value,"sync-coordinator":(0,a.unref)(w)},null,8,[`zoom`,`transaction-version`,`sync-coordinator`]),(0,a.unref)(Ve)&&!F.value&&!m.value?((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:3,type:`button`,class:`docx-editor-vue__floating-comment`,style:(0,a.normalizeStyle)({top:(0,a.unref)(Ve).top+`px`,left:(0,a.unref)(Ve).left+`px`}),title:(0,a.unref)(h)(`comments.addComment`),onMousedown:i[15]||=(0,a.withModifiers)((...e)=>(0,a.unref)(Je)&&(0,a.unref)(Je)(...e),[`prevent`,`stop`])},[(0,a.createVNode)(e.p,{name:`add_comment`,size:16})],44,En)):(0,a.createCommentVNode)(``,!0),(0,a.unref)(Z)&&!m.value?((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:4,type:`button`,class:`docx-editor-vue__table-insert-btn`,style:(0,a.normalizeStyle)({left:(0,a.unref)(Z).x+`px`,top:(0,a.unref)(Z).y+`px`}),title:(0,a.unref)(Z).type===`row`?`Insert row below`:`Insert column to the right`,"aria-label":(0,a.unref)(Z).type===`row`?`Insert row below`:`Insert column to the right`,onMousedown:i[16]||=(...e)=>(0,a.unref)(An)&&(0,a.unref)(An)(...e),onMouseenter:i[17]||=(...e)=>(0,a.unref)(jn)&&(0,a.unref)(jn)(...e),onMouseleave:i[18]||=e=>Z.value=null},[...i[37]||=[(0,a.createElementVNode)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`},[(0,a.createElementVNode)(`path`,{d:`M6 1v10M1 6h10`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`})],-1)]],44,Dn)):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(t.s,{comments:L.value,"pages-container":y.value,zoom:(0,a.unref)(R),"page-width-px":Le.value,"sidebar-open":P.value,"resolved-comment-ids":Re.value,onMarkerClick:(0,a.unref)(Ye)},null,8,[`comments`,`pages-container`,`zoom`,`page-width-px`,`sidebar-open`,`resolved-comment-ids`,`onMarkerClick`]),(0,a.createVNode)(t.c,{"is-open":P.value,comments:L.value,"tracked-changes":ne.value,"is-adding-comment":F.value,"add-comment-y-position":(0,a.unref)(Ue),"show-resolved":!0,"pages-container":y.value,"page-width-px":Le.value,zoom:(0,a.unref)(R),"active-item-id":I.value,onClose:i[19]||=e=>P.value=!1,onAddComment:(0,a.unref)(Ke),onCancelAddComment:(0,a.unref)(qe),onCommentReply:(0,a.unref)(It),onCommentResolve:(0,a.unref)(Pt),onCommentUnresolve:(0,a.unref)(Lt),onCommentDelete:(0,a.unref)(Rt),onAcceptChange:(0,a.unref)(Y),onRejectChange:(0,a.unref)(zt),onAcceptChangeById:(0,a.unref)(Bt),onRejectChangeById:(0,a.unref)(Ht),onTrackedChangeReply:(0,a.unref)(Ut),"onUpdate:activeItemId":i[20]||=e=>I.value=e},null,8,[`is-open`,`comments`,`tracked-changes`,`is-adding-comment`,`add-comment-y-position`,`pages-container`,`page-width-px`,`zoom`,`active-item-id`,`onAddComment`,`onCancelAddComment`,`onCommentReply`,`onCommentResolve`,`onCommentUnresolve`,`onCommentDelete`,`onAcceptChange`,`onRejectChange`,`onAcceptChangeById`,`onRejectChangeById`,`onTrackedChangeReply`]),(0,a.createVNode)(Zt,{data:(0,a.unref)(rt),"read-only":m.value,onNavigate:(0,a.unref)(ot),onCopy:i[21]||=e=>rt.value=null,onEdit:(0,a.unref)(st),onRemove:(0,a.unref)(ct),onClose:i[22]||=e=>rt.value=null},null,8,[`data`,`read-only`,`onNavigate`,`onEdit`,`onRemove`])],544),!M.value&&n.showOutlineButton?((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:0,type:`button`,class:`docx-editor-vue__outline-toggle`,title:`Show document outline`,onClick:i[29]||=(...e)=>(0,a.unref)(Ot)&&(0,a.unref)(Ot)(...e),onMousedown:i[30]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createVNode)(e.p,{name:`format_list_bulleted`,size:20})],32)):(0,a.createCommentVNode)(``,!0),(0,a.unref)($).totalPages>1?((0,a.openBlock)(),(0,a.createBlock)(_e,{key:1,"current-page":(0,a.unref)($).currentPage,"total-pages":(0,a.unref)($).totalPages,visible:(0,a.unref)($).visible},null,8,[`current-page`,`total-pages`,`visible`])):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(ge,{"is-open":M.value,headings:re.value,onClose:i[31]||=e=>M.value=!1,onNavigate:(0,a.unref)(kt)},null,8,[`is-open`,`headings`,`onNavigate`])])],32),(0,a.createElementVNode)(`input`,{ref_key:`docxInputRef`,ref:Xe,type:`file`,accept:`.docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document`,style:{display:`none`},onChange:i[33]||=(...e)=>(0,a.unref)(Ze)&&(0,a.unref)(Ze)(...e)},null,544),(0,a.createVNode)(Vt,{"read-only":m.value,"context-menu":(0,a.unref)(Pn),"image-context-menu":(0,a.unref)(Fn),"image-context-menu-text-actions":(0,a.unref)(In),"can-open-image-properties":!!(0,a.unref)(X),onContextMenuAction:(0,a.unref)(Bn),onCloseContextMenu:i[34]||=e=>(0,a.unref)(Pn).isOpen=!1,onImageWrapSelect:(0,a.unref)(zn),onCloseImageContextMenu:i[35]||=e=>Fn.value=null,onOpenImageProperties:i[36]||=e=>A.value=!0},null,8,[`read-only`,`context-menu`,`image-context-menu`,`image-context-menu-text-actions`,`can-open-image-properties`,`onContextMenuAction`,`onImageWrapSelect`])],6))}});async function kn(e,t,n={}){let r=e instanceof ArrayBuffer?e:await(0,c.toArrayBuffer)(e),i=null,o=null,s=!1,l={save:async()=>{let e=await(i?.save()??Promise.resolve(null));return e?new Blob([e],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`}):null},getDocument:()=>i?.getDocument()??null,focus:()=>{i?.focus()},setZoom:e=>{i?.setZoom(e)},scrollToParaId:e=>i?.scrollToParaId(e)??!1,scrollToPosition:e=>{i?.scrollToPosition(e)},destroy:()=>{i?.destroy(),o?.unmount(),o=null}};return new Promise((e,c)=>{o=(0,a.createApp)({setup(){return()=>(0,a.h)(On,{...n,documentBuffer:r,showToolbar:n.showToolbar??!0,readOnly:n.readOnly??!1,ref:e=>{i=e??null},onReady:()=>{n.onReady?.(),s||(s=!0,e(l))},onError:e=>{n.onError?.(e),s||(s=!0,c(e))},onChange:n.onChange,onRename:n.onRename,onMenuAction:n.onMenuAction,onModeChange:n.onModeChange})}}),o.mount(t)})}var An=`0.0.2`;exports.DocxEditor=On,exports.VERSION=An,Object.defineProperty(exports,`createDocumentWithText`,{enumerable:!0,get:function(){return P.createDocumentWithText}}),Object.defineProperty(exports,`createEmptyDocument`,{enumerable:!0,get:function(){return P.createEmptyDocument}}),exports.defaultLocale=e.f,exports.i18nPlugin=e.l,exports.provideLocale=e.u,exports.renderAsync=kn,exports.useTranslation=e.d;
|
|
19
|
+
`,i.appendChild(t)}}return(0,a.onBeforeUnmount)(()=>{i!==null&&cancelAnimationFrame(i),c()}),{clearOverlay:c,updateSelectionOverlay:u}}function vn(e){function t(t){let n=e.editorView.value;if(!n)return;let r=e.getCommands()[t];r&&(r()(n.state,e=>n.dispatch(e),n),n.focus())}function n(t,n){let r=e.editorView.value;if(!r)return;let i=e.getCommands().insertTable;i&&(i(t,n)(r.state,e=>r.dispatch(e),r),r.focus())}function r(n){switch(n){case`open`:e.docxInputRef.value?.click(),e.emit(`menu-action`,`open`);break;case`save`:e.emit(`menu-action`,`save`),e.downloadCurrentDocument();break;case`pageSetup`:e.showPageSetup.value=!0;break;case`watermark`:e.showWatermark.value=!0;break;case`clearFormatting`:e.handleClearFormatting();break;case`insertImage`:e.showInsertImage.value=!0;break;case`insertLink`:e.showHyperlink.value=!0;break;case`insertSymbol`:e.showInsertSymbol.value=!0;break;case`insertPageBreak`:e.handleInsertPageBreak();break;case`insertTOC`:t(`generateTOC`);break;case`outline`:e.handleToggleOutline();break;case`sidebar`:e.handleToggleSidebar();break;case`shortcuts`:e.showKeyboardShortcuts.value=!0;break;case`reportIssue`:(0,j.openReportIssue)();break;case`dirLTR`:t(`setLtr`);break;case`dirRTL`:t(`setRtl`);break}}return{handleMenuAction:r,handleMenuTableInsert:n,execSimpleCommand:t}}function yn(e){async function t(t){e.sidebarAutoOpenedRef.value=!1,await e.loadDocumentBuffer(t)}function n(t){e.sidebarAutoOpenedRef.value=!1,e.loadDocument(t)}(0,a.watch)(e.documentBuffer,e=>{e&&t(e)}),(0,a.watch)(e.document,e=>{e&&n(e)}),(0,a.onMounted)(async()=>{await(0,a.nextTick)();let r=e.documentBuffer(),i=e.document();r?await t(r):i&&n(i)})}function bn(e){function t(){let t=e.pagesRef.value;t&&(0,h.renderAllPagesNow)(t),e.onPrint?.(),window.print()}function n(){t()}function r(){return e.zoom.value}function i(t){if(!Number.isInteger(t)||t<1)return;let n=e.pagesViewportRef.value,r=e.pagesRef.value?.querySelector(`[data-page-number="${t}"]`);if(!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect();n.scrollTo({top:a.top-i.top+n.scrollTop-24,behavior:`smooth`})}function a(t){Number.isFinite(t)&&e.scrollVisiblePositionIntoView(t)}function o(){return e.editorView.value?{getDocument:e.getDocument,getView:()=>e.editorView.value,getState:()=>e.editorView.value?.state??null}:null}function s(){return e.layout.value?.pages.length??0}function l(){let t=e.layout.value,n=e.editorView.value;if(!t||!n)return 0;let r=(0,b.findPageIndexContainingPmPos)(t,n.state.selection.from);return r==null?0:r+1}function u(t){let n=e.editorView.value;if(!n)return!1;let r=(0,N.findParaIdRange)(n.state.doc,t);return r?(e.scrollVisiblePositionIntoView(r.from+1),!0):!1}function d(t,n){return(0,ee.findInDocument)(e.editorView.value,t,n)}function f(){return(0,ee.getSelectionInfo)(e.editorView.value)}function p(){return e.comments.value}function m(t){let n=e.editorView.value;return n?(0,c.findContentControlsInPM)(n.state.doc,t??{}):[]}function g(t){let n=e.editorView.value;if(!n)return!1;let r=(0,c.findContentControlPos)(n.state.doc,t);return r==null?!1:(a(r),!0)}function _(t,n,r){let i=e.editorView.value;if(!i)return!1;try{return i.dispatch((0,c.setContentControlContentTr)(i.state,t,n,r)),!0}catch(e){if(e instanceof M.ContentControlNotFoundError)return!1;throw e}}function v(t,n){let r=e.editorView.value;if(!r)return!1;try{return r.dispatch((0,c.removeContentControlTr)(r.state,t,n)),!0}catch(e){if(e instanceof M.ContentControlNotFoundError)return!1;throw e}}function y(t,n,r){let i=e.editorView.value;if(!i)return!1;try{return i.dispatch((0,c.setContentControlValueTr)(i.state,t,n,r)),!0}catch(e){if(e instanceof M.ContentControlNotFoundError)return!1;throw e}}function x(t){return(0,ee.getPageContent)(e.editorView.value,e.layout.value,t)}function S(t){return e.contentChangeSubscribers.add(t),()=>e.contentChangeSubscribers.delete(t)}function C(t){return e.selectionChangeSubscribers.add(t),()=>e.selectionChangeSubscribers.delete(t)}return{exposed:{getAgent:()=>null,save:e.save,setZoom:e.setZoom,getZoom:r,focus:e.focus,scrollToPage:i,scrollToPosition:a,openPrintPreview:n,print:t,loadDocument:e.loadDocument,loadDocumentBuffer:e.loadDocumentBuffer,destroy:e.destroy,getDocument:e.getDocument,getEditorRef:o,addComment:e.addComment,replyToComment:e.replyToComment,resolveComment:e.resolveComment,proposeChange:e.proposeChange,scrollToParaId:u,findInDocument:d,getSelectionInfo:f,getComments:p,getContentControls:m,scrollToContentControl:g,setContentControlContent:_,removeContentControl:v,setContentControlValue:y,applyFormatting:e.applyFormatting,setParagraphStyle:e.setParagraphStyle,getPageContent:x,getTotalPages:s,getCurrentPage:l,onContentChange:S,onSelectionChange:C}}}function xn(e,t){(0,a.watch)(e,e=>{(0,l.loadFontDefinitions)(e)},{immediate:!0});let n=(0,l.onFontError)(t);(0,a.onBeforeUnmount)(()=>n())}var Sn={class:`docx-editor-vue__toolbar-shell`},Cn={key:0,class:`docx-editor-vue__error`},wn={key:1,class:`docx-editor-vue__loading`},Tn={class:`docx-editor-vue__editor-area`},En={key:0,class:`docx-editor-vue__vertical-ruler`},Dn=[`title`],On=[`title`,`aria-label`],kn=(0,a.defineComponent)({__name:`DocxEditor`,props:{documentBuffer:{default:null},document:{default:null},showToolbar:{type:Boolean,default:!0},showMenuBar:{type:Boolean,default:!0},showRuler:{type:Boolean,default:!0},documentName:{default:``},readOnly:{type:Boolean,default:!1},author:{default:`User`},mode:{default:`editing`},onModeChange:{},i18n:{default:void 0},theme:{default:null},externalPlugins:{default:()=>[]},showZoomControl:{type:Boolean,default:!0},initialZoom:{default:1},toolbarExtra:{type:Function,default:void 0},className:{default:``},style:{type:[Boolean,null,String,Object,Array],default:void 0},showOutline:{type:Boolean,default:!1},showOutlineButton:{type:Boolean,default:!0},fontFamilies:{default:void 0},fonts:{},onPrint:{type:Function,default:void 0},disableFindReplaceShortcuts:{type:Boolean,default:!1},renderLogo:{type:Function,default:void 0},onDocumentNameChange:{type:Function,default:void 0},documentNameEditable:{type:Boolean,default:!0},renderTitleBarRight:{type:Function,default:void 0},onChange:{},onError:{},onSelectionChange:{},onEditorViewReady:{},onCommentAdd:{},onCommentResolve:{},onCommentDelete:{},onCommentReply:{},onCommentsChange:{}},emits:[`change`,`update:document`,`error`,`ready`,`rename`,`menu-action`,`mode-change`],setup(n,{expose:r,emit:d}){let f=n,p=d,m=(0,a.ref)(f.mode),h=(0,a.computed)(()=>f.readOnly||m.value===`viewing`),g=(0,a.computed)(()=>f.author);e.u((0,a.computed)(()=>f.i18n));let{t:v}=e.c((0,a.computed)(()=>f.i18n)),y=(0,a.ref)(null),b=(0,a.ref)(null),x=(0,a.ref)(null),S=(0,a.ref)(0),C=new Set,w=new Set,T=new c.LayoutSelectionGate,E=(0,a.ref)(!1),D=(0,a.ref)(!1),k=(0,a.ref)(!1),A=(0,a.ref)(!1),j=(0,a.ref)(!1),M=(0,a.ref)(!1),N=(0,a.ref)(f.showOutline),P=(0,a.ref)(!1),F=(0,a.ref)(!1),I=(0,a.ref)(!1),L=(0,a.ref)(null),R=(0,a.shallowRef)([]),ne=(0,a.shallowRef)([]),z=(0,a.shallowRef)([]),{zoom:B,zoomPercent:ie,isMinZoom:ae,isMaxZoom:oe,setZoom:se,zoomIn:ce,zoomOut:le,handleWheel:de,handleKeyDown:fe,installShortcuts:V,ZOOM_PRESETS:H}=i.r(f.initialZoom);V();let{editorView:U,isReady:me,parseError:W,layout:ge,loadBuffer:G,loadDocument:ve,save:ye,focus:be,destroy:xe,getDocument:K,getCommands:q,reLayout:Ce,getHfPmView:we,syncHfPMs:Ee,setHfTransactionListener:De,setDocument:Oe}=i.i({hiddenContainer:y,pagesContainer:b,readOnly:h,externalPlugins:f.externalPlugins,syncCoordinator:T,editorMode:m,author:g,onChange:e=>{p(`change`,e),p(`update:document`,e),f.onChange?.(e),C.forEach(t=>t(e))},onError:e=>{p(`error`,e),f.onError?.(e)},onSelectionUpdate:()=>{S.value++,Zn();let e=U.value;f.onSelectionChange?.(e?(0,c.extractSelectionState)(e.state):null);let t=(0,ee.getSelectionInfo)(e);w.forEach(e=>e(t))}}),{commentCallbacks:ke}=on(f,U),J=(0,a.computed)(()=>{S.value;let e=K();if(!e?.package?.document)return null;let t=e.package.document;return t.finalSectionProperties??t.sections?.[0]?.properties??null}),Ae=(0,a.computed)(()=>{S.value;let e=U.value,t=e?(0,u.extractSelectionContext)(e.state).paragraphFormatting:{};return{indentLeft:t.indentLeft??0,indentRight:t.indentRight??0,firstLineIndent:t.indentFirstLine??0,hangingIndent:t.hangingIndent??!1,tabStops:t.tabs??null}}),je=(0,a.computed)(()=>(S.value,K()?.package?.theme??f.theme??null)),Y=(0,a.ref)(null),Me=(0,a.ref)([]);function Ne(e,t){Y.value=(0,s.computeHfCaretRectFromView)(e,t),Me.value=(0,s.computeHfSelectionRectsFromView)(e,t)}function Pe(){Y.value=null,Me.value=[]}xn(()=>f.fonts,e=>{p(`error`,e),f.onError?.(e)});let Fe=(0,a.computed)(()=>$.value?.headerFooter?we($.value.headerFooter)??null:null);(0,a.onMounted)(()=>{De((e,t)=>{requestAnimationFrame(()=>{let e=$.value;if(!e)return;Ne(t,e.position);let n=te(e.position),r=x.value;if(!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect(),o=B.value||1;$.value={...e,targetRect:{top:(i.top-a.top+r.scrollTop)/o,left:(i.left-a.left+r.scrollLeft)/o,width:i.width/o,height:i.height/o}}})}),(0,a.watch)(()=>$.value,e=>{if(!e){Pe();return}let t=U.value;if(t){try{let e=t.state.tr.setSelection(o.TextSelection.create(t.state.doc,0));t.dispatch(e)}catch{}t.dom.blur?.()}Qn.updateSelectionOverlay()});let e=0;function t(){!$.value||e||(e=requestAnimationFrame(()=>{e=0;let t=$.value;if(!t?.headerFooter)return;let n=we(t.headerFooter);n&&Ne(n,t.position)}))}window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),(0,a.onBeforeUnmount)(()=>{e&&cancelAnimationFrame(e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)})});let Ie=(0,a.computed)(()=>{let e=[];return F.value&&e.push(`translateX(-${l.SIDEBAR_DOCUMENT_SHIFT}px)`),B.value!==1&&e.push(`scale(${B.value})`),{transform:e.length>0?e.join(` `):void 0,transformOrigin:`top center`,transition:`transform 0.2s ease`}}),Le=(0,a.computed)(()=>({paddingLeft:`20px`,paddingRight:20+(F.value?l.SIDEBAR_DOCUMENT_SHIFT*2:0)+`px`,transition:`padding 0.2s ease`})),Re=(0,a.computed)(()=>{let e=J.value;return(0,_.twipsToPixels)(e?.pageWidth??12240)*B.value}),ze=(0,a.computed)(()=>{let e=new Set;for(let t of R.value)t.parentId==null&&t.done&&e.add(t.id);return e}),Be=(0,a.computed)(()=>{S.value;let e=U.value;if(!e)return[];let t=new Set,n=[];return e.state.doc.descendants(e=>{let r=e.attrs?.bookmarks;if(!r)return!0;for(let e of r){let r=e.name;!r||r.startsWith(`_`)||t.has(r)||(t.add(r),n.push({name:r,label:r}))}return!0}),n.sort((e,t)=>e.name.localeCompare(t.name))}),Ve=(0,O.createCommentIdAllocator)(),{floatingCommentBtn:He,pendingCommentRange:Ue,addCommentYPosition:We,sidebarAutoOpenedRef:Ge,extractCommentsAndChanges:Ke,handleAddComment:qe,handleCancelAddComment:Je,handleStartAddComment:Ye,handleMarkerClick:Xe}=sn({editorView:U,getDocument:K,comments:R,trackedChanges:ne,resolvedCommentIds:ze,activeSidebarItem:L,showSidebar:F,isAddingComment:I,readOnly:h,zoom:B,stateTick:S,pagesRef:b,pagesViewportRef:x,emit:p,commentIdAllocator:Ve,author:g,commentCallbacks:ke}),{docxInputRef:Ze,handleDocxFileChange:Qe,handleDocumentNameChange:$e,downloadCurrentDocument:et,loadDocumentBuffer:tt,loadDocument:nt,save:rt}=Zt({loadBuffer:G,loadParsedDocument:ve,getDocument:K,saveBlob:ye,extractCommentsAndChanges:Ke,emit:p,documentName:()=>f.documentName,onDocumentNameChange:f.onDocumentNameChange,nextTick:a.nextTick}),{hyperlinkPopupData:it,handleHyperlinkSubmit:at,handleHyperlinkRemove:ot,handleHyperlinkPopupNavigate:st,handleHyperlinkPopupEdit:ct,handleHyperlinkPopupRemove:lt}=Qt({editorView:U,getCommands:q}),{handleClearFormatting:ut,handleApplyStyle:dt,handleInsertPageBreak:ft,handleInsertSymbol:pt,applyFormatting:mt,setParagraphStyle:gt}=$t({editorView:U,getDocument:K}),{handlePageSetupApply:_t,handleLeftMarginChange:vt,handleRightMarginChange:yt,handleTopMarginChange:bt,handleBottomMarginChange:xt,handleIndentLeftChange:St,handleIndentRightChange:Ct,handleFirstLineIndentChange:wt,handleTabStopRemove:Tt}=en({editorView:U,getDocument:K,readOnly:h,stateTick:S,reLayout:Ce,emit:p}),{showWatermark:Et,currentWatermark:Dt,handleWatermarkApply:Ot}=tn({editorView:U,readOnly:h,stateTick:S}),{handleToggleOutline:kt,handleOutlineNavigate:At,handleToggleSidebar:jt,handleEditorScrollMouseDown:Mt}=nn({editorView:U,showOutline:N,showSidebar:F,outlineHeadings:z,activeSidebarItem:L,extractCommentsAndChanges:Ke});rn({showKeyboardShortcuts:P,showFindReplace:E,showHyperlink:k,handleZoomKeyDown:fe,disableFindReplaceShortcuts:()=>f.disableFindReplaceShortcuts});let{addComment:Nt,replyToComment:Pt,resolveComment:Ft,proposeChange:It,handleCommentReply:Lt,handleCommentResolve:X,handleCommentUnresolve:Rt,handleCommentDelete:zt,handleAcceptChange:Vt,handleRejectChange:Ht,handleAcceptChangeById:Ut,handleRejectChangeById:Wt,handleTrackedChangeReply:Gt}=an({editorView:U,getDocument:K,comments:R,trackedChanges:ne,showSidebar:F,isAddingComment:I,pendingCommentRange:Ue,contentChangeSubscribers:C,extractCommentsAndChanges:Ke,emit:p,commentIdAllocator:Ve,author:g,commentCallbacks:ke}),{selectedImage:Z,imageInteracting:Kt,imageToolbarContext:qt,handleInsertImage:Jt,handleToolbarImageWrap:Yt,handleImageTransform:ln}=cn({editorView:U,zoom:B,stateTick:S,getCommands:q}),un=i.n(),dn=null,{tableInsertButton:Q,hfEdit:$,scrollPageInfo:fn,resolvePos:pn,setPmSelection:hn,scrollVisiblePositionIntoView:kn,handlePagesMouseDown:An,handlePagesMouseMove:jn,handlePagesClick:Mn,handlePagesDoubleClick:Nn,handleTableInsertClick:Pn,clearTableInsertTimer:Fn,handleHfSave:In,handleHfRemove:Ln}=gn({editorView:U,pagesRef:b,pagesViewportRef:x,selectedImage:Z,imageInteracting:Kt,hyperlinkPopupData:it,readOnly:h,zoom:B,layout:ge,tableResize:un,getCommands:q,getDocument:K,reLayout:Ce,emit:p,clearOverlay:Xn,syncHfPMs:Ee,getHfPmView:we,setDocument:Oe}),{contextMenu:Rn,imageContextMenu:zn,imageContextMenuTextActions:Bn,handleContextMenu:Vn,handleSelectedImageContextMenu:Hn,handleImageWrapSelect:Un,handleContextMenuAction:Wn}=mn({editorView:U,selectedImage:Z,zoom:B,showImageProperties:j,getCommands:q,clearOverlay:Xn,setPmSelection:hn,resolvePos:pn}),{handleMenuAction:Gn,handleMenuTableInsert:Kn}=vn({editorView:U,getCommands:q,docxInputRef:Ze,showPageSetup:M,showWatermark:Et,showInsertImage:D,showHyperlink:k,showInsertSymbol:A,showKeyboardShortcuts:P,handleClearFormatting:ut,handleInsertPageBreak:ft,handleToggleOutline:kt,handleToggleSidebar:jt,downloadCurrentDocument:et,emit:p});yn({documentBuffer:()=>f.documentBuffer,document:()=>f.document,loadDocumentBuffer:tt,loadDocument:nt,sidebarAutoOpenedRef:Ge});let qn=()=>U.value,Jn=()=>b.value;(0,a.watch)(()=>f.mode,e=>{e&&e!==m.value&&(m.value=e)}),(0,a.watch)(()=>f.showOutline,e=>{N.value=!!e});function Yn(e){m.value!==e&&(m.value=e,p(`mode-change`,e))}(0,a.onMounted)(()=>{dn=un.install()}),(0,a.onBeforeUnmount)(()=>{dn?.()});function Xn(){Qn.clearOverlay()}function Zn(){Qn.updateSelectionOverlay()}let Qn=_n({editorView:U,pagesRef:b,zoom:B,selectedImage:Z,isHfEditing:(0,a.computed)(()=>$.value!==null),imageInteracting:Kt});(0,a.onBeforeUnmount)(()=>{Xn()});let{exposed:$n}=bn({editorView:U,layout:ge,pagesRef:b,pagesViewportRef:x,zoom:B,comments:R,focus:be,destroy:xe,getDocument:K,setZoom:se,save:rt,loadDocument:nt,loadDocumentBuffer:tt,addComment:Nt,replyToComment:Pt,resolveComment:Ft,proposeChange:It,applyFormatting:mt,setParagraphStyle:gt,scrollVisiblePositionIntoView:kn,contentChangeSubscribers:C,selectionChangeSubscribers:w,onPrint:f.onPrint});return r($n),(r,i)=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{class:(0,a.normalizeClass)([`docx-editor-vue ep-root paged-editor`,n.className,{"paged-editor--readonly":h.value,"paged-editor--hf-editing":(0,a.unref)($)!==null,"paged-editor--editing-header":(0,a.unref)($)?.position===`header`,"paged-editor--editing-footer":(0,a.unref)($)?.position===`footer`}]),style:(0,a.normalizeStyle)(n.style)},[(0,a.createElementVNode)(`div`,Sn,[(0,a.createVNode)(Te,{"show-menu-bar":n.showMenuBar,"document-name":n.documentName,"document-name-editable":n.documentNameEditable,"render-logo":n.renderLogo,"render-title-bar-right":n.renderTitleBarRight,onRename:(0,a.unref)($e),onMenuAction:(0,a.unref)(Gn),onInsertTable:(0,a.unref)(Kn)},{"title-bar-left":(0,a.withCtx)(()=>[(0,a.renderSlot)(r.$slots,`title-bar-left`)]),"title-bar-right":(0,a.withCtx)(()=>[(0,a.renderSlot)(r.$slots,`title-bar-right`)]),_:3},8,[`show-menu-bar`,`document-name`,`document-name-editable`,`render-logo`,`render-title-bar-right`,`onRename`,`onMenuAction`,`onInsertTable`]),n.showToolbar?((0,a.openBlock)(),(0,a.createBlock)(t.x,{key:0,view:(0,a.unref)(U),"get-commands":(0,a.unref)(q),"state-tick":S.value,"zoom-percent":(0,a.unref)(ie),"is-min-zoom":(0,a.unref)(ae),"is-max-zoom":(0,a.unref)(oe),"zoom-presets":(0,a.unref)(H),"show-zoom-control":n.showZoomControl,"editor-mode":m.value,"comments-sidebar-open":F.value,"image-context":(0,a.unref)(qt),theme:je.value,"font-families":n.fontFamilies,onInsertLink:i[0]||=e=>k.value=!0,onApplyStyle:(0,a.unref)(dt),onZoomIn:(0,a.unref)(ce),onZoomOut:(0,a.unref)(le),onZoomSet:(0,a.unref)(se),onToggleSidebar:(0,a.unref)(jt),onModeChange:Yn,onImageWrapType:(0,a.unref)(Yt),onImageProperties:i[1]||=e=>j.value=!0,onImageTransform:(0,a.unref)(ln)},(0,a.createSlots)({"table-context":(0,a.withCtx)(()=>[(0,a.createVNode)(t.h,{view:(0,a.unref)(U),"get-commands":(0,a.unref)(q),"state-tick":S.value,theme:je.value},null,8,[`view`,`get-commands`,`state-tick`,`theme`])]),_:2},[n.toolbarExtra?{name:`toolbar-extra`,fn:(0,a.withCtx)(()=>[((0,a.openBlock)(),(0,a.createBlock)((0,a.resolveDynamicComponent)(n.toolbarExtra)))]),key:`0`}:{name:`toolbar-extra`,fn:(0,a.withCtx)(()=>[(0,a.renderSlot)(r.$slots,`toolbar-extra`)]),key:`1`}]),1032,[`view`,`get-commands`,`state-tick`,`zoom-percent`,`is-min-zoom`,`is-max-zoom`,`zoom-presets`,`show-zoom-control`,`editor-mode`,`comments-sidebar-open`,`image-context`,`theme`,`font-families`,`onApplyStyle`,`onZoomIn`,`onZoomOut`,`onZoomSet`,`onToggleSidebar`,`onImageWrapType`,`onImageTransform`])):(0,a.createCommentVNode)(``,!0)]),(0,a.createVNode)(ht,{"show-find-replace":E.value,"onUpdate:showFindReplace":i[2]||=e=>E.value=e,"show-insert-image":D.value,"onUpdate:showInsertImage":i[3]||=e=>D.value=e,"show-hyperlink":k.value,"onUpdate:showHyperlink":i[4]||=e=>k.value=e,"show-insert-symbol":A.value,"onUpdate:showInsertSymbol":i[5]||=e=>A.value=e,"show-image-properties":j.value,"onUpdate:showImageProperties":i[6]||=e=>j.value=e,"show-page-setup":M.value,"onUpdate:showPageSetup":i[7]||=e=>M.value=e,"show-watermark":(0,a.unref)(Et),"onUpdate:showWatermark":i[8]||=e=>(0,a.isRef)(Et)?Et.value=e:null,"show-keyboard-shortcuts":P.value,"onUpdate:showKeyboardShortcuts":i[9]||=e=>P.value=e,view:(0,a.unref)(U),bookmarks:Be.value,"selected-image-pm-pos":(0,a.unref)(Z)?.pmPos??null,"section-properties":J.value,"current-watermark":(0,a.unref)(Dt),"scroll-visible-position-into-view":(0,a.unref)(kn),onInsertImage:(0,a.unref)(Jt),onInsertSymbol:(0,a.unref)(pt),onHyperlinkSubmit:(0,a.unref)(at),onHyperlinkRemove:(0,a.unref)(ot),onPageSetupApply:(0,a.unref)(_t),onWatermarkApply:(0,a.unref)(Ot)},null,8,[`show-find-replace`,`show-insert-image`,`show-hyperlink`,`show-insert-symbol`,`show-image-properties`,`show-page-setup`,`show-watermark`,`show-keyboard-shortcuts`,`view`,`bookmarks`,`selected-image-pm-pos`,`section-properties`,`current-watermark`,`scroll-visible-position-into-view`,`onInsertImage`,`onInsertSymbol`,`onHyperlinkSubmit`,`onHyperlinkRemove`,`onPageSetupApply`,`onWatermarkApply`]),(0,a.unref)(W)?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Cn,(0,a.toDisplayString)((0,a.unref)(W)),1)):(0,a.createCommentVNode)(``,!0),!(0,a.unref)(me)&&!(0,a.unref)(W)?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,wn,`Loading...`)):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,{ref_key:`hiddenPmRef`,ref:y,class:`docx-editor-vue__hidden-pm paged-editor__hidden-pm`},null,512),(0,a.createElementVNode)(`div`,{class:`docx-editor-vue__editor-scroll`,onMousedown:i[32]||=(...e)=>(0,a.unref)(Mt)&&(0,a.unref)(Mt)(...e)},[n.showRuler&&J.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`docx-editor-vue__ruler-row`,style:(0,a.normalizeStyle)(Le.value)},[(0,a.createVNode)(t.o,{"section-props":J.value,zoom:(0,a.unref)(B),editable:!h.value,"indent-left":Ae.value.indentLeft,"indent-right":Ae.value.indentRight,"first-line-indent":Ae.value.firstLineIndent,"hanging-indent":Ae.value.hangingIndent,"tab-stops":Ae.value.tabStops,onLeftMarginChange:(0,a.unref)(vt),onRightMarginChange:(0,a.unref)(yt),onIndentLeftChange:(0,a.unref)(St),onIndentRightChange:(0,a.unref)(Ct),onFirstLineIndentChange:(0,a.unref)(wt),onTabStopRemove:(0,a.unref)(Tt)},null,8,[`section-props`,`zoom`,`editable`,`indent-left`,`indent-right`,`first-line-indent`,`hanging-indent`,`tab-stops`,`onLeftMarginChange`,`onRightMarginChange`,`onIndentLeftChange`,`onIndentRightChange`,`onFirstLineIndentChange`,`onTabStopRemove`])],4)):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,Tn,[(0,a.createElementVNode)(`div`,{ref_key:`pagesViewportRef`,ref:x,class:`docx-editor-vue__pages-viewport`,onMousedown:i[23]||=(...e)=>(0,a.unref)(An)&&(0,a.unref)(An)(...e),onMousemove:i[24]||=(...e)=>(0,a.unref)(jn)&&(0,a.unref)(jn)(...e),onClick:i[25]||=(...e)=>(0,a.unref)(Mn)&&(0,a.unref)(Mn)(...e),onDblclick:i[26]||=(...e)=>(0,a.unref)(Nn)&&(0,a.unref)(Nn)(...e),onContextmenu:i[27]||=(0,a.withModifiers)((...e)=>(0,a.unref)(Vn)&&(0,a.unref)(Vn)(...e),[`prevent`]),onWheel:i[28]||=(...e)=>(0,a.unref)(de)&&(0,a.unref)(de)(...e)},[n.showRuler&&J.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,En,[(0,a.createVNode)(t.a,{"section-props":J.value,zoom:(0,a.unref)(B),editable:!h.value,onTopMarginChange:(0,a.unref)(bt),onBottomMarginChange:(0,a.unref)(xt)},null,8,[`section-props`,`zoom`,`editable`,`onTopMarginChange`,`onBottomMarginChange`])])):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,{ref_key:`pagesRef`,ref:b,class:`docx-editor-vue__pages paged-editor__pages`,style:(0,a.normalizeStyle)(Ie.value)},null,4),h.value?(0,a.createCommentVNode)(``,!0):((0,a.openBlock)(),(0,a.createBlock)(Se,{key:1,container:b.value,view:(0,a.unref)(U)},null,8,[`container`,`view`])),(0,a.createVNode)(_e,{"is-open":(0,a.unref)($)!==null,position:(0,a.unref)($)?.position??`header`,view:Fe.value,"target-rect":(0,a.unref)($)?.targetRect??null,onSave:(0,a.unref)(In),onClose:i[10]||=e=>$.value=null,onRemove:(0,a.unref)(Ln)},null,8,[`is-open`,`position`,`view`,`target-rect`,`onSave`,`onRemove`]),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)((0,a.unref)($)?Me.value:[],(e,t)=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:`hf-sel-${t}-${e.top}-${e.left}`,class:`vue-hf-sel-rect`,"aria-hidden":`true`,style:(0,a.normalizeStyle)({position:`fixed`,top:`${e.top}px`,left:`${e.left}px`,width:`${e.width}px`,height:`${e.height}px`,background:`rgba(66, 133, 244, 0.25)`,pointerEvents:`none`,zIndex:9998})},null,4))),128)),(0,a.unref)($)&&Y.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:2,"aria-hidden":`true`,style:(0,a.normalizeStyle)({position:`fixed`,top:`${Y.value.top}px`,left:`${Y.value.left}px`,width:`2px`,height:`${Y.value.height}px`,background:`#4285f4`,pointerEvents:`none`,zIndex:9999,animation:`hf-caret-blink 1.06s steps(1) infinite`})},null,4)):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(ue,{"image-info":(0,a.unref)(Z),zoom:(0,a.unref)(B),view:(0,a.unref)(U),onOpenProperties:i[11]||=e=>j.value=!0,onDeselect:i[12]||=e=>Z.value=null,onInteractStart:i[13]||=e=>Kt.value=!0,onInteractEnd:i[14]||=e=>Kt.value=!1,onContextMenu:(0,a.unref)(Hn)},null,8,[`image-info`,`zoom`,`view`,`onContextMenu`]),(0,a.createVNode)(re,{"get-view":qn,"get-pages-container":Jn,zoom:(0,a.unref)(B),"transaction-version":S.value,"sync-coordinator":(0,a.unref)(T)},null,8,[`zoom`,`transaction-version`,`sync-coordinator`]),(0,a.unref)(He)&&!I.value&&!h.value?((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:3,type:`button`,class:`docx-editor-vue__floating-comment`,style:(0,a.normalizeStyle)({top:(0,a.unref)(He).top+`px`,left:(0,a.unref)(He).left+`px`}),title:(0,a.unref)(v)(`comments.addComment`),onMousedown:i[15]||=(0,a.withModifiers)((...e)=>(0,a.unref)(Ye)&&(0,a.unref)(Ye)(...e),[`prevent`,`stop`])},[(0,a.createVNode)(e.p,{name:`add_comment`,size:16})],44,Dn)):(0,a.createCommentVNode)(``,!0),(0,a.unref)(Q)&&!h.value?((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:4,type:`button`,class:`docx-editor-vue__table-insert-btn`,style:(0,a.normalizeStyle)({left:(0,a.unref)(Q).x+`px`,top:(0,a.unref)(Q).y+`px`}),title:(0,a.unref)(Q).type===`row`?`Insert row below`:`Insert column to the right`,"aria-label":(0,a.unref)(Q).type===`row`?`Insert row below`:`Insert column to the right`,onMousedown:i[16]||=(...e)=>(0,a.unref)(Pn)&&(0,a.unref)(Pn)(...e),onMouseenter:i[17]||=(...e)=>(0,a.unref)(Fn)&&(0,a.unref)(Fn)(...e),onMouseleave:i[18]||=e=>Q.value=null},[...i[37]||=[(0,a.createElementVNode)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`},[(0,a.createElementVNode)(`path`,{d:`M6 1v10M1 6h10`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`})],-1)]],44,On)):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(t.s,{comments:R.value,"pages-container":b.value,zoom:(0,a.unref)(B),"page-width-px":Re.value,"sidebar-open":F.value,"resolved-comment-ids":ze.value,onMarkerClick:(0,a.unref)(Xe)},null,8,[`comments`,`pages-container`,`zoom`,`page-width-px`,`sidebar-open`,`resolved-comment-ids`,`onMarkerClick`]),(0,a.createVNode)(t.c,{"is-open":F.value,comments:R.value,"tracked-changes":ne.value,"is-adding-comment":I.value,"add-comment-y-position":(0,a.unref)(We),"show-resolved":!0,"pages-container":b.value,"page-width-px":Re.value,zoom:(0,a.unref)(B),"active-item-id":L.value,onClose:i[19]||=e=>F.value=!1,onAddComment:(0,a.unref)(qe),onCancelAddComment:(0,a.unref)(Je),onCommentReply:(0,a.unref)(Lt),onCommentResolve:(0,a.unref)(X),onCommentUnresolve:(0,a.unref)(Rt),onCommentDelete:(0,a.unref)(zt),onAcceptChange:(0,a.unref)(Vt),onRejectChange:(0,a.unref)(Ht),onAcceptChangeById:(0,a.unref)(Ut),onRejectChangeById:(0,a.unref)(Wt),onTrackedChangeReply:(0,a.unref)(Gt),"onUpdate:activeItemId":i[20]||=e=>L.value=e},null,8,[`is-open`,`comments`,`tracked-changes`,`is-adding-comment`,`add-comment-y-position`,`pages-container`,`page-width-px`,`zoom`,`active-item-id`,`onAddComment`,`onCancelAddComment`,`onCommentReply`,`onCommentResolve`,`onCommentUnresolve`,`onCommentDelete`,`onAcceptChange`,`onRejectChange`,`onAcceptChangeById`,`onRejectChangeById`,`onTrackedChangeReply`]),(0,a.createVNode)(Xt,{data:(0,a.unref)(it),"read-only":h.value,onNavigate:(0,a.unref)(st),onCopy:i[21]||=e=>it.value=null,onEdit:(0,a.unref)(ct),onRemove:(0,a.unref)(lt),onClose:i[22]||=e=>it.value=null},null,8,[`data`,`read-only`,`onNavigate`,`onEdit`,`onRemove`])],544),!N.value&&n.showOutlineButton?((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:0,type:`button`,class:`docx-editor-vue__outline-toggle`,title:`Show document outline`,onClick:i[29]||=(...e)=>(0,a.unref)(kt)&&(0,a.unref)(kt)(...e),onMousedown:i[30]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createVNode)(e.p,{name:`format_list_bulleted`,size:20})],32)):(0,a.createCommentVNode)(``,!0),(0,a.unref)(fn).totalPages>1?((0,a.openBlock)(),(0,a.createBlock)(he,{key:1,"current-page":(0,a.unref)(fn).currentPage,"total-pages":(0,a.unref)(fn).totalPages,visible:(0,a.unref)(fn).visible},null,8,[`current-page`,`total-pages`,`visible`])):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(pe,{"is-open":N.value,headings:z.value,onClose:i[31]||=e=>N.value=!1,onNavigate:(0,a.unref)(At)},null,8,[`is-open`,`headings`,`onNavigate`])])],32),(0,a.createElementVNode)(`input`,{ref_key:`docxInputRef`,ref:Ze,type:`file`,accept:`.docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document`,style:{display:`none`},onChange:i[33]||=(...e)=>(0,a.unref)(Qe)&&(0,a.unref)(Qe)(...e)},null,544),(0,a.createVNode)(Bt,{"read-only":h.value,"context-menu":(0,a.unref)(Rn),"image-context-menu":(0,a.unref)(zn),"image-context-menu-text-actions":(0,a.unref)(Bn),"can-open-image-properties":!!(0,a.unref)(Z),onContextMenuAction:(0,a.unref)(Wn),onCloseContextMenu:i[34]||=e=>(0,a.unref)(Rn).isOpen=!1,onImageWrapSelect:(0,a.unref)(Un),onCloseImageContextMenu:i[35]||=e=>zn.value=null,onOpenImageProperties:i[36]||=e=>j.value=!0},null,8,[`read-only`,`context-menu`,`image-context-menu`,`image-context-menu-text-actions`,`can-open-image-properties`,`onContextMenuAction`,`onImageWrapSelect`])],6))}});async function An(e,t,n={}){let r=e instanceof ArrayBuffer?e:await(0,l.toArrayBuffer)(e),i=null,o=null,s=!1,c={save:async()=>{let e=await(i?.save()??Promise.resolve(null));return e?new Blob([e],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`}):null},getDocument:()=>i?.getDocument()??null,focus:()=>{i?.focus()},setZoom:e=>{i?.setZoom(e)},scrollToParaId:e=>i?.scrollToParaId(e)??!1,scrollToPosition:e=>{i?.scrollToPosition(e)},destroy:()=>{i?.destroy(),o?.unmount(),o=null}};return new Promise((e,l)=>{o=(0,a.createApp)({setup(){return()=>(0,a.h)(kn,{...n,documentBuffer:r,showToolbar:n.showToolbar??!0,readOnly:n.readOnly??!1,ref:e=>{i=e??null},onReady:()=>{n.onReady?.(),s||(s=!0,e(c))},onError:e=>{n.onError?.(e),s||(s=!0,l(e))},onChange:n.onChange,onRename:n.onRename,onMenuAction:n.onMenuAction,onModeChange:n.onModeChange})}}),o.mount(t)})}var jn=`0.0.2`;exports.DocxEditor=kn,exports.VERSION=jn,Object.defineProperty(exports,`createDocumentWithText`,{enumerable:!0,get:function(){return P.createDocumentWithText}}),Object.defineProperty(exports,`createEmptyDocument`,{enumerable:!0,get:function(){return P.createEmptyDocument}}),exports.defaultLocale=e.f,exports.i18nPlugin=e.l,exports.provideLocale=e.u,exports.renderAsync=An,exports.useTranslation=e.d;
|