@eigenpal/docx-editor-vue 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/KeyboardShortcutsDialog-Dohz9D39.cjs +1 -0
  2. package/dist/{KeyboardShortcutsDialog-BbuDgglK.js → KeyboardShortcutsDialog-OPAV0oVm.js} +351 -506
  3. package/dist/{MenuBar-CbONA9-a.js → MenuBar-BLKoZqG3.js} +813 -692
  4. package/dist/MenuBar-BP-XM0MI.cjs +4 -0
  5. package/dist/{TablePropertiesDialog-JWT68zEO.cjs → TablePropertiesDialog-B-FVOqkH.cjs} +1 -1
  6. package/dist/TablePropertiesDialog-B3oZIIjw.js +1145 -0
  7. package/dist/components/DocxEditor/types.d.ts +26 -0
  8. package/dist/components/Toolbar/presets.d.ts +0 -1
  9. package/dist/components/ui/fontPickerValue.d.ts +1 -0
  10. package/dist/components/ui/fontPickerValue.test.d.ts +1 -0
  11. package/dist/composables/imageOverlayRect.d.ts +44 -0
  12. package/dist/composables/imageOverlayRect.test.d.ts +1 -0
  13. package/dist/composables/useColorMode.d.ts +8 -0
  14. package/dist/composables/useCommentSidebarItems.test.d.ts +1 -0
  15. package/dist/composables/useDocxEditorRefApi.d.ts +4 -0
  16. package/dist/composables/useFileIO.d.ts +5 -0
  17. package/dist/composables/useFormattingActions.d.ts +5 -2
  18. package/dist/composables/useImageActions.d.ts +0 -6
  19. package/dist/composables/useMenuActions.d.ts +3 -1
  20. package/dist/composables/useParagraphStyleOptions.d.ts +18 -0
  21. package/dist/composables/useToolbarDropdowns.d.ts +1 -0
  22. package/dist/composables/useToolbarFontSize.d.ts +15 -0
  23. package/dist/composables.cjs +1 -1
  24. package/dist/composables.js +5 -4
  25. package/dist/dialogs.cjs +1 -1
  26. package/dist/dialogs.js +3 -3
  27. package/dist/docx-editor-vue.css +1 -1
  28. package/dist/index.cjs +4 -4
  29. package/dist/index.js +1375 -1258
  30. package/dist/plugin-api.cjs +1 -1
  31. package/dist/plugin-api.js +1 -1
  32. package/dist/ui.cjs +2 -2
  33. package/dist/ui.js +253 -230
  34. package/dist/{useCommentSidebarItems-CbNvNCd3.cjs → useCommentSidebarItems-DBeGKNGA.cjs} +1 -1
  35. package/dist/{useCommentSidebarItems-BHomCzpj.js → useCommentSidebarItems-DXbF857R.js} +2 -1
  36. package/dist/{useDragAutoScroll-BNPB-6SM.js → useDragAutoScroll-B21Ec-Zy.js} +6 -7
  37. package/dist/useDragAutoScroll-BPnc7LEO.cjs +1 -0
  38. package/package.json +4 -4
  39. package/dist/KeyboardShortcutsDialog-Bct8AJ0i.cjs +0 -1
  40. package/dist/MenuBar-m0JEaF1X.cjs +0 -4
  41. package/dist/TablePropertiesDialog-D5MIF3cj.js +0 -987
  42. package/dist/useDragAutoScroll-DCUotwOX.cjs +0 -1
package/dist/index.cjs CHANGED
@@ -1,13 +1,13 @@
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-DCUotwOX.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 z(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 ne(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`}}]});function L(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`,R),document.addEventListener(`mouseup`,z))}function R(e){let t=c.zoom,n=(e.clientX-C)/t,r=(e.clientY-w)/t,i=!e.shiftKey,a=(0,m.calculateResizedImageDimensions)(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 z(){document.removeEventListener(`mousemove`,R),document.removeEventListener(`mouseup`,z),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&&ve(n),(0,a.nextTick)(()=>P())}let ne=0,re=0,le=0,ue=0,V=null,H=null;function de(e){if(!e)return 0;let t=e.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/);return t?parseFloat(t[1]):0}function fe(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 U(e,t){return Math.atan2(e-ne,-(t-re))*180/Math.PI}function pe(e){if(!c.imageInfo)return;let t=c.imageInfo.element.getBoundingClientRect();ne=t.left+t.width/2,re=t.top+t.height/2;let n=j(c.view,c.imageInfo.pmPos);V=n&&n.attrs.transform||null,ue=de(V),H=c.imageInfo.element.querySelector(`img`),le=U(e.clientX,e.clientY),b.value=ue,_.value=!0,u(`interact-start`),document.addEventListener(`mousemove`,me),document.addEventListener(`mouseup`,he)}function me(e){let t=U(e.clientX,e.clientY)-le,n=ue+t;e.shiftKey||(n=Math.round(n/ce)*ce),b.value=(n%360+360)%360,H&&(H.style.transform=fe(V,b.value)||``)}function he(){document.removeEventListener(`mousemove`,me),document.removeEventListener(`mouseup`,he),_.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:fe(n.attrs.transform,b.value)})),ve(t.pmPos))}catch{}finally{H&&(H.style.transform=``),H=null,V=null}(0,a.nextTick)(()=>P())}let W=null;function ge(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`),W=document.createElement(`div`),W.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;W.style.width=`${r.width*e}px`,W.style.height=`${r.height*e}px`,document.body.appendChild(W)}if(W){let t=c.zoom;W.style.left=`${e.clientX-r.width*t/2}px`,W.style.top=`${e.clientY-r.height*t/2}px`}}},o=e=>{document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o),k=null,A=null,W&&=(W.remove(),null),g.value=!1,i&&(u(`interact-end`),_e(e.clientX,e.clientY))};k=a,A=o,document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o)}function _e(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&&ve(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&&ve(o)}(0,a.nextTick)(()=>P())}}function ve(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`,R),document.removeEventListener(`mouseup`,z),document.removeEventListener(`mousemove`,me),document.removeEventListener(`mouseup`,he),k&&document.removeEventListener(`mousemove`,k),A&&document.removeEventListener(`mouseup`,A),W&&=(W.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=>ge(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=>L(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=>pe(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-503209ad`]]),V={class:`doc-outline__header`},H={class:`doc-outline__body`},de={key:0,class:`doc-outline__empty`},fe=[`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`,V,[(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`,H,[t.headings.length===0?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,de,` 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,fe))),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`}},_e=(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)}}),ve=n.t(_e,[[`__scopeId`,`data-v-e93a9f94`]]),ye=[`role`],be={key:0,class:`layout-sdt-widget-empty`},xe=[`aria-selected`,`onClick`],Se=[`value`],Ce=(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`,be,`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,Se))],44,ye)):(0,a.createCommentVNode)(``,!0)}}),G={key:0,class:`docx-editor-vue__title-bar`},K={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`,G,[(0,a.createElementVNode)(`div`,K,[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`},ke={class:`wm-body`},Ae={class:`wm-radio-row`},q=[`checked`],J={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`,Oe,(0,a.toDisplayString)((0,a.unref)(o)(`dialogs.watermark.title`)),1),(0,a.createElementVNode)(`div`,ke,[(0,a.createElementVNode)(`div`,Ae,[(0,a.createElementVNode)(`input`,{id:`wm-none`,type:`radio`,checked:l.value===`none`,onChange:n[0]||=e=>l.value=`none`},null,40,q),(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,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,De)],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`},Kt=[`placeholder`,`onKeydown`],Z={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,Kt),[[a.vModelText,c.value]])]),(0,a.createElementVNode)(`div`,Z,[(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){let t=()=>e.activeView?.value??e.editorView.value;function n(){let e=t();e&&((0,d.clearFormatting)(e.state,e.dispatch,e),e.focus())}function r(n){let r=t();if(!r)return;let i=e.getDocument()?.package?.styles;if(i){let e=(0,S.createStyleResolver)(i).resolveParagraphStyle(n);(0,x.applyStyle)(n,{paragraphFormatting:e.paragraphFormatting,runFormatting:e.runFormatting})(r.state,e=>r.dispatch(e))}else (0,x.applyStyle)(n)(r.state,e=>r.dispatch(e));r.focus()}function i(){let t=e.editorView.value;t&&((0,C.insertPageBreak)(t.state,e=>t.dispatch(e),t),t.focus())}function a(e){let n=t();if(!n)return;let{from:r}=n.state.selection,i=n.state.tr.insertText(e,r);n.dispatch(i.scrollIntoView()),n.focus()}function o(t){let n=e.editorView.value;return n?(0,w.applyFormatting)(n,t):!1}function s(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:n,handleApplyStyle:r,handleInsertPageBreak:i,handleInsertSymbol:a,applyFormatting:o,setParagraphStyle:s}}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 fn(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function Q(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 $(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 fn(await un(n,t)),i=await Q(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 fn(i),o=await Q(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`:$(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){z(e.pagesRef.value,t,y,s.value?.position)}function S(t){ne(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=`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./KeyboardShortcutsDialog-Dohz9D39.cjs`),t=require(`./MenuBar-BP-XM0MI.cjs`),n=require(`./_plugin-vue_export-helper-CX7YVcP6.cjs`),r=require(`./zIndex-CH0jZ7U7.cjs`),i=require(`./useDragAutoScroll-BPnc7LEO.cjs`);let a=require(`vue`),o=require(`prosemirror-state`),s=require(`@eigenpal/docx-editor-core/layout-bridge`),c=require(`@eigenpal/docx-editor-core/prosemirror/queries`),l=require(`@eigenpal/docx-editor-core/prosemirror`),u=require(`@eigenpal/docx-editor-core/utils`),d=require(`@eigenpal/docx-editor-core/prosemirror/plugins/selectionTracker`),f=require(`@eigenpal/docx-editor-core/prosemirror/commands/formatting`),p=require(`@eigenpal/docx-editor-core/prosemirror/extensions/nodes/TableExtension`),m=require(`@eigenpal/docx-editor-core/layout-bridge/clickToPositionDom`),h=require(`@eigenpal/docx-editor-core/prosemirror/imageCommit`),g=require(`@eigenpal/docx-editor-core/layout-painter`),_=require(`@eigenpal/docx-editor-core/prosemirror/conversion`),v=require(`@eigenpal/docx-editor-core/utils/units`),y=require(`@eigenpal/docx-editor-core/types/document`),b=require(`@eigenpal/docx-editor-core/prosemirror/plugins`),x=require(`@eigenpal/docx-editor-core/layout-engine`),S=require(`@eigenpal/docx-editor-core/prosemirror/commands`),C=require(`@eigenpal/docx-editor-core/prosemirror/commands/paragraph`),w=require(`@eigenpal/docx-editor-core/prosemirror/styles`),T=require(`@eigenpal/docx-editor-core/docx`),E=require(`@eigenpal/docx-editor-core/prosemirror/commands/pageBreak`),D=require(`@eigenpal/docx-editor-core/prosemirror/commands/sectionBreak`),O=require(`@eigenpal/docx-editor-core/prosemirror/applyFormatting`),k=require(`@eigenpal/docx-editor-core/utils/headingCollector`),A=require(`@eigenpal/docx-editor-core/prosemirror/commentOps`),j=require(`@eigenpal/docx-editor-core/prosemirror/commentIdAllocator`),M=require(`@eigenpal/docx-editor-core/prosemirror/utils/extractTrackedChanges`),N=require(`@eigenpal/docx-editor-core/layout-bridge/tableInsertHover`),P=require(`@eigenpal/docx-editor-core/prosemirror/cellDragSelection`),F=require(`@eigenpal/docx-editor-core/utils/reportIssue`),I=require(`@eigenpal/docx-editor-core/agent`),L=require(`@eigenpal/docx-editor-core/prosemirror/paraText`),R=require(`@eigenpal/docx-editor-core`),z=require(`@eigenpal/docx-editor-core/plugin-api/RenderedDomContext`);function ee(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 B(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 te(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 V(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=B(e,t,r);if(!i)return;let a=i.textContent||``,o=Number(i.dataset.pmStart)||0,[s,c]=(0,u.findWordBoundaries)(a,t-o),l=o+s,d=o+c;l<d&&n(l,d)}function re(e,t,n,r){if(!e)return;let i=B(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,z.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))}});function ae(e){let t=Math.max(0,e.parentOffsetWidth-e.parentClientWidth)/2,n=e.zoom||1;return{left:(e.imageRect.left-e.parentRect.left-t+e.scrollLeft)/n,top:(e.imageRect.top-e.parentRect.top+e.scrollTop)/n,width:e.imageRect.width/n,height:e.imageRect.height/n}}var oe=[`data-handle`,`onMousedown`],se=[`title`],ce={key:0,class:`image-overlay__dim`},le={key:1,class:`image-overlay__dim image-overlay__dim--rotate`},ue=4,de=15,fe=250,H=700,pe=(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.u(),c=t,l=n,d=(0,a.ref)(null),f=(0,a.ref)(!1),p=(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,g.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();x.value=ae({imageRect:e.getBoundingClientRect(),parentRect:n,scrollLeft:t.scrollLeft,scrollTop:t.scrollTop,parentOffsetWidth:t.offsetWidth,parentClientWidth:t.clientWidth,zoom:c.zoom})}let F=null;function I(){F?.();let e=0,t=``,n=0,r=0,i=a=>{r===0&&(r=a);let o=a-r;P();let s=x.value,c=s?`${s.left}|${s.top}|${s.width}|${s.height}`:``;n=c===t?n+1:0,t=c,!(o>=fe&&n>=2)&&o<H&&(e=requestAnimationFrame(i))};e=requestAnimationFrame(i);let a=setTimeout(P,fe);F=()=>{cancelAnimationFrame(e),clearTimeout(a)}}(0,a.watch)(()=>c.imageInfo,(e,t,n)=>{if(!c.imageInfo){x.value=null;return}I(),n(()=>F?.())},{immediate:!0}),(0,a.watch)(()=>c.zoom,()=>{c.imageInfo&&I()}),(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});let o=null,s=!1;(0,a.nextTick)(()=>{if(s||!c.imageInfo)return;let e=M();e&&(o=new MutationObserver(()=>I()),o.observe(e,{attributes:!0,attributeFilter:[`style`]}))}),n(()=>{s=!0,i?.removeEventListener(`scroll`,r),window.removeEventListener(`resize`,r),o?.disconnect(),O&&cancelAnimationFrame(O)})},{immediate:!0});let L=(0,a.computed)(()=>f.value?v.value:x.value?.width||0),R=(0,a.computed)(()=>f.value?y.value:x.value?.height||0),z=(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`}}),ee=(0,a.computed)(()=>{let e=L.value,t=R.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`}}]});function B(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,l(`interact-start`),document.addEventListener(`mousemove`,te),document.addEventListener(`mouseup`,V))}function te(e){let t=c.zoom,n=(e.clientX-C)/t,r=(e.clientY-w)/t,i=!e.shiftKey,a=(0,h.calculateResizedImageDimensions)(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 V(){document.removeEventListener(`mousemove`,te),document.removeEventListener(`mouseup`,V),f.value=!1,D=null,l(`interact-end`);let e=c.view,t=c.imageInfo;if(!e||!t){P();return}let n=(0,h.commitImageResize)(e,t.pmPos,v.value,y.value);n!==null&&K(n),(0,a.nextTick)(()=>P())}let ne=0,re=0,ie=0,pe=0,me=null,U=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 _e(e,t){return Math.atan2(e-ne,-(t-re))*180/Math.PI}function ve(e){if(!c.imageInfo)return;let t=c.imageInfo.element.getBoundingClientRect();ne=t.left+t.width/2,re=t.top+t.height/2;let n=j(c.view,c.imageInfo.pmPos);me=n&&n.attrs.transform||null,pe=he(me),U=c.imageInfo.element.querySelector(`img`),ie=_e(e.clientX,e.clientY),b.value=pe,_.value=!0,l(`interact-start`),document.addEventListener(`mousemove`,ye),document.addEventListener(`mouseup`,be)}function ye(e){let t=_e(e.clientX,e.clientY)-ie,n=pe+t;e.shiftKey||(n=Math.round(n/de)*de),b.value=(n%360+360)%360,U&&(U.style.transform=ge(me,b.value)||``)}function be(){document.removeEventListener(`mousemove`,ye),document.removeEventListener(`mouseup`,be),_.value=!1,l(`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:ge(n.attrs.transform,b.value)})),K(t.pmPos))}catch{}finally{U&&(U.style.transform=``),U=null,me=null}(0,a.nextTick)(()=>P())}let W=null;function xe(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)<ue)){if(!i){i=!0,p.value=!0,l(`interact-start`),W=document.createElement(`div`),W.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;W.style.width=`${r.width*e}px`,W.style.height=`${r.height*e}px`,document.body.appendChild(W)}if(W){let t=c.zoom;W.style.left=`${e.clientX-r.width*t/2}px`,W.style.top=`${e.clientY-r.height*t/2}px`}}},o=e=>{document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o),k=null,A=null,W&&=(W.remove(),null),p.value=!1,i&&(l(`interact-end`),G(e.clientX,e.clientY))};k=a,A=o,document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o)}function G(e,t){let n=c.view,r=c.imageInfo;if(!n||!r)return;let i=j(n,r.pmPos);if(i){if((0,h.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,l=(0,u.pixelsToEmu)((e-o.left)/s),f=(0,u.pixelsToEmu)((t-o.top)/s),p=(0,h.commitImageFloatMove)(n,r.pmPos,l,f);p!==null&&K(p)}else{let i=M();if(!i)return;let a=(0,m.clickToPositionDom)(i,e,t,1);if(a==null||a<0)return;let o=(0,h.commitImageInlineMove)(n,r.pmPos,a);o!==null&&K(o)}(0,a.nextTick)(()=>P())}}function K(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`,te),document.removeEventListener(`mouseup`,V),document.removeEventListener(`mousemove`,ye),document.removeEventListener(`mouseup`,be),k&&document.removeEventListener(`mousemove`,k),A&&document.removeEventListener(`mouseup`,A),W&&=(W.remove(),null),O&&cancelAnimationFrame(O),F?.()}),(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)(z.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:p.value?`grabbing`:`grab`}),onMousedown:n[0]||=(0,a.withModifiers)(e=>xe(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)(ee.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=>B(t,e.pos),[`prevent`,`stop`])},null,44,oe))),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:`${L.value/2-7}px`}),title:(0,a.unref)(i)(`imageOverlay.rotate`),onMousedown:n[2]||=(0,a.withModifiers)(e=>ve(e),[`prevent`,`stop`])},null,44,se),f.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,ce,(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`,le,(0,a.toDisplayString)(Math.round(b.value))+`° `,1)):(0,a.createCommentVNode)(``,!0)],36)):(0,a.createCommentVNode)(``,!0)}}),me=n.t(pe,[[`__scopeId`,`data-v-a3e3aca1`]]),U={class:`doc-outline__header`},he={class:`doc-outline__body`},ge={key:0,class:`doc-outline__empty`},_e=[`onMousedown`],ve=(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`,U,[(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.f,{name:`arrow_back`,size:20})]),r[2]||=(0,a.createElementVNode)(`span`,{class:`doc-outline__title`},`Document Outline`,-1)]),(0,a.createElementVNode)(`div`,he,[t.headings.length===0?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,ge,` 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,_e))),128))])],32)):(0,a.createCommentVNode)(``,!0)}}),ye=n.t(ve,[[`__scopeId`,`data-v-d3dae0f1`]]),be=(0,a.defineComponent)({__name:`PageIndicator`,props:{currentPage:{},totalPages:{},visible:{type:Boolean}},setup(t){let{t:n}=e.u();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))}}),W=n.t(be,[[`__scopeId`,`data-v-877b9ee2`]]),xe={class:`hf-editor__label`},G={class:`hf-editor__actions`,style:{position:`relative`}},K=(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=l.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 u(){n.view&&(r(`save`,(0,_.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`,xe,(0,a.toDisplayString)(e.position===`header`?`Header`:`Footer`),1),(0,a.createElementVNode)(`div`,G,[(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)}}),Se=n.t(K,[[`__scopeId`,`data-v-81468575`]]),Ce=[`role`],we={key:0,class:`layout-sdt-widget-empty`},Te=[`aria-selected`,`onClick`],Ee=[`value`],De=`.layout-sdt-widget, .layout-inline-sdt-widget`,Oe=(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}function n(e){if(e==null||e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function r(e){let r=t(e.dataset.sdtGroupId)??n(e.dataset.sdtPos),i=e.dataset.sdtTag;return r==null?i?{tag:i}:null:i?{pos:r,tag:i}:{pos:r}}let i=e,o=(0,a.ref)(null),s=(0,a.ref)(null);function c(e,t){let n=i.view;if(n)try{let r=e.pos==null?e.tag?(0,l.setContentControlValueTr)(n.state,{tag:e.tag},t):null:(0,l.setContentControlValueAtPosTr)(n.state,e.pos,t);if(!r)return;n.dispatch(r),n.focus()}catch{}o.value=null}function u(e){let n=i.view,r=t(e.dataset.sdtGroupId);if(!(!n||r==null))try{let t=e.dataset.sdtRepeat===`add`?(0,l.addRepeatingSectionItemTr)(n.state,r):(0,l.removeRepeatingSectionItemTr)(n.state,r);n.dispatch(t),n.focus()}catch{}}function d(e){let t=e.target;(t?.closest?.(De)||t?.closest?.(`.layout-sdt-repeat-btn`))&&e.preventDefault()}function f(e){let t=i.view,n=e.dataset.sdtWidget,a=r(e);if(!t||!n||!a)return;let s=a.pos==null?a.tag?(0,l.findContentControlsInPM)(t.state.doc,{tag:a.tag})[0]:void 0:(0,l.findContentControlsInPM)(t.state.doc).find(e=>e.pos===a.pos),u=e.getBoundingClientRect();n===`checkbox`?c(a,{kind:`checkbox`,checked:!s?.checked}):n===`dropdown`?o.value={kind:`dropdown`,target:a,items:s?.listItems??[],current:s?.text??``,x:u.left,y:u.bottom+2}:n===`date`&&(o.value={kind:`date`,target:a,current:s?.dateValue??``,x:u.left,y:u.bottom+2})}function p(e){let t=e.target?.closest?.(`.layout-sdt-repeat-btn`);if(t){e.preventDefault(),e.stopPropagation(),u(t);return}let n=e.target?.closest?.(De);n&&(e.preventDefault(),e.stopPropagation(),f(n))}function m(e){if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target?.closest?.(De);t&&(e.preventDefault(),f(t))}function h(e){o.value&&!s.value?.contains(e.target)&&(o.value=null)}function g(e){e.key===`Escape`&&(o.value=null)}let _=null;(0,a.watch)(()=>i.container,e=>{_&&(_.removeEventListener(`mousedown`,d),_.removeEventListener(`click`,p),_.removeEventListener(`keydown`,m)),_=e??null,_&&(_.addEventListener(`mousedown`,d),_.addEventListener(`click`,p),_.addEventListener(`keydown`,m))},{immediate:!0}),(0,a.watch)(o,e=>{e?(document.addEventListener(`mousedown`,h),document.addEventListener(`keydown`,g),e.kind===`dropdown`&&(0,a.nextTick)(()=>{let e=s.value?.querySelectorAll(`.layout-sdt-widget-option`);e?.length&&([...e].find(e=>e.getAttribute(`aria-selected`)===`true`)??e[0]).focus()})):(document.removeEventListener(`mousedown`,h),document.removeEventListener(`keydown`,g))});function v(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=[...s.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)(()=>{_&&(_.removeEventListener(`mousedown`,d),_.removeEventListener(`click`,p),_.removeEventListener(`keydown`,m)),document.removeEventListener(`mousedown`,h),document.removeEventListener(`keydown`,g)});function y(e){let t=e.target.value;t&&o.value&&c(o.value.target,{kind:`date`,date:t})}return(e,t)=>o.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,ref_key:`popupEl`,ref:s,class:`layout-sdt-widget-popup`,role:o.value.kind===`dropdown`?`listbox`:void 0,style:(0,a.normalizeStyle)({position:`fixed`,top:o.value.y+`px`,left:o.value.x+`px`,zIndex:1e3}),onKeydown:v,onMousedown:t[0]||=(0,a.withModifiers)(()=>{},[`prevent`])},[o.value.kind===`dropdown`?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:0},[o.value.items.length===0?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,we,`No options`)):(0,a.createCommentVNode)(``,!0),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(o.value.items,e=>((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:e.value,type:`button`,role:`option`,"aria-selected":e.displayText===o.value.current,class:(0,a.normalizeClass)([`layout-sdt-widget-option`,{"is-selected":e.displayText===o.value.current}]),onClick:t=>c(o.value.target,{kind:`dropdown`,value:e.value})},(0,a.toDisplayString)(e.displayText),11,Te))),128))],64)):((0,a.openBlock)(),(0,a.createElementBlock)(`input`,{key:1,type:`date`,class:`layout-sdt-widget-date`,value:o.value.current,onChange:y},null,40,Ee))],44,Ce)):(0,a.createCommentVNode)(``,!0)}}),ke={key:0,class:`docx-editor-vue__title-bar`},q={class:`docx-editor-vue__title-bar-left`},Ae={class:`docx-editor-vue__title-bar-center`},je={class:`docx-editor-vue__title-bar-right`},Me=(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`,ke,[(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`,Ae,[(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`,je,[(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)}}),Ne=[`aria-label`],J={class:`wm-header`},Pe={class:`wm-body`},Fe={class:`wm-radio-row`},Ie=[`checked`],Le={for:`wm-none`,class:`wm-inline-label`},Re={class:`wm-radio-row`},ze=[`checked`],Be={for:`wm-picture`,class:`wm-inline-label`},Ve={key:0,class:`wm-subform`},He={class:`wm-row`},Ue={key:0,class:`wm-row`},We=[`src`],Ge={class:`wm-row`},Ke={class:`wm-label`},qe={class:`wm-inline-label`},Je={class:`wm-radio-row`},Ye=[`checked`],Xe={for:`wm-text`,class:`wm-inline-label`},Ze={key:1,class:`wm-subform`},Qe={key:0,class:`wm-row`},$e={class:`wm-label`},et=[`value`],tt=[`value`],nt={class:`wm-row`},rt={class:`wm-label`},it={class:`wm-row`},at={class:`wm-label`},ot=[`value`],st={class:`wm-row`},ct={class:`wm-label`},lt={class:`wm-inline-label`},ut={class:`wm-row`},dt={class:`wm-label`},ft={class:`wm-row`},pt={class:`wm-label`},mt={class:`wm-inline-label`},ht=[`checked`],gt={class:`wm-inline-label`},_t=[`checked`],vt={class:`wm-inline-label`},yt={class:`wm-footer`},bt=[`disabled`],xt=(0,a.defineComponent)({__name:`WatermarkDialog`,props:{isOpen:{type:Boolean},current:{},presets:{default:()=>y.DEFAULT_WATERMARK_PRESETS}},emits:[`close`,`apply`],setup(t,{emit:n}){let r=[`Calibri`,`Arial`,`Times New Roman`,`Georgia`,`Verdana`,`Courier New`],{t:i}=e.u(),o=t,s=(0,a.computed)(()=>o.presets),c=n,l=(0,a.ref)(`none`),u=(0,a.ref)(o.presets[0]??`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),v=(0,a.ref)(void 0),b=(0,a.ref)(100),x=(0,a.ref)(!0);(0,a.watch)(()=>o.isOpen,e=>{if(!e)return;let t=o.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,v.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,v.value=void 0,!e)return;let t=new Image;t.onload=()=>{v.value=(0,y.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,...v.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)(i)(`dialogs.watermark.title`),onMousedown:n[13]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createElementVNode)(`div`,J,(0,a.toDisplayString)((0,a.unref)(i)(`dialogs.watermark.title`)),1),(0,a.createElementVNode)(`div`,Pe,[(0,a.createElementVNode)(`div`,Fe,[(0,a.createElementVNode)(`input`,{id:`wm-none`,type:`radio`,checked:l.value===`none`,onChange:n[0]||=e=>l.value=`none`},null,40,Ie),(0,a.createElementVNode)(`label`,Le,(0,a.toDisplayString)((0,a.unref)(i)(`dialogs.watermark.noWatermark`)),1)]),(0,a.createElementVNode)(`div`,Re,[(0,a.createElementVNode)(`input`,{id:`wm-picture`,type:`radio`,checked:l.value===`picture`,onChange:n[1]||=e=>l.value=`picture`},null,40,ze),(0,a.createElementVNode)(`label`,Be,(0,a.toDisplayString)((0,a.unref)(i)(`dialogs.watermark.picture`)),1)]),l.value===`picture`?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Ve,[(0,a.createElementVNode)(`div`,He,[(0,a.createElementVNode)(`input`,{type:`file`,accept:`image/*`,onChange:w},null,32)]),_.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Ue,[(0,a.createElementVNode)(`img`,{src:_.value,alt:``,class:`wm-preview`},null,8,We)])):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,Ge,[(0,a.createElementVNode)(`span`,Ke,(0,a.toDisplayString)((0,a.unref)(i)(`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`,qe,[(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)(i)(`dialogs.watermark.washout`)),1)])])):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,Je,[(0,a.createElementVNode)(`input`,{id:`wm-text`,type:`radio`,checked:l.value===`text`,onChange:n[4]||=e=>l.value=`text`},null,40,Ye),(0,a.createElementVNode)(`label`,Xe,(0,a.toDisplayString)((0,a.unref)(i)(`dialogs.watermark.text`)),1)]),l.value===`text`?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Ze,[s.value.length>0?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Qe,[(0,a.createElementVNode)(`span`,$e,(0,a.toDisplayString)((0,a.unref)(i)(`dialogs.watermark.presetLabel`)),1),(0,a.createElementVNode)(`select`,{class:`wm-input`,value:s.value.includes(u.value)?u.value:``,onChange:C},[n[15]||=(0,a.createElementVNode)(`option`,{value:``},`—`,-1),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(s.value,e=>((0,a.openBlock)(),(0,a.createElementBlock)(`option`,{key:e,value:e},(0,a.toDisplayString)(e),9,tt))),128))],40,et)])):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,nt,[(0,a.createElementVNode)(`span`,rt,(0,a.toDisplayString)((0,a.unref)(i)(`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`,it,[(0,a.createElementVNode)(`span`,at,(0,a.toDisplayString)((0,a.unref)(i)(`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)(r,e=>(0,a.createElementVNode)(`option`,{key:e,value:e},(0,a.toDisplayString)(e),9,ot)),64))],512),[[a.vModelSelect,d.value]])]),(0,a.createElementVNode)(`div`,st,[(0,a.createElementVNode)(`span`,ct,(0,a.toDisplayString)((0,a.unref)(i)(`dialogs.watermark.sizeLabel`)),1),(0,a.createElementVNode)(`label`,lt,[(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)(i)(`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`,ut,[(0,a.createElementVNode)(`span`,dt,(0,a.toDisplayString)((0,a.unref)(i)(`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`,ft,[(0,a.createElementVNode)(`span`,pt,(0,a.toDisplayString)((0,a.unref)(i)(`dialogs.watermark.layoutLabel`)),1),(0,a.createElementVNode)(`label`,mt,[(0,a.createElementVNode)(`input`,{type:`radio`,name:`wm-layout`,checked:h.value===`diagonal`,onChange:n[10]||=e=>h.value=`diagonal`},null,40,ht),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(i)(`dialogs.watermark.diagonal`)),1)]),(0,a.createElementVNode)(`label`,gt,[(0,a.createElementVNode)(`input`,{type:`radio`,name:`wm-layout`,checked:h.value===`horizontal`,onChange:n[11]||=e=>h.value=`horizontal`},null,40,_t),(0,a.createTextVNode)(` `+(0,a.toDisplayString)((0,a.unref)(i)(`dialogs.watermark.horizontal`)),1)])]),(0,a.createElementVNode)(`label`,vt,[(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)(i)(`dialogs.watermark.semitransparent`)),1)])])):(0,a.createCommentVNode)(``,!0)]),(0,a.createElementVNode)(`div`,yt,[(0,a.createElementVNode)(`button`,{type:`button`,class:`wm-btn`,onClick:T},(0,a.toDisplayString)((0,a.unref)(i)(`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)(i)(`dialogs.watermark.applyButton`)),11,bt)])],40,Ne)],32)):(0,a.createCommentVNode)(``,!0)}}),St=n.t(xt,[[`__scopeId`,`data-v-cf7e36c1`]]),Ct=(0,a.defineComponent)({__name:`DocxEditorDialogs`,props:{view:{},bookmarks:{},selectedImagePmPos:{},sectionProperties:{},scrollVisiblePositionIntoView:{type:Function},showFindReplace:{type:Boolean},showHyperlink:{type:Boolean},showInsertSymbol:{type:Boolean},showImageProperties:{type:Boolean},showPageSetup:{type:Boolean},showWatermark:{type:Boolean},currentWatermark:{},watermarkPresets:{},showKeyboardShortcuts:{type:Boolean}},emits:[`update:showFindReplace`,`update:showHyperlink`,`update:showInsertSymbol`,`update:showImageProperties`,`update:showPageSetup`,`update:showWatermark`,`update:showKeyboardShortcuts`,`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.o,{"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.a,{"is-open":t.showHyperlink,view:t.view,bookmarks:t.bookmarks,onClose:i[1]||=e=>r(`update:showHyperlink`,!1),onSubmit:i[2]||=e=>r(`hyperlink-submit`,e),onRemove:i[3]||=e=>r(`hyperlink-remove`)},null,8,[`is-open`,`view`,`bookmarks`]),(0,a.createVNode)(e.i,{"is-open":t.showInsertSymbol,onClose:i[4]||=e=>r(`update:showInsertSymbol`,!1),onInsert:i[5]||=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[6]||=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[7]||=e=>r(`update:showPageSetup`,!1),onApply:i[8]||=e=>r(`page-setup-apply`,e)},null,8,[`is-open`,`section-properties`]),(0,a.createVNode)(St,{"is-open":t.showWatermark,current:t.currentWatermark,presets:t.watermarkPresets,onClose:i[9]||=e=>r(`update:showWatermark`,!1),onApply:i[10]||=e=>r(`watermark-apply`,e)},null,8,[`is-open`,`current`,`presets`]),(0,a.createVNode)(e.t,{"is-open":t.showKeyboardShortcuts,onClose:i[11]||=e=>r(`update:showKeyboardShortcuts`,!1)},null,8,[`is-open`])],64))}}),wt=[`disabled`,`onMousedown`],Tt={class:`ctx-menu__label`},Et={key:0,class:`ctx-menu__shortcut`},Dt=220,Ot=32,kt=10,At=(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.u(),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*Ot+i*9;return typeof window<`u`&&(e+Dt+kt>window.innerWidth&&(e=window.innerWidth-Dt-kt),t+a+kt>window.innerHeight&&(t=window.innerHeight-a-kt)),{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`,Tt,(0,a.toDisplayString)(e.label),1),e.shortcut?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,Et,(0,a.toDisplayString)(e.shortcut),1)):(0,a.createCommentVNode)(``,!0)],42,wt))),128))],36)):(0,a.createCommentVNode)(``,!0)]))}}),jt=n.t(At,[[`__scopeId`,`data-v-852b8986`]]),Mt=[`aria-label`],Nt={class:`image-ctx-menu__icon`},Pt={class:`image-ctx-menu__label`},Ft={key:1,class:`image-ctx-menu__divider`,role:`separator`},It=[`data-wrap-type`,`data-current`,`data-disabled`,`disabled`,`title`,`onClick`],Lt={class:`image-ctx-menu__icon`},Rt={class:`image-ctx-menu__label`},zt=[`aria-label`],Bt=[`disabled`,`onClick`],Vt={class:`image-ctx-menu__label`},Ht={key:0,class:`image-ctx-menu__shortcut`},Ut={key:0,class:`image-ctx-menu__divider`,role:`separator`},Wt=18,Gt=260,Y=10,Kt=(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.u(),c=(0,a.ref)(null),l=g.IMAGE_LAYOUT_OPTIONS,u=(0,a.computed)(()=>r.state?(0,g.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=g.IMAGE_LAYOUT_OPTIONS.length*36+16,t=r.state.position.x,n=r.state.position.y;return typeof window<`u`&&(t+Gt>window.innerWidth&&(t=window.innerWidth-Gt-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:`${Gt}px`,zIndex:400}});function m(e){return r.state?(0,g.isImageLayoutOptionEnabled)(e,r.state.currentWrapType):!1}function h(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`,Nt,[(0,a.createVNode)(e.f,{name:`settings`,size:Wt})]),(0,a.createElementVNode)(`span`,Pt,(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`,Ft)):(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=>h(t)},[(0,a.createElementVNode)(`span`,Lt,[(0,a.createVNode)(e.f,{name:f(t.iconHint),size:Wt},null,8,[`name`])]),(0,a.createElementVNode)(`span`,Rt,(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,zt)):(0,a.createCommentVNode)(``,!0)],42,It))),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`,Vt,(0,a.toDisplayString)(e.label),1),e.shortcut?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,Ht,(0,a.toDisplayString)(e.shortcut),1)):(0,a.createCommentVNode)(``,!0)],40,Bt),e.dividerAfter?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Ut)):(0,a.createCommentVNode)(``,!0)],64))),128))],64)):(0,a.createCommentVNode)(``,!0)],44,Mt)):(0,a.createCommentVNode)(``,!0)]))}}),qt=n.t(Kt,[[`__scopeId`,`data-v-de904a04`]]),Jt=(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)(jt,{"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)(qt,{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))}}),Yt=[`href`,`title`],Xt=[`title`],Zt=[`title`],Qt=[`title`],$t={class:`docx-hyperlink-popup__edit-row`},X=[`placeholder`,`onKeydown`],en={class:`docx-hyperlink-popup__edit-row`},tn=[`onKeydown`],nn=[`disabled`],rn=(0,a.defineComponent)({__name:`HyperlinkPopup`,props:{data:{},readOnly:{type:Boolean}},emits:[`navigate`,`copy`,`edit`,`remove`,`close`],setup(t,{emit:n}){let{t:r}=e.u(),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`,$t,[(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,X),[[a.vModelText,c.value]])]),(0,a.createElementVNode)(`div`,en,[(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,tn),[[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,nn)])],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-084b4288><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-084b4288><circle cx="12" cy="12" r="10" data-v-084b4288></circle><path d="M2 12h20" data-v-084b4288></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-084b4288></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,Yt),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,Xt),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,Zt)),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-084b4288><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-084b4288></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-084b4288></path><line x1="8" y1="2" x2="8" y2="5" data-v-084b4288></line><line x1="2" y1="8" x2="5" y2="8" data-v-084b4288></line><line x1="16" y1="19" x2="16" y2="22" data-v-084b4288></line><line x1="19" y1="16" x2="22" y2="16" data-v-084b4288></line></svg>`,1)]],8,Qt))],64))],38)):(0,a.createCommentVNode)(``,!0)}}),an=n.t(rn,[[`__scopeId`,`data-v-084b4288`]]);function on(e){let t=(0,a.ref)(null),n=(0,a.ref)(null);function r(t){let n=t.target,r=n.files?.[0],i=e.getActiveView();r&&i&&(0,S.insertImageFromFile)(i,r,{onError:t=>e.emit(`error`,t instanceof Error?t:Error(`Failed to insert image`))}),n.value=``}async function i(){await e.nextTick(),e.extractCommentsAndChanges(),e.emit(`ready`)}async function o(t){try{let n=await(0,u.readDocxFileFromInput)(t);if(!n)return;await e.loadBuffer(n.buffer),e.emit(`update:document`,e.getDocument()),e.emit(`rename`,n.name),await i()}catch(t){e.emit(`error`,t instanceof Error?t:Error(`Failed to open document`))}}function s(t){e.onDocumentNameChange?.(t),e.emit(`rename`,t)}async function c(){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 l(t){await e.loadBuffer(t),e.emit(`update:document`,e.getDocument()),await i()}function d(t){e.loadParsedDocument(t),e.emit(`update:document`,t),i()}async function f(){let t=await e.saveBlob();return t?t.arrayBuffer():null}return{docxInputRef:t,imageInputRef:n,handleImageFileChange:r,handleDocxFileChange:o,handleDocumentNameChange:s,downloadCurrentDocument:c,emitReadyAfterSidebarStateRefresh:i,loadDocumentBuffer:l,loadDocument:d,save:f}}function sn(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,f.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]),d=i.state.tr.replaceWith(a.start,a.end,u);i.dispatch(d.scrollIntoView()),t.value=null,i.focus()}function s(){let n=e.editorView.value;if(!n)return;let r=(0,f.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 cn(e){let t=()=>e.activeView?.value??e.editorView.value;function n(){let e=t();e&&((0,f.clearFormatting)(e.state,e.dispatch,e),e.focus())}function r(n){let r=t();if(!r)return;let i=e.getDocument(),a=i?.package?.styles;if(a){let e=(0,w.createStyleResolver)(a).resolveParagraphStyle(n);(0,C.applyStyle)(n,{paragraphFormatting:e.paragraphFormatting,runFormatting:e.runFormatting,numbering:i?.package?.numbering?(0,T.getCachedNumberingMap)(i.package.numbering):null})(r.state,e=>r.dispatch(e))}else (0,C.applyStyle)(n)(r.state,e=>r.dispatch(e));r.focus()}function i(){let t=e.editorView.value;t&&((0,E.insertPageBreak)(t.state,e=>t.dispatch(e),t),t.focus())}function a(){let t=e.editorView.value;t&&((0,D.insertSectionBreakNextPage)(t.state,e=>t.dispatch(e),t),t.focus())}function o(){let t=e.editorView.value;t&&((0,D.insertSectionBreakContinuous)(t.state,e=>t.dispatch(e),t),t.focus())}function s(e){let n=t();if(!n)return;let{from:r}=n.state.selection,i=n.state.tr.insertText(e,r);n.dispatch(i.scrollIntoView()),n.focus()}function c(t){let n=e.editorView.value;return n?(0,O.applyFormatting)(n,t):!1}function l(t){let n=e.editorView.value;if(!n)return!1;let r=e.getDocument();return(0,O.setParagraphStyle)(n,t,{styleResolver:r?.package?.styles?(0,w.createStyleResolver)(r.package.styles):null,numbering:r?.package?.numbering?(0,T.getCachedNumberingMap)(r.package.numbering):null})}function u(t){let n=e.editorView.value;return n?(0,O.insertBreak)(n,t):!1}return{handleClearFormatting:n,handleApplyStyle:r,handleInsertPageBreak:i,handleInsertSectionBreakNextPage:a,handleInsertSectionBreakContinuous:o,handleInsertSymbol:s,applyFormatting:c,setParagraphStyle:l,insertBreak:u}}function ln(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,C.setIndentLeft)(t)(n.state,n.dispatch)}function c(t){let n=e.editorView.value;n&&(0,C.setIndentRight)(t)(n.state,n.dispatch)}function l(t){let n=e.editorView.value;n&&(t<0?(0,C.setIndentFirstLine)(-t,!0)(n.state,n.dispatch):(0,C.setIndentFirstLine)(t,!1)(n.state,n.dispatch))}function u(t){let n=e.editorView.value;n&&(0,C.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 un(e){let t=(0,a.ref)(!1),n=(0,a.computed)(()=>{e.stateTick.value;let t=e.editorView.value;return t?(0,S.getWatermarkFromState)(t.state)??void 0:void 0});function r(t){if(e.readOnly.value)return;let n=e.editorView.value;n&&((0,S.setWatermark)(t)(n.state,n.dispatch),e.stateTick.value++,n.focus())}return{showWatermark:t,currentWatermark:n,handleWatermarkApply:r}}function dn(e){function t(){if(!e.showOutline.value){let t=e.editorView.value;t&&(e.outlineHeadings.value=(0,k.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 fn(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 pn(e){let t=()=>(0,a.unref)(e.author)??`User`;function n(t){e.comments.value=t,e.commentCallbacks?.onCommentsChange?.(t)}function r(){(0,j.seedCommentAllocator)(e.commentIdAllocator,e.getDocument()?.package?.document?.comments,e.editorView.value)}function i(t,n,i){return r(),(0,A.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,A.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,A.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,S.acceptChange)(t,n)(r.state,r.dispatch),e.extractCommentsAndChanges(),r.focus())}function h(t,n){let r=e.editorView.value;r&&((0,S.rejectChange)(t,n)(r.state,r.dispatch),e.extractCommentsAndChanges(),r.focus())}function g(t){let n=e.editorView.value;n&&((0,S.acceptChangeById)(t)(n.state,n.dispatch),e.extractCommentsAndChanges(),n.focus())}function _(t){let n=e.editorView.value;n&&((0,S.rejectChangeById)(t)(n.state,n.dispatch),e.extractCommentsAndChanges(),n.focus())}function v(r,a){let o=e.getDocument();if(!o?.package?.document)return;o.package.document.comments||(o.package.document.comments=[]);let s=i(a,t(),r);o.package.document.comments.push(s),n([...o.package.document.comments]),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 mn(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 hn(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,M.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=B(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===j.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:j.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,j.seedCommentAllocator)(e.commentIdAllocator,i.package.document.comments,o);let s=(0,A.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 gn(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(n){let r=e.editorView.value,i=t.value;if(!r||!i)return;let a=(0,g.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,g.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 o(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,handleToolbarImageWrap:i,handleImageTransform:o}}function _n(e,t,n){let r=(0,b.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 vn(e,t){return e.getBlob(t)}function Z(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 yn(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 vn(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);_n(e,c,s),e.dispatch(c);return}if(n.types.includes(`text/html`)){let t=await(await vn(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);_n(e,l,c),e.dispatch(l);return}}if(n.types.includes(`text/plain`)){let t=await(await vn(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 bn(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 xn(t){let{t:n}=e.u(),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,g.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,g.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,p.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,g.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){Z(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?Z(n,t.selectedImage.value.pmPos):document.execCommand(`copy`);break;case`paste`:yn(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&&bn(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 Sn=500;function Cn(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=(0,P.createCellDragTracker)(),m=i.t({pagesContainer:e.pagesRef,onScrollExtendSelection:(e,t)=>{if(!d||f===null)return;let n=v(e,t);n!==null&&n!==f&&b(f,n)}}),h=(0,a.ref)({currentPage:1,totalPages:1,visible:!1}),_=null;function v(t,n){return V(e.pagesRef.value,e.editorView.value,t,n)}function y(){let t=s.value;if(t?.headerFooter&&e.getHfPmView){let n=e.getHfPmView(t.headerFooter);if(n)return n}return e.editorView.value}function b(e,t){let n=y();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 x(t){te(e.pagesRef.value,e.pagesViewportRef.value,t)}function S(t){ne(e.pagesRef.value,t,b,s.value?.position)}function C(t){re(e.pagesRef.value,t,b,s.value?.position)}function w(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){x(r);try{b(Math.min(r+1,n.state.doc.content.size))}catch{b(r)}}}function T(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,N.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},N.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 E(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 D(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&&w(e);return}let i=y();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 O(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 k(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 A(){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=y()??n;if(!e.readOnly.value&&e.tableResize.tryStartResize(t,i))return;let a=(0,g.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 m=v(t.clientX,t.clientY);if(m===null){i.focus();return}let h=Date.now();if(h-c<Sn&&l===m?u++:u=1,c=h,l=m,u===2)S(m);else if(u>=3)C(m),u=0;else{if(t.shiftKey){let{from:e}=i.state.selection;b(e,m)}else b(m);f=m,d=!0,p.begin((0,P.findCellPosFromPmPos)(i,m))}i.focus()}function M(e){if(!d||f===null)return;let t=v(e.clientX,e.clientY);if(t!==null){let n=y();if(n&&p.update(n,t,e.clientX)){m.updateMousePosition(e.clientX,e.clientY);return}t!==f&&b(f,t)}m.updateMousePosition(e.clientX,e.clientY)}function F(){d=!1,p.end(),m.stopAutoScroll()}function I(){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},_&&clearTimeout(_),_=setTimeout(()=>{h.value={...h.value,visible:!1}},600)}return(0,a.onMounted)(()=>{window.addEventListener(`mousemove`,M),window.addEventListener(`mouseup`,F),e.pagesViewportRef.value?.addEventListener(`scroll`,I,{passive:!0})}),(0,a.onBeforeUnmount)(()=>{r(),window.removeEventListener(`mousemove`,M),window.removeEventListener(`mouseup`,F),e.pagesViewportRef.value?.removeEventListener(`scroll`,I),_&&clearTimeout(_)}),{tableInsertButton:t,hfEdit:s,scrollPageInfo:h,resolvePos:v,setPmSelection:b,scrollVisiblePositionIntoView:x,navigateToBookmark:w,handlePagesMouseDown:j,handlePagesMouseMove:T,handlePagesClick:D,handlePagesDoubleClick:O,handleTableInsertClick:E,clearTableInsertTimer:r,handleHfSave:k,handleHfRemove:A}}function wn(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,g.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:p}=u,h=i.scrollTop,g=i.scrollLeft,_=e.zoom.value||1;if(p){let e=(0,m.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;
5
5
  width: 2px;
6
6
  height: ${e.height}px;
7
- background: #000;
7
+ background: var(--doc-caret, #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,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=`
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,m.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 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)([]),z=(0,a.shallowRef)([]),ne=(0,a.shallowRef)([]),{zoom:B,zoomPercent:ie,isMinZoom:ae,isMaxZoom:oe,setZoom:se,zoomIn:ce,zoomOut:le,handleWheel:V,handleKeyDown:H,installShortcuts:de,ZOOM_PRESETS:fe}=i.r(f.initialZoom);de();let{editorView:U,isReady:me,parseError:W,layout:ge,loadBuffer:_e,loadDocument:ye,save:be,focus:xe,destroy:Se,getDocument:G,getCommands:K,reLayout:we,getHfPmView:Te,syncHfPMs:De,setHfTransactionListener:Oe,setDocument:ke}=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++;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:Ae}=on(f,U),q=(0,a.computed)(()=>{S.value;let e=G();if(!e?.package?.document)return null;let t=e.package.document;return t.finalSectionProperties??t.sections?.[0]?.properties??null}),J=(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,G()?.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?Te($.value.headerFooter)??null:null),Ie=(0,a.computed)(()=>Fe.value??U.value);(0,a.onMounted)(()=>{Oe((e,t)=>{S.value++,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?.()}$n.updateSelectionOverlay()});let e=0;function t(){!$.value||e||(e=requestAnimationFrame(()=>{e=0;let t=$.value;if(!t?.headerFooter)return;let n=Te(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 Le=(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`}}),Re=(0,a.computed)(()=>({paddingLeft:`20px`,paddingRight:20+(F.value?l.SIDEBAR_DOCUMENT_SHIFT*2:0)+`px`,transition:`padding 0.2s ease`})),ze=(0,a.computed)(()=>{let e=q.value;return(0,_.twipsToPixels)(e?.pageWidth??12240)*B.value}),Be=(0,a.computed)(()=>{let e=new Set;for(let t of R.value)t.parentId==null&&t.done&&e.add(t.id);return e}),Ve=(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))}),He=(0,O.createCommentIdAllocator)(),{floatingCommentBtn:Ue,pendingCommentRange:We,addCommentYPosition:Ge,sidebarAutoOpenedRef:Ke,extractCommentsAndChanges:qe,handleAddComment:Je,handleCancelAddComment:Ye,handleStartAddComment:Xe,handleMarkerClick:Ze}=sn({editorView:U,getDocument:G,comments:R,trackedChanges:z,resolvedCommentIds:Be,activeSidebarItem:L,showSidebar:F,isAddingComment:I,readOnly:h,zoom:B,stateTick:S,pagesRef:b,pagesViewportRef:x,emit:p,commentIdAllocator:He,author:g,commentCallbacks:Ae}),{docxInputRef:Qe,handleDocxFileChange:$e,handleDocumentNameChange:et,downloadCurrentDocument:tt,loadDocumentBuffer:nt,loadDocument:rt,save:it}=Zt({loadBuffer:_e,loadParsedDocument:ye,getDocument:G,saveBlob:be,extractCommentsAndChanges:qe,emit:p,documentName:()=>f.documentName,onDocumentNameChange:f.onDocumentNameChange,nextTick:a.nextTick}),{hyperlinkPopupData:at,handleHyperlinkSubmit:ot,handleHyperlinkRemove:st,handleHyperlinkPopupNavigate:ct,handleHyperlinkPopupEdit:lt,handleHyperlinkPopupRemove:ut}=Qt({editorView:U,getCommands:K}),{handleClearFormatting:dt,handleApplyStyle:ft,handleInsertPageBreak:pt,handleInsertSymbol:mt,applyFormatting:gt,setParagraphStyle:_t}=$t({editorView:U,activeView:Ie,getDocument:G}),{handlePageSetupApply:vt,handleLeftMarginChange:yt,handleRightMarginChange:bt,handleTopMarginChange:xt,handleBottomMarginChange:St,handleIndentLeftChange:Ct,handleIndentRightChange:wt,handleFirstLineIndentChange:Tt,handleTabStopRemove:Et}=en({editorView:U,getDocument:G,readOnly:h,stateTick:S,reLayout:we,emit:p}),{showWatermark:Dt,currentWatermark:Ot,handleWatermarkApply:kt}=tn({editorView:U,readOnly:h,stateTick:S}),{handleToggleOutline:At,handleOutlineNavigate:jt,handleToggleSidebar:Mt,handleEditorScrollMouseDown:Nt}=nn({editorView:U,showOutline:N,showSidebar:F,outlineHeadings:ne,activeSidebarItem:L,extractCommentsAndChanges:qe});rn({showKeyboardShortcuts:P,showFindReplace:E,showHyperlink:k,handleZoomKeyDown:H,disableFindReplaceShortcuts:()=>f.disableFindReplaceShortcuts});let{addComment:Pt,replyToComment:Ft,resolveComment:It,proposeChange:Lt,handleCommentReply:X,handleCommentResolve:Rt,handleCommentUnresolve:zt,handleCommentDelete:Vt,handleAcceptChange:Ht,handleRejectChange:Ut,handleAcceptChangeById:Wt,handleRejectChangeById:Gt,handleTrackedChangeReply:Kt}=an({editorView:U,getDocument:G,comments:R,trackedChanges:z,showSidebar:F,isAddingComment:I,pendingCommentRange:We,contentChangeSubscribers:C,extractCommentsAndChanges:qe,emit:p,commentIdAllocator:He,author:g,commentCallbacks:Ae}),{selectedImage:Z,imageInteracting:qt,imageToolbarContext:Jt,handleInsertImage:Yt,handleToolbarImageWrap:ln,handleImageTransform:un}=cn({editorView:U,zoom:B,stateTick:S,getCommands:K}),dn=i.n(),fn=null,{tableInsertButton:Q,hfEdit:$,scrollPageInfo:pn,resolvePos:hn,setPmSelection:kn,scrollVisiblePositionIntoView:An,handlePagesMouseDown:jn,handlePagesMouseMove:Mn,handlePagesClick:Nn,handlePagesDoubleClick:Pn,handleTableInsertClick:Fn,clearTableInsertTimer:In,handleHfSave:Ln,handleHfRemove:Rn}=gn({editorView:U,pagesRef:b,pagesViewportRef:x,selectedImage:Z,imageInteracting:qt,hyperlinkPopupData:at,readOnly:h,zoom:B,layout:ge,tableResize:dn,getCommands:K,getDocument:G,reLayout:we,emit:p,clearOverlay:Zn,syncHfPMs:De,getHfPmView:Te,setDocument:ke}),{contextMenu:zn,imageContextMenu:Bn,imageContextMenuTextActions:Vn,handleContextMenu:Hn,handleSelectedImageContextMenu:Un,handleImageWrapSelect:Wn,handleContextMenuAction:Gn}=mn({editorView:U,selectedImage:Z,zoom:B,showImageProperties:j,getCommands:K,clearOverlay:Zn,setPmSelection:kn,resolvePos:hn}),{handleMenuAction:Kn,handleMenuTableInsert:qn}=vn({editorView:U,getCommands:K,docxInputRef:Qe,showPageSetup:M,showWatermark:Dt,showInsertImage:D,showHyperlink:k,showInsertSymbol:A,showKeyboardShortcuts:P,handleClearFormatting:dt,handleInsertPageBreak:pt,handleToggleOutline:At,handleToggleSidebar:Mt,downloadCurrentDocument:tt,emit:p});yn({documentBuffer:()=>f.documentBuffer,document:()=>f.document,loadDocumentBuffer:nt,loadDocument:rt,sidebarAutoOpenedRef:Ke});let Jn=()=>U.value,Yn=()=>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 Xn(e){m.value!==e&&(m.value=e,p(`mode-change`,e))}(0,a.onMounted)(()=>{fn=dn.install()}),(0,a.onBeforeUnmount)(()=>{fn?.()});function Zn(){$n.clearOverlay()}function Qn(){$n.updateSelectionOverlay()}let $n=_n({editorView:U,pagesRef:b,zoom:B,selectedImage:Z,isHfEditing:(0,a.computed)(()=>$.value!==null),imageInteracting:qt}),er=T.onRender(()=>Qn());Qn(),(0,a.onBeforeUnmount)(()=>{er(),Zn()});let{exposed:tr}=bn({editorView:U,layout:ge,pagesRef:b,pagesViewportRef:x,zoom:B,comments:R,focus:xe,destroy:Se,getDocument:G,setZoom:se,save:it,loadDocument:rt,loadDocumentBuffer:nt,addComment:Pt,replyToComment:Ft,resolveComment:It,proposeChange:Lt,applyFormatting:gt,setParagraphStyle:_t,scrollVisiblePositionIntoView:An,contentChangeSubscribers:C,selectionChangeSubscribers:w,onPrint:f.onPrint});return r(tr),(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)(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)(et),onMenuAction:(0,a.unref)(Kn),onInsertTable:(0,a.unref)(qn)},{"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:Ie.value,"get-commands":(0,a.unref)(K),"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)(fe),"show-zoom-control":n.showZoomControl,"editor-mode":m.value,"comments-sidebar-open":F.value,"image-context":(0,a.unref)(Jt),theme:je.value,"font-families":n.fontFamilies,onInsertLink:i[0]||=e=>k.value=!0,onApplyStyle:(0,a.unref)(ft),onZoomIn:(0,a.unref)(ce),onZoomOut:(0,a.unref)(le),onZoomSet:(0,a.unref)(se),onToggleSidebar:(0,a.unref)(Mt),onModeChange:Xn,onImageWrapType:(0,a.unref)(ln),onImageProperties:i[1]||=e=>j.value=!0,onImageTransform:(0,a.unref)(un)},(0,a.createSlots)({"table-context":(0,a.withCtx)(()=>[(0,a.createVNode)(t.h,{view:Ie.value,"get-commands":(0,a.unref)(K),"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)(Dt),"onUpdate:showWatermark":i[8]||=e=>(0,a.isRef)(Dt)?Dt.value=e:null,"show-keyboard-shortcuts":P.value,"onUpdate:showKeyboardShortcuts":i[9]||=e=>P.value=e,view:(0,a.unref)(U),bookmarks:Ve.value,"selected-image-pm-pos":(0,a.unref)(Z)?.pmPos??null,"section-properties":q.value,"current-watermark":(0,a.unref)(Ot),"scroll-visible-position-into-view":(0,a.unref)(An),onInsertImage:(0,a.unref)(Yt),onInsertSymbol:(0,a.unref)(mt),onHyperlinkSubmit:(0,a.unref)(ot),onHyperlinkRemove:(0,a.unref)(st),onPageSetupApply:(0,a.unref)(vt),onWatermarkApply:(0,a.unref)(kt)},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)(Nt)&&(0,a.unref)(Nt)(...e)},[n.showRuler&&q.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`docx-editor-vue__ruler-row`,style:(0,a.normalizeStyle)(Re.value)},[(0,a.createVNode)(t.o,{"section-props":q.value,zoom:(0,a.unref)(B),editable:!h.value,"indent-left":J.value.indentLeft,"indent-right":J.value.indentRight,"first-line-indent":J.value.firstLineIndent,"hanging-indent":J.value.hangingIndent,"tab-stops":J.value.tabStops,onLeftMarginChange:(0,a.unref)(yt),onRightMarginChange:(0,a.unref)(bt),onIndentLeftChange:(0,a.unref)(Ct),onIndentRightChange:(0,a.unref)(wt),onFirstLineIndentChange:(0,a.unref)(Tt),onTabStopRemove:(0,a.unref)(Et)},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)(jn)&&(0,a.unref)(jn)(...e),onMousemove:i[24]||=(...e)=>(0,a.unref)(Mn)&&(0,a.unref)(Mn)(...e),onClick:i[25]||=(...e)=>(0,a.unref)(Nn)&&(0,a.unref)(Nn)(...e),onDblclick:i[26]||=(...e)=>(0,a.unref)(Pn)&&(0,a.unref)(Pn)(...e),onContextmenu:i[27]||=(0,a.withModifiers)((...e)=>(0,a.unref)(Hn)&&(0,a.unref)(Hn)(...e),[`prevent`]),onWheel:i[28]||=(...e)=>(0,a.unref)(V)&&(0,a.unref)(V)(...e)},[n.showRuler&&q.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,En,[(0,a.createVNode)(t.a,{"section-props":q.value,zoom:(0,a.unref)(B),editable:!h.value,onTopMarginChange:(0,a.unref)(xt),onBottomMarginChange:(0,a.unref)(St)},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)(Le.value)},null,4),h.value?(0,a.createCommentVNode)(``,!0):((0,a.openBlock)(),(0,a.createBlock)(Ce,{key:1,container:b.value,view:(0,a.unref)(U)},null,8,[`container`,`view`])),(0,a.createVNode)(ve,{"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)(Ln),onClose:i[10]||=e=>$.value=null,onRemove:(0,a.unref)(Rn)},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=>qt.value=!0,onInteractEnd:i[14]||=e=>qt.value=!1,onContextMenu:(0,a.unref)(Un)},null,8,[`image-info`,`zoom`,`view`,`onContextMenu`]),(0,a.createVNode)(re,{"get-view":Jn,"get-pages-container":Yn,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)(Ue)&&!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)(Ue).top+`px`,left:(0,a.unref)(Ue).left+`px`}),title:(0,a.unref)(v)(`comments.addComment`),onMousedown:i[15]||=(0,a.withModifiers)((...e)=>(0,a.unref)(Xe)&&(0,a.unref)(Xe)(...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)(Fn)&&(0,a.unref)(Fn)(...e),onMouseenter:i[17]||=(...e)=>(0,a.unref)(In)&&(0,a.unref)(In)(...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":ze.value,"sidebar-open":F.value,"resolved-comment-ids":Be.value,onMarkerClick:(0,a.unref)(Ze)},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":z.value,"is-adding-comment":I.value,"add-comment-y-position":(0,a.unref)(Ge),"show-resolved":!0,"pages-container":b.value,"page-width-px":ze.value,zoom:(0,a.unref)(B),"active-item-id":L.value,onClose:i[19]||=e=>F.value=!1,onAddComment:(0,a.unref)(Je),onCancelAddComment:(0,a.unref)(Ye),onCommentReply:(0,a.unref)(X),onCommentResolve:(0,a.unref)(Rt),onCommentUnresolve:(0,a.unref)(zt),onCommentDelete:(0,a.unref)(Vt),onAcceptChange:(0,a.unref)(Ht),onRejectChange:(0,a.unref)(Ut),onAcceptChangeById:(0,a.unref)(Wt),onRejectChangeById:(0,a.unref)(Gt),onTrackedChangeReply:(0,a.unref)(Kt),"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)(at),"read-only":h.value,onNavigate:(0,a.unref)(ct),onCopy:i[21]||=e=>at.value=null,onEdit:(0,a.unref)(lt),onRemove:(0,a.unref)(ut),onClose:i[22]||=e=>at.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)(At)&&(0,a.unref)(At)(...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)(pn).totalPages>1?((0,a.openBlock)(),(0,a.createBlock)(he,{key:1,"current-page":(0,a.unref)(pn).currentPage,"total-pages":(0,a.unref)(pn).totalPages,visible:(0,a.unref)(pn).visible},null,8,[`current-page`,`total-pages`,`visible`])):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(pe,{"is-open":N.value,headings:ne.value,onClose:i[31]||=e=>N.value=!1,onNavigate:(0,a.unref)(jt)},null,8,[`is-open`,`headings`,`onNavigate`])])],32),(0,a.createElementVNode)(`input`,{ref_key:`docxInputRef`,ref:Qe,type:`file`,accept:`.docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document`,style:{display:`none`},onChange:i[33]||=(...e)=>(0,a.unref)($e)&&(0,a.unref)($e)(...e)},null,544),(0,a.createVNode)(Bt,{"read-only":h.value,"context-menu":(0,a.unref)(zn),"image-context-menu":(0,a.unref)(Bn),"image-context-menu-text-actions":(0,a.unref)(Vn),"can-open-image-properties":!!(0,a.unref)(Z),onContextMenuAction:(0,a.unref)(Gn),onCloseContextMenu:i[34]||=e=>(0,a.unref)(zn).isOpen=!1,onImageWrapSelect:(0,a.unref)(Wn),onCloseImageContextMenu:i[35]||=e=>Bn.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;
19
+ `,i.appendChild(t)}}return(0,a.onBeforeUnmount)(()=>{i!==null&&cancelAnimationFrame(i),c()}),{clearOverlay:c,updateSelectionOverlay:u}}function Tn(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.imageInputRef.value?.click();break;case`insertLink`:e.showHyperlink.value=!0;break;case`insertSymbol`:e.showInsertSymbol.value=!0;break;case`insertPageBreak`:e.handleInsertPageBreak();break;case`insertSectionBreakNextPage`:e.handleInsertSectionBreakNextPage();break;case`insertSectionBreakContinuous`:e.handleInsertSectionBreakContinuous();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,F.openReportIssue)();break;case`dirLTR`:t(`setLtr`);break;case`dirRTL`:t(`setRtl`);break}}return{handleMenuAction:r,handleMenuTableInsert:n,execSimpleCommand:t}}function En(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 Dn(e){function t(){let t=e.pagesRef.value;t&&(0,g.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 s(){return e.editorView.value?{getDocument:e.getDocument,getView:()=>e.editorView.value,getState:()=>e.editorView.value?.state??null}:null}function u(){return e.layout.value?.pages.length??0}function d(){let t=e.layout.value,n=e.editorView.value;if(!t||!n)return 0;let r=(0,x.findPageIndexContainingPmPos)(t,n.state.selection.from);return r==null?0:r+1}function f(t){let n=e.editorView.value;if(!n)return!1;let r=(0,L.findParaIdRange)(n.state.doc,t);return r?(e.scrollVisiblePositionIntoView(r.from+1),!0):!1}function p(t,n){return(0,c.findInDocument)(e.editorView.value,t,n)}function m(){return(0,c.getSelectionInfo)(e.editorView.value)}function h(){return e.comments.value}function _(t){let n=e.editorView.value;return n?(0,l.findContentControlsInPM)(n.state.doc,t??{}):[]}function v(t){let n=e.editorView.value;if(!n)return!1;let r=(0,l.findContentControlPos)(n.state.doc,t);return r==null?!1:(a(r),!0)}function y(t,n,r){let i=o.TextSelection.between(t.state.doc.resolve(n),t.state.doc.resolve(r));t.dispatch(t.state.tr.setSelection(i)),e.scrollVisiblePositionIntoView(n)}function b(t,n){let r=e.editorView.value;if(!r)return;let i=(0,c.clampRangeToDoc)(r.state.doc,t,n);i&&y(r,i.from,i.to)}function S(t){let n=e.editorView.value;if(!n)return!1;let r=(0,c.findCommentRange)(n,t);return r?(y(n,r.from,r.to),!0):!1}function C(t){let n=e.editorView.value;if(!n)return!1;let r=(0,c.findChangeRange)(n,t);return r?(y(n,r.from,r.to),!0):!1}function w(t,n,r){let i=e.editorView.value;if(!i)return!1;try{return i.dispatch((0,l.setContentControlContentTr)(i.state,t,n,r)),!0}catch(e){if(e instanceof I.ContentControlNotFoundError)return!1;throw e}}function T(t,n){let r=e.editorView.value;if(!r)return!1;try{return r.dispatch((0,l.removeContentControlTr)(r.state,t,n)),!0}catch(e){if(e instanceof I.ContentControlNotFoundError)return!1;throw e}}function E(t,n,r){let i=e.editorView.value;if(!i)return!1;try{return i.dispatch((0,l.setContentControlValueTr)(i.state,t,n,r)),!0}catch(e){if(e instanceof I.ContentControlNotFoundError)return!1;throw e}}function D(t){return(0,c.getPageContent)(e.editorView.value,e.layout.value,t)}function O(t){return e.contentChangeSubscribers.add(t),()=>e.contentChangeSubscribers.delete(t)}function k(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:s,addComment:e.addComment,replyToComment:e.replyToComment,resolveComment:e.resolveComment,proposeChange:e.proposeChange,scrollToParaId:f,scrollToCommentId:S,scrollToChangeId:C,highlightRange:b,findInDocument:p,getSelectionInfo:m,getComments:h,getContentControls:_,scrollToContentControl:v,setContentControlContent:w,removeContentControl:T,setContentControlValue:E,applyFormatting:e.applyFormatting,setParagraphStyle:e.setParagraphStyle,insertBreak:e.insertBreak,getPageContent:D,getTotalPages:u,getCurrentPage:d,onContentChange:O,onSelectionChange:k}}}function On(e){let t=(0,a.ref)((0,u.prefersColorSchemeDark)());return(0,a.watchEffect)(n=>{e()===`system`&&n((0,u.subscribeSystemDark)(e=>{t.value=e}))}),(0,a.computed)(()=>(0,u.resolveIsDark)(e(),t.value))}function kn(e,t){(0,a.watch)(e,e=>{(0,u.loadFontDefinitions)(e)},{immediate:!0});let n=(0,u.onFontError)(t);(0,a.onBeforeUnmount)(()=>n())}var An={class:`docx-editor-vue__toolbar-shell`},jn={key:0,class:`docx-editor-vue__error`},Mn={key:1,class:`docx-editor-vue__loading`},Nn={class:`docx-editor-vue__editor-area`},Pn={key:0,class:`docx-editor-vue__vertical-ruler`},Fn=[`title`],In=[`title`,`aria-label`],Ln=(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},colorMode:{default:`light`},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:{},watermarkPresets:{default:void 0},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:f}){let p=n,m=f,h=On(()=>p.colorMode),g=(0,a.ref)(p.mode),_=(0,a.computed)(()=>p.readOnly||g.value===`viewing`),y=(0,a.computed)(()=>p.author);e.l((0,a.computed)(()=>p.i18n));let{t:b}=e.s((0,a.computed)(()=>p.i18n)),x=(0,a.ref)(null),S=(0,a.ref)(null),C=(0,a.ref)(null),w=(0,a.ref)(0),T=new Set,E=new Set,D=new l.LayoutSelectionGate,O=(0,a.ref)(!1),k=(0,a.ref)(!1),A=(0,a.ref)(!1),M=(0,a.ref)(!1),N=(0,a.ref)(!1),P=(0,a.ref)(p.showOutline),F=(0,a.ref)(!1),I=(0,a.ref)(!1),L=(0,a.ref)(!1),R=(0,a.ref)(null),z=(0,a.shallowRef)([]),B=(0,a.shallowRef)([]),te=(0,a.shallowRef)([]),{zoom:V,zoomPercent:ne,isMinZoom:re,isMaxZoom:ae,setZoom:oe,zoomIn:se,zoomOut:ce,handleWheel:le,handleKeyDown:ue,installShortcuts:de,ZOOM_PRESETS:fe}=i.r(p.initialZoom);de();let{editorView:H,isReady:pe,parseError:U,layout:he,loadBuffer:ge,loadDocument:_e,save:ve,focus:be,destroy:xe,getDocument:G,getCommands:K,reLayout:Ce,getHfPmView:we,syncHfPMs:Te,setHfTransactionListener:Ee,setDocument:De}=i.i({hiddenContainer:x,pagesContainer:S,readOnly:_,externalPlugins:p.externalPlugins,syncCoordinator:D,editorMode:g,author:y,onChange:e=>{m(`change`,e),m(`update:document`,e),p.onChange?.(e),T.forEach(t=>t(e))},onError:e=>{m(`error`,e),p.onError?.(e)},onSelectionUpdate:()=>{w.value++;let e=H.value;p.onSelectionChange?.(e?(0,l.extractSelectionState)(e.state):null);let t=(0,c.getSelectionInfo)(e);E.forEach(e=>e(t))}}),{commentCallbacks:ke}=mn(p,H),q=(0,a.computed)(()=>{w.value;let e=G();if(!e?.package?.document)return null;let t=e.package.document;return t.finalSectionProperties??t.sections?.[0]?.properties??null}),Ae=(0,a.computed)(()=>{w.value;let e=H.value,t=e?(0,d.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)(()=>(w.value,G()?.package?.theme??p.theme??null)),Ne=(0,a.computed)(()=>(w.value,G()?.package?.styles?.styles??void 0)),J=(0,a.ref)(null),Pe=(0,a.ref)([]);function Fe(e,t){J.value=(0,s.computeHfCaretRectFromView)(e,t),Pe.value=(0,s.computeHfSelectionRectsFromView)(e,t)}function Ie(){J.value=null,Pe.value=[]}kn(()=>p.fonts,e=>{m(`error`,e),p.onError?.(e)});let Le=(0,a.computed)(()=>Q.value?.headerFooter?we(Q.value.headerFooter)??null:null),Re=(0,a.computed)(()=>Le.value??H.value);(0,a.onMounted)(()=>{Ee((e,t)=>{w.value++,requestAnimationFrame(()=>{let e=Q.value;if(!e)return;Fe(t,e.position);let n=ee(e.position),r=C.value;if(!n||!r)return;let i=n.getBoundingClientRect(),a=r.getBoundingClientRect(),o=V.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){Ie();return}let t=H.value;if(t){try{let e=t.state.tr.setSelection(o.TextSelection.create(t.state.doc,0));t.dispatch(e)}catch{}t.dom.blur?.()}ar.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&&Fe(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 ze=(0,a.computed)(()=>{let e=[];return I.value&&e.push(`translateX(-${u.SIDEBAR_DOCUMENT_SHIFT}px)`),V.value!==1&&e.push(`scale(${V.value})`),{transform:e.length>0?e.join(` `):void 0,transformOrigin:`top center`,transition:`transform 0.2s ease`}}),Be=(0,a.computed)(()=>({paddingLeft:`20px`,paddingRight:20+(I.value?u.SIDEBAR_DOCUMENT_SHIFT*2:0)+`px`,transition:`padding 0.2s ease`})),Ve=(0,a.computed)(()=>{let e=q.value;return(0,v.twipsToPixels)(e?.pageWidth??12240)*V.value}),He=(0,a.computed)(()=>{let e=new Set;for(let t of z.value)t.parentId==null&&t.done&&e.add(t.id);return e}),Ue=(0,a.computed)(()=>{w.value;let e=H.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))}),We=(0,j.createCommentIdAllocator)(),{floatingCommentBtn:Ge,pendingCommentRange:Ke,addCommentYPosition:qe,sidebarAutoOpenedRef:Je,extractCommentsAndChanges:Ye,handleAddComment:Xe,handleCancelAddComment:Ze,handleStartAddComment:Qe,handleMarkerClick:$e}=hn({editorView:H,getDocument:G,comments:z,trackedChanges:B,resolvedCommentIds:He,activeSidebarItem:R,showSidebar:I,isAddingComment:L,readOnly:_,zoom:V,stateTick:w,pagesRef:S,pagesViewportRef:C,emit:m,commentIdAllocator:We,author:y,commentCallbacks:ke}),{docxInputRef:et,imageInputRef:tt,handleImageFileChange:nt,handleDocxFileChange:rt,handleDocumentNameChange:it,downloadCurrentDocument:at,loadDocumentBuffer:ot,loadDocument:st,save:ct}=on({loadBuffer:ge,loadParsedDocument:_e,getDocument:G,saveBlob:ve,extractCommentsAndChanges:Ye,emit:m,documentName:()=>p.documentName,onDocumentNameChange:p.onDocumentNameChange,getActiveView:()=>Re.value,nextTick:a.nextTick}),{hyperlinkPopupData:lt,handleHyperlinkSubmit:ut,handleHyperlinkRemove:dt,handleHyperlinkPopupNavigate:ft,handleHyperlinkPopupEdit:pt,handleHyperlinkPopupRemove:mt}=sn({editorView:H,getCommands:K}),{handleClearFormatting:ht,handleApplyStyle:gt,handleInsertPageBreak:_t,handleInsertSectionBreakNextPage:vt,handleInsertSectionBreakContinuous:yt,handleInsertSymbol:bt,applyFormatting:xt,setParagraphStyle:St,insertBreak:wt}=cn({editorView:H,activeView:Re,getDocument:G}),{handlePageSetupApply:Tt,handleLeftMarginChange:Et,handleRightMarginChange:Dt,handleTopMarginChange:Ot,handleBottomMarginChange:kt,handleIndentLeftChange:At,handleIndentRightChange:jt,handleFirstLineIndentChange:Mt,handleTabStopRemove:Nt}=ln({editorView:H,getDocument:G,readOnly:_,stateTick:w,reLayout:Ce,emit:m}),{showWatermark:Pt,currentWatermark:Ft,handleWatermarkApply:It}=un({editorView:H,readOnly:_,stateTick:w}),{handleToggleOutline:Lt,handleOutlineNavigate:Rt,handleToggleSidebar:zt,handleEditorScrollMouseDown:Bt}=dn({editorView:H,showOutline:P,showSidebar:I,outlineHeadings:te,activeSidebarItem:R,extractCommentsAndChanges:Ye});fn({showKeyboardShortcuts:F,showFindReplace:O,showHyperlink:k,handleZoomKeyDown:ue,disableFindReplaceShortcuts:()=>p.disableFindReplaceShortcuts});let{addComment:Vt,replyToComment:Ht,resolveComment:Ut,proposeChange:Wt,handleCommentReply:Gt,handleCommentResolve:Y,handleCommentUnresolve:Kt,handleCommentDelete:qt,handleAcceptChange:Yt,handleRejectChange:Xt,handleAcceptChangeById:Zt,handleRejectChangeById:Qt,handleTrackedChangeReply:$t}=pn({editorView:H,getDocument:G,comments:z,trackedChanges:B,showSidebar:I,isAddingComment:L,pendingCommentRange:Ke,contentChangeSubscribers:T,extractCommentsAndChanges:Ye,emit:m,commentIdAllocator:We,author:y,commentCallbacks:ke}),{selectedImage:X,imageInteracting:en,imageToolbarContext:tn,handleToolbarImageWrap:nn,handleImageTransform:rn}=gn({editorView:H,zoom:V,stateTick:w,getCommands:K}),_n=i.n(),vn=null,{tableInsertButton:Z,hfEdit:Q,scrollPageInfo:$,resolvePos:yn,setPmSelection:bn,scrollVisiblePositionIntoView:Sn,handlePagesMouseDown:Ln,handlePagesMouseMove:Rn,handlePagesClick:zn,handlePagesDoubleClick:Bn,handleTableInsertClick:Vn,clearTableInsertTimer:Hn,handleHfSave:Un,handleHfRemove:Wn}=Cn({editorView:H,pagesRef:S,pagesViewportRef:C,selectedImage:X,imageInteracting:en,hyperlinkPopupData:lt,readOnly:_,zoom:V,layout:he,tableResize:_n,getCommands:K,getDocument:G,reLayout:Ce,emit:m,clearOverlay:rr,syncHfPMs:Te,getHfPmView:we,setDocument:De}),{contextMenu:Gn,imageContextMenu:Kn,imageContextMenuTextActions:qn,handleContextMenu:Jn,handleSelectedImageContextMenu:Yn,handleImageWrapSelect:Xn,handleContextMenuAction:Zn}=xn({editorView:H,selectedImage:X,zoom:V,showImageProperties:M,getCommands:K,clearOverlay:rr,setPmSelection:bn,resolvePos:yn}),{handleMenuAction:Qn,handleMenuTableInsert:$n}=Tn({editorView:H,getCommands:K,docxInputRef:et,imageInputRef:tt,showPageSetup:N,showWatermark:Pt,showHyperlink:k,showInsertSymbol:A,showKeyboardShortcuts:F,handleClearFormatting:ht,handleInsertPageBreak:_t,handleInsertSectionBreakNextPage:vt,handleInsertSectionBreakContinuous:yt,handleToggleOutline:Lt,handleToggleSidebar:zt,downloadCurrentDocument:at,emit:m});En({documentBuffer:()=>p.documentBuffer,document:()=>p.document,loadDocumentBuffer:ot,loadDocument:st,sidebarAutoOpenedRef:Je});let er=()=>H.value,tr=()=>S.value;(0,a.watch)(()=>p.mode,e=>{e&&e!==g.value&&(g.value=e)}),(0,a.watch)(()=>p.showOutline,e=>{P.value=!!e});function nr(e){g.value!==e&&(g.value=e,m(`mode-change`,e))}(0,a.onMounted)(()=>{vn=_n.install()}),(0,a.onBeforeUnmount)(()=>{vn?.()});function rr(){ar.clearOverlay()}function ir(){ar.updateSelectionOverlay()}let ar=wn({editorView:H,pagesRef:S,zoom:V,selectedImage:X,isHfEditing:(0,a.computed)(()=>Q.value!==null),imageInteracting:en}),or=D.onRender(()=>ir());ir(),(0,a.onBeforeUnmount)(()=>{or(),rr()});let{exposed:sr}=Dn({editorView:H,layout:he,pagesRef:S,pagesViewportRef:C,zoom:V,comments:z,focus:be,destroy:xe,getDocument:G,setZoom:oe,save:ct,loadDocument:st,loadDocumentBuffer:ot,addComment:Vt,replyToComment:Ht,resolveComment:Ut,proposeChange:Wt,applyFormatting:xt,setParagraphStyle:St,insertBreak:wt,scrollVisiblePositionIntoView:Sn,contentChangeSubscribers:T,selectionChangeSubscribers:E,onPrint:p.onPrint});return r(sr),(r,i)=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{class:(0,a.normalizeClass)([`docx-editor-vue ep-root paged-editor`,(0,a.unref)(h)?`dark`:``,n.className,{"paged-editor--readonly":_.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`,An,[(0,a.createVNode)(Me,{"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)(it),onMenuAction:(0,a.unref)(Qn),onInsertTable:(0,a.unref)($n)},{"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:Re.value,"get-commands":(0,a.unref)(K),"state-tick":w.value,"zoom-percent":(0,a.unref)(ne),"is-min-zoom":(0,a.unref)(re),"is-max-zoom":(0,a.unref)(ae),"zoom-presets":(0,a.unref)(fe),"show-zoom-control":n.showZoomControl,"editor-mode":g.value,"comments-sidebar-open":I.value,"image-context":(0,a.unref)(tn),theme:je.value,"font-families":n.fontFamilies,"document-styles":Ne.value,onInsertLink:i[0]||=e=>k.value=!0,onApplyStyle:(0,a.unref)(gt),onZoomIn:(0,a.unref)(se),onZoomOut:(0,a.unref)(ce),onZoomSet:(0,a.unref)(oe),onToggleSidebar:(0,a.unref)(zt),onModeChange:nr,onImageWrapType:(0,a.unref)(nn),onImageProperties:i[1]||=e=>M.value=!0,onImageTransform:(0,a.unref)(rn)},(0,a.createSlots)({"table-context":(0,a.withCtx)(()=>[(0,a.createVNode)(t.h,{view:Re.value,"get-commands":(0,a.unref)(K),"state-tick":w.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`,`document-styles`,`onApplyStyle`,`onZoomIn`,`onZoomOut`,`onZoomSet`,`onToggleSidebar`,`onImageWrapType`,`onImageTransform`])):(0,a.createCommentVNode)(``,!0)]),(0,a.createVNode)(Ct,{"show-find-replace":O.value,"onUpdate:showFindReplace":i[2]||=e=>O.value=e,"show-hyperlink":k.value,"onUpdate:showHyperlink":i[3]||=e=>k.value=e,"show-insert-symbol":A.value,"onUpdate:showInsertSymbol":i[4]||=e=>A.value=e,"show-image-properties":M.value,"onUpdate:showImageProperties":i[5]||=e=>M.value=e,"show-page-setup":N.value,"onUpdate:showPageSetup":i[6]||=e=>N.value=e,"show-watermark":(0,a.unref)(Pt),"onUpdate:showWatermark":i[7]||=e=>(0,a.isRef)(Pt)?Pt.value=e:null,"show-keyboard-shortcuts":F.value,"onUpdate:showKeyboardShortcuts":i[8]||=e=>F.value=e,view:(0,a.unref)(H),bookmarks:Ue.value,"selected-image-pm-pos":(0,a.unref)(X)?.pmPos??null,"section-properties":q.value,"current-watermark":(0,a.unref)(Ft),"watermark-presets":n.watermarkPresets,"scroll-visible-position-into-view":(0,a.unref)(Sn),onInsertSymbol:(0,a.unref)(bt),onHyperlinkSubmit:(0,a.unref)(ut),onHyperlinkRemove:(0,a.unref)(dt),onPageSetupApply:(0,a.unref)(Tt),onWatermarkApply:(0,a.unref)(It)},null,8,[`show-find-replace`,`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`,`watermark-presets`,`scroll-visible-position-into-view`,`onInsertSymbol`,`onHyperlinkSubmit`,`onHyperlinkRemove`,`onPageSetupApply`,`onWatermarkApply`]),(0,a.unref)(U)?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,jn,(0,a.toDisplayString)((0,a.unref)(U)),1)):(0,a.createCommentVNode)(``,!0),!(0,a.unref)(pe)&&!(0,a.unref)(U)?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Mn,`Loading...`)):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,{ref_key:`hiddenPmRef`,ref:x,class:`docx-editor-vue__hidden-pm paged-editor__hidden-pm`},null,512),(0,a.createElementVNode)(`div`,{class:`docx-editor-vue__editor-scroll`,onMousedown:i[31]||=(...e)=>(0,a.unref)(Bt)&&(0,a.unref)(Bt)(...e)},[n.showRuler&&q.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,class:`docx-editor-vue__ruler-row`,style:(0,a.normalizeStyle)(Be.value)},[(0,a.createVNode)(t.o,{"section-props":q.value,zoom:(0,a.unref)(V),editable:!_.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)(Et),onRightMarginChange:(0,a.unref)(Dt),onIndentLeftChange:(0,a.unref)(At),onIndentRightChange:(0,a.unref)(jt),onFirstLineIndentChange:(0,a.unref)(Mt),onTabStopRemove:(0,a.unref)(Nt)},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`,Nn,[(0,a.createElementVNode)(`div`,{ref_key:`pagesViewportRef`,ref:C,class:`docx-editor-vue__pages-viewport`,onMousedown:i[22]||=(...e)=>(0,a.unref)(Ln)&&(0,a.unref)(Ln)(...e),onMousemove:i[23]||=(...e)=>(0,a.unref)(Rn)&&(0,a.unref)(Rn)(...e),onClick:i[24]||=(...e)=>(0,a.unref)(zn)&&(0,a.unref)(zn)(...e),onDblclick:i[25]||=(...e)=>(0,a.unref)(Bn)&&(0,a.unref)(Bn)(...e),onContextmenu:i[26]||=(0,a.withModifiers)((...e)=>(0,a.unref)(Jn)&&(0,a.unref)(Jn)(...e),[`prevent`]),onWheel:i[27]||=(...e)=>(0,a.unref)(le)&&(0,a.unref)(le)(...e)},[n.showRuler&&q.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,Pn,[(0,a.createVNode)(t.a,{"section-props":q.value,zoom:(0,a.unref)(V),editable:!_.value,onTopMarginChange:(0,a.unref)(Ot),onBottomMarginChange:(0,a.unref)(kt)},null,8,[`section-props`,`zoom`,`editable`,`onTopMarginChange`,`onBottomMarginChange`])])):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`div`,{ref_key:`pagesRef`,ref:S,class:`docx-editor-vue__pages paged-editor__pages`,style:(0,a.normalizeStyle)(ze.value)},null,4),_.value?(0,a.createCommentVNode)(``,!0):((0,a.openBlock)(),(0,a.createBlock)(Oe,{key:1,container:S.value,view:(0,a.unref)(H)},null,8,[`container`,`view`])),(0,a.createVNode)(Se,{"is-open":(0,a.unref)(Q)!==null,position:(0,a.unref)(Q)?.position??`header`,view:Le.value,"target-rect":(0,a.unref)(Q)?.targetRect??null,onSave:(0,a.unref)(Un),onClose:i[9]||=e=>Q.value=null,onRemove:(0,a.unref)(Wn)},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)?Pe.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:`var(--doc-selection)`,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)(me,{"image-info":(0,a.unref)(X),zoom:(0,a.unref)(V),view:(0,a.unref)(H),onOpenProperties:i[10]||=e=>M.value=!0,onDeselect:i[11]||=e=>X.value=null,onInteractStart:i[12]||=e=>en.value=!0,onInteractEnd:i[13]||=e=>en.value=!1,onContextMenu:(0,a.unref)(Yn)},null,8,[`image-info`,`zoom`,`view`,`onContextMenu`]),(0,a.createVNode)(ie,{"get-view":er,"get-pages-container":tr,zoom:(0,a.unref)(V),"transaction-version":w.value,"sync-coordinator":(0,a.unref)(D)},null,8,[`zoom`,`transaction-version`,`sync-coordinator`]),(0,a.unref)(Ge)&&!L.value&&!_.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)(Ge).top+`px`,left:(0,a.unref)(Ge).left+`px`}),title:(0,a.unref)(b)(`comments.addComment`),onMousedown:i[14]||=(0,a.withModifiers)((...e)=>(0,a.unref)(Qe)&&(0,a.unref)(Qe)(...e),[`prevent`,`stop`])},[(0,a.createVNode)(e.f,{name:`add_comment`,size:16})],44,Fn)):(0,a.createCommentVNode)(``,!0),(0,a.unref)(Z)&&!_.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[15]||=(...e)=>(0,a.unref)(Vn)&&(0,a.unref)(Vn)(...e),onMouseenter:i[16]||=(...e)=>(0,a.unref)(Hn)&&(0,a.unref)(Hn)(...e),onMouseleave:i[17]||=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,In)):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(t.s,{comments:z.value,"pages-container":S.value,zoom:(0,a.unref)(V),"page-width-px":Ve.value,"sidebar-open":I.value,"resolved-comment-ids":He.value,onMarkerClick:(0,a.unref)($e)},null,8,[`comments`,`pages-container`,`zoom`,`page-width-px`,`sidebar-open`,`resolved-comment-ids`,`onMarkerClick`]),(0,a.createVNode)(t.c,{"is-open":I.value,comments:z.value,"tracked-changes":B.value,"is-adding-comment":L.value,"add-comment-y-position":(0,a.unref)(qe),"show-resolved":!0,"pages-container":S.value,"page-width-px":Ve.value,zoom:(0,a.unref)(V),"active-item-id":R.value,onClose:i[18]||=e=>I.value=!1,onAddComment:(0,a.unref)(Xe),onCancelAddComment:(0,a.unref)(Ze),onCommentReply:(0,a.unref)(Gt),onCommentResolve:(0,a.unref)(Y),onCommentUnresolve:(0,a.unref)(Kt),onCommentDelete:(0,a.unref)(qt),onAcceptChange:(0,a.unref)(Yt),onRejectChange:(0,a.unref)(Xt),onAcceptChangeById:(0,a.unref)(Zt),onRejectChangeById:(0,a.unref)(Qt),onTrackedChangeReply:(0,a.unref)($t),"onUpdate:activeItemId":i[19]||=e=>R.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)(an,{data:(0,a.unref)(lt),"read-only":_.value,onNavigate:(0,a.unref)(ft),onCopy:i[20]||=e=>lt.value=null,onEdit:(0,a.unref)(pt),onRemove:(0,a.unref)(mt),onClose:i[21]||=e=>lt.value=null},null,8,[`data`,`read-only`,`onNavigate`,`onEdit`,`onRemove`])],544),!P.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[28]||=(...e)=>(0,a.unref)(Lt)&&(0,a.unref)(Lt)(...e),onMousedown:i[29]||=(0,a.withModifiers)(()=>{},[`stop`])},[(0,a.createVNode)(e.f,{name:`format_list_bulleted`,size:20})],32)):(0,a.createCommentVNode)(``,!0),(0,a.unref)($).totalPages>1?((0,a.openBlock)(),(0,a.createBlock)(W,{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)(ye,{"is-open":P.value,headings:te.value,onClose:i[30]||=e=>P.value=!1,onNavigate:(0,a.unref)(Rt)},null,8,[`is-open`,`headings`,`onNavigate`])])],32),(0,a.createElementVNode)(`input`,{ref_key:`docxInputRef`,ref:et,type:`file`,accept:`.docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document`,style:{display:`none`},onChange:i[32]||=(...e)=>(0,a.unref)(rt)&&(0,a.unref)(rt)(...e)},null,544),(0,a.createElementVNode)(`input`,{ref_key:`imageInputRef`,ref:tt,type:`file`,accept:`image/*`,style:{display:`none`},onChange:i[33]||=(...e)=>(0,a.unref)(nt)&&(0,a.unref)(nt)(...e)},null,544),(0,a.createVNode)(Jt,{"read-only":_.value,"context-menu":(0,a.unref)(Gn),"image-context-menu":(0,a.unref)(Kn),"image-context-menu-text-actions":(0,a.unref)(qn),"can-open-image-properties":!!(0,a.unref)(X),onContextMenuAction:(0,a.unref)(Zn),onCloseContextMenu:i[34]||=e=>(0,a.unref)(Gn).isOpen=!1,onImageWrapSelect:(0,a.unref)(Xn),onCloseImageContextMenu:i[35]||=e=>Kn.value=null,onOpenImageProperties:i[36]||=e=>M.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 Rn(e,t,n={}){let r=e instanceof ArrayBuffer?e:await(0,u.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)(Ln,{...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 zn=`0.0.2`;exports.DocxEditor=Ln,exports.VERSION=zn,Object.defineProperty(exports,`createDocumentWithText`,{enumerable:!0,get:function(){return R.createDocumentWithText}}),Object.defineProperty(exports,`createEmptyDocument`,{enumerable:!0,get:function(){return R.createEmptyDocument}}),exports.defaultLocale=e.d,exports.i18nPlugin=e.c,exports.provideLocale=e.l,exports.renderAsync=Rn,exports.useTranslation=e.u;