@eigenpal/docx-editor-react 1.6.0 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var chunkGDJM7SOG_js=require('./chunk-GDJM7SOG.js'),chunkPSBO3UDN_js=require('./chunk-PSBO3UDN.js'),chunkLNONBJQM_js=require('./chunk-LNONBJQM.js'),chunkWNWY6WX7_js=require('./chunk-WNWY6WX7.js'),chunkBZO4G5M6_js=require('./chunk-BZO4G5M6.js');require('./chunk-GWXEFL3H.js');var chunkL4MDZW2J_js=require('./chunk-L4MDZW2J.js'),chunkQD7BVJV3_js=require('./chunk-QD7BVJV3.js'),chunkGNIO6SOS_js=require('./chunk-GNIO6SOS.js'),chunkBJ5RZW6Y_js=require('./chunk-BJ5RZW6Y.js'),Bl=require('react'),utils=require('@eigenpal/docx-editor-core/utils'),prosemirror=require('@eigenpal/docx-editor-core/prosemirror'),docx=require('@eigenpal/docx-editor-core/docx'),extensions=require('@eigenpal/docx-editor-core/prosemirror/extensions'),commands=require('@eigenpal/docx-editor-core/prosemirror/commands'),layoutPainter=require('@eigenpal/docx-editor-core/layout-painter'),sonner=require('sonner'),prosemirrorState=require('prosemirror-state'),queries=require('@eigenpal/docx-editor-core/prosemirror/queries'),applyFormatting=require('@eigenpal/docx-editor-core/prosemirror/applyFormatting'),agent=require('@eigenpal/docx-editor-core/agent'),commentOps=require('@eigenpal/docx-editor-core/prosemirror/commentOps'),commentIdAllocator=require('@eigenpal/docx-editor-core/prosemirror/commentIdAllocator'),jsxRuntime=require('react/jsx-runtime'),layoutBridge=require('@eigenpal/docx-editor-core/layout-bridge'),conversion=require('@eigenpal/docx-editor-core/prosemirror/conversion'),docxEditorI18n=require('@eigenpal/docx-editor-i18n'),prosemirrorHistory=require('prosemirror-history'),reactDom=require('react-dom'),prosemirrorTables=require('prosemirror-tables'),prosemirrorView=require('prosemirror-view'),editor=require('@eigenpal/docx-editor-core/editor');require('prosemirror-view/style/prosemirror.css'),require('@eigenpal/docx-editor-core/prosemirror/editor.css');var imageCommit=require('@eigenpal/docx-editor-core/prosemirror/imageCommit'),LayoutSelectionGate=require('@eigenpal/docx-editor-core/prosemirror/utils/LayoutSelectionGate'),sidebarConstants=require('@eigenpal/docx-editor-core/utils/sidebarConstants'),findVerticalScrollParent=require('@eigenpal/docx-editor-core/utils/findVerticalScrollParent'),layoutEngine=require('@eigenpal/docx-editor-core/layout-engine'),tableResize=require('@eigenpal/docx-editor-core/prosemirror/tableResize'),cellDragSelection=require('@eigenpal/docx-editor-core/prosemirror/cellDragSelection'),resolveItemPositions=require('@eigenpal/docx-editor-core/plugin-api/resolveItemPositions'),docxEditorCore=require('@eigenpal/docx-editor-core'),react=require('@eigenpal/docx-editor-agents/react'),comments=require('@eigenpal/docx-editor-core/utils/comments'),cardStyles=require('@eigenpal/docx-editor-core/utils/cardStyles'),plugins=require('@eigenpal/docx-editor-core/prosemirror/plugins'),client=require('react-dom/client');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Bl__default=/*#__PURE__*/_interopDefault(Bl);function fi({showOutlineProp:e,pagedEditorRef:t,scrollContainerRef:o,isLoading:r}){let[n,u]=Bl.useState(e),d=Bl.useRef(false);d.current=n;let[l,m]=Bl.useState([]);Bl.useEffect(()=>{if(u(e),e){let g=t.current?.getView();g&&m(utils.collectHeadings(g.state.doc));}},[e,t]);let s=Bl.useRef(null),a=Bl.useRef(null),[h,f]=Bl.useState(0),b=Bl.useCallback(g=>{if(a.current=g,s.current&&(s.current.disconnect(),s.current=null),!g){f(0);return}f(g.offsetHeight);let x=new ResizeObserver(()=>{f(g.offsetHeight);});x.observe(g),s.current=x;},[]);Bl.useEffect(()=>()=>{s.current?.disconnect();},[]);let[i,p]=Bl.useState(0);return Bl.useEffect(()=>{let g=o.current;if(!g)return;let x=0,y=()=>{x=0,p(g.scrollLeft);},c=()=>{x===0&&(x=requestAnimationFrame(y));};return y(),g.addEventListener("scroll",c,{passive:true}),()=>{g.removeEventListener("scroll",c),x!==0&&cancelAnimationFrame(x);}},[r,o]),{showOutline:n,setShowOutline:u,showOutlineRef:d,outlineHeadings:l,setHeadingInfos:m,toolbarHeight:h,toolbarRefCallback:b,editorScrollLeft:i}}function gi({pagedEditorRef:e,disableFindReplaceShortcuts:t,findReplace:o,hyperlinkDialog:r,tableSelection:n}){Bl.useEffect(()=>{let u=d=>{let m=navigator.platform.toUpperCase().indexOf("MAC")>=0?d.metaKey:d.ctrlKey;if(!m&&!d.shiftKey&&!d.altKey&&(d.key==="Delete"||d.key==="Backspace")){let s=e.current?.getView();if(s){let a=s.state.selection;if("$anchorCell"in a&&typeof a.forEachCell=="function"){let f=prosemirror.getTableContext(s.state);if(f.isInTable&&f.table){let b=0;f.table.descendants(p=>{(p.type.name==="tableCell"||p.type.name==="tableHeader")&&(b+=1);});let i=0;if(a.forEachCell(()=>{i+=1;}),b>0&&i>=b){d.preventDefault(),prosemirror.deleteTable(s.state,s.dispatch);return}}}}if(n.state.tableIndex!==null){d.preventDefault(),n.handleAction("deleteTable");return}}if(m&&!d.shiftKey&&!d.altKey){if(d.key.toLowerCase()==="f"){if(t)return;d.preventDefault();let s=window.getSelection(),a=s&&!s.isCollapsed?s.toString():"";o.openFind(a);}else if(d.key.toLowerCase()==="h"){if(t)return;d.preventDefault();let s=window.getSelection(),a=s&&!s.isCollapsed?s.toString():"";o.openReplace(a);}else if(d.key.toLowerCase()==="k"){d.preventDefault();let s=e.current?.getView();if(s){let a=prosemirror.getSelectedText(s.state),h=prosemirror.getHyperlinkAttrs(s.state);h?r.openEdit({url:h.href,displayText:a,tooltip:h.tooltip}):r.openInsert(a);}}}};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u);}},[e,t,o,r,n]);}function hi({agentRef:e,pagedEditorRef:t,containerRef:o,comments:r,documentName:n,onSave:u,onError:d,onPrint:l,onDocumentNameChange:m,loadBuffer:s,getActiveEditorView:a,focusActiveEditor:h}){let f=Bl.useRef(null),b=Bl.useRef(null),i=Bl.useCallback(async v=>{if(!e.current)return null;try{let C=e.current.getDocument(),R=t.current?.getDocument();R?.package?.document&&(C.package.document.content=R.package.document.content),C.package.document.comments=r,docx.injectReplyRangeMarkers(C.package.document.content,r),docx.injectTCReplyRangeMarkers(C.package.document.content,r);let P=v?.selective!==!1,k=t.current?.getView(),E;if(P&&k){let w=k.state,D=r.some(H=>H.parentId!=null);E={selective:{changedParaIds:extensions.getChangedParagraphIds(w),structuralChange:extensions.hasStructuralChanges(w)||D,hasUntrackedChanges:extensions.hasUntrackedChanges(w)}};}let I=await e.current.toBuffer(E);return k&&k.dispatch(extensions.clearTrackedChanges(k.state)),u?.(I),I}catch(C){return d?.(C instanceof Error?C:new Error("Failed to save document")),null}},[e,t,r,u,d]),p=Bl.useCallback(()=>{let v=o.current?.querySelector(".paged-editor__pages");if(!v){window.print(),l?.();return}layoutPainter.renderAllPagesNow(v);let C=window.open("","_blank");if(!C){window.print(),l?.();return}let R=[];for(let k of Array.from(document.styleSheets))try{for(let E of Array.from(k.cssRules))E instanceof CSSFontFaceRule&&R.push(E.cssText);}catch{}let P=v.cloneNode(true);P.style.cssText="display: block; margin: 0; padding: 0;";for(let k of Array.from(P.querySelectorAll(".layout-page"))){let E=k;E.style.boxShadow="none",E.style.margin="0";}C.document.write(`<!DOCTYPE html>
1
+ 'use strict';var chunkGDJM7SOG_js=require('./chunk-GDJM7SOG.js'),chunkPSBO3UDN_js=require('./chunk-PSBO3UDN.js'),chunkLNONBJQM_js=require('./chunk-LNONBJQM.js'),chunkWNWY6WX7_js=require('./chunk-WNWY6WX7.js'),chunkBZO4G5M6_js=require('./chunk-BZO4G5M6.js');require('./chunk-GWXEFL3H.js');var chunkL4MDZW2J_js=require('./chunk-L4MDZW2J.js'),chunkQD7BVJV3_js=require('./chunk-QD7BVJV3.js'),chunkGNIO6SOS_js=require('./chunk-GNIO6SOS.js'),chunkBJ5RZW6Y_js=require('./chunk-BJ5RZW6Y.js'),zl=require('react'),utils=require('@eigenpal/docx-editor-core/utils'),prosemirror=require('@eigenpal/docx-editor-core/prosemirror'),docx=require('@eigenpal/docx-editor-core/docx'),extensions=require('@eigenpal/docx-editor-core/prosemirror/extensions'),commands=require('@eigenpal/docx-editor-core/prosemirror/commands'),layoutPainter=require('@eigenpal/docx-editor-core/layout-painter'),sonner=require('sonner'),prosemirrorState=require('prosemirror-state'),queries=require('@eigenpal/docx-editor-core/prosemirror/queries'),applyFormatting=require('@eigenpal/docx-editor-core/prosemirror/applyFormatting'),agent=require('@eigenpal/docx-editor-core/agent'),commentOps=require('@eigenpal/docx-editor-core/prosemirror/commentOps'),commentIdAllocator=require('@eigenpal/docx-editor-core/prosemirror/commentIdAllocator'),jsxRuntime=require('react/jsx-runtime'),layoutBridge=require('@eigenpal/docx-editor-core/layout-bridge'),conversion=require('@eigenpal/docx-editor-core/prosemirror/conversion'),docxEditorI18n=require('@eigenpal/docx-editor-i18n'),prosemirrorHistory=require('prosemirror-history'),reactDom=require('react-dom'),prosemirrorTables=require('prosemirror-tables'),prosemirrorView=require('prosemirror-view'),editor=require('@eigenpal/docx-editor-core/editor');require('prosemirror-view/style/prosemirror.css'),require('@eigenpal/docx-editor-core/prosemirror/editor.css');var imageCommit=require('@eigenpal/docx-editor-core/prosemirror/imageCommit'),LayoutSelectionGate=require('@eigenpal/docx-editor-core/prosemirror/utils/LayoutSelectionGate'),sidebarConstants=require('@eigenpal/docx-editor-core/utils/sidebarConstants'),findVerticalScrollParent=require('@eigenpal/docx-editor-core/utils/findVerticalScrollParent'),layoutEngine=require('@eigenpal/docx-editor-core/layout-engine'),tableResize=require('@eigenpal/docx-editor-core/prosemirror/tableResize'),cellDragSelection=require('@eigenpal/docx-editor-core/prosemirror/cellDragSelection'),resolveItemPositions=require('@eigenpal/docx-editor-core/plugin-api/resolveItemPositions'),docxEditorCore=require('@eigenpal/docx-editor-core'),react=require('@eigenpal/docx-editor-agents/react'),comments=require('@eigenpal/docx-editor-core/utils/comments'),cardStyles=require('@eigenpal/docx-editor-core/utils/cardStyles'),plugins=require('@eigenpal/docx-editor-core/prosemirror/plugins'),client=require('react-dom/client');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var zl__default=/*#__PURE__*/_interopDefault(zl);function hi({showOutlineProp:e,pagedEditorRef:t,scrollContainerRef:o,isLoading:r}){let[n,u]=zl.useState(e),d=zl.useRef(false);d.current=n;let[l,m]=zl.useState([]);zl.useEffect(()=>{if(u(e),e){let g=t.current?.getView();g&&m(utils.collectHeadings(g.state.doc));}},[e,t]);let s=zl.useRef(null),a=zl.useRef(null),[b,f]=zl.useState(0),h=zl.useCallback(g=>{if(a.current=g,s.current&&(s.current.disconnect(),s.current=null),!g){f(0);return}f(g.offsetHeight);let x=new ResizeObserver(()=>{f(g.offsetHeight);});x.observe(g),s.current=x;},[]);zl.useEffect(()=>()=>{s.current?.disconnect();},[]);let[i,p]=zl.useState(0);return zl.useEffect(()=>{let g=o.current;if(!g)return;let x=0,y=()=>{x=0,p(g.scrollLeft);},c=()=>{x===0&&(x=requestAnimationFrame(y));};return y(),g.addEventListener("scroll",c,{passive:true}),()=>{g.removeEventListener("scroll",c),x!==0&&cancelAnimationFrame(x);}},[r,o]),{showOutline:n,setShowOutline:u,showOutlineRef:d,outlineHeadings:l,setHeadingInfos:m,toolbarHeight:b,toolbarRefCallback:h,editorScrollLeft:i}}function yi({pagedEditorRef:e,disableFindReplaceShortcuts:t,findReplace:o,hyperlinkDialog:r,tableSelection:n}){zl.useEffect(()=>{let u=d=>{let m=navigator.platform.toUpperCase().indexOf("MAC")>=0?d.metaKey:d.ctrlKey;if(!m&&!d.shiftKey&&!d.altKey&&(d.key==="Delete"||d.key==="Backspace")){let s=e.current?.getView();if(s){let a=s.state.selection;if("$anchorCell"in a&&typeof a.forEachCell=="function"){let f=prosemirror.getTableContext(s.state);if(f.isInTable&&f.table){let h=0;f.table.descendants(p=>{(p.type.name==="tableCell"||p.type.name==="tableHeader")&&(h+=1);});let i=0;if(a.forEachCell(()=>{i+=1;}),h>0&&i>=h){d.preventDefault(),prosemirror.deleteTable(s.state,s.dispatch);return}}}}if(n.state.tableIndex!==null){d.preventDefault(),n.handleAction("deleteTable");return}}if(m&&!d.shiftKey&&!d.altKey){if(d.key.toLowerCase()==="f"){if(t)return;d.preventDefault();let s=window.getSelection(),a=s&&!s.isCollapsed?s.toString():"";o.openFind(a);}else if(d.key.toLowerCase()==="h"){if(t)return;d.preventDefault();let s=window.getSelection(),a=s&&!s.isCollapsed?s.toString():"";o.openReplace(a);}else if(d.key.toLowerCase()==="k"){d.preventDefault();let s=e.current?.getView();if(s){let a=prosemirror.getSelectedText(s.state),b=prosemirror.getHyperlinkAttrs(s.state);b?r.openEdit({url:b.href,displayText:a,tooltip:b.tooltip}):r.openInsert(a);}}}};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u);}},[e,t,o,r,n]);}function Ci({agentRef:e,pagedEditorRef:t,containerRef:o,comments:r,documentName:n,onSave:u,onError:d,onPrint:l,onDocumentNameChange:m,loadBuffer:s,getActiveEditorView:a,focusActiveEditor:b}){let f=zl.useRef(null),h=zl.useRef(null),i=zl.useCallback(async v=>{if(!e.current)return null;try{let C=e.current.getDocument(),R=t.current?.getDocument();R?.package?.document&&(C.package.document.content=R.package.document.content),C.package.document.comments=r,docx.injectReplyRangeMarkers(C.package.document.content,r),docx.injectTCReplyRangeMarkers(C.package.document.content,r);let T=v?.selective!==!1,k=t.current?.getView(),E;if(T&&k){let w=k.state,D=r.some(H=>H.parentId!=null);E={selective:{changedParaIds:extensions.getChangedParagraphIds(w),structuralChange:extensions.hasStructuralChanges(w)||D,hasUntrackedChanges:extensions.hasUntrackedChanges(w)}};}let I=await e.current.toBuffer(E);return k&&k.dispatch(extensions.clearTrackedChanges(k.state)),u?.(I),I}catch(C){return d?.(C instanceof Error?C:new Error("Failed to save document")),null}},[e,t,r,u,d]),p=zl.useCallback(()=>{let v=o.current?.querySelector(".paged-editor__pages");if(!v){window.print(),l?.();return}layoutPainter.renderAllPagesNow(v);let C=window.open("","_blank");if(!C){window.print(),l?.();return}let R=[];for(let k of Array.from(document.styleSheets))try{for(let E of Array.from(k.cssRules))E instanceof CSSFontFaceRule&&R.push(E.cssText);}catch{}let T=v.cloneNode(true);T.style.cssText="display: block; margin: 0; padding: 0;";for(let k of Array.from(T.querySelectorAll(".layout-page"))){let E=k;E.style.boxShadow="none",E.style.margin="0";}C.document.write(`<!DOCTYPE html>
2
2
  <html><head><title>Print</title>
3
3
  <style>
4
4
  ${R.join(`
@@ -9,7 +9,7 @@ body { background: white; }
9
9
  .layout-page:last-child { break-after: auto; }
10
10
  @page { margin: 0; size: auto; }
11
11
  </style>
12
- </head><body>${P.outerHTML}</body></html>`),C.document.close(),C.onload=()=>{C.print(),C.close();},setTimeout(()=>{C.closed||(C.print(),C.close());},1e3),l?.();},[o,l]),g=Bl.useCallback(async()=>{let v=await i();if(!v)return;let C=new Blob([v],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}),R=URL.createObjectURL(C),P=window.document.createElement("a");P.href=R,P.download=`${(n?.trim()||"document").replace(/\.docx$/i,"")}.docx`,P.click(),setTimeout(()=>URL.revokeObjectURL(R),0);},[i,n]),x=Bl.useCallback(()=>{b.current?.click();},[]),y=Bl.useCallback(async v=>{try{let C=await utils.readDocxFileFromInput(v.nativeEvent);if(!C)return;await s(C.buffer),m?.(C.name);}catch(C){d?.(C instanceof Error?C:new Error("Failed to open document"));}},[s,m,d]),c=Bl.useCallback(()=>{f.current?.click();},[]),S=Bl.useCallback(v=>{let C=v.target.files?.[0],R=a();C&&R&&commands.insertImageFromFile(R,C,{onInserted:h}),v.target.value="";},[a,h]);return {imageInputRef:f,docxInputRef:b,handleSave:i,handleDirectPrint:p,handleDownloadDocument:g,handleOpenDocument:x,handleDocxFileChange:y,handleInsertImageClick:c,handleImageFileChange:S}}function vi({document:e,readOnly:t,handleDocumentChange:o,getActiveEditorView:r}){let[n,u]=Bl.useState(false),d=Bl.useCallback(()=>u(true),[]),l=Bl.useCallback(x=>y=>{if(!e||t)return;let c={...e,package:{...e.package,document:{...e.package.document,finalSectionProperties:{...e.package.document.finalSectionProperties,[x]:y}}}};o(c);},[e,t,o]),m=Bl.useMemo(()=>l("marginLeft"),[l]),s=Bl.useMemo(()=>l("marginRight"),[l]),a=Bl.useMemo(()=>l("marginTop"),[l]),h=Bl.useMemo(()=>l("marginBottom"),[l]),f=Bl.useCallback(x=>{if(!e||t)return;let y={...e,package:{...e.package,document:{...e.package.document,finalSectionProperties:{...e.package.document.finalSectionProperties,...x}}}};o(y);},[e,t,o]),b=Bl.useCallback(x=>{let y=r();y&&commands.setIndentLeft(x)(y.state,y.dispatch);},[r]),i=Bl.useCallback(x=>{let y=r();y&&commands.setIndentRight(x)(y.state,y.dispatch);},[r]),p=Bl.useCallback(x=>{let y=r();y&&(x<0?commands.setIndentFirstLine(-x,true)(y.state,y.dispatch):commands.setIndentFirstLine(x,false)(y.state,y.dispatch));},[r]),g=Bl.useCallback(x=>{let y=r();y&&commands.removeTabStop(x)(y.state,y.dispatch);},[r]);return {showPageSetup:n,setShowPageSetup:u,handleOpenPageSetup:d,handleLeftMarginChange:m,handleRightMarginChange:s,handleTopMarginChange:a,handleBottomMarginChange:h,handlePageSetupApply:f,handleIndentLeftChange:b,handleIndentRightChange:i,handleFirstLineIndentChange:p,handleTabStopRemove:g}}function Si({readOnly:e,getBodyEditorView:t}){let[o,r]=Bl.useState(false),n=Bl.useCallback(()=>r(true),[]),u=t(),d=u?commands.getWatermarkFromState(u.state)??void 0:void 0,l=Bl.useCallback(m=>{if(e)return;let s=t();s&&commands.setWatermark(m)(s.state,s.dispatch);},[e,t]);return {showWatermark:o,setShowWatermark:r,handleOpenWatermark:n,currentWatermark:d,handleWatermarkApply:l}}function Pi({hyperlinkDialog:e,getActiveEditorView:t,focusActiveEditor:o}){let[r,n]=Bl.useState(null),u=Bl.useCallback(i=>{let p=t();if(!p)return;let g=i.url||"",x=i.tooltip,{empty:y}=p.state.selection;y&&i.displayText?commands.insertHyperlink(i.displayText,g,x)(p.state,p.dispatch):y?i.displayText&&commands.insertHyperlink(i.displayText,g,x)(p.state,p.dispatch):commands.setHyperlink(g,x)(p.state,p.dispatch),e.close(),o();},[e,t,o]),d=Bl.useCallback(()=>{let i=t();i&&(commands.removeHyperlink(i.state,i.dispatch),o());},[t,o]),l=Bl.useCallback(()=>{d(),e.close();},[e,d]),m=Bl.useCallback(i=>n(i),[]),s=Bl.useCallback(i=>{window.open(i,"_blank","noopener,noreferrer");},[]),a=Bl.useCallback(i=>{navigator.clipboard.writeText(i).catch(()=>{let p=document.createElement("textarea");p.value=i,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.select(),document.execCommand("copy"),document.body.removeChild(p);});},[]),h=Bl.useCallback((i,p)=>{let g=t();if(!g)return;let x=commands.findHyperlinkRangeAt(g.state);if(x){let y=g.state.schema.marks.hyperlink,{$from:c}=g.state.selection,S=y.create({href:p,tooltip:x.mark.attrs.tooltip}),v=g.state.schema.text(i,[...c.marks().filter(R=>R.type!==y),S]),C=g.state.tr.replaceWith(x.start,x.end,v);g.dispatch(C.scrollIntoView());}n(null),o();},[t,o]),f=Bl.useCallback(()=>{let i=t();if(!i)return;let p=commands.findHyperlinkRangeAt(i.state,r?.href);if(!p)return;let g=i.state.schema.marks.hyperlink;i.dispatch(i.state.tr.removeMark(p.start,p.end,g).scrollIntoView()),n(null),o(),sonner.toast("Link removed");},[t,o,r]),b=Bl.useCallback(()=>{n(null);},[]);return {hyperlinkPopupData:r,setHyperlinkPopupData:n,handleHyperlinkSubmit:u,handleHyperlinkRemove:l,handleHyperlinkClick:m,handleHyperlinkPopupNavigate:s,handleHyperlinkPopupCopy:a,handleHyperlinkPopupEdit:h,handleHyperlinkPopupRemove:f,handleHyperlinkPopupClose:b}}function Ti(e,t,o){let r=0;for(let n of e){let u=r+n.text.length;if(o==="start"&&t>=r&&t<u||o==="end"&&t>r&&t<=u)return n.pmStart+t-r;r=u;}return null}function wi(e,t,o){let r=[],n=0;return e.state.doc.descendants((u,d)=>{if(!u.isTextblock)return true;let l=[],m="";if(u.descendants((a,h)=>(!a.isText||!a.text||(l.push({text:a.text,pmStart:d+1+h}),m+=a.text),true)),!m)return n+=1,false;let s=(0, chunkL4MDZW2J_js.a.findAllMatches)(m,t,o);for(let a of s){let h=Ti(l,a.start,"start"),f=Ti(l,a.end,"end");h==null||f==null||h>=f||r.push({paragraphIndex:n,contentIndex:0,startOffset:a.start,endOffset:a.end,text:m.slice(a.start,a.end),pmFrom:h,pmTo:f});}return n+=1,false}),r}function Ei({pagedEditorRef:e,findReplace:t}){let o=Bl.useRef(null),r=Bl.useCallback(()=>e.current?.getView()??null,[e]),n=Bl.useCallback((a,h)=>{let f=r();if(!f||!a)return null;try{let i=prosemirrorState.TextSelection.create(f.state.doc,a.pmFrom,a.pmTo);f.dispatch(f.state.tr.setSelection(i)),e.current?.scrollToPosition(a.pmFrom);}catch(i){return console.error("Find navigation failed:",i),null}let b=o.current;return b&&(b.currentIndex=h),t.goToMatch(h),a},[t,r,e]),u=Bl.useCallback((a,h)=>{let f=r();if(!f||!a.trim())return o.current=null,t.setMatches([],0),null;let b=wi(f,a,h),i={matches:b,totalCount:b.length,currentIndex:0};return o.current=i,t.setMatches(b,0),b.length>0&&n(b[0],0),i},[t,r,n]),d=Bl.useCallback(()=>{let a=o.current;if(!a||a.matches.length===0)return null;let h=(a.currentIndex+1)%a.matches.length;return n(a.matches[h],h)},[n]),l=Bl.useCallback(()=>{let a=o.current;if(!a||a.matches.length===0)return null;let h=a.currentIndex===0?a.matches.length-1:a.currentIndex-1;return n(a.matches[h],h)},[n]),m=Bl.useCallback(a=>{let h=r(),f=o.current;if(!h||!f||f.matches.length===0)return false;let b=f.matches[f.currentIndex];if(!b)return false;try{let i=a?h.state.tr.replaceWith(b.pmFrom,b.pmTo,h.state.schema.text(a)):h.state.tr.delete(b.pmFrom,b.pmTo);return h.dispatch(i),!0}catch(i){return console.error("Replace failed:",i),false}},[r]),s=Bl.useCallback((a,h,f)=>{let b=r();if(!b||!a.trim())return 0;let i=wi(b,a,f);if(i.length===0)return 0;let p=[...i].sort((x,y)=>y.pmFrom-x.pmFrom),g=b.state.tr;for(let x of p)try{g=h?g.replaceWith(x.pmFrom,x.pmTo,b.state.schema.text(h)):g.delete(x.pmFrom,x.pmTo);}catch(y){console.error("Replace failed for match:",x,y);}return b.dispatch(g),o.current=null,t.setMatches([],0),i.length},[t,r]);return {findResultRef:o,handleFind:u,handleFindNext:d,handleFindPrevious:l,handleReplace:m,handleReplaceAll:s}}function Mi({getActiveEditorView:e,focusActiveEditor:t,pagedEditorRef:o,lastSelectionRef:r,hyperlinkDialog:n,historyStateRef:u,getCachedStyleResolver:d}){let l=Bl.useCallback(b=>{let i=e();if(!i)return;i.focus();let p=i===o.current?.getView(),{from:g,to:x}=i.state.selection,y=r.current;if(p&&y&&(g!==y.from||x!==y.to))try{let c=i.state.tr.setSelection(prosemirrorState.TextSelection.create(i.state.doc,y.from,y.to));i.dispatch(c);}catch(c){console.warn("Could not restore selection:",c);}if(b==="bold")return void commands.toggleBold(i.state,i.dispatch);if(b==="italic")return void commands.toggleItalic(i.state,i.dispatch);if(b==="underline")return void commands.toggleUnderline(i.state,i.dispatch);if(b==="strikethrough")return void commands.toggleStrike(i.state,i.dispatch);if(b==="superscript")return void commands.toggleSuperscript(i.state,i.dispatch);if(b==="subscript")return void commands.toggleSubscript(i.state,i.dispatch);if(b==="bulletList")return void commands.toggleBulletList(i.state,i.dispatch);if(b==="numberedList")return void commands.toggleNumberedList(i.state,i.dispatch);if(b==="indent"){commands.increaseListLevel(i.state,i.dispatch)||commands.increaseIndent()(i.state,i.dispatch);return}if(b==="outdent"){commands.decreaseListLevel(i.state,i.dispatch)||commands.decreaseIndent()(i.state,i.dispatch);return}if(b==="clearFormatting")return void commands.clearFormatting(i.state,i.dispatch);if(b==="setRtl")return void commands.setRtl(i.state,i.dispatch);if(b==="setLtr")return void commands.setLtr(i.state,i.dispatch);if(b==="insertLink"){let c=commands.getSelectedText(i.state),S=commands.getHyperlinkAttrs(i.state);S?n.openEdit({url:S.href,displayText:c,tooltip:S.tooltip}):n.openInsert(c);return}if(typeof b=="object")switch(b.type){case "alignment":commands.setAlignment(b.value)(i.state,i.dispatch);break;case "textColor":{let c=b.value;typeof c=="string"?commands.setTextColor({rgb:c.replace("#","")})(i.state,i.dispatch):c.auto?commands.clearTextColor(i.state,i.dispatch):commands.setTextColor(c)(i.state,i.dispatch);break}case "highlightColor":{let c=b.value?chunkGDJM7SOG_js.g(b.value):"";commands.setHighlight(c||b.value)(i.state,i.dispatch);break}case "fontSize":commands.setFontSize(chunkGDJM7SOG_js.d(b.value))(i.state,i.dispatch);break;case "fontFamily":commands.setFontFamily(b.value)(i.state,i.dispatch);break;case "lineSpacing":commands.setLineSpacing(b.value)(i.state,i.dispatch);break;case "applyStyle":{let c=u.current,S=c?.package.styles?d(c.package.styles):null;if(S){let v=S.resolveParagraphStyle(b.value);commands.applyStyle(b.value,{paragraphFormatting:v.paragraphFormatting,runFormatting:v.runFormatting,numbering:c?.package.numbering?docx.getCachedNumberingMap(c.package.numbering):null})(i.state,i.dispatch);}else commands.applyStyle(b.value)(i.state,i.dispatch);break}}},[e,o,r,n,u,d]),m=Bl.useCallback((b,i)=>{let p=e();p&&(commands.insertTable(b,i)(p.state,p.dispatch),t());},[e,t]),s=Bl.useCallback(()=>{let b=e();b&&(commands.insertPageBreak(b.state,b.dispatch),t());},[e,t]),a=Bl.useCallback(()=>{let b=e();b&&(commands.insertSectionBreakNextPage(b.state,b.dispatch),t());},[e,t]),h=Bl.useCallback(()=>{let b=e();b&&(commands.insertSectionBreakContinuous(b.state,b.dispatch),t());},[e,t]),f=Bl.useCallback(()=>{let b=e();b&&(commands.generateTOC(b.state,b.dispatch),t());},[e,t]);return {handleFormat:l,handleInsertTable:m,handleInsertPageBreak:s,handleInsertSectionBreakNextPage:a,handleInsertSectionBreakContinuous:h,handleInsertTOC:f}}function Di({document:e,pmImageContext:t,zoom:o,getActiveEditorView:r,focusActiveEditor:n,pushDocument:u}){let[d,l]=Bl.useState(false),[m,s]=Bl.useState(false),[a,h]=Bl.useState(false),f=Bl.useCallback(y=>{let c=r();if(!c||!t)return;let S=t.pos,v=c.state.doc.nodeAt(S);if(!v||v.type.name!=="image")return;let C=layoutPainter.toolbarValueToLayoutTarget(y);if(!C)return;let R;if(v.attrs.wrapType==="inline"&&C!=="inline"){let P=window.document.querySelector(`.layout-run-image[data-pm-start="${S}"]`),k=P?layoutPainter.captureInlinePositionEmu(P,o):void 0;k&&(R={initialPositionEmu:k});}commands.setImageWrapType(S,C,R)(c.state,c.dispatch),n();},[r,n,t,o]),b=Bl.useCallback(y=>{let c=r();if(!c||!t)return;let S=t.pos,v=c.state.doc.nodeAt(S);if(!v||v.type.name!=="image")return;let C=v.attrs.transform||"",R=C.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),P=R?parseFloat(R[1]):0,k=/scaleX\(-1\)/.test(C),E=/scaleY\(-1\)/.test(C);switch(y){case "rotateCW":P=(P+90)%360;break;case "rotateCCW":P=(P-90+360)%360;break;case "flipH":k=!k;break;case "flipV":E=!E;break}let I=[];P!==0&&I.push(`rotate(${P}deg)`),k&&I.push("scaleX(-1)"),E&&I.push("scaleY(-1)");let w=I.length>0?I.join(" "):null,D=c.state.tr.setNodeMarkup(S,void 0,{...v.attrs,transform:w});c.dispatch(D.scrollIntoView()),n();},[r,n,t]),i=Bl.useCallback(y=>{let c=r();if(!c||!t)return;let S=t.pos,v=c.state.doc.nodeAt(S);if(!v||v.type.name!=="image")return;let C=c.state.tr.setNodeMarkup(S,void 0,{...v.attrs,position:{horizontal:y.horizontal,vertical:y.vertical},distTop:y.distTop??v.attrs.distTop,distBottom:y.distBottom??v.attrs.distBottom,distLeft:y.distLeft??v.attrs.distLeft,distRight:y.distRight??v.attrs.distRight});c.dispatch(C.scrollIntoView()),n();},[r,n,t]),p=Bl.useCallback(()=>{s(true);},[]),g=Bl.useCallback(y=>{let c=r();if(!c||!t)return;let S=t.pos,v=c.state.doc.nodeAt(S);if(!v||v.type.name!=="image")return;let C=c.state.tr.setNodeMarkup(S,void 0,{...v.attrs,alt:y.alt??null,borderWidth:y.borderWidth??null,borderColor:y.borderColor??null,borderStyle:y.borderStyle??null,width:y.width??null,height:y.height??null});c.dispatch(C.scrollIntoView()),n();},[r,n,t]),x=Bl.useCallback((y,c)=>{if(!e?.package)return;let S={...e.package.document,finalSectionProperties:{...e.package.document.finalSectionProperties,footnotePr:y,endnotePr:c}};u({...e,package:{...e.package,document:S}});},[e,u]);return {imagePositionOpen:d,setImagePositionOpen:l,imagePropsOpen:m,setImagePropsOpen:s,footnotePropsOpen:a,setFootnotePropsOpen:h,handleImageWrapType:f,handleImageTransform:b,handleApplyImagePosition:i,handleOpenImageProperties:p,handleApplyImageProperties:g,handleApplyFootnoteProperties:x}}var qo=new Map;function Fi({ref:e,agentRef:t,document:o,historyStateRef:r,pagedEditorRef:n,handleSave:u,handleDirectPrint:d,zoom:l,setZoom:m,scrollPageInfo:s,loadParsedDocument:a,loadBuffer:h,comments:f,setComments:b,setShowCommentsSidebar:i,contentChangeSubscribersRef:p,selectionChangeSubscribersRef:g,getCachedStyleResolver:x,commentIdAllocator:y}){Bl.useImperativeHandle(e,()=>({getAgent:()=>t.current,getDocument:()=>o,getEditorRef:()=>n.current,save:u,setZoom:m,getZoom:()=>l,focus:()=>{n.current?.focus();},getCurrentPage:()=>s.currentPage,getTotalPages:()=>s.totalPages,scrollToPage:c=>{n.current?.scrollToPage(c);},scrollToPosition:c=>{n.current?.scrollToPosition(c);},openPrintPreview:d,print:d,loadDocument:a,loadDocumentBuffer:h,addComment:c=>{let S=n.current?.getView();if(!S)return null;let v=commentOps.addCommentToRange(S,c,y);return v?(b(C=>[...C,v]),i(true),v.id):null},replyToComment:(c,S,v)=>{if(!f.some(R=>R.id===c))return null;let C=commentOps.createComment(y,S,v,c);return b(R=>[...R,C]),C.id},resolveComment:c=>{b(S=>S.map(v=>v.id===c?{...v,done:true}:v));},proposeChange:c=>{let S=n.current?.getView();if(!S)return false;let v=commentOps.applyProposedChange(S,c,y);return v&&i(true),v},applyFormatting:c=>{let S=n.current?.getView();return S?applyFormatting.applyFormatting(S,c):false},setParagraphStyle:c=>{let S=n.current?.getView();if(!S)return false;let v=r.current,C=v?.package?.styles?x(v.package.styles):null,R=v?.package?.numbering?docx.getCachedNumberingMap(v.package.numbering):null;return applyFormatting.setParagraphStyle(S,c,{styleResolver:C,numbering:R})},insertBreak:c=>{let S=n.current?.getView();return S?applyFormatting.insertBreak(S,c):false},getPageContent:c=>queries.getPageContent(n.current?.getView()??null,n.current?.getLayout()??null,c),scrollToParaId:c=>n.current?.scrollToParaId(c)??false,scrollToCommentId:c=>n.current?.scrollToCommentId(c)??false,scrollToChangeId:c=>n.current?.scrollToChangeId(c)??false,highlightRange:(c,S)=>{n.current?.highlightRange(c,S);},findInDocument:(c,S)=>queries.findInDocument(n.current?.getView()??null,c,S),getSelectionInfo:()=>queries.getSelectionInfo(n.current?.getView()??null),getComments:()=>f,getContentControls:c=>{let S=n.current?.getView();return S?prosemirror.findContentControlsInPM(S.state.doc,c??{}):[]},scrollToContentControl:c=>{let S=n.current?.getView();if(!S)return false;let v=prosemirror.findContentControlPos(S.state.doc,c);return v==null?false:(n.current?.scrollToPosition(v),true)},setContentControlContent:(c,S,v)=>{let C=n.current?.getView();if(!C)return false;try{return C.dispatch(prosemirror.setContentControlContentTr(C.state,c,S,v)),!0}catch(R){if(R instanceof agent.ContentControlNotFoundError)return false;throw R}},removeContentControl:(c,S)=>{let v=n.current?.getView();if(!v)return false;try{return v.dispatch(prosemirror.removeContentControlTr(v.state,c,S)),!0}catch(C){if(C instanceof agent.ContentControlNotFoundError)return false;throw C}},setContentControlValue:(c,S,v)=>{let C=n.current?.getView();if(!C)return false;try{return C.dispatch(prosemirror.setContentControlValueTr(C.state,c,S,v)),!0}catch(R){if(R instanceof agent.ContentControlNotFoundError)return false;throw R}},onContentChange:c=>(p.current.add(c),()=>{p.current.delete(c);}),onSelectionChange:c=>(g.current.add(c),()=>{g.current.delete(c);})}),[o,l,s,u,d,a,h,f]);}var U=e=>({style:"single",size:4,color:{rgb:e}}),op=[{id:"TableNormal",name:"Normal Table",look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGrid",name:"Table Grid",tableBorders:{top:U("000000"),bottom:U("000000"),left:U("000000"),right:U("000000"),insideH:U("000000"),insideV:U("000000")},look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGridLight",name:"Grid Table Light",tableBorders:{top:U("BFBFBF"),bottom:U("BFBFBF"),left:U("BFBFBF"),right:U("BFBFBF"),insideH:U("BFBFBF"),insideV:U("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:U("000000")}}}},{id:"PlainTable1",name:"Plain Table 1",tableBorders:{top:U("BFBFBF"),bottom:U("BFBFBF"),insideH:U("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true}}},{id:"PlainTable2",name:"Plain Table 2",look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:U("7F7F7F")}},band1Horz:{backgroundColor:"#F2F2F2"}}},{id:"PlainTable3",name:"Plain Table 3",look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#A5A5A5"},band1Horz:{backgroundColor:"#E7E7E7"}}},{id:"PlainTable4",name:"Plain Table 4",look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#000000"},band1Horz:{backgroundColor:"#F2F2F2"}}},{id:"GridTable1Light-Accent1",name:"Grid Table 1 Light",tableBorders:{top:U("B4C6E7"),bottom:U("B4C6E7"),left:U("B4C6E7"),right:U("B4C6E7"),insideH:U("B4C6E7"),insideV:U("B4C6E7")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:U("4472C4")}}}},{id:"GridTable4-Accent1",name:"Grid Table 4 Accent 1",tableBorders:{top:U("4472C4"),bottom:U("4472C4"),left:U("4472C4"),right:U("4472C4"),insideH:U("4472C4"),insideV:U("4472C4")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#4472C4"},band1Horz:{backgroundColor:"#D6E4F0"}}},{id:"GridTable5Dark-Accent1",name:"Grid Table 5 Dark",tableBorders:{top:U("FFFFFF"),bottom:U("FFFFFF"),left:U("FFFFFF"),right:U("FFFFFF"),insideH:U("FFFFFF"),insideV:U("FFFFFF")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#4472C4"},band1Horz:{backgroundColor:"#D6E4F0"},band2Horz:{backgroundColor:"#B4C6E7"}}},{id:"ListTable3-Accent2",name:"List Table 3 Accent 2",tableBorders:{top:U("ED7D31"),bottom:U("ED7D31")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#ED7D31"},band1Horz:{backgroundColor:"#FBE4D5"}}},{id:"ListTable4-Accent3",name:"List Table 4 Accent 3",tableBorders:{top:U("A5A5A5"),bottom:U("A5A5A5"),insideH:U("A5A5A5")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#A5A5A5"},band1Horz:{backgroundColor:"#EDEDED"}}},{id:"GridTable4-Accent5",name:"Grid Table 4 Accent 5",tableBorders:{top:U("5B9BD5"),bottom:U("5B9BD5"),left:U("5B9BD5"),right:U("5B9BD5"),insideH:U("5B9BD5"),insideV:U("5B9BD5")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#5B9BD5"},band1Horz:{backgroundColor:"#DEEAF6"}}},{id:"GridTable4-Accent6",name:"Grid Table 4 Accent 6",tableBorders:{top:U("70AD47"),bottom:U("70AD47"),left:U("70AD47"),right:U("70AD47"),insideH:U("70AD47"),insideV:U("70AD47")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#70AD47"},band1Horz:{backgroundColor:"#E2EFDA"}}}];function Li(e){return op.find(t=>t.id===e)}function Oi({getActiveEditorView:e,focusActiveEditor:t,tableSelection:o,borderSpecRef:r,historyStateRef:n,getCachedStyleResolver:u}){let[d,l]=Bl.useState(false),[m,s]=Bl.useState({isOpen:false,initialRows:1,initialCols:2,minRows:1,minCols:1,source:null,capturedCellRow:null,capturedCellCol:null}),a=Bl.useCallback(()=>{let i=e(),p=i?commands.getSplitCellDialogConfig(i.state):null,g=p?null:o.getSplitCellConfig(),x=p??g;x&&s({isOpen:true,...x,source:p?"pm":"legacy",capturedCellRow:p?.capturedCellRow??null,capturedCellCol:p?.capturedCellCol??null});},[e,o]),h=Bl.useCallback(i=>{let p=e();if(!p){i==="splitCell"?a():typeof i!="object"&&o.handleAction(i);return}switch(i){case "addRowAbove":prosemirror.addRowAbove(p.state,p.dispatch);break;case "addRowBelow":prosemirror.addRowBelow(p.state,p.dispatch);break;case "addColumnLeft":prosemirror.addColumnLeft(p.state,p.dispatch);break;case "addColumnRight":prosemirror.addColumnRight(p.state,p.dispatch);break;case "deleteRow":prosemirror.deleteRow(p.state,p.dispatch);break;case "deleteColumn":prosemirror.deleteColumn(p.state,p.dispatch);break;case "deleteTable":prosemirror.deleteTable(p.state,p.dispatch);break;case "selectTable":prosemirror.selectTable(p.state,p.dispatch);break;case "selectRow":prosemirror.selectRow(p.state,p.dispatch);break;case "selectColumn":prosemirror.selectColumn(p.state,p.dispatch);break;case "mergeCells":prosemirror.mergeCells(p.state,p.dispatch);break;case "splitCell":a();break;case "borderAll":prosemirror.setAllTableBorders(p.state,p.dispatch,r.current);break;case "borderOutside":prosemirror.setOutsideTableBorders(p.state,p.dispatch,r.current);break;case "borderInside":prosemirror.setInsideTableBorders(p.state,p.dispatch,r.current);break;case "borderNone":prosemirror.removeTableBorders(p.state,p.dispatch);break;case "borderTop":prosemirror.setCellBorder("top",r.current,true)(p.state,p.dispatch);break;case "borderBottom":prosemirror.setCellBorder("bottom",r.current,true)(p.state,p.dispatch);break;case "borderLeft":prosemirror.setCellBorder("left",r.current,true)(p.state,p.dispatch);break;case "borderRight":prosemirror.setCellBorder("right",r.current,true)(p.state,p.dispatch);break;default:if(typeof i=="object"){if(i.type==="cellFillColor")prosemirror.setCellFillColor(i.color)(p.state,p.dispatch);else if(i.type==="borderColor"){let g=i.color.replace(/^#/,"");r.current={...r.current,color:{rgb:g}},prosemirror.setTableBorderColor(i.color)(p.state,p.dispatch);}else if(i.type==="borderWidth")r.current={...r.current,size:i.size},prosemirror.setTableBorderWidth(i.size)(p.state,p.dispatch);else if(i.type==="cellBorder")prosemirror.setCellBorder(i.side,{style:i.style,size:i.size,color:{rgb:i.color.replace(/^#/,"")}})(p.state,p.dispatch);else if(i.type==="cellVerticalAlign")prosemirror.setCellVerticalAlign(i.align)(p.state,p.dispatch);else if(i.type==="cellMargins")prosemirror.setCellMargins(i.margins)(p.state,p.dispatch);else if(i.type==="cellTextDirection")prosemirror.setCellTextDirection(i.direction)(p.state,p.dispatch);else if(i.type==="toggleNoWrap")prosemirror.toggleNoWrap()(p.state,p.dispatch);else if(i.type==="rowHeight")prosemirror.setRowHeight(i.height,i.rule)(p.state,p.dispatch);else if(i.type==="toggleHeaderRow")prosemirror.toggleHeaderRow()(p.state,p.dispatch);else if(i.type==="distributeColumns")prosemirror.distributeColumns()(p.state,p.dispatch);else if(i.type==="autoFitContents")prosemirror.autoFitContents()(p.state,p.dispatch);else if(i.type==="openTableProperties")l(true);else if(i.type==="applyTableStyle"){let g=Li(i.styleId),x=n.current;if(!g&&x?.package.styles){let c=u(x.package.styles).getStyle(i.styleId);if(c){if(g={id:c.styleId,name:c.name??c.styleId},c.tblPr?.borders){let S=c.tblPr.borders;g.tableBorders={};for(let v of ["top","bottom","left","right","insideH","insideV"]){let C=S[v];C&&(g.tableBorders[v]={style:C.style,size:C.size,color:C.color?.rgb?{rgb:C.color.rgb}:void 0});}}if(c.tblStylePr){g.conditionals={};for(let S of c.tblStylePr){let v={};if(S.tcPr?.shading?.fill&&(v.backgroundColor=`#${S.tcPr.shading.fill}`),S.tcPr?.borders){let C={};for(let R of ["top","bottom","left","right"]){let P=S.tcPr.borders[R];P&&(C[R]={style:P.style,size:P.size,color:P.color?.rgb?{rgb:P.color.rgb}:void 0});}v.borders=C;}S.rPr?.bold&&(v.bold=true),S.rPr?.color?.rgb&&(v.color=`#${S.rPr.color.rgb}`),g.conditionals[S.type]=v;}}g.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}g&&prosemirror.applyTableStyle({styleId:g.id,tableBorders:g.tableBorders,conditionals:g.conditionals,look:g.look})(p.state,p.dispatch);}}else o.handleAction(i);}t();},[o,e,t,a,r,n,u]),f=Bl.useCallback(()=>{s(i=>({...i,isOpen:false,source:null,capturedCellRow:null,capturedCellCol:null}));},[]),b=Bl.useCallback((i,p)=>{if(m.source==="legacy"){o.applySplitCell(i,p),t();return}let g=e();g&&(commands.splitActiveTableCell(g.state,g.dispatch,i,p,m.capturedCellRow??void 0,m.capturedCellCol??void 0),t());},[t,e,m.source,m.capturedCellRow,m.capturedCellCol,o]);return {tablePropsOpen:d,setTablePropsOpen:l,splitCellDialogState:m,openSplitCellDialog:a,handleTableAction:h,handleSplitCellDialogClose:f,handleSplitCellDialogApply:b}}function Bi({document:e,pushDocument:t,hfEditorRef:o,containerRef:r,initialSectionProperties:n,finalSectionProperties:u,hfEditPosition:d,setHfEditPosition:l,hfEditIsFirstPage:m,setHfEditIsFirstPage:s}){let{headerContent:a,footerContent:h,firstPageHeaderContent:f,firstPageFooterContent:b}=Bl.useMemo(()=>{let{header:c,footer:S,firstHeader:v,firstFooter:C}=layoutBridge.resolveHeaderFooter(e??null,u??n);return {headerContent:c,footerContent:S,firstPageHeaderContent:v,firstPageFooterContent:C}},[e,n,u]),i=Bl.useCallback((c,S)=>{let C=e?.package?.document?.finalSectionProperties?.titlePg===true&&(S??1)===1,R=C?c==="header"?f:b:c==="header"?a:h;if(s(C),R){l(c);return}if(!e?.package)return;let P=e.package,k=P.document?.finalSectionProperties;if(!k)return;let E=C?"first":"default",I=`rId_new_${c}_${E}`,w={type:c==="header"?"header":"footer",hdrFtrType:E,content:[{type:"paragraph",content:[]}]},D=c==="header"?"headers":"footers",H=new Map(P[D]??[]);H.set(I,w);let O=c==="header"?"headerReferences":"footerReferences",B=k[O]??[],_={type:E,rId:I},W=P.relationships,Z=new Set;for(let me of W?.values()??[])me.target&&Z.add(me.target);let Y=1;for(;Z.has(`${c}${Y}.xml`);)Y++;let J=c==="header"?"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header":"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",te=new Map(W);te.set(I,{id:I,type:J,target:`${c}${Y}.xml`});let ne={...e,package:{...P,[D]:H,relationships:te,document:P.document?{...P.document,finalSectionProperties:{...k,[O]:[...B,_]}}:P.document}};t(ne),l(c);},[a,h,f,b,e,t,l,s]),p=Bl.useCallback(c=>{if(!d||!e?.package){l(null);return}let S=e.package,v=S.document?.finalSectionProperties,C=d==="header"?v?.headerReferences:v?.footerReferences,R=m?"first":"default",P=C?.find(I=>I.type===R)??C?.find(I=>I.type==="default")??C?.find(I=>I.type==="first")??C?.[0],k=d==="header"?"headers":"footers",E=S[k];if(P?.rId&&E){let I=E.get(P.rId),w={type:d,hdrFtrType:P.type,...I,content:c},D=new Map(E);D.set(P.rId,w);let H={...e,package:{...S,[k]:D}};t(H);}l(null);},[d,m,e,t,l]),g=Bl.useCallback(()=>{if(!d)return;let c=o.current?.getView();if(c){let S=conversion.proseDocToBlocks(c.state.doc);p(S);}else l(null);},[d,p,o,l]),x=Bl.useCallback(()=>{if(!d||!e?.package){l(null);return}let c=e.package,S=c.document?.finalSectionProperties,v=d==="header"?"headerReferences":"footerReferences",C=d==="header"?"headers":"footers",R=S?.[v],P=m?"first":"default",k=R?.find(E=>E.type===P)??R?.find(E=>E.type==="default")??R?.find(E=>E.type==="first")??R?.[0];if(k?.rId){let E=new Map(c[C]??[]);E.delete(k.rId);let I=(R??[]).filter(D=>D.rId!==k.rId),w={...e,package:{...c,[C]:E,document:c.document?{...c.document,finalSectionProperties:{...S,[v]:I}}:c.document}};t(w);}l(null);},[d,m,e,t,l]),y=Bl.useCallback(c=>{let S=r.current?.querySelector(".paged-editor__pages");if(!S)return null;let v=c==="header"?".layout-page-header":".layout-page-footer";return S.querySelector(v)},[r]);return {headerContent:a,footerContent:h,firstPageHeaderContent:f,firstPageFooterContent:b,handleHeaderFooterDoubleClick:i,handleHeaderFooterSave:p,handleBodyClick:g,handleRemoveHeaderFooter:x,getHfTargetElement:y}}function zi({documentBuffer:e,initialDocument:t,externalContent:o,history:r,agentRef:n,pagedEditorRef:u,setLoadingState:d,setComments:l,setShowCommentsSidebar:m,onError:s,resetForNewDocument:a,commentsLoadedRef:h,commentIdAllocator:f}){let b=Bl.useRef(0),i=Bl.useCallback(g=>{a(),r.reset(g),d({isLoading:false,parseError:null}),utils.loadDocumentFonts(g).catch(x=>{console.warn("Failed to load document fonts:",x);});},[a,r,d]),p=Bl.useCallback(async g=>{let x=++b.current;a(),d({isLoading:true,parseError:null});try{let y=await docx.parseDocx(g);if(b.current!==x)return;i(y);}catch(y){if(b.current!==x)return;let c=y instanceof Error?y.message:"Failed to parse document";d({isLoading:false,parseError:c}),s?.(y instanceof Error?y:new Error(c));}},[a,i,s,d]);return Bl.useEffect(()=>{if(!o){if(!e){t&&i(t);return}p(e);}},[e,t,o]),Bl.useEffect(()=>{r.state?n.current=new agent.DocumentAgent(r.state):n.current=null;},[r.state,n]),Bl.useEffect(()=>{if(h.current)return;let g=r.state;if(!g)return;h.current=true;let x=g.package?.document?.comments;x&&x.length>0&&(l(x),m(true)),commentIdAllocator.seedCommentAllocator(f,x,u.current?.getView()??null);},[r.state,u,l,m,h,f]),{loadParsedDocument:i,loadBuffer:p}}var Up={inline:"wrap_text",squareLeft:"format_image_left",squareRight:"format_image_right",behind:"flip_to_back",inFront:"flip_to_front"},go=18,Vi=({isOpen:e,position:t,currentWrapType:o,currentCssFloat:r,onApplyLayout:n,textActions:u,onTextAction:d,onOpenProperties:l,onClose:m})=>{let{t:s}=chunkGNIO6SOS_js.b(),a=Bl.useRef(null),[h,f]=Bl.useState(0),b=Bl.useMemo(()=>layoutPainter.deriveLayoutChoice(o,r),[o,r]),i=Bl.useMemo(()=>layoutPainter.IMAGE_LAYOUT_OPTIONS.filter(c=>layoutPainter.isImageLayoutOptionEnabled(c,o)),[o]),p=Bl.useMemo(()=>(u??[]).filter(c=>!c.disabled),[u]),g=l?1:0,x=g+i.length+p.length;Bl.useEffect(()=>{if(!e)return;let c=v=>{a.current&&!a.current.contains(v.target)&&m();},S=setTimeout(()=>{document.addEventListener("mousedown",c);},0);return ()=>{clearTimeout(S),document.removeEventListener("mousedown",c);}},[e,m]),Bl.useEffect(()=>{if(!e)return;let c=S=>{if(S.key==="Escape"){S.preventDefault(),m();return}let v=Math.max(1,x);if(S.key==="ArrowDown")S.preventDefault(),f(C=>(C+1)%v);else if(S.key==="ArrowUp")S.preventDefault(),f(C=>(C-1+v)%v);else if(S.key==="Enter"){if(S.preventDefault(),g&&h===0)l?.(),m();else if(h<g+i.length)n(i[h-g].choice),m();else if(d){let C=p[h-g-i.length];C&&(d(C.action),m());}}};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,h,i,p,x,g,n,l,d,m]),Bl.useEffect(()=>{if(!e)return;let c=b?i.findIndex(S=>S.choice===b):-1;f(c>=0?g+c:0);},[e,b,i,g]);let y=Bl.useCallback(()=>{let S=layoutPainter.IMAGE_LAYOUT_OPTIONS.length,v=u?.length??0,C=S*36+v*32+(v>0?9:0)+16,R=t.x,P=t.y;return typeof window<"u"&&(R+260>window.innerWidth&&(R=window.innerWidth-260-10),P+C>window.innerHeight&&(P=window.innerHeight-C-10),R<10&&(R=10),P<10&&(P=10)),{position:"fixed",top:P,left:R,minWidth:260,background:"var(--doc-surface)",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 2px 10px var(--doc-shadow)",zIndex:chunkGDJM7SOG_js.h.contextMenu,padding:"4px 0",overflow:"hidden"}},[t,u]);return e?jsxRuntime.jsxs("div",{ref:a,className:"docx-image-context-menu",style:y(),role:"menu","aria-label":s("imageWrap.menu.ariaLabel"),"data-testid":"image-context-menu",children:[l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",role:"menuitem","data-action":"open-properties",onClick:()=>{l(),m();},onMouseEnter:()=>f(0),style:{display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",border:"none",background:h===0?"var(--doc-primary-light)":"transparent",cursor:"pointer",fontSize:"13px",color:"var(--doc-text)",textAlign:"left"},children:[jsxRuntime.jsx("span",{style:{display:"flex",color:"var(--doc-text-muted)",width:go},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"settings",size:go})}),jsxRuntime.jsx("span",{style:{flex:1},children:s("imageWrap.menu.imageProperties")})]}),jsxRuntime.jsx("div",{style:{height:1,background:"var(--doc-border-light)",margin:"4px 0"},role:"separator"})]}),layoutPainter.IMAGE_LAYOUT_OPTIONS.map(c=>{let S=c.choice===b,v=layoutPainter.isImageLayoutOptionEnabled(c,o),C=v?g+i.findIndex(k=>k.choice===c.choice):-1,R=C>=0&&C===h,P=s(`imageWrap.menuDesc.${c.i18nDescKey}`);return jsxRuntime.jsxs("button",{type:"button",role:"menuitem","data-wrap-type":c.choice,"data-current":S?"true":"false","data-disabled":v?"false":"true",disabled:!v,onClick:()=>{v&&(n(c.choice),m());},onMouseEnter:()=>{C>=0&&f(C);},title:P,style:{display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",border:"none",background:R?"var(--doc-primary-light)":"transparent",cursor:v?"pointer":"not-allowed",fontSize:"13px",color:v?"var(--doc-text)":"var(--doc-text-placeholder)",textAlign:"left",opacity:v?1:.55},children:[jsxRuntime.jsx("span",{style:{display:"flex",color:S?"var(--doc-primary)":"var(--doc-text-muted)",width:go},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:Up[c.iconHint],size:go})}),jsxRuntime.jsx("span",{style:{flex:1},children:s(`imageWrap.menu.${c.i18nLabelKey}`)}),S&&jsxRuntime.jsx("span",{style:{fontSize:"11px",color:"var(--doc-primary)"},"aria-label":s("toolbar.imageWrap.current"),children:"\u25CF"})]},c.choice)}),u&&u.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{height:1,background:"var(--doc-border-light)",margin:"4px 0"},role:"separator"}),u.map((c,S)=>{let v=c.disabled?-1:g+i.length+p.findIndex(R=>R.action===c.action),C=v===h&&!c.disabled;return jsxRuntime.jsxs(Bl__default.default.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",role:"menuitem","data-action":c.action,"data-disabled":c.disabled?"true":"false",disabled:c.disabled,onClick:()=>{c.disabled||!d||(d(c.action),m());},onMouseEnter:()=>{v>=0&&f(v);},style:{display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"7px 12px",border:"none",background:C?"var(--doc-primary-light)":"transparent",cursor:c.disabled?"not-allowed":"pointer",fontSize:"13px",color:c.disabled?"var(--doc-text-placeholder)":"var(--doc-text)",textAlign:"left",opacity:c.disabled?.55:1},children:[jsxRuntime.jsx("span",{style:{width:go},"aria-hidden":"true"}),jsxRuntime.jsx("span",{style:{flex:1},children:c.label}),c.shortcut&&jsxRuntime.jsx("span",{style:{fontSize:"11px",color:"var(--doc-text-muted)",fontFamily:"monospace"},children:c.shortcut})]}),c.dividerAfter&&jsxRuntime.jsx("div",{style:{height:1,background:"var(--doc-border-light)",margin:"4px 0"},role:"separator"})]},`${c.action}-${S}`)})]})]}):null};function Ui(){let[e,t]=Bl.useState(false),[o,r]=Bl.useState({x:0,y:0}),[n,u]=Bl.useState("inline"),[d,l]=Bl.useState(null),[m,s]=Bl.useState(null),[a,h]=Bl.useState(null),f=Bl.useCallback(i=>{r({x:i.x,y:i.y}),u(i.wrapType),l(i.cssFloat??null),s(i.pos),h(i.inlinePositionEmu??null),t(true);},[]),b=Bl.useCallback(()=>{t(false),s(null),h(null);},[]);return {isOpen:e,position:o,currentWrapType:n,currentCssFloat:d,imagePos:m,inlinePositionEmu:a,openForImage:f,closeMenu:b}}function Zo(e,t,o){if(!e||!t)return null;let r=e.querySelector(".paged-editor__pages");if(!r)return null;for(let n of layoutBridge.findBodyPmAnchors(r)){let u=Number(n.dataset.pmStart),d=Number(n.dataset.pmEnd);if(o>=u&&o<=d)return n.getBoundingClientRect().top-t.getBoundingClientRect().top}return null}function $i(e){let t=e?.package?.document;return t?.sections?.[0]?.properties??t?.finalSectionProperties}function qi({getActiveEditorView:e,focusActiveEditor:t,openSplitCellDialog:o,scrollContainerRef:r,editorContentRef:n,i18n:u,onAddComment:d}){let{t:l}=chunkGNIO6SOS_js.b(),[m,s]=Bl.useState({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false,tableContext:null}),a=Ui(),h=Bl.useCallback(y=>{let c=y.target;if(c?.closest(".paged-editor__pages")&&!c.closest(".hf-inline-editor"))return;y.preventDefault(),y.stopPropagation();let S=e(),v=S?prosemirror.getTableContext(S.state):{isInTable:false},{from:C,to:R}=S?.state.selection??{from:0,to:0},P=C!==R;s({isOpen:true,position:{x:y.clientX,y:y.clientY},hasSelection:P,cursorInTable:v.isInTable,tableContext:v.isInTable?v:null});},[e]),f=Bl.useCallback(y=>{if(y.image){a.openForImage({x:y.x,y:y.y,wrapType:y.image.wrapType,cssFloat:y.image.cssFloat,pos:y.image.pos,inlinePositionEmu:y.image.inlinePositionEmu});return}let c=e(),S=c?prosemirror.getTableContext(c.state):{isInTable:false};s({isOpen:true,position:y,hasSelection:y.hasSelection,cursorInTable:S.isInTable,tableContext:S.isInTable?S:null});},[e,a]),b=Bl.useCallback(y=>{let c=e();if(!c||a.imagePos===null)return;let S=a.inlinePositionEmu?{initialPositionEmu:a.inlinePositionEmu}:void 0;commands.setImageWrapType(a.imagePos,y,S)(c.state,c.dispatch);},[e,a.imagePos,a.inlinePositionEmu]),i=Bl.useMemo(()=>[{action:"cut",label:l("contextMenu.cut"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.cutShortcut"))},{action:"copy",label:l("contextMenu.copy"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.copyShortcut"))},{action:"paste",label:l("contextMenu.paste"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.pasteShortcut")),dividerAfter:true},{action:"delete",label:l("contextMenu.delete"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.deleteShortcut"))}],[l]),p=Bl.useCallback(()=>{s({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false,tableContext:null});},[]),g=Bl.useMemo(()=>{let y=[{action:"cut",label:l("contextMenu.cut"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.cutShortcut"))},{action:"copy",label:l("contextMenu.copy"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.copyShortcut"))},{action:"paste",label:l("contextMenu.paste"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.pasteShortcut"))},{action:"pasteAsPlainText",label:l("contextMenu.pastePlainText"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.pastePlainTextShortcut")),dividerAfter:true},{action:"delete",label:l("contextMenu.delete"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.deleteShortcut")),dividerAfter:!m.hasSelection&&!m.cursorInTable}];return m.hasSelection&&y.push({action:"addComment",label:"Comment",dividerAfter:!m.cursorInTable}),m.cursorInTable&&y.push({action:"addRowAbove",label:"Insert row above"},{action:"addRowBelow",label:"Insert row below"},{action:"deleteRow",label:"Delete row",dividerAfter:true},{action:"addColumnLeft",label:"Insert column left"},{action:"addColumnRight",label:"Insert column right"},{action:"deleteColumn",label:"Delete column"},{action:"mergeCells",label:u?.table?.mergeCells??docxEditorI18n.en.table.mergeCells,disabled:!m.tableContext?.hasMultiCellSelection},{action:"splitCell",label:u?.table?.splitCell??docxEditorI18n.en.table.splitCell,disabled:!m.tableContext?.canSplitCell,dividerAfter:true}),y.push({action:"selectAll",label:l("contextMenu.selectAll"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.selectAllShortcut"))}),y},[m.hasSelection,m.cursorInTable,m.tableContext,u,l]),x=Bl.useCallback(async y=>{let c=e();if(c)switch(t(),y){case "cut":document.execCommand("cut");break;case "copy":document.execCommand("copy");break;case "paste":{try{let S=await navigator.clipboard.read(),v="",C="";for(let k of S)k.types.includes("text/html")&&(v=await(await k.getType("text/html")).text()),k.types.includes("text/plain")&&(C=await(await k.getType("text/plain")).text());let R=new DataTransfer;v&&R.items.add(v,"text/html"),C&&R.items.add(C,"text/plain");let P=new ClipboardEvent("paste",{clipboardData:R,bubbles:!0,cancelable:!0});c.dom.dispatchEvent(P);}catch{try{let S=await navigator.clipboard.readText();S&&c.dispatch(c.state.tr.insertText(S));}catch{}}break}case "pasteAsPlainText":try{let S=await navigator.clipboard.readText();S&&c.dispatch(c.state.tr.insertText(S));}catch{}break;case "delete":{let{from:S,to:v}=c.state.selection;S!==v&&c.dispatch(c.state.tr.deleteRange(S,v));break}case "selectAll":c.dispatch(c.state.tr.setSelection(prosemirrorState.TextSelection.create(c.state.doc,0,c.state.doc.content.size)));break;case "addRowAbove":prosemirror.addRowAbove(c.state,c.dispatch);break;case "addRowBelow":prosemirror.addRowBelow(c.state,c.dispatch);break;case "deleteRow":prosemirror.deleteRow(c.state,c.dispatch);break;case "addColumnLeft":prosemirror.addColumnLeft(c.state,c.dispatch);break;case "addColumnRight":prosemirror.addColumnRight(c.state,c.dispatch);break;case "deleteColumn":prosemirror.deleteColumn(c.state,c.dispatch);break;case "mergeCells":prosemirror.mergeCells(c.state,c.dispatch);break;case "splitCell":o();break;case "addComment":{let{from:S,to:v}=c.state.selection;if(S===v)break;let C=Zo(r.current,n.current,S),R=c.state.schema.marks.comment.create({commentId:commentIdAllocator.PENDING_COMMENT_ID}),P=c.state.tr.addMark(S,v,R);P.setSelection(prosemirrorState.TextSelection.create(P.doc,v)),c.dispatch(P),d({from:S,to:v,yPos:C});break}}},[e,t,o,r,n,d]);return {contextMenu:m,imageContextMenu:a,handleEditorContextMenu:h,handleContextMenu:f,handleContextMenuClose:p,handleImageWrapApply:b,imageContextMenuTextActions:i,contextMenuItems:g,handleContextMenuAction:x}}function Zi({commentsProp:e,onCommentDelete:t,onCommentsChange:o,pagedEditorRef:r}){let[n,u]=Bl.useState([]),d=e!==void 0,l=d?e:n,[m,s]=Bl.useState(false),[a,h]=Bl.useState(null),[f,b]=Bl.useState(null),[i,p]=Bl.useState(null),g=Bl.useRef(null),x=Bl.useRef(l);x.current=l;let y=Bl.useRef(m);y.current=m;let c=Bl.useRef(t);c.current=t;let S=Bl.useRef(o);S.current=o;let v=Bl.useCallback(R=>{let P=typeof R=="function"?R(x.current):R;P!==x.current&&(d||(x.current=P,u(P)),S.current?.(P));},[d]),C=Bl.useCallback(()=>{if(y.current)return;let R=r.current?.getView();if(!R)return;let{doc:P,schema:k}=R.state,E=k.marks.comment;if(!E)return;let I=new Set;P.descendants(H=>{for(let O of H.marks)if(O.type===E){let B=O.attrs.commentId;B!==commentIdAllocator.PENDING_COMMENT_ID&&I.add(B);}});let w=x.current,D=new Set;for(let H of w)H.parentId==null&&!I.has(H.id)&&D.add(H.id);if(D.size!==0){for(let H of w)D.has(H.id)&&c.current?.(H);v(H=>H.filter(O=>!D.has(O.id)&&!D.has(O.parentId)));}},[r,v]);return Bl.useEffect(()=>()=>{g.current&&clearTimeout(g.current);},[]),{comments:l,setComments:v,isAddingComment:m,setIsAddingComment:s,isAddingCommentRef:y,commentSelectionRange:a,setCommentSelectionRange:h,addCommentYPosition:f,setAddCommentYPosition:b,floatingCommentBtn:i,setFloatingCommentBtn:p,cleanOrphanedCommentsTimerRef:g,cleanOrphanedComments:C}}function Ji({commentToRevision:e,setComments:t,pmState:o,isLoading:r,trackedChangesCount:n,setShowCommentsSidebar:u,trackedChangesLoadedRef:d}){Bl.useEffect(()=>{e.size!==0&&t(l=>{let m=false,s=l.map(a=>{if(a.parentId!=null)return a;let h=e.get(a.id);return h!=null?(m=true,{...a,parentId:h}):a});return m?s:l});},[e,t]),Bl.useEffect(()=>{d.current||r||!o||(d.current=true,n>0&&u(true));},[o,r,n,u,d]);}function ta({getActiveEditorView:e,lastSelectionRef:t,borderSpecRef:o,theme:r,historyStateRef:n,getCachedStyleResolver:u,setFloatingCommentBtn:d,applySelectionDelta:l,recomputeFloatingCommentBtn:m,onSelectionChange:s,selectionChangeSubscribersRef:a}){return {handleSelectionChange:Bl.useCallback(f=>{let b=e();if(b){let{from:k,to:E}=b.state.selection;t.current={from:k,to:E};}let i=null;if(b&&(i=prosemirror.getTableContext(b.state),i.isInTable||(i=null)),i?.cellBorderColor){let k=utils.resolveColorToHex(i.cellBorderColor,r??void 0);k&&(o.current={...o.current,color:{rgb:k}});}let p=null;if(b){let k=b.state.selection,E=k.node;E?.type.name==="image"&&(p={pos:k.from,wrapType:E.attrs.wrapType??"inline",displayMode:E.attrs.displayMode??"inline",cssFloat:E.attrs.cssFloat??null,transform:E.attrs.transform??null,alt:E.attrs.alt??null,borderWidth:E.attrs.borderWidth??null,borderColor:E.attrs.borderColor??null,borderStyle:E.attrs.borderStyle??null,width:E.attrs.width??null,height:E.attrs.height??null});}if(!f){d(null),l({selectionFormatting:{},pmTableContext:i,pmImageContext:p});return}let{textFormatting:g,paragraphFormatting:x}=f,y=g.fontFamily?.ascii||g.fontFamily?.hAnsi,c=g.fontSize;if(!y||!c){let k=n.current,E=f.styleId;if(k?.package.styles&&E){let w=u(k.package.styles).resolveParagraphStyle(E);!y&&w.runFormatting?.fontFamily&&(y=w.runFormatting.fontFamily.ascii||w.runFormatting.fontFamily.hAnsi),!c&&w.runFormatting?.fontSize&&(c=w.runFormatting.fontSize);}}let S=utils.resolveColorToHex(g.color,r??void 0),v=S?`#${S}`:void 0,C=x.numPr,R=C?{type:C.numId===1?"bullet":"numbered",level:C.ilvl??0,isInList:true,numId:C.numId}:void 0,P={bold:g.bold,italic:g.italic,underline:!!g.underline,strike:g.strike,superscript:g.vertAlign==="superscript",subscript:g.vertAlign==="subscript",fontFamily:y,fontSize:c,color:v,highlight:g.highlight,alignment:x.alignment,lineSpacing:x.lineSpacing,listState:R,styleId:f.styleId??void 0,indentLeft:x.indentLeft,bidi:!!x.bidi};l({selectionFormatting:P,paragraphIndentLeft:x.indentLeft??0,paragraphIndentRight:x.indentRight??0,paragraphFirstLineIndent:x.indentFirstLine??0,paragraphHangingIndent:x.hangingIndent??false,paragraphTabs:x.tabs??null,pmTableContext:i,pmImageContext:p}),m(),s?.(f);for(let k of a.current)try{k(f);}catch(E){console.error("selectionChange subscriber threw:",E);}},[e,t,o,r,n,u,d,l,m,s,a])}}function na({pagedEditorRef:e,scrollContainerRef:t,editorContentRef:o,isAddingCommentRef:r,setFloatingCommentBtn:n,readOnly:u,isLoading:d,zoom:l}){let m=Bl.useRef(false);m.current=u;let s=Bl.useCallback(()=>{let a=e.current?.getView();if(!a)return;if(r.current||m.current){n(null);return}let{from:h,to:f}=a.state.selection;if(h===f){n(null);return}let b=t.current,i=o.current;if(!b||!i)return;let p=Zo(b,i,h);if(p==null)return;let x=b.querySelector(".paged-editor__pages")?.querySelector(".layout-page"),y=x?x.getBoundingClientRect().right-i.getBoundingClientRect().left:i.getBoundingClientRect().width/2+408;n({top:p,left:y});},[e,t,o,r,n]);return Bl.useEffect(()=>{let a=t.current;if(!a)return;let h=new ResizeObserver(()=>s());h.observe(a);let f=()=>s();return window.addEventListener("resize",f),()=>{h.disconnect(),window.removeEventListener("resize",f);}},[d,s,t]),Bl.useEffect(()=>{s();},[l,s]),{recomputeFloatingCommentBtn:s}}function ra({hfEditPosition:e,hfEditorRef:t,pagedEditorRef:o}){let r=Bl.useCallback(()=>e&&t.current?t.current.getView():o.current?.getView(),[e,t,o]),n=Bl.useCallback(()=>{e&&t.current?t.current.focus():o.current?.focus();},[e,t,o]),u=Bl.useCallback(()=>{e&&t.current?t.current.undo():o.current?.undo();},[e,t,o]),d=Bl.useCallback(()=>{e&&t.current?t.current.redo():o.current?.redo();},[e,t,o]);return {getActiveEditorView:r,focusActiveEditor:n,undoActiveEditor:u,redoActiveEditor:d}}function ia({scrollContainerRef:e,pagedEditorRef:t}){let[o,r]=Bl.useState({currentPage:1,totalPages:1,visible:false}),n=Bl.useRef(null),u=e.current;return Bl.useEffect(()=>{if(!u)return;let d=()=>{let l=t.current?.getLayout();if(!l||l.pages.length===0)return;let m=u.scrollTop,s=l.pages.length,a=24,h=24,f=m+u.clientHeight/2,b=h,i=1;for(let p=0;p<l.pages.length;p++){let g=l.pages[p].size.h,x=b+g;if(f<x){i=p+1;break}b=x+a,i=p+2;}i=Math.min(i,s),r({currentPage:i,totalPages:s,visible:true}),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{r(p=>({...p,visible:false}));},600);};return u.addEventListener("scroll",d,{passive:true}),()=>{u.removeEventListener("scroll",d),n.current&&clearTimeout(n.current);}},[u,t]),{scrollPageInfo:o,setScrollPageInfo:r}}function aa({contextMenu:e,contextMenuItems:t,onContextMenuAction:o,onContextMenuClose:r,imageContextMenu:n,onImageWrapApply:u,imageContextMenuTextActions:d,onOpenImageProperties:l,readOnly:m}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(chunkGDJM7SOG_js.i,{isOpen:e.isOpen,position:e.position,hasSelection:e.hasSelection,isEditable:!m,items:t,onAction:o,onClose:r}),jsxRuntime.jsx(Vi,{isOpen:n.isOpen,position:n.position,currentWrapType:n.currentWrapType,currentCssFloat:n.currentCssFloat,onApplyLayout:u,textActions:d,onTextAction:o,onOpenProperties:l,onClose:n.closeMenu}),jsxRuntime.jsx(sonner.Toaster,{position:"bottom-right"})]})}var mm=Bl.lazy(()=>import('./FindReplaceDialog-HM63BMXE.js')),fm=Bl.lazy(()=>import('./HyperlinkDialog-7MEQJIYP.js')),gm=Bl.lazy(()=>import('./TablePropertiesDialog-VCDCPM3R.js').then(e=>({default:e.TablePropertiesDialog}))),bm=Bl.lazy(()=>import('./SplitCellDialog-45W7SDPY.js')),hm=Bl.lazy(()=>import('./ImagePositionDialog-LSCCQORZ.js').then(e=>({default:e.ImagePositionDialog}))),ym=Bl.lazy(()=>import('./ImagePropertiesDialog-Z4M6XKFG.js').then(e=>({default:e.ImagePropertiesDialog}))),vm=Bl.lazy(()=>import('./FootnotePropertiesDialog-TV2BGQDC.js').then(e=>({default:e.FootnotePropertiesDialog}))),Cm=Bl.lazy(()=>import('./PageSetupDialog-LWYOYKEU.js').then(e=>({default:e.PageSetupDialog}))),Sm=Bl.lazy(()=>import('./WatermarkDialog-XGLAH3TK.js').then(e=>({default:e.WatermarkDialog})));function sa({findReplace:e,findResultRef:t,onFind:o,onFindNext:r,onFindPrevious:n,onReplace:u,onReplaceAll:d,hyperlinkDialog:l,onHyperlinkSubmit:m,onHyperlinkRemove:s,tablePropsOpen:a,onTablePropsClose:h,pmTableContext:f,getActiveEditorView:b,splitCellDialogState:i,onSplitCellDialogClose:p,onSplitCellDialogApply:g,imagePositionOpen:x,onImagePositionClose:y,onApplyImagePosition:c,imagePropsOpen:S,onImagePropsClose:v,onApplyImageProperties:C,pmImageContext:R,showPageSetup:P,onPageSetupClose:k,onPageSetupApply:E,showWatermark:I,onWatermarkClose:w,onWatermarkApply:D,currentWatermark:H,watermarkPresets:O,document:B,footnotePropsOpen:_,onFootnotePropsClose:W,onApplyFootnoteProperties:Z}){return jsxRuntime.jsxs(Bl.Suspense,{fallback:null,children:[e.state.isOpen&&jsxRuntime.jsx(mm,{isOpen:e.state.isOpen,onClose:e.close,onFind:o,onFindNext:r,onFindPrevious:n,onReplace:u,onReplaceAll:d,initialSearchText:e.state.searchText,replaceMode:e.state.replaceMode,currentResult:t.current}),l.state.isOpen&&jsxRuntime.jsx(fm,{isOpen:l.state.isOpen,onClose:l.close,onSubmit:m,onRemove:l.state.isEditing?s:void 0,initialData:l.state.initialData,selectedText:l.state.selectedText,isEditing:l.state.isEditing}),a&&jsxRuntime.jsx(gm,{isOpen:a,onClose:h,onApply:Y=>{let J=b();J&&commands.setTableProperties(Y)(J.state,J.dispatch);},currentProps:f?.table?.attrs}),i.isOpen&&jsxRuntime.jsx(bm,{isOpen:i.isOpen,onClose:p,onApply:g,initialRows:i.initialRows,initialCols:i.initialCols,minRows:i.minRows,minCols:i.minCols}),x&&jsxRuntime.jsx(hm,{isOpen:x,onClose:y,onApply:c}),S&&jsxRuntime.jsx(ym,{isOpen:S,onClose:v,onApply:C,currentData:R?{alt:R.alt??void 0,borderWidth:R.borderWidth??void 0,borderColor:R.borderColor??void 0,borderStyle:R.borderStyle??void 0,width:R.width??void 0,height:R.height??void 0}:void 0}),P&&jsxRuntime.jsx(Cm,{isOpen:P,onClose:k,onApply:E,currentProps:B?.package.document?.finalSectionProperties}),I&&jsxRuntime.jsx(Sm,{isOpen:I,onClose:w,onApply:D,current:H,presets:O}),_&&jsxRuntime.jsx(vm,{isOpen:_,onClose:W,onApply:Z,footnotePr:B?.package.document?.finalSectionProperties?.footnotePr,endnotePr:B?.package.document?.finalSectionProperties?.endnotePr})]})}function ca({active:e,onClick:t}){let{t:o}=chunkGNIO6SOS_js.b(),r=o("editor.toggleCommentsSidebar");return jsxRuntime.jsx(chunkGDJM7SOG_js.A,{onClick:t,active:e,title:r,ariaLabel:r,children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"comment",size:20})})}var nr=[{value:"editing",labelKey:"editor.editing",icon:"edit_note",descKey:"editor.editingDescription"},{value:"suggesting",labelKey:"editor.suggesting",icon:"rate_review",descKey:"editor.suggestingDescription"},{value:"viewing",labelKey:"editor.viewing",icon:"visibility",descKey:"editor.viewingDescription"}];function ua({mode:e,onModeChange:t}){let{t:o}=chunkGNIO6SOS_js.b(),[r,n]=Bl.useState(false),[u,d]=Bl.useState(false),l=Bl.useRef(null),m=Bl.useRef(null),[s,a]=Bl.useState({top:0,left:0}),h=nr.find(f=>f.value===e);return Bl.useEffect(()=>{let f=window.matchMedia("(max-width: 1400px)");d(f.matches);let b=i=>d(i.matches);return f.addEventListener("change",b),()=>f.removeEventListener("change",b)},[]),Bl.useEffect(()=>{if(!r||!l.current)return;let f=l.current.getBoundingClientRect();a({top:f.bottom+2,left:f.right-220});},[r]),Bl.useEffect(()=>{if(!r)return;let f=i=>{!l.current?.contains(i.target)&&!m.current?.contains(i.target)&&n(false);},b=i=>{i.key==="Escape"&&n(false);};return document.addEventListener("mousedown",f),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",b);}},[r]),jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{ref:l,type:"button",onMouseDown:f=>f.preventDefault(),onClick:()=>n(!r),title:`${o(h.labelKey)} (Ctrl+Shift+E)`,style:{display:"flex",alignItems:"center",gap:u?0:4,padding:u?"2px 4px":"2px 6px 2px 4px",border:"none",background:r?"var(--doc-bg-hover)":"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text)",whiteSpace:"nowrap",height:28},children:[jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:h.icon,size:18}),!u&&jsxRuntime.jsx("span",{children:o(h.labelKey)}),jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"arrow_drop_down",size:16})]}),r&&jsxRuntime.jsx("div",{ref:m,onMouseDown:f=>f.preventDefault(),style:{position:"fixed",top:s.top,left:s.left,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 12px var(--doc-shadow)",padding:"4px 0",zIndex:1e4,minWidth:220},children:nr.map(f=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:b=>b.preventDefault(),onClick:()=>{t(f.value),n(false);},onMouseOver:b=>{b.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:b=>{b.currentTarget.style.backgroundColor="transparent";},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left"},children:[jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:f.icon,size:20}),jsxRuntime.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[jsxRuntime.jsx("span",{style:{fontWeight:500},children:o(f.labelKey)}),jsxRuntime.jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted)"},children:o(f.descKey)})]}),f.value===e&&jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"check",size:18,style:{marginLeft:"auto",color:"var(--doc-primary)"}})]},f.value))})]})}function pa({active:e,onClick:t,badge:o}){let{t:r}=chunkGNIO6SOS_js.b(),n=r("agentPanel.toggle");return jsxRuntime.jsx(chunkGDJM7SOG_js.A,{onClick:t,active:e,title:n,ariaLabel:n,children:jsxRuntime.jsxs("span",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"agent-sparkle",size:20}),o!=null&&jsxRuntime.jsx("span",{"data-testid":"agent-panel-toggle-badge",style:{position:"absolute",top:-4,right:-6,display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:14,height:14,padding:"0 3px",borderRadius:7,fontSize:10,fontWeight:600,background:"var(--doc-error)",color:"var(--doc-on-primary)",lineHeight:1},children:o})]})})}function ma({toolbarRefCallback:e,agentPanelOpen:t,setAgentPanelOpen:o,document:r,theme:n,pmState:u,selectionFormatting:d,tableContext:l,imageContext:m,readOnly:s,editingMode:a,setEditingMode:h,setShowCommentsSidebar:f,setExpandedSidebarItem:b,showCommentsSidebar:i,agentPanel:p,renderLogo:g,documentName:x,onDocumentNameChange:y,documentNameEditable:c,renderTitleBarRight:S,toolbarExtra:v,fontFamilies:C,zoom:R,showZoomControl:P,onFormat:k,onUndo:E,onRedo:I,onPrint:w,onOpen:D,onSave:H,onZoomChange:O,onRefocusEditor:B,onInsertTable:_,onInsertImage:W,onInsertPageBreak:Z,onInsertSectionBreakNextPage:Y,onInsertSectionBreakContinuous:J,onInsertTOC:te,onImageWrapType:ne,onImageTransform:me,onOpenImageProperties:ke,onPageSetup:Ce,onWatermark:M,onTableAction:F}){return jsxRuntime.jsx("div",{ref:e,className:"z-50 flex flex-col gap-0 flex-shrink-0",children:jsxRuntime.jsxs(chunkGDJM7SOG_js.E,{className:t?"rounded-br-2xl":void 0,style:{transition:"border-radius 220ms cubic-bezier(0.4, 0, 0.2, 1)"},currentFormatting:d,onFormat:k,onUndo:E,onRedo:I,canUndo:u?prosemirrorHistory.undoDepth(u)>0:false,canRedo:u?prosemirrorHistory.redoDepth(u)>0:false,disabled:s,documentStyles:r?.package.styles?.styles,theme:r?.package.theme||n,fontFamilies:C,onPrint:w,onOpen:D,onSave:H,showZoomControl:P,zoom:R,onZoomChange:O,onRefocusEditor:B,onInsertTable:_,showTableInsert:true,onInsertImage:W,onInsertPageBreak:Z,onInsertSectionBreakNextPage:Y,onInsertSectionBreakContinuous:J,onInsertTOC:te,imageContext:m,onImageWrapType:ne,onImageTransform:me,onOpenImageProperties:ke,onPageSetup:Ce,onWatermark:M,tableContext:l,onTableAction:F,children:[jsxRuntime.jsxs(chunkGDJM7SOG_js.E.TitleBar,{children:[g&&jsxRuntime.jsx(chunkGDJM7SOG_js.E.Logo,{children:g()}),x!==void 0&&jsxRuntime.jsx(chunkGDJM7SOG_js.E.DocumentName,{value:x,onChange:y,editable:c}),S&&jsxRuntime.jsx(chunkGDJM7SOG_js.E.TitleBarRight,{children:S()}),jsxRuntime.jsx(chunkGDJM7SOG_js.E.MenuBar,{})]}),jsxRuntime.jsxs(chunkGDJM7SOG_js.E.Toolbar,{children:[jsxRuntime.jsx(chunkGDJM7SOG_js.C,{}),jsxRuntime.jsx(ca,{active:i,onClick:()=>{f(A=>!A),b(null);}}),jsxRuntime.jsx(chunkGDJM7SOG_js.C,{}),jsxRuntime.jsx(ua,{mode:a,onModeChange:A=>{h(A),A==="suggesting"&&f(true);}}),p&&p.showToolbarButton!==false&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(chunkGDJM7SOG_js.C,{}),jsxRuntime.jsx(pa,{active:t,badge:p.toolbarBadge,onClick:()=>o(!t)})]}),v]})]})})}function fa(e,t,o){let r=e.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!r)return null;let n=r.getBoundingClientRect(),u=layoutBridge.getCaretPositionFromDom(e,t,n);return u?{x:u.x/o,y:u.y/o,height:u.height,pageIndex:u.pageIndex}:null}function ga(e,t,o,r,n){return layoutBridge.getSelectionRectsFromDom(e,o,r,t).map(d=>({x:d.x/n,y:d.y/n,width:d.width/n,height:d.height/n,pageIndex:d.pageIndex}))}var Gm={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function va(e,t,o,r=[]){let n=o?.getSchema()??prosemirror.schema,u=t??e?.package?.styles,d=e?conversion.toProseDoc(e,{styles:u}):conversion.createEmptyDoc(),l=prosemirror.createDocumentStylesPlugin(u),m=[...r,...o?.getPlugins()??[],l];return prosemirror.ensureParaIdsInState(prosemirrorState.EditorState.create({doc:d,schema:n,plugins:m}))}function Km(e,t){return t?conversion.fromProseDoc(e.doc,t):null}var jm=Bl.forwardRef(function(t,o){let{document:r,styles:n,theme:u,widthPx:d=612,readOnly:l=false,onTransaction:m,onSelectionChange:s,externalPlugins:a=[],extensionManager:h,onEditorViewReady:f,onEditorViewDestroy:b,onKeyDown:i}=t,p=Bl.useRef(null),g=Bl.useRef(null),x=Bl.useRef(r),y=Bl.useRef(false),c=Bl.useRef(null),S=Bl.useRef(false),v=Bl.useRef(m),C=Bl.useRef(s),R=Bl.useRef(f),P=Bl.useRef(b),k=Bl.useRef(i),E=Bl.useRef(l);v.current=m,C.current=s,R.current=f,P.current=b,k.current=i,E.current=l,x.current=r;let I=_=>{if(!_)return "empty";let W=_.package?.properties;return `${W?.created||""}-${W?.modified||""}-${W?.title||""}`},w=Bl.useCallback(()=>{if(!p.current||y.current)return;let W={state:va(r,n,h,a),editable:()=>!E.current,attributes:{style:"overflow-anchor: none"},dispatchTransaction(Y){if(y.current)return;g.current||(g.current=this),editor.stripScrollFlag(Y,this.state.tr);let J=this.state.apply(Y);this.updateState(J),v.current?.(Y,J),(Y.selectionSet||Y.docChanged)&&C.current?.(J);},handleKeyDown:(Y,J)=>k.current?.(Y,J)??false,handleScrollToSelection:()=>true,handleDOMEvents:{focus:()=>false,blur:()=>false}};g.current=new prosemirrorView.EditorView(p.current,W);let Z=g.current.dom;Z.style.overflowAnchor="none",S.current=true,c.current=I(r),R.current?.(g.current);},[r,n,a,h,l]),D=Bl.useCallback(()=>{g.current&&!y.current&&(y.current=true,P.current?.(),g.current.destroy(),g.current=null,y.current=false);},[]);Bl.useEffect(()=>(w(),()=>D()),[]),Bl.useEffect(()=>{if(!g.current||y.current)return;let _=I(r);if(S.current&&_===c.current)return;S.current=true,c.current=_;let W=va(r,n,h,a);g.current.updateState(W),C.current?.(W);},[r,n,h,a]),Bl.useEffect(()=>{g.current;},[l]),Bl.useImperativeHandle(o,()=>({getState(){return g.current?.state??null},getView(){return g.current??null},getDocument(){return g.current?Km(g.current.state,x.current):null},focus(){g.current?.focus();},blur(){g.current?.hasFocus()&&g.current.dom.blur();},isFocused(){return g.current?.hasFocus()??false},dispatch(_){g.current&&!y.current&&g.current.dispatch(_);},executeCommand(_){return g.current?_(g.current.state,g.current.dispatch,g.current):false},undo(){return g.current?prosemirrorHistory.undo(g.current.state,g.current.dispatch):false},redo(){return g.current?prosemirrorHistory.redo(g.current.state,g.current.dispatch):false},canUndo(){return g.current?prosemirrorHistory.undo(g.current.state):false},canRedo(){return g.current?prosemirrorHistory.redo(g.current.state):false},setSelection(_,W){if(!g.current)return;let{state:Z,dispatch:Y}=g.current,J=Z.doc.resolve(_),te=W!==void 0?Z.doc.resolve(W):J,ne=prosemirrorState.TextSelection.between(J,te);Y(Z.tr.setSelection(ne));},setNodeSelection(_){if(!g.current)return;let{state:W,dispatch:Z}=g.current;try{let Y=prosemirrorState.NodeSelection.create(W.doc,_);Z(W.tr.setSelection(Y));}catch{this.setSelection(_);}},setCellSelection(_,W){if(!g.current)return;let{state:Z,dispatch:Y}=g.current;try{let J=prosemirrorTables.CellSelection.create(Z.doc,_,W);Y(Z.tr.setSelection(J));}catch{this.setSelection(_,W);}},scrollToSelection(){}}),[]);let H=jsxRuntime.jsx("div",{ref:p,className:"paged-editor__hidden-pm",style:{...Gm,width:d>0?`${d}px`:void 0}}),O=globalThis.document,B=O&&"body"in O&&O.body!=null?O.body:null;return B?reactDom.createPortal(H,B):H}),Ca=Bl.memo(jm);function cf(e,t,o,r,n){let u=conversion.headerFooterToProseDoc(e.content,{styles:t??void 0,theme:o??null,defaultTabStopTwips:r??null}),d=prosemirror.createDocumentStylesPlugin(t);return prosemirrorState.EditorState.create({doc:u,schema:prosemirror.schema,plugins:[...n.getPlugins(),d]})}function df(e){if(!e?.package)return [];let t=[],o=e.package.headers;if(o)for(let n of o.keys())t.push({rId:n,kind:"header"});let r=e.package.footers;if(r)for(let n of r.keys())(!o||!o.has(n))&&t.push({rId:n,kind:"footer"});return t}var lr=Bl.memo(Bl.forwardRef(function({document:t,styles:o,theme:r,defaultTabStopTwips:n,onTransaction:u},d){let l=Bl.useRef(u);l.current=u;let m=Bl.useRef(t);m.current=t;let s=Bl.useRef(null),a=Bl.useRef(null),h=Bl.useRef(new Map),f=Bl.useRef(new Map);s.current=(p,g,x)=>{let c=m.current?.package;if(!c)return;let v=(g==="header"?c.headers:c.footers)?.get(p);v&&(v.content=conversion.proseDocToBlocks(x.doc));};let b=Bl.useCallback((p,g)=>{let x=t?.package;return x?(g==="header"?x.headers:x.footers)?.get(p)??null:null},[t]),i=Bl.useMemo(()=>df(t),[t?.package?.headers,t?.package?.footers]);return Bl.useEffect(()=>{if(!a.current)return;let p=a.current,g=new Map(i.map(y=>[y.rId,y])),x=h.current;for(let[y,c]of x)g.has(y)||(c.view.destroy(),c.mountNode.remove(),f.current.get(y)?.destroy(),f.current.delete(y),x.delete(y));for(let y of i){if(x.has(y.rId))continue;let c=b(y.rId,y.kind);if(!c)continue;let S=new extensions.ExtensionManager(extensions.createStarterKit());S.buildSchema(),S.initializeRuntime(),f.current.set(y.rId,S);let v=p.ownerDocument.createElement("div");v.dataset.hfRId=y.rId,v.dataset.hfKind=y.kind,p.appendChild(v);let C=cf(c,o,r,n,S),R=y.rId,P=y.kind,k=new prosemirrorView.EditorView(v,{state:C,dispatchTransaction(E){let I=k.state.apply(E);k.updateState(I),E.docChanged&&s.current?.(R,P,I),l.current?.(R,k,E.docChanged);}});x.set(y.rId,{rId:y.rId,kind:y.kind,view:k,mountNode:v});}},[i,b,o,r,n]),Bl.useEffect(()=>{let p=h.current,g=f.current;return ()=>{for(let{view:x,mountNode:y}of p.values())x.destroy(),y.remove();p.clear();for(let x of g.values())x.destroy();g.clear();}},[]),Bl.useImperativeHandle(d,()=>({getView(p){return h.current.get(p)?.view??null}}),[]),jsxRuntime.jsx("div",{ref:a,style:{position:"fixed",left:-9999,top:0,opacity:0,zIndex:-1,pointerEvents:"none"}})}));lr.displayName="HiddenHeaderFooterPMs";var ff="var(--doc-caret, #000)",gf="rgba(66, 133, 244, 0.3)",bf=2,hf=530,yf={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},vf=(e,t,o,r)=>({position:"absolute",left:e.x,top:e.y,width:o,height:e.height,backgroundColor:t,opacity:r?1:0,transition:"opacity 0.05s ease-out",pointerEvents:"none"}),Cf=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),Sf=({position:e,color:t,width:o,blinkInterval:r,isFocused:n})=>{let[u,d]=Bl.useState(n),l=Bl.useRef(null);return Bl.useEffect(()=>(l.current&&(window.clearInterval(l.current),l.current=null),n&&r>0?(d(true),l.current=window.setInterval(()=>{d(m=>!m);},r)):d(false),()=>{l.current&&window.clearInterval(l.current);}),[n,r]),Bl.useEffect(()=>{if(n)return d(true),l.current&&window.clearInterval(l.current),r>0&&(l.current=window.setInterval(()=>{d(m=>!m);},r)),()=>{l.current&&window.clearInterval(l.current);}},[e.x,e.y,n,r]),jsxRuntime.jsx("div",{style:vf(e,t,o,u),"data-testid":"caret"})},xf=({rect:e,color:t,index:o})=>jsxRuntime.jsx("div",{style:Cf(e,t),"data-testid":`selection-rect-${o}`,"data-page-index":e.pageIndex}),Ra=({selectionRects:e,caretPosition:t,isFocused:o,readOnly:r=false,caretColor:n=ff,selectionColor:u=gf,caretWidth:d=bf,blinkInterval:l=hf})=>{if(r)return null;let m=e.length>0,s=t!==null&&!m;return jsxRuntime.jsxs("div",{style:yf,"data-testid":"selection-overlay",children:[m&&e.map((a,h)=>jsxRuntime.jsx(xf,{rect:a,color:u,index:h},`sel-${a.pageIndex}-${a.x}-${a.y}-${h}`)),s&&t&&jsxRuntime.jsx(Sf,{position:t,color:n,width:d,blinkInterval:l,isFocused:o})]})};var dr=10,Ta=dr/2,Co=2,Ia="#2563eb",wa={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},Tf={position:"absolute",border:`${Co}px solid ${Ia}`,pointerEvents:"none",boxSizing:"border-box"},wf={position:"absolute",width:`${dr}px`,height:`${dr}px`,backgroundColor:"#ffffff",border:`1.5px solid ${Ia}`,borderRadius:"50%",boxShadow:"0 1px 2.5px rgba(0, 0, 0, 0.35)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},Ef={position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.75)",color:"var(--doc-on-primary)",fontSize:"11px",fontFamily:"system-ui, sans-serif",padding:"2px 8px",borderRadius:"3px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:20,transform:"translateX(-50%)"},If={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize",n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize"},kf=[{pos:"nw",x:0,y:0},{pos:"ne",x:1,y:0},{pos:"se",x:1,y:1},{pos:"sw",x:0,y:1},{pos:"n",x:.5,y:0},{pos:"s",x:.5,y:1},{pos:"e",x:1,y:.5},{pos:"w",x:0,y:.5}];function ka({imageInfo:e,zoom:t,isFocused:o,onResize:r,onResizeStart:n,onResizeEnd:u,onDragMove:d,onDragStart:l,onDragEnd:m,onContextMenu:s}){let[a,h]=Bl.useState(false),[f,b]=Bl.useState(false),[i,p]=Bl.useState(0),[g,x]=Bl.useState(0),[y,c]=Bl.useState(null),S=Bl.useRef(null),v=Bl.useRef(null),C=Bl.useRef(r),R=Bl.useRef(n),P=Bl.useRef(u),k=Bl.useRef(d),E=Bl.useRef(l),I=Bl.useRef(m);C.current=r,R.current=n,P.current=u,k.current=d,E.current=l,I.current=m;let w=Bl.useRef(e),D=Bl.useRef(t);w.current=e,D.current=t;let H=Bl.useCallback(()=>{if(!e||!v.current){c(null);return}let te=v.current.offsetParent;if(!te){c(null);return}let ne=te.getBoundingClientRect(),me=e.element.getBoundingClientRect();c({left:(me.left-ne.left)/t,top:(me.top-ne.top)/t,width:me.width/t,height:me.height/t});},[e,t]);Bl.useEffect(()=>{H();},[H]),Bl.useEffect(()=>{if(!e)return;let te=v.current?.closest('[style*="overflow"]')??v.current?.closest(".paged-editor__container");if(!te)return;let ne=()=>{S.current&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(H);};return te.addEventListener("scroll",ne,{passive:true}),window.addEventListener("resize",ne,{passive:true}),()=>{te.removeEventListener("scroll",ne),window.removeEventListener("resize",ne),S.current&&cancelAnimationFrame(S.current);}},[e,H]);let O=Bl.useCallback((te,ne)=>{if(!e||!y)return;ne.preventDefault(),ne.stopPropagation();let me=y.width,ke=y.height,Ce=ne.clientX,M=ne.clientY,F=Math.round(me),N=Math.round(ke);h(true),p(F),x(N),R.current?.();let A=V=>{let se=D.current,ee=(V.clientX-Ce)/se,$=(V.clientY-M)/se,de=!V.shiftKey,re=imageCommit.calculateResizedImageDimensions(te,ee,$,me,ke,de);F=Math.round(re.width),N=Math.round(re.height),p(F),x(N),c(X=>{if(!X)return X;let oe={...X};return te.includes("w")&&(oe.left=X.left+(X.width-re.width)),te.includes("n")&&(oe.top=X.top+(X.height-re.height)),oe.width=re.width,oe.height=re.height,oe});},z=()=>{window.removeEventListener("mousemove",A),window.removeEventListener("mouseup",z),h(false);let V=w.current;V&&C.current?.(V.pmPos,F,N),P.current?.();};window.addEventListener("mousemove",A),window.addEventListener("mouseup",z);},[e,y]),B=Bl.useCallback(te=>{if(!e||!y)return;te.preventDefault(),te.stopPropagation();let ne=4,me=te.clientX,ke=te.clientY,Ce=false,M=null,F=A=>{let z=A.clientX-me,V=A.clientY-ke;!Ce&&Math.sqrt(z*z+V*V)<ne||(Ce||(Ce=true,b(true),E.current?.(),M=document.createElement("div"),M.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);",M.style.width=`${y.width}px`,M.style.height=`${y.height}px`,document.body.appendChild(M)),M&&(M.style.left=`${A.clientX-y.width/2}px`,M.style.top=`${A.clientY-y.height/2}px`));},N=A=>{if(window.removeEventListener("mousemove",F),window.removeEventListener("mouseup",N),M&&(M.remove(),M=null),b(false),Ce){let z=w.current;z&&k.current?.(z.pmPos,A.clientX,A.clientY),I.current?.();}};window.addEventListener("mousemove",F),window.addEventListener("mouseup",N);},[e,y]);if(!!!(e&&y&&o))return jsxRuntime.jsx("div",{ref:v,style:{...wa,visibility:"hidden"},className:"image-selection-overlay"});let{left:W,top:Z,width:Y,height:J}=y;return jsxRuntime.jsxs("div",{ref:v,style:wa,className:"image-selection-overlay",children:[jsxRuntime.jsx("div",{style:{...Tf,left:W-Co,top:Z-Co,width:Y+Co*2,height:J+Co*2}}),jsxRuntime.jsx("div",{style:{position:"absolute",left:W,top:Z,width:Y,height:J,cursor:f?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:B,onContextMenu:s}),kf.map(({pos:te,x:ne,y:me})=>jsxRuntime.jsx(Mf,{handle:te,style:{left:W+Y*ne-Ta,top:Z+J*me-Ta},onMouseDown:O},te)),a&&jsxRuntime.jsxs("div",{style:{...Ef,left:W+Y/2,top:Z+J+12},children:[i," \xD7 ",g]})]})}function Mf({handle:e,style:t,onMouseDown:o}){return jsxRuntime.jsx("div",{style:{...wf,...t,cursor:If[e]},onMouseDown:r=>o(e,r),"data-handle":e})}var Hf={position:"absolute",inset:0,pointerEvents:"none",zIndex:11};function Ha({getView:e,getPagesContainer:t,zoom:o,decorationSyncToken:r,syncCoordinator:n}){let u=Bl.useRef(null),d=Bl.useRef(null),[l,m]=Bl.useState(0);return Bl.useEffect(()=>n.onRender(()=>m(s=>s+1)),[n]),Bl.useEffect(()=>(d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null;let s=e(),a=t(),h=u.current;!s||!a||!h||n.isSafeToRender()&&Ff(s,a,h,o);}),()=>{d.current!==null&&(cancelAnimationFrame(d.current),d.current=null);}),[o,r,l]),jsxRuntime.jsx("div",{ref:u,className:"paged-editor__decoration-overlay",style:Hf,"aria-hidden":"true"})}function Ff(e,t,o,r){let n=Lf(e.state);if(n.length===0){o.firstChild&&o.replaceChildren();return}let u=chunkBZO4G5M6_js.b(t,r),d=u.getContainerOffset(),l=document.createDocumentFragment();for(let{decoration:m,from:s,to:a}of n){if(s===a){let b=Af(m,e);if(!b)continue;let i=u.getCoordinatesForPosition(s);if(!i)continue;let p=document.createElement("div");p.style.cssText=`position:absolute;left:${i.x+d.x}px;top:${i.y+d.y}px;height:${i.height}px;`,p.appendChild(b),l.appendChild(p);continue}let h=Of(m);if(!h)continue;let f=u.getRectsForRange(s,a);for(let b of f){let i=document.createElement("div");for(let[g,x]of Object.entries(h))g!=="nodeName"&&i.setAttribute(g,x);let p=`position:absolute;left:${b.x+d.x}px;top:${b.y+d.y}px;width:${b.width}px;height:${b.height}px;`;i.style.cssText=p+(h.style??""),l.appendChild(i);}}o.replaceChildren(l);}function Lf(e){let t=[];for(let o of e.plugins){let r=o.props.decorations;if(!r)continue;let n=r.call(o,e);n&&n.forEachSet(u=>{u.find().forEach(d=>{d.spec?.noOverlay||t.push({decoration:d,from:d.from,to:d.to});});});}return t}function Af(e,t){let o=e.type;if(!o)return null;let r=o.toDOM;return typeof r=="function"?r(t,()=>e.from):r instanceof HTMLElement?r.cloneNode(true):null}function Of(e){return e.type?.attrs??null}var Oa=[];var Ba={position:"relative",width:"100%",minHeight:"100%",overflow:"visible",backgroundColor:"var(--doc-bg)"},Na={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:24,paddingBottom:24,overflowAnchor:"none"},za={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",overflowAnchor:"none"},_a={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function nn(e,t,o){let r=t.getBoundingClientRect(),n=e.getBoundingClientRect(),u=n.top+n.height/2,d=r.top+r.height/2,l=u-d,m=Math.max(0,t.scrollHeight-t.clientHeight),s=Math.max(0,Math.min(m,t.scrollTop+l));t.scrollTop=s;}function rn(e,t){if(t.aborted)return;let o=requestAnimationFrame(()=>{if(t.aborted)return;let r=requestAnimationFrame(()=>{if(t.aborted)return;let n=requestAnimationFrame(()=>{t.aborted||e();});t.addEventListener("abort",()=>cancelAnimationFrame(n),{once:true});});t.addEventListener("abort",()=>cancelAnimationFrame(r),{once:true});});t.addEventListener("abort",()=>cancelAnimationFrame(o),{once:true});}function Va(e,t){let o=null,r=layoutBridge.findBodyPmAnchors(e);for(let n=0;n<r.length;n++){let u=r[n].dataset.pmStart;if(u==null)continue;let d=Number(u);Number.isNaN(d)||d<=t&&(o===null||d>o)&&(o=d);}return o}function an(e,t){let o=e.pages.length;return e.pages.reduce((n,u)=>n+u.size.h,0)+Math.max(0,o-1)*t+24+24}function Ua(e,t,o,r,n){let u=new Map;if(!e?.state)return u;let{doc:d,schema:l}=e.state,m=l.marks.comment,s=l.marks.insertion,a=l.marks.deletion;if(!m&&!s&&!a)return u;let h=new Set,f=24+n,b=(i,p)=>{if(h.has(i))return;h.add(i);let g=layoutBridge.getCaretPosition(t,o,r,p);if(g){u.set(i,g.y+f);return}for(let x=0;x<t.pages.length;x++){let y=t.pages[x];for(let c of y.fragments){let S=c.pmStart??0,v=c.pmEnd??S;if(p<S||p>v)continue;let C=c.kind==="table"?Wf(o,r,c,p):0;u.set(i,c.y+C+layoutBridge.getPageTop(t,x)+f);return}}};return d.descendants((i,p)=>{let g=i.attrs;if(g){let x=[g.trIns,g.trDel,g.pPrIns,g.pPrDel];for(let v of x){let C=v?.revisionId;typeof C=="number"&&b(`revision-${C}`,p);}let c=g.cellMarker?.info?.revisionId;typeof c=="number"&&b(`revision-${c}`,p);let S=[g.pPrChange,g.trPrChange,g.tcPrChange,g.tblPrChange];for(let v of S)if(Array.isArray(v))for(let C of v){let R=C?.info?.id;typeof R=="number"&&b(`revision-${R}`,p);}}if(i.isInline)for(let x of i.marks){let y=null;m&&x.type===m?y=`comment-${x.attrs.commentId}`:(s&&x.type===s||a&&x.type===a)&&(y=`revision-${x.attrs.revisionId}`),y&&b(y,p);}}),u}function Wf(e,t,o,r){let n=e.findIndex(m=>m.id===o.blockId);if(n===-1)return 0;let u=e[n],d=t[n];if(u.kind!=="table"||d.kind!=="table")return 0;let l=0;for(let m=o.fromRow;m<o.toRow;m++){let s=u.rows[m];if(!s||s.cells.some(h=>h.blocks.some(f=>{let b=f.pmStart??0,i=f.pmEnd??b;return r>=b&&r<=i})))break;l+=d.rows[m]?.height??0;}return l}function Ka(e,t,o,r){switch(e.kind){case "paragraph":{let n=e;if(!o||o.length===0){let d=layoutBridge.getCachedParagraphMeasure(n,t);if(d)return d}let u=layoutBridge.measureParagraph(n,t,{floatingZones:o,paragraphYOffset:r??0});return (!o||o.length===0)&&layoutBridge.setCachedParagraphMeasure(n,t,u),u}case "table":return layoutBridge.measureTableBlock(e,t,Ka);case "image":{let n=e;return {kind:"image",width:n.width??100,height:n.height??100}}case "textBox":{let n=e,u=n.margins??layoutEngine.DEFAULT_TEXTBOX_MARGINS,d=(n.width??layoutEngine.DEFAULT_TEXTBOX_WIDTH)-u.left-u.right,l=n.content.map(a=>layoutBridge.measureParagraph(a,d)),m=l.reduce((a,h)=>a+h.totalHeight,0),s=n.height??m+u.top+u.bottom;return {kind:"textBox",width:n.width??layoutEngine.DEFAULT_TEXTBOX_WIDTH,height:s,innerMeasures:l}}case "pageBreak":return {kind:"pageBreak"};case "columnBreak":return {kind:"columnBreak"};case "sectionBreak":return {kind:"sectionBreak"};default:layoutEngine.assertExhaustiveFlowBlock(e,"react PagedEditor measureBlock");}}function ja(e,t,o){return layoutBridge.measureBlocksWithFloats(e,t,Ka,o)}function qa(e,t,o){t.style.overflowAnchor||t.style.setProperty("overflow-anchor","none");let r=Math.max(1,t.scrollHeight-t.clientHeight),n=t.scrollTop/r,u=Va(e,o),d=0;if(u!=null){let l=layoutBridge.findBodyPmAnchor(e,u);if(l){let m=l.getBoundingClientRect(),s=t.getBoundingClientRect();d=m.top-s.top;}else u=null;}return {scrollRestoreRatioPre:n,domAnchorPmStart:u,domAnchorOffsetInScroller:d}}function Xa(e,t,o){let r=o.scrollRestoreRatioPre;if(e==="incremental"){let u=Math.max(1,t.scrollHeight-t.clientHeight);r=t.scrollTop/u;}let n=e==="incremental"?t.scrollTop:null;return {renderKind:e,ratio:r,scrollTopSnapshot:n,domAnchorPmStart:o.domAnchorPmStart,domAnchorOffsetInScroller:o.domAnchorOffsetInScroller}}function pr(e,t,o){let{renderKind:r,ratio:n,scrollTopSnapshot:u,domAnchorPmStart:d,domAnchorOffsetInScroller:l}=e;if(r==="incremental"&&u!=null){let s=Math.max(1,o.scrollHeight-o.clientHeight);o.scrollTop=Math.min(Math.max(0,u),s);return}if(r!=="incremental"&&d!=null){let s=layoutBridge.findBodyPmAnchor(t,d);if(s){let a=o.getBoundingClientRect(),h=s.getBoundingClientRect().top-a.top;o.scrollTop+=l-h;return}}let m=Math.max(1,o.scrollHeight-o.clientHeight);o.scrollTop=n*m;}function Za(e,t,o,r){if(e?.renderKind!=="incremental"||e.scrollTopSnapshot==null||r&&o>32||!t?.isConnected)return;let n=Math.max(1,t.scrollHeight-t.clientHeight),u=Math.min(Math.max(0,e.scrollTopSnapshot),n);Math.abs(t.scrollTop-u)>.5&&(t.scrollTop=u);}function os(e){let{document:t,styles:o,theme:r,sectionProperties:n,finalSectionProperties:u,headerContent:d,footerContent:l,firstPageHeaderContent:m,firstPageFooterContent:s,getHfPmDoc:a,pageGap:h,zoom:f,resolvedCommentIds:b,pagesContainerRef:i,viewportLayoutRef:p,hiddenPMRef:g,syncCoordinator:x,getScrollContainer:y,onTotalPagesChange:c,onAnchorPositionsChange:S,onRenderedDomContextReady:v}=e,[C,R]=Bl.useState(null),[P,k]=Bl.useState([]),[E,I]=Bl.useState([]),[w,D]=Bl.useState(0),H=Bl.useCallback(()=>D($=>$+1),[]),O=Bl.useRef(c),B=Bl.useRef(S),_=Bl.useRef(v),W=Bl.useRef(a);O.current=c,B.current=S,_.current=v,W.current=a;let Z=Bl.useRef(0);Bl.useEffect(()=>{let $=C?.pages.length??0;$!==Z.current&&(Z.current=$,O.current?.($));},[C]);let Y=Bl.useMemo(()=>layoutBridge.getPageSize(n),[n]),J=Bl.useMemo(()=>layoutBridge.getMargins(n),[n]),te=Bl.useMemo(()=>layoutBridge.getColumns(n),[n]),{finalPageSize:ne,finalMargins:me,finalColumns:ke}=Bl.useMemo(()=>{let $=u??n;return {finalPageSize:layoutBridge.getPageSize($),finalMargins:layoutBridge.getMargins($),finalColumns:layoutBridge.getColumns($)}},[u,n]),Ce=Y.w-J.left-J.right,M=Bl.useMemo(()=>new layoutPainter.LayoutPainter({pageGap:h,showShadow:true,pageBackground:"var(--doc-page-bg, #ffffff)"}),[h]),F=Bl.useRef(null);F.current=M;let N=Bl.useRef(null),A=Bl.useRef(0),z=Bl.useCallback($=>{let de=performance.now(),re=x.getStateSeq();x.onLayoutStart();let X=oe=>{let le=i.current,Re=le?y()??findVerticalScrollParent.findVerticalScrollParentOrRoot(le):null,Q=performance.now()-A.current;Za(N.current,Re,Q,oe);};X(true);try{let{blocks:oe,measures:le,layout:Re,headerContentForRender:Q,footerContentForRender:he,firstPageHeaderForRender:Pe,firstPageFooterForRender:Ae,hasTitlePg:Oe,watermark:De,headerDistancePx:He,footerDistancePx:q,pageBorders:ue,footnotesByPage:ce}=editor.computeLayout({state:$,document:t,pageSize:Y,margins:J,columns:te,finalPageSize:ne,finalMargins:me,finalColumns:ke,pageGap:h,contentWidth:Ce,theme:r,styles:o,sectionProperties:n,finalSectionProperties:u,headerContent:d,footerContent:l,firstPageHeaderContent:m,firstPageFooterContent:s,measureBlocks:ja,getHfPmDoc:we=>W.current?.(we)??null});if(k(oe),I(le),R(Re),i.current&&F.current){N.current=null,A.current=0;let we=i.current,Se=y()??findVerticalScrollParent.findVerticalScrollParentOrRoot(we),et=Se?.isConnected?qa(we,Se,$.selection.head):null,ae=layoutPainter.buildBlockLookup(oe,le);F.current.setBlockLookup(ae);let ze=layoutPainter.renderPages(Re.pages,i.current,{pageGap:h,showShadow:!0,pageBackground:"var(--doc-page-bg, #ffffff)",blockLookup:ae,headerContent:Q,footerContent:he,firstPageHeaderContent:Pe,firstPageFooterContent:Ae,titlePg:Oe,headerDistance:He,footerDistance:q,pageBorders:ue,theme:r,watermark:De,footnotesByPage:ce,resolvedCommentIds:b}),Te=p.current;if(Te){let _e=an(Re,h);Te.style.minHeight=`${_e}px`,f!==1?Te.style.marginBottom=`${_e*(f-1)}px`:Te.style.marginBottom="";}if(Se?.isConnected&&et){let _e=Xa(ze,Se,et);N.current=_e,_e.renderKind==="incremental"&&_e.scrollTopSnapshot!=null&&(A.current=performance.now());}if(i.current?.dispatchEvent(new CustomEvent("painter:painted",{bubbles:!0})),_.current){let _e=chunkBZO4G5M6_js.b(i.current,f);_.current(_e);}}else N.current=null,A.current=0;if(B.current){let we=Ua(g.current?.getView()??null,Re,oe,le,h);B.current(we);}X(!1);let fe=performance.now()-de;fe>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(fe)}ms total (${oe.length} blocks, ${le.length} measures)`);}catch(oe){console.error("[PagedEditor] Layout pipeline error:",oe);}x.onLayoutComplete(re),X(false);},[Ce,te,Y,J,ne,me,ke,h,f,x,d,l,m,s,n,u,t,b,y,g,i,o,r,p]);Bl.useLayoutEffect(()=>{let $=N.current;if(!$)return;N.current=null,A.current=0;let de=i.current,re=y()??(de?findVerticalScrollParent.findVerticalScrollParentOrRoot(de):null);if(!de||!re?.isConnected)return;pr($,de,re);let X=requestAnimationFrame(()=>{re.isConnected&&pr($,de,re);});return ()=>cancelAnimationFrame(X)},[C,y,i]);let V=Bl.useRef(z);V.current=z;let se=Bl.useRef(null);se.current||(se.current=editor.createLayoutScheduler($=>V.current($)));let ee=Bl.useCallback($=>{se.current.schedule($);},[]);return Bl.useEffect(()=>{let $=se.current;return ()=>$?.cancel()},[]),{layout:C,blocks:P,measures:E,decorationSyncToken:w,notifyDecorationLayer:H,contentWidth:Ce,runLayoutPipeline:z,scheduleLayout:ee}}function is(e){let{layout:t,blocks:o,measures:r,zoom:n,containerRef:u,pagesContainerRef:d,hiddenPMRef:l,syncCoordinator:m,isImageInteractingRef:s,onSelectionChangeRef:a}=e,[h,f]=Bl.useState([]),[b,i]=Bl.useState(null),[p,g]=Bl.useState(null),x=Bl.useRef(null),y=Bl.useCallback((v,C)=>{let R=v.tagName==="IMG"?v:v.querySelector("img"),P=(R??v).getBoundingClientRect();return {element:R??v,pmPos:C,width:Math.round(P.width/n),height:Math.round(P.height/n)}},[n]),c=Bl.useCallback(v=>{let{from:C,to:R}=v.selection;x.current!==v&&(x.current=v,a.current?.(C,R));let P=d.current;if(P&&(layoutBridge.applyCellSelectionHighlight(P,v),layoutPainter.applySdtFocus(P,layoutPainter.enclosingSdtGroupIds(v.doc,C,R))),!(!t||o.length===0))if(C===R){let k=P?fa(P,C,n):null;if(k)i(k);else {let E=d.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),I=d.current?.querySelector(".layout-page");if(E&&I){let w=E.getBoundingClientRect(),D=I.getBoundingClientRect(),H=layoutBridge.getCaretPosition(t,o,r,C);i(H?{...H,x:H.x+(D.left-w.left)/n,y:H.y+(D.top-w.top)/n}:null);}else i(null);}f([]);}else {let k=d.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(k&&d.current){let E=k.getBoundingClientRect(),I=ga(d.current,E,C,R,n);if(I.length>0)f(I);else {let w=d.current.querySelector(".layout-page");if(w){let D=w.getBoundingClientRect(),H=(D.left-E.left)/n,O=(D.top-E.top)/n,_=layoutBridge.selectionToRects(t,o,r,C,R).map(W=>({...W,x:W.x+H,y:W.y+O}));f(_);}else f([]);}}else f([]);i(null);}},[t,o,r,n,a,d]),S=Bl.useCallback(v=>{let{selection:C}=v;C instanceof prosemirrorState.NodeSelection&&C.node.type.name==="image"?(f([]),i(null)):m.isSafeToRender()&&c(v),requestAnimationFrame(()=>{let R=l.current?.getView();if(!R){g(null);return}let{selection:P}=R.state;if(P instanceof prosemirrorState.NodeSelection&&P.node.type.name==="image"){let k=P.from,E=d.current?layoutBridge.findBodyPmAnchor(d.current,k):null;if(E){g(y(E,k));return}}s.current||g(null);});},[c,y,m,l,s,d]);return Bl.useEffect(()=>{let v=u.current;if(!v)return;let C=new ResizeObserver(()=>{let R=l.current?.getState();R&&c(R);});return C.observe(v),()=>C.disconnect()},[c,u,l]),Bl.useEffect(()=>{let v=l.current?.getState();t&&v&&c(v);},[t,c,l]),{selectionRects:h,caretPosition:b,selectedImageInfo:p,setSelectionRects:f,setCaretPosition:i,setSelectedImageInfo:g,buildImageSelectionInfo:y,updateSelectionOverlay:c,handleSelectionChange:S}}function ss(e){let{pagesContainerRef:t,hiddenPMRef:o,zoom:r,isImageInteractingRef:n,getPositionFromMouse:u}=e,d=Bl.useCallback((f,b,i)=>{let p=o.current?.getView();if(!p)return;let g=imageCommit.commitImageResize(p,f,b,i);g!==null&&o.current?.setNodeSelection(g);},[o]),l=Bl.useCallback(()=>{n.current=true;},[n]),m=Bl.useCallback(()=>{n.current=false;},[n]),s=Bl.useCallback((f,b,i)=>{let p=o.current?.getView();if(!p)return;let g=p.state.doc.nodeAt(f);if(!(!g||g.type.name!=="image"))if(imageCommit.isFloatingImage(g)){let x=t.current?.querySelectorAll(".layout-page");if(!x||x.length===0)return;let y=null;for(let R of x){let P=R.getBoundingClientRect();if(i>=P.top&&i<=P.bottom){y=R.querySelector(".layout-page-content");break}}if(y||(y=x[x.length-1].querySelector(".layout-page-content")),!y)return;let c=y.getBoundingClientRect(),S=utils.pixelsToEmu((b-c.left)/r),v=utils.pixelsToEmu((i-c.top)/r),C=imageCommit.commitImageFloatMove(p,f,S,v);C!==null&&o.current?.setNodeSelection(C);}else {let x=u(b,i);if(x===null)return;let y=imageCommit.commitImageInlineMove(p,f,x);y!==null&&o.current?.setNodeSelection(y);}},[u,r,o,t]),a=Bl.useCallback(()=>{n.current=true;},[n]),h=Bl.useCallback(()=>{n.current=false;},[n]);return {handleImageResize:d,handleImageResizeStart:l,handleImageResizeEnd:m,handleImageDragMove:s,handleImageDragStart:a,handleImageDragEnd:h}}function ds(e){let{layout:t,blocks:o,measures:r,pagesContainerRef:n,hiddenPMRef:u,getScrollContainer:d}=e,l=Bl.useRef(null);Bl.useEffect(()=>()=>{l.current?.abort(),l.current=null;},[]);let m=Bl.useCallback((h,f=false)=>{if(!Number.isInteger(h)||h<0)return;let b=n.current;if(!b)return;l.current?.abort();let i=new AbortController;l.current=i;let{signal:p}=i,g=()=>{let E=layoutBridge.findBodyPmAnchor(b,h);if(E)return E;for(let I of layoutBridge.findBodyPmSpans(b)){let w=Number(I.dataset.pmStart),D=Number(I.dataset.pmEnd);if(Number.isFinite(w)&&Number.isFinite(D)&&h>=w&&h<=D)return I}return null};if(!f){let E={block:"center",inline:"nearest",behavior:"smooth"},I=g();if(I){I.scrollIntoView(E);return}let w=t,D=o,H=r;if(!w||D.length===0||H.length!==D.length)return;let O=null,B=layoutBridge.getCaretPosition(w,D,H,h);if(B?O=B.pageIndex:O=layoutEngine.findPageIndexContainingPmPos(w,h),O==null)return;let W=b.querySelectorAll(".layout-page")[O];if(!W)return;W.scrollIntoView(E),rn(()=>{if(!b.isConnected)return;let Z=g();Z&&Z.scrollIntoView(E);},p);return}let x=d()??findVerticalScrollParent.findVerticalScrollParentOrRoot(b),y=()=>{let E=g();return E?(nn(E,x),true):false};if(y())return;let c=t,S=o,v=r;if(!c||S.length===0||v.length!==S.length)return;let C=null,R=layoutBridge.getCaretPosition(c,S,v,h);if(R?C=R.pageIndex:C=layoutEngine.findPageIndexContainingPmPos(c,h),C==null)return;let k=b.querySelectorAll(".layout-page")[C];k&&(nn(k,x),rn(()=>{if(!b.isConnected)return;let E=g();E?nn(E,x):y();},p));},[t,o,r,d,n]),s=Bl.useCallback(h=>{if(!Number.isInteger(h)||h<1||!t||h>t.pages.length)return;let f=t.pages[h-1];for(let i of f.fragments)if(typeof i.pmStart=="number"){m(i.pmStart,true);return}n.current?.querySelectorAll(".layout-page")[h-1]?.scrollIntoView({block:"center",inline:"nearest"});},[t,m,n]),a=Bl.useCallback(h=>{let f=u.current?.getState();if(!f)return false;let b=prosemirror.findStartPosForParaId(f.doc,h);if(b==null||b<0)return false;m(b,true);let i=l.current?.signal;if(!i)return true;let p=f.doc.nodeAt(b),g=p?.isTextblock===true?Math.min(b+1+p.content.size,f.doc.content.size):Math.min(b+1,f.doc.content.size);return rn(()=>{u.current&&(u.current.setSelection(g),u.current.focus());},i),true},[m,u]);return {scrollToPositionImpl:m,scrollToPageImpl:s,scrollToParaIdImpl:a}}function ys(e){let{hiddenPMRef:t,getActiveHfView:o}=e,r=Bl.useRef(null);function n(w){return w.closest(".layout-page-header")||w.closest(".layout-page-footer")?o?.()??t.current?.getView()??null:t.current?.getView()??null}let u=Bl.useRef(false),d=Bl.useRef(0),l=Bl.useRef(0),m=Bl.useRef(0),s=Bl.useRef({left:0,right:0}),a=Bl.useRef(null),h=Bl.useRef(false),f=Bl.useRef(0),b=Bl.useRef(0),i=Bl.useRef(0),p=Bl.useRef(0),g=Bl.useRef(null),x=Bl.useRef(false),y=Bl.useRef(false),c=Bl.useRef(0),S=Bl.useRef(0),v=Bl.useRef(0),C=Bl.useRef(0),R=Bl.useRef(null),P=Bl.useCallback((w,D)=>{let H=n(w);if(!H)return false;if(w.classList.contains("layout-table-resize-handle")){D.preventDefault(),D.stopPropagation(),u.current=true,d.current=D.clientX,a.current=w,r.current=H,w.classList.add("dragging");let O=parseInt(w.dataset.columnIndex??"0",10);l.current=O,m.current=parseInt(w.dataset.tablePmStart??"0",10);let B=tableResize.readColumnWidths(H,m.current,O);return B&&(s.current=B),true}if(w.classList.contains("layout-table-row-resize-handle")||w.classList.contains("layout-table-edge-handle-bottom")){D.preventDefault(),D.stopPropagation(),h.current=true,f.current=D.clientY,g.current=w,x.current=w.dataset.isEdge==="bottom",r.current=H,w.classList.add("dragging");let O=parseInt(w.dataset.rowIndex??"0",10);b.current=O,i.current=parseInt(w.dataset.tablePmStart??"0",10);let B=tableResize.readRowHeight(H,i.current,O);if(B!=null)p.current=B;else {let W=w.closest(".layout-table")?.querySelector(`[data-row-index="${O}"]`),Z=W?W.getBoundingClientRect().height:30;p.current=Math.round(Z*tableResize.TWIPS_PER_PIXEL);}return true}if(w.classList.contains("layout-table-edge-handle-right")){D.preventDefault(),D.stopPropagation(),y.current=true,c.current=D.clientX,R.current=w,r.current=H,w.classList.add("dragging");let O=parseInt(w.dataset.columnIndex??"0",10);S.current=O,v.current=parseInt(w.dataset.tablePmStart??"0",10);let B=tableResize.readColumnWidthAt(H,v.current,O);return B!=null&&(C.current=B),true}return false},[t,o]),k=Bl.useCallback(w=>{if(u.current){w.preventDefault();let D=w.clientX-d.current;if(a.current){let H=parseFloat(a.current.style.left);a.current.style.left=`${H+D}px`,d.current=w.clientX;let O=Math.round(D*tableResize.TWIPS_PER_PIXEL),B=s.current.left+O,_=s.current.right-O;B>=tableResize.MIN_CELL_WIDTH_TWIPS&&_>=tableResize.MIN_CELL_WIDTH_TWIPS&&(s.current={left:B,right:_});}return true}if(h.current){w.preventDefault();let D=w.clientY-f.current;if(g.current){let H=parseFloat(g.current.style.top);g.current.style.top=`${H+D}px`,f.current=w.clientY;let O=Math.round(D*tableResize.TWIPS_PER_PIXEL),B=p.current+O;B>=tableResize.MIN_ROW_HEIGHT_TWIPS&&(p.current=B);}return true}if(y.current){w.preventDefault();let D=w.clientX-c.current;if(R.current){let H=parseFloat(R.current.style.left);R.current.style.left=`${H+D}px`,c.current=w.clientX;let O=Math.round(D*tableResize.TWIPS_PER_PIXEL),B=C.current+O;B>=tableResize.MIN_CELL_WIDTH_TWIPS&&(C.current=B);}return true}return false},[]),E=Bl.useCallback(()=>{let w=r.current;if(u.current){if(u.current=false,a.current&&(a.current.classList.remove("dragging"),a.current=null),w){let{left:D,right:H}=s.current;tableResize.commitColumnResize(w,{pmStart:m.current,colIdx:l.current,newLeft:D,newRight:H});}return r.current=null,true}return h.current?(h.current=false,g.current&&(g.current.classList.remove("dragging"),g.current=null),w&&tableResize.commitRowResize(w,{pmStart:i.current,rowIdx:b.current,newHeight:p.current}),r.current=null,true):y.current?(y.current=false,R.current&&(R.current.classList.remove("dragging"),R.current=null),w&&tableResize.commitRightEdgeResize(w,{pmStart:v.current,colIdx:S.current,newWidth:C.current}),r.current=null,true):false},[]),I=Bl.useCallback(()=>u.current||h.current||y.current,[]);return {tryStartFromMouseDown:P,handleMouseMoveUpdate:k,tryCommit:E,isAnyResizeActive:I}}function Mg(e){return {getView:()=>e,setSelection(t,o){let r=o??t;try{let n=e.state.doc.resolve(t),u=e.state.doc.resolve(r);e.dispatch(e.state.tr.setSelection(prosemirrorState.TextSelection.between(n,u)));}catch{e.dispatch(e.state.tr.setSelection(prosemirrorState.TextSelection.create(e.state.doc,0)));}},setNodeSelection(t){try{e.dispatch(e.state.tr.setSelection(prosemirrorState.NodeSelection.create(e.state.doc,t)));}catch{}},setCellSelection(t,o){try{let r=e.state.doc.resolve(t),n=e.state.doc.resolve(o);e.dispatch(e.state.tr.setSelection(new prosemirrorTables.CellSelection(r,n)));}catch{}},focus(){e.focus();}}}function Rs(e){let{pagesContainerRef:t,hiddenPMRef:o,getHfView:r,layout:n,blocks:u,measures:d,zoom:l,readOnly:m,hfEditMode:s,onBodyClick:a,onContextMenu:h,onHyperlinkClick:f,onHeaderFooterDoubleClick:b,setSelectedImageInfo:i,setSelectionRects:p,setCaretPosition:g,buildImageSelectionInfo:x,setIsFocused:y,scrollToPositionImpl:c}=e,S=Bl.useRef(false),v=Bl.useRef(null),C=ys({hiddenPMRef:o,getActiveHfView:r}),R=Bl.useRef(cellDragSelection.createCellDragTracker()),[P,k]=Bl.useState(null),E=Bl.useRef(null),I=Bl.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null);},[]);Bl.useEffect(()=>()=>{E.current&&clearTimeout(E.current);},[]);let w=Bl.useRef(()=>{}),D=Bl.useCallback((M,F)=>{w.current(M,F);},[]),{updateMousePosition:H,stopAutoScroll:O}=chunkLNONBJQM_js.b({pagesContainerRef:t,onScrollExtendSelection:D}),B=Bl.useCallback((M,F)=>{if(!t.current||!n)return null;let N=layoutBridge.clickToPositionDom(t.current,M,F,l);if(N!==null)return N;if(s){let oe=window.document.elementsFromPoint(M,F).find(he=>he.closest(".layout-page-header")||he.closest(".layout-page-footer"));if(!oe)return null;let le=oe.closest(".layout-page-header")??oe.closest(".layout-page-footer");if(!le)return null;let Re=Array.from(le.querySelectorAll("span[data-pm-start][data-pm-end]")),Q=null;for(let he of Re){let Pe=he.getBoundingClientRect();if(F<Pe.top-4||F>Pe.bottom+4)continue;let Ae=Number(he.dataset.pmStart),Oe=Number(he.dataset.pmEnd);if(!Number.isFinite(Ae)||!Number.isFinite(Oe))continue;let De,He;if(M<Pe.left)De=Ae,He=Pe.left-M;else if(M>Pe.right)De=Oe,He=M-Pe.right;else {let q=(M-Pe.left)/Math.max(1,Pe.width);De=Ae+Math.round(q*(Oe-Ae)),He=0;}(!Q||He<Q.dist)&&(Q={pos:De,dist:He});}return Q?.pos??null}let A=t.current.querySelectorAll(".layout-page"),z=-1,V=null;for(let X=0;X<A.length;X++){let le=A[X].getBoundingClientRect();if(M>=le.left&&M<=le.right&&F>=le.top&&F<=le.bottom){z=X,V=le;break}}if(z<0||!V)return null;let se=(M-V.left)/l,ee=(F-V.top)/l,$=n.pages[z];if(!$)return null;let de={pageIndex:z,page:$,pageY:ee},re=layoutBridge.hitTestFragment(de,u,d,{x:se,y:ee});if(!re)return null;if(re.fragment.kind==="table"){let X=layoutBridge.hitTestTableCell(de,u,d,{x:se,y:ee});return layoutBridge.clickToPosition(re,X)}return layoutBridge.clickToPosition(re)},[n,u,d,l,s,t]),_=Bl.useCallback(()=>{if(s&&r){let M=r();if(M)return Mg(M)}return o.current},[s,r,o]),W=Bl.useCallback(M=>{let F=_()?.getView();return F?cellDragSelection.findCellPosFromPmPos(F,M):null},[_]),Z=Bl.useCallback(M=>{let F=_();if(!F)return;if(M.button===2){M.preventDefault();return}if(M.button!==0||(k(null),I(),M.target.closest("a[href]")&&M.preventDefault(),m))return;let A=M.target;if(s){if(!(A.closest(".layout-page-header")||A.closest(".layout-page-footer")||A.closest(".hf-inline-editor"))&&a){M.preventDefault(),M.stopPropagation(),a();return}}else if((A.closest(".layout-page-header")||A.closest(".layout-page-footer"))&&M.detail!==2){M.preventDefault();return}if(C.tryStartFromMouseDown(A,M))return;let z=layoutPainter.findImageElement(A);if(z){M.preventDefault(),M.stopPropagation();let se=z.dataset.pmStart;if(se!==void 0){let ee=parseInt(se,10);F.setNodeSelection(ee),i(x(z,ee)),p([]),g(null);}F.focus(),s||y(true);return}i(null),M.preventDefault();let V=B(M.clientX,M.clientY);if(V!==null)R.current.begin(W(V)),S.current=true,v.current=V,F.setSelection(V);else {R.current.begin(null);let se=F.getView();if(se){let ee=Math.max(0,se.state.doc.content.size-1);F.setSelection(ee),v.current=ee,S.current=true;}}F.focus(),s||y(true);},[_,m,s,a,B,W,C,I,i,p,g,x,y]);w.current=(M,F)=>{if(!S.current||v.current===null)return;let N=_();if(!N)return;let A=B(M,F);A!==null&&N.setSelection(v.current,A);};let Y=Bl.useCallback(M=>{if(C.handleMouseMoveUpdate(M)||!S.current||v.current===null)return;let F=_();if(!F||!t.current)return;H(M.clientX,M.clientY);let N=B(M.clientX,M.clientY);if(N===null)return;let A=F.getView();if(A&&R.current.update(A,N,M.clientX))return;let z=v.current;F.setSelection(z,N);},[_,B,W,H,C,t]),J=Bl.useCallback(()=>{C.tryCommit()||(S.current=false,R.current.end(),O());},[O,C]);Bl.useEffect(()=>(window.addEventListener("mousemove",Y),window.addEventListener("mouseup",J),()=>{window.removeEventListener("mousemove",Y),window.removeEventListener("mouseup",J);}),[Y,J]);let te=Bl.useCallback(M=>{if(m||S.current||R.current.isCellDragging||C.isAnyResizeActive())return;let F=t.current;if(!F)return;let N=layoutBridge.detectTableInsertHover({mouseX:M.clientX,mouseY:M.clientY,pagesContainer:F,target:M.target,hfEditMode:s??null});if(!N){E.current||(E.current=setTimeout(()=>{k(null),E.current=null;},layoutBridge.TABLE_INSERT_HIDE_DELAY_MS));return}let A=F.parentElement;if(!A)return;let z=A.getBoundingClientRect();k({type:N.type,x:N.clientX-z.left,y:N.clientY-z.top,cellPmPos:N.cellPmPos}),I();},[m,I,s,t]),ne=Bl.useCallback(M=>{if(M.preventDefault(),M.stopPropagation(),!P)return;let F=_(),N=F?.getView();if(!F||!N)return;let{type:A,cellPmPos:z}=P,V=N.state.tr.setSelection(prosemirrorState.TextSelection.create(N.state.doc,z+1));N.dispatch(V),A==="row"?prosemirror.addRowBelow(N.state,N.dispatch):prosemirror.addColumnRight(N.state,N.dispatch),k(null),F.focus();},[P,_]),me=Bl.useCallback(M=>{let F=_(),N=M.target.closest("a[href]");if(N&&F){M.preventDefault();let z=N.getAttribute("href")||"",V=F.getView();if(z.startsWith("#")){let se=z.substring(1);if(se&&V){let ee=null;V.state.doc.descendants(($,de)=>{if(ee!==null)return false;if($.type.name==="paragraph"&&$.attrs.bookmarks?.some(X=>X.name===se))return ee=de,false}),ee!==null&&(c(ee),F.setSelection(ee+1));}}else if(f&&!(V&&V.state.selection.from!==V.state.selection.to)){let ee=N.textContent||"",$=N.getAttribute("title")||void 0,de=N.closest(".ep-root.paged-editor");if(de){let re=de.getBoundingClientRect(),X=N.getBoundingClientRect(),oe={top:X.bottom-re.top+4,left:X.left-re.left};f({href:z,displayText:ee,tooltip:$,position:oe});}}return}if(M.detail===2&&!s&&b){let z=M.target,V=z.closest(".layout-page-header"),se=z.closest(".layout-page-footer");if(V||se){let ee=z.closest("[data-page-number]"),$=ee?Number(ee.dataset.pageNumber):1;M.preventDefault(),M.stopPropagation(),b(V?"header":"footer",$);return}}if(!F)return;let A=F.getView();if(A){if(M.detail===2){let z=B(M.clientX,M.clientY);if(z!==null){let V=W(z);if(V!==null){M.preventDefault(),M.stopPropagation(),F.setCellSelection(V,V);return}let{doc:se}=A.state,ee=se.resolve(z),$=ee.parent;if($.isTextblock){let de=$.textContent,re=ee.parentOffset,[X,oe]=utils.findWordBoundaries(de,re),le=ee.start()+X,Re=ee.start()+oe;le<Re&&F.setSelection(le,Re);}}}if(M.detail===3){let z=B(M.clientX,M.clientY);if(z!==null){let V=A.state.doc.resolve(z);F.setSelection(V.start(V.depth),V.end(V.depth));}}}},[_,s,B,b,f,W,c]),ke=Bl.useCallback(M=>{if(!h)return;M.preventDefault();let F=_(),N=F?.getView();if(!F||!N)return;let A=re=>{let X=N.state.doc.nodeAt(re);if(!X||X.type.name!=="image")return null;let oe=X.attrs.wrapType??"inline",le=X.attrs.cssFloat;return {pos:re,wrapType:oe,cssFloat:le}},z=null,V=layoutPainter.hitTestImage(M.target);if(V&&(z=A(V.pos),z&&(z.inlinePositionEmu=layoutPainter.captureInlinePositionEmu(V.imageEl,l))),!z){let re=N.state.selection;if(re instanceof prosemirrorState.NodeSelection&&re.node.type.name==="image"&&(z=A(re.from),z)){let X=t.current?.querySelector(`.layout-run-image[data-pm-start="${re.from}"]`);X&&(z.inlinePositionEmu=layoutPainter.captureInlinePositionEmu(X,l));}}let{from:se,to:ee}=N.state.selection,$=B(M.clientX,M.clientY);$!==null&&(se===ee||$<se||$>ee)&&(F.setSelection($),F.focus(),s||y(true));let de=N.state.selection.from!==N.state.selection.to;h({x:M.clientX,y:M.clientY,hasSelection:de,image:z});},[_,s,h,B,l,t,y]),Ce=Bl.useCallback(()=>k(null),[]);return {handlePagesMouseDown:Z,handlePagesMouseMove:te,handlePagesClick:me,handlePagesContextMenu:ke,handleTableInsertClick:ne,tableInsertButton:P,clearTableInsertTimer:I,hideTableInsertButton:Ce,getPositionFromMouse:B}}function Og(e,t){let o=e?.package;if(!o)return null;let r=n=>{if(!n)return null;for(let[u,d]of n)if(d===t)return u;return null};return r(o.headers)??r(o.footers)}function Ps(e){let{hiddenPMRef:t,hiddenHfPMsRef:o,documentRef:r,layout:n,runLayoutPipeline:u,scrollToPositionImpl:d,scrollToParaIdImpl:l,scrollToPageImpl:m,setIsFocused:s}=e;return {getDocument:()=>t.current?.getDocument()??null,getState:()=>t.current?.getState()??null,getView:()=>t.current?.getView()??null,focus:()=>{t.current?.focus(),s(true);},blur:()=>{t.current?.blur(),s(false);},isFocused:()=>t.current?.isFocused()??false,dispatch:a=>t.current?.dispatch(a),undo:()=>t.current?.undo()??false,redo:()=>t.current?.redo()??false,setSelection:(a,h)=>t.current?.setSelection(a,h),getLayout:()=>n,relayout:()=>{let a=t.current?.getState();a&&u(a);},scrollToPosition:d,scrollToParaId:l,scrollToPage:m,highlightRange:(a,h)=>{let f=t.current?.getView()??null;if(!f)return;let b=queries.clampRangeToDoc(f.state.doc,a,h);b&&(t.current?.setSelection(b.from,b.to),d(b.from,true));},scrollToCommentId:a=>{let h=t.current?.getView()??null,f=queries.findCommentRange(h,a);return f?(t.current?.setSelection(f.from,f.to),d(f.from,true),true):false},scrollToChangeId:a=>{let h=t.current?.getView()??null,f=queries.findChangeRange(h,a);return f?(t.current?.setSelection(f.from,f.to),d(f.from,true),true):false},getHfPmView:a=>{let h=Og(r.current,a);return h?o.current?.getView(h)??null:null}}}function Ts(e){let{ref:t,hiddenPMRef:o,hiddenHfPMsRef:r,documentRef:n,layout:u,runLayoutPipeline:d,scrollToPositionImpl:l,scrollToParaIdImpl:m,scrollToPageImpl:s,setIsFocused:a,onReadyRef:h}=e;Bl.useImperativeHandle(t,()=>Ps({hiddenPMRef:o,hiddenHfPMsRef:r,documentRef:n,layout:u,runLayoutPipeline:d,scrollToPositionImpl:l,scrollToParaIdImpl:m,scrollToPageImpl:s,setIsFocused:a}),[u,d,l,m,s]),Bl.useEffect(()=>{h.current&&o.current&&h.current(Ps({hiddenPMRef:o,hiddenHfPMsRef:r,documentRef:n,layout:u,runLayoutPipeline:d,scrollToPositionImpl:l,scrollToParaIdImpl:m,scrollToPageImpl:s,setIsFocused:a}));},[u,d,m,s]);}function Es(e){let{hiddenPMRef:t,runLayoutPipeline:o,updateSelectionOverlay:r,headerContent:n,footerContent:u,firstPageHeaderContent:d,firstPageFooterContent:l}=e;Bl.useEffect(()=>{let s=()=>{let a=t.current?.getView();a&&(layoutBridge.resetCanvasContext(),layoutBridge.clearAllCaches(),o(a.state),r(a.state));};return window.document.fonts.addEventListener("loadingdone",s),()=>{window.document.fonts.removeEventListener("loadingdone",s);}},[]);let m=Bl.useRef(0);Bl.useEffect(()=>{if(m.current===0){m.current=1;return}let s=t.current?.getView();s&&o(s.state);},[n,u,d,l,o,t]);}function Is({type:e,x:t,y:o,onMouseDown:r,onMouseEnter:n,onMouseLeave:u}){let d=e==="row"?"Insert row below":"Insert column to the right";return jsxRuntime.jsx("button",{type:"button",onMouseDown:r,onMouseEnter:n,onMouseLeave:u,style:{position:"absolute",left:t,top:o,width:20,height:20,borderRadius:"4px",border:"1px solid var(--doc-border-light)",backgroundColor:"var(--doc-bg)",color:"var(--doc-text-muted)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:200,padding:0,boxShadow:"none"},title:d,"aria-label":d,children:jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 1v10M1 6h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})}var Hs={position:"absolute",zIndex:1e4,background:"var(--doc-surface)",borderRadius:"8px",boxShadow:"0 1px 3px var(--doc-shadow), 0 4px 12px var(--doc-shadow-subtle)",border:"1px solid var(--doc-border-light)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px"},Wg={...Hs,padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",maxWidth:"400px"},Vg={...Hs,padding:"12px",width:"320px"},Sr={width:"20px",height:"20px",flexShrink:0,color:"var(--doc-text-muted)",display:"flex",alignItems:"center",justifyContent:"center"},Ug={color:"var(--doc-link)",textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"220px",fontSize:"14px",lineHeight:"20px",cursor:"pointer"},$g={width:"28px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"none",borderRadius:"4px",cursor:"pointer",color:"var(--doc-text-muted)",padding:0,flexShrink:0},Gg={width:"1px",height:"20px",background:"var(--doc-border-light)",flexShrink:0},Ms={display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},Ds={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",fontSize:"14px",outline:"none",lineHeight:"20px"},Kg={color:"var(--doc-primary)",fontWeight:600,fontSize:"14px",border:"none",background:"none",cursor:"pointer",padding:"6px 12px",borderRadius:"4px",flexShrink:0},Qt={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};function jg(){return jsxRuntime.jsxs("svg",{...Qt,children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M2 12h20"}),jsxRuntime.jsx("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"})]})}function Yg(){return jsxRuntime.jsxs("svg",{...Qt,children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function qg(){return jsxRuntime.jsx("svg",{...Qt,children:jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}function Xg(){return jsxRuntime.jsxs("svg",{...Qt,children:[jsxRuntime.jsx("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"}),jsxRuntime.jsx("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"}),jsxRuntime.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),jsxRuntime.jsx("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),jsxRuntime.jsx("line",{x1:"16",y1:"19",x2:"16",y2:"22"}),jsxRuntime.jsx("line",{x1:"19",y1:"16",x2:"22",y2:"16"})]})}function Zg(){return jsxRuntime.jsxs("svg",{...Qt,children:[jsxRuntime.jsx("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),jsxRuntime.jsx("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),jsxRuntime.jsx("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),jsxRuntime.jsx("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function Qg(){return jsxRuntime.jsxs("svg",{...Qt,children:[jsxRuntime.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),jsxRuntime.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function xr({title:e,onClick:t,children:o}){return jsxRuntime.jsx("button",{type:"button",className:"ep-hyperlink-popup__icon-btn",style:$g,title:e,onClick:t,children:o})}function Fs({data:e,onNavigate:t,onCopy:o,onEdit:r,onRemove:n,onClose:u,readOnly:d}){let{t:l}=chunkGNIO6SOS_js.b(),[m,s]=Bl.useState("view"),[a,h]=Bl.useState(""),[f,b]=Bl.useState(""),i=Bl.useRef(null),p=Bl.useRef(null);Bl.useEffect(()=>{e&&(s("view"),h(e.displayText),b(e.href));},[e]),Bl.useEffect(()=>{m==="edit"&&requestAnimationFrame(()=>{p.current?.focus(),p.current?.select();});},[m]),Bl.useEffect(()=>{if(!e)return;let C=false,R=k=>{i.current&&!i.current.contains(k.target)&&u();},P=setTimeout(()=>{C||document.addEventListener("mousedown",R);},0);return ()=>{C=true,clearTimeout(P),document.removeEventListener("mousedown",R);}},[e,u]),Bl.useEffect(()=>{if(!e)return;let C=R=>{R.key==="Escape"&&(m==="edit"?s("view"):u());};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[e,m,u]);let g=Bl.useCallback(()=>{e&&(o(e.href),sonner.toast("Link copied to clipboard"));},[e,o]),x=Bl.useCallback(()=>{e&&(h(e.displayText),b(e.href),s("edit"));},[e]),y=Bl.useCallback(()=>{let C=f.trim();C&&r(a.trim()||C,C);},[a,f,r]),c=Bl.useCallback(C=>{C.key==="Enter"&&(C.preventDefault(),y());},[y]);if(!e)return null;let S=e.position.top,v=e.position.left;return m==="edit"?jsxRuntime.jsxs("div",{ref:i,className:"ep-hyperlink-popup ep-hyperlink-popup--edit",style:{...Vg,top:S,left:v},onMouseDown:C=>C.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:Ms,children:[jsxRuntime.jsx("span",{style:Sr,children:jsxRuntime.jsx(Zg,{})}),jsxRuntime.jsx("input",{ref:p,type:"text",style:Ds,value:a,onChange:C=>h(C.target.value),onKeyDown:c,placeholder:l("hyperlinkPopup.displayTextPlaceholder"),onFocus:C=>C.target.style.borderColor="var(--doc-primary)",onBlur:C=>C.target.style.borderColor="var(--doc-border-light)"})]}),jsxRuntime.jsxs("div",{style:{...Ms,marginBottom:0},children:[jsxRuntime.jsx("span",{style:Sr,children:jsxRuntime.jsx(Qg,{})}),jsxRuntime.jsx("input",{type:"text",style:Ds,value:f,onChange:C=>b(C.target.value),onKeyDown:c,placeholder:l("hyperlinkPopup.urlPlaceholder"),onFocus:C=>C.target.style.borderColor="var(--doc-primary)",onBlur:C=>C.target.style.borderColor="var(--doc-border-light)"}),jsxRuntime.jsx("button",{type:"button",style:{...Kg,opacity:f.trim()?1:.5,cursor:f.trim()?"pointer":"default"},onClick:y,disabled:!f.trim(),children:l("common.apply")})]})]}):jsxRuntime.jsxs("div",{ref:i,className:"ep-hyperlink-popup",style:{...Wg,top:S,left:v},onMouseDown:C=>C.stopPropagation(),children:[jsxRuntime.jsx("span",{style:Sr,children:jsxRuntime.jsx(jg,{})}),jsxRuntime.jsx("a",{href:e.href,style:Ug,title:e.href,target:"_blank",rel:"noopener noreferrer",onClick:C=>{C.preventDefault(),t(e.href);},children:e.href}),jsxRuntime.jsx("span",{style:Gg}),jsxRuntime.jsx(xr,{title:l("hyperlinkPopup.copyLink"),onClick:g,children:jsxRuntime.jsx(Yg,{})}),!d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(xr,{title:l("hyperlinkPopup.editLink"),onClick:x,children:jsxRuntime.jsx(qg,{})}),jsxRuntime.jsx(xr,{title:l("hyperlinkPopup.removeLink"),onClick:n,children:jsxRuntime.jsx(Xg,{})})]})]})}var sb=Bl.forwardRef(function(t,o){let{document:r,styles:n,theme:u,sectionProperties:d,finalSectionProperties:l,headerContent:m,footerContent:s,firstPageHeaderContent:a,firstPageFooterContent:h,readOnly:f=false,pageGap:b=24,zoom:i=1,onDocumentChange:p,onSelectionChange:g,externalPlugins:x=Oa,extensionManager:y,onReady:c,onRenderedDomContextReady:S,pluginOverlays:v,onHeaderFooterDoubleClick:C,hfEditMode:R,onBodyClick:P,onHfTransaction:k,className:E,style:I,commentsSidebarOpen:w=false,sidebarOverlay:D,scrollContainerRef:H,onHyperlinkClick:O,onContextMenu:B,onAnchorPositionsChange:_,onTotalPagesChange:W,resolvedCommentIds:Z,hyperlinkPopupData:Y,onHyperlinkPopupNavigate:J,onHyperlinkPopupCopy:te,onHyperlinkPopupEdit:ne,onHyperlinkPopupRemove:me,onHyperlinkPopupClose:ke}=t,Ce=Bl.useCallback(()=>H&&typeof H=="object"?H.current:M.current,[H]),M=Bl.useRef(null),F=Bl.useRef(null),N=Bl.useRef(null),A=Bl.useRef(null),z=Bl.useRef(null),V=Bl.useRef(r);V.current=r;let{handlePMKeyDown:se}=chunkLNONBJQM_js.a({pagesContainerRef:F}),ee=Bl.useRef(g),$=Bl.useRef(p),de=Bl.useRef(c),re=Bl.useRef(S);ee.current=g,$.current=p,de.current=c,re.current=S;let[X,oe]=Bl.useState(false);Bl.useEffect(()=>{if(R){let G=A.current?.getView();if(G){try{let ye=G.state.tr.setSelection(prosemirrorState.TextSelection.create(G.state.doc,0));G.dispatch(ye);}catch{}G.dom.blur?.();}oe(false);}},[R]);let le=Bl.useRef(false),Re=Bl.useMemo(()=>new LayoutSelectionGate.LayoutSelectionGate,[]),Q=Bl.useCallback(G=>{let ye=z.current;if(!ye)return null;let ge=r?.package;if(!ge)return null;let pe=$t=>{if(!$t)return null;for(let[so,lo]of $t)if(lo===G)return so;return null},tt=pe(ge.headers)??pe(ge.footers);return tt?ye.getView(tt)?.state.doc??null:null},[r]),{layout:he,blocks:Pe,measures:Ae,decorationSyncToken:Oe,notifyDecorationLayer:De,contentWidth:He,runLayoutPipeline:q,scheduleLayout:ue}=os({document:r,styles:n,theme:u,sectionProperties:d,finalSectionProperties:l,headerContent:m,footerContent:s,firstPageHeaderContent:a,firstPageFooterContent:h,getHfPmDoc:Q,pageGap:b,zoom:i,resolvedCommentIds:Z,pagesContainerRef:F,viewportLayoutRef:N,hiddenPMRef:A,syncCoordinator:Re,getScrollContainer:Ce,onTotalPagesChange:W,onAnchorPositionsChange:_,onRenderedDomContextReady:S}),{selectionRects:ce,caretPosition:fe,selectedImageInfo:we,setSelectionRects:Se,setCaretPosition:et,setSelectedImageInfo:ae,buildImageSelectionInfo:ze,updateSelectionOverlay:Te,handleSelectionChange:_e}=is({layout:he,blocks:Pe,measures:Ae,zoom:i,containerRef:M,pagesContainerRef:F,hiddenPMRef:A,syncCoordinator:Re,isImageInteractingRef:le,onSelectionChangeRef:ee}),Pt=Bl.useCallback((G,ye)=>{if(De(),G.docChanged){Re.incrementStateSeq(),ue(ye);let ge=A.current?.getDocument();ge&&$.current?.(ge);}Re.requestRender(),G.docChanged||Te(ye);},[ue,Te,Re,De]),{scrollToPositionImpl:Fo,scrollToPageImpl:Wt,scrollToParaIdImpl:Tt}=ds({layout:he,blocks:Pe,measures:Ae,pagesContainerRef:F,hiddenPMRef:A,getScrollContainer:Ce}),{handlePagesMouseDown:kn,handlePagesMouseMove:wt,handlePagesClick:Mn,handlePagesContextMenu:ht,handleTableInsertClick:Vt,tableInsertButton:Et,clearTableInsertTimer:ro,hideTableInsertButton:io,getPositionFromMouse:It}=Rs({pagesContainerRef:F,hiddenPMRef:A,getHfView:Bl.useCallback(()=>{let G=z.current;if(!G)return null;let ye=r?.package?.document?.finalSectionProperties,ge=R==="header"?ye?.headerReferences:ye?.footerReferences,pe=ge?.find(tt=>tt.type==="default")??ge?.find(tt=>tt.type==="first")??null;return pe?.rId?G.getView(pe.rId):null},[R,r]),layout:he,blocks:Pe,measures:Ae,zoom:i,readOnly:f,hfEditMode:R,onBodyClick:P,onContextMenu:B,onHyperlinkClick:O,onHeaderFooterDoubleClick:C,setSelectedImageInfo:ae,setSelectionRects:Se,setCaretPosition:et,buildImageSelectionInfo:ze,setIsFocused:oe,scrollToPositionImpl:Fo}),Dn=Bl.useCallback(G=>{if(f)return;let ye=G.target;ye.closest(".docx-comments-sidebar")||ye.closest(".docx-unified-sidebar")||ye.closest(".ep-hyperlink-popup")||ye.closest("[data-hf-r-id]")||(A.current?.focus(),oe(true));},[f]),Hn=Bl.useCallback(G=>{let ye=G.relatedTarget;ye&&M.current?.contains(ye)||ye?.closest('[role="toolbar"], [data-radix-popper-content-wrapper], [data-radix-select-content], .docx-table-options-dropdown')||oe(false);},[]),{handleImageResize:Lo,handleImageResizeStart:Fn,handleImageResizeEnd:Ln,handleImageDragMove:kt,handleImageDragStart:An,handleImageDragEnd:Ye}=ss({pagesContainerRef:F,hiddenPMRef:A,zoom:i,isImageInteractingRef:le,getPositionFromMouse:It}),On=Bl.useCallback(G=>{if(f)return;let ye=G.target;if(!ye?.closest("[data-hf-r-id]")&&!ye?.closest(".ep-hyperlink-popup")){if(A.current?.isFocused()||(A.current?.focus(),oe(true)),G.key===" "&&!G.ctrlKey&&!G.metaKey&&!G.nativeEvent.isComposing){G.preventDefault();let ge=A.current?.getView();if(ge){let{from:pe,to:tt}=ge.state.selection;ge.someProp("handleTextInput",so=>so(ge,pe,tt," "))||ge.dispatch(ge.state.tr.insertText(" "));}return}if(["PageUp","PageDown"].includes(G.key)&&!G.metaKey&&G.ctrlKey,G.key==="Home"&&(G.metaKey||G.ctrlKey)){let ge=Ce();ge&&(ge.scrollTop=0);}if(G.key==="End"&&(G.metaKey||G.ctrlKey)){let ge=Ce();ge&&(ge.scrollTop=ge.scrollHeight);}}},[f,Ce]),Bn=Bl.useCallback(G=>{f||G.target.closest(".docx-comments-sidebar")||G.target.closest(".docx-unified-sidebar")||A.current?.isFocused()||(A.current?.focus(),oe(true));},[f]),ao=Bl.useCallback(G=>{q(G.state),Te(G.state),f||requestAnimationFrame(()=>{G.focus(),oe(true);});},[q,Te,f]);Es({hiddenPMRef:A,runLayoutPipeline:q,updateSelectionOverlay:Te,headerContent:m,footerContent:s,firstPageHeaderContent:a,firstPageFooterContent:h}),Ts({ref:o,hiddenPMRef:A,hiddenHfPMsRef:z,documentRef:V,layout:he,runLayoutPipeline:q,scrollToPositionImpl:Fo,scrollToParaIdImpl:Tt,scrollToPageImpl:Wt,setIsFocused:oe,onReadyRef:de});let Ut=Bl.useMemo(()=>he?an(he,b):layoutBridge.DEFAULT_PAGE_HEIGHT_PX+24+24,[he,b]);return jsxRuntime.jsxs("div",{ref:M,className:`ep-root paged-editor ${E??""}`,style:{...Ba,...I},tabIndex:0,onFocus:Dn,onBlur:Hn,onKeyDown:On,onMouseDown:Bn,children:[jsxRuntime.jsx(Ca,{ref:A,document:r,styles:n,widthPx:He,readOnly:f||!!R,onTransaction:Pt,onSelectionChange:_e,externalPlugins:x,extensionManager:y,onEditorViewReady:ao,onKeyDown:se}),jsxRuntime.jsx(lr,{ref:z,document:r,styles:n,theme:u,defaultTabStopTwips:r?.package?.settings?.defaultTabStop??null,onTransaction:(G,ye,ge)=>{if(ge){let pe=A.current?.getState();pe&&q(pe);}k?.(G,ye,ge);}}),jsxRuntime.jsxs("div",{ref:N,style:{...Na,minHeight:Ut,marginBottom:i!==1?Ut*(i-1):void 0,transform:(()=>{let G=[];return w&&G.push(`translateX(-${sidebarConstants.SIDEBAR_DOCUMENT_SHIFT}px)`),i!==1&&G.push(`scale(${i})`),G.length>0?G.join(" "):void 0})(),transformOrigin:"top center",transition:"transform 0.2s ease"},children:[jsxRuntime.jsx("div",{ref:F,className:`paged-editor__pages${f?" paged-editor--readonly":""}${R?` paged-editor--hf-editing paged-editor--editing-${R}`:""}`,style:za,onMouseDown:kn,onMouseMove:wt,onClick:Mn,onContextMenu:ht,"aria-hidden":"true"}),jsxRuntime.jsx(Ra,{selectionRects:R?[]:ce,caretPosition:R?null:fe,isFocused:X&&!R,pageGap:b,readOnly:f}),jsxRuntime.jsx(ka,{imageInfo:we,zoom:i,isFocused:X,onResize:Lo,onResizeStart:Fn,onResizeEnd:Ln,onDragMove:kt,onDragStart:An,onDragEnd:Ye,onContextMenu:ht}),Et&&jsxRuntime.jsx(Is,{type:Et.type,x:Et.x,y:Et.y,onMouseDown:Vt,onMouseEnter:ro,onMouseLeave:io}),v&&jsxRuntime.jsx("div",{className:"paged-editor__plugin-overlays",style:_a,children:v}),jsxRuntime.jsx(Ha,{getView:()=>A.current?.getView()??null,getPagesContainer:()=>F.current,zoom:i,decorationSyncToken:Oe,syncCoordinator:Re})]}),D&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:Ut*i,pointerEvents:"none",overflow:"visible"},children:jsxRuntime.jsx("div",{style:{pointerEvents:"auto"},children:D})}),Y&&J&&te&&ne&&me&&ke&&jsxRuntime.jsx(Fs,{data:Y,onNavigate:J,onCopy:te,onEdit:ne,onRemove:me,onClose:ke,readOnly:f})]})}),Bs=Bl.memo(sb);var _s={position:"absolute",left:0,right:0,bottom:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"2px 0",fontSize:11,color:"var(--doc-primary)",userSelect:"none",pointerEvents:"auto"},Ws={fontWeight:500,letterSpacing:.3},gb={background:"none",border:"none",color:"var(--doc-primary)",cursor:"pointer",fontSize:11,padding:"2px 6px",borderRadius:3},bb={position:"absolute",right:0,top:"100%",background:"var(--doc-surface)",border:"1px solid var(--doc-border-light)",borderRadius:4,boxShadow:"0 2px 6px var(--doc-shadow)",zIndex:chunkGDJM7SOG_js.h.dropdown,minWidth:160,padding:"4px 0"},pn={display:"block",width:"100%",padding:"6px 12px",border:"none",background:"none",textAlign:"left",cursor:"pointer",fontSize:12,color:"var(--doc-text)"},Us=Bl.forwardRef(function({headerFooter:t,position:o,view:r,targetElement:n,parentElement:u,onSave:d,onClose:l,onRemove:m},s){let a=Bl.useRef(r);a.current=r;let[h,f]=Bl.useState(false),b=Bl.useRef(null),[i,p]=Bl.useState(null);Bl.useLayoutEffect(()=>{let R=()=>{let k=u.getBoundingClientRect(),E=n.getBoundingClientRect();p({top:E.top-k.top+u.scrollTop,left:E.left-k.left+u.scrollLeft,width:E.width,height:E.height});};R();let P=u.closest('[style*="overflow"]')||u;return P.addEventListener("scroll",R),window.addEventListener("resize",R),()=>{P.removeEventListener("scroll",R),window.removeEventListener("resize",R);}},[n,u]);let g=Bl.useRef(false);Bl.useEffect(()=>{!r||g.current||(g.current=true,requestAnimationFrame(()=>r.focus()));},[r]);let x=Bl.useCallback(()=>{if(!a.current)return;let R=conversion.proseDocToBlocks(a.current.state.doc);d(R);},[d]),y=Bl.useCallback(()=>{x(),l();},[x,l]);Bl.useEffect(()=>{function R(P){P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),y());}return document.addEventListener("keydown",R,true),()=>document.removeEventListener("keydown",R,true)},[y]),Bl.useEffect(()=>{if(!h)return;function R(P){b.current&&!b.current.contains(P.target)&&f(false);}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[h]),Bl.useImperativeHandle(s,()=>({getView:()=>a.current,focus:()=>a.current?.focus(),undo:()=>{let R=a.current;return R?prosemirrorHistory.undo(R.state,R.dispatch):false},redo:()=>{let R=a.current;return R?prosemirrorHistory.redo(R.state,R.dispatch):false}}));let{t:c}=chunkGNIO6SOS_js.b(),S=c(o==="header"?"headerFooter.header":"headerFooter.footer");if(!i)return null;let v={position:"absolute",top:i.top,left:i.left,width:i.width,height:i.height,zIndex:chunkGDJM7SOG_js.h.hfInlineEditor,pointerEvents:"none"},C={..._s,bottom:"auto",top:"100%"};return jsxRuntime.jsxs("div",{className:"hf-inline-editor",style:v,children:[o==="footer"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:C,children:[jsxRuntime.jsx("span",{style:Ws,children:S}),jsxRuntime.jsx(Vs,{label:S,showOptions:h,setShowOptions:f,optionsRef:b,onRemove:m,onClose:y,viewRef:a})]}),o==="header"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:_s,children:[jsxRuntime.jsx("span",{style:Ws,children:S}),jsxRuntime.jsx(Vs,{label:S,showOptions:h,setShowOptions:f,optionsRef:b,onRemove:m,onClose:y,viewRef:a})]})]})});function Vs({label:e,showOptions:t,setShowOptions:o,optionsRef:r,onRemove:n,onClose:u,viewRef:d}){let{t:l}=chunkGNIO6SOS_js.b(),m=s=>{let a=d.current;if(!a)return;let{$from:h,from:f}=a.state.selection,b=a.state.storedMarks||h.marks(),i=prosemirror.schema.nodes.field.create({fieldType:s,instruction:` ${s} \\* MERGEFORMAT `,fieldKind:"simple",dirty:true}),p=a.state.tr.insert(f,i.mark(b));a.dispatch(p),a.focus();};return jsxRuntime.jsxs("div",{style:{position:"relative"},ref:r,children:[jsxRuntime.jsxs("button",{type:"button",style:gb,onClick:s=>{s.stopPropagation(),o(a=>!a);},onMouseDown:s=>s.stopPropagation(),children:[l("headerFooter.options")," \u25BE"]}),t&&jsxRuntime.jsxs("div",{style:bb,onMouseDown:s=>s.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",style:pn,onClick:()=>{o(false),m("PAGE");},onMouseOver:s=>{s.target.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:s=>{s.target.style.backgroundColor="transparent";},children:l("headerFooter.insertPageNumber")}),jsxRuntime.jsx("button",{type:"button",style:pn,onClick:()=>{o(false),m("NUMPAGES");},onMouseOver:s=>{s.target.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:s=>{s.target.style.backgroundColor="transparent";},children:l("headerFooter.insertTotalPages")}),jsxRuntime.jsx("div",{style:{borderTop:"1px solid var(--doc-border-light)",margin:"4px 0"}}),n&&jsxRuntime.jsx("button",{type:"button",style:pn,onClick:()=>{o(false),n();},onMouseOver:s=>{s.target.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:s=>{s.target.style.backgroundColor="transparent";},children:l("headerFooter.remove",{label:e.toLowerCase()})}),jsxRuntime.jsx("button",{type:"button",style:pn,onClick:()=>{o(false),u();},onMouseOver:s=>{s.target.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:s=>{s.target.style.backgroundColor="transparent";},children:l("headerFooter.closeEditing",{label:e.toLowerCase()})})]})]})}var $s=resolveItemPositions.resolveItemPositions;function js({items:e,anchorPositions:t,renderedDomContext:o,pageWidth:r,zoom:n,editorContainerRef:u,onExpandedItemChange:d,activeItemId:l}){let{t:m}=chunkGNIO6SOS_js.b(),s=l??null,a=Bl.useRef(s);a.current=s;let[h,f]=Bl.useState(false),b=Bl.useRef(new Map),i=Bl.useRef(new Map),p=Bl.useRef(new Set),g=Bl.useRef(null),x=Bl.useRef(new Map),y=Bl.useRef(new Map),[c,S]=Bl.useState(0),v=Bl.useMemo(()=>$s(e,t,o,n,b.current,i.current),[e,t,o,n,c]),C=v.length>0,R=Bl.useMemo(()=>{let I=new Map;for(let w of v)I.set(w.item.id,w.y);return I},[v]);Bl.useEffect(()=>{for(let I of v)p.current.add(I.item.id);},[v]);let P=Bl.useCallback(()=>{let I=false;for(let[w,D]of x.current){let H=D.offsetHeight;b.current.get(w)!==H&&(b.current.set(w,H),I=true);}I&&S(w=>w+1);},[]);Bl.useEffect(()=>{let I=requestAnimationFrame(P),w=setTimeout(()=>{P(),f(true);},400);return ()=>{cancelAnimationFrame(I),clearTimeout(w);}},[e.length,P]),Bl.useEffect(()=>{let I=u?.current;if(!I)return;let w=new ResizeObserver(()=>{requestAnimationFrame(()=>S(D=>D+1));});return w.observe(I),()=>w.disconnect()},[u]),Bl.useEffect(()=>{let I=requestAnimationFrame(P);return ()=>cancelAnimationFrame(I)},[s,P]),Bl.useEffect(()=>{if(!s)return;let I=x.current.get(s);if(!I){let H=requestAnimationFrame(()=>S(O=>O+1));return ()=>cancelAnimationFrame(H)}let w,D=new ResizeObserver(()=>{cancelAnimationFrame(w),w=requestAnimationFrame(()=>{b.current.set(s,I.offsetHeight),S(H=>H+1);});});return D.observe(I),()=>{cancelAnimationFrame(w),D.disconnect();}},[s]);let k=Bl.useCallback(I=>{let w=y.current.get(I);return w||(w=D=>{D?(x.current.set(I,D),b.current.set(I,D.offsetHeight)):(x.current.delete(I),b.current.delete(I));},y.current.set(I,w)),w},[]),E=Bl.useCallback(I=>{d?.(a.current===I?null:I);},[d]);return e.length===0?null:jsxRuntime.jsx("aside",{ref:g,className:"docx-unified-sidebar",role:"complementary","aria-label":m("sidebar.ariaLabel"),style:{position:"absolute",top:0,left:`calc(50% - ${sidebarConstants.SIDEBAR_DOCUMENT_SHIFT}px + ${r*n/2+sidebarConstants.SIDEBAR_PAGE_GAP}px)`,width:sidebarConstants.SIDEBAR_WIDTH,fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,backgroundColor:"transparent",overflowY:"visible",overflowX:"visible",opacity:C?1:0,transition:"opacity 0.15s ease"},onMouseDown:I=>I.stopPropagation(),children:jsxRuntime.jsx("div",{style:{position:"relative"},children:e.map(I=>{let w=R.get(I.id),D=s===I.id,O=!p.current.has(I.id)&&w!==void 0,B=C&&!R.has(I.id),_=C?w!==void 0?{position:"absolute",top:w,left:0,right:0,opacity:1}:{position:"absolute",top:0,left:0,right:0,opacity:0,visibility:"hidden"}:{marginBottom:6},W=B?"none":O||I.isTemporary?"opacity 0.2s ease":h?"opacity 0.2s ease, top 0.15s ease":"none";return jsxRuntime.jsx("div",{style:{..._,transition:W},children:I.render({isExpanded:D,onToggleExpand:()=>E(I.id),measureRef:k(I.id)})},I.id)})})})}function Ys({comments:e,anchorPositions:t,zoom:o,pageWidth:r,sidebarOpen:n,resolvedCommentIds:u,onMarkerClick:d}){let{t:l}=chunkGNIO6SOS_js.b(),s=e.filter(a=>a.parentId==null).map(a=>{let h=u.has(a.id);if(!h&&n||h&&n)return null;let f=t.get(`comment-${a.id}`);return f==null?null:{comment:a,isResolved:h,y:f}}).filter(Boolean);return s.length===0?null:jsxRuntime.jsx("div",{className:"docx-comment-margin-markers",style:{position:"absolute",top:0,left:`calc(50% + ${r*o/2+6}px)`,zIndex:30,pointerEvents:"none"},onMouseDown:a=>a.stopPropagation(),children:s.map(({comment:a,isResolved:h,y:f})=>jsxRuntime.jsx("button",{onClick:()=>d(a.id),title:l(h?"commentMarkers.resolvedComment":"commentMarkers.comment"),style:{position:"absolute",top:f*o,left:0,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",borderRadius:4,background:"transparent",cursor:"pointer",pointerEvents:"auto",color:"var(--doc-text-muted)",padding:0,fontFamily:"inherit"},onMouseOver:b=>{b.currentTarget.style.opacity="0.7";},onMouseOut:b=>{b.currentTarget.style.opacity="1";},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:h?"chat_bubble_check":"chat_bubble_outline",size:18})},a.id))})}function Zs({pagedEditorRef:e,hfEditorRef:t,scrollContainerRef:o,editorContentRef:r,document:n,theme:u,initialSectionProperties:d,finalSectionProperties:l,headerContent:m,footerContent:s,firstPageHeaderContent:a,firstPageFooterContent:h,hfEditPosition:f,setHfEditPosition:b,hfEditIsFirstPage:i,onHeaderFooterDoubleClick:p,onHeaderFooterSave:g,onRemoveHeaderFooter:x,onBodyClick:y,getHfTargetElement:c,zoom:S,readOnly:v,extensionManager:C,externalPlugins:R,onDocumentChange:P,onSelectionChange:k,onPagedSelectionChange:E,onReady:I,onEditorViewReady:w,onRenderedDomContextReady:D,pluginOverlays:H,onHyperlinkClick:O,hyperlinkPopupData:B,onHyperlinkPopupNavigate:_,onHyperlinkPopupCopy:W,onHyperlinkPopupEdit:Z,onHyperlinkPopupRemove:Y,onHyperlinkPopupClose:J,onContextMenu:te,sidebarOpen:ne,sidebarItems:me,anchorPositions:ke,onAnchorPositionsChange:Ce,pluginRenderedDomContext:M,pageWidthPx:F,expandedSidebarItem:N,setExpandedSidebarItem:A,comments:z,resolvedCommentIds:V,resolvedIdsForRender:se,setShowCommentsSidebar:ee,onTotalPagesChange:$,floatingCommentBtn:de,isAddingComment:re,setCommentSelectionRange:X,setAddCommentYPosition:oe,setIsAddingComment:le,setFloatingCommentBtn:Re}){let Q=f?i?f==="header"?a:h:f==="header"?m:s:null,[he,Pe]=Bl.useState(null),[Ae,Oe]=Bl.useState([]),De=Bl.useCallback(q=>{let ce=window.document.querySelector(".paged-editor__pages")?.parentElement;if(!ce)return q;let fe=ce.getBoundingClientRect();return {...q,top:q.top-fe.top+ce.scrollTop,left:q.left-fe.left+ce.scrollLeft}},[]),He=Bl.useCallback(q=>{if(!f){Pe(null),Oe([]);return}let ue=layoutBridge.computeHfCaretRectFromView(q,f);Pe(ue?De(ue):null),Oe(layoutBridge.computeHfSelectionRectsFromView(q,f).map(De));let ce=window.document.querySelector(".paged-editor__pages");ce&&layoutBridge.applyCellSelectionHighlight(ce,q.state,{scope:f});},[f,De]);return Bl.useEffect(()=>{if(!f){Pe(null),Oe([]),layoutBridge.invalidateHfDomCache();return}let q=()=>{let Se=t.current?.getView();Se&&He(Se);},ue=window.document.querySelector(".paged-editor__pages"),ce=()=>{layoutBridge.invalidateHfDomCache(),q();};ue?.addEventListener("painter:painted",ce);let fe=requestAnimationFrame(q),we=()=>q();return window.addEventListener("resize",we),()=>{cancelAnimationFrame(fe),ue?.removeEventListener("painter:painted",ce),window.removeEventListener("resize",we),layoutBridge.invalidateHfDomCache();}},[f,t,He]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bs,{ref:e,document:n,styles:n?.package.styles,theme:n?.package.theme||u,sectionProperties:d,finalSectionProperties:l,headerContent:m,footerContent:s,firstPageHeaderContent:a,firstPageFooterContent:h,onHeaderFooterDoubleClick:p,hfEditMode:f,onBodyClick:y,onHfTransaction:(q,ue,ce)=>{let fe=window.document.querySelector(".paged-editor__pages"),we=false,Se=()=>{we||(we=true,layoutBridge.invalidateHfDomCache(),He(ue));};fe?.addEventListener("painter:painted",Se,{once:true}),requestAnimationFrame(()=>{we||(fe?.removeEventListener("painter:painted",Se),Se());}),k(prosemirror.extractSelectionState(ue.state));},zoom:S,readOnly:v,extensionManager:C,onDocumentChange:P,onSelectionChange:E,externalPlugins:R,onReady:q=>{I(q);let ue=q.getView();ue&&w?.(ue);},onRenderedDomContextReady:D,pluginOverlays:H,onHyperlinkClick:O,hyperlinkPopupData:B,onHyperlinkPopupNavigate:_,onHyperlinkPopupCopy:W,onHyperlinkPopupEdit:Z,onHyperlinkPopupRemove:Y,onHyperlinkPopupClose:J,onContextMenu:te,commentsSidebarOpen:ne,onAnchorPositionsChange:Ce,onTotalPagesChange:$,resolvedCommentIds:se,scrollContainerRef:o,sidebarOverlay:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[me.length>0&&jsxRuntime.jsx(js,{items:me,anchorPositions:ke,renderedDomContext:M??null,pageWidth:F,zoom:S,editorContainerRef:o,onExpandedItemChange:A,activeItemId:N}),jsxRuntime.jsx(Ys,{comments:z,anchorPositions:ke,zoom:S,pageWidth:F,sidebarOpen:ne,resolvedCommentIds:V,onMarkerClick:()=>ee(true)})]})}),de!=null&&!re&&!v&&jsxRuntime.jsx(chunkGDJM7SOG_js.o,{content:"Add comment",side:"bottom",delayMs:300,children:jsxRuntime.jsx("button",{type:"button",onMouseDown:q=>{q.preventDefault(),q.stopPropagation();let ue=e.current?.getView();if(ue){let{from:ce,to:fe}=ue.state.selection;if(ce!==fe){X({from:ce,to:fe});let we=ue.state.schema.marks.comment.create({commentId:commentIdAllocator.PENDING_COMMENT_ID}),Se=ue.state.tr.addMark(ce,fe,we);Se.setSelection(prosemirrorState.TextSelection.create(Se.doc,fe)),ue.dispatch(Se);}}oe(de.top),ee(true),le(true),Re(null);},style:{position:"absolute",top:de.top,left:de.left,transform:"translate(-50%, -50%)",zIndex:50,width:28,height:28,borderRadius:6,border:"1px solid var(--doc-focus-ring)",backgroundColor:"var(--doc-surface)",color:"var(--doc-primary)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px var(--doc-shadow)",transition:"background-color 0.15s ease, box-shadow 0.15s ease"},onMouseOver:q=>{q.currentTarget.style.backgroundColor="var(--doc-primary-light)",q.currentTarget.style.boxShadow="0 1px 4px var(--doc-focus-ring)";},onMouseOut:q=>{q.currentTarget.style.backgroundColor="var(--doc-surface)",q.currentTarget.style.boxShadow="0 1px 3px var(--doc-shadow)";},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"add_comment",size:16})})}),f&&(he||Ae.length>0)&&(()=>{let q=window.document.querySelector(".paged-editor__pages"),ue=q?.parentElement;return !q||!ue?null:reactDom.createPortal(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[he&&Ae.length===0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("div",{"aria-hidden":"true",style:{position:"absolute",top:he.top,left:he.left,width:2,height:he.height,background:"#4285f4",pointerEvents:"none",zIndex:11,animation:"hf-caret-blink 1.06s steps(1) infinite"}})}),Ae.map((ce,fe)=>jsxRuntime.jsx("div",{"aria-hidden":"true",style:{position:"absolute",top:ce.top,left:ce.left,width:ce.width,height:ce.height,background:"rgba(66, 133, 244, 0.25)",pointerEvents:"none",zIndex:10}},`hf-sel-${fe}-${ce.top}-${ce.left}`))]}),ue)})(),f&&Q&&(()=>{let q=c(f),ue=r.current;if(!q||!ue)return null;let ce=e.current?.getHfPmView(Q)??null;return jsxRuntime.jsx(Us,{ref:t,headerFooter:Q,position:f,view:ce,targetElement:q,parentElement:ue,onSave:g,onClose:()=>{b(null),Pe(null);},onRemove:x})})()]})}var Mr=".layout-sdt-widget, .layout-inline-sdt-widget";function Js(e){let t=/^sdt@(\d+)$/.exec(e??"");return t?Number(t[1]):null}function Db(e){if(e==null||e==="")return null;let t=Number(e);return Number.isFinite(t)?t:null}function Hb(e){let t=Js(e.dataset.sdtGroupId)??Db(e.dataset.sdtPos),o=e.dataset.sdtTag;return t!=null?o?{pos:t,tag:o}:{pos:t}:o?{tag:o}:null}function Fb(e,t){return prosemirror.findContentControlsInPM(e.state.doc,{tag:t})[0]}function Lb(e,t){return t.pos!=null?prosemirror.findContentControlsInPM(e.state.doc).find(o=>o.pos===t.pos):t.tag?Fb(e,t.tag):void 0}function el({containerRef:e,getView:t}){let[o,r]=Bl.useState(null),n=Bl.useRef(null),u=Bl.useCallback((m,s)=>{let a=t();if(a){try{let h=m.pos!=null?prosemirror.setContentControlValueAtPosTr(a.state,m.pos,s):m.tag?prosemirror.setContentControlValueTr(a.state,{tag:m.tag},s):null;if(!h)return;a.dispatch(h),a.focus();}catch{}r(null);}},[t]);Bl.useEffect(()=>{let m=e.current;if(!m)return;let s=i=>{let p=t(),g=i.dataset.sdtWidget,x=Hb(i);if(!p||!g||!x)return;let y=Lb(p,x),c=i.getBoundingClientRect();g==="checkbox"?u(x,{kind:"checkbox",checked:!y?.checked}):g==="dropdown"?r({kind:"dropdown",target:x,items:y?.listItems??[],current:y?.text??"",rect:c}):g==="date"&&r({kind:"date",target:x,current:y?.dateValue??"",rect:c});},a=i=>{let p=t(),g=Js(i.dataset.sdtGroupId);if(!(!p||g==null))try{let x=i.dataset.sdtRepeat==="add"?prosemirror.addRepeatingSectionItemTr(p.state,g):prosemirror.removeRepeatingSectionItemTr(p.state,g);p.dispatch(x),p.focus();}catch{}},h=i=>{let p=i.target;(p?.closest?.(Mr)||p?.closest?.(".layout-sdt-repeat-btn"))&&i.preventDefault();},f=i=>{let p=i.target?.closest?.(".layout-sdt-repeat-btn");if(p){i.preventDefault(),i.stopPropagation(),a(p);return}let g=i.target?.closest?.(Mr);g&&(i.preventDefault(),i.stopPropagation(),s(g));},b=i=>{if(i.key!=="Enter"&&i.key!==" ")return;let p=i.target?.closest?.(Mr);p&&(i.preventDefault(),s(p));};return m.addEventListener("mousedown",h),m.addEventListener("click",f),m.addEventListener("keydown",b),()=>{m.removeEventListener("mousedown",h),m.removeEventListener("click",f),m.removeEventListener("keydown",b);}},[e,t,u]),Bl.useEffect(()=>{if(!o)return;let m=a=>{n.current?.contains(a.target)||r(null);},s=a=>{a.key==="Escape"&&r(null);};return document.addEventListener("mousedown",m),document.addEventListener("keydown",s),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",s);}},[o]),Bl.useEffect(()=>{if(o?.kind!=="dropdown")return;let m=n.current?.querySelectorAll(".layout-sdt-widget-option");m?.length&&([...m].find(s=>s.getAttribute("aria-selected")==="true")??m[0]).focus();},[o]);let d=m=>{if(m.key!=="ArrowDown"&&m.key!=="ArrowUp")return;let s=[...n.current?.querySelectorAll(".layout-sdt-widget-option")??[]];if(!s.length)return;m.preventDefault();let a=s.indexOf(document.activeElement),h=m.key==="ArrowDown"?(a+1)%s.length:(a-1+s.length)%s.length;s[h].focus();};if(!o)return null;let l={position:"fixed",top:o.rect.bottom+2,left:o.rect.left,zIndex:1e3};return jsxRuntime.jsx("div",{ref:n,className:"layout-sdt-widget-popup",style:l,role:o.kind==="dropdown"?"listbox":void 0,onKeyDown:d,onMouseDown:m=>m.preventDefault(),children:o.kind==="dropdown"?o.items.length===0?jsxRuntime.jsx("div",{className:"layout-sdt-widget-empty",children:"No options"}):o.items.map(m=>{let s=m.displayText===o.current;return jsxRuntime.jsx("button",{type:"button",role:"option","aria-selected":s,className:`layout-sdt-widget-option${s?" is-selected":""}`,onClick:()=>u(o.target,{kind:"dropdown",value:m.value}),children:m.displayText},m.value)}):jsxRuntime.jsx("input",{type:"date",className:"layout-sdt-widget-date",autoFocus:true,defaultValue:o.current,onChange:m=>{m.target.value&&u(o.target,{kind:"date",date:m.target.value});}})})}function tl({commentsLoadedRef:e,trackedChangesLoadedRef:t,setComments:o,setHeadingInfos:r,setShowCommentsSidebar:n,setIsAddingComment:u,setCommentSelectionRange:d,setAddCommentYPosition:l,setFloatingCommentBtn:m,setHfEditPosition:s,setHfEditIsFirstPage:a,setAnchorPositions:h,clearFindReplaceMatches:f,cleanOrphanedCommentsTimerRef:b}){return {resetForNewDocument:Bl.useCallback(()=>{e.current=false,t.current=false,o([]),r([]),n(false),u(false),d(null),l(null),m(null),s(null),a(false),h(qo),f(),b.current&&(clearTimeout(b.current),b.current=null);},[e,t,o,r,n,u,d,l,m,s,a,h,f,b])}}var Wb=Bl.createContext(null);function nl({children:e}){let t=Bl.useMemo(()=>new docxEditorCore.ErrorManager,[]),o=Bl.useSyncExternalStore(t.subscribe,t.getSnapshot),r=Bl.useCallback((s,a)=>{t.showError(s,a);},[t]),n=Bl.useCallback((s,a)=>{t.showWarning(s,a);},[t]),u=Bl.useCallback((s,a)=>{t.showInfo(s,a);},[t]),d=Bl.useCallback(s=>{t.dismiss(s);},[t]),l=Bl.useCallback(()=>{t.clearAll();},[t]),m=Bl.useMemo(()=>({notifications:o.notifications,showError:r,showWarning:n,showInfo:u,dismissNotification:d,clearNotifications:l}),[o.notifications,r,n,u,d,l]);return jsxRuntime.jsxs(Wb.Provider,{value:m,children:[e,jsxRuntime.jsx(Vb,{notifications:o.notifications,onDismiss:d})]})}function Vb({notifications:e,onDismiss:t}){let o=e.filter(n=>!n.dismissed);return o.length===0?null:jsxRuntime.jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:o.map(n=>jsxRuntime.jsx(Ub,{notification:n,onDismiss:()=>t(n.id)},n.id))})}function Ub({notification:e,onDismiss:t}){let{t:o}=chunkGNIO6SOS_js.b(),[r,n]=Bl.useState(false),d=(p=>{switch(p){case "error":return {bg:"var(--doc-error-bg)",border:"var(--doc-error)",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"var(--doc-warning)",text:"var(--doc-warning-text)",icon:"var(--doc-warning)"};case "info":return {bg:"var(--doc-primary-light)",border:"var(--doc-primary)",text:"var(--doc-primary)",icon:"var(--doc-primary)"}}})(e.severity),l={background:d.bg,border:`1px solid ${d.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px var(--doc-shadow)",animation:"slideIn 0.3s ease-out"},m={display:"flex",alignItems:"flex-start",gap:"8px"},s={color:d.icon,flexShrink:0},a={flex:1,minWidth:0},h={color:d.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},f={marginTop:"8px",padding:"8px",background:"var(--doc-shadow-subtle)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:d.text,maxHeight:"200px",overflow:"auto"},b={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:d.text},i=p=>{switch(p){case "error":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxRuntime.jsxs("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:l,children:[jsxRuntime.jsx("style",{children:`
12
+ </head><body>${T.outerHTML}</body></html>`),C.document.close(),C.onload=()=>{C.print(),C.close();},setTimeout(()=>{C.closed||(C.print(),C.close());},1e3),l?.();},[o,l]),g=zl.useCallback(async()=>{let v=await i();if(!v)return;let C=new Blob([v],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}),R=URL.createObjectURL(C),T=window.document.createElement("a");T.href=R,T.download=`${(n?.trim()||"document").replace(/\.docx$/i,"")}.docx`,T.click(),setTimeout(()=>URL.revokeObjectURL(R),0);},[i,n]),x=zl.useCallback(()=>{h.current?.click();},[]),y=zl.useCallback(async v=>{try{let C=await utils.readDocxFileFromInput(v.nativeEvent);if(!C)return;await s(C.buffer),m?.(C.name);}catch(C){d?.(C instanceof Error?C:new Error("Failed to open document"));}},[s,m,d]),c=zl.useCallback(()=>{f.current?.click();},[]),S=zl.useCallback(v=>{let C=v.target.files?.[0],R=a();C&&R&&commands.insertImageFromFile(R,C,{onInserted:b}),v.target.value="";},[a,b]);return {imageInputRef:f,docxInputRef:h,handleSave:i,handleDirectPrint:p,handleDownloadDocument:g,handleOpenDocument:x,handleDocxFileChange:y,handleInsertImageClick:c,handleImageFileChange:S}}function xi({document:e,readOnly:t,handleDocumentChange:o,getActiveEditorView:r}){let[n,u]=zl.useState(false),d=zl.useCallback(()=>u(true),[]),l=zl.useCallback(x=>y=>{if(!e||t)return;let c={...e,package:{...e.package,document:{...e.package.document,finalSectionProperties:{...e.package.document.finalSectionProperties,[x]:y}}}};o(c);},[e,t,o]),m=zl.useMemo(()=>l("marginLeft"),[l]),s=zl.useMemo(()=>l("marginRight"),[l]),a=zl.useMemo(()=>l("marginTop"),[l]),b=zl.useMemo(()=>l("marginBottom"),[l]),f=zl.useCallback(x=>{if(!e||t)return;let y={...e,package:{...e.package,document:{...e.package.document,finalSectionProperties:{...e.package.document.finalSectionProperties,...x}}}};o(y);},[e,t,o]),h=zl.useCallback(x=>{let y=r();y&&commands.setIndentLeft(x)(y.state,y.dispatch);},[r]),i=zl.useCallback(x=>{let y=r();y&&commands.setIndentRight(x)(y.state,y.dispatch);},[r]),p=zl.useCallback(x=>{let y=r();y&&(x<0?commands.setIndentFirstLine(-x,true)(y.state,y.dispatch):commands.setIndentFirstLine(x,false)(y.state,y.dispatch));},[r]),g=zl.useCallback(x=>{let y=r();y&&commands.removeTabStop(x)(y.state,y.dispatch);},[r]);return {showPageSetup:n,setShowPageSetup:u,handleOpenPageSetup:d,handleLeftMarginChange:m,handleRightMarginChange:s,handleTopMarginChange:a,handleBottomMarginChange:b,handlePageSetupApply:f,handleIndentLeftChange:h,handleIndentRightChange:i,handleFirstLineIndentChange:p,handleTabStopRemove:g}}function Pi({readOnly:e,getBodyEditorView:t}){let[o,r]=zl.useState(false),n=zl.useCallback(()=>r(true),[]),u=t(),d=u?commands.getWatermarkFromState(u.state)??void 0:void 0,l=zl.useCallback(m=>{if(e)return;let s=t();s&&commands.setWatermark(m)(s.state,s.dispatch);},[e,t]);return {showWatermark:o,setShowWatermark:r,handleOpenWatermark:n,currentWatermark:d,handleWatermarkApply:l}}function Ei({hyperlinkDialog:e,getActiveEditorView:t,focusActiveEditor:o}){let[r,n]=zl.useState(null),u=zl.useCallback(i=>{let p=t();if(!p)return;let g=i.url||"",x=i.tooltip,{empty:y}=p.state.selection;y&&i.displayText?commands.insertHyperlink(i.displayText,g,x)(p.state,p.dispatch):y?i.displayText&&commands.insertHyperlink(i.displayText,g,x)(p.state,p.dispatch):commands.setHyperlink(g,x)(p.state,p.dispatch),e.close(),o();},[e,t,o]),d=zl.useCallback(()=>{let i=t();i&&(commands.removeHyperlink(i.state,i.dispatch),o());},[t,o]),l=zl.useCallback(()=>{d(),e.close();},[e,d]),m=zl.useCallback(i=>n(i),[]),s=zl.useCallback(i=>{window.open(i,"_blank","noopener,noreferrer");},[]),a=zl.useCallback(i=>{navigator.clipboard.writeText(i).catch(()=>{let p=document.createElement("textarea");p.value=i,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.select(),document.execCommand("copy"),document.body.removeChild(p);});},[]),b=zl.useCallback((i,p)=>{let g=t();if(!g)return;let x=commands.findHyperlinkRangeAt(g.state);if(x){let y=g.state.schema.marks.hyperlink,{$from:c}=g.state.selection,S=y.create({href:p,tooltip:x.mark.attrs.tooltip}),v=g.state.schema.text(i,[...c.marks().filter(R=>R.type!==y),S]),C=g.state.tr.replaceWith(x.start,x.end,v);g.dispatch(C.scrollIntoView());}n(null),o();},[t,o]),f=zl.useCallback(()=>{let i=t();if(!i)return;let p=commands.findHyperlinkRangeAt(i.state,r?.href);if(!p)return;let g=i.state.schema.marks.hyperlink;i.dispatch(i.state.tr.removeMark(p.start,p.end,g).scrollIntoView()),n(null),o(),sonner.toast("Link removed");},[t,o,r]),h=zl.useCallback(()=>{n(null);},[]);return {hyperlinkPopupData:r,setHyperlinkPopupData:n,handleHyperlinkSubmit:u,handleHyperlinkRemove:l,handleHyperlinkClick:m,handleHyperlinkPopupNavigate:s,handleHyperlinkPopupCopy:a,handleHyperlinkPopupEdit:b,handleHyperlinkPopupRemove:f,handleHyperlinkPopupClose:h}}function Ii(e,t,o){let r=0;for(let n of e){let u=r+n.text.length;if(o==="start"&&t>=r&&t<u||o==="end"&&t>r&&t<=u)return n.pmStart+t-r;r=u;}return null}function ki(e,t,o){let r=[],n=0;return e.state.doc.descendants((u,d)=>{if(!u.isTextblock)return true;let l=[],m="";if(u.descendants((a,b)=>(!a.isText||!a.text||(l.push({text:a.text,pmStart:d+1+b}),m+=a.text),true)),!m)return n+=1,false;let s=(0, chunkL4MDZW2J_js.a.findAllMatches)(m,t,o);for(let a of s){let b=Ii(l,a.start,"start"),f=Ii(l,a.end,"end");b==null||f==null||b>=f||r.push({paragraphIndex:n,contentIndex:0,startOffset:a.start,endOffset:a.end,text:m.slice(a.start,a.end),pmFrom:b,pmTo:f});}return n+=1,false}),r}function Mi({pagedEditorRef:e,findReplace:t}){let o=zl.useRef(null),r=zl.useCallback(()=>e.current?.getView()??null,[e]),n=zl.useCallback((a,b)=>{let f=r();if(!f||!a)return null;try{let i=prosemirrorState.TextSelection.create(f.state.doc,a.pmFrom,a.pmTo);f.dispatch(f.state.tr.setSelection(i)),e.current?.scrollToPosition(a.pmFrom);}catch(i){return console.error("Find navigation failed:",i),null}let h=o.current;return h&&(h.currentIndex=b),t.goToMatch(b),a},[t,r,e]),u=zl.useCallback((a,b)=>{let f=r();if(!f||!a.trim())return o.current=null,t.setMatches([],0),null;let h=ki(f,a,b),i={matches:h,totalCount:h.length,currentIndex:0};return o.current=i,t.setMatches(h,0),h.length>0&&n(h[0],0),i},[t,r,n]),d=zl.useCallback(()=>{let a=o.current;if(!a||a.matches.length===0)return null;let b=(a.currentIndex+1)%a.matches.length;return n(a.matches[b],b)},[n]),l=zl.useCallback(()=>{let a=o.current;if(!a||a.matches.length===0)return null;let b=a.currentIndex===0?a.matches.length-1:a.currentIndex-1;return n(a.matches[b],b)},[n]),m=zl.useCallback(a=>{let b=r(),f=o.current;if(!b||!f||f.matches.length===0)return false;let h=f.matches[f.currentIndex];if(!h)return false;try{let i=a?b.state.tr.replaceWith(h.pmFrom,h.pmTo,b.state.schema.text(a)):b.state.tr.delete(h.pmFrom,h.pmTo);return b.dispatch(i),!0}catch(i){return console.error("Replace failed:",i),false}},[r]),s=zl.useCallback((a,b,f)=>{let h=r();if(!h||!a.trim())return 0;let i=ki(h,a,f);if(i.length===0)return 0;let p=[...i].sort((x,y)=>y.pmFrom-x.pmFrom),g=h.state.tr;for(let x of p)try{g=b?g.replaceWith(x.pmFrom,x.pmTo,h.state.schema.text(b)):g.delete(x.pmFrom,x.pmTo);}catch(y){console.error("Replace failed for match:",x,y);}return h.dispatch(g),o.current=null,t.setMatches([],0),i.length},[t,r]);return {findResultRef:o,handleFind:u,handleFindNext:d,handleFindPrevious:l,handleReplace:m,handleReplaceAll:s}}function Fi({getActiveEditorView:e,focusActiveEditor:t,pagedEditorRef:o,lastSelectionRef:r,hyperlinkDialog:n,historyStateRef:u,getCachedStyleResolver:d}){let l=zl.useCallback(h=>{let i=e();if(!i)return;i.focus();let p=i===o.current?.getView(),{from:g,to:x}=i.state.selection,y=r.current;if(p&&y&&(g!==y.from||x!==y.to))try{let c=i.state.tr.setSelection(prosemirrorState.TextSelection.create(i.state.doc,y.from,y.to));i.dispatch(c);}catch(c){console.warn("Could not restore selection:",c);}if(h==="bold")return void commands.toggleBold(i.state,i.dispatch);if(h==="italic")return void commands.toggleItalic(i.state,i.dispatch);if(h==="underline")return void commands.toggleUnderline(i.state,i.dispatch);if(h==="strikethrough")return void commands.toggleStrike(i.state,i.dispatch);if(h==="superscript")return void commands.toggleSuperscript(i.state,i.dispatch);if(h==="subscript")return void commands.toggleSubscript(i.state,i.dispatch);if(h==="bulletList")return void commands.toggleBulletList(i.state,i.dispatch);if(h==="numberedList")return void commands.toggleNumberedList(i.state,i.dispatch);if(h==="indent"){commands.increaseListLevel(i.state,i.dispatch)||commands.increaseIndent()(i.state,i.dispatch);return}if(h==="outdent"){commands.decreaseListLevel(i.state,i.dispatch)||commands.decreaseIndent()(i.state,i.dispatch);return}if(h==="clearFormatting")return void commands.clearFormatting(i.state,i.dispatch);if(h==="setRtl")return void commands.setRtl(i.state,i.dispatch);if(h==="setLtr")return void commands.setLtr(i.state,i.dispatch);if(h==="insertLink"){let c=commands.getSelectedText(i.state),S=commands.getHyperlinkAttrs(i.state);S?n.openEdit({url:S.href,displayText:c,tooltip:S.tooltip}):n.openInsert(c);return}if(typeof h=="object")switch(h.type){case "alignment":commands.setAlignment(h.value)(i.state,i.dispatch);break;case "textColor":{let c=h.value;typeof c=="string"?commands.setTextColor({rgb:c.replace("#","")})(i.state,i.dispatch):c.auto?commands.clearTextColor(i.state,i.dispatch):commands.setTextColor(c)(i.state,i.dispatch);break}case "highlightColor":{let c=h.value?chunkGDJM7SOG_js.g(h.value):"";commands.setHighlight(c||h.value)(i.state,i.dispatch);break}case "fontSize":commands.setFontSize(chunkGDJM7SOG_js.d(h.value))(i.state,i.dispatch);break;case "fontFamily":commands.setFontFamily(h.value)(i.state,i.dispatch);break;case "lineSpacing":commands.setLineSpacing(h.value)(i.state,i.dispatch);break;case "applyStyle":{let c=u.current,S=c?.package.styles?d(c.package.styles):null;if(S){let v=S.resolveParagraphStyle(h.value);commands.applyStyle(h.value,{paragraphFormatting:v.paragraphFormatting,runFormatting:v.runFormatting,numbering:c?.package.numbering?docx.getCachedNumberingMap(c.package.numbering):null})(i.state,i.dispatch);}else commands.applyStyle(h.value)(i.state,i.dispatch);break}}},[e,o,r,n,u,d]),m=zl.useCallback((h,i)=>{let p=e();p&&(commands.insertTable(h,i)(p.state,p.dispatch),t());},[e,t]),s=zl.useCallback(()=>{let h=e();h&&(commands.insertPageBreak(h.state,h.dispatch),t());},[e,t]),a=zl.useCallback(()=>{let h=e();h&&(commands.insertSectionBreakNextPage(h.state,h.dispatch),t());},[e,t]),b=zl.useCallback(()=>{let h=e();h&&(commands.insertSectionBreakContinuous(h.state,h.dispatch),t());},[e,t]),f=zl.useCallback(()=>{let h=e();h&&(commands.generateTOC(h.state,h.dispatch),t());},[e,t]);return {handleFormat:l,handleInsertTable:m,handleInsertPageBreak:s,handleInsertSectionBreakNextPage:a,handleInsertSectionBreakContinuous:b,handleInsertTOC:f}}function Li({document:e,pmImageContext:t,zoom:o,getActiveEditorView:r,focusActiveEditor:n,pushDocument:u}){let[d,l]=zl.useState(false),[m,s]=zl.useState(false),[a,b]=zl.useState(false),f=zl.useCallback(y=>{let c=r();if(!c||!t)return;let S=t.pos,v=c.state.doc.nodeAt(S);if(!v||v.type.name!=="image")return;let C=layoutPainter.toolbarValueToLayoutTarget(y);if(!C)return;let R;if(v.attrs.wrapType==="inline"&&C!=="inline"){let T=window.document.querySelector(`.layout-run-image[data-pm-start="${S}"]`),k=T?layoutPainter.captureInlinePositionEmu(T,o):void 0;k&&(R={initialPositionEmu:k});}commands.setImageWrapType(S,C,R)(c.state,c.dispatch),n();},[r,n,t,o]),h=zl.useCallback(y=>{let c=r();if(!c||!t)return;let S=t.pos,v=c.state.doc.nodeAt(S);if(!v||v.type.name!=="image")return;let C=v.attrs.transform||"",R=C.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),T=R?parseFloat(R[1]):0,k=/scaleX\(-1\)/.test(C),E=/scaleY\(-1\)/.test(C);switch(y){case "rotateCW":T=(T+90)%360;break;case "rotateCCW":T=(T-90+360)%360;break;case "flipH":k=!k;break;case "flipV":E=!E;break}let I=[];T!==0&&I.push(`rotate(${T}deg)`),k&&I.push("scaleX(-1)"),E&&I.push("scaleY(-1)");let w=I.length>0?I.join(" "):null,D=c.state.tr.setNodeMarkup(S,void 0,{...v.attrs,transform:w});c.dispatch(D.scrollIntoView()),n();},[r,n,t]),i=zl.useCallback(y=>{let c=r();if(!c||!t)return;let S=t.pos,v=c.state.doc.nodeAt(S);if(!v||v.type.name!=="image")return;let C=c.state.tr.setNodeMarkup(S,void 0,{...v.attrs,position:{horizontal:y.horizontal,vertical:y.vertical},distTop:y.distTop??v.attrs.distTop,distBottom:y.distBottom??v.attrs.distBottom,distLeft:y.distLeft??v.attrs.distLeft,distRight:y.distRight??v.attrs.distRight});c.dispatch(C.scrollIntoView()),n();},[r,n,t]),p=zl.useCallback(()=>{s(true);},[]),g=zl.useCallback(y=>{let c=r();if(!c||!t)return;let S=t.pos,v=c.state.doc.nodeAt(S);if(!v||v.type.name!=="image")return;let C=c.state.tr.setNodeMarkup(S,void 0,{...v.attrs,alt:y.alt??null,borderWidth:y.borderWidth??null,borderColor:y.borderColor??null,borderStyle:y.borderStyle??null,width:y.width??null,height:y.height??null});c.dispatch(C.scrollIntoView()),n();},[r,n,t]),x=zl.useCallback((y,c)=>{if(!e?.package)return;let S={...e.package.document,finalSectionProperties:{...e.package.document.finalSectionProperties,footnotePr:y,endnotePr:c}};u({...e,package:{...e.package,document:S}});},[e,u]);return {imagePositionOpen:d,setImagePositionOpen:l,imagePropsOpen:m,setImagePropsOpen:s,footnotePropsOpen:a,setFootnotePropsOpen:b,handleImageWrapType:f,handleImageTransform:h,handleApplyImagePosition:i,handleOpenImageProperties:p,handleApplyImageProperties:g,handleApplyFootnoteProperties:x}}var Zo=new Map;function Oi({ref:e,agentRef:t,document:o,historyStateRef:r,pagedEditorRef:n,handleSave:u,handleDirectPrint:d,zoom:l,setZoom:m,scrollPageInfo:s,loadParsedDocument:a,loadBuffer:b,comments:f,setComments:h,setShowCommentsSidebar:i,contentChangeSubscribersRef:p,selectionChangeSubscribersRef:g,getCachedStyleResolver:x,commentIdAllocator:y}){zl.useImperativeHandle(e,()=>({getAgent:()=>t.current,getDocument:()=>o,getEditorRef:()=>n.current,save:u,setZoom:m,getZoom:()=>l,focus:()=>{n.current?.focus();},getCurrentPage:()=>s.currentPage,getTotalPages:()=>s.totalPages,scrollToPage:c=>{n.current?.scrollToPage(c);},scrollToPosition:c=>{n.current?.scrollToPosition(c);},openPrintPreview:d,print:d,loadDocument:a,loadDocumentBuffer:b,addComment:c=>{let S=n.current?.getView();if(!S)return null;let v=commentOps.addCommentToRange(S,c,y);return v?(h(C=>[...C,v]),i(true),v.id):null},replyToComment:(c,S,v)=>{if(!f.some(R=>R.id===c))return null;let C=commentOps.createComment(y,S,v,c);return h(R=>[...R,C]),C.id},resolveComment:c=>{h(S=>S.map(v=>v.id===c?{...v,done:true}:v));},proposeChange:c=>{let S=n.current?.getView();if(!S)return false;let v=commentOps.applyProposedChange(S,c,y);return v&&i(true),v},applyFormatting:c=>{let S=n.current?.getView();return S?applyFormatting.applyFormatting(S,c):false},setParagraphStyle:c=>{let S=n.current?.getView();if(!S)return false;let v=r.current,C=v?.package?.styles?x(v.package.styles):null,R=v?.package?.numbering?docx.getCachedNumberingMap(v.package.numbering):null;return applyFormatting.setParagraphStyle(S,c,{styleResolver:C,numbering:R})},insertBreak:c=>{let S=n.current?.getView();return S?applyFormatting.insertBreak(S,c):false},getPageContent:c=>queries.getPageContent(n.current?.getView()??null,n.current?.getLayout()??null,c),scrollToParaId:c=>n.current?.scrollToParaId(c)??false,scrollToCommentId:c=>n.current?.scrollToCommentId(c)??false,scrollToChangeId:c=>n.current?.scrollToChangeId(c)??false,highlightRange:(c,S)=>{n.current?.highlightRange(c,S);},findInDocument:(c,S)=>queries.findInDocument(n.current?.getView()??null,c,S),getSelectionInfo:()=>queries.getSelectionInfo(n.current?.getView()??null),getComments:()=>f,getContentControls:c=>{let S=n.current?.getView();return S?prosemirror.findContentControlsInPM(S.state.doc,c??{}):[]},scrollToContentControl:c=>{let S=n.current?.getView();if(!S)return false;let v=prosemirror.findContentControlPos(S.state.doc,c);return v==null?false:(n.current?.scrollToPosition(v),true)},setContentControlContent:(c,S,v)=>{let C=n.current?.getView();if(!C)return false;try{return C.dispatch(prosemirror.setContentControlContentTr(C.state,c,S,v)),!0}catch(R){if(R instanceof agent.ContentControlNotFoundError)return false;throw R}},removeContentControl:(c,S)=>{let v=n.current?.getView();if(!v)return false;try{return v.dispatch(prosemirror.removeContentControlTr(v.state,c,S)),!0}catch(C){if(C instanceof agent.ContentControlNotFoundError)return false;throw C}},setContentControlValue:(c,S,v)=>{let C=n.current?.getView();if(!C)return false;try{return C.dispatch(prosemirror.setContentControlValueTr(C.state,c,S,v)),!0}catch(R){if(R instanceof agent.ContentControlNotFoundError)return false;throw R}},onContentChange:c=>(p.current.add(c),()=>{p.current.delete(c);}),onSelectionChange:c=>(g.current.add(c),()=>{g.current.delete(c);})}),[o,l,s,u,d,a,b,f]);}var U=e=>({style:"single",size:4,color:{rgb:e}}),ap=[{id:"TableNormal",name:"Normal Table",look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGrid",name:"Table Grid",tableBorders:{top:U("000000"),bottom:U("000000"),left:U("000000"),right:U("000000"),insideH:U("000000"),insideV:U("000000")},look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGridLight",name:"Grid Table Light",tableBorders:{top:U("BFBFBF"),bottom:U("BFBFBF"),left:U("BFBFBF"),right:U("BFBFBF"),insideH:U("BFBFBF"),insideV:U("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:U("000000")}}}},{id:"PlainTable1",name:"Plain Table 1",tableBorders:{top:U("BFBFBF"),bottom:U("BFBFBF"),insideH:U("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true}}},{id:"PlainTable2",name:"Plain Table 2",look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:U("7F7F7F")}},band1Horz:{backgroundColor:"#F2F2F2"}}},{id:"PlainTable3",name:"Plain Table 3",look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#A5A5A5"},band1Horz:{backgroundColor:"#E7E7E7"}}},{id:"PlainTable4",name:"Plain Table 4",look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#000000"},band1Horz:{backgroundColor:"#F2F2F2"}}},{id:"GridTable1Light-Accent1",name:"Grid Table 1 Light",tableBorders:{top:U("B4C6E7"),bottom:U("B4C6E7"),left:U("B4C6E7"),right:U("B4C6E7"),insideH:U("B4C6E7"),insideV:U("B4C6E7")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:U("4472C4")}}}},{id:"GridTable4-Accent1",name:"Grid Table 4 Accent 1",tableBorders:{top:U("4472C4"),bottom:U("4472C4"),left:U("4472C4"),right:U("4472C4"),insideH:U("4472C4"),insideV:U("4472C4")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#4472C4"},band1Horz:{backgroundColor:"#D6E4F0"}}},{id:"GridTable5Dark-Accent1",name:"Grid Table 5 Dark",tableBorders:{top:U("FFFFFF"),bottom:U("FFFFFF"),left:U("FFFFFF"),right:U("FFFFFF"),insideH:U("FFFFFF"),insideV:U("FFFFFF")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#4472C4"},band1Horz:{backgroundColor:"#D6E4F0"},band2Horz:{backgroundColor:"#B4C6E7"}}},{id:"ListTable3-Accent2",name:"List Table 3 Accent 2",tableBorders:{top:U("ED7D31"),bottom:U("ED7D31")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#ED7D31"},band1Horz:{backgroundColor:"#FBE4D5"}}},{id:"ListTable4-Accent3",name:"List Table 4 Accent 3",tableBorders:{top:U("A5A5A5"),bottom:U("A5A5A5"),insideH:U("A5A5A5")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#A5A5A5"},band1Horz:{backgroundColor:"#EDEDED"}}},{id:"GridTable4-Accent5",name:"Grid Table 4 Accent 5",tableBorders:{top:U("5B9BD5"),bottom:U("5B9BD5"),left:U("5B9BD5"),right:U("5B9BD5"),insideH:U("5B9BD5"),insideV:U("5B9BD5")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#5B9BD5"},band1Horz:{backgroundColor:"#DEEAF6"}}},{id:"GridTable4-Accent6",name:"Grid Table 4 Accent 6",tableBorders:{top:U("70AD47"),bottom:U("70AD47"),left:U("70AD47"),right:U("70AD47"),insideH:U("70AD47"),insideV:U("70AD47")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#70AD47"},band1Horz:{backgroundColor:"#E2EFDA"}}}];function Bi(e){return ap.find(t=>t.id===e)}function zi({getActiveEditorView:e,focusActiveEditor:t,tableSelection:o,borderSpecRef:r,historyStateRef:n,getCachedStyleResolver:u}){let[d,l]=zl.useState(false),[m,s]=zl.useState({isOpen:false,initialRows:1,initialCols:2,minRows:1,minCols:1,source:null,capturedCellRow:null,capturedCellCol:null}),a=zl.useCallback(()=>{let i=e(),p=i?commands.getSplitCellDialogConfig(i.state):null,g=p?null:o.getSplitCellConfig(),x=p??g;x&&s({isOpen:true,...x,source:p?"pm":"legacy",capturedCellRow:p?.capturedCellRow??null,capturedCellCol:p?.capturedCellCol??null});},[e,o]),b=zl.useCallback(i=>{let p=e();if(!p){i==="splitCell"?a():typeof i!="object"&&o.handleAction(i);return}switch(i){case "addRowAbove":prosemirror.addRowAbove(p.state,p.dispatch);break;case "addRowBelow":prosemirror.addRowBelow(p.state,p.dispatch);break;case "addColumnLeft":prosemirror.addColumnLeft(p.state,p.dispatch);break;case "addColumnRight":prosemirror.addColumnRight(p.state,p.dispatch);break;case "deleteRow":prosemirror.deleteRow(p.state,p.dispatch);break;case "deleteColumn":prosemirror.deleteColumn(p.state,p.dispatch);break;case "deleteTable":prosemirror.deleteTable(p.state,p.dispatch);break;case "selectTable":prosemirror.selectTable(p.state,p.dispatch);break;case "selectRow":prosemirror.selectRow(p.state,p.dispatch);break;case "selectColumn":prosemirror.selectColumn(p.state,p.dispatch);break;case "mergeCells":prosemirror.mergeCells(p.state,p.dispatch);break;case "splitCell":a();break;case "borderAll":prosemirror.setAllTableBorders(p.state,p.dispatch,r.current);break;case "borderOutside":prosemirror.setOutsideTableBorders(p.state,p.dispatch,r.current);break;case "borderInside":prosemirror.setInsideTableBorders(p.state,p.dispatch,r.current);break;case "borderNone":prosemirror.removeTableBorders(p.state,p.dispatch);break;case "borderTop":prosemirror.setCellBorder("top",r.current,true)(p.state,p.dispatch);break;case "borderBottom":prosemirror.setCellBorder("bottom",r.current,true)(p.state,p.dispatch);break;case "borderLeft":prosemirror.setCellBorder("left",r.current,true)(p.state,p.dispatch);break;case "borderRight":prosemirror.setCellBorder("right",r.current,true)(p.state,p.dispatch);break;default:if(typeof i=="object"){if(i.type==="cellFillColor")prosemirror.setCellFillColor(i.color)(p.state,p.dispatch);else if(i.type==="borderColor"){let g=i.color.replace(/^#/,"");r.current={...r.current,color:{rgb:g}},prosemirror.setTableBorderColor(i.color)(p.state,p.dispatch);}else if(i.type==="borderWidth")r.current={...r.current,size:i.size},prosemirror.setTableBorderWidth(i.size)(p.state,p.dispatch);else if(i.type==="cellBorder")prosemirror.setCellBorder(i.side,{style:i.style,size:i.size,color:{rgb:i.color.replace(/^#/,"")}})(p.state,p.dispatch);else if(i.type==="cellVerticalAlign")prosemirror.setCellVerticalAlign(i.align)(p.state,p.dispatch);else if(i.type==="cellMargins")prosemirror.setCellMargins(i.margins)(p.state,p.dispatch);else if(i.type==="cellTextDirection")prosemirror.setCellTextDirection(i.direction)(p.state,p.dispatch);else if(i.type==="toggleNoWrap")prosemirror.toggleNoWrap()(p.state,p.dispatch);else if(i.type==="rowHeight")prosemirror.setRowHeight(i.height,i.rule)(p.state,p.dispatch);else if(i.type==="toggleHeaderRow")prosemirror.toggleHeaderRow()(p.state,p.dispatch);else if(i.type==="distributeColumns")prosemirror.distributeColumns()(p.state,p.dispatch);else if(i.type==="autoFitContents")prosemirror.autoFitContents()(p.state,p.dispatch);else if(i.type==="openTableProperties")l(true);else if(i.type==="applyTableStyle"){let g=Bi(i.styleId),x=n.current;if(!g&&x?.package.styles){let c=u(x.package.styles).getStyle(i.styleId);if(c){if(g={id:c.styleId,name:c.name??c.styleId},c.tblPr?.borders){let S=c.tblPr.borders;g.tableBorders={};for(let v of ["top","bottom","left","right","insideH","insideV"]){let C=S[v];C&&(g.tableBorders[v]={style:C.style,size:C.size,color:C.color?.rgb?{rgb:C.color.rgb}:void 0});}}if(c.tblStylePr){g.conditionals={};for(let S of c.tblStylePr){let v={};if(S.tcPr?.shading?.fill&&(v.backgroundColor=`#${S.tcPr.shading.fill}`),S.tcPr?.borders){let C={};for(let R of ["top","bottom","left","right"]){let T=S.tcPr.borders[R];T&&(C[R]={style:T.style,size:T.size,color:T.color?.rgb?{rgb:T.color.rgb}:void 0});}v.borders=C;}S.rPr?.bold&&(v.bold=true),S.rPr?.color?.rgb&&(v.color=`#${S.rPr.color.rgb}`),g.conditionals[S.type]=v;}}g.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}g&&prosemirror.applyTableStyle({styleId:g.id,tableBorders:g.tableBorders,conditionals:g.conditionals,look:g.look})(p.state,p.dispatch);}}else o.handleAction(i);}t();},[o,e,t,a,r,n,u]),f=zl.useCallback(()=>{s(i=>({...i,isOpen:false,source:null,capturedCellRow:null,capturedCellCol:null}));},[]),h=zl.useCallback((i,p)=>{if(m.source==="legacy"){o.applySplitCell(i,p),t();return}let g=e();g&&(commands.splitActiveTableCell(g.state,g.dispatch,i,p,m.capturedCellRow??void 0,m.capturedCellCol??void 0),t());},[t,e,m.source,m.capturedCellRow,m.capturedCellCol,o]);return {tablePropsOpen:d,setTablePropsOpen:l,splitCellDialogState:m,openSplitCellDialog:a,handleTableAction:b,handleSplitCellDialogClose:f,handleSplitCellDialogApply:h}}function _i({document:e,pushDocument:t,hfEditorRef:o,containerRef:r,initialSectionProperties:n,finalSectionProperties:u,hfEditPosition:d,setHfEditPosition:l,hfEditIsFirstPage:m,setHfEditIsFirstPage:s}){let{headerContent:a,footerContent:b,firstPageHeaderContent:f,firstPageFooterContent:h}=zl.useMemo(()=>{let{header:c,footer:S,firstHeader:v,firstFooter:C}=layoutBridge.resolveHeaderFooter(e??null,u??n);return {headerContent:c,footerContent:S,firstPageHeaderContent:v,firstPageFooterContent:C}},[e,n,u]),i=zl.useCallback((c,S)=>{let C=e?.package?.document?.finalSectionProperties?.titlePg===true&&(S??1)===1,R=C?c==="header"?f:h:c==="header"?a:b;if(s(C),R){l(c);return}if(!e?.package)return;let T=e.package,k=T.document?.finalSectionProperties;if(!k)return;let E=C?"first":"default",I=`rId_new_${c}_${E}`,w={type:c==="header"?"header":"footer",hdrFtrType:E,content:[{type:"paragraph",content:[]}]},D=c==="header"?"headers":"footers",H=new Map(T[D]??[]);H.set(I,w);let O=c==="header"?"headerReferences":"footerReferences",B=k[O]??[],_={type:E,rId:I},W=T.relationships,Z=new Set;for(let me of W?.values()??[])me.target&&Z.add(me.target);let Y=1;for(;Z.has(`${c}${Y}.xml`);)Y++;let J=c==="header"?"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header":"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",te=new Map(W);te.set(I,{id:I,type:J,target:`${c}${Y}.xml`});let ne={...e,package:{...T,[D]:H,relationships:te,document:T.document?{...T.document,finalSectionProperties:{...k,[O]:[...B,_]}}:T.document}};t(ne),l(c);},[a,b,f,h,e,t,l,s]),p=zl.useCallback(c=>{if(!d||!e?.package){l(null);return}let S=e.package,v=S.document?.finalSectionProperties,C=d==="header"?v?.headerReferences:v?.footerReferences,R=m?"first":"default",T=C?.find(I=>I.type===R)??C?.find(I=>I.type==="default")??C?.find(I=>I.type==="first")??C?.[0],k=d==="header"?"headers":"footers",E=S[k];if(T?.rId&&E){let I=E.get(T.rId),w={type:d,hdrFtrType:T.type,...I,content:c},D=new Map(E);D.set(T.rId,w);let H={...e,package:{...S,[k]:D}};t(H);}l(null);},[d,m,e,t,l]),g=zl.useCallback(()=>{if(!d)return;let c=o.current?.getView();if(c){let S=conversion.proseDocToBlocks(c.state.doc);p(S);}else l(null);},[d,p,o,l]),x=zl.useCallback(()=>{if(!d||!e?.package){l(null);return}let c=e.package,S=c.document?.finalSectionProperties,v=d==="header"?"headerReferences":"footerReferences",C=d==="header"?"headers":"footers",R=S?.[v],T=m?"first":"default",k=R?.find(E=>E.type===T)??R?.find(E=>E.type==="default")??R?.find(E=>E.type==="first")??R?.[0];if(k?.rId){let E=new Map(c[C]??[]);E.delete(k.rId);let I=(R??[]).filter(D=>D.rId!==k.rId),w={...e,package:{...c,[C]:E,document:c.document?{...c.document,finalSectionProperties:{...S,[v]:I}}:c.document}};t(w);}l(null);},[d,m,e,t,l]),y=zl.useCallback(c=>{let S=r.current?.querySelector(".paged-editor__pages");if(!S)return null;let v=c==="header"?".layout-page-header":".layout-page-footer";return S.querySelector(v)},[r]);return {headerContent:a,footerContent:b,firstPageHeaderContent:f,firstPageFooterContent:h,handleHeaderFooterDoubleClick:i,handleHeaderFooterSave:p,handleBodyClick:g,handleRemoveHeaderFooter:x,getHfTargetElement:y}}function Vi({documentBuffer:e,initialDocument:t,externalContent:o,history:r,agentRef:n,pagedEditorRef:u,setLoadingState:d,setComments:l,setShowCommentsSidebar:m,onError:s,resetForNewDocument:a,commentsLoadedRef:b,commentIdAllocator:f}){let h=zl.useRef(0),i=zl.useCallback(g=>{a(),r.reset(g),d({isLoading:false,parseError:null}),utils.loadDocumentFonts(g).catch(x=>{console.warn("Failed to load document fonts:",x);});},[a,r,d]),p=zl.useCallback(async g=>{let x=++h.current;a(),d({isLoading:true,parseError:null});try{let y=await docx.parseDocx(g);if(h.current!==x)return;i(y);}catch(y){if(h.current!==x)return;let c=y instanceof Error?y.message:"Failed to parse document";d({isLoading:false,parseError:c}),s?.(y instanceof Error?y:new Error(c));}},[a,i,s,d]);return zl.useEffect(()=>{if(!o){if(!e){t&&i(t);return}p(e);}},[e,t,o]),zl.useEffect(()=>{r.state?n.current=new agent.DocumentAgent(r.state):n.current=null;},[r.state,n]),zl.useEffect(()=>{if(b.current)return;let g=r.state;if(!g)return;b.current=true;let x=g.package?.document?.comments;x&&x.length>0&&(l(x),m(true)),commentIdAllocator.seedCommentAllocator(f,x,u.current?.getView()??null);},[r.state,u,l,m,b,f]),{loadParsedDocument:i,loadBuffer:p}}var jp={inline:"wrap_text",squareLeft:"format_image_left",squareRight:"format_image_right",behind:"flip_to_back",inFront:"flip_to_front"},bo=18,Gi=({isOpen:e,position:t,currentWrapType:o,currentCssFloat:r,onApplyLayout:n,textActions:u,onTextAction:d,onOpenProperties:l,onClose:m})=>{let{t:s}=chunkGNIO6SOS_js.b(),a=zl.useRef(null),[b,f]=zl.useState(0),h=zl.useMemo(()=>layoutPainter.deriveLayoutChoice(o,r),[o,r]),i=zl.useMemo(()=>layoutPainter.IMAGE_LAYOUT_OPTIONS.filter(c=>layoutPainter.isImageLayoutOptionEnabled(c,o)),[o]),p=zl.useMemo(()=>(u??[]).filter(c=>!c.disabled),[u]),g=l?1:0,x=g+i.length+p.length;zl.useEffect(()=>{if(!e)return;let c=v=>{a.current&&!a.current.contains(v.target)&&m();},S=setTimeout(()=>{document.addEventListener("mousedown",c);},0);return ()=>{clearTimeout(S),document.removeEventListener("mousedown",c);}},[e,m]),zl.useEffect(()=>{if(!e)return;let c=S=>{if(S.key==="Escape"){S.preventDefault(),m();return}let v=Math.max(1,x);if(S.key==="ArrowDown")S.preventDefault(),f(C=>(C+1)%v);else if(S.key==="ArrowUp")S.preventDefault(),f(C=>(C-1+v)%v);else if(S.key==="Enter"){if(S.preventDefault(),g&&b===0)l?.(),m();else if(b<g+i.length)n(i[b-g].choice),m();else if(d){let C=p[b-g-i.length];C&&(d(C.action),m());}}};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,b,i,p,x,g,n,l,d,m]),zl.useEffect(()=>{if(!e)return;let c=h?i.findIndex(S=>S.choice===h):-1;f(c>=0?g+c:0);},[e,h,i,g]);let y=zl.useCallback(()=>{let S=layoutPainter.IMAGE_LAYOUT_OPTIONS.length,v=u?.length??0,C=S*36+v*32+(v>0?9:0)+16,R=t.x,T=t.y;return typeof window<"u"&&(R+260>window.innerWidth&&(R=window.innerWidth-260-10),T+C>window.innerHeight&&(T=window.innerHeight-C-10),R<10&&(R=10),T<10&&(T=10)),{position:"fixed",top:T,left:R,minWidth:260,background:"var(--doc-surface)",border:"1px solid var(--doc-border-light)",borderRadius:"8px",boxShadow:"0 2px 10px var(--doc-shadow)",zIndex:chunkGDJM7SOG_js.h.contextMenu,padding:"4px 0",overflow:"hidden"}},[t,u]);return e?jsxRuntime.jsxs("div",{ref:a,className:"docx-image-context-menu",style:y(),role:"menu","aria-label":s("imageWrap.menu.ariaLabel"),"data-testid":"image-context-menu",children:[l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",role:"menuitem","data-action":"open-properties",onClick:()=>{l(),m();},onMouseEnter:()=>f(0),style:{display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",border:"none",background:b===0?"var(--doc-primary-light)":"transparent",cursor:"pointer",fontSize:"13px",color:"var(--doc-text)",textAlign:"left"},children:[jsxRuntime.jsx("span",{style:{display:"flex",color:"var(--doc-text-muted)",width:bo},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"settings",size:bo})}),jsxRuntime.jsx("span",{style:{flex:1},children:s("imageWrap.menu.imageProperties")})]}),jsxRuntime.jsx("div",{style:{height:1,background:"var(--doc-border-light)",margin:"4px 0"},role:"separator"})]}),layoutPainter.IMAGE_LAYOUT_OPTIONS.map(c=>{let S=c.choice===h,v=layoutPainter.isImageLayoutOptionEnabled(c,o),C=v?g+i.findIndex(k=>k.choice===c.choice):-1,R=C>=0&&C===b,T=s(`imageWrap.menuDesc.${c.i18nDescKey}`);return jsxRuntime.jsxs("button",{type:"button",role:"menuitem","data-wrap-type":c.choice,"data-current":S?"true":"false","data-disabled":v?"false":"true",disabled:!v,onClick:()=>{v&&(n(c.choice),m());},onMouseEnter:()=>{C>=0&&f(C);},title:T,style:{display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",border:"none",background:R?"var(--doc-primary-light)":"transparent",cursor:v?"pointer":"not-allowed",fontSize:"13px",color:v?"var(--doc-text)":"var(--doc-text-placeholder)",textAlign:"left",opacity:v?1:.55},children:[jsxRuntime.jsx("span",{style:{display:"flex",color:S?"var(--doc-primary)":"var(--doc-text-muted)",width:bo},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:jp[c.iconHint],size:bo})}),jsxRuntime.jsx("span",{style:{flex:1},children:s(`imageWrap.menu.${c.i18nLabelKey}`)}),S&&jsxRuntime.jsx("span",{style:{fontSize:"11px",color:"var(--doc-primary)"},"aria-label":s("toolbar.imageWrap.current"),children:"\u25CF"})]},c.choice)}),u&&u.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{height:1,background:"var(--doc-border-light)",margin:"4px 0"},role:"separator"}),u.map((c,S)=>{let v=c.disabled?-1:g+i.length+p.findIndex(R=>R.action===c.action),C=v===b&&!c.disabled;return jsxRuntime.jsxs(zl__default.default.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",role:"menuitem","data-action":c.action,"data-disabled":c.disabled?"true":"false",disabled:c.disabled,onClick:()=>{c.disabled||!d||(d(c.action),m());},onMouseEnter:()=>{v>=0&&f(v);},style:{display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"7px 12px",border:"none",background:C?"var(--doc-primary-light)":"transparent",cursor:c.disabled?"not-allowed":"pointer",fontSize:"13px",color:c.disabled?"var(--doc-text-placeholder)":"var(--doc-text)",textAlign:"left",opacity:c.disabled?.55:1},children:[jsxRuntime.jsx("span",{style:{width:bo},"aria-hidden":"true"}),jsxRuntime.jsx("span",{style:{flex:1},children:c.label}),c.shortcut&&jsxRuntime.jsx("span",{style:{fontSize:"11px",color:"var(--doc-text-muted)",fontFamily:"monospace"},children:c.shortcut})]}),c.dividerAfter&&jsxRuntime.jsx("div",{style:{height:1,background:"var(--doc-border-light)",margin:"4px 0"},role:"separator"})]},`${c.action}-${S}`)})]})]}):null};function Ki(){let[e,t]=zl.useState(false),[o,r]=zl.useState({x:0,y:0}),[n,u]=zl.useState("inline"),[d,l]=zl.useState(null),[m,s]=zl.useState(null),[a,b]=zl.useState(null),f=zl.useCallback(i=>{r({x:i.x,y:i.y}),u(i.wrapType),l(i.cssFloat??null),s(i.pos),b(i.inlinePositionEmu??null),t(true);},[]),h=zl.useCallback(()=>{t(false),s(null),b(null);},[]);return {isOpen:e,position:o,currentWrapType:n,currentCssFloat:d,imagePos:m,inlinePositionEmu:a,openForImage:f,closeMenu:h}}function Jo(e,t,o){if(!e||!t)return null;let r=e.querySelector(".paged-editor__pages");if(!r)return null;for(let n of layoutBridge.findBodyPmAnchors(r)){let u=Number(n.dataset.pmStart),d=Number(n.dataset.pmEnd);if(o>=u&&o<=d)return n.getBoundingClientRect().top-t.getBoundingClientRect().top}return null}function ji(e){let t=e?.package?.document;return t?.sections?.[0]?.properties??t?.finalSectionProperties}function Qi({getActiveEditorView:e,focusActiveEditor:t,openSplitCellDialog:o,scrollContainerRef:r,editorContentRef:n,i18n:u,onAddComment:d}){let{t:l}=chunkGNIO6SOS_js.b(),[m,s]=zl.useState({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false,tableContext:null}),a=Ki(),b=zl.useCallback(y=>{let c=y.target;if(c?.closest(".paged-editor__pages")&&!c.closest(".hf-inline-editor"))return;y.preventDefault(),y.stopPropagation();let S=e(),v=S?prosemirror.getTableContext(S.state):{isInTable:false},{from:C,to:R}=S?.state.selection??{from:0,to:0},T=C!==R;s({isOpen:true,position:{x:y.clientX,y:y.clientY},hasSelection:T,cursorInTable:v.isInTable,tableContext:v.isInTable?v:null});},[e]),f=zl.useCallback(y=>{if(y.image){a.openForImage({x:y.x,y:y.y,wrapType:y.image.wrapType,cssFloat:y.image.cssFloat,pos:y.image.pos,inlinePositionEmu:y.image.inlinePositionEmu});return}let c=e(),S=c?prosemirror.getTableContext(c.state):{isInTable:false};s({isOpen:true,position:y,hasSelection:y.hasSelection,cursorInTable:S.isInTable,tableContext:S.isInTable?S:null});},[e,a]),h=zl.useCallback(y=>{let c=e();if(!c||a.imagePos===null)return;let S=a.inlinePositionEmu?{initialPositionEmu:a.inlinePositionEmu}:void 0;commands.setImageWrapType(a.imagePos,y,S)(c.state,c.dispatch);},[e,a.imagePos,a.inlinePositionEmu]),i=zl.useMemo(()=>[{action:"cut",label:l("contextMenu.cut"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.cutShortcut"))},{action:"copy",label:l("contextMenu.copy"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.copyShortcut"))},{action:"paste",label:l("contextMenu.paste"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.pasteShortcut")),dividerAfter:true},{action:"delete",label:l("contextMenu.delete"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.deleteShortcut"))}],[l]),p=zl.useCallback(()=>{s({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false,tableContext:null});},[]),g=zl.useMemo(()=>{let y=[{action:"cut",label:l("contextMenu.cut"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.cutShortcut"))},{action:"copy",label:l("contextMenu.copy"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.copyShortcut"))},{action:"paste",label:l("contextMenu.paste"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.pasteShortcut"))},{action:"pasteAsPlainText",label:l("contextMenu.pastePlainText"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.pastePlainTextShortcut")),dividerAfter:true},{action:"delete",label:l("contextMenu.delete"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.deleteShortcut")),dividerAfter:!m.hasSelection&&!m.cursorInTable}];return m.hasSelection&&y.push({action:"addComment",label:"Comment",dividerAfter:!m.cursorInTable}),m.cursorInTable&&y.push({action:"addRowAbove",label:"Insert row above"},{action:"addRowBelow",label:"Insert row below"},{action:"deleteRow",label:"Delete row",dividerAfter:true},{action:"addColumnLeft",label:"Insert column left"},{action:"addColumnRight",label:"Insert column right"},{action:"deleteColumn",label:"Delete column"},{action:"mergeCells",label:u?.table?.mergeCells??docxEditorI18n.en.table.mergeCells,disabled:!m.tableContext?.hasMultiCellSelection},{action:"splitCell",label:u?.table?.splitCell??docxEditorI18n.en.table.splitCell,disabled:!m.tableContext?.canSplitCell,dividerAfter:true}),y.push({action:"selectAll",label:l("contextMenu.selectAll"),shortcut:chunkPSBO3UDN_js.a(l("contextMenu.selectAllShortcut"))}),y},[m.hasSelection,m.cursorInTable,m.tableContext,u,l]),x=zl.useCallback(async y=>{let c=e();if(c)switch(t(),y){case "cut":document.execCommand("cut");break;case "copy":document.execCommand("copy");break;case "paste":{try{let S=await navigator.clipboard.read(),v="",C="";for(let k of S)k.types.includes("text/html")&&(v=await(await k.getType("text/html")).text()),k.types.includes("text/plain")&&(C=await(await k.getType("text/plain")).text());let R=new DataTransfer;v&&R.items.add(v,"text/html"),C&&R.items.add(C,"text/plain");let T=new ClipboardEvent("paste",{clipboardData:R,bubbles:!0,cancelable:!0});c.dom.dispatchEvent(T);}catch{try{let S=await navigator.clipboard.readText();S&&c.dispatch(c.state.tr.insertText(S));}catch{}}break}case "pasteAsPlainText":try{let S=await navigator.clipboard.readText();S&&c.dispatch(c.state.tr.insertText(S));}catch{}break;case "delete":{let{from:S,to:v}=c.state.selection;S!==v&&c.dispatch(c.state.tr.deleteRange(S,v));break}case "selectAll":c.dispatch(c.state.tr.setSelection(prosemirrorState.TextSelection.create(c.state.doc,0,c.state.doc.content.size)));break;case "addRowAbove":prosemirror.addRowAbove(c.state,c.dispatch);break;case "addRowBelow":prosemirror.addRowBelow(c.state,c.dispatch);break;case "deleteRow":prosemirror.deleteRow(c.state,c.dispatch);break;case "addColumnLeft":prosemirror.addColumnLeft(c.state,c.dispatch);break;case "addColumnRight":prosemirror.addColumnRight(c.state,c.dispatch);break;case "deleteColumn":prosemirror.deleteColumn(c.state,c.dispatch);break;case "mergeCells":prosemirror.mergeCells(c.state,c.dispatch);break;case "splitCell":o();break;case "addComment":{let{from:S,to:v}=c.state.selection;if(S===v)break;let C=Jo(r.current,n.current,S),R=c.state.schema.marks.comment.create({commentId:commentIdAllocator.PENDING_COMMENT_ID}),T=c.state.tr.addMark(S,v,R);T.setSelection(prosemirrorState.TextSelection.create(T.doc,v)),c.dispatch(T),d({from:S,to:v,yPos:C});break}}},[e,t,o,r,n,d]);return {contextMenu:m,imageContextMenu:a,handleEditorContextMenu:b,handleContextMenu:f,handleContextMenuClose:p,handleImageWrapApply:h,imageContextMenuTextActions:i,contextMenuItems:g,handleContextMenuAction:x}}function ea({commentsProp:e,onCommentDelete:t,onCommentsChange:o,pagedEditorRef:r}){let[n,u]=zl.useState([]),d=e!==void 0,l=d?e:n,[m,s]=zl.useState(false),[a,b]=zl.useState(null),[f,h]=zl.useState(null),[i,p]=zl.useState(null),g=zl.useRef(null),x=zl.useRef(l);x.current=l;let y=zl.useRef(m);y.current=m;let c=zl.useRef(t);c.current=t;let S=zl.useRef(o);S.current=o;let v=zl.useCallback(R=>{let T=typeof R=="function"?R(x.current):R;T!==x.current&&(d||(x.current=T,u(T)),S.current?.(T));},[d]),C=zl.useCallback(()=>{if(y.current)return;let R=r.current?.getView();if(!R)return;let{doc:T,schema:k}=R.state,E=k.marks.comment;if(!E)return;let I=new Set;T.descendants(H=>{for(let O of H.marks)if(O.type===E){let B=O.attrs.commentId;B!==commentIdAllocator.PENDING_COMMENT_ID&&I.add(B);}});let w=x.current,D=new Set;for(let H of w)H.parentId==null&&!I.has(H.id)&&D.add(H.id);if(D.size!==0){for(let H of w)D.has(H.id)&&c.current?.(H);v(H=>H.filter(O=>!D.has(O.id)&&!D.has(O.parentId)));}},[r,v]);return zl.useEffect(()=>()=>{g.current&&clearTimeout(g.current);},[]),{comments:l,setComments:v,isAddingComment:m,setIsAddingComment:s,isAddingCommentRef:y,commentSelectionRange:a,setCommentSelectionRange:b,addCommentYPosition:f,setAddCommentYPosition:h,floatingCommentBtn:i,setFloatingCommentBtn:p,cleanOrphanedCommentsTimerRef:g,cleanOrphanedComments:C}}function oa({commentToRevision:e,setComments:t,pmState:o,isLoading:r,trackedChangesCount:n,setShowCommentsSidebar:u,trackedChangesLoadedRef:d}){zl.useEffect(()=>{e.size!==0&&t(l=>{let m=false,s=l.map(a=>{if(a.parentId!=null)return a;let b=e.get(a.id);return b!=null?(m=true,{...a,parentId:b}):a});return m?s:l});},[e,t]),zl.useEffect(()=>{d.current||r||!o||(d.current=true,n>0&&u(true));},[o,r,n,u,d]);}function ra({getActiveEditorView:e,lastSelectionRef:t,borderSpecRef:o,theme:r,historyStateRef:n,getCachedStyleResolver:u,setFloatingCommentBtn:d,applySelectionDelta:l,recomputeFloatingCommentBtn:m,onSelectionChange:s,selectionChangeSubscribersRef:a}){return {handleSelectionChange:zl.useCallback(f=>{let h=e();if(h){let{from:k,to:E}=h.state.selection;t.current={from:k,to:E};}let i=null;if(h&&(i=prosemirror.getTableContext(h.state),i.isInTable||(i=null)),i?.cellBorderColor){let k=utils.resolveColorToHex(i.cellBorderColor,r??void 0);k&&(o.current={...o.current,color:{rgb:k}});}let p=null;if(h){let k=h.state.selection,E=k.node;E?.type.name==="image"&&(p={pos:k.from,wrapType:E.attrs.wrapType??"inline",displayMode:E.attrs.displayMode??"inline",cssFloat:E.attrs.cssFloat??null,transform:E.attrs.transform??null,alt:E.attrs.alt??null,borderWidth:E.attrs.borderWidth??null,borderColor:E.attrs.borderColor??null,borderStyle:E.attrs.borderStyle??null,width:E.attrs.width??null,height:E.attrs.height??null});}if(!f){d(null),l({selectionFormatting:{},pmTableContext:i,pmImageContext:p});return}let{textFormatting:g,paragraphFormatting:x}=f,y=g.fontFamily?.ascii||g.fontFamily?.hAnsi,c=g.fontSize;if(!y||!c){let k=n.current,E=f.styleId;if(k?.package.styles&&E){let w=u(k.package.styles).resolveParagraphStyle(E);!y&&w.runFormatting?.fontFamily&&(y=w.runFormatting.fontFamily.ascii||w.runFormatting.fontFamily.hAnsi),!c&&w.runFormatting?.fontSize&&(c=w.runFormatting.fontSize);}}let S=utils.resolveColorToHex(g.color,r??void 0),v=S?`#${S}`:void 0,C=x.numPr,R=C?{type:C.numId===1?"bullet":"numbered",level:C.ilvl??0,isInList:true,numId:C.numId}:void 0,T={bold:g.bold,italic:g.italic,underline:!!g.underline,strike:g.strike,superscript:g.vertAlign==="superscript",subscript:g.vertAlign==="subscript",fontFamily:y,fontSize:c,color:v,highlight:g.highlight,alignment:x.alignment,lineSpacing:x.lineSpacing,listState:R,styleId:f.styleId??void 0,indentLeft:x.indentLeft,bidi:!!x.bidi};l({selectionFormatting:T,paragraphIndentLeft:x.indentLeft??0,paragraphIndentRight:x.indentRight??0,paragraphFirstLineIndent:x.indentFirstLine??0,paragraphHangingIndent:x.hangingIndent??false,paragraphTabs:x.tabs??null,pmTableContext:i,pmImageContext:p}),m(),s?.(f);for(let k of a.current)try{k(f);}catch(E){console.error("selectionChange subscriber threw:",E);}},[e,t,o,r,n,u,d,l,m,s,a])}}function aa({pagedEditorRef:e,scrollContainerRef:t,editorContentRef:o,isAddingCommentRef:r,setFloatingCommentBtn:n,readOnly:u,isLoading:d,zoom:l}){let m=zl.useRef(false);m.current=u;let s=zl.useCallback(()=>{let a=e.current?.getView();if(!a)return;if(r.current||m.current){n(null);return}let{from:b,to:f}=a.state.selection;if(b===f){n(null);return}let h=t.current,i=o.current;if(!h||!i)return;let p=Jo(h,i,b);if(p==null)return;let x=h.querySelector(".paged-editor__pages")?.querySelector(".layout-page"),y=x?x.getBoundingClientRect().right-i.getBoundingClientRect().left:i.getBoundingClientRect().width/2+408;n({top:p,left:y});},[e,t,o,r,n]);return zl.useEffect(()=>{let a=t.current;if(!a)return;let b=new ResizeObserver(()=>s());b.observe(a);let f=()=>s();return window.addEventListener("resize",f),()=>{b.disconnect(),window.removeEventListener("resize",f);}},[d,s,t]),zl.useEffect(()=>{s();},[l,s]),{recomputeFloatingCommentBtn:s}}function sa({hfEditPosition:e,hfEditorRef:t,pagedEditorRef:o}){let r=zl.useCallback(()=>e&&t.current?t.current.getView():o.current?.getView(),[e,t,o]),n=zl.useCallback(()=>{e&&t.current?t.current.focus():o.current?.focus();},[e,t,o]),u=zl.useCallback(()=>{e&&t.current?t.current.undo():o.current?.undo();},[e,t,o]),d=zl.useCallback(()=>{e&&t.current?t.current.redo():o.current?.redo();},[e,t,o]);return {getActiveEditorView:r,focusActiveEditor:n,undoActiveEditor:u,redoActiveEditor:d}}function la({scrollContainerRef:e,pagedEditorRef:t}){let[o,r]=zl.useState({currentPage:1,totalPages:1,visible:false}),n=zl.useRef(null),u=e.current;return zl.useEffect(()=>{if(!u)return;let d=()=>{let l=t.current?.getLayout();if(!l||l.pages.length===0)return;let m=u.scrollTop,s=l.pages.length,a=24,b=24,f=m+u.clientHeight/2,h=b,i=1;for(let p=0;p<l.pages.length;p++){let g=l.pages[p].size.h,x=h+g;if(f<x){i=p+1;break}h=x+a,i=p+2;}i=Math.min(i,s),r({currentPage:i,totalPages:s,visible:true}),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{r(p=>({...p,visible:false}));},600);};return u.addEventListener("scroll",d,{passive:true}),()=>{u.removeEventListener("scroll",d),n.current&&clearTimeout(n.current);}},[u,t]),{scrollPageInfo:o,setScrollPageInfo:r}}function ca({contextMenu:e,contextMenuItems:t,onContextMenuAction:o,onContextMenuClose:r,imageContextMenu:n,onImageWrapApply:u,imageContextMenuTextActions:d,onOpenImageProperties:l,readOnly:m}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(chunkGDJM7SOG_js.i,{isOpen:e.isOpen,position:e.position,hasSelection:e.hasSelection,isEditable:!m,items:t,onAction:o,onClose:r}),jsxRuntime.jsx(Gi,{isOpen:n.isOpen,position:n.position,currentWrapType:n.currentWrapType,currentCssFloat:n.currentCssFloat,onApplyLayout:u,textActions:d,onTextAction:o,onOpenProperties:l,onClose:n.closeMenu}),jsxRuntime.jsx(sonner.Toaster,{position:"bottom-right"})]})}var hm=zl.lazy(()=>import('./FindReplaceDialog-HM63BMXE.js')),ym=zl.lazy(()=>import('./HyperlinkDialog-7MEQJIYP.js')),vm=zl.lazy(()=>import('./TablePropertiesDialog-VCDCPM3R.js').then(e=>({default:e.TablePropertiesDialog}))),Cm=zl.lazy(()=>import('./SplitCellDialog-45W7SDPY.js')),Sm=zl.lazy(()=>import('./ImagePositionDialog-LSCCQORZ.js').then(e=>({default:e.ImagePositionDialog}))),xm=zl.lazy(()=>import('./ImagePropertiesDialog-Z4M6XKFG.js').then(e=>({default:e.ImagePropertiesDialog}))),Rm=zl.lazy(()=>import('./FootnotePropertiesDialog-TV2BGQDC.js').then(e=>({default:e.FootnotePropertiesDialog}))),Pm=zl.lazy(()=>import('./PageSetupDialog-LWYOYKEU.js').then(e=>({default:e.PageSetupDialog}))),Tm=zl.lazy(()=>import('./WatermarkDialog-XGLAH3TK.js').then(e=>({default:e.WatermarkDialog})));function da({findReplace:e,findResultRef:t,onFind:o,onFindNext:r,onFindPrevious:n,onReplace:u,onReplaceAll:d,hyperlinkDialog:l,onHyperlinkSubmit:m,onHyperlinkRemove:s,tablePropsOpen:a,onTablePropsClose:b,pmTableContext:f,getActiveEditorView:h,splitCellDialogState:i,onSplitCellDialogClose:p,onSplitCellDialogApply:g,imagePositionOpen:x,onImagePositionClose:y,onApplyImagePosition:c,imagePropsOpen:S,onImagePropsClose:v,onApplyImageProperties:C,pmImageContext:R,showPageSetup:T,onPageSetupClose:k,onPageSetupApply:E,showWatermark:I,onWatermarkClose:w,onWatermarkApply:D,currentWatermark:H,watermarkPresets:O,document:B,footnotePropsOpen:_,onFootnotePropsClose:W,onApplyFootnoteProperties:Z}){return jsxRuntime.jsxs(zl.Suspense,{fallback:null,children:[e.state.isOpen&&jsxRuntime.jsx(hm,{isOpen:e.state.isOpen,onClose:e.close,onFind:o,onFindNext:r,onFindPrevious:n,onReplace:u,onReplaceAll:d,initialSearchText:e.state.searchText,replaceMode:e.state.replaceMode,currentResult:t.current}),l.state.isOpen&&jsxRuntime.jsx(ym,{isOpen:l.state.isOpen,onClose:l.close,onSubmit:m,onRemove:l.state.isEditing?s:void 0,initialData:l.state.initialData,selectedText:l.state.selectedText,isEditing:l.state.isEditing}),a&&jsxRuntime.jsx(vm,{isOpen:a,onClose:b,onApply:Y=>{let J=h();J&&commands.setTableProperties(Y)(J.state,J.dispatch);},currentProps:f?.table?.attrs}),i.isOpen&&jsxRuntime.jsx(Cm,{isOpen:i.isOpen,onClose:p,onApply:g,initialRows:i.initialRows,initialCols:i.initialCols,minRows:i.minRows,minCols:i.minCols}),x&&jsxRuntime.jsx(Sm,{isOpen:x,onClose:y,onApply:c}),S&&jsxRuntime.jsx(xm,{isOpen:S,onClose:v,onApply:C,currentData:R?{alt:R.alt??void 0,borderWidth:R.borderWidth??void 0,borderColor:R.borderColor??void 0,borderStyle:R.borderStyle??void 0,width:R.width??void 0,height:R.height??void 0}:void 0}),T&&jsxRuntime.jsx(Pm,{isOpen:T,onClose:k,onApply:E,currentProps:B?.package.document?.finalSectionProperties}),I&&jsxRuntime.jsx(Tm,{isOpen:I,onClose:w,onApply:D,current:H,presets:O}),_&&jsxRuntime.jsx(Rm,{isOpen:_,onClose:W,onApply:Z,footnotePr:B?.package.document?.finalSectionProperties?.footnotePr,endnotePr:B?.package.document?.finalSectionProperties?.endnotePr})]})}function pa({active:e,onClick:t}){let{t:o}=chunkGNIO6SOS_js.b(),r=o("editor.toggleCommentsSidebar");return jsxRuntime.jsx(chunkGDJM7SOG_js.A,{onClick:t,active:e,title:r,ariaLabel:r,children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"comment",size:20})})}var lr=[{value:"editing",labelKey:"editor.editing",icon:"edit_note",descKey:"editor.editingDescription"},{value:"suggesting",labelKey:"editor.suggesting",icon:"rate_review",descKey:"editor.suggestingDescription"},{value:"viewing",labelKey:"editor.viewing",icon:"visibility",descKey:"editor.viewingDescription"}];function fa({mode:e,onModeChange:t}){let{t:o}=chunkGNIO6SOS_js.b(),[r,n]=zl.useState(false),[u,d]=zl.useState(false),l=zl.useRef(null),m=zl.useRef(null),[s,a]=zl.useState({top:0,left:0}),b=lr.find(f=>f.value===e);return zl.useEffect(()=>{let f=window.matchMedia("(max-width: 1400px)");d(f.matches);let h=i=>d(i.matches);return f.addEventListener("change",h),()=>f.removeEventListener("change",h)},[]),zl.useEffect(()=>{if(!r||!l.current)return;let f=l.current.getBoundingClientRect();a({top:f.bottom+2,left:f.right-220});},[r]),zl.useEffect(()=>{if(!r)return;let f=i=>{!l.current?.contains(i.target)&&!m.current?.contains(i.target)&&n(false);},h=i=>{i.key==="Escape"&&n(false);};return document.addEventListener("mousedown",f),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",h);}},[r]),jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{ref:l,type:"button",onMouseDown:f=>f.preventDefault(),onClick:()=>n(!r),title:`${o(b.labelKey)} (Ctrl+Shift+E)`,style:{display:"flex",alignItems:"center",gap:u?0:4,padding:u?"2px 4px":"2px 6px 2px 4px",border:"none",background:r?"var(--doc-bg-hover)":"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text)",whiteSpace:"nowrap",height:28},children:[jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:b.icon,size:18}),!u&&jsxRuntime.jsx("span",{children:o(b.labelKey)}),jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"arrow_drop_down",size:16})]}),r&&jsxRuntime.jsx("div",{ref:m,onMouseDown:f=>f.preventDefault(),style:{position:"fixed",top:s.top,left:s.left,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 12px var(--doc-shadow)",padding:"4px 0",zIndex:1e4,minWidth:220},children:lr.map(f=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:h=>h.preventDefault(),onClick:()=>{t(f.value),n(false);},onMouseOver:h=>{h.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:h=>{h.currentTarget.style.backgroundColor="transparent";},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left"},children:[jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:f.icon,size:20}),jsxRuntime.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[jsxRuntime.jsx("span",{style:{fontWeight:500},children:o(f.labelKey)}),jsxRuntime.jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted)"},children:o(f.descKey)})]}),f.value===e&&jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"check",size:18,style:{marginLeft:"auto",color:"var(--doc-primary)"}})]},f.value))})]})}function ga({active:e,onClick:t,badge:o}){let{t:r}=chunkGNIO6SOS_js.b(),n=r("agentPanel.toggle");return jsxRuntime.jsx(chunkGDJM7SOG_js.A,{onClick:t,active:e,title:n,ariaLabel:n,children:jsxRuntime.jsxs("span",{style:{position:"relative",display:"inline-flex"},children:[jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"agent-sparkle",size:20}),o!=null&&jsxRuntime.jsx("span",{"data-testid":"agent-panel-toggle-badge",style:{position:"absolute",top:-4,right:-6,display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:14,height:14,padding:"0 3px",borderRadius:7,fontSize:10,fontWeight:600,background:"var(--doc-error)",color:"var(--doc-on-primary)",lineHeight:1},children:o})]})})}function ba({toolbarRefCallback:e,agentPanelOpen:t,setAgentPanelOpen:o,document:r,theme:n,pmState:u,selectionFormatting:d,tableContext:l,imageContext:m,readOnly:s,editingMode:a,setEditingMode:b,setShowCommentsSidebar:f,setExpandedSidebarItem:h,showCommentsSidebar:i,agentPanel:p,renderLogo:g,documentName:x,onDocumentNameChange:y,documentNameEditable:c,renderTitleBarRight:S,toolbarExtra:v,fontFamilies:C,zoom:R,showZoomControl:T,onFormat:k,onUndo:E,onRedo:I,onPrint:w,onOpen:D,onSave:H,onZoomChange:O,onRefocusEditor:B,onInsertTable:_,onInsertImage:W,onInsertPageBreak:Z,onInsertSectionBreakNextPage:Y,onInsertSectionBreakContinuous:J,onInsertTOC:te,onImageWrapType:ne,onImageTransform:me,onOpenImageProperties:ke,onPageSetup:Ce,onWatermark:M,onTableAction:F}){return jsxRuntime.jsx("div",{ref:e,className:"z-50 flex flex-col gap-0 flex-shrink-0",children:jsxRuntime.jsxs(chunkGDJM7SOG_js.E,{className:t?"rounded-br-2xl":void 0,style:{transition:"border-radius 220ms cubic-bezier(0.4, 0, 0.2, 1)"},currentFormatting:d,onFormat:k,onUndo:E,onRedo:I,canUndo:u?prosemirrorHistory.undoDepth(u)>0:false,canRedo:u?prosemirrorHistory.redoDepth(u)>0:false,disabled:s,documentStyles:r?.package.styles?.styles,theme:r?.package.theme||n,fontFamilies:C,onPrint:w,onOpen:D,onSave:H,showZoomControl:T,zoom:R,onZoomChange:O,onRefocusEditor:B,onInsertTable:_,showTableInsert:true,onInsertImage:W,onInsertPageBreak:Z,onInsertSectionBreakNextPage:Y,onInsertSectionBreakContinuous:J,onInsertTOC:te,imageContext:m,onImageWrapType:ne,onImageTransform:me,onOpenImageProperties:ke,onPageSetup:Ce,onWatermark:M,tableContext:l,onTableAction:F,children:[jsxRuntime.jsxs(chunkGDJM7SOG_js.E.TitleBar,{children:[g&&jsxRuntime.jsx(chunkGDJM7SOG_js.E.Logo,{children:g()}),x!==void 0&&jsxRuntime.jsx(chunkGDJM7SOG_js.E.DocumentName,{value:x,onChange:y,editable:c}),S&&jsxRuntime.jsx(chunkGDJM7SOG_js.E.TitleBarRight,{children:S()}),jsxRuntime.jsx(chunkGDJM7SOG_js.E.MenuBar,{})]}),jsxRuntime.jsxs(chunkGDJM7SOG_js.E.Toolbar,{children:[jsxRuntime.jsx(chunkGDJM7SOG_js.C,{}),jsxRuntime.jsx(pa,{active:i,onClick:()=>{f(A=>!A),h(null);}}),jsxRuntime.jsx(chunkGDJM7SOG_js.C,{}),jsxRuntime.jsx(fa,{mode:a,onModeChange:A=>{b(A),A==="suggesting"&&f(true);}}),p&&p.showToolbarButton!==false&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(chunkGDJM7SOG_js.C,{}),jsxRuntime.jsx(ga,{active:t,badge:p.toolbarBadge,onClick:()=>o(!t)})]}),v]})]})})}function ha(e,t,o){let r=e.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!r)return null;let n=r.getBoundingClientRect(),u=layoutBridge.getCaretPositionFromDom(e,t,n);return u?{x:u.x/o,y:u.y/o,height:u.height,pageIndex:u.pageIndex}:null}function ya(e,t,o,r,n){return layoutBridge.getSelectionRectsFromDom(e,o,r,t).map(d=>({x:d.x/n,y:d.y/n,width:d.width/n,height:d.height/n,pageIndex:d.pageIndex}))}var qm={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function xa(e,t,o,r=[]){let n=o?.getSchema()??prosemirror.schema,u=t??e?.package?.styles,d=e?conversion.toProseDoc(e,{styles:u}):conversion.createEmptyDoc(),l=prosemirror.createDocumentStylesPlugin(u),m=[...r,...o?.getPlugins()??[],l];return prosemirror.ensureParaIdsInState(prosemirrorState.EditorState.create({doc:d,schema:n,plugins:m}))}function Xm(e,t){return t?conversion.fromProseDoc(e.doc,t):null}var Zm=zl.forwardRef(function(t,o){let{document:r,styles:n,theme:u,widthPx:d=612,readOnly:l=false,onTransaction:m,onSelectionChange:s,externalPlugins:a=[],extensionManager:b,onEditorViewReady:f,onEditorViewDestroy:h,onKeyDown:i}=t,p=zl.useRef(null),g=zl.useRef(null),x=zl.useRef(r),y=zl.useRef(false),c=zl.useRef(null),S=zl.useRef(false),v=zl.useRef(m),C=zl.useRef(s),R=zl.useRef(f),T=zl.useRef(h),k=zl.useRef(i),E=zl.useRef(l);v.current=m,C.current=s,R.current=f,T.current=h,k.current=i,E.current=l,x.current=r;let I=_=>{if(!_)return "empty";let W=_.package?.properties;return `${W?.created||""}-${W?.modified||""}-${W?.title||""}`},w=zl.useCallback(()=>{if(!p.current||y.current)return;let W={state:xa(r,n,b,a),editable:()=>!E.current,attributes:{style:"overflow-anchor: none"},dispatchTransaction(Y){if(y.current)return;g.current||(g.current=this),editor.stripScrollFlag(Y,this.state.tr);let J=this.state.apply(Y);this.updateState(J),v.current?.(Y,J),(Y.selectionSet||Y.docChanged)&&C.current?.(J);},handleKeyDown:(Y,J)=>k.current?.(Y,J)??false,handleScrollToSelection:()=>true,handleDOMEvents:{focus:()=>false,blur:()=>false}};g.current=new prosemirrorView.EditorView(p.current,W);let Z=g.current.dom;Z.style.overflowAnchor="none",S.current=true,c.current=I(r),R.current?.(g.current);},[r,n,a,b,l]),D=zl.useCallback(()=>{g.current&&!y.current&&(y.current=true,T.current?.(),g.current.destroy(),g.current=null,y.current=false);},[]);zl.useEffect(()=>(w(),()=>D()),[]),zl.useEffect(()=>{if(!g.current||y.current)return;let _=I(r);if(S.current&&_===c.current)return;S.current=true,c.current=_;let W=xa(r,n,b,a);g.current.updateState(W),C.current?.(W);},[r,n,b,a]),zl.useEffect(()=>{g.current;},[l]),zl.useImperativeHandle(o,()=>({getState(){return g.current?.state??null},getView(){return g.current??null},getDocument(){return g.current?Xm(g.current.state,x.current):null},focus(){g.current?.focus();},blur(){g.current?.hasFocus()&&g.current.dom.blur();},isFocused(){return g.current?.hasFocus()??false},dispatch(_){g.current&&!y.current&&g.current.dispatch(_);},executeCommand(_){return g.current?_(g.current.state,g.current.dispatch,g.current):false},undo(){return g.current?prosemirrorHistory.undo(g.current.state,g.current.dispatch):false},redo(){return g.current?prosemirrorHistory.redo(g.current.state,g.current.dispatch):false},canUndo(){return g.current?prosemirrorHistory.undo(g.current.state):false},canRedo(){return g.current?prosemirrorHistory.redo(g.current.state):false},setSelection(_,W){if(!g.current)return;let{state:Z,dispatch:Y}=g.current,J=Z.doc.resolve(_),te=W!==void 0?Z.doc.resolve(W):J,ne=prosemirrorState.TextSelection.between(J,te);Y(Z.tr.setSelection(ne));},setNodeSelection(_){if(!g.current)return;let{state:W,dispatch:Z}=g.current;try{let Y=prosemirrorState.NodeSelection.create(W.doc,_);Z(W.tr.setSelection(Y));}catch{this.setSelection(_);}},setCellSelection(_,W){if(!g.current)return;let{state:Z,dispatch:Y}=g.current;try{let J=prosemirrorTables.CellSelection.create(Z.doc,_,W);Y(Z.tr.setSelection(J));}catch{this.setSelection(_,W);}},scrollToSelection(){}}),[]);let H=jsxRuntime.jsx("div",{ref:p,className:"paged-editor__hidden-pm",style:{...qm,width:d>0?`${d}px`:void 0}}),O=globalThis.document,B=O&&"body"in O&&O.body!=null?O.body:null;return B?reactDom.createPortal(H,B):H}),Ra=zl.memo(Zm);function mf(e,t,o,r,n){let u=conversion.headerFooterToProseDoc(e.content,{styles:t??void 0,theme:o??null,defaultTabStopTwips:r??null}),d=prosemirror.createDocumentStylesPlugin(t);return prosemirrorState.EditorState.create({doc:u,schema:prosemirror.schema,plugins:[...n.getPlugins(),d]})}function ff(e){if(!e?.package)return [];let t=[],o=e.package.headers;if(o)for(let n of o.keys())t.push({rId:n,kind:"header"});let r=e.package.footers;if(r)for(let n of r.keys())(!o||!o.has(n))&&t.push({rId:n,kind:"footer"});return t}var mr=zl.memo(zl.forwardRef(function({document:t,styles:o,theme:r,defaultTabStopTwips:n,onTransaction:u},d){let l=zl.useRef(u);l.current=u;let m=zl.useRef(t);m.current=t;let s=zl.useRef(null),a=zl.useRef(null),b=zl.useRef(new Map),f=zl.useRef(new Map);s.current=(p,g,x)=>{let c=m.current?.package;if(!c)return;let v=(g==="header"?c.headers:c.footers)?.get(p);v&&(v.content=conversion.proseDocToBlocks(x.doc));};let h=zl.useCallback((p,g)=>{let x=t?.package;return x?(g==="header"?x.headers:x.footers)?.get(p)??null:null},[t]),i=zl.useMemo(()=>ff(t),[t?.package?.headers,t?.package?.footers]);return zl.useEffect(()=>{if(!a.current)return;let p=a.current,g=new Map(i.map(y=>[y.rId,y])),x=b.current;for(let[y,c]of x)g.has(y)||(c.view.destroy(),c.mountNode.remove(),f.current.get(y)?.destroy(),f.current.delete(y),x.delete(y));for(let y of i){if(x.has(y.rId))continue;let c=h(y.rId,y.kind);if(!c)continue;let S=new extensions.ExtensionManager(extensions.createStarterKit());S.buildSchema(),S.initializeRuntime(),f.current.set(y.rId,S);let v=p.ownerDocument.createElement("div");v.dataset.hfRId=y.rId,v.dataset.hfKind=y.kind,p.appendChild(v);let C=mf(c,o,r,n,S),R=y.rId,T=y.kind,k=new prosemirrorView.EditorView(v,{state:C,dispatchTransaction(E){let I=k.state.apply(E);k.updateState(I),E.docChanged&&s.current?.(R,T,I),l.current?.(R,k,E.docChanged);}});x.set(y.rId,{rId:y.rId,kind:y.kind,view:k,mountNode:v});}},[i,h,o,r,n]),zl.useEffect(()=>{let p=b.current,g=f.current;return ()=>{for(let{view:x,mountNode:y}of p.values())x.destroy(),y.remove();p.clear();for(let x of g.values())x.destroy();g.clear();}},[]),zl.useImperativeHandle(d,()=>({getView(p){return b.current.get(p)?.view??null}}),[]),jsxRuntime.jsx("div",{ref:a,style:{position:"fixed",left:-9999,top:0,opacity:0,zIndex:-1,pointerEvents:"none"}})}));mr.displayName="HiddenHeaderFooterPMs";var yf="var(--doc-caret, #000)",vf="rgba(66, 133, 244, 0.3)",Cf=2,Sf=530,xf={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},Rf=(e,t,o,r)=>({position:"absolute",left:e.x,top:e.y,width:o,height:e.height,backgroundColor:t,opacity:r?1:0,transition:"opacity 0.05s ease-out",pointerEvents:"none"}),Pf=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),Tf=({position:e,color:t,width:o,blinkInterval:r,isFocused:n})=>{let[u,d]=zl.useState(n),l=zl.useRef(null);return zl.useEffect(()=>(l.current&&(window.clearInterval(l.current),l.current=null),n&&r>0?(d(true),l.current=window.setInterval(()=>{d(m=>!m);},r)):d(false),()=>{l.current&&window.clearInterval(l.current);}),[n,r]),zl.useEffect(()=>{if(n)return d(true),l.current&&window.clearInterval(l.current),r>0&&(l.current=window.setInterval(()=>{d(m=>!m);},r)),()=>{l.current&&window.clearInterval(l.current);}},[e.x,e.y,n,r]),jsxRuntime.jsx("div",{style:Rf(e,t,o,u),"data-testid":"caret"})},wf=({rect:e,color:t,index:o})=>jsxRuntime.jsx("div",{style:Pf(e,t),"data-testid":`selection-rect-${o}`,"data-page-index":e.pageIndex}),wa=({selectionRects:e,caretPosition:t,isFocused:o,readOnly:r=false,caretColor:n=yf,selectionColor:u=vf,caretWidth:d=Cf,blinkInterval:l=Sf})=>{if(r)return null;let m=e.length>0,s=t!==null&&!m;return jsxRuntime.jsxs("div",{style:xf,"data-testid":"selection-overlay",children:[m&&e.map((a,b)=>jsxRuntime.jsx(wf,{rect:a,color:u,index:b},`sel-${a.pageIndex}-${a.x}-${a.y}-${b}`)),s&&t&&jsxRuntime.jsx(Tf,{position:t,color:n,width:d,blinkInterval:l,isFocused:o})]})};var gr=10,Ia=gr/2,So=2,Da="#2563eb",ka={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},kf={position:"absolute",border:`${So}px solid ${Da}`,pointerEvents:"none",boxSizing:"border-box"},Mf={position:"absolute",width:`${gr}px`,height:`${gr}px`,backgroundColor:"#ffffff",border:`1.5px solid ${Da}`,borderRadius:"50%",boxShadow:"0 1px 2.5px rgba(0, 0, 0, 0.35)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},Df={position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.75)",color:"var(--doc-on-primary)",fontSize:"11px",fontFamily:"system-ui, sans-serif",padding:"2px 8px",borderRadius:"3px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:20,transform:"translateX(-50%)"},Hf={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize",n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize"},Ff=[{pos:"nw",x:0,y:0},{pos:"ne",x:1,y:0},{pos:"se",x:1,y:1},{pos:"sw",x:0,y:1},{pos:"n",x:.5,y:0},{pos:"s",x:.5,y:1},{pos:"e",x:1,y:.5},{pos:"w",x:0,y:.5}];function Ha({imageInfo:e,zoom:t,isFocused:o,onResize:r,onResizeStart:n,onResizeEnd:u,onDragMove:d,onDragStart:l,onDragEnd:m,onContextMenu:s}){let[a,b]=zl.useState(false),[f,h]=zl.useState(false),[i,p]=zl.useState(0),[g,x]=zl.useState(0),[y,c]=zl.useState(null),S=zl.useRef(null),v=zl.useRef(null),C=zl.useRef(r),R=zl.useRef(n),T=zl.useRef(u),k=zl.useRef(d),E=zl.useRef(l),I=zl.useRef(m);C.current=r,R.current=n,T.current=u,k.current=d,E.current=l,I.current=m;let w=zl.useRef(e),D=zl.useRef(t);w.current=e,D.current=t;let H=zl.useCallback(()=>{if(!e||!v.current){c(null);return}let te=v.current.offsetParent;if(!te){c(null);return}let ne=te.getBoundingClientRect(),me=e.element.getBoundingClientRect();c({left:(me.left-ne.left)/t,top:(me.top-ne.top)/t,width:me.width/t,height:me.height/t});},[e,t]);zl.useEffect(()=>{H();},[H]),zl.useEffect(()=>{if(!e)return;let te=v.current?.closest('[style*="overflow"]')??v.current?.closest(".paged-editor__container");if(!te)return;let ne=()=>{S.current&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(H);};return te.addEventListener("scroll",ne,{passive:true}),window.addEventListener("resize",ne,{passive:true}),()=>{te.removeEventListener("scroll",ne),window.removeEventListener("resize",ne),S.current&&cancelAnimationFrame(S.current);}},[e,H]);let O=zl.useCallback((te,ne)=>{if(!e||!y)return;ne.preventDefault(),ne.stopPropagation();let me=y.width,ke=y.height,Ce=ne.clientX,M=ne.clientY,F=Math.round(me),N=Math.round(ke);b(true),p(F),x(N),R.current?.();let A=V=>{let se=D.current,ee=(V.clientX-Ce)/se,$=(V.clientY-M)/se,de=!V.shiftKey,re=imageCommit.calculateResizedImageDimensions(te,ee,$,me,ke,de);F=Math.round(re.width),N=Math.round(re.height),p(F),x(N),c(X=>{if(!X)return X;let oe={...X};return te.includes("w")&&(oe.left=X.left+(X.width-re.width)),te.includes("n")&&(oe.top=X.top+(X.height-re.height)),oe.width=re.width,oe.height=re.height,oe});},z=()=>{window.removeEventListener("mousemove",A),window.removeEventListener("mouseup",z),b(false);let V=w.current;V&&C.current?.(V.pmPos,F,N),T.current?.();};window.addEventListener("mousemove",A),window.addEventListener("mouseup",z);},[e,y]),B=zl.useCallback(te=>{if(!e||!y)return;te.preventDefault(),te.stopPropagation();let ne=4,me=te.clientX,ke=te.clientY,Ce=false,M=null,F=A=>{let z=A.clientX-me,V=A.clientY-ke;!Ce&&Math.sqrt(z*z+V*V)<ne||(Ce||(Ce=true,h(true),E.current?.(),M=document.createElement("div"),M.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);",M.style.width=`${y.width}px`,M.style.height=`${y.height}px`,document.body.appendChild(M)),M&&(M.style.left=`${A.clientX-y.width/2}px`,M.style.top=`${A.clientY-y.height/2}px`));},N=A=>{if(window.removeEventListener("mousemove",F),window.removeEventListener("mouseup",N),M&&(M.remove(),M=null),h(false),Ce){let z=w.current;z&&k.current?.(z.pmPos,A.clientX,A.clientY),I.current?.();}};window.addEventListener("mousemove",F),window.addEventListener("mouseup",N);},[e,y]);if(!!!(e&&y&&o))return jsxRuntime.jsx("div",{ref:v,style:{...ka,visibility:"hidden"},className:"image-selection-overlay"});let{left:W,top:Z,width:Y,height:J}=y;return jsxRuntime.jsxs("div",{ref:v,style:ka,className:"image-selection-overlay",children:[jsxRuntime.jsx("div",{style:{...kf,left:W-So,top:Z-So,width:Y+So*2,height:J+So*2}}),jsxRuntime.jsx("div",{style:{position:"absolute",left:W,top:Z,width:Y,height:J,cursor:f?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:B,onContextMenu:s}),Ff.map(({pos:te,x:ne,y:me})=>jsxRuntime.jsx(Lf,{handle:te,style:{left:W+Y*ne-Ia,top:Z+J*me-Ia},onMouseDown:O},te)),a&&jsxRuntime.jsxs("div",{style:{...Df,left:W+Y/2,top:Z+J+12},children:[i," \xD7 ",g]})]})}function Lf({handle:e,style:t,onMouseDown:o}){return jsxRuntime.jsx("div",{style:{...Mf,...t,cursor:Hf[e]},onMouseDown:r=>o(e,r),"data-handle":e})}var Of={position:"absolute",inset:0,pointerEvents:"none",zIndex:11};function Aa({getView:e,getPagesContainer:t,zoom:o,decorationSyncToken:r,syncCoordinator:n}){let u=zl.useRef(null),d=zl.useRef(null),[l,m]=zl.useState(0);return zl.useEffect(()=>n.onRender(()=>m(s=>s+1)),[n]),zl.useEffect(()=>(d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null;let s=e(),a=t(),b=u.current;!s||!a||!b||n.isSafeToRender()&&Bf(s,a,b,o);}),()=>{d.current!==null&&(cancelAnimationFrame(d.current),d.current=null);}),[o,r,l]),jsxRuntime.jsx("div",{ref:u,className:"paged-editor__decoration-overlay",style:Of,"aria-hidden":"true"})}function Bf(e,t,o,r){let n=Nf(e.state);if(n.length===0){o.firstChild&&o.replaceChildren();return}let u=chunkBZO4G5M6_js.b(t,r),d=u.getContainerOffset(),l=document.createDocumentFragment();for(let{decoration:m,from:s,to:a}of n){if(s===a){let h=zf(m,e);if(!h)continue;let i=u.getCoordinatesForPosition(s);if(!i)continue;let p=document.createElement("div");p.style.cssText=`position:absolute;left:${i.x+d.x}px;top:${i.y+d.y}px;height:${i.height}px;`,p.appendChild(h),l.appendChild(p);continue}let b=_f(m);if(!b)continue;let f=u.getRectsForRange(s,a);for(let h of f){let i=document.createElement("div");for(let[g,x]of Object.entries(b))g!=="nodeName"&&i.setAttribute(g,x);let p=`position:absolute;left:${h.x+d.x}px;top:${h.y+d.y}px;width:${h.width}px;height:${h.height}px;`;i.style.cssText=p+(b.style??""),l.appendChild(i);}}o.replaceChildren(l);}function Nf(e){let t=[];for(let o of e.plugins){let r=o.props.decorations;if(!r)continue;let n=r.call(o,e);n&&n.forEachSet(u=>{u.find().forEach(d=>{d.spec?.noOverlay||t.push({decoration:d,from:d.from,to:d.to});});});}return t}function zf(e,t){let o=e.type;if(!o)return null;let r=o.toDOM;return typeof r=="function"?r(t,()=>e.from):r instanceof HTMLElement?r.cloneNode(true):null}function _f(e){return e.type?.attrs??null}var za=[];var _a={position:"relative",width:"100%",minHeight:"100%",overflow:"visible",backgroundColor:"var(--doc-bg)"},Wa={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:24,paddingBottom:24,overflowAnchor:"none"},Va={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",overflowAnchor:"none"},Ua={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function an(e,t,o){let r=t.getBoundingClientRect(),n=e.getBoundingClientRect(),u=n.top+n.height/2,d=r.top+r.height/2,l=u-d,m=Math.max(0,t.scrollHeight-t.clientHeight),s=Math.max(0,Math.min(m,t.scrollTop+l));t.scrollTop=s;}function sn(e,t){if(t.aborted)return;let o=requestAnimationFrame(()=>{if(t.aborted)return;let r=requestAnimationFrame(()=>{if(t.aborted)return;let n=requestAnimationFrame(()=>{t.aborted||e();});t.addEventListener("abort",()=>cancelAnimationFrame(n),{once:true});});t.addEventListener("abort",()=>cancelAnimationFrame(r),{once:true});});t.addEventListener("abort",()=>cancelAnimationFrame(o),{once:true});}function Ga(e,t){let o=null,r=layoutBridge.findBodyPmAnchors(e);for(let n=0;n<r.length;n++){let u=r[n].dataset.pmStart;if(u==null)continue;let d=Number(u);Number.isNaN(d)||d<=t&&(o===null||d>o)&&(o=d);}return o}function ln(e,t){let o=e.pages.length;return e.pages.reduce((n,u)=>n+u.size.h,0)+Math.max(0,o-1)*t+24+24}function Ka(e,t,o,r,n){let u=new Map;if(!e?.state)return u;let{doc:d,schema:l}=e.state,m=l.marks.comment,s=l.marks.insertion,a=l.marks.deletion;if(!m&&!s&&!a)return u;let b=new Set,f=24+n,h=(i,p)=>{if(b.has(i))return;b.add(i);let g=layoutBridge.getCaretPosition(t,o,r,p);if(g){u.set(i,g.y+f);return}for(let x=0;x<t.pages.length;x++){let y=t.pages[x];for(let c of y.fragments){let S=c.pmStart??0,v=c.pmEnd??S;if(p<S||p>v)continue;let C=c.kind==="table"?Gf(o,r,c,p):0;u.set(i,c.y+C+layoutBridge.getPageTop(t,x)+f);return}}};return d.descendants((i,p)=>{let g=i.attrs;if(g){let x=[g.trIns,g.trDel,g.pPrIns,g.pPrDel];for(let v of x){let C=v?.revisionId;typeof C=="number"&&h(`revision-${C}`,p);}let c=g.cellMarker?.info?.revisionId;typeof c=="number"&&h(`revision-${c}`,p);let S=[g.pPrChange,g.trPrChange,g.tcPrChange,g.tblPrChange];for(let v of S)if(Array.isArray(v))for(let C of v){let R=C?.info?.id;typeof R=="number"&&h(`revision-${R}`,p);}}if(i.isInline)for(let x of i.marks){let y=null;m&&x.type===m?y=`comment-${x.attrs.commentId}`:(s&&x.type===s||a&&x.type===a)&&(y=`revision-${x.attrs.revisionId}`),y&&h(y,p);}}),u}function Gf(e,t,o,r){let n=e.findIndex(m=>m.id===o.blockId);if(n===-1)return 0;let u=e[n],d=t[n];if(u.kind!=="table"||d.kind!=="table")return 0;let l=0;for(let m=o.fromRow;m<o.toRow;m++){let s=u.rows[m];if(!s||s.cells.some(b=>b.blocks.some(f=>{let h=f.pmStart??0,i=f.pmEnd??h;return r>=h&&r<=i})))break;l+=d.rows[m]?.height??0;}return l}function qa(e,t,o,r){switch(e.kind){case "paragraph":{let n=e;if(!o||o.length===0){let d=layoutBridge.getCachedParagraphMeasure(n,t);if(d)return d}let u=layoutBridge.measureParagraph(n,t,{floatingZones:o,paragraphYOffset:r??0});return (!o||o.length===0)&&layoutBridge.setCachedParagraphMeasure(n,t,u),u}case "table":return layoutBridge.measureTableBlock(e,t,qa);case "image":{let n=e;return {kind:"image",width:n.width??100,height:n.height??100}}case "textBox":{let n=e,u=n.margins??layoutEngine.DEFAULT_TEXTBOX_MARGINS,d=(n.width??layoutEngine.DEFAULT_TEXTBOX_WIDTH)-u.left-u.right,l=n.content.map(a=>layoutBridge.measureParagraph(a,d)),m=l.reduce((a,b)=>a+b.totalHeight,0),s=n.height??m+u.top+u.bottom;return {kind:"textBox",width:n.width??layoutEngine.DEFAULT_TEXTBOX_WIDTH,height:s,innerMeasures:l}}case "pageBreak":return {kind:"pageBreak"};case "columnBreak":return {kind:"columnBreak"};case "sectionBreak":return {kind:"sectionBreak"};default:layoutEngine.assertExhaustiveFlowBlock(e,"react PagedEditor measureBlock");}}function Xa(e,t,o){return layoutBridge.measureBlocksWithFloats(e,t,qa,o)}function Qa(e,t,o){t.style.overflowAnchor||t.style.setProperty("overflow-anchor","none");let r=Math.max(1,t.scrollHeight-t.clientHeight),n=t.scrollTop/r,u=Ga(e,o),d=0;if(u!=null){let l=layoutBridge.findBodyPmAnchor(e,u);if(l){let m=l.getBoundingClientRect(),s=t.getBoundingClientRect();d=m.top-s.top;}else u=null;}return {scrollRestoreRatioPre:n,domAnchorPmStart:u,domAnchorOffsetInScroller:d}}function Ja(e,t,o){let r=o.scrollRestoreRatioPre;if(e==="incremental"){let u=Math.max(1,t.scrollHeight-t.clientHeight);r=t.scrollTop/u;}let n=e==="incremental"?t.scrollTop:null;return {renderKind:e,ratio:r,scrollTopSnapshot:n,domAnchorPmStart:o.domAnchorPmStart,domAnchorOffsetInScroller:o.domAnchorOffsetInScroller}}function hr(e,t,o){let{renderKind:r,ratio:n,scrollTopSnapshot:u,domAnchorPmStart:d,domAnchorOffsetInScroller:l}=e;if(r==="incremental"&&u!=null){let s=Math.max(1,o.scrollHeight-o.clientHeight);o.scrollTop=Math.min(Math.max(0,u),s);return}if(r!=="incremental"&&d!=null){let s=layoutBridge.findBodyPmAnchor(t,d);if(s){let a=o.getBoundingClientRect(),b=s.getBoundingClientRect().top-a.top;o.scrollTop+=l-b;return}}let m=Math.max(1,o.scrollHeight-o.clientHeight);o.scrollTop=n*m;}function es(e,t,o,r){if(e?.renderKind!=="incremental"||e.scrollTopSnapshot==null||r&&o>32||!t?.isConnected)return;let n=Math.max(1,t.scrollHeight-t.clientHeight),u=Math.min(Math.max(0,e.scrollTopSnapshot),n);Math.abs(t.scrollTop-u)>.5&&(t.scrollTop=u);}function is(e){let{document:t,styles:o,theme:r,sectionProperties:n,finalSectionProperties:u,headerContent:d,footerContent:l,firstPageHeaderContent:m,firstPageFooterContent:s,getHfPmDoc:a,pageGap:b,zoom:f,resolvedCommentIds:h,pagesContainerRef:i,viewportLayoutRef:p,hiddenPMRef:g,syncCoordinator:x,getScrollContainer:y,onTotalPagesChange:c,onAnchorPositionsChange:S,onRenderedDomContextReady:v}=e,[C,R]=zl.useState(null),[T,k]=zl.useState([]),[E,I]=zl.useState([]),[w,D]=zl.useState(0),H=zl.useCallback(()=>D($=>$+1),[]),O=zl.useRef(c),B=zl.useRef(S),_=zl.useRef(v),W=zl.useRef(a);O.current=c,B.current=S,_.current=v,W.current=a;let Z=zl.useRef(0);zl.useEffect(()=>{let $=C?.pages.length??0;$!==Z.current&&(Z.current=$,O.current?.($));},[C]);let Y=zl.useMemo(()=>layoutBridge.getPageSize(n),[n]),J=zl.useMemo(()=>layoutBridge.getMargins(n),[n]),te=zl.useMemo(()=>layoutBridge.getColumns(n),[n]),{finalPageSize:ne,finalMargins:me,finalColumns:ke}=zl.useMemo(()=>{let $=u??n;return {finalPageSize:layoutBridge.getPageSize($),finalMargins:layoutBridge.getMargins($),finalColumns:layoutBridge.getColumns($)}},[u,n]),Ce=Y.w-J.left-J.right,M=zl.useMemo(()=>new layoutPainter.LayoutPainter({pageGap:b,showShadow:true,pageBackground:"var(--doc-page-bg, #ffffff)"}),[b]),F=zl.useRef(null);F.current=M;let N=zl.useRef(null),A=zl.useRef(0),z=zl.useCallback($=>{let de=performance.now(),re=x.getStateSeq();x.onLayoutStart();let X=oe=>{let le=i.current,Re=le?y()??findVerticalScrollParent.findVerticalScrollParentOrRoot(le):null,Q=performance.now()-A.current;es(N.current,Re,Q,oe);};X(true);try{let{blocks:oe,measures:le,layout:Re,headerContentForRender:Q,footerContentForRender:he,firstPageHeaderForRender:Pe,firstPageFooterForRender:Ae,hasTitlePg:Oe,watermark:De,headerDistancePx:He,footerDistancePx:q,pageBorders:ue,footnotesByPage:ce}=editor.computeLayout({state:$,document:t,pageSize:Y,margins:J,columns:te,finalPageSize:ne,finalMargins:me,finalColumns:ke,pageGap:b,contentWidth:Ce,theme:r,styles:o,sectionProperties:n,finalSectionProperties:u,headerContent:d,footerContent:l,firstPageHeaderContent:m,firstPageFooterContent:s,measureBlocks:Xa,getHfPmDoc:we=>W.current?.(we)??null});if(k(oe),I(le),R(Re),i.current&&F.current){N.current=null,A.current=0;let we=i.current,Se=y()??findVerticalScrollParent.findVerticalScrollParentOrRoot(we),et=Se?.isConnected?Qa(we,Se,$.selection.head):null,ae=layoutPainter.buildBlockLookup(oe,le);F.current.setBlockLookup(ae);let ze=layoutPainter.renderPages(Re.pages,i.current,{pageGap:b,showShadow:!0,pageBackground:"var(--doc-page-bg, #ffffff)",blockLookup:ae,headerContent:Q,footerContent:he,firstPageHeaderContent:Pe,firstPageFooterContent:Ae,titlePg:Oe,headerDistance:He,footerDistance:q,pageBorders:ue,theme:r,watermark:De,footnotesByPage:ce,resolvedCommentIds:h}),Te=p.current;if(Te){let _e=ln(Re,b);Te.style.minHeight=`${_e}px`,f!==1?Te.style.marginBottom=`${_e*(f-1)}px`:Te.style.marginBottom="";}if(Se?.isConnected&&et){let _e=Ja(ze,Se,et);N.current=_e,_e.renderKind==="incremental"&&_e.scrollTopSnapshot!=null&&(A.current=performance.now());}if(i.current?.dispatchEvent(new CustomEvent("painter:painted",{bubbles:!0})),_.current){let _e=chunkBZO4G5M6_js.b(i.current,f);_.current(_e);}}else N.current=null,A.current=0;if(B.current){let we=Ka(g.current?.getView()??null,Re,oe,le,b);B.current(we);}X(!1);let fe=performance.now()-de;fe>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(fe)}ms total (${oe.length} blocks, ${le.length} measures)`);}catch(oe){console.error("[PagedEditor] Layout pipeline error:",oe);}x.onLayoutComplete(re),X(false);},[Ce,te,Y,J,ne,me,ke,b,f,x,d,l,m,s,n,u,t,h,y,g,i,o,r,p]);zl.useLayoutEffect(()=>{let $=N.current;if(!$)return;N.current=null,A.current=0;let de=i.current,re=y()??(de?findVerticalScrollParent.findVerticalScrollParentOrRoot(de):null);if(!de||!re?.isConnected)return;hr($,de,re);let X=requestAnimationFrame(()=>{re.isConnected&&hr($,de,re);});return ()=>cancelAnimationFrame(X)},[C,y,i]);let V=zl.useRef(z);V.current=z;let se=zl.useRef(null);se.current||(se.current=editor.createLayoutScheduler($=>V.current($)));let ee=zl.useCallback($=>{se.current.schedule($);},[]);return zl.useEffect(()=>{let $=se.current;return ()=>$?.cancel()},[]),{layout:C,blocks:T,measures:E,decorationSyncToken:w,notifyDecorationLayer:H,contentWidth:Ce,runLayoutPipeline:z,scheduleLayout:ee}}function ls(e){let{layout:t,blocks:o,measures:r,zoom:n,containerRef:u,pagesContainerRef:d,hiddenPMRef:l,syncCoordinator:m,isImageInteractingRef:s,onSelectionChangeRef:a}=e,[b,f]=zl.useState([]),[h,i]=zl.useState(null),[p,g]=zl.useState(null),x=zl.useRef(null),y=zl.useCallback((v,C)=>{let R=v.tagName==="IMG"?v:v.querySelector("img"),T=(R??v).getBoundingClientRect();return {element:R??v,pmPos:C,width:Math.round(T.width/n),height:Math.round(T.height/n)}},[n]),c=zl.useCallback(v=>{let{from:C,to:R}=v.selection;x.current!==v&&(x.current=v,a.current?.(C,R));let T=d.current;if(T&&(layoutBridge.applyCellSelectionHighlight(T,v),layoutPainter.applySdtFocus(T,layoutPainter.enclosingSdtGroupIds(v.doc,C,R))),!(!t||o.length===0))if(C===R){let k=T?ha(T,C,n):null;if(k)i(k);else {let E=d.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),I=d.current?.querySelector(".layout-page");if(E&&I){let w=E.getBoundingClientRect(),D=I.getBoundingClientRect(),H=layoutBridge.getCaretPosition(t,o,r,C);i(H?{...H,x:H.x+(D.left-w.left)/n,y:H.y+(D.top-w.top)/n}:null);}else i(null);}f([]);}else {let k=d.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(k&&d.current){let E=k.getBoundingClientRect(),I=ya(d.current,E,C,R,n);if(I.length>0)f(I);else {let w=d.current.querySelector(".layout-page");if(w){let D=w.getBoundingClientRect(),H=(D.left-E.left)/n,O=(D.top-E.top)/n,_=layoutBridge.selectionToRects(t,o,r,C,R).map(W=>({...W,x:W.x+H,y:W.y+O}));f(_);}else f([]);}}else f([]);i(null);}},[t,o,r,n,a,d]),S=zl.useCallback(v=>{let{selection:C}=v;C instanceof prosemirrorState.NodeSelection&&C.node.type.name==="image"?(f([]),i(null)):m.isSafeToRender()&&c(v),requestAnimationFrame(()=>{let R=l.current?.getView();if(!R){g(null);return}let{selection:T}=R.state;if(T instanceof prosemirrorState.NodeSelection&&T.node.type.name==="image"){let k=T.from,E=d.current?layoutBridge.findBodyPmAnchor(d.current,k):null;if(E){g(y(E,k));return}}s.current||g(null);});},[c,y,m,l,s,d]);return zl.useEffect(()=>{let v=u.current;if(!v)return;let C=new ResizeObserver(()=>{let R=l.current?.getState();R&&c(R);});return C.observe(v),()=>C.disconnect()},[c,u,l]),zl.useEffect(()=>{let v=l.current?.getState();t&&v&&c(v);},[t,c,l]),{selectionRects:b,caretPosition:h,selectedImageInfo:p,setSelectionRects:f,setCaretPosition:i,setSelectedImageInfo:g,buildImageSelectionInfo:y,updateSelectionOverlay:c,handleSelectionChange:S}}function ds(e){let{pagesContainerRef:t,hiddenPMRef:o,zoom:r,isImageInteractingRef:n,getPositionFromMouse:u}=e,d=zl.useCallback((f,h,i)=>{let p=o.current?.getView();if(!p)return;let g=imageCommit.commitImageResize(p,f,h,i);g!==null&&o.current?.setNodeSelection(g);},[o]),l=zl.useCallback(()=>{n.current=true;},[n]),m=zl.useCallback(()=>{n.current=false;},[n]),s=zl.useCallback((f,h,i)=>{let p=o.current?.getView();if(!p)return;let g=p.state.doc.nodeAt(f);if(!(!g||g.type.name!=="image"))if(imageCommit.isFloatingImage(g)){let x=t.current?.querySelectorAll(".layout-page");if(!x||x.length===0)return;let y=null;for(let R of x){let T=R.getBoundingClientRect();if(i>=T.top&&i<=T.bottom){y=R.querySelector(".layout-page-content");break}}if(y||(y=x[x.length-1].querySelector(".layout-page-content")),!y)return;let c=y.getBoundingClientRect(),S=utils.pixelsToEmu((h-c.left)/r),v=utils.pixelsToEmu((i-c.top)/r),C=imageCommit.commitImageFloatMove(p,f,S,v);C!==null&&o.current?.setNodeSelection(C);}else {let x=u(h,i);if(x===null)return;let y=imageCommit.commitImageInlineMove(p,f,x);y!==null&&o.current?.setNodeSelection(y);}},[u,r,o,t]),a=zl.useCallback(()=>{n.current=true;},[n]),b=zl.useCallback(()=>{n.current=false;},[n]);return {handleImageResize:d,handleImageResizeStart:l,handleImageResizeEnd:m,handleImageDragMove:s,handleImageDragStart:a,handleImageDragEnd:b}}function ms(e){let{layout:t,blocks:o,measures:r,pagesContainerRef:n,hiddenPMRef:u,getScrollContainer:d}=e,l=zl.useRef(null);zl.useEffect(()=>()=>{l.current?.abort(),l.current=null;},[]);let m=zl.useCallback((b,f=false)=>{if(!Number.isInteger(b)||b<0)return;let h=n.current;if(!h)return;l.current?.abort();let i=new AbortController;l.current=i;let{signal:p}=i,g=()=>{let E=layoutBridge.findBodyPmAnchor(h,b);if(E)return E;for(let I of layoutBridge.findBodyPmSpans(h)){let w=Number(I.dataset.pmStart),D=Number(I.dataset.pmEnd);if(Number.isFinite(w)&&Number.isFinite(D)&&b>=w&&b<=D)return I}return null};if(!f){let E={block:"center",inline:"nearest",behavior:"smooth"},I=g();if(I){I.scrollIntoView(E);return}let w=t,D=o,H=r;if(!w||D.length===0||H.length!==D.length)return;let O=null,B=layoutBridge.getCaretPosition(w,D,H,b);if(B?O=B.pageIndex:O=layoutEngine.findPageIndexContainingPmPos(w,b),O==null)return;let W=h.querySelectorAll(".layout-page")[O];if(!W)return;W.scrollIntoView(E),sn(()=>{if(!h.isConnected)return;let Z=g();Z&&Z.scrollIntoView(E);},p);return}let x=d()??findVerticalScrollParent.findVerticalScrollParentOrRoot(h),y=()=>{let E=g();return E?(an(E,x),true):false};if(y())return;let c=t,S=o,v=r;if(!c||S.length===0||v.length!==S.length)return;let C=null,R=layoutBridge.getCaretPosition(c,S,v,b);if(R?C=R.pageIndex:C=layoutEngine.findPageIndexContainingPmPos(c,b),C==null)return;let k=h.querySelectorAll(".layout-page")[C];k&&(an(k,x),sn(()=>{if(!h.isConnected)return;let E=g();E?an(E,x):y();},p));},[t,o,r,d,n]),s=zl.useCallback(b=>{if(!Number.isInteger(b)||b<1||!t||b>t.pages.length)return;let f=t.pages[b-1];for(let i of f.fragments)if(typeof i.pmStart=="number"){m(i.pmStart,true);return}n.current?.querySelectorAll(".layout-page")[b-1]?.scrollIntoView({block:"center",inline:"nearest"});},[t,m,n]),a=zl.useCallback(b=>{let f=u.current?.getState();if(!f)return false;let h=prosemirror.findStartPosForParaId(f.doc,b);if(h==null||h<0)return false;m(h,true);let i=l.current?.signal;if(!i)return true;let p=f.doc.nodeAt(h),g=p?.isTextblock===true?Math.min(h+1+p.content.size,f.doc.content.size):Math.min(h+1,f.doc.content.size);return sn(()=>{u.current&&(u.current.setSelection(g),u.current.focus());},i),true},[m,u]);return {scrollToPositionImpl:m,scrollToPageImpl:s,scrollToParaIdImpl:a}}function Ss(e){let{hiddenPMRef:t,getActiveHfView:o}=e,r=zl.useRef(null);function n(w){return w.closest(".layout-page-header")||w.closest(".layout-page-footer")?o?.()??t.current?.getView()??null:t.current?.getView()??null}let u=zl.useRef(false),d=zl.useRef(0),l=zl.useRef(0),m=zl.useRef(0),s=zl.useRef({left:0,right:0}),a=zl.useRef(null),b=zl.useRef(false),f=zl.useRef(0),h=zl.useRef(0),i=zl.useRef(0),p=zl.useRef(0),g=zl.useRef(null),x=zl.useRef(false),y=zl.useRef(false),c=zl.useRef(0),S=zl.useRef(0),v=zl.useRef(0),C=zl.useRef(0),R=zl.useRef(null),T=zl.useCallback((w,D)=>{let H=n(w);if(!H)return false;if(w.classList.contains("layout-table-resize-handle")){D.preventDefault(),D.stopPropagation(),u.current=true,d.current=D.clientX,a.current=w,r.current=H,w.classList.add("dragging");let O=parseInt(w.dataset.columnIndex??"0",10);l.current=O,m.current=parseInt(w.dataset.tablePmStart??"0",10);let B=tableResize.readColumnWidths(H,m.current,O);return B&&(s.current=B),true}if(w.classList.contains("layout-table-row-resize-handle")||w.classList.contains("layout-table-edge-handle-bottom")){D.preventDefault(),D.stopPropagation(),b.current=true,f.current=D.clientY,g.current=w,x.current=w.dataset.isEdge==="bottom",r.current=H,w.classList.add("dragging");let O=parseInt(w.dataset.rowIndex??"0",10);h.current=O,i.current=parseInt(w.dataset.tablePmStart??"0",10);let B=tableResize.readRowHeight(H,i.current,O);if(B!=null)p.current=B;else {let W=w.closest(".layout-table")?.querySelector(`[data-row-index="${O}"]`),Z=W?W.getBoundingClientRect().height:30;p.current=Math.round(Z*tableResize.TWIPS_PER_PIXEL);}return true}if(w.classList.contains("layout-table-edge-handle-right")){D.preventDefault(),D.stopPropagation(),y.current=true,c.current=D.clientX,R.current=w,r.current=H,w.classList.add("dragging");let O=parseInt(w.dataset.columnIndex??"0",10);S.current=O,v.current=parseInt(w.dataset.tablePmStart??"0",10);let B=tableResize.readColumnWidthAt(H,v.current,O);return B!=null&&(C.current=B),true}return false},[t,o]),k=zl.useCallback(w=>{if(u.current){w.preventDefault();let D=w.clientX-d.current;if(a.current){let H=parseFloat(a.current.style.left);a.current.style.left=`${H+D}px`,d.current=w.clientX;let O=Math.round(D*tableResize.TWIPS_PER_PIXEL),B=s.current.left+O,_=s.current.right-O;B>=tableResize.MIN_CELL_WIDTH_TWIPS&&_>=tableResize.MIN_CELL_WIDTH_TWIPS&&(s.current={left:B,right:_});}return true}if(b.current){w.preventDefault();let D=w.clientY-f.current;if(g.current){let H=parseFloat(g.current.style.top);g.current.style.top=`${H+D}px`,f.current=w.clientY;let O=Math.round(D*tableResize.TWIPS_PER_PIXEL),B=p.current+O;B>=tableResize.MIN_ROW_HEIGHT_TWIPS&&(p.current=B);}return true}if(y.current){w.preventDefault();let D=w.clientX-c.current;if(R.current){let H=parseFloat(R.current.style.left);R.current.style.left=`${H+D}px`,c.current=w.clientX;let O=Math.round(D*tableResize.TWIPS_PER_PIXEL),B=C.current+O;B>=tableResize.MIN_CELL_WIDTH_TWIPS&&(C.current=B);}return true}return false},[]),E=zl.useCallback(()=>{let w=r.current;if(u.current){if(u.current=false,a.current&&(a.current.classList.remove("dragging"),a.current=null),w){let{left:D,right:H}=s.current;tableResize.commitColumnResize(w,{pmStart:m.current,colIdx:l.current,newLeft:D,newRight:H});}return r.current=null,true}return b.current?(b.current=false,g.current&&(g.current.classList.remove("dragging"),g.current=null),w&&tableResize.commitRowResize(w,{pmStart:i.current,rowIdx:h.current,newHeight:p.current}),r.current=null,true):y.current?(y.current=false,R.current&&(R.current.classList.remove("dragging"),R.current=null),w&&tableResize.commitRightEdgeResize(w,{pmStart:v.current,colIdx:S.current,newWidth:C.current}),r.current=null,true):false},[]),I=zl.useCallback(()=>u.current||b.current||y.current,[]);return {tryStartFromMouseDown:T,handleMouseMoveUpdate:k,tryCommit:E,isAnyResizeActive:I}}function Lg(e){return {getView:()=>e,setSelection(t,o){let r=o??t;try{let n=e.state.doc.resolve(t),u=e.state.doc.resolve(r);e.dispatch(e.state.tr.setSelection(prosemirrorState.TextSelection.between(n,u)));}catch{e.dispatch(e.state.tr.setSelection(prosemirrorState.TextSelection.create(e.state.doc,0)));}},setNodeSelection(t){try{e.dispatch(e.state.tr.setSelection(prosemirrorState.NodeSelection.create(e.state.doc,t)));}catch{}},setCellSelection(t,o){try{let r=e.state.doc.resolve(t),n=e.state.doc.resolve(o);e.dispatch(e.state.tr.setSelection(new prosemirrorTables.CellSelection(r,n)));}catch{}},focus(){e.focus();}}}function ws(e){let{pagesContainerRef:t,hiddenPMRef:o,getHfView:r,layout:n,blocks:u,measures:d,zoom:l,readOnly:m,hfEditMode:s,onBodyClick:a,onContextMenu:b,onHyperlinkClick:f,onHeaderFooterDoubleClick:h,setSelectedImageInfo:i,setSelectionRects:p,setCaretPosition:g,buildImageSelectionInfo:x,setIsFocused:y,scrollToPositionImpl:c}=e,S=zl.useRef(false),v=zl.useRef(null),C=Ss({hiddenPMRef:o,getActiveHfView:r}),R=zl.useRef(cellDragSelection.createCellDragTracker()),[T,k]=zl.useState(null),E=zl.useRef(null),I=zl.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null);},[]);zl.useEffect(()=>()=>{E.current&&clearTimeout(E.current);},[]);let w=zl.useRef(()=>{}),D=zl.useCallback((M,F)=>{w.current(M,F);},[]),{updateMousePosition:H,stopAutoScroll:O}=chunkLNONBJQM_js.b({pagesContainerRef:t,onScrollExtendSelection:D}),B=zl.useCallback((M,F)=>{if(!t.current||!n)return null;let N=layoutBridge.clickToPositionDom(t.current,M,F,l);if(N!==null)return N;if(s){let oe=window.document.elementsFromPoint(M,F).find(he=>he.closest(".layout-page-header")||he.closest(".layout-page-footer"));if(!oe)return null;let le=oe.closest(".layout-page-header")??oe.closest(".layout-page-footer");if(!le)return null;let Re=Array.from(le.querySelectorAll("span[data-pm-start][data-pm-end]")),Q=null;for(let he of Re){let Pe=he.getBoundingClientRect();if(F<Pe.top-4||F>Pe.bottom+4)continue;let Ae=Number(he.dataset.pmStart),Oe=Number(he.dataset.pmEnd);if(!Number.isFinite(Ae)||!Number.isFinite(Oe))continue;let De,He;if(M<Pe.left)De=Ae,He=Pe.left-M;else if(M>Pe.right)De=Oe,He=M-Pe.right;else {let q=(M-Pe.left)/Math.max(1,Pe.width);De=Ae+Math.round(q*(Oe-Ae)),He=0;}(!Q||He<Q.dist)&&(Q={pos:De,dist:He});}return Q?.pos??null}let A=t.current.querySelectorAll(".layout-page"),z=-1,V=null;for(let X=0;X<A.length;X++){let le=A[X].getBoundingClientRect();if(M>=le.left&&M<=le.right&&F>=le.top&&F<=le.bottom){z=X,V=le;break}}if(z<0||!V)return null;let se=(M-V.left)/l,ee=(F-V.top)/l,$=n.pages[z];if(!$)return null;let de={pageIndex:z,page:$,pageY:ee},re=layoutBridge.hitTestFragment(de,u,d,{x:se,y:ee});if(!re)return null;if(re.fragment.kind==="table"){let X=layoutBridge.hitTestTableCell(de,u,d,{x:se,y:ee});return layoutBridge.clickToPosition(re,X)}return layoutBridge.clickToPosition(re)},[n,u,d,l,s,t]),_=zl.useCallback(()=>{if(s&&r){let M=r();if(M)return Lg(M)}return o.current},[s,r,o]),W=zl.useCallback(M=>{let F=_()?.getView();return F?cellDragSelection.findCellPosFromPmPos(F,M):null},[_]),Z=zl.useCallback(M=>{let F=_();if(!F)return;if(M.button===2){M.preventDefault();return}if(M.button!==0||(k(null),I(),M.target.closest("a[href]")&&M.preventDefault(),m))return;let A=M.target;if(s){if(!(A.closest(".layout-page-header")||A.closest(".layout-page-footer")||A.closest(".hf-inline-editor"))&&a){M.preventDefault(),M.stopPropagation(),a();return}}else if((A.closest(".layout-page-header")||A.closest(".layout-page-footer"))&&M.detail!==2){M.preventDefault();return}if(C.tryStartFromMouseDown(A,M))return;let z=layoutPainter.findImageElement(A);if(z){M.preventDefault(),M.stopPropagation();let se=z.dataset.pmStart;if(se!==void 0){let ee=parseInt(se,10);F.setNodeSelection(ee),i(x(z,ee)),p([]),g(null);}F.focus(),s||y(true);return}i(null),M.preventDefault();let V=B(M.clientX,M.clientY);if(V!==null)R.current.begin(W(V)),S.current=true,v.current=V,F.setSelection(V);else {R.current.begin(null);let se=F.getView();if(se){let ee=Math.max(0,se.state.doc.content.size-1);F.setSelection(ee),v.current=ee,S.current=true;}}F.focus(),s||y(true);},[_,m,s,a,B,W,C,I,i,p,g,x,y]);w.current=(M,F)=>{if(!S.current||v.current===null)return;let N=_();if(!N)return;let A=B(M,F);A!==null&&N.setSelection(v.current,A);};let Y=zl.useCallback(M=>{if(C.handleMouseMoveUpdate(M)||!S.current||v.current===null)return;let F=_();if(!F||!t.current)return;H(M.clientX,M.clientY);let N=B(M.clientX,M.clientY);if(N===null)return;let A=F.getView();if(A&&R.current.update(A,N,M.clientX))return;let z=v.current;F.setSelection(z,N);},[_,B,W,H,C,t]),J=zl.useCallback(()=>{C.tryCommit()||(S.current=false,R.current.end(),O());},[O,C]);zl.useEffect(()=>(window.addEventListener("mousemove",Y),window.addEventListener("mouseup",J),()=>{window.removeEventListener("mousemove",Y),window.removeEventListener("mouseup",J);}),[Y,J]);let te=zl.useCallback(M=>{if(m||S.current||R.current.isCellDragging||C.isAnyResizeActive())return;let F=t.current;if(!F)return;let N=layoutBridge.detectTableInsertHover({mouseX:M.clientX,mouseY:M.clientY,pagesContainer:F,target:M.target,hfEditMode:s??null});if(!N){E.current||(E.current=setTimeout(()=>{k(null),E.current=null;},layoutBridge.TABLE_INSERT_HIDE_DELAY_MS));return}let A=F.parentElement;if(!A)return;let z=A.getBoundingClientRect();k({type:N.type,x:N.clientX-z.left,y:N.clientY-z.top,cellPmPos:N.cellPmPos}),I();},[m,I,s,t]),ne=zl.useCallback(M=>{if(M.preventDefault(),M.stopPropagation(),!T)return;let F=_(),N=F?.getView();if(!F||!N)return;let{type:A,cellPmPos:z}=T,V=N.state.tr.setSelection(prosemirrorState.TextSelection.create(N.state.doc,z+1));N.dispatch(V),A==="row"?prosemirror.addRowBelow(N.state,N.dispatch):prosemirror.addColumnRight(N.state,N.dispatch),k(null),F.focus();},[T,_]),me=zl.useCallback(M=>{let F=_(),N=M.target.closest("a[href]");if(N&&F){M.preventDefault();let z=N.getAttribute("href")||"",V=F.getView();if(z.startsWith("#")){let se=z.substring(1);if(se&&V){let ee=null;V.state.doc.descendants(($,de)=>{if(ee!==null)return false;if($.type.name==="paragraph"&&$.attrs.bookmarks?.some(X=>X.name===se))return ee=de,false}),ee!==null&&(c(ee),F.setSelection(ee+1));}}else if(f&&!(V&&V.state.selection.from!==V.state.selection.to)){let ee=N.textContent||"",$=N.getAttribute("title")||void 0,de=N.closest(".ep-root.paged-editor");if(de){let re=de.getBoundingClientRect(),X=N.getBoundingClientRect(),oe={top:X.bottom-re.top+4,left:X.left-re.left};f({href:z,displayText:ee,tooltip:$,position:oe});}}return}if(M.detail===2&&!s&&h){let z=M.target,V=z.closest(".layout-page-header"),se=z.closest(".layout-page-footer");if(V||se){let ee=z.closest("[data-page-number]"),$=ee?Number(ee.dataset.pageNumber):1;M.preventDefault(),M.stopPropagation(),h(V?"header":"footer",$);return}}if(!F)return;let A=F.getView();if(A){if(M.detail===2){let z=B(M.clientX,M.clientY);if(z!==null){let V=W(z);if(V!==null){M.preventDefault(),M.stopPropagation(),F.setCellSelection(V,V);return}let{doc:se}=A.state,ee=se.resolve(z),$=ee.parent;if($.isTextblock){let de=$.textContent,re=ee.parentOffset,[X,oe]=utils.findWordBoundaries(de,re),le=ee.start()+X,Re=ee.start()+oe;le<Re&&F.setSelection(le,Re);}}}if(M.detail===3){let z=B(M.clientX,M.clientY);if(z!==null){let V=A.state.doc.resolve(z);F.setSelection(V.start(V.depth),V.end(V.depth));}}}},[_,s,B,h,f,W,c]),ke=zl.useCallback(M=>{if(!b)return;M.preventDefault();let F=_(),N=F?.getView();if(!F||!N)return;let A=re=>{let X=N.state.doc.nodeAt(re);if(!X||X.type.name!=="image")return null;let oe=X.attrs.wrapType??"inline",le=X.attrs.cssFloat;return {pos:re,wrapType:oe,cssFloat:le}},z=null,V=layoutPainter.hitTestImage(M.target);if(V&&(z=A(V.pos),z&&(z.inlinePositionEmu=layoutPainter.captureInlinePositionEmu(V.imageEl,l))),!z){let re=N.state.selection;if(re instanceof prosemirrorState.NodeSelection&&re.node.type.name==="image"&&(z=A(re.from),z)){let X=t.current?.querySelector(`.layout-run-image[data-pm-start="${re.from}"]`);X&&(z.inlinePositionEmu=layoutPainter.captureInlinePositionEmu(X,l));}}let{from:se,to:ee}=N.state.selection,$=B(M.clientX,M.clientY);$!==null&&(se===ee||$<se||$>ee)&&(F.setSelection($),F.focus(),s||y(true));let de=N.state.selection.from!==N.state.selection.to;b({x:M.clientX,y:M.clientY,hasSelection:de,image:z});},[_,s,b,B,l,t,y]),Ce=zl.useCallback(()=>k(null),[]);return {handlePagesMouseDown:Z,handlePagesMouseMove:te,handlePagesClick:me,handlePagesContextMenu:ke,handleTableInsertClick:ne,tableInsertButton:T,clearTableInsertTimer:I,hideTableInsertButton:Ce,getPositionFromMouse:B}}function _g(e,t){let o=e?.package;if(!o)return null;let r=n=>{if(!n)return null;for(let[u,d]of n)if(d===t)return u;return null};return r(o.headers)??r(o.footers)}function Es(e){let{hiddenPMRef:t,hiddenHfPMsRef:o,documentRef:r,layout:n,runLayoutPipeline:u,scrollToPositionImpl:d,scrollToParaIdImpl:l,scrollToPageImpl:m,setIsFocused:s}=e;return {getDocument:()=>t.current?.getDocument()??null,getState:()=>t.current?.getState()??null,getView:()=>t.current?.getView()??null,focus:()=>{t.current?.focus(),s(true);},blur:()=>{t.current?.blur(),s(false);},isFocused:()=>t.current?.isFocused()??false,dispatch:a=>t.current?.dispatch(a),undo:()=>t.current?.undo()??false,redo:()=>t.current?.redo()??false,setSelection:(a,b)=>t.current?.setSelection(a,b),getLayout:()=>n,relayout:()=>{let a=t.current?.getState();a&&u(a);},scrollToPosition:d,scrollToParaId:l,scrollToPage:m,highlightRange:(a,b)=>{let f=t.current?.getView()??null;if(!f)return;let h=queries.clampRangeToDoc(f.state.doc,a,b);h&&(t.current?.setSelection(h.from,h.to),d(h.from,true));},scrollToCommentId:a=>{let b=t.current?.getView()??null,f=queries.findCommentRange(b,a);return f?(t.current?.setSelection(f.from,f.to),d(f.from,true),true):false},scrollToChangeId:a=>{let b=t.current?.getView()??null,f=queries.findChangeRange(b,a);return f?(t.current?.setSelection(f.from,f.to),d(f.from,true),true):false},getHfPmView:a=>{let b=_g(r.current,a);return b?o.current?.getView(b)??null:null}}}function Is(e){let{ref:t,hiddenPMRef:o,hiddenHfPMsRef:r,documentRef:n,layout:u,runLayoutPipeline:d,scrollToPositionImpl:l,scrollToParaIdImpl:m,scrollToPageImpl:s,setIsFocused:a,onReadyRef:b}=e;zl.useImperativeHandle(t,()=>Es({hiddenPMRef:o,hiddenHfPMsRef:r,documentRef:n,layout:u,runLayoutPipeline:d,scrollToPositionImpl:l,scrollToParaIdImpl:m,scrollToPageImpl:s,setIsFocused:a}),[u,d,l,m,s]),zl.useEffect(()=>{b.current&&o.current&&b.current(Es({hiddenPMRef:o,hiddenHfPMsRef:r,documentRef:n,layout:u,runLayoutPipeline:d,scrollToPositionImpl:l,scrollToParaIdImpl:m,scrollToPageImpl:s,setIsFocused:a}));},[u,d,m,s]);}function Ms(e){let{hiddenPMRef:t,runLayoutPipeline:o,updateSelectionOverlay:r,headerContent:n,footerContent:u,firstPageHeaderContent:d,firstPageFooterContent:l}=e;zl.useEffect(()=>{let s=()=>{let a=t.current?.getView();a&&(layoutBridge.resetCanvasContext(),layoutBridge.clearAllCaches(),o(a.state),r(a.state));};return window.document.fonts.addEventListener("loadingdone",s),()=>{window.document.fonts.removeEventListener("loadingdone",s);}},[]);let m=zl.useRef(0);zl.useEffect(()=>{if(m.current===0){m.current=1;return}let s=t.current?.getView();s&&o(s.state);},[n,u,d,l,o,t]);}function Ds({type:e,x:t,y:o,onMouseDown:r,onMouseEnter:n,onMouseLeave:u}){let d=e==="row"?"Insert row below":"Insert column to the right";return jsxRuntime.jsx("button",{type:"button",onMouseDown:r,onMouseEnter:n,onMouseLeave:u,style:{position:"absolute",left:t,top:o,width:20,height:20,borderRadius:"4px",border:"1px solid var(--doc-border-light)",backgroundColor:"var(--doc-bg)",color:"var(--doc-text-muted)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:200,padding:0,boxShadow:"none"},title:d,"aria-label":d,children:jsxRuntime.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M6 1v10M1 6h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})}var As={position:"absolute",zIndex:1e4,background:"var(--doc-surface)",borderRadius:"8px",boxShadow:"0 1px 3px var(--doc-shadow), 0 4px 12px var(--doc-shadow-subtle)",border:"1px solid var(--doc-border-light)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px"},Gg={...As,padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",maxWidth:"400px"},Kg={...As,padding:"12px",width:"320px"},wr={width:"20px",height:"20px",flexShrink:0,color:"var(--doc-text-muted)",display:"flex",alignItems:"center",justifyContent:"center"},jg={color:"var(--doc-link)",textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"220px",fontSize:"14px",lineHeight:"20px",cursor:"pointer"},Yg={width:"28px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"none",borderRadius:"4px",cursor:"pointer",color:"var(--doc-text-muted)",padding:0,flexShrink:0},qg={width:"1px",height:"20px",background:"var(--doc-border-light)",flexShrink:0},Fs={display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},Ls={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border-light)",borderRadius:"4px",fontSize:"14px",outline:"none",lineHeight:"20px"},Xg={color:"var(--doc-primary)",fontWeight:600,fontSize:"14px",border:"none",background:"none",cursor:"pointer",padding:"6px 12px",borderRadius:"4px",flexShrink:0},Jt={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};function Zg(){return jsxRuntime.jsxs("svg",{...Jt,children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M2 12h20"}),jsxRuntime.jsx("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"})]})}function Qg(){return jsxRuntime.jsxs("svg",{...Jt,children:[jsxRuntime.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsxRuntime.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function Jg(){return jsxRuntime.jsx("svg",{...Jt,children:jsxRuntime.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}function eb(){return jsxRuntime.jsxs("svg",{...Jt,children:[jsxRuntime.jsx("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"}),jsxRuntime.jsx("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"}),jsxRuntime.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),jsxRuntime.jsx("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),jsxRuntime.jsx("line",{x1:"16",y1:"19",x2:"16",y2:"22"}),jsxRuntime.jsx("line",{x1:"19",y1:"16",x2:"22",y2:"16"})]})}function tb(){return jsxRuntime.jsxs("svg",{...Jt,children:[jsxRuntime.jsx("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),jsxRuntime.jsx("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),jsxRuntime.jsx("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),jsxRuntime.jsx("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function ob(){return jsxRuntime.jsxs("svg",{...Jt,children:[jsxRuntime.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),jsxRuntime.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function Er({title:e,onClick:t,children:o}){return jsxRuntime.jsx("button",{type:"button",className:"ep-hyperlink-popup__icon-btn",style:Yg,title:e,onClick:t,children:o})}function Os({data:e,onNavigate:t,onCopy:o,onEdit:r,onRemove:n,onClose:u,readOnly:d}){let{t:l}=chunkGNIO6SOS_js.b(),[m,s]=zl.useState("view"),[a,b]=zl.useState(""),[f,h]=zl.useState(""),i=zl.useRef(null),p=zl.useRef(null);zl.useEffect(()=>{e&&(s("view"),b(e.displayText),h(e.href));},[e]),zl.useEffect(()=>{m==="edit"&&requestAnimationFrame(()=>{p.current?.focus(),p.current?.select();});},[m]),zl.useEffect(()=>{if(!e)return;let C=false,R=k=>{i.current&&!i.current.contains(k.target)&&u();},T=setTimeout(()=>{C||document.addEventListener("mousedown",R);},0);return ()=>{C=true,clearTimeout(T),document.removeEventListener("mousedown",R);}},[e,u]),zl.useEffect(()=>{if(!e)return;let C=R=>{R.key==="Escape"&&(m==="edit"?s("view"):u());};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[e,m,u]);let g=zl.useCallback(()=>{e&&(o(e.href),sonner.toast("Link copied to clipboard"));},[e,o]),x=zl.useCallback(()=>{e&&(b(e.displayText),h(e.href),s("edit"));},[e]),y=zl.useCallback(()=>{let C=f.trim();C&&r(a.trim()||C,C);},[a,f,r]),c=zl.useCallback(C=>{C.key==="Enter"&&(C.preventDefault(),y());},[y]);if(!e)return null;let S=e.position.top,v=e.position.left;return m==="edit"?jsxRuntime.jsxs("div",{ref:i,className:"ep-hyperlink-popup ep-hyperlink-popup--edit",style:{...Kg,top:S,left:v},onMouseDown:C=>C.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:Fs,children:[jsxRuntime.jsx("span",{style:wr,children:jsxRuntime.jsx(tb,{})}),jsxRuntime.jsx("input",{ref:p,type:"text",style:Ls,value:a,onChange:C=>b(C.target.value),onKeyDown:c,placeholder:l("hyperlinkPopup.displayTextPlaceholder"),onFocus:C=>C.target.style.borderColor="var(--doc-primary)",onBlur:C=>C.target.style.borderColor="var(--doc-border-light)"})]}),jsxRuntime.jsxs("div",{style:{...Fs,marginBottom:0},children:[jsxRuntime.jsx("span",{style:wr,children:jsxRuntime.jsx(ob,{})}),jsxRuntime.jsx("input",{type:"text",style:Ls,value:f,onChange:C=>h(C.target.value),onKeyDown:c,placeholder:l("hyperlinkPopup.urlPlaceholder"),onFocus:C=>C.target.style.borderColor="var(--doc-primary)",onBlur:C=>C.target.style.borderColor="var(--doc-border-light)"}),jsxRuntime.jsx("button",{type:"button",style:{...Xg,opacity:f.trim()?1:.5,cursor:f.trim()?"pointer":"default"},onClick:y,disabled:!f.trim(),children:l("common.apply")})]})]}):jsxRuntime.jsxs("div",{ref:i,className:"ep-hyperlink-popup",style:{...Gg,top:S,left:v},onMouseDown:C=>C.stopPropagation(),children:[jsxRuntime.jsx("span",{style:wr,children:jsxRuntime.jsx(Zg,{})}),jsxRuntime.jsx("a",{href:e.href,style:jg,title:e.href,target:"_blank",rel:"noopener noreferrer",onClick:C=>{C.preventDefault(),t(e.href);},children:e.href}),jsxRuntime.jsx("span",{style:qg}),jsxRuntime.jsx(Er,{title:l("hyperlinkPopup.copyLink"),onClick:g,children:jsxRuntime.jsx(Qg,{})}),!d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Er,{title:l("hyperlinkPopup.editLink"),onClick:x,children:jsxRuntime.jsx(Jg,{})}),jsxRuntime.jsx(Er,{title:l("hyperlinkPopup.removeLink"),onClick:n,children:jsxRuntime.jsx(eb,{})})]})]})}var ub=zl.forwardRef(function(t,o){let{document:r,styles:n,theme:u,sectionProperties:d,finalSectionProperties:l,headerContent:m,footerContent:s,firstPageHeaderContent:a,firstPageFooterContent:b,readOnly:f=false,pageGap:h=24,zoom:i=1,onDocumentChange:p,onSelectionChange:g,externalPlugins:x=za,extensionManager:y,onReady:c,onRenderedDomContextReady:S,pluginOverlays:v,onHeaderFooterDoubleClick:C,hfEditMode:R,onBodyClick:T,onHfTransaction:k,className:E,style:I,commentsSidebarOpen:w=false,sidebarOverlay:D,scrollContainerRef:H,onHyperlinkClick:O,onContextMenu:B,onAnchorPositionsChange:_,onTotalPagesChange:W,resolvedCommentIds:Z,hyperlinkPopupData:Y,onHyperlinkPopupNavigate:J,onHyperlinkPopupCopy:te,onHyperlinkPopupEdit:ne,onHyperlinkPopupRemove:me,onHyperlinkPopupClose:ke}=t,Ce=zl.useCallback(()=>H&&typeof H=="object"?H.current:M.current,[H]),M=zl.useRef(null),F=zl.useRef(null),N=zl.useRef(null),A=zl.useRef(null),z=zl.useRef(null),V=zl.useRef(r);V.current=r;let{handlePMKeyDown:se}=chunkLNONBJQM_js.a({pagesContainerRef:F}),ee=zl.useRef(g),$=zl.useRef(p),de=zl.useRef(c),re=zl.useRef(S);ee.current=g,$.current=p,de.current=c,re.current=S;let[X,oe]=zl.useState(false);zl.useEffect(()=>{if(R){let G=A.current?.getView();if(G){try{let ye=G.state.tr.setSelection(prosemirrorState.TextSelection.create(G.state.doc,0));G.dispatch(ye);}catch{}G.dom.blur?.();}oe(false);}},[R]);let le=zl.useRef(false),Re=zl.useMemo(()=>new LayoutSelectionGate.LayoutSelectionGate,[]),Q=zl.useCallback(G=>{let ye=z.current;if(!ye)return null;let ge=r?.package;if(!ge)return null;let pe=Gt=>{if(!Gt)return null;for(let[lo,co]of Gt)if(co===G)return lo;return null},tt=pe(ge.headers)??pe(ge.footers);return tt?ye.getView(tt)?.state.doc??null:null},[r]),{layout:he,blocks:Pe,measures:Ae,decorationSyncToken:Oe,notifyDecorationLayer:De,contentWidth:He,runLayoutPipeline:q,scheduleLayout:ue}=is({document:r,styles:n,theme:u,sectionProperties:d,finalSectionProperties:l,headerContent:m,footerContent:s,firstPageHeaderContent:a,firstPageFooterContent:b,getHfPmDoc:Q,pageGap:h,zoom:i,resolvedCommentIds:Z,pagesContainerRef:F,viewportLayoutRef:N,hiddenPMRef:A,syncCoordinator:Re,getScrollContainer:Ce,onTotalPagesChange:W,onAnchorPositionsChange:_,onRenderedDomContextReady:S}),{selectionRects:ce,caretPosition:fe,selectedImageInfo:we,setSelectionRects:Se,setCaretPosition:et,setSelectedImageInfo:ae,buildImageSelectionInfo:ze,updateSelectionOverlay:Te,handleSelectionChange:_e}=ls({layout:he,blocks:Pe,measures:Ae,zoom:i,containerRef:M,pagesContainerRef:F,hiddenPMRef:A,syncCoordinator:Re,isImageInteractingRef:le,onSelectionChangeRef:ee}),Pt=zl.useCallback((G,ye)=>{if(De(),G.docChanged){Re.incrementStateSeq(),ue(ye);let ge=A.current?.getDocument();ge&&$.current?.(ge);}Re.requestRender(),G.docChanged||Te(ye);},[ue,Te,Re,De]),{scrollToPositionImpl:Ao,scrollToPageImpl:Vt,scrollToParaIdImpl:Tt}=ms({layout:he,blocks:Pe,measures:Ae,pagesContainerRef:F,hiddenPMRef:A,getScrollContainer:Ce}),{handlePagesMouseDown:Hn,handlePagesMouseMove:wt,handlePagesClick:Fn,handlePagesContextMenu:ht,handleTableInsertClick:Ut,tableInsertButton:Et,clearTableInsertTimer:io,hideTableInsertButton:ao,getPositionFromMouse:It}=ws({pagesContainerRef:F,hiddenPMRef:A,getHfView:zl.useCallback(()=>{let G=z.current;if(!G)return null;let ye=r?.package?.document?.finalSectionProperties,ge=R==="header"?ye?.headerReferences:ye?.footerReferences,pe=ge?.find(tt=>tt.type==="default")??ge?.find(tt=>tt.type==="first")??null;return pe?.rId?G.getView(pe.rId):null},[R,r]),layout:he,blocks:Pe,measures:Ae,zoom:i,readOnly:f,hfEditMode:R,onBodyClick:T,onContextMenu:B,onHyperlinkClick:O,onHeaderFooterDoubleClick:C,setSelectedImageInfo:ae,setSelectionRects:Se,setCaretPosition:et,buildImageSelectionInfo:ze,setIsFocused:oe,scrollToPositionImpl:Ao}),Ln=zl.useCallback(G=>{if(f)return;let ye=G.target;ye.closest(".docx-comments-sidebar")||ye.closest(".docx-unified-sidebar")||ye.closest(".ep-hyperlink-popup")||ye.closest("[data-hf-r-id]")||(A.current?.focus(),oe(true));},[f]),An=zl.useCallback(G=>{let ye=G.relatedTarget;ye&&M.current?.contains(ye)||ye?.closest('[role="toolbar"], [data-radix-popper-content-wrapper], [data-radix-select-content], .docx-table-options-dropdown')||oe(false);},[]),{handleImageResize:Oo,handleImageResizeStart:On,handleImageResizeEnd:Bn,handleImageDragMove:kt,handleImageDragStart:Nn,handleImageDragEnd:Ye}=ds({pagesContainerRef:F,hiddenPMRef:A,zoom:i,isImageInteractingRef:le,getPositionFromMouse:It}),zn=zl.useCallback(G=>{if(f)return;let ye=G.target;if(!ye?.closest("[data-hf-r-id]")&&!ye?.closest(".ep-hyperlink-popup")){if(A.current?.isFocused()||(A.current?.focus(),oe(true)),G.key===" "&&!G.ctrlKey&&!G.metaKey&&!G.nativeEvent.isComposing){G.preventDefault();let ge=A.current?.getView();if(ge){let{from:pe,to:tt}=ge.state.selection;ge.someProp("handleTextInput",lo=>lo(ge,pe,tt," "))||ge.dispatch(ge.state.tr.insertText(" "));}return}if(["PageUp","PageDown"].includes(G.key)&&!G.metaKey&&G.ctrlKey,G.key==="Home"&&(G.metaKey||G.ctrlKey)){let ge=Ce();ge&&(ge.scrollTop=0);}if(G.key==="End"&&(G.metaKey||G.ctrlKey)){let ge=Ce();ge&&(ge.scrollTop=ge.scrollHeight);}}},[f,Ce]),_n=zl.useCallback(G=>{f||G.target.closest(".docx-comments-sidebar")||G.target.closest(".docx-unified-sidebar")||A.current?.isFocused()||(A.current?.focus(),oe(true));},[f]),so=zl.useCallback(G=>{q(G.state),Te(G.state),f||requestAnimationFrame(()=>{G.focus(),oe(true);});},[q,Te,f]);Ms({hiddenPMRef:A,runLayoutPipeline:q,updateSelectionOverlay:Te,headerContent:m,footerContent:s,firstPageHeaderContent:a,firstPageFooterContent:b}),Is({ref:o,hiddenPMRef:A,hiddenHfPMsRef:z,documentRef:V,layout:he,runLayoutPipeline:q,scrollToPositionImpl:Ao,scrollToParaIdImpl:Tt,scrollToPageImpl:Vt,setIsFocused:oe,onReadyRef:de});let $t=zl.useMemo(()=>he?ln(he,h):layoutBridge.DEFAULT_PAGE_HEIGHT_PX+24+24,[he,h]);return jsxRuntime.jsxs("div",{ref:M,className:`ep-root paged-editor ${E??""}`,style:{..._a,...I},tabIndex:0,onFocus:Ln,onBlur:An,onKeyDown:zn,onMouseDown:_n,children:[jsxRuntime.jsx(Ra,{ref:A,document:r,styles:n,widthPx:He,readOnly:f||!!R,onTransaction:Pt,onSelectionChange:_e,externalPlugins:x,extensionManager:y,onEditorViewReady:so,onKeyDown:se}),jsxRuntime.jsx(mr,{ref:z,document:r,styles:n,theme:u,defaultTabStopTwips:r?.package?.settings?.defaultTabStop??null,onTransaction:(G,ye,ge)=>{if(ge){let pe=A.current?.getState();pe&&q(pe);}k?.(G,ye,ge);}}),jsxRuntime.jsxs("div",{ref:N,style:{...Wa,minHeight:$t,marginBottom:i!==1?$t*(i-1):void 0,transform:(()=>{let G=[];return w&&G.push(`translateX(-${sidebarConstants.SIDEBAR_DOCUMENT_SHIFT}px)`),i!==1&&G.push(`scale(${i})`),G.length>0?G.join(" "):void 0})(),transformOrigin:"top center",transition:"transform 0.2s ease"},children:[jsxRuntime.jsx("div",{ref:F,className:`paged-editor__pages${f?" paged-editor--readonly":""}${R?` paged-editor--hf-editing paged-editor--editing-${R}`:""}`,style:Va,onMouseDown:Hn,onMouseMove:wt,onClick:Fn,onContextMenu:ht,"aria-hidden":"true"}),jsxRuntime.jsx(wa,{selectionRects:R?[]:ce,caretPosition:R?null:fe,isFocused:X&&!R,pageGap:h,readOnly:f}),jsxRuntime.jsx(Ha,{imageInfo:we,zoom:i,isFocused:X,onResize:Oo,onResizeStart:On,onResizeEnd:Bn,onDragMove:kt,onDragStart:Nn,onDragEnd:Ye,onContextMenu:ht}),Et&&jsxRuntime.jsx(Ds,{type:Et.type,x:Et.x,y:Et.y,onMouseDown:Ut,onMouseEnter:io,onMouseLeave:ao}),v&&jsxRuntime.jsx("div",{className:"paged-editor__plugin-overlays",style:Ua,children:v}),jsxRuntime.jsx(Aa,{getView:()=>A.current?.getView()??null,getPagesContainer:()=>F.current,zoom:i,decorationSyncToken:Oe,syncCoordinator:Re})]}),D&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:$t*i,pointerEvents:"none",overflow:"visible"},children:jsxRuntime.jsx("div",{style:{pointerEvents:"auto"},children:D})}),Y&&J&&te&&ne&&me&&ke&&jsxRuntime.jsx(Os,{data:Y,onNavigate:J,onCopy:te,onEdit:ne,onRemove:me,onClose:ke,readOnly:f})]})}),_s=zl.memo(ub);var Us={position:"absolute",left:0,right:0,bottom:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"2px 0",fontSize:11,color:"var(--doc-primary)",userSelect:"none",pointerEvents:"auto"},$s={fontWeight:500,letterSpacing:.3},vb={background:"none",border:"none",color:"var(--doc-primary)",cursor:"pointer",fontSize:11,padding:"2px 6px",borderRadius:3},Cb={position:"absolute",right:0,top:"100%",background:"var(--doc-surface)",border:"1px solid var(--doc-border-light)",borderRadius:4,boxShadow:"0 2px 6px var(--doc-shadow)",zIndex:chunkGDJM7SOG_js.h.dropdown,minWidth:160,padding:"4px 0"},fn={display:"block",width:"100%",padding:"6px 12px",border:"none",background:"none",textAlign:"left",cursor:"pointer",fontSize:12,color:"var(--doc-text)"},Ks=zl.forwardRef(function({headerFooter:t,position:o,view:r,targetElement:n,parentElement:u,onSave:d,onClose:l,onRemove:m},s){let a=zl.useRef(r);a.current=r;let[b,f]=zl.useState(false),h=zl.useRef(null),[i,p]=zl.useState(null);zl.useLayoutEffect(()=>{let R=()=>{let k=u.getBoundingClientRect(),E=n.getBoundingClientRect();p({top:E.top-k.top+u.scrollTop,left:E.left-k.left+u.scrollLeft,width:E.width,height:E.height});};R();let T=u.closest('[style*="overflow"]')||u;return T.addEventListener("scroll",R),window.addEventListener("resize",R),()=>{T.removeEventListener("scroll",R),window.removeEventListener("resize",R);}},[n,u]);let g=zl.useRef(false);zl.useEffect(()=>{!r||g.current||(g.current=true,requestAnimationFrame(()=>r.focus()));},[r]);let x=zl.useCallback(()=>{if(!a.current)return;let R=conversion.proseDocToBlocks(a.current.state.doc);d(R);},[d]),y=zl.useCallback(()=>{x(),l();},[x,l]);zl.useEffect(()=>{function R(T){T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),y());}return document.addEventListener("keydown",R,true),()=>document.removeEventListener("keydown",R,true)},[y]),zl.useEffect(()=>{if(!b)return;function R(T){h.current&&!h.current.contains(T.target)&&f(false);}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[b]),zl.useImperativeHandle(s,()=>({getView:()=>a.current,focus:()=>a.current?.focus(),undo:()=>{let R=a.current;return R?prosemirrorHistory.undo(R.state,R.dispatch):false},redo:()=>{let R=a.current;return R?prosemirrorHistory.redo(R.state,R.dispatch):false}}));let{t:c}=chunkGNIO6SOS_js.b(),S=c(o==="header"?"headerFooter.header":"headerFooter.footer");if(!i)return null;let v={position:"absolute",top:i.top,left:i.left,width:i.width,height:i.height,zIndex:chunkGDJM7SOG_js.h.hfInlineEditor,pointerEvents:"none"},C={...Us,bottom:"auto",top:"100%"};return jsxRuntime.jsxs("div",{className:"hf-inline-editor",style:v,children:[o==="footer"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:C,children:[jsxRuntime.jsx("span",{style:$s,children:S}),jsxRuntime.jsx(Gs,{label:S,showOptions:b,setShowOptions:f,optionsRef:h,onRemove:m,onClose:y,viewRef:a})]}),o==="header"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:Us,children:[jsxRuntime.jsx("span",{style:$s,children:S}),jsxRuntime.jsx(Gs,{label:S,showOptions:b,setShowOptions:f,optionsRef:h,onRemove:m,onClose:y,viewRef:a})]})]})});function Gs({label:e,showOptions:t,setShowOptions:o,optionsRef:r,onRemove:n,onClose:u,viewRef:d}){let{t:l}=chunkGNIO6SOS_js.b(),m=s=>{let a=d.current;if(!a)return;let{$from:b,from:f}=a.state.selection,h=a.state.storedMarks||b.marks(),i=prosemirror.schema.nodes.field.create({fieldType:s,instruction:` ${s} \\* MERGEFORMAT `,fieldKind:"simple",dirty:true}),p=a.state.tr.insert(f,i.mark(h));a.dispatch(p),a.focus();};return jsxRuntime.jsxs("div",{style:{position:"relative"},ref:r,children:[jsxRuntime.jsxs("button",{type:"button",style:vb,onClick:s=>{s.stopPropagation(),o(a=>!a);},onMouseDown:s=>s.stopPropagation(),children:[l("headerFooter.options")," \u25BE"]}),t&&jsxRuntime.jsxs("div",{style:Cb,onMouseDown:s=>s.stopPropagation(),children:[jsxRuntime.jsx("button",{type:"button",style:fn,onClick:()=>{o(false),m("PAGE");},onMouseOver:s=>{s.target.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:s=>{s.target.style.backgroundColor="transparent";},children:l("headerFooter.insertPageNumber")}),jsxRuntime.jsx("button",{type:"button",style:fn,onClick:()=>{o(false),m("NUMPAGES");},onMouseOver:s=>{s.target.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:s=>{s.target.style.backgroundColor="transparent";},children:l("headerFooter.insertTotalPages")}),jsxRuntime.jsx("div",{style:{borderTop:"1px solid var(--doc-border-light)",margin:"4px 0"}}),n&&jsxRuntime.jsx("button",{type:"button",style:fn,onClick:()=>{o(false),n();},onMouseOver:s=>{s.target.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:s=>{s.target.style.backgroundColor="transparent";},children:l("headerFooter.remove",{label:e.toLowerCase()})}),jsxRuntime.jsx("button",{type:"button",style:fn,onClick:()=>{o(false),u();},onMouseOver:s=>{s.target.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:s=>{s.target.style.backgroundColor="transparent";},children:l("headerFooter.closeEditing",{label:e.toLowerCase()})})]})]})}var js=resolveItemPositions.resolveItemPositions;function Xs({items:e,anchorPositions:t,renderedDomContext:o,pageWidth:r,zoom:n,editorContainerRef:u,onExpandedItemChange:d,activeItemId:l}){let{t:m}=chunkGNIO6SOS_js.b(),s=l??null,a=zl.useRef(s);a.current=s;let[b,f]=zl.useState(false),h=zl.useRef(new Map),i=zl.useRef(new Map),p=zl.useRef(new Set),g=zl.useRef(null),x=zl.useRef(new Map),y=zl.useRef(new Map),[c,S]=zl.useState(0),v=zl.useMemo(()=>js(e,t,o,n,h.current,i.current),[e,t,o,n,c]),C=v.length>0,R=zl.useMemo(()=>{let I=new Map;for(let w of v)I.set(w.item.id,w.y);return I},[v]);zl.useEffect(()=>{for(let I of v)p.current.add(I.item.id);},[v]);let T=zl.useCallback(()=>{let I=false;for(let[w,D]of x.current){let H=D.offsetHeight;h.current.get(w)!==H&&(h.current.set(w,H),I=true);}I&&S(w=>w+1);},[]);zl.useEffect(()=>{let I=requestAnimationFrame(T),w=setTimeout(()=>{T(),f(true);},400);return ()=>{cancelAnimationFrame(I),clearTimeout(w);}},[e.length,T]),zl.useEffect(()=>{let I=u?.current;if(!I)return;let w=new ResizeObserver(()=>{requestAnimationFrame(()=>S(D=>D+1));});return w.observe(I),()=>w.disconnect()},[u]),zl.useEffect(()=>{let I=requestAnimationFrame(T);return ()=>cancelAnimationFrame(I)},[s,T]),zl.useEffect(()=>{if(!s)return;let I=x.current.get(s);if(!I){let H=requestAnimationFrame(()=>S(O=>O+1));return ()=>cancelAnimationFrame(H)}let w,D=new ResizeObserver(()=>{cancelAnimationFrame(w),w=requestAnimationFrame(()=>{h.current.set(s,I.offsetHeight),S(H=>H+1);});});return D.observe(I),()=>{cancelAnimationFrame(w),D.disconnect();}},[s]);let k=zl.useCallback(I=>{let w=y.current.get(I);return w||(w=D=>{D?(x.current.set(I,D),h.current.set(I,D.offsetHeight)):(x.current.delete(I),h.current.delete(I));},y.current.set(I,w)),w},[]),E=zl.useCallback(I=>{d?.(a.current===I?null:I);},[d]);return e.length===0?null:jsxRuntime.jsx("aside",{ref:g,className:"docx-unified-sidebar",role:"complementary","aria-label":m("sidebar.ariaLabel"),style:{position:"absolute",top:0,left:`calc(50% - ${sidebarConstants.SIDEBAR_DOCUMENT_SHIFT}px + ${r*n/2+sidebarConstants.SIDEBAR_PAGE_GAP}px)`,width:sidebarConstants.SIDEBAR_WIDTH,fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,backgroundColor:"transparent",overflowY:"visible",overflowX:"visible",opacity:C?1:0,transition:"opacity 0.15s ease"},onMouseDown:I=>I.stopPropagation(),children:jsxRuntime.jsx("div",{style:{position:"relative"},children:e.map(I=>{let w=R.get(I.id),D=s===I.id,O=!p.current.has(I.id)&&w!==void 0,B=C&&!R.has(I.id),_=C?w!==void 0?{position:"absolute",top:w,left:0,right:0,opacity:1}:{position:"absolute",top:0,left:0,right:0,opacity:0,visibility:"hidden"}:{marginBottom:6},W=B?"none":O||I.isTemporary?"opacity 0.2s ease":b?"opacity 0.2s ease, top 0.15s ease":"none";return jsxRuntime.jsx("div",{style:{..._,transition:W},children:I.render({isExpanded:D,onToggleExpand:()=>E(I.id),measureRef:k(I.id)})},I.id)})})})}function Zs({comments:e,anchorPositions:t,zoom:o,pageWidth:r,sidebarOpen:n,resolvedCommentIds:u,onMarkerClick:d}){let{t:l}=chunkGNIO6SOS_js.b(),s=e.filter(a=>a.parentId==null).map(a=>{let b=u.has(a.id);if(!b&&n||b&&n)return null;let f=t.get(`comment-${a.id}`);return f==null?null:{comment:a,isResolved:b,y:f}}).filter(Boolean);return s.length===0?null:jsxRuntime.jsx("div",{className:"docx-comment-margin-markers",style:{position:"absolute",top:0,left:`calc(50% + ${r*o/2+6}px)`,zIndex:30,pointerEvents:"none"},onMouseDown:a=>a.stopPropagation(),children:s.map(({comment:a,isResolved:b,y:f})=>jsxRuntime.jsx("button",{onClick:()=>d(a.id),title:l(b?"commentMarkers.resolvedComment":"commentMarkers.comment"),style:{position:"absolute",top:f*o,left:0,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",borderRadius:4,background:"transparent",cursor:"pointer",pointerEvents:"auto",color:"var(--doc-text-muted)",padding:0,fontFamily:"inherit"},onMouseOver:h=>{h.currentTarget.style.opacity="0.7";},onMouseOut:h=>{h.currentTarget.style.opacity="1";},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:b?"chat_bubble_check":"chat_bubble_outline",size:18})},a.id))})}function el({pagedEditorRef:e,hfEditorRef:t,scrollContainerRef:o,editorContentRef:r,document:n,theme:u,initialSectionProperties:d,finalSectionProperties:l,headerContent:m,footerContent:s,firstPageHeaderContent:a,firstPageFooterContent:b,hfEditPosition:f,setHfEditPosition:h,hfEditIsFirstPage:i,onHeaderFooterDoubleClick:p,onHeaderFooterSave:g,onRemoveHeaderFooter:x,onBodyClick:y,getHfTargetElement:c,zoom:S,readOnly:v,extensionManager:C,externalPlugins:R,onDocumentChange:T,onSelectionChange:k,onPagedSelectionChange:E,onReady:I,onEditorViewReady:w,onRenderedDomContextReady:D,pluginOverlays:H,onHyperlinkClick:O,hyperlinkPopupData:B,onHyperlinkPopupNavigate:_,onHyperlinkPopupCopy:W,onHyperlinkPopupEdit:Z,onHyperlinkPopupRemove:Y,onHyperlinkPopupClose:J,onContextMenu:te,sidebarOpen:ne,sidebarItems:me,anchorPositions:ke,onAnchorPositionsChange:Ce,pluginRenderedDomContext:M,pageWidthPx:F,expandedSidebarItem:N,setExpandedSidebarItem:A,comments:z,resolvedCommentIds:V,resolvedIdsForRender:se,setShowCommentsSidebar:ee,onTotalPagesChange:$,floatingCommentBtn:de,isAddingComment:re,setCommentSelectionRange:X,setAddCommentYPosition:oe,setIsAddingComment:le,setFloatingCommentBtn:Re}){let Q=f?i?f==="header"?a:b:f==="header"?m:s:null,[he,Pe]=zl.useState(null),[Ae,Oe]=zl.useState([]),De=zl.useCallback(q=>{let ce=window.document.querySelector(".paged-editor__pages")?.parentElement;if(!ce)return q;let fe=ce.getBoundingClientRect();return {...q,top:q.top-fe.top+ce.scrollTop,left:q.left-fe.left+ce.scrollLeft}},[]),He=zl.useCallback(q=>{if(!f){Pe(null),Oe([]);return}let ue=layoutBridge.computeHfCaretRectFromView(q,f);Pe(ue?De(ue):null),Oe(layoutBridge.computeHfSelectionRectsFromView(q,f).map(De));let ce=window.document.querySelector(".paged-editor__pages");ce&&layoutBridge.applyCellSelectionHighlight(ce,q.state,{scope:f});},[f,De]);return zl.useEffect(()=>{if(!f){Pe(null),Oe([]),layoutBridge.invalidateHfDomCache();return}let q=()=>{let Se=t.current?.getView();Se&&He(Se);},ue=window.document.querySelector(".paged-editor__pages"),ce=()=>{layoutBridge.invalidateHfDomCache(),q();};ue?.addEventListener("painter:painted",ce);let fe=requestAnimationFrame(q),we=()=>q();return window.addEventListener("resize",we),()=>{cancelAnimationFrame(fe),ue?.removeEventListener("painter:painted",ce),window.removeEventListener("resize",we),layoutBridge.invalidateHfDomCache();}},[f,t,He]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(_s,{ref:e,document:n,styles:n?.package.styles,theme:n?.package.theme||u,sectionProperties:d,finalSectionProperties:l,headerContent:m,footerContent:s,firstPageHeaderContent:a,firstPageFooterContent:b,onHeaderFooterDoubleClick:p,hfEditMode:f,onBodyClick:y,onHfTransaction:(q,ue,ce)=>{let fe=window.document.querySelector(".paged-editor__pages"),we=false,Se=()=>{we||(we=true,layoutBridge.invalidateHfDomCache(),He(ue));};fe?.addEventListener("painter:painted",Se,{once:true}),requestAnimationFrame(()=>{we||(fe?.removeEventListener("painter:painted",Se),Se());}),k(prosemirror.extractSelectionState(ue.state));},zoom:S,readOnly:v,extensionManager:C,onDocumentChange:T,onSelectionChange:E,externalPlugins:R,onReady:q=>{I(q);let ue=q.getView();ue&&w?.(ue);},onRenderedDomContextReady:D,pluginOverlays:H,onHyperlinkClick:O,hyperlinkPopupData:B,onHyperlinkPopupNavigate:_,onHyperlinkPopupCopy:W,onHyperlinkPopupEdit:Z,onHyperlinkPopupRemove:Y,onHyperlinkPopupClose:J,onContextMenu:te,commentsSidebarOpen:ne,onAnchorPositionsChange:Ce,onTotalPagesChange:$,resolvedCommentIds:se,scrollContainerRef:o,sidebarOverlay:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[me.length>0&&jsxRuntime.jsx(Xs,{items:me,anchorPositions:ke,renderedDomContext:M??null,pageWidth:F,zoom:S,editorContainerRef:o,onExpandedItemChange:A,activeItemId:N}),jsxRuntime.jsx(Zs,{comments:z,anchorPositions:ke,zoom:S,pageWidth:F,sidebarOpen:ne,resolvedCommentIds:V,onMarkerClick:()=>ee(true)})]})}),de!=null&&!re&&!v&&jsxRuntime.jsx(chunkGDJM7SOG_js.o,{content:"Add comment",side:"bottom",delayMs:300,children:jsxRuntime.jsx("button",{type:"button",onMouseDown:q=>{q.preventDefault(),q.stopPropagation();let ue=e.current?.getView();if(ue){let{from:ce,to:fe}=ue.state.selection;if(ce!==fe){X({from:ce,to:fe});let we=ue.state.schema.marks.comment.create({commentId:commentIdAllocator.PENDING_COMMENT_ID}),Se=ue.state.tr.addMark(ce,fe,we);Se.setSelection(prosemirrorState.TextSelection.create(Se.doc,fe)),ue.dispatch(Se);}}oe(de.top),ee(true),le(true),Re(null);},style:{position:"absolute",top:de.top,left:de.left,transform:"translate(-50%, -50%)",zIndex:50,width:28,height:28,borderRadius:6,border:"1px solid var(--doc-focus-ring)",backgroundColor:"var(--doc-surface)",color:"var(--doc-primary)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px var(--doc-shadow)",transition:"background-color 0.15s ease, box-shadow 0.15s ease"},onMouseOver:q=>{q.currentTarget.style.backgroundColor="var(--doc-primary-light)",q.currentTarget.style.boxShadow="0 1px 4px var(--doc-focus-ring)";},onMouseOut:q=>{q.currentTarget.style.backgroundColor="var(--doc-surface)",q.currentTarget.style.boxShadow="0 1px 3px var(--doc-shadow)";},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"add_comment",size:16})})}),f&&(he||Ae.length>0)&&(()=>{let q=window.document.querySelector(".paged-editor__pages"),ue=q?.parentElement;return !q||!ue?null:reactDom.createPortal(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[he&&Ae.length===0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("div",{"aria-hidden":"true",style:{position:"absolute",top:he.top,left:he.left,width:2,height:he.height,background:"#4285f4",pointerEvents:"none",zIndex:11,animation:"hf-caret-blink 1.06s steps(1) infinite"}})}),Ae.map((ce,fe)=>jsxRuntime.jsx("div",{"aria-hidden":"true",style:{position:"absolute",top:ce.top,left:ce.left,width:ce.width,height:ce.height,background:"rgba(66, 133, 244, 0.25)",pointerEvents:"none",zIndex:10}},`hf-sel-${fe}-${ce.top}-${ce.left}`))]}),ue)})(),f&&Q&&(()=>{let q=c(f),ue=r.current;if(!q||!ue)return null;let ce=e.current?.getHfPmView(Q)??null;return jsxRuntime.jsx(Ks,{ref:t,headerFooter:Q,position:f,view:ce,targetElement:q,parentElement:ue,onSave:g,onClose:()=>{h(null),Pe(null);},onRemove:x})})()]})}var Ar=".layout-sdt-widget, .layout-inline-sdt-widget";function ol(e){let t=/^sdt@(\d+)$/.exec(e??"");return t?Number(t[1]):null}function Ab(e){if(e==null||e==="")return null;let t=Number(e);return Number.isFinite(t)?t:null}function Ob(e){let t=ol(e.dataset.sdtGroupId)??Ab(e.dataset.sdtPos),o=e.dataset.sdtTag;return t!=null?o?{pos:t,tag:o}:{pos:t}:o?{tag:o}:null}function Bb(e,t){return prosemirror.findContentControlsInPM(e.state.doc,{tag:t})[0]}function Nb(e,t){return t.pos!=null?prosemirror.findContentControlsInPM(e.state.doc).find(o=>o.pos===t.pos):t.tag?Bb(e,t.tag):void 0}function nl({containerRef:e,getView:t}){let[o,r]=zl.useState(null),n=zl.useRef(null),u=zl.useCallback((m,s)=>{let a=t();if(a){try{let b=m.pos!=null?prosemirror.setContentControlValueAtPosTr(a.state,m.pos,s):m.tag?prosemirror.setContentControlValueTr(a.state,{tag:m.tag},s):null;if(!b)return;a.dispatch(b),a.focus();}catch{}r(null);}},[t]);zl.useEffect(()=>{let m=e.current;if(!m)return;let s=i=>{let p=t(),g=i.dataset.sdtWidget,x=Ob(i);if(!p||!g||!x)return;let y=Nb(p,x),c=i.getBoundingClientRect();g==="checkbox"?u(x,{kind:"checkbox",checked:!y?.checked}):g==="dropdown"?r({kind:"dropdown",target:x,items:y?.listItems??[],current:y?.text??"",rect:c}):g==="date"&&r({kind:"date",target:x,current:y?.dateValue??"",rect:c});},a=i=>{let p=t(),g=ol(i.dataset.sdtGroupId);if(!(!p||g==null))try{let x=i.dataset.sdtRepeat==="add"?prosemirror.addRepeatingSectionItemTr(p.state,g):prosemirror.removeRepeatingSectionItemTr(p.state,g);p.dispatch(x),p.focus();}catch{}},b=i=>{let p=i.target;(p?.closest?.(Ar)||p?.closest?.(".layout-sdt-repeat-btn"))&&i.preventDefault();},f=i=>{let p=i.target?.closest?.(".layout-sdt-repeat-btn");if(p){i.preventDefault(),i.stopPropagation(),a(p);return}let g=i.target?.closest?.(Ar);g&&(i.preventDefault(),i.stopPropagation(),s(g));},h=i=>{if(i.key!=="Enter"&&i.key!==" ")return;let p=i.target?.closest?.(Ar);p&&(i.preventDefault(),s(p));};return m.addEventListener("mousedown",b),m.addEventListener("click",f),m.addEventListener("keydown",h),()=>{m.removeEventListener("mousedown",b),m.removeEventListener("click",f),m.removeEventListener("keydown",h);}},[e,t,u]),zl.useEffect(()=>{if(!o)return;let m=a=>{n.current?.contains(a.target)||r(null);},s=a=>{a.key==="Escape"&&r(null);};return document.addEventListener("mousedown",m),document.addEventListener("keydown",s),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",s);}},[o]),zl.useEffect(()=>{if(o?.kind!=="dropdown")return;let m=n.current?.querySelectorAll(".layout-sdt-widget-option");m?.length&&([...m].find(s=>s.getAttribute("aria-selected")==="true")??m[0]).focus();},[o]);let d=m=>{if(m.key!=="ArrowDown"&&m.key!=="ArrowUp")return;let s=[...n.current?.querySelectorAll(".layout-sdt-widget-option")??[]];if(!s.length)return;m.preventDefault();let a=s.indexOf(document.activeElement),b=m.key==="ArrowDown"?(a+1)%s.length:(a-1+s.length)%s.length;s[b].focus();};if(!o)return null;let l={position:"fixed",top:o.rect.bottom+2,left:o.rect.left,zIndex:1e3};return jsxRuntime.jsx("div",{ref:n,className:"layout-sdt-widget-popup",style:l,role:o.kind==="dropdown"?"listbox":void 0,onKeyDown:d,onMouseDown:m=>m.preventDefault(),children:o.kind==="dropdown"?o.items.length===0?jsxRuntime.jsx("div",{className:"layout-sdt-widget-empty",children:"No options"}):o.items.map(m=>{let s=m.displayText===o.current;return jsxRuntime.jsx("button",{type:"button",role:"option","aria-selected":s,className:`layout-sdt-widget-option${s?" is-selected":""}`,onClick:()=>u(o.target,{kind:"dropdown",value:m.value}),children:m.displayText},m.value)}):jsxRuntime.jsx("input",{type:"date",className:"layout-sdt-widget-date",autoFocus:true,defaultValue:o.current,onChange:m=>{m.target.value&&u(o.target,{kind:"date",date:m.target.value});}})})}function rl({commentsLoadedRef:e,trackedChangesLoadedRef:t,setComments:o,setHeadingInfos:r,setShowCommentsSidebar:n,setIsAddingComment:u,setCommentSelectionRange:d,setAddCommentYPosition:l,setFloatingCommentBtn:m,setHfEditPosition:s,setHfEditIsFirstPage:a,setAnchorPositions:b,clearFindReplaceMatches:f,cleanOrphanedCommentsTimerRef:h}){return {resetForNewDocument:zl.useCallback(()=>{e.current=false,t.current=false,o([]),r([]),n(false),u(false),d(null),l(null),m(null),s(null),a(false),b(Zo),f(),h.current&&(clearTimeout(h.current),h.current=null);},[e,t,o,r,n,u,d,l,m,s,a,b,f,h])}}var Gb=zl.createContext(null);function al({children:e}){let t=zl.useMemo(()=>new docxEditorCore.ErrorManager,[]),o=zl.useSyncExternalStore(t.subscribe,t.getSnapshot),r=zl.useCallback((s,a)=>{t.showError(s,a);},[t]),n=zl.useCallback((s,a)=>{t.showWarning(s,a);},[t]),u=zl.useCallback((s,a)=>{t.showInfo(s,a);},[t]),d=zl.useCallback(s=>{t.dismiss(s);},[t]),l=zl.useCallback(()=>{t.clearAll();},[t]),m=zl.useMemo(()=>({notifications:o.notifications,showError:r,showWarning:n,showInfo:u,dismissNotification:d,clearNotifications:l}),[o.notifications,r,n,u,d,l]);return jsxRuntime.jsxs(Gb.Provider,{value:m,children:[e,jsxRuntime.jsx(Kb,{notifications:o.notifications,onDismiss:d})]})}function Kb({notifications:e,onDismiss:t}){let o=e.filter(n=>!n.dismissed);return o.length===0?null:jsxRuntime.jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:o.map(n=>jsxRuntime.jsx(jb,{notification:n,onDismiss:()=>t(n.id)},n.id))})}function jb({notification:e,onDismiss:t}){let{t:o}=chunkGNIO6SOS_js.b(),[r,n]=zl.useState(false),d=(p=>{switch(p){case "error":return {bg:"var(--doc-error-bg)",border:"var(--doc-error)",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"var(--doc-warning)",text:"var(--doc-warning-text)",icon:"var(--doc-warning)"};case "info":return {bg:"var(--doc-primary-light)",border:"var(--doc-primary)",text:"var(--doc-primary)",icon:"var(--doc-primary)"}}})(e.severity),l={background:d.bg,border:`1px solid ${d.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px var(--doc-shadow)",animation:"slideIn 0.3s ease-out"},m={display:"flex",alignItems:"flex-start",gap:"8px"},s={color:d.icon,flexShrink:0},a={flex:1,minWidth:0},b={color:d.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},f={marginTop:"8px",padding:"8px",background:"var(--doc-shadow-subtle)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:d.text,maxHeight:"200px",overflow:"auto"},h={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:d.text},i=p=>{switch(p){case "error":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxRuntime.jsxs("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:l,children:[jsxRuntime.jsx("style",{children:`
13
13
  @keyframes slideIn {
14
14
  from {
15
15
  opacity: 0;
@@ -20,13 +20,13 @@ body { background: white; }
20
20
  transform: translateX(0);
21
21
  }
22
22
  }
23
- `}),jsxRuntime.jsxs("div",{style:m,children:[jsxRuntime.jsx("span",{style:s,children:i(e.severity)}),jsxRuntime.jsxs("div",{style:a,children:[jsxRuntime.jsx("div",{style:h,children:e.message}),e.details&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(!r),style:{...b,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:o(r?"errors.hideDetails":"errors.showDetails")}),r&&jsxRuntime.jsx("div",{style:f,children:e.details})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,style:b,title:o("common.dismiss"),children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var bn=class extends Bl.Component{constructor(o){super(o);chunkBJ5RZW6Y_js.b(this,"resetError",()=>{this.setState({hasError:false,error:null,errorInfo:null});});this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(o){return {hasError:true,error:o}}componentDidCatch(o,r){this.setState({errorInfo:r}),console.error("ErrorBoundary caught an error:",o,r),this.props.onError&&this.props.onError(o,r);}render(){if(this.state.hasError){let{fallback:o,showDetails:r=true}=this.props,{error:n,errorInfo:u}=this.state;return o?typeof o=="function"?o(n,this.resetError):o:jsxRuntime.jsx($b,{error:n,errorInfo:u,showDetails:r,onReset:this.resetError})}return this.props.children}};function $b({error:e,errorInfo:t,showDetails:o,onReset:r}){let{t:n}=chunkGNIO6SOS_js.b(),u={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"var(--doc-surface)",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},d={color:"var(--doc-error)",marginBottom:"16px"},l={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},m={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},s={width:"100%",maxWidth:"600px",marginBottom:"16px",padding:"12px",background:"var(--doc-error-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"200px",overflow:"auto"},a={padding:"10px 20px",background:"var(--doc-primary)",color:"var(--doc-on-primary)",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxRuntime.jsxs("div",{className:"docx-error-fallback",style:u,children:[jsxRuntime.jsx("div",{style:d,children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsxRuntime.jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h2",{style:l,children:n("errors.somethingWentWrong")}),jsxRuntime.jsx("p",{style:m,children:n("errors.errorDescription")}),o&&jsxRuntime.jsxs("div",{style:s,children:[jsxRuntime.jsx("strong",{children:n("errors.errorLabel")})," ",e.message,t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[`
23
+ `}),jsxRuntime.jsxs("div",{style:m,children:[jsxRuntime.jsx("span",{style:s,children:i(e.severity)}),jsxRuntime.jsxs("div",{style:a,children:[jsxRuntime.jsx("div",{style:b,children:e.message}),e.details&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>n(!r),style:{...h,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:o(r?"errors.hideDetails":"errors.showDetails")}),r&&jsxRuntime.jsx("div",{style:f,children:e.details})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,style:h,title:o("common.dismiss"),children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var yn=class extends zl.Component{constructor(o){super(o);chunkBJ5RZW6Y_js.b(this,"resetError",()=>{this.setState({hasError:false,error:null,errorInfo:null});});this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(o){return {hasError:true,error:o}}componentDidCatch(o,r){this.setState({errorInfo:r}),console.error("ErrorBoundary caught an error:",o,r),this.props.onError&&this.props.onError(o,r);}render(){if(this.state.hasError){let{fallback:o,showDetails:r=true}=this.props,{error:n,errorInfo:u}=this.state;return o?typeof o=="function"?o(n,this.resetError):o:jsxRuntime.jsx(Yb,{error:n,errorInfo:u,showDetails:r,onReset:this.resetError})}return this.props.children}};function Yb({error:e,errorInfo:t,showDetails:o,onReset:r}){let{t:n}=chunkGNIO6SOS_js.b(),u={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"var(--doc-surface)",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},d={color:"var(--doc-error)",marginBottom:"16px"},l={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},m={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},s={width:"100%",maxWidth:"600px",marginBottom:"16px",padding:"12px",background:"var(--doc-error-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"200px",overflow:"auto"},a={padding:"10px 20px",background:"var(--doc-primary)",color:"var(--doc-on-primary)",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxRuntime.jsxs("div",{className:"docx-error-fallback",style:u,children:[jsxRuntime.jsx("div",{style:d,children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsxRuntime.jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h2",{style:l,children:n("errors.somethingWentWrong")}),jsxRuntime.jsx("p",{style:m,children:n("errors.errorDescription")}),o&&jsxRuntime.jsxs("div",{style:s,children:[jsxRuntime.jsx("strong",{children:n("errors.errorLabel")})," ",e.message,t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[`
24
24
 
25
- `,jsxRuntime.jsx("strong",{children:n("errors.componentStack")}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:r,style:a,children:n("errors.tryAgain")})]})}var Yb=15840,al=1440,qb=1440,Xb=567,ll=20,Zb="var(--doc-text-muted)",Qb="var(--doc-text-subtle)",Jb="var(--doc-primary)",eh="var(--doc-primary)",th="var(--doc-primary-hover)";function cl({sectionProps:e,zoom:t=1,editable:o=false,onTopMarginChange:r,onBottomMarginChange:n,unit:u="inch",className:d="",style:l}){let{t:m}=chunkGNIO6SOS_js.b(),[s,a]=Bl.useState(null),[h,f]=Bl.useState(null),b=Bl.useRef(null),i=e?.pageHeight??Yb,p=e?.marginTop??al,g=e?.marginBottom??al,x=utils.twipsToPixels(i)*t,y=utils.twipsToPixels(p)*t,c=utils.twipsToPixels(g)*t,S=Bl.useCallback((k,E)=>{o&&(k.preventDefault(),a(E));},[o]),v=Bl.useCallback(k=>{if(!s||!b.current)return;let E=b.current.getBoundingClientRect(),I=k.clientY-E.top,w=utils.pixelsToTwips(I/t);if(s==="topMargin"){let D=i-g-720,H=Math.max(0,Math.min(w,D));r?.(Math.round(H));}else if(s==="bottomMargin"){let D=i-w,H=i-p-720,O=Math.max(0,Math.min(D,H));n?.(Math.round(O));}},[s,t,i,p,g,r,n]),C=Bl.useCallback(()=>{a(null);},[]);Bl.useEffect(()=>{if(s)return document.addEventListener("mousemove",v),document.addEventListener("mouseup",C),()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",C);}},[s,v,C]);let R=nh(i,t,u),P={position:"relative",width:ll,height:utils.formatPx(x),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:s?"ns-resize":"default",...l};return jsxRuntime.jsxs("div",{ref:b,className:`docx-vertical-ruler ${d}`,style:P,role:"slider","aria-label":m("ruler.vertical"),"aria-orientation":"vertical",children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:R.map((k,E)=>jsxRuntime.jsx(oh,{tick:k},E))}),jsxRuntime.jsx(sl,{type:"topMargin",position:y,editable:o,isDragging:s==="topMargin",isHovered:h==="topMargin",onMouseEnter:()=>f("topMargin"),onMouseLeave:()=>f(null),onMouseDown:k=>S(k,"topMargin")}),jsxRuntime.jsx(sl,{type:"bottomMargin",position:x-c,editable:o,isDragging:s==="bottomMargin",isHovered:h==="bottomMargin",onMouseEnter:()=>f("bottomMargin"),onMouseLeave:()=>f(null),onMouseDown:k=>S(k,"bottomMargin")})]})}function oh({tick:e}){let t={position:"absolute",top:utils.formatPx(e.position),right:0,height:1,width:e.width,backgroundColor:Qb},o={position:"absolute",top:utils.formatPx(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:Zb,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:t}),e.label&&jsxRuntime.jsx("div",{style:o,children:e.label})]})}function sl({type:e,position:t,editable:o,isDragging:r,isHovered:n,onMouseEnter:u,onMouseLeave:d,onMouseDown:l}){let{t:m}=chunkGNIO6SOS_js.b(),s=r?th:n?eh:Jb,a={position:"absolute",top:utils.formatPx(t-5),right:0,width:ll,height:10,cursor:o?"ns-resize":"default",zIndex:r?10:1},h={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${s}`,transition:"border-right-color 0.1s"};return jsxRuntime.jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:a,onMouseEnter:u,onMouseLeave:d,onMouseDown:l,role:"slider","aria-label":m(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical",tabIndex:o?0:-1,children:jsxRuntime.jsx("div",{style:h})})}function nh(e,t,o){let r=[];if(o==="inch"){let n=qb/8,u=Math.ceil(e/n);for(let d=0;d<=u;d++){let l=d*n;if(l>e)break;let m=utils.twipsToPixels(l)*t;if(d%8===0){let s=d/8;r.push({position:m,width:10,label:s>0?String(s):void 0});}else d%4===0?r.push({position:m,width:6}):d%2===0?r.push({position:m,width:4}):r.push({position:m,width:2});}}else {let n=Xb/10,u=Math.ceil(e/n);for(let d=0;d<=u;d++){let l=d*n;if(l>e)break;let m=utils.twipsToPixels(l)*t;if(d%10===0){let s=d/10;r.push({position:m,width:10,label:s>0?String(s):void 0});}else d%5===0?r.push({position:m,width:6}):r.push({position:m,width:3});}}return r}var Hr=30,Fr=240,pl=16,lh=24,ml=Hr+Fr+pl,Lr=48,ch=32,fl=Lr+ch+pl,gl=Bl__default.default.memo(function({headings:t,onHeadingClick:o,onClose:r,topOffset:n=0,scrollLeft:u=0}){let{t:d}=chunkGNIO6SOS_js.b(),[l,m]=Bl.useState(false);return Bl.useEffect(()=>{requestAnimationFrame(()=>m(true));},[]),jsxRuntime.jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":d("documentOutline.ariaLabel"),style:{position:"absolute",top:n,left:Hr-u,bottom:0,width:Fr,paddingTop:lh,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:l?"translateX(0)":`translateX(-${Hr+Fr}px)`,transition:"transform 0.15s ease-out"},onMouseDown:s=>s.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px"},children:[jsxRuntime.jsx("button",{onClick:r,"aria-label":d("documentOutline.closeAriaLabel"),style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"var(--doc-text-muted)"},title:d("documentOutline.closeTitle"),children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"arrow_back",size:20})}),jsxRuntime.jsx("span",{style:{fontWeight:400,fontSize:14,color:"var(--doc-text)",letterSpacing:"0.01em"},children:d("documentOutline.title")})]}),jsxRuntime.jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:20},children:t.length===0?jsxRuntime.jsx("div",{style:{padding:"8px 16px",color:"var(--doc-text-subtle)",fontSize:13,lineHeight:"20px"},children:d("documentOutline.noHeadings")}):t.map((s,a)=>jsxRuntime.jsx("div",{style:{marginLeft:s.level*12},children:jsxRuntime.jsx("button",{className:"docx-outline-heading-btn",onClick:()=>o(s.pmPos),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 12px",fontSize:13,fontWeight:400,color:"var(--doc-text)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:s.text,children:s.text})},`${s.pmPos}-${a}`))})]})});function hl({onClick:e,topPx:t,scrollLeft:o=0}){let{t:r}=chunkGNIO6SOS_js.b();return jsxRuntime.jsx("button",{className:"docx-outline-nav",onClick:e,onMouseDown:n=>n.stopPropagation(),title:r("editor.showDocumentOutline"),style:{position:"absolute",left:Lr-o,top:t,zIndex:chunkGDJM7SOG_js.h.outline,background:"transparent",border:"none",borderRadius:"50%",padding:6,cursor:"pointer",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"format_list_bulleted",size:20,style:{color:"var(--doc-text-muted)"}})})}function yl({currentPage:e,totalPages:t,visible:o}){let{t:r}=chunkGNIO6SOS_js.b();return jsxRuntime.jsx("div",{style:{position:"absolute",right:24,top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--doc-overlay)",color:"#fff",padding:"6px 12px",borderRadius:"4px",fontSize:"12px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontWeight:500,whiteSpace:"nowrap",pointerEvents:"none",zIndex:1e3,opacity:o?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:r("viewer.pageIndicator",{current:e,total:t})})}function vl({agentPanel:e,closed:t,onClose:o}){let{t:r}=chunkGNIO6SOS_js.b();return jsxRuntime.jsx(react.AgentPanel,{title:e.title??r("agentPanel.defaultTitle"),icon:e.icon,closeLabel:r("agentPanel.close"),resizeHandleLabel:r("agentPanel.resizeHandle"),defaultWidth:e.defaultWidth,minWidth:e.minWidth,maxWidth:e.maxWidth,onClose:o,closed:t,children:e.render({close:o})})}function Cl({i18n:e,isDark:t,onEditorError:o,containerRef:r,scrollContainerRef:n,editorContentRef:u,className:d,containerStyle:l,mainContentStyle:m,editorContainerStyle:s,showRuler:a,readOnlyProp:h,showOutline:f,showOutlineButton:b,sidebarOpen:i,minLayoutWidth:p,toolbarHeight:g,editorScrollLeft:x,expandedSidebarItem:y,trackedChanges:c,onScrollContainerMouseDown:S,onEditorBgMouseDown:v,onEditorContextMenu:C,horizontalRulerProps:R,verticalRulerProps:P,outlineProps:k,onToggleOutline:E,scrollPageInfo:I,agentPanel:w,agentPanelOpen:D,onAgentPanelClose:H,toolbar:O,pagedArea:B,overlays:_,dialogs:W,fileInputs:Z}){return jsxRuntime.jsx(chunkGNIO6SOS_js.a,{i18n:e,children:jsxRuntime.jsx(nl,{children:jsxRuntime.jsx(bn,{onError:o,children:jsxRuntime.jsxs("div",{ref:r,className:chunkGDJM7SOG_js.a("ep-root docx-editor",t&&"dark",d),style:l,"data-testid":"docx-editor",children:[jsxRuntime.jsxs("div",{style:m,children:[jsxRuntime.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[O,jsxRuntime.jsxs("div",{ref:n,style:s,onMouseDown:S,children:[a&&jsxRuntime.jsx("div",{className:"flex justify-center py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:chunkGDJM7SOG_js.h.ruler,paddingLeft:20,paddingRight:20+(i?sidebarConstants.SIDEBAR_DOCUMENT_SHIFT*2:0),minWidth:p,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(chunkGDJM7SOG_js.F,{...R})}),jsxRuntime.jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:p},children:jsxRuntime.jsxs("div",{ref:u,style:{position:"relative",flex:1,minWidth:0},onMouseDown:v,onContextMenu:C,children:[a&&!h&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:chunkGDJM7SOG_js.h.ruler,paddingTop:48},children:jsxRuntime.jsx(cl,{...P})}),y&&y.startsWith("comment-")&&jsxRuntime.jsx("style",{children:`.paged-editor__pages [data-comment-id="${y.replace("comment-","")}"] { background-color: rgba(255, 212, 0, 0.35) !important; border-bottom: 2px solid rgba(255, 212, 0, 0.7) !important; }`}),y?.startsWith("tc-")&&(()=>{let Y=y.split("-")[1],te=c.find(ne=>String(ne.revisionId)===Y)?.insertionRevisionId;return jsxRuntime.jsx("style",{children:`
25
+ `,jsxRuntime.jsx("strong",{children:n("errors.componentStack")}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:r,style:a,children:n("errors.tryAgain")})]})}var Qb=15840,cl=1440,Jb=1440,eh=567,zt=20,th="var(--doc-text-muted)",oh="var(--doc-text-subtle)",nh="var(--doc-primary)",rh="var(--doc-primary)",ih="var(--doc-primary-hover)";function ul({sectionProps:e,zoom:t=1,editable:o=false,onTopMarginChange:r,onBottomMarginChange:n,unit:u="inch",className:d="",style:l}){let{t:m}=chunkGNIO6SOS_js.b(),[s,a]=zl.useState(null),[b,f]=zl.useState(null),h=zl.useRef(null),i=e?.pageHeight??Qb,p=e?.marginTop??cl,g=e?.marginBottom??cl,x=utils.twipsToPixels(i)*t,y=utils.twipsToPixels(p)*t,c=utils.twipsToPixels(g)*t,S=zl.useCallback((k,E)=>{o&&(k.preventDefault(),a(E));},[o]),v=zl.useCallback(k=>{if(!s||!h.current)return;let E=h.current.getBoundingClientRect(),I=k.clientY-E.top,w=utils.pixelsToTwips(I/t);if(s==="topMargin"){let D=i-g-720,H=Math.max(0,Math.min(w,D));r?.(Math.round(H));}else if(s==="bottomMargin"){let D=i-w,H=i-p-720,O=Math.max(0,Math.min(D,H));n?.(Math.round(O));}},[s,t,i,p,g,r,n]),C=zl.useCallback(()=>{a(null);},[]);zl.useEffect(()=>{if(s)return document.addEventListener("mousemove",v),document.addEventListener("mouseup",C),()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",C);}},[s,v,C]);let R=sh(i,t,u),T={position:"relative",width:zt,height:utils.formatPx(x),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:s?"ns-resize":"default",...l};return jsxRuntime.jsxs("div",{ref:h,className:`docx-vertical-ruler ${d}`,style:T,role:"slider","aria-label":m("ruler.vertical"),"aria-orientation":"vertical",children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:R.map((k,E)=>jsxRuntime.jsx(ah,{tick:k},E))}),jsxRuntime.jsx(dl,{type:"topMargin",position:y,editable:o,isDragging:s==="topMargin",isHovered:b==="topMargin",onMouseEnter:()=>f("topMargin"),onMouseLeave:()=>f(null),onMouseDown:k=>S(k,"topMargin")}),jsxRuntime.jsx(dl,{type:"bottomMargin",position:x-c,editable:o,isDragging:s==="bottomMargin",isHovered:b==="bottomMargin",onMouseEnter:()=>f("bottomMargin"),onMouseLeave:()=>f(null),onMouseDown:k=>S(k,"bottomMargin")})]})}function ah({tick:e}){let t={position:"absolute",top:utils.formatPx(e.position),right:0,height:1,width:e.width,backgroundColor:oh},o={position:"absolute",top:utils.formatPx(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:th,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:t}),e.label&&jsxRuntime.jsx("div",{style:o,children:e.label})]})}function dl({type:e,position:t,editable:o,isDragging:r,isHovered:n,onMouseEnter:u,onMouseLeave:d,onMouseDown:l}){let{t:m}=chunkGNIO6SOS_js.b(),s=r?ih:n?rh:nh,a={position:"absolute",top:utils.formatPx(t-5),right:0,width:zt,height:10,cursor:o?"ns-resize":"default",zIndex:r?10:1},b={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${s}`,transition:"border-right-color 0.1s"};return jsxRuntime.jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:a,onMouseEnter:u,onMouseLeave:d,onMouseDown:l,role:"slider","aria-label":m(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical",tabIndex:o?0:-1,children:jsxRuntime.jsx("div",{style:b})})}function sh(e,t,o){let r=[];if(o==="inch"){let n=Jb/8,u=Math.ceil(e/n);for(let d=0;d<=u;d++){let l=d*n;if(l>e)break;let m=utils.twipsToPixels(l)*t;if(d%8===0){let s=d/8;r.push({position:m,width:10,label:s>0?String(s):void 0});}else d%4===0?r.push({position:m,width:6}):d%2===0?r.push({position:m,width:4}):r.push({position:m,width:2});}}else {let n=eh/10,u=Math.ceil(e/n);for(let d=0;d<=u;d++){let l=d*n;if(l>e)break;let m=utils.twipsToPixels(l)*t;if(d%10===0){let s=d/10;r.push({position:m,width:10,label:s>0?String(s):void 0});}else d%5===0?r.push({position:m,width:6}):r.push({position:m,width:3});}}return r}var Cn=12,Br=240,fl=16,ph=24,gl=Cn+Br+fl,ko=12,mh=36,bl=ko+mh+fl,hl=zl__default.default.memo(function({headings:t,onHeadingClick:o,onClose:r,topOffset:n=0,scrollLeft:u=0,leftOffset:d=Cn}){let{t:l}=chunkGNIO6SOS_js.b(),[m,s]=zl.useState(false),a=t.length?Math.min(...t.map(b=>b.level)):0;return zl.useEffect(()=>{requestAnimationFrame(()=>s(true));},[]),jsxRuntime.jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":l("documentOutline.ariaLabel"),style:{position:"absolute",top:n,left:d-u,bottom:0,width:Br,paddingTop:ph,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:m?"translateX(0)":`translateX(-${d+Br}px)`,transition:"transform 0.15s ease-out"},onMouseDown:b=>b.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px 0"},children:[jsxRuntime.jsx("button",{onClick:r,"aria-label":l("documentOutline.closeAriaLabel"),style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"var(--doc-text-muted)"},title:l("documentOutline.closeTitle"),children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"arrow_back",size:20})}),jsxRuntime.jsx("span",{style:{fontWeight:400,fontSize:14,color:"var(--doc-text)",letterSpacing:"0.01em"},children:l("documentOutline.title")})]}),jsxRuntime.jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:4},children:t.length===0?jsxRuntime.jsx("div",{style:{padding:"8px 16px",color:"var(--doc-text-subtle)",fontSize:13,lineHeight:"20px"},children:l("documentOutline.noHeadings")}):t.map((b,f)=>jsxRuntime.jsx("div",{style:{marginLeft:(b.level-a)*16},children:jsxRuntime.jsx("button",{className:"docx-outline-heading-btn",onClick:()=>o(b.pmPos),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 8px",fontSize:13,fontWeight:400,color:"var(--doc-text)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:b.text,children:b.text})},`${b.pmPos}-${f}`))})]})});function vl({onClick:e,topPx:t,scrollLeft:o=0,leftOffset:r=ko}){let{t:n}=chunkGNIO6SOS_js.b();return jsxRuntime.jsx("button",{className:"docx-outline-toggle",onClick:e,onMouseDown:u=>u.stopPropagation(),title:n("editor.showDocumentOutline"),"aria-label":n("editor.showDocumentOutline"),style:{position:"absolute",left:r-o,top:t,zIndex:chunkGDJM7SOG_js.h.outline},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"format_list_bulleted",size:20})})}function Cl({currentPage:e,totalPages:t,visible:o}){let{t:r}=chunkGNIO6SOS_js.b();return jsxRuntime.jsx("div",{style:{position:"absolute",right:24,top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--doc-overlay)",color:"#fff",padding:"6px 12px",borderRadius:"4px",fontSize:"12px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontWeight:500,whiteSpace:"nowrap",pointerEvents:"none",zIndex:1e3,opacity:o?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:r("viewer.pageIndicator",{current:e,total:t})})}function Sl({agentPanel:e,closed:t,onClose:o}){let{t:r}=chunkGNIO6SOS_js.b();return jsxRuntime.jsx(react.AgentPanel,{title:e.title??r("agentPanel.defaultTitle"),icon:e.icon,closeLabel:r("agentPanel.close"),resizeHandleLabel:r("agentPanel.resizeHandle"),defaultWidth:e.defaultWidth,minWidth:e.minWidth,maxWidth:e.maxWidth,onClose:o,closed:t,children:e.render({close:o})})}function xl({i18n:e,isDark:t,onEditorError:o,containerRef:r,scrollContainerRef:n,editorContentRef:u,className:d,containerStyle:l,mainContentStyle:m,editorContainerStyle:s,showRuler:a,readOnlyProp:b,showOutline:f,showOutlineButton:h,sidebarOpen:i,minLayoutWidth:p,toolbarHeight:g,editorScrollLeft:x,expandedSidebarItem:y,trackedChanges:c,onScrollContainerMouseDown:S,onEditorBgMouseDown:v,onEditorContextMenu:C,horizontalRulerProps:R,verticalRulerProps:T,outlineProps:k,onToggleOutline:E,scrollPageInfo:I,agentPanel:w,agentPanelOpen:D,onAgentPanelClose:H,toolbar:O,pagedArea:B,overlays:_,dialogs:W,fileInputs:Z}){return jsxRuntime.jsx(chunkGNIO6SOS_js.a,{i18n:e,children:jsxRuntime.jsx(al,{children:jsxRuntime.jsx(yn,{onError:o,children:jsxRuntime.jsxs("div",{ref:r,className:chunkGDJM7SOG_js.a("ep-root docx-editor",t&&"dark",d),style:l,"data-testid":"docx-editor",children:[jsxRuntime.jsxs("div",{style:m,children:[jsxRuntime.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[O,jsxRuntime.jsxs("div",{ref:n,style:s,onMouseDown:S,children:[a&&jsxRuntime.jsx("div",{className:"flex justify-center py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:chunkGDJM7SOG_js.h.ruler,paddingLeft:20,paddingRight:20+(i?sidebarConstants.SIDEBAR_DOCUMENT_SHIFT*2:0),minWidth:p,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(chunkGDJM7SOG_js.F,{...R})}),jsxRuntime.jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:p},children:jsxRuntime.jsxs("div",{ref:u,style:{position:"relative",flex:1,minWidth:0},onMouseDown:v,onContextMenu:C,children:[a&&!b&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:chunkGDJM7SOG_js.h.ruler,paddingTop:48},children:jsxRuntime.jsx(ul,{...T})}),y&&y.startsWith("comment-")&&jsxRuntime.jsx("style",{children:`.paged-editor__pages [data-comment-id="${y.replace("comment-","")}"] { background-color: rgba(255, 212, 0, 0.35) !important; border-bottom: 2px solid rgba(255, 212, 0, 0.7) !important; }`}),y?.startsWith("tc-")&&(()=>{let Y=y.split("-")[1],te=c.find(ne=>String(ne.revisionId)===Y)?.insertionRevisionId;return jsxRuntime.jsx("style",{children:`
26
26
  .paged-editor__pages .docx-insertion[data-revision-id="${te??Y}"] { background-color: rgba(52, 168, 83, 0.2) !important; border-bottom: 2px solid #2e7d32 !important; }
27
27
  .paged-editor__pages .docx-deletion[data-revision-id="${Y}"] { background-color: rgba(211, 47, 47, 0.2) !important; text-decoration-thickness: 2px !important; }
28
- `})})(),B]})})]}),I.totalPages>1&&jsxRuntime.jsx(yl,{currentPage:I.currentPage,totalPages:I.totalPages,visible:I.visible}),f&&jsxRuntime.jsx(gl,{...k}),b&&!f&&jsxRuntime.jsx(hl,{onClick:E,topPx:g+(a?30:0)+48,scrollLeft:x})]}),w&&jsxRuntime.jsx(vl,{agentPanel:w,closed:!D,onClose:H})]}),_,W,Z]})})})})}var eo={background:"none",border:"none",cursor:"pointer",padding:4,color:"var(--doc-text-muted)",display:"flex",borderRadius:"50%"},yn={padding:"6px 16px",fontSize:14,border:"none",background:"none",color:"var(--doc-primary)",cursor:"pointer",fontWeight:500,fontFamily:"inherit"};function to(e,t=32){return {width:t,height:t,borderRadius:"50%",backgroundColor:comments.getAvatarColor(e),color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:t===32?13:11,fontWeight:500,flexShrink:0}}function vn(e){return {padding:"6px 16px",fontSize:14,border:"none",borderRadius:20,background:e?"var(--doc-primary)":"var(--doc-bg-hover)",color:e?"#fff":"var(--doc-text-subtle)",cursor:e?"pointer":"default",fontWeight:500,fontFamily:"inherit"}}function xn({replies:e,isExpanded:t}){let{t:o}=chunkGNIO6SOS_js.b();if(e.length===0)return null;let r=t?e:e.slice(-1),n=t?0:e.length-1;return jsxRuntime.jsxs("div",{style:{marginTop:8},children:[n>0&&jsxRuntime.jsx("div",{style:{fontSize:12,fontWeight:500,color:"var(--doc-primary)",paddingTop:6,paddingBottom:6,borderTop:"1px solid var(--doc-border-light)"},children:o("comments.replyCount",{count:n})}),r.map(u=>jsxRuntime.jsxs("div",{style:{marginBottom:t?8:0,paddingTop:8,borderTop:"1px solid var(--doc-border-light)"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:to(u.author||"U",28),children:comments.getInitials(u.author||"U")}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--doc-text)"},children:u.author||o("comments.unknown")}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"var(--doc-text-muted)"},children:comments.formatDate(u.date)})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,color:"var(--doc-text)",lineHeight:"20px",marginTop:4,...t?{}:{overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"}},children:comments.getCommentText(u.content)})]},u.id))]})}var fh={width:"100%",border:"1px solid var(--doc-primary)",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",boxSizing:"border-box",color:"var(--doc-text)"},gh={width:"100%",border:"1px solid var(--doc-border-light)",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",color:"var(--doc-text-subtle)",cursor:"text",backgroundColor:"var(--doc-surface)",boxSizing:"border-box"};function Rn({onSubmit:e}){let[t,o]=Bl.useState(false),[r,n]=Bl.useState(""),{t:u}=chunkGNIO6SOS_js.b();if(!t)return jsxRuntime.jsx("div",{onClick:l=>l.stopPropagation(),style:{marginTop:12},children:jsxRuntime.jsx("input",{readOnly:true,onMouseDown:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),o(true);},placeholder:u("comments.replyPlaceholder"),style:gh})});let d=r.trim();return jsxRuntime.jsxs("div",{onClick:l=>l.stopPropagation(),style:{marginTop:12},children:[jsxRuntime.jsx("input",{ref:l=>l?.focus({preventScroll:true}),type:"text",value:r,onChange:l=>n(l.target.value),onMouseDown:l=>l.stopPropagation(),onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"&&(l.preventDefault(),d&&e(d),n(""),o(false)),l.key==="Escape"&&(o(false),n(""));},placeholder:u("comments.replyPlaceholder"),style:fh}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsxRuntime.jsx("button",{onClick:l=>{l.stopPropagation(),o(false),n("");},style:yn,children:u("common.cancel")}),jsxRuntime.jsx("button",{onClick:l=>{l.stopPropagation(),d&&e(d),n(""),o(false);},disabled:!d,style:vn(!!d),children:u("common.reply")})]})]})}var Pn=cardStyles.CARD_STYLE_COLLAPSED,Tn=cardStyles.CARD_STYLE_EXPANDED;function Rl({comment:e,replies:t,isExpanded:o,onToggleExpand:r,measureRef:n,onReply:u,onResolve:d,onUnresolve:l,onDelete:m}){let[s,a]=Bl.useState(false),{t:h}=chunkGNIO6SOS_js.b();return jsxRuntime.jsxs("div",{ref:n,"data-comment-id":e.id,className:"docx-comment-card",onClick:r,onMouseDown:f=>f.stopPropagation(),style:{...o?Tn:Pn},children:[e.done&&jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",marginBottom:8,fontSize:11,fontWeight:500,color:"var(--doc-success)",backgroundColor:"var(--doc-success-bg)",borderRadius:10},children:[jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"check",size:12}),h("comments.resolved")]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:to(e.author||"U"),children:comments.getInitials(e.author||"U")}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--doc-text)"},children:e.author||h("comments.unknown")}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"var(--doc-text-muted)"},children:comments.formatDate(e.date)})]}),o&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:4,marginTop:2,position:"relative"},children:[jsxRuntime.jsx("button",{onClick:f=>{f.stopPropagation(),e.done?l?.(e.id):d?.(e.id);},title:e.done?h("comments.reopen"):h("comments.resolve"),style:eo,children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:e.done?"undo":"check",size:20})}),jsxRuntime.jsx("button",{onClick:f=>{f.stopPropagation(),a(!s);},title:h("comments.moreOptions"),style:eo,children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"more_vert",size:20})}),s&&jsxRuntime.jsx("div",{onClick:f=>f.stopPropagation(),onMouseDown:f=>f.stopPropagation(),style:{position:"absolute",top:32,right:0,background:"var(--doc-surface)",borderRadius:8,boxShadow:"0 2px 6px var(--doc-shadow-strong), 0 1px 2px var(--doc-shadow)",zIndex:100,minWidth:120,padding:"4px 0"},children:jsxRuntime.jsx("button",{onClick:()=>{a(false),m?.(e.id);},style:{display:"block",width:"100%",padding:"8px 16px",border:"none",background:"none",textAlign:"left",fontSize:14,color:"var(--doc-text)",cursor:"pointer",fontFamily:"inherit"},onMouseOver:f=>{f.target.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:f=>{f.target.style.backgroundColor="transparent";},children:h("common.delete")})})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,color:"var(--doc-text)",lineHeight:"20px",marginTop:6},children:comments.getCommentText(e.content)}),jsxRuntime.jsx(xn,{replies:t,isExpanded:o}),o&&!e.done&&jsxRuntime.jsx(Rn,{onSubmit:f=>u?.(e.id,f)})]})}function Pl({change:e,replies:t,isExpanded:o,onToggleExpand:r,measureRef:n,onAccept:u,onReject:d,onAcceptById:l,onRejectById:m,onReply:s}){let{t:a}=chunkGNIO6SOS_js.b(),h=e.author||a("trackedChanges.unknown"),f=()=>{let p=new Set([e.revisionId]);e.type==="replacement"&&e.insertionRevisionId!=null&&p.add(e.insertionRevisionId);for(let g of e.coalescedRevisionIds??[])p.add(g);return [...p]},b=p=>{if(p.stopPropagation(),l)for(let g of f())l(g);else u?.(e.from,e.to);},i=p=>{if(p.stopPropagation(),m)for(let g of f())m(g);else d?.(e.from,e.to);};return jsxRuntime.jsxs("div",{ref:n,className:"docx-tracked-change-card",onClick:()=>r(),onMouseDown:p=>p.stopPropagation(),style:o?Tn:Pn,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:to(h),children:comments.getInitials(h)}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--doc-text)"},children:h}),e.date&&jsxRuntime.jsx("div",{style:{fontSize:11,color:"var(--doc-text-muted)"},children:comments.formatDate(e.date)})]}),o&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:4,marginTop:2},children:[jsxRuntime.jsx("button",{onClick:b,title:a("common.accept"),style:eo,children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"check",size:20})}),jsxRuntime.jsx("button",{onClick:i,title:a("common.reject"),style:eo,children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"close",size:20})})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,lineHeight:"20px",color:"var(--doc-text)",marginTop:6},children:e.type==="replacement"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a("trackedChanges.replaced")," ",jsxRuntime.jsxs("span",{style:{color:"var(--doc-error)",fontWeight:500},children:['"',comments.truncateText(e.deletedText||""),'"']})," ",a("trackedChanges.with")," ",jsxRuntime.jsxs("span",{style:{color:"var(--doc-success)",fontWeight:500},children:['"',comments.truncateText(e.text),'"']})]}):e.type==="paragraphMarkInsertion"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a("revisions.paragraphMarkInserted"),e.text?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[": ",jsxRuntime.jsxs("span",{style:{color:"var(--doc-success)",fontWeight:500},children:['"',comments.truncateText(e.text),'"']})]}):null]}):e.type==="paragraphMarkDeletion"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a("revisions.paragraphMarkDeleted"),e.text?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[": ",jsxRuntime.jsxs("span",{style:{color:"var(--doc-error)",fontWeight:500},children:['"',comments.truncateText(e.text),'"']})]}):null]}):e.type==="paragraphPropertiesChanged"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a("revisions.paragraphPropertiesChanged"),e.text?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[": ",jsxRuntime.jsxs("span",{style:{color:"var(--doc-text-muted)",fontWeight:500},children:['"',comments.truncateText(e.text),'"']})]}):null]}):e.type==="rowInserted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-success)",fontWeight:500},children:a("revisions.rowInserted")}):e.type==="rowDeleted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-error)",fontWeight:500},children:a("revisions.rowDeleted")}):e.type==="cellInserted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-success)",fontWeight:500},children:a("revisions.cellInserted")}):e.type==="cellDeleted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-error)",fontWeight:500},children:a("revisions.cellDeleted")}):e.type==="cellMerged"?jsxRuntime.jsx("span",{style:{color:"var(--doc-text-muted)",fontWeight:500},children:a("revisions.cellMerged")}):e.type==="rowPropertiesChanged"?jsxRuntime.jsx("span",{style:{color:"var(--doc-text-muted)"},children:a("revisions.rowPropertiesChanged")}):e.type==="cellPropertiesChanged"?jsxRuntime.jsx("span",{style:{color:"var(--doc-text-muted)"},children:a("revisions.cellPropertiesChanged")}):e.type==="tablePropertiesChanged"?jsxRuntime.jsx("span",{style:{color:"var(--doc-text-muted)"},children:a("revisions.tablePropertiesChanged")}):e.type==="tableInserted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-success)",fontWeight:500},children:a("revisions.tableInserted")}):e.type==="tableDeleted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-error)",fontWeight:500},children:a("revisions.tableDeleted")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.type==="insertion"?a("trackedChanges.added"):a("trackedChanges.deleted")," ",jsxRuntime.jsxs("span",{style:{color:e.type==="insertion"?"var(--doc-success)":"var(--doc-error)",fontWeight:500},children:['"',comments.truncateText(e.text),'"']})]})}),jsxRuntime.jsx(xn,{replies:t,isExpanded:o}),o&&jsxRuntime.jsx(Rn,{onSubmit:p=>s?.(e.revisionId,p)})]})}function wl({measureRef:e,onSubmit:t,onCancel:o}){let[r,n]=Bl.useState(""),{t:u}=chunkGNIO6SOS_js.b(),d=()=>{r.trim()&&(t?.(r.trim()),n(""));};return jsxRuntime.jsxs("div",{ref:e,onMouseDown:l=>l.stopPropagation(),style:{padding:12,borderRadius:8,backgroundColor:"var(--doc-surface)",boxShadow:"0 1px 3px var(--doc-shadow-strong), 0 4px 8px 3px var(--doc-shadow)",zIndex:50},children:[jsxRuntime.jsx("textarea",{ref:l=>l?.focus({preventScroll:true}),value:r,onChange:l=>n(l.target.value),onMouseDown:l=>l.stopPropagation(),onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),d()),l.key==="Escape"&&(o?.(),n(""));},placeholder:u("comments.addComment"),style:{width:"100%",border:"1px solid var(--doc-primary)",borderRadius:20,outline:"none",resize:"none",fontSize:14,lineHeight:"20px",padding:"8px 16px",fontFamily:"inherit",minHeight:40,boxSizing:"border-box",color:"var(--doc-text)"}}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsxRuntime.jsx("button",{onClick:()=>{o?.(),n("");},style:yn,children:u("common.cancel")}),jsxRuntime.jsx("button",{onClick:d,disabled:!r.trim(),style:vn(!!r.trim()),children:u("common.comment")})]})]})}function Il({comment:e,measureRef:t,onToggleExpand:o}){return jsxRuntime.jsx("div",{ref:t,"data-comment-id":e.id,"data-comment-resolved":"true",onClick:o,onMouseDown:r=>r.stopPropagation(),style:{display:"inline-flex",alignItems:"center",cursor:"pointer",color:"var(--doc-text-muted)",padding:2},onMouseOver:r=>{r.currentTarget.style.opacity="0.7";},onMouseOut:r=>{r.currentTarget.style.opacity="1";},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"chat_bubble_check",size:20})})}function kl({comments:e,trackedChanges:t,callbacks:o,showResolved:r=false,isAddingComment:n=false,addCommentYPosition:u=null}){let d=Bl.useMemo(()=>e.filter(m=>!(m.parentId!=null||m.done&&!r)),[e,r]),l=Bl.useMemo(()=>{let m=new Map;for(let s of e)if(s.parentId!=null){let a=m.get(s.parentId);a?a.push(s):m.set(s.parentId,[s]);}return m},[e]);return Bl.useMemo(()=>{let m=[];n&&u!=null&&m.push({id:"new-comment-input",anchorPos:0,fixedY:u,priority:-1e3,isTemporary:true,estimatedHeight:120,render:s=>jsxRuntime.jsx(wl,{...s,onSubmit:o.onAddComment,onCancel:o.onCancelAddComment})});for(let s of d){let a=l.get(s.id)??[];m.push({id:`comment-${s.id}`,anchorPos:0,anchorKey:`comment-${s.id}`,priority:0,estimatedHeight:s.done?28:80,render:h=>s.done&&!h.isExpanded?jsxRuntime.jsx(Il,{...h,comment:s}):jsxRuntime.jsx(Rl,{...h,comment:s,replies:a,onReply:o.onCommentReply,onResolve:o.onCommentResolve,onUnresolve:o.onCommentUnresolve,onDelete:o.onCommentDelete})});}return t.forEach((s,a)=>{let h=l.get(s.revisionId)??[];m.push({id:`tc-${s.revisionId}-${a}`,anchorPos:s.from,anchorKey:`revision-${s.revisionId}`,priority:1,estimatedHeight:80,render:f=>jsxRuntime.jsx(Pl,{...f,change:s,replies:h,onAccept:o.onAcceptChange,onReject:o.onRejectChange,onAcceptById:o.onAcceptChangeById,onRejectById:o.onRejectChangeById,onReply:o.onTrackedChangeReply})});}),m},[d,t,l,o,n,u])}function Ml(){let{t:e}=chunkGNIO6SOS_js.b();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"20px",color:"var(--doc-text-muted)"},children:[jsxRuntime.jsx("div",{style:{width:"36px",height:"36px",border:"3px solid var(--doc-border)",borderTopColor:"var(--doc-primary)",borderRadius:"50%",animation:"docx-spin 0.8s linear infinite"}}),jsxRuntime.jsx("style",{children:`
28
+ `})})(),B]})})]}),I.totalPages>1&&jsxRuntime.jsx(Cl,{currentPage:I.currentPage,totalPages:I.totalPages,visible:I.visible}),f&&jsxRuntime.jsx(hl,{...k,leftOffset:Cn+(a?zt:0)}),h&&!f&&jsxRuntime.jsx(vl,{onClick:E,topPx:g+(a?30:0)+48,scrollLeft:x,leftOffset:ko+(a?zt:0)})]}),w&&jsxRuntime.jsx(Sl,{agentPanel:w,closed:!D,onClose:H})]}),_,W,Z]})})})})}var to={background:"none",border:"none",cursor:"pointer",padding:4,color:"var(--doc-text-muted)",display:"flex",borderRadius:"50%"},Sn={padding:"6px 16px",fontSize:14,border:"none",background:"none",color:"var(--doc-primary)",cursor:"pointer",fontWeight:500,fontFamily:"inherit"};function oo(e,t=32){return {width:t,height:t,borderRadius:"50%",backgroundColor:comments.getAvatarColor(e),color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:t===32?13:11,fontWeight:500,flexShrink:0}}function xn(e){return {padding:"6px 16px",fontSize:14,border:"none",borderRadius:20,background:e?"var(--doc-primary)":"var(--doc-bg-hover)",color:e?"#fff":"var(--doc-text-subtle)",cursor:e?"pointer":"default",fontWeight:500,fontFamily:"inherit"}}function Tn({replies:e,isExpanded:t}){let{t:o}=chunkGNIO6SOS_js.b();if(e.length===0)return null;let r=t?e:e.slice(-1),n=t?0:e.length-1;return jsxRuntime.jsxs("div",{style:{marginTop:8},children:[n>0&&jsxRuntime.jsx("div",{style:{fontSize:12,fontWeight:500,color:"var(--doc-primary)",paddingTop:6,paddingBottom:6,borderTop:"1px solid var(--doc-border-light)"},children:o("comments.replyCount",{count:n})}),r.map(u=>jsxRuntime.jsxs("div",{style:{marginBottom:t?8:0,paddingTop:8,borderTop:"1px solid var(--doc-border-light)"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:oo(u.author||"U",28),children:comments.getInitials(u.author||"U")}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--doc-text)"},children:u.author||o("comments.unknown")}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"var(--doc-text-muted)"},children:comments.formatDate(u.date)})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,color:"var(--doc-text)",lineHeight:"20px",marginTop:4,...t?{}:{overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"}},children:comments.getCommentText(u.content)})]},u.id))]})}var yh={width:"100%",border:"1px solid var(--doc-primary)",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",boxSizing:"border-box",color:"var(--doc-text)"},vh={width:"100%",border:"1px solid var(--doc-border-light)",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",color:"var(--doc-text-subtle)",cursor:"text",backgroundColor:"var(--doc-surface)",boxSizing:"border-box"};function wn({onSubmit:e}){let[t,o]=zl.useState(false),[r,n]=zl.useState(""),{t:u}=chunkGNIO6SOS_js.b();if(!t)return jsxRuntime.jsx("div",{onClick:l=>l.stopPropagation(),style:{marginTop:12},children:jsxRuntime.jsx("input",{readOnly:true,onMouseDown:l=>l.stopPropagation(),onClick:l=>{l.stopPropagation(),o(true);},placeholder:u("comments.replyPlaceholder"),style:vh})});let d=r.trim();return jsxRuntime.jsxs("div",{onClick:l=>l.stopPropagation(),style:{marginTop:12},children:[jsxRuntime.jsx("input",{ref:l=>l?.focus({preventScroll:true}),type:"text",value:r,onChange:l=>n(l.target.value),onMouseDown:l=>l.stopPropagation(),onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"&&(l.preventDefault(),d&&e(d),n(""),o(false)),l.key==="Escape"&&(o(false),n(""));},placeholder:u("comments.replyPlaceholder"),style:yh}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsxRuntime.jsx("button",{onClick:l=>{l.stopPropagation(),o(false),n("");},style:Sn,children:u("common.cancel")}),jsxRuntime.jsx("button",{onClick:l=>{l.stopPropagation(),d&&e(d),n(""),o(false);},disabled:!d,style:xn(!!d),children:u("common.reply")})]})]})}var En=cardStyles.CARD_STYLE_COLLAPSED,In=cardStyles.CARD_STYLE_EXPANDED;function Tl({comment:e,replies:t,isExpanded:o,onToggleExpand:r,measureRef:n,onReply:u,onResolve:d,onUnresolve:l,onDelete:m}){let[s,a]=zl.useState(false),{t:b}=chunkGNIO6SOS_js.b();return jsxRuntime.jsxs("div",{ref:n,"data-comment-id":e.id,className:"docx-comment-card",onClick:r,onMouseDown:f=>f.stopPropagation(),style:{...o?In:En},children:[e.done&&jsxRuntime.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",marginBottom:8,fontSize:11,fontWeight:500,color:"var(--doc-success)",backgroundColor:"var(--doc-success-bg)",borderRadius:10},children:[jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"check",size:12}),b("comments.resolved")]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:oo(e.author||"U"),children:comments.getInitials(e.author||"U")}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--doc-text)"},children:e.author||b("comments.unknown")}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"var(--doc-text-muted)"},children:comments.formatDate(e.date)})]}),o&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:4,marginTop:2,position:"relative"},children:[jsxRuntime.jsx("button",{onClick:f=>{f.stopPropagation(),e.done?l?.(e.id):d?.(e.id);},title:e.done?b("comments.reopen"):b("comments.resolve"),style:to,children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:e.done?"undo":"check",size:20})}),jsxRuntime.jsx("button",{onClick:f=>{f.stopPropagation(),a(!s);},title:b("comments.moreOptions"),style:to,children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"more_vert",size:20})}),s&&jsxRuntime.jsx("div",{onClick:f=>f.stopPropagation(),onMouseDown:f=>f.stopPropagation(),style:{position:"absolute",top:32,right:0,background:"var(--doc-surface)",borderRadius:8,boxShadow:"0 2px 6px var(--doc-shadow-strong), 0 1px 2px var(--doc-shadow)",zIndex:100,minWidth:120,padding:"4px 0"},children:jsxRuntime.jsx("button",{onClick:()=>{a(false),m?.(e.id);},style:{display:"block",width:"100%",padding:"8px 16px",border:"none",background:"none",textAlign:"left",fontSize:14,color:"var(--doc-text)",cursor:"pointer",fontFamily:"inherit"},onMouseOver:f=>{f.target.style.backgroundColor="var(--doc-bg-hover)";},onMouseOut:f=>{f.target.style.backgroundColor="transparent";},children:b("common.delete")})})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,color:"var(--doc-text)",lineHeight:"20px",marginTop:6},children:comments.getCommentText(e.content)}),jsxRuntime.jsx(Tn,{replies:t,isExpanded:o}),o&&!e.done&&jsxRuntime.jsx(wn,{onSubmit:f=>u?.(e.id,f)})]})}function wl({change:e,replies:t,isExpanded:o,onToggleExpand:r,measureRef:n,onAccept:u,onReject:d,onAcceptById:l,onRejectById:m,onReply:s}){let{t:a}=chunkGNIO6SOS_js.b(),b=e.author||a("trackedChanges.unknown"),f=()=>{let p=new Set([e.revisionId]);e.type==="replacement"&&e.insertionRevisionId!=null&&p.add(e.insertionRevisionId);for(let g of e.coalescedRevisionIds??[])p.add(g);return [...p]},h=p=>{if(p.stopPropagation(),l)for(let g of f())l(g);else u?.(e.from,e.to);},i=p=>{if(p.stopPropagation(),m)for(let g of f())m(g);else d?.(e.from,e.to);};return jsxRuntime.jsxs("div",{ref:n,className:"docx-tracked-change-card",onClick:()=>r(),onMouseDown:p=>p.stopPropagation(),style:o?In:En,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:oo(b),children:comments.getInitials(b)}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--doc-text)"},children:b}),e.date&&jsxRuntime.jsx("div",{style:{fontSize:11,color:"var(--doc-text-muted)"},children:comments.formatDate(e.date)})]}),o&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:4,marginTop:2},children:[jsxRuntime.jsx("button",{onClick:h,title:a("common.accept"),style:to,children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"check",size:20})}),jsxRuntime.jsx("button",{onClick:i,title:a("common.reject"),style:to,children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"close",size:20})})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,lineHeight:"20px",color:"var(--doc-text)",marginTop:6},children:e.type==="replacement"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a("trackedChanges.replaced")," ",jsxRuntime.jsxs("span",{style:{color:"var(--doc-error)",fontWeight:500},children:['"',comments.truncateText(e.deletedText||""),'"']})," ",a("trackedChanges.with")," ",jsxRuntime.jsxs("span",{style:{color:"var(--doc-success)",fontWeight:500},children:['"',comments.truncateText(e.text),'"']})]}):e.type==="paragraphMarkInsertion"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a("revisions.paragraphMarkInserted"),e.text?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[": ",jsxRuntime.jsxs("span",{style:{color:"var(--doc-success)",fontWeight:500},children:['"',comments.truncateText(e.text),'"']})]}):null]}):e.type==="paragraphMarkDeletion"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a("revisions.paragraphMarkDeleted"),e.text?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[": ",jsxRuntime.jsxs("span",{style:{color:"var(--doc-error)",fontWeight:500},children:['"',comments.truncateText(e.text),'"']})]}):null]}):e.type==="paragraphPropertiesChanged"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a("revisions.paragraphPropertiesChanged"),e.text?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[": ",jsxRuntime.jsxs("span",{style:{color:"var(--doc-text-muted)",fontWeight:500},children:['"',comments.truncateText(e.text),'"']})]}):null]}):e.type==="rowInserted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-success)",fontWeight:500},children:a("revisions.rowInserted")}):e.type==="rowDeleted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-error)",fontWeight:500},children:a("revisions.rowDeleted")}):e.type==="cellInserted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-success)",fontWeight:500},children:a("revisions.cellInserted")}):e.type==="cellDeleted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-error)",fontWeight:500},children:a("revisions.cellDeleted")}):e.type==="cellMerged"?jsxRuntime.jsx("span",{style:{color:"var(--doc-text-muted)",fontWeight:500},children:a("revisions.cellMerged")}):e.type==="rowPropertiesChanged"?jsxRuntime.jsx("span",{style:{color:"var(--doc-text-muted)"},children:a("revisions.rowPropertiesChanged")}):e.type==="cellPropertiesChanged"?jsxRuntime.jsx("span",{style:{color:"var(--doc-text-muted)"},children:a("revisions.cellPropertiesChanged")}):e.type==="tablePropertiesChanged"?jsxRuntime.jsx("span",{style:{color:"var(--doc-text-muted)"},children:a("revisions.tablePropertiesChanged")}):e.type==="tableInserted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-success)",fontWeight:500},children:a("revisions.tableInserted")}):e.type==="tableDeleted"?jsxRuntime.jsx("span",{style:{color:"var(--doc-error)",fontWeight:500},children:a("revisions.tableDeleted")}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.type==="insertion"?a("trackedChanges.added"):a("trackedChanges.deleted")," ",jsxRuntime.jsxs("span",{style:{color:e.type==="insertion"?"var(--doc-success)":"var(--doc-error)",fontWeight:500},children:['"',comments.truncateText(e.text),'"']})]})}),jsxRuntime.jsx(Tn,{replies:t,isExpanded:o}),o&&jsxRuntime.jsx(wn,{onSubmit:p=>s?.(e.revisionId,p)})]})}function Il({measureRef:e,onSubmit:t,onCancel:o}){let[r,n]=zl.useState(""),{t:u}=chunkGNIO6SOS_js.b(),d=()=>{r.trim()&&(t?.(r.trim()),n(""));};return jsxRuntime.jsxs("div",{ref:e,onMouseDown:l=>l.stopPropagation(),style:{padding:12,borderRadius:8,backgroundColor:"var(--doc-surface)",boxShadow:"0 1px 3px var(--doc-shadow-strong), 0 4px 8px 3px var(--doc-shadow)",zIndex:50},children:[jsxRuntime.jsx("textarea",{ref:l=>l?.focus({preventScroll:true}),value:r,onChange:l=>n(l.target.value),onMouseDown:l=>l.stopPropagation(),onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),d()),l.key==="Escape"&&(o?.(),n(""));},placeholder:u("comments.addComment"),style:{width:"100%",border:"1px solid var(--doc-primary)",borderRadius:20,outline:"none",resize:"none",fontSize:14,lineHeight:"20px",padding:"8px 16px",fontFamily:"inherit",minHeight:40,boxSizing:"border-box",color:"var(--doc-text)"}}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsxRuntime.jsx("button",{onClick:()=>{o?.(),n("");},style:Sn,children:u("common.cancel")}),jsxRuntime.jsx("button",{onClick:d,disabled:!r.trim(),style:xn(!!r.trim()),children:u("common.comment")})]})]})}function Ml({comment:e,measureRef:t,onToggleExpand:o}){return jsxRuntime.jsx("div",{ref:t,"data-comment-id":e.id,"data-comment-resolved":"true",onClick:o,onMouseDown:r=>r.stopPropagation(),style:{display:"inline-flex",alignItems:"center",cursor:"pointer",color:"var(--doc-text-muted)",padding:2},onMouseOver:r=>{r.currentTarget.style.opacity="0.7";},onMouseOut:r=>{r.currentTarget.style.opacity="1";},children:jsxRuntime.jsx(chunkWNWY6WX7_js.b,{name:"chat_bubble_check",size:20})})}function Dl({comments:e,trackedChanges:t,callbacks:o,showResolved:r=false,isAddingComment:n=false,addCommentYPosition:u=null}){let d=zl.useMemo(()=>e.filter(m=>!(m.parentId!=null||m.done&&!r)),[e,r]),l=zl.useMemo(()=>{let m=new Map;for(let s of e)if(s.parentId!=null){let a=m.get(s.parentId);a?a.push(s):m.set(s.parentId,[s]);}return m},[e]);return zl.useMemo(()=>{let m=[];n&&u!=null&&m.push({id:"new-comment-input",anchorPos:0,fixedY:u,priority:-1e3,isTemporary:true,estimatedHeight:120,render:s=>jsxRuntime.jsx(Il,{...s,onSubmit:o.onAddComment,onCancel:o.onCancelAddComment})});for(let s of d){let a=l.get(s.id)??[];m.push({id:`comment-${s.id}`,anchorPos:0,anchorKey:`comment-${s.id}`,priority:0,estimatedHeight:s.done?28:80,render:b=>s.done&&!b.isExpanded?jsxRuntime.jsx(Ml,{...b,comment:s}):jsxRuntime.jsx(Tl,{...b,comment:s,replies:a,onReply:o.onCommentReply,onResolve:o.onCommentResolve,onUnresolve:o.onCommentUnresolve,onDelete:o.onCommentDelete})});}return t.forEach((s,a)=>{let b=l.get(s.revisionId)??[];m.push({id:`tc-${s.revisionId}-${a}`,anchorPos:s.from,anchorKey:`revision-${s.revisionId}`,priority:1,estimatedHeight:80,render:f=>jsxRuntime.jsx(wl,{...f,change:s,replies:b,onAccept:o.onAcceptChange,onReject:o.onRejectChange,onAcceptById:o.onAcceptChangeById,onRejectById:o.onRejectChangeById,onReply:o.onTrackedChangeReply})});}),m},[d,t,l,o,n,u])}function Hl(){let{t:e}=chunkGNIO6SOS_js.b();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"20px",color:"var(--doc-text-muted)"},children:[jsxRuntime.jsx("div",{style:{width:"36px",height:"36px",border:"3px solid var(--doc-border)",borderTopColor:"var(--doc-primary)",borderRadius:"50%",animation:"docx-spin 0.8s linear infinite"}}),jsxRuntime.jsx("style",{children:`
29
29
  @keyframes docx-spin {
30
30
  to { transform: rotate(360deg); }
31
31
  }
32
- `}),jsxRuntime.jsx("div",{style:{fontSize:"14px"},children:e("errors.loadingDocument")})]})}function Dl(){let{t:e}=chunkGNIO6SOS_js.b();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--doc-text-placeholder)"},children:[jsxRuntime.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsxRuntime.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsxRuntime.jsx("polyline",{points:"14 2 14 8 20 8"})]}),jsxRuntime.jsx("div",{style:{marginTop:"16px"},children:e("errors.noDocumentLoaded")})]})}function Hl({message:e}){let{t}=chunkGNIO6SOS_js.b();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"20px",textAlign:"center"},children:[jsxRuntime.jsx("div",{style:{color:"var(--doc-error)",marginBottom:"16px"},children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M12 8v4M12 16v.01"})]})}),jsxRuntime.jsx("h3",{style:{color:"var(--doc-error)",marginBottom:"8px"},children:t("errors.failedToLoad")}),jsxRuntime.jsx("p",{style:{color:"var(--doc-text-muted)",maxWidth:"400px"},children:e})]})}function Fl(e,t,o){Bl.useEffect(()=>{utils.loadFontDefinitions(e);},[e]),Bl.useEffect(()=>utils.onFontsLoaded(()=>t?.()),[t]);let r=Bl.useRef(o);Bl.useEffect(()=>{r.current=o;},[o]),Bl.useEffect(()=>utils.onFontError(n=>r.current?.(n)),[]);}var Br=Bl.forwardRef(function({documentBuffer:t,document:o,onSave:r,author:n="User",onChange:u,onSelectionChange:d,onError:l,onFontsLoaded:m,colorMode:s="light",theme:a,showToolbar:h=true,showZoomControl:f=true,showMarginGuides:b=false,marginGuideColor:i,showRuler:p=false,rulerUnit:g="inch",initialZoom:x=1,readOnly:y=false,disableFindReplaceShortcuts:c=false,toolbarExtra:S,className:v="",style:C,placeholder:R,loadingIndicator:P,showOutline:k=false,showOutlineButton:E=true,fontFamilies:I,fonts:w,watermarkPresets:D,printOptions:H,onPrint:O,onCopy:B,onCut:_,onPaste:W,mode:Z,onModeChange:Y,onCommentAdd:J,onCommentResolve:te,onCommentDelete:ne,onCommentReply:me,comments:ke,onCommentsChange:Ce,externalPlugins:M,externalContent:F=false,onEditorViewReady:N,onRenderedDomContextReady:A,pluginOverlays:z,pluginSidebarItems:V,pluginRenderedDomContext:se,renderLogo:ee,documentName:$,onDocumentNameChange:de,documentNameEditable:re=true,renderTitleBarRight:X,i18n:oe,agentPanel:le},Re){let[Q,he]=Bl.useState({isLoading:!!t&&!F,parseError:null,zoom:x,selectionFormatting:{},paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[Pe,Ae]=Bl.useState(utils.prefersColorSchemeDark);Bl.useEffect(()=>{if(s==="system")return utils.subscribeSystemDark(Ae)},[s]);let Oe=utils.resolveIsDark(s,Pe),[De,He]=Bl.useState(null),[q,ue]=Bl.useState(false),[ce,fe]=Bl.useState(false),we=Bl.useRef(false),[Se,et]=Bl.useState(null),ae=Bl.useRef(null),{comments:ze,setComments:Te,isAddingComment:_e,setIsAddingComment:Pt,isAddingCommentRef:Fo,commentSelectionRange:Wt,setCommentSelectionRange:Tt,addCommentYPosition:kn,setAddCommentYPosition:wt,floatingCommentBtn:Mn,setFloatingCommentBtn:ht,cleanOrphanedCommentsTimerRef:Vt,cleanOrphanedComments:Et}=Zi({commentsProp:ke,onCommentDelete:ne,onCommentsChange:Ce,pagedEditorRef:ae}),[ro,io]=Bl.useState(null),{entries:It,commentToRevision:Dn}=chunkLNONBJQM_js.d(ro),[Hn,Lo]=Bl.useState(qo),[Fn,Ln]=Bl.useState(Z??"editing"),kt=Z??Fn,An=T=>{Z||Ln(T),Y?.(T);},Ye=y||kt==="viewing",[On,Bn]=Bl.useState(false),ao=le?.open!==void 0,Ut=le?ao?!!le.open:On:false,G=Bl.useCallback(T=>{le?.onOpenChange?.(T),ao||Bn(T);},[le,ao]),ye=Bl.useRef(new Set),ge=Bl.useRef(new Set),pe=chunkLNONBJQM_js.i(o||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),tt=Bl.useMemo(()=>{let T=new extensions.ExtensionManager(extensions.createStarterKit());return T.buildSchema(),T.initializeRuntime(),T},[]),$t=Bl.useMemo(()=>plugins.createSuggestionModePlugin(kt==="suggesting",n),[]),so=Bl.useMemo(()=>[$t,...M??[]],[$t,M]),lo=Bl.useRef(null),Nn=Bl.useRef(null),Ao=Bl.useRef(null),Nr=Bl.useRef(null),Oo=Bl.useRef(null),Gt=Bl.useRef(null),{showOutline:zr,setShowOutline:_r,showOutlineRef:Nl,outlineHeadings:zl,setHeadingInfos:zn,toolbarHeight:Wr,toolbarRefCallback:_l,editorScrollLeft:Vr}=fi({showOutlineProp:k,pagedEditorRef:ae,scrollContainerRef:Gt,isLoading:Q.isLoading}),co=Bl.useRef(pe.state);co.current=pe.state;let Ur=Bl.useRef({style:"single",size:4,color:{rgb:"000000"}}),$r=Bl.useRef(null),Bo=Bl.useCallback(T=>{let L=$r.current;if(L&&L.styles===T)return L.resolver;let K=prosemirror.createStyleResolver(T);return $r.current={styles:T,resolver:K},K},[]),{getActiveEditorView:lt,focusActiveEditor:Mt,undoActiveEditor:Wl,redoActiveEditor:Vl}=ra({hfEditPosition:De,hfEditorRef:lo,pagedEditorRef:ae}),uo=chunkL4MDZW2J_js.b(),No=chunkQD7BVJV3_js.m(),Gr=Bl.useRef(false),Kr=Bl.useRef(false),po=Bl.useRef(commentIdAllocator.createCommentIdAllocator()),{resetForNewDocument:Ul}=tl({commentsLoadedRef:Gr,trackedChangesLoadedRef:Kr,setComments:Te,setHeadingInfos:zn,setShowCommentsSidebar:fe,setIsAddingComment:Pt,setCommentSelectionRange:Tt,setAddCommentYPosition:wt,setFloatingCommentBtn:ht,setHfEditPosition:He,setHfEditIsFirstPage:ue,setAnchorPositions:Lo,clearFindReplaceMatches:Bl.useCallback(()=>uo.setMatches([],0),[uo]),cleanOrphanedCommentsTimerRef:Vt}),{loadParsedDocument:$l,loadBuffer:jr}=zi({documentBuffer:t,initialDocument:o,externalContent:F,history:pe,agentRef:Nn,pagedEditorRef:ae,setLoadingState:Bl.useCallback(T=>{he(L=>({...L,isLoading:T.isLoading,parseError:T.parseError}));},[]),setComments:Te,setShowCommentsSidebar:fe,onError:l,resetForNewDocument:Ul,commentsLoadedRef:Gr,commentIdAllocator:po.current}),{imageInputRef:Gl,docxInputRef:Kl,handleSave:jl,handleDirectPrint:Yr,handleDownloadDocument:Yl,handleOpenDocument:ql,handleDocxFileChange:Xl,handleInsertImageClick:Zl,handleImageFileChange:Ql}=hi({agentRef:Nn,pagedEditorRef:ae,containerRef:Ao,comments:ze,documentName:$,onSave:r,onError:l,onPrint:O,onDocumentNameChange:de,loadBuffer:jr,getActiveEditorView:lt,focusActiveEditor:Mt});Bl.useEffect(()=>{if(Q.isLoading||!pe.state)return;let T=ae.current?.getView();T&&io(T.state);},[Q.isLoading,pe.state]),Ji({commentToRevision:Dn,setComments:Te,pmState:ro,isLoading:Q.isLoading,trackedChangesCount:It.length,setShowCommentsSidebar:fe,trackedChangesLoadedRef:Kr}),Fl(w,m,l),Bl.useEffect(()=>{let T=ae.current?.getView();T&&plugins.setSuggestionMode(kt==="suggesting",T.state,T.dispatch,n);},[kt,n]);let zo=Bl.useCallback(T=>(pe.push(T),T),[pe]),_n=Bl.useCallback(T=>{zo(T),u?.(T);for(let K of ye.current)try{K(T);}catch(xe){console.error("contentChange subscriber threw:",xe);}if(Nl.current){let K=ae.current?.getView();K&&zn(utils.collectHeadings(K.state.doc));}let L=ae.current?.getView();L&&io(L.state),Vt.current&&clearTimeout(Vt.current),Vt.current=setTimeout(Et,300);},[u,zo,Et]),{recomputeFloatingCommentBtn:Jl}=na({pagedEditorRef:ae,scrollContainerRef:Gt,editorContentRef:Oo,isAddingCommentRef:Fo,setFloatingCommentBtn:ht,readOnly:Ye,isLoading:Q.isLoading,zoom:Q.zoom}),{handleSelectionChange:_o}=ta({getActiveEditorView:lt,lastSelectionRef:Nr,borderSpecRef:Ur,theme:a,historyStateRef:co,getCachedStyleResolver:Bo,setFloatingCommentBtn:ht,applySelectionDelta:Bl.useCallback(T=>he(L=>({...L,...T})),[]),recomputeFloatingCommentBtn:Jl,onSelectionChange:d,selectionChangeSubscribersRef:ge}),qr=chunkLNONBJQM_js.e({document:pe.state,onChange:_n,onSelectionChange:T=>{}});gi({pagedEditorRef:ae,disableFindReplaceShortcuts:c,findReplace:uo,hyperlinkDialog:No,tableSelection:qr});let ec=Bl.useCallback(()=>{_r(T=>{if(!T){let L=ae.current?.getView();L&&zn(utils.collectHeadings(L.state.doc));}return !T});},[]),tc=Bl.useCallback(T=>{ae.current?.scrollToPosition(T),ae.current?.setSelection(T+1),ae.current?.focus();},[]),{imagePositionOpen:oc,setImagePositionOpen:nc,imagePropsOpen:rc,setImagePropsOpen:ic,footnotePropsOpen:ac,setFootnotePropsOpen:sc,handleImageWrapType:lc,handleImageTransform:cc,handleApplyImagePosition:dc,handleOpenImageProperties:Xr,handleApplyImageProperties:uc,handleApplyFootnoteProperties:pc}=Di({document:pe.state,pmImageContext:Q.pmImageContext,zoom:Q.zoom,getActiveEditorView:lt,focusActiveEditor:Mt,pushDocument:zo}),{tablePropsOpen:mc,setTablePropsOpen:fc,splitCellDialogState:gc,openSplitCellDialog:bc,handleTableAction:hc,handleSplitCellDialogClose:yc,handleSplitCellDialogApply:vc}=Oi({getActiveEditorView:lt,focusActiveEditor:Mt,tableSelection:qr,borderSpecRef:Ur,historyStateRef:co,getCachedStyleResolver:Bo}),{handleFormat:Cc,handleInsertTable:Sc,handleInsertPageBreak:xc,handleInsertSectionBreakNextPage:Rc,handleInsertSectionBreakContinuous:Pc,handleInsertTOC:Tc}=Mi({getActiveEditorView:lt,focusActiveEditor:Mt,pagedEditorRef:ae,lastSelectionRef:Nr,hyperlinkDialog:No,historyStateRef:co,getCachedStyleResolver:Bo}),wc=Bl.useCallback(T=>{he(L=>({...L,zoom:T}));},[]),{hyperlinkPopupData:Ec,handleHyperlinkSubmit:Ic,handleHyperlinkRemove:kc,handleHyperlinkClick:Mc,handleHyperlinkPopupNavigate:Dc,handleHyperlinkPopupCopy:Hc,handleHyperlinkPopupEdit:Fc,handleHyperlinkPopupRemove:Lc,handleHyperlinkPopupClose:Ac}=Pi({hyperlinkDialog:No,getActiveEditorView:lt,focusActiveEditor:Mt}),{contextMenu:Oc,imageContextMenu:Bc,handleEditorContextMenu:Nc,handleContextMenu:zc,handleContextMenuClose:_c,handleImageWrapApply:Wc,imageContextMenuTextActions:Vc,contextMenuItems:Uc,handleContextMenuAction:$c}=qi({getActiveEditorView:lt,focusActiveEditor:Mt,openSplitCellDialog:bc,scrollContainerRef:Gt,editorContentRef:Oo,i18n:oe,onAddComment:Bl.useCallback(({from:T,to:L,yPos:K})=>{Tt({from:T,to:L}),wt(K),fe(true),Pt(true),ht(null);},[])}),{showPageSetup:Gc,setShowPageSetup:Kc,handleOpenPageSetup:jc,handleLeftMarginChange:Yc,handleRightMarginChange:qc,handleTopMarginChange:Xc,handleBottomMarginChange:Zc,handlePageSetupApply:Qc,handleIndentLeftChange:Jc,handleIndentRightChange:ed,handleFirstLineIndentChange:td,handleTabStopRemove:od}=vi({document:pe.state,readOnly:Ye,handleDocumentChange:_n,getActiveEditorView:lt}),{showWatermark:nd,setShowWatermark:rd,handleOpenWatermark:id,currentWatermark:ad,handleWatermarkApply:sd}=Si({readOnly:Ye,getBodyEditorView:()=>ae.current?.getView()}),{scrollPageInfo:Zr,setScrollPageInfo:ld}=ia({scrollContainerRef:Gt,pagedEditorRef:ae}),cd=Bl.useCallback(T=>{l?.(T);},[l]),{findResultRef:dd,handleFind:ud,handleFindNext:pd,handleFindPrevious:md,handleReplace:fd,handleReplaceAll:gd}=Ei({pagedEditorRef:ae,findReplace:uo});Fi({ref:Re,agentRef:Nn,document:pe.state,historyStateRef:co,pagedEditorRef:ae,handleSave:jl,handleDirectPrint:Yr,zoom:Q.zoom,setZoom:T=>he(L=>({...L,zoom:T})),scrollPageInfo:Zr,loadParsedDocument:$l,loadBuffer:jr,comments:ze,setComments:Te,setShowCommentsSidebar:fe,contentChangeSubscribersRef:ye,selectionChangeSubscribersRef:ge,getCachedStyleResolver:Bo,commentIdAllocator:po.current});let Wn=Bl.useMemo(()=>$i(pe.state),[pe.state]),Qr=pe.state?.package.document?.finalSectionProperties,{headerContent:bd,footerContent:hd,firstPageHeaderContent:yd,firstPageFooterContent:vd,handleHeaderFooterDoubleClick:Cd,handleHeaderFooterSave:Sd,handleBodyClick:xd,handleRemoveHeaderFooter:Rd,getHfTargetElement:Pd}=Bi({document:pe.state,pushDocument:zo,hfEditorRef:lo,containerRef:Ao,initialSectionProperties:Wn,finalSectionProperties:Qr,hfEditPosition:De,setHfEditPosition:He,hfEditIsFirstPage:q,setHfEditIsFirstPage:ue}),Wo={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)",...C},Td={display:"flex",flex:1,minHeight:0,minWidth:0,flexDirection:"row"},Ge=Bl.useRef({});Ge.current={onCommentReply:(T,L)=>{let K=commentOps.createComment(po.current,L,n,T),xe=ze.find(Fe=>Fe.id===T);Te(Fe=>[...Fe,K]),xe&&me?.(K,xe);},onCommentResolve:T=>{let L=ze.find(K=>K.id===T);Te(K=>K.map(xe=>xe.id===T?{...xe,done:true}:xe)),Se===`comment-${T}`&&et(null),L&&te?.({...L,done:true});},onCommentUnresolve:T=>{Te(L=>L.map(K=>K.id===T?{...K,done:void 0}:K));},onCommentDelete:T=>{let L=ze.find(xe=>xe.id===T);Te(xe=>xe.filter(Fe=>Fe.id!==T&&Fe.parentId!==T));let K=ae.current?.getView();if(K){let xe=K.state.schema.marks.comment?.create({commentId:T});if(xe){let Fe=K.state.tr.removeMark(0,K.state.doc.content.size,xe);Fe.docChanged&&K.dispatch(Fe);}}L&&ne?.(L);},onAddComment:T=>{let L=commentOps.createComment(po.current,T,n),K=ae.current?.getView();if(K&&Wt){let{from:xe,to:Fe}=Wt,ct=K.state.schema.marks.comment.create({commentId:commentIdAllocator.PENDING_COMMENT_ID}),Ht=K.state.schema.marks.comment.create({commentId:L.id}),$n=K.state.tr.removeMark(xe,Fe,ct).addMark(xe,Fe,Ht);K.dispatch($n);}Te(xe=>[...xe,L]),Pt(false),Tt(null),wt(null),J?.(L);},onCancelAddComment:()=>{let T=ae.current?.getView();if(T&&Wt){let{from:L,to:K}=Wt,xe=T.state.schema.marks.comment.create({commentId:commentIdAllocator.PENDING_COMMENT_ID});T.dispatch(T.state.tr.removeMark(L,K,xe));}Pt(false),Tt(null),wt(null);},onAcceptChange:(T,L)=>{let K=ae.current?.getView();K&&commands.acceptChange(T,L)(K.state,K.dispatch);},onRejectChange:(T,L)=>{let K=ae.current?.getView();K&&commands.rejectChange(T,L)(K.state,K.dispatch);},onAcceptChangeById:T=>{let L=ae.current?.getView();L&&commands.acceptChangeById(T)(L.state,L.dispatch);},onRejectChangeById:T=>{let L=ae.current?.getView();L&&commands.rejectChangeById(T)(L.state,L.dispatch);},onTrackedChangeReply:(T,L)=>{Te(K=>[...K,commentOps.createComment(po.current,L,n,T)]);}};let wd=Bl.useMemo(()=>({onCommentReply:(...T)=>Ge.current.onCommentReply?.(...T),onCommentResolve:(...T)=>Ge.current.onCommentResolve?.(...T),onCommentUnresolve:(...T)=>Ge.current.onCommentUnresolve?.(...T),onCommentDelete:(...T)=>Ge.current.onCommentDelete?.(...T),onAddComment:(...T)=>Ge.current.onAddComment?.(...T),onCancelAddComment:(...T)=>Ge.current.onCancelAddComment?.(...T),onAcceptChange:(...T)=>Ge.current.onAcceptChange?.(...T),onRejectChange:(...T)=>Ge.current.onRejectChange?.(...T),onAcceptChangeById:(...T)=>Ge.current.onAcceptChangeById?.(...T),onRejectChangeById:(...T)=>Ge.current.onRejectChangeById?.(...T),onTrackedChangeReply:(...T)=>Ge.current.onTrackedChangeReply?.(...T)}),[]),Dt=kl({comments:ze,trackedChanges:It,callbacks:wd,showResolved:ce,isAddingComment:ce?_e:false,addCommentYPosition:kn}),Jr=Bl.useMemo(()=>{let T=[];return ce&&T.push(...Dt),V&&T.push(...V),T},[ce,Dt,V]),Vn=Bl.useMemo(()=>{let T=new Map;return It.forEach((L,K)=>{L.type==="replacement"&&L.insertionRevisionId!=null&&T.set(String(L.insertionRevisionId),`tc-${L.revisionId}-${K}`);}),T},[It]),Un=Jr.length>0,Ed=2*(zr?ml:E?fl:20)+816+(Un?sidebarConstants.SIDEBAR_DOCUMENT_SHIFT*2:0),ei=pe.state?.package?.document?.finalSectionProperties?.pageWidth,Id=ei?Math.round(ei/15):816,yt=Bl.useMemo(()=>{let T=new Set;for(let L of ze)L.done&&L.parentId==null&&T.add(L.id);return T},[ze]),kd=Bl.useCallback(()=>{let T=ae.current?.getView();if(!T){_o(null);return}let L=prosemirror.extractSelectionState(T.state);_o(L);let K=T.state.selection.$from,xe=[...T.state.storedMarks??[],...K.nodeAfter?.marks??[],...K.nodeBefore?.marks??[],...K.marks()],Fe=null;for(let ct of xe){if(ct.type.name==="comment"&&ct.attrs.commentId!=null){let Ht=ct.attrs.commentId;if(yt.has(Ht))continue;Fe=`comment-${Ht}`;break}if((ct.type.name==="insertion"||ct.type.name==="deletion")&&ct.attrs.revisionId!=null){let Ht=String(ct.attrs.revisionId),$n=`tc-${Ht}-`,Vo=Dt.find(Uo=>Uo.id.startsWith($n));if(!Vo&&Vn){let Uo=Vn.get(Ht);Uo&&(Vo=Dt.find(Hd=>Hd.id===Uo));}if(Vo){Fe=Vo.id;break}}}Fe&&fe(true),et(Fe);},[_o,yt,Dt,Vn]);Bl.useEffect(()=>{we.current||Dt.length!==0&&(we.current=true,fe(true));},[Dt]);let Md=Bl.useMemo(()=>{if(!Se?.startsWith("comment-"))return yt;let T=parseInt(Se.slice(8),10);if(isNaN(T)||!yt.has(T))return yt;let L=new Set(yt);return L.delete(T),L},[yt,Se]),Dd={flex:1,minHeight:0,minWidth:0,overflow:"auto",position:"relative",overflowAnchor:"none"};return Q.isLoading?jsxRuntime.jsx("div",{className:chunkGDJM7SOG_js.a("ep-root docx-editor docx-editor-loading",Oe&&"dark",v),style:Wo,"data-testid":"docx-editor",children:P||jsxRuntime.jsx(Ml,{})}):Q.parseError?jsxRuntime.jsx("div",{className:chunkGDJM7SOG_js.a("ep-root docx-editor docx-editor-error",Oe&&"dark",v),style:Wo,"data-testid":"docx-editor",children:jsxRuntime.jsx(Hl,{message:Q.parseError})}):pe.state?jsxRuntime.jsx(Cl,{i18n:oe,isDark:Oe,onEditorError:cd,containerRef:Ao,scrollContainerRef:Gt,editorContentRef:Oo,className:v,containerStyle:Wo,mainContentStyle:Td,editorContainerStyle:Dd,showRuler:p,readOnlyProp:y,showOutline:zr,showOutlineButton:E,sidebarOpen:Un,minLayoutWidth:Ed,toolbarHeight:Wr,editorScrollLeft:Vr,expandedSidebarItem:Se,trackedChanges:It,onScrollContainerMouseDown:T=>{let L=T.target;L.closest(".paged-editor__pages")||L.closest(".docx-unified-sidebar")||L.closest(".docx-comment-margin-markers")||et(null);},onEditorBgMouseDown:T=>{T.target===T.currentTarget&&(T.preventDefault(),ae.current?.focus());},onEditorContextMenu:Nc,horizontalRulerProps:{sectionProps:pe.state?.package.document?.finalSectionProperties,zoom:Q.zoom,unit:g,editable:!Ye,onLeftMarginChange:Yc,onRightMarginChange:qc,indentLeft:Q.paragraphIndentLeft,indentRight:Q.paragraphIndentRight,onIndentLeftChange:Jc,onIndentRightChange:ed,firstLineIndent:Q.paragraphFirstLineIndent,hangingIndent:Q.paragraphHangingIndent,onFirstLineIndentChange:td,tabStops:Q.paragraphTabs,onTabStopRemove:od},verticalRulerProps:{sectionProps:Wn,zoom:Q.zoom,unit:g,editable:!Ye,onTopMarginChange:Xc,onBottomMarginChange:Zc},outlineProps:{headings:zl,onHeadingClick:tc,onClose:()=>_r(false),topOffset:Wr,scrollLeft:Vr},onToggleOutline:ec,scrollPageInfo:Zr,agentPanel:le,agentPanelOpen:Ut,onAgentPanelClose:()=>G(false),toolbar:h&&!y?jsxRuntime.jsx(ma,{toolbarRefCallback:_l,agentPanelOpen:Ut,setAgentPanelOpen:G,document:pe.state,theme:a,pmState:ro,selectionFormatting:Q.selectionFormatting,tableContext:Q.pmTableContext,imageContext:Q.pmImageContext,readOnly:Ye,editingMode:kt,setEditingMode:An,setShowCommentsSidebar:fe,setExpandedSidebarItem:et,showCommentsSidebar:ce,agentPanel:le,renderLogo:ee,documentName:$,onDocumentNameChange:de,documentNameEditable:re,renderTitleBarRight:X,toolbarExtra:S,fontFamilies:I,zoom:Q.zoom,showZoomControl:f,onFormat:Cc,onUndo:Wl,onRedo:Vl,onPrint:Yr,onOpen:ql,onSave:Yl,onZoomChange:wc,onRefocusEditor:Mt,onInsertTable:Sc,onInsertImage:Zl,onInsertPageBreak:xc,onInsertSectionBreakNextPage:Rc,onInsertSectionBreakContinuous:Pc,onInsertTOC:Tc,onImageWrapType:lc,onImageTransform:cc,onOpenImageProperties:Xr,onPageSetup:jc,onWatermark:id,onTableAction:hc}):null,pagedArea:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Zs,{pagedEditorRef:ae,hfEditorRef:lo,scrollContainerRef:Gt,editorContentRef:Oo,document:pe.state,theme:a,initialSectionProperties:Wn,finalSectionProperties:Qr,headerContent:bd,footerContent:hd,firstPageHeaderContent:yd,firstPageFooterContent:vd,hfEditPosition:De,setHfEditPosition:He,hfEditIsFirstPage:q,onHeaderFooterDoubleClick:Cd,onHeaderFooterSave:Sd,onRemoveHeaderFooter:Rd,onBodyClick:xd,getHfTargetElement:Pd,zoom:Q.zoom,readOnly:Ye,extensionManager:tt,externalPlugins:so,onDocumentChange:_n,onSelectionChange:_o,onPagedSelectionChange:kd,onReady:T=>{let L=T.getView();L&&io(L.state);},onEditorViewReady:N,onRenderedDomContextReady:A,pluginOverlays:z,onHyperlinkClick:Mc,hyperlinkPopupData:Ec,onHyperlinkPopupNavigate:Dc,onHyperlinkPopupCopy:Hc,onHyperlinkPopupEdit:Fc,onHyperlinkPopupRemove:Lc,onHyperlinkPopupClose:Ac,onContextMenu:zc,sidebarOpen:Un,sidebarItems:Jr,anchorPositions:Hn,onAnchorPositionsChange:Lo,pluginRenderedDomContext:se,pageWidthPx:Id,expandedSidebarItem:Se,setExpandedSidebarItem:et,comments:ze,resolvedCommentIds:yt,resolvedIdsForRender:Md,setShowCommentsSidebar:fe,onTotalPagesChange:T=>{ld(L=>L.totalPages===T?L:{...L,totalPages:T});},floatingCommentBtn:Mn,isAddingComment:_e,setCommentSelectionRange:Tt,setAddCommentYPosition:wt,setIsAddingComment:Pt,setFloatingCommentBtn:ht}),!Ye&&jsxRuntime.jsx(el,{containerRef:Ao,getView:()=>ae.current?.getView()??null})]}),overlays:jsxRuntime.jsx(aa,{contextMenu:Oc,contextMenuItems:Uc,onContextMenuAction:$c,onContextMenuClose:_c,imageContextMenu:Bc,onImageWrapApply:Wc,imageContextMenuTextActions:Vc,onOpenImageProperties:Xr,readOnly:Ye}),dialogs:jsxRuntime.jsx(sa,{findReplace:uo,findResultRef:dd,onFind:ud,onFindNext:pd,onFindPrevious:md,onReplace:fd,onReplaceAll:gd,hyperlinkDialog:No,onHyperlinkSubmit:Ic,onHyperlinkRemove:kc,tablePropsOpen:mc,onTablePropsClose:()=>fc(false),pmTableContext:Q.pmTableContext,getActiveEditorView:lt,splitCellDialogState:gc,onSplitCellDialogClose:yc,onSplitCellDialogApply:vc,imagePositionOpen:oc,onImagePositionClose:()=>nc(false),onApplyImagePosition:dc,imagePropsOpen:rc,onImagePropsClose:()=>ic(false),onApplyImageProperties:uc,pmImageContext:Q.pmImageContext,showPageSetup:Gc,onPageSetupClose:()=>Kc(false),onPageSetupApply:Qc,showWatermark:nd,onWatermarkClose:()=>rd(false),onWatermarkApply:sd,currentWatermark:ad,watermarkPresets:D,document:pe.state,footnotePropsOpen:ac,onFootnotePropsClose:()=>sc(false),onApplyFootnoteProperties:pc}),fileInputs:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("input",{ref:Gl,type:"file",accept:"image/*",style:{display:"none"},onChange:Ql}),jsxRuntime.jsx("input",{ref:Kl,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:Xl})]})}):jsxRuntime.jsx("div",{className:chunkGDJM7SOG_js.a("ep-root docx-editor docx-editor-empty",Oe&&"dark",v),style:Wo,"data-testid":"docx-editor",children:R||jsxRuntime.jsx(Dl,{})})});function zh(e,t,o={}){return new Promise((r,n)=>{let u=Bl__default.default.createRef(),d=null;try{d=client.createRoot(t);}catch(a){n(a);return}let l={save:async()=>{let a=await(u.current?.save()??Promise.resolve(null));return a?new Blob([a],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}):null},getDocument:()=>u.current?.getDocument()??null,focus:()=>u.current?.focus(),setZoom:a=>u.current?.setZoom(a),scrollToParaId:a=>u.current?.scrollToParaId(a)??false,scrollToPosition:a=>u.current?.scrollToPosition(a),destroy:()=>{d?.unmount(),d=null;}},m=false,s=Bl__default.default.createElement(Br,{...o,documentBuffer:e,onError:a=>{o.onError?.(a),m||(m=true,n(a));},onChange:a=>{o.onChange?.(a),m||(m=true,r(l));},ref:u});d.render(s);})}var Vw="0.0.2";Object.defineProperty(exports,"LocaleProvider",{enumerable:true,get:function(){return chunkGNIO6SOS_js.a}});Object.defineProperty(exports,"useTranslation",{enumerable:true,get:function(){return chunkGNIO6SOS_js.b}});Object.defineProperty(exports,"createDocumentWithText",{enumerable:true,get:function(){return docxEditorCore.createDocumentWithText}});Object.defineProperty(exports,"createEmptyDocument",{enumerable:true,get:function(){return docxEditorCore.createEmptyDocument}});exports.DocxEditor=Br;exports.VERSION=Vw;exports.renderAsync=zh;
32
+ `}),jsxRuntime.jsx("div",{style:{fontSize:"14px"},children:e("errors.loadingDocument")})]})}function Fl(){let{t:e}=chunkGNIO6SOS_js.b();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--doc-text-placeholder)"},children:[jsxRuntime.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsxRuntime.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsxRuntime.jsx("polyline",{points:"14 2 14 8 20 8"})]}),jsxRuntime.jsx("div",{style:{marginTop:"16px"},children:e("errors.noDocumentLoaded")})]})}function Ll({message:e}){let{t}=chunkGNIO6SOS_js.b();return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"20px",textAlign:"center"},children:[jsxRuntime.jsx("div",{style:{color:"var(--doc-error)",marginBottom:"16px"},children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M12 8v4M12 16v.01"})]})}),jsxRuntime.jsx("h3",{style:{color:"var(--doc-error)",marginBottom:"8px"},children:t("errors.failedToLoad")}),jsxRuntime.jsx("p",{style:{color:"var(--doc-text-muted)",maxWidth:"400px"},children:e})]})}function Al(e,t,o){zl.useEffect(()=>{utils.loadFontDefinitions(e);},[e]),zl.useEffect(()=>utils.onFontsLoaded(()=>t?.()),[t]);let r=zl.useRef(o);zl.useEffect(()=>{r.current=o;},[o]),zl.useEffect(()=>utils.onFontError(n=>r.current?.(n)),[]);}var _r=zl.forwardRef(function({documentBuffer:t,document:o,onSave:r,author:n="User",onChange:u,onSelectionChange:d,onError:l,onFontsLoaded:m,colorMode:s="light",theme:a,showToolbar:b=true,showZoomControl:f=true,showMarginGuides:h=false,marginGuideColor:i,showRuler:p=false,rulerUnit:g="inch",initialZoom:x=1,readOnly:y=false,disableFindReplaceShortcuts:c=false,toolbarExtra:S,className:v="",style:C,placeholder:R,loadingIndicator:T,showOutline:k=false,showOutlineButton:E=true,fontFamilies:I,fonts:w,watermarkPresets:D,printOptions:H,onPrint:O,onCopy:B,onCut:_,onPaste:W,mode:Z,onModeChange:Y,onCommentAdd:J,onCommentResolve:te,onCommentDelete:ne,onCommentReply:me,comments:ke,onCommentsChange:Ce,externalPlugins:M,externalContent:F=false,onEditorViewReady:N,onRenderedDomContextReady:A,pluginOverlays:z,pluginSidebarItems:V,pluginRenderedDomContext:se,renderLogo:ee,documentName:$,onDocumentNameChange:de,documentNameEditable:re=true,renderTitleBarRight:X,i18n:oe,agentPanel:le},Re){let[Q,he]=zl.useState({isLoading:!!t&&!F,parseError:null,zoom:x,selectionFormatting:{},paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[Pe,Ae]=zl.useState(utils.prefersColorSchemeDark);zl.useEffect(()=>{if(s==="system")return utils.subscribeSystemDark(Ae)},[s]);let Oe=utils.resolveIsDark(s,Pe),[De,He]=zl.useState(null),[q,ue]=zl.useState(false),[ce,fe]=zl.useState(false),we=zl.useRef(false),[Se,et]=zl.useState(null),ae=zl.useRef(null),{comments:ze,setComments:Te,isAddingComment:_e,setIsAddingComment:Pt,isAddingCommentRef:Ao,commentSelectionRange:Vt,setCommentSelectionRange:Tt,addCommentYPosition:Hn,setAddCommentYPosition:wt,floatingCommentBtn:Fn,setFloatingCommentBtn:ht,cleanOrphanedCommentsTimerRef:Ut,cleanOrphanedComments:Et}=ea({commentsProp:ke,onCommentDelete:ne,onCommentsChange:Ce,pagedEditorRef:ae}),[io,ao]=zl.useState(null),{entries:It,commentToRevision:Ln}=chunkLNONBJQM_js.d(io),[An,Oo]=zl.useState(Zo),[On,Bn]=zl.useState(Z??"editing"),kt=Z??On,Nn=P=>{Z||Bn(P),Y?.(P);},Ye=y||kt==="viewing",[zn,_n]=zl.useState(false),so=le?.open!==void 0,$t=le?so?!!le.open:zn:false,G=zl.useCallback(P=>{le?.onOpenChange?.(P),so||_n(P);},[le,so]),ye=zl.useRef(new Set),ge=zl.useRef(new Set),pe=chunkLNONBJQM_js.i(o||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),tt=zl.useMemo(()=>{let P=new extensions.ExtensionManager(extensions.createStarterKit());return P.buildSchema(),P.initializeRuntime(),P},[]),Gt=zl.useMemo(()=>plugins.createSuggestionModePlugin(kt==="suggesting",n),[]),lo=zl.useMemo(()=>[Gt,...M??[]],[Gt,M]),co=zl.useRef(null),Wn=zl.useRef(null),Bo=zl.useRef(null),Wr=zl.useRef(null),No=zl.useRef(null),Kt=zl.useRef(null),{showOutline:Vn,setShowOutline:Vr,showOutlineRef:_l,outlineHeadings:Wl,setHeadingInfos:Un,toolbarHeight:Ur,toolbarRefCallback:Vl,editorScrollLeft:$r}=hi({showOutlineProp:k,pagedEditorRef:ae,scrollContainerRef:Kt,isLoading:Q.isLoading}),uo=zl.useRef(pe.state);uo.current=pe.state;let Gr=zl.useRef({style:"single",size:4,color:{rgb:"000000"}}),Kr=zl.useRef(null),zo=zl.useCallback(P=>{let L=Kr.current;if(L&&L.styles===P)return L.resolver;let K=prosemirror.createStyleResolver(P);return Kr.current={styles:P,resolver:K},K},[]),{getActiveEditorView:lt,focusActiveEditor:Mt,undoActiveEditor:Ul,redoActiveEditor:$l}=sa({hfEditPosition:De,hfEditorRef:co,pagedEditorRef:ae}),po=chunkL4MDZW2J_js.b(),_o=chunkQD7BVJV3_js.m(),jr=zl.useRef(false),Yr=zl.useRef(false),mo=zl.useRef(commentIdAllocator.createCommentIdAllocator()),{resetForNewDocument:Gl}=rl({commentsLoadedRef:jr,trackedChangesLoadedRef:Yr,setComments:Te,setHeadingInfos:Un,setShowCommentsSidebar:fe,setIsAddingComment:Pt,setCommentSelectionRange:Tt,setAddCommentYPosition:wt,setFloatingCommentBtn:ht,setHfEditPosition:He,setHfEditIsFirstPage:ue,setAnchorPositions:Oo,clearFindReplaceMatches:zl.useCallback(()=>po.setMatches([],0),[po]),cleanOrphanedCommentsTimerRef:Ut}),{loadParsedDocument:Kl,loadBuffer:qr}=Vi({documentBuffer:t,initialDocument:o,externalContent:F,history:pe,agentRef:Wn,pagedEditorRef:ae,setLoadingState:zl.useCallback(P=>{he(L=>({...L,isLoading:P.isLoading,parseError:P.parseError}));},[]),setComments:Te,setShowCommentsSidebar:fe,onError:l,resetForNewDocument:Gl,commentsLoadedRef:jr,commentIdAllocator:mo.current}),{imageInputRef:jl,docxInputRef:Yl,handleSave:ql,handleDirectPrint:Xr,handleDownloadDocument:Xl,handleOpenDocument:Zl,handleDocxFileChange:Ql,handleInsertImageClick:Jl,handleImageFileChange:ec}=Ci({agentRef:Wn,pagedEditorRef:ae,containerRef:Bo,comments:ze,documentName:$,onSave:r,onError:l,onPrint:O,onDocumentNameChange:de,loadBuffer:qr,getActiveEditorView:lt,focusActiveEditor:Mt});zl.useEffect(()=>{if(Q.isLoading||!pe.state)return;let P=ae.current?.getView();P&&ao(P.state);},[Q.isLoading,pe.state]),oa({commentToRevision:Ln,setComments:Te,pmState:io,isLoading:Q.isLoading,trackedChangesCount:It.length,setShowCommentsSidebar:fe,trackedChangesLoadedRef:Yr}),Al(w,m,l),zl.useEffect(()=>{let P=ae.current?.getView();P&&plugins.setSuggestionMode(kt==="suggesting",P.state,P.dispatch,n);},[kt,n]);let Wo=zl.useCallback(P=>(pe.push(P),P),[pe]),$n=zl.useCallback(P=>{Wo(P),u?.(P);for(let K of ye.current)try{K(P);}catch(xe){console.error("contentChange subscriber threw:",xe);}if(_l.current){let K=ae.current?.getView();K&&Un(utils.collectHeadings(K.state.doc));}let L=ae.current?.getView();L&&ao(L.state),Ut.current&&clearTimeout(Ut.current),Ut.current=setTimeout(Et,300);},[u,Wo,Et]),{recomputeFloatingCommentBtn:tc}=aa({pagedEditorRef:ae,scrollContainerRef:Kt,editorContentRef:No,isAddingCommentRef:Ao,setFloatingCommentBtn:ht,readOnly:Ye,isLoading:Q.isLoading,zoom:Q.zoom}),{handleSelectionChange:Vo}=ra({getActiveEditorView:lt,lastSelectionRef:Wr,borderSpecRef:Gr,theme:a,historyStateRef:uo,getCachedStyleResolver:zo,setFloatingCommentBtn:ht,applySelectionDelta:zl.useCallback(P=>he(L=>({...L,...P})),[]),recomputeFloatingCommentBtn:tc,onSelectionChange:d,selectionChangeSubscribersRef:ge}),Zr=chunkLNONBJQM_js.e({document:pe.state,onChange:$n,onSelectionChange:P=>{}});yi({pagedEditorRef:ae,disableFindReplaceShortcuts:c,findReplace:po,hyperlinkDialog:_o,tableSelection:Zr});let oc=zl.useCallback(()=>{Vr(P=>{if(!P){let L=ae.current?.getView();L&&Un(utils.collectHeadings(L.state.doc));}return !P});},[]),nc=zl.useCallback(P=>{ae.current?.scrollToPosition(P),ae.current?.setSelection(P+1),ae.current?.focus();},[]),{imagePositionOpen:rc,setImagePositionOpen:ic,imagePropsOpen:ac,setImagePropsOpen:sc,footnotePropsOpen:lc,setFootnotePropsOpen:cc,handleImageWrapType:dc,handleImageTransform:uc,handleApplyImagePosition:pc,handleOpenImageProperties:Qr,handleApplyImageProperties:mc,handleApplyFootnoteProperties:fc}=Li({document:pe.state,pmImageContext:Q.pmImageContext,zoom:Q.zoom,getActiveEditorView:lt,focusActiveEditor:Mt,pushDocument:Wo}),{tablePropsOpen:gc,setTablePropsOpen:bc,splitCellDialogState:hc,openSplitCellDialog:yc,handleTableAction:vc,handleSplitCellDialogClose:Cc,handleSplitCellDialogApply:Sc}=zi({getActiveEditorView:lt,focusActiveEditor:Mt,tableSelection:Zr,borderSpecRef:Gr,historyStateRef:uo,getCachedStyleResolver:zo}),{handleFormat:xc,handleInsertTable:Rc,handleInsertPageBreak:Pc,handleInsertSectionBreakNextPage:Tc,handleInsertSectionBreakContinuous:wc,handleInsertTOC:Ec}=Fi({getActiveEditorView:lt,focusActiveEditor:Mt,pagedEditorRef:ae,lastSelectionRef:Wr,hyperlinkDialog:_o,historyStateRef:uo,getCachedStyleResolver:zo}),Ic=zl.useCallback(P=>{he(L=>({...L,zoom:P}));},[]),{hyperlinkPopupData:kc,handleHyperlinkSubmit:Mc,handleHyperlinkRemove:Dc,handleHyperlinkClick:Hc,handleHyperlinkPopupNavigate:Fc,handleHyperlinkPopupCopy:Lc,handleHyperlinkPopupEdit:Ac,handleHyperlinkPopupRemove:Oc,handleHyperlinkPopupClose:Bc}=Ei({hyperlinkDialog:_o,getActiveEditorView:lt,focusActiveEditor:Mt}),{contextMenu:Nc,imageContextMenu:zc,handleEditorContextMenu:_c,handleContextMenu:Wc,handleContextMenuClose:Vc,handleImageWrapApply:Uc,imageContextMenuTextActions:$c,contextMenuItems:Gc,handleContextMenuAction:Kc}=Qi({getActiveEditorView:lt,focusActiveEditor:Mt,openSplitCellDialog:yc,scrollContainerRef:Kt,editorContentRef:No,i18n:oe,onAddComment:zl.useCallback(({from:P,to:L,yPos:K})=>{Tt({from:P,to:L}),wt(K),fe(true),Pt(true),ht(null);},[])}),{showPageSetup:jc,setShowPageSetup:Yc,handleOpenPageSetup:qc,handleLeftMarginChange:Xc,handleRightMarginChange:Zc,handleTopMarginChange:Qc,handleBottomMarginChange:Jc,handlePageSetupApply:ed,handleIndentLeftChange:td,handleIndentRightChange:od,handleFirstLineIndentChange:nd,handleTabStopRemove:rd}=xi({document:pe.state,readOnly:Ye,handleDocumentChange:$n,getActiveEditorView:lt}),{showWatermark:id,setShowWatermark:ad,handleOpenWatermark:sd,currentWatermark:ld,handleWatermarkApply:cd}=Pi({readOnly:Ye,getBodyEditorView:()=>ae.current?.getView()}),{scrollPageInfo:Jr,setScrollPageInfo:dd}=la({scrollContainerRef:Kt,pagedEditorRef:ae}),ud=zl.useCallback(P=>{l?.(P);},[l]),{findResultRef:pd,handleFind:md,handleFindNext:fd,handleFindPrevious:gd,handleReplace:bd,handleReplaceAll:hd}=Mi({pagedEditorRef:ae,findReplace:po});Oi({ref:Re,agentRef:Wn,document:pe.state,historyStateRef:uo,pagedEditorRef:ae,handleSave:ql,handleDirectPrint:Xr,zoom:Q.zoom,setZoom:P=>he(L=>({...L,zoom:P})),scrollPageInfo:Jr,loadParsedDocument:Kl,loadBuffer:qr,comments:ze,setComments:Te,setShowCommentsSidebar:fe,contentChangeSubscribersRef:ye,selectionChangeSubscribersRef:ge,getCachedStyleResolver:zo,commentIdAllocator:mo.current});let Gn=zl.useMemo(()=>ji(pe.state),[pe.state]),ei=pe.state?.package.document?.finalSectionProperties,{headerContent:yd,footerContent:vd,firstPageHeaderContent:Cd,firstPageFooterContent:Sd,handleHeaderFooterDoubleClick:xd,handleHeaderFooterSave:Rd,handleBodyClick:Pd,handleRemoveHeaderFooter:Td,getHfTargetElement:wd}=_i({document:pe.state,pushDocument:Wo,hfEditorRef:co,containerRef:Bo,initialSectionProperties:Gn,finalSectionProperties:ei,hfEditPosition:De,setHfEditPosition:He,hfEditIsFirstPage:q,setHfEditIsFirstPage:ue}),Uo={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)",...C},Ed={display:"flex",flex:1,minHeight:0,minWidth:0,flexDirection:"row"},Ge=zl.useRef({});Ge.current={onCommentReply:(P,L)=>{let K=commentOps.createComment(mo.current,L,n,P),xe=ze.find(Fe=>Fe.id===P);Te(Fe=>[...Fe,K]),xe&&me?.(K,xe);},onCommentResolve:P=>{let L=ze.find(K=>K.id===P);Te(K=>K.map(xe=>xe.id===P?{...xe,done:true}:xe)),Se===`comment-${P}`&&et(null),L&&te?.({...L,done:true});},onCommentUnresolve:P=>{Te(L=>L.map(K=>K.id===P?{...K,done:void 0}:K));},onCommentDelete:P=>{let L=ze.find(xe=>xe.id===P);Te(xe=>xe.filter(Fe=>Fe.id!==P&&Fe.parentId!==P));let K=ae.current?.getView();if(K){let xe=K.state.schema.marks.comment?.create({commentId:P});if(xe){let Fe=K.state.tr.removeMark(0,K.state.doc.content.size,xe);Fe.docChanged&&K.dispatch(Fe);}}L&&ne?.(L);},onAddComment:P=>{let L=commentOps.createComment(mo.current,P,n),K=ae.current?.getView();if(K&&Vt){let{from:xe,to:Fe}=Vt,ct=K.state.schema.marks.comment.create({commentId:commentIdAllocator.PENDING_COMMENT_ID}),Ht=K.state.schema.marks.comment.create({commentId:L.id}),qn=K.state.tr.removeMark(xe,Fe,ct).addMark(xe,Fe,Ht);K.dispatch(qn);}Te(xe=>[...xe,L]),Pt(false),Tt(null),wt(null),J?.(L);},onCancelAddComment:()=>{let P=ae.current?.getView();if(P&&Vt){let{from:L,to:K}=Vt,xe=P.state.schema.marks.comment.create({commentId:commentIdAllocator.PENDING_COMMENT_ID});P.dispatch(P.state.tr.removeMark(L,K,xe));}Pt(false),Tt(null),wt(null);},onAcceptChange:(P,L)=>{let K=ae.current?.getView();K&&commands.acceptChange(P,L)(K.state,K.dispatch);},onRejectChange:(P,L)=>{let K=ae.current?.getView();K&&commands.rejectChange(P,L)(K.state,K.dispatch);},onAcceptChangeById:P=>{let L=ae.current?.getView();L&&commands.acceptChangeById(P)(L.state,L.dispatch);},onRejectChangeById:P=>{let L=ae.current?.getView();L&&commands.rejectChangeById(P)(L.state,L.dispatch);},onTrackedChangeReply:(P,L)=>{Te(K=>[...K,commentOps.createComment(mo.current,L,n,P)]);}};let Id=zl.useMemo(()=>({onCommentReply:(...P)=>Ge.current.onCommentReply?.(...P),onCommentResolve:(...P)=>Ge.current.onCommentResolve?.(...P),onCommentUnresolve:(...P)=>Ge.current.onCommentUnresolve?.(...P),onCommentDelete:(...P)=>Ge.current.onCommentDelete?.(...P),onAddComment:(...P)=>Ge.current.onAddComment?.(...P),onCancelAddComment:(...P)=>Ge.current.onCancelAddComment?.(...P),onAcceptChange:(...P)=>Ge.current.onAcceptChange?.(...P),onRejectChange:(...P)=>Ge.current.onRejectChange?.(...P),onAcceptChangeById:(...P)=>Ge.current.onAcceptChangeById?.(...P),onRejectChangeById:(...P)=>Ge.current.onRejectChangeById?.(...P),onTrackedChangeReply:(...P)=>Ge.current.onTrackedChangeReply?.(...P)}),[]),Dt=Dl({comments:ze,trackedChanges:It,callbacks:Id,showResolved:ce,isAddingComment:ce?_e:false,addCommentYPosition:Hn}),ti=zl.useMemo(()=>{let P=[];return ce&&P.push(...Dt),V&&P.push(...V),P},[ce,Dt,V]),Kn=zl.useMemo(()=>{let P=new Map;return It.forEach((L,K)=>{L.type==="replacement"&&L.insertionRevisionId!=null&&P.set(String(L.insertionRevisionId),`tc-${L.revisionId}-${K}`);}),P},[It]),jn=ti.length>0,kd=(Vn?gl:E?bl:20)+(p&&(Vn||E)?zt:0),Yn=pe.state?.package?.document,oi=[Yn?.finalSectionProperties?.pageWidth,...Yn?.sections?.map(P=>P.properties?.pageWidth)??[]].filter(P=>typeof P=="number"&&P>0),Md=oi.length?Math.round(Math.max(...oi)/15):816,Dd=2*kd+Md+(jn?sidebarConstants.SIDEBAR_DOCUMENT_SHIFT*2:0),ni=Yn?.finalSectionProperties?.pageWidth,Hd=ni?Math.round(ni/15):816,yt=zl.useMemo(()=>{let P=new Set;for(let L of ze)L.done&&L.parentId==null&&P.add(L.id);return P},[ze]),Fd=zl.useCallback(()=>{let P=ae.current?.getView();if(!P){Vo(null);return}let L=prosemirror.extractSelectionState(P.state);Vo(L);let K=P.state.selection.$from,xe=[...P.state.storedMarks??[],...K.nodeAfter?.marks??[],...K.nodeBefore?.marks??[],...K.marks()],Fe=null;for(let ct of xe){if(ct.type.name==="comment"&&ct.attrs.commentId!=null){let Ht=ct.attrs.commentId;if(yt.has(Ht))continue;Fe=`comment-${Ht}`;break}if((ct.type.name==="insertion"||ct.type.name==="deletion")&&ct.attrs.revisionId!=null){let Ht=String(ct.attrs.revisionId),qn=`tc-${Ht}-`,$o=Dt.find(Go=>Go.id.startsWith(qn));if(!$o&&Kn){let Go=Kn.get(Ht);Go&&($o=Dt.find(Od=>Od.id===Go));}if($o){Fe=$o.id;break}}}Fe&&fe(true),et(Fe);},[Vo,yt,Dt,Kn]);zl.useEffect(()=>{we.current||Dt.length!==0&&(we.current=true,fe(true));},[Dt]);let Ld=zl.useMemo(()=>{if(!Se?.startsWith("comment-"))return yt;let P=parseInt(Se.slice(8),10);if(isNaN(P)||!yt.has(P))return yt;let L=new Set(yt);return L.delete(P),L},[yt,Se]),Ad={flex:1,minHeight:0,minWidth:0,overflow:"auto",position:"relative",overflowAnchor:"none"};return Q.isLoading?jsxRuntime.jsx("div",{className:chunkGDJM7SOG_js.a("ep-root docx-editor docx-editor-loading",Oe&&"dark",v),style:Uo,"data-testid":"docx-editor",children:T||jsxRuntime.jsx(Hl,{})}):Q.parseError?jsxRuntime.jsx("div",{className:chunkGDJM7SOG_js.a("ep-root docx-editor docx-editor-error",Oe&&"dark",v),style:Uo,"data-testid":"docx-editor",children:jsxRuntime.jsx(Ll,{message:Q.parseError})}):pe.state?jsxRuntime.jsx(xl,{i18n:oe,isDark:Oe,onEditorError:ud,containerRef:Bo,scrollContainerRef:Kt,editorContentRef:No,className:v,containerStyle:Uo,mainContentStyle:Ed,editorContainerStyle:Ad,showRuler:p,readOnlyProp:y,showOutline:Vn,showOutlineButton:E,sidebarOpen:jn,minLayoutWidth:Dd,toolbarHeight:Ur,editorScrollLeft:$r,expandedSidebarItem:Se,trackedChanges:It,onScrollContainerMouseDown:P=>{let L=P.target;L.closest(".paged-editor__pages")||L.closest(".docx-unified-sidebar")||L.closest(".docx-comment-margin-markers")||et(null);},onEditorBgMouseDown:P=>{P.target===P.currentTarget&&(P.preventDefault(),ae.current?.focus());},onEditorContextMenu:_c,horizontalRulerProps:{sectionProps:pe.state?.package.document?.finalSectionProperties,zoom:Q.zoom,unit:g,editable:!Ye,onLeftMarginChange:Xc,onRightMarginChange:Zc,indentLeft:Q.paragraphIndentLeft,indentRight:Q.paragraphIndentRight,onIndentLeftChange:td,onIndentRightChange:od,firstLineIndent:Q.paragraphFirstLineIndent,hangingIndent:Q.paragraphHangingIndent,onFirstLineIndentChange:nd,tabStops:Q.paragraphTabs,onTabStopRemove:rd},verticalRulerProps:{sectionProps:Gn,zoom:Q.zoom,unit:g,editable:!Ye,onTopMarginChange:Qc,onBottomMarginChange:Jc},outlineProps:{headings:Wl,onHeadingClick:nc,onClose:()=>Vr(false),topOffset:Ur,scrollLeft:$r},onToggleOutline:oc,scrollPageInfo:Jr,agentPanel:le,agentPanelOpen:$t,onAgentPanelClose:()=>G(false),toolbar:b&&!y?jsxRuntime.jsx(ba,{toolbarRefCallback:Vl,agentPanelOpen:$t,setAgentPanelOpen:G,document:pe.state,theme:a,pmState:io,selectionFormatting:Q.selectionFormatting,tableContext:Q.pmTableContext,imageContext:Q.pmImageContext,readOnly:Ye,editingMode:kt,setEditingMode:Nn,setShowCommentsSidebar:fe,setExpandedSidebarItem:et,showCommentsSidebar:ce,agentPanel:le,renderLogo:ee,documentName:$,onDocumentNameChange:de,documentNameEditable:re,renderTitleBarRight:X,toolbarExtra:S,fontFamilies:I,zoom:Q.zoom,showZoomControl:f,onFormat:xc,onUndo:Ul,onRedo:$l,onPrint:Xr,onOpen:Zl,onSave:Xl,onZoomChange:Ic,onRefocusEditor:Mt,onInsertTable:Rc,onInsertImage:Jl,onInsertPageBreak:Pc,onInsertSectionBreakNextPage:Tc,onInsertSectionBreakContinuous:wc,onInsertTOC:Ec,onImageWrapType:dc,onImageTransform:uc,onOpenImageProperties:Qr,onPageSetup:qc,onWatermark:sd,onTableAction:vc}):null,pagedArea:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(el,{pagedEditorRef:ae,hfEditorRef:co,scrollContainerRef:Kt,editorContentRef:No,document:pe.state,theme:a,initialSectionProperties:Gn,finalSectionProperties:ei,headerContent:yd,footerContent:vd,firstPageHeaderContent:Cd,firstPageFooterContent:Sd,hfEditPosition:De,setHfEditPosition:He,hfEditIsFirstPage:q,onHeaderFooterDoubleClick:xd,onHeaderFooterSave:Rd,onRemoveHeaderFooter:Td,onBodyClick:Pd,getHfTargetElement:wd,zoom:Q.zoom,readOnly:Ye,extensionManager:tt,externalPlugins:lo,onDocumentChange:$n,onSelectionChange:Vo,onPagedSelectionChange:Fd,onReady:P=>{let L=P.getView();L&&ao(L.state);},onEditorViewReady:N,onRenderedDomContextReady:A,pluginOverlays:z,onHyperlinkClick:Hc,hyperlinkPopupData:kc,onHyperlinkPopupNavigate:Fc,onHyperlinkPopupCopy:Lc,onHyperlinkPopupEdit:Ac,onHyperlinkPopupRemove:Oc,onHyperlinkPopupClose:Bc,onContextMenu:Wc,sidebarOpen:jn,sidebarItems:ti,anchorPositions:An,onAnchorPositionsChange:Oo,pluginRenderedDomContext:se,pageWidthPx:Hd,expandedSidebarItem:Se,setExpandedSidebarItem:et,comments:ze,resolvedCommentIds:yt,resolvedIdsForRender:Ld,setShowCommentsSidebar:fe,onTotalPagesChange:P=>{dd(L=>L.totalPages===P?L:{...L,totalPages:P});},floatingCommentBtn:Fn,isAddingComment:_e,setCommentSelectionRange:Tt,setAddCommentYPosition:wt,setIsAddingComment:Pt,setFloatingCommentBtn:ht}),!Ye&&jsxRuntime.jsx(nl,{containerRef:Bo,getView:()=>ae.current?.getView()??null})]}),overlays:jsxRuntime.jsx(ca,{contextMenu:Nc,contextMenuItems:Gc,onContextMenuAction:Kc,onContextMenuClose:Vc,imageContextMenu:zc,onImageWrapApply:Uc,imageContextMenuTextActions:$c,onOpenImageProperties:Qr,readOnly:Ye}),dialogs:jsxRuntime.jsx(da,{findReplace:po,findResultRef:pd,onFind:md,onFindNext:fd,onFindPrevious:gd,onReplace:bd,onReplaceAll:hd,hyperlinkDialog:_o,onHyperlinkSubmit:Mc,onHyperlinkRemove:Dc,tablePropsOpen:gc,onTablePropsClose:()=>bc(false),pmTableContext:Q.pmTableContext,getActiveEditorView:lt,splitCellDialogState:hc,onSplitCellDialogClose:Cc,onSplitCellDialogApply:Sc,imagePositionOpen:rc,onImagePositionClose:()=>ic(false),onApplyImagePosition:pc,imagePropsOpen:ac,onImagePropsClose:()=>sc(false),onApplyImageProperties:mc,pmImageContext:Q.pmImageContext,showPageSetup:jc,onPageSetupClose:()=>Yc(false),onPageSetupApply:ed,showWatermark:id,onWatermarkClose:()=>ad(false),onWatermarkApply:cd,currentWatermark:ld,watermarkPresets:D,document:pe.state,footnotePropsOpen:lc,onFootnotePropsClose:()=>cc(false),onApplyFootnoteProperties:fc}),fileInputs:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("input",{ref:jl,type:"file",accept:"image/*",style:{display:"none"},onChange:ec}),jsxRuntime.jsx("input",{ref:Yl,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:Ql})]})}):jsxRuntime.jsx("div",{className:chunkGDJM7SOG_js.a("ep-root docx-editor docx-editor-empty",Oe&&"dark",v),style:Uo,"data-testid":"docx-editor",children:R||jsxRuntime.jsx(Fl,{})})});function Uh(e,t,o={}){return new Promise((r,n)=>{let u=zl__default.default.createRef(),d=null;try{d=client.createRoot(t);}catch(a){n(a);return}let l={save:async()=>{let a=await(u.current?.save()??Promise.resolve(null));return a?new Blob([a],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}):null},getDocument:()=>u.current?.getDocument()??null,focus:()=>u.current?.focus(),setZoom:a=>u.current?.setZoom(a),scrollToParaId:a=>u.current?.scrollToParaId(a)??false,scrollToPosition:a=>u.current?.scrollToPosition(a),destroy:()=>{d?.unmount(),d=null;}},m=false,s=zl__default.default.createElement(_r,{...o,documentBuffer:e,onError:a=>{o.onError?.(a),m||(m=true,n(a));},onChange:a=>{o.onChange?.(a),m||(m=true,r(l));},ref:u});d.render(s);})}var Kw="0.0.2";Object.defineProperty(exports,"LocaleProvider",{enumerable:true,get:function(){return chunkGNIO6SOS_js.a}});Object.defineProperty(exports,"useTranslation",{enumerable:true,get:function(){return chunkGNIO6SOS_js.b}});Object.defineProperty(exports,"createDocumentWithText",{enumerable:true,get:function(){return docxEditorCore.createDocumentWithText}});Object.defineProperty(exports,"createEmptyDocument",{enumerable:true,get:function(){return docxEditorCore.createEmptyDocument}});exports.DocxEditor=_r;exports.VERSION=Kw;exports.renderAsync=Uh;